summaryrefslogtreecommitdiff
path: root/sw/source/core
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/core')
-rw-r--r--sw/source/core/access/accembedded.cxx4
-rw-r--r--sw/source/core/access/accpara.cxx2
-rw-r--r--sw/source/core/uibase/app/appenv.cxx508
-rw-r--r--sw/source/core/uibase/app/apphdl.cxx888
-rw-r--r--sw/source/core/uibase/app/applab.cxx403
-rw-r--r--sw/source/core/uibase/app/appopt.cxx560
-rw-r--r--sw/source/core/uibase/app/docsh.cxx1327
-rw-r--r--sw/source/core/uibase/app/docsh2.cxx1586
-rw-r--r--sw/source/core/uibase/app/docshdrw.cxx54
-rw-r--r--sw/source/core/uibase/app/docshini.cxx682
-rw-r--r--sw/source/core/uibase/app/docst.cxx1255
-rw-r--r--sw/source/core/uibase/app/docstyle.cxx2973
-rw-r--r--sw/source/core/uibase/app/mainwn.cxx141
-rw-r--r--sw/source/core/uibase/app/swdll.cxx164
-rw-r--r--sw/source/core/uibase/app/swdllimpl.hxx36
-rw-r--r--sw/source/core/uibase/app/swmodul1.cxx659
-rw-r--r--sw/source/core/uibase/app/swmodule.cxx427
-rw-r--r--sw/source/core/uibase/app/swwait.cxx84
-rw-r--r--sw/source/core/uibase/cctrl/actctrl.cxx134
-rw-r--r--sw/source/core/uibase/cctrl/popbox.cxx63
-rw-r--r--sw/source/core/uibase/cctrl/swlbox.cxx137
-rw-r--r--sw/source/core/uibase/chrdlg/ccoll.cxx187
-rw-r--r--sw/source/core/uibase/config/barcfg.cxx127
-rw-r--r--sw/source/core/uibase/config/caption.cxx76
-rw-r--r--sw/source/core/uibase/config/cfgitems.cxx358
-rw-r--r--sw/source/core/uibase/config/dbconfig.cxx120
-rw-r--r--sw/source/core/uibase/config/fontcfg.cxx320
-rw-r--r--sw/source/core/uibase/config/modcfg.cxx1398
-rw-r--r--sw/source/core/uibase/config/prtopt.cxx175
-rw-r--r--sw/source/core/uibase/config/uinums.cxx567
-rw-r--r--sw/source/core/uibase/config/usrpref.cxx592
-rw-r--r--sw/source/core/uibase/config/viewopt.cxx550
-rw-r--r--sw/source/core/uibase/dbui/dbmgr.cxx2960
-rw-r--r--sw/source/core/uibase/dbui/dbtree.cxx524
-rw-r--r--sw/source/core/uibase/dbui/dbui.cxx87
-rw-r--r--sw/source/core/uibase/dbui/maildispatcher.cxx275
-rw-r--r--sw/source/core/uibase/dbui/mailmergechildwindow.cxx666
-rw-r--r--sw/source/core/uibase/dbui/mailmergechildwindow.hrc47
-rw-r--r--sw/source/core/uibase/dbui/mailmergechildwindow.src210
-rw-r--r--sw/source/core/uibase/dbui/mailmergehelper.cxx906
-rw-r--r--sw/source/core/uibase/dbui/mmconfigitem.cxx1739
-rw-r--r--sw/source/core/uibase/dbui/swdbtoolsclient.cxx232
-rw-r--r--sw/source/core/uibase/dialog/SwSpellDialogChildWindow.cxx843
-rw-r--r--sw/source/core/uibase/dialog/regionsw.cxx242
-rw-r--r--sw/source/core/uibase/dialog/regionsw.hrc42
-rw-r--r--sw/source/core/uibase/dialog/regionsw.src119
-rw-r--r--sw/source/core/uibase/dialog/swabstdlg.cxx59
-rw-r--r--sw/source/core/uibase/dialog/swwrtshitem.cxx43
-rw-r--r--sw/source/core/uibase/dialog/wordcountwrapper.cxx49
-rw-r--r--sw/source/core/uibase/dochdl/gloshdl.cxx753
-rw-r--r--sw/source/core/uibase/dochdl/swdtflvr.cxx3783
-rw-r--r--sw/source/core/uibase/docvw/AnchorOverlayObject.cxx449
-rw-r--r--sw/source/core/uibase/docvw/AnchorOverlayObject.hxx133
-rw-r--r--sw/source/core/uibase/docvw/AnnotationMenuButton.cxx203
-rw-r--r--sw/source/core/uibase/docvw/AnnotationMenuButton.hxx53
-rw-r--r--sw/source/core/uibase/docvw/AnnotationWin.cxx318
-rw-r--r--sw/source/core/uibase/docvw/DashedLine.cxx97
-rw-r--r--sw/source/core/uibase/docvw/FrameControlsManager.cxx159
-rw-r--r--sw/source/core/uibase/docvw/HeaderFooterWin.cxx520
-rwxr-xr-xsw/source/core/uibase/docvw/OverlayRanges.cxx180
-rwxr-xr-xsw/source/core/uibase/docvw/OverlayRanges.hxx78
-rw-r--r--sw/source/core/uibase/docvw/PageBreakWin.cxx463
-rw-r--r--sw/source/core/uibase/docvw/PostItMgr.cxx1939
-rw-r--r--sw/source/core/uibase/docvw/ShadowOverlayObject.cxx252
-rw-r--r--sw/source/core/uibase/docvw/ShadowOverlayObject.hxx70
-rw-r--r--sw/source/core/uibase/docvw/SidebarTxtControl.cxx408
-rw-r--r--sw/source/core/uibase/docvw/SidebarTxtControl.hxx75
-rw-r--r--sw/source/core/uibase/docvw/SidebarTxtControlAcc.cxx293
-rw-r--r--sw/source/core/uibase/docvw/SidebarTxtControlAcc.hxx46
-rw-r--r--sw/source/core/uibase/docvw/SidebarWin.cxx1354
-rw-r--r--sw/source/core/uibase/docvw/SidebarWinAcc.cxx143
-rw-r--r--sw/source/core/uibase/docvw/SidebarWinAcc.hxx57
-rw-r--r--sw/source/core/uibase/docvw/annotation.hrc45
-rw-r--r--sw/source/core/uibase/docvw/docvw.hrc91
-rw-r--r--sw/source/core/uibase/docvw/docvw.src307
-rw-r--r--sw/source/core/uibase/docvw/edtdd.cxx495
-rw-r--r--sw/source/core/uibase/docvw/edtwin.cxx6157
-rw-r--r--sw/source/core/uibase/docvw/edtwin2.cxx526
-rw-r--r--sw/source/core/uibase/docvw/edtwin3.cxx193
-rw-r--r--sw/source/core/uibase/docvw/frmsidebarwincontainer.cxx204
-rw-r--r--sw/source/core/uibase/docvw/frmsidebarwincontainer.hxx63
-rw-r--r--sw/source/core/uibase/docvw/romenu.cxx368
-rw-r--r--sw/source/core/uibase/docvw/romenu.hxx64
-rw-r--r--sw/source/core/uibase/docvw/srcedtw.cxx993
-rw-r--r--sw/source/core/uibase/envelp/envimg.cxx355
-rw-r--r--sw/source/core/uibase/envelp/label.hrc42
-rw-r--r--sw/source/core/uibase/envelp/labelcfg.cxx358
-rw-r--r--sw/source/core/uibase/envelp/labimg.cxx473
-rw-r--r--sw/source/core/uibase/envelp/labimp.hxx114
-rw-r--r--sw/source/core/uibase/envelp/syncbtn.cxx82
-rw-r--r--sw/source/core/uibase/fldui/fldmgr.cxx1773
-rw-r--r--sw/source/core/uibase/fldui/fldwrap.cxx161
-rw-r--r--sw/source/core/uibase/fldui/xfldui.cxx168
-rw-r--r--sw/source/core/uibase/frmdlg/colex.cxx589
-rw-r--r--sw/source/core/uibase/frmdlg/colmgr.cxx150
-rw-r--r--sw/source/core/uibase/frmdlg/frmmgr.cxx608
-rw-r--r--sw/source/core/uibase/globdoc/globdoc.cxx73
-rw-r--r--sw/source/core/uibase/inc/DashedLine.hxx30
-rw-r--r--sw/source/core/uibase/inc/DropDownFieldDialog.hxx58
-rw-r--r--sw/source/core/uibase/inc/FrameControl.hxx53
-rw-r--r--sw/source/core/uibase/inc/FrameControlsManager.hxx56
-rw-r--r--sw/source/core/uibase/inc/HeaderFooterWin.hxx58
-rw-r--r--sw/source/core/uibase/inc/PageBreakWin.hxx63
-rw-r--r--sw/source/core/uibase/inc/SidebarWindowsConsts.hxx31
-rw-r--r--sw/source/core/uibase/inc/SwSpellDialogChildWindow.hxx67
-rw-r--r--sw/source/core/uibase/inc/SwXFilterOptions.hxx101
-rw-r--r--sw/source/core/uibase/inc/abstract.hxx42
-rw-r--r--sw/source/core/uibase/inc/actctrl.hxx92
-rw-r--r--sw/source/core/uibase/inc/addrdlg.hxx32
-rw-r--r--sw/source/core/uibase/inc/annotsh.hxx74
-rw-r--r--sw/source/core/uibase/inc/app.hrc118
-rw-r--r--sw/source/core/uibase/inc/ascfldlg.hxx62
-rw-r--r--sw/source/core/uibase/inc/autoedit.hxx37
-rw-r--r--sw/source/core/uibase/inc/barcfg.hxx41
-rw-r--r--sw/source/core/uibase/inc/basesh.hxx115
-rw-r--r--sw/source/core/uibase/inc/beziersh.hxx38
-rw-r--r--sw/source/core/uibase/inc/bmpwin.hxx56
-rw-r--r--sw/source/core/uibase/inc/bookctrl.hxx47
-rw-r--r--sw/source/core/uibase/inc/bookmark.hxx70
-rw-r--r--sw/source/core/uibase/inc/break.hxx75
-rw-r--r--sw/source/core/uibase/inc/caption.hxx98
-rw-r--r--sw/source/core/uibase/inc/cfgid.h28
-rw-r--r--sw/source/core/uibase/inc/cfgitems.hxx221
-rw-r--r--sw/source/core/uibase/inc/changedb.hxx68
-rw-r--r--sw/source/core/uibase/inc/chartins.hxx27
-rw-r--r--sw/source/core/uibase/inc/chldwrap.hxx47
-rw-r--r--sw/source/core/uibase/inc/chrdlg.hxx94
-rw-r--r--sw/source/core/uibase/inc/chrdlgmodes.hxx21
-rw-r--r--sw/source/core/uibase/inc/cnttab.hxx88
-rw-r--r--sw/source/core/uibase/inc/colex.hxx109
-rw-r--r--sw/source/core/uibase/inc/colmgr.hxx127
-rw-r--r--sw/source/core/uibase/inc/column.hxx206
-rw-r--r--sw/source/core/uibase/inc/conarc.hxx48
-rw-r--r--sw/source/core/uibase/inc/concustomshape.hxx63
-rw-r--r--sw/source/core/uibase/inc/condedit.hxx49
-rw-r--r--sw/source/core/uibase/inc/conform.hxx38
-rw-r--r--sw/source/core/uibase/inc/conpoly.hxx47
-rw-r--r--sw/source/core/uibase/inc/conrect.hxx51
-rw-r--r--sw/source/core/uibase/inc/content.hxx208
-rw-r--r--sw/source/core/uibase/inc/conttree.hxx329
-rw-r--r--sw/source/core/uibase/inc/convert.hxx74
-rw-r--r--sw/source/core/uibase/inc/cption.hxx113
-rw-r--r--sw/source/core/uibase/inc/dbconfig.hxx47
-rw-r--r--sw/source/core/uibase/inc/dbinsdlg.hxx171
-rw-r--r--sw/source/core/uibase/inc/dbtree.hxx72
-rw-r--r--sw/source/core/uibase/inc/dbui.hxx70
-rw-r--r--sw/source/core/uibase/inc/dialmgr.hxx31
-rw-r--r--sw/source/core/uibase/inc/docfnote.hxx44
-rw-r--r--sw/source/core/uibase/inc/docstdlg.hxx70
-rw-r--r--sw/source/core/uibase/inc/drawbase.hxx79
-rw-r--r--sw/source/core/uibase/inc/drawsh.hxx50
-rw-r--r--sw/source/core/uibase/inc/drformsh.hxx41
-rw-r--r--sw/source/core/uibase/inc/drpcps.hxx103
-rw-r--r--sw/source/core/uibase/inc/drwbassh.hxx56
-rw-r--r--sw/source/core/uibase/inc/drwtxtsh.hxx80
-rw-r--r--sw/source/core/uibase/inc/dselect.hxx43
-rw-r--r--sw/source/core/uibase/inc/edtwin.hxx302
-rw-r--r--sw/source/core/uibase/inc/envimg.hxx91
-rw-r--r--sw/source/core/uibase/inc/envlop.hxx122
-rw-r--r--sw/source/core/uibase/inc/fldedt.hxx55
-rw-r--r--sw/source/core/uibase/inc/fldmgr.hxx217
-rw-r--r--sw/source/core/uibase/inc/fldtdlg.hxx66
-rw-r--r--sw/source/core/uibase/inc/fldwrap.hxx56
-rw-r--r--sw/source/core/uibase/inc/fontcfg.hxx112
-rw-r--r--sw/source/core/uibase/inc/formatclipboard.hxx95
-rw-r--r--sw/source/core/uibase/inc/formedt.hxx92
-rw-r--r--sw/source/core/uibase/inc/frmdlg.hxx68
-rw-r--r--sw/source/core/uibase/inc/frmmgr.hxx188
-rw-r--r--sw/source/core/uibase/inc/frmpage.hxx328
-rw-r--r--sw/source/core/uibase/inc/frmsh.hxx44
-rw-r--r--sw/source/core/uibase/inc/frmui.hrc71
-rw-r--r--sw/source/core/uibase/inc/globals.h31
-rw-r--r--sw/source/core/uibase/inc/globdoc.hrc44
-rw-r--r--sw/source/core/uibase/inc/glosbib.hxx116
-rw-r--r--sw/source/core/uibase/inc/glosdoc.hxx135
-rw-r--r--sw/source/core/uibase/inc/gloshdl.hxx104
-rw-r--r--sw/source/core/uibase/inc/gloslst.hxx82
-rw-r--r--sw/source/core/uibase/inc/glossary.hxx168
-rw-r--r--sw/source/core/uibase/inc/glshell.hxx85
-rw-r--r--sw/source/core/uibase/inc/grfsh.hxx41
-rw-r--r--sw/source/core/uibase/inc/hyp.hxx58
-rw-r--r--sw/source/core/uibase/inc/idxmrk.hxx60
-rw-r--r--sw/source/core/uibase/inc/imaildsplistener.hxx70
-rw-r--r--sw/source/core/uibase/inc/initui.hxx66
-rw-r--r--sw/source/core/uibase/inc/inpdlg.hxx63
-rw-r--r--sw/source/core/uibase/inc/inputwin.hxx119
-rw-r--r--sw/source/core/uibase/inc/insfnote.hxx85
-rw-r--r--sw/source/core/uibase/inc/instable.hxx76
-rw-r--r--sw/source/core/uibase/inc/javaedit.hxx88
-rw-r--r--sw/source/core/uibase/inc/label.hxx93
-rw-r--r--sw/source/core/uibase/inc/labelcfg.hxx61
-rw-r--r--sw/source/core/uibase/inc/labimg.hxx125
-rw-r--r--sw/source/core/uibase/inc/langhelper.hxx62
-rw-r--r--sw/source/core/uibase/inc/linenum.hxx64
-rw-r--r--sw/source/core/uibase/inc/listsh.hxx38
-rw-r--r--sw/source/core/uibase/inc/macassgn.hxx47
-rw-r--r--sw/source/core/uibase/inc/mailconfigpage.hxx77
-rw-r--r--sw/source/core/uibase/inc/maildispatcher.hxx154
-rw-r--r--sw/source/core/uibase/inc/mailmergechildwindow.hxx52
-rw-r--r--sw/source/core/uibase/inc/mailmergehelper.hxx310
-rw-r--r--sw/source/core/uibase/inc/mailmergewizard.hxx97
-rw-r--r--sw/source/core/uibase/inc/mailmrge.hxx176
-rw-r--r--sw/source/core/uibase/inc/mediash.hxx37
-rw-r--r--sw/source/core/uibase/inc/mergetbl.hxx41
-rw-r--r--sw/source/core/uibase/inc/misc.hrc60
-rw-r--r--sw/source/core/uibase/inc/mmconfigitem.hxx270
-rw-r--r--sw/source/core/uibase/inc/multmrk.hxx53
-rw-r--r--sw/source/core/uibase/inc/navicfg.hxx109
-rw-r--r--sw/source/core/uibase/inc/navicont.hxx54
-rw-r--r--sw/source/core/uibase/inc/navipi.hxx186
-rw-r--r--sw/source/core/uibase/inc/navmgr.hxx56
-rw-r--r--sw/source/core/uibase/inc/navsh.hxx28
-rw-r--r--sw/source/core/uibase/inc/num.hxx166
-rw-r--r--sw/source/core/uibase/inc/numberingtypelistbox.hxx51
-rw-r--r--sw/source/core/uibase/inc/numfmtlb.hxx73
-rw-r--r--sw/source/core/uibase/inc/numpara.hxx86
-rw-r--r--sw/source/core/uibase/inc/numprevw.hxx71
-rw-r--r--sw/source/core/uibase/inc/olesh.hxx35
-rw-r--r--sw/source/core/uibase/inc/olmenu.hxx91
-rw-r--r--sw/source/core/uibase/inc/optcomp.hxx75
-rw-r--r--sw/source/core/uibase/inc/optload.hxx175
-rw-r--r--sw/source/core/uibase/inc/optpage.hxx439
-rw-r--r--sw/source/core/uibase/inc/outline.hxx138
-rw-r--r--sw/source/core/uibase/inc/pardlg.hxx30
-rw-r--r--sw/source/core/uibase/inc/pattern.hxx36
-rw-r--r--sw/source/core/uibase/inc/pgfnote.hxx77
-rw-r--r--sw/source/core/uibase/inc/pggrid.hxx101
-rw-r--r--sw/source/core/uibase/inc/popbox.hxx57
-rw-r--r--sw/source/core/uibase/inc/popup.hrc49
-rw-r--r--sw/source/core/uibase/inc/prcntfld.hxx111
-rw-r--r--sw/source/core/uibase/inc/pview.hxx301
-rw-r--r--sw/source/core/uibase/inc/redline_tmpl.hrc39
-rw-r--r--sw/source/core/uibase/inc/redlndlg.hxx162
-rw-r--r--sw/source/core/uibase/inc/regionsw.hxx303
-rw-r--r--sw/source/core/uibase/inc/ribbar.hrc104
-rw-r--r--sw/source/core/uibase/inc/rowht.hxx44
-rw-r--r--sw/source/core/uibase/inc/scroll.hxx59
-rw-r--r--sw/source/core/uibase/inc/selglos.hxx54
-rw-r--r--sw/source/core/uibase/inc/sharedconnection.hxx30
-rw-r--r--sw/source/core/uibase/inc/shdwcrsr.hxx57
-rw-r--r--sw/source/core/uibase/inc/shells.hrc100
-rw-r--r--sw/source/core/uibase/inc/splittbl.hxx49
-rw-r--r--sw/source/core/uibase/inc/srcedtw.hxx157
-rw-r--r--sw/source/core/uibase/inc/srcview.hxx89
-rw-r--r--sw/source/core/uibase/inc/srtdlg.hxx92
-rw-r--r--sw/source/core/uibase/inc/stmenu.hxx74
-rw-r--r--sw/source/core/uibase/inc/swcont.hxx99
-rw-r--r--sw/source/core/uibase/inc/swdtflvr.hxx213
-rw-r--r--sw/source/core/uibase/inc/swlbox.hxx86
-rw-r--r--sw/source/core/uibase/inc/swmessdialog.hxx30
-rw-r--r--sw/source/core/uibase/inc/swmodalredlineacceptdlg.hxx40
-rw-r--r--sw/source/core/uibase/inc/swrenamexnameddlg.hxx69
-rw-r--r--sw/source/core/uibase/inc/swruler.hxx122
-rw-r--r--sw/source/core/uibase/inc/swtablerep.hxx84
-rw-r--r--sw/source/core/uibase/inc/swuiccoll.hxx75
-rw-r--r--sw/source/core/uibase/inc/swuicnttab.hxx497
-rw-r--r--sw/source/core/uibase/inc/swuiidxmrk.hxx253
-rw-r--r--sw/source/core/uibase/inc/swuipardlg.hxx53
-rw-r--r--sw/source/core/uibase/inc/swvset.hxx32
-rw-r--r--sw/source/core/uibase/inc/swwrtshitem.hxx45
-rw-r--r--sw/source/core/uibase/inc/syncbtn.hxx53
-rw-r--r--sw/source/core/uibase/inc/table.hrc37
-rw-r--r--sw/source/core/uibase/inc/tabledlg.hxx49
-rw-r--r--sw/source/core/uibase/inc/tablemgr.hxx88
-rw-r--r--sw/source/core/uibase/inc/tabsh.hxx52
-rw-r--r--sw/source/core/uibase/inc/tautofmt.hxx91
-rw-r--r--sw/source/core/uibase/inc/tblctrl.hxx40
-rw-r--r--sw/source/core/uibase/inc/tblnumfm.hxx35
-rw-r--r--sw/source/core/uibase/inc/tbxanchr.hxx42
-rw-r--r--sw/source/core/uibase/inc/textsh.hxx83
-rw-r--r--sw/source/core/uibase/inc/titlepage.hxx70
-rw-r--r--sw/source/core/uibase/inc/tmpdlg.hxx89
-rw-r--r--sw/source/core/uibase/inc/tmplctrl.hxx45
-rw-r--r--sw/source/core/uibase/inc/toolbox.hrc553
-rw-r--r--sw/source/core/uibase/inc/toxmgr.hxx310
-rw-r--r--sw/source/core/uibase/inc/uiborder.hxx41
-rw-r--r--sw/source/core/uibase/inc/uiitems.hxx119
-rw-r--r--sw/source/core/uibase/inc/uinums.hxx123
-rw-r--r--sw/source/core/uibase/inc/uitool.hxx109
-rw-r--r--sw/source/core/uibase/inc/uivwimp.hxx173
-rw-r--r--sw/source/core/uibase/inc/unoatxt.hxx283
-rw-r--r--sw/source/core/uibase/inc/unodispatch.hxx128
-rw-r--r--sw/source/core/uibase/inc/unomailmerge.hxx191
-rw-r--r--sw/source/core/uibase/inc/unomod.hxx161
-rw-r--r--sw/source/core/uibase/inc/unotools.hxx121
-rw-r--r--sw/source/core/uibase/inc/unotxvw.hxx338
-rw-r--r--sw/source/core/uibase/inc/usrpref.hxx276
-rw-r--r--sw/source/core/uibase/inc/utlui.hrc189
-rw-r--r--sw/source/core/uibase/inc/view.hxx689
-rw-r--r--sw/source/core/uibase/inc/viewlayoutctrl.hxx46
-rw-r--r--sw/source/core/uibase/inc/web.hrc47
-rw-r--r--sw/source/core/uibase/inc/wformsh.hxx36
-rw-r--r--sw/source/core/uibase/inc/wfrmsh.hxx38
-rw-r--r--sw/source/core/uibase/inc/wgrfsh.hxx36
-rw-r--r--sw/source/core/uibase/inc/wlistsh.hxx36
-rw-r--r--sw/source/core/uibase/inc/wolesh.hxx35
-rw-r--r--sw/source/core/uibase/inc/wordcountctrl.hxx33
-rw-r--r--sw/source/core/uibase/inc/wordcountdialog.hxx79
-rw-r--r--sw/source/core/uibase/inc/workctrl.hxx185
-rw-r--r--sw/source/core/uibase/inc/wrap.hxx117
-rw-r--r--sw/source/core/uibase/inc/wrtsh.hxx646
-rw-r--r--sw/source/core/uibase/inc/wtabsh.hxx36
-rw-r--r--sw/source/core/uibase/inc/wtextsh.hxx38
-rw-r--r--sw/source/core/uibase/inc/wview.hxx41
-rw-r--r--sw/source/core/uibase/inc/zoomctrl.hxx43
-rw-r--r--sw/source/core/uibase/index/idxmrk.cxx114
-rw-r--r--sw/source/core/uibase/index/idxmrk.hrc26
-rw-r--r--sw/source/core/uibase/index/toxmgr.cxx525
-rw-r--r--sw/source/core/uibase/lingu/hhcwrp.cxx720
-rw-r--r--sw/source/core/uibase/lingu/hyp.cxx132
-rw-r--r--sw/source/core/uibase/lingu/olmenu.cxx891
-rw-r--r--sw/source/core/uibase/lingu/olmenu.hrc89
-rw-r--r--sw/source/core/uibase/lingu/olmenu.src131
-rw-r--r--sw/source/core/uibase/lingu/sdrhhcwrap.cxx175
-rw-r--r--sw/source/core/uibase/lingu/sdrhhcwrap.hxx56
-rw-r--r--sw/source/core/uibase/misc/glosdoc.cxx693
-rw-r--r--sw/source/core/uibase/misc/glshell.cxx274
-rw-r--r--sw/source/core/uibase/misc/numberingtypelistbox.cxx164
-rw-r--r--sw/source/core/uibase/misc/redlndlg.cxx1210
-rw-r--r--sw/source/core/uibase/misc/redlndlg.hrc28
-rw-r--r--sw/source/core/uibase/misc/redlndlg.src85
-rw-r--r--sw/source/core/uibase/misc/swruler.cxx302
-rw-r--r--sw/source/core/uibase/ribbar/conarc.cxx102
-rw-r--r--sw/source/core/uibase/ribbar/concustomshape.cxx196
-rw-r--r--sw/source/core/uibase/ribbar/conform.cxx110
-rw-r--r--sw/source/core/uibase/ribbar/conpoly.cxx107
-rw-r--r--sw/source/core/uibase/ribbar/conrect.cxx187
-rw-r--r--sw/source/core/uibase/ribbar/drawbase.cxx623
-rw-r--r--sw/source/core/uibase/ribbar/dselect.cxx72
-rw-r--r--sw/source/core/uibase/ribbar/inputwin.cxx636
-rw-r--r--sw/source/core/uibase/ribbar/inputwin.hrc62
-rw-r--r--sw/source/core/uibase/ribbar/inputwin.src290
-rw-r--r--sw/source/core/uibase/ribbar/tblctrl.cxx55
-rw-r--r--sw/source/core/uibase/ribbar/tbxanchr.cxx124
-rw-r--r--sw/source/core/uibase/ribbar/workctrl.cxx775
-rw-r--r--sw/source/core/uibase/ribbar/workctrl.hrc75
-rw-r--r--sw/source/core/uibase/ribbar/workctrl.src382
-rw-r--r--sw/source/core/uibase/shells/annotsh.cxx1760
-rw-r--r--sw/source/core/uibase/shells/basesh.cxx2832
-rw-r--r--sw/source/core/uibase/shells/beziersh.cxx330
-rw-r--r--sw/source/core/uibase/shells/drawdlg.cxx234
-rw-r--r--sw/source/core/uibase/shells/drawsh.cxx597
-rw-r--r--sw/source/core/uibase/shells/drformsh.cxx258
-rw-r--r--sw/source/core/uibase/shells/drwbassh.cxx961
-rw-r--r--sw/source/core/uibase/shells/drwtxtex.cxx1084
-rw-r--r--sw/source/core/uibase/shells/drwtxtsh.cxx878
-rw-r--r--sw/source/core/uibase/shells/frmsh.cxx1185
-rw-r--r--sw/source/core/uibase/shells/grfsh.cxx892
-rw-r--r--sw/source/core/uibase/shells/grfshex.cxx154
-rw-r--r--sw/source/core/uibase/shells/langhelper.cxx612
-rw-r--r--sw/source/core/uibase/shells/listsh.cxx280
-rw-r--r--sw/source/core/uibase/shells/mediash.cxx199
-rw-r--r--sw/source/core/uibase/shells/navsh.cxx106
-rw-r--r--sw/source/core/uibase/shells/olesh.cxx55
-rw-r--r--sw/source/core/uibase/shells/slotadd.cxx139
-rw-r--r--sw/source/core/uibase/shells/tabsh.cxx1476
-rw-r--r--sw/source/core/uibase/shells/textdrw.cxx122
-rw-r--r--sw/source/core/uibase/shells/textfld.cxx923
-rw-r--r--sw/source/core/uibase/shells/textglos.cxx129
-rw-r--r--sw/source/core/uibase/shells/textidx.cxx251
-rw-r--r--sw/source/core/uibase/shells/textsh.cxx1131
-rw-r--r--sw/source/core/uibase/shells/textsh1.cxx1811
-rw-r--r--sw/source/core/uibase/shells/textsh2.cxx285
-rw-r--r--sw/source/core/uibase/shells/txtattr.cxx743
-rw-r--r--sw/source/core/uibase/shells/txtcrsr.cxx376
-rw-r--r--sw/source/core/uibase/shells/txtnum.cxx410
-rw-r--r--sw/source/core/uibase/sidebar/PageColumnControl.cxx110
-rw-r--r--sw/source/core/uibase/sidebar/PageColumnControl.hxx65
-rw-r--r--sw/source/core/uibase/sidebar/PageMarginControl.cxx518
-rw-r--r--sw/source/core/uibase/sidebar/PageMarginControl.hxx121
-rw-r--r--sw/source/core/uibase/sidebar/PageOrientationControl.cxx90
-rw-r--r--sw/source/core/uibase/sidebar/PageOrientationControl.hxx56
-rw-r--r--sw/source/core/uibase/sidebar/PagePropertyPanel.cxx742
-rw-r--r--sw/source/core/uibase/sidebar/PagePropertyPanel.hrc188
-rw-r--r--sw/source/core/uibase/sidebar/PagePropertyPanel.hxx223
-rw-r--r--sw/source/core/uibase/sidebar/PageSizeControl.cxx177
-rw-r--r--sw/source/core/uibase/sidebar/PageSizeControl.hxx71
-rw-r--r--sw/source/core/uibase/sidebar/PropertyPanel.hrc35
-rw-r--r--sw/source/core/uibase/sidebar/SwPanelFactory.cxx148
-rw-r--r--sw/source/core/uibase/sidebar/WrapPropertyPanel.cxx243
-rw-r--r--sw/source/core/uibase/sidebar/WrapPropertyPanel.hxx88
-rw-r--r--sw/source/core/uibase/smartmenu/stmenu.cxx170
-rw-r--r--sw/source/core/uibase/smartmenu/stmenu.hrc33
-rw-r--r--sw/source/core/uibase/smartmenu/stmenu.src37
-rw-r--r--sw/source/core/uibase/table/chartins.cxx254
-rw-r--r--sw/source/core/uibase/table/swtablerep.cxx186
-rw-r--r--sw/source/core/uibase/table/tablemgr.cxx349
-rw-r--r--sw/source/core/uibase/table/tablepg.hxx195
-rw-r--r--sw/source/core/uibase/uiview/formatclipboard.cxx608
-rw-r--r--sw/source/core/uibase/uiview/pview.cxx1909
-rw-r--r--sw/source/core/uibase/uiview/scroll.cxx121
-rw-r--r--sw/source/core/uibase/uiview/srcview.cxx873
-rw-r--r--sw/source/core/uibase/uiview/swcli.cxx172
-rw-r--r--sw/source/core/uibase/uiview/uivwimp.cxx305
-rw-r--r--sw/source/core/uibase/uiview/view.cxx1822
-rw-r--r--sw/source/core/uibase/uiview/view.hrc74
-rw-r--r--sw/source/core/uibase/uiview/view.src149
-rw-r--r--sw/source/core/uibase/uiview/view0.cxx581
-rw-r--r--sw/source/core/uibase/uiview/view1.cxx185
-rw-r--r--sw/source/core/uibase/uiview/view2.cxx2469
-rw-r--r--sw/source/core/uibase/uiview/viewcoll.cxx80
-rw-r--r--sw/source/core/uibase/uiview/viewdlg.cxx75
-rw-r--r--sw/source/core/uibase/uiview/viewdlg2.cxx202
-rw-r--r--sw/source/core/uibase/uiview/viewdraw.cxx755
-rw-r--r--sw/source/core/uibase/uiview/viewfunc.hxx53
-rw-r--r--sw/source/core/uibase/uiview/viewling.cxx898
-rw-r--r--sw/source/core/uibase/uiview/viewmdi.cxx614
-rw-r--r--sw/source/core/uibase/uiview/viewport.cxx1275
-rw-r--r--sw/source/core/uibase/uiview/viewprt.cxx306
-rw-r--r--sw/source/core/uibase/uiview/viewsrch.cxx814
-rw-r--r--sw/source/core/uibase/uiview/viewstat.cxx526
-rw-r--r--sw/source/core/uibase/uiview/viewtab.cxx2010
-rw-r--r--sw/source/core/uibase/uno/SwXDocumentSettings.cxx1254
-rw-r--r--sw/source/core/uibase/uno/SwXDocumentSettings.hxx93
-rw-r--r--sw/source/core/uibase/uno/SwXFilterOptions.cxx179
-rw-r--r--sw/source/core/uibase/uno/dlelstnr.cxx165
-rw-r--r--sw/source/core/uibase/uno/unoatxt.cxx1121
-rw-r--r--sw/source/core/uibase/uno/unodefaults.cxx51
-rw-r--r--sw/source/core/uibase/uno/unodefaults.hxx40
-rw-r--r--sw/source/core/uibase/uno/unodispatch.cxx392
-rw-r--r--sw/source/core/uibase/uno/unodoc.cxx113
-rw-r--r--sw/source/core/uibase/uno/unofreg.cxx373
-rw-r--r--sw/source/core/uibase/uno/unomailmerge.cxx1227
-rw-r--r--sw/source/core/uibase/uno/unomod.cxx990
-rw-r--r--sw/source/core/uibase/uno/unomodule.cxx154
-rw-r--r--sw/source/core/uibase/uno/unomodule.hxx81
-rw-r--r--sw/source/core/uibase/uno/unotxdoc.cxx3994
-rw-r--r--sw/source/core/uibase/uno/unotxvw.cxx1851
-rw-r--r--sw/source/core/uibase/utlui/attrdesc.cxx1248
-rw-r--r--sw/source/core/uibase/utlui/attrdesc.hrc115
-rw-r--r--sw/source/core/uibase/utlui/attrdesc.src363
-rw-r--r--sw/source/core/uibase/utlui/bookctrl.cxx128
-rw-r--r--sw/source/core/uibase/utlui/condedit.cxx90
-rw-r--r--sw/source/core/uibase/utlui/content.cxx3517
-rw-r--r--sw/source/core/uibase/utlui/glbltree.cxx1374
-rw-r--r--sw/source/core/uibase/utlui/gloslst.cxx418
-rw-r--r--sw/source/core/uibase/utlui/initui.cxx337
-rw-r--r--sw/source/core/uibase/utlui/initui.hrc57
-rw-r--r--sw/source/core/uibase/utlui/initui.src412
-rw-r--r--sw/source/core/uibase/utlui/navicfg.cxx119
-rw-r--r--sw/source/core/uibase/utlui/navipi.cxx1384
-rw-r--r--sw/source/core/uibase/utlui/navipi.hrc74
-rw-r--r--sw/source/core/uibase/utlui/navipi.src508
-rw-r--r--sw/source/core/uibase/utlui/numfmtlb.cxx488
-rw-r--r--sw/source/core/uibase/utlui/prcntfld.cxx287
-rw-r--r--sw/source/core/uibase/utlui/shdwcrsr.cxx120
-rw-r--r--sw/source/core/uibase/utlui/tmplctrl.cxx137
-rw-r--r--sw/source/core/uibase/utlui/uiitems.cxx317
-rw-r--r--sw/source/core/uibase/utlui/uitool.cxx818
-rw-r--r--sw/source/core/uibase/utlui/unotools.cxx562
-rw-r--r--sw/source/core/uibase/utlui/unotools.hrc35
-rw-r--r--sw/source/core/uibase/utlui/unotools.src42
-rw-r--r--sw/source/core/uibase/utlui/viewlayoutctrl.cxx195
-rw-r--r--sw/source/core/uibase/utlui/wordcountctrl.cxx27
-rw-r--r--sw/source/core/uibase/utlui/zoomctrl.cxx72
-rw-r--r--sw/source/core/uibase/web/wdocsh.cxx86
-rw-r--r--sw/source/core/uibase/web/wformsh.cxx56
-rw-r--r--sw/source/core/uibase/web/wfrmsh.cxx56
-rw-r--r--sw/source/core/uibase/web/wgrfsh.cxx61
-rw-r--r--sw/source/core/uibase/web/wlistsh.cxx55
-rw-r--r--sw/source/core/uibase/web/wolesh.cxx56
-rw-r--r--sw/source/core/uibase/web/wtabsh.cxx61
-rw-r--r--sw/source/core/uibase/web/wtextsh.cxx64
-rw-r--r--sw/source/core/uibase/web/wview.cxx288
-rw-r--r--sw/source/core/uibase/wrtsh/delete.cxx543
-rw-r--r--sw/source/core/uibase/wrtsh/move.cxx693
-rw-r--r--sw/source/core/uibase/wrtsh/navmgr.cxx228
-rw-r--r--sw/source/core/uibase/wrtsh/select.cxx973
-rw-r--r--sw/source/core/uibase/wrtsh/wrtsh.hrc41
-rw-r--r--sw/source/core/uibase/wrtsh/wrtsh.src46
-rw-r--r--sw/source/core/uibase/wrtsh/wrtsh1.cxx1801
-rw-r--r--sw/source/core/uibase/wrtsh/wrtsh2.cxx542
-rw-r--r--sw/source/core/uibase/wrtsh/wrtsh3.cxx227
-rw-r--r--sw/source/core/uibase/wrtsh/wrtsh4.cxx238
-rw-r--r--sw/source/core/uibase/wrtsh/wrtundo.cxx154
-rw-r--r--sw/source/core/view/viewsh.cxx2
476 files changed, 155584 insertions, 4 deletions
diff --git a/sw/source/core/access/accembedded.cxx b/sw/source/core/access/accembedded.cxx
index b5f2c94f21f7..762482e528dd 100644
--- a/sw/source/core/access/accembedded.cxx
+++ b/sw/source/core/access/accembedded.cxx
@@ -28,8 +28,8 @@
#include "ndole.hxx"
#include <doc.hxx>
#include <docsh.hxx>
-#include <../../ui/inc/wrtsh.hxx>
-#include <../../ui/inc/view.hxx>
+#include <../uibase/inc/wrtsh.hxx>
+#include <../uibase/inc/view.hxx>
using namespace ::com::sun::star;
using namespace ::com::sun::star::lang;
diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx
index 04c3b3fc6ad2..82e9ff31f43c 100644
--- a/sw/source/core/access/accpara.cxx
+++ b/sw/source/core/access/accpara.cxx
@@ -96,7 +96,7 @@
#include <expfld.hxx>
#include <flddat.hxx>
#include <fldui.hrc>
-#include "../../ui/inc/fldmgr.hxx"
+#include "../uibase/inc/fldmgr.hxx"
#include "fldbas.hxx" // SwField
using namespace ::com::sun::star;
diff --git a/sw/source/core/uibase/app/appenv.cxx b/sw/source/core/uibase/app/appenv.cxx
new file mode 100644
index 000000000000..50acd4ada9e2
--- /dev/null
+++ b/sw/source/core/uibase/app/appenv.cxx
@@ -0,0 +1,508 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <cstdarg>
+
+#include <hintids.hxx>
+
+#include <comphelper/string.hxx>
+#include <sfx2/request.hxx>
+#include <svx/svxids.hrc>
+
+#include <svtools/svmedit.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/wrkwin.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/docfac.hxx>
+#include <sfx2/printer.hxx>
+#include <vcl/msgbox.hxx>
+#include <sfx2/dispatch.hxx>
+#include <editeng/boxitem.hxx>
+#include <editeng/lrspitem.hxx>
+#include <editeng/ulspitem.hxx>
+#include <editeng/pbinitem.hxx>
+#include <editeng/paperinf.hxx>
+#include <editeng/formatbreakitem.hxx>
+#include <fmthdft.hxx>
+#include <swwait.hxx>
+#include <paratr.hxx>
+#include <swmodule.hxx>
+#include <wrtsh.hxx>
+#include <view.hxx>
+#include <docsh.hxx>
+#include <frmatr.hxx>
+#include <fldbas.hxx>
+#include <swundo.hxx>
+#include <IDocumentDeviceAccess.hxx>
+#include <dbmgr.hxx>
+#include <fmtcol.hxx>
+#include <frmmgr.hxx>
+#include <fldmgr.hxx>
+#include <pagedesc.hxx>
+#include <poolfmt.hxx>
+#include <expfld.hxx>
+#include <SwStyleNameMapper.hxx>
+#include <crsskip.hxx>
+
+#include <cmdid.h>
+#include <globals.hrc>
+#include <app.hrc>
+#include <poolfmt.hrc>
+#include "swabstdlg.hxx"
+#include "envelp.hrc"
+#include "envimg.hxx"
+
+#include <boost/scoped_ptr.hpp>
+
+#define ENV_NEWDOC RET_OK
+#define ENV_INSERT RET_USER
+
+// Function used for labels and envelopes in applab.cxx and appenv.cxx
+OUString InsertLabEnvText( SwWrtShell& rSh, SwFldMgr& rFldMgr, const OUString& rText )
+{
+ OUString sRet;
+ OUString aText(comphelper::string::remove(rText, '\r'));
+
+ sal_Int32 nTokenPos = 0;
+ while( -1 != nTokenPos )
+ {
+ OUString aLine = aText.getToken( 0, '\n', nTokenPos );
+ while ( !aLine.isEmpty() )
+ {
+ OUString sTmpText;
+ bool bField = false;
+
+ sal_Int32 nPos = aLine.indexOf( '<' );
+ if (0 != nPos)
+ {
+ sal_Int32 const nCopy((nPos != -1) ? nPos : aLine.getLength());
+ sTmpText = aLine.copy(0, nCopy);
+ aLine = aLine.copy(nCopy);
+ }
+ else
+ {
+ nPos = aLine.indexOf( '>' );
+ if ( nPos == -1 )
+ {
+ sTmpText = aLine;
+ aLine = "";
+ }
+ else
+ {
+ sTmpText = aLine.copy( 0, nPos + 1);
+ aLine = aLine.copy( nPos + 1);
+
+ // Database fields must contain at least 3 points!
+ OUString sDBName( sTmpText.copy( 1, sTmpText.getLength() - 2));
+ sal_uInt16 nCnt = comphelper::string::getTokenCount(sDBName, '.');
+ if (nCnt >= 3)
+ {
+ sDBName = ::ReplacePoint(sDBName, true);
+ SwInsertFld_Data aData(TYP_DBFLD, 0, sDBName, aEmptyOUStr, 0, &rSh );
+ rFldMgr.InsertFld( aData );
+ sRet = sDBName;
+ bField = true;
+ }
+ }
+ }
+ if ( !bField )
+ rSh.Insert( sTmpText );
+ }
+ rSh.InsertLineBreak();
+ }
+ rSh.DelLeft(); // Again remove last linebreak
+
+ return sRet;
+}
+
+static void lcl_CopyCollAttr(SwWrtShell* pOldSh, SwWrtShell* pNewSh, sal_uInt16 nCollId)
+{
+ sal_uInt16 nCollCnt = pOldSh->GetTxtFmtCollCount();
+ SwTxtFmtColl* pColl;
+ for( sal_uInt16 nCnt = 0; nCnt < nCollCnt; ++nCnt )
+ if(nCollId == (pColl = &pOldSh->GetTxtFmtColl(nCnt))->GetPoolFmtId())
+ pNewSh->GetTxtCollFromPool(nCollId)->SetFmtAttr(pColl->GetAttrSet());
+}
+
+void SwModule::InsertEnv( SfxRequest& rReq )
+{
+ static sal_uInt16 nTitleNo = 0;
+
+ SwDocShell *pMyDocSh;
+ SfxViewFrame *pFrame;
+ SwView *pNewView;
+ SwWrtShell *pOldSh,
+ *pSh;
+
+ // Get current shell
+ pMyDocSh = (SwDocShell*) SfxObjectShell::Current();
+ pOldSh = pMyDocSh ? pMyDocSh->GetWrtShell() : 0;
+
+ // Create new document (don't show!)
+ SfxObjectShellLock xDocSh( new SwDocShell( SFX_CREATE_MODE_STANDARD ) );
+ xDocSh->DoInitNew( 0 );
+ pFrame = SfxViewFrame::LoadHiddenDocument( *xDocSh, 0 );
+ pNewView = (SwView*) pFrame->GetViewShell();
+ pNewView->AttrChangedNotify( &pNewView->GetWrtShell() ); // so that SelectShell is being called
+ pSh = pNewView->GetWrtShellPtr();
+
+ OUString aTmp( SW_RES(STR_ENV_TITLE) );
+ aTmp += OUString::number( ++nTitleNo );
+ xDocSh->SetTitle( aTmp );
+
+ // if applicable, copy the old Collections "Sender" and "Receiver" to
+ // a new document
+ if ( pOldSh )
+ {
+ ::lcl_CopyCollAttr(pOldSh, pSh, RES_POOLCOLL_JAKETADRESS);
+ ::lcl_CopyCollAttr(pOldSh, pSh, RES_POOLCOLL_SENDADRESS);
+ }
+
+ // Read SwEnvItem from config
+ SwEnvCfgItem aEnvCfg;
+
+ // Check if there's already an envelope.
+ bool bEnvChange = false;
+
+ SfxItemSet aSet(GetPool(), FN_ENVELOP, FN_ENVELOP, 0);
+ aSet.Put(aEnvCfg.GetItem());
+
+ SfxPrinter* pTempPrinter = pSh->getIDocumentDeviceAccess()->getPrinter( true );
+ if(pOldSh )
+ {
+ const SwPageDesc& rCurPageDesc = pOldSh->GetPageDesc(pOldSh->GetCurPageDesc());
+ OUString sJacket;
+ SwStyleNameMapper::FillUIName( RES_POOLPAGE_JAKET, sJacket );
+ bEnvChange = rCurPageDesc.GetName() == sJacket;
+
+ IDocumentDeviceAccess* pIDDA_old = pOldSh->getIDocumentDeviceAccess();
+ if( pIDDA_old->getPrinter( false ) )
+ {
+ IDocumentDeviceAccess* pIDDA = pSh->getIDocumentDeviceAccess();
+ pIDDA->setJobsetup( *pIDDA_old->getJobsetup() );
+ //#69563# if it isn't the same printer then the pointer has been invalidated!
+ pTempPrinter = pIDDA->getPrinter( true );
+ }
+ pTempPrinter->SetPaperBin(rCurPageDesc.GetMaster().GetPaperBin().GetValue());
+
+ }
+
+ Window *pParent = pOldSh ? pOldSh->GetWin() : 0;
+ boost::scoped_ptr<SfxAbstractTabDialog> pDlg;
+ short nMode = ENV_INSERT;
+
+ SFX_REQUEST_ARG( rReq, pItem, SwEnvItem, FN_ENVELOP, false );
+ if ( !pItem )
+ {
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+
+ pDlg.reset(pFact->CreateSwEnvDlg( pParent, aSet, pOldSh, pTempPrinter, !bEnvChange ));
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ nMode = pDlg->Execute();
+ }
+ else
+ {
+ SFX_REQUEST_ARG( rReq, pBoolItem, SfxBoolItem, FN_PARAM_1, false );
+ if ( pBoolItem && pBoolItem->GetValue() )
+ nMode = ENV_NEWDOC;
+ }
+
+ if (nMode == ENV_NEWDOC || nMode == ENV_INSERT)
+ {
+ SwWait aWait( (SwDocShell&)*xDocSh, true );
+
+ // Read dialog and save item to config
+ const SwEnvItem& rItem = pItem ? *pItem : (const SwEnvItem&) pDlg->GetOutputItemSet()->Get(FN_ENVELOP);
+ aEnvCfg.GetItem() = rItem;
+ aEnvCfg.Commit();
+
+ // When we print we take the Jobsetup that is set up in the dialog.
+ // Information has to be set here, before a possible destruction of
+ // the new shell because the shell's printer has been handed to the
+ // dialog.
+ if ( nMode != ENV_NEWDOC )
+ {
+ OSL_ENSURE(pOldSh, "No document - wasn't 'Insert' disabled???");
+ SvxPaperBinItem aItem( RES_PAPER_BIN );
+ aItem.SetValue((sal_uInt8)pSh->getIDocumentDeviceAccess()->getPrinter(true)->GetPaperBin());
+ pOldSh->GetPageDescFromPool(RES_POOLPAGE_JAKET)->GetMaster().SetFmtAttr(aItem);
+ }
+
+ SwWrtShell *pTmp = nMode == ENV_INSERT ? pOldSh : pSh;
+ const SwPageDesc* pFollow = 0;
+ SwTxtFmtColl *pSend = pTmp->GetTxtCollFromPool( RES_POOLCOLL_SENDADRESS ),
+ *pAddr = pTmp->GetTxtCollFromPool( RES_POOLCOLL_JAKETADRESS);
+ const OUString sSendMark = pSend->GetName();
+ const OUString sAddrMark = pAddr->GetName();
+
+ if (nMode == ENV_INSERT)
+ {
+
+ SetView(&pOldSh->GetView()); // Set pointer to top view
+
+ // Delete new document
+ xDocSh->DoClose();
+ pSh = pOldSh;
+ //#i4251# selected text or objects in the document should
+ //not be deleted on inserting envelopes
+ pSh->EnterStdMode();
+ // Here it goes (insert)
+ pSh->StartUndo(UNDO_UI_INSERT_ENVELOPE, NULL);
+ pSh->StartAllAction();
+ pSh->SttEndDoc(sal_True);
+
+ if (bEnvChange)
+ {
+ // followup template: page 2
+ pFollow = pSh->GetPageDesc(pSh->GetCurPageDesc()).GetFollow();
+
+ // Delete text from the first page
+ if ( !pSh->SttNxtPg(sal_True) )
+ pSh->EndPg(sal_True);
+ pSh->DelRight();
+ // Delete frame of the first page
+ if ( pSh->GotoFly(sSendMark) )
+ {
+ pSh->EnterSelFrmMode();
+ pSh->DelRight();
+ }
+ if ( pSh->GotoFly(sAddrMark) )
+ {
+ pSh->EnterSelFrmMode();
+ pSh->DelRight();
+ }
+ pSh->SttEndDoc(sal_True);
+ }
+ else
+ // Followup template: page 1
+ pFollow = &pSh->GetPageDesc(pSh->GetCurPageDesc());
+
+ // Insert page break
+ if ( pSh->IsCrsrInTbl() )
+ {
+ pSh->SplitNode();
+ pSh->Right( CRSR_SKIP_CHARS, sal_False, 1, sal_False );
+ SfxItemSet aBreakSet( pSh->GetAttrPool(), RES_BREAK, RES_BREAK, 0 );
+ aBreakSet.Put( SvxFmtBreakItem(SVX_BREAK_PAGE_BEFORE, RES_BREAK) );
+ pSh->SetTblAttr( aBreakSet );
+ }
+ else
+ pSh->InsertPageBreak(0, boost::none);
+ pSh->SttEndDoc(sal_True);
+ }
+ else
+ {
+ pFollow = &pSh->GetPageDesc(pSh->GetCurPageDesc());
+ // Let's go (print)
+ pSh->StartAllAction();
+ pSh->DoUndo(sal_False);
+
+ // Again, copy the new collections "Sender" and "Receiver" to
+ // a new document
+ if ( pOldSh )
+ {
+ ::lcl_CopyCollAttr(pOldSh, pSh, RES_POOLCOLL_JAKETADRESS);
+ ::lcl_CopyCollAttr(pOldSh, pSh, RES_POOLCOLL_SENDADRESS);
+ }
+ }
+
+ SET_CURR_SHELL(pSh);
+ pSh->SetNewDoc(); // Avoid performance problems
+
+ // Remember Flys of this site
+ std::vector<SwFrmFmt*> aFlyArr;
+ if( ENV_NEWDOC != nMode && !bEnvChange )
+ pSh->GetPageObjs( aFlyArr );
+
+ // Get page description
+ SwPageDesc* pDesc = pSh->GetPageDescFromPool(RES_POOLPAGE_JAKET);
+ SwFrmFmt& rFmt = pDesc->GetMaster();
+
+ Printer *pPrt = pSh->getIDocumentDeviceAccess()->getPrinter( true );
+
+ // Borders (are put together by Shift-Offset and alignment)
+ Size aPaperSize = pPrt->PixelToLogic( pPrt->GetPaperSizePixel(),
+ MAP_TWIP);
+ if ( !aPaperSize.Width() && !aPaperSize.Height() )
+ aPaperSize = SvxPaperInfo::GetPaperSize(PAPER_A4);
+ if ( aPaperSize.Width() > aPaperSize.Height() )
+ Swap( aPaperSize );
+
+ long lLeft = rItem.lShiftRight,
+ lUpper = rItem.lShiftDown;
+
+ sal_uInt16 nPageW = (sal_uInt16) std::max(rItem.lWidth, rItem.lHeight),
+ nPageH = (sal_uInt16) std::min(rItem.lWidth, rItem.lHeight);
+
+ switch (rItem.eAlign)
+ {
+ case ENV_HOR_LEFT: break;
+ case ENV_HOR_CNTR: lLeft += std::max(0L, long(aPaperSize.Width() - nPageW)) / 2;
+ break;
+ case ENV_HOR_RGHT: lLeft += std::max(0L, long(aPaperSize.Width() - nPageW));
+ break;
+ case ENV_VER_LEFT: lUpper += std::max(0L, long(aPaperSize.Width() - nPageH));
+ break;
+ case ENV_VER_CNTR: lUpper += std::max(0L, long(aPaperSize.Width() - nPageH)) / 2;
+ break;
+ case ENV_VER_RGHT: break;
+ }
+ SvxLRSpaceItem aLRMargin( RES_LR_SPACE );
+ SvxULSpaceItem aULMargin( RES_UL_SPACE );
+ aLRMargin.SetLeft ((sal_uInt16) lLeft );
+ aULMargin.SetUpper((sal_uInt16) lUpper);
+ aLRMargin.SetRight(0);
+ aULMargin.SetLower(0);
+ rFmt.SetFmtAttr(aLRMargin);
+ rFmt.SetFmtAttr(aULMargin);
+
+ // Header and footer
+ rFmt.SetFmtAttr(SwFmtHeader(sal_False));
+ pDesc->ChgHeaderShare(sal_False);
+ rFmt.SetFmtAttr(SwFmtFooter(sal_False));
+ pDesc->ChgFooterShare(sal_False);
+
+ // Page numbering
+ pDesc->SetUseOn(nsUseOnPage::PD_ALL);
+
+ // Page size
+ rFmt.SetFmtAttr(SwFmtFrmSize(ATT_FIX_SIZE,
+ nPageW + lLeft, nPageH + lUpper));
+
+ // Set type of page numbering
+ SvxNumberType aType;
+ aType.SetNumberingType(SVX_NUM_NUMBER_NONE);
+ pDesc->SetNumType(aType);
+
+ // Followup template
+ if (pFollow)
+ pDesc->SetFollow(pFollow);
+
+ // Landscape
+ pDesc->SetLandscape( rItem.eAlign >= ENV_VER_LEFT &&
+ rItem.eAlign <= ENV_VER_RGHT);
+
+ // Apply page description
+
+ sal_uInt16 nPos;
+ pSh->FindPageDescByName( pDesc->GetName(),
+ sal_False,
+ &nPos );
+
+ pSh->ChgPageDesc( nPos, *pDesc);
+ pSh->ChgCurPageDesc(*pDesc);
+
+ // Insert Frame
+ SwFlyFrmAttrMgr aMgr(sal_False, pSh, FRMMGR_TYPE_ENVELP);
+ SwFldMgr aFldMgr;
+ aMgr.SetHeightSizeType(ATT_VAR_SIZE);
+
+ // Overwrite defaults!
+ aMgr.GetAttrSet().Put( SvxBoxItem(RES_BOX) );
+ aMgr.SetULSpace( 0L, 0L );
+ aMgr.SetLRSpace( 0L, 0L );
+
+ // Sender
+ if (rItem.bSend)
+ {
+ pSh->SttEndDoc(sal_True);
+ aMgr.InsertFlyFrm(FLY_AT_PAGE,
+ Point(rItem.lSendFromLeft + lLeft, rItem.lSendFromTop + lUpper),
+ Size (rItem.lAddrFromLeft - rItem.lSendFromLeft, 0));
+
+ pSh->EnterSelFrmMode();
+ pSh->SetFlyName(sSendMark);
+ pSh->UnSelectFrm();
+ pSh->LeaveSelFrmMode();
+ pSh->SetTxtFmtColl( pSend );
+ InsertLabEnvText( *pSh, aFldMgr, rItem.aSendText );
+ aMgr.UpdateAttrMgr();
+ }
+
+ // Addressee
+ pSh->SttEndDoc(sal_True);
+
+ aMgr.InsertFlyFrm(FLY_AT_PAGE,
+ Point(rItem.lAddrFromLeft + lLeft, rItem.lAddrFromTop + lUpper),
+ Size (nPageW - rItem.lAddrFromLeft - 566, 0));
+ pSh->EnterSelFrmMode();
+ pSh->SetFlyName(sAddrMark);
+ pSh->UnSelectFrm();
+ pSh->LeaveSelFrmMode();
+ pSh->SetTxtFmtColl( pAddr );
+ InsertLabEnvText(*pSh, aFldMgr, rItem.aAddrText);
+
+ // Move Flys to the "old" pages
+ if (!aFlyArr.empty())
+ pSh->SetPageObjsNewPage(aFlyArr, 1);
+
+ // Finished
+ pSh->SttEndDoc(sal_True);
+
+ pSh->EndAllAction();
+
+ if (nMode == ENV_NEWDOC)
+ pSh->DoUndo(sal_True);
+ else
+ pSh->EndUndo(UNDO_UI_INSERT_ENVELOPE);
+
+ if (nMode == ENV_NEWDOC)
+ {
+ pFrame->GetFrame().Appear();
+
+ if ( rItem.aAddrText.indexOf('<') >= 0 )
+ {
+ static sal_uInt16 const aInva[] =
+ {
+ SID_SBA_BRW_UPDATE,
+ SID_SBA_BRW_INSERT,
+ SID_SBA_BRW_MERGE,
+ 0
+ };
+ pFrame->GetBindings().Invalidate( aInva );
+
+ // Open database beamer
+ ShowDBObj(*pNewView, pSh->GetDBData());
+ }
+ }
+
+ if ( !pItem )
+ {
+ rReq.AppendItem( rItem );
+ if ( nMode == ENV_NEWDOC )
+ rReq.AppendItem( SfxBoolItem( FN_PARAM_1, true ) );
+ }
+
+ rReq.Done();
+ }
+ else // Abort
+ {
+ rReq.Ignore();
+
+ xDocSh->DoClose();
+ --nTitleNo;
+
+ // Set pointer to top view
+ if (pOldSh)
+ SetView(&pOldSh->GetView());
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/app/apphdl.cxx b/sw/source/core/uibase/app/apphdl.cxx
new file mode 100644
index 000000000000..60ad48006403
--- /dev/null
+++ b/sw/source/core/uibase/app/apphdl.cxx
@@ -0,0 +1,888 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <hintids.hxx>
+
+#include <osl/diagnose.h>
+#include <tools/link.hxx>
+#include <svl/urihelper.hxx>
+#include <unotools/pathoptions.hxx>
+#include <svtools/accessibilityoptions.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/event.hxx>
+#include <sfx2/objitem.hxx>
+#include <svx/dataaccessdescriptor.hxx>
+#include <svl/srchitem.hxx>
+#include <svtools/colorcfg.hxx>
+#include <svl/eitem.hxx>
+#include <svl/whiter.hxx>
+#include <svl/isethint.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/fcontnr.hxx>
+#include <svl/stritem.hxx>
+#include <svl/ctloptions.hxx>
+#include <unotools/useroptions.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/wrkwin.hxx>
+#include <svx/insctrl.hxx>
+#include <svx/selctrl.hxx>
+#include <com/sun/star/document/UpdateDocMode.hpp>
+#include <sfx2/docfile.hxx>
+#include <svx/xmlsecctrl.hxx>
+#include <navicfg.hxx>
+
+#include <sfx2/objface.hxx>
+#include <sfx2/app.hxx>
+
+#include <view.hxx>
+#include <pview.hxx>
+#include <srcview.hxx>
+#include <wrtsh.hxx>
+#include <docsh.hxx>
+#include <cmdid.h>
+#include <initui.hxx>
+#include <uitool.hxx>
+#include <swmodule.hxx>
+#include <wdocsh.hxx>
+#include <wview.hxx>
+#include <usrpref.hxx>
+#include <gloslst.hxx>
+#include <glosdoc.hxx>
+#include <doc.hxx>
+#include <IDocumentUndoRedo.hxx>
+#include <cfgitems.hxx>
+#include <prtopt.hxx>
+#include <modcfg.hxx>
+#include <globals.h>
+#include <app.hrc>
+#include <fontcfg.hxx>
+#include <barcfg.hxx>
+#include <uinums.hxx>
+#include <dbconfig.hxx>
+#include <mmconfigitem.hxx>
+#include <mailmergechildwindow.hxx>
+#include <linguistic/lngprops.hxx>
+#include <editeng/unolingu.hxx>
+#include <com/sun/star/beans/XMultiPropertySet.hpp>
+#include <com/sun/star/beans/XFastPropertySet.hpp>
+#include <com/sun/star/beans/XPropertyState.hpp>
+#include <com/sun/star/beans/XPropertyStateChangeListener.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/beans/XPropertyAccess.hpp>
+#include <com/sun/star/beans/XPropertyContainer.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#include <swabstdlg.hxx>
+
+#include <vcl/status.hxx>
+
+#include "salhelper/simplereferenceobject.hxx"
+#include "rtl/ref.hxx"
+
+#include <unomid.h>
+
+using namespace ::com::sun::star;
+
+// Slotmaps for the application's methods
+
+// here are the SlotID's being included
+// see Idl-file
+#define SwModule
+#include <sfx2/msg.hxx>
+#include "swslots.hxx"
+#include <cfgid.h>
+
+#include <shells.hrc>
+
+SFX_IMPL_INTERFACE( SwModule, SfxModule, SW_RES(RID_SW_NAME) )
+{
+ SFX_STATUSBAR_REGISTRATION(SW_RES(CFG_STATUSBAR));
+ SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_APPLICATION |
+ SFX_VISIBILITY_DESKTOP | SFX_VISIBILITY_STANDARD | SFX_VISIBILITY_CLIENT | SFX_VISIBILITY_VIEWER,
+ SW_RES(RID_MODULE_TOOLBOX) );
+}
+
+// other states
+void SwModule::StateOther(SfxItemSet &rSet)
+{
+ SfxWhichIter aIter(rSet);
+ sal_uInt16 nWhich = aIter.FirstWhich();
+
+ SwView* pActView = ::GetActiveView();
+ sal_Bool bWebView = 0 != PTR_CAST(SwWebView, pActView);
+
+ while(nWhich)
+ {
+ switch(nWhich)
+ {
+ case FN_BUSINESS_CARD:
+ case FN_LABEL:
+ case FN_ENVELOP:
+ {
+ bool bDisable = false;
+ SfxViewShell* pCurrView = SfxViewShell::Current();
+ if( !pCurrView || (pCurrView && !pCurrView->ISA(SwView)) )
+ bDisable = true;
+ SwDocShell *pDocSh = (SwDocShell*) SfxObjectShell::Current();
+ if ( bDisable ||
+ (pDocSh && (pDocSh->IsReadOnly() ||
+ pDocSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED)) )
+ rSet.DisableItem( nWhich );
+
+ }
+ break;
+ case FN_XFORMS_INIT:
+ // slot is always active!
+ break;
+ case FN_EDIT_FORMULA:
+ {
+ SwWrtShell* pSh = 0;
+ int nSelection = 0;
+ if( pActView )
+ pSh = &pActView->GetWrtShell();
+ if( pSh )
+ nSelection = pSh->GetSelectionType();
+
+ if( (pSh && pSh->HasSelection()) ||
+ !(nSelection & (nsSelectionType::SEL_TXT | nsSelectionType::SEL_TBL)))
+ rSet.DisableItem(nWhich);
+ }
+ break;
+ case SID_ATTR_METRIC:
+ rSet.Put( SfxUInt16Item( SID_ATTR_METRIC, static_cast< sal_uInt16 >(::GetDfltMetric(bWebView))));
+ break;
+ case FN_SET_MODOPT_TBLNUMFMT:
+ rSet.Put( SfxBoolItem( nWhich, pModuleConfig->
+ IsInsTblFormatNum( bWebView )));
+ break;
+ default:
+ OSL_FAIL("::StateOther: default");
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+static SwView* lcl_LoadDoc(SwView* pView, const OUString& rURL)
+{
+ SwView* pNewView = 0;
+ if(!rURL.isEmpty())
+ {
+ SfxStringItem aURL(SID_FILE_NAME, rURL);
+ SfxStringItem aTargetFrameName( SID_TARGETNAME, OUString("_blank") );
+ SfxBoolItem aHidden( SID_HIDDEN, true );
+ SfxStringItem aReferer(SID_REFERER, pView->GetDocShell()->GetTitle());
+ SfxObjectItem* pItem = (SfxObjectItem*)pView->GetViewFrame()->GetDispatcher()->
+ Execute(SID_OPENDOC, SFX_CALLMODE_SYNCHRON,
+ &aURL, &aHidden, &aReferer, &aTargetFrameName, 0L);
+ SfxShell* pShell = pItem ? pItem->GetShell() : 0;
+
+ if(pShell)
+ {
+ SfxViewShell* pViewShell = pShell->GetViewShell();
+ if(pViewShell)
+ {
+ if( pViewShell->ISA(SwView) )
+ {
+ pNewView = PTR_CAST(SwView,pViewShell);
+ pNewView->GetViewFrame()->GetFrame().Appear();
+ }
+ else
+ {
+ pViewShell->GetViewFrame()->DoClose();
+ }
+ }
+ }
+ }
+ else
+ {
+ SfxStringItem aFactory(SID_NEWDOCDIRECT, SwDocShell::Factory().GetFilterContainer()->GetName());
+ const SfxFrameItem* pItem = (SfxFrameItem*)
+ pView->GetViewFrame()->GetDispatcher()->Execute(SID_NEWDOCDIRECT,
+ SFX_CALLMODE_SYNCHRON, &aFactory, 0L);
+ SfxFrame* pFrm = pItem ? pItem->GetFrame() : 0;
+ SfxViewFrame* pFrame = pFrm ? pFrm->GetCurrentViewFrame() : 0;
+ pNewView = pFrame ? PTR_CAST(SwView, pFrame->GetViewShell()) : 0;
+ }
+
+ return pNewView;
+}
+
+// start field dialog
+void NewXForms( SfxRequest& rReq ); // implementation: below
+
+namespace
+{
+
+class SwMailMergeWizardExecutor : public salhelper::SimpleReferenceObject
+{
+ SwView* m_pView; // never owner
+ SwView* m_pView2Close; // never owner
+ SwMailMergeConfigItem* m_pMMConfig; // sometimes owner
+ AbstractMailMergeWizard* m_pWizard; // always owner
+
+ DECL_LINK( EndDialogHdl, AbstractMailMergeWizard* );
+ DECL_LINK( DestroyDialogHdl, void* );
+ DECL_LINK( DestroyWizardHdl, AbstractMailMergeWizard* );
+ DECL_LINK( CancelHdl, void* );
+ DECL_LINK( CloseFrameHdl, void* );
+
+ void ExecutionFinished( bool bDeleteConfigItem );
+ void ExecuteWizard();
+
+public:
+ SwMailMergeWizardExecutor();
+ ~SwMailMergeWizardExecutor();
+
+ void ExecuteMailMergeWizard( const SfxItemSet * pArgs );
+};
+
+SwMailMergeWizardExecutor::SwMailMergeWizardExecutor()
+ : m_pView( 0 ),
+ m_pView2Close( NULL ),
+ m_pMMConfig( 0 ),
+ m_pWizard( 0 )
+{
+}
+
+SwMailMergeWizardExecutor::~SwMailMergeWizardExecutor()
+{
+ OSL_ENSURE( m_pWizard == 0, "SwMailMergeWizardExecutor: m_pWizard must be Null!" );
+ OSL_ENSURE( m_pMMConfig == 0, "SwMailMergeWizardExecutor: m_pMMConfig must be Null!" );
+}
+
+void SwMailMergeWizardExecutor::ExecuteMailMergeWizard( const SfxItemSet * pArgs )
+{
+ if ( m_pView )
+ {
+ OSL_FAIL("SwMailMergeWizardExecutor::ExecuteMailMergeWizard: Already executing the wizard!" );
+ return;
+ }
+
+ m_pView = ::GetActiveView(); // not owner!
+ OSL_ENSURE(m_pView, "no current view?");
+ if(m_pView)
+ {
+ // keep self alive until done.
+ acquire();
+
+ // if called from the child window - get the config item and close the ChildWindow, then restore
+ // the wizard
+ SwMailMergeChildWindow* pChildWin =
+ static_cast<SwMailMergeChildWindow*>(m_pView->GetViewFrame()->GetChildWindow(FN_MAILMERGE_CHILDWINDOW));
+ bool bRestoreWizard = false;
+ sal_uInt16 nRestartPage = 0;
+ if(pChildWin && pChildWin->IsVisible())
+ {
+ m_pMMConfig = m_pView->GetMailMergeConfigItem();
+ nRestartPage = m_pView->GetMailMergeRestartPage();
+ if(m_pView->IsMailMergeSourceView())
+ m_pMMConfig->SetSourceView( m_pView );
+ m_pView->SetMailMergeConfigItem(0, 0, sal_True);
+ SfxViewFrame* pViewFrame = m_pView->GetViewFrame();
+ pViewFrame->ShowChildWindow(FN_MAILMERGE_CHILDWINDOW, sal_False);
+ OSL_ENSURE(m_pMMConfig, "no MailMergeConfigItem available");
+ bRestoreWizard = true;
+ }
+ // to make it bullet proof ;-)
+ if(!m_pMMConfig)
+ {
+ m_pMMConfig = new SwMailMergeConfigItem;
+ m_pMMConfig->SetSourceView(m_pView);
+
+ //set the first used database as default source on the config item
+ const SfxPoolItem* pItem = 0;
+ if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(
+ FN_PARAM_DATABASE_PROPERTIES, false, &pItem))
+ {
+ //mailmerge has been called from the database beamer
+ uno::Sequence< beans::PropertyValue> aDBValues;
+ if(static_cast<const SfxUsrAnyItem*>(pItem)->GetValue() >>= aDBValues)
+ {
+ SwDBData aDBData;
+ svx::ODataAccessDescriptor aDescriptor(aDBValues);
+ aDescriptor[svx::daDataSource] >>= aDBData.sDataSource;
+ aDescriptor[svx::daCommand] >>= aDBData.sCommand;
+ aDescriptor[svx::daCommandType] >>= aDBData.nCommandType;
+
+ uno::Sequence< uno::Any > aSelection;
+ uno::Reference< sdbc::XConnection> xConnection;
+ uno::Reference< sdbc::XDataSource> xSource;
+ uno::Reference< sdbcx::XColumnsSupplier> xColumnsSupplier;
+ if ( aDescriptor.has(svx::daSelection) )
+ aDescriptor[svx::daSelection] >>= aSelection;
+ if ( aDescriptor.has(svx::daConnection) )
+ aDescriptor[svx::daConnection] >>= xConnection;
+ uno::Reference<container::XChild> xChild(xConnection, uno::UNO_QUERY);
+ if(xChild.is())
+ xSource = uno::Reference<sdbc::XDataSource>(
+ xChild->getParent(), uno::UNO_QUERY);
+ m_pMMConfig->SetCurrentConnection(
+ xSource, SharedConnection( xConnection, SharedConnection::NoTakeOwnership ),
+ xColumnsSupplier, aDBData);
+ }
+ }
+ else
+ {
+ std::vector<OUString> aDBNameList;
+ std::vector<OUString> aAllDBNames;
+ m_pView->GetWrtShell().GetAllUsedDB( aDBNameList, &aAllDBNames );
+ if(!aDBNameList.empty())
+ {
+ OUString sDBName(aDBNameList[0]);
+ SwDBData aDBData;
+ aDBData.sDataSource = sDBName.getToken(0, DB_DELIM);
+ aDBData.sCommand = sDBName.getToken(1, DB_DELIM);
+ aDBData.nCommandType = sDBName.getToken(2, DB_DELIM ).toInt32();
+ //set the currently used database for the wizard
+ m_pMMConfig->SetCurrentDBData( aDBData );
+ }
+ }
+ }
+
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ m_pWizard = pFact->CreateMailMergeWizard(*m_pView, *m_pMMConfig);
+
+ if(bRestoreWizard)
+ {
+ m_pWizard->ShowPage( nRestartPage );
+ }
+
+ ExecuteWizard();
+ }
+}
+
+void SwMailMergeWizardExecutor::ExecutionFinished( bool bDeleteConfigItem )
+{
+ m_pMMConfig->Commit();
+ if ( bDeleteConfigItem ) // owner?
+ delete m_pMMConfig;
+
+ m_pMMConfig = 0;
+
+ // release/destroy asynchronously
+ Application::PostUserEvent( LINK( this, SwMailMergeWizardExecutor, DestroyDialogHdl ) );
+}
+
+void SwMailMergeWizardExecutor::ExecuteWizard()
+{
+ m_pWizard->StartExecuteModal(
+ LINK( this, SwMailMergeWizardExecutor, EndDialogHdl ) );
+}
+
+IMPL_LINK( SwMailMergeWizardExecutor, EndDialogHdl, AbstractMailMergeWizard*, pDialog )
+{
+ OSL_ENSURE( pDialog == m_pWizard, "wrong dialog passed to EndDialogHdl!" );
+ (void) pDialog;
+
+ long nRet = m_pWizard->GetResult();
+ sal_uInt16 nRestartPage = m_pWizard->GetRestartPage();
+
+ switch ( nRet )
+ {
+ case RET_LOAD_DOC:
+ {
+ SwView* pNewView = lcl_LoadDoc(m_pView, m_pWizard->GetReloadDocument());
+
+ // destroy wizard asynchronously
+ Application::PostUserEvent(
+ LINK( this, SwMailMergeWizardExecutor, DestroyWizardHdl ), m_pWizard );
+
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ if(pNewView)
+ {
+ m_pView = pNewView;
+ m_pMMConfig->DocumentReloaded();
+ //new source view!
+ m_pMMConfig->SetSourceView( m_pView );
+ m_pWizard = pFact->CreateMailMergeWizard(*m_pView, *m_pMMConfig);
+ m_pWizard->ShowPage( nRestartPage );
+ }
+ else
+ {
+ m_pWizard = pFact->CreateMailMergeWizard(*m_pView, *m_pMMConfig);
+ }
+
+ // execute the wizard again
+ ExecuteWizard();
+ break;
+ }
+ case RET_TARGET_CREATED:
+ {
+ SwView* pTargetView = m_pMMConfig->GetTargetView();
+ uno::Reference< frame::XFrame > xFrame =
+ m_pView->GetViewFrame()->GetFrame().GetFrameInterface();
+ xFrame->getContainerWindow()->setVisible(sal_False);
+ OSL_ENSURE(pTargetView, "No target view has been created");
+ if(pTargetView)
+ {
+ // destroy wizard asynchronously
+ Application::PostUserEvent(
+ LINK( this, SwMailMergeWizardExecutor, DestroyWizardHdl ), m_pWizard );
+
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ m_pWizard = pFact->CreateMailMergeWizard(*pTargetView, *m_pMMConfig);
+ m_pWizard->ShowPage( nRestartPage );
+
+ // execute the wizard again
+ ExecuteWizard();
+ }
+ else
+ {
+ // should not happen - just in case no target view has been created
+ ExecutionFinished( true );
+ }
+ break;
+ }
+ case RET_EDIT_DOC:
+ case RET_EDIT_RESULT_DOC:
+ {
+ //create a non-modal dialog that allows to return to the wizard
+ //the ConfigItem ownership moves to this dialog
+ bool bResult = nRet == RET_EDIT_RESULT_DOC && m_pMMConfig->GetTargetView();
+ SwView* pTempView = bResult ? m_pMMConfig->GetTargetView() : m_pMMConfig->GetSourceView();
+ pTempView->SetMailMergeConfigItem(m_pMMConfig, m_pWizard->GetRestartPage(), !bResult);
+ SfxViewFrame* pViewFrame = pTempView->GetViewFrame();
+ pViewFrame->GetDispatcher()->Execute(
+ FN_MAILMERGE_CHILDWINDOW, SFX_CALLMODE_SYNCHRON);
+ ExecutionFinished( false );
+ break;
+ }
+ case RET_REMOVE_TARGET:
+ {
+ SwView* pTargetView = m_pMMConfig->GetTargetView();
+ SwView* pSourceView = m_pMMConfig->GetSourceView();
+ OSL_ENSURE(pTargetView && pSourceView, "source or target view not available" );
+ if(pTargetView && pSourceView)
+ {
+ m_pView2Close = pTargetView;
+ pTargetView->GetViewFrame()->GetTopViewFrame()->GetWindow().Hide();
+ pSourceView->GetViewFrame()->GetFrame().AppearWithUpdate();
+ // the current view has be be set when the target is destroyed
+ m_pView = pSourceView;
+ m_pMMConfig->SetTargetView(0);
+
+ // destroy wizard asynchronously
+ Application::PostUserEvent(
+ LINK( this, SwMailMergeWizardExecutor, CloseFrameHdl ), m_pWizard );
+
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ m_pWizard = pFact->CreateMailMergeWizard(*pSourceView, *m_pMMConfig);
+ m_pWizard->ShowPage( nRestartPage );
+
+ // execute the wizard again
+ ExecuteWizard();
+ }
+ else
+ {
+ // should not happen - just in case no target view has been created
+ ExecutionFinished( true );
+ }
+ break;
+ }
+ case RET_CANCEL:
+ {
+ // close frame and destroy wizard asynchronously
+ Application::PostUserEvent(
+ LINK( this, SwMailMergeWizardExecutor, CancelHdl ), m_pWizard );
+ break;
+ }
+ default: // finish
+ {
+ SwView* pSourceView = m_pMMConfig->GetSourceView();
+ if(pSourceView)
+ {
+ SwDocShell* pDocShell = pSourceView->GetDocShell();
+ if(pDocShell->HasName() && !pDocShell->IsModified())
+ m_pMMConfig->GetSourceView()->GetViewFrame()->DoClose();
+ else
+ m_pMMConfig->GetSourceView()->GetViewFrame()->GetFrame().Appear();
+ }
+ ExecutionFinished( true );
+ break;
+ }
+
+ } // switch
+
+ return 0L;
+}
+
+IMPL_LINK_NOARG(SwMailMergeWizardExecutor, DestroyDialogHdl)
+{
+ delete m_pWizard;
+ m_pWizard = 0;
+
+ release();
+ return 0L;
+}
+
+IMPL_LINK( SwMailMergeWizardExecutor, DestroyWizardHdl, AbstractMailMergeWizard*, pDialog )
+{
+ delete pDialog;
+ return 0L;
+}
+
+IMPL_LINK_NOARG(SwMailMergeWizardExecutor, CancelHdl)
+{
+ if(m_pMMConfig->GetTargetView())
+ {
+ m_pMMConfig->GetTargetView()->GetViewFrame()->DoClose();
+ m_pMMConfig->SetTargetView(0);
+ }
+ if(m_pMMConfig->GetSourceView())
+ m_pMMConfig->GetSourceView()->GetViewFrame()->GetFrame().AppearWithUpdate();
+
+ m_pMMConfig->Commit();
+ delete m_pMMConfig;
+ m_pMMConfig = 0;
+ // m_pWizard already deleted by closing the target view
+ m_pWizard = 0;
+ release();
+
+ return 0L;
+}
+
+IMPL_LINK_NOARG(SwMailMergeWizardExecutor, CloseFrameHdl)
+{
+ if ( m_pView2Close )
+ {
+ m_pView2Close->GetViewFrame()->DoClose();
+ m_pView2Close = NULL;
+ }
+
+ return 0L;
+}
+
+} // namespace
+
+void SwModule::ExecOther(SfxRequest& rReq)
+{
+ const SfxItemSet *pArgs = rReq.GetArgs();
+ const SfxPoolItem* pItem = 0;
+
+ sal_uInt16 nWhich = rReq.GetSlot();
+ switch (nWhich)
+ {
+ case FN_ENVELOP:
+ InsertEnv( rReq );
+ break;
+
+ case FN_BUSINESS_CARD:
+ case FN_LABEL:
+ InsertLab(rReq, nWhich == FN_LABEL);
+ break;
+
+ case FN_XFORMS_INIT:
+ NewXForms( rReq );
+ break;
+
+ case SID_ATTR_METRIC:
+ if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(nWhich, false, &pItem))
+ {
+ FieldUnit eUnit = (FieldUnit)((const SfxUInt16Item*)pItem)->GetValue();
+ switch( eUnit )
+ {
+ case FUNIT_MM:
+ case FUNIT_CM:
+ case FUNIT_INCH:
+ case FUNIT_PICA:
+ case FUNIT_POINT:
+ {
+ SwView* pActView = ::GetActiveView();
+ sal_Bool bWebView = 0 != PTR_CAST(SwWebView, pActView);
+ ::SetDfltMetric(eUnit, bWebView);
+ }
+ break;
+ default:;//prevent warning
+ }
+ }
+ break;
+
+ case FN_SET_MODOPT_TBLNUMFMT:
+ {
+ sal_Bool bWebView = 0 != PTR_CAST(SwWebView, ::GetActiveView() ),
+ bSet;
+
+ if( pArgs && SFX_ITEM_SET == pArgs->GetItemState(
+ nWhich, false, &pItem ))
+ bSet = ((SfxBoolItem*)pItem)->GetValue();
+ else
+ bSet = !pModuleConfig->IsInsTblFormatNum( bWebView );
+
+ pModuleConfig->SetInsTblFormatNum( bWebView, bSet );
+ }
+ break;
+ case FN_MAILMERGE_WIZARD:
+ {
+ rtl::Reference< SwMailMergeWizardExecutor > xEx( new SwMailMergeWizardExecutor );
+ xEx->ExecuteMailMergeWizard( pArgs );
+ }
+ break;
+ }
+}
+
+// Catch notifications
+
+// Catch hint for DocInfo
+void SwModule::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
+{
+ if( rHint.ISA( SfxEventHint ) )
+ {
+ SfxEventHint& rEvHint = (SfxEventHint&) rHint;
+ SwDocShell* pDocSh = PTR_CAST( SwDocShell, rEvHint.GetObjShell() );
+ if( pDocSh )
+ {
+ SwWrtShell* pWrtSh = pDocSh->GetWrtShell();
+ switch( rEvHint.GetEventId() )
+ {
+ case SFX_EVENT_LOADFINISHED:
+ OSL_ASSERT(!pWrtSh);
+ // if it is a new document created from a template,
+ // update fixed fields
+ if (pDocSh->GetMedium())
+ {
+ SFX_ITEMSET_ARG( pDocSh->GetMedium()->GetItemSet(),
+ pTemplateItem, SfxBoolItem,
+ SID_TEMPLATE, false);
+ if (pTemplateItem && pTemplateItem->GetValue())
+ {
+ pDocSh->GetDoc()->SetFixFields(false, 0);
+ }
+ }
+ break;
+ case SFX_EVENT_CREATEDOC:
+ // Update all FIX-Date/Time fields
+ if( pWrtSh )
+ {
+ SFX_ITEMSET_ARG( pDocSh->GetMedium()->GetItemSet(), pUpdateDocItem, SfxUInt16Item, SID_UPDATEDOCMODE, false);
+ bool bUpdateFields = true;
+ if( pUpdateDocItem && pUpdateDocItem->GetValue() == document::UpdateDocMode::NO_UPDATE)
+ bUpdateFields = false;
+ if(bUpdateFields)
+ {
+ pWrtSh->UpdateInputFlds();
+
+ // Are database fields contained?
+ // Get all used databases for the first time
+ SwDoc *pDoc = pDocSh->GetDoc();
+ std::vector<OUString> aDBNameList;
+ pDoc->GetAllUsedDB( aDBNameList );
+ if(!aDBNameList.empty())
+ { // Open database beamer
+ ShowDBObj(pWrtSh->GetView(), pDoc->GetDBData());
+ }
+ }
+ }
+ break;
+ }
+ }
+ }
+ else if(rHint.ISA(SfxItemSetHint))
+ {
+ if( SFX_ITEM_SET == ((SfxItemSetHint&)rHint).GetItemSet().GetItemState(SID_ATTR_PATHNAME))
+ {
+ ::GetGlossaries()->UpdateGlosPath( sal_False );
+ SwGlossaryList* pList = ::GetGlossaryList();
+ if(pList->IsActive())
+ pList->Update();
+ }
+ }
+ else if(rHint.ISA(SfxSimpleHint))
+ {
+ sal_uInt16 nHintId = ((SfxSimpleHint&)rHint).GetId();
+ if(SFX_HINT_DEINITIALIZING == nHintId)
+ {
+ DELETEZ(pWebUsrPref);
+ DELETEZ(pUsrPref) ;
+ DELETEZ(pModuleConfig);
+ DELETEZ(pPrtOpt) ;
+ DELETEZ(pWebPrtOpt) ;
+ DELETEZ(pChapterNumRules);
+ DELETEZ(pStdFontConfig) ;
+ DELETEZ(pNavigationConfig) ;
+ DELETEZ(pToolbarConfig) ;
+ DELETEZ(pWebToolbarConfig) ;
+ DELETEZ(pAuthorNames) ;
+ DELETEZ(pDBConfig);
+ if( pColorConfig )
+ {
+ pColorConfig->RemoveListener(this);
+ DELETEZ(pColorConfig);
+ }
+ if( pAccessibilityOptions )
+ {
+ pAccessibilityOptions->RemoveListener(this);
+ DELETEZ(pAccessibilityOptions);
+ }
+ if( pCTLOptions )
+ {
+ pCTLOptions->RemoveListener(this);
+ DELETEZ(pCTLOptions);
+ }
+ if( pUserOptions )
+ {
+ pUserOptions->RemoveListener(this);
+ DELETEZ(pUserOptions);
+ }
+ }
+ }
+}
+
+void SwModule::ConfigurationChanged( utl::ConfigurationBroadcaster* pBrdCst, sal_uInt32 )
+{
+ if( pBrdCst == pUserOptions )
+ {
+ bAuthorInitialised = sal_False;
+ }
+ else if ( pBrdCst == pColorConfig || pBrdCst == pAccessibilityOptions )
+ {
+ bool bAccessibility = false;
+ if( pBrdCst == pColorConfig )
+ SwViewOption::ApplyColorConfigValues(*pColorConfig);
+ else
+ bAccessibility = true;
+
+ //invalidate all edit windows
+ const TypeId aSwViewTypeId = TYPE(SwView);
+ const TypeId aSwPreviewTypeId = TYPE(SwPagePreview);
+ const TypeId aSwSrcViewTypeId = TYPE(SwSrcView);
+ SfxViewShell* pViewShell = SfxViewShell::GetFirst();
+ while(pViewShell)
+ {
+ if(pViewShell->GetWindow())
+ {
+ if((pViewShell->IsA(aSwViewTypeId) ||
+ pViewShell->IsA(aSwPreviewTypeId) ||
+ pViewShell->IsA(aSwSrcViewTypeId)))
+ {
+ if(bAccessibility)
+ {
+ if(pViewShell->IsA(aSwViewTypeId))
+ ((SwView*)pViewShell)->ApplyAccessiblityOptions(*pAccessibilityOptions);
+ else if(pViewShell->IsA(aSwPreviewTypeId))
+ ((SwPagePreview*)pViewShell)->ApplyAccessiblityOptions(*pAccessibilityOptions);
+ }
+ pViewShell->GetWindow()->Invalidate();
+ }
+ }
+ pViewShell = SfxViewShell::GetNext( *pViewShell );
+ }
+ }
+ else if( pBrdCst == pCTLOptions )
+ {
+ const SfxObjectShell* pObjSh = SfxObjectShell::GetFirst();
+ while( pObjSh )
+ {
+ if( pObjSh->IsA(TYPE(SwDocShell)) )
+ {
+ const SwDoc* pDoc = ((SwDocShell*)pObjSh)->GetDoc();
+ SwViewShell* pVSh = 0;
+ pDoc->GetEditShell( &pVSh );
+ if ( pVSh )
+ pVSh->ChgNumberDigits();
+ }
+ pObjSh = SfxObjectShell::GetNext(*pObjSh);
+ }
+ }
+
+}
+
+SwDBConfig* SwModule::GetDBConfig()
+{
+ if(!pDBConfig)
+ pDBConfig = new SwDBConfig;
+ return pDBConfig;
+}
+
+svtools::ColorConfig& SwModule::GetColorConfig()
+{
+ if(!pColorConfig)
+ {
+ pColorConfig = new svtools::ColorConfig;
+ SwViewOption::ApplyColorConfigValues(*pColorConfig);
+ pColorConfig->AddListener(this);
+ }
+ return *pColorConfig;
+}
+
+SvtAccessibilityOptions& SwModule::GetAccessibilityOptions()
+{
+ if(!pAccessibilityOptions)
+ {
+ pAccessibilityOptions = new SvtAccessibilityOptions;
+ pAccessibilityOptions->AddListener(this);
+ }
+ return *pAccessibilityOptions;
+}
+
+SvtCTLOptions& SwModule::GetCTLOptions()
+{
+ if(!pCTLOptions)
+ {
+ pCTLOptions = new SvtCTLOptions;
+ pCTLOptions->AddListener(this);
+ }
+ return *pCTLOptions;
+}
+
+SvtUserOptions& SwModule::GetUserOptions()
+{
+ if(!pUserOptions)
+ {
+ pUserOptions = new SvtUserOptions;
+ pUserOptions->AddListener(this);
+ }
+ return *pUserOptions;
+}
+
+const SwMasterUsrPref *SwModule::GetUsrPref(sal_Bool bWeb) const
+{
+ SwModule* pNonConstModule = (SwModule*)this;
+ if(bWeb && !pWebUsrPref)
+ {
+ // The SpellChecker is needed in SwMasterUsrPref's Load, but it must not
+ // be created there #58256#
+ pNonConstModule->pWebUsrPref = new SwMasterUsrPref(sal_True);
+ }
+ else if(!bWeb && !pUsrPref)
+ {
+ pNonConstModule->pUsrPref = new SwMasterUsrPref(sal_False);
+ }
+ return bWeb ? pWebUsrPref : pUsrPref;
+}
+
+void NewXForms( SfxRequest& rReq )
+{
+ // copied & excerpted from SwModule::InsertLab(..)
+
+ // create new document
+ SfxObjectShellLock xDocSh( new SwDocShell( SFX_CREATE_MODE_STANDARD) );
+ xDocSh->DoInitNew( 0 );
+
+ // initialize XForms
+ static_cast<SwDocShell*>( &xDocSh )->GetDoc()->initXForms( true );
+
+ // load document into frame
+ SfxViewFrame::DisplayNewDocument( *xDocSh, rReq );
+
+ // set return value
+ rReq.SetReturnValue( SfxVoidItem( rReq.GetSlot() ) );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/app/applab.cxx b/sw/source/core/uibase/app/applab.cxx
new file mode 100644
index 000000000000..4118e705b98c
--- /dev/null
+++ b/sw/source/core/uibase/app/applab.cxx
@@ -0,0 +1,403 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <cstdarg>
+
+#include <hintids.hxx>
+
+#include <comphelper/string.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/wrkwin.hxx>
+#include <vcl/msgbox.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/printer.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/linkmgr.hxx>
+#include <editeng/pbinitem.hxx>
+#include <editeng/ulspitem.hxx>
+#include <editeng/lrspitem.hxx>
+#include <editeng/boxitem.hxx>
+#include <editeng/paperinf.hxx>
+#include <editeng/protitem.hxx>
+#include <com/sun/star/frame/XStorable.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <fmthdft.hxx>
+#include <fmtanchr.hxx>
+#include <fmtfsize.hxx>
+#include <fmtornt.hxx>
+#include <swwait.hxx>
+#include <gloshdl.hxx>
+#include <mdiexp.hxx>
+#include <frmatr.hxx>
+#include <paratr.hxx>
+#include <swmodule.hxx>
+#include <view.hxx>
+#include <docsh.hxx>
+#include <fldbas.hxx>
+#include <swundo.hxx>
+#include <wrtsh.hxx>
+#include <cmdid.h>
+#include <dbmgr.hxx>
+#include <fmtcol.hxx>
+#include <expfld.hxx>
+#include <fldmgr.hxx>
+#include <label.hxx>
+#include <labimg.hxx>
+#include <section.hxx>
+#include <pagedesc.hxx>
+#include <poolfmt.hxx>
+
+#include <app.hrc>
+#include <poolfmt.hrc>
+#include "swabstdlg.hxx"
+#include "envelp.hrc"
+#include <misc.hrc>
+
+#include <IDocumentDeviceAccess.hxx>
+
+#include <boost/scoped_ptr.hpp>
+
+using namespace ::com::sun::star;
+
+// is in appenv.cxx
+extern OUString InsertLabEnvText( SwWrtShell& , SwFldMgr& , const OUString& );
+
+const char MASTER_LABEL[] = "MasterLabel";
+
+static const SwFrmFmt *lcl_InsertBCText( SwWrtShell& rSh, const SwLabItem& rItem,
+ SwFrmFmt &rFmt,
+ sal_uInt16 nCol, sal_uInt16 nRow )
+{
+ SfxItemSet aSet(rSh.GetAttrPool(), RES_ANCHOR, RES_ANCHOR,
+ RES_VERT_ORIENT, RES_VERT_ORIENT, RES_HORI_ORIENT, RES_HORI_ORIENT, 0 );
+ sal_uInt16 nPhyPageNum, nVirtPageNum;
+ rSh.GetPageNum( nPhyPageNum, nVirtPageNum );
+
+ //anchor frame to page
+ aSet.Put( SwFmtAnchor( FLY_AT_PAGE, nPhyPageNum ) );
+ aSet.Put( SwFmtHoriOrient( rItem.lLeft + nCol * rItem.lHDist,
+ text::HoriOrientation::NONE, text::RelOrientation::PAGE_FRAME ) );
+ aSet.Put( SwFmtVertOrient( rItem.lUpper + nRow * rItem.lVDist,
+ text::VertOrientation::NONE, text::RelOrientation::PAGE_FRAME ) );
+ const SwFrmFmt *pFmt = rSh.NewFlyFrm(aSet, sal_True, &rFmt ); // Insert Fly
+ OSL_ENSURE( pFmt, "Fly not inserted" );
+
+ rSh.UnSelectFrm(); //Frame was selected automatically
+
+ rSh.SetTxtFmtColl( rSh.GetTxtCollFromPool( RES_POOLCOLL_STANDARD ) );
+
+ if(!rItem.bSynchron || !(nCol|nRow))
+ {
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "Dialogdiet fail!");
+ ::GlossarySetActGroup fnSetActGroup = pFact->SetGlossaryActGroupFunc();
+ if ( fnSetActGroup )
+ (*fnSetActGroup)( rItem.sGlossaryGroup );
+ SwGlossaryHdl* pGlosHdl = rSh.GetView().GetGlosHdl();
+ pGlosHdl->SetCurGroup(rItem.sGlossaryGroup, sal_True);
+ pGlosHdl->InsertGlossary( rItem.sGlossaryBlockName );
+ }
+
+ return pFmt;
+}
+
+static const SwFrmFmt *lcl_InsertLabText( SwWrtShell& rSh, const SwLabItem& rItem,
+ SwFrmFmt &rFmt, SwFldMgr& rFldMgr,
+ sal_uInt16 nCol, sal_uInt16 nRow, sal_Bool bLast )
+{
+ SfxItemSet aSet(rSh.GetAttrPool(), RES_ANCHOR, RES_ANCHOR,
+ RES_VERT_ORIENT, RES_VERT_ORIENT, RES_HORI_ORIENT, RES_HORI_ORIENT, 0 );
+ sal_uInt16 nPhyPageNum, nVirtPageNum;
+ rSh.GetPageNum( nPhyPageNum, nVirtPageNum );
+
+ //anchor frame to page
+ aSet.Put( SwFmtAnchor( FLY_AT_PAGE, nPhyPageNum ) );
+ aSet.Put( SwFmtHoriOrient( rItem.lLeft + nCol * rItem.lHDist,
+ text::HoriOrientation::NONE, text::RelOrientation::PAGE_FRAME ) );
+ aSet.Put( SwFmtVertOrient( rItem.lUpper + nRow * rItem.lVDist,
+ text::VertOrientation::NONE, text::RelOrientation::PAGE_FRAME ) );
+ const SwFrmFmt *pFmt = rSh.NewFlyFrm(aSet, sal_True, &rFmt ); // Insert Fly
+ OSL_ENSURE( pFmt, "Fly not inserted" );
+
+ rSh.UnSelectFrm(); //Frame was selected automatically
+
+ rSh.SetTxtFmtColl( rSh.GetTxtCollFromPool( RES_POOLCOLL_STANDARD ) );
+
+ // If applicable "next dataset"
+ OUString sDBName;
+ if( (!rItem.bSynchron || !(nCol|nRow)) && !(sDBName = InsertLabEnvText( rSh, rFldMgr, rItem.aWriting )).isEmpty() && !bLast )
+ {
+ sDBName = comphelper::string::setToken(sDBName, 3, DB_DELIM, "True");
+ SwInsertFld_Data aData(TYP_DBNEXTSETFLD, 0, sDBName, aEmptyOUStr, 0, &rSh );
+ rFldMgr.InsertFld( aData );
+ }
+
+ return pFmt;
+}
+
+void SwModule::InsertLab(SfxRequest& rReq, sal_Bool bLabel)
+{
+ static sal_uInt16 nLabelTitleNo = 0;
+ static sal_uInt16 nBCTitleNo = 0;
+
+ // Create DB-Manager
+ boost::scoped_ptr<SwNewDBMgr> pNewDBMgr(new SwNewDBMgr);
+
+ // Read SwLabItem from Config
+ SwLabCfgItem aLabCfg(bLabel);
+
+ // Move up Dialog
+ SfxItemSet aSet( GetPool(), FN_LABEL, FN_LABEL, 0 );
+ aSet.Put( aLabCfg.GetItem() );
+
+ SwAbstractDialogFactory* pDialogFactory = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pDialogFactory, "SwAbstractDialogFactory fail!");
+
+ boost::scoped_ptr<AbstractSwLabDlg> pDlg(pDialogFactory->CreateSwLabDlg(0, aSet, pNewDBMgr.get(), bLabel));
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+
+ if ( RET_OK == pDlg->Execute() )
+ {
+ // Read dialog, store item in config
+ const SwLabItem& rItem = (const SwLabItem&) pDlg->
+ GetOutputItemSet()->Get(FN_LABEL);
+ aLabCfg.GetItem() = rItem;
+ aLabCfg.Commit();
+
+ // Create new document
+ SfxObjectShellLock xDocSh( new SwDocShell( SFX_CREATE_MODE_STANDARD));
+ xDocSh->DoInitNew( 0 );
+
+ // Printer
+ Printer *pPrt = pDlg->GetPrt();
+ if (pPrt)
+ {
+ SwDocShell *pDocSh = (SwDocShell*)(&*xDocSh);
+ pDocSh->getIDocumentDeviceAccess()->setJobsetup(pPrt->GetJobSetup());
+ }
+
+ SfxViewFrame* pViewFrame = SfxViewFrame::DisplayNewDocument( *xDocSh, rReq );
+
+ SwView *pNewView = (SwView*) pViewFrame->GetViewShell();
+ pNewView->AttrChangedNotify( &pNewView->GetWrtShell() );// So that SelectShell is being called.
+
+ // Set document title
+ OUString aTmp;
+ if(bLabel)
+ {
+ aTmp = SW_RES( STR_LAB_TITLE);
+ aTmp += OUString::number(++nLabelTitleNo );
+ }
+ else
+ {
+ aTmp = pDlg->GetBusinessCardStr();
+ aTmp += OUString::number( ++nBCTitleNo );
+ }
+ xDocSh->SetTitle( aTmp );
+
+ pViewFrame->GetFrame().Appear();
+
+ // Determine Shell
+ SwWrtShell *pSh = pNewView->GetWrtShellPtr();
+ OSL_ENSURE( pSh, "missing WrtShell" );
+
+ { // block for locks the dispatcher!!
+
+ SwWait aWait( (SwDocShell&)*xDocSh, true );
+
+ SET_CURR_SHELL(pSh);
+ pSh->SetLabelDoc(rItem.bSynchron);
+ pSh->DoUndo( sal_False );
+ pSh->StartAllAction();
+
+ pSh->SetNewDoc(); // Avoid performance problems
+
+ SwPageDesc aDesc = pSh->GetPageDesc( 0 );
+ SwFrmFmt& rFmt = aDesc.GetMaster();
+
+ // Borders
+ SvxLRSpaceItem aLRMargin( RES_LR_SPACE );
+ SvxULSpaceItem aULMargin( RES_UL_SPACE );
+ aLRMargin.SetLeft ((sal_uInt16) rItem.lLeft );
+ aULMargin.SetUpper((sal_uInt16) rItem.lUpper);
+ aLRMargin.SetRight( 0 );
+ aULMargin.SetLower( 0 );
+ rFmt.SetFmtAttr(aLRMargin);
+ rFmt.SetFmtAttr(aULMargin);
+
+ // Header and footer
+ rFmt.SetFmtAttr(SwFmtHeader(sal_Bool(sal_False)));
+ aDesc.ChgHeaderShare(sal_False);
+ rFmt.SetFmtAttr(SwFmtFooter(sal_Bool(sal_False)));
+ aDesc.ChgFooterShare(sal_False);
+
+ aDesc.SetUseOn(nsUseOnPage::PD_ALL); // Site numbering
+
+ // Set page size
+ long lPgWidth, lPgHeight;
+ lPgWidth = (rItem.lPWidth > MINLAY ? rItem.lPWidth : MINLAY);
+ lPgHeight = (rItem.lPHeight > MINLAY ? rItem.lPHeight : MINLAY);
+ rFmt.SetFmtAttr( SwFmtFrmSize( ATT_FIX_SIZE, lPgWidth, lPgHeight ));
+ // Numbering type
+ SvxNumberType aType;
+ aType.SetNumberingType(SVX_NUM_NUMBER_NONE);
+ aDesc.SetNumType( aType );
+
+ // Followup template
+ const SwPageDesc &rFollow = pSh->GetPageDesc( pSh->GetCurPageDesc() );
+ aDesc.SetFollow( &rFollow );
+
+ pPrt = pSh->getIDocumentDeviceAccess()->getPrinter( true );
+ SvxPaperBinItem aItem( RES_PAPER_BIN );
+ aItem.SetValue((sal_Int8)pPrt->GetPaperBin());
+ rFmt.SetFmtAttr(aItem);
+
+ // Determine orientation of the resulting page
+ aDesc.SetLandscape(rItem.lPWidth > rItem.lPHeight);
+
+ pSh->ChgPageDesc( 0, aDesc );
+
+ // Insert frame
+ boost::scoped_ptr<SwFldMgr> pFldMgr(new SwFldMgr);
+ pFldMgr->SetEvalExpFlds(sal_False);
+
+ // Prepare border template
+ SwFrmFmt* pFmt = pSh->GetFrmFmtFromPool( RES_POOLFRM_LABEL );
+ sal_Int32 iResultWidth = rItem.lLeft + (rItem.nCols - 1) * rItem.lHDist + rItem.lWidth - rItem.lPWidth;
+ sal_Int32 iResultHeight = rItem.lUpper + (rItem.nRows - 1) * rItem.lVDist + rItem.lHeight - rItem.lPHeight;
+ sal_Int32 iWidth = (iResultWidth > 0 ? rItem.lWidth - (iResultWidth / rItem.nCols) - 1 : rItem.lWidth);
+ sal_Int32 iHeight = (iResultHeight > 0 ? rItem.lHeight - (iResultHeight / rItem.nRows) - 1 : rItem.lHeight);
+ SwFmtFrmSize aFrmSize( ATT_FIX_SIZE, iWidth, iHeight );
+ pFmt->SetFmtAttr( aFrmSize );
+
+ //frame represents label itself, no border space
+ SvxULSpaceItem aFrmNoULSpace( 0, 0, RES_UL_SPACE );
+ SvxLRSpaceItem aFrmNoLRSpace( 0, 0, 0, 0, RES_LR_SPACE );
+ pFmt->SetFmtAttr( aFrmNoULSpace );
+ pFmt->SetFmtAttr( aFrmNoLRSpace );
+
+ const SwFrmFmt *pFirstFlyFmt = 0;
+ if ( rItem.bPage )
+ {
+ SwFmtVertOrient aFrmVertOrient( pFmt->GetVertOrient() );
+ aFrmVertOrient.SetVertOrient( text::VertOrientation::TOP );
+ pFmt->SetFmtAttr(aFrmVertOrient);
+
+ for ( sal_uInt16 i = 0; i < rItem.nRows; ++i )
+ {
+ for ( sal_uInt16 j = 0; j < rItem.nCols; ++j )
+ {
+ pSh->Push();
+ const SwFrmFmt *pTmp = ( bLabel ?
+ lcl_InsertLabText( *pSh, rItem, *pFmt, *pFldMgr, j, i,
+ i == rItem.nRows - 1 && j == rItem.nCols - 1 ) :
+ lcl_InsertBCText( *pSh, rItem, *pFmt, j, i ) );
+ if (!(i|j))
+ {
+ pFirstFlyFmt = pTmp;
+
+ if (rItem.bSynchron)
+ {
+ // if there is no content in the fly then
+ // dont leave the fly!!!
+ pSh->Push();
+ pSh->SttDoc();
+ sal_Bool bInFly = 0 != pSh->WizzardGetFly();
+ pSh->Pop( bInFly );
+
+ if( bInFly )
+ pSh->EndDoc(sal_True); // select all content
+ // in the fly
+ else
+ pSh->SetMark(); // set only the mark
+
+ SwSectionData aSect(CONTENT_SECTION,
+ OUString(MASTER_LABEL));
+ pSh->InsertSection(aSect);
+ }
+ }
+ else if (rItem.bSynchron)
+ {
+ SwSectionData aSect(FILE_LINK_SECTION,
+ pSh->GetUniqueSectionName());
+ OUStringBuffer sLinkName;
+ sLinkName.append(sfx2::cTokenSeparator);
+ sLinkName.append(sfx2::cTokenSeparator);
+ sLinkName.append(MASTER_LABEL);
+ aSect.SetLinkFileName(sLinkName.makeStringAndClear());
+ aSect.SetProtectFlag(true);
+ pSh->Insert("."); // Dummytext to allocate the Section
+ pSh->SttDoc();
+ pSh->EndDoc(sal_True); // Select everything in the frame
+ pSh->InsertSection(aSect);
+ }
+ pSh->Pop( sal_False );
+ }
+ }
+ }
+ else
+ {
+ pFirstFlyFmt = bLabel ?
+ lcl_InsertLabText( *pSh, rItem, *pFmt, *pFldMgr,
+ static_cast< sal_uInt16 >(rItem.nCol - 1),
+ static_cast< sal_uInt16 >(rItem.nRow - 1), sal_True ) :
+ lcl_InsertBCText(*pSh, rItem, *pFmt,
+ static_cast< sal_uInt16 >(rItem.nCol - 1),
+ static_cast< sal_uInt16 >(rItem.nRow - 1));
+ }
+
+ //fill the user fields
+ if(!bLabel)
+ {
+ uno::Reference< frame::XModel > xModel = pSh->GetView().GetDocShell()->GetBaseModel();
+ OSL_ENSURE(pDialogFactory, "SwAbstractDialogFactory fail!");
+ SwLabDlgMethod SwLabDlgUpdateFieldInformation = pDialogFactory->GetSwLabDlgStaticMethod ();
+ SwLabDlgUpdateFieldInformation(xModel, rItem);
+ }
+
+ pFldMgr->SetEvalExpFlds(sal_True);
+ pFldMgr->EvalExpFlds(pSh);
+
+ pFldMgr.reset();
+
+ if (pFirstFlyFmt)
+ pSh->GotoFly(pFirstFlyFmt->GetName(), FLYCNTTYPE_ALL, sal_False);
+
+ pSh->EndAllAction();
+ pSh->DoUndo( sal_True );
+ }
+
+ if( rItem.aWriting.indexOf( '<' ) >= 0 )
+ {
+ // Open database browser on recently used database
+ ShowDBObj( *pNewView, pSh->GetDBData() );
+ }
+
+ if( rItem.bSynchron )
+ {
+ SfxDispatcher* pDisp = pViewFrame->GetDispatcher();
+ OSL_ENSURE(pDisp, "No dispatcher in frame?");
+ pDisp->Execute(FN_SYNC_LABELS, SFX_CALLMODE_ASYNCHRON);
+ }
+ rReq.SetReturnValue(SfxVoidItem(bLabel ? FN_LABEL : FN_BUSINESS_CARD));
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/app/appopt.cxx b/sw/source/core/uibase/app/appopt.cxx
new file mode 100644
index 000000000000..3658dfa6c0d1
--- /dev/null
+++ b/sw/source/core/uibase/app/appopt.cxx
@@ -0,0 +1,560 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <cmdid.h>
+
+#include <com/sun/star/i18n/ScriptType.hpp>
+
+#include <hintids.hxx>
+#include <vcl/msgbox.hxx>
+#include <svl/eitem.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/printer.hxx>
+#include <sfx2/htmlmode.hxx>
+#include <sfx2/bindings.hxx>
+#include <editeng/brushitem.hxx>
+#include <editeng/tstpitem.hxx>
+#include <svx/optgrid.hxx>
+#include <svx/svxdlg.hxx>
+#include <svx/dialogs.hrc>
+#include <i18nlangtag/mslangid.hxx>
+#include <i18nlangtag/languagetag.hxx>
+#include <fontcfg.hxx>
+#include <optload.hxx>
+#include <optcomp.hxx>
+#include <edtwin.hxx>
+#include <swmodule.hxx>
+#include <view.hxx>
+#include <doc.hxx>
+#include <wrtsh.hxx>
+#include <IDocumentDeviceAccess.hxx>
+#include <uitool.hxx>
+#include <initui.hxx>
+#include <fldbas.hxx>
+#include <wview.hxx>
+#include <cfgitems.hxx>
+#include <prtopt.hxx>
+#include <pview.hxx>
+#include <usrpref.hxx>
+#include <modcfg.hxx>
+#include <glosdoc.hxx>
+#include <uiitems.hxx>
+#include <editeng/langitem.hxx>
+#include <unotools/lingucfg.hxx>
+#include <editeng/unolingu.hxx>
+#include <globals.hrc>
+#include <globals.h>
+#include <svl/slstitm.hxx>
+#include "swabstdlg.hxx"
+#include <swwrtshitem.hxx>
+
+#include <unomid.h>
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+
+SfxItemSet* SwModule::CreateItemSet( sal_uInt16 nId )
+{
+ bool bTextDialog = (nId == SID_SW_EDITOPTIONS);
+
+ // the options for the Web- and Textdialog are put together here
+ SwViewOption aViewOpt = *GetUsrPref(!bTextDialog);
+ SwMasterUsrPref* pPref = bTextDialog ? pUsrPref : pWebUsrPref;
+ // no MakeUsrPref, because only options from textdoks can be used here
+ SwView* pAppView = GetView();
+ if(pAppView && pAppView->GetViewFrame() != SfxViewFrame::Current())
+ pAppView = 0;
+ if(pAppView)
+ {
+ // if Text then no WebView and vice versa
+ bool bWebView = 0 != PTR_CAST(SwWebView, pAppView);
+ if( (bWebView && !bTextDialog) ||(!bWebView && bTextDialog))
+ {
+ aViewOpt = *pAppView->GetWrtShell().GetViewOptions();
+ }
+ else
+ pAppView = 0; // with View, there's nothing to win here
+ }
+
+ // Options/Edit
+ SfxItemSet* pRet = new SfxItemSet (GetPool(), FN_PARAM_DOCDISP, FN_PARAM_ELEM,
+ SID_PRINTPREVIEW, SID_PRINTPREVIEW,
+ SID_ATTR_GRID_OPTIONS, SID_ATTR_GRID_OPTIONS,
+ FN_PARAM_PRINTER, FN_PARAM_STDFONTS,
+ FN_PARAM_WRTSHELL, FN_PARAM_WRTSHELL,
+ FN_PARAM_ADDPRINTER, FN_PARAM_ADDPRINTER,
+ SID_ATTR_METRIC, SID_ATTR_METRIC,
+ SID_ATTR_APPLYCHARUNIT, SID_ATTR_APPLYCHARUNIT,
+ SID_ATTR_DEFTABSTOP, SID_ATTR_DEFTABSTOP,
+ RES_BACKGROUND, RES_BACKGROUND,
+ SID_HTML_MODE, SID_HTML_MODE,
+ FN_PARAM_SHADOWCURSOR, FN_PARAM_SHADOWCURSOR,
+ FN_PARAM_CRSR_IN_PROTECTED, FN_PARAM_CRSR_IN_PROTECTED,
+ FN_HSCROLL_METRIC, FN_VSCROLL_METRIC,
+ SID_ATTR_LANGUAGE, SID_ATTR_LANGUAGE,
+ SID_ATTR_CHAR_CJK_LANGUAGE, SID_ATTR_CHAR_CJK_LANGUAGE,
+ SID_ATTR_CHAR_CTL_LANGUAGE, SID_ATTR_CHAR_CTL_LANGUAGE,
+#if OSL_DEBUG_LEVEL > 1
+ FN_PARAM_SWTEST, FN_PARAM_SWTEST,
+#endif
+ 0);
+
+ pRet->Put( SwDocDisplayItem( aViewOpt, FN_PARAM_DOCDISP) );
+ pRet->Put( SwElemItem( aViewOpt, FN_PARAM_ELEM) );
+ if( bTextDialog )
+ {
+ pRet->Put( SwShadowCursorItem( aViewOpt, FN_PARAM_SHADOWCURSOR ));
+ pRet->Put( SfxBoolItem(FN_PARAM_CRSR_IN_PROTECTED, aViewOpt.IsCursorInProtectedArea()));
+ }
+
+ if( pAppView )
+ {
+ SwWrtShell& rWrtShell = pAppView->GetWrtShell();
+
+ SfxPrinter* pPrt = rWrtShell.getIDocumentDeviceAccess()->getPrinter( false );
+ if( pPrt )
+ pRet->Put(SwPtrItem(FN_PARAM_PRINTER, pPrt));
+ pRet->Put(SwPtrItem(FN_PARAM_WRTSHELL, &rWrtShell));
+
+ pRet->Put((const SvxLanguageItem&)
+ rWrtShell.GetDefault(RES_CHRATR_LANGUAGE), SID_ATTR_LANGUAGE);
+
+ pRet->Put((const SvxLanguageItem&)
+ rWrtShell.GetDefault(RES_CHRATR_CJK_LANGUAGE), SID_ATTR_CHAR_CJK_LANGUAGE);
+
+ pRet->Put((const SvxLanguageItem&)
+ rWrtShell.GetDefault(RES_CHRATR_CTL_LANGUAGE), SID_ATTR_CHAR_CTL_LANGUAGE);
+ }
+ else
+ {
+ SvtLinguConfig aLinguCfg;
+ com::sun::star::lang::Locale aLocale;
+ LanguageType nLang;
+
+ using namespace ::com::sun::star::i18n::ScriptType;
+
+ Any aLang = aLinguCfg.GetProperty(OUString("DefaultLocale"));
+ aLang >>= aLocale;
+ nLang = MsLangId::resolveSystemLanguageByScriptType(LanguageTag::convertToLanguageType( aLocale, false), LATIN);
+ pRet->Put(SvxLanguageItem(nLang, SID_ATTR_LANGUAGE));
+
+ aLang = aLinguCfg.GetProperty(OUString("DefaultLocale_CJK"));
+ aLang >>= aLocale;
+ nLang = MsLangId::resolveSystemLanguageByScriptType(LanguageTag::convertToLanguageType( aLocale, false), ASIAN);
+ pRet->Put(SvxLanguageItem(nLang, SID_ATTR_CHAR_CJK_LANGUAGE));
+
+ aLang = aLinguCfg.GetProperty(OUString("DefaultLocale_CTL"));
+ aLang >>= aLocale;
+ nLang = MsLangId::resolveSystemLanguageByScriptType(LanguageTag::convertToLanguageType( aLocale, false), COMPLEX);
+ pRet->Put(SvxLanguageItem(nLang, SID_ATTR_CHAR_CTL_LANGUAGE));
+ }
+ if(bTextDialog)
+ pRet->Put(SwPtrItem(FN_PARAM_STDFONTS, GetStdFontConfig()));
+ if( PTR_CAST( SwPagePreview, SfxViewShell::Current())!=0)
+ {
+ SfxBoolItem aBool(SfxBoolItem(SID_PRINTPREVIEW, true));
+ pRet->Put(aBool);
+ }
+
+ FieldUnit eUnit = pPref->GetHScrollMetric();
+ if(pAppView)
+ pAppView->GetHRulerMetric(eUnit);
+ pRet->Put(SfxUInt16Item( FN_HSCROLL_METRIC, static_cast< sal_uInt16 >(eUnit)));
+
+ eUnit = pPref->GetVScrollMetric();
+ if(pAppView)
+ pAppView->GetVRulerMetric(eUnit);
+ pRet->Put(SfxUInt16Item( FN_VSCROLL_METRIC, static_cast< sal_uInt16 >(eUnit) ));
+ pRet->Put(SfxUInt16Item( SID_ATTR_METRIC, static_cast< sal_uInt16 >(pPref->GetMetric()) ));
+ pRet->Put(SfxBoolItem(SID_ATTR_APPLYCHARUNIT, pPref->IsApplyCharUnit()));
+ if(bTextDialog)
+ {
+ if(pAppView)
+ {
+ const SvxTabStopItem& rDefTabs =
+ (const SvxTabStopItem&)pAppView->GetWrtShell().
+ GetDefault(RES_PARATR_TABSTOP);
+ pRet->Put( SfxUInt16Item( SID_ATTR_DEFTABSTOP, (sal_uInt16)::GetTabDist(rDefTabs)));
+ }
+ else
+ pRet->Put(SfxUInt16Item( SID_ATTR_DEFTABSTOP, (sal_uInt16)pPref->GetDefTab()));
+ }
+
+ // Options for GridTabPage
+ SvxGridItem aGridItem( SID_ATTR_GRID_OPTIONS);
+
+ aGridItem.SetUseGridSnap( aViewOpt.IsSnap());
+ aGridItem.SetSynchronize( aViewOpt.IsSynchronize());
+ aGridItem.SetGridVisible( aViewOpt.IsGridVisible());
+
+ const Size& rSnapSize = aViewOpt.GetSnapSize();
+ aGridItem.SetFldDrawX( (sal_uInt16) (rSnapSize.Width() ));
+ aGridItem.SetFldDrawY( (sal_uInt16) (rSnapSize.Height()));
+
+ aGridItem.SetFldDivisionX( aViewOpt.GetDivisionX());
+ aGridItem.SetFldDivisionY( aViewOpt.GetDivisionY());
+
+ pRet->Put(aGridItem);
+
+ // Options for PrintTabPage
+ const SwPrintData* pOpt = pAppView ?
+ &pAppView->GetWrtShell().getIDocumentDeviceAccess()->getPrintData() :
+ 0;
+
+ if(!pOpt)
+ pOpt = GetPrtOptions(!bTextDialog);
+
+ SwAddPrinterItem aAddPrinterItem (FN_PARAM_ADDPRINTER, *pOpt );
+ pRet->Put(aAddPrinterItem);
+
+ // Options for Web background
+ if(!bTextDialog)
+ {
+ pRet->Put(SvxBrushItem(aViewOpt.GetRetoucheColor(), RES_BACKGROUND));
+ }
+
+ if(!bTextDialog)
+ pRet->Put(SfxUInt16Item(SID_HTML_MODE, HTMLMODE_ON));
+ return pRet;
+}
+
+void SwModule::ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet )
+{
+ bool bTextDialog = nId == SID_SW_EDITOPTIONS;
+ SwView* pAppView = GetView();
+ if(pAppView && pAppView->GetViewFrame() != SfxViewFrame::Current())
+ pAppView = 0;
+ if(pAppView)
+ {
+ // the text dialog mustn't apply data to the web view and vice versa
+ bool bWebView = 0 != PTR_CAST(SwWebView, pAppView);
+ if(bWebView == bTextDialog)
+ pAppView = 0;
+ }
+
+ SwViewOption aViewOpt = *GetUsrPref(!bTextDialog);
+ SwMasterUsrPref* pPref = bTextDialog ? pUsrPref : pWebUsrPref;
+
+ const SfxPoolItem* pItem;
+ SfxBindings *pBindings = pAppView ? &pAppView->GetViewFrame()->GetBindings()
+ : NULL;
+
+ // Interpret the page Documentview
+ if( SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_DOCDISP, false, &pItem ))
+ {
+ const SwDocDisplayItem* pDocDispItem = (const SwDocDisplayItem*)pItem;
+
+ if(!aViewOpt.IsViewMetaChars())
+ {
+ if( (!aViewOpt.IsTab( sal_True ) && pDocDispItem->bTab) ||
+ (!aViewOpt.IsBlank( sal_True ) && pDocDispItem->bSpace) ||
+ (!aViewOpt.IsParagraph( sal_True ) && pDocDispItem->bParagraphEnd) ||
+ (!aViewOpt.IsLineBreak( sal_True ) && pDocDispItem->bManualBreak) )
+ {
+ aViewOpt.SetViewMetaChars(sal_True);
+ if(pBindings)
+ pBindings->Invalidate(FN_VIEW_META_CHARS);
+ }
+
+ }
+ pDocDispItem->FillViewOptions( aViewOpt );
+ if(pBindings)
+ {
+ pBindings->Invalidate(FN_VIEW_GRAPHIC);
+ pBindings->Invalidate(FN_VIEW_HIDDEN_PARA);
+ }
+ }
+
+ // Elements - interpret Item
+ if( SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_ELEM, false, &pItem ) )
+ {
+ const SwElemItem* pElemItem = (const SwElemItem*)pItem;
+ pElemItem->FillViewOptions( aViewOpt );
+
+ }
+
+ if( SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_METRIC, false, &pItem ) )
+ {
+ SFX_APP()->SetOptions(rSet);
+ PutItem(*pItem);
+ const SfxUInt16Item* pMetricItem = (const SfxUInt16Item*)pItem;
+ ::SetDfltMetric((FieldUnit)pMetricItem->GetValue(), !bTextDialog);
+ }
+ if( SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_APPLYCHARUNIT,
+ false, &pItem ) )
+ {
+ SFX_APP()->SetOptions(rSet);
+ const SfxBoolItem* pCharItem = (const SfxBoolItem*)pItem;
+ ::SetApplyCharUnit(pCharItem->GetValue(), !bTextDialog);
+ }
+
+ if( SFX_ITEM_SET == rSet.GetItemState(FN_HSCROLL_METRIC, false, &pItem ) )
+ {
+ const SfxUInt16Item* pMetricItem = (const SfxUInt16Item*)pItem;
+ FieldUnit eUnit = (FieldUnit)pMetricItem->GetValue();
+ pPref->SetHScrollMetric(eUnit);
+ if(pAppView)
+ pAppView->ChangeTabMetric(eUnit);
+ }
+
+ if( SFX_ITEM_SET == rSet.GetItemState(FN_VSCROLL_METRIC, false, &pItem ) )
+ {
+ const SfxUInt16Item* pMetricItem = (const SfxUInt16Item*)pItem;
+ FieldUnit eUnit = (FieldUnit)pMetricItem->GetValue();
+ pPref->SetVScrollMetric(eUnit);
+ if(pAppView)
+ pAppView->ChangeVRulerMetric(eUnit);
+ }
+
+ if( SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_DEFTABSTOP, false, &pItem ) )
+ {
+ sal_uInt16 nTabDist = ((const SfxUInt16Item*)pItem)->GetValue();
+ pPref->SetDefTab(nTabDist);
+ if(pAppView)
+ {
+ SvxTabStopItem aDefTabs( 0, 0, SVX_TAB_ADJUST_DEFAULT, RES_PARATR_TABSTOP );
+ MakeDefTabs( nTabDist, aDefTabs );
+ pAppView->GetWrtShell().SetDefault( aDefTabs );
+ }
+ }
+
+ // Background only in WebDialog
+ if(SFX_ITEM_SET == rSet.GetItemState(RES_BACKGROUND))
+ {
+ const SvxBrushItem& rBrushItem = (const SvxBrushItem&)rSet.Get(
+ RES_BACKGROUND);
+ aViewOpt.SetRetoucheColor( rBrushItem.GetColor() );
+ }
+
+ // Interpret page Grid Settings
+ if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_GRID_OPTIONS, false, &pItem ))
+ {
+ const SvxGridItem* pGridItem = (const SvxGridItem*)pItem;
+
+ aViewOpt.SetSnap( pGridItem->GetUseGridSnap() );
+ aViewOpt.SetSynchronize(pGridItem->GetSynchronize());
+ if( aViewOpt.IsGridVisible() != pGridItem->GetGridVisible() )
+ aViewOpt.SetGridVisible( pGridItem->GetGridVisible());
+ Size aSize = Size( pGridItem->GetFldDrawX() ,
+ pGridItem->GetFldDrawY() );
+ if( aViewOpt.GetSnapSize() != aSize )
+ aViewOpt.SetSnapSize( aSize );
+ short nDiv = (short)pGridItem->GetFldDivisionX() ;
+ if( aViewOpt.GetDivisionX() != nDiv )
+ aViewOpt.SetDivisionX( nDiv );
+ nDiv = (short)pGridItem->GetFldDivisionY();
+ if( aViewOpt.GetDivisionY() != nDiv )
+ aViewOpt.SetDivisionY( nDiv );
+
+ if(pBindings)
+ {
+ pBindings->Invalidate(SID_GRID_VISIBLE);
+ pBindings->Invalidate(SID_GRID_USE);
+ }
+ }
+
+ // Interpret Writer Printer Options
+ if( SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_ADDPRINTER, false, &pItem ))
+ {
+ SwPrintOptions* pOpt = GetPrtOptions(!bTextDialog);
+ if (pOpt)
+ {
+ const SwAddPrinterItem* pAddPrinterAttr = (const SwAddPrinterItem*)pItem;
+ *pOpt = *pAddPrinterAttr;
+
+ if(pAppView)
+ pAppView->GetWrtShell().getIDocumentDeviceAccess()->setPrintData( *pOpt );
+ }
+
+ }
+
+ if( SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_SHADOWCURSOR, false, &pItem ))
+ {
+ ((SwShadowCursorItem*)pItem)->FillViewOptions( aViewOpt );
+ if(pBindings)
+ pBindings->Invalidate(FN_SHADOWCURSOR);
+ }
+
+ if( pAppView )
+ {
+ SwWrtShell &rWrtSh = pAppView->GetWrtShell();
+ const bool bAlignFormulas = rWrtSh.GetDoc()->get( IDocumentSettingAccess::MATH_BASELINE_ALIGNMENT );
+ pPref->SetAlignMathObjectsToBaseline( bAlignFormulas );
+
+ // don't align formulas in documents that are currently loading
+ if (bAlignFormulas && !rWrtSh.GetDoc()->IsInReading())
+ rWrtSh.AlignAllFormulasToBaseline();
+ }
+
+ if( SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_CRSR_IN_PROTECTED, false, &pItem ))
+ {
+ aViewOpt.SetCursorInProtectedArea(((const SfxBoolItem*)pItem)->GetValue());
+ }
+
+ // set elements for the current view and shell
+ ApplyUsrPref( aViewOpt, pAppView, bTextDialog? VIEWOPT_DEST_TEXT : VIEWOPT_DEST_WEB);
+}
+
+SfxTabPage* SwModule::CreateTabPage( sal_uInt16 nId, Window* pParent, const SfxItemSet& rSet )
+{
+ SfxTabPage* pRet = NULL;
+ SfxAllItemSet aSet(*(rSet.GetPool()));
+ switch( nId )
+ {
+ case RID_SW_TP_CONTENT_OPT:
+ case RID_SW_TP_HTML_CONTENT_OPT:
+ {
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ if ( pFact )
+ {
+ ::CreateTabPage fnCreatePage = pFact->GetTabPageCreatorFunc( nId );
+ if ( fnCreatePage )
+ pRet = (*fnCreatePage)( pParent, rSet );
+ }
+ break;
+ }
+ case RID_SW_TP_HTML_OPTGRID_PAGE:
+ case RID_SVXPAGE_GRID:
+ pRet = SvxGridTabPage::Create(pParent, rSet);
+ break;
+
+ case RID_SW_TP_STD_FONT:
+ case RID_SW_TP_STD_FONT_CJK:
+ case RID_SW_TP_STD_FONT_CTL:
+ {
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ if ( pFact )
+ {
+ ::CreateTabPage fnCreatePage = pFact->GetTabPageCreatorFunc( nId );
+ if ( fnCreatePage )
+ pRet = (*fnCreatePage)( pParent, rSet );
+ }
+ if(RID_SW_TP_STD_FONT != nId)
+ {
+ aSet.Put (SfxUInt16Item(SID_FONTMODE_TYPE, RID_SW_TP_STD_FONT_CJK == nId ? FONT_GROUP_CJK : FONT_GROUP_CTL));
+ pRet->PageCreated(aSet);
+ }
+ }
+ break;
+ case RID_SW_TP_HTML_OPTPRINT_PAGE:
+ case RID_SW_TP_OPTPRINT_PAGE:
+ {
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ if ( pFact )
+ {
+ ::CreateTabPage fnCreatePage = pFact->GetTabPageCreatorFunc( nId );
+ if ( fnCreatePage )
+ pRet = (*fnCreatePage)( pParent, rSet );
+ }
+ aSet.Put (SfxBoolItem(SID_FAX_LIST, true));
+ pRet->PageCreated(aSet);
+ }
+ break;
+ case RID_SW_TP_HTML_OPTTABLE_PAGE:
+ case RID_SW_TP_OPTTABLE_PAGE:
+ {
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ if ( pFact )
+ {
+ ::CreateTabPage fnCreatePage = pFact->GetTabPageCreatorFunc( nId );
+ if ( fnCreatePage )
+ pRet = (*fnCreatePage)( pParent, rSet );
+ }
+ SwView* pCurrView = GetView();
+ if(pCurrView)
+ {
+ // if text then not WebView and vice versa
+ bool bWebView = 0 != PTR_CAST(SwWebView, pCurrView);
+ if( (bWebView && RID_SW_TP_HTML_OPTTABLE_PAGE == nId) ||
+ (!bWebView && RID_SW_TP_HTML_OPTTABLE_PAGE != nId) )
+ {
+ aSet.Put (SwWrtShellItem(SID_WRT_SHELL,pCurrView->GetWrtShellPtr()));
+ pRet->PageCreated(aSet);
+ }
+ }
+ }
+ break;
+ case RID_SW_TP_OPTSHDWCRSR:
+ case RID_SW_TP_HTML_OPTSHDWCRSR:
+ case RID_SW_TP_REDLINE_OPT:
+ case RID_SW_TP_COMPARISON_OPT:
+ case RID_SW_TP_OPTLOAD_PAGE:
+ case RID_SW_TP_OPTCOMPATIBILITY_PAGE:
+ case RID_SW_TP_MAILCONFIG:
+ {
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ if ( pFact )
+ {
+ ::CreateTabPage fnCreatePage = pFact->GetTabPageCreatorFunc( nId );
+ if ( fnCreatePage )
+ pRet = (*fnCreatePage)( pParent, rSet );
+ }
+ if (pRet && (nId == RID_SW_TP_OPTSHDWCRSR || nId == RID_SW_TP_HTML_OPTSHDWCRSR))
+ {
+ SwView* pCurrView = GetView();
+ if(pCurrView)
+ {
+ aSet.Put( SwWrtShellItem( SID_WRT_SHELL, pCurrView->GetWrtShellPtr() ) );
+ pRet->PageCreated(aSet);
+ }
+ }
+ }
+ break;
+ case RID_SW_TP_OPTTEST_PAGE:
+ {
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ if ( pFact )
+ {
+ ::CreateTabPage fnCreatePage = pFact->GetTabPageCreatorFunc( nId );
+ if ( fnCreatePage )
+ pRet = (*fnCreatePage)( pParent, rSet );
+ }
+ break;
+ }
+ case RID_SW_TP_BACKGROUND:
+ {
+ SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
+ if ( pFact )
+ {
+ ::CreateTabPage fnCreatePage = pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND );
+ if ( fnCreatePage )
+ pRet = (*fnCreatePage)( pParent, rSet );
+ }
+ break;
+ }
+ case RID_SW_TP_OPTCAPTION_PAGE:
+ {
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ if ( pFact )
+ {
+ ::CreateTabPage fnCreatePage = pFact->GetTabPageCreatorFunc( RID_SW_TP_OPTCAPTION_PAGE );
+ if ( fnCreatePage )
+ pRet = (*fnCreatePage)( pParent, rSet );
+ }
+ }
+ break;
+ }
+
+ if(!pRet)
+ SAL_WARN( "sw", "SwModule::CreateTabPage(): Unknown tabpage id " << nId );
+ return pRet;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/app/docsh.cxx b/sw/source/core/uibase/app/docsh.cxx
new file mode 100644
index 000000000000..875e91cc965b
--- /dev/null
+++ b/sw/source/core/uibase/app/docsh.cxx
@@ -0,0 +1,1327 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <hintids.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/wrkwin.hxx>
+#include <vcl/jobset.hxx>
+#include <svl/whiter.hxx>
+#include <svl/zforlist.hxx>
+#include <svl/eitem.hxx>
+#include <svl/stritem.hxx>
+#include <svl/PasswordHelper.hxx>
+#include <editeng/adjustitem.hxx>
+#include <basic/sbx.hxx>
+#include <unotools/moduleoptions.hxx>
+#include <unotools/misccfg.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/passwd.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/evntconf.hxx>
+#include <sfx2/docfilt.hxx>
+#include <sfx2/printer.hxx>
+#include <sfx2/linkmgr.hxx>
+#include <svl/srchitem.hxx>
+#include <editeng/flstitem.hxx>
+#include <sfx2/htmlmode.hxx>
+#include <svtools/soerr.hxx>
+#include <comphelper/classids.hxx>
+#include <basic/basmgr.hxx>
+#include <basic/sbmod.hxx>
+#include <swevent.hxx>
+#include <fmtpdsc.hxx>
+#include <fmtfsize.hxx>
+#include <fmtfld.hxx>
+#include <node.hxx>
+#include <swwait.hxx>
+#include <printdata.hxx>
+#include <frmatr.hxx>
+#include <view.hxx>
+#include <edtwin.hxx>
+#include <PostItMgr.hxx>
+#include <wrtsh.hxx>
+#include <docsh.hxx>
+#include <basesh.hxx>
+#include <viewopt.hxx>
+#include <wdocsh.hxx>
+#include <swmodule.hxx>
+#include <globdoc.hxx>
+#include <usrpref.hxx>
+#include <shellio.hxx>
+#include <docstyle.hxx>
+#include <doc.hxx>
+#include <IDocumentUndoRedo.hxx>
+#include <docstat.hxx>
+#include <pagedesc.hxx>
+#include <pview.hxx>
+#include <mdiexp.hxx>
+#include <swbaslnk.hxx>
+#include <srcview.hxx>
+#include <ndindex.hxx>
+#include <ndole.hxx>
+#include <swcli.hxx>
+#include <txtftn.hxx>
+#include <ftnidx.hxx>
+#include <fldbas.hxx>
+#include <docary.hxx>
+#include <swerror.h>
+#include <helpid.h>
+#include <cmdid.h>
+#include <globals.hrc>
+#include <app.hrc>
+
+#include <cfgid.h>
+#include <unotools/fltrcfg.hxx>
+#include <svtools/htmlcfg.hxx>
+#include <sfx2/fcontnr.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/objface.hxx>
+#include <comphelper/storagehelper.hxx>
+
+#define SwDocShell
+#include <sfx2/msg.hxx>
+#include <swslots.hxx>
+#include <com/sun/star/document/UpdateDocMode.hpp>
+
+#include <com/sun/star/document/XDocumentProperties.hpp>
+#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
+
+#include <unomid.h>
+#include <unotextrange.hxx>
+
+#include <sfx2/Metadatable.hxx>
+#include <switerator.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::script;
+using namespace ::com::sun::star::container;
+
+SFX_IMPL_INTERFACE( SwDocShell, SfxObjectShell, SW_RES(0) )
+{
+}
+
+TYPEINIT2(SwDocShell, SfxObjectShell, SfxListener);
+
+SFX_IMPL_OBJECTFACTORY(SwDocShell, SvGlobalName(SO3_SW_CLASSID), SFXOBJECTSHELL_STD_NORMAL|SFXOBJECTSHELL_HASMENU, "swriter" )
+
+bool SwDocShell::InsertGeneratedStream(SfxMedium & rMedium,
+ uno::Reference<text::XTextRange> const& xInsertPosition)
+{
+ SwUnoInternalPaM aPam(*GetDoc()); // must have doc since called from SwView
+ if (!::sw::XTextRangeToSwPaM(aPam, xInsertPosition))
+ return false;
+ // similar to SwView::InsertMedium
+ SwReader *pReader(0);
+ Reader *const pRead = StartConvertFrom(rMedium, &pReader, 0, &aPam);
+ if (!pRead)
+ return false;
+ sal_uLong const nError = pReader->Read(*pRead);
+ delete pReader;
+ return 0 == nError;
+}
+
+// Prepare loading
+Reader* SwDocShell::StartConvertFrom(SfxMedium& rMedium, SwReader** ppRdr,
+ SwCrsrShell *pCrsrShell,
+ SwPaM* pPaM )
+{
+ sal_Bool bAPICall = sal_False;
+ const SfxPoolItem* pApiItem;
+ const SfxItemSet* pMedSet;
+ if( 0 != ( pMedSet = rMedium.GetItemSet() ) && SFX_ITEM_SET ==
+ pMedSet->GetItemState( FN_API_CALL, true, &pApiItem ) )
+ bAPICall = ((const SfxBoolItem*)pApiItem)->GetValue();
+
+ const SfxFilter* pFlt = rMedium.GetFilter();
+ if( !pFlt )
+ {
+ if(!bAPICall)
+ {
+ InfoBox( 0, SW_RESSTR(STR_CANTOPEN)).Execute();
+ }
+ return 0;
+ }
+ OUString aFileName( rMedium.GetName() );
+ SwRead pRead = SwReaderWriter::GetReader( pFlt->GetUserData() );
+ if( !pRead )
+ return 0;
+
+ if( rMedium.IsStorage()
+ ? SW_STORAGE_READER & pRead->GetReaderType()
+ : SW_STREAM_READER & pRead->GetReaderType() )
+ {
+ *ppRdr = pPaM ? new SwReader( rMedium, aFileName, *pPaM ) :
+ pCrsrShell ?
+ new SwReader( rMedium, aFileName, *pCrsrShell->GetCrsr() )
+ : new SwReader( rMedium, aFileName, pDoc );
+ }
+ else
+ return 0;
+
+ // Check password
+ OUString aPasswd;
+ if ((*ppRdr)->NeedsPasswd( *pRead ))
+ {
+ if(!bAPICall)
+ {
+ SfxPasswordDialog* pPasswdDlg =
+ new SfxPasswordDialog( 0 );
+ if(RET_OK == pPasswdDlg->Execute())
+ aPasswd = pPasswdDlg->GetPassword();
+ }
+ else
+ {
+ const SfxItemSet* pSet = rMedium.GetItemSet();
+ const SfxPoolItem *pPassItem;
+ if(pSet && SFX_ITEM_SET == pSet->GetItemState(SID_PASSWORD, true, &pPassItem))
+ aPasswd = ((const SfxStringItem *)pPassItem)->GetValue();
+ }
+
+ if (!(*ppRdr)->CheckPasswd( aPasswd, *pRead ))
+ {
+ InfoBox( 0, SW_RES(MSG_ERROR_PASSWD)).Execute();
+ delete *ppRdr;
+ return 0;
+ }
+ }
+
+ // #i30171# set the UpdateDocMode at the SwDocShell
+ SFX_ITEMSET_ARG( rMedium.GetItemSet(), pUpdateDocItem, SfxUInt16Item, SID_UPDATEDOCMODE, false);
+ nUpdateDocMode = pUpdateDocItem ? pUpdateDocItem->GetValue() : document::UpdateDocMode::NO_UPDATE;
+
+ if (!pFlt->GetDefaultTemplate().isEmpty())
+ pRead->SetTemplateName( pFlt->GetDefaultTemplate() );
+
+ if( pRead == ReadAscii && 0 != rMedium.GetInStream() &&
+ pFlt->GetUserData() == FILTER_TEXT_DLG )
+ {
+ SwAsciiOptions aOpt;
+ const SfxItemSet* pSet;
+ const SfxPoolItem* pItem;
+ if( 0 != ( pSet = rMedium.GetItemSet() ) && SFX_ITEM_SET ==
+ pSet->GetItemState( SID_FILE_FILTEROPTIONS, true, &pItem ) )
+ aOpt.ReadUserData( ((const SfxStringItem*)pItem)->GetValue() );
+
+ if( pRead )
+ pRead->GetReaderOpt().SetASCIIOpts( aOpt );
+ }
+
+ return pRead;
+}
+
+// Loading
+sal_Bool SwDocShell::ConvertFrom( SfxMedium& rMedium )
+{
+ SwReader* pRdr;
+ SwRead pRead = StartConvertFrom(rMedium, &pRdr);
+ if (!pRead)
+ return sal_False; // #129881# return if no reader is found
+ SotStorageRef pStg=pRead->getSotStorageRef(); // #i45333# save sot storage ref in case of recursive calls
+
+ pDoc->setDocAccTitle(OUString());
+ SfxViewFrame* pFrame1 = SfxViewFrame::GetFirst( this );
+ if (pFrame1)
+ {
+ Window* pWindow = &pFrame1->GetWindow();
+ if ( pWindow )
+ {
+ Window* pSysWin = pWindow->GetSystemWindow();
+ if ( pSysWin )
+ {
+ pSysWin->SetAccessibleName(OUString());
+ }
+ }
+ }
+ SwWait aWait( *this, true );
+
+ // Suppress SfxProgress, when we are Embedded
+ SW_MOD()->SetEmbeddedLoadSave(
+ SFX_CREATE_MODE_EMBEDDED == GetCreateMode() );
+
+ pRdr->GetDoc()->set(IDocumentSettingAccess::HTML_MODE, ISA(SwWebDocShell));
+
+ /* #106748# Restore the pool default if reading a saved document. */
+ pDoc->RemoveAllFmtLanguageDependencies();
+
+ sal_uLong nErr = pRdr->Read( *pRead );
+
+ // Maybe put away one old Doc
+ if ( pDoc != pRdr->GetDoc() )
+ {
+ RemoveLink();
+ pDoc = pRdr->GetDoc();
+
+ AddLink();
+
+ if ( !mxBasePool.is() )
+ mxBasePool = new SwDocStyleSheetPool( *pDoc, SFX_CREATE_MODE_ORGANIZER == GetCreateMode() );
+ }
+
+ UpdateFontList();
+ InitDraw();
+
+ delete pRdr;
+
+ SW_MOD()->SetEmbeddedLoadSave( sal_False );
+
+ SetError( nErr, OUString( OSL_LOG_PREFIX ) );
+ sal_Bool bOk = !IsError( nErr );
+
+ if ( bOk && !pDoc->IsInLoadAsynchron() )
+ {
+ LoadingFinished();
+ }
+
+ pRead->setSotStorageRef(pStg); // #i45333# save sot storage ref in case of recursive calls
+
+ return bOk;
+}
+
+// Saving the Default-Format, Stg present
+sal_Bool SwDocShell::Save()
+{
+ //#i3370# remove quick help to prevent saving of autocorrection suggestions
+ if(pView)
+ pView->GetEditWin().StopQuickHelp();
+ SwWait aWait( *this, true );
+
+ CalcLayoutForOLEObjects(); // format for OLE objets
+ // #i62875#
+ // reset compatibility flag <DoNotCaptureDrawObjsOnPage>, if possible
+ if ( pWrtShell && pDoc &&
+ pDoc->get(IDocumentSettingAccess::DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE) &&
+ docfunc::AllDrawObjsOnPage( *pDoc ) )
+ {
+ pDoc->set(IDocumentSettingAccess::DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE, false);
+ }
+
+ sal_uLong nErr = ERR_SWG_WRITE_ERROR, nVBWarning = ERRCODE_NONE;
+ if( SfxObjectShell::Save() )
+ {
+ switch( GetCreateMode() )
+ {
+ case SFX_CREATE_MODE_INTERNAL:
+ nErr = 0;
+ break;
+
+ case SFX_CREATE_MODE_ORGANIZER:
+ {
+ WriterRef xWrt;
+ ::GetXMLWriter( aEmptyOUStr, GetMedium()->GetBaseURL( true ), xWrt );
+ xWrt->SetOrganizerMode( sal_True );
+ SwWriter aWrt( *GetMedium(), *pDoc );
+ nErr = aWrt.Write( xWrt );
+ xWrt->SetOrganizerMode( sal_False );
+ }
+ break;
+
+ case SFX_CREATE_MODE_EMBEDDED:
+ // Suppress SfxProgress, if we are Embedded
+ SW_MOD()->SetEmbeddedLoadSave( sal_True );
+ // no break;
+
+ case SFX_CREATE_MODE_STANDARD:
+ case SFX_CREATE_MODE_PREVIEW:
+ default:
+ {
+ if( pDoc->ContainsMSVBasic() )
+ {
+ if( SvtFilterOptions::Get().IsLoadWordBasicStorage() )
+ nVBWarning = GetSaveWarningOfMSVBAStorage( (SfxObjectShell&) (*this) );
+ pDoc->SetContainsMSVBasic( false );
+ }
+
+ // End TableBox Edit!
+ if( pWrtShell )
+ pWrtShell->EndAllTblBoxEdit();
+
+ WriterRef xWrt;
+ ::GetXMLWriter( aEmptyOUStr, GetMedium()->GetBaseURL( true ), xWrt );
+
+ sal_Bool bLockedView(sal_False);
+ if ( pWrtShell )
+ {
+ bLockedView = pWrtShell->IsViewLocked();
+ pWrtShell->LockView( sal_True ); //lock visible section
+ }
+
+ SwWriter aWrt( *GetMedium(), *pDoc );
+ nErr = aWrt.Write( xWrt );
+
+ if ( pWrtShell )
+ pWrtShell->LockView( bLockedView );
+ }
+ break;
+ }
+ SW_MOD()->SetEmbeddedLoadSave( sal_False );
+ }
+ SetError( nErr ? nErr : nVBWarning, OUString( OSL_LOG_PREFIX ) );
+
+ SfxViewFrame* pFrm = pWrtShell ? pWrtShell->GetView().GetViewFrame() : 0;
+ if( pFrm )
+ {
+ pFrm->GetBindings().SetState(SfxBoolItem(SID_DOC_MODIFIED, false));
+ }
+ return !IsError( nErr );
+}
+
+// Save using the Defaultformat
+sal_Bool SwDocShell::SaveAs( SfxMedium& rMedium )
+{
+ SwWait aWait( *this, true );
+ //#i3370# remove quick help to prevent saving of autocorrection suggestions
+ if(pView)
+ pView->GetEditWin().StopQuickHelp();
+
+ //#i91811# mod if we have an active margin window, write back the text
+ if ( pView &&
+ pView->GetPostItMgr() &&
+ pView->GetPostItMgr()->HasActiveSidebarWin() )
+ {
+ pView->GetPostItMgr()->UpdateDataOnActiveSidebarWin();
+ }
+
+ if( pDoc->get(IDocumentSettingAccess::GLOBAL_DOCUMENT) &&
+ !pDoc->get(IDocumentSettingAccess::GLOBAL_DOCUMENT_SAVE_LINKS) )
+ RemoveOLEObjects();
+
+ {
+ // Task 75666 - is the Document imported by our Microsoft-Filters?
+ const SfxFilter* pOldFilter = GetMedium()->GetFilter();
+ if( pOldFilter &&
+ ( pOldFilter->GetUserData() == FILTER_WW8 ||
+ pOldFilter->GetUserData() == "CWW6" ||
+ pOldFilter->GetUserData() == "WW6" ||
+ pOldFilter->GetUserData() == "WW1" ) )
+ {
+ // when saving it in our own fileformat, then remove the template
+ // name from the docinfo.
+ uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
+ GetModel(), uno::UNO_QUERY_THROW);
+ uno::Reference<document::XDocumentProperties> xDocProps
+ = xDPS->getDocumentProperties();
+ xDocProps->setTemplateName(OUString());
+ xDocProps->setTemplateURL(OUString());
+ xDocProps->setTemplateDate(::util::DateTime());
+ }
+ }
+
+ CalcLayoutForOLEObjects(); // format for OLE objets
+ // #i62875#
+ // reset compatibility flag <DoNotCaptureDrawObjsOnPage>, if possible
+ if ( pWrtShell &&
+ pDoc->get(IDocumentSettingAccess::DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE) &&
+ docfunc::AllDrawObjsOnPage( *pDoc ) )
+ {
+ pDoc->set(IDocumentSettingAccess::DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE, false);
+ }
+
+ sal_uLong nErr = ERR_SWG_WRITE_ERROR, nVBWarning = ERRCODE_NONE;
+ uno::Reference < embed::XStorage > xStor = rMedium.GetOutputStorage();
+ if( SfxObjectShell::SaveAs( rMedium ) )
+ {
+ if( GetDoc()->get(IDocumentSettingAccess::GLOBAL_DOCUMENT) && !ISA( SwGlobalDocShell ) )
+ {
+ // This is to set the correct class id if SaveAs is
+ // called from SwDoc::SplitDoc to save a normal doc as
+ // global doc. In this case, SaveAs is called at a
+ // normal doc shell, therefore, SfxInplaceObject::SaveAs
+ // will set the wrong class id.
+ SvGlobalName aClassName;
+ // The document is closed explicitly, but using SfxObjectShellLock is still more correct here
+ SfxObjectShellLock xDocSh =
+ new SwGlobalDocShell( SFX_CREATE_MODE_INTERNAL );
+ // the global document can not be a template
+ xDocSh->SetupStorage( xStor, SotStorage::GetVersion( xStor ), sal_False );
+ xDocSh->DoClose();
+ }
+
+ if( pDoc->ContainsMSVBasic() )
+ {
+ if( SvtFilterOptions::Get().IsLoadWordBasicStorage() )
+ nVBWarning = GetSaveWarningOfMSVBAStorage( (SfxObjectShell&) *this );
+ pDoc->SetContainsMSVBasic( false );
+ }
+
+ // End TableBox Edit!
+ if( pWrtShell )
+ pWrtShell->EndAllTblBoxEdit();
+
+ // Remember and preserve Modified-Flag without calling the Link
+ // (for OLE; after Statement from MM)
+ sal_Bool bIsModified = pDoc->IsModified();
+ pDoc->GetIDocumentUndoRedo().LockUndoNoModifiedPosition();
+ Link aOldOLELnk( pDoc->GetOle2Link() );
+ pDoc->SetOle2Link( Link() );
+
+ // Suppress SfxProgress when we are Embedded
+ SW_MOD()->SetEmbeddedLoadSave(
+ SFX_CREATE_MODE_EMBEDDED == GetCreateMode() );
+
+ WriterRef xWrt;
+ ::GetXMLWriter( aEmptyOUStr, rMedium.GetBaseURL( true ), xWrt );
+
+ sal_Bool bLockedView(sal_False);
+ if ( pWrtShell )
+ {
+ bLockedView = pWrtShell->IsViewLocked();
+ pWrtShell->LockView( sal_True ); //lock visible section
+ }
+
+ SwWriter aWrt( rMedium, *pDoc );
+ nErr = aWrt.Write( xWrt );
+
+ if ( pWrtShell )
+ pWrtShell->LockView( bLockedView );
+
+ if( bIsModified )
+ {
+ pDoc->SetModified();
+ pDoc->GetIDocumentUndoRedo().UnLockUndoNoModifiedPosition();
+ }
+ pDoc->SetOle2Link( aOldOLELnk );
+
+ SW_MOD()->SetEmbeddedLoadSave( sal_False );
+
+ // Increase RSID
+ pDoc->setRsid( pDoc->getRsid() );
+ }
+ SetError( nErr ? nErr : nVBWarning, OUString( OSL_LOG_PREFIX ) );
+
+ return !IsError( nErr );
+}
+
+// Save all Formats
+static SwSrcView* lcl_GetSourceView( SwDocShell* pSh )
+{
+ // are we in SourceView?
+ SfxViewFrame* pVFrame = SfxViewFrame::GetFirst( pSh );
+ SfxViewShell* pViewShell = pVFrame ? pVFrame->GetViewShell() : 0;
+ return PTR_CAST( SwSrcView, pViewShell);
+}
+
+sal_Bool SwDocShell::ConvertTo( SfxMedium& rMedium )
+{
+ const SfxFilter* pFlt = rMedium.GetFilter();
+ if( !pFlt )
+ return sal_False;
+
+ WriterRef xWriter;
+ SwReaderWriter::GetWriter( pFlt->GetUserData(), rMedium.GetBaseURL( true ), xWriter );
+ if( !xWriter.Is() )
+ { // Filter not available
+ InfoBox( 0,
+ SW_RESSTR(STR_DLLNOTFOUND) ).Execute();
+ return sal_False;
+ }
+
+ //#i3370# remove quick help to prevent saving of autocorrection suggestions
+ if(pView)
+ pView->GetEditWin().StopQuickHelp();
+
+ //#i91811# mod if we have an active margin window, write back the text
+ if ( pView &&
+ pView->GetPostItMgr() &&
+ pView->GetPostItMgr()->HasActiveSidebarWin() )
+ {
+ pView->GetPostItMgr()->UpdateDataOnActiveSidebarWin();
+ }
+
+ sal_uLong nVBWarning = 0;
+
+ if( pDoc->ContainsMSVBasic() )
+ {
+ sal_Bool bSave = pFlt->GetUserData() == "CWW8"
+ && SvtFilterOptions::Get().IsLoadWordBasicStorage();
+
+ if ( bSave )
+ {
+ SvStorageRef xStg = new SotStorage( rMedium.GetOutStream(), false );
+ OSL_ENSURE( !xStg->GetError(), "No storage available for storing VBA macros!" );
+ if ( !xStg->GetError() )
+ {
+ nVBWarning = SaveOrDelMSVBAStorage( (SfxObjectShell&) *this, *xStg, bSave, OUString("Macros") );
+ xStg->Commit();
+ pDoc->SetContainsMSVBasic( true );
+ }
+ }
+ }
+
+ // End TableBox Edit!
+ if( pWrtShell )
+ pWrtShell->EndAllTblBoxEdit();
+
+ if( pFlt->GetUserData() == "HTML" )
+ {
+#ifndef DISABLE_SCRIPTING
+ SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get();
+ if( !rHtmlOpt.IsStarBasic() && rHtmlOpt.IsStarBasicWarning() && HasBasic() )
+ {
+ uno::Reference< XLibraryContainer > xLibCont(GetBasicContainer(), UNO_QUERY);
+ uno::Reference< XNameAccess > xLib;
+ Sequence<OUString> aNames = xLibCont->getElementNames();
+ const OUString* pNames = aNames.getConstArray();
+ for(sal_Int32 nLib = 0; nLib < aNames.getLength(); nLib++)
+ {
+ Any aLib = xLibCont->getByName(pNames[nLib]);
+ aLib >>= xLib;
+ if(xLib.is())
+ {
+ Sequence<OUString> aModNames = xLib->getElementNames();
+ if(aModNames.getLength())
+ {
+ SetError(WARN_SWG_HTML_NO_MACROS, OUString( OSL_LOG_PREFIX ) );
+ break;
+ }
+ }
+ }
+ }
+#endif
+ UpdateDocInfoForSave();
+ }
+
+ // #i76360# Update document statistics
+ pDoc->UpdateDocStat();
+
+ CalcLayoutForOLEObjects(); // format for OLE objets
+ // #i62875#
+ // reset compatibility flag <DoNotCaptureDrawObjsOnPage>, if possible
+ if ( pWrtShell &&
+ pDoc->get(IDocumentSettingAccess::DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE) &&
+ docfunc::AllDrawObjsOnPage( *pDoc ) )
+ {
+ pDoc->set(IDocumentSettingAccess::DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE, false);
+ }
+
+ if( xWriter->IsStgWriter() &&
+ ( pFlt->GetUserData() == FILTER_XML ||
+ pFlt->GetUserData() == FILTER_XMLV ||
+ pFlt->GetUserData() == FILTER_XMLVW ) )
+ {
+ // determine the own Type
+ sal_uInt8 nMyType = 0;
+ if( ISA( SwWebDocShell) )
+ nMyType = 1;
+ else if( ISA( SwGlobalDocShell) )
+ nMyType = 2;
+
+ // determine the desired Type
+ sal_uInt8 nSaveType = 0;
+ sal_uLong nSaveClipId = pFlt->GetFormat();
+ if( SOT_FORMATSTR_ID_STARWRITERWEB_8 == nSaveClipId ||
+ SOT_FORMATSTR_ID_STARWRITERWEB_60 == nSaveClipId ||
+ SOT_FORMATSTR_ID_STARWRITERWEB_50 == nSaveClipId ||
+ SOT_FORMATSTR_ID_STARWRITERWEB_40 == nSaveClipId )
+ nSaveType = 1;
+ else if( SOT_FORMATSTR_ID_STARWRITERGLOB_8 == nSaveClipId ||
+ SOT_FORMATSTR_ID_STARWRITERGLOB_60 == nSaveClipId ||
+ SOT_FORMATSTR_ID_STARWRITERGLOB_50 == nSaveClipId ||
+ SOT_FORMATSTR_ID_STARWRITERGLOB_40 == nSaveClipId )
+ nSaveType = 2;
+
+ // Change Flags of the Document accordingly
+ sal_Bool bIsHTMLModeSave = GetDoc()->get(IDocumentSettingAccess::HTML_MODE);
+ sal_Bool bIsGlobalDocSave = GetDoc()->get(IDocumentSettingAccess::GLOBAL_DOCUMENT);
+ sal_Bool bIsGlblDocSaveLinksSave = GetDoc()->get(IDocumentSettingAccess::GLOBAL_DOCUMENT_SAVE_LINKS);
+ if( nMyType != nSaveType )
+ {
+ GetDoc()->set(IDocumentSettingAccess::HTML_MODE, 1 == nSaveType);
+ GetDoc()->set(IDocumentSettingAccess::GLOBAL_DOCUMENT, 2 == nSaveType);
+ if( 2 != nSaveType )
+ GetDoc()->set(IDocumentSettingAccess::GLOBAL_DOCUMENT_SAVE_LINKS, false);
+ }
+
+ // if the target format is storage based, then the output storage must be already created
+ if ( rMedium.IsStorage() )
+ {
+ // set MediaType on target storage
+ // (MediaType will be queried during SaveAs)
+ try
+ {
+ // TODO/MBA: testing
+ uno::Reference < beans::XPropertySet > xSet( rMedium.GetStorage(), uno::UNO_QUERY );
+ if ( xSet.is() )
+ xSet->setPropertyValue("MediaType", uno::makeAny( OUString( SotExchange::GetFormatMimeType( nSaveClipId ) ) ) );
+ }
+ catch (const uno::Exception&)
+ {
+ }
+ }
+
+ // Now normally save the Document
+ sal_Bool bRet = SaveAs( rMedium );
+
+ if( nMyType != nSaveType )
+ {
+ GetDoc()->set(IDocumentSettingAccess::HTML_MODE, bIsHTMLModeSave );
+ GetDoc()->set(IDocumentSettingAccess::GLOBAL_DOCUMENT, bIsGlobalDocSave);
+ GetDoc()->set(IDocumentSettingAccess::GLOBAL_DOCUMENT_SAVE_LINKS, bIsGlblDocSaveLinksSave);
+ }
+
+ return bRet;
+ }
+
+ if( pFlt->GetUserData() == FILTER_TEXT_DLG &&
+ ( pWrtShell || !::lcl_GetSourceView( this ) ))
+ {
+ SwAsciiOptions aOpt;
+ OUString sItemOpt;
+ const SfxItemSet* pSet;
+ const SfxPoolItem* pItem;
+ if( 0 != ( pSet = rMedium.GetItemSet() ) )
+ {
+ if( SFX_ITEM_SET == pSet->GetItemState( SID_FILE_FILTEROPTIONS,
+ true, &pItem ) )
+ sItemOpt = ((const SfxStringItem*)pItem)->GetValue();
+ }
+ if(!sItemOpt.isEmpty())
+ aOpt.ReadUserData( sItemOpt );
+
+ xWriter->SetAsciiOptions( aOpt );
+ }
+
+ // Suppress SfxProgress when we are Embedded
+ SW_MOD()->SetEmbeddedLoadSave(
+ SFX_CREATE_MODE_EMBEDDED == GetCreateMode());
+
+ // Span Context in order to suppress the Selection's View
+ sal_uLong nErrno;
+ const OUString aFileName( rMedium.GetName() );
+
+ // No View, so the whole Document!
+ if ( pWrtShell )
+ {
+ SwWait aWait( *this, true );
+ // #i106906#
+ const sal_Bool bFormerLockView = pWrtShell->IsViewLocked();
+ pWrtShell->LockView( sal_True );
+ pWrtShell->StartAllAction();
+ pWrtShell->Push();
+ SwWriter aWrt( rMedium, *pWrtShell, sal_True );
+ nErrno = aWrt.Write( xWriter, &aFileName );
+ //JP 16.05.97: In case the SFX revokes the View while saving
+ if( pWrtShell )
+ {
+ pWrtShell->Pop(sal_False);
+ pWrtShell->EndAllAction();
+ // #i106906#
+ pWrtShell->LockView( bFormerLockView );
+ }
+ }
+ else
+ {
+ // are we in SourceView?
+ SwSrcView* pSrcView = ::lcl_GetSourceView( this );
+ if( pSrcView )
+ {
+ pSrcView->SaveContentTo(rMedium);
+ nErrno = 0;
+ }
+ else
+ {
+ SwWriter aWrt( rMedium, *pDoc );
+ nErrno = aWrt.Write( xWriter, &aFileName );
+ }
+ }
+
+ SW_MOD()->SetEmbeddedLoadSave( sal_False );
+ SetError( nErrno ? nErrno : nVBWarning, OUString( OSL_LOG_PREFIX ) );
+ if( !rMedium.IsStorage() )
+ rMedium.CloseOutStream();
+
+ return !IsError( nErrno );
+}
+
+// Hands off
+// do not yet activate, must deliver TRUE
+sal_Bool SwDocShell::SaveCompleted( const uno::Reference < embed::XStorage >& xStor )
+{
+ sal_Bool bRet = SfxObjectShell::SaveCompleted( xStor );
+ if( bRet )
+ {
+ // Do not decide until here, whether Saving was successful or not
+ if( IsModified() )
+ pDoc->SetModified();
+ else
+ pDoc->ResetModified();
+ }
+
+ if( pOLEChildList )
+ {
+ sal_Bool bResetModified = IsEnableSetModified();
+ if( bResetModified )
+ EnableSetModified( sal_False );
+
+ uno::Sequence < OUString > aNames = pOLEChildList->GetObjectNames();
+ for( sal_Int32 n = aNames.getLength(); n; n-- )
+ {
+ if ( !pOLEChildList->MoveEmbeddedObject( aNames[n-1], GetEmbeddedObjectContainer() ) )
+ {
+ OSL_FAIL("Copying of objects didn't work!" );
+ }
+ }
+
+ DELETEZ( pOLEChildList );
+ if( bResetModified )
+ EnableSetModified( sal_True );
+ }
+ return bRet;
+}
+
+// Draw()-Overload for OLE2 (Sfx)
+void SwDocShell::Draw( OutputDevice* pDev, const JobSetup& rSetup,
+ sal_uInt16 nAspect )
+{
+ //fix #25341# Draw should not affect the Modified
+ sal_Bool bResetModified;
+ if ( sal_True == (bResetModified = IsEnableSetModified()) )
+ EnableSetModified( sal_False );
+
+ // When there is a JobSetup connected to the Document, we copy it to
+ // reconnect it after PrtOle2. We don't use an empty JobSetup because
+ // that would only lead to questionable results after expensive
+ // reformatting (Preview!)
+ JobSetup *pOrig = 0;
+ if ( !rSetup.GetPrinterName().isEmpty() && ASPECT_THUMBNAIL != nAspect )
+ {
+ pOrig = const_cast<JobSetup*>(pDoc->getJobsetup());
+ if( pOrig ) // then we copy that
+ pOrig = new JobSetup( *pOrig );
+ pDoc->setJobsetup( rSetup );
+ }
+
+ Rectangle aRect( nAspect == ASPECT_THUMBNAIL ?
+ GetVisArea( nAspect ) : GetVisArea( ASPECT_CONTENT ) );
+
+ pDev->Push();
+ pDev->SetFillColor();
+ pDev->SetLineColor();
+ pDev->SetBackground();
+ sal_Bool bWeb = 0 != PTR_CAST(SwWebDocShell, this);
+ SwPrintData aOpts;
+ SwViewShell::PrtOle2( pDoc, SW_MOD()->GetUsrPref(bWeb), aOpts, pDev, aRect );
+ pDev->Pop();
+
+ if( pOrig )
+ {
+ pDoc->setJobsetup( *pOrig );
+ delete pOrig;
+ }
+ if ( bResetModified )
+ EnableSetModified( sal_True );
+}
+
+void SwDocShell::SetVisArea( const Rectangle &rRect )
+{
+ Rectangle aRect( rRect );
+ if ( pView )
+ {
+ Size aSz( pView->GetDocSz() );
+ aSz.Width() += DOCUMENTBORDER; aSz.Height() += DOCUMENTBORDER;
+ long nMoveX = 0, nMoveY = 0;
+ if ( aRect.Right() > aSz.Width() )
+ nMoveX = aSz.Width() - aRect.Right();
+ if ( aRect.Bottom() > aSz.Height() )
+ nMoveY = aSz.Height() - aRect.Bottom();
+ aRect.Move( nMoveX, nMoveY );
+ nMoveX = aRect.Left() < 0 ? -aRect.Left() : 0;
+ nMoveY = aRect.Top() < 0 ? -aRect.Top() : 0;
+ aRect.Move( nMoveX, nMoveY );
+
+ // Calls SfxInPlaceObject::SetVisArea()!
+ pView->SetVisArea( aRect, sal_True );
+ }
+ else
+ SfxObjectShell::SetVisArea( aRect );
+}
+
+Rectangle SwDocShell::GetVisArea( sal_uInt16 nAspect ) const
+{
+ if ( nAspect == ASPECT_THUMBNAIL )
+ {
+ // Preview: set VisArea to the first page.
+ SwNodeIndex aIdx( pDoc->GetNodes().GetEndOfExtras(), 1 );
+ SwCntntNode* pNd = pDoc->GetNodes().GoNext( &aIdx );
+
+ const SwRect aPageRect = pNd->FindPageFrmRect( sal_False, 0, sal_False );
+ return aPageRect.SVRect();
+ }
+ return SfxObjectShell::GetVisArea( nAspect );
+}
+
+Printer *SwDocShell::GetDocumentPrinter()
+{
+ return pDoc->getPrinter( false );
+}
+
+OutputDevice* SwDocShell::GetDocumentRefDev()
+{
+ return pDoc->getReferenceDevice( false );
+}
+
+void SwDocShell::OnDocumentPrinterChanged( Printer * pNewPrinter )
+{
+ if ( pNewPrinter )
+ GetDoc()->setJobsetup( pNewPrinter->GetJobSetup() );
+ else
+ GetDoc()->setPrinter( 0, true, true );
+}
+
+sal_uLong SwDocShell::GetMiscStatus() const
+{
+ return SVOBJ_MISCSTATUS_RESIZEONPRINTERCHANGE;
+}
+
+// #i20883# Digital Signatures and Encryption
+sal_uInt16 SwDocShell::GetHiddenInformationState( sal_uInt16 nStates )
+{
+ // get global state like HIDDENINFORMATION_DOCUMENTVERSIONS
+ sal_uInt16 nState = SfxObjectShell::GetHiddenInformationState( nStates );
+
+ if ( nStates & HIDDENINFORMATION_RECORDEDCHANGES )
+ {
+ if ( !GetDoc()->GetRedlineTbl().empty() )
+ nState |= HIDDENINFORMATION_RECORDEDCHANGES;
+ }
+ if ( nStates & HIDDENINFORMATION_NOTES )
+ {
+ OSL_ENSURE( GetWrtShell(), "No SwWrtShell, no information" );
+ if ( GetWrtShell() )
+ {
+ SwFieldType* pType = GetWrtShell()->GetFldType( RES_POSTITFLD, aEmptyOUStr );
+ SwIterator<SwFmtFld,SwFieldType> aIter( *pType );
+ SwFmtFld* pFirst = aIter.First();
+ while( pFirst )
+ {
+ if( pFirst->GetTxtFld() && pFirst->IsFldInDoc() )
+ {
+ nState |= HIDDENINFORMATION_NOTES;
+ break;
+ }
+ pFirst = aIter.Next();
+ }
+ }
+ }
+
+ return nState;
+}
+
+void SwDocShell::GetState(SfxItemSet& rSet)
+{
+ SfxWhichIter aIter(rSet);
+ sal_uInt16 nWhich = aIter.FirstWhich();
+
+ while (nWhich)
+ {
+ switch (nWhich)
+ {
+ case SID_PRINTPREVIEW:
+ {
+ sal_Bool bDisable = IsInPlaceActive();
+ // Disable "multiple layout"
+ if ( !bDisable )
+ {
+ SfxViewFrame *pTmpFrm = SfxViewFrame::GetFirst(this);
+ while (pTmpFrm) // Look for Preview
+ {
+ if ( PTR_CAST(SwView, pTmpFrm->GetViewShell()) &&
+ ((SwView*)pTmpFrm->GetViewShell())->GetWrtShell().GetViewOptions()->getBrowseMode() )
+ {
+ bDisable = sal_True;
+ break;
+ }
+ pTmpFrm = pTmpFrm->GetNext(*pTmpFrm, this);
+ }
+ }
+ // End of disabled "multiple layout"
+ if ( bDisable )
+ rSet.DisableItem( SID_PRINTPREVIEW );
+ else
+ {
+ SfxBoolItem aBool( SID_PRINTPREVIEW, false );
+ if( PTR_CAST( SwPagePreview, SfxViewShell::Current()) )
+ aBool.SetValue( true );
+ rSet.Put( aBool );
+ }
+ }
+ break;
+ case SID_SOURCEVIEW:
+ {
+ SfxViewShell* pCurrView = GetView() ? (SfxViewShell*)GetView()
+ : SfxViewShell::Current();
+ sal_Bool bSourceView = 0 != PTR_CAST(SwSrcView, pCurrView);
+ rSet.Put(SfxBoolItem(SID_SOURCEVIEW, bSourceView));
+ }
+ break;
+ case SID_HTML_MODE:
+ rSet.Put(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(this)));
+ break;
+
+ case FN_ABSTRACT_STARIMPRESS:
+ case FN_OUTLINE_TO_IMPRESS:
+ {
+ SvtModuleOptions aMOpt;
+ if ( !aMOpt.IsImpress() )
+ rSet.DisableItem( nWhich );
+ }
+ /* no break here */
+ case FN_ABSTRACT_NEWDOC:
+ case FN_OUTLINE_TO_CLIPBOARD:
+ {
+ if ( GetDoc()->GetNodes().GetOutLineNds().empty() )
+ rSet.DisableItem( nWhich );
+ }
+ break;
+ case SID_BROWSER_MODE:
+ case FN_PRINT_LAYOUT:
+ {
+ sal_Bool bState = GetDoc()->get(IDocumentSettingAccess::BROWSE_MODE);
+ if(FN_PRINT_LAYOUT == nWhich)
+ bState = !bState;
+ rSet.Put( SfxBoolItem( nWhich, bState));
+ }
+ break;
+
+ case FN_NEW_GLOBAL_DOC:
+ if ( ISA(SwGlobalDocShell) )
+ rSet.DisableItem( nWhich );
+ break;
+
+ case FN_NEW_HTML_DOC:
+ if( ISA( SwWebDocShell ) )
+ rSet.DisableItem( nWhich );
+ break;
+
+ case FN_OPEN_FILE:
+ if( ISA( SwWebDocShell ) )
+ rSet.DisableItem( nWhich );
+ break;
+
+ case SID_ATTR_YEAR2000:
+ {
+ const SvNumberFormatter* pFmtr = pDoc->GetNumberFormatter(sal_False);
+ rSet.Put( SfxUInt16Item( nWhich,
+ static_cast< sal_uInt16 >(
+ pFmtr ? pFmtr->GetYear2000()
+ : ::utl::MiscCfg().GetYear2000() )));
+ }
+ break;
+ case SID_ATTR_CHAR_FONTLIST:
+ {
+ rSet.Put( SvxFontListItem( pFontList, SID_ATTR_CHAR_FONTLIST ) );
+ }
+ break;
+ case SID_MAIL_PREPAREEXPORT:
+ {
+ //check if linked content or possibly hidden content is available
+ //pDoc->UpdateFlds( NULL, false );
+ sfx2::LinkManager& rLnkMgr = pDoc->GetLinkManager();
+ const ::sfx2::SvBaseLinks& rLnks = rLnkMgr.GetLinks();
+ sal_Bool bRet = sal_False;
+ if( !rLnks.empty() )
+ bRet = sal_True;
+ else
+ {
+ //sections with hidden flag, hidden character attribute, hidden paragraph/text or conditional text fields
+ bRet = pDoc->HasInvisibleContent();
+ }
+ rSet.Put( SfxBoolItem( nWhich, bRet ) );
+ }
+ break;
+
+ default: OSL_ENSURE(!this,"You cannot get here!");
+
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+// OLE-Hdls
+IMPL_LINK( SwDocShell, Ole2ModifiedHdl, void *, p )
+{
+ // the Status is handed over from Doc (see doc.cxx)
+ // Bit 0: -> old state
+ // Bit 1: -> new state
+ sal_IntPtr nStatus = (sal_IntPtr)p;
+ if( IsEnableSetModified() )
+ SetModified( (nStatus & 2) ? sal_True : sal_False );
+ return 0;
+}
+
+// return Pool here, because virtual
+SfxStyleSheetBasePool* SwDocShell::GetStyleSheetPool()
+{
+ return mxBasePool.get();
+}
+
+void SwDocShell::SetView(SwView* pVw)
+{
+ if ( 0 != (pView = pVw) )
+ pWrtShell = &pView->GetWrtShell();
+ else
+ pWrtShell = 0;
+}
+
+void SwDocShell::PrepareReload()
+{
+ ::DelAllGrfCacheEntries( pDoc );
+}
+
+// #i59688#
+// linked graphics are now loaded on demand.
+// Thus, loading of linked graphics no longer needed and necessary for
+// the load of document being finished.
+void SwDocShell::LoadingFinished()
+{
+ // #i38810#
+ // Original fix fails after integration of cws xmlsec11:
+ // interface <SfxObjectShell::EnableSetModified(..)> no longer works, because
+ // <SfxObjectShell::FinishedLoading(..)> doesn't care about its status and
+ // enables the document modification again.
+ // Thus, manuell modify the document, if its modified and its links are updated
+ // before <FinishedLoading(..)> is called.
+ const bool bHasDocToStayModified( pDoc->IsModified() && pDoc->LinksUpdated() );
+
+ FinishedLoading( SFX_LOADED_ALL );
+ SfxViewFrame* pVFrame = SfxViewFrame::GetFirst(this);
+ if(pVFrame)
+ {
+ SfxViewShell* pShell = pVFrame->GetViewShell();
+ if(PTR_CAST(SwSrcView, pShell))
+ ((SwSrcView*)pShell)->Load(this);
+ }
+
+ // #i38810#
+ if ( bHasDocToStayModified && !pDoc->IsModified() )
+ {
+ pDoc->SetModified();
+ }
+}
+
+// a Transfer is cancelled (is called from SFX)
+void SwDocShell::CancelTransfers()
+{
+ // Cancel all links from LinkManager
+ aFinishedTimer.Stop();
+ pDoc->GetLinkManager().CancelTransfers();
+ SfxObjectShell::CancelTransfers();
+}
+
+SwFEShell* SwDocShell::GetFEShell()
+{
+ return pWrtShell;
+}
+
+void SwDocShell::RemoveOLEObjects()
+{
+ SwIterator<SwCntntNode,SwFmtColl> aIter( *pDoc->GetDfltGrfFmtColl() );
+ for( SwCntntNode* pNd = aIter.First(); pNd; pNd = aIter.Next() )
+ {
+ SwOLENode* pOLENd = pNd->GetOLENode();
+ if( pOLENd && ( pOLENd->IsOLEObjectDeleted() ||
+ pOLENd->IsInGlobalDocSection() ) )
+ {
+ if( !pOLEChildList )
+ pOLEChildList = new comphelper::EmbeddedObjectContainer;
+
+ OUString aObjName = pOLENd->GetOLEObj().GetCurrentPersistName();
+ GetEmbeddedObjectContainer().MoveEmbeddedObject( aObjName, *pOLEChildList );
+ }
+ }
+}
+
+// When a document is loaded, SwDoc::PrtOLENotify is called to update
+// the sizes of math objects. However, for objects that do not have a
+// SwFrm at this time, only a flag is set (bIsOLESizeInvalid) and the
+// size change takes place later, while calculating the layout in the
+// idle handler. If this document is saved now, it is saved with invalid
+// sizes. For this reason, the layout has to be calculated before a document is
+// saved, but of course only id there are OLE objects with bOLESizeInvalid set.
+void SwDocShell::CalcLayoutForOLEObjects()
+{
+ if( !pWrtShell )
+ return;
+
+ SwIterator<SwCntntNode,SwFmtColl> aIter( *pDoc->GetDfltGrfFmtColl() );
+ for( SwCntntNode* pNd = aIter.First(); pNd; pNd = aIter.Next() )
+ {
+ SwOLENode* pOLENd = pNd->GetOLENode();
+ if( pOLENd && pOLENd->IsOLESizeInvalid() )
+ {
+ pWrtShell->CalcLayout();
+ break;
+ }
+ }
+}
+
+// #i42634# Overwrites SfxObjectShell::UpdateLinks
+// This new function is necessary to trigger update of links in docs
+// read by the binary filter:
+void SwDocShell::UpdateLinks()
+{
+ GetDoc()->UpdateLinks(true);
+ // #i50703# Update footnote numbers
+ SwTxtFtn::SetUniqueSeqRefNo( *GetDoc() );
+ SwNodeIndex aTmp( GetDoc()->GetNodes() );
+ GetDoc()->GetFtnIdxs().UpdateFtn( aTmp );
+}
+
+uno::Reference< frame::XController >
+ SwDocShell::GetController()
+{
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > aRet;
+ // #i82346# No view in page preview
+ if ( GetView() )
+ aRet = GetView()->GetController();
+ return aRet;
+}
+
+void SwDocShell::setDocAccTitle( const OUString& rTitle )
+{
+ if (pDoc)
+ {
+ pDoc->setDocAccTitle( rTitle );
+ }
+}
+
+const OUString SwDocShell::getDocAccTitle() const
+{
+ OUString sRet;
+ if (pDoc)
+ {
+ sRet = pDoc->getDocAccTitle();
+ }
+
+ return sRet;
+}
+
+static const char* s_EventNames[] =
+{
+ "OnPageCountChange",
+ "OnMailMerge",
+ "OnMailMergeFinished",
+ "OnFieldMerge",
+ "OnFieldMergeFinished",
+ "OnLayoutFinished"
+};
+static sal_Int32 const s_nEvents(sizeof(s_EventNames)/sizeof(s_EventNames[0]));
+
+Sequence< OUString > SwDocShell::GetEventNames()
+{
+ Sequence< OUString > aRet = SfxObjectShell::GetEventNames();
+ sal_Int32 nLen = aRet.getLength();
+ aRet.realloc(nLen + 6);
+ OUString* pNames = aRet.getArray();
+ pNames[nLen++] = GetEventName(0);
+ pNames[nLen++] = GetEventName(1);
+ pNames[nLen++] = GetEventName(2);
+ pNames[nLen++] = GetEventName(3);
+ pNames[nLen++] = GetEventName(4);
+ pNames[nLen] = GetEventName(5);
+
+ return aRet;
+}
+
+OUString SwDocShell::GetEventName( sal_Int32 nIndex )
+{
+ if (nIndex < s_nEvents)
+ {
+ return OUString::createFromAscii(s_EventNames[nIndex]);
+ }
+ return OUString();
+}
+
+const ::sfx2::IXmlIdRegistry* SwDocShell::GetXmlIdRegistry() const
+{
+ return pDoc ? &pDoc->GetXmlIdRegistry() : 0;
+}
+
+bool SwDocShell::IsChangeRecording() const
+{
+ return (pWrtShell->GetRedlineMode() & nsRedlineMode_t::REDLINE_ON) != 0;
+}
+
+bool SwDocShell::HasChangeRecordProtection() const
+{
+ return pWrtShell->getIDocumentRedlineAccess()->GetRedlinePassword().getLength() > 0;
+}
+
+void SwDocShell::SetChangeRecording( bool bActivate )
+{
+ sal_uInt16 nOn = bActivate ? nsRedlineMode_t::REDLINE_ON : 0;
+ sal_uInt16 nMode = pWrtShell->GetRedlineMode();
+ pWrtShell->SetRedlineModeAndCheckInsMode( (nMode & ~nsRedlineMode_t::REDLINE_ON) | nOn);
+}
+
+bool SwDocShell::SetProtectionPassword( const OUString &rNewPassword )
+{
+ const SfxAllItemSet aSet( GetPool() );
+ const SfxItemSet* pArgs = &aSet;
+ const SfxPoolItem* pItem = NULL;
+
+ IDocumentRedlineAccess* pIDRA = pWrtShell->getIDocumentRedlineAccess();
+ Sequence< sal_Int8 > aPasswd = pIDRA->GetRedlinePassword();
+ if (pArgs && SFX_ITEM_SET == pArgs->GetItemState( FN_REDLINE_PROTECT, false, &pItem )
+ && ((SfxBoolItem*)pItem)->GetValue() == (aPasswd.getLength() > 0))
+ return false;
+
+ bool bRes = false;
+
+ if (!rNewPassword.isEmpty())
+ {
+ // when password protection is applied change tracking must always be active
+ SetChangeRecording( true );
+
+ Sequence< sal_Int8 > aNewPasswd;
+ SvPasswordHelper::GetHashPassword( aNewPasswd, rNewPassword );
+ pIDRA->SetRedlinePassword( aNewPasswd );
+ bRes = true;
+ }
+ else
+ {
+ pIDRA->SetRedlinePassword( Sequence< sal_Int8 >() );
+ bRes = true;
+ }
+
+ return bRes;
+}
+
+bool SwDocShell::GetProtectionHash( /*out*/ ::com::sun::star::uno::Sequence< sal_Int8 > &rPasswordHash )
+{
+ bool bRes = false;
+
+ const SfxAllItemSet aSet( GetPool() );
+ const SfxItemSet* pArgs = &aSet;
+ const SfxPoolItem* pItem = NULL;
+
+ IDocumentRedlineAccess* pIDRA = pWrtShell->getIDocumentRedlineAccess();
+ Sequence< sal_Int8 > aPasswdHash( pIDRA->GetRedlinePassword() );
+ if (pArgs && SFX_ITEM_SET == pArgs->GetItemState( FN_REDLINE_PROTECT, false, &pItem )
+ && ((SfxBoolItem*)pItem)->GetValue() == (aPasswdHash.getLength() != 0))
+ return false;
+ rPasswordHash = aPasswdHash;
+ bRes = true;
+
+ return bRes;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/app/docsh2.cxx b/sw/source/core/uibase/app/docsh2.cxx
new file mode 100644
index 000000000000..e3830a7ba4e2
--- /dev/null
+++ b/sw/source/core/uibase/app/docsh2.cxx
@@ -0,0 +1,1586 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <com/sun/star/drawing/ModuleDispatcher.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/frame/DispatchHelper.hpp>
+
+#include <comphelper/processfactory.hxx>
+
+#include <hintids.hxx>
+#include <tools/urlobj.hxx>
+#include <unotools/tempfile.hxx>
+#include <vcl/wrkwin.hxx>
+#include <vcl/msgbox.hxx>
+#include <svl/lckbitem.hxx>
+#include <svl/eitem.hxx>
+#include <svl/zforlist.hxx>
+#include <svl/zformat.hxx>
+#include <unotools/pathoptions.hxx>
+#include <svtools/transfer.hxx>
+#include <sfx2/dialogs.hrc>
+#include <sfx2/dinfdlg.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/new.hxx>
+#include <sfx2/filedlghelper.hxx>
+#include <sfx2/printer.hxx>
+#include <sfx2/evntconf.hxx>
+#include <svtools/sfxecode.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/docfilt.hxx>
+#include <svx/svxids.hrc>
+#include <svx/drawitem.hxx>
+#include <editeng/svxacorr.hxx>
+#include <editeng/langitem.hxx>
+#include <svx/fmshell.hxx>
+#include <sfx2/linkmgr.hxx>
+
+#include <svtools/htmlcfg.hxx>
+#include <svx/ofaitem.hxx>
+#include <SwSmartTagMgr.hxx>
+#include <sfx2/app.hxx>
+#include <basic/sbstar.hxx>
+#include <basic/basmgr.hxx>
+#include <sot/storage.hxx>
+#include <comphelper/classids.hxx>
+#include <fmtcol.hxx>
+#include <swevent.hxx>
+#include <view.hxx>
+#include <docsh.hxx>
+#include <docary.hxx>
+#include <wrtsh.hxx>
+#include <fldbas.hxx>
+#include <viewopt.hxx>
+#include <globdoc.hxx>
+#include <fldwrap.hxx>
+#include <redlndlg.hxx>
+#include <docstyle.hxx>
+#include <doc.hxx>
+#include <IDocumentUndoRedo.hxx>
+#include <pagedesc.hxx>
+#include <shellio.hxx>
+#include <pview.hxx>
+#include <srcview.hxx>
+#include <poolfmt.hxx>
+#include <usrpref.hxx>
+#include <wdocsh.hxx>
+#include <unotxdoc.hxx>
+#include <acmplwrd.hxx>
+#include <swmodule.hxx>
+#include <unobaseclass.hxx>
+#include <swwait.hxx>
+#include <swcli.hxx>
+
+#include <cmdid.h>
+#include <globals.h>
+#include <helpid.h>
+#include <app.hrc>
+#include <poolfmt.hrc>
+#include <globals.hrc>
+#include <com/sun/star/ui/dialogs/XFilePicker.hpp>
+#include <com/sun/star/ui/dialogs/XFilterManager.hpp>
+#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
+#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
+#include <com/sun/star/ui/dialogs/ListboxControlActions.hpp>
+#include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp>
+#include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
+#include <com/sun/star/script/vba/XVBAEventProcessor.hpp>
+#include <com/sun/star/script/vba/VBAEventId.hpp>
+#include <editeng/acorrcfg.hxx>
+#include <SwStyleNameMapper.hxx>
+
+#include <sfx2/fcontnr.hxx>
+
+#include "dialog.hrc"
+#include "swabstdlg.hxx"
+
+#include <ndtxt.hxx>
+
+#include <boost/scoped_ptr.hpp>
+
+using namespace ::com::sun::star::ui::dialogs;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star;
+using namespace ::sfx2;
+
+extern bool FindPhyStyle( SwDoc& , const OUString& , SfxStyleFamily );
+
+// create DocInfo (virtual)
+SfxDocumentInfoDialog* SwDocShell::CreateDocumentInfoDialog(
+ Window *pParent, const SfxItemSet &rSet)
+{
+ SfxDocumentInfoDialog* pDlg = new SfxDocumentInfoDialog(pParent, rSet);
+ //only with statistics, when this document is being shown, not
+ //from within the Doc-Manager
+ SwDocShell* pDocSh = (SwDocShell*) SfxObjectShell::Current();
+ if( pDocSh == this )
+ {
+ //Not for SourceView.
+ SfxViewShell *pVSh = SfxViewShell::Current();
+ if ( pVSh && !pVSh->ISA(SwSrcView) )
+ {
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+ pDlg->AddFontTabPage();
+ pDlg->AddTabPage(TP_DOC_STAT, SW_RESSTR(STR_DOC_STAT),pFact->GetTabPageCreatorFunc( TP_DOC_STAT ),0);
+ }
+ }
+ return pDlg;
+}
+
+// Disable "multiple layout"
+
+void SwDocShell::ToggleBrowserMode(sal_Bool bSet, SwView* _pView )
+{
+ GetDoc()->set(IDocumentSettingAccess::BROWSE_MODE, bSet );
+ UpdateFontList();
+ SwView* pTempView = _pView ? _pView : (SwView*)GetView();
+ if( pTempView )
+ {
+ pTempView->GetViewFrame()->GetBindings().Invalidate(FN_SHADOWCURSOR);
+ if( !GetDoc()->getPrinter( false ) )
+ pTempView->SetPrinter( GetDoc()->getPrinter( false ), SFX_PRINTER_PRINTER | SFX_PRINTER_JOBSETUP );
+ GetDoc()->CheckDefaultPageFmt();
+ SfxViewFrame *pTmpFrm = SfxViewFrame::GetFirst(this, sal_False);
+ do {
+ if( pTmpFrm != pTempView->GetViewFrame() )
+ {
+ pTmpFrm->DoClose();
+ pTmpFrm = SfxViewFrame::GetFirst(this, sal_False);
+ }
+ else
+ pTmpFrm = pTmpFrm->GetNext(*pTmpFrm, this, sal_False);
+
+ } while ( pTmpFrm );
+ const SwViewOption& rViewOptions = *pTempView->GetWrtShell().GetViewOptions();
+ pTempView->GetWrtShell().CheckBrowseView( sal_True );
+ pTempView->CheckVisArea();
+ if( bSet )
+ {
+ const SvxZoomType eType = (SvxZoomType)rViewOptions.GetZoomType();
+ if ( SVX_ZOOM_PERCENT != eType)
+ ((SwView*)GetView())->SetZoom( eType );
+ }
+ pTempView->InvalidateBorder();
+ pTempView->SetNewWindowAllowed(!bSet);
+ }
+}
+// End of disabled "multiple layout"
+
+// update text fields on document properties changes
+void SwDocShell::DoFlushDocInfo()
+{
+ if ( !pDoc ) return;
+
+ bool bUnlockView(true);
+ if ( pWrtShell ) {
+ bUnlockView = !pWrtShell->IsViewLocked();
+ pWrtShell->LockView( sal_True ); // lock visible section
+ pWrtShell->StartAllAction();
+ }
+
+ pDoc->DocInfoChgd();
+
+ if ( pWrtShell ) {
+ pWrtShell->EndAllAction();
+ if ( bUnlockView ) {
+ pWrtShell->LockView( sal_False );
+ }
+ }
+}
+
+static void lcl_processCompatibleSfxHint( const uno::Reference< script::vba::XVBAEventProcessor >& xVbaEvents, const SfxHint& rHint )
+{
+ using namespace com::sun::star::script::vba::VBAEventId;
+ if ( rHint.ISA( SfxEventHint ) )
+ {
+ uno::Sequence< uno::Any > aArgs;
+ sal_uLong nEventId = ((SfxEventHint&)rHint).GetEventId();
+ switch( nEventId )
+ {
+ case SFX_EVENT_CREATEDOC:
+ xVbaEvents->processVbaEvent( DOCUMENT_NEW, aArgs );
+ break;
+ case SFX_EVENT_OPENDOC:
+ xVbaEvents->processVbaEvent( DOCUMENT_OPEN, aArgs );
+ break;
+ }
+ }
+}
+
+// Notification on DocInfo changes
+void SwDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ if( !pDoc )
+ {
+ return ;
+ }
+
+ uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents = pDoc->GetVbaEventProcessor();
+ if( xVbaEvents.is() )
+ lcl_processCompatibleSfxHint( xVbaEvents, rHint );
+
+ sal_uInt16 nAction = 0;
+ if( rHint.ISA(SfxSimpleHint) )
+ {
+ // switch for more actions
+ switch( ((SfxSimpleHint&) rHint).GetId() )
+ {
+ case SFX_HINT_TITLECHANGED:
+ if( GetMedium() )
+ nAction = 2;
+ break;
+ }
+ }
+ else if( rHint.ISA(SfxEventHint) &&
+ ((SfxEventHint&) rHint).GetEventId() == SFX_EVENT_LOADFINISHED )
+ {
+ // #i38126# - own action id
+ nAction = 3;
+ }
+
+ if( nAction )
+ {
+ bool bUnlockView = true; //initializing prevents warning
+ if( pWrtShell )
+ {
+ bUnlockView = !pWrtShell->IsViewLocked();
+ pWrtShell->LockView( sal_True ); //lock visible section
+ pWrtShell->StartAllAction();
+ }
+ switch( nAction )
+ {
+ case 2:
+ pDoc->GetSysFldType( RES_FILENAMEFLD )->UpdateFlds();
+ break;
+ // #i38126# - own action for event LOADFINISHED
+ // in order to avoid a modified document.
+ // #i41679# - Also for the instance of <SwDoc>
+ // it has to be assured, that it's not modified.
+ // Perform the same as for action id 1, but disable <SetModified>.
+ case 3:
+ {
+ const bool bResetModified = IsEnableSetModified();
+ if ( bResetModified )
+ EnableSetModified( sal_False );
+ // #i41679#
+ const bool bIsDocModified = pDoc->IsModified();
+
+ pDoc->DocInfoChgd( );
+
+ // #i41679#
+ if ( !bIsDocModified )
+ pDoc->ResetModified();
+ if ( bResetModified )
+ EnableSetModified( sal_True );
+ }
+ break;
+ }
+
+ if( pWrtShell )
+ {
+ pWrtShell->EndAllAction();
+ if( bUnlockView )
+ pWrtShell->LockView( sal_False );
+ }
+ }
+}
+
+// Notification Close Doc
+bool SwDocShell::PrepareClose( sal_Bool bUI )
+{
+ bool nRet = SfxObjectShell::PrepareClose( bUI );
+
+ if( nRet )
+ EndListening( *this );
+
+ if( pDoc && IsInPrepareClose() )
+ {
+ uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents = pDoc->GetVbaEventProcessor();
+ if( xVbaEvents.is() )
+ {
+ using namespace com::sun::star::script::vba::VBAEventId;
+ uno::Sequence< uno::Any > aArgs;
+ xVbaEvents->processVbaEvent( DOCUMENT_CLOSE, aArgs );
+ }
+ }
+ return nRet;
+}
+
+void SwDocShell::Execute(SfxRequest& rReq)
+{
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ const SfxPoolItem* pItem;
+ sal_uInt16 nWhich = rReq.GetSlot();
+ sal_Bool bDone = sal_False;
+ switch ( nWhich )
+ {
+ case SID_AUTO_CORRECT_DLG:
+ {
+ SvxSwAutoFmtFlags* pAFlags = &SvxAutoCorrCfg::Get().GetAutoCorrect()->GetSwFlags();
+ SwAutoCompleteWord& rACW = SwDoc::GetAutoCompleteWords();
+
+ bool bOldLocked = rACW.IsLockWordLstLocked(),
+ bOldAutoCmpltCollectWords = pAFlags->bAutoCmpltCollectWords;
+
+ rACW.SetLockWordLstLocked( true );
+
+ editeng::SortedAutoCompleteStrings aTmpLst( rACW.GetWordList() );
+ pAFlags->m_pAutoCompleteList = &aTmpLst;
+
+ SfxApplication* pApp = SFX_APP();
+ SfxRequest aAppReq(SID_AUTO_CORRECT_DLG, SFX_CALLMODE_SYNCHRON, pApp->GetPool());
+ SfxBoolItem aSwOptions( SID_AUTO_CORRECT_DLG, true );
+ aAppReq.AppendItem(aSwOptions);
+
+ // SMARTTAGS
+ pAFlags->pSmartTagMgr = &SwSmartTagMgr::Get();
+
+ SfxItemSet aSet( pApp->GetPool(), SID_AUTO_CORRECT_DLG, SID_AUTO_CORRECT_DLG, SID_OPEN_SMARTTAGOPTIONS, SID_OPEN_SMARTTAGOPTIONS, 0 );
+ aSet.Put( aSwOptions );
+
+ const SfxPoolItem* pOpenSmartTagOptionsItem = 0;
+ if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( SID_OPEN_SMARTTAGOPTIONS, false, &pOpenSmartTagOptionsItem ) )
+ aSet.Put( *static_cast<const SfxBoolItem*>(pOpenSmartTagOptionsItem) );
+
+ SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
+ SfxAbstractTabDialog* pDlg = pFact->CreateTabDialog( RID_OFA_AUTOCORR_DLG, NULL, &aSet, NULL );
+ pDlg->Execute();
+ delete pDlg;
+
+ rACW.SetLockWordLstLocked( bOldLocked );
+
+ SwEditShell::SetAutoFmtFlags( pAFlags );
+ rACW.SetMinWordLen( pAFlags->nAutoCmpltWordLen );
+ rACW.SetMaxCount( pAFlags->nAutoCmpltListLen );
+ if (pAFlags->m_pAutoCompleteList) // any changes?
+ {
+ rACW.CheckChangedList( aTmpLst );
+ // clear the temp WordList pointer
+ pAFlags->m_pAutoCompleteList = 0;
+ }
+ // remove all pointer we never delete the strings
+ aTmpLst.clear();
+
+ if( !bOldAutoCmpltCollectWords && bOldAutoCmpltCollectWords !=
+ pAFlags->bAutoCmpltCollectWords )
+ {
+ // call on all Docs the idle formatter to start
+ // the collection of Words
+ TypeId aType = TYPE(SwDocShell);
+ for( SwDocShell *pDocSh = (SwDocShell*)SfxObjectShell::GetFirst(&aType);
+ pDocSh;
+ pDocSh = (SwDocShell*)SfxObjectShell::GetNext( *pDocSh, &aType ) )
+ {
+ SwDoc* pTmp = pDocSh->GetDoc();
+ if ( pTmp->GetCurrentViewShell() )
+ pTmp->InvalidateAutoCompleteFlag();
+ }
+ }
+ }
+ break;
+
+ case SID_PRINTPREVIEW:
+ {
+ sal_Bool bSet = sal_False;
+ bool bFound = false, bOnly = true;
+ SfxViewFrame *pTmpFrm = SfxViewFrame::GetFirst(this);
+ SfxViewShell* pViewShell = SfxViewShell::Current();
+ SwView* pCurrView = dynamic_cast< SwView *> ( pViewShell );
+ sal_Bool bCurrent = IS_TYPE( SwPagePreview, pViewShell );
+
+ while( pTmpFrm ) // search Preview
+ {
+ if( IS_TYPE( SwView, pTmpFrm->GetViewShell()) )
+ bOnly = false;
+ else if( IS_TYPE( SwPagePreview, pTmpFrm->GetViewShell()))
+ {
+ pTmpFrm->GetFrame().Appear();
+ bFound = true;
+ }
+ if( bFound && !bOnly )
+ break;
+ pTmpFrm = pTmpFrm->GetNext(*pTmpFrm, this);
+ }
+
+ if( pArgs && SFX_ITEM_SET ==
+ pArgs->GetItemState( SID_PRINTPREVIEW, false, &pItem ))
+ bSet = ((SfxBoolItem*)pItem)->GetValue();
+ else
+ bSet = !bCurrent;
+
+ sal_uInt16 nSlotId = 0;
+ if( bSet && !bFound ) // Nothing found, so create new Preview
+ nSlotId = SID_VIEWSHELL1;
+ else if( bFound && !bSet )
+ nSlotId = bOnly ? SID_VIEWSHELL0 : SID_VIEWSHELL1;
+
+ if( nSlotId )
+ {
+ // PagePreview in the WebDocShell
+ // is found under Id VIEWSHELL2.
+ if( ISA(SwWebDocShell) && SID_VIEWSHELL1 == nSlotId )
+ nSlotId = SID_VIEWSHELL2;
+
+ if( pCurrView && pCurrView->GetDocShell() == this )
+ pTmpFrm = pCurrView->GetViewFrame();
+ else
+ pTmpFrm = SfxViewFrame::GetFirst( this );
+
+ pTmpFrm->GetDispatcher()->Execute( nSlotId, 0, 0, SFX_CALLMODE_ASYNCHRON );
+ }
+
+ rReq.SetReturnValue(SfxBoolItem(SID_PRINTPREVIEW, bSet ));
+ }
+ break;
+ case SID_TEMPLATE_LOAD:
+ {
+ OUString aFileName;
+ static sal_Bool bText = sal_True;
+ static sal_Bool bFrame = sal_False;
+ static sal_Bool bPage = sal_False;
+ static sal_Bool bNum = sal_False;
+ static sal_Bool bMerge = sal_False;
+ sal_uInt16 nRet = USHRT_MAX;
+
+ sal_uInt16 nFlags = bFrame ? SFX_LOAD_FRAME_STYLES : 0;
+ if(bPage)
+ nFlags|= SFX_LOAD_PAGE_STYLES;
+ if(bNum)
+ nFlags|= SFX_LOAD_NUM_STYLES;
+ if(!nFlags || bText)
+ nFlags|= SFX_LOAD_TEXT_STYLES;
+ if(bMerge)
+ nFlags|= SFX_MERGE_STYLES;
+
+ if ( pArgs )
+ {
+ SFX_REQUEST_ARG( rReq, pTemplateItem, SfxStringItem, SID_TEMPLATE_NAME, false );
+ if ( pTemplateItem )
+ {
+ aFileName = pTemplateItem->GetValue();
+ SFX_REQUEST_ARG( rReq, pFlagsItem, SfxInt32Item, SID_TEMPLATE_LOAD, false );
+ if ( pFlagsItem )
+ nFlags = (sal_uInt16) pFlagsItem->GetValue();
+ }
+ }
+
+ if ( aFileName.isEmpty() )
+ {
+ SvtPathOptions aPathOpt;
+ SfxNewFileDialog* pNewFileDlg =
+ new SfxNewFileDialog(&GetView()->GetViewFrame()->GetWindow(), SFXWB_LOAD_TEMPLATE);
+ pNewFileDlg->SetTemplateFlags(nFlags);
+
+ nRet = pNewFileDlg->Execute();
+ if(RET_TEMPLATE_LOAD == nRet)
+ {
+ FileDialogHelper aDlgHelper( TemplateDescription::FILEOPEN_SIMPLE, 0 );
+ uno::Reference < XFilePicker > xFP = aDlgHelper.GetFilePicker();
+
+ xFP->setDisplayDirectory( aPathOpt.GetWorkPath() );
+
+ SfxObjectFactory &rFact = GetFactory();
+ SfxFilterMatcher aMatcher( OUString::createFromAscii(rFact.GetShortName()) );
+ SfxFilterMatcherIter aIter( aMatcher );
+ uno::Reference<XFilterManager> xFltMgr(xFP, UNO_QUERY);
+ const SfxFilter* pFlt = aIter.First();
+ while( pFlt )
+ {
+ // --> OD #i117339#
+ if( pFlt && pFlt->IsAllowedAsTemplate() &&
+ ( pFlt->GetUserData() == "CXML" ||
+ pFlt->GetUserData() == "CXMLV" ) )
+ {
+ const OUString sWild = pFlt->GetWildcard().getGlob();
+ xFltMgr->appendFilter( pFlt->GetUIName(), sWild );
+ }
+ pFlt = aIter.Next();
+ }
+ bool bWeb = 0 != dynamic_cast< SwWebDocShell *>( this );
+ const SfxFilter *pOwnFlt =
+ SwDocShell::Factory().GetFilterContainer()->
+ GetFilter4FilterName(OUString("writer8"));
+
+ // make sure the default file format is also available
+ if(bWeb)
+ {
+ const OUString sWild = pOwnFlt->GetWildcard().getGlob();
+ xFltMgr->appendFilter( pOwnFlt->GetUIName(), sWild );
+ }
+
+ bool bError = false;
+ // catch exception if wrong filter is selected - should not happen anymore
+ try
+ {
+ xFltMgr->setCurrentFilter( pOwnFlt->GetUIName() );
+ }
+ catch (const uno::Exception&)
+ {
+ bError = true;
+ }
+
+ if( !bError && ERRCODE_NONE == aDlgHelper.Execute() )
+ {
+ aFileName = xFP->getFiles().getConstArray()[0];
+ }
+ }
+ else if( RET_OK == nRet)
+ {
+ aFileName = pNewFileDlg->GetTemplateFileName();
+ }
+
+ nFlags = pNewFileDlg->GetTemplateFlags();
+ rReq.AppendItem( SfxStringItem( SID_TEMPLATE_NAME, aFileName ) );
+ rReq.AppendItem( SfxInt32Item( SID_TEMPLATE_LOAD, (long) nFlags ) );
+ delete pNewFileDlg;
+ }
+
+ if( !aFileName.isEmpty() )
+ {
+ SwgReaderOption aOpt;
+ aOpt.SetTxtFmts( bText = (0 != (nFlags&SFX_LOAD_TEXT_STYLES) ));
+ aOpt.SetFrmFmts( bFrame = (0 != (nFlags&SFX_LOAD_FRAME_STYLES)));
+ aOpt.SetPageDescs( bPage = (0 != (nFlags&SFX_LOAD_PAGE_STYLES )));
+ aOpt.SetNumRules( bNum = (0 != (nFlags&SFX_LOAD_NUM_STYLES )));
+ //different meaning between SFX_MERGE_STYLES and aOpt.SetMerge!
+ bMerge = 0 != (nFlags&SFX_MERGE_STYLES);
+ aOpt.SetMerge( !bMerge );
+
+ SetError( LoadStylesFromFile( aFileName, aOpt, sal_False ), OUString( OSL_LOG_PREFIX ));
+ if ( !GetError() )
+ rReq.Done();
+ }
+ }
+ break;
+ case SID_SOURCEVIEW:
+ {
+ SfxViewShell* pViewShell = GetView()
+ ? (SfxViewShell*)GetView()
+ : SfxViewShell::Current();
+ SfxViewFrame* pViewFrm = pViewShell->GetViewFrame();
+ SwSrcView* pSrcView = dynamic_cast< SwSrcView *>( pViewShell );
+ if(!pSrcView)
+ {
+ // 3 possible state:
+ // 1 - file unsaved -> save as HTML
+ // 2 - file modified and HTML filter active -> save
+ // 3 - file saved in non-HTML -> QueryBox to save as HTML
+ const SfxFilter* pHtmlFlt =
+ SwIoSystem::GetFilterOfFormat(
+ OUString("HTML"),
+ SwWebDocShell::Factory().GetFilterContainer() );
+ sal_Bool bLocalHasName = HasName();
+ if(bLocalHasName)
+ {
+ //check for filter type
+ const SfxFilter* pFlt = GetMedium()->GetFilter();
+ if(!pFlt || pFlt->GetUserData() != pHtmlFlt->GetUserData())
+ {
+ MessageDialog aQuery(&pViewFrm->GetWindow(),
+ "SaveAsHTMLDialog", "modules/swriter/ui/saveashtmldialog.ui");
+
+ if(RET_YES == aQuery.Execute())
+ bLocalHasName = sal_False;
+ else
+ break;
+ }
+ }
+ if(!bLocalHasName)
+ {
+ FileDialogHelper aDlgHelper( TemplateDescription::FILESAVE_AUTOEXTENSION, 0 );
+ aDlgHelper.AddFilter( pHtmlFlt->GetFilterName(), pHtmlFlt->GetDefaultExtension() );
+ aDlgHelper.SetCurrentFilter( pHtmlFlt->GetFilterName() );
+ if( ERRCODE_NONE != aDlgHelper.Execute())
+ {
+ break;
+ }
+ OUString sPath = aDlgHelper.GetPath();
+ SfxStringItem aName(SID_FILE_NAME, sPath);
+ SfxStringItem aFilter(SID_FILTER_NAME, pHtmlFlt->GetName());
+ const SfxBoolItem* pBool = (const SfxBoolItem*)
+ pViewFrm->GetDispatcher()->Execute(
+ SID_SAVEASDOC, SFX_CALLMODE_SYNCHRON, &aName, &aFilter, 0L );
+ if(!pBool || !pBool->GetValue())
+ break;
+ }
+ }
+
+ OSL_ENSURE(dynamic_cast<SwWebDocShell*>(this),
+ "SourceView only in WebDocShell");
+
+ // the SourceView is not the 1 for SwWebDocShell
+ sal_uInt16 nSlot = SID_VIEWSHELL1;
+ bool bSetModified = false;
+ SfxPrinter* pSavePrinter = 0;
+ if( 0 != pSrcView)
+ {
+ SfxPrinter* pTemp = GetDoc()->getPrinter( false );
+ if(pTemp)
+ pSavePrinter = new SfxPrinter(*pTemp);
+ bSetModified = IsModified() || pSrcView->IsModified();
+ if(pSrcView->IsModified()||pSrcView->HasSourceSaved())
+ {
+ utl::TempFile aTempFile;
+ aTempFile.EnableKillingFile();
+ pSrcView->SaveContent(aTempFile.GetURL());
+ bDone = sal_True;
+ SvxMacro aMac(aEmptyOUStr, aEmptyOUStr, STARBASIC);
+ SfxEventConfiguration::ConfigureEvent(GlobalEventConfig::GetEventName( STR_EVENT_OPENDOC ), aMac, this);
+ SfxEventConfiguration::ConfigureEvent(GlobalEventConfig::GetEventName( STR_EVENT_PREPARECLOSEDOC ), aMac, this);
+ SfxEventConfiguration::ConfigureEvent(GlobalEventConfig::GetEventName( STR_EVENT_ACTIVATEDOC ), aMac, this);
+ SfxEventConfiguration::ConfigureEvent(GlobalEventConfig::GetEventName( STR_EVENT_DEACTIVATEDOC ), aMac, this);
+ ReloadFromHtml(aTempFile.GetURL(), pSrcView);
+ nSlot = 0;
+ }
+ else
+ {
+ nSlot = SID_VIEWSHELL0;
+ }
+ }
+ if(nSlot)
+ pViewFrm->GetDispatcher()->Execute(nSlot, SFX_CALLMODE_SYNCHRON);
+ if(bSetModified)
+ GetDoc()->SetModified();
+ if(pSavePrinter)
+ {
+ GetDoc()->setPrinter( pSavePrinter, true, true);
+ //pSavePrinter must not be deleted again
+ }
+ pViewFrm->GetBindings().SetState(SfxBoolItem(SID_SOURCEVIEW, nSlot == SID_VIEWSHELL2));
+ pViewFrm->GetBindings().Invalidate( SID_NEWWINDOW );
+ pViewFrm->GetBindings().Invalidate( SID_BROWSER_MODE );
+ pViewFrm->GetBindings().Invalidate( FN_PRINT_LAYOUT );
+ }
+ break;
+ case SID_GET_COLORLIST:
+ {
+ SvxColorListItem* pColItem = (SvxColorListItem*)GetItem(SID_COLOR_TABLE);
+ XColorListRef pList = pColItem->GetColorList();
+ rReq.SetReturnValue(OfaRefItem<XColorList>(SID_GET_COLORLIST, pList));
+ }
+ break;
+ case FN_ABSTRACT_STARIMPRESS:
+ case FN_ABSTRACT_NEWDOC:
+ {
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+
+ boost::scoped_ptr<AbstractSwInsertAbstractDlg> pDlg(pFact->CreateSwInsertAbstractDlg(0));
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ if(RET_OK == pDlg->Execute())
+ {
+ sal_uInt8 nLevel = pDlg->GetLevel();
+ sal_uInt8 nPara = pDlg->GetPara();
+ SwDoc* pSmryDoc = new SwDoc();
+ SfxObjectShellLock xDocSh( new SwDocShell( pSmryDoc, SFX_CREATE_MODE_STANDARD));
+ xDocSh->DoInitNew( 0 );
+
+ bool bImpress = FN_ABSTRACT_STARIMPRESS == nWhich;
+ pDoc->Summary( pSmryDoc, nLevel, nPara, bImpress );
+ if( bImpress )
+ {
+ WriterRef xWrt;
+ // mba: looks as if relative URLs don't make sense here
+ ::GetRTFWriter( aEmptyOUStr, OUString(), xWrt );
+ SvMemoryStream *pStrm = new SvMemoryStream();
+ pStrm->SetBufferSize( 16348 );
+ SwWriter aWrt( *pStrm, *pSmryDoc );
+ ErrCode eErr = aWrt.Write( xWrt );
+ if( !ERRCODE_TOERROR( eErr ) )
+ {
+ uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
+ uno::Reference< frame::XDispatchProvider > xProv = drawing::ModuleDispatcher::create( xContext );
+
+ OUString aCmd("SendOutlineToImpress");
+ uno::Reference< frame::XDispatchHelper > xHelper( frame::DispatchHelper::create(xContext) );
+ pStrm->Seek( STREAM_SEEK_TO_END );
+ pStrm->WriteChar( '\0' );
+ pStrm->Seek( STREAM_SEEK_TO_BEGIN );
+
+ // Transfer ownership of stream to a lockbytes object
+ SvLockBytes aLockBytes( pStrm, true );
+ SvLockBytesStat aStat;
+ if ( aLockBytes.Stat( &aStat, SVSTATFLAG_DEFAULT ) == ERRCODE_NONE )
+ {
+ sal_uInt32 nLen = aStat.nSize;
+ sal_uLong nRead = 0;
+ uno::Sequence< sal_Int8 > aSeq( nLen );
+ aLockBytes.ReadAt( 0, aSeq.getArray(), nLen, &nRead );
+
+ uno::Sequence< beans::PropertyValue > aArgs(1);
+ aArgs[0].Name = "RtfOutline";
+ aArgs[0].Value <<= aSeq;
+ xHelper->executeDispatch( xProv, aCmd, OUString(), 0, aArgs );
+ }
+ }
+ else
+ ErrorHandler::HandleError(ErrCode( eErr ));
+ }
+ else
+ {
+ // Create new document
+ SfxViewFrame *pFrame = SfxViewFrame::LoadDocument( *xDocSh, 0 );
+ SwView *pCurrView = (SwView*) pFrame->GetViewShell();
+
+ // Set document's title
+ OUString aTmp( SW_RES(STR_ABSTRACT_TITLE) );
+ aTmp += GetTitle();
+ xDocSh->SetTitle( aTmp );
+ pCurrView->GetWrtShell().SetNewDoc();
+ pFrame->Show();
+ pSmryDoc->SetModified();
+ }
+
+ }
+ }
+ break;
+ case FN_OUTLINE_TO_CLIPBOARD:
+ case FN_OUTLINE_TO_IMPRESS:
+ {
+ sal_Bool bEnable = IsEnableSetModified();
+ EnableSetModified( sal_False );
+ WriterRef xWrt;
+ // mba: looks as if relative URLs don't make sense here
+ ::GetRTFWriter( OUString('O'), OUString(), xWrt );
+ SvMemoryStream *pStrm = new SvMemoryStream();
+ pStrm->SetBufferSize( 16348 );
+ SwWriter aWrt( *pStrm, *GetDoc() );
+ ErrCode eErr = aWrt.Write( xWrt );
+ EnableSetModified( bEnable );
+ if( !ERRCODE_TOERROR( eErr ) )
+ {
+ pStrm->Seek( STREAM_SEEK_TO_END );
+ pStrm->WriteChar( '\0' );
+ pStrm->Seek( STREAM_SEEK_TO_BEGIN );
+ if ( nWhich == FN_OUTLINE_TO_IMPRESS )
+ {
+ uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
+ uno::Reference< frame::XDispatchProvider > xProv = drawing::ModuleDispatcher::create( xContext );
+
+ OUString aCmd("SendOutlineToImpress");
+ uno::Reference< frame::XDispatchHelper > xHelper( frame::DispatchHelper::create(xContext) );
+ pStrm->Seek( STREAM_SEEK_TO_END );
+ pStrm->WriteChar( '\0' );
+ pStrm->Seek( STREAM_SEEK_TO_BEGIN );
+
+ // Transfer ownership of stream to a lockbytes object
+ SvLockBytes aLockBytes( pStrm, true );
+ SvLockBytesStat aStat;
+ if ( aLockBytes.Stat( &aStat, SVSTATFLAG_DEFAULT ) == ERRCODE_NONE )
+ {
+ sal_uInt32 nLen = aStat.nSize;
+ sal_uLong nRead = 0;
+ uno::Sequence< sal_Int8 > aSeq( nLen );
+ aLockBytes.ReadAt( 0, aSeq.getArray(), nLen, &nRead );
+
+ uno::Sequence< beans::PropertyValue > aArgs(1);
+ aArgs[0].Name = "RtfOutline";
+ aArgs[0].Value <<= aSeq;
+ xHelper->executeDispatch( xProv, aCmd, OUString(), 0, aArgs );
+ }
+ }
+ else
+ {
+ TransferDataContainer* pClipCntnr =
+ new TransferDataContainer;
+ ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >
+ xRef( pClipCntnr );
+
+ pClipCntnr->CopyAnyData( FORMAT_RTF, (sal_Char*)
+ pStrm->GetData(), pStrm->GetEndOfData() );
+ pClipCntnr->CopyToClipboard(
+ GetView()? (Window*)&GetView()->GetEditWin() : 0 );
+ delete pStrm;
+ }
+ }
+ else
+ ErrorHandler::HandleError(ErrCode( eErr ));
+ }
+ break;
+ case SID_SPELLCHECKER_CHANGED:
+ //! false, true, true is on the save side but a probably overdone
+ SW_MOD()->CheckSpellChanges(false, true, true, false );
+ break;
+
+ case SID_MAIL_PREPAREEXPORT:
+ {
+ //pWrtShell is not set in page preview
+ if(pWrtShell)
+ pWrtShell->StartAllAction();
+ pDoc->UpdateFlds( NULL, false );
+ pDoc->EmbedAllLinks();
+ pDoc->RemoveInvisibleContent();
+ if(pWrtShell)
+ pWrtShell->EndAllAction();
+ }
+ break;
+
+ case SID_MAIL_EXPORT_FINISHED:
+ {
+ if(pWrtShell)
+ pWrtShell->StartAllAction();
+ //try to undo the removal of invisible content
+ pDoc->RestoreInvisibleContent();
+ if(pWrtShell)
+ pWrtShell->EndAllAction();
+ }
+ break;
+ case FN_NEW_HTML_DOC:
+ case FN_NEW_GLOBAL_DOC:
+ {
+ bDone = sal_False;
+ bool bCreateHtml = FN_NEW_HTML_DOC == nWhich;
+
+ bool bCreateByOutlineLevel = false;
+ sal_Int32 nTemplateOutlineLevel = 0;
+
+ OUString aFileName, aTemplateName;
+ if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( nWhich, false, &pItem ) )
+ {
+ aFileName = ((const SfxStringItem*)pItem)->GetValue();
+ SFX_ITEMSET_ARG( pArgs, pTemplItem, SfxStringItem, SID_TEMPLATE_NAME, false );
+ if ( pTemplItem )
+ aTemplateName = pTemplItem->GetValue();
+ }
+ bool bError = false;
+ if ( aFileName.isEmpty() )
+ {
+ FileDialogHelper aDlgHelper( TemplateDescription::FILESAVE_AUTOEXTENSION_TEMPLATE, 0 );
+
+ const sal_Int16 nControlIds[] = {
+ CommonFilePickerElementIds::PUSHBUTTON_OK,
+ CommonFilePickerElementIds::PUSHBUTTON_CANCEL,
+ CommonFilePickerElementIds::LISTBOX_FILTER,
+ CommonFilePickerElementIds::CONTROL_FILEVIEW,
+ CommonFilePickerElementIds::EDIT_FILEURL,
+ ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION,
+ ExtendedFilePickerElementIds::LISTBOX_TEMPLATE,
+ 0
+ };
+
+ const char* aHTMLHelpIds[] =
+ {
+ HID_SEND_HTML_CTRL_PUSHBUTTON_OK,
+ HID_SEND_HTML_CTRL_PUSHBUTTON_CANCEL,
+ HID_SEND_HTML_CTRL_LISTBOX_FILTER,
+ HID_SEND_HTML_CTRL_CONTROL_FILEVIEW,
+ HID_SEND_HTML_CTRL_EDIT_FILEURL,
+ HID_SEND_HTML_CTRL_CHECKBOX_AUTOEXTENSION,
+ HID_SEND_HTML_CTRL_LISTBOX_TEMPLATE,
+ ""
+ };
+
+ const char* aMasterHelpIds[] =
+ {
+ HID_SEND_MASTER_CTRL_PUSHBUTTON_OK,
+ HID_SEND_MASTER_CTRL_PUSHBUTTON_CANCEL,
+ HID_SEND_MASTER_CTRL_LISTBOX_FILTER,
+ HID_SEND_MASTER_CTRL_CONTROL_FILEVIEW,
+ HID_SEND_MASTER_CTRL_EDIT_FILEURL,
+ HID_SEND_MASTER_CTRL_CHECKBOX_AUTOEXTENSION,
+ HID_SEND_MASTER_CTRL_LISTBOX_TEMPLATE,
+ ""
+ };
+
+ const char** pHelpIds = bCreateHtml ? aHTMLHelpIds : aMasterHelpIds;
+ aDlgHelper.SetControlHelpIds( nControlIds, pHelpIds );
+ uno::Reference < XFilePicker > xFP = aDlgHelper.GetFilePicker();
+
+ const SfxFilter* pFlt;
+ sal_uInt16 nStrId;
+
+ if( bCreateHtml )
+ {
+ // for HTML there is only one filter!!
+ pFlt = SwIoSystem::GetFilterOfFormat(
+ OUString("HTML"),
+ SwWebDocShell::Factory().GetFilterContainer() );
+ nStrId = STR_LOAD_HTML_DOC;
+ }
+ else
+ {
+ // for Global-documents we now only offer the current one.
+ pFlt = SwGlobalDocShell::Factory().GetFilterContainer()->
+ GetFilter4Extension( OUString("odm") );
+ nStrId = STR_LOAD_GLOBAL_DOC;
+ }
+
+ if( pFlt )
+ {
+ uno::Reference<XFilterManager> xFltMgr(xFP, UNO_QUERY);
+ const OUString sWild = pFlt->GetWildcard().getGlob();
+ xFltMgr->appendFilter( pFlt->GetUIName(), sWild );
+ try
+ {
+ xFltMgr->setCurrentFilter( pFlt->GetUIName() ) ;
+ }
+ catch (const uno::Exception&)
+ {
+ bError = true;
+ }
+ }
+ if(!bError)
+ {
+ uno::Reference<XFilePickerControlAccess> xCtrlAcc(xFP, UNO_QUERY);
+
+ bool bOutline[MAXLEVEL] = {false};
+ const SwOutlineNodes& rOutlNds = pDoc->GetNodes().GetOutLineNds();
+ if( !rOutlNds.empty() )
+ {
+ int nLevel;
+ for(sal_uInt16 n = 0; n < rOutlNds.size(); ++n )
+ if( ( nLevel = rOutlNds[n]->GetTxtNode()->GetAttrOutlineLevel()) > 0 &&
+ ! bOutline[nLevel-1] )
+ {
+ bOutline[nLevel-1] = true;
+ }
+ }
+
+ const sal_uInt16 nStyleCount = pDoc->GetTxtFmtColls()->size();
+ Sequence<OUString> aListBoxEntries( MAXLEVEL + nStyleCount);
+ OUString* pEntries = aListBoxEntries.getArray();
+ sal_Int32 nIdx = 0 ;
+
+ OUString sOutline( SW_RESSTR(STR_FDLG_OUTLINE_LEVEL) );
+ for( sal_uInt16 i = 0; i < MAXLEVEL; ++i )
+ {
+ if( bOutline[i] )
+ pEntries[nIdx++] = sOutline + OUString::number( i+1 );
+ }
+
+ OUString sStyle( SW_RESSTR(STR_FDLG_STYLE) );
+ for(sal_uInt16 i = 0; i < nStyleCount; ++i)
+ {
+ SwTxtFmtColl &rTxtColl = *(*pDoc->GetTxtFmtColls())[ i ];
+ if( !rTxtColl.IsDefault() && rTxtColl.IsAtDocNodeSet() )
+ {
+ pEntries[nIdx++] = sStyle + rTxtColl.GetName();
+ }
+ }
+
+ aListBoxEntries.realloc(nIdx);
+ sal_Int16 nSelect = 0;
+
+ try
+ {
+ Any aTemplates(&aListBoxEntries, ::getCppuType(&aListBoxEntries));
+
+ xCtrlAcc->setValue( ExtendedFilePickerElementIds::LISTBOX_TEMPLATE,
+ ListboxControlActions::ADD_ITEMS , aTemplates );
+ Any aSelectPos(&nSelect, ::getCppuType(&nSelect));
+ xCtrlAcc->setValue( ExtendedFilePickerElementIds::LISTBOX_TEMPLATE,
+ ListboxControlActions::SET_SELECT_ITEM, aSelectPos );
+ xCtrlAcc->setLabel( ExtendedFilePickerElementIds::LISTBOX_TEMPLATE,
+ OUString(SW_RES( STR_FDLG_TEMPLATE_NAME )));
+ }
+ catch (const Exception&)
+ {
+ OSL_FAIL("control acces failed");
+ }
+
+ xFP->setTitle( SW_RESSTR( nStrId ));
+ SvtPathOptions aPathOpt;
+ xFP->setDisplayDirectory( aPathOpt.GetWorkPath() );
+ if( ERRCODE_NONE == aDlgHelper.Execute())
+ {
+ aFileName = xFP->getFiles().getConstArray()[0];
+ Any aTemplateValue = xCtrlAcc->getValue(
+ ExtendedFilePickerElementIds::LISTBOX_TEMPLATE,
+ ListboxControlActions::GET_SELECTED_ITEM );
+ OUString sTmpl;
+ aTemplateValue >>= sTmpl;
+
+ sal_Int32 nColonPos = sTmpl.indexOf( ':' );
+ OUString sPrefix = sTmpl.copy( 0L, nColonPos );
+ if ( sPrefix == "Style" )
+ {
+ aTemplateName = sTmpl.copy( 7L ); //get string behind "Style: "
+ }
+ else if ( sPrefix == "Outline" )
+ {
+ nTemplateOutlineLevel = ( sTmpl.copy( 15L )).toInt32(); //get string behind "Outline: Leve ";
+ bCreateByOutlineLevel = true;
+ }
+
+ if ( !aFileName.isEmpty() )
+ {
+ rReq.AppendItem( SfxStringItem( nWhich, aFileName ) );
+ if( !aTemplateName.isEmpty() )
+ rReq.AppendItem( SfxStringItem( SID_TEMPLATE_NAME, aTemplateName ) );
+ }
+ }
+ }
+ }
+
+ if( !aFileName.isEmpty() )
+ {
+ if( PrepareClose( sal_False ) )
+ {
+ SwWait aWait( *this, true );
+
+ if ( bCreateByOutlineLevel )
+ {
+ bDone = bCreateHtml
+ ? pDoc->GenerateHTMLDoc( aFileName, nTemplateOutlineLevel )
+ : pDoc->GenerateGlobalDoc( aFileName, nTemplateOutlineLevel );
+ }
+ else
+ {
+ const SwTxtFmtColl* pSplitColl = 0;
+ if ( !aTemplateName.isEmpty() )
+ pSplitColl = pDoc->FindTxtFmtCollByName(aTemplateName);
+ bDone = bCreateHtml
+ ? pDoc->GenerateHTMLDoc( aFileName, pSplitColl )
+ : pDoc->GenerateGlobalDoc( aFileName, pSplitColl );
+ }
+ if( bDone )
+ {
+ SfxStringItem aName( SID_FILE_NAME, aFileName );
+ SfxStringItem aReferer( SID_REFERER, aEmptyOUStr );
+ SfxViewShell* pViewShell = SfxViewShell::GetFirst();
+ while(pViewShell)
+ {
+ //search for the view that created the call
+ if(pViewShell->GetObjectShell() == this && pViewShell->GetDispatcher())
+ {
+ SfxFrameItem* pFrameItem = new SfxFrameItem( SID_DOCFRAME,
+ pViewShell->GetViewFrame() );
+ SfxDispatcher* pDispatch = pViewShell->GetDispatcher();
+ pDispatch->Execute(
+ SID_OPENDOC,
+ SFX_CALLMODE_ASYNCHRON,
+ &aName,
+ &aReferer,
+ pFrameItem, 0L );
+
+ delete pFrameItem;
+ break;
+ }
+ pViewShell = SfxViewShell::GetNext(*pViewShell);
+ }
+ }
+ }
+ if( !bDone && !rReq.IsAPI() )
+ {
+ InfoBox( 0, SW_RESSTR( STR_CANTCREATE )).Execute();
+ }
+ }
+ }
+ rReq.SetReturnValue(SfxBoolItem( nWhich, bDone ));
+ if (bDone)
+ rReq.Done();
+ else
+ rReq.Ignore();
+ break;
+
+ case SID_ATTR_YEAR2000:
+ if ( pArgs && SFX_ITEM_SET == pArgs->GetItemState( nWhich , false, &pItem ))
+ {
+ OSL_ENSURE(pItem->ISA(SfxUInt16Item), "wrong Item");
+ sal_uInt16 nYear2K = ((SfxUInt16Item*)pItem)->GetValue();
+ // iterate over Views and put the State to FormShells
+
+ SfxViewFrame* pVFrame = SfxViewFrame::GetFirst( this );
+ SfxViewShell* pViewShell = pVFrame ? pVFrame->GetViewShell() : 0;
+ SwView* pCurrView = dynamic_cast< SwView* >( pViewShell );
+ while(pCurrView)
+ {
+ FmFormShell* pFormShell = pCurrView->GetFormShell();
+ if(pFormShell)
+ pFormShell->SetY2KState(nYear2K);
+ pVFrame = SfxViewFrame::GetNext( *pVFrame, this );
+ pViewShell = pVFrame ? pVFrame->GetViewShell() : 0;
+ pCurrView = dynamic_cast<SwView*>( pViewShell );
+ }
+ pDoc->GetNumberFormatter(sal_True)->SetYear2000(nYear2K);
+ }
+ break;
+ case FN_OPEN_FILE:
+ {
+ SfxViewShell* pViewShell = GetView();
+ if (!pViewShell)
+ pViewShell = SfxViewShell::Current();
+
+ if (!pViewShell)
+ // Ok. I did my best.
+ break;
+
+ SfxStringItem aApp(SID_DOC_SERVICE, OUString("com.sun.star.text.TextDocument"));
+ SfxStringItem aTarget(SID_TARGETNAME, OUString("_blank"));
+ pViewShell->GetDispatcher()->Execute(
+ SID_OPENDOC, SFX_CALLMODE_API|SFX_CALLMODE_SYNCHRON, &aApp, &aTarget, 0L);
+ }
+ break;
+
+ default: OSL_FAIL("wrong Dispatcher");
+ }
+}
+
+ // #FIXME - align with NEW event stuff ( if possible )
+#if 0
+void lcl_processCompatibleSfxHint( const uno::Reference< document::XVbaEventsHelper >& xVbaEventsHelper, const SfxHint& rHint )
+{
+ if ( rHint.ISA( SfxEventHint ) )
+ {
+ uno::Sequence< uno::Any > aArgs;
+ sal_uLong nEventId = ((SfxEventHint&)rHint).GetEventId();
+ switch( nEventId )
+ {
+ case SFX_EVENT_CREATEDOC:
+ {
+ xVbaEventsHelper->ProcessCompatibleVbaEvent( VBAEVENT_DOCUMENT_NEW, aArgs );
+ break;
+ }
+ case SFX_EVENT_OPENDOC:
+ {
+ xVbaEventsHelper->ProcessCompatibleVbaEvent( VBAEVENT_DOCUMENT_OPEN, aArgs );
+ break;
+ }
+ default:
+ {
+ //do nothing
+ }
+ }
+ }
+}
+#endif
+
+bool SwDocShell::DdeGetData( const OUString& rItem, const OUString& rMimeType,
+ uno::Any & rValue )
+{
+ return pDoc->GetData( rItem, rMimeType, rValue );
+}
+
+bool SwDocShell::DdeSetData( const OUString& rItem, const OUString& rMimeType,
+ const uno::Any & rValue )
+{
+ return pDoc->SetData( rItem, rMimeType, rValue );
+}
+
+::sfx2::SvLinkSource* SwDocShell::DdeCreateLinkSource( const OUString& rItem )
+{
+ return pDoc->CreateLinkSource( rItem );
+}
+
+void SwDocShell::ReconnectDdeLink(SfxObjectShell& rServer)
+{
+ if ( pDoc ) {
+ ::sfx2::LinkManager& rLinkManager = pDoc->GetLinkManager();
+ rLinkManager.ReconnectDdeLink(rServer);
+ }
+}
+
+void SwDocShell::FillClass( SvGlobalName * pClassName,
+ sal_uInt32 * pClipFormat,
+ OUString * /*pAppName*/,
+ OUString * pLongUserName,
+ OUString * pUserName,
+ sal_Int32 nVersion,
+ sal_Bool bTemplate /* = sal_False */) const
+{
+ if (nVersion == SOFFICE_FILEFORMAT_60)
+ {
+ *pClassName = SvGlobalName( SO3_SW_CLASSID_60 );
+ *pClipFormat = SOT_FORMATSTR_ID_STARWRITER_60;
+ *pLongUserName = SW_RESSTR(STR_WRITER_DOCUMENT_FULLTYPE);
+ }
+ else if (nVersion == SOFFICE_FILEFORMAT_8)
+ {
+ *pClassName = SvGlobalName( SO3_SW_CLASSID_60 );
+ *pClipFormat = bTemplate ? SOT_FORMATSTR_ID_STARWRITER_8_TEMPLATE : SOT_FORMATSTR_ID_STARWRITER_8;
+ *pLongUserName = SW_RESSTR(STR_WRITER_DOCUMENT_FULLTYPE);
+ }
+// #FIXME check with new Event handling
+#if 0
+ uno::Reference< document::XVbaEventsHelper > xVbaEventsHelper = pDoc->GetVbaEventsHelper();
+ if( xVbaEventsHelper.is() )
+ lcl_processCompatibleSfxHint( xVbaEventsHelper, rHint );
+#endif
+
+ *pUserName = SW_RESSTR(STR_HUMAN_SWDOC_NAME);
+}
+
+void SwDocShell::SetModified( sal_Bool bSet )
+{
+ SfxObjectShell::SetModified( bSet );
+ if( IsEnableSetModified())
+ {
+ if (!pDoc->IsInCallModified() )
+ {
+ EnableSetModified( sal_False );
+ if( bSet )
+ {
+ sal_Bool bOld = pDoc->IsModified();
+ pDoc->SetModified();
+ if( !bOld )
+ {
+ pDoc->GetIDocumentUndoRedo().SetUndoNoResetModified();
+ }
+ }
+ else
+ pDoc->ResetModified();
+
+ EnableSetModified( sal_True );
+ }
+
+ UpdateChildWindows();
+ Broadcast(SfxSimpleHint(SFX_HINT_DOCCHANGED));
+ }
+}
+
+void SwDocShell::UpdateChildWindows()
+{
+ // if necessary newly initialize Flddlg (i.e. for TYP_SETVAR)
+ if(!GetView())
+ return;
+ SfxViewFrame* pVFrame = GetView()->GetViewFrame();
+ SwFldDlgWrapper *pWrp = (SwFldDlgWrapper*)pVFrame->
+ GetChildWindow( SwFldDlgWrapper::GetChildWindowId() );
+ if( pWrp )
+ pWrp->ReInitDlg( this );
+
+ // if necessary newly initialize RedlineDlg
+ SwRedlineAcceptChild *pRed = (SwRedlineAcceptChild*)pVFrame->
+ GetChildWindow( SwRedlineAcceptChild::GetChildWindowId() );
+ if( pRed )
+ pRed->ReInitDlg( this );
+}
+
+// #i48748#
+class SwReloadFromHtmlReader : public SwReader
+{
+ public:
+ SwReloadFromHtmlReader( SfxMedium& _rTmpMedium,
+ const OUString& _rFilename,
+ SwDoc* _pDoc )
+ : SwReader( _rTmpMedium, _rFilename, _pDoc )
+ {
+ SetBaseURL( _rFilename );
+ }
+};
+
+void SwDocShell::ReloadFromHtml( const OUString& rStreamName, SwSrcView* pSrcView )
+{
+ sal_Bool bModified = IsModified();
+
+ // The HTTP-Header fields have to be removed, otherwise
+ // there are some from Meta-Tags dublicated or triplicated afterwards.
+ ClearHeaderAttributesForSourceViewHack();
+
+#ifndef DISABLE_SCRIPTING
+ // The Document-Basic also bites the dust ...
+ // A EnterBasicCall is not needed here, because nothing is called and
+ // there can't be any Dok-Basic, that has not yet been loaded inside
+ // of an HTML document.
+ SvxHtmlOptions& rHtmlOptions = SvxHtmlOptions::Get();
+ //#59620# HasBasic() shows, that there already is a BasicManager at the DocShell.
+ // That was always generated in HTML-Import, when there are
+ // Macros in the source code.
+ if( rHtmlOptions.IsStarBasic() && HasBasic())
+ {
+ BasicManager *pBasicMan = GetBasicManager();
+ if( pBasicMan && (pBasicMan != SFX_APP()->GetBasicManager()) )
+ {
+ sal_uInt16 nLibCount = pBasicMan->GetLibCount();
+ while( nLibCount )
+ {
+ StarBASIC *pBasic = pBasicMan->GetLib( --nLibCount );
+ if( pBasic )
+ {
+ // Notify the IDE
+ SfxUsrAnyItem aShellItem( SID_BASICIDE_ARG_DOCUMENT_MODEL, makeAny( GetModel() ) );
+ OUString aLibName( pBasic->GetName() );
+ SfxStringItem aLibNameItem( SID_BASICIDE_ARG_LIBNAME, aLibName );
+ pSrcView->GetViewFrame()->GetDispatcher()->Execute(
+ SID_BASICIDE_LIBREMOVED,
+ SFX_CALLMODE_SYNCHRON,
+ &aShellItem, &aLibNameItem, 0L );
+
+ // Only the modules are deleted from the standard-lib
+ if( nLibCount )
+ pBasicMan->RemoveLib( nLibCount, sal_True );
+ else
+ pBasic->Clear();
+ }
+ }
+
+ OSL_ENSURE( pBasicMan->GetLibCount() <= 1,
+ "Deleting Basics didn't work" );
+ }
+ }
+#endif
+ sal_Bool bWasBrowseMode = pDoc->get(IDocumentSettingAccess::BROWSE_MODE);
+ RemoveLink();
+
+ // now also the UNO-Model has to be informed about the new Doc #51535#
+ uno::Reference<text::XTextDocument> xDoc(GetBaseModel(), uno::UNO_QUERY);
+ text::XTextDocument* pxDoc = xDoc.get();
+ ((SwXTextDocument*)pxDoc)->InitNewDoc();
+
+ AddLink();
+ //#116402# update font list when new document is created
+ UpdateFontList();
+ pDoc->set(IDocumentSettingAccess::BROWSE_MODE, bWasBrowseMode);
+ pSrcView->SetPool(&GetPool());
+
+ const OUString& rMedname = GetMedium()->GetName();
+
+ // The HTML template still has to be set
+ SetHTMLTemplate( *GetDoc() ); //Styles from HTML.vor
+
+ SfxViewShell* pViewShell = GetView() ? (SfxViewShell*)GetView()
+ : SfxViewShell::Current();
+ SfxViewFrame* pViewFrm = pViewShell->GetViewFrame();
+ pViewFrm->GetDispatcher()->Execute( SID_VIEWSHELL0, SFX_CALLMODE_SYNCHRON );
+
+ SubInitNew();
+
+ SfxMedium aMed( rStreamName, STREAM_READ );
+ // #i48748# - use class <SwReloadFromHtmlReader>, because
+ // the base URL has to be set to the filename of the document <rMedname>
+ // and not to the base URL of the temporary file <aMed> in order to get
+ // the URLs of the linked graphics correctly resolved.
+ SwReloadFromHtmlReader aReader( aMed, rMedname, pDoc );
+
+ aReader.Read( *ReadHTML );
+
+ const SwView* pCurrView = GetView();
+ //in print layout the first page(s) may have been formatted as a mix of browse
+ //and print layout
+ if(!bWasBrowseMode && pCurrView)
+ {
+ SwWrtShell& rWrtSh = pCurrView->GetWrtShell();
+ if( rWrtSh.GetLayout())
+ rWrtSh.CheckBrowseView( sal_True );
+ }
+
+ // Take HTTP-Header-Attibutes over into the DokInfo again.
+ // The Base-URL doesn't matter here because TLX uses the one from the document
+ // for absolutization.
+ SetHeaderAttributesForSourceViewHack();
+
+ if(bModified && !IsReadOnly())
+ SetModified();
+ else
+ pDoc->ResetModified();
+}
+
+sal_uLong SwDocShell::LoadStylesFromFile( const OUString& rURL,
+ SwgReaderOption& rOpt, sal_Bool bUnoCall )
+{
+ sal_uLong nErr = 0;
+
+ // Set filter:
+ OUString sFactory(OUString::createFromAscii(SwDocShell::Factory().GetShortName()));
+ SfxFilterMatcher aMatcher( sFactory );
+
+ // search for filter in WebDocShell, too
+ SfxMedium aMed( rURL, STREAM_STD_READ );
+ const SfxFilter* pFlt = 0;
+ aMatcher.DetectFilter( aMed, &pFlt, sal_False, sal_False );
+ if(!pFlt)
+ {
+ OUString sWebFactory(OUString::createFromAscii(SwWebDocShell::Factory().GetShortName()));
+ SfxFilterMatcher aWebMatcher( sWebFactory );
+ aWebMatcher.DetectFilter( aMed, &pFlt, sal_False, sal_False );
+ }
+ // --> OD #i117339# - trigger import only for own formats
+ bool bImport( false );
+ {
+ if ( aMed.IsStorage() )
+ {
+ // As <SfxMedium.GetFilter().IsOwnFormat() resp. IsOwnTemplateFormat()
+ // does not work correct (e.g., MS Word 2007 XML Template),
+ // use workaround provided by MAV.
+ uno::Reference< embed::XStorage > xStorage = aMed.GetStorage();
+ if ( xStorage.is() )
+ {
+ // use <try-catch> on retrieving <MediaType> in order to check,
+ // if the storage is one of our own ones.
+ try
+ {
+ uno::Reference< beans::XPropertySet > xProps( xStorage, uno::UNO_QUERY_THROW );
+ const OUString aMediaTypePropName( "MediaType" );
+ xProps->getPropertyValue( aMediaTypePropName );
+ bImport = true;
+ }
+ catch (const uno::Exception&)
+ {
+ bImport = false;
+ }
+ }
+ }
+ }
+ if ( bImport )
+ {
+ SwRead pRead = ReadXML;
+ boost::scoped_ptr<SwReader> pReader;
+ boost::scoped_ptr<SwPaM> pPam;
+ // the SW3IO - Reader need the pam/wrtshell, because only then he
+ // insert the styles!
+ if( bUnoCall )
+ {
+ SwNodeIndex aIdx( pDoc->GetNodes().GetEndOfContent(), -1 );
+ pPam.reset(new SwPaM( aIdx ));
+ pReader.reset(new SwReader( aMed, rURL, *pPam ));
+ }
+ else
+ {
+ pReader.reset(new SwReader( aMed, rURL, *pWrtShell->GetCrsr() ));
+ }
+
+ pRead->GetReaderOpt().SetTxtFmts( rOpt.IsTxtFmts() );
+ pRead->GetReaderOpt().SetFrmFmts( rOpt.IsFrmFmts() );
+ pRead->GetReaderOpt().SetPageDescs( rOpt.IsPageDescs() );
+ pRead->GetReaderOpt().SetNumRules( rOpt.IsNumRules() );
+ pRead->GetReaderOpt().SetMerge( rOpt.IsMerge() );
+
+ if( bUnoCall )
+ {
+ UnoActionContext aAction( pDoc );
+ nErr = pReader->Read( *pRead );
+ }
+ else
+ {
+ pWrtShell->StartAllAction();
+ nErr = pReader->Read( *pRead );
+ pWrtShell->EndAllAction();
+ }
+ }
+
+ return nErr;
+}
+
+// Get a client for an embedded object if possible.
+SfxInPlaceClient* SwDocShell::GetIPClient( const ::svt::EmbeddedObjectRef& xObjRef )
+{
+ SfxInPlaceClient* pResult = NULL;
+
+ SwWrtShell* pShell = GetWrtShell();
+ if ( pShell )
+ {
+ pResult = pShell->GetView().FindIPClient( xObjRef.GetObject(), (Window*)&pShell->GetView().GetEditWin() );
+ if ( !pResult )
+ pResult = new SwOleClient( &pShell->GetView(), &pShell->GetView().GetEditWin(), xObjRef );
+ }
+
+ return pResult;
+}
+
+int SwFindDocShell( SfxObjectShellRef& xDocSh,
+ SfxObjectShellLock& xLockRef,
+ const OUString& rFileName,
+ const OUString& rPasswd,
+ const OUString& rFilter,
+ sal_Int16 nVersion,
+ SwDocShell* pDestSh )
+{
+ if ( rFileName.isEmpty() )
+ return 0;
+
+ // 1. Does the file already exist in the list of all Documents?
+ INetURLObject aTmpObj( rFileName );
+ aTmpObj.SetMark( OUString() );
+
+ // Iterate over the DocShell and get the ones with the name
+ TypeId aType( TYPE(SwDocShell) );
+
+ SfxObjectShell* pShell = pDestSh;
+ bool bFirst = 0 != pShell;
+
+ if( !bFirst )
+ // No DocShell passed, starting with the first from the DocShell list
+ pShell = SfxObjectShell::GetFirst( &aType );
+
+ while( pShell )
+ {
+ // We want this one
+ SfxMedium* pMed = pShell->GetMedium();
+ if( pMed && pMed->GetURLObject() == aTmpObj )
+ {
+ const SfxPoolItem* pItem;
+ if( ( SFX_ITEM_SET == pMed->GetItemSet()->GetItemState(
+ SID_VERSION, false, &pItem ) )
+ ? (nVersion == ((SfxInt16Item*)pItem)->GetValue())
+ : !nVersion )
+ {
+ // Found, thus return
+ xDocSh = pShell;
+ return 1;
+ }
+ }
+
+ if( bFirst )
+ {
+ bFirst = false;
+ pShell = SfxObjectShell::GetFirst( &aType );
+ }
+ else
+ pShell = SfxObjectShell::GetNext( *pShell, &aType );
+ }
+
+ // 2. Open the file ourselves
+ SfxMedium* pMed = new SfxMedium( aTmpObj.GetMainURL(
+ INetURLObject::NO_DECODE ), STREAM_READ );
+ if( INET_PROT_FILE == aTmpObj.GetProtocol() )
+ pMed->DownLoad(); // Touch the medium (download it)
+
+ const SfxFilter* pSfxFlt = 0;
+ if( !pMed->GetError() )
+ {
+ SfxFilterMatcher aMatcher( OUString::createFromAscii(SwDocShell::Factory().GetShortName()) );
+
+ // No Filter, so search for it. Else test if the one passed is a valid one
+ if( !rFilter.isEmpty() )
+ {
+ pSfxFlt = aMatcher.GetFilter4FilterName( rFilter );
+ }
+
+ if( nVersion )
+ pMed->GetItemSet()->Put( SfxInt16Item( SID_VERSION, nVersion ));
+
+ if( !rPasswd.isEmpty() )
+ pMed->GetItemSet()->Put( SfxStringItem( SID_PASSWORD, rPasswd ));
+
+ if( !pSfxFlt )
+ aMatcher.DetectFilter( *pMed, &pSfxFlt, sal_False, sal_False );
+
+ if( pSfxFlt )
+ {
+ // We cannot do anything without a Filter
+ pMed->SetFilter( pSfxFlt );
+
+ // If the new shell is created, SfxObjectShellLock should be used to let it be closed later for sure
+ xLockRef = new SwDocShell( SFX_CREATE_MODE_INTERNAL );
+ xDocSh = (SfxObjectShell*)xLockRef;
+ if( xDocSh->DoLoad( pMed ) )
+ return 2;
+ }
+ }
+
+ if( !xDocSh.Is() ) // Medium still needs to be deleted
+ delete pMed;
+
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/app/docshdrw.cxx b/sw/source/core/uibase/app/docshdrw.cxx
new file mode 100644
index 000000000000..12f31e8006ed
--- /dev/null
+++ b/sw/source/core/uibase/app/docshdrw.cxx
@@ -0,0 +1,54 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <hintids.hxx>
+#include <svx/svxids.hrc>
+#include <svl/stritem.hxx>
+#include <svx/drawitem.hxx>
+#include <svx/svdmodel.hxx>
+#include <svx/svdoutl.hxx>
+#include <svx/xtable.hxx>
+
+#include <docsh.hxx>
+#include <doc.hxx>
+
+using namespace ::com::sun::star;
+
+// Load Document
+void SwDocShell::InitDraw()
+{
+ SdrModel *pDrDoc = pDoc->GetDrawModel();
+ if( pDrDoc )
+ {
+ // create Lists and Tables DocShell's ItemSet
+ PutItem( SvxGradientListItem( pDrDoc->GetGradientList(), SID_GRADIENT_LIST ) );
+ PutItem( SvxHatchListItem( pDrDoc->GetHatchList(), SID_HATCH_LIST ) );
+ PutItem( SvxBitmapListItem( pDrDoc->GetBitmapList(), SID_BITMAP_LIST ) );
+ PutItem( SvxDashListItem( pDrDoc->GetDashList(), SID_DASH_LIST ) );
+ PutItem( SvxLineEndListItem( pDrDoc->GetLineEndList(), SID_LINEEND_LIST ) );
+
+ Outliner& rOutliner = pDrDoc->GetDrawOutliner();
+ uno::Reference<linguistic2::XHyphenator> xHyphenator( ::GetHyphenator() );
+ rOutliner.SetHyphenator( xHyphenator );
+ }
+ else
+ PutItem( SvxColorListItem( XColorList::GetStdColorList(), SID_COLOR_TABLE ));
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/app/docshini.cxx b/sw/source/core/uibase/app/docshini.cxx
new file mode 100644
index 000000000000..968ec591f168
--- /dev/null
+++ b/sw/source/core/uibase/app/docshini.cxx
@@ -0,0 +1,682 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <hintids.hxx>
+
+#include <svx/dialogs.hrc>
+#include <i18nlangtag/mslangid.hxx>
+#include <sot/storinfo.hxx>
+#include <sot/storage.hxx>
+#include <svl/zforlist.hxx>
+#include <svtools/ctrltool.hxx>
+#include <unotools/lingucfg.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/sfxmodelfactory.hxx>
+#include <sfx2/printer.hxx>
+#include <sfx2/bindings.hxx>
+#include <svl/asiancfg.hxx>
+#include <editeng/unolingu.hxx>
+#include <sfx2/request.hxx>
+#include <svl/intitem.hxx>
+#include <editeng/adjustitem.hxx>
+#include <editeng/autokernitem.hxx>
+#include <linguistic/lngprops.hxx>
+#include <com/sun/star/document/UpdateDocMode.hpp>
+#include <com/sun/star/i18n/ScriptType.hpp>
+#include <sfx2/docfilt.hxx>
+#include <svx/xtable.hxx>
+#include <svx/drawitem.hxx>
+#include <editeng/fhgtitem.hxx>
+#include <editeng/fontitem.hxx>
+#include <editeng/flstitem.hxx>
+#include <editeng/tstpitem.hxx>
+#include <editeng/langitem.hxx>
+#include <editeng/colritem.hxx>
+#include <editeng/hyphenzoneitem.hxx>
+#include <editeng/svxacorr.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/settings.hxx>
+#include <view.hxx>
+#include <prtopt.hxx>
+#include <fmtcol.hxx>
+#include <docsh.hxx>
+#include <wdocsh.hxx>
+#include <swmodule.hxx>
+#include <doc.hxx>
+#include <docfac.hxx>
+#include <docstyle.hxx>
+#include <shellio.hxx>
+#include <tox.hxx>
+#include <swdtflvr.hxx>
+#include <dbmgr.hxx>
+#include <usrpref.hxx>
+#include <fontcfg.hxx>
+#include <poolfmt.hxx>
+#include <modcfg.hxx>
+#include <globdoc.hxx>
+#include <ndole.hxx>
+#include <mdiexp.hxx>
+#include <unotxdoc.hxx>
+#include <linkenum.hxx>
+#include <swwait.hxx>
+#include <wrtsh.hxx>
+#include <swerror.h>
+#include <globals.hrc>
+#include <unochart.hxx>
+
+// text grid
+#include <tgrditem.hxx>
+
+using namespace ::com::sun::star::i18n;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star;
+
+// Load Document
+sal_Bool SwDocShell::InitNew( const uno::Reference < embed::XStorage >& xStor )
+{
+ sal_Bool bRet = SfxObjectShell::InitNew( xStor );
+ OSL_ENSURE( GetMapUnit() == MAP_TWIP, "map unit is not twip!" );
+ sal_Bool bHTMLTemplSet = sal_False;
+ if( bRet )
+ {
+ AddLink(); // create pDoc / pIo if applicable
+
+ sal_Bool bWeb = ISA( SwWebDocShell );
+ if ( bWeb )
+ bHTMLTemplSet = SetHTMLTemplate( *GetDoc() );// Styles from HTML.vor
+ else if( ISA( SwGlobalDocShell ) )
+ GetDoc()->set(IDocumentSettingAccess::GLOBAL_DOCUMENT, true); // Globaldokument
+
+ if ( GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
+ SwTransferable::InitOle( this, *pDoc );
+
+ // set forbidden characters if necessary
+ SvxAsianConfig aAsian;
+ Sequence<lang::Locale> aLocales = aAsian.GetStartEndCharLocales();
+ if(aLocales.getLength())
+ {
+ const lang::Locale* pLocales = aLocales.getConstArray();
+ for(sal_Int32 i = 0; i < aLocales.getLength(); i++)
+ {
+ ForbiddenCharacters aForbidden;
+ aAsian.GetStartEndChars( pLocales[i], aForbidden.beginLine, aForbidden.endLine);
+ LanguageType eLang = LanguageTag::convertToLanguageType(pLocales[i]);
+ pDoc->setForbiddenCharacters( eLang, aForbidden);
+ }
+ }
+ pDoc->set(IDocumentSettingAccess::KERN_ASIAN_PUNCTUATION,
+ !aAsian.IsKerningWesternTextOnly());
+ pDoc->setCharacterCompressionType(static_cast<SwCharCompressType>(aAsian.GetCharDistanceCompression()));
+ pDoc->setPrintData(*SW_MOD()->GetPrtOptions(bWeb));
+
+ SubInitNew();
+
+ // for all
+
+ SwStdFontConfig* pStdFont = SW_MOD()->GetStdFontConfig();
+ SfxPrinter* pPrt = pDoc->getPrinter( false );
+
+ OUString sEntry;
+ sal_uInt16 aFontWhich[] =
+ { RES_CHRATR_FONT,
+ RES_CHRATR_CJK_FONT,
+ RES_CHRATR_CTL_FONT
+ };
+ sal_uInt16 aFontHeightWhich[] =
+ {
+ RES_CHRATR_FONTSIZE,
+ RES_CHRATR_CJK_FONTSIZE,
+ RES_CHRATR_CTL_FONTSIZE
+ };
+ sal_uInt16 aFontIds[] =
+ {
+ FONT_STANDARD,
+ FONT_STANDARD_CJK,
+ FONT_STANDARD_CTL
+ };
+ sal_uInt16 nFontTypes[] =
+ {
+ DEFAULTFONT_LATIN_TEXT,
+ DEFAULTFONT_CJK_TEXT,
+ DEFAULTFONT_CTL_TEXT
+ };
+ sal_uInt16 aLangTypes[] =
+ {
+ RES_CHRATR_LANGUAGE,
+ RES_CHRATR_CJK_LANGUAGE,
+ RES_CHRATR_CTL_LANGUAGE
+ };
+
+ for(sal_uInt8 i = 0; i < 3; i++)
+ {
+ sal_uInt16 nFontWhich = aFontWhich[i];
+ sal_uInt16 nFontId = aFontIds[i];
+ SvxFontItem* pFontItem = 0;
+ const SvxLanguageItem& rLang = (const SvxLanguageItem&)pDoc->GetDefault( aLangTypes[i] );
+ LanguageType eLanguage = rLang.GetLanguage();
+ if(!pStdFont->IsFontDefault(nFontId))
+ {
+ sEntry = pStdFont->GetFontFor(nFontId);
+
+ Font aFont( sEntry, Size( 0, 10 ) );
+ if( pPrt )
+ {
+ aFont = pPrt->GetFontMetric( aFont );
+ }
+
+ pFontItem = new SvxFontItem(aFont.GetFamily(), aFont.GetName(),
+ aEmptyOUStr, aFont.GetPitch(), aFont.GetCharSet(), nFontWhich);
+ }
+ else
+ {
+ // #107782# OJ use korean language if latin was used
+ if ( i == 0 )
+ {
+ LanguageType eUiLanguage = Application::GetSettings().GetUILanguageTag().getLanguageType();
+ if (MsLangId::isKorean(eUiLanguage))
+ eLanguage = eUiLanguage;
+ }
+
+ Font aLangDefFont = OutputDevice::GetDefaultFont(
+ nFontTypes[i],
+ eLanguage,
+ DEFAULTFONT_FLAGS_ONLYONE );
+ pFontItem = new SvxFontItem(aLangDefFont.GetFamily(), aLangDefFont.GetName(),
+ aEmptyOUStr, aLangDefFont.GetPitch(), aLangDefFont.GetCharSet(), nFontWhich);
+ }
+ pDoc->SetDefault(*pFontItem);
+ if( !bHTMLTemplSet )
+ {
+ SwTxtFmtColl *pColl = pDoc->GetTxtCollFromPool(RES_POOLCOLL_STANDARD);
+ pColl->ResetFmtAttr(nFontWhich);
+ }
+ delete pFontItem;
+ sal_Int32 nFontHeight = pStdFont->GetFontHeight( FONT_STANDARD, i, eLanguage );
+ if(nFontHeight <= 0)
+ nFontHeight = pStdFont->GetDefaultHeightFor( nFontId, eLanguage );
+ pDoc->SetDefault(SvxFontHeightItem( nFontHeight, 100, aFontHeightWhich[i] ));
+ if( !bHTMLTemplSet )
+ {
+ SwTxtFmtColl *pColl = pDoc->GetTxtCollFromPool(RES_POOLCOLL_STANDARD);
+ pColl->ResetFmtAttr(aFontHeightWhich[i]);
+ }
+
+ }
+ sal_uInt16 aFontIdPoolId[] =
+ {
+ FONT_OUTLINE, RES_POOLCOLL_HEADLINE_BASE,
+ FONT_LIST, RES_POOLCOLL_NUMBUL_BASE,
+ FONT_CAPTION, RES_POOLCOLL_LABEL,
+ FONT_INDEX, RES_POOLCOLL_REGISTER_BASE,
+ FONT_OUTLINE_CJK, RES_POOLCOLL_HEADLINE_BASE,
+ FONT_LIST_CJK, RES_POOLCOLL_NUMBUL_BASE,
+ FONT_CAPTION_CJK, RES_POOLCOLL_LABEL,
+ FONT_INDEX_CJK, RES_POOLCOLL_REGISTER_BASE,
+ FONT_OUTLINE_CTL, RES_POOLCOLL_HEADLINE_BASE,
+ FONT_LIST_CTL, RES_POOLCOLL_NUMBUL_BASE,
+ FONT_CAPTION_CTL, RES_POOLCOLL_LABEL,
+ FONT_INDEX_CTL, RES_POOLCOLL_REGISTER_BASE
+ };
+
+ sal_uInt16 nFontWhich = RES_CHRATR_FONT;
+ sal_uInt16 nFontHeightWhich = RES_CHRATR_FONTSIZE;
+ LanguageType eLanguage = static_cast<const SvxLanguageItem&>(pDoc->GetDefault( RES_CHRATR_LANGUAGE )).GetLanguage();
+ for(sal_uInt8 nIdx = 0; nIdx < 24; nIdx += 2)
+ {
+ if(nIdx == 8)
+ {
+ nFontWhich = RES_CHRATR_CJK_FONT;
+ nFontHeightWhich = RES_CHRATR_CJK_FONTSIZE;
+ eLanguage = static_cast<const SvxLanguageItem&>(pDoc->GetDefault( RES_CHRATR_CJK_LANGUAGE )).GetLanguage();
+ }
+ else if(nIdx == 16)
+ {
+ nFontWhich = RES_CHRATR_CTL_FONT;
+ nFontHeightWhich = RES_CHRATR_CTL_FONTSIZE;
+ eLanguage = static_cast<const SvxLanguageItem&>(pDoc->GetDefault( RES_CHRATR_CTL_LANGUAGE )).GetLanguage();
+ }
+ SwTxtFmtColl *pColl = 0;
+ if(!pStdFont->IsFontDefault(aFontIdPoolId[nIdx]))
+ {
+ sEntry = pStdFont->GetFontFor(aFontIdPoolId[nIdx]);
+
+ Font aFont( sEntry, Size( 0, 10 ) );
+ if( pPrt )
+ aFont = pPrt->GetFontMetric( aFont );
+
+ pColl = pDoc->GetTxtCollFromPool(aFontIdPoolId[nIdx + 1]);
+ if( !bHTMLTemplSet ||
+ SFX_ITEM_SET != pColl->GetAttrSet().GetItemState(
+ nFontWhich, false ) )
+ {
+ pColl->SetFmtAttr(SvxFontItem(aFont.GetFamily(), aFont.GetName(),
+ aEmptyOUStr, aFont.GetPitch(), aFont.GetCharSet(), nFontWhich));
+ }
+ }
+ sal_Int32 nFontHeight = pStdFont->GetFontHeight( static_cast< sal_Int8 >(aFontIdPoolId[nIdx]), 0, eLanguage );
+ if(nFontHeight <= 0)
+ nFontHeight = pStdFont->GetDefaultHeightFor( aFontIdPoolId[nIdx], eLanguage );
+ if(!pColl)
+ pColl = pDoc->GetTxtCollFromPool(aFontIdPoolId[nIdx + 1]);
+ SvxFontHeightItem aFontHeight( (const SvxFontHeightItem&)pColl->GetFmtAttr( nFontHeightWhich, sal_True ));
+ if(aFontHeight.GetHeight() != sal::static_int_cast<sal_uInt32, sal_Int32>(nFontHeight))
+ {
+ aFontHeight.SetHeight(nFontHeight);
+ pColl->SetFmtAttr( aFontHeight );
+ }
+ }
+
+ // the default for documents created via 'File/New' should be 'on'
+ // (old documents, where this property was not yet implemented, will get the
+ // value 'false' in the SwDoc c-tor)
+ pDoc->set( IDocumentSettingAccess::MATH_BASELINE_ALIGNMENT,
+ SW_MOD()->GetUsrPref( bWeb )->IsAlignMathObjectsToBaseline() );
+ }
+
+ /* #106748# If the default frame direction of a document is RTL
+ the default adjusment is to the right. */
+ if( !bHTMLTemplSet &&
+ FRMDIR_HORI_RIGHT_TOP == GetDefaultFrameDirection(GetAppLanguage()) )
+ pDoc->SetDefault( SvxAdjustItem(SVX_ADJUST_RIGHT, RES_PARATR_ADJUST ) );
+
+// #i29550#
+ pDoc->SetDefault( SfxBoolItem( RES_COLLAPSING_BORDERS, true ) );
+// <-- collapsing
+
+ //#i16874# AutoKerning as default for new documents
+ pDoc->SetDefault( SvxAutoKernItem( true, RES_CHRATR_AUTOKERN ) );
+
+ // #i42080# - Due to the several calls of method <SetDefault(..)>
+ // at the document instance, the document is modified. Thus, reset this
+ // status here. Note: In method <SubInitNew()> this is also done.
+ pDoc->ResetModified();
+
+ return bRet;
+}
+
+// Ctor with SfxCreateMode ?????
+SwDocShell::SwDocShell( SfxObjectCreateMode eMode ) :
+ SfxObjectShell ( eMode ),
+ pDoc(0),
+ pFontList(0),
+ pView( 0 ),
+ pWrtShell( 0 ),
+ pOLEChildList( 0 ),
+ nUpdateDocMode(document::UpdateDocMode::ACCORDING_TO_CONFIG),
+ bInUpdateFontList(false)
+{
+ Init_Impl();
+}
+
+// Ctor / Dtor
+SwDocShell::SwDocShell( const sal_uInt64 i_nSfxCreationFlags ) :
+ SfxObjectShell ( i_nSfxCreationFlags ),
+ pDoc(0),
+ pFontList(0),
+ pView( 0 ),
+ pWrtShell( 0 ),
+ pOLEChildList( 0 ),
+ nUpdateDocMode(document::UpdateDocMode::ACCORDING_TO_CONFIG),
+ bInUpdateFontList(false)
+{
+ Init_Impl();
+}
+
+// Ctor / Dtor
+SwDocShell::SwDocShell( SwDoc *pD, SfxObjectCreateMode eMode ):
+ SfxObjectShell ( eMode ),
+ pDoc(pD),
+ pFontList(0),
+ pView( 0 ),
+ pWrtShell( 0 ),
+ pOLEChildList( 0 ),
+ nUpdateDocMode(document::UpdateDocMode::ACCORDING_TO_CONFIG),
+ bInUpdateFontList(false)
+{
+ Init_Impl();
+}
+
+// Dtor
+SwDocShell::~SwDocShell()
+{
+ // disable chart related objects now because in ~SwDoc it may be to late for this
+ if( pDoc )
+ {
+ pDoc->GetChartControllerHelper().Disconnect();
+ SwChartDataProvider *pPCD = pDoc->GetChartDataProvider();
+ if (pPCD)
+ pPCD->dispose();
+ }
+
+ RemoveLink();
+ delete pFontList;
+
+ // we, as BroadCaster also become our own Listener
+ // (for DocInfo/FileNames/....)
+ EndListening( *this );
+
+ delete pOLEChildList;
+}
+
+void SwDocShell::Init_Impl()
+{
+ SetPool(&SW_MOD()->GetPool());
+ SetBaseModel(new SwXTextDocument(this));
+ // we, as BroadCaster also become our own Listener
+ // (for DocInfo/FileNames/....)
+ StartListening( *this );
+ //position of the "Automatic" style filter for the stylist (app.src)
+ SetAutoStyleFilterIndex(3);
+
+ // set map unit to twip
+ SetMapUnit( MAP_TWIP );
+}
+
+// AddLink
+void SwDocShell::AddLink()
+{
+ if( !pDoc )
+ {
+ SwDocFac aFactory;
+ pDoc = aFactory.GetDoc();
+ pDoc->acquire();
+ pDoc->set(IDocumentSettingAccess::HTML_MODE, ISA(SwWebDocShell) );
+ }
+ else
+ pDoc->acquire();
+ pDoc->SetDocShell( this ); // set the DocShell-Pointer for Doc
+ uno::Reference< text::XTextDocument > xDoc(GetBaseModel(), uno::UNO_QUERY);
+ ((SwXTextDocument*)xDoc.get())->Reactivate(this);
+
+ SetPool(&pDoc->GetAttrPool());
+
+ // most suitably not until a sdbcx::View is created!!!
+ pDoc->SetOle2Link(LINK(this, SwDocShell, Ole2ModifiedHdl));
+}
+
+// create new FontList Change Printer
+void SwDocShell::UpdateFontList()
+{
+ if(!bInUpdateFontList)
+ {
+ bInUpdateFontList = true;
+ OSL_ENSURE(pDoc, "No Doc no FontList");
+ if( pDoc )
+ {
+ delete pFontList;
+ pFontList = new FontList( pDoc->getReferenceDevice( true ) );
+ PutItem( SvxFontListItem( pFontList, SID_ATTR_CHAR_FONTLIST ) );
+ }
+ bInUpdateFontList = false;
+ }
+}
+
+// RemoveLink
+void SwDocShell::RemoveLink()
+{
+ // disconnect Uno-Object
+ uno::Reference< text::XTextDocument > xDoc(GetBaseModel(), uno::UNO_QUERY);
+ ((SwXTextDocument*)xDoc.get())->Invalidate();
+ aFinishedTimer.Stop();
+ if(pDoc)
+ {
+ if( mxBasePool.is() )
+ {
+ static_cast<SwDocStyleSheetPool*>(mxBasePool.get())->dispose();
+ mxBasePool.clear();
+ }
+ sal_Int8 nRefCt = static_cast< sal_Int8 >(pDoc->release());
+ pDoc->SetOle2Link(Link());
+ pDoc->SetDocShell( 0 );
+ if( !nRefCt )
+ delete pDoc;
+ pDoc = 0; // we don't have the Doc anymore!!
+ }
+}
+void SwDocShell::InvalidateModel()
+{
+ // disconnect Uno-Object
+ uno::Reference< text::XTextDocument > xDoc(GetBaseModel(), uno::UNO_QUERY);
+ ((SwXTextDocument*)xDoc.get())->Invalidate();
+}
+void SwDocShell::ReactivateModel()
+{
+ // disconnect Uno-Object
+ uno::Reference< text::XTextDocument > xDoc(GetBaseModel(), uno::UNO_QUERY);
+ ((SwXTextDocument*)xDoc.get())->Reactivate(this);
+}
+
+// Load, Default-Format
+sal_Bool SwDocShell::Load( SfxMedium& rMedium )
+{
+ sal_Bool bRet = sal_False;
+ if( SfxObjectShell::Load( rMedium ))
+ {
+ SAL_INFO( "sw.ui", "after SfxInPlaceObject::Load" );
+ if( pDoc ) // for last version!!
+ RemoveLink(); // release the existing
+
+ AddLink(); // set Link and update Data!!
+
+ // Loading
+ // for MD
+ OSL_ENSURE( !mxBasePool.is(), "who hasn't destroyed their Pool?" );
+ mxBasePool = new SwDocStyleSheetPool( *pDoc, SFX_CREATE_MODE_ORGANIZER == GetCreateMode() );
+ if(GetCreateMode() != SFX_CREATE_MODE_ORGANIZER)
+ {
+ SFX_ITEMSET_ARG( rMedium.GetItemSet(), pUpdateDocItem, SfxUInt16Item, SID_UPDATEDOCMODE, false);
+ nUpdateDocMode = pUpdateDocItem ? pUpdateDocItem->GetValue() : document::UpdateDocMode::NO_UPDATE;
+ }
+
+ SwWait aWait( *this, true );
+ sal_uInt32 nErr = ERR_SWG_READ_ERROR;
+ switch( GetCreateMode() )
+ {
+ case SFX_CREATE_MODE_ORGANIZER:
+ {
+ if( ReadXML )
+ {
+ ReadXML->SetOrganizerMode( sal_True );
+ SwReader aRdr( rMedium, aEmptyOUStr, pDoc );
+ nErr = aRdr.Read( *ReadXML );
+ ReadXML->SetOrganizerMode( sal_False );
+ }
+ }
+ break;
+
+ case SFX_CREATE_MODE_INTERNAL:
+ case SFX_CREATE_MODE_EMBEDDED:
+ {
+ // for MWERKS (Mac-Compiler): can't cast autonomously
+ SwTransferable::InitOle( this, *pDoc );
+ }
+ // suppress SfxProgress, when we are Embedded
+ SW_MOD()->SetEmbeddedLoadSave( sal_True );
+ // no break;
+
+ case SFX_CREATE_MODE_STANDARD:
+ case SFX_CREATE_MODE_PREVIEW:
+ {
+ Reader *pReader = ReadXML;
+ if( pReader )
+ {
+ // set Doc's DocInfo at DocShell-Medium
+ SAL_INFO( "sw.ui", "before ReadDocInfo" );
+ SwReader aRdr( rMedium, aEmptyOUStr, pDoc );
+ SAL_INFO( "sw.ui", "before Read" );
+ nErr = aRdr.Read( *pReader );
+ SAL_INFO( "sw.ui", "after Read" );
+ // If a XML document is loaded, the global doc/web doc
+ // flags have to be set, because they aren't loaded
+ // by this formats.
+ if( ISA( SwWebDocShell ) )
+ {
+ if( !pDoc->get(IDocumentSettingAccess::HTML_MODE) )
+ pDoc->set(IDocumentSettingAccess::HTML_MODE, true);
+ }
+ if( ISA( SwGlobalDocShell ) )
+ {
+ if( !pDoc->get(IDocumentSettingAccess::GLOBAL_DOCUMENT) )
+ pDoc->set(IDocumentSettingAccess::GLOBAL_DOCUMENT, true);
+ }
+ }
+ }
+ break;
+
+ default:
+ OSL_ENSURE( !this, "Load: new CreateMode?" );
+ }
+
+ UpdateFontList();
+ InitDraw();
+
+ SetError( nErr, OUString( OSL_LOG_PREFIX ) );
+ bRet = !IsError( nErr );
+
+ if ( bRet && !pDoc->IsInLoadAsynchron() &&
+ GetCreateMode() == SFX_CREATE_MODE_STANDARD )
+ {
+ LoadingFinished();
+ }
+
+ // suppress SfxProgress, when we are Embedded
+ SW_MOD()->SetEmbeddedLoadSave( sal_False );
+ }
+
+ return bRet;
+}
+
+sal_Bool SwDocShell::LoadFrom( SfxMedium& rMedium )
+{
+ sal_Bool bRet = sal_False;
+ if( pDoc )
+ RemoveLink();
+
+ AddLink(); // set Link and update Data!!
+
+ do { // middle check loop
+ sal_uInt32 nErr = ERR_SWG_READ_ERROR;
+ OUString aStreamName = "styles.xml";
+ uno::Reference < container::XNameAccess > xAccess( rMedium.GetStorage(), uno::UNO_QUERY );
+ if ( xAccess->hasByName( aStreamName ) && rMedium.GetStorage()->isStreamElement( aStreamName ) )
+ {
+ // Loading
+ SwWait aWait( *this, true );
+ {
+ OSL_ENSURE( !mxBasePool.is(), "who hasn't destroyed their Pool?" );
+ mxBasePool = new SwDocStyleSheetPool( *pDoc, SFX_CREATE_MODE_ORGANIZER == GetCreateMode() );
+ if( ReadXML )
+ {
+ ReadXML->SetOrganizerMode( sal_True );
+ SwReader aRdr( rMedium, aEmptyOUStr, pDoc );
+ nErr = aRdr.Read( *ReadXML );
+ ReadXML->SetOrganizerMode( sal_False );
+ }
+ }
+ }
+ else
+ {
+ OSL_FAIL("Code removed!");
+ }
+
+ SetError( nErr, OUString( OSL_LOG_PREFIX ) );
+ bRet = !IsError( nErr );
+
+ } while( false );
+
+ SfxObjectShell::LoadFrom( rMedium );
+ pDoc->ResetModified();
+ return bRet;
+}
+
+void SwDocShell::SubInitNew()
+{
+ OSL_ENSURE( !mxBasePool.is(), "who hasn't destroyed their Pool?" );
+ mxBasePool = new SwDocStyleSheetPool( *pDoc, SFX_CREATE_MODE_ORGANIZER == GetCreateMode() );
+ UpdateFontList();
+ InitDraw();
+
+ pDoc->setLinkUpdateMode( GLOBALSETTING );
+ pDoc->setFieldUpdateFlags( AUTOUPD_GLOBALSETTING );
+
+ sal_Bool bWeb = ISA(SwWebDocShell);
+
+ sal_uInt16 nRange[] = {
+ RES_PARATR_ADJUST, RES_PARATR_ADJUST,
+ RES_CHRATR_COLOR, RES_CHRATR_COLOR,
+ RES_CHRATR_LANGUAGE, RES_CHRATR_LANGUAGE,
+ RES_CHRATR_CJK_LANGUAGE, RES_CHRATR_CJK_LANGUAGE,
+ RES_CHRATR_CTL_LANGUAGE, RES_CHRATR_CTL_LANGUAGE,
+ 0, 0, 0 };
+ if(!bWeb)
+ {
+ nRange[ (sizeof(nRange)/sizeof(nRange[0])) - 3 ] = RES_PARATR_TABSTOP;
+ nRange[ (sizeof(nRange)/sizeof(nRange[0])) - 2 ] = RES_PARATR_HYPHENZONE;
+ }
+ SfxItemSet aDfltSet( pDoc->GetAttrPool(), nRange );
+
+ //! get lingu options without loading lingu DLL
+ SvtLinguOptions aLinguOpt;
+
+ SvtLinguConfig().GetOptions( aLinguOpt );
+
+ sal_Int16 nVal = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage, ::com::sun::star::i18n::ScriptType::LATIN),
+ eCJK = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CJK, ::com::sun::star::i18n::ScriptType::ASIAN),
+ eCTL = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CTL, ::com::sun::star::i18n::ScriptType::COMPLEX);
+ aDfltSet.Put( SvxLanguageItem( nVal, RES_CHRATR_LANGUAGE ) );
+ aDfltSet.Put( SvxLanguageItem( eCJK, RES_CHRATR_CJK_LANGUAGE ) );
+ aDfltSet.Put( SvxLanguageItem( eCTL, RES_CHRATR_CTL_LANGUAGE ) );
+
+ if(!bWeb)
+ {
+ SvxHyphenZoneItem aHyp( (SvxHyphenZoneItem&) pDoc->GetDefault(
+ RES_PARATR_HYPHENZONE) );
+ aHyp.GetMinLead() = static_cast< sal_uInt8 >(aLinguOpt.nHyphMinLeading);
+ aHyp.GetMinTrail() = static_cast< sal_uInt8 >(aLinguOpt.nHyphMinTrailing);
+
+ aDfltSet.Put( aHyp );
+
+ sal_uInt16 nNewPos = static_cast< sal_uInt16 >(SW_MOD()->GetUsrPref(sal_False)->GetDefTab());
+ if( nNewPos )
+ aDfltSet.Put( SvxTabStopItem( 1, nNewPos,
+ SVX_TAB_ADJUST_DEFAULT, RES_PARATR_TABSTOP ) );
+ }
+ aDfltSet.Put( SvxColorItem( Color( COL_AUTO ), RES_CHRATR_COLOR ) );
+
+ pDoc->SetDefault( aDfltSet );
+
+ //default page mode for text grid
+ if(!bWeb)
+ {
+ sal_Bool bSquaredPageMode = SW_MOD()->GetUsrPref(sal_False)->IsSquaredPageMode();
+ pDoc->SetDefaultPageMode( bSquaredPageMode );
+ }
+
+ pDoc->ResetModified();
+}
+
+/*
+ * Document Interface Access
+ */
+IDocumentDeviceAccess* SwDocShell::getIDocumentDeviceAccess() { return pDoc; }
+const IDocumentSettingAccess* SwDocShell::getIDocumentSettingAccess() const { return pDoc; }
+IDocumentChartDataProviderAccess* SwDocShell::getIDocumentChartDataProviderAccess() { return pDoc; }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/app/docst.cxx b/sw/source/core/uibase/app/docst.cxx
new file mode 100644
index 000000000000..896062714055
--- /dev/null
+++ b/sw/source/core/uibase/app/docst.cxx
@@ -0,0 +1,1255 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+
+#include <comphelper/flagguard.hxx>
+
+#include <hintids.hxx>
+#include <sfx2/app.hxx>
+#include <svl/whiter.hxx>
+#include <sfx2/templdlg.hxx>
+#include <sfx2/tplpitem.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/newstyle.hxx>
+#include <sfx2/printer.hxx>
+#include <svl/macitem.hxx>
+#include <svl/stritem.hxx>
+#include <svl/languageoptions.hxx>
+#include <editeng/eeitem.hxx>
+#include <sfx2/htmlmode.hxx>
+#include <swmodule.hxx>
+#include <wdocsh.hxx>
+#include <fmtfsize.hxx>
+#include <fchrfmt.hxx>
+#include <svtools/htmlcfg.hxx>
+#include <SwStyleNameMapper.hxx>
+#include <SwRewriter.hxx>
+#include <numrule.hxx>
+#include <swundo.hxx>
+
+#include "view.hxx"
+#include "wrtsh.hxx"
+#include "docsh.hxx"
+#include "uitool.hxx"
+#include "cmdid.h"
+#include "globals.hrc"
+#include "viewopt.hxx"
+#include <doc.hxx>
+#include <IDocumentUndoRedo.hxx>
+#include "swstyle.h"
+#include "frmfmt.hxx"
+#include "charfmt.hxx"
+#include "poolfmt.hxx"
+#include "pagedesc.hxx"
+#include "docstyle.hxx"
+#include "uiitems.hxx"
+#include "fmtcol.hxx"
+#include "frmmgr.hxx"
+#include "swevent.hxx"
+#include "edtwin.hxx"
+#include "unochart.hxx"
+
+#include "app.hrc"
+#include "swabstdlg.hxx"
+
+#include <list.hxx>
+
+#include <paratr.hxx>
+
+extern bool bNoInterrupt; // in mainwn.cxx
+
+using namespace ::com::sun::star;
+
+void SwDocShell::StateStyleSheet(SfxItemSet& rSet, SwWrtShell* pSh)
+{
+ SfxWhichIter aIter(rSet);
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ sal_uInt16 nActualFamily = USHRT_MAX;
+
+ SwWrtShell* pShell = pSh ? pSh : GetWrtShell();
+ if(!pShell)
+ {
+ while (nWhich)
+ {
+ rSet.DisableItem(nWhich);
+ nWhich = aIter.NextWhich();
+ }
+ return;
+ }
+ else
+ {
+ SfxViewFrame* pFrame = pShell->GetView().GetViewFrame();
+ const ISfxTemplateCommon* pCommon = SFX_APP()->GetCurrentTemplateCommon(pFrame->GetBindings());
+ if( pCommon )
+ nActualFamily = static_cast< sal_uInt16 >(pCommon->GetActualFamily());
+ }
+
+ while (nWhich)
+ {
+ // determine current template to every family
+ OUString aName;
+ switch (nWhich)
+ {
+ case SID_STYLE_APPLY:
+ {// here the template and its family are passed to the StyleBox
+ // so that this family is being showed
+ if(pShell->IsFrmSelected())
+ {
+ SwFrmFmt* pFmt = pShell->GetCurFrmFmt();
+ if( pFmt )
+ aName = pFmt->GetName();
+ }
+ else
+ {
+ SwTxtFmtColl* pColl = pShell->GetCurTxtFmtColl();
+ if(pColl)
+ aName = pColl->GetName();
+ }
+ rSet.Put(SfxTemplateItem(nWhich, aName));
+ }
+ break;
+ case SID_STYLE_FAMILY1:
+ if( !pShell->IsFrmSelected() )
+ {
+ SwCharFmt* pFmt = pShell->GetCurCharFmt();
+ if(pFmt)
+ aName = pFmt->GetName();
+ else
+ aName = SwStyleNameMapper::GetTextUINameArray()[
+ RES_POOLCOLL_STANDARD - RES_POOLCOLL_TEXT_BEGIN ];
+ rSet.Put(SfxTemplateItem(nWhich, aName));
+ }
+ break;
+
+ case SID_STYLE_FAMILY2:
+ if(!pShell->IsFrmSelected())
+ {
+ SwTxtFmtColl* pColl = pShell->GetCurTxtFmtColl();
+ if(pColl)
+ aName = pColl->GetName();
+
+ SfxTemplateItem aItem(nWhich, aName);
+
+ sal_uInt16 nMask = 0;
+ if( pDoc->get(IDocumentSettingAccess::HTML_MODE) )
+ nMask = SWSTYLEBIT_HTML;
+ else
+ {
+ const int nSelection = pShell->GetFrmType(0,sal_True);
+ if(pShell->GetCurTOX())
+ nMask = SWSTYLEBIT_IDX ;
+ else if(nSelection & FRMTYPE_HEADER ||
+ nSelection & FRMTYPE_FOOTER ||
+ nSelection & FRMTYPE_TABLE ||
+ nSelection & FRMTYPE_FLY_ANY ||
+ nSelection & FRMTYPE_FOOTNOTE ||
+ nSelection & FRMTYPE_FTNPAGE)
+ nMask = SWSTYLEBIT_EXTRA;
+ else
+ nMask = SWSTYLEBIT_TEXT;
+ }
+
+ aItem.SetValue(nMask);
+ rSet.Put(aItem);
+ }
+
+ break;
+
+ case SID_STYLE_FAMILY3:
+
+ if( pDoc->get(IDocumentSettingAccess::HTML_MODE) )
+ rSet.DisableItem( nWhich );
+ else
+ {
+ SwFrmFmt* pFmt = pShell->GetCurFrmFmt();
+ if(pFmt && pShell->IsFrmSelected())
+ {
+ aName = pFmt->GetName();
+ rSet.Put(SfxTemplateItem(nWhich, aName));
+ }
+ }
+ break;
+
+ case SID_STYLE_FAMILY4:
+ {
+ SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get();
+ if( pDoc->get(IDocumentSettingAccess::HTML_MODE) && !rHtmlOpt.IsPrintLayoutExtension())
+ rSet.DisableItem( nWhich );
+ else
+ {
+ sal_uInt16 n = pShell->GetCurPageDesc( sal_False );
+ if( n < pShell->GetPageDescCnt() )
+ aName = pShell->GetPageDesc( n ).GetName();
+
+ rSet.Put(SfxTemplateItem(nWhich, aName));
+ }
+ }
+ break;
+ case SID_STYLE_FAMILY5:
+ {
+ const SwNumRule* pRule = pShell->GetCurNumRule();
+ if( pRule )
+ aName = pRule->GetName();
+
+ rSet.Put(SfxTemplateItem(nWhich, aName));
+ }
+ break;
+
+ case SID_STYLE_WATERCAN:
+ {
+ SwEditWin& rEdtWin = pShell->GetView().GetEditWin();
+ SwApplyTemplate* pApply = rEdtWin.GetApplyTemplate();
+ rSet.Put(SfxBoolItem(nWhich, pApply && pApply->eType != 0));
+ }
+ break;
+ case SID_STYLE_UPDATE_BY_EXAMPLE:
+ if( pShell->IsFrmSelected()
+ ? SFX_STYLE_FAMILY_FRAME != nActualFamily
+ : ( SFX_STYLE_FAMILY_FRAME == nActualFamily ||
+ SFX_STYLE_FAMILY_PAGE == nActualFamily ||
+ (SFX_STYLE_FAMILY_PSEUDO == nActualFamily && !pShell->GetCurNumRule())) )
+ {
+ rSet.DisableItem( nWhich );
+ }
+ break;
+
+ case SID_STYLE_NEW_BY_EXAMPLE:
+ if( (pShell->IsFrmSelected()
+ ? SFX_STYLE_FAMILY_FRAME != nActualFamily
+ : SFX_STYLE_FAMILY_FRAME == nActualFamily) ||
+ (SFX_STYLE_FAMILY_PSEUDO == nActualFamily && !pShell->GetCurNumRule()) )
+ {
+ rSet.DisableItem( nWhich );
+ }
+ break;
+
+ default:
+ OSL_FAIL("Invalid SlotId");
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+// evaluate StyleSheet-Requests
+void SwDocShell::ExecStyleSheet( SfxRequest& rReq )
+{
+ sal_uInt16 nSlot = rReq.GetSlot();
+ sal_uInt16 nRet = SFXSTYLEBIT_ALL;
+
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ const SfxPoolItem* pItem;
+ SwWrtShell* pActShell = 0;
+ switch (nSlot)
+ {
+ case SID_STYLE_NEW:
+ if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( SID_STYLE_FAMILY,
+ false, &pItem ))
+ {
+ const sal_uInt16 nFamily = ((const SfxUInt16Item*)pItem)->GetValue();
+
+ OUString sName;
+ sal_uInt16 nMask = 0;
+ if( SFX_ITEM_SET == pArgs->GetItemState( SID_STYLE_NEW,
+ false, &pItem ))
+ sName = ((const SfxStringItem*)pItem)->GetValue();
+ if( SFX_ITEM_SET == pArgs->GetItemState( SID_STYLE_MASK,
+ false, &pItem ))
+ nMask = ((const SfxUInt16Item*)pItem)->GetValue();
+ OUString sParent;
+ if( SFX_ITEM_SET == pArgs->GetItemState( SID_STYLE_REFERENCE,
+ false, &pItem ))
+ sParent = ((const SfxStringItem*)pItem)->GetValue();
+
+ nRet = Edit( sName, sParent, nFamily, nMask, sal_True, OString(), 0, rReq.IsAPI() );
+ }
+ break;
+
+ case SID_STYLE_APPLY:
+ if( !pArgs )
+ {
+ GetView()->GetViewFrame()->GetDispatcher()->Execute(SID_STYLE_DESIGNER, sal_False);
+ break;
+ }
+ else
+ {
+ // convert internal StyleName to DisplayName (slot implementation uses the latter)
+ SFX_REQUEST_ARG( rReq, pNameItem, SfxStringItem, SID_APPLY_STYLE, false );
+ SFX_REQUEST_ARG( rReq, pFamilyItem, SfxStringItem, SID_STYLE_FAMILYNAME, false );
+ if ( pFamilyItem && pNameItem )
+ {
+ uno::Reference< style::XStyleFamiliesSupplier > xModel(GetModel(), uno::UNO_QUERY);
+ try
+ {
+ uno::Reference< container::XNameAccess > xStyles;
+ uno::Reference< container::XNameAccess > xCont = xModel->getStyleFamilies();
+ xCont->getByName(pFamilyItem->GetValue()) >>= xStyles;
+ uno::Reference< beans::XPropertySet > xInfo;
+ xStyles->getByName( pNameItem->GetValue() ) >>= xInfo;
+ OUString aUIName;
+ xInfo->getPropertyValue("DisplayName") >>= aUIName;
+ if ( !aUIName.isEmpty() )
+ rReq.AppendItem( SfxStringItem( SID_STYLE_APPLY, aUIName ) );
+ }
+ catch (const uno::Exception&)
+ {
+ }
+ }
+ }
+
+ // intentionally no break
+
+ case SID_STYLE_EDIT:
+ case SID_STYLE_DELETE:
+ case SID_STYLE_HIDE:
+ case SID_STYLE_SHOW:
+ case SID_STYLE_WATERCAN:
+ case SID_STYLE_FAMILY:
+ case SID_STYLE_UPDATE_BY_EXAMPLE:
+ case SID_STYLE_NEW_BY_EXAMPLE:
+ {
+ OUString aParam;
+ sal_uInt16 nFamily = SFX_STYLE_FAMILY_PARA;
+ sal_uInt16 nMask = 0;
+
+ if( !pArgs )
+ {
+ nFamily = SFX_STYLE_FAMILY_PARA;
+
+ switch (nSlot)
+ {
+ case SID_STYLE_NEW_BY_EXAMPLE:
+ {
+ boost::scoped_ptr<SfxNewStyleDlg> pDlg(new SfxNewStyleDlg( 0,
+ *GetStyleSheetPool()));
+ if(RET_OK == pDlg->Execute())
+ {
+ aParam = pDlg->GetName();
+ rReq.AppendItem(SfxStringItem(nSlot, aParam));
+ }
+ }
+ break;
+
+ case SID_STYLE_UPDATE_BY_EXAMPLE:
+ case SID_STYLE_EDIT:
+ {
+ SwTxtFmtColl* pColl = GetWrtShell()->GetCurTxtFmtColl();
+ if(pColl)
+ {
+ aParam = pColl->GetName();
+ rReq.AppendItem(SfxStringItem(nSlot, aParam));
+ }
+ }
+ break;
+ }
+ }
+ else
+ {
+ SAL_WARN_IF( !pArgs->Count(), "sw.ui", "SfxBug ItemSet is empty" );
+
+ SwWrtShell* pShell = GetWrtShell();
+ if( SFX_ITEM_SET == pArgs->GetItemState(nSlot, false, &pItem ))
+ aParam = ((const SfxStringItem*)pItem)->GetValue();
+
+ if( SFX_ITEM_SET == pArgs->GetItemState(SID_STYLE_FAMILY,
+ false, &pItem ))
+ nFamily = ((const SfxUInt16Item*)pItem)->GetValue();
+
+ if( SFX_ITEM_SET == pArgs->GetItemState(SID_STYLE_FAMILYNAME, false, &pItem ))
+ {
+ OUString aFamily = ((const SfxStringItem*)pItem)->GetValue();
+ if(aFamily.equalsAscii("CharacterStyles"))
+ nFamily = SFX_STYLE_FAMILY_CHAR;
+ else
+ if(aFamily.equalsAscii("ParagraphStyles"))
+ nFamily = SFX_STYLE_FAMILY_PARA;
+ else
+ if(aFamily.equalsAscii("PageStyles"))
+ nFamily = SFX_STYLE_FAMILY_PAGE;
+ else
+ if(aFamily.equalsAscii("FrameStyles"))
+ nFamily = SFX_STYLE_FAMILY_FRAME;
+ else
+ if(aFamily.equalsAscii("NumberingStyles"))
+ nFamily = SFX_STYLE_FAMILY_PSEUDO;
+ }
+
+ if( SFX_ITEM_SET == pArgs->GetItemState(SID_STYLE_MASK,
+ false, &pItem ))
+ nMask = ((const SfxUInt16Item*)pItem)->GetValue();
+ if( SFX_ITEM_SET == pArgs->GetItemState(FN_PARAM_WRTSHELL,
+ false, &pItem ))
+ pActShell = pShell = (SwWrtShell*)((SwPtrItem*)pItem)->GetValue();
+
+ if( nSlot == SID_STYLE_UPDATE_BY_EXAMPLE )
+ {
+ switch( nFamily )
+ {
+ case SFX_STYLE_FAMILY_PARA:
+ {
+ SwTxtFmtColl* pColl = pShell->GetCurTxtFmtColl();
+ if(pColl)
+ aParam = pColl->GetName();
+ }
+ break;
+ case SFX_STYLE_FAMILY_FRAME:
+ {
+ SwFrmFmt* pFrm = pWrtShell->GetCurFrmFmt();
+ if( pFrm )
+ aParam = pFrm->GetName();
+ }
+ break;
+ case SFX_STYLE_FAMILY_CHAR:
+ {
+ SwCharFmt* pChar = pWrtShell->GetCurCharFmt();
+ if( pChar )
+ aParam = pChar->GetName();
+ }
+ break;
+ case SFX_STYLE_FAMILY_PSEUDO:
+ if(SFX_ITEM_SET == pArgs->GetItemState(SID_STYLE_UPD_BY_EX_NAME, false, &pItem))
+ {
+ aParam = ((const SfxStringItem*)pItem)->GetValue();
+ }
+ break;
+ }
+ rReq.AppendItem(SfxStringItem(nSlot, aParam));
+ }
+ }
+ if (!aParam.isEmpty() || nSlot == SID_STYLE_WATERCAN )
+ {
+ switch(nSlot)
+ {
+ case SID_STYLE_EDIT:
+ nRet = Edit(aParam, aEmptyOUStr, nFamily, nMask, sal_False, OString(), pActShell );
+ break;
+ case SID_STYLE_DELETE:
+ nRet = Delete(aParam, nFamily);
+ break;
+ case SID_STYLE_HIDE:
+ case SID_STYLE_SHOW:
+ nRet = Hide(aParam, nFamily, nSlot == SID_STYLE_HIDE);
+ break;
+ case SID_STYLE_APPLY:
+ // Shell-switch in ApplyStyles
+ nRet = ApplyStyles(aParam, nFamily, pActShell, rReq.GetModifier() );
+ break;
+ case SID_STYLE_WATERCAN:
+ nRet = DoWaterCan(aParam, nFamily);
+ break;
+ case SID_STYLE_UPDATE_BY_EXAMPLE:
+ nRet = UpdateStyle(aParam, nFamily, pActShell);
+ break;
+ case SID_STYLE_NEW_BY_EXAMPLE:
+ {
+ nRet = MakeByExample(aParam, nFamily, nMask, pActShell );
+ SfxTemplateDialog* pDlg = SFX_APP()->GetTemplateDialog();
+
+ if(pDlg && pDlg->IsVisible())
+ pDlg->Update();
+ }
+ break;
+
+ default:
+ OSL_FAIL("Invalid SlotId");
+ }
+
+ rReq.Done();
+ }
+
+ break;
+ }
+ }
+
+ if(rReq.IsAPI()) // Basic only gets TRUE or FALSE
+ rReq.SetReturnValue(SfxUInt16Item(nSlot, sal_uInt16(nRet !=0)));
+ else
+ rReq.SetReturnValue(SfxUInt16Item(nSlot, nRet));
+}
+
+class ApplyStyle
+{
+public:
+ ApplyStyle(SwDocShell &rDocSh, bool bNew, SfxStyleSheetBase* pStyle,
+ sal_uInt16 nRet, rtl::Reference< SwDocStyleSheet > xTmp,
+ sal_uInt16 nFamily, SfxAbstractApplyTabDialog *pDlg,
+ rtl::Reference< SfxStyleSheetBasePool > xBasePool,
+ bool bModified)
+ : m_rDocSh(rDocSh)
+ , m_bNew(bNew)
+ , m_pStyle(pStyle)
+ , m_nRet(nRet)
+ , m_xTmp(xTmp)
+ , m_nFamily(nFamily)
+ , m_pDlg(pDlg)
+ , m_xBasePool(xBasePool)
+ , m_bModified(bModified)
+ {
+ }
+ DECL_LINK( ApplyHdl, void* );
+ void apply()
+ {
+ ApplyHdl(NULL);
+ }
+ sal_uInt16 getRet() const { return m_nRet; }
+private:
+ SwDocShell &m_rDocSh;
+ bool m_bNew;
+ SfxStyleSheetBase* m_pStyle;
+ sal_uInt16 m_nRet;
+ rtl::Reference< SwDocStyleSheet > m_xTmp;
+ sal_uInt16 m_nFamily;
+ SfxAbstractApplyTabDialog *m_pDlg;
+ rtl::Reference< SfxStyleSheetBasePool > m_xBasePool;
+ bool m_bModified;
+};
+
+IMPL_LINK_NOARG(ApplyStyle, ApplyHdl)
+{
+ SwWrtShell* pWrtShell = m_rDocSh.GetWrtShell();
+ SwDoc* pDoc = m_rDocSh.GetDoc();
+ SwView* pView = m_rDocSh.GetView();
+
+ pWrtShell->StartAllAction();
+
+ // newly set the mask only with paragraph-templates
+ if( m_bNew )
+ {
+ m_nRet = SFX_STYLE_FAMILY_PARA == m_pStyle->GetFamily()
+ ? m_xTmp->GetMask()
+ : SFXSTYLEBIT_USERDEF;
+ }
+ else if( m_pStyle->GetMask() != m_xTmp->GetMask() )
+ m_nRet = m_xTmp->GetMask();
+
+ if( SFX_STYLE_FAMILY_PARA == m_nFamily )
+ {
+ SfxItemSet aSet( *m_pDlg->GetOutputItemSet() );
+ ::SfxToSwPageDescAttr( *pWrtShell, aSet );
+ // reset indent attributes at paragraph style, if a list style
+ // will be applied and no indent attributes will be applied.
+ m_xTmp->SetItemSet( aSet, true );
+ }
+ else
+ {
+ if(SFX_STYLE_FAMILY_PAGE == m_nFamily)
+ {
+ static const sal_uInt16 aInval[] = {
+ SID_IMAGE_ORIENTATION,
+ SID_ATTR_CHAR_FONT,
+ FN_INSERT_CTRL, FN_INSERT_OBJ_CTRL, 0};
+ pView->GetViewFrame()->GetBindings().Invalidate(aInval);
+ }
+ SfxItemSet aTmpSet( *m_pDlg->GetOutputItemSet() );
+ if( SFX_STYLE_FAMILY_CHAR == m_nFamily )
+ {
+ ::ConvertAttrGenToChar(aTmpSet, CONV_ATTR_STD);
+ }
+ m_xTmp->SetItemSet( aTmpSet );
+
+ if( SFX_STYLE_FAMILY_PAGE == m_nFamily && SvtLanguageOptions().IsCTLFontEnabled() )
+ {
+ const SfxPoolItem *pItem = NULL;
+ if( aTmpSet.GetItemState( m_rDocSh.GetPool().GetTrueWhich( SID_ATTR_FRAMEDIRECTION, false ) , true, &pItem ) == SFX_ITEM_SET )
+ SwChartHelper::DoUpdateAllCharts( pDoc );
+ }
+ }
+ if(SFX_STYLE_FAMILY_PAGE == m_nFamily)
+ pView->InvalidateRulerPos();
+
+ if( m_bNew )
+ m_xBasePool->Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_CREATED, *m_xTmp.get() ) );
+
+ pDoc->SetModified();
+ if( !m_bModified )
+ {
+ pDoc->GetIDocumentUndoRedo().SetUndoNoResetModified();
+ }
+
+ pWrtShell->EndAllAction();
+
+ return m_nRet;
+}
+
+sal_uInt16 SwDocShell::Edit(
+ const OUString &rName,
+ const OUString &rParent,
+ const sal_uInt16 nFamily,
+ sal_uInt16 nMask,
+ const sal_Bool bNew,
+ const OString sPage,
+ SwWrtShell* pActShell,
+ const sal_Bool bBasic )
+{
+ assert( GetWrtShell() );
+ SfxStyleSheetBase *pStyle = 0;
+
+ sal_uInt16 nRet = nMask;
+ sal_Bool bModified = pDoc->IsModified();
+
+ if( bNew )
+ {
+ if( SFXSTYLEBIT_ALL != nMask && SFXSTYLEBIT_USED != nMask )
+ nMask |= SFXSTYLEBIT_USERDEF;
+ else
+ nMask = SFXSTYLEBIT_USERDEF;
+
+ pStyle = &mxBasePool->Make( rName, (SfxStyleFamily)nFamily, nMask );
+
+ // set the current one as Parent
+ SwDocStyleSheet* pDStyle = (SwDocStyleSheet*)pStyle;
+ switch( nFamily )
+ {
+ case SFX_STYLE_FAMILY_PARA:
+ {
+ if(!rParent.isEmpty())
+ {
+ SwTxtFmtColl* pColl = pWrtShell->FindTxtFmtCollByName( rParent );
+ if(!pColl)
+ {
+ sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rParent, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL);
+ if(USHRT_MAX != nId)
+ pColl = pWrtShell->GetTxtCollFromPool( nId );
+ }
+ pDStyle->GetCollection()->SetDerivedFrom( pColl );
+ pDStyle->PresetParent( rParent );
+
+ /*When a new paragraph style is created based on a "to outline style
+ assigned" paragraph style, the outline level attribute and the list
+ style attribute of the new paragraph style have to be set to 0
+ respectively "".*/
+ if (pColl && pColl->IsAssignedToListLevelOfOutlineStyle())
+ {
+ SwNumRuleItem aItem(aEmptyOUStr);
+ pDStyle->GetCollection()->SetFmtAttr( aItem );
+ pDStyle->GetCollection()->SetAttrOutlineLevel( 0 );
+ }
+ }
+ else
+ {
+ SwTxtFmtColl* pColl = pWrtShell->GetCurTxtFmtColl();
+ pDStyle->GetCollection()->SetDerivedFrom( pColl );
+ if( pColl )
+ pDStyle->PresetParent( pColl->GetName() );
+ }
+ }
+ break;
+ case SFX_STYLE_FAMILY_CHAR:
+ {
+ if(!rParent.isEmpty())
+ {
+ SwCharFmt* pCFmt = pWrtShell->FindCharFmtByName( rParent );
+ if(!pCFmt)
+ {
+ sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rParent, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT);
+ if(USHRT_MAX != nId)
+ pCFmt = pWrtShell->GetCharFmtFromPool( nId );
+ }
+
+ pDStyle->GetCharFmt()->SetDerivedFrom( pCFmt );
+ pDStyle->PresetParent( rParent );
+ }
+ else
+ {
+ SwCharFmt* pCFmt = pWrtShell->GetCurCharFmt();
+ pDStyle->GetCharFmt()->SetDerivedFrom( pCFmt );
+ if( pCFmt )
+ pDStyle->PresetParent( pCFmt->GetName() );
+ }
+ }
+ break;
+ case SFX_STYLE_FAMILY_FRAME :
+ {
+ if(!rParent.isEmpty())
+ {
+ SwFrmFmt* pFFmt = pWrtShell->GetDoc()->FindFrmFmtByName( rParent );
+ if(!pFFmt)
+ {
+ sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rParent, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT);
+ if(USHRT_MAX != nId)
+ pFFmt = pWrtShell->GetFrmFmtFromPool( nId );
+ }
+ pDStyle->GetFrmFmt()->SetDerivedFrom( pFFmt );
+ pDStyle->PresetParent( rParent );
+ }
+ }
+ break;
+ }
+ }
+ else
+ {
+ pStyle = mxBasePool->Find( rName, (SfxStyleFamily)nFamily );
+ SAL_WARN_IF( !pStyle, "sw.ui", "Style not found" );
+ }
+
+ if(!pStyle)
+ return sal_False;
+
+ // put dialogues together
+ rtl::Reference< SwDocStyleSheet > xTmp( new SwDocStyleSheet( *(SwDocStyleSheet*)pStyle ) );
+ if( SFX_STYLE_FAMILY_PARA == nFamily )
+ {
+ SfxItemSet& rSet = xTmp->GetItemSet();
+ ::SwToSfxPageDescAttr( rSet );
+ // firstly only a Zero
+ rSet.Put(SwBackgroundDestinationItem(SID_PARA_BACKGRND_DESTINATION, 0));
+ // merge list level indent attributes into the item set if needed
+ xTmp->MergeIndentAttrsOfListStyle( rSet );
+ }
+ else if( SFX_STYLE_FAMILY_CHAR == nFamily )
+ {
+ ::ConvertAttrCharToGen(xTmp->GetItemSet(), CONV_ATTR_STD);
+ }
+ if (!bBasic)
+ {
+ // prior to the dialog the HtmlMode at the DocShell is being sunk
+ sal_uInt16 nHtmlMode = ::GetHtmlMode(this);
+
+ // In HTML mode, we do not always have a printer. In order to show
+ // the correct page size in the Format - Page dialog, we have to
+ // get one here.
+ SwWrtShell* pCurrShell = ( pActShell ? pActShell : pWrtShell );
+ if( ( HTMLMODE_ON & nHtmlMode ) &&
+ !pCurrShell->getIDocumentDeviceAccess()->getPrinter( false ) )
+ pCurrShell->InitPrt( pCurrShell->getIDocumentDeviceAccess()->getPrinter( true ) );
+
+ PutItem(SfxUInt16Item(SID_HTML_MODE, nHtmlMode));
+ FieldUnit eMetric = ::GetDfltMetric(0 != (HTMLMODE_ON&nHtmlMode));
+ SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)));
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ assert( pFact );
+ boost::scoped_ptr<SfxAbstractApplyTabDialog> pDlg(pFact->CreateTemplateDialog(
+ 0, *(xTmp.get()), nFamily, sPage,
+ pActShell ? pActShell : pWrtShell, bNew));
+ assert( pDlg );
+ ApplyStyle aApplyStyleHelper(*this, bNew, pStyle, nRet, xTmp, nFamily, pDlg.get(), mxBasePool, bModified);
+ pDlg->SetApplyHdl(LINK(&aApplyStyleHelper, ApplyStyle, ApplyHdl));
+
+ if (RET_OK == pDlg->Execute())
+ {
+ aApplyStyleHelper.apply();
+ }
+ else
+ {
+ if( bNew )
+ {
+ GetWrtShell()->Undo(1);
+ pDoc->GetIDocumentUndoRedo().ClearRedo();
+ }
+
+ if( !bModified )
+ pDoc->ResetModified();
+ }
+
+ nRet = aApplyStyleHelper.getRet();
+ }
+ else
+ {
+ // prior to the dialog the HtmlMode at the DocShell is being sunk
+ PutItem(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(this)));
+
+ GetWrtShell()->StartAllAction();
+
+ // newly set the mask only with paragraph-templates
+ if( bNew )
+ {
+ nRet = SFX_STYLE_FAMILY_PARA == pStyle->GetFamily()
+ ? xTmp->GetMask()
+ : SFXSTYLEBIT_USERDEF;
+ }
+ else if( pStyle->GetMask() != xTmp->GetMask() )
+ nRet = xTmp->GetMask();
+
+ if( SFX_STYLE_FAMILY_PARA == nFamily )
+ ::SfxToSwPageDescAttr( *GetWrtShell(), xTmp->GetItemSet() );
+ else
+ {
+ ::ConvertAttrGenToChar(xTmp->GetItemSet(), CONV_ATTR_STD);
+ }
+ if(SFX_STYLE_FAMILY_PAGE == nFamily)
+ pView->InvalidateRulerPos();
+
+ if( bNew )
+ mxBasePool->Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_CREATED, *xTmp.get() ) );
+
+ pDoc->SetModified();
+ if( !bModified ) // Bug 57028
+ {
+ pDoc->GetIDocumentUndoRedo().SetUndoNoResetModified();
+ }
+ GetWrtShell()->EndAllAction();
+ }
+
+ return nRet;
+}
+
+// Delete
+sal_uInt16 SwDocShell::Delete(const OUString &rName, sal_uInt16 nFamily)
+{
+ SfxStyleSheetBase *pStyle = mxBasePool->Find(rName, (SfxStyleFamily)nFamily);
+
+ if(pStyle)
+ {
+ assert( GetWrtShell() );
+
+ GetWrtShell()->StartAllAction();
+ mxBasePool->Remove(pStyle);
+ GetWrtShell()->EndAllAction();
+
+ return sal_True;
+ }
+ return sal_False;
+}
+
+sal_uInt16 SwDocShell::Hide(const OUString &rName, sal_uInt16 nFamily, bool bHidden)
+{
+ SfxStyleSheetBase *pStyle = mxBasePool->Find(rName, (SfxStyleFamily)nFamily);
+
+ if(pStyle)
+ {
+ assert( GetWrtShell() );
+
+ GetWrtShell()->StartAllAction();
+ rtl::Reference< SwDocStyleSheet > xTmp( new SwDocStyleSheet( *(SwDocStyleSheet*)pStyle ) );
+ xTmp->SetHidden( bHidden );
+ GetWrtShell()->EndAllAction();
+
+ return sal_True;
+ }
+ return sal_False;
+}
+
+// apply template
+sal_uInt16 SwDocShell::ApplyStyles(const OUString &rName, sal_uInt16 nFamily,
+ SwWrtShell* pShell, sal_uInt16 nMode )
+{
+ SwDocStyleSheet* pStyle =
+ (SwDocStyleSheet*)mxBasePool->Find(rName, (SfxStyleFamily)nFamily);
+
+ SAL_WARN_IF( !pStyle, "sw.ui", "Style not found" );
+
+ if(!pStyle)
+ return sal_False;
+
+ SwWrtShell *pSh = pShell ? pShell : GetWrtShell();
+
+ assert( pSh );
+
+ pSh->StartAllAction();
+
+ switch(nFamily)
+ {
+ case SFX_STYLE_FAMILY_CHAR:
+ {
+ SwFmtCharFmt aFmt(pStyle->GetCharFmt());
+ pSh->SetAttrItem( aFmt, (nMode & KEY_SHIFT) ?
+ nsSetAttrMode::SETATTR_DONTREPLACE : nsSetAttrMode::SETATTR_DEFAULT );
+ break;
+ }
+ case SFX_STYLE_FAMILY_PARA:
+ {
+ // #i62675#
+ // clear also list attributes at affected text nodes, if paragraph
+ // style has the list style attribute set.
+ pSh->SetTxtFmtColl( pStyle->GetCollection(), true );
+ break;
+ }
+ case SFX_STYLE_FAMILY_FRAME:
+ {
+ if ( pSh->IsFrmSelected() )
+ pSh->SetFrmFmt( pStyle->GetFrmFmt() );
+ break;
+ }
+ case SFX_STYLE_FAMILY_PAGE:
+ {
+ pSh->SetPageStyle(pStyle->GetPageDesc()->GetName());
+ break;
+ }
+ case SFX_STYLE_FAMILY_PSEUDO:
+ {
+ // reset indent attribute on applying list style
+ // continue list of list style
+ const SwNumRule* pNumRule = pStyle->GetNumRule();
+ const OUString sListIdForStyle =pNumRule->GetDefaultListId();
+ pSh->SetCurNumRule( *pNumRule, false, sListIdForStyle, true );
+ break;
+ }
+ default:
+ OSL_FAIL("Unknown family");
+ }
+ pSh->EndAllAction();
+
+ return nFamily;
+}
+
+// start watering-can
+sal_uInt16 SwDocShell::DoWaterCan(const OUString &rName, sal_uInt16 nFamily)
+{
+ assert( GetWrtShell() );
+
+ SwEditWin& rEdtWin = pView->GetEditWin();
+ SwApplyTemplate* pApply = rEdtWin.GetApplyTemplate();
+ bool bWaterCan = !(pApply && pApply->eType != 0);
+
+ if( rName.isEmpty() )
+ bWaterCan = false;
+
+ SwApplyTemplate aTemplate;
+ aTemplate.eType = nFamily;
+
+ if(bWaterCan)
+ {
+ SwDocStyleSheet* pStyle =
+ (SwDocStyleSheet*)mxBasePool->Find(rName, (SfxStyleFamily)nFamily);
+
+ SAL_WARN_IF( !pStyle, "sw.ui", "Where's the StyleSheet" );
+
+ if(!pStyle) return nFamily;
+
+ switch(nFamily)
+ {
+ case SFX_STYLE_FAMILY_CHAR:
+ aTemplate.aColl.pCharFmt = pStyle->GetCharFmt();
+ break;
+ case SFX_STYLE_FAMILY_PARA:
+ aTemplate.aColl.pTxtColl = pStyle->GetCollection();
+ break;
+ case SFX_STYLE_FAMILY_FRAME:
+ aTemplate.aColl.pFrmFmt = pStyle->GetFrmFmt();
+ break;
+ case SFX_STYLE_FAMILY_PAGE:
+ aTemplate.aColl.pPageDesc = (SwPageDesc*)pStyle->GetPageDesc();
+ break;
+ case SFX_STYLE_FAMILY_PSEUDO:
+ aTemplate.aColl.pNumRule = (SwNumRule*)pStyle->GetNumRule();
+ break;
+
+ default:
+ OSL_FAIL("Unknown family");
+ }
+ }
+ else
+ aTemplate.eType = 0;
+
+ pView->GetEditWin().SetApplyTemplate(aTemplate);
+
+ return nFamily;
+}
+
+// update template
+sal_uInt16 SwDocShell::UpdateStyle(const OUString &rName, sal_uInt16 nFamily, SwWrtShell* pShell)
+{
+ SwWrtShell* pCurrWrtShell = pShell ? pShell : GetWrtShell();
+ assert( pCurrWrtShell );
+
+ SwDocStyleSheet* pStyle =
+ (SwDocStyleSheet*)mxBasePool->Find(rName, (SfxStyleFamily)nFamily);
+
+ if(!pStyle)
+ return nFamily;
+
+ switch(nFamily)
+ {
+ case SFX_STYLE_FAMILY_PARA:
+ {
+ SwTxtFmtColl* pColl = pStyle->GetCollection();
+ if(pColl && !pColl->IsDefault())
+ {
+ GetWrtShell()->StartAllAction();
+
+ SwRewriter aRewriter;
+ aRewriter.AddRule(UndoArg1, pColl->GetName());
+
+ GetWrtShell()->StartUndo(UNDO_INSFMTATTR, &aRewriter);
+ GetWrtShell()->FillByEx(pColl);
+ // also apply template to remove hard set attributes
+ GetWrtShell()->SetTxtFmtColl( pColl );
+ GetWrtShell()->EndUndo();
+ GetWrtShell()->EndAllAction();
+ }
+ break;
+ }
+ case SFX_STYLE_FAMILY_FRAME:
+ {
+ SwFrmFmt* pFrm = pStyle->GetFrmFmt();
+ if( pCurrWrtShell->IsFrmSelected() && pFrm && !pFrm->IsDefault() )
+ {
+ SfxItemSet aSet( GetPool(), aFrmFmtSetRange );
+ pCurrWrtShell->StartAllAction();
+ pCurrWrtShell->GetFlyFrmAttr( aSet );
+
+ // #i105535#
+ // no update of anchor attribute
+ aSet.ClearItem( RES_ANCHOR );
+
+ pFrm->SetFmtAttr( aSet );
+
+ // also apply template to remove hard set attributes
+ pCurrWrtShell->SetFrmFmt( pFrm, true );
+ pCurrWrtShell->EndAllAction();
+ }
+ }
+ break;
+ case SFX_STYLE_FAMILY_CHAR:
+ {
+ SwCharFmt* pChar = pStyle->GetCharFmt();
+ if( pChar && !pChar->IsDefault() )
+ {
+ pCurrWrtShell->StartAllAction();
+ pCurrWrtShell->FillByEx(pChar);
+ // also apply template to remove hard set attributes
+ pCurrWrtShell->EndAllAction();
+ }
+
+ }
+ break;
+ case SFX_STYLE_FAMILY_PSEUDO:
+ {
+ const SwNumRule* pCurRule;
+ if( pStyle->GetNumRule() &&
+ 0 != ( pCurRule = pCurrWrtShell->GetCurNumRule() ))
+ {
+ SwNumRule aRule( *pCurRule );
+ // #i91400#
+ aRule.SetName( pStyle->GetNumRule()->GetName(),
+ *(pCurrWrtShell->GetDoc()) );
+ pCurrWrtShell->ChgNumRuleFmts( aRule );
+ }
+ }
+ break;
+ }
+ return nFamily;
+}
+
+// NewByExample
+sal_uInt16 SwDocShell::MakeByExample( const OUString &rName, sal_uInt16 nFamily,
+ sal_uInt16 nMask, SwWrtShell* pShell )
+{
+ SwWrtShell* pCurrWrtShell = pShell ? pShell : GetWrtShell();
+ SwDocStyleSheet* pStyle = (SwDocStyleSheet*)mxBasePool->Find(
+ rName, (SfxStyleFamily)nFamily );
+ if(!pStyle)
+ {
+ // preserve the current mask of PI, then the new one is
+ // immediately merged with the viewable area
+ if( SFXSTYLEBIT_ALL == nMask || SFXSTYLEBIT_USED == nMask )
+ nMask = SFXSTYLEBIT_USERDEF;
+ else
+ nMask |= SFXSTYLEBIT_USERDEF;
+
+ pStyle = (SwDocStyleSheet*)&mxBasePool->Make(rName,
+ (SfxStyleFamily)nFamily, nMask );
+ }
+
+ switch(nFamily)
+ {
+ case SFX_STYLE_FAMILY_PARA:
+ {
+ SwTxtFmtColl* pColl = pStyle->GetCollection();
+ if(pColl && !pColl->IsDefault())
+ {
+ pCurrWrtShell->StartAllAction();
+ pCurrWrtShell->FillByEx(pColl);
+ // also apply template to remove hard set attributes
+ pColl->SetDerivedFrom(pCurrWrtShell->GetCurTxtFmtColl());
+
+ // set the mask at the Collection:
+ sal_uInt16 nId = pColl->GetPoolFmtId() & 0x87ff;
+ switch( nMask & 0x0fff )
+ {
+ case SWSTYLEBIT_TEXT:
+ nId |= COLL_TEXT_BITS;
+ break;
+ case SWSTYLEBIT_CHAPTER:
+ nId |= COLL_DOC_BITS;
+ break;
+ case SWSTYLEBIT_LIST:
+ nId |= COLL_LISTS_BITS;
+ break;
+ case SWSTYLEBIT_IDX:
+ nId |= COLL_REGISTER_BITS;
+ break;
+ case SWSTYLEBIT_EXTRA:
+ nId |= COLL_EXTRA_BITS;
+ break;
+ case SWSTYLEBIT_HTML:
+ nId |= COLL_HTML_BITS;
+ break;
+ }
+ pColl->SetPoolFmtId(nId);
+
+ pCurrWrtShell->SetTxtFmtColl(pColl);
+ pCurrWrtShell->EndAllAction();
+ }
+ }
+ break;
+ case SFX_STYLE_FAMILY_FRAME:
+ {
+ SwFrmFmt* pFrm = pStyle->GetFrmFmt();
+ if(pCurrWrtShell->IsFrmSelected() && pFrm && !pFrm->IsDefault())
+ {
+ pCurrWrtShell->StartAllAction();
+
+ SfxItemSet aSet(GetPool(), aFrmFmtSetRange );
+ pCurrWrtShell->GetFlyFrmAttr( aSet );
+
+ SwFrmFmt* pFFmt = pCurrWrtShell->GetCurFrmFmt();
+ pFrm->SetDerivedFrom( pFFmt );
+
+ pFrm->SetFmtAttr( aSet );
+ // also apply template to remove hard set attributes
+ pCurrWrtShell->SetFrmFmt( pFrm );
+ pCurrWrtShell->EndAllAction();
+ }
+ }
+ break;
+ case SFX_STYLE_FAMILY_CHAR:
+ {
+ SwCharFmt* pChar = pStyle->GetCharFmt();
+ if(pChar && !pChar->IsDefault())
+ {
+ pCurrWrtShell->StartAllAction();
+ pCurrWrtShell->FillByEx( pChar );
+ pChar->SetDerivedFrom( pCurrWrtShell->GetCurCharFmt() );
+ SwFmtCharFmt aFmt( pChar );
+ pCurrWrtShell->SetAttrItem( aFmt );
+ pCurrWrtShell->EndAllAction();
+ }
+ }
+ break;
+
+ case SFX_STYLE_FAMILY_PAGE:
+ {
+ pCurrWrtShell->StartAllAction();
+ sal_uInt16 nPgDsc = pCurrWrtShell->GetCurPageDesc();
+ SwPageDesc& rSrc = (SwPageDesc&)pCurrWrtShell->GetPageDesc( nPgDsc );
+ SwPageDesc& rDest = *(SwPageDesc*)pStyle->GetPageDesc();
+
+ sal_uInt16 nPoolId = rDest.GetPoolFmtId();
+ sal_uInt16 nHId = rDest.GetPoolHelpId();
+ sal_uInt8 nHFId = rDest.GetPoolHlpFileId();
+
+ pCurrWrtShell->GetDoc()->CopyPageDesc( rSrc, rDest );
+
+ // PoolId must NEVER be copied!
+ rDest.SetPoolFmtId( nPoolId );
+ rDest.SetPoolHelpId( nHId );
+ rDest.SetPoolHlpFileId( nHFId );
+
+ // when Headers/Footers are created, there is no Undo anymore!
+ pCurrWrtShell->GetDoc()->GetIDocumentUndoRedo().DelAllUndoObj();
+
+ pCurrWrtShell->EndAllAction();
+ }
+ break;
+
+ case SFX_STYLE_FAMILY_PSEUDO:
+ {
+ const SwNumRule* pCurRule = pCurrWrtShell->GetCurNumRule();
+
+ if (pCurRule)
+ {
+ pCurrWrtShell->StartAllAction();
+
+ SwNumRule aRule( *pCurRule );
+ OUString sOrigRule( aRule.GetName() );
+ // #i91400#
+ aRule.SetName( pStyle->GetNumRule()->GetName(),
+ *(pCurrWrtShell->GetDoc()) );
+ pCurrWrtShell->ChgNumRuleFmts( aRule );
+
+ pCurrWrtShell->ReplaceNumRule( sOrigRule, aRule.GetName() );
+
+ pCurrWrtShell->EndAllAction();
+ }
+ }
+ break;
+ }
+ return nFamily;
+}
+
+void SwDocShell::LoadStyles( SfxObjectShell& rSource )
+{
+ _LoadStyles(rSource, sal_False);
+}
+/* --------------------------------------------------
+ bPreserveCurrentDocument determines whether SetFixFields() is called
+ This call modifies the source document. This mustn't happen when the source
+ is a document the user is working on.
+ Calls of ::LoadStyles() normally use files especially loaded for the purpose
+ of importing styles.
+ --------------------------------------------------*/
+void SwDocShell::_LoadStyles( SfxObjectShell& rSource, sal_Bool bPreserveCurrentDocument )
+{
+/* [Description]
+
+ This method is called by SFx if Styles have to be reloaded from a
+ document-template. Existing Styles should be overwritten by that.
+ That's why the document has to be reformatted. Therefore applications
+ will usually overload this method and call the baseclass' implementation
+ in their implementation.
+*/
+ // When the source is our document, we do the checking ourselves
+ // (much quicker and doesn't use the crutch StxStylePool).
+ if( rSource.ISA( SwDocShell ))
+ {
+ // in order for the Headers/Footers not to get the fixed content
+ // of the template, update all the Source's
+ // FixFields once.
+ if(!bPreserveCurrentDocument)
+ ((SwDocShell&)rSource).pDoc->SetFixFields(false, NULL);
+ if( pWrtShell )
+ {
+ // rhbz#818557, fdo#58893: EndAllAction will call SelectShell(),
+ // which pushes a bunch of SfxShells that are not cleared
+ // (for unknown reasons) when closing the document, causing crash;
+ // setting bNoInterrupt appears to avoid the problem.
+ ::comphelper::FlagRestorationGuard g(bNoInterrupt, true);
+ pWrtShell->StartAllAction();
+ pDoc->ReplaceStyles( *((SwDocShell&)rSource).pDoc );
+ pWrtShell->EndAllAction();
+ }
+ else
+ {
+ sal_Bool bModified = pDoc->IsModified();
+ pDoc->ReplaceStyles( *((SwDocShell&)rSource).pDoc );
+ if( !bModified && pDoc->IsModified() && !pView )
+ {
+ // the View is created later, but overwrites the Modify-Flag.
+ // Undo doesn't work anymore anyways.
+ pDoc->GetIDocumentUndoRedo().SetUndoNoResetModified();
+ }
+ }
+ }
+ else
+ SfxObjectShell::LoadStyles( rSource );
+}
+
+void SwDocShell::FormatPage(
+ const OUString& rPage,
+ const OString& rPageId,
+ SwWrtShell& rActShell )
+{
+ Edit( rPage, aEmptyOUStr, SFX_STYLE_FAMILY_PAGE, 0, sal_False, rPageId, &rActShell);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/app/docstyle.cxx b/sw/source/core/uibase/app/docstyle.cxx
new file mode 100644
index 000000000000..b52bcd971f01
--- /dev/null
+++ b/sw/source/core/uibase/app/docstyle.cxx
@@ -0,0 +1,2973 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <svl/smplhint.hxx>
+#include <hintids.hxx>
+#include <svl/itemiter.hxx>
+#include <svl/eitem.hxx>
+#include <unotools/syslocale.hxx>
+#include <editeng/boxitem.hxx>
+#include <editeng/numitem.hxx>
+#include <editeng/lrspitem.hxx>
+#include <fmtcol.hxx>
+#include <uitool.hxx>
+#include <swmodule.hxx>
+#include <wrtsh.hxx>
+#include <docsh.hxx>
+#include <frmfmt.hxx>
+#include <charfmt.hxx>
+#include <poolfmt.hxx>
+#include <pagedesc.hxx>
+#include <docstyle.hxx>
+#include <docary.hxx>
+#include <ccoll.hxx>
+#include <doc.hxx>
+#include <IDocumentUndoRedo.hxx>
+#include <cmdid.h>
+#include <swstyle.h>
+#include <app.hrc>
+#include <paratr.hxx>
+#include <SwStyleNameMapper.hxx>
+#include <svl/cjkoptions.hxx>
+#include <comphelper/processfactory.hxx>
+#include <unotools/localedatawrapper.hxx>
+#include <unotools/intlwrapper.hxx>
+#include <numrule.hxx>
+#include <fmthdft.hxx>
+#include <svx/svxids.hrc>
+#include <SwRewriter.hxx>
+
+using namespace com::sun::star;
+
+// The Format names in the list of all names have the
+// following family as their first character:
+
+#define cCHAR (sal_Unicode)'c'
+#define cPARA (sal_Unicode)'p'
+#define cFRAME (sal_Unicode)'f'
+#define cPAGE (sal_Unicode)'g'
+#define cNUMRULE (sal_Unicode)'n'
+
+// At the names' publication, this character is removed again and the
+// family is newly generated.
+
+// In addition now there is the Bit bPhysical. In case this Bit is
+// TRUE, the Pool-Formatnames are not being submitted.
+
+class SwImplShellAction
+{
+ SwWrtShell* pSh;
+ CurrShell* pCurrSh;
+public:
+ SwImplShellAction( SwDoc& rDoc );
+ ~SwImplShellAction();
+
+ SwWrtShell* GetSh() { return pSh; }
+};
+
+SwImplShellAction::SwImplShellAction( SwDoc& rDoc )
+ : pCurrSh( 0 )
+{
+ if( rDoc.GetDocShell() )
+ pSh = rDoc.GetDocShell()->GetWrtShell();
+ else
+ pSh = 0;
+
+ if( pSh )
+ {
+ pCurrSh = new CurrShell( pSh );
+ pSh->StartAllAction();
+ }
+}
+
+SwImplShellAction::~SwImplShellAction()
+{
+ if( pCurrSh )
+ {
+ pSh->EndAllAction();
+ delete pCurrSh;
+ }
+}
+
+// find/create SwCharFormate
+// possibly fill Style
+static SwCharFmt* lcl_FindCharFmt( SwDoc& rDoc,
+ const OUString& rName,
+ SwDocStyleSheet* pStyle = 0,
+ bool bCreate = true )
+{
+ SwCharFmt* pFmt = 0;
+ if (!rName.isEmpty())
+ {
+ pFmt = rDoc.FindCharFmtByName( rName );
+ if( !pFmt && rName == SwStyleNameMapper::GetTextUINameArray()[ RES_POOLCOLL_STANDARD -
+ RES_POOLCOLL_TEXT_BEGIN ] )
+ {
+ // Standard-Character template
+ pFmt = (SwCharFmt*)rDoc.GetDfltCharFmt();
+ }
+
+ if( !pFmt && bCreate )
+ { // explore Pool
+ const sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rName, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT);
+ if(nId != USHRT_MAX)
+ pFmt = rDoc.GetCharFmtFromPool(nId);
+ }
+ }
+ if(pStyle)
+ {
+ if(pFmt)
+ {
+ pStyle->SetPhysical(sal_True);
+ SwFmt* p = pFmt->DerivedFrom();
+ if( p && !p->IsDefault() )
+ pStyle->PresetParent( p->GetName() );
+ else
+ pStyle->PresetParent( OUString() );
+ }
+ else
+ pStyle->SetPhysical(sal_False);
+ }
+ return pFmt;
+}
+
+// find/create ParaFormats
+// fill Style
+static SwTxtFmtColl* lcl_FindParaFmt( SwDoc& rDoc,
+ const OUString& rName,
+ SwDocStyleSheet* pStyle = 0,
+ bool bCreate = true )
+{
+ SwTxtFmtColl* pColl = 0;
+
+ if (!rName.isEmpty())
+ {
+ pColl = rDoc.FindTxtFmtCollByName( rName );
+ if( !pColl && bCreate )
+ { // explore Pool
+ const sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL);
+ if(nId != USHRT_MAX)
+ pColl = rDoc.GetTxtCollFromPool(nId);
+ }
+ }
+
+ if(pStyle)
+ {
+ if(pColl)
+ {
+ pStyle->SetPhysical(sal_True);
+ if( pColl->DerivedFrom() && !pColl->DerivedFrom()->IsDefault() )
+ pStyle->PresetParent( pColl->DerivedFrom()->GetName() );
+ else
+ pStyle->PresetParent( OUString() );
+
+ SwTxtFmtColl& rNext = pColl->GetNextTxtFmtColl();
+ pStyle->PresetFollow(rNext.GetName());
+ }
+ else
+ pStyle->SetPhysical(sal_False);
+ }
+ return pColl;
+}
+
+// Border formats
+static SwFrmFmt* lcl_FindFrmFmt( SwDoc& rDoc,
+ const OUString& rName,
+ SwDocStyleSheet* pStyle = 0,
+ bool bCreate = true )
+{
+ SwFrmFmt* pFmt = 0;
+ if( !rName.isEmpty() )
+ {
+ pFmt = rDoc.FindFrmFmtByName( rName );
+ if( !pFmt && bCreate )
+ { // explore Pool
+ const sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rName, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT);
+ if(nId != USHRT_MAX)
+ pFmt = rDoc.GetFrmFmtFromPool(nId);
+ }
+ }
+
+ if(pStyle)
+ {
+ if(pFmt)
+ {
+ pStyle->SetPhysical(sal_True);
+ if( pFmt->DerivedFrom() && !pFmt->DerivedFrom()->IsDefault() )
+ pStyle->PresetParent( pFmt->DerivedFrom()->GetName() );
+ else
+ pStyle->PresetParent( OUString() );
+ }
+ else
+ pStyle->SetPhysical(sal_False);
+ }
+ return pFmt;
+}
+
+// Page descriptors
+static const SwPageDesc* lcl_FindPageDesc( SwDoc& rDoc,
+ const OUString& rName,
+ SwDocStyleSheet* pStyle = 0,
+ bool bCreate = true )
+{
+ const SwPageDesc* pDesc = 0;
+
+ if (!rName.isEmpty())
+ {
+ pDesc = rDoc.FindPageDescByName( rName );
+ if( !pDesc && bCreate )
+ {
+ sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rName, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC);
+ if(nId != USHRT_MAX)
+ pDesc = rDoc.GetPageDescFromPool(nId);
+ }
+ }
+
+ if(pStyle)
+ {
+ if(pDesc)
+ {
+ pStyle->SetPhysical(sal_True);
+ if(pDesc->GetFollow())
+ pStyle->PresetFollow(pDesc->GetFollow()->GetName());
+ else
+ pStyle->PresetParent( OUString() );
+ }
+ else
+ pStyle->SetPhysical(sal_False);
+ }
+ return pDesc;
+}
+
+static const SwNumRule* lcl_FindNumRule( SwDoc& rDoc,
+ const OUString& rName,
+ SwDocStyleSheet* pStyle = 0,
+ bool bCreate = true )
+{
+ const SwNumRule* pRule = 0;
+
+ if (!rName.isEmpty())
+ {
+ pRule = rDoc.FindNumRulePtr( rName );
+ if( !pRule && bCreate )
+ {
+ sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rName, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE);
+ if(nId != USHRT_MAX)
+ pRule = rDoc.GetNumRuleFromPool(nId);
+ }
+ }
+
+ if(pStyle)
+ {
+ if(pRule)
+ {
+ pStyle->SetPhysical(sal_True);
+ pStyle->PresetParent( OUString() );
+ }
+ else
+ pStyle->SetPhysical(sal_False);
+ }
+ return pRule;
+}
+
+static sal_uInt16 lcl_FindName(const SwPoolFmtList& rLst, SfxStyleFamily eFam,
+ const OUString& rName)
+{
+ if(!rLst.empty())
+ {
+ sal_Unicode cStyle(0);
+ switch( eFam )
+ {
+ case SFX_STYLE_FAMILY_CHAR:
+ cStyle = cCHAR;
+ break;
+ case SFX_STYLE_FAMILY_PARA:
+ cStyle = cPARA;
+ break;
+ case SFX_STYLE_FAMILY_FRAME:
+ cStyle = cFRAME;
+ break;
+ case SFX_STYLE_FAMILY_PAGE:
+ cStyle = cPAGE;
+ break;
+ case SFX_STYLE_FAMILY_PSEUDO:
+ cStyle = cNUMRULE;
+ break;
+ default:
+ cStyle = ' ';
+ break;
+ }
+ const OUString sSrch = OUString(cStyle) + rName;
+ for(size_t i = 0; i < rLst.size(); ++i)
+ if(rLst[i] == sSrch)
+ return i;
+ }
+ return USHRT_MAX;
+}
+
+bool FindPhyStyle( SwDoc& rDoc, const OUString& rName, SfxStyleFamily eFam )
+{
+ switch( eFam )
+ {
+ case SFX_STYLE_FAMILY_CHAR :
+ return 0 != lcl_FindCharFmt( rDoc, rName, 0, false );
+ case SFX_STYLE_FAMILY_PARA :
+ return 0 != lcl_FindParaFmt( rDoc, rName, 0, false );
+ case SFX_STYLE_FAMILY_FRAME:
+ return 0 != lcl_FindFrmFmt( rDoc, rName, 0, false );
+ case SFX_STYLE_FAMILY_PAGE :
+ return 0 != lcl_FindPageDesc( rDoc, rName, 0, false );
+ case SFX_STYLE_FAMILY_PSEUDO:
+ return 0 != lcl_FindNumRule( rDoc, rName, 0, false );
+ default:; //prevent warning
+ }
+ return false;
+}
+
+// Add Strings to the list of templates
+void SwPoolFmtList::Append( char cChar, const OUString& rStr )
+{
+ const OUString aStr = OUString(cChar) + rStr;
+ for(std::vector<OUString>::const_iterator i = begin(); i != end(); ++i)
+ if(*i == aStr)
+ return;
+ push_back(aStr);
+}
+
+// Erase the list completely
+void SwPoolFmtList::Erase()
+{
+ clear();
+}
+
+// UI-sided implementation of StyleSheets
+// uses the Core-Engine
+SwDocStyleSheet::SwDocStyleSheet( SwDoc& rDocument,
+ const OUString& rName,
+ SwDocStyleSheetPool* _rPool,
+ SfxStyleFamily eFam,
+ sal_uInt16 _nMask) :
+
+ SfxStyleSheetBase( rName, _rPool, eFam, _nMask ),
+ pCharFmt(0),
+ pColl(0),
+ pFrmFmt(0),
+ pDesc(0),
+ pNumRule(0),
+
+ rDoc(rDocument),
+ aCoreSet(GetPool().GetPool(),
+ RES_CHRATR_BEGIN, RES_CHRATR_END - 1,
+ RES_PARATR_BEGIN, RES_PARATR_END - 1,
+ RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END - 1,
+ RES_FRMATR_BEGIN, RES_FRMATR_END - 1,
+ RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1,
+ SID_ATTR_PAGE, SID_ATTR_PAGE_EXT1,
+ SID_ATTR_PAGE_HEADERSET,SID_ATTR_PAGE_FOOTERSET,
+ SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
+ FN_PARAM_FTN_INFO, FN_PARAM_FTN_INFO,
+ SID_ATTR_PARA_MODEL, SID_ATTR_PARA_MODEL,
+ SID_ATTR_PARA_PAGENUM, SID_ATTR_PARA_PAGENUM,
+ SID_SWREGISTER_MODE, SID_SWREGISTER_MODE,
+ SID_SWREGISTER_COLLECTION, SID_SWREGISTER_COLLECTION,
+ FN_COND_COLL, FN_COND_COLL,
+ SID_ATTR_AUTO_STYLE_UPDATE, SID_ATTR_AUTO_STYLE_UPDATE,
+ SID_ATTR_NUMBERING_RULE, SID_ATTR_NUMBERING_RULE,
+ SID_PARA_BACKGRND_DESTINATION, SID_ATTR_BRUSH_CHAR,
+ SID_ATTR_NUMBERING_RULE, SID_ATTR_NUMBERING_RULE,
+ 0),
+ bPhysical(sal_False)
+{
+ nHelpId = UCHAR_MAX;
+}
+
+SwDocStyleSheet::SwDocStyleSheet( const SwDocStyleSheet& rOrg) :
+ SfxStyleSheetBase(rOrg),
+ pCharFmt(rOrg.pCharFmt),
+ pColl(rOrg.pColl),
+ pFrmFmt(rOrg.pFrmFmt),
+ pDesc(rOrg.pDesc),
+ pNumRule(rOrg.pNumRule),
+ rDoc(rOrg.rDoc),
+ aCoreSet(rOrg.aCoreSet),
+ bPhysical(rOrg.bPhysical)
+{
+}
+
+ SwDocStyleSheet::~SwDocStyleSheet()
+{
+}
+
+// Reset
+void SwDocStyleSheet::Reset()
+{
+ aName = "";
+ aFollow = "";
+ aParent = "";
+ SetPhysical(sal_False);
+}
+
+void SwDocStyleSheet::SetGrabBagItem(const uno::Any& rVal)
+{
+ bool bChg = false;
+ if (!bPhysical)
+ FillStyleSheet(FillPhysical);
+
+ SwFmt* pFmt = 0;
+ switch (nFamily)
+ {
+ case SFX_STYLE_FAMILY_CHAR:
+ pFmt = rDoc.FindCharFmtByName(aName);
+ if (pFmt)
+ {
+ pFmt->SetGrabBagItem(rVal);
+ bChg = true;
+ }
+ break;
+ case SFX_STYLE_FAMILY_PARA:
+ pFmt = rDoc.FindTxtFmtCollByName(aName);
+ if (pFmt)
+ {
+ pFmt->SetGrabBagItem(rVal);
+ bChg = true;
+ }
+ break;
+ case SFX_STYLE_FAMILY_PSEUDO:
+ {
+ SwNumRule* pRule = rDoc.FindNumRulePtr(aName);
+ if (pRule)
+ {
+ pRule->SetGrabBagItem(rVal);
+ bChg = true;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+
+ if (bChg)
+ {
+ dynamic_cast<SwDocStyleSheetPool*>(pPool)->InvalidateIterator();
+ pPool->Broadcast(SfxStyleSheetHint(SFX_STYLESHEET_MODIFIED, *this));
+ SwEditShell* pSh = rDoc.GetEditShell();
+ if (pSh)
+ pSh->CallChgLnk();
+ }
+}
+
+void SwDocStyleSheet::GetGrabBagItem(uno::Any& rVal) const
+{
+ SwFmt* pFmt = 0;
+ switch (nFamily)
+ {
+ case SFX_STYLE_FAMILY_CHAR:
+ pFmt = rDoc.FindCharFmtByName(aName);
+ if (pFmt)
+ pFmt->GetGrabBagItem(rVal);
+ break;
+ case SFX_STYLE_FAMILY_PARA:
+ pFmt = rDoc.FindTxtFmtCollByName(aName);
+ if (pFmt)
+ pFmt->GetGrabBagItem(rVal);
+ break;
+ case SFX_STYLE_FAMILY_PSEUDO:
+ {
+ SwNumRule* pRule = rDoc.FindNumRulePtr(aName);
+ if (pRule)
+ pRule->GetGrabBagItem(rVal);
+ }
+ break;
+ default:
+ break;
+ }
+}
+// virtual methods
+void SwDocStyleSheet::SetHidden( sal_Bool bValue )
+{
+ bool bChg = false;
+ if(!bPhysical)
+ FillStyleSheet( FillPhysical );
+
+ SwFmt* pFmt = 0;
+ switch(nFamily)
+ {
+ case SFX_STYLE_FAMILY_CHAR:
+ pFmt = rDoc.FindCharFmtByName( aName );
+ if ( pFmt )
+ {
+ pFmt->SetHidden( bValue );
+ bChg = true;
+ }
+ break;
+
+ case SFX_STYLE_FAMILY_PARA:
+ pFmt = rDoc.FindTxtFmtCollByName( aName );
+ if ( pFmt )
+ {
+ pFmt->SetHidden( bValue );
+ bChg = true;
+ }
+ break;
+
+ case SFX_STYLE_FAMILY_FRAME:
+ pFmt = rDoc.FindFrmFmtByName( aName );
+ if ( pFmt )
+ {
+ pFmt->SetHidden( bValue );
+ bChg = true;
+ }
+ break;
+
+ case SFX_STYLE_FAMILY_PAGE:
+ {
+ SwPageDesc* pPgDesc = rDoc.FindPageDescByName( aName );
+ if ( pPgDesc )
+ {
+ pPgDesc->SetHidden( bValue );
+ bChg = true;
+ }
+ }
+ break;
+
+ case SFX_STYLE_FAMILY_PSEUDO:
+ {
+ SwNumRule* pRule = rDoc.FindNumRulePtr( aName );
+ if ( pRule )
+ {
+ pRule->SetHidden( bValue );
+ bChg = true;
+ }
+ }
+ default:;
+ }
+
+ if( bChg )
+ {
+ // calling pPool->First() here would be quite slow...
+ dynamic_cast<SwDocStyleSheetPool*>(pPool)->InvalidateIterator(); // internal list has to be updated
+ pPool->Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_MODIFIED, *this ) );
+ SwEditShell* pSh = rDoc.GetEditShell();
+ if( pSh )
+ pSh->CallChgLnk();
+ }
+}
+
+bool SwDocStyleSheet::IsHidden( ) const
+{
+ sal_Bool bRet = sal_False;
+
+ SwFmt* pFmt = 0;
+ switch(nFamily)
+ {
+ case SFX_STYLE_FAMILY_CHAR:
+ pFmt = rDoc.FindCharFmtByName( aName );
+ bRet = pFmt && pFmt->IsHidden( );
+ break;
+
+ case SFX_STYLE_FAMILY_PARA:
+ pFmt = rDoc.FindTxtFmtCollByName( aName );
+ bRet = pFmt && pFmt->IsHidden( );
+ break;
+
+ case SFX_STYLE_FAMILY_FRAME:
+ pFmt = rDoc.FindFrmFmtByName( aName );
+ bRet = pFmt && pFmt->IsHidden( );
+ break;
+
+ case SFX_STYLE_FAMILY_PAGE:
+ {
+ SwPageDesc* pPgDesc = rDoc.FindPageDescByName( aName );
+ bRet = pPgDesc && pPgDesc->IsHidden( );
+ }
+ break;
+ case SFX_STYLE_FAMILY_PSEUDO:
+ {
+ SwNumRule* pRule = rDoc.FindNumRulePtr( aName );
+ bRet = pRule && pRule->IsHidden( );
+ }
+ default:;
+ }
+
+ return bRet;
+}
+
+const OUString& SwDocStyleSheet::GetParent() const
+{
+ if( !bPhysical )
+ {
+ // check if it's already in document
+ SwFmt* pFmt = 0;
+ SwGetPoolIdFromName eGetType;
+ switch(nFamily)
+ {
+ case SFX_STYLE_FAMILY_CHAR:
+ pFmt = rDoc.FindCharFmtByName( aName );
+ eGetType = nsSwGetPoolIdFromName::GET_POOLID_CHRFMT;
+ break;
+
+ case SFX_STYLE_FAMILY_PARA:
+ pFmt = rDoc.FindTxtFmtCollByName( aName );
+ eGetType = nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL;
+ break;
+
+ case SFX_STYLE_FAMILY_FRAME:
+ pFmt = rDoc.FindFrmFmtByName( aName );
+ eGetType = nsSwGetPoolIdFromName::GET_POOLID_FRMFMT;
+ break;
+
+ case SFX_STYLE_FAMILY_PAGE:
+ case SFX_STYLE_FAMILY_PSEUDO:
+ default:
+ return aEmptyOUStr; // there's no parent
+ }
+
+ OUString sTmp;
+ if( !pFmt ) // not yet there, so default Parent
+ {
+ sal_uInt16 i = SwStyleNameMapper::GetPoolIdFromUIName( aName, eGetType );
+ i = ::GetPoolParent( i );
+ if( i && USHRT_MAX != i )
+ SwStyleNameMapper::FillUIName( i, sTmp );
+ }
+ else
+ {
+ SwFmt* p = pFmt->DerivedFrom();
+ if( p && !p->IsDefault() )
+ sTmp = p->GetName();
+ }
+ SwDocStyleSheet* pThis = (SwDocStyleSheet*)this;
+ pThis->aParent = sTmp;
+ }
+ return aParent;
+}
+
+// Follower
+const OUString& SwDocStyleSheet::GetFollow() const
+{
+ if( !bPhysical )
+ {
+ SwDocStyleSheet* pThis = (SwDocStyleSheet*)this;
+ pThis->FillStyleSheet( FillAllInfo );
+ }
+ return aFollow;
+}
+
+// What Linkage is possible
+bool SwDocStyleSheet::HasFollowSupport() const
+{
+ switch(nFamily)
+ {
+ case SFX_STYLE_FAMILY_PARA :
+ case SFX_STYLE_FAMILY_PAGE : return true;
+ case SFX_STYLE_FAMILY_FRAME:
+ case SFX_STYLE_FAMILY_CHAR :
+ case SFX_STYLE_FAMILY_PSEUDO: return false;
+ default:
+ OSL_ENSURE(!this, "unknown style family");
+ }
+ return false;
+}
+
+// Parent ?
+bool SwDocStyleSheet::HasParentSupport() const
+{
+ bool bRet = false;
+ switch(nFamily)
+ {
+ case SFX_STYLE_FAMILY_CHAR :
+ case SFX_STYLE_FAMILY_PARA :
+ case SFX_STYLE_FAMILY_FRAME: bRet = true;
+ default:; //prevent warning
+ }
+ return bRet;
+}
+
+bool SwDocStyleSheet::HasClearParentSupport() const
+{
+ bool bRet = false;
+ switch(nFamily)
+ {
+ case SFX_STYLE_FAMILY_PARA :
+ case SFX_STYLE_FAMILY_CHAR :
+ case SFX_STYLE_FAMILY_FRAME: bRet = true;
+ default:; //prevent warning
+ }
+ return bRet;
+}
+
+// determine textual description
+OUString SwDocStyleSheet::GetDescription(SfxMapUnit eUnit)
+{
+ IntlWrapper aIntlWrapper( SvtSysLocale().GetLanguageTag() );
+
+ const OUString sPlus(" + ");
+ if ( SFX_STYLE_FAMILY_PAGE == nFamily )
+ {
+ if( !pSet )
+ GetItemSet();
+
+ SfxItemIter aIter( *pSet );
+ OUString aDesc;
+
+ for (const SfxPoolItem* pItem = aIter.FirstItem(); pItem; pItem = aIter.NextItem())
+ {
+ if(!IsInvalidItem(pItem))
+ {
+ switch ( pItem->Which() )
+ {
+ case RES_LR_SPACE:
+ case SID_ATTR_PAGE_SIZE:
+ case SID_ATTR_PAGE_MAXSIZE:
+ case SID_ATTR_PAGE_PAPERBIN:
+ case SID_ATTR_PAGE_APP:
+ case SID_ATTR_BORDER_INNER:
+ break;
+ default:
+ {
+ OUString aItemPresentation;
+ if ( !IsInvalidItem( pItem ) &&
+ pPool->GetPool().GetPresentation(
+ *pItem, SFX_ITEM_PRESENTATION_COMPLETE,
+ eUnit, aItemPresentation, &aIntlWrapper ) )
+ {
+ if ( !aDesc.isEmpty() && !aItemPresentation.isEmpty() )
+ aDesc += sPlus;
+ aDesc += aItemPresentation;
+ }
+ }
+ }
+ }
+ }
+ return aDesc;
+ }
+
+ if ( SFX_STYLE_FAMILY_FRAME == nFamily || SFX_STYLE_FAMILY_PARA == nFamily)
+ {
+ if( !pSet )
+ GetItemSet();
+
+ SfxItemIter aIter( *pSet );
+ OUString aDesc;
+ OUString sPageNum;
+ OUString sModel;
+ OUString sBreak;
+ bool bHasWesternFontPrefix = false;
+ bool bHasCJKFontPrefix = false;
+ SvtCJKOptions aCJKOptions;
+
+ for ( const SfxPoolItem* pItem = aIter.FirstItem(); pItem; pItem = aIter.NextItem() )
+ {
+ if(!IsInvalidItem(pItem))
+ {
+ switch ( pItem->Which() )
+ {
+ case SID_ATTR_AUTO_STYLE_UPDATE:
+ case SID_PARA_BACKGRND_DESTINATION:
+ case RES_PAGEDESC:
+ //CTL not yet supported
+ case RES_CHRATR_CTL_FONT:
+ case RES_CHRATR_CTL_FONTSIZE:
+ case RES_CHRATR_CTL_LANGUAGE:
+ case RES_CHRATR_CTL_POSTURE:
+ case RES_CHRATR_CTL_WEIGHT:
+ break;
+ default:
+ {
+ OUString aItemPresentation;
+ if ( !IsInvalidItem( pItem ) &&
+ pPool->GetPool().GetPresentation(
+ *pItem, SFX_ITEM_PRESENTATION_COMPLETE,
+ eUnit, aItemPresentation, &aIntlWrapper ) )
+ {
+ bool bIsDefault = false;
+ switch ( pItem->Which() )
+ {
+ case SID_ATTR_PARA_PAGENUM:
+ sPageNum = aItemPresentation;
+ break;
+ case SID_ATTR_PARA_MODEL:
+ sModel = aItemPresentation;
+ break;
+ case RES_BREAK:
+ sBreak = aItemPresentation;
+ break;
+ case RES_CHRATR_CJK_FONT:
+ case RES_CHRATR_CJK_FONTSIZE:
+ case RES_CHRATR_CJK_LANGUAGE:
+ case RES_CHRATR_CJK_POSTURE:
+ case RES_CHRATR_CJK_WEIGHT:
+ if(aCJKOptions.IsCJKFontEnabled())
+ bIsDefault = true;
+ if(!bHasCJKFontPrefix)
+ {
+ aItemPresentation = SW_RESSTR(STR_CJK_FONT) + aItemPresentation;
+ bHasCJKFontPrefix = true;
+ }
+ break;
+ case RES_CHRATR_FONT:
+ case RES_CHRATR_FONTSIZE:
+ case RES_CHRATR_LANGUAGE:
+ case RES_CHRATR_POSTURE:
+ case RES_CHRATR_WEIGHT:
+ if(!bHasWesternFontPrefix)
+ {
+ aItemPresentation = SW_RESSTR(STR_WESTERN_FONT) + aItemPresentation;
+ bHasWesternFontPrefix = true;
+ bIsDefault = true;
+ }
+ // no break;
+ default:
+ bIsDefault = true;
+ }
+ if(bIsDefault)
+ {
+ if ( !aDesc.isEmpty() && !aItemPresentation.isEmpty() )
+ aDesc += sPlus;
+ aDesc += aItemPresentation;
+ }
+ }
+ }
+ }
+ }
+ }
+ // Special treatment for Break, Page template and Site offset
+ if (!sModel.isEmpty())
+ {
+ if (!aDesc.isEmpty())
+ aDesc += sPlus;
+ aDesc += SW_RESSTR(STR_PAGEBREAK) + sPlus + sModel;
+ if (sPageNum != "0")
+ {
+ aDesc += sPlus + SW_RESSTR(STR_PAGEOFFSET) + sPageNum;
+ }
+ }
+ else if (!sBreak.isEmpty()) // Break can be valid only when NO Model
+ {
+ if (!aDesc.isEmpty())
+ aDesc += sPlus;
+ aDesc += sBreak;
+ }
+ return aDesc;
+ }
+
+ if( SFX_STYLE_FAMILY_PSEUDO == nFamily )
+ {
+ return OUString();
+ }
+
+ return SfxStyleSheetBase::GetDescription(eUnit);
+}
+
+OUString SwDocStyleSheet::GetDescription()
+{
+ return GetDescription(SFX_MAPUNIT_CM);
+}
+
+// Set names
+bool SwDocStyleSheet::SetName( const OUString& rStr)
+{
+ if( rStr.isEmpty() )
+ return false;
+
+ if( aName != rStr )
+ {
+ if( !SfxStyleSheetBase::SetName( rStr ))
+ return false;
+ }
+ else if(!bPhysical)
+ FillStyleSheet( FillPhysical );
+
+ bool bChg = false;
+ switch(nFamily)
+ {
+ case SFX_STYLE_FAMILY_CHAR :
+ {
+ OSL_ENSURE(pCharFmt, "SwCharFormat missing!");
+ if( pCharFmt && pCharFmt->GetName() != rStr )
+ {
+ pCharFmt->SetName( rStr );
+ bChg = true;
+ }
+ break;
+ }
+ case SFX_STYLE_FAMILY_PARA :
+ {
+ OSL_ENSURE(pColl, "Collection missing!");
+ if( pColl && pColl->GetName() != rStr )
+ {
+ if (!pColl->GetName().isEmpty())
+ rDoc.RenameFmt(*pColl, rStr);
+ else
+ pColl->SetName(rStr);
+
+ bChg = true;
+ }
+ break;
+ }
+ case SFX_STYLE_FAMILY_FRAME:
+ {
+ OSL_ENSURE(pFrmFmt, "FrmFmt missing!");
+ if( pFrmFmt && pFrmFmt->GetName() != rStr )
+ {
+ if (!pFrmFmt->GetName().isEmpty())
+ rDoc.RenameFmt(*pFrmFmt, rStr);
+ else
+ pFrmFmt->SetName( rStr );
+
+ bChg = true;
+ }
+ break;
+ }
+ case SFX_STYLE_FAMILY_PAGE :
+ OSL_ENSURE(pDesc, "PageDesc missing!");
+ if( pDesc && pDesc->GetName() != rStr )
+ {
+ // Set PageDesc - copy with earlier one - probably not
+ // necessary for setting the name. So here we allow a
+ // cast.
+ SwPageDesc aPageDesc(*((SwPageDesc*)pDesc));
+ const OUString aOldName(aPageDesc.GetName());
+
+ aPageDesc.SetName( rStr );
+ bool const bDoesUndo = rDoc.GetIDocumentUndoRedo().DoesUndo();
+
+ rDoc.GetIDocumentUndoRedo().DoUndo(!aOldName.isEmpty());
+ rDoc.ChgPageDesc(aOldName, aPageDesc);
+ rDoc.GetIDocumentUndoRedo().DoUndo(bDoesUndo);
+
+ rDoc.SetModified();
+ bChg = true;
+ }
+ break;
+ case SFX_STYLE_FAMILY_PSEUDO:
+ OSL_ENSURE(pNumRule, "NumRule missing!");
+
+ if (pNumRule)
+ {
+ OUString aOldName = pNumRule->GetName();
+
+ if (!aOldName.isEmpty())
+ {
+ if ( aOldName != rStr &&
+ rDoc.RenameNumRule(aOldName, rStr))
+ {
+ pNumRule = rDoc.FindNumRulePtr(rStr);
+ rDoc.SetModified();
+
+ bChg = true;
+ }
+ }
+ else
+ {
+ // #i91400#
+ ((SwNumRule*)pNumRule)->SetName( rStr, rDoc );
+ rDoc.SetModified();
+
+ bChg = true;
+ }
+ }
+
+ break;
+
+ default:
+ OSL_ENSURE(!this, "unknown style family");
+ }
+
+ if( bChg )
+ {
+ pPool->First(); // internal list has to be updated
+ pPool->Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_MODIFIED, *this ) );
+ SwEditShell* pSh = rDoc.GetEditShell();
+ if( pSh )
+ pSh->CallChgLnk();
+ }
+ return true;
+}
+
+// hierarchy of deduction
+bool SwDocStyleSheet::SetParent( const OUString& rStr)
+{
+ SwFmt* pFmt = 0, *pParent = 0;
+ switch(nFamily)
+ {
+ case SFX_STYLE_FAMILY_CHAR :
+ OSL_ENSURE( pCharFmt, "SwCharFormat missing!" );
+ if( 0 != ( pFmt = pCharFmt ) && !rStr.isEmpty() )
+ pParent = lcl_FindCharFmt(rDoc, rStr);
+ break;
+
+ case SFX_STYLE_FAMILY_PARA :
+ OSL_ENSURE( pColl, "Collektion missing!");
+ if( 0 != ( pFmt = pColl ) && !rStr.isEmpty() )
+ pParent = lcl_FindParaFmt( rDoc, rStr );
+ break;
+
+ case SFX_STYLE_FAMILY_FRAME:
+ OSL_ENSURE(pFrmFmt, "FrameFormat missing!");
+ if( 0 != ( pFmt = pFrmFmt ) && !rStr.isEmpty() )
+ pParent = lcl_FindFrmFmt( rDoc, rStr );
+ break;
+
+ case SFX_STYLE_FAMILY_PAGE:
+ case SFX_STYLE_FAMILY_PSEUDO:
+ break;
+ default:
+ OSL_ENSURE(!this, "unknown style family");
+ }
+
+ bool bRet = false;
+ if( pFmt && pFmt->DerivedFrom() &&
+ pFmt->DerivedFrom()->GetName() != rStr )
+ {
+ {
+ SwImplShellAction aTmp( rDoc );
+ bRet = pFmt->SetDerivedFrom( pParent );
+ }
+
+ if( bRet )
+ {
+ aParent = rStr;
+ pPool->Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_MODIFIED,
+ *this ) );
+ }
+ }
+
+ return bRet;
+}
+
+// Set Follower
+bool SwDocStyleSheet::SetFollow( const OUString& rStr)
+{
+ if( !rStr.isEmpty() && !SfxStyleSheetBase::SetFollow( rStr ))
+ return false;
+
+ SwImplShellAction aTmpSh( rDoc );
+ switch(nFamily)
+ {
+ case SFX_STYLE_FAMILY_PARA :
+ {
+ OSL_ENSURE(pColl, "Collection missing!");
+ if( pColl )
+ {
+ SwTxtFmtColl* pFollow = pColl;
+ if( !rStr.isEmpty() && 0 == (pFollow = lcl_FindParaFmt(rDoc, rStr) ))
+ pFollow = pColl;
+
+ pColl->SetNextTxtFmtColl(*pFollow);
+ }
+ break;
+ }
+ case SFX_STYLE_FAMILY_PAGE :
+ {
+ OSL_ENSURE(pDesc, "PageDesc missing!");
+ if( pDesc )
+ {
+ const SwPageDesc* pFollowDesc = !rStr.isEmpty()
+ ? lcl_FindPageDesc(rDoc, rStr)
+ : 0;
+ sal_uInt16 nId = 0;
+ if( pFollowDesc != pDesc->GetFollow() &&
+ rDoc.FindPageDescByName( pDesc->GetName(), &nId ) )
+ {
+ SwPageDesc aDesc( *pDesc );
+ aDesc.SetFollow( pFollowDesc );
+ rDoc.ChgPageDesc( nId, aDesc );
+ pDesc = &rDoc.GetPageDesc( nId );
+ }
+ }
+ break;
+ }
+ case SFX_STYLE_FAMILY_CHAR:
+ case SFX_STYLE_FAMILY_FRAME:
+ case SFX_STYLE_FAMILY_PSEUDO:
+ break;
+ default:
+ OSL_ENSURE(!this, "unknwown style family");
+ }
+
+ return true;
+}
+
+// extract ItemSet to Name and Family, Mask
+SfxItemSet& SwDocStyleSheet::GetItemSet()
+{
+ if(!bPhysical)
+ FillStyleSheet( FillPhysical );
+
+ switch(nFamily)
+ {
+ case SFX_STYLE_FAMILY_CHAR:
+ case SFX_STYLE_FAMILY_PARA:
+ case SFX_STYLE_FAMILY_FRAME:
+ {
+ SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
+ aBoxInfo.SetTable( false );
+ aBoxInfo.SetDist( true ); // always show gap field
+ aBoxInfo.SetMinDist( true );// set minimum size in tables and paragraphs
+ aBoxInfo.SetDefDist( MIN_BORDER_DIST );// always set Default-Gap
+ // Single lines can only have DontCare-Status in tables
+ aBoxInfo.SetValid( VALID_DISABLE, true );
+
+ if( nFamily == SFX_STYLE_FAMILY_CHAR )
+ {
+ SAL_WARN_IF(!pCharFmt, "sw.ui", "Where's SwCharFmt");
+ aCoreSet.Put(pCharFmt->GetAttrSet());
+ aCoreSet.Put( aBoxInfo );
+
+ if(pCharFmt->DerivedFrom())
+ aCoreSet.SetParent(&pCharFmt->DerivedFrom()->GetAttrSet());
+ }
+ else if ( nFamily == SFX_STYLE_FAMILY_PARA )
+ {
+ OSL_ENSURE(pColl, "Where's Collection");
+ aCoreSet.Put(pColl->GetAttrSet());
+ aCoreSet.Put( aBoxInfo );
+ aCoreSet.Put(SfxBoolItem(SID_ATTR_AUTO_STYLE_UPDATE, pColl->IsAutoUpdateFmt()));
+
+ if(pColl->DerivedFrom())
+ aCoreSet.SetParent(&pColl->DerivedFrom()->GetAttrSet());
+ }
+ else
+ {
+ OSL_ENSURE(pFrmFmt, "Where's FrmFmt");
+ aCoreSet.Put(pFrmFmt->GetAttrSet());
+ aCoreSet.Put( aBoxInfo );
+ aCoreSet.Put(SfxBoolItem(SID_ATTR_AUTO_STYLE_UPDATE, pFrmFmt->IsAutoUpdateFmt()));
+
+ if(pFrmFmt->DerivedFrom())
+ aCoreSet.SetParent(&pFrmFmt->DerivedFrom()->GetAttrSet());
+ }
+ }
+ break;
+
+ case SFX_STYLE_FAMILY_PAGE :
+ {
+ OSL_ENSURE(pDesc, "No PageDescriptor");
+ ::PageDescToItemSet(*((SwPageDesc*)pDesc), aCoreSet);
+ }
+ break;
+
+ case SFX_STYLE_FAMILY_PSEUDO:
+ {
+ OSL_ENSURE(pNumRule, "No NumRule");
+ SvxNumRule aRule = pNumRule->MakeSvxNumRule();
+ aCoreSet.Put(SvxNumBulletItem(aRule));
+ }
+ break;
+
+ default:
+ OSL_ENSURE(!this, "unknown style family");
+ }
+ // Member of Baseclass
+ pSet = &aCoreSet;
+
+ return aCoreSet;
+}
+
+void SwDocStyleSheet::MergeIndentAttrsOfListStyle( SfxItemSet& rSet )
+{
+ if ( nFamily != SFX_STYLE_FAMILY_PARA )
+ {
+ return;
+ }
+
+ OSL_ENSURE( pColl, "<SwDocStyleSheet::MergeIndentAttrsOfListStyle(..)> - missing paragraph style");
+ if ( pColl->AreListLevelIndentsApplicable() )
+ {
+ OSL_ENSURE( pColl->GetItemState( RES_PARATR_NUMRULE ) == SFX_ITEM_SET,
+ "<SwDocStyleSheet::MergeIndentAttrsOfListStyle(..)> - list level indents are applicable at paragraph style, but no list style found. Serious defect -> please inform OD." );
+ const OUString sNumRule = pColl->GetNumRule().GetValue();
+ if (!sNumRule.isEmpty())
+ {
+ const SwNumRule* pRule = rDoc.FindNumRulePtr( sNumRule );
+ if( pRule )
+ {
+ const SwNumFmt& rFmt = pRule->Get( 0 );
+ if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
+ {
+ SvxLRSpaceItem aLR( RES_LR_SPACE );
+ aLR.SetTxtLeft( rFmt.GetIndentAt() );
+ aLR.SetTxtFirstLineOfst( static_cast<short>(rFmt.GetFirstLineIndent()) );
+ rSet.Put( aLR );
+ }
+ }
+ }
+ }
+}
+
+// handling of parameter <bResetIndentAttrsAtParagraphStyle>
+void SwDocStyleSheet::SetItemSet( const SfxItemSet& rSet,
+ const bool bResetIndentAttrsAtParagraphStyle )
+{
+ // if applicable determine format first
+ if(!bPhysical)
+ FillStyleSheet( FillPhysical );
+
+ SwImplShellAction aTmpSh( rDoc );
+
+ OSL_ENSURE( &rSet != &aCoreSet, "SetItemSet with own Set is not allowed" );
+
+ if (rDoc.GetIDocumentUndoRedo().DoesUndo())
+ {
+ SwRewriter aRewriter;
+ aRewriter.AddRule( UndoArg1, GetName() );
+ rDoc.GetIDocumentUndoRedo().StartUndo( UNDO_INSFMTATTR, &aRewriter );
+ }
+
+ SwFmt* pFmt = 0;
+ SwPageDesc* pNewDsc = 0;
+ sal_uInt16 nPgDscPos = 0;
+
+ switch(nFamily)
+ {
+ case SFX_STYLE_FAMILY_CHAR :
+ {
+ OSL_ENSURE(pCharFmt, "Where's CharFormat");
+ pFmt = pCharFmt;
+ }
+ break;
+
+ case SFX_STYLE_FAMILY_PARA :
+ {
+ OSL_ENSURE(pColl, "Where's Collection");
+ const SfxPoolItem* pAutoUpdate;
+ if(SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_AUTO_STYLE_UPDATE,false, &pAutoUpdate ))
+ {
+ pColl->SetAutoUpdateFmt(((const SfxBoolItem*)pAutoUpdate)->GetValue());
+ }
+
+ const SwCondCollItem* pCondItem;
+ if( SFX_ITEM_SET != rSet.GetItemState( FN_COND_COLL, false,
+ (const SfxPoolItem**)&pCondItem ))
+ pCondItem = 0;
+
+ if( RES_CONDTXTFMTCOLL == pColl->Which() && pCondItem )
+ {
+ const CommandStruct* pCmds = SwCondCollItem::GetCmds();
+ for(sal_uInt16 i = 0; i < COND_COMMAND_COUNT; i++)
+ {
+ SwCollCondition aCond( 0, pCmds[ i ].nCnd, pCmds[ i ].nSubCond );
+ ((SwConditionTxtFmtColl*)pColl)->RemoveCondition( aCond );
+ const OUString sStyle = pCondItem->GetStyle( i );
+ if (sStyle.isEmpty())
+ continue;
+ SwFmt *const pFindFmt = lcl_FindParaFmt( rDoc, sStyle, 0, true );
+ if (pFindFmt)
+ {
+ aCond.RegisterToFormat( *pFindFmt );
+ ((SwConditionTxtFmtColl*)pColl)->InsertCondition( aCond );
+ }
+ }
+
+ // Update document to new conditions
+ SwCondCollCondChg aMsg( pColl );
+ pColl->ModifyNotification( &aMsg, &aMsg );
+ }
+ else if( pCondItem && !pColl->GetDepends() )
+ {
+ // no conditional template, then first create and adopt
+ // all important values
+ SwConditionTxtFmtColl* pCColl = rDoc.MakeCondTxtFmtColl(
+ pColl->GetName(), (SwTxtFmtColl*)pColl->DerivedFrom() );
+ if( pColl != &pColl->GetNextTxtFmtColl() )
+ pCColl->SetNextTxtFmtColl( pColl->GetNextTxtFmtColl() );
+
+ if( pColl->IsAssignedToListLevelOfOutlineStyle())
+ pCColl->AssignToListLevelOfOutlineStyle(pColl->GetAssignedOutlineStyleLevel());
+ else
+ pCColl->DeleteAssignmentToListLevelOfOutlineStyle();
+
+ const CommandStruct* pCmds = SwCondCollItem::GetCmds();
+ for( sal_uInt16 i = 0; i < COND_COMMAND_COUNT; ++i )
+ {
+ const OUString sStyle = pCondItem->GetStyle( i );
+ if (sStyle.isEmpty())
+ continue;
+ SwTxtFmtColl *const pFindFmt = lcl_FindParaFmt( rDoc, sStyle, 0, true );
+ if (pFindFmt)
+ {
+ pCColl->InsertCondition( SwCollCondition( pFindFmt,
+ pCmds[ i ].nCnd, pCmds[ i ].nSubCond ) );
+ }
+ }
+
+ rDoc.DelTxtFmtColl( pColl );
+ pColl = pCColl;
+ }
+ if ( bResetIndentAttrsAtParagraphStyle &&
+ rSet.GetItemState( RES_PARATR_NUMRULE, false, 0 ) == SFX_ITEM_SET &&
+ rSet.GetItemState( RES_LR_SPACE, false, 0 ) != SFX_ITEM_SET &&
+ pColl->GetItemState( RES_LR_SPACE, sal_False, 0 ) == SFX_ITEM_SET )
+ {
+ rDoc.ResetAttrAtFormat( RES_LR_SPACE, *pColl );
+ }
+
+ // #i56252: If a standard numbering style is assigned to a standard paragraph style
+ // we have to create a physical instance of the numbering style. If we do not and
+ // neither the paragraph style nor the numbering style is used in the document
+ // the numbering style will not be saved with the document and the assignment got lost.
+ const SfxPoolItem* pNumRuleItem = 0;
+ if( SFX_ITEM_SET == rSet.GetItemState( RES_PARATR_NUMRULE, false, &pNumRuleItem ) )
+ { // Setting a numbering rule?
+ const OUString sNumRule = ((SwNumRuleItem*)pNumRuleItem)->GetValue();
+ if (!sNumRule.isEmpty())
+ {
+ SwNumRule* pRule = rDoc.FindNumRulePtr( sNumRule );
+ if( !pRule )
+ { // Numbering rule not in use yet.
+ sal_uInt16 nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( sNumRule, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE );
+ if( USHRT_MAX != nPoolId ) // It's a standard numbering rule
+ {
+ pRule = rDoc.GetNumRuleFromPool( nPoolId ); // Create numbering rule (physical)
+ }
+ }
+ }
+ }
+
+ pFmt = pColl;
+
+ sal_uInt16 nId = pColl->GetPoolFmtId() &
+ ~ ( COLL_GET_RANGE_BITS | POOLGRP_NOCOLLID );
+ switch( GetMask() & ( 0x0fff & ~SWSTYLEBIT_CONDCOLL ) )
+ {
+ case SWSTYLEBIT_TEXT:
+ nId |= COLL_TEXT_BITS;
+ break;
+ case SWSTYLEBIT_CHAPTER:
+ nId |= COLL_DOC_BITS;
+ break;
+ case SWSTYLEBIT_LIST:
+ nId |= COLL_LISTS_BITS;
+ break;
+ case SWSTYLEBIT_IDX:
+ nId |= COLL_REGISTER_BITS;
+ break;
+ case SWSTYLEBIT_EXTRA:
+ nId |= COLL_EXTRA_BITS;
+ break;
+ case SWSTYLEBIT_HTML:
+ nId |= COLL_HTML_BITS;
+ break;
+ }
+ pColl->SetPoolFmtId( nId );
+ break;
+ }
+ case SFX_STYLE_FAMILY_FRAME:
+ {
+ OSL_ENSURE(pFrmFmt, "Where's FrmFmt");
+ const SfxPoolItem* pAutoUpdate;
+ if(SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_AUTO_STYLE_UPDATE,false, &pAutoUpdate ))
+ {
+ pFrmFmt->SetAutoUpdateFmt(((const SfxBoolItem*)pAutoUpdate)->GetValue());
+ }
+ pFmt = pFrmFmt;
+ }
+ break;
+
+ case SFX_STYLE_FAMILY_PAGE :
+ {
+ OSL_ENSURE(pDesc, "Where's PageDescriptor");
+
+ if( rDoc.FindPageDescByName( pDesc->GetName(), &nPgDscPos ))
+ {
+ pNewDsc = new SwPageDesc( *pDesc );
+ // #i48949# - no undo actions for the
+ // copy of the page style
+ ::sw::UndoGuard const ug(rDoc.GetIDocumentUndoRedo());
+ rDoc.CopyPageDesc(*pDesc, *pNewDsc); // #i7983#
+
+ pFmt = &pNewDsc->GetMaster();
+ }
+ }
+ break;
+
+ case SFX_STYLE_FAMILY_PSEUDO:
+ {
+ OSL_ENSURE(pNumRule, "Where's NumRule");
+
+ if (!pNumRule)
+ break;
+
+ const SfxPoolItem* pItem;
+ switch( rSet.GetItemState( SID_ATTR_NUMBERING_RULE, false, &pItem ))
+ {
+ case SFX_ITEM_SET:
+ {
+ SvxNumRule* pSetRule = ((SvxNumBulletItem*)pItem)->GetNumRule();
+ pSetRule->UnLinkGraphics();
+ SwNumRule aSetRule(*pNumRule);
+ aSetRule.SetSvxRule(*pSetRule, &rDoc);
+ rDoc.ChgNumRuleFmts( aSetRule );
+ }
+ break;
+ case SFX_ITEM_DONTCARE:
+ // set NumRule to default values
+ // what are the default values?
+ {
+ SwNumRule aRule( pNumRule->GetName(),
+ // #i89178#
+ numfunc::GetDefaultPositionAndSpaceMode() );
+ rDoc.ChgNumRuleFmts( aRule );
+ }
+ break;
+ }
+ }
+ break;
+
+ default:
+ OSL_ENSURE(!this, "unknown style family");
+ }
+
+ if( pFmt && rSet.Count())
+ {
+ SfxItemIter aIter( rSet );
+ const SfxPoolItem* pItem = aIter.GetCurItem();
+ while( true )
+ {
+ if( IsInvalidItem( pItem ) ) // Clear
+ {
+ // use method <SwDoc::ResetAttrAtFormat(..)> in order to
+ // create an Undo object for the attribute reset.
+ rDoc.ResetAttrAtFormat( rSet.GetWhichByPos(aIter.GetCurPos()),
+ *pFmt );
+ }
+
+ if( aIter.IsAtEnd() )
+ break;
+ pItem = aIter.NextItem();
+ }
+ SfxItemSet aSet(rSet);
+ aSet.ClearInvalidItems();
+
+ aCoreSet.ClearItem();
+
+ if( pNewDsc )
+ {
+ ::ItemSetToPageDesc( aSet, *pNewDsc );
+ rDoc.ChgPageDesc( nPgDscPos, *pNewDsc );
+ pDesc = &rDoc.GetPageDesc( nPgDscPos );
+ rDoc.PreDelPageDesc(pNewDsc); // #i7983#
+ delete pNewDsc;
+ }
+ else
+ rDoc.ChgFmt(*pFmt, aSet); // put all that is set
+ }
+ else
+ {
+ aCoreSet.ClearItem();
+ if( pNewDsc ) // we still need to delete it
+ {
+ rDoc.PreDelPageDesc(pNewDsc); // #i7983#
+ delete pNewDsc;
+ }
+ }
+
+ if (rDoc.GetIDocumentUndoRedo().DoesUndo())
+ {
+ rDoc.GetIDocumentUndoRedo().EndUndo(UNDO_END, 0);
+ }
+}
+
+static void lcl_SaveStyles( sal_uInt16 nFamily, std::vector<void*>& rArr, SwDoc& rDoc )
+{
+ switch( nFamily )
+ {
+ case SFX_STYLE_FAMILY_CHAR:
+ {
+ const SwCharFmts& rTbl = *rDoc.GetCharFmts();
+ for( sal_uInt16 n = 0, nCnt = rTbl.size(); n < nCnt; ++n )
+ {
+ rArr.push_back( rTbl[ n ] );
+ }
+ }
+ break;
+ case SFX_STYLE_FAMILY_PARA:
+ {
+ const SwTxtFmtColls& rTbl = *rDoc.GetTxtFmtColls();
+ for( sal_uInt16 n = 0, nCnt = rTbl.size(); n < nCnt; ++n )
+ {
+ rArr.push_back( rTbl[ n ] );
+ }
+ }
+ break;
+ case SFX_STYLE_FAMILY_FRAME:
+ {
+ const SwFrmFmts& rTbl = *rDoc.GetFrmFmts();
+ for( sal_uInt16 n = 0, nCnt = rTbl.size(); n < nCnt; ++n )
+ {
+ rArr.push_back( rTbl[ n ] );
+ }
+ }
+ break;
+
+ case SFX_STYLE_FAMILY_PAGE:
+ {
+ for( sal_uInt16 n = 0, nCnt = rDoc.GetPageDescCnt(); n < nCnt; ++n )
+ {
+ rArr.push_back( &rDoc.GetPageDesc( n ) );
+ }
+ }
+ break;
+
+ case SFX_STYLE_FAMILY_PSEUDO:
+ {
+ const SwNumRuleTbl& rTbl = rDoc.GetNumRuleTbl();
+ for( sal_uInt16 n = 0, nCnt = rTbl.size(); n < nCnt; ++n )
+ {
+ rArr.push_back( rTbl[ n ] );
+ }
+ }
+ break;
+ }
+}
+
+static bool lcl_Contains(const std::vector<void*>& rArr, const void* p)
+{
+ return std::find( rArr.begin(), rArr.end(), p ) != rArr.end();
+}
+
+static void lcl_DeleteInfoStyles( sal_uInt16 nFamily, std::vector<void*>& rArr, SwDoc& rDoc )
+{
+ sal_uInt16 n, nCnt;
+ switch( nFamily )
+ {
+ case SFX_STYLE_FAMILY_CHAR:
+ {
+ std::deque<sal_uInt16> aDelArr;
+ const SwCharFmts& rTbl = *rDoc.GetCharFmts();
+ for( n = 0, nCnt = rTbl.size(); n < nCnt; ++n )
+ {
+ if( !lcl_Contains( rArr, rTbl[ n ] ))
+ aDelArr.push_front( n );
+ }
+ for( n = 0, nCnt = aDelArr.size(); n < nCnt; ++n )
+ rDoc.DelCharFmt( aDelArr[ n ] );
+ }
+ break;
+
+ case SFX_STYLE_FAMILY_PARA :
+ {
+ std::deque<sal_uInt16> aDelArr;
+ const SwTxtFmtColls& rTbl = *rDoc.GetTxtFmtColls();
+ for( n = 0, nCnt = rTbl.size(); n < nCnt; ++n )
+ {
+ if( !lcl_Contains( rArr, rTbl[ n ] ))
+ aDelArr.push_front( n );
+ }
+ for( n = 0, nCnt = aDelArr.size(); n < nCnt; ++n )
+ rDoc.DelTxtFmtColl( aDelArr[ n ] );
+ }
+ break;
+
+ case SFX_STYLE_FAMILY_FRAME:
+ {
+ std::deque<SwFrmFmt*> aDelArr;
+ const SwFrmFmts& rTbl = *rDoc.GetFrmFmts();
+ for( n = 0, nCnt = rTbl.size(); n < nCnt; ++n )
+ {
+ if( !lcl_Contains( rArr, rTbl[ n ] ))
+ aDelArr.push_front( rTbl[ n ] );
+ }
+ for( n = 0, nCnt = aDelArr.size(); n < nCnt; ++n )
+ rDoc.DelFrmFmt( aDelArr[ n ] );
+ }
+ break;
+
+ case SFX_STYLE_FAMILY_PAGE:
+ {
+ std::deque<sal_uInt16> aDelArr;
+ for( n = 0, nCnt = rDoc.GetPageDescCnt(); n < nCnt; ++n )
+ {
+ if( !lcl_Contains( rArr, &rDoc.GetPageDesc( n ) ))
+ aDelArr.push_front( n );
+ }
+ for( n = 0, nCnt = aDelArr.size(); n < nCnt; ++n )
+ rDoc.DelPageDesc( aDelArr[ n ] );
+ }
+ break;
+
+ case SFX_STYLE_FAMILY_PSEUDO:
+ {
+ std::deque<SwNumRule*> aDelArr;
+ const SwNumRuleTbl& rTbl = rDoc.GetNumRuleTbl();
+ for( n = 0, nCnt = rTbl.size(); n < nCnt; ++n )
+ {
+ if( !lcl_Contains( rArr, rTbl[ n ] ))
+ aDelArr.push_front( rTbl[ n ] );
+ }
+ for( n = 0, nCnt = aDelArr.size(); n < nCnt; ++n )
+ rDoc.DelNumRule( aDelArr[ n ]->GetName() );
+ }
+ break;
+ }
+}
+
+// determine the format
+sal_Bool SwDocStyleSheet::FillStyleSheet( FillStyleType eFType )
+{
+ sal_Bool bRet = sal_False;
+ sal_uInt16 nPoolId = USHRT_MAX;
+ SwFmt* pFmt = 0;
+
+ bool bCreate = FillPhysical == eFType;
+ bool bDeleteInfo = false;
+ bool bFillOnlyInfo = FillAllInfo == eFType;
+ std::vector<void*> aDelArr;
+
+ switch(nFamily)
+ {
+ case SFX_STYLE_FAMILY_CHAR:
+ pCharFmt = lcl_FindCharFmt(rDoc, aName, this, bCreate );
+ bPhysical = 0 != pCharFmt;
+ if( bFillOnlyInfo && !bPhysical )
+ {
+ bDeleteInfo = true;
+ ::lcl_SaveStyles( static_cast< sal_uInt16 >(nFamily), aDelArr, rDoc );
+ pCharFmt = lcl_FindCharFmt(rDoc, aName, this, true );
+ }
+
+ pFmt = pCharFmt;
+ if( !bCreate && !pFmt )
+ {
+ if( aName == SwStyleNameMapper::GetTextUINameArray()[ RES_POOLCOLL_STANDARD -
+ RES_POOLCOLL_TEXT_BEGIN ] )
+ nPoolId = 0;
+ else
+ nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT );
+ }
+
+ bRet = 0 != pCharFmt || USHRT_MAX != nPoolId;
+
+ if( bDeleteInfo )
+ pCharFmt = 0;
+ break;
+
+ case SFX_STYLE_FAMILY_PARA:
+ {
+ pColl = lcl_FindParaFmt(rDoc, aName, this, bCreate);
+ bPhysical = 0 != pColl;
+ if( bFillOnlyInfo && !bPhysical )
+ {
+ bDeleteInfo = true;
+ ::lcl_SaveStyles( static_cast< sal_uInt16 >(nFamily), aDelArr, rDoc );
+ pColl = lcl_FindParaFmt(rDoc, aName, this, true );
+ }
+
+ pFmt = pColl;
+ if( pColl )
+ PresetFollow( pColl->GetNextTxtFmtColl().GetName() );
+ else if( !bCreate )
+ nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
+
+ bRet = 0 != pColl || USHRT_MAX != nPoolId;
+
+ if( bDeleteInfo )
+ pColl = 0;
+ }
+ break;
+
+ case SFX_STYLE_FAMILY_FRAME:
+ pFrmFmt = lcl_FindFrmFmt(rDoc, aName, this, bCreate);
+ bPhysical = 0 != pFrmFmt;
+ if( bFillOnlyInfo && bPhysical )
+ {
+ bDeleteInfo = true;
+ ::lcl_SaveStyles( static_cast< sal_uInt16 >(nFamily), aDelArr, rDoc );
+ pFrmFmt = lcl_FindFrmFmt(rDoc, aName, this, true );
+ }
+ pFmt = pFrmFmt;
+ if( !bCreate && !pFmt )
+ nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT );
+
+ bRet = 0 != pFrmFmt || USHRT_MAX != nPoolId;
+
+ if( bDeleteInfo )
+ pFrmFmt = 0;
+ break;
+
+ case SFX_STYLE_FAMILY_PAGE:
+ pDesc = lcl_FindPageDesc(rDoc, aName, this, bCreate);
+ bPhysical = 0 != pDesc;
+ if( bFillOnlyInfo && !pDesc )
+ {
+ bDeleteInfo = true;
+ ::lcl_SaveStyles( static_cast< sal_uInt16 >(nFamily), aDelArr, rDoc );
+ pDesc = lcl_FindPageDesc( rDoc, aName, this, true );
+ }
+
+ if( pDesc )
+ {
+ nPoolId = pDesc->GetPoolFmtId();
+ nHelpId = pDesc->GetPoolHelpId();
+ if( pDesc->GetPoolHlpFileId() != UCHAR_MAX )
+ aHelpFile = *rDoc.GetDocPattern( pDesc->GetPoolHlpFileId() );
+ else
+ aHelpFile = "";
+ }
+ else if( !bCreate )
+ nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC );
+ SetMask( USER_FMT & nPoolId ? SFXSTYLEBIT_USERDEF : 0 );
+
+ bRet = 0 != pDesc || USHRT_MAX != nPoolId;
+ if( bDeleteInfo )
+ pDesc = 0;
+ break;
+
+ case SFX_STYLE_FAMILY_PSEUDO:
+ pNumRule = lcl_FindNumRule(rDoc, aName, this, bCreate);
+ bPhysical = 0 != pNumRule;
+ if( bFillOnlyInfo && !pNumRule )
+ {
+ bDeleteInfo = true;
+ ::lcl_SaveStyles( static_cast< sal_uInt16 >(nFamily), aDelArr, rDoc );
+ pNumRule = lcl_FindNumRule( rDoc, aName, this, true );
+ }
+
+ if( pNumRule )
+ {
+ nPoolId = pNumRule->GetPoolFmtId();
+ nHelpId = pNumRule->GetPoolHelpId();
+ if( pNumRule->GetPoolHlpFileId() != UCHAR_MAX )
+ aHelpFile = *rDoc.GetDocPattern( pNumRule->GetPoolHlpFileId() );
+ else
+ aHelpFile = "";
+ }
+ else if( !bCreate )
+ nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE );
+ SetMask( USER_FMT & nPoolId ? SFXSTYLEBIT_USERDEF : 0 );
+
+ bRet = 0 != pNumRule || USHRT_MAX != nPoolId;
+
+ if( bDeleteInfo )
+ pNumRule = 0;
+ break;
+ default:; //prevent warning
+ }
+
+ if( SFX_STYLE_FAMILY_CHAR == nFamily ||
+ SFX_STYLE_FAMILY_PARA == nFamily ||
+ SFX_STYLE_FAMILY_FRAME == nFamily )
+ {
+ if( pFmt )
+ nPoolId = pFmt->GetPoolFmtId();
+
+ sal_uInt16 _nMask = 0;
+ if( pFmt == rDoc.GetDfltCharFmt() )
+ _nMask |= SFXSTYLEBIT_READONLY;
+ else if( USER_FMT & nPoolId )
+ _nMask |= SFXSTYLEBIT_USERDEF;
+
+ switch ( COLL_GET_RANGE_BITS & nPoolId )
+ {
+ case COLL_TEXT_BITS: _nMask |= SWSTYLEBIT_TEXT; break;
+ case COLL_DOC_BITS : _nMask |= SWSTYLEBIT_CHAPTER; break;
+ case COLL_LISTS_BITS: _nMask |= SWSTYLEBIT_LIST; break;
+ case COLL_REGISTER_BITS: _nMask |= SWSTYLEBIT_IDX; break;
+ case COLL_EXTRA_BITS: _nMask |= SWSTYLEBIT_EXTRA; break;
+ case COLL_HTML_BITS: _nMask |= SWSTYLEBIT_HTML; break;
+ }
+
+ if( pFmt )
+ {
+ OSL_ENSURE( bPhysical, "Format not found" );
+
+ nHelpId = pFmt->GetPoolHelpId();
+ if( pFmt->GetPoolHlpFileId() != UCHAR_MAX )
+ aHelpFile = *rDoc.GetDocPattern( pFmt->GetPoolHlpFileId() );
+ else
+ aHelpFile = "";
+
+ if( RES_CONDTXTFMTCOLL == pFmt->Which() )
+ _nMask |= SWSTYLEBIT_CONDCOLL;
+ }
+
+ SetMask( _nMask );
+ }
+ if( bDeleteInfo && bFillOnlyInfo )
+ ::lcl_DeleteInfoStyles( static_cast< sal_uInt16 >(nFamily), aDelArr, rDoc );
+ return bRet;
+}
+
+// Create new format in Core
+void SwDocStyleSheet::Create()
+{
+ switch(nFamily)
+ {
+ case SFX_STYLE_FAMILY_CHAR :
+ pCharFmt = lcl_FindCharFmt( rDoc, aName );
+ if( !pCharFmt )
+ pCharFmt = rDoc.MakeCharFmt(aName,
+ rDoc.GetDfltCharFmt());
+ pCharFmt->SetAuto( false );
+ break;
+
+ case SFX_STYLE_FAMILY_PARA :
+ pColl = lcl_FindParaFmt( rDoc, aName );
+ if( !pColl )
+ {
+ SwTxtFmtColl *pPar = (*rDoc.GetTxtFmtColls())[0];
+ if( nMask & SWSTYLEBIT_CONDCOLL )
+ pColl = rDoc.MakeCondTxtFmtColl( aName, pPar );
+ else
+ pColl = rDoc.MakeTxtFmtColl( aName, pPar );
+ }
+ break;
+
+ case SFX_STYLE_FAMILY_FRAME:
+ pFrmFmt = lcl_FindFrmFmt( rDoc, aName );
+ if( !pFrmFmt )
+ pFrmFmt = rDoc.MakeFrmFmt(aName, rDoc.GetDfltFrmFmt(), false, false);
+
+ break;
+
+ case SFX_STYLE_FAMILY_PAGE :
+ pDesc = lcl_FindPageDesc( rDoc, aName );
+ if( !pDesc )
+ {
+ sal_uInt16 nId = rDoc.MakePageDesc(aName);
+ pDesc = &rDoc.GetPageDesc(nId);
+ }
+ break;
+
+ case SFX_STYLE_FAMILY_PSEUDO:
+ pNumRule = lcl_FindNumRule( rDoc, aName );
+ if( !pNumRule )
+ {
+ const OUString sTmpNm( aName.isEmpty() ? rDoc.GetUniqueNumRuleName() : aName );
+ SwNumRule* pRule = rDoc.GetNumRuleTbl()[
+ rDoc.MakeNumRule( sTmpNm, 0, false,
+ // #i89178#
+ numfunc::GetDefaultPositionAndSpaceMode() ) ];
+ pRule->SetAutoRule( sal_False );
+ if( aName.isEmpty() )
+ {
+ // #i91400#
+ pRule->SetName( aName, rDoc );
+ }
+ pNumRule = pRule;
+ }
+ break;
+ default:; //prevent warning
+ }
+ bPhysical = sal_True;
+ aCoreSet.ClearItem();
+}
+
+SwCharFmt* SwDocStyleSheet::GetCharFmt()
+{
+ if(!bPhysical)
+ FillStyleSheet( FillPhysical );
+ return pCharFmt;
+}
+
+SwTxtFmtColl* SwDocStyleSheet::GetCollection()
+{
+ if(!bPhysical)
+ FillStyleSheet( FillPhysical );
+ return pColl;
+}
+
+const SwPageDesc* SwDocStyleSheet::GetPageDesc()
+{
+ if(!bPhysical)
+ FillStyleSheet( FillPhysical );
+ return pDesc;
+}
+
+const SwNumRule * SwDocStyleSheet::GetNumRule()
+{
+ if(!bPhysical)
+ FillStyleSheet( FillPhysical );
+ return pNumRule;
+}
+
+void SwDocStyleSheet::SetNumRule(const SwNumRule& rRule)
+{
+ OSL_ENSURE(pNumRule, "Wo ist die NumRule");
+ rDoc.ChgNumRuleFmts( rRule );
+}
+
+// re-generate Name AND Family from String
+// First() and Next() (see below) insert an identification letter at Pos.1
+
+void SwDocStyleSheet::PresetNameAndFamily(const OUString& rName)
+{
+ switch( rName[0] )
+ {
+ case cPARA: nFamily = SFX_STYLE_FAMILY_PARA; break;
+ case cFRAME: nFamily = SFX_STYLE_FAMILY_FRAME; break;
+ case cPAGE: nFamily = SFX_STYLE_FAMILY_PAGE; break;
+ case cNUMRULE: nFamily = SFX_STYLE_FAMILY_PSEUDO; break;
+ default: nFamily = SFX_STYLE_FAMILY_CHAR; break;
+ }
+ aName = rName.copy(1);
+}
+
+// Is the format physically present yet
+void SwDocStyleSheet::SetPhysical(sal_Bool bPhys)
+{
+ bPhysical = bPhys;
+
+ if(!bPhys)
+ {
+ pCharFmt = 0;
+ pColl = 0;
+ pFrmFmt = 0;
+ pDesc = 0;
+ }
+}
+
+SwFrmFmt* SwDocStyleSheet::GetFrmFmt()
+{
+ if(!bPhysical)
+ FillStyleSheet( FillPhysical );
+ return pFrmFmt;
+}
+
+bool SwDocStyleSheet::IsUsed() const
+{
+ if( !bPhysical )
+ {
+ SwDocStyleSheet* pThis = (SwDocStyleSheet*)this;
+ pThis->FillStyleSheet( FillOnlyName );
+ }
+
+ if( !bPhysical )
+ return false;
+
+ const SwModify* pMod;
+ switch( nFamily )
+ {
+ case SFX_STYLE_FAMILY_CHAR : pMod = pCharFmt; break;
+ case SFX_STYLE_FAMILY_PARA : pMod = pColl; break;
+ case SFX_STYLE_FAMILY_FRAME: pMod = pFrmFmt; break;
+ case SFX_STYLE_FAMILY_PAGE : pMod = pDesc; break;
+
+ case SFX_STYLE_FAMILY_PSEUDO:
+ return pNumRule ? rDoc.IsUsed( *pNumRule ) : false;
+
+ default:
+ OSL_ENSURE(!this, "unknown style family");
+ return false;
+ }
+ return rDoc.IsUsed( *pMod );
+}
+
+sal_uLong SwDocStyleSheet::GetHelpId( OUString& rFile )
+{
+ sal_uInt16 nId = 0;
+ sal_uInt16 nPoolId = 0;
+ unsigned char nFileId = UCHAR_MAX;
+
+ rFile = "swrhlppi.hlp";
+
+ const SwFmt* pTmpFmt = 0;
+ switch( nFamily )
+ {
+ case SFX_STYLE_FAMILY_CHAR :
+ if( !pCharFmt &&
+ 0 == (pCharFmt = lcl_FindCharFmt( rDoc, aName, 0, false )) )
+ {
+ nId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT );
+ return USHRT_MAX == nId ? 0 : nId;
+ }
+ pTmpFmt = pCharFmt;
+ break;
+
+ case SFX_STYLE_FAMILY_PARA:
+ if( !pColl &&
+ 0 == ( pColl = lcl_FindParaFmt( rDoc, aName, 0, false )) )
+ {
+ nId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
+ return USHRT_MAX == nId ? 0 : nId;
+ }
+ pTmpFmt = pColl;
+ break;
+
+ case SFX_STYLE_FAMILY_FRAME:
+ if( !pFrmFmt &&
+ 0 == ( pFrmFmt = lcl_FindFrmFmt( rDoc, aName, 0, false ) ) )
+ {
+ nId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT );
+ return USHRT_MAX == nId ? 0 : nId;
+ }
+ pTmpFmt = pFrmFmt;
+ break;
+
+ case SFX_STYLE_FAMILY_PAGE:
+ if( !pDesc &&
+ 0 == ( pDesc = lcl_FindPageDesc( rDoc, aName, 0, false ) ) )
+ {
+ nId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC );
+ return USHRT_MAX == nId ? 0 : nId;
+ }
+
+ nId = pDesc->GetPoolHelpId();
+ nFileId = pDesc->GetPoolHlpFileId();
+ nPoolId = pDesc->GetPoolFmtId();
+ break;
+
+ case SFX_STYLE_FAMILY_PSEUDO:
+ if( !pNumRule &&
+ 0 == ( pNumRule = lcl_FindNumRule( rDoc, aName, 0, false ) ) )
+ {
+ nId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE );
+ return USHRT_MAX == nId ? 0 : nId;
+ }
+
+ nId = pNumRule->GetPoolHelpId();
+ nFileId = pNumRule->GetPoolHlpFileId();
+ nPoolId = pNumRule->GetPoolFmtId();
+ break;
+
+ default:
+ OSL_ENSURE(!this, "unknown style family");
+ return 0;
+ }
+
+ if( pTmpFmt )
+ {
+ nId = pTmpFmt->GetPoolHelpId();
+ nFileId = pTmpFmt->GetPoolHlpFileId();
+ nPoolId = pTmpFmt->GetPoolFmtId();
+ }
+
+ if( UCHAR_MAX != nFileId )
+ {
+ const OUString *pTemplate = rDoc.GetDocPattern( nFileId );
+ if( pTemplate )
+ {
+ rFile = *pTemplate;
+ }
+ }
+ else if( !IsPoolUserFmt( nPoolId ) )
+ {
+ nId = nPoolId;
+ }
+
+ // because SFX acts like that, with HelpId:
+ if( USHRT_MAX == nId )
+ nId = 0; // don't show Help accordingly
+
+ return nId;
+}
+
+void SwDocStyleSheet::SetHelpId( const OUString& r, sal_uLong nId )
+{
+ sal_uInt8 nFileId = static_cast< sal_uInt8 >(rDoc.SetDocPattern( r ));
+ sal_uInt16 nHId = static_cast< sal_uInt16 >(nId); //!! SFX changed over to ULONG arbitrarily!
+
+ SwFmt* pTmpFmt = 0;
+ switch( nFamily )
+ {
+ case SFX_STYLE_FAMILY_CHAR : pTmpFmt = pCharFmt; break;
+ case SFX_STYLE_FAMILY_PARA : pTmpFmt = pColl; break;
+ case SFX_STYLE_FAMILY_FRAME: pTmpFmt = pFrmFmt; break;
+ case SFX_STYLE_FAMILY_PAGE :
+ ((SwPageDesc*)pDesc)->SetPoolHelpId( nHId );
+ ((SwPageDesc*)pDesc)->SetPoolHlpFileId( nFileId );
+ break;
+
+ case SFX_STYLE_FAMILY_PSEUDO:
+ ((SwNumRule*)pNumRule)->SetPoolHelpId( nHId );
+ ((SwNumRule*)pNumRule)->SetPoolHlpFileId( nFileId );
+ break;
+
+ default:
+ OSL_ENSURE(!this, "unknown style family");
+ return ;
+ }
+ if( pTmpFmt )
+ {
+ pTmpFmt->SetPoolHelpId( nHId );
+ pTmpFmt->SetPoolHlpFileId( nFileId );
+ }
+}
+
+// methods for DocStyleSheetPool
+SwDocStyleSheetPool::SwDocStyleSheetPool( SwDoc& rDocument, sal_Bool bOrg )
+: SfxStyleSheetBasePool( rDocument.GetAttrPool() )
+, mxStyleSheet( new SwDocStyleSheet( rDocument, OUString(), this, SFX_STYLE_FAMILY_CHAR, 0 ) )
+, rDoc( rDocument )
+{
+ bOrganizer = bOrg;
+}
+
+ SwDocStyleSheetPool::~SwDocStyleSheetPool()
+{
+}
+
+void SAL_CALL SwDocStyleSheetPool::acquire( ) throw ()
+{
+ comphelper::OWeakTypeObject::acquire();
+}
+
+void SAL_CALL SwDocStyleSheetPool::release( ) throw ()
+{
+ comphelper::OWeakTypeObject::release();
+}
+
+SfxStyleSheetBase& SwDocStyleSheetPool::Make( const OUString& rName,
+ SfxStyleFamily eFam,
+ sal_uInt16 _nMask)
+{
+ mxStyleSheet->PresetName(rName);
+ mxStyleSheet->PresetParent(OUString());
+ mxStyleSheet->PresetFollow(OUString());
+ mxStyleSheet->SetMask(_nMask) ;
+ mxStyleSheet->SetFamily(eFam);
+ mxStyleSheet->SetPhysical(sal_True);
+ mxStyleSheet->Create();
+
+ return *mxStyleSheet.get();
+}
+
+SfxStyleSheetBase* SwDocStyleSheetPool::Create( const SfxStyleSheetBase& /*rOrg*/)
+{
+ OSL_ENSURE(!this , "Create im SW-Stylesheet-Pool geht nicht" );
+ return NULL;
+}
+
+SfxStyleSheetBase* SwDocStyleSheetPool::Create( const OUString &,
+ SfxStyleFamily, sal_uInt16 )
+{
+ OSL_ENSURE( !this, "Create im SW-Stylesheet-Pool geht nicht" );
+ return NULL;
+}
+
+void SwDocStyleSheetPool::Replace( SfxStyleSheetBase& rSource,
+ SfxStyleSheetBase& rTarget )
+{
+ SfxStyleFamily eFamily( rSource.GetFamily() );
+ if( rSource.HasParentSupport())
+ {
+ const OUString sParentName = rSource.GetParent();
+ if (!sParentName.isEmpty())
+ {
+ SfxStyleSheetBase* pParentOfNew = Find( sParentName, eFamily );
+ if( pParentOfNew )
+ rTarget.SetParent( sParentName );
+ }
+ }
+ if( rSource.HasFollowSupport())
+ {
+ const OUString sFollowName = rSource.GetFollow();
+ if (!sFollowName.isEmpty())
+ {
+ SfxStyleSheetBase* pFollowOfNew = Find( sFollowName, eFamily );
+ if( pFollowOfNew )
+ rTarget.SetFollow( sFollowName );
+ }
+ }
+
+ SwImplShellAction aTmpSh( rDoc );
+
+ bool bSwSrcPool = GetAppName() == rSource.GetPool().GetAppName();
+ if( SFX_STYLE_FAMILY_PAGE == eFamily && bSwSrcPool )
+ {
+ // deal with separately!
+ SwPageDesc* pDestDsc =
+ (SwPageDesc*)((SwDocStyleSheet&)rTarget).GetPageDesc();
+ SwPageDesc* pCpyDsc =
+ (SwPageDesc*)((SwDocStyleSheet&)rSource).GetPageDesc();
+ rDoc.CopyPageDesc( *pCpyDsc, *pDestDsc );
+ }
+ else
+ {
+ const SwFmt *pSourceFmt = 0;
+ SwFmt *pTargetFmt = 0;
+ sal_uInt16 nPgDscPos = USHRT_MAX;
+ switch( eFamily )
+ {
+ case SFX_STYLE_FAMILY_CHAR :
+ if( bSwSrcPool )
+ pSourceFmt = ((SwDocStyleSheet&)rSource).GetCharFmt();
+ pTargetFmt = ((SwDocStyleSheet&)rTarget).GetCharFmt();
+ break;
+ case SFX_STYLE_FAMILY_PARA :
+ if( bSwSrcPool )
+ pSourceFmt = ((SwDocStyleSheet&)rSource).GetCollection();
+ pTargetFmt = ((SwDocStyleSheet&)rTarget).GetCollection();
+ break;
+ case SFX_STYLE_FAMILY_FRAME:
+ if( bSwSrcPool )
+ pSourceFmt = ((SwDocStyleSheet&)rSource).GetFrmFmt();
+ pTargetFmt = ((SwDocStyleSheet&)rTarget).GetFrmFmt();
+ break;
+ case SFX_STYLE_FAMILY_PAGE:
+ if( bSwSrcPool )
+ pSourceFmt = &((SwDocStyleSheet&)rSource).GetPageDesc()
+ ->GetMaster();
+ {
+ SwPageDesc *pDesc = rDoc.FindPageDescByName(
+ ((SwDocStyleSheet&)rTarget).GetPageDesc()->GetName(),
+ &nPgDscPos );
+
+ if( pDesc )
+ pTargetFmt = &pDesc->GetMaster();
+ }
+ break;
+ case SFX_STYLE_FAMILY_PSEUDO:
+ // A NumRule only consists of one Item, so nothing has
+ // to be deleted here.
+ break;
+ default:; //prevent warning
+ }
+ if( pTargetFmt )
+ {
+ if( pSourceFmt )
+ pTargetFmt->DelDiffs( *pSourceFmt );
+ else if( USHRT_MAX != nPgDscPos )
+ pTargetFmt->ResetFmtAttr( RES_PAGEDESC, RES_FRMATR_END-1 );
+ else
+ {
+ // #i73790# - method renamed
+ pTargetFmt->ResetAllFmtAttr();
+ }
+
+ if( USHRT_MAX != nPgDscPos )
+ rDoc.ChgPageDesc( nPgDscPos,
+ rDoc.GetPageDesc(nPgDscPos) );
+ }
+ ((SwDocStyleSheet&)rTarget).SetItemSet( rSource.GetItemSet() );
+ }
+}
+
+SfxStyleSheetIteratorPtr SwDocStyleSheetPool::CreateIterator( SfxStyleFamily eFam, sal_uInt16 _nMask )
+{
+ return SfxStyleSheetIteratorPtr(new SwStyleSheetIterator( this, eFam, _nMask ));
+}
+
+void SwDocStyleSheetPool::dispose()
+{
+ mxStyleSheet.clear();
+}
+
+void SwDocStyleSheetPool::Remove( SfxStyleSheetBase* pStyle)
+{
+ if( !pStyle )
+ return;
+
+ bool bBroadcast = true;
+ SwImplShellAction aTmpSh( rDoc );
+ const OUString sName = pStyle->GetName();
+ switch( pStyle->GetFamily() )
+ {
+ case SFX_STYLE_FAMILY_CHAR:
+ {
+ SwCharFmt* pFmt = lcl_FindCharFmt(rDoc, sName, 0, false );
+ if(pFmt)
+ rDoc.DelCharFmt(pFmt);
+ }
+ break;
+ case SFX_STYLE_FAMILY_PARA:
+ {
+ SwTxtFmtColl* pColl = lcl_FindParaFmt(rDoc, sName, 0, false );
+ if(pColl)
+ rDoc.DelTxtFmtColl(pColl);
+ }
+ break;
+ case SFX_STYLE_FAMILY_FRAME:
+ {
+ SwFrmFmt* pFmt = lcl_FindFrmFmt(rDoc, sName, 0, false );
+ if(pFmt)
+ rDoc.DelFrmFmt(pFmt);
+ }
+ break;
+ case SFX_STYLE_FAMILY_PAGE :
+ {
+ sal_uInt16 nPos;
+ if( rDoc.FindPageDescByName( sName, &nPos ))
+ rDoc.DelPageDesc( nPos );
+ }
+ break;
+
+ case SFX_STYLE_FAMILY_PSEUDO:
+ {
+ if( !rDoc.DelNumRule( sName ) )
+ // Only send Broadcast, when something was deleted
+ bBroadcast = false;
+ }
+ break;
+
+ default:
+ OSL_ENSURE(!this, "unknown style family");
+ bBroadcast = false;
+ }
+
+ if( bBroadcast )
+ Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_ERASED, *pStyle ) );
+}
+
+bool SwDocStyleSheetPool::SetParent( SfxStyleFamily eFam,
+ const OUString &rStyle, const OUString &rParent )
+{
+ SwFmt* pFmt = 0, *pParent = 0;
+ switch( eFam )
+ {
+ case SFX_STYLE_FAMILY_CHAR :
+ if( 0 != ( pFmt = lcl_FindCharFmt( rDoc, rStyle ) ) && !rParent.isEmpty() )
+ pParent = lcl_FindCharFmt(rDoc, rParent );
+ break;
+
+ case SFX_STYLE_FAMILY_PARA :
+ if( 0 != ( pFmt = lcl_FindParaFmt( rDoc, rStyle ) ) && !rParent.isEmpty() )
+ pParent = lcl_FindParaFmt( rDoc, rParent );
+ break;
+
+ case SFX_STYLE_FAMILY_FRAME:
+ if( 0 != ( pFmt = lcl_FindFrmFmt( rDoc, rStyle ) ) && !rParent.isEmpty() )
+ pParent = lcl_FindFrmFmt( rDoc, rParent );
+ break;
+
+ case SFX_STYLE_FAMILY_PAGE:
+ case SFX_STYLE_FAMILY_PSEUDO:
+ break;
+
+ default:
+ OSL_ENSURE(!this, "unknown style family");
+ }
+
+ bool bRet = false;
+ if( pFmt && pFmt->DerivedFrom() &&
+ pFmt->DerivedFrom()->GetName() != rParent )
+ {
+ {
+ SwImplShellAction aTmpSh( rDoc );
+ bRet = pFmt->SetDerivedFrom( pParent );
+ }
+
+ if( bRet )
+ {
+ // only for Broadcasting
+ mxStyleSheet->PresetName( rStyle );
+ mxStyleSheet->PresetParent( rParent );
+ if( SFX_STYLE_FAMILY_PARA == eFam )
+ mxStyleSheet->PresetFollow( ((SwTxtFmtColl*)pFmt)->
+ GetNextTxtFmtColl().GetName() );
+ else
+ mxStyleSheet->PresetFollow( OUString() );
+
+ Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_MODIFIED,
+ *(mxStyleSheet.get()) ) );
+ }
+ }
+
+ return bRet;
+}
+
+SfxStyleSheetBase* SwDocStyleSheetPool::Find( const OUString& rName,
+ SfxStyleFamily eFam, sal_uInt16 n )
+{
+ sal_uInt16 nSMask = n;
+ if( SFX_STYLE_FAMILY_PARA == eFam && rDoc.get(IDocumentSettingAccess::HTML_MODE) )
+ {
+ // then only HTML-Templates are of interest
+ if( USHRT_MAX == nSMask )
+ nSMask = SWSTYLEBIT_HTML | SFXSTYLEBIT_USERDEF | SFXSTYLEBIT_USED;
+ else
+ nSMask &= SFXSTYLEBIT_USED | SFXSTYLEBIT_USERDEF |
+ SWSTYLEBIT_CONDCOLL | SWSTYLEBIT_HTML;
+ if( !nSMask )
+ nSMask = SWSTYLEBIT_HTML;
+ }
+
+ const bool bSearchUsed = ( n != SFXSTYLEBIT_ALL && n & SFXSTYLEBIT_USED );
+ const SwModify* pMod = 0;
+
+ mxStyleSheet->SetPhysical( sal_False );
+ mxStyleSheet->PresetName( rName );
+ mxStyleSheet->SetFamily( eFam );
+ sal_Bool bFnd = mxStyleSheet->FillStyleSheet( SwDocStyleSheet::FillOnlyName );
+
+ if( mxStyleSheet->IsPhysical() )
+ {
+ switch( eFam )
+ {
+ case SFX_STYLE_FAMILY_CHAR:
+ pMod = mxStyleSheet->GetCharFmt();
+ break;
+
+ case SFX_STYLE_FAMILY_PARA:
+ pMod = mxStyleSheet->GetCollection();
+ break;
+
+ case SFX_STYLE_FAMILY_FRAME:
+ pMod = mxStyleSheet->GetFrmFmt();
+ break;
+
+ case SFX_STYLE_FAMILY_PAGE:
+ pMod = mxStyleSheet->GetPageDesc();
+ break;
+
+ case SFX_STYLE_FAMILY_PSEUDO:
+ {
+ const SwNumRule* pRule = mxStyleSheet->GetNumRule();
+ if( pRule &&
+ !bSearchUsed &&
+ (( nSMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF
+ ? !(pRule->GetPoolFmtId() & USER_FMT)
+ // searched for used and found none
+ : bSearchUsed ))
+ bFnd = sal_False;
+ }
+ break;
+
+ default:
+ OSL_ENSURE(!this, "unknown style family");
+ }
+ }
+
+ // then evaluate the mask:
+ if( pMod && !bSearchUsed )
+ {
+ const sal_uInt16 nId = SFX_STYLE_FAMILY_PAGE == eFam
+ ? ((SwPageDesc*)pMod)->GetPoolFmtId()
+ : ((SwFmt*)pMod)->GetPoolFmtId();
+
+ if( ( nSMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF
+ ? !(nId & USER_FMT)
+ // searched for used and found none
+ : bSearchUsed )
+ bFnd = sal_False;
+ }
+ return bFnd ? mxStyleSheet.get() : 0;
+}
+
+SwStyleSheetIterator::SwStyleSheetIterator( SwDocStyleSheetPool* pBase,
+ SfxStyleFamily eFam, sal_uInt16 n )
+ : SfxStyleSheetIterator( pBase, eFam, n ),
+ mxIterSheet( new SwDocStyleSheet( pBase->GetDoc(), OUString(), pBase, SFX_STYLE_FAMILY_CHAR, 0 ) ),
+ mxStyleSheet( new SwDocStyleSheet( pBase->GetDoc(), OUString(), pBase, SFX_STYLE_FAMILY_CHAR, 0 ) )
+{
+ bFirstCalled = sal_False;
+ nLastPos = 0;
+ StartListening( *pBase );
+}
+
+SwStyleSheetIterator::~SwStyleSheetIterator()
+{
+ EndListening( mxIterSheet->GetPool() );
+}
+
+sal_uInt16 SwStyleSheetIterator::Count()
+{
+ // let the list fill correctly!!
+ if( !bFirstCalled )
+ First();
+ return aLst.size();
+}
+
+SfxStyleSheetBase* SwStyleSheetIterator::operator[]( sal_uInt16 nIdx )
+{
+ // found
+ if( !bFirstCalled )
+ First();
+ mxStyleSheet->PresetNameAndFamily( aLst[ nIdx ] );
+ mxStyleSheet->SetPhysical( sal_False );
+ mxStyleSheet->FillStyleSheet( SwDocStyleSheet::FillOnlyName );
+
+ return mxStyleSheet.get();
+}
+
+SfxStyleSheetBase* SwStyleSheetIterator::First()
+{
+ // Delete old list
+ bFirstCalled = sal_True;
+ nLastPos = 0;
+ aLst.Erase();
+
+ // Delete current
+ mxIterSheet->Reset();
+
+ SwDoc& rDoc = ((SwDocStyleSheetPool*)pBasePool)->GetDoc();
+ const sal_uInt16 nSrchMask = nMask;
+ const sal_Bool bIsSearchUsed = SearchUsed();
+
+ bool bSearchHidden = ( nMask & SFXSTYLEBIT_HIDDEN );
+ bool bOnlyHidden = nMask == SFXSTYLEBIT_HIDDEN;
+
+ const sal_Bool bOrganizer = ((SwDocStyleSheetPool*)pBasePool)->IsOrganizerMode();
+ bool bAll = ( nSrchMask & SFXSTYLEBIT_ALL_VISIBLE ) == SFXSTYLEBIT_ALL_VISIBLE;
+
+ if( nSearchFamily == SFX_STYLE_FAMILY_CHAR
+ || nSearchFamily == SFX_STYLE_FAMILY_ALL )
+ {
+ const sal_uInt16 nArrLen = rDoc.GetCharFmts()->size();
+ for( sal_uInt16 i = 0; i < nArrLen; i++ )
+ {
+ SwCharFmt* pFmt = (*rDoc.GetCharFmts())[ i ];
+
+ const bool bUsed = bIsSearchUsed && (bOrganizer || rDoc.IsUsed(*pFmt));
+ if( ( !bSearchHidden && pFmt->IsHidden() && !bUsed ) || ( pFmt->IsDefault() && pFmt != rDoc.GetDfltCharFmt() ) )
+ continue;
+
+ if ( nSrchMask == SFXSTYLEBIT_HIDDEN && !pFmt->IsHidden( ) )
+ continue;
+
+ if( !bUsed )
+ {
+ // Standard is no User template
+ const sal_uInt16 nId = rDoc.GetDfltCharFmt() == pFmt ?
+ sal_uInt16( RES_POOLCHR_INET_NORMAL ):
+ pFmt->GetPoolFmtId();
+ if( (nSrchMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF
+ ? !(nId & USER_FMT)
+ // searched for used and found none
+ : bIsSearchUsed )
+ {
+ continue;
+ }
+
+ if( rDoc.get(IDocumentSettingAccess::HTML_MODE) && !(nId & USER_FMT) &&
+ !( RES_POOLCHR_HTML_BEGIN <= nId &&
+ nId < RES_POOLCHR_HTML_END ) &&
+ RES_POOLCHR_INET_NORMAL != nId &&
+ RES_POOLCHR_INET_VISIT != nId &&
+ RES_POOLCHR_FOOTNOTE != nId &&
+ RES_POOLCHR_ENDNOTE != nId )
+ continue;
+ }
+
+ aLst.Append( cCHAR, pFmt == rDoc.GetDfltCharFmt()
+ ? SwStyleNameMapper::GetTextUINameArray()[ RES_POOLCOLL_STANDARD -
+ RES_POOLCOLL_TEXT_BEGIN ]
+ : pFmt->GetName() );
+ }
+
+ // PoolFormate
+ if( bAll )
+ {
+ if( !rDoc.get(IDocumentSettingAccess::HTML_MODE) )
+ AppendStyleList(SwStyleNameMapper::GetChrFmtUINameArray(),
+ bIsSearchUsed, bSearchHidden, bOnlyHidden,
+ nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, cCHAR);
+ else
+ {
+ aLst.Append( cCHAR, SwStyleNameMapper::GetChrFmtUINameArray()[
+ RES_POOLCHR_INET_NORMAL - RES_POOLCHR_BEGIN ] );
+ aLst.Append( cCHAR, SwStyleNameMapper::GetChrFmtUINameArray()[
+ RES_POOLCHR_INET_VISIT - RES_POOLCHR_BEGIN ] );
+ aLst.Append( cCHAR, SwStyleNameMapper::GetChrFmtUINameArray()[
+ RES_POOLCHR_ENDNOTE - RES_POOLCHR_BEGIN ] );
+ aLst.Append( cCHAR, SwStyleNameMapper::GetChrFmtUINameArray()[
+ RES_POOLCHR_FOOTNOTE - RES_POOLCHR_BEGIN ] );
+ }
+ AppendStyleList(SwStyleNameMapper::GetHTMLChrFmtUINameArray(),
+ bIsSearchUsed, bSearchHidden, bOnlyHidden,
+ nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, cCHAR);
+ }
+ }
+
+ if( nSearchFamily == SFX_STYLE_FAMILY_PARA ||
+ nSearchFamily == SFX_STYLE_FAMILY_ALL )
+ {
+ sal_uInt16 nSMask = nSrchMask;
+ if( rDoc.get(IDocumentSettingAccess::HTML_MODE) )
+ {
+ // then only HTML-Template are of interest
+ if( SFXSTYLEBIT_ALL_VISIBLE == ( nSMask & SFXSTYLEBIT_ALL_VISIBLE ) )
+ nSMask = SWSTYLEBIT_HTML | SFXSTYLEBIT_USERDEF |
+ SFXSTYLEBIT_USED;
+ else
+ nSMask &= SFXSTYLEBIT_USED | SFXSTYLEBIT_USERDEF |
+ SWSTYLEBIT_CONDCOLL | SWSTYLEBIT_HTML;
+ if( !nSMask )
+ nSMask = SWSTYLEBIT_HTML;
+ }
+
+ const sal_uInt16 nArrLen = rDoc.GetTxtFmtColls()->size();
+ for( sal_uInt16 i = 0; i < nArrLen; i++ )
+ {
+ SwTxtFmtColl* pColl = (*rDoc.GetTxtFmtColls())[ i ];
+
+ const bool bUsed = bOrganizer || rDoc.IsUsed(*pColl);
+ if ( ( !bSearchHidden && pColl->IsHidden( ) && !bUsed ) || pColl->IsDefault() )
+ continue;
+
+ if ( nSMask == SFXSTYLEBIT_HIDDEN && !pColl->IsHidden( ) )
+ continue;
+
+ if( !(bIsSearchUsed && bUsed ))
+ {
+ const sal_uInt16 nId = pColl->GetPoolFmtId();
+ switch ( (nSMask & ~SFXSTYLEBIT_USED) )
+ {
+ case SFXSTYLEBIT_USERDEF:
+ if(!IsPoolUserFmt(nId)) continue;
+ break;
+ case SWSTYLEBIT_TEXT:
+ if((nId & COLL_GET_RANGE_BITS) != COLL_TEXT_BITS) continue;
+ break;
+ case SWSTYLEBIT_CHAPTER:
+ if((nId & COLL_GET_RANGE_BITS) != COLL_DOC_BITS) continue;
+ break;
+ case SWSTYLEBIT_LIST:
+ if((nId & COLL_GET_RANGE_BITS) != COLL_LISTS_BITS) continue;
+ break;
+ case SWSTYLEBIT_IDX:
+ if((nId & COLL_GET_RANGE_BITS) != COLL_REGISTER_BITS) continue;
+ break;
+ case SWSTYLEBIT_EXTRA:
+ if((nId & COLL_GET_RANGE_BITS) != COLL_EXTRA_BITS) continue;
+ break;
+ case SWSTYLEBIT_HTML | SFXSTYLEBIT_USERDEF:
+ if(IsPoolUserFmt(nId))
+ break;
+ // otherwise move on
+ case SWSTYLEBIT_HTML:
+ if( (nId & COLL_GET_RANGE_BITS) != COLL_HTML_BITS)
+ {
+ // but some we also want to see in this section
+ bool bContinue = true;
+ switch( nId )
+ {
+ case RES_POOLCOLL_SENDADRESS: // --> ADDRESS
+ case RES_POOLCOLL_TABLE_HDLN: // --> TH
+ case RES_POOLCOLL_TABLE: // --> TD
+ case RES_POOLCOLL_TEXT: // --> P
+ case RES_POOLCOLL_HEADLINE_BASE:// --> H
+ case RES_POOLCOLL_HEADLINE1: // --> H1
+ case RES_POOLCOLL_HEADLINE2: // --> H2
+ case RES_POOLCOLL_HEADLINE3: // --> H3
+ case RES_POOLCOLL_HEADLINE4: // --> H4
+ case RES_POOLCOLL_HEADLINE5: // --> H5
+ case RES_POOLCOLL_HEADLINE6: // --> H6
+ case RES_POOLCOLL_STANDARD: // --> P
+ case RES_POOLCOLL_FOOTNOTE:
+ case RES_POOLCOLL_ENDNOTE:
+ bContinue = false;
+ break;
+ }
+ if( bContinue )
+ continue;
+ }
+ break;
+ case SWSTYLEBIT_CONDCOLL:
+ if( RES_CONDTXTFMTCOLL != pColl->Which() ) continue;
+ break;
+ default:
+ // searched for used and found none
+ if( bIsSearchUsed )
+ continue;
+ }
+ }
+ aLst.Append( cPARA, pColl->GetName() );
+ }
+
+ bAll = ( nSMask & SFXSTYLEBIT_ALL_VISIBLE ) == SFXSTYLEBIT_ALL_VISIBLE;
+ if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_TEXT )
+ AppendStyleList(SwStyleNameMapper::GetTextUINameArray(),
+ bIsSearchUsed, bSearchHidden, bOnlyHidden, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA );
+ if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_CHAPTER )
+ AppendStyleList(SwStyleNameMapper::GetDocUINameArray(),
+ bIsSearchUsed, bSearchHidden, bOnlyHidden, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA ) ;
+ if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_LIST )
+ AppendStyleList(SwStyleNameMapper::GetListsUINameArray(),
+ bIsSearchUsed, bSearchHidden, bOnlyHidden, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA ) ;
+ if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_IDX )
+ AppendStyleList(SwStyleNameMapper::GetRegisterUINameArray(),
+ bIsSearchUsed, bSearchHidden, bOnlyHidden, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA ) ;
+ if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_EXTRA )
+ AppendStyleList(SwStyleNameMapper::GetExtraUINameArray(),
+ bIsSearchUsed, bSearchHidden, bOnlyHidden, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA ) ;
+ if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_CONDCOLL )
+ {
+ if( !bIsSearchUsed ||
+ rDoc.IsPoolTxtCollUsed( RES_POOLCOLL_TEXT ))
+ aLst.Append( cPARA, SwStyleNameMapper::GetTextUINameArray()[
+ RES_POOLCOLL_TEXT - RES_POOLCOLL_TEXT_BEGIN ] );
+ }
+ if ( bAll ||
+ (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_HTML ||
+ (nSMask & ~SFXSTYLEBIT_USED) ==
+ (SWSTYLEBIT_HTML | SFXSTYLEBIT_USERDEF) )
+ {
+ AppendStyleList(SwStyleNameMapper::GetHTMLUINameArray(),
+ bIsSearchUsed, bSearchHidden, bOnlyHidden, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA ) ;
+ if( !bAll )
+ {
+ // then also the ones, that we are mapping:
+ static sal_uInt16 aPoolIds[] = {
+ RES_POOLCOLL_SENDADRESS, // --> ADDRESS
+ RES_POOLCOLL_TABLE_HDLN, // --> TH
+ RES_POOLCOLL_TABLE, // --> TD
+ RES_POOLCOLL_STANDARD, // --> P
+ RES_POOLCOLL_TEXT, // --> P
+ RES_POOLCOLL_HEADLINE_BASE, // --> H
+ RES_POOLCOLL_HEADLINE1, // --> H1
+ RES_POOLCOLL_HEADLINE2, // --> H2
+ RES_POOLCOLL_HEADLINE3, // --> H3
+ RES_POOLCOLL_HEADLINE4, // --> H4
+ RES_POOLCOLL_HEADLINE5, // --> H5
+ RES_POOLCOLL_HEADLINE6, // --> H6
+ RES_POOLCOLL_FOOTNOTE,
+ RES_POOLCOLL_ENDNOTE,
+ 0
+ };
+
+ sal_uInt16* pPoolIds = aPoolIds;
+ OUString s;
+ while( *pPoolIds )
+ {
+ if( !bIsSearchUsed || rDoc.IsPoolTxtCollUsed( *pPoolIds ) )
+ aLst.Append( cPARA,
+ s = SwStyleNameMapper::GetUIName( *pPoolIds, s ));
+ ++pPoolIds;
+ }
+ }
+ }
+ }
+
+ if( nSearchFamily == SFX_STYLE_FAMILY_FRAME ||
+ nSearchFamily == SFX_STYLE_FAMILY_ALL )
+ {
+ const sal_uInt16 nArrLen = rDoc.GetFrmFmts()->size();
+ for( sal_uInt16 i = 0; i < nArrLen; i++ )
+ {
+ SwFrmFmt* pFmt = (*rDoc.GetFrmFmts())[ i ];
+
+ bool bUsed = bIsSearchUsed && ( bOrganizer || rDoc.IsUsed(*pFmt));
+ if( ( !bSearchHidden && pFmt->IsHidden( ) && !bUsed ) || pFmt->IsDefault() || pFmt->IsAuto() )
+ continue;
+
+ if ( nSrchMask == SFXSTYLEBIT_HIDDEN && !pFmt->IsHidden( ) )
+ continue;
+
+ const sal_uInt16 nId = pFmt->GetPoolFmtId();
+ if( !bUsed )
+ {
+ if( (nSrchMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF
+ ? !(nId & USER_FMT)
+ // searched for used and found none
+ : bIsSearchUsed )
+ {
+ continue;
+ }
+ }
+
+ aLst.Append( cFRAME, pFmt->GetName() );
+ }
+
+ // PoolFormate
+ if ( bAll )
+ AppendStyleList(SwStyleNameMapper::GetFrmFmtUINameArray(),
+ bIsSearchUsed, bSearchHidden, bOnlyHidden, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT, cFRAME);
+ }
+
+ if( nSearchFamily == SFX_STYLE_FAMILY_PAGE ||
+ nSearchFamily == SFX_STYLE_FAMILY_ALL )
+ {
+ const sal_uInt16 nCount = rDoc.GetPageDescCnt();
+ for(sal_uInt16 i = 0; i < nCount; ++i)
+ {
+ const SwPageDesc& rDesc = rDoc.GetPageDesc(i);
+ const sal_uInt16 nId = rDesc.GetPoolFmtId();
+ bool bUsed = bIsSearchUsed && ( bOrganizer || rDoc.IsUsed(rDesc));
+ if( !bUsed )
+ {
+ if ( ( !bSearchHidden && rDesc.IsHidden() ) ||
+ ( (nSrchMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF
+ ? !(nId & USER_FMT)
+ // searched for used and found none
+ : bIsSearchUsed ) )
+ continue;
+ }
+
+ if ( nSrchMask == SFXSTYLEBIT_HIDDEN && !rDesc.IsHidden( ) )
+ continue;
+
+ aLst.Append( cPAGE, rDesc.GetName() );
+ }
+ if ( bAll )
+ AppendStyleList(SwStyleNameMapper::GetPageDescUINameArray(),
+ bIsSearchUsed, bSearchHidden, bOnlyHidden, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, cPAGE);
+ }
+
+ if( nSearchFamily == SFX_STYLE_FAMILY_PSEUDO ||
+ nSearchFamily == SFX_STYLE_FAMILY_ALL )
+ {
+ const SwNumRuleTbl& rNumTbl = rDoc.GetNumRuleTbl();
+ for(sal_uInt16 i = 0; i < rNumTbl.size(); ++i)
+ {
+ const SwNumRule& rRule = *rNumTbl[ i ];
+ if( !rRule.IsAutoRule() )
+ {
+ if ( nSrchMask == SFXSTYLEBIT_HIDDEN && !rRule.IsHidden( ) )
+ continue;
+
+ bool bUsed = bIsSearchUsed && ( bOrganizer || rDoc.IsUsed(rRule) );
+ if( !bUsed )
+ {
+ if( ( !bSearchHidden && rRule.IsHidden() ) ||
+ ( (nSrchMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF
+ ? !(rRule.GetPoolFmtId() & USER_FMT)
+ // searched for used and found none
+ : bIsSearchUsed ) )
+ continue;
+ }
+
+ aLst.Append( cNUMRULE, rRule.GetName() );
+ }
+ }
+ if ( bAll )
+ AppendStyleList(SwStyleNameMapper::GetNumRuleUINameArray(),
+ bIsSearchUsed, bSearchHidden, bOnlyHidden, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE, cNUMRULE);
+ }
+
+ if(!aLst.empty())
+ {
+ nLastPos = USHRT_MAX;
+ return Next();
+ }
+ return 0;
+}
+
+SfxStyleSheetBase* SwStyleSheetIterator::Next()
+{
+ assert(bFirstCalled);
+ ++nLastPos;
+ if(!aLst.empty() && nLastPos < aLst.size())
+ {
+ mxIterSheet->PresetNameAndFamily(aLst[nLastPos]);
+ mxIterSheet->SetPhysical( sal_False );
+ mxIterSheet->SetMask( nMask );
+ if(mxIterSheet->pSet)
+ {
+ mxIterSheet->pSet->ClearItem(0);
+ mxIterSheet->pSet= 0;
+ }
+ return mxIterSheet.get();
+ }
+ return 0;
+}
+
+SfxStyleSheetBase* SwStyleSheetIterator::Find(const OUString& rName)
+{
+ // searching
+ if( !bFirstCalled )
+ First();
+
+ nLastPos = lcl_FindName( aLst, nSearchFamily, rName );
+ if( USHRT_MAX != nLastPos )
+ {
+ // found
+ mxStyleSheet->PresetNameAndFamily(aLst[nLastPos]);
+ // new name is set, so determine its Data
+ mxStyleSheet->FillStyleSheet( SwDocStyleSheet::FillOnlyName );
+ if( !mxStyleSheet->IsPhysical() )
+ mxStyleSheet->SetPhysical( sal_False );
+
+ return mxStyleSheet.get();
+ }
+ return 0;
+}
+
+void SwStyleSheetIterator::AppendStyleList(const ::std::vector<OUString>& rList,
+ sal_Bool bTestUsed, sal_Bool bTestHidden, bool bOnlyHidden,
+ sal_uInt16 nSection, char cType )
+{
+ SwDoc& rDoc = ((SwDocStyleSheetPool*)pBasePool)->GetDoc();
+ sal_Bool bUsed = sal_False;
+ for ( sal_uInt16 i=0; i < rList.size(); ++i )
+ {
+ bool bHidden = false;
+ sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rList[i], (SwGetPoolIdFromName)nSection);
+ switch ( nSection )
+ {
+ case nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL:
+ {
+ bUsed = rDoc.IsPoolTxtCollUsed( nId );
+ SwFmt* pFmt = rDoc.FindTxtFmtCollByName( rList[i] );
+ bHidden = pFmt && pFmt->IsHidden( );
+ }
+ break;
+ case nsSwGetPoolIdFromName::GET_POOLID_CHRFMT:
+ {
+ bUsed = rDoc.IsPoolFmtUsed( nId );
+ SwFmt* pFmt = rDoc.FindCharFmtByName( rList[i] );
+ bHidden = pFmt && pFmt->IsHidden( );
+ }
+ break;
+ case nsSwGetPoolIdFromName::GET_POOLID_FRMFMT:
+ {
+ bUsed = rDoc.IsPoolFmtUsed( nId );
+ SwFmt* pFmt = rDoc.FindFrmFmtByName( rList[i] );
+ bHidden = pFmt && pFmt->IsHidden( );
+ }
+ break;
+ case nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC:
+ {
+ bUsed = rDoc.IsPoolPageDescUsed( nId );
+ SwPageDesc* pPgDesc = rDoc.FindPageDescByName( rList[i] );
+ bHidden = pPgDesc && pPgDesc->IsHidden( );
+ }
+ break;
+ case nsSwGetPoolIdFromName::GET_POOLID_NUMRULE:
+ {
+ SwNumRule* pRule = rDoc.FindNumRulePtr( rList[i] );
+ bUsed = pRule && rDoc.IsUsed( *pRule );
+ bHidden = pRule && pRule->IsHidden( );
+ }
+ break;
+ default:
+ OSL_ENSURE( !this, "unknown PoolFmt-Id" );
+ }
+
+ bool bMatchHidden = ( bTestHidden && ( bHidden || !bOnlyHidden ) ) || ( !bTestHidden && ( !bHidden || bUsed ) );
+ if ( ( !bTestUsed && bMatchHidden ) || ( bTestUsed && bUsed ) )
+ aLst.Append( cType, rList[i] );
+ }
+}
+
+void SwDocStyleSheetPool::InvalidateIterator()
+{
+ dynamic_cast<SwStyleSheetIterator&>(GetIterator_Impl()).InvalidateIterator();
+}
+
+void SwStyleSheetIterator::InvalidateIterator()
+{
+ // potentially we could send an SfxHint to Notify but currently it's
+ // iterating over the vector anyway so would still be slow - why does
+ // this iterator not use a map?
+ bFirstCalled = false;
+ nLastPos = 0;
+ aLst.Erase();
+}
+
+void SwStyleSheetIterator::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ // search and remove from View-List!!
+ if( rHint.ISA( SfxStyleSheetHint ) &&
+ SFX_STYLESHEET_ERASED == ((SfxStyleSheetHint&) rHint).GetHint() )
+ {
+ SfxStyleSheetBase* pStyle = ((SfxStyleSheetHint&)rHint).GetStyleSheet();
+
+ if (pStyle)
+ {
+ sal_uInt16 nTmpPos = lcl_FindName( aLst, pStyle->GetFamily(),
+ pStyle->GetName() );
+ if( nTmpPos < aLst.size() )
+ aLst.erase(aLst.begin() + nTmpPos);
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/app/mainwn.cxx b/sw/source/core/uibase/app/mainwn.cxx
new file mode 100644
index 000000000000..98b2e4b623b7
--- /dev/null
+++ b/sw/source/core/uibase/app/mainwn.cxx
@@ -0,0 +1,141 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <mdiexp.hxx>
+#include <tools/shl.hxx>
+#include <sfx2/progress.hxx>
+#include <tools/resid.hxx>
+#include <docsh.hxx>
+#include <swmodule.hxx>
+#include "swtypes.hxx"
+
+class SwDocShell;
+
+struct SwProgress
+{
+ long nStartValue,
+ nStartCount;
+ SwDocShell *pDocShell;
+ SfxProgress *pProgress;
+};
+
+static std::vector<SwProgress*> *pProgressContainer = 0;
+
+static SwProgress *lcl_SwFindProgress( SwDocShell *pDocShell )
+{
+ for ( sal_uInt16 i = 0; i < pProgressContainer->size(); ++i )
+ {
+ SwProgress *pTmp = (*pProgressContainer)[i];
+ if ( pTmp->pDocShell == pDocShell )
+ return pTmp;
+ }
+ return 0;
+}
+
+void StartProgress( sal_uInt16 nMessResId, long nStartValue, long nEndValue,
+ SwDocShell *pDocShell )
+{
+ if( !SW_MOD()->IsEmbeddedLoadSave() )
+ {
+ SwProgress *pProgress = 0;
+
+ if ( !pProgressContainer )
+ pProgressContainer = new std::vector<SwProgress*>;
+ else
+ {
+ if ( 0 != (pProgress = lcl_SwFindProgress( pDocShell )) )
+ ++pProgress->nStartCount;
+ }
+ if ( !pProgress )
+ {
+ pProgress = new SwProgress;
+ pProgress->pProgress = new SfxProgress( pDocShell,
+ SW_RESSTR(nMessResId),
+ nEndValue - nStartValue,
+ sal_False,
+ sal_True );
+ pProgress->nStartCount = 1;
+ pProgress->pDocShell = pDocShell;
+ pProgressContainer->insert( pProgressContainer->begin(), pProgress );
+ }
+ pProgress->nStartValue = nStartValue;
+ }
+}
+
+void SetProgressState( long nPosition, SwDocShell *pDocShell )
+{
+ if( pProgressContainer && !SW_MOD()->IsEmbeddedLoadSave() )
+ {
+ SwProgress *pProgress = lcl_SwFindProgress( pDocShell );
+ if ( pProgress )
+ pProgress->pProgress->SetState(nPosition - pProgress->nStartValue);
+ }
+}
+
+void EndProgress( SwDocShell *pDocShell )
+{
+ if( pProgressContainer && !SW_MOD()->IsEmbeddedLoadSave() )
+ {
+ SwProgress *pProgress = 0;
+ sal_uInt16 i;
+ for ( i = 0; i < pProgressContainer->size(); ++i )
+ {
+ SwProgress *pTmp = (SwProgress*)(*pProgressContainer)[i];
+ if ( pTmp->pDocShell == pDocShell )
+ {
+ pProgress = pTmp;
+ break;
+ }
+ }
+
+ if ( pProgress && 0 == --pProgress->nStartCount )
+ {
+ pProgress->pProgress->Stop();
+ pProgressContainer->erase( pProgressContainer->begin() + i );
+ delete pProgress->pProgress;
+ delete pProgress;
+ //#112337# it may happen that the container has been removed
+ //while rescheduling
+ if ( pProgressContainer && pProgressContainer->empty() )
+ delete pProgressContainer, pProgressContainer = 0;
+ }
+ }
+}
+
+void SetProgressText( sal_uInt16 nId, SwDocShell *pDocShell )
+{
+ if( pProgressContainer && !SW_MOD()->IsEmbeddedLoadSave() )
+ {
+ SwProgress *pProgress = lcl_SwFindProgress( pDocShell );
+ if ( pProgress )
+ pProgress->pProgress->SetStateText( 0, SW_RESSTR(nId) );
+ }
+}
+
+void RescheduleProgress( SwDocShell *pDocShell )
+{
+ if( pProgressContainer && !SW_MOD()->IsEmbeddedLoadSave() )
+ {
+ SwProgress *pProgress = lcl_SwFindProgress( pDocShell );
+ if ( pProgress )
+ pProgress->pProgress->Reschedule();
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/app/swdll.cxx b/sw/source/core/uibase/app/swdll.cxx
new file mode 100644
index 000000000000..cb6d19e079e1
--- /dev/null
+++ b/sw/source/core/uibase/app/swdll.cxx
@@ -0,0 +1,164 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <config_features.h>
+
+#include <svx/svdobj.hxx>
+
+#include "globdoc.hrc"
+
+#include <swdll.hxx>
+#include <wdocsh.hxx>
+#include <globdoc.hxx>
+#include <initui.hxx>
+#include <swmodule.hxx>
+#include <swtypes.hxx>
+#include <init.hxx>
+#include <dobjfac.hxx>
+#include <cfgid.h>
+
+#include <com/sun/star/frame/Desktop.hpp>
+#include <unotools/moduleoptions.hxx>
+#include <comphelper/scoped_disposing_ptr.hxx>
+#include <comphelper/processfactory.hxx>
+
+#include <svx/fmobjfac.hxx>
+#include <svx/svdfield.hxx>
+#include <svx/objfac3d.hxx>
+
+#include <unomid.h>
+
+#include "swdllimpl.hxx"
+
+using namespace com::sun::star;
+
+namespace
+{
+ //Holds a SwDLL and release it on exit, or dispose of the
+ //default XComponent, whichever comes first
+ class SwDLLInstance : public comphelper::scoped_disposing_solar_mutex_reset_ptr<SwDLL>
+ {
+ public:
+ SwDLLInstance() : comphelper::scoped_disposing_solar_mutex_reset_ptr<SwDLL>(uno::Reference<lang::XComponent>( frame::Desktop::create(comphelper::getProcessComponentContext()), uno::UNO_QUERY_THROW), new SwDLL)
+ {
+ }
+ };
+
+ struct theSwDLLInstance : public rtl::Static<SwDLLInstance, theSwDLLInstance> {};
+}
+
+namespace SwGlobals
+{
+ void ensure()
+ {
+ theSwDLLInstance::get();
+ }
+
+ sw::Filters & getFilters()
+ {
+ return theSwDLLInstance::get().get()->getFilters();
+ }
+}
+
+SwDLL::SwDLL()
+{
+ // the SdModule must be created
+ SwModule** ppShlPtr = (SwModule**) GetAppData(SHL_WRITER);
+ if ( *ppShlPtr )
+ return;
+
+ SvtModuleOptions aOpt;
+ SfxObjectFactory* pDocFact = 0;
+ SfxObjectFactory* pGlobDocFact = 0;
+ if ( aOpt.IsWriter() )
+ {
+ pDocFact = &SwDocShell::Factory();
+ pGlobDocFact = &SwGlobalDocShell::Factory();
+ }
+
+ SfxObjectFactory* pWDocFact = &SwWebDocShell::Factory();
+
+ SwModule* pModule = new SwModule( pWDocFact, pDocFact, pGlobDocFact );
+ *ppShlPtr = pModule;
+
+ pWDocFact->SetDocumentServiceName(OUString("com.sun.star.text.WebDocument"));
+
+ if ( aOpt.IsWriter() )
+ {
+ pGlobDocFact->SetDocumentServiceName(OUString("com.sun.star.text.GlobalDocument"));
+ pDocFact->SetDocumentServiceName(OUString("com.sun.star.text.TextDocument"));
+ }
+
+ // register SvDraw-Fields
+ SdrRegisterFieldClasses();
+
+ // register 3D-Objekt-Factory
+ E3dObjFactory();
+
+ // register form::component::Form-Objekt-Factory
+ FmFormObjFactory();
+
+ SdrObjFactory::InsertMakeObjectHdl( LINK( &aSwObjectFactory, SwObjectFactory, MakeObject ) );
+
+ SAL_INFO( "sw.ui", "Init Core/UI/Filter" );
+ // Initialisation of Statics
+ ::_InitCore();
+ filters_.reset(new sw::Filters);
+ ::_InitUI();
+
+ pModule->InitAttrPool();
+ // now SWModule can create its Pool
+
+ // register your view-factories here
+ RegisterFactories();
+
+#if HAVE_FEATURE_DESKTOP
+ // register your shell-interfaces here
+ RegisterInterfaces();
+
+ // register your controllers here
+ RegisterControls();
+#endif
+}
+
+SwDLL::~SwDLL()
+{
+ // Pool has to be deleted before statics are
+ SW_MOD()->RemoveAttrPool();
+
+ ::_FinitUI();
+ filters_.reset();
+ ::_FinitCore();
+ // sign out Objekt-Factory
+ SdrObjFactory::RemoveMakeObjectHdl(LINK(&aSwObjectFactory, SwObjectFactory, MakeObject ));
+#if 0
+ // the SwModule must be destroyed
+ SwModule** ppShlPtr = (SwModule**) GetAppData(SHL_WRITER);
+ delete (*ppShlPtr);
+ (*ppShlPtr) = NULL;
+#endif
+}
+
+sw::Filters & SwDLL::getFilters()
+{
+ OSL_ASSERT(filters_);
+ return *filters_.get();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/app/swdllimpl.hxx b/sw/source/core/uibase/app/swdllimpl.hxx
new file mode 100644
index 000000000000..b51ab6b49ca2
--- /dev/null
+++ b/sw/source/core/uibase/app/swdllimpl.hxx
@@ -0,0 +1,36 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_SW_SOURCE_UI_APP_SWDLLIMPL_HXX
+#define INCLUDED_SW_SOURCE_UI_APP_SWDLLIMPL_HXX
+
+#include "sal/config.h"
+
+#include "boost/noncopyable.hpp"
+#include "boost/scoped_ptr.hpp"
+
+namespace sw { class Filters; }
+
+class SwDLL: private boost::noncopyable
+{
+public:
+ static void RegisterFactories();
+ static void RegisterInterfaces();
+ static void RegisterControls();
+
+ SwDLL();
+ ~SwDLL();
+
+ sw::Filters & getFilters();
+
+private:
+ boost::scoped_ptr< sw::Filters > filters_;
+};
+
+#endif
diff --git a/sw/source/core/uibase/app/swmodul1.cxx b/sw/source/core/uibase/app/swmodul1.cxx
new file mode 100644
index 000000000000..a0401dd70c5b
--- /dev/null
+++ b/sw/source/core/uibase/app/swmodul1.cxx
@@ -0,0 +1,659 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <boost/scoped_ptr.hpp>
+
+#include <hintids.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/childwin.hxx>
+#include <unotools/useroptions.hxx>
+#include <cppuhelper/weak.hxx>
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#include <com/sun/star/view/XSelectionSupplier.hpp>
+#include <cppuhelper/implbase1.hxx>
+#include <svx/dataaccessdescriptor.hxx>
+#include <editeng/wghtitem.hxx>
+#include <editeng/postitem.hxx>
+#include <editeng/udlnitem.hxx>
+#include <editeng/crossedoutitem.hxx>
+#include <editeng/cmapitem.hxx>
+#include <editeng/colritem.hxx>
+#include <editeng/brushitem.hxx>
+#include <vcl/msgbox.hxx>
+#include <svl/cjkoptions.hxx>
+#include <swmodule.hxx>
+#include <swtypes.hxx>
+#include <usrpref.hxx>
+#include <modcfg.hxx>
+#include <view.hxx>
+#include <pview.hxx>
+#include <wview.hxx>
+#include <wrtsh.hxx>
+#include <docsh.hxx>
+#include <dbmgr.hxx>
+#include <uinums.hxx>
+#include <prtopt.hxx>
+#include <navicfg.hxx>
+#include <doc.hxx>
+#include <cmdid.h>
+#include <app.hrc>
+#include "helpid.h"
+
+#include <unomid.h>
+#include <tools/color.hxx>
+#include "PostItMgr.hxx"
+
+using namespace ::svx;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::view;
+using namespace ::com::sun::star::lang;
+
+static void lcl_SetUIPrefs(const SwViewOption &rPref, SwView* pView, SwViewShell* pSh )
+{
+ // in FrameSets the actual visibility can differ from the ViewOption's setting
+ bool bVScrollChanged = rPref.IsViewVScrollBar() != pSh->GetViewOptions()->IsViewVScrollBar();
+ bool bHScrollChanged = rPref.IsViewHScrollBar() != pSh->GetViewOptions()->IsViewHScrollBar();
+ bool bVAlignChanged = rPref.IsVRulerRight() != pSh->GetViewOptions()->IsVRulerRight();
+
+ pSh->SetUIOptions(rPref);
+ const SwViewOption* pNewPref = pSh->GetViewOptions();
+
+ // Scrollbars on / off
+ if(bVScrollChanged)
+ {
+ pView->EnableVScrollbar(pNewPref->IsViewVScrollBar());
+ }
+ if(bHScrollChanged)
+ {
+ pView->EnableHScrollbar( pNewPref->IsViewHScrollBar() || pNewPref->getBrowseMode() );
+ }
+ //if only the position of the vertical ruler has been changed initiate an update
+ if(bVAlignChanged && !bHScrollChanged && !bVScrollChanged)
+ pView->InvalidateBorder();
+
+ // Rulers on / off
+ if(pNewPref->IsViewVRuler())
+ pView->CreateVRuler();
+ else
+ pView->KillVRuler();
+
+ // TabWindow on / off
+ if(pNewPref->IsViewHRuler())
+ pView->CreateTab();
+ else
+ pView->KillTab();
+
+ pView->GetPostItMgr()->PrepareView(true);
+}
+
+SwWrtShell* GetActiveWrtShell()
+{
+ SwView *pActive = ::GetActiveView();
+ if( pActive )
+ return &pActive->GetWrtShell();
+ return 0;
+}
+
+SwView* GetActiveView()
+{
+ SfxViewShell* pView = SfxViewShell::Current();
+ return PTR_CAST( SwView, pView );
+}
+
+SwView* SwModule::GetFirstView()
+{
+ // returns only sivible SwView
+ const TypeId aTypeId = TYPE(SwView);
+ SwView* pView = (SwView*)SfxViewShell::GetFirst(&aTypeId);
+ return pView;
+}
+
+SwView* SwModule::GetNextView(SwView* pView)
+{
+ OSL_ENSURE(PTR_CAST(SwView, pView),"return no SwView");
+ const TypeId aTypeId = TYPE(SwView);
+ SwView* pNView = (SwView*)SfxViewShell::GetNext(*pView, &aTypeId, sal_True);
+ return pNView;
+}
+
+// New Master for the settings is set; this affects the current view and all following.
+void SwModule::ApplyUsrPref(const SwViewOption &rUsrPref, SwView* pActView,
+ sal_uInt16 nDest )
+{
+ SwView* pCurrView = pActView;
+ SwViewShell* pSh = pCurrView ? &pCurrView->GetWrtShell() : 0;
+
+ SwMasterUsrPref* pPref = (SwMasterUsrPref*)GetUsrPref( static_cast< sal_Bool >(
+ VIEWOPT_DEST_WEB == nDest ? sal_True :
+ VIEWOPT_DEST_TEXT== nDest ? sal_False :
+ pCurrView && pCurrView->ISA(SwWebView) ));
+
+ // with Uno, only sdbcx::View, but not the Module should be changed
+ bool bViewOnly = VIEWOPT_DEST_VIEW_ONLY == nDest;
+ // fob Preview off
+ SwPagePreview* pPPView;
+ if( !pCurrView && 0 != (pPPView = PTR_CAST( SwPagePreview, SfxViewShell::Current())) )
+ {
+ if(!bViewOnly)
+ pPref->SetUIOptions( rUsrPref );
+ pPPView->EnableVScrollbar(pPref->IsViewVScrollBar());
+ pPPView->EnableHScrollbar(pPref->IsViewHScrollBar());
+ if(!bViewOnly)
+ {
+ pPref->SetPagePrevRow(rUsrPref.GetPagePrevRow());
+ pPref->SetPagePrevCol(rUsrPref.GetPagePrevCol());
+ }
+ return;
+ }
+
+ if(!bViewOnly)
+ {
+ pPref->SetUsrPref( rUsrPref );
+ pPref->SetModified();
+ }
+
+ if( !pCurrView )
+ return;
+
+ // Passing on to CORE
+ sal_Bool bReadonly;
+ const SwDocShell* pDocSh = pCurrView->GetDocShell();
+ if (pDocSh)
+ bReadonly = pDocSh->IsReadOnly();
+ else //Use existing option if DocShell missing
+ bReadonly = pSh->GetViewOptions()->IsReadonly();
+ boost::scoped_ptr<SwViewOption> xViewOpt;
+ if (!bViewOnly)
+ xViewOpt.reset(new SwViewOption(*pPref));
+ else
+ xViewOpt.reset(new SwViewOption(rUsrPref));
+ xViewOpt->SetReadonly( bReadonly );
+ if( !(*pSh->GetViewOptions() == *xViewOpt) )
+ {
+ //is maybe only a SwViewShell
+ pSh->StartAction();
+ pSh->ApplyViewOptions( *xViewOpt );
+ ((SwWrtShell*)pSh)->SetReadOnlyAvailable(xViewOpt->IsCursorInProtectedArea());
+ pSh->EndAction();
+ }
+ if ( pSh->GetViewOptions()->IsReadonly() != bReadonly )
+ pSh->SetReadonlyOption(bReadonly);
+
+ lcl_SetUIPrefs(*xViewOpt, pCurrView, pSh);
+
+ // in the end the Idle-Flag is set again
+ pPref->SetIdle(sal_True);
+}
+
+void SwModule::ApplyUserMetric( FieldUnit eMetric, bool bWeb )
+{
+ SwMasterUsrPref* pPref;
+ if(bWeb)
+ {
+ if(!pWebUsrPref)
+ GetUsrPref(sal_True);
+ pPref = pWebUsrPref;
+ }
+ else
+ {
+ if(!pUsrPref)
+ GetUsrPref(sal_False);
+ pPref = pUsrPref;
+ }
+ FieldUnit eOldMetric = pPref->GetMetric();
+ if(eOldMetric != eMetric)
+ pPref->SetMetric(eMetric);
+
+ FieldUnit eHScrollMetric = pPref->IsHScrollMetric() ? pPref->GetHScrollMetric() : eMetric;
+ FieldUnit eVScrollMetric = pPref->IsVScrollMetric() ? pPref->GetVScrollMetric() : eMetric;
+
+ SwView* pTmpView = SwModule::GetFirstView();
+ // switch the ruler for all MDI-Windows
+ while(pTmpView)
+ {
+ if(bWeb == (0 != PTR_CAST(SwWebView, pTmpView)))
+ {
+ pTmpView->ChangeVRulerMetric(eVScrollMetric);
+ pTmpView->ChangeTabMetric(eHScrollMetric);
+ }
+
+ pTmpView = SwModule::GetNextView(pTmpView);
+ }
+}
+
+void SwModule::ApplyRulerMetric( FieldUnit eMetric, sal_Bool bHorizontal, bool bWeb )
+{
+ SwMasterUsrPref* pPref;
+ if(bWeb)
+ {
+ if(!pWebUsrPref)
+ GetUsrPref(sal_True);
+ pPref = pWebUsrPref;
+ }
+ else
+ {
+ if(!pUsrPref)
+ GetUsrPref(sal_False);
+ pPref = pUsrPref;
+ }
+ if( bHorizontal )
+ pPref->SetHScrollMetric(eMetric);
+ else
+ pPref->SetVScrollMetric(eMetric);
+
+ SwView* pTmpView = SwModule::GetFirstView();
+ // switch metric at the appropriate rulers
+ while(pTmpView)
+ {
+ if(bWeb == (0 != dynamic_cast<SwWebView *>( pTmpView )))
+ {
+ if( bHorizontal )
+ pTmpView->ChangeTabMetric(eMetric);
+ else
+ pTmpView->ChangeVRulerMetric(eMetric);
+ }
+ pTmpView = SwModule::GetNextView(pTmpView);
+ }
+}
+
+//set the usrpref 's char unit attribute and set rulers unit as char if the "apply char unit" is checked
+void SwModule::ApplyUserCharUnit(sal_Bool bApplyChar, bool bWeb)
+{
+ SwMasterUsrPref* pPref;
+ if(bWeb)
+ {
+ if(!pWebUsrPref)
+ GetUsrPref(sal_True);
+ pPref = pWebUsrPref;
+ }
+ else
+ {
+ if(!pUsrPref)
+ GetUsrPref(sal_False);
+ pPref = pUsrPref;
+ }
+ sal_Bool bOldApplyCharUnit = pPref->IsApplyCharUnit();
+ bool bHasChanged = false;
+ if(bOldApplyCharUnit != bApplyChar)
+ {
+ pPref->SetApplyCharUnit(bApplyChar);
+ bHasChanged = true;
+ }
+
+ if( !bHasChanged )
+ return;
+
+ FieldUnit eHScrollMetric = pPref->IsHScrollMetric() ? pPref->GetHScrollMetric() : pPref->GetMetric();
+ FieldUnit eVScrollMetric = pPref->IsVScrollMetric() ? pPref->GetVScrollMetric() : pPref->GetMetric();
+ if(bApplyChar)
+ {
+ eHScrollMetric = FUNIT_CHAR;
+ eVScrollMetric = FUNIT_LINE;
+ }
+ else
+ {
+ SvtCJKOptions aCJKOptions;
+ if ( !aCJKOptions.IsAsianTypographyEnabled() && ( eHScrollMetric == FUNIT_CHAR ))
+ eHScrollMetric = FUNIT_INCH;
+ else if ( eHScrollMetric == FUNIT_CHAR )
+ eHScrollMetric = FUNIT_CM;
+ if ( !aCJKOptions.IsAsianTypographyEnabled() && ( eVScrollMetric == FUNIT_LINE ))
+ eVScrollMetric = FUNIT_INCH;
+ else if ( eVScrollMetric == FUNIT_LINE )
+ eVScrollMetric = FUNIT_CM;
+ }
+ SwView* pTmpView = SwModule::GetFirstView();
+ // switch rulers for all MDI-Windows
+ while(pTmpView)
+ {
+ if(bWeb == (0 != PTR_CAST(SwWebView, pTmpView)))
+ {
+ pTmpView->ChangeVRulerMetric(eVScrollMetric);
+ pTmpView->ChangeTabMetric(eHScrollMetric);
+ }
+
+ pTmpView = SwModule::GetNextView(pTmpView);
+ }
+}
+
+SwNavigationConfig* SwModule::GetNavigationConfig()
+{
+ if(!pNavigationConfig)
+ {
+ pNavigationConfig = new SwNavigationConfig;
+ }
+ return pNavigationConfig;
+}
+
+SwPrintOptions* SwModule::GetPrtOptions(sal_Bool bWeb)
+{
+ if(bWeb && !pWebPrtOpt)
+ {
+ pWebPrtOpt = new SwPrintOptions(sal_True);
+ }
+ else if(!bWeb && !pPrtOpt)
+ {
+ pPrtOpt = new SwPrintOptions(sal_False);
+ }
+
+ return bWeb ? pWebPrtOpt : pPrtOpt;
+}
+
+SwChapterNumRules* SwModule::GetChapterNumRules()
+{
+ if(!pChapterNumRules)
+ pChapterNumRules = new SwChapterNumRules;
+ return pChapterNumRules;
+}
+
+void SwModule::ShowDBObj(SwView& rView, const SwDBData& rData, sal_Bool /*bOnlyIfAvailable*/)
+{
+ Reference<XFrame> xFrame = rView.GetViewFrame()->GetFrame().GetFrameInterface();
+ Reference<XDispatchProvider> xDP(xFrame, uno::UNO_QUERY);
+
+ uno::Reference<XFrame> xBeamerFrame = xFrame->findFrame("_beamer", FrameSearchFlag::CHILDREN);
+ if (xBeamerFrame.is())
+ { // the beamer has been opened by the SfxViewFrame
+ Reference<XController> xController = xBeamerFrame->getController();
+ Reference<XSelectionSupplier> xControllerSelection(xController, UNO_QUERY);
+ if (xControllerSelection.is())
+ {
+
+ ODataAccessDescriptor aSelection;
+ aSelection.setDataSource(rData.sDataSource);
+ aSelection[daCommand] <<= rData.sCommand;
+ aSelection[daCommandType] <<= rData.nCommandType;
+ xControllerSelection->select(makeAny(aSelection.createPropertyValueSequence()));
+ }
+ else {
+ OSL_FAIL("no selection supplier in the beamer!");
+ }
+ }
+}
+
+sal_uInt16 SwModule::GetRedlineAuthor()
+{
+ if (!bAuthorInitialised)
+ {
+ const SvtUserOptions& rOpt = GetUserOptions();
+ sActAuthor = rOpt.GetFullName();
+ if (sActAuthor.isEmpty())
+ {
+ sActAuthor = rOpt.GetID();
+ if (sActAuthor.isEmpty())
+ sActAuthor = SW_RESSTR( STR_REDLINE_UNKNOWN_AUTHOR );
+ }
+ bAuthorInitialised = sal_True;
+ }
+ return InsertRedlineAuthor( sActAuthor );
+}
+
+void SwModule::SetRedlineAuthor(const OUString &rAuthor)
+{
+ bAuthorInitialised = sal_True;
+ sActAuthor = rAuthor;
+ InsertRedlineAuthor( sActAuthor );
+}
+
+OUString SwModule::GetRedlineAuthor(sal_uInt16 nPos)
+{
+ OSL_ENSURE(nPos < pAuthorNames->size(), "author not found!"); //#i45342# RTF doc with no author table caused reader to crash
+ while(!(nPos < pAuthorNames->size()))
+ {
+ InsertRedlineAuthor("nn");
+ };
+ return (*pAuthorNames)[nPos];
+}
+
+sal_uInt16 SwModule::InsertRedlineAuthor(const OUString& rAuthor)
+{
+ sal_uInt16 nPos = 0;
+
+ while(nPos < pAuthorNames->size() && (*pAuthorNames)[nPos] != rAuthor)
+ ++nPos;
+
+ if (nPos == pAuthorNames->size())
+ pAuthorNames->push_back(rAuthor);
+
+ return nPos;
+}
+
+static void lcl_FillAuthorAttr( sal_uInt16 nAuthor, SfxItemSet &rSet,
+ const AuthorCharAttr &rAttr )
+{
+ Color aCol( rAttr.nColor );
+
+ if( COL_TRANSPARENT == rAttr.nColor )
+ {
+ static const ColorData aColArr[] = {
+ COL_AUTHOR1_DARK, COL_AUTHOR2_DARK, COL_AUTHOR3_DARK,
+ COL_AUTHOR4_DARK, COL_AUTHOR5_DARK, COL_AUTHOR6_DARK,
+ COL_AUTHOR7_DARK, COL_AUTHOR8_DARK, COL_AUTHOR9_DARK };
+
+ aCol.SetColor( aColArr[ nAuthor % (sizeof( aColArr ) /
+ sizeof( aColArr[0] )) ] );
+ }
+
+ bool bBackGr = COL_NONE == rAttr.nColor;
+
+ switch (rAttr.nItemId)
+ {
+ case SID_ATTR_CHAR_WEIGHT:
+ {
+ SvxWeightItem aW( (FontWeight)rAttr.nAttr, RES_CHRATR_WEIGHT );
+ rSet.Put( aW );
+ aW.SetWhich( RES_CHRATR_CJK_WEIGHT );
+ rSet.Put( aW );
+ aW.SetWhich( RES_CHRATR_CTL_WEIGHT );
+ rSet.Put( aW );
+ }
+ break;
+
+ case SID_ATTR_CHAR_POSTURE:
+ {
+ SvxPostureItem aP( (FontItalic)rAttr.nAttr, RES_CHRATR_POSTURE );
+ rSet.Put( aP );
+ aP.SetWhich( RES_CHRATR_CJK_POSTURE );
+ rSet.Put( aP );
+ aP.SetWhich( RES_CHRATR_CTL_POSTURE );
+ rSet.Put( aP );
+ }
+ break;
+
+ case SID_ATTR_CHAR_UNDERLINE:
+ rSet.Put( SvxUnderlineItem( (FontUnderline)rAttr.nAttr,
+ RES_CHRATR_UNDERLINE));
+ break;
+
+ case SID_ATTR_CHAR_STRIKEOUT:
+ rSet.Put(SvxCrossedOutItem( (FontStrikeout)rAttr.nAttr,
+ RES_CHRATR_CROSSEDOUT));
+ break;
+
+ case SID_ATTR_CHAR_CASEMAP:
+ rSet.Put( SvxCaseMapItem( (SvxCaseMap)rAttr.nAttr,
+ RES_CHRATR_CASEMAP));
+ break;
+
+ case SID_ATTR_BRUSH:
+ rSet.Put( SvxBrushItem( aCol, RES_CHRATR_BACKGROUND ));
+ bBackGr = true;
+ break;
+ }
+
+ if( !bBackGr )
+ rSet.Put( SvxColorItem( aCol, RES_CHRATR_COLOR ) );
+}
+
+void SwModule::GetInsertAuthorAttr(sal_uInt16 nAuthor, SfxItemSet &rSet)
+{
+ lcl_FillAuthorAttr(nAuthor, rSet, pModuleConfig->GetInsertAuthorAttr());
+}
+
+void SwModule::GetDeletedAuthorAttr(sal_uInt16 nAuthor, SfxItemSet &rSet)
+{
+ lcl_FillAuthorAttr(nAuthor, rSet, pModuleConfig->GetDeletedAuthorAttr());
+}
+
+// For future extension:
+void SwModule::GetFormatAuthorAttr( sal_uInt16 nAuthor, SfxItemSet &rSet )
+{
+ lcl_FillAuthorAttr( nAuthor, rSet, pModuleConfig->GetFormatAuthorAttr() );
+}
+
+sal_uInt16 SwModule::GetRedlineMarkPos()
+{
+ return pModuleConfig->GetMarkAlignMode();
+}
+
+sal_Bool SwModule::IsInsTblFormatNum(sal_Bool bHTML) const
+{
+ return pModuleConfig->IsInsTblFormatNum(bHTML);
+}
+
+sal_Bool SwModule::IsInsTblChangeNumFormat(sal_Bool bHTML) const
+{
+ return pModuleConfig->IsInsTblChangeNumFormat(bHTML);
+}
+
+sal_Bool SwModule::IsInsTblAlignNum(sal_Bool bHTML) const
+{
+ return pModuleConfig->IsInsTblAlignNum(bHTML);
+}
+
+const Color &SwModule::GetRedlineMarkColor()
+{
+ return pModuleConfig->GetMarkAlignColor();
+}
+
+const SwViewOption* SwModule::GetViewOption(sal_Bool bWeb)
+{
+ return GetUsrPref( bWeb );
+}
+
+OUString SwModule::GetDocStatWordDelim() const
+{
+ return pModuleConfig->GetWordDelimiter();
+}
+
+// Passing-through of the ModuleConfig's Metric (for HTML-Export)
+sal_uInt16 SwModule::GetMetric( sal_Bool bWeb ) const
+{
+ SwMasterUsrPref* pPref;
+ if(bWeb)
+ {
+ if(!pWebUsrPref)
+ GetUsrPref(sal_True);
+ pPref = pWebUsrPref;
+ }
+ else
+ {
+ if(!pUsrPref)
+ GetUsrPref(sal_False);
+ pPref = pUsrPref;
+ }
+ return static_cast< sal_uInt16 >(pPref->GetMetric());
+}
+
+// Pass-through Update-Status
+sal_uInt16 SwModule::GetLinkUpdMode( sal_Bool ) const
+{
+ if(!pUsrPref)
+ GetUsrPref(sal_False);
+ return (sal_uInt16)pUsrPref->GetUpdateLinkMode();
+}
+
+SwFldUpdateFlags SwModule::GetFldUpdateFlags( sal_Bool ) const
+{
+ if(!pUsrPref)
+ GetUsrPref(sal_False);
+ return pUsrPref->GetFldUpdateFlags();
+}
+
+void SwModule::ApplyFldUpdateFlags(SwFldUpdateFlags eFldFlags)
+{
+ if(!pUsrPref)
+ GetUsrPref(sal_False);
+ pUsrPref->SetFldUpdateFlags(eFldFlags);
+}
+
+void SwModule::ApplyLinkMode(sal_Int32 nNewLinkMode)
+{
+ if(!pUsrPref)
+ GetUsrPref(sal_False);
+ pUsrPref->SetUpdateLinkMode(nNewLinkMode);
+}
+
+void SwModule::CheckSpellChanges( bool bOnlineSpelling,
+ bool bIsSpellWrongAgain, bool bIsSpellAllAgain, bool bSmartTags )
+{
+ bool bOnlyWrong = bIsSpellWrongAgain && !bIsSpellAllAgain;
+ bool bInvalid = bOnlyWrong || bIsSpellAllAgain;
+ if( bOnlineSpelling || bInvalid )
+ {
+ TypeId aType = TYPE(SwDocShell);
+ for( SwDocShell *pDocSh = (SwDocShell*)SfxObjectShell::GetFirst(&aType);
+ pDocSh;
+ pDocSh = (SwDocShell*)SfxObjectShell::GetNext( *pDocSh, &aType ) )
+ {
+ SwDoc* pTmp = pDocSh->GetDoc();
+ if ( pTmp->GetCurrentViewShell() )
+ {
+ pTmp->SpellItAgainSam( bInvalid, bOnlyWrong, bSmartTags );
+ SwViewShell* pViewShell = 0;
+ pTmp->GetEditShell( &pViewShell );
+ if ( bSmartTags && pViewShell && pViewShell->GetWin() )
+ pViewShell->GetWin()->Invalidate();
+ }
+ }
+ }
+}
+
+void SwModule::ApplyDefaultPageMode(sal_Bool bIsSquaredPageMode)
+{
+ if(!pUsrPref)
+ GetUsrPref(sal_False);
+ pUsrPref->SetDefaultPageMode(bIsSquaredPageMode);
+}
+
+SvxCompareMode SwModule::GetCompareMode() const
+{
+ return pModuleConfig->GetCompareMode();
+}
+
+sal_Bool SwModule::IsUseRsid() const
+{
+ return pModuleConfig->IsUseRsid();
+}
+
+sal_Bool SwModule::IsIgnorePieces() const
+{
+ return pModuleConfig->IsIgnorePieces();
+}
+
+sal_uInt16 SwModule::GetPieceLen() const
+{
+ return pModuleConfig->GetPieceLen();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/app/swmodule.cxx b/sw/source/core/uibase/app/swmodule.cxx
new file mode 100644
index 000000000000..115ab46da5cf
--- /dev/null
+++ b/sw/source/core/uibase/app/swmodule.cxx
@@ -0,0 +1,427 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <config_features.h>
+
+#include <hintids.hxx>
+#include <swerror.h>
+#include <vcl/wrkwin.hxx>
+#include <vcl/graph.hxx>
+#include <svx/galbrws.hxx>
+#include <svx/svdobj.hxx>
+#include <svtools/ehdl.hxx>
+#include <svx/fntszctl.hxx>
+#include <svx/fntctl.hxx>
+#include <svx/SmartTagCtl.hxx>
+#include <svx/pszctrl.hxx>
+#include <svx/insctrl.hxx>
+#include <svx/selctrl.hxx>
+#include <svx/linectrl.hxx>
+#include <svx/tbxctl.hxx>
+#include <svx/fillctrl.hxx>
+#include <svx/tbcontrl.hxx>
+#include <svx/verttexttbxctrl.hxx>
+#include <svx/formatpaintbrushctrl.hxx>
+#include <svx/contdlg.hxx>
+#include <svx/layctrl.hxx>
+#include <svx/fontwork.hxx>
+#include <SwSpellDialogChildWindow.hxx>
+#include <svx/tbxalign.hxx>
+#include <svx/grafctrl.hxx>
+#include <svx/tbxcolor.hxx>
+#include <svx/clipboardctl.hxx>
+#include <svx/lboxctrl.hxx>
+#include <svx/tbxcustomshapes.hxx>
+#include <svx/imapdlg.hxx>
+#include <svx/srchdlg.hxx>
+#include <svx/hyperdlg.hxx>
+#include <svx/extrusioncolorcontrol.hxx>
+#include <svx/fontworkgallery.hxx>
+#include <svx/modctrl.hxx>
+#include <com/sun/star/scanner/ScannerManager.hpp>
+#include <com/sun/star/container/XSet.hpp>
+#include <com/sun/star/linguistic2/LanguageGuessing.hpp>
+#include <comphelper/processfactory.hxx>
+#include <docsh.hxx>
+#include <swmodule.hxx>
+#include <swevent.hxx>
+#include <swacorr.hxx>
+#include <cmdid.h>
+#include <dobjfac.hxx>
+#include <init.hxx>
+#include <pview.hxx>
+#include <wview.hxx>
+#include <wdocsh.hxx>
+#include <globdoc.hxx>
+#include <srcview.hxx>
+#include <glshell.hxx>
+#include <tabsh.hxx>
+#include <listsh.hxx>
+#include <grfsh.hxx>
+#include <mediash.hxx>
+#include <olesh.hxx>
+#include <drawsh.hxx>
+#include <wformsh.hxx>
+#include <drwtxtsh.hxx>
+#include <beziersh.hxx>
+#include <wtextsh.hxx>
+#include <wfrmsh.hxx>
+#include <drformsh.hxx>
+#include <wgrfsh.hxx>
+#include <wolesh.hxx>
+#include <wlistsh.hxx>
+#include <wtabsh.hxx>
+#include <navipi.hxx>
+#include <chartins.hxx>
+#include <inputwin.hxx>
+#include <usrpref.hxx>
+#include <uinums.hxx>
+#include <prtopt.hxx>
+#include <bookctrl.hxx>
+#include <tmplctrl.hxx>
+#include <viewlayoutctrl.hxx>
+#include <svx/zoomsliderctrl.hxx>
+#include <tblctrl.hxx>
+#include <zoomctrl.hxx>
+#include <wordcountctrl.hxx>
+#include <workctrl.hxx>
+#include <tbxanchr.hxx>
+#include <fldwrap.hxx>
+#include <redlndlg.hxx>
+#include <syncbtn.hxx>
+#include <mailmergechildwindow.hxx>
+#include <modcfg.hxx>
+#include <fontcfg.hxx>
+#include <sfx2/sidebar/SidebarChildWindow.hxx>
+#include <sfx2/taskpane.hxx>
+#include <sfx2/evntconf.hxx>
+#include <swatrset.hxx>
+#include <idxmrk.hxx>
+#include <wordcountdialog.hxx>
+#include <dlelstnr.hxx>
+#include <barcfg.hxx>
+#include <svx/rubydialog.hxx>
+#include <svtools/colorcfg.hxx>
+
+#include <editeng/acorrcfg.hxx>
+#include <unotools/moduleoptions.hxx>
+
+#include <avmedia/mediaplayer.hxx>
+#include <avmedia/mediatoolbox.hxx>
+
+#include <annotsh.hxx>
+#include <navsh.hxx>
+
+#include <app.hrc>
+#include <svx/xmlsecctrl.hxx>
+ResMgr *pSwResMgr = 0;
+bool bNoInterrupt = false;
+
+#include <sfx2/app.hxx>
+
+#include <svx/svxerr.hxx>
+
+#include <unomid.h>
+
+#include "swdllimpl.hxx"
+
+using namespace com::sun::star;
+
+TYPEINIT1( SwModule, SfxModule );
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+SwModule::SwModule( SfxObjectFactory* pWebFact,
+ SfxObjectFactory* pFact,
+ SfxObjectFactory* pGlobalFact )
+ : SfxModule( SfxApplication::CreateResManager( "sw" ), sal_False, pWebFact,
+ pFact, pGlobalFact, NULL ),
+ pModuleConfig(0),
+ pUsrPref(0),
+ pWebUsrPref(0),
+ pPrtOpt(0),
+ pWebPrtOpt(0),
+ pChapterNumRules(0),
+ pStdFontConfig(0),
+ pNavigationConfig(0),
+ pToolbarConfig(0),
+ pWebToolbarConfig(0),
+ pDBConfig(0),
+ pColorConfig(0),
+ pAccessibilityOptions(0),
+ pCTLOptions(0),
+ pUserOptions(0),
+ pAttrPool(0),
+ pView(0),
+ bAuthorInitialised(sal_False),
+ bEmbeddedLoadSave( sal_False ),
+ pDragDrop( 0 ),
+ pXSelection( 0 )
+{
+ SetName( OUString("StarWriter") );
+ pSwResMgr = GetResMgr();
+ SvxErrorHandler::ensure();
+ pErrorHdl = new SfxErrorHandler( RID_SW_ERRHDL,
+ ERRCODE_AREA_SW,
+ ERRCODE_AREA_SW_END,
+ pSwResMgr );
+
+ pModuleConfig = new SwModuleOptions;
+
+ // We need them anyways
+ pToolbarConfig = new SwToolbarConfigItem( false );
+ pWebToolbarConfig = new SwToolbarConfigItem( true );
+
+ pStdFontConfig = new SwStdFontConfig;
+
+ pAuthorNames = new std::vector<OUString>; // All Redlining-Authors
+
+ // replace SvxAutocorrect with SwAutocorrect
+ SvxAutoCorrCfg& rACfg = SvxAutoCorrCfg::Get();
+ const SvxAutoCorrect* pOld = rACfg.GetAutoCorrect();
+ rACfg.SetAutoCorrect(new SwAutoCorrect( *pOld ));
+
+ StartListening( *SFX_APP() );
+
+ // OD 14.02.2003 #107424# - init color configuration
+ // member <pColorConfig> is created and the color configuration is applied
+ // at the view options.
+ GetColorConfig();
+}
+uno::Reference< scanner::XScannerManager2 >
+SwModule::GetScannerManager()
+{
+ if (!m_xScannerManager.is())
+ {
+ m_xScannerManager = scanner::ScannerManager::create( comphelper::getProcessComponentContext() );
+ }
+ return m_xScannerManager;
+}
+
+uno::Reference< linguistic2::XLanguageGuessing > SwModule::GetLanguageGuesser()
+{
+ if (!m_xLanguageGuesser.is())
+ {
+ m_xLanguageGuesser = linguistic2::LanguageGuessing::create( comphelper::getProcessComponentContext() );
+ }
+ return m_xLanguageGuesser;
+}
+
+SwModule::~SwModule()
+{
+ delete pErrorHdl;
+ EndListening( *SFX_APP() );
+}
+
+void SwModule::CreateLngSvcEvtListener()
+{
+ if (!xLngSvcEvtListener.is())
+ xLngSvcEvtListener = new SwLinguServiceEventListener;
+}
+
+void SwDLL::RegisterFactories()
+{
+ // These Id's must not be changed. Through these Id's the View (resume Documentview)
+ // is created by Sfx.
+ if ( SvtModuleOptions().IsWriter() )
+ SwView::RegisterFactory ( 2 );
+
+#if HAVE_FEATURE_DESKTOP
+ SwWebView::RegisterFactory ( 5 );
+
+ if ( SvtModuleOptions().IsWriter() )
+ {
+ SwSrcView::RegisterFactory ( 6 );
+ SwPagePreview::RegisterFactory ( 7 );
+ }
+#endif
+}
+
+void SwDLL::RegisterInterfaces()
+{
+ SwModule* pMod = SW_MOD();
+ SwModule::RegisterInterface( pMod );
+ SwDocShell::RegisterInterface( pMod );
+ SwWebDocShell::RegisterInterface( pMod );
+ SwGlosDocShell::RegisterInterface( pMod );
+ SwWebGlosDocShell::RegisterInterface( pMod );
+ SwView::RegisterInterface( pMod );
+ SwWebView::RegisterInterface( pMod );
+ SwPagePreview::RegisterInterface( pMod );
+ SwSrcView::RegisterInterface( pMod );
+
+ SwBaseShell::RegisterInterface(pMod);
+ SwTextShell::RegisterInterface(pMod);
+ SwTableShell::RegisterInterface(pMod);
+ SwListShell::RegisterInterface(pMod);
+ SwFrameShell::RegisterInterface(pMod);
+ SwDrawBaseShell::RegisterInterface(pMod);
+ SwDrawShell::RegisterInterface(pMod);
+ SwDrawFormShell::RegisterInterface(pMod);
+ SwDrawTextShell::RegisterInterface(pMod);
+ SwBezierShell::RegisterInterface(pMod);
+ SwGrfShell::RegisterInterface(pMod);
+ SwOleShell::RegisterInterface(pMod);
+ SwNavigationShell::RegisterInterface(pMod);
+ SwWebTextShell::RegisterInterface(pMod);
+ SwWebFrameShell::RegisterInterface(pMod);
+ SwWebGrfShell::RegisterInterface(pMod);
+ SwWebListShell::RegisterInterface(pMod);
+ SwWebTableShell::RegisterInterface(pMod);
+ SwWebDrawFormShell::RegisterInterface(pMod);
+ SwWebOleShell::RegisterInterface(pMod);
+ SwMediaShell::RegisterInterface(pMod);
+ SwAnnotationShell::RegisterInterface(pMod);
+}
+
+void SwDLL::RegisterControls()
+{
+ SwModule* pMod = SW_MOD();
+
+ SfxRecentFilesToolBoxControl::RegisterControl( FN_OPEN_FILE, pMod );
+ SvxTbxCtlDraw::RegisterControl(SID_INSERT_DRAW, pMod );
+ SvxTbxCtlAlign::RegisterControl(SID_OBJECT_ALIGN, pMod );
+ SwTbxAnchor::RegisterControl(FN_TOOL_ANCHOR, pMod );
+ SwTbxInsertCtrl::RegisterControl(FN_INSERT_CTRL, pMod );
+ SwTbxInsertCtrl::RegisterControl(FN_INSERT_OBJ_CTRL, pMod );
+ SwTbxFieldCtrl::RegisterControl(FN_INSERT_FIELD_CTRL, pMod );
+ SwTbxAutoTextCtrl::RegisterControl(FN_GLOSSARY_DLG, 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 );
+
+ svx::ExtrusionColorControl::RegisterControl( SID_EXTRUSION_3D_COLOR, pMod );
+ svx::FontWorkShapeTypeControl::RegisterControl( SID_FONTWORK_SHAPE_TYPE, pMod );
+
+ SvxClipBoardControl::RegisterControl(SID_PASTE, pMod );
+ SvxUndoRedoControl::RegisterControl(SID_UNDO, pMod );
+ SvxUndoRedoControl::RegisterControl(SID_REDO, pMod );
+ svx::FormatPaintBrushToolBoxControl::RegisterControl(SID_FORMATPAINTBRUSH, pMod );
+
+ SvxFillToolBoxControl::RegisterControl(SID_ATTR_FILL_STYLE, pMod );
+ SvxLineStyleToolBoxControl::RegisterControl(SID_ATTR_LINE_STYLE, pMod );
+ SvxLineWidthToolBoxControl::RegisterControl(SID_ATTR_LINE_WIDTH, pMod );
+ SvxLineColorToolBoxControl::RegisterControl(SID_ATTR_LINE_COLOR, pMod );
+ SvxLineEndToolBoxControl::RegisterControl(SID_ATTR_LINEEND_STYLE, pMod );
+
+ SvxFontNameToolBoxControl::RegisterControl(SID_ATTR_CHAR_FONT, pMod );
+ SvxFontColorToolBoxControl::RegisterControl(SID_ATTR_CHAR_COLOR, pMod );
+ SvxColorExtToolBoxControl::RegisterControl(SID_ATTR_CHAR_COLOR2, pMod );
+ SvxColorExtToolBoxControl::RegisterControl(SID_ATTR_CHAR_COLOR_BACKGROUND, pMod );
+ SvxStyleToolBoxControl::RegisterControl(SID_STYLE_APPLY, pMod );
+ SvxColorExtToolBoxControl::RegisterControl( SID_BACKGROUND_COLOR, pMod );
+ SvxFrameToolBoxControl::RegisterControl(SID_ATTR_BORDER, pMod );
+ SvxFrameLineStyleToolBoxControl::RegisterControl(SID_FRAME_LINESTYLE, pMod );
+ SvxColorExtToolBoxControl::RegisterControl(SID_FRAME_LINECOLOR, pMod );
+
+ SvxColumnsToolBoxControl::RegisterControl(FN_INSERT_FRAME_INTERACT, pMod );
+ SvxColumnsToolBoxControl::RegisterControl(FN_INSERT_FRAME, pMod );
+ SvxColumnsToolBoxControl::RegisterControl(FN_INSERT_REGION, pMod );
+ SvxTableToolBoxControl::RegisterControl(FN_INSERT_TABLE, pMod );
+ SvxTableToolBoxControl::RegisterControl(FN_SHOW_MULTIPLE_PAGES, pMod );
+
+ SvxFontMenuControl::RegisterControl(SID_ATTR_CHAR_FONT, pMod );
+ SvxFontSizeMenuControl::RegisterControl(SID_ATTR_CHAR_FONTHEIGHT, pMod );
+
+ SwZoomControl::RegisterControl(SID_ATTR_ZOOM, pMod );
+ SwPreviewZoomControl::RegisterControl(FN_PREVIEW_ZOOM, pMod);
+ SvxPosSizeStatusBarControl::RegisterControl(0, pMod );
+ SvxInsertStatusBarControl::RegisterControl(SID_ATTR_INSERT, pMod );
+ SvxSelectionModeControl::RegisterControl(FN_STAT_SELMODE, pMod );
+ XmlSecStatusBarControl::RegisterControl( SID_SIGNATURE, pMod );
+ SwWordCountStatusBarControl::RegisterControl(FN_STAT_WORDCOUNT, pMod);
+
+ SwBookmarkControl::RegisterControl(FN_STAT_PAGE, pMod );
+ SwTemplateControl::RegisterControl(FN_STAT_TEMPLATE, pMod );
+ SwViewLayoutControl::RegisterControl( SID_ATTR_VIEWLAYOUT, pMod );
+ SvxModifyControl::RegisterControl( SID_DOC_MODIFIED, pMod );
+ SvxZoomSliderControl::RegisterControl( SID_ATTR_ZOOMSLIDER, pMod );
+
+ SwTableOptimizeCtrl::RegisterControl(FN_OPTIMIZE_TABLE, pMod);
+
+ SvxIMapDlgChildWindow::RegisterChildWindow( sal_False, pMod );
+ SvxSearchDialogWrapper::RegisterChildWindow( sal_False, pMod );
+ SvxHlinkDlgWrapper::RegisterChildWindow( sal_False, pMod );
+ SvxFontWorkChildWindow::RegisterChildWindow( sal_False, pMod );
+ SwFldDlgWrapper::RegisterChildWindow( sal_False, pMod );
+ SwFldDataOnlyDlgWrapper::RegisterChildWindow( sal_False, pMod );
+ SvxContourDlgChildWindow::RegisterChildWindow( sal_False, pMod );
+ SwNavigationChild::RegisterChildWindowContext( pMod );
+ SwInputChild::RegisterChildWindow( sal_False, pMod, SFX_CHILDWIN_FORCEDOCK );
+ SwRedlineAcceptChild::RegisterChildWindow( sal_False, pMod );
+ SwSyncChildWin::RegisterChildWindow( sal_True, pMod );
+ SwMailMergeChildWindow::RegisterChildWindow( sal_False, pMod );
+ SwInsertIdxMarkWrapper::RegisterChildWindow( sal_False, pMod );
+ SwInsertAuthMarkWrapper::RegisterChildWindow( sal_False, pMod );
+ SwWordCountWrapper::RegisterChildWindow( sal_False, pMod );
+ SvxRubyChildWindow::RegisterChildWindow( sal_False, pMod);
+ SwSpellDialogChildWindow::RegisterChildWindow(sal_False, 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 );
+ SvxGrafModeToolBoxControl::RegisterControl( SID_ATTR_GRAF_MODE, pMod );
+ SvxGrafFilterToolBoxControl::RegisterControl( SID_GRFFILTER, pMod );
+ SvxVertTextTbxCtrl::RegisterControl(SID_TEXTDIRECTION_LEFT_TO_RIGHT, pMod);
+ SvxVertTextTbxCtrl::RegisterControl(SID_TEXTDIRECTION_TOP_TO_BOTTOM, pMod);
+ SvxVertTextTbxCtrl::RegisterControl(SID_DRAW_CAPTION_VERTICAL, pMod);
+ SvxVertTextTbxCtrl::RegisterControl(SID_DRAW_TEXT_VERTICAL, pMod);
+
+ SvxCTLTextTbxCtrl::RegisterControl(SID_ATTR_PARA_LEFT_TO_RIGHT, pMod);
+ SvxCTLTextTbxCtrl::RegisterControl(SID_ATTR_PARA_RIGHT_TO_LEFT, pMod);
+
+ GalleryChildWindow::RegisterChildWindow(0, pMod);
+
+ ::avmedia::MediaToolBoxControl::RegisterControl(SID_AVMEDIA_TOOLBOX, pMod);
+ ::avmedia::MediaPlayer::RegisterChildWindow(0, pMod);
+
+ SvxSmartTagsControl::RegisterControl(SID_OPEN_SMARTTAGMENU, pMod);
+ ::sfx2::sidebar::SidebarChildWindow::RegisterChildWindow(0, pMod);
+ ::sfx2::TaskPaneWrapper::RegisterChildWindow(0, pMod);
+}
+
+/*************************************************************************
+|*
+|* Load Module (only dummy for linking of the DLL)
+|*
+\************************************************************************/
+
+void SwModule::InitAttrPool()
+{
+ OSL_ENSURE(!pAttrPool, "Pool already exists!");
+ pAttrPool = new SwAttrPool(0);
+ SetPool(pAttrPool);
+}
+
+void SwModule::RemoveAttrPool()
+{
+ SetPool(0);
+ SfxItemPool::Free(pAttrPool);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/app/swwait.cxx b/sw/source/core/uibase/app/swwait.cxx
new file mode 100644
index 000000000000..f25f27209b1b
--- /dev/null
+++ b/sw/source/core/uibase/app/swwait.cxx
@@ -0,0 +1,84 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <swwait.hxx>
+#include <docsh.hxx>
+
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/dispatch.hxx>
+#include <vcl/window.hxx>
+
+SwWait::SwWait(
+ SwDocShell &rDocShell,
+ const bool bLockUnlockDispatcher )
+ : mrDoc ( rDocShell )
+ , mbLockUnlockDispatcher( bLockUnlockDispatcher )
+ , mpLockedDispatchers()
+{
+ EnterWaitAndLockDispatcher();
+}
+
+SwWait::~SwWait()
+{
+ LeaveWaitAndUnlockDispatcher();
+}
+
+void SwWait::EnterWaitAndLockDispatcher()
+{
+ SfxViewFrame *pFrame = SfxViewFrame::GetFirst( &mrDoc, sal_False );
+ while ( pFrame )
+ {
+ pFrame->GetWindow().EnterWait();
+ if ( mbLockUnlockDispatcher )
+ {
+ // do not look already locked dispatchers
+ SfxDispatcher* pDispatcher = pFrame->GetDispatcher();
+ if ( !pDispatcher->IsLocked() )
+ {
+ pDispatcher->Lock( sal_True );
+ mpLockedDispatchers.insert( pDispatcher );
+ }
+ }
+
+ pFrame = SfxViewFrame::GetNext( *pFrame, &mrDoc, sal_False );
+ }
+}
+
+void SwWait::LeaveWaitAndUnlockDispatcher()
+{
+ SfxViewFrame *pFrame = SfxViewFrame::GetFirst( &mrDoc, sal_False );
+ while ( pFrame )
+ {
+ pFrame->GetWindow().LeaveWait();
+ if ( mbLockUnlockDispatcher )
+ {
+ // only unlock dispatchers which had been locked
+ SfxDispatcher* pDispatcher = pFrame->GetDispatcher();
+ if ( mpLockedDispatchers.find( pDispatcher ) != mpLockedDispatchers.end() )
+ {
+ mpLockedDispatchers.erase( pDispatcher );
+ pDispatcher->Lock( sal_False );
+ }
+ }
+
+ pFrame = SfxViewFrame::GetNext( *pFrame, &mrDoc, sal_False );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/cctrl/actctrl.cxx b/sw/source/core/uibase/cctrl/actctrl.cxx
new file mode 100644
index 000000000000..d3d1936aea04
--- /dev/null
+++ b/sw/source/core/uibase/cctrl/actctrl.cxx
@@ -0,0 +1,134 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <comphelper/string.hxx>
+#include <vcl/builder.hxx>
+#include "actctrl.hxx"
+
+void NumEditAction::Action()
+{
+ aActionLink.Call( this );
+}
+
+bool NumEditAction::Notify( NotifyEvent& rNEvt )
+{
+ bool nHandled = false;
+
+ if ( rNEvt.GetType() == EVENT_KEYINPUT )
+ {
+ const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
+ const KeyCode aKeyCode = pKEvt->GetKeyCode();
+ const sal_uInt16 nModifier = aKeyCode.GetModifier();
+ if( aKeyCode.GetCode() == KEY_RETURN &&
+ !nModifier)
+ {
+ Action();
+ nHandled = true;
+ }
+
+ }
+ if(!nHandled)
+ NumericField::Notify( rNEvt );
+ return nHandled;
+}
+
+NoSpaceEdit::NoSpaceEdit(Window* pParent)
+ : Edit(pParent, WB_BORDER|WB_TABSTOP)
+ , sForbiddenChars(OUString(" "))
+{
+}
+
+NoSpaceEdit::~NoSpaceEdit()
+{
+}
+
+void NoSpaceEdit::KeyInput(const KeyEvent& rEvt)
+{
+ bool bCallParent = true;
+ if(rEvt.GetCharCode())
+ {
+ OUString sKey(rEvt.GetCharCode());
+ if( -1 != sForbiddenChars.indexOf(sKey))
+ bCallParent = false;
+ }
+ if(bCallParent)
+ Edit::KeyInput(rEvt);
+}
+
+void NoSpaceEdit::Modify()
+{
+ Selection aSel = GetSelection();
+ OUString sTemp = GetText();
+ for(sal_uInt16 i = 0; i < sForbiddenChars.getLength(); i++)
+ {
+ sTemp = comphelper::string::remove(sTemp, sForbiddenChars[i]);
+ }
+ sal_Int32 nDiff = GetText().getLength() - sTemp.getLength();
+ if(nDiff)
+ {
+ aSel.setMin(aSel.getMin() - nDiff);
+ aSel.setMax(aSel.getMin());
+ SetText(sTemp);
+ SetSelection(aSel);
+ }
+ Edit::Modify();
+}
+
+ReturnActionEdit::ReturnActionEdit(Window* pParent, const ResId& rResId)
+ : Edit(pParent, rResId)
+{
+}
+
+ReturnActionEdit::~ReturnActionEdit()
+{
+}
+
+void ReturnActionEdit::KeyInput( const KeyEvent& rEvt)
+{
+ const KeyCode aKeyCode = rEvt.GetKeyCode();
+ const sal_uInt16 nModifier = aKeyCode.GetModifier();
+ if( aKeyCode.GetCode() == KEY_RETURN &&
+ !nModifier)
+ {
+ if(aReturnActionLink.IsSet())
+ aReturnActionLink.Call(this);
+ }
+ else
+ Edit::KeyInput(rEvt);
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeTableNameEdit(Window *pParent, VclBuilder::stringmap &rMap)
+{
+ VclBuilder::ensureDefaultWidthChars(rMap);
+ return new TableNameEdit(pParent);
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeNoSpaceEdit(Window *pParent, VclBuilder::stringmap &rMap)
+{
+ VclBuilder::ensureDefaultWidthChars(rMap);
+ return new NoSpaceEdit(pParent);
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeReturnActionEdit(Window *pParent, VclBuilder::stringmap &rMap)
+{
+ VclBuilder::ensureDefaultWidthChars(rMap);
+ return new ReturnActionEdit(pParent, WB_LEFT|WB_VCENTER|WB_BORDER|WB_3DLOOK);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/cctrl/popbox.cxx b/sw/source/core/uibase/cctrl/popbox.cxx
new file mode 100644
index 000000000000..4ebf98d738df
--- /dev/null
+++ b/sw/source/core/uibase/cctrl/popbox.cxx
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <cmdid.h>
+#include <swtypes.hxx>
+#include <popbox.hxx>
+#include <navipi.hxx>
+
+SwHelpToolBox::SwHelpToolBox( SwNavigationPI* pParent, const ResId& rResId )
+ : ToolBox( pParent, rResId ),
+ DropTargetHelper( this )
+{
+}
+
+void SwHelpToolBox::MouseButtonDown(const MouseEvent &rEvt)
+{
+ // If doubleclick is detected use doubleclick handler
+ if(rEvt.GetButtons() == MOUSE_RIGHT &&
+ 0 == GetItemId(rEvt.GetPosPixel()))
+ {
+ aRightClickLink.Call((MouseEvent *)&rEvt);
+ }
+ else
+ ToolBox::MouseButtonDown(rEvt);
+}
+
+long SwHelpToolBox::DoubleClick( ToolBox* pCaller )
+{
+ // No doubleclick on button
+ if( 0 == pCaller->GetCurItemId() && aDoubleClickLink.Call(0) )
+ return sal_True;
+ return sal_False;
+}
+
+SwHelpToolBox::~SwHelpToolBox() {}
+
+sal_Int8 SwHelpToolBox::AcceptDrop( const AcceptDropEvent& rEvt )
+{
+ return ((SwNavigationPI*)GetParent())->AcceptDrop( rEvt );
+}
+
+sal_Int8 SwHelpToolBox::ExecuteDrop( const ExecuteDropEvent& rEvt )
+{
+ return ((SwNavigationPI*)GetParent())->ExecuteDrop( rEvt );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/cctrl/swlbox.cxx b/sw/source/core/uibase/cctrl/swlbox.cxx
new file mode 100644
index 000000000000..384fca4f5fc0
--- /dev/null
+++ b/sw/source/core/uibase/cctrl/swlbox.cxx
@@ -0,0 +1,137 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <osl/diagnose.h>
+#include <unotools/charclass.hxx>
+#include <swtypes.hxx>
+#include <swlbox.hxx>
+
+// Description: ListboxElement
+SwBoxEntry::SwBoxEntry() :
+ bModified(sal_False),
+ bNew(sal_False),
+ nId(COMBOBOX_APPEND)
+{
+}
+
+SwBoxEntry::SwBoxEntry(const OUString& aNam, sal_Int32 nIdx) :
+ bModified(sal_False),
+ bNew(sal_False),
+ aName(aNam),
+ nId(nIdx)
+{
+}
+
+SwBoxEntry::SwBoxEntry(const SwBoxEntry& rOld) :
+ bModified(rOld.bModified),
+ bNew(rOld.bNew),
+ aName(rOld.aName),
+ nId(rOld.nId)
+{
+}
+
+SwComboBox::SwComboBox(Window* pParent, WinBits nStyle)
+ : ComboBox(pParent, nStyle)
+{
+ Init();
+}
+
+void SwComboBox::Init()
+{
+ // create administration for the resource's Stringlist
+ sal_Int32 nSize = GetEntryCount();
+ for( sal_Int32 i=0; i < nSize; ++i )
+ {
+ SwBoxEntry* pTmp = new SwBoxEntry(ComboBox::GetEntry(i), i);
+ aEntryLst.push_back(pTmp);
+ }
+}
+
+// Basic class Dtor
+SwComboBox::~SwComboBox()
+{
+}
+
+void SwComboBox::InsertSwEntry(const SwBoxEntry& rEntry)
+{
+ InsertSorted(new SwBoxEntry(rEntry));
+}
+
+sal_Int32 SwComboBox::InsertEntry(const OUString& rStr, sal_Int32)
+{
+ InsertSwEntry(SwBoxEntry(rStr));
+ return 0;
+}
+
+void SwComboBox::RemoveEntryAt(sal_Int32 const nPos)
+{
+ if(nPos < 0 || static_cast<size_t>(nPos) >= aEntryLst.size())
+ return;
+
+ // Remove old element
+ SwBoxEntry* pEntry = &aEntryLst[nPos];
+ ComboBox::RemoveEntryAt(nPos);
+
+ // Don't add new entries to the list
+ if(pEntry->bNew)
+ {
+ aEntryLst.erase(aEntryLst.begin() + nPos);
+ }
+ else
+ {
+ // add to DelEntryLst
+ aDelEntryLst.transfer(aDelEntryLst.end(),
+ aEntryLst.begin() + nPos, aEntryLst);
+ }
+}
+
+sal_Int32 SwComboBox::GetSwEntryPos(const SwBoxEntry& rEntry) const
+{
+ return ComboBox::GetEntryPos(rEntry.aName);
+}
+
+const SwBoxEntry& SwComboBox::GetSwEntry(sal_Int32 const nPos) const
+{
+ if(0 <= nPos && static_cast<size_t>(nPos) < aEntryLst.size())
+ return aEntryLst[nPos];
+
+ return aDefault;
+}
+
+sal_Int32 SwComboBox::GetRemovedCount() const
+{
+ return static_cast<sal_Int32>(aDelEntryLst.size());
+}
+
+const SwBoxEntry& SwComboBox::GetRemovedEntry(sal_Int32 nPos) const
+{
+ if(0 <= nPos && static_cast<size_t>(nPos) < aDelEntryLst.size())
+ return aDelEntryLst[nPos];
+
+ return aDefault;
+}
+
+void SwComboBox::InsertSorted(SwBoxEntry* pEntry)
+{
+ ComboBox::InsertEntry(pEntry->aName);
+ sal_Int32 nPos = ComboBox::GetEntryPos(pEntry->aName);
+ aEntryLst.insert( aEntryLst.begin() + nPos, pEntry );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/chrdlg/ccoll.cxx b/sw/source/core/uibase/chrdlg/ccoll.cxx
new file mode 100644
index 000000000000..726c66974f13
--- /dev/null
+++ b/sw/source/core/uibase/chrdlg/ccoll.cxx
@@ -0,0 +1,187 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "cmdid.h"
+#include "swmodule.hxx"
+#include "view.hxx"
+#include "wrtsh.hxx"
+#include "globals.hrc"
+#include "helpid.h"
+
+#include <sfx2/styfitem.hxx>
+
+#include "uitool.hxx"
+#include "ccoll.hxx"
+#include "fmtcol.hxx"
+#include "hintids.hxx"
+#include "docsh.hxx"
+#include "docstyle.hxx"
+#include "hints.hxx"
+
+#include "chrdlg.hrc"
+#include <vcl/svapp.hxx>
+
+#include <unomid.h>
+
+// ******************************************************************
+
+//!! order of entries has to be the same as in
+//!! CommandStruct SwCondCollItem::aCmds[]
+
+const char *aCommandContext[COND_COMMAND_COUNT] =
+{
+ "TableHeader",
+ "Table",
+ "Frame",
+ "Section",
+ "Footnote",
+ "Endnote",
+ "Header",
+ "Footer",
+ "OutlineLevel1",
+ "OutlineLevel2",
+ "OutlineLevel3",
+ "OutlineLevel4",
+ "OutlineLevel5",
+ "OutlineLevel6",
+ "OutlineLevel7",
+ "OutlineLevel8",
+ "OutlineLevel9",
+ "OutlineLevel10",
+ "NumberingLevel1",
+ "NumberingLevel2",
+ "NumberingLevel3",
+ "NumberingLevel4",
+ "NumberingLevel5",
+ "NumberingLevel6",
+ "NumberingLevel7",
+ "NumberingLevel8",
+ "NumberingLevel9",
+ "NumberingLevel10"
+};
+
+sal_Int16 GetCommandContextIndex( const OUString &rContextName )
+{
+ sal_Int16 nRes = -1;
+ for (sal_Int16 i = 0; nRes == -1 && i < COND_COMMAND_COUNT; ++i)
+ {
+ if (rContextName.equalsAscii( aCommandContext[i] ))
+ nRes = i;
+ }
+ return nRes;
+}
+
+OUString GetCommandContextByIndex( sal_Int16 nIndex )
+{
+ OUString aRes;
+ if (0 <= nIndex && nIndex < COND_COMMAND_COUNT)
+ {
+ aRes = OUString::createFromAscii( aCommandContext[ nIndex ] );
+ }
+ return aRes;
+}
+
+// Globals ******************************************************************
+
+const CommandStruct SwCondCollItem::aCmds[] =
+{
+ { PARA_IN_TABLEHEAD, 0 },
+ { PARA_IN_TABLEBODY, 0 },
+ { PARA_IN_FRAME, 0 },
+ { PARA_IN_SECTION, 0 },
+ { PARA_IN_FOOTENOTE, 0 },
+ { PARA_IN_ENDNOTE, 0 },
+ { PARA_IN_HEADER, 0 },
+ { PARA_IN_FOOTER, 0 },
+ { PARA_IN_OUTLINE, 0 },
+ { PARA_IN_OUTLINE, 1 },
+ { PARA_IN_OUTLINE, 2 },
+ { PARA_IN_OUTLINE, 3 },
+ { PARA_IN_OUTLINE, 4 },
+ { PARA_IN_OUTLINE, 5 },
+ { PARA_IN_OUTLINE, 6 },
+ { PARA_IN_OUTLINE, 7 },
+ { PARA_IN_OUTLINE, 8 },
+ { PARA_IN_OUTLINE, 9 },
+ { PARA_IN_LIST, 0 },
+ { PARA_IN_LIST, 1 },
+ { PARA_IN_LIST, 2 },
+ { PARA_IN_LIST, 3 },
+ { PARA_IN_LIST, 4 },
+ { PARA_IN_LIST, 5 },
+ { PARA_IN_LIST, 6 },
+ { PARA_IN_LIST, 7 },
+ { PARA_IN_LIST, 8 },
+ { PARA_IN_LIST, 9 }
+};
+
+TYPEINIT1_AUTOFACTORY(SwCondCollItem, SfxPoolItem)
+
+/****************************************************************************
+ Item for the transport of the condition table
+****************************************************************************/
+
+SwCondCollItem::SwCondCollItem(sal_uInt16 _nWhich ) :
+ SfxPoolItem(_nWhich)
+{
+
+}
+
+SwCondCollItem::~SwCondCollItem()
+{
+}
+
+SfxPoolItem* SwCondCollItem::Clone( SfxItemPool * /*pPool*/ ) const
+{
+ return new SwCondCollItem(*this);
+}
+
+bool SwCondCollItem::operator==( const SfxPoolItem& rItem) const
+{
+ OSL_ENSURE( SfxPoolItem::operator==(rItem), "different types" );
+ sal_Bool bReturn = sal_True;
+ for(sal_uInt16 i = 0; i < COND_COMMAND_COUNT; i++)
+ if (m_sStyles[i] !=
+ static_cast<SwCondCollItem const&>(rItem).m_sStyles[i])
+ {
+ bReturn = sal_False;
+ break;
+ }
+
+ return bReturn;
+}
+
+OUString SwCondCollItem::GetStyle(sal_uInt16 const nPos) const
+{
+ return (nPos < COND_COMMAND_COUNT) ? m_sStyles[nPos] : OUString();
+}
+
+void
+SwCondCollItem::SetStyle(OUString const*const pStyle, sal_uInt16 const nPos)
+{
+ if( nPos < COND_COMMAND_COUNT )
+ m_sStyles[nPos] = (pStyle) ? *pStyle : OUString();
+}
+
+const CommandStruct* SwCondCollItem::GetCmds()
+{
+ return aCmds;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/config/barcfg.cxx b/sw/source/core/uibase/config/barcfg.cxx
new file mode 100644
index 000000000000..f9c4db5a81fd
--- /dev/null
+++ b/sw/source/core/uibase/config/barcfg.cxx
@@ -0,0 +1,127 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <osl/diagnose.h>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <wrtsh.hxx>
+#include "barcfg.hxx"
+
+#include <unomid.h>
+
+using namespace utl;
+using namespace com::sun::star::uno;
+
+#define SEL_TYPE_TABLE_TEXT 0
+#define SEL_TYPE_LIST_TEXT 1
+#define SEL_TYPE_TABLE_LIST 2
+#define SEL_TYPE_BEZIER 3
+#define SEL_TYPE_GRAPHIC 4
+
+SwToolbarConfigItem::SwToolbarConfigItem( bool bWeb ) :
+ ConfigItem(bWeb ? OUString("Office.WriterWeb/ObjectBar") : OUString("Office.Writer/ObjectBar"),
+ CONFIG_MODE_DELAYED_UPDATE|CONFIG_MODE_RELEASE_TREE)
+{
+ for(sal_uInt16 i = 0; i <= SEL_TYPE_GRAPHIC; i++ )
+ aTbxIdArray[i] = -1;
+
+ Sequence<OUString> aNames = GetPropertyNames();
+ Sequence<Any> aValues = GetProperties(aNames);
+ const Any* pValues = aValues.getConstArray();
+ OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
+ if(aValues.getLength() == aNames.getLength())
+ {
+ for(int nProp = 0; nProp < aNames.getLength(); nProp++)
+ {
+ if(pValues[nProp].hasValue())
+ {
+ sal_Int32 nVal = 0;
+ pValues[nProp] >>= nVal;
+ aTbxIdArray[nProp] = nVal;
+ }
+ }
+ }
+}
+
+SwToolbarConfigItem::~SwToolbarConfigItem()
+{
+}
+
+static sal_Int32 lcl_getArrayIndex(int nSelType)
+{
+ sal_Int32 nRet = -1;
+ if(nSelType & nsSelectionType::SEL_NUM)
+ {
+ if(nSelType & nsSelectionType::SEL_TBL)
+ nRet = SEL_TYPE_TABLE_LIST;
+ else
+ nRet = SEL_TYPE_LIST_TEXT;
+ }
+ else if(nSelType & nsSelectionType::SEL_TBL)
+ nRet = SEL_TYPE_TABLE_TEXT;
+ else if(nSelType & nsSelectionType::SEL_BEZ)
+ nRet = SEL_TYPE_BEZIER;
+ else if(nSelType & nsSelectionType::SEL_GRF)
+ nRet = SEL_TYPE_GRAPHIC;
+ return nRet;
+}
+
+void SwToolbarConfigItem::SetTopToolbar( sal_Int32 nSelType, sal_Int32 nBarId )
+{
+ sal_Int32 nProp = lcl_getArrayIndex(nSelType);
+ if(nProp >= 0)
+ {
+ aTbxIdArray[nProp] = nBarId;
+ SetModified();
+ }
+}
+
+Sequence<OUString> SwToolbarConfigItem::GetPropertyNames()
+{
+ static const char* aPropNames[] =
+ {
+ "Selection/Table", // SEL_TYPE_TABLE_TEXT
+ "Selection/NumberedList", // SEL_TYPE_LIST_TEXT
+ "Selection/NumberedList_InTable", // SEL_TYPE_TABLE_LIST
+ "Selection/BezierObject", // SEL_TYPE_BEZIER
+ "Selection/Graphic" //SEL_TYPE_GRAPHIC
+ };
+ const int nCount = 5;
+ Sequence<OUString> aNames(nCount);
+ OUString* pNames = aNames.getArray();
+ for(int i = 0; i < nCount; i++)
+ pNames[i] = OUString::createFromAscii(aPropNames[i]);
+ return aNames;
+}
+
+void SwToolbarConfigItem::Commit()
+{
+ Sequence<OUString> aNames = GetPropertyNames();
+
+ Sequence<Any> aValues(aNames.getLength());
+ Any* pValues = aValues.getArray();
+
+ for(int nProp = 0; nProp < aNames.getLength(); nProp++)
+ pValues[nProp] <<= aTbxIdArray[nProp];
+ PutProperties(aNames, aValues);
+}
+
+void SwToolbarConfigItem::Notify( const ::com::sun::star::uno::Sequence< OUString >& ) {}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/config/caption.cxx b/sw/source/core/uibase/config/caption.cxx
new file mode 100644
index 000000000000..76e1a0907b2f
--- /dev/null
+++ b/sw/source/core/uibase/config/caption.cxx
@@ -0,0 +1,76 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <osl/diagnose.h>
+
+#include "numrule.hxx"
+#include "caption.hxx"
+
+InsCaptionOpt::InsCaptionOpt(const SwCapObjType eType, const SvGlobalName* pOleId) :
+ bUseCaption(sal_False),
+ eObjType(eType),
+ nNumType(SVX_NUM_ARABIC),
+ sNumberSeparator((". ")),
+ nPos(1),
+ nLevel(0),
+ sSeparator( OUString(": ") ),
+ bIgnoreSeqOpts(false),
+ bCopyAttributes(sal_False)
+{
+ if (pOleId)
+ aOleId = *pOleId;
+}
+
+InsCaptionOpt::InsCaptionOpt(const InsCaptionOpt& rOpt)
+{
+ *this = rOpt;
+}
+
+InsCaptionOpt::~InsCaptionOpt()
+{
+}
+
+InsCaptionOpt& InsCaptionOpt::operator=( const InsCaptionOpt& rOpt )
+{
+ bUseCaption = rOpt.bUseCaption;
+ eObjType = rOpt.eObjType;
+ aOleId = rOpt.aOleId;
+ sCategory = rOpt.sCategory;
+ nNumType = rOpt.nNumType;
+ sNumberSeparator = rOpt.sNumberSeparator;
+ sCaption = rOpt.sCaption;
+ nPos = rOpt.nPos;
+ nLevel = rOpt.nLevel;
+ sSeparator = rOpt.sSeparator;
+ bIgnoreSeqOpts = rOpt.bIgnoreSeqOpts;
+ sCharacterStyle = rOpt.sCharacterStyle;
+ bCopyAttributes = rOpt.bCopyAttributes;
+
+ return *this;
+}
+
+bool InsCaptionOpt::operator==( const InsCaptionOpt& rOpt ) const
+{
+ return (eObjType == rOpt.eObjType &&
+ aOleId == rOpt.aOleId); // So that identical Ole-IDs can't be added multiple
+ // times, don't compare against anything else.
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/config/cfgitems.cxx b/sw/source/core/uibase/config/cfgitems.cxx
new file mode 100644
index 000000000000..7272f6c7000f
--- /dev/null
+++ b/sw/source/core/uibase/config/cfgitems.cxx
@@ -0,0 +1,358 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <basic/sbxvar.hxx>
+
+#include <svx/svxids.hrc>
+#include <editeng/svxenum.hxx>
+
+#include "viewopt.hxx"
+#include "swtypes.hxx"
+#include "cmdid.h"
+#include "prtopt.hxx"
+#include "cfgitems.hxx"
+#include "crstate.hxx"
+
+TYPEINIT1_AUTOFACTORY(SwDocDisplayItem, SfxPoolItem)
+TYPEINIT1_AUTOFACTORY(SwElemItem, SfxPoolItem)
+TYPEINIT1_AUTOFACTORY(SwAddPrinterItem, SfxPoolItem)
+TYPEINIT1_AUTOFACTORY(SwShadowCursorItem, SfxPoolItem)
+
+SwDocDisplayItem::SwDocDisplayItem( sal_uInt16 _nWhich ) :
+ SfxPoolItem(_nWhich),
+ aIndexBackgrndCol(COL_GRAY)
+{
+ bParagraphEnd =
+ bTab =
+ bSpace =
+ bNonbreakingSpace =
+ bSoftHyphen =
+ bFldHiddenText =
+ bCharHiddenText =
+ bManualBreak =
+ bShowHiddenPara = sal_False;
+
+};
+
+/*-------------------------------------------------------------------
+ Item for the Settings dialog, page document view
+--------------------------------------------------------------------*/
+SwDocDisplayItem::SwDocDisplayItem( const SwDocDisplayItem& rDocDisplayItem ):
+ SfxPoolItem(rDocDisplayItem)
+{
+ *this = rDocDisplayItem;
+};
+
+SwDocDisplayItem::SwDocDisplayItem(const SwViewOption& rVOpt, sal_uInt16 _nWhich ) :
+ SfxPoolItem( _nWhich )
+{
+ bParagraphEnd = rVOpt.IsParagraph(sal_True);
+ bTab = rVOpt.IsTab(sal_True);
+ bSpace = rVOpt.IsBlank(sal_True);
+ bNonbreakingSpace = rVOpt.IsHardBlank();
+ bSoftHyphen = rVOpt.IsSoftHyph();
+ bCharHiddenText = rVOpt.IsShowHiddenChar(sal_True);
+ bFldHiddenText = rVOpt.IsShowHiddenField();
+ bManualBreak = rVOpt.IsLineBreak(sal_True);
+ bShowHiddenPara = rVOpt.IsShowHiddenPara();
+}
+
+SfxPoolItem* SwDocDisplayItem::Clone( SfxItemPool* ) const
+{
+ return new SwDocDisplayItem( *this );
+}
+
+bool SwDocDisplayItem::operator==( const SfxPoolItem& rAttr ) const
+{
+ OSL_ENSURE( SfxPoolItem::operator==(rAttr), "different types" );
+
+ const SwDocDisplayItem& rItem = (SwDocDisplayItem&)rAttr;
+
+ return ( bParagraphEnd == rItem.bParagraphEnd &&
+ bTab == rItem.bTab &&
+ bSpace == rItem.bSpace &&
+ bNonbreakingSpace == rItem.bNonbreakingSpace &&
+ bSoftHyphen == rItem.bSoftHyphen &&
+ bCharHiddenText == rItem.bCharHiddenText &&
+ bFldHiddenText == rItem.bFldHiddenText &&
+ bManualBreak == rItem.bManualBreak &&
+ bShowHiddenPara == rItem.bShowHiddenPara );
+}
+
+void SwDocDisplayItem::operator=( const SwDocDisplayItem& rDocDisplayItem)
+{
+ bParagraphEnd = rDocDisplayItem.bParagraphEnd ;
+ bTab = rDocDisplayItem.bTab ;
+ bSpace = rDocDisplayItem.bSpace ;
+ bNonbreakingSpace = rDocDisplayItem.bNonbreakingSpace ;
+ bSoftHyphen = rDocDisplayItem.bSoftHyphen ;
+ bCharHiddenText = rDocDisplayItem.bCharHiddenText ;
+ bFldHiddenText = rDocDisplayItem.bFldHiddenText ;
+ bManualBreak = rDocDisplayItem.bManualBreak ;
+ bShowHiddenPara = rDocDisplayItem.bShowHiddenPara ;
+}
+
+void SwDocDisplayItem::FillViewOptions( SwViewOption& rVOpt) const
+{
+ rVOpt.SetParagraph (bParagraphEnd );
+ rVOpt.SetTab (bTab );
+ rVOpt.SetBlank (bSpace );
+ rVOpt.SetHardBlank (bNonbreakingSpace );
+ rVOpt.SetSoftHyph (bSoftHyphen );
+ rVOpt.SetShowHiddenChar(bCharHiddenText );
+ rVOpt.SetShowHiddenField(bFldHiddenText );
+ rVOpt.SetLineBreak (bManualBreak );
+ rVOpt.SetShowHiddenPara(bShowHiddenPara );
+}
+
+SwElemItem::SwElemItem( sal_uInt16 _nWhich ) :
+ SfxPoolItem(_nWhich)
+{
+ bHorzScrollbar =
+ bVertScrollbar =
+ bAnyRuler =
+ bHorzRuler =
+ bVertRuler =
+ bVertRulerRight=
+ bCrosshair =
+ bSmoothScroll =
+ bTable =
+ bGraphic =
+ bDrawing =
+ bFieldName =
+ bNotes = false;
+}
+
+SwElemItem::SwElemItem( const SwElemItem& rElemItem ):
+ SfxPoolItem(rElemItem)
+{
+ *this = rElemItem;
+}
+
+SwElemItem::SwElemItem(const SwViewOption& rVOpt, sal_uInt16 _nWhich) :
+ SfxPoolItem( _nWhich )
+{
+ bHorzScrollbar = rVOpt.IsViewHScrollBar();
+ bVertScrollbar = rVOpt.IsViewVScrollBar();
+ bAnyRuler = rVOpt.IsViewAnyRuler();
+ bHorzRuler = rVOpt.IsViewHRuler(sal_True);
+ bVertRuler = rVOpt.IsViewVRuler(sal_True);
+ bVertRulerRight = rVOpt.IsVRulerRight();
+ bCrosshair = rVOpt.IsCrossHair();
+ bSmoothScroll = rVOpt.IsSmoothScroll();
+ bTable = rVOpt.IsTable();
+ bGraphic = rVOpt.IsGraphic();
+ bDrawing = rVOpt.IsDraw() && rVOpt.IsControl();
+ bFieldName = rVOpt.IsFldName();
+ bNotes = rVOpt.IsPostIts();
+
+}
+
+SfxPoolItem* SwElemItem::Clone( SfxItemPool* ) const
+{
+ return new SwElemItem( *this );
+}
+
+bool SwElemItem::operator==( const SfxPoolItem& rAttr ) const
+{
+ OSL_ENSURE( SfxPoolItem::operator==(rAttr), "different types" );
+
+ const SwElemItem& rItem = (SwElemItem&)rAttr;
+
+ return ( bHorzScrollbar == rItem.bHorzScrollbar &&
+ bVertScrollbar == rItem.bVertScrollbar &&
+ bAnyRuler == rItem.bAnyRuler &&
+ bHorzRuler == rItem.bHorzRuler &&
+ bVertRuler == rItem.bVertRuler &&
+ bVertRulerRight == rItem.bVertRulerRight&&
+ bCrosshair == rItem.bCrosshair &&
+ bSmoothScroll == rItem.bSmoothScroll &&
+ bTable == rItem.bTable &&
+ bGraphic == rItem.bGraphic &&
+ bDrawing == rItem.bDrawing &&
+ bFieldName == rItem.bFieldName &&
+ bNotes == rItem.bNotes );
+}
+
+void SwElemItem::operator=( const SwElemItem& rElemItem)
+{
+ bHorzScrollbar = rElemItem. bHorzScrollbar ;
+ bVertScrollbar = rElemItem. bVertScrollbar ;
+ bAnyRuler = rElemItem. bAnyRuler;
+ bHorzRuler = rElemItem. bHorzRuler ;
+ bVertRuler = rElemItem. bVertRuler ;
+ bVertRulerRight = rElemItem. bVertRulerRight ;
+ bCrosshair = rElemItem. bCrosshair ;
+ bSmoothScroll = rElemItem. bSmoothScroll ;
+ bTable = rElemItem.bTable ;
+ bGraphic = rElemItem.bGraphic ;
+ bDrawing = rElemItem.bDrawing ;
+ bFieldName = rElemItem.bFieldName ;
+ bNotes = rElemItem.bNotes ;
+}
+
+void SwElemItem::FillViewOptions( SwViewOption& rVOpt) const
+{
+ rVOpt.SetViewHScrollBar(bHorzScrollbar );
+ rVOpt.SetViewVScrollBar(bVertScrollbar );
+ rVOpt.SetViewAnyRuler(bAnyRuler);
+ rVOpt.SetViewHRuler(bHorzRuler );
+ rVOpt.SetViewVRuler(bVertRuler );
+ rVOpt.SetVRulerRight(bVertRulerRight );
+ rVOpt.SetCrossHair(bCrosshair );
+ rVOpt.SetSmoothScroll(bSmoothScroll);
+ rVOpt.SetTable (bTable );
+ rVOpt.SetGraphic (bGraphic );
+ rVOpt.SetDraw (bDrawing );
+ rVOpt.SetControl (bDrawing );
+ rVOpt.SetFldName (bFieldName );
+ rVOpt.SetPostIts (bNotes );
+}
+
+/*--------------------------------------------------------------------
+ Description: CopyCTOR
+ --------------------------------------------------------------------*/
+SwAddPrinterItem::SwAddPrinterItem( const SwAddPrinterItem& rAddPrinterItem ):
+ SfxPoolItem(rAddPrinterItem),
+ SwPrintData( rAddPrinterItem )
+{
+}
+
+/*--------------------------------------------------------------------
+ Description: CTOR for empty Item
+ --------------------------------------------------------------------*/
+SwAddPrinterItem::SwAddPrinterItem( sal_uInt16 _nWhich):
+ SfxPoolItem(_nWhich)
+{
+}
+
+/*--------------------------------------------------------------------
+ Description: CTOR from SwPrintOptions
+ --------------------------------------------------------------------*/
+SwAddPrinterItem::SwAddPrinterItem( sal_uInt16 _nWhich, const SwPrintData& rPrtData ) :
+ SfxPoolItem(_nWhich)
+{
+ SwPrintData::operator=(rPrtData);
+}
+
+SfxPoolItem* SwAddPrinterItem::Clone( SfxItemPool* ) const
+{
+ return new SwAddPrinterItem( *this );
+}
+
+bool SwAddPrinterItem::operator==( const SfxPoolItem& rAttr ) const
+{
+ OSL_ENSURE( SfxPoolItem::operator==(rAttr), "different types" );
+
+ const SwAddPrinterItem& rItem = (SwAddPrinterItem&)rAttr;
+
+ return SwPrintData::operator==(rItem);
+}
+
+/*--------------------------------------------------
+ Item for Settings dialog, ShadowCursorPage
+--------------------------------------------------*/
+SwShadowCursorItem::SwShadowCursorItem( sal_uInt16 _nWhich )
+ : SfxPoolItem( _nWhich ),
+ eMode( FILL_TAB )
+ ,bOn( sal_False )
+{
+}
+
+SwShadowCursorItem::SwShadowCursorItem( const SwShadowCursorItem& rCpy )
+ : SfxPoolItem( rCpy.Which() ),
+ eMode( rCpy.GetMode() )
+ ,bOn( rCpy.IsOn() )
+
+{
+}
+
+SwShadowCursorItem::SwShadowCursorItem( const SwViewOption& rVOpt, sal_uInt16 _nWhich )
+ : SfxPoolItem( _nWhich ),
+ eMode( rVOpt.GetShdwCrsrFillMode() )
+ ,bOn( rVOpt.IsShadowCursor() )
+
+{
+}
+
+SfxPoolItem* SwShadowCursorItem::Clone( SfxItemPool* ) const
+{
+ return new SwShadowCursorItem( *this );
+}
+
+bool SwShadowCursorItem::operator==( const SfxPoolItem& rCmp ) const
+{
+ return IsOn() == ((SwShadowCursorItem&)rCmp).IsOn() &&
+ GetMode() == ((SwShadowCursorItem&)rCmp).GetMode();
+}
+
+void SwShadowCursorItem::operator=( const SwShadowCursorItem& rCpy )
+{
+ SetOn( rCpy.IsOn() );
+ SetMode( rCpy.GetMode() );
+}
+
+void SwShadowCursorItem::FillViewOptions( SwViewOption& rVOpt ) const
+{
+ rVOpt.SetShadowCursor( bOn );
+ rVOpt.SetShdwCrsrFillMode( eMode );
+}
+
+#ifdef DBG_UTIL
+SwTestItem::SwTestItem( const SwTestItem& rTestItem ):
+ SfxPoolItem(rTestItem)
+{
+ bTest1=rTestItem.bTest1;
+ bTest2=rTestItem.bTest2;
+ bTest3=rTestItem.bTest3;
+ bTest4=rTestItem.bTest4;
+ bTest5=rTestItem.bTest5;
+ bTest6=rTestItem.bTest6;
+ bTest7=rTestItem.bTest7;
+ bTest8=rTestItem.bTest8;
+ bTest9=rTestItem.bTest9;
+ bTest10=rTestItem.bTest10;
+};
+
+SfxPoolItem* SwTestItem::Clone( SfxItemPool* ) const
+{
+ return new SwTestItem( *this );
+}
+
+bool SwTestItem::operator==( const SfxPoolItem& rAttr ) const
+{
+ OSL_ENSURE( SfxPoolItem::operator==(rAttr), "different types" );
+
+ const SwTestItem& rItem = (const SwTestItem&) rAttr;
+
+ return ( bTest1==rItem.bTest1&&
+ bTest2==rItem.bTest2&&
+ bTest3==rItem.bTest3&&
+ bTest4==rItem.bTest4&&
+ bTest5==rItem.bTest5&&
+ bTest6==rItem.bTest6&&
+ bTest7==rItem.bTest7&&
+ bTest8==rItem.bTest8&&
+ bTest9==rItem.bTest9&&
+ bTest10==rItem.bTest10);
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/config/dbconfig.cxx b/sw/source/core/uibase/config/dbconfig.cxx
new file mode 100644
index 000000000000..19f802df42d5
--- /dev/null
+++ b/sw/source/core/uibase/config/dbconfig.cxx
@@ -0,0 +1,120 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <dbconfig.hxx>
+#include <osl/diagnose.h>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <swdbdata.hxx>
+
+#include <unomid.h>
+
+using namespace utl;
+using namespace com::sun::star::uno;
+
+/*--------------------------------------------------------------------
+ Description: Ctor
+ --------------------------------------------------------------------*/
+
+const Sequence<OUString>& SwDBConfig::GetPropertyNames()
+{
+ static Sequence<OUString> aNames;
+ if(!aNames.getLength())
+ {
+ static const char* aPropNames[] =
+ {
+ "AddressBook/DataSourceName", // 0
+ "AddressBook/Command", // 1
+ "AddressBook/CommandType", // 2
+ "Bibliography/CurrentDataSource/DataSourceName", // 4
+ "Bibliography/CurrentDataSource/Command", // 5
+ "Bibliography/CurrentDataSource/CommandType" // 6
+ };
+ const int nCount = sizeof(aPropNames)/sizeof(const char*);
+ aNames.realloc(nCount);
+ OUString* pNames = aNames.getArray();
+ for(int i = 0; i < nCount; i++)
+ pNames[i] = OUString::createFromAscii(aPropNames[i]);
+ }
+ return aNames;
+}
+
+SwDBConfig::SwDBConfig() :
+ ConfigItem("Office.DataAccess",
+ CONFIG_MODE_DELAYED_UPDATE|CONFIG_MODE_RELEASE_TREE),
+ pAdrImpl(0),
+ pBibImpl(0)
+{
+};
+
+SwDBConfig::~SwDBConfig()
+{
+ delete pAdrImpl;
+ delete pBibImpl;
+}
+
+void SwDBConfig::Load()
+{
+ const Sequence<OUString>& rNames = GetPropertyNames();
+ if(!pAdrImpl)
+ {
+
+ pAdrImpl = new SwDBData;
+ pAdrImpl->nCommandType = 0;
+ pBibImpl = new SwDBData;
+ pBibImpl->nCommandType = 0;
+ }
+ Sequence<Any> aValues = GetProperties(rNames);
+ const Any* pValues = aValues.getConstArray();
+ OSL_ENSURE(aValues.getLength() == rNames.getLength(), "GetProperties failed");
+ if(aValues.getLength() == rNames.getLength())
+ {
+ for(int nProp = 0; nProp < rNames.getLength(); nProp++)
+ {
+ switch(nProp)
+ {
+ case 0: pValues[nProp] >>= pAdrImpl->sDataSource; break;
+ case 1: pValues[nProp] >>= pAdrImpl->sCommand; break;
+ case 2: pValues[nProp] >>= pAdrImpl->nCommandType; break;
+ case 3: pValues[nProp] >>= pBibImpl->sDataSource; break;
+ case 4: pValues[nProp] >>= pBibImpl->sCommand; break;
+ case 5: pValues[nProp] >>= pBibImpl->nCommandType; break;
+ }
+ }
+ }
+}
+
+const SwDBData& SwDBConfig::GetAddressSource()
+{
+ if(!pAdrImpl)
+ Load();
+ return *pAdrImpl;
+}
+
+const SwDBData& SwDBConfig::GetBibliographySource()
+{
+ if(!pBibImpl)
+ Load();
+ return *pBibImpl;
+}
+
+void SwDBConfig::Commit() {}
+void SwDBConfig::Notify( const ::com::sun::star::uno::Sequence< OUString >& ) {}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/config/fontcfg.cxx b/sw/source/core/uibase/config/fontcfg.cxx
new file mode 100644
index 000000000000..35d84ab36034
--- /dev/null
+++ b/sw/source/core/uibase/config/fontcfg.cxx
@@ -0,0 +1,320 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <fontcfg.hxx>
+#include <i18nlangtag/mslangid.hxx>
+#include <vcl/outdev.hxx>
+#include <unotools/lingucfg.hxx>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/i18n/ScriptType.hpp>
+#include <swtypes.hxx>
+
+#include <unomid.h>
+
+using namespace utl;
+using namespace com::sun::star::uno;
+
+static inline LanguageType lcl_LanguageOfType(sal_Int16 nType, sal_Int16 eWestern, sal_Int16 eCJK, sal_Int16 eCTL)
+{
+ return LanguageType(
+ nType < FONT_STANDARD_CJK ? eWestern :
+ nType >= FONT_STANDARD_CTL ? eCTL : eCJK);
+}
+
+Sequence<OUString> SwStdFontConfig::GetPropertyNames()
+{
+ Sequence<OUString> aNames;
+ if(!aNames.getLength())
+ {
+ static const char* aPropNames[] =
+ {
+ "DefaultFont/Standard", // 0
+ "DefaultFont/Heading", // 1
+ "DefaultFont/List", // 2
+ "DefaultFont/Caption", // 3
+ "DefaultFont/Index", // 4
+ "DefaultFontCJK/Standard", // 5
+ "DefaultFontCJK/Heading", // 6
+ "DefaultFontCJK/List", // 7
+ "DefaultFontCJK/Caption", // 8
+ "DefaultFontCJK/Index", // 9
+ "DefaultFontCTL/Standard", // 10
+ "DefaultFontCTL/Heading", // 11
+ "DefaultFontCTL/List", // 12
+ "DefaultFontCTL/Caption", // 13
+ "DefaultFontCTL/Index", // 14
+ "DefaultFont/StandardHeight", // 15
+ "DefaultFont/HeadingHeight", // 16
+ "DefaultFont/ListHeight", // 17
+ "DefaultFont/CaptionHeight", // 18
+ "DefaultFont/IndexHeight", // 19
+ "DefaultFontCJK/StandardHeight", // 20
+ "DefaultFontCJK/HeadingHeight", // 21
+ "DefaultFontCJK/ListHeight", // 22
+ "DefaultFontCJK/CaptionHeight", // 23
+ "DefaultFontCJK/IndexHeight", // 24
+ "DefaultFontCTL/StandardHeight", // 25
+ "DefaultFontCTL/HeadingHeight", // 26
+ "DefaultFontCTL/ListHeight", // 27
+ "DefaultFontCTL/CaptionHeight", // 28
+ "DefaultFontCTL/IndexHeight" // 29
+ };
+ const int nCount = sizeof(aPropNames)/sizeof(const char*);
+ aNames.realloc(nCount);
+ OUString* pNames = aNames.getArray();
+ for(int i = 0; i < nCount; i++)
+ {
+ pNames[i] = OUString::createFromAscii(aPropNames[i]);
+ }
+ }
+ return aNames;
+}
+
+SwStdFontConfig::SwStdFontConfig() :
+ utl::ConfigItem("Office.Writer")
+{
+ SvtLinguOptions aLinguOpt;
+
+ SvtLinguConfig().GetOptions( aLinguOpt );
+
+ sal_Int16 eWestern = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage, ::com::sun::star::i18n::ScriptType::LATIN),
+ eCJK = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CJK, ::com::sun::star::i18n::ScriptType::ASIAN),
+ eCTL = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CTL, ::com::sun::star::i18n::ScriptType::COMPLEX);
+
+ for(sal_Int16 i = 0; i < DEF_FONT_COUNT; i++)
+ {
+ sDefaultFonts[i] = GetDefaultFor(i,
+ lcl_LanguageOfType(i, eWestern, eCJK, eCTL));
+ nDefaultFontHeight[i] = -1;
+ }
+
+ Sequence<OUString> aNames = GetPropertyNames();
+ Sequence<Any> aValues = GetProperties(aNames);
+ const Any* pValues = aValues.getConstArray();
+ OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
+ if(aValues.getLength() == aNames.getLength())
+ {
+ for(int nProp = 0; nProp < aNames.getLength(); nProp++)
+ {
+ if(pValues[nProp].hasValue())
+ {
+ if( nProp < DEF_FONT_COUNT)
+ {
+ OUString sVal;
+ pValues[nProp] >>= sVal;
+ sDefaultFonts[nProp] = sVal;
+ }
+ else
+ {
+ pValues[nProp] >>= nDefaultFontHeight[nProp - DEF_FONT_COUNT];
+ nDefaultFontHeight[nProp - DEF_FONT_COUNT] = MM100_TO_TWIP(nDefaultFontHeight[nProp - DEF_FONT_COUNT]);
+ }
+ }
+ }
+ }
+}
+
+void SwStdFontConfig::Commit()
+{
+ Sequence<OUString> aNames = GetPropertyNames();
+ Sequence<Any> aValues(aNames.getLength());
+ Any* pValues = aValues.getArray();
+ SvtLinguOptions aLinguOpt;
+
+ SvtLinguConfig().GetOptions( aLinguOpt );
+
+ sal_Int16 eWestern = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage, ::com::sun::star::i18n::ScriptType::LATIN),
+ eCJK = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CJK, ::com::sun::star::i18n::ScriptType::ASIAN),
+ eCTL = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CTL, ::com::sun::star::i18n::ScriptType::COMPLEX);
+
+ for(sal_uInt16 nProp = 0;
+ nProp < sal::static_int_cast< sal_uInt16, sal_Int32 >( aNames.getLength() );
+ nProp++)
+ {
+ if( nProp < DEF_FONT_COUNT )
+ {
+ if(GetDefaultFor(nProp, lcl_LanguageOfType(nProp, eWestern, eCJK, eCTL)) != sDefaultFonts[nProp])
+ pValues[nProp] <<= OUString(sDefaultFonts[nProp]);
+ }
+ else
+ {
+ if(nDefaultFontHeight[nProp - DEF_FONT_COUNT] > 0)
+ pValues[nProp] <<= static_cast<sal_Int32>(TWIP_TO_MM100(nDefaultFontHeight[nProp - DEF_FONT_COUNT]));
+ }
+ }
+ PutProperties(aNames, aValues);
+}
+
+SwStdFontConfig::~SwStdFontConfig()
+{
+}
+
+bool SwStdFontConfig::IsFontDefault(sal_uInt16 nFontType) const
+{
+ bool bSame = false;
+ SvtLinguOptions aLinguOpt;
+
+ SvtLinguConfig().GetOptions( aLinguOpt );
+
+ sal_Int16 eWestern = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage, ::com::sun::star::i18n::ScriptType::LATIN),
+ eCJK = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CJK, ::com::sun::star::i18n::ScriptType::ASIAN),
+ eCTL = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CTL, ::com::sun::star::i18n::ScriptType::COMPLEX);
+
+ OUString sDefFont(GetDefaultFor(FONT_STANDARD, eWestern));
+ OUString sDefFontCJK(GetDefaultFor(FONT_STANDARD_CJK, eCJK));
+ OUString sDefFontCTL(GetDefaultFor(FONT_STANDARD_CTL, eCTL));
+ LanguageType eLang = lcl_LanguageOfType(nFontType, eWestern, eCJK, eCTL);
+ switch( nFontType )
+ {
+ case FONT_STANDARD:
+ bSame = sDefaultFonts[nFontType] == sDefFont;
+ break;
+ case FONT_STANDARD_CJK:
+ bSame = sDefaultFonts[nFontType] == sDefFontCJK;
+ break;
+ case FONT_STANDARD_CTL:
+ bSame = sDefaultFonts[nFontType] == sDefFontCTL;
+ break;
+ case FONT_OUTLINE :
+ case FONT_OUTLINE_CJK :
+ case FONT_OUTLINE_CTL :
+ bSame = sDefaultFonts[nFontType] ==
+ GetDefaultFor(nFontType, eLang);
+ break;
+ case FONT_LIST :
+ case FONT_CAPTION :
+ case FONT_INDEX :
+ bSame = sDefaultFonts[nFontType] == sDefFont &&
+ sDefaultFonts[FONT_STANDARD] == sDefFont;
+ break;
+ case FONT_LIST_CJK :
+ case FONT_CAPTION_CJK :
+ case FONT_INDEX_CJK :
+ {
+ bool b1 = sDefaultFonts[FONT_STANDARD_CJK] == sDefFontCJK;
+ bSame = b1 && sDefaultFonts[nFontType] == sDefFontCJK;
+ }
+ break;
+ case FONT_LIST_CTL :
+ case FONT_CAPTION_CTL :
+ case FONT_INDEX_CTL :
+ {
+ bool b1 = sDefaultFonts[FONT_STANDARD_CJK] == sDefFontCTL;
+ bSame = b1 && sDefaultFonts[nFontType] == sDefFontCTL;
+ }
+ break;
+ }
+ return bSame;
+}
+
+OUString SwStdFontConfig::GetDefaultFor(sal_uInt16 nFontType, LanguageType eLang)
+{
+ sal_uInt16 nFontId;
+ switch( nFontType )
+ {
+ case FONT_OUTLINE :
+ nFontId = DEFAULTFONT_LATIN_HEADING;
+ break;
+ case FONT_OUTLINE_CJK :
+ nFontId = DEFAULTFONT_CJK_HEADING;
+ break;
+ case FONT_OUTLINE_CTL :
+ nFontId = DEFAULTFONT_CTL_HEADING;
+ break;
+ case FONT_STANDARD_CJK:
+ case FONT_LIST_CJK :
+ case FONT_CAPTION_CJK :
+ case FONT_INDEX_CJK :
+ nFontId = DEFAULTFONT_CJK_TEXT;
+ break;
+ case FONT_STANDARD_CTL:
+ case FONT_LIST_CTL :
+ case FONT_CAPTION_CTL :
+ case FONT_INDEX_CTL :
+ nFontId = DEFAULTFONT_CTL_TEXT;
+ break;
+ default:
+ nFontId = DEFAULTFONT_LATIN_TEXT;
+ }
+ Font aFont = OutputDevice::GetDefaultFont(nFontId, eLang, DEFAULTFONT_FLAGS_ONLYONE);
+ return aFont.GetName();
+}
+
+sal_Int32 SwStdFontConfig::GetDefaultHeightFor(sal_uInt16 nFontType, LanguageType eLang)
+{
+ sal_Int32 nRet = FONTSIZE_DEFAULT;
+ switch( nFontType )
+ {
+ case FONT_OUTLINE:
+ case FONT_OUTLINE_CJK:
+ case FONT_OUTLINE_CTL:
+ nRet = FONTSIZE_OUTLINE;
+ break;
+ case FONT_STANDARD_CJK:
+ nRet = FONTSIZE_CJK_DEFAULT;
+ break;
+ }
+ if( eLang == LANGUAGE_THAI && nFontType >= FONT_STANDARD_CTL )
+ {
+ nRet = nRet * 4 / 3;
+ }
+ return nRet;
+}
+
+void SwStdFontConfig::ChangeInt( sal_uInt16 nFontType, sal_Int32 nHeight )
+{
+ OSL_ENSURE( nFontType < DEF_FONT_COUNT, "invalid index in SwStdFontConfig::ChangInt()");
+ if( nFontType < DEF_FONT_COUNT && nDefaultFontHeight[nFontType] != nHeight)
+ {
+ SvtLinguOptions aLinguOpt;
+ SvtLinguConfig().GetOptions( aLinguOpt );
+
+ sal_Int16 eWestern = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage, ::com::sun::star::i18n::ScriptType::LATIN),
+ eCJK = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CJK, ::com::sun::star::i18n::ScriptType::ASIAN),
+ eCTL = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CTL, ::com::sun::star::i18n::ScriptType::COMPLEX);
+
+ // #i92090# default height value sets back to -1
+ const sal_Int32 nDefaultHeight = GetDefaultHeightFor(nFontType, lcl_LanguageOfType(nFontType, eWestern, eCJK, eCTL));
+ const bool bIsDefaultHeight = nHeight == nDefaultHeight;
+ if( bIsDefaultHeight && nDefaultFontHeight[nFontType] > 0 )
+ {
+ SetModified();
+ nDefaultFontHeight[nFontType] = -1;
+ }
+ else if( !bIsDefaultHeight && nHeight != nDefaultFontHeight[nFontType] )
+ {
+ SetModified();
+ nDefaultFontHeight[nFontType] = nHeight;
+ }
+ }
+}
+
+sal_Int32 SwStdFontConfig::GetFontHeight( sal_uInt8 nFont, sal_uInt8 nScriptType, LanguageType eLang )
+{
+ OSL_ENSURE(nFont + FONT_PER_GROUP * nScriptType < DEF_FONT_COUNT, "wrong index in SwStdFontConfig::GetFontHeight()");
+ sal_Int32 nRet = nDefaultFontHeight[nFont + FONT_PER_GROUP * nScriptType];
+ if(nRet <= 0)
+ return GetDefaultHeightFor(nFont + FONT_PER_GROUP * nScriptType, eLang);
+ return nRet;
+}
+
+void SwStdFontConfig::Notify( const ::com::sun::star::uno::Sequence< OUString >& ) {}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/config/modcfg.cxx b/sw/source/core/uibase/config/modcfg.cxx
new file mode 100644
index 000000000000..211b34ad1080
--- /dev/null
+++ b/sw/source/core/uibase/config/modcfg.cxx
@@ -0,0 +1,1398 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <hintids.hxx>
+#include <comphelper/classids.hxx>
+#include <tools/stream.hxx>
+#include <vcl/svapp.hxx>
+#include <svl/mailenum.hxx>
+#include <svx/svxids.hrc>
+#include <editeng/svxenum.hxx>
+#include <osl/diagnose.h>
+
+#include <tools/globname.hxx>
+#include <swtypes.hxx>
+#include <itabenum.hxx>
+#include <modcfg.hxx>
+#include <fldupde.hxx>
+#include <unotools/syslocaleoptions.hxx>
+#include <caption.hxx>
+#include <com/sun/star/uno/Any.hxx>
+
+#include <unomid.h>
+
+using namespace utl;
+using namespace com::sun::star::uno;
+
+#define GLOB_NAME_CALC 0
+#define GLOB_NAME_IMPRESS 1
+#define GLOB_NAME_DRAW 2
+#define GLOB_NAME_MATH 3
+#define GLOB_NAME_CHART 4
+
+InsCaptionOpt* InsCaptionOptArr::Find(const SwCapObjType eType, const SvGlobalName *pOleId)
+{
+ for (InsCapOptArr::iterator aI = m_aInsCapOptArr.begin(); aI != m_aInsCapOptArr.end(); ++aI)
+ {
+ InsCaptionOpt &rObj = *aI;
+ if (rObj.GetObjType() == eType && (eType != OLE_CAP || (pOleId && rObj.GetOleId() == *pOleId)))
+ return &rObj;
+ }
+
+ return NULL;
+}
+
+void InsCaptionOptArr::Insert(InsCaptionOpt* pObj)
+{
+ m_aInsCapOptArr.push_back(pObj); //takes ownership
+}
+
+const InsCaptionOpt* SwModuleOptions::GetCapOption(
+ sal_Bool bHTML, const SwCapObjType eType, const SvGlobalName *pOleId)
+{
+ if(bHTML)
+ {
+ OSL_FAIL("no caption option in sw/web!");
+ return 0;
+ }
+ else
+ {
+ if(eType == OLE_CAP && pOleId)
+ {
+ bool bFound = false;
+ for( sal_uInt16 nId = 0; nId <= GLOB_NAME_CHART && !bFound; nId++)
+ bFound = *pOleId == aInsertConfig.aGlobalNames[nId ];
+ if(!bFound)
+ return aInsertConfig.pOLEMiscOpt;
+ }
+ return aInsertConfig.pCapOptions->Find(eType, pOleId);
+ }
+}
+
+sal_Bool SwModuleOptions::SetCapOption(sal_Bool bHTML, const InsCaptionOpt* pOpt)
+{
+ sal_Bool bRet = sal_False;
+
+ if(bHTML)
+ {
+ OSL_FAIL("no caption option in sw/web!");
+ }
+ else if (pOpt)
+ {
+ if(pOpt->GetObjType() == OLE_CAP && &pOpt->GetOleId())
+ {
+ bool bFound = false;
+ for( sal_uInt16 nId = 0; nId <= GLOB_NAME_CHART; nId++)
+ bFound = pOpt->GetOleId() == aInsertConfig.aGlobalNames[nId ];
+ if(!bFound)
+ {
+ if(aInsertConfig.pOLEMiscOpt)
+ *aInsertConfig.pOLEMiscOpt = *pOpt;
+ else
+ aInsertConfig.pOLEMiscOpt = new InsCaptionOpt(*pOpt);
+ }
+ }
+
+ InsCaptionOptArr& rArr = *aInsertConfig.pCapOptions;
+ InsCaptionOpt *pObj = rArr.Find(pOpt->GetObjType(), &pOpt->GetOleId());
+
+ if (pObj)
+ {
+ *pObj = *pOpt;
+ }
+ else
+ rArr.Insert(new InsCaptionOpt(*pOpt));
+
+ aInsertConfig.SetModified();
+ bRet = sal_True;
+ }
+
+ return bRet;
+}
+
+SwModuleOptions::SwModuleOptions() :
+ aInsertConfig(sal_False),
+ aWebInsertConfig(sal_True),
+ aTableConfig(sal_False),
+ aWebTableConfig(sal_True),
+ bHideFieldTips(sal_False)
+{
+}
+
+OUString SwModuleOptions::ConvertWordDelimiter(const OUString& rDelim, sal_Bool bFromUI)
+{
+ OUString sReturn;
+ const sal_Int32 nDelimLen = rDelim.getLength();
+ if(bFromUI)
+ {
+ for (sal_Int32 i = 0; i < nDelimLen; )
+ {
+ const sal_Unicode c = rDelim[i++];
+
+ if (c == '\\' && i < nDelimLen )
+ {
+ switch (rDelim[i++])
+ {
+ case 'n': sReturn += "\n"; break;
+ case 't': sReturn += "\t"; break;
+ case '\\': sReturn += "\\"; break;
+
+ case 'x':
+ {
+ sal_Unicode nChar = 0;
+ bool bValidData = true;
+ for( sal_Int32 n = 0; n < 2 && i < nDelimLen; ++n, ++i )
+ {
+ sal_Unicode nVal = rDelim[i];
+ if( (nVal >= '0') && ( nVal <= '9') )
+ nVal -= '0';
+ else if( (nVal >= 'A') && (nVal <= 'F') )
+ nVal -= 'A' - 10;
+ else if( (nVal >= 'a') && (nVal <= 'f') )
+ nVal -= 'a' - 10;
+ else
+ {
+ OSL_FAIL("wrong hex value" );
+ bValidData = false;
+ break;
+ }
+
+ nChar <<= 4;
+ nChar += nVal;
+ }
+ if( bValidData )
+ sReturn += OUString(nChar);
+ break;
+ }
+
+ default: // Unknown, so insert backslash
+ sReturn += "\\";
+ i--;
+ break;
+ }
+ }
+ else
+ sReturn += OUString(c);
+ }
+ }
+ else
+ {
+ for (sal_Int32 i = 0; i < nDelimLen; ++i)
+ {
+ const sal_Unicode c = rDelim[i];
+
+ switch (c)
+ {
+ case '\n': sReturn += "\\n"; break;
+ case '\t': sReturn += "\\t"; break;
+ case '\\': sReturn += "\\\\"; break;
+
+ default:
+ if( c <= 0x1f || c >= 0x7f )
+ {
+ sReturn += "\\x" + OUString::number( c, 16 );
+ }
+ else
+ {
+ sReturn += OUString(c);
+ }
+ }
+ }
+ }
+ return sReturn;
+}
+
+const Sequence<OUString>& SwRevisionConfig::GetPropertyNames()
+{
+ static Sequence<OUString> aNames;
+ if(!aNames.getLength())
+ {
+ const int nCount = 8;
+ aNames.realloc(nCount);
+ static const char* aPropNames[] =
+ {
+ "TextDisplay/Insert/Attribute", // 0
+ "TextDisplay/Insert/Color", // 1
+ "TextDisplay/Delete/Attribute", // 2
+ "TextDisplay/Delete/Color", // 3
+ "TextDisplay/ChangedAttribute/Attribute", // 4
+ "TextDisplay/ChangedAttribute/Color", // 5
+ "LinesChanged/Mark", // 6
+ "LinesChanged/Color" // 7
+ };
+ OUString* pNames = aNames.getArray();
+ for(int i = 0; i < nCount; i++)
+ pNames[i] = OUString::createFromAscii(aPropNames[i]);
+ }
+ return aNames;
+}
+
+SwRevisionConfig::SwRevisionConfig() :
+ ConfigItem("Office.Writer/Revision",
+ CONFIG_MODE_DELAYED_UPDATE|CONFIG_MODE_RELEASE_TREE)
+{
+ aInsertAttr.nItemId = SID_ATTR_CHAR_UNDERLINE;
+ aInsertAttr.nAttr = UNDERLINE_SINGLE;
+ aInsertAttr.nColor = COL_TRANSPARENT;
+ aDeletedAttr.nItemId = SID_ATTR_CHAR_STRIKEOUT;
+ aDeletedAttr.nAttr = STRIKEOUT_SINGLE;
+ aDeletedAttr.nColor = COL_TRANSPARENT;
+ aFormatAttr.nItemId = SID_ATTR_CHAR_WEIGHT;
+ aFormatAttr.nAttr = WEIGHT_BOLD;
+ aFormatAttr.nColor = COL_BLACK;
+
+ Load();
+}
+
+SwRevisionConfig::~SwRevisionConfig()
+{
+}
+
+static sal_Int32 lcl_ConvertAttrToCfg(const AuthorCharAttr& rAttr)
+{
+ sal_Int32 nRet = 0;
+ switch(rAttr.nItemId)
+ {
+ case SID_ATTR_CHAR_WEIGHT: nRet = 1; break;
+ case SID_ATTR_CHAR_POSTURE: nRet = 2; break;
+ case SID_ATTR_CHAR_UNDERLINE: nRet = UNDERLINE_SINGLE == rAttr.nAttr ? 3 : 4; break;
+ case SID_ATTR_CHAR_STRIKEOUT: nRet = 3; break;
+ case SID_ATTR_CHAR_CASEMAP:
+ {
+ switch(rAttr.nAttr)
+ {
+ case SVX_CASEMAP_VERSALIEN : nRet = 5;break;
+ case SVX_CASEMAP_GEMEINE : nRet = 6;break;
+ case SVX_CASEMAP_KAPITAELCHEN: nRet = 7;break;
+ case SVX_CASEMAP_TITEL : nRet = 8;break;
+ }
+ }
+ break;
+ case SID_ATTR_BRUSH : nRet = 9; break;
+ }
+ return nRet;
+}
+
+void SwRevisionConfig::Notify( const ::com::sun::star::uno::Sequence< OUString >& ) {}
+
+void SwRevisionConfig::Commit()
+{
+ const Sequence<OUString>& aNames = GetPropertyNames();
+ Sequence<Any> aValues(aNames.getLength());
+ Any* pValues = aValues.getArray();
+
+ for(int nProp = 0; nProp < aNames.getLength(); nProp++)
+ {
+ sal_Int32 nVal = -1;
+ switch(nProp)
+ {
+ case 0 : nVal = lcl_ConvertAttrToCfg(aInsertAttr); break;
+ case 1 : nVal = aInsertAttr.nColor ; break;
+ case 2 : nVal = lcl_ConvertAttrToCfg(aDeletedAttr); break;
+ case 3 : nVal = aDeletedAttr.nColor ; break;
+ case 4 : nVal = lcl_ConvertAttrToCfg(aFormatAttr); break;
+ case 5 : nVal = aFormatAttr.nColor ; break;
+ case 6 : nVal = nMarkAlign ; break;
+ case 7 : nVal = aMarkColor.GetColor(); break;
+ }
+ pValues[nProp] <<= nVal;
+ }
+ PutProperties(aNames, aValues);
+}
+
+static void lcl_ConvertCfgToAttr(sal_Int32 nVal, AuthorCharAttr& rAttr, bool bDelete = false)
+{
+ rAttr.nItemId = rAttr.nAttr = 0;
+ switch(nVal)
+ {
+ case 1: rAttr.nItemId = SID_ATTR_CHAR_WEIGHT; rAttr.nAttr = WEIGHT_BOLD ; break;
+ case 2: rAttr.nItemId = SID_ATTR_CHAR_POSTURE; rAttr.nAttr = ITALIC_NORMAL ; break;
+ case 3: if(bDelete)
+ {
+ rAttr.nItemId = SID_ATTR_CHAR_STRIKEOUT;
+ rAttr.nAttr = STRIKEOUT_SINGLE;
+ }
+ else
+ {
+ rAttr.nItemId = SID_ATTR_CHAR_UNDERLINE;
+ rAttr.nAttr = UNDERLINE_SINGLE;
+ }
+ break;
+ case 4: rAttr.nItemId = SID_ATTR_CHAR_UNDERLINE;rAttr.nAttr = UNDERLINE_DOUBLE ; break;
+ case 5: rAttr.nItemId = SID_ATTR_CHAR_CASEMAP; rAttr.nAttr = SVX_CASEMAP_VERSALIEN ; break;
+ case 6: rAttr.nItemId = SID_ATTR_CHAR_CASEMAP; rAttr.nAttr = SVX_CASEMAP_GEMEINE ; break;
+ case 7: rAttr.nItemId = SID_ATTR_CHAR_CASEMAP; rAttr.nAttr = SVX_CASEMAP_KAPITAELCHEN ; break;
+ case 8: rAttr.nItemId = SID_ATTR_CHAR_CASEMAP; rAttr.nAttr = SVX_CASEMAP_TITEL ; break;
+ case 9: rAttr.nItemId = SID_ATTR_BRUSH; break;
+ }
+}
+void SwRevisionConfig::Load()
+{
+ const Sequence<OUString>& aNames = GetPropertyNames();
+ Sequence<Any> aValues = GetProperties(aNames);
+ const Any* pValues = aValues.getConstArray();
+ OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
+ if(aValues.getLength() == aNames.getLength())
+ {
+ for(int nProp = 0; nProp < aNames.getLength(); nProp++)
+ {
+ if(pValues[nProp].hasValue())
+ {
+ sal_Int32 nVal = 0;
+ pValues[nProp] >>= nVal;
+ switch(nProp)
+ {
+ case 0 : lcl_ConvertCfgToAttr(nVal, aInsertAttr); break;
+ case 1 : aInsertAttr.nColor = nVal; break;
+ case 2 : lcl_ConvertCfgToAttr(nVal, aDeletedAttr, true); break;
+ case 3 : aDeletedAttr.nColor = nVal; break;
+ case 4 : lcl_ConvertCfgToAttr(nVal, aFormatAttr); break;
+ case 5 : aFormatAttr.nColor = nVal; break;
+ case 6 : nMarkAlign = sal::static_int_cast< sal_uInt16, sal_Int32>(nVal); break;
+ case 7 : aMarkColor.SetColor(nVal); break;
+ }
+ }
+ }
+ }
+}
+
+enum InsertConfigProp
+{
+ INS_PROP_TABLE_HEADER = 0,
+ INS_PROP_TABLE_REPEATHEADER, // 1
+ INS_PROP_TABLE_BORDER, // 2
+ INS_PROP_TABLE_SPLIT, // 3 from here not in writer/web
+ INS_PROP_CAP_AUTOMATIC, // 4
+ INS_PROP_CAP_CAPTIONORDERNUMBERINGFIRST, // 5
+ INS_PROP_CAP_OBJECT_TABLE_ENABLE, // 6
+ INS_PROP_CAP_OBJECT_TABLE_CATEGORY, // 7
+ INS_PROP_CAP_OBJECT_TABLE_NUMBERING, // 8
+ INS_PROP_CAP_OBJECT_TABLE_NUMBERINGSEPARATOR, // 9
+ INS_PROP_CAP_OBJECT_TABLE_CAPTIONTEXT, //10
+ INS_PROP_CAP_OBJECT_TABLE_DELIMITER, //11
+ INS_PROP_CAP_OBJECT_TABLE_LEVEL, //12
+ INS_PROP_CAP_OBJECT_TABLE_POSITION, //13
+ INS_PROP_CAP_OBJECT_TABLE_CHARACTERSTYLE, //14
+ INS_PROP_CAP_OBJECT_FRAME_ENABLE, //15
+ INS_PROP_CAP_OBJECT_FRAME_CATEGORY, //16
+ INS_PROP_CAP_OBJECT_FRAME_NUMBERING, //17
+ INS_PROP_CAP_OBJECT_FRAME_NUMBERINGSEPARATOR, //18
+ INS_PROP_CAP_OBJECT_FRAME_CAPTIONTEXT, //19
+ INS_PROP_CAP_OBJECT_FRAME_DELIMITER, //20
+ INS_PROP_CAP_OBJECT_FRAME_LEVEL, //21
+ INS_PROP_CAP_OBJECT_FRAME_POSITION, //22
+ INS_PROP_CAP_OBJECT_FRAME_CHARACTERSTYLE, //23
+ INS_PROP_CAP_OBJECT_GRAPHIC_ENABLE, //24
+ INS_PROP_CAP_OBJECT_GRAPHIC_CATEGORY, //25
+ INS_PROP_CAP_OBJECT_GRAPHIC_NUMBERING, //26
+ INS_PROP_CAP_OBJECT_GRAPHIC_NUMBERINGSEPARATOR, //27
+ INS_PROP_CAP_OBJECT_GRAPHIC_CAPTIONTEXT, //28
+ INS_PROP_CAP_OBJECT_GRAPHIC_DELIMITER, //29
+ INS_PROP_CAP_OBJECT_GRAPHIC_LEVEL, //30
+ INS_PROP_CAP_OBJECT_GRAPHIC_POSITION, //31
+ INS_PROP_CAP_OBJECT_GRAPHIC_CHARACTERSTYLE, //32
+ INS_PROP_CAP_OBJECT_GRAPHIC_APPLYATTRIBUTES, //33
+ INS_PROP_CAP_OBJECT_CALC_ENABLE, //34
+ INS_PROP_CAP_OBJECT_CALC_CATEGORY, //35
+ INS_PROP_CAP_OBJECT_CALC_NUMBERING, //36
+ INS_PROP_CAP_OBJECT_CALC_NUMBERINGSEPARATOR, //37
+ INS_PROP_CAP_OBJECT_CALC_CAPTIONTEXT, //38
+ INS_PROP_CAP_OBJECT_CALC_DELIMITER, //39
+ INS_PROP_CAP_OBJECT_CALC_LEVEL, //40
+ INS_PROP_CAP_OBJECT_CALC_POSITION, //41
+ INS_PROP_CAP_OBJECT_CALC_CHARACTERSTYLE, //42
+ INS_PROP_CAP_OBJECT_CALC_APPLYATTRIBUTES, //43
+ INS_PROP_CAP_OBJECT_IMPRESS_ENABLE, //44
+ INS_PROP_CAP_OBJECT_IMPRESS_CATEGORY, //45
+ INS_PROP_CAP_OBJECT_IMPRESS_NUMBERING, //46
+ INS_PROP_CAP_OBJECT_IMPRESS_NUMBERINGSEPARATOR, //47
+ INS_PROP_CAP_OBJECT_IMPRESS_CAPTIONTEXT, //48
+ INS_PROP_CAP_OBJECT_IMPRESS_DELIMITER, //49
+ INS_PROP_CAP_OBJECT_IMPRESS_LEVEL, //50
+ INS_PROP_CAP_OBJECT_IMPRESS_POSITION, //51
+ INS_PROP_CAP_OBJECT_IMPRESS_CHARACTERSTYLE, //52
+ INS_PROP_CAP_OBJECT_IMPRESS_APPLYATTRIBUTES, //53
+ INS_PROP_CAP_OBJECT_CHART_ENABLE, //54
+ INS_PROP_CAP_OBJECT_CHART_CATEGORY, //55
+ INS_PROP_CAP_OBJECT_CHART_NUMBERING, //56
+ INS_PROP_CAP_OBJECT_CHART_NUMBERINGSEPARATOR, //57
+ INS_PROP_CAP_OBJECT_CHART_CAPTIONTEXT, //58
+ INS_PROP_CAP_OBJECT_CHART_DELIMITER, //59
+ INS_PROP_CAP_OBJECT_CHART_LEVEL, //60
+ INS_PROP_CAP_OBJECT_CHART_POSITION, //61
+ INS_PROP_CAP_OBJECT_CHART_CHARACTERSTYLE, //62
+ INS_PROP_CAP_OBJECT_CHART_APPLYATTRIBUTES, //63
+ INS_PROP_CAP_OBJECT_FORMULA_ENABLE, //64
+ INS_PROP_CAP_OBJECT_FORMULA_CATEGORY, //65
+ INS_PROP_CAP_OBJECT_FORMULA_NUMBERING, //66
+ INS_PROP_CAP_OBJECT_FORMULA_NUMBERINGSEPARATOR, //67
+ INS_PROP_CAP_OBJECT_FORMULA_CAPTIONTEXT, //68
+ INS_PROP_CAP_OBJECT_FORMULA_DELIMITER, //69
+ INS_PROP_CAP_OBJECT_FORMULA_LEVEL, //70
+ INS_PROP_CAP_OBJECT_FORMULA_POSITION, //71
+ INS_PROP_CAP_OBJECT_FORMULA_CHARACTERSTYLE, //72
+ INS_PROP_CAP_OBJECT_FORMULA_APPLYATTRIBUTES, //73
+ INS_PROP_CAP_OBJECT_DRAW_ENABLE, //74
+ INS_PROP_CAP_OBJECT_DRAW_CATEGORY, //75
+ INS_PROP_CAP_OBJECT_DRAW_NUMBERING, //76
+ INS_PROP_CAP_OBJECT_DRAW_NUMBERINGSEPARATOR, //77
+ INS_PROP_CAP_OBJECT_DRAW_CAPTIONTEXT, //78
+ INS_PROP_CAP_OBJECT_DRAW_DELIMITER, //79
+ INS_PROP_CAP_OBJECT_DRAW_LEVEL, //80
+ INS_PROP_CAP_OBJECT_DRAW_POSITION, //81
+ INS_PROP_CAP_OBJECT_DRAW_CHARACTERSTYLE, //82
+ INS_PROP_CAP_OBJECT_DRAW_APPLYATTRIBUTES, //83
+ INS_PROP_CAP_OBJECT_OLEMISC_ENABLE, //84
+ INS_PROP_CAP_OBJECT_OLEMISC_CATEGORY, //85
+ INS_PROP_CAP_OBJECT_OLEMISC_NUMBERING, //86
+ INS_PROP_CAP_OBJECT_OLEMISC_NUMBERINGSEPARATOR, //87
+ INS_PROP_CAP_OBJECT_OLEMISC_CAPTIONTEXT, //88
+ INS_PROP_CAP_OBJECT_OLEMISC_DELIMITER, //89
+ INS_PROP_CAP_OBJECT_OLEMISC_LEVEL, //90
+ INS_PROP_CAP_OBJECT_OLEMISC_POSITION, //91
+ INS_PROP_CAP_OBJECT_OLEMISC_CHARACTERSTYLE, //92
+ INS_PROP_CAP_OBJECT_OLEMISC_APPLYATTRIBUTES //93
+};
+const Sequence<OUString>& SwInsertConfig::GetPropertyNames()
+{
+ static Sequence<OUString> aNames;
+ static Sequence<OUString> aWebNames;
+ if(!aNames.getLength())
+ {
+ static const char* aPropNames[] =
+ {
+ "Table/Header", // 0
+ "Table/RepeatHeader", // 1
+ "Table/Border", // 2
+ "Table/Split", // 3 from here not in writer/web
+ "Caption/Automatic", // 4
+ "Caption/CaptionOrderNumberingFirst", // 5
+ "Caption/WriterObject/Table/Enable", // 6
+ "Caption/WriterObject/Table/Settings/Category", // 7
+ "Caption/WriterObject/Table/Settings/Numbering", // 8
+ "Caption/WriterObject/Table/Settings/NumberingSeparator", // 9
+ "Caption/WriterObject/Table/Settings/CaptionText", //10
+ "Caption/WriterObject/Table/Settings/Delimiter", //11
+ "Caption/WriterObject/Table/Settings/Level", //12
+ "Caption/WriterObject/Table/Settings/Position", //13
+ "Caption/WriterObject/Table/Settings/CharacterStyle", //14
+ "Caption/WriterObject/Frame/Enable", //15
+ "Caption/WriterObject/Frame/Settings/Category", //16
+ "Caption/WriterObject/Frame/Settings/Numbering", //17
+ "Caption/WriterObject/Frame/Settings/NumberingSeparator", //18
+ "Caption/WriterObject/Frame/Settings/CaptionText", //19
+ "Caption/WriterObject/Frame/Settings/Delimiter", //20
+ "Caption/WriterObject/Frame/Settings/Level", //21
+ "Caption/WriterObject/Frame/Settings/Position", //22
+ "Caption/WriterObject/Frame/Settings/CharacterStyle", //23
+ "Caption/WriterObject/Graphic/Enable", //24
+ "Caption/WriterObject/Graphic/Settings/Category", //25
+ "Caption/WriterObject/Graphic/Settings/Numbering", //26
+ "Caption/WriterObject/Graphic/Settings/NumberingSeparator", //27
+ "Caption/WriterObject/Graphic/Settings/CaptionText", //28
+ "Caption/WriterObject/Graphic/Settings/Delimiter", //29
+ "Caption/WriterObject/Graphic/Settings/Level", //30
+ "Caption/WriterObject/Graphic/Settings/Position", //31
+ "Caption/WriterObject/Graphic/Settings/CharacterStyle", //32
+ "Caption/WriterObject/Graphic/Settings/ApplyAttributes", //33
+ "Caption/OfficeObject/Calc/Enable", //34
+ "Caption/OfficeObject/Calc/Settings/Category", //35
+ "Caption/OfficeObject/Calc/Settings/Numbering", //36
+ "Caption/OfficeObject/Calc/Settings/NumberingSeparator", //37
+ "Caption/OfficeObject/Calc/Settings/CaptionText", //38
+ "Caption/OfficeObject/Calc/Settings/Delimiter", //39
+ "Caption/OfficeObject/Calc/Settings/Level", //40
+ "Caption/OfficeObject/Calc/Settings/Position", //41
+ "Caption/OfficeObject/Calc/Settings/CharacterStyle", //42
+ "Caption/OfficeObject/Calc/Settings/ApplyAttributes", //43
+ "Caption/OfficeObject/Impress/Enable", //44
+ "Caption/OfficeObject/Impress/Settings/Category", //45
+ "Caption/OfficeObject/Impress/Settings/Numbering", //46
+ "Caption/OfficeObject/Impress/Settings/NumberingSeparator", //47
+ "Caption/OfficeObject/Impress/Settings/CaptionText", //48
+ "Caption/OfficeObject/Impress/Settings/Delimiter", //49
+ "Caption/OfficeObject/Impress/Settings/Level", //50
+ "Caption/OfficeObject/Impress/Settings/Position", //51
+ "Caption/OfficeObject/Impress/Settings/CharacterStyle", //52
+ "Caption/OfficeObject/Impress/Settings/ApplyAttributes", //53
+ "Caption/OfficeObject/Chart/Enable", //54
+ "Caption/OfficeObject/Chart/Settings/Category", //55
+ "Caption/OfficeObject/Chart/Settings/Numbering", //56
+ "Caption/OfficeObject/Chart/Settings/NumberingSeparator", //57
+ "Caption/OfficeObject/Chart/Settings/CaptionText", //58
+ "Caption/OfficeObject/Chart/Settings/Delimiter", //59
+ "Caption/OfficeObject/Chart/Settings/Level", //60
+ "Caption/OfficeObject/Chart/Settings/Position", //61
+ "Caption/OfficeObject/Chart/Settings/CharacterStyle", //62
+ "Caption/OfficeObject/Chart/Settings/ApplyAttributes", //63
+ "Caption/OfficeObject/Formula/Enable", //64
+ "Caption/OfficeObject/Formula/Settings/Category", //65
+ "Caption/OfficeObject/Formula/Settings/Numbering", //66
+ "Caption/OfficeObject/Formula/Settings/NumberingSeparator", //67
+ "Caption/OfficeObject/Formula/Settings/CaptionText", //68
+ "Caption/OfficeObject/Formula/Settings/Delimiter", //69
+ "Caption/OfficeObject/Formula/Settings/Level", //70
+ "Caption/OfficeObject/Formula/Settings/Position", //71
+ "Caption/OfficeObject/Formula/Settings/CharacterStyle", //72
+ "Caption/OfficeObject/Formula/Settings/ApplyAttributes", //73
+ "Caption/OfficeObject/Draw/Enable", //74
+ "Caption/OfficeObject/Draw/Settings/Category", //75
+ "Caption/OfficeObject/Draw/Settings/Numbering", //76
+ "Caption/OfficeObject/Draw/Settings/NumberingSeparator", //77
+ "Caption/OfficeObject/Draw/Settings/CaptionText", //78
+ "Caption/OfficeObject/Draw/Settings/Delimiter", //79
+ "Caption/OfficeObject/Draw/Settings/Level", //80
+ "Caption/OfficeObject/Draw/Settings/Position", //81
+ "Caption/OfficeObject/Draw/Settings/CharacterStyle", //82
+ "Caption/OfficeObject/Draw/Settings/ApplyAttributes", //83
+ "Caption/OfficeObject/OLEMisc/Enable", //84
+ "Caption/OfficeObject/OLEMisc/Settings/Category", //85
+ "Caption/OfficeObject/OLEMisc/Settings/Numbering", //86
+ "Caption/OfficeObject/OLEMisc/Settings/NumberingSeparator", //87
+ "Caption/OfficeObject/OLEMisc/Settings/CaptionText", //88
+ "Caption/OfficeObject/OLEMisc/Settings/Delimiter", //89
+ "Caption/OfficeObject/OLEMisc/Settings/Level", //90
+ "Caption/OfficeObject/OLEMisc/Settings/Position", //91
+ "Caption/OfficeObject/OLEMisc/Settings/CharacterStyle", //92
+ "Caption/OfficeObject/OLEMisc/Settings/ApplyAttributes" //93
+ };
+ const int nCount = INS_PROP_CAP_OBJECT_OLEMISC_APPLYATTRIBUTES + 1;
+ const int nWebCount = INS_PROP_TABLE_BORDER + 1;
+ aNames.realloc(nCount);
+ aWebNames.realloc(nWebCount);
+ OUString* pNames = aNames.getArray();
+ OUString* pWebNames = aWebNames.getArray();
+ int i;
+ for(i = 0; i < nCount; i++)
+ pNames[i] = OUString::createFromAscii(aPropNames[i]);
+ for(i = 0; i < nWebCount; i++)
+ pWebNames[i] = OUString::createFromAscii(aPropNames[i]);
+ }
+ return bIsWeb ? aWebNames : aNames;
+}
+
+SwInsertConfig::SwInsertConfig(sal_Bool bWeb) :
+ ConfigItem(bWeb ? OUString("Office.WriterWeb/Insert") : OUString("Office.Writer/Insert"),
+ CONFIG_MODE_DELAYED_UPDATE|CONFIG_MODE_RELEASE_TREE),
+ pCapOptions(0),
+ pOLEMiscOpt(0),
+ bInsWithCaption( sal_False ),
+ bCaptionOrderNumberingFirst( sal_False ),
+ aInsTblOpts(0,0),
+ bIsWeb(bWeb)
+{
+ aGlobalNames[GLOB_NAME_CALC ] = SvGlobalName(SO3_SC_CLASSID);
+ aGlobalNames[GLOB_NAME_IMPRESS] = SvGlobalName(SO3_SIMPRESS_CLASSID);
+ aGlobalNames[GLOB_NAME_DRAW ] = SvGlobalName(SO3_SDRAW_CLASSID);
+ aGlobalNames[GLOB_NAME_MATH ] = SvGlobalName(SO3_SM_CLASSID);
+ aGlobalNames[GLOB_NAME_CHART ] = SvGlobalName(SO3_SCH_CLASSID);
+ if(!bIsWeb)
+ pCapOptions = new InsCaptionOptArr;
+
+ Load();
+}
+
+SwInsertConfig::~SwInsertConfig()
+{
+ delete pCapOptions;
+ delete pOLEMiscOpt;
+}
+
+static void lcl_WriteOpt(const InsCaptionOpt& rOpt, Any* pValues, sal_Int32 nProp, sal_Int32 nOffset)
+{
+ switch(nOffset)
+ {
+ case 0:
+ {
+ sal_Bool bTemp = rOpt.UseCaption();
+ pValues[nProp].setValue(&bTemp, ::getBooleanCppuType());
+ }
+ break;//Enable
+ case 1: pValues[nProp] <<= OUString(rOpt.GetCategory()); break;//Category
+ case 2: pValues[nProp] <<= (sal_Int32)rOpt.GetNumType(); break;//Numbering",
+ case 3: pValues[nProp] <<= rOpt.GetNumSeparator(); break;//NumberingSeparator",
+ case 4: pValues[nProp] <<= OUString(rOpt.GetCaption()); break;//CaptionText",
+ case 5: pValues[nProp] <<= OUString(rOpt.GetSeparator());break;//Delimiter",
+ case 6: pValues[nProp] <<= (sal_Int32)rOpt.GetLevel(); break;//Level",
+ case 7: pValues[nProp] <<= (sal_Int32)rOpt.GetPos(); break;//Position",
+ case 8: pValues[nProp] <<= (OUString&)rOpt.GetCharacterStyle(); break; //CharacterStyle
+ case 9: pValues[nProp] <<= rOpt.CopyAttributes(); break; //ApplyAttributes
+ }
+}
+
+void SwInsertConfig::Notify( const ::com::sun::star::uno::Sequence< OUString >& ) {}
+
+void SwInsertConfig::Commit()
+{
+ const Sequence<OUString>& aNames = GetPropertyNames();
+ Sequence<Any> aValues(aNames.getLength());
+ Any* pValues = aValues.getArray();
+
+ const Type& rType = ::getBooleanCppuType();
+ for(int nProp = 0; nProp < aNames.getLength(); nProp++)
+ {
+ const InsCaptionOpt* pWriterTableOpt = 0;
+ const InsCaptionOpt* pWriterFrameOpt = 0;
+ const InsCaptionOpt* pWriterGraphicOpt = 0;
+ const InsCaptionOpt* pOLECalcOpt = 0;
+ const InsCaptionOpt* pOLEImpressOpt = 0;
+ const InsCaptionOpt* pOLEChartOpt = 0;
+ const InsCaptionOpt* pOLEFormulaOpt = 0;
+ const InsCaptionOpt* pOLEDrawOpt = 0;
+ if(pCapOptions)
+ {
+ pWriterTableOpt = pCapOptions->Find(TABLE_CAP, 0);
+ pWriterFrameOpt = pCapOptions->Find(FRAME_CAP, 0);
+ pWriterGraphicOpt = pCapOptions->Find(GRAPHIC_CAP, 0);
+ pOLECalcOpt = pCapOptions->Find(OLE_CAP, &aGlobalNames[GLOB_NAME_CALC]);
+ pOLEImpressOpt = pCapOptions->Find(OLE_CAP, &aGlobalNames[GLOB_NAME_IMPRESS]);
+ pOLEDrawOpt = pCapOptions->Find(OLE_CAP, &aGlobalNames[GLOB_NAME_DRAW ]);
+ pOLEFormulaOpt = pCapOptions->Find(OLE_CAP, &aGlobalNames[GLOB_NAME_MATH ]);
+ pOLEChartOpt = pCapOptions->Find(OLE_CAP, &aGlobalNames[GLOB_NAME_CHART ]);
+ }
+ switch(nProp)
+ {
+ case INS_PROP_TABLE_HEADER:
+ {
+ sal_Bool bVal = 0 !=(aInsTblOpts.mnInsMode & tabopts::HEADLINE); pValues[nProp].setValue(&bVal, rType);
+ }
+ break;//"Table/Header",
+ case INS_PROP_TABLE_REPEATHEADER:
+ {
+ sal_Bool bVal = (aInsTblOpts.mnRowsToRepeat>0); pValues[nProp].setValue(&bVal, rType);
+ }
+ break;//"Table/RepeatHeader",
+ case INS_PROP_TABLE_BORDER:
+ {
+ sal_Bool bVal = 0 !=(aInsTblOpts.mnInsMode & tabopts::DEFAULT_BORDER ); pValues[nProp].setValue(&bVal, rType);
+ }
+ break;//"Table/Border",
+ case INS_PROP_TABLE_SPLIT:
+ {
+ sal_Bool bVal = 0 !=(aInsTblOpts.mnInsMode & tabopts::SPLIT_LAYOUT); pValues[nProp].setValue(&bVal, rType);
+ }
+ break;//"Table/Split",
+ case INS_PROP_CAP_AUTOMATIC: pValues[nProp].setValue(&bInsWithCaption, rType);break;//"Caption/Automatic",
+ case INS_PROP_CAP_CAPTIONORDERNUMBERINGFIRST:
+ pValues[nProp] <<= bCaptionOrderNumberingFirst;
+ break;//"Caption/CaptionOrderNumberingFirst"
+
+ case INS_PROP_CAP_OBJECT_TABLE_ENABLE:
+ case INS_PROP_CAP_OBJECT_TABLE_CATEGORY:
+ case INS_PROP_CAP_OBJECT_TABLE_NUMBERING:
+ case INS_PROP_CAP_OBJECT_TABLE_NUMBERINGSEPARATOR:
+ case INS_PROP_CAP_OBJECT_TABLE_CAPTIONTEXT:
+ case INS_PROP_CAP_OBJECT_TABLE_DELIMITER:
+ case INS_PROP_CAP_OBJECT_TABLE_LEVEL:
+ case INS_PROP_CAP_OBJECT_TABLE_POSITION:
+ case INS_PROP_CAP_OBJECT_TABLE_CHARACTERSTYLE:
+ if(pWriterTableOpt)
+ lcl_WriteOpt(*pWriterTableOpt, pValues, nProp, nProp - INS_PROP_CAP_OBJECT_TABLE_ENABLE);
+ break;
+ case INS_PROP_CAP_OBJECT_FRAME_ENABLE:
+ case INS_PROP_CAP_OBJECT_FRAME_CATEGORY:
+ case INS_PROP_CAP_OBJECT_FRAME_NUMBERING:
+ case INS_PROP_CAP_OBJECT_FRAME_NUMBERINGSEPARATOR:
+ case INS_PROP_CAP_OBJECT_FRAME_CAPTIONTEXT:
+ case INS_PROP_CAP_OBJECT_FRAME_DELIMITER:
+ case INS_PROP_CAP_OBJECT_FRAME_LEVEL:
+ case INS_PROP_CAP_OBJECT_FRAME_POSITION:
+ case INS_PROP_CAP_OBJECT_FRAME_CHARACTERSTYLE:
+ if(pWriterFrameOpt)
+ lcl_WriteOpt(*pWriterFrameOpt, pValues, nProp, nProp - INS_PROP_CAP_OBJECT_FRAME_ENABLE);
+ break;
+ case INS_PROP_CAP_OBJECT_GRAPHIC_ENABLE:
+ case INS_PROP_CAP_OBJECT_GRAPHIC_CATEGORY:
+ case INS_PROP_CAP_OBJECT_GRAPHIC_NUMBERING:
+ case INS_PROP_CAP_OBJECT_GRAPHIC_NUMBERINGSEPARATOR:
+ case INS_PROP_CAP_OBJECT_GRAPHIC_CAPTIONTEXT:
+ case INS_PROP_CAP_OBJECT_GRAPHIC_DELIMITER:
+ case INS_PROP_CAP_OBJECT_GRAPHIC_LEVEL:
+ case INS_PROP_CAP_OBJECT_GRAPHIC_POSITION:
+ case INS_PROP_CAP_OBJECT_GRAPHIC_CHARACTERSTYLE:
+ case INS_PROP_CAP_OBJECT_GRAPHIC_APPLYATTRIBUTES:
+ if(pWriterGraphicOpt)
+ lcl_WriteOpt(*pWriterGraphicOpt, pValues, nProp, nProp - INS_PROP_CAP_OBJECT_GRAPHIC_ENABLE);
+ break;
+ case INS_PROP_CAP_OBJECT_CALC_ENABLE:
+ case INS_PROP_CAP_OBJECT_CALC_CATEGORY:
+ case INS_PROP_CAP_OBJECT_CALC_NUMBERING:
+ case INS_PROP_CAP_OBJECT_CALC_NUMBERINGSEPARATOR:
+ case INS_PROP_CAP_OBJECT_CALC_CAPTIONTEXT:
+ case INS_PROP_CAP_OBJECT_CALC_DELIMITER:
+ case INS_PROP_CAP_OBJECT_CALC_LEVEL:
+ case INS_PROP_CAP_OBJECT_CALC_POSITION:
+ case INS_PROP_CAP_OBJECT_CALC_CHARACTERSTYLE:
+ case INS_PROP_CAP_OBJECT_CALC_APPLYATTRIBUTES:
+ if(pOLECalcOpt)
+ lcl_WriteOpt(*pOLECalcOpt, pValues, nProp, nProp - INS_PROP_CAP_OBJECT_CALC_ENABLE);
+ break;
+ case INS_PROP_CAP_OBJECT_IMPRESS_ENABLE:
+ case INS_PROP_CAP_OBJECT_IMPRESS_CATEGORY:
+ case INS_PROP_CAP_OBJECT_IMPRESS_NUMBERING:
+ case INS_PROP_CAP_OBJECT_IMPRESS_NUMBERINGSEPARATOR:
+ case INS_PROP_CAP_OBJECT_IMPRESS_CAPTIONTEXT:
+ case INS_PROP_CAP_OBJECT_IMPRESS_DELIMITER:
+ case INS_PROP_CAP_OBJECT_IMPRESS_LEVEL:
+ case INS_PROP_CAP_OBJECT_IMPRESS_POSITION:
+ case INS_PROP_CAP_OBJECT_IMPRESS_CHARACTERSTYLE:
+ case INS_PROP_CAP_OBJECT_IMPRESS_APPLYATTRIBUTES:
+ if(pOLEImpressOpt)
+ lcl_WriteOpt(*pOLEImpressOpt, pValues, nProp, nProp - INS_PROP_CAP_OBJECT_IMPRESS_ENABLE);
+ break;
+ case INS_PROP_CAP_OBJECT_CHART_ENABLE:
+ case INS_PROP_CAP_OBJECT_CHART_CATEGORY:
+ case INS_PROP_CAP_OBJECT_CHART_NUMBERING:
+ case INS_PROP_CAP_OBJECT_CHART_NUMBERINGSEPARATOR:
+ case INS_PROP_CAP_OBJECT_CHART_CAPTIONTEXT:
+ case INS_PROP_CAP_OBJECT_CHART_DELIMITER:
+ case INS_PROP_CAP_OBJECT_CHART_LEVEL:
+ case INS_PROP_CAP_OBJECT_CHART_POSITION:
+ case INS_PROP_CAP_OBJECT_CHART_CHARACTERSTYLE:
+ case INS_PROP_CAP_OBJECT_CHART_APPLYATTRIBUTES:
+ if(pOLEChartOpt)
+ lcl_WriteOpt(*pOLEChartOpt, pValues, nProp, nProp - INS_PROP_CAP_OBJECT_CHART_ENABLE);
+ break;
+ case INS_PROP_CAP_OBJECT_FORMULA_ENABLE:
+ case INS_PROP_CAP_OBJECT_FORMULA_CATEGORY:
+ case INS_PROP_CAP_OBJECT_FORMULA_NUMBERING:
+ case INS_PROP_CAP_OBJECT_FORMULA_NUMBERINGSEPARATOR:
+ case INS_PROP_CAP_OBJECT_FORMULA_CAPTIONTEXT:
+ case INS_PROP_CAP_OBJECT_FORMULA_DELIMITER:
+ case INS_PROP_CAP_OBJECT_FORMULA_LEVEL:
+ case INS_PROP_CAP_OBJECT_FORMULA_POSITION:
+ case INS_PROP_CAP_OBJECT_FORMULA_CHARACTERSTYLE:
+ case INS_PROP_CAP_OBJECT_FORMULA_APPLYATTRIBUTES:
+ if(pOLEFormulaOpt)
+ lcl_WriteOpt(*pOLEFormulaOpt, pValues, nProp, nProp - INS_PROP_CAP_OBJECT_FORMULA_ENABLE);
+ break;
+ case INS_PROP_CAP_OBJECT_DRAW_ENABLE:
+ case INS_PROP_CAP_OBJECT_DRAW_CATEGORY:
+ case INS_PROP_CAP_OBJECT_DRAW_NUMBERING:
+ case INS_PROP_CAP_OBJECT_DRAW_NUMBERINGSEPARATOR:
+ case INS_PROP_CAP_OBJECT_DRAW_CAPTIONTEXT:
+ case INS_PROP_CAP_OBJECT_DRAW_DELIMITER:
+ case INS_PROP_CAP_OBJECT_DRAW_LEVEL:
+ case INS_PROP_CAP_OBJECT_DRAW_POSITION:
+ case INS_PROP_CAP_OBJECT_DRAW_CHARACTERSTYLE:
+ case INS_PROP_CAP_OBJECT_DRAW_APPLYATTRIBUTES:
+ if(pOLEDrawOpt)
+ lcl_WriteOpt(*pOLEDrawOpt, pValues, nProp, nProp - INS_PROP_CAP_OBJECT_DRAW_ENABLE);
+ break;
+ case INS_PROP_CAP_OBJECT_OLEMISC_ENABLE:
+ case INS_PROP_CAP_OBJECT_OLEMISC_CATEGORY:
+ case INS_PROP_CAP_OBJECT_OLEMISC_NUMBERING:
+ case INS_PROP_CAP_OBJECT_OLEMISC_NUMBERINGSEPARATOR:
+ case INS_PROP_CAP_OBJECT_OLEMISC_CAPTIONTEXT:
+ case INS_PROP_CAP_OBJECT_OLEMISC_DELIMITER:
+ case INS_PROP_CAP_OBJECT_OLEMISC_LEVEL:
+ case INS_PROP_CAP_OBJECT_OLEMISC_POSITION:
+ case INS_PROP_CAP_OBJECT_OLEMISC_CHARACTERSTYLE:
+ case INS_PROP_CAP_OBJECT_OLEMISC_APPLYATTRIBUTES:
+ if(pOLEMiscOpt)
+ lcl_WriteOpt(*pOLEMiscOpt, pValues, nProp, nProp - INS_PROP_CAP_OBJECT_OLEMISC_ENABLE);
+ break;
+
+ }
+ }
+ PutProperties(aNames, aValues);
+}
+
+static void lcl_ReadOpt(InsCaptionOpt& rOpt, const Any* pValues, sal_Int32 nProp, sal_Int32 nOffset)
+{
+ switch(nOffset)
+ {
+ case 0:
+ rOpt.UseCaption() = *(sal_Bool*)pValues[nProp].getValue();
+ break;//Enable
+ case 1:
+ {
+ OUString sTemp; pValues[nProp] >>= sTemp;
+ rOpt.SetCategory(sTemp);
+ }
+ break;//Category
+ case 2:
+ {
+ sal_Int32 nTemp = 0;
+ pValues[nProp] >>= nTemp;
+ rOpt.SetNumType(sal::static_int_cast< sal_uInt16, sal_Int32>(nTemp));
+ }
+ break;//Numbering",
+ case 3:
+ {
+ OUString sTemp; pValues[nProp] >>= sTemp;
+ rOpt.SetNumSeparator(sTemp);
+ }
+ break;//NumberingSeparator",
+ case 4:
+ {
+ OUString sTemp; pValues[nProp] >>= sTemp;
+ rOpt.SetCaption(sTemp);
+ }
+ break;//CaptionText",
+ case 5:
+ {
+ OUString sTemp;
+ if(pValues[nProp] >>= sTemp)
+ rOpt.SetSeparator(sTemp);
+ }
+ break;//Delimiter",
+ case 6:
+ {
+ sal_Int32 nTemp = 0;
+ pValues[nProp] >>= nTemp;
+ rOpt.SetLevel(sal::static_int_cast< sal_uInt16, sal_Int32>(nTemp));
+ }
+ break;//Level",
+ case 7:
+ {
+ sal_Int32 nTemp = 0;
+ pValues[nProp] >>= nTemp;
+ rOpt.SetPos(sal::static_int_cast< sal_uInt16, sal_Int32>(nTemp));
+ }
+ break;//Position",
+ case 8 : //CharacterStyle
+ {
+ OUString sTemp; pValues[nProp] >>= sTemp;
+ rOpt.SetCharacterStyle( sTemp );
+ }
+ break;
+ case 9 : //ApplyAttributes
+ {
+ pValues[nProp] >>= rOpt.CopyAttributes();
+ }
+ break;
+ }
+}
+
+void SwInsertConfig::Load()
+{
+ const Sequence<OUString>& aNames = GetPropertyNames();
+ Sequence<Any> aValues = GetProperties(aNames);
+ const Any* pValues = aValues.getConstArray();
+ OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
+ if(aValues.getLength() == aNames.getLength())
+ {
+ InsCaptionOpt* pWriterTableOpt = 0;
+ InsCaptionOpt* pWriterFrameOpt = 0;
+ InsCaptionOpt* pWriterGraphicOpt = 0;
+ InsCaptionOpt* pOLECalcOpt = 0;
+ InsCaptionOpt* pOLEImpressOpt = 0;
+ InsCaptionOpt* pOLEChartOpt = 0;
+ InsCaptionOpt* pOLEFormulaOpt = 0;
+ InsCaptionOpt* pOLEDrawOpt = 0;
+ if(pCapOptions)
+ {
+ pWriterTableOpt = pCapOptions->Find(TABLE_CAP, 0);
+ pWriterFrameOpt = pCapOptions->Find(FRAME_CAP, 0);
+ pWriterGraphicOpt = pCapOptions->Find(GRAPHIC_CAP, 0);
+ pOLECalcOpt = pCapOptions->Find(OLE_CAP, &aGlobalNames[GLOB_NAME_CALC]);
+ pOLEImpressOpt = pCapOptions->Find(OLE_CAP, &aGlobalNames[GLOB_NAME_IMPRESS]);
+ pOLEDrawOpt = pCapOptions->Find(OLE_CAP, &aGlobalNames[GLOB_NAME_DRAW ]);
+ pOLEFormulaOpt = pCapOptions->Find(OLE_CAP, &aGlobalNames[GLOB_NAME_MATH ]);
+ pOLEChartOpt = pCapOptions->Find(OLE_CAP, &aGlobalNames[GLOB_NAME_CHART ]);
+ }
+ else if(!bIsWeb)
+ return;
+
+ sal_uInt16 nInsTblFlags = 0;
+ for(int nProp = 0; nProp < aNames.getLength(); nProp++)
+ {
+ if(pValues[nProp].hasValue())
+ {
+ sal_Bool bBool = nProp < INS_PROP_CAP_OBJECT_TABLE_ENABLE ? *(sal_Bool*)pValues[nProp].getValue() : sal_False;
+ switch(nProp)
+ {
+ case INS_PROP_TABLE_HEADER:
+ {
+ if(bBool)
+ nInsTblFlags|= tabopts::HEADLINE;
+ }
+ break;//"Table/Header",
+ case INS_PROP_TABLE_REPEATHEADER:
+ {
+ aInsTblOpts.mnRowsToRepeat = bBool? 1 : 0;
+
+ }
+ break;//"Table/RepeatHeader",
+ case INS_PROP_TABLE_BORDER:
+ {
+ if(bBool)
+ nInsTblFlags|= tabopts::DEFAULT_BORDER;
+ }
+ break;//"Table/Border",
+ case INS_PROP_TABLE_SPLIT:
+ {
+ if(bBool)
+ nInsTblFlags|= tabopts::SPLIT_LAYOUT;
+ }
+ break;//"Table/Split",
+ case INS_PROP_CAP_AUTOMATIC:
+ bInsWithCaption = bBool;
+ break;
+ case INS_PROP_CAP_CAPTIONORDERNUMBERINGFIRST: bCaptionOrderNumberingFirst = bBool; break;
+ case INS_PROP_CAP_OBJECT_TABLE_ENABLE:
+ case INS_PROP_CAP_OBJECT_TABLE_CATEGORY:
+ case INS_PROP_CAP_OBJECT_TABLE_NUMBERING:
+ case INS_PROP_CAP_OBJECT_TABLE_NUMBERINGSEPARATOR:
+ case INS_PROP_CAP_OBJECT_TABLE_CAPTIONTEXT:
+ case INS_PROP_CAP_OBJECT_TABLE_DELIMITER:
+ case INS_PROP_CAP_OBJECT_TABLE_LEVEL:
+ case INS_PROP_CAP_OBJECT_TABLE_POSITION:
+ case INS_PROP_CAP_OBJECT_TABLE_CHARACTERSTYLE:
+ if(!pWriterTableOpt)
+ {
+ pWriterTableOpt = new InsCaptionOpt(TABLE_CAP);
+ pCapOptions->Insert(pWriterTableOpt);
+ }
+ lcl_ReadOpt(*pWriterTableOpt, pValues, nProp, nProp - INS_PROP_CAP_OBJECT_TABLE_ENABLE);
+ break;
+ case INS_PROP_CAP_OBJECT_FRAME_ENABLE:
+ case INS_PROP_CAP_OBJECT_FRAME_CATEGORY:
+ case INS_PROP_CAP_OBJECT_FRAME_NUMBERING:
+ case INS_PROP_CAP_OBJECT_FRAME_NUMBERINGSEPARATOR:
+ case INS_PROP_CAP_OBJECT_FRAME_CAPTIONTEXT:
+ case INS_PROP_CAP_OBJECT_FRAME_DELIMITER:
+ case INS_PROP_CAP_OBJECT_FRAME_LEVEL:
+ case INS_PROP_CAP_OBJECT_FRAME_POSITION:
+ case INS_PROP_CAP_OBJECT_FRAME_CHARACTERSTYLE:
+ if(!pWriterFrameOpt)
+ {
+ pWriterFrameOpt = new InsCaptionOpt(FRAME_CAP);
+ pCapOptions->Insert(pWriterFrameOpt);
+ }
+ lcl_ReadOpt(*pWriterFrameOpt, pValues, nProp, nProp - INS_PROP_CAP_OBJECT_FRAME_ENABLE);
+ break;
+ case INS_PROP_CAP_OBJECT_GRAPHIC_ENABLE:
+ case INS_PROP_CAP_OBJECT_GRAPHIC_CATEGORY:
+ case INS_PROP_CAP_OBJECT_GRAPHIC_NUMBERING:
+ case INS_PROP_CAP_OBJECT_GRAPHIC_NUMBERINGSEPARATOR:
+ case INS_PROP_CAP_OBJECT_GRAPHIC_CAPTIONTEXT:
+ case INS_PROP_CAP_OBJECT_GRAPHIC_DELIMITER:
+ case INS_PROP_CAP_OBJECT_GRAPHIC_LEVEL:
+ case INS_PROP_CAP_OBJECT_GRAPHIC_POSITION:
+ case INS_PROP_CAP_OBJECT_GRAPHIC_CHARACTERSTYLE:
+ case INS_PROP_CAP_OBJECT_GRAPHIC_APPLYATTRIBUTES:
+ if(!pWriterGraphicOpt)
+ {
+ pWriterGraphicOpt = new InsCaptionOpt(GRAPHIC_CAP);
+ pCapOptions->Insert(pWriterGraphicOpt);
+ }
+ lcl_ReadOpt(*pWriterGraphicOpt, pValues, nProp, nProp - INS_PROP_CAP_OBJECT_GRAPHIC_ENABLE);
+ break;
+ case INS_PROP_CAP_OBJECT_CALC_ENABLE:
+ case INS_PROP_CAP_OBJECT_CALC_CATEGORY:
+ case INS_PROP_CAP_OBJECT_CALC_NUMBERING:
+ case INS_PROP_CAP_OBJECT_CALC_NUMBERINGSEPARATOR:
+ case INS_PROP_CAP_OBJECT_CALC_CAPTIONTEXT:
+ case INS_PROP_CAP_OBJECT_CALC_DELIMITER:
+ case INS_PROP_CAP_OBJECT_CALC_LEVEL:
+ case INS_PROP_CAP_OBJECT_CALC_POSITION:
+ case INS_PROP_CAP_OBJECT_CALC_CHARACTERSTYLE:
+ case INS_PROP_CAP_OBJECT_CALC_APPLYATTRIBUTES:
+ if(!pOLECalcOpt)
+ {
+ pOLECalcOpt = new InsCaptionOpt(OLE_CAP, &aGlobalNames[GLOB_NAME_CALC]);
+ pCapOptions->Insert(pOLECalcOpt);
+ }
+ lcl_ReadOpt(*pOLECalcOpt, pValues, nProp, nProp - INS_PROP_CAP_OBJECT_CALC_ENABLE);
+ break;
+ case INS_PROP_CAP_OBJECT_IMPRESS_ENABLE:
+ case INS_PROP_CAP_OBJECT_IMPRESS_CATEGORY:
+ case INS_PROP_CAP_OBJECT_IMPRESS_NUMBERING:
+ case INS_PROP_CAP_OBJECT_IMPRESS_NUMBERINGSEPARATOR:
+ case INS_PROP_CAP_OBJECT_IMPRESS_CAPTIONTEXT:
+ case INS_PROP_CAP_OBJECT_IMPRESS_DELIMITER:
+ case INS_PROP_CAP_OBJECT_IMPRESS_LEVEL:
+ case INS_PROP_CAP_OBJECT_IMPRESS_POSITION:
+ case INS_PROP_CAP_OBJECT_IMPRESS_CHARACTERSTYLE:
+ case INS_PROP_CAP_OBJECT_IMPRESS_APPLYATTRIBUTES:
+ if(!pOLEImpressOpt)
+ {
+ pOLEImpressOpt = new InsCaptionOpt(OLE_CAP, &aGlobalNames[GLOB_NAME_IMPRESS]);
+ pCapOptions->Insert(pOLEImpressOpt);
+ }
+ lcl_ReadOpt(*pOLEImpressOpt, pValues, nProp, nProp - INS_PROP_CAP_OBJECT_IMPRESS_ENABLE);
+ break;
+ case INS_PROP_CAP_OBJECT_CHART_ENABLE:
+ case INS_PROP_CAP_OBJECT_CHART_CATEGORY:
+ case INS_PROP_CAP_OBJECT_CHART_NUMBERING:
+ case INS_PROP_CAP_OBJECT_CHART_NUMBERINGSEPARATOR:
+ case INS_PROP_CAP_OBJECT_CHART_CAPTIONTEXT:
+ case INS_PROP_CAP_OBJECT_CHART_DELIMITER:
+ case INS_PROP_CAP_OBJECT_CHART_LEVEL:
+ case INS_PROP_CAP_OBJECT_CHART_POSITION:
+ case INS_PROP_CAP_OBJECT_CHART_CHARACTERSTYLE:
+ case INS_PROP_CAP_OBJECT_CHART_APPLYATTRIBUTES:
+ if(!pOLEChartOpt)
+ {
+ pOLEChartOpt = new InsCaptionOpt(OLE_CAP, &aGlobalNames[GLOB_NAME_CHART]);
+ pCapOptions->Insert(pOLEChartOpt);
+ }
+ lcl_ReadOpt(*pOLEChartOpt, pValues, nProp, nProp - INS_PROP_CAP_OBJECT_CHART_ENABLE);
+ break;
+ case INS_PROP_CAP_OBJECT_FORMULA_ENABLE:
+ case INS_PROP_CAP_OBJECT_FORMULA_CATEGORY:
+ case INS_PROP_CAP_OBJECT_FORMULA_NUMBERING:
+ case INS_PROP_CAP_OBJECT_FORMULA_NUMBERINGSEPARATOR:
+ case INS_PROP_CAP_OBJECT_FORMULA_CAPTIONTEXT:
+ case INS_PROP_CAP_OBJECT_FORMULA_DELIMITER:
+ case INS_PROP_CAP_OBJECT_FORMULA_LEVEL:
+ case INS_PROP_CAP_OBJECT_FORMULA_POSITION:
+ case INS_PROP_CAP_OBJECT_FORMULA_CHARACTERSTYLE:
+ case INS_PROP_CAP_OBJECT_FORMULA_APPLYATTRIBUTES:
+ if(!pOLEFormulaOpt)
+ {
+ pOLEFormulaOpt = new InsCaptionOpt(OLE_CAP, &aGlobalNames[GLOB_NAME_MATH]);
+ pCapOptions->Insert(pOLEFormulaOpt);
+ }
+ lcl_ReadOpt(*pOLEFormulaOpt, pValues, nProp, nProp - INS_PROP_CAP_OBJECT_FORMULA_ENABLE);
+ break;
+ case INS_PROP_CAP_OBJECT_DRAW_ENABLE:
+ case INS_PROP_CAP_OBJECT_DRAW_CATEGORY:
+ case INS_PROP_CAP_OBJECT_DRAW_NUMBERING:
+ case INS_PROP_CAP_OBJECT_DRAW_NUMBERINGSEPARATOR:
+ case INS_PROP_CAP_OBJECT_DRAW_CAPTIONTEXT:
+ case INS_PROP_CAP_OBJECT_DRAW_DELIMITER:
+ case INS_PROP_CAP_OBJECT_DRAW_LEVEL:
+ case INS_PROP_CAP_OBJECT_DRAW_POSITION:
+ case INS_PROP_CAP_OBJECT_DRAW_CHARACTERSTYLE:
+ case INS_PROP_CAP_OBJECT_DRAW_APPLYATTRIBUTES:
+ if(!pOLEDrawOpt)
+ {
+ pOLEDrawOpt = new InsCaptionOpt(OLE_CAP, &aGlobalNames[GLOB_NAME_DRAW]);
+ pCapOptions->Insert(pOLEDrawOpt);
+ }
+ lcl_ReadOpt(*pOLEDrawOpt, pValues, nProp, nProp - INS_PROP_CAP_OBJECT_DRAW_ENABLE);
+ break;
+ case INS_PROP_CAP_OBJECT_OLEMISC_ENABLE:
+ case INS_PROP_CAP_OBJECT_OLEMISC_CATEGORY:
+ case INS_PROP_CAP_OBJECT_OLEMISC_NUMBERING:
+ case INS_PROP_CAP_OBJECT_OLEMISC_NUMBERINGSEPARATOR:
+ case INS_PROP_CAP_OBJECT_OLEMISC_CAPTIONTEXT:
+ case INS_PROP_CAP_OBJECT_OLEMISC_DELIMITER:
+ case INS_PROP_CAP_OBJECT_OLEMISC_LEVEL:
+ case INS_PROP_CAP_OBJECT_OLEMISC_POSITION:
+ case INS_PROP_CAP_OBJECT_OLEMISC_CHARACTERSTYLE:
+ case INS_PROP_CAP_OBJECT_OLEMISC_APPLYATTRIBUTES:
+ if(!pOLEMiscOpt)
+ {
+ pOLEMiscOpt = new InsCaptionOpt(OLE_CAP);
+ }
+ lcl_ReadOpt(*pOLEMiscOpt, pValues, nProp, nProp - INS_PROP_CAP_OBJECT_OLEMISC_ENABLE);
+ break;
+ }
+ }
+ else if(nProp == INS_PROP_CAP_CAPTIONORDERNUMBERINGFIRST)
+ {
+ //#i61007# initialize caption order, right now only HUNGARIAN seems to need a different order
+ SvtSysLocaleOptions aSysLocaleOptions;
+ OUString sLang = aSysLocaleOptions.GetLocaleConfigString();
+ bCaptionOrderNumberingFirst = ( !sLang.isEmpty() && sLang.matchAsciiL( "hu", 2 )) ? sal_True : sal_False;
+ }
+
+ }
+ aInsTblOpts.mnInsMode = nInsTblFlags;
+ }
+}
+
+const Sequence<OUString>& SwTableConfig::GetPropertyNames()
+{
+ const int nCount = 8;
+ static Sequence<OUString> aNames(nCount);
+ static const char* aPropNames[] =
+ {
+ "Shift/Row", // 0
+ "Shift/Column", // 1
+ "Insert/Row", // 2
+ "Insert/Column", // 3
+ "Change/Effect", // 4
+ "Input/NumberRecognition", // 5
+ "Input/NumberFormatRecognition",// 6
+ "Input/Alignment" // 7
+ };
+ OUString* pNames = aNames.getArray();
+ for(int i = 0; i < nCount; i++)
+ pNames[i] = OUString::createFromAscii(aPropNames[i]);
+ return aNames;
+}
+
+SwTableConfig::SwTableConfig(sal_Bool bWeb) :
+ ConfigItem(bWeb ? OUString("Office.WriterWeb/Table") : OUString("Office.Writer/Table"),
+ CONFIG_MODE_DELAYED_UPDATE|CONFIG_MODE_RELEASE_TREE)
+{
+ Load();
+}
+
+SwTableConfig::~SwTableConfig()
+{
+}
+
+void SwTableConfig::Notify( const ::com::sun::star::uno::Sequence< OUString >& ) {}
+
+void SwTableConfig::Commit()
+{
+ const Sequence<OUString>& aNames = GetPropertyNames();
+ Sequence<Any> aValues(aNames.getLength());
+ Any* pValues = aValues.getArray();
+
+ const Type& rType = ::getBooleanCppuType();
+ for(int nProp = 0; nProp < aNames.getLength(); nProp++)
+ {
+ switch(nProp)
+ {
+ case 0 : pValues[nProp] <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(nTblHMove); break; //"Shift/Row",
+ case 1 : pValues[nProp] <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(nTblVMove); break; //"Shift/Column",
+ case 2 : pValues[nProp] <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(nTblHInsert); break; //"Insert/Row",
+ case 3 : pValues[nProp] <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(nTblVInsert); break; //"Insert/Column",
+ case 4 : pValues[nProp] <<= (sal_Int32)eTblChgMode; break; //"Change/Effect",
+ case 5 : pValues[nProp].setValue(&bInsTblFormatNum, rType); break; //"Input/NumberRecognition",
+ case 6 : pValues[nProp].setValue(&bInsTblChangeNumFormat, rType); break; //"Input/NumberFormatRecognition",
+ case 7 : pValues[nProp].setValue(&bInsTblAlignNum, rType); break; //"Input/Alignment"
+ }
+ }
+ PutProperties(aNames, aValues);
+}
+
+void SwTableConfig::Load()
+{
+ const Sequence<OUString>& aNames = GetPropertyNames();
+ Sequence<Any> aValues = GetProperties(aNames);
+ const Any* pValues = aValues.getConstArray();
+ OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
+ if(aValues.getLength() == aNames.getLength())
+ {
+ for(int nProp = 0; nProp < aNames.getLength(); nProp++)
+ {
+ if(pValues[nProp].hasValue())
+ {
+ sal_Int32 nTemp = 0;
+ switch(nProp)
+ {
+ case 0 : pValues[nProp] >>= nTemp; nTblHMove = (sal_uInt16)MM100_TO_TWIP(nTemp); break; //"Shift/Row",
+ case 1 : pValues[nProp] >>= nTemp; nTblVMove = (sal_uInt16)MM100_TO_TWIP(nTemp); break; //"Shift/Column",
+ case 2 : pValues[nProp] >>= nTemp; nTblHInsert = (sal_uInt16)MM100_TO_TWIP(nTemp); break; //"Insert/Row",
+ case 3 : pValues[nProp] >>= nTemp; nTblVInsert = (sal_uInt16)MM100_TO_TWIP(nTemp); break; //"Insert/Column",
+ case 4 : pValues[nProp] >>= nTemp; eTblChgMode = (TblChgMode)nTemp; break; //"Change/Effect",
+ case 5 : bInsTblFormatNum = *(sal_Bool*)pValues[nProp].getValue(); break; //"Input/NumberRecognition",
+ case 6 : bInsTblChangeNumFormat = *(sal_Bool*)pValues[nProp].getValue(); break; //"Input/NumberFormatRecognition",
+ case 7 : bInsTblAlignNum = *(sal_Bool*)pValues[nProp].getValue(); break; //"Input/Alignment"
+ }
+ }
+ }
+ }
+}
+
+SwMiscConfig::SwMiscConfig() :
+ ConfigItem("Office.Writer",
+ CONFIG_MODE_DELAYED_UPDATE|CONFIG_MODE_RELEASE_TREE),
+ bDefaultFontsInCurrDocOnly(sal_False),
+ bShowIndexPreview(sal_False),
+ bGrfToGalleryAsLnk(sal_True),
+ bNumAlignSize(sal_True),
+ bSinglePrintJob(sal_False),
+ bIsNameFromColumn(sal_True),
+ bAskForMailMergeInPrint(sal_True),
+ nMailingFormats(0)
+{
+ Load();
+}
+
+SwMiscConfig::~SwMiscConfig()
+{
+}
+
+const Sequence<OUString>& SwMiscConfig::GetPropertyNames()
+{
+ static Sequence<OUString> aNames;
+ if(!aNames.getLength())
+ {
+ const int nCount = 12;
+ aNames.realloc(nCount);
+ static const char* aPropNames[] =
+ {
+ "Statistics/WordNumber/Delimiter", // 0
+ "DefaultFont/Document", // 1
+ "Index/ShowPreview", // 2
+ "Misc/GraphicToGalleryAsLink", // 3
+ "Numbering/Graphic/KeepRatio", // 4
+ "FormLetter/PrintOutput/SinglePrintJobs", // 5
+ "FormLetter/MailingOutput/Format", // 6
+ "FormLetter/FileOutput/FileName/FromDatabaseField", // 7
+ "FormLetter/FileOutput/Path", // 8
+ "FormLetter/FileOutput/FileName/FromManualSetting", // 9
+ "FormLetter/FileOutput/FileName/Generation",//10
+ "FormLetter/PrintOutput/AskForMerge" //11
+ };
+ OUString* pNames = aNames.getArray();
+ for(int i = 0; i < nCount; i++)
+ pNames[i] = OUString::createFromAscii(aPropNames[i]);
+ }
+ return aNames;
+}
+
+void SwMiscConfig::Notify( const ::com::sun::star::uno::Sequence< OUString >& ) {}
+
+void SwMiscConfig::Commit()
+{
+ const Sequence<OUString>& aNames = GetPropertyNames();
+ Sequence<Any> aValues(aNames.getLength());
+ Any* pValues = aValues.getArray();
+
+ const Type& rType = ::getBooleanCppuType();
+ for(int nProp = 0; nProp < aNames.getLength(); nProp++)
+ {
+ switch(nProp)
+ {
+ case 0 :
+ pValues[nProp] <<=
+ SwModuleOptions::ConvertWordDelimiter(sWordDelimiter, sal_False);
+ break;
+ case 1 : pValues[nProp].setValue(&bDefaultFontsInCurrDocOnly, rType); break;
+ case 2 : pValues[nProp].setValue(&bShowIndexPreview, rType) ; break;
+ case 3 : pValues[nProp].setValue(&bGrfToGalleryAsLnk, rType); break;
+ case 4 : pValues[nProp].setValue(&bNumAlignSize, rType); break;
+ case 5 : pValues[nProp].setValue(&bSinglePrintJob, rType); break;
+ case 6 : pValues[nProp] <<= nMailingFormats; break;
+ case 7 : pValues[nProp] <<= sNameFromColumn; break;
+ case 8 : pValues[nProp] <<= sMailingPath; break;
+ case 9 : pValues[nProp] <<= sMailName; break;
+ case 10: pValues[nProp].setValue(&bIsNameFromColumn, rType);break;
+ case 11: pValues[nProp] <<= bAskForMailMergeInPrint; break;
+ }
+ }
+ PutProperties(aNames, aValues);
+}
+
+void SwMiscConfig::Load()
+{
+ const Sequence<OUString>& aNames = GetPropertyNames();
+ Sequence<Any> aValues = GetProperties(aNames);
+ const Any* pValues = aValues.getConstArray();
+ OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
+ if(aValues.getLength() == aNames.getLength())
+ {
+ OUString sTmp;
+ for(int nProp = 0; nProp < aNames.getLength(); nProp++)
+ {
+ if(pValues[nProp].hasValue())
+ {
+ switch(nProp)
+ {
+ case 0 : pValues[nProp] >>= sTmp;
+ sWordDelimiter = SwModuleOptions::ConvertWordDelimiter(sTmp, sal_True);
+ break;
+ case 1 : bDefaultFontsInCurrDocOnly = *(sal_Bool*)pValues[nProp].getValue(); break;
+ case 2 : bShowIndexPreview = *(sal_Bool*)pValues[nProp].getValue(); break;
+ case 3 : bGrfToGalleryAsLnk = *(sal_Bool*)pValues[nProp].getValue(); break;
+ case 4 : bNumAlignSize = *(sal_Bool*)pValues[nProp].getValue(); break;
+ case 5 : bSinglePrintJob = *(sal_Bool*)pValues[nProp].getValue(); break;
+ case 6 : pValues[nProp] >>= nMailingFormats; ; break;
+ case 7 : pValues[nProp] >>= sTmp; sNameFromColumn = sTmp; break;
+ case 8 : pValues[nProp] >>= sTmp; sMailingPath = sTmp; break;
+ case 9 : pValues[nProp] >>= sTmp; sMailName = sTmp; break;
+ case 10: bIsNameFromColumn = *(sal_Bool*)pValues[nProp].getValue(); break;
+ case 11: pValues[nProp] >>= bAskForMailMergeInPrint; break;
+ }
+ }
+ }
+ }
+}
+
+const Sequence<OUString>& SwCompareConfig::GetPropertyNames()
+{
+ static Sequence<OUString> aNames;
+ if(!aNames.getLength())
+ {
+ const int nCount = 4;
+ aNames.realloc(nCount);
+ static const char* aPropNames[] =
+ {
+ "Mode", // 0
+ "UseRSID", // 1
+ "IgnorePieces", // 2
+ "IgnoreLength" // 3
+ };
+ OUString* pNames = aNames.getArray();
+ for(int i = 0; i < nCount; i++)
+ pNames[i] = OUString::createFromAscii(aPropNames[i]);
+ }
+ return aNames;
+}
+
+SwCompareConfig::SwCompareConfig() :
+ ConfigItem("Office.Writer/Comparison",
+ CONFIG_MODE_DELAYED_UPDATE|CONFIG_MODE_RELEASE_TREE)
+{
+ eCmpMode = SVX_CMP_AUTO;
+ bUseRsid = 0;
+ bIgnorePieces = 0;
+ nPieceLen = 1;
+
+ Load();
+}
+
+SwCompareConfig::~SwCompareConfig()
+{
+}
+
+void SwCompareConfig::Commit()
+{
+ const Sequence<OUString>& aNames = GetPropertyNames();
+ Sequence<Any> aValues(aNames.getLength());
+ Any* pValues = aValues.getArray();
+
+ const Type& rType = ::getBooleanCppuType();
+
+ pValues[0] <<= (sal_Int32) eCmpMode;
+ pValues[1].setValue(&bUseRsid, rType);
+ pValues[2].setValue(&bIgnorePieces, rType);
+ pValues[3] <<= (sal_Int32) nPieceLen;
+
+ PutProperties(aNames, aValues);
+}
+
+void SwCompareConfig::Load()
+{
+ const Sequence<OUString>& aNames = GetPropertyNames();
+ Sequence<Any> aValues = GetProperties(aNames);
+ const Any* pValues = aValues.getConstArray();
+ DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed");
+ if(aValues.getLength() == aNames.getLength())
+ {
+ for(int nProp = 0; nProp < aNames.getLength(); nProp++)
+ {
+ if(pValues[nProp].hasValue())
+ {
+ sal_Int32 nVal = 0;
+ pValues[nProp] >>= nVal;
+
+ switch(nProp)
+ {
+ case 0 : eCmpMode = (SvxCompareMode) nVal; break;;
+ case 1 : bUseRsid = *(sal_Bool*)pValues[nProp].getValue(); break;
+ case 2 : bIgnorePieces = *(sal_Bool*)pValues[nProp].getValue(); break;
+ case 3 : nPieceLen = nVal; break;
+ }
+ }
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/config/prtopt.cxx b/sw/source/core/uibase/config/prtopt.cxx
new file mode 100644
index 000000000000..ac3251b0d145
--- /dev/null
+++ b/sw/source/core/uibase/config/prtopt.cxx
@@ -0,0 +1,175 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <unotools/configmgr.hxx>
+#include <prtopt.hxx>
+#include <osl/diagnose.h>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <unomid.h>
+
+using namespace utl;
+using namespace com::sun::star::uno;
+
+/*--------------------------------------------------------------------
+ Description: Ctor
+ --------------------------------------------------------------------*/
+
+Sequence<OUString> SwPrintOptions::GetPropertyNames()
+{
+ static const char* aPropNames[] =
+ {
+ "Content/Graphic", // 0
+ "Content/Table", // 1
+ "Content/Control", // 2
+ "Content/Background", // 3
+ "Content/PrintBlack", // 4
+ "Content/Note", // 5
+ "Page/Reversed", // 6
+ "Page/Brochure", // 7
+ "Page/BrochureRightToLeft", // 8
+ "Output/SinglePrintJob", // 9
+ "Output/Fax", // 10
+ "Papertray/FromPrinterSetup", // 11
+ "Content/Drawing", // 12 not in SW/Web
+ "Page/LeftPage", // 13 not in SW/Web
+ "Page/RightPage", // 14 not in SW/Web
+ "EmptyPages", // 15 not in SW/Web
+ "Content/PrintPlaceholders", // 16 not in Sw/Web
+ "Content/PrintHiddenText" // 17 not in Sw/Web
+ };
+ const int nCount = bIsWeb ? 12 : 18;
+ Sequence<OUString> aNames(nCount);
+ OUString* pNames = aNames.getArray();
+ for(int i = 0; i < nCount; i++)
+ {
+ pNames[i] = OUString::createFromAscii(aPropNames[i]);
+ }
+ return aNames;
+}
+
+SwPrintOptions::SwPrintOptions(sal_Bool bWeb) :
+ ConfigItem(bWeb ? OUString("Office.WriterWeb/Print") : OUString("Office.Writer/Print"),
+ CONFIG_MODE_DELAYED_UPDATE|CONFIG_MODE_RELEASE_TREE),
+ bIsWeb(bWeb)
+{
+ bPrintPageBackground = !bWeb;
+ bPrintBlackFont = bWeb;
+ bPrintTextPlaceholder = bPrintHiddenText = sal_False;
+ if (bWeb)
+ bPrintEmptyPages = sal_False;
+
+ Sequence<OUString> aNames = GetPropertyNames();
+ Sequence<Any> aValues = GetProperties(aNames);
+ const Any* pValues = aValues.getConstArray();
+ OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
+ if(aValues.getLength() == aNames.getLength())
+ {
+ for(int nProp = 0; nProp < aNames.getLength(); nProp++)
+ {
+ if(pValues[nProp].hasValue())
+ {
+ switch(nProp)
+ {
+ case 0: bPrintGraphic = *(sal_Bool*)pValues[nProp].getValue(); break;
+ case 1: bPrintTable = *(sal_Bool*)pValues[nProp].getValue(); break;
+ case 2: bPrintControl = *(sal_Bool*)pValues[nProp].getValue() ; break;
+ case 3: bPrintPageBackground= *(sal_Bool*)pValues[nProp].getValue(); break;
+ case 4: bPrintBlackFont = *(sal_Bool*)pValues[nProp].getValue(); break;
+ case 5:
+ {
+ sal_Int32 nTmp = 0;
+ pValues[nProp] >>= nTmp;
+ nPrintPostIts = (sal_Int16)nTmp;
+ }
+ break;
+ case 6: bPrintReverse = *(sal_Bool*)pValues[nProp].getValue(); break;
+ case 7: bPrintProspect = *(sal_Bool*)pValues[nProp].getValue(); break;
+ case 8: bPrintProspectRTL = *(sal_Bool*)pValues[nProp].getValue(); break;
+ case 9: bPrintSingleJobs = *(sal_Bool*)pValues[nProp].getValue(); break;
+ case 10: pValues[nProp] >>= sFaxName; break;
+ case 11: bPaperFromSetup = *(sal_Bool*)pValues[nProp].getValue(); break;
+ case 12: bPrintDraw = *(sal_Bool*)pValues[nProp].getValue() ; break;
+ case 13: bPrintLeftPages = *(sal_Bool*)pValues[nProp].getValue(); break;
+ case 14: bPrintRightPages = *(sal_Bool*)pValues[nProp].getValue(); break;
+ case 15: bPrintEmptyPages = *(sal_Bool*)pValues[nProp].getValue(); break;
+ case 16: bPrintTextPlaceholder = *(sal_Bool*)pValues[nProp].getValue(); break;
+ case 17: bPrintHiddenText = *(sal_Bool*)pValues[nProp].getValue(); break;
+ }
+ }
+ }
+ }
+
+ // currently there is just one checkbox for print drawings and print graphics
+ // In the UI. (File/Print dialog and Tools/Options/.../Print)
+ // And since print graphics is the only available in Writer and WrtierWeb ...
+
+ bPrintDraw = bPrintGraphic;
+}
+
+SwPrintOptions::~SwPrintOptions()
+{
+}
+
+void SwPrintOptions::Notify( const ::com::sun::star::uno::Sequence< OUString >& ) {}
+
+void SwPrintOptions::Commit()
+{
+ Sequence<OUString> aNames = GetPropertyNames();
+
+ Sequence<Any> aValues(aNames.getLength());
+ Any* pValues = aValues.getArray();
+
+ const Type& rType = ::getBooleanCppuType();
+ sal_Bool bVal;
+ for(int nProp = 0; nProp < aNames.getLength(); nProp++)
+ {
+ switch(nProp)
+ {
+ case 0: bVal = bPrintGraphic; pValues[nProp].setValue(&bVal, rType);break;
+ case 1: bVal = bPrintTable ;pValues[nProp].setValue(&bVal, rType); break;
+ case 2: bVal = bPrintControl ; pValues[nProp].setValue(&bVal, rType); break;
+ case 3: bVal = bPrintPageBackground; pValues[nProp].setValue(&bVal, rType); break;
+ case 4: bVal = bPrintBlackFont ; pValues[nProp].setValue(&bVal, rType); break;
+ case 5: pValues[nProp] <<= (sal_Int32)nPrintPostIts ; break;
+ case 6: bVal = bPrintReverse ; pValues[nProp].setValue(&bVal, rType); break;
+ case 7: bVal = bPrintProspect ; pValues[nProp].setValue(&bVal, rType); break;
+ case 8: bVal = bPrintProspectRTL ; pValues[nProp].setValue(&bVal, rType); break;
+ case 9: bVal = bPrintSingleJobs ; pValues[nProp].setValue(&bVal, rType); break;
+ case 10: pValues[nProp] <<= sFaxName; break;
+ case 11: bVal = bPaperFromSetup ; pValues[nProp].setValue(&bVal, rType); break;
+ case 12: bVal = bPrintDraw ; pValues[nProp].setValue(&bVal, rType); break;
+ case 13: bVal = bPrintLeftPages ; pValues[nProp].setValue(&bVal, rType); break;
+ case 14: bVal = bPrintRightPages ; pValues[nProp].setValue(&bVal, rType); break;
+ case 15: bVal = bPrintEmptyPages ; pValues[nProp].setValue(&bVal, rType); break;
+ case 16: bVal = bPrintTextPlaceholder; pValues[nProp].setValue(&bVal, rType); break;
+ case 17: bVal = bPrintHiddenText; pValues[nProp].setValue(&bVal, rType); break;
+ }
+ }
+
+ // currently there is just one checkbox for print drawings and print graphics
+ // In the UI. (File/Print dialog and Tools/Options/.../Print)
+ // And since print graphics is the only available in Writer and WrtierWeb ...
+ bPrintDraw = bPrintGraphic;
+
+ PutProperties(aNames, aValues);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/config/uinums.cxx b/sw/source/core/uibase/config/uinums.cxx
new file mode 100644
index 000000000000..8871d2b15bc7
--- /dev/null
+++ b/sw/source/core/uibase/config/uinums.cxx
@@ -0,0 +1,567 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <hintids.hxx>
+#include <svl/urihelper.hxx>
+#include <osl/thread.h>
+#include <unotools/pathoptions.hxx>
+#include <tools/stream.hxx>
+#include <sfx2/docfile.hxx>
+#include <svl/itemiter.hxx>
+#include <editeng/brushitem.hxx>
+
+#include <tools/resid.hxx>
+#include <fmtornt.hxx>
+#include <swtypes.hxx>
+#include <wrtsh.hxx>
+#include <uinums.hxx>
+#include <poolfmt.hxx>
+#include <charfmt.hxx>
+#include <frmatr.hxx>
+
+#include <unomid.h>
+
+using namespace ::com::sun::star;
+
+#define VERSION_30B ((sal_uInt16)250)
+#define VERSION_31B ((sal_uInt16)326)
+#define VERSION_40A ((sal_uInt16)364)
+#define VERSION_53A ((sal_uInt16)596)
+#define ACT_NUM_VERSION VERSION_53A
+
+#define CHAPTER_FILENAME "chapter.cfg"
+
+// SwNumRulesWithName ----------------------------------------------------
+// PUBLIC METHODES -------------------------------------------------------
+/*------------------------------------------------------------------------
+ Description: Saving a rule
+ Parameter: rCopy -- the rule to save
+ nIdx -- position, where the rule is to be saved.
+ An old rule at that position will be overwritten.
+------------------------------------------------------------------------*/
+
+SwBaseNumRules::SwBaseNumRules( const OUString& rFileName )
+ :
+ sFileName( rFileName ),
+ nVersion(0),
+ bModified( sal_False )
+{
+ Init();
+}
+
+SwBaseNumRules::~SwBaseNumRules()
+{
+ if( bModified )
+ {
+ SvtPathOptions aPathOpt;
+ OUString sNm( aPathOpt.GetUserConfigPath() );
+ sNm += OUString(INET_PATH_TOKEN);
+ sNm += sFileName;
+ INetURLObject aTempObj(sNm);
+ sNm = aTempObj.GetFull();
+ SfxMedium aStrm( sNm, STREAM_WRITE | STREAM_TRUNC |
+ STREAM_SHARE_DENYALL );
+ Store( *aStrm.GetOutStream() );
+ }
+
+ for( sal_uInt16 i = 0; i < nMaxRules; ++i )
+ delete pNumRules[i];
+}
+
+void SwBaseNumRules::Init()
+{
+ for(sal_uInt16 i = 0; i < nMaxRules; ++i )
+ pNumRules[i] = 0;
+
+ OUString sNm( sFileName );
+ SvtPathOptions aOpt;
+ if( aOpt.SearchFile( sNm, SvtPathOptions::PATH_USERCONFIG ))
+ {
+ SfxMedium aStrm( sNm, STREAM_STD_READ );
+ Load( *aStrm.GetInStream() );
+ }
+}
+
+void SwBaseNumRules::ApplyNumRules(const SwNumRulesWithName &rCopy, sal_uInt16 nIdx)
+{
+ OSL_ENSURE(nIdx < nMaxRules, "Array der NumRules ueberindiziert.");
+ if( !pNumRules[nIdx] )
+ pNumRules[nIdx] = new SwNumRulesWithName( rCopy );
+ else
+ *pNumRules[nIdx] = rCopy;
+}
+
+// PROTECTED METHODS ----------------------------------------------------
+sal_Bool SwBaseNumRules::Store(SvStream &rStream)
+{
+ rStream.WriteUInt16( ACT_NUM_VERSION );
+ // Write, what positions are occupied by a rule
+ // Then write each of the rules
+ for(sal_uInt16 i = 0; i < nMaxRules; ++i)
+ {
+ if(pNumRules[i])
+ {
+ rStream.WriteUChar( (unsigned char) sal_True );
+ pNumRules[i]->Store( rStream );
+ }
+ else
+ rStream.WriteUChar( (unsigned char) sal_False );
+ }
+ return sal_True;
+}
+
+int SwBaseNumRules::Load(SvStream &rStream)
+{
+ int rc = 0;
+
+ rStream.ReadUInt16( nVersion );
+
+ // due to a small but serious mistake, PreFinal writes the same VERION_40A as SP2
+ // #55402#
+ if(VERSION_40A == nVersion)
+ {
+ OSL_FAIL("Version 364 is not clear #55402#");
+ }
+ else if( VERSION_30B == nVersion || VERSION_31B == nVersion ||
+ ACT_NUM_VERSION >= nVersion )
+ {
+ unsigned char bRule = sal_False;
+ for(sal_uInt16 i = 0; i < nMaxRules; ++i)
+ {
+ rStream.ReadUChar( bRule );
+ if(bRule)
+ pNumRules[i] = new SwNumRulesWithName( rStream, nVersion );
+ }
+ }
+ else
+ {
+ rc = 1;
+ }
+
+ return rc;
+}
+
+SwChapterNumRules::SwChapterNumRules() :
+ SwBaseNumRules(OUString(CHAPTER_FILENAME))
+{
+}
+
+ SwChapterNumRules::~SwChapterNumRules()
+{
+}
+
+void SwChapterNumRules::ApplyNumRules(const SwNumRulesWithName &rCopy, sal_uInt16 nIdx)
+{
+ bModified = sal_True;
+ SwBaseNumRules::ApplyNumRules(rCopy, nIdx);
+}
+
+SwNumRulesWithName::SwNumRulesWithName( const SwNumRule &rCopy,
+ const OUString &rName )
+ : maName(rName)
+{
+ for( sal_uInt16 n = 0; n < MAXLEVEL; ++n )
+ {
+ const SwNumFmt* pFmt = rCopy.GetNumFmt( n );
+ if( pFmt )
+ aFmts[ n ] = new _SwNumFmtGlobal( *pFmt );
+ else
+ aFmts[ n ] = 0;
+ }
+}
+
+SwNumRulesWithName::SwNumRulesWithName( const SwNumRulesWithName& rCopy )
+{
+ memset( aFmts, 0, sizeof( aFmts ));
+ *this = rCopy;
+}
+
+SwNumRulesWithName::~SwNumRulesWithName()
+{
+ for( int n = 0; n < MAXLEVEL; ++n )
+ delete aFmts[ n ];
+}
+
+const SwNumRulesWithName& SwNumRulesWithName::operator=(const SwNumRulesWithName &rCopy)
+{
+ if( this != &rCopy )
+ {
+ maName = rCopy.maName;
+ for( int n = 0; n < MAXLEVEL; ++n )
+ {
+ delete aFmts[ n ];
+
+ _SwNumFmtGlobal* pFmt = rCopy.aFmts[ n ];
+ if( pFmt )
+ aFmts[ n ] = new _SwNumFmtGlobal( *pFmt );
+ else
+ aFmts[ n ] = 0;
+ }
+ }
+ return *this;
+}
+
+SwNumRulesWithName::SwNumRulesWithName( SvStream &rStream, sal_uInt16 nVersion )
+{
+ rtl_TextEncoding eEncoding = osl_getThreadTextEncoding();
+ maName = rStream.ReadUniOrByteString(eEncoding);
+
+ char c;
+ for(sal_uInt16 n = 0; n < MAXLEVEL; ++n )
+ {
+ if( VERSION_30B == nVersion )
+ c = 1;
+ // due to a small but serious mistake, PreFinal writes the same VERION_40A as SP2
+ // #55402#
+ else if(nVersion < VERSION_40A && n > 5)
+ c = 0;
+ else
+ rStream.ReadChar( c );
+
+ if( c )
+ aFmts[ n ] = new _SwNumFmtGlobal( rStream, nVersion );
+ else
+ aFmts[ n ] = 0;
+ }
+}
+
+void SwNumRulesWithName::MakeNumRule( SwWrtShell& rSh, SwNumRule& rChg ) const
+{
+ // #i89178#
+ rChg = SwNumRule( maName, numfunc::GetDefaultPositionAndSpaceMode() );
+ rChg.SetAutoRule( sal_False );
+ _SwNumFmtGlobal* pFmt;
+ for( sal_uInt16 n = 0; n < MAXLEVEL; ++n )
+ if( 0 != ( pFmt = aFmts[ n ] ) )
+ {
+ SwNumFmt aNew;
+ pFmt->ChgNumFmt( rSh, aNew );
+ rChg.Set( n, aNew );
+ }
+}
+
+void SwNumRulesWithName::Store( SvStream &rStream )
+{
+ rtl_TextEncoding eEncoding = osl_getThreadTextEncoding();
+ rStream.WriteUniOrByteString(maName, eEncoding);
+
+ for( sal_uInt16 n = 0; n < MAXLEVEL; ++n )
+ {
+ _SwNumFmtGlobal* pFmt = aFmts[ n ];
+ if( pFmt )
+ {
+ rStream.WriteChar( (char)1 );
+ pFmt->Store( rStream );
+ }
+ else
+ rStream.WriteChar( (char)0 );
+ }
+}
+
+SwNumRulesWithName::_SwNumFmtGlobal::_SwNumFmtGlobal( const SwNumFmt& rFmt )
+ : aFmt( rFmt ), nCharPoolId( USHRT_MAX )
+{
+ // relative gaps?????
+
+ SwCharFmt* pFmt = rFmt.GetCharFmt();
+ if( pFmt )
+ {
+ sCharFmtName = pFmt->GetName();
+ nCharPoolId = pFmt->GetPoolFmtId();
+ if( pFmt->GetAttrSet().Count() )
+ {
+ SfxItemIter aIter( pFmt->GetAttrSet() );
+ const SfxPoolItem *pCurr = aIter.GetCurItem();
+ while( true )
+ {
+ aItems.push_back( pCurr->Clone() );
+ if( aIter.IsAtEnd() )
+ break;
+ pCurr = aIter.NextItem();
+ }
+ }
+
+ aFmt.SetCharFmt( 0 );
+ }
+}
+
+SwNumRulesWithName::_SwNumFmtGlobal::_SwNumFmtGlobal( const _SwNumFmtGlobal& rFmt )
+ :
+ aFmt( rFmt.aFmt ),
+ sCharFmtName( rFmt.sCharFmtName ),
+ nCharPoolId( rFmt.nCharPoolId )
+{
+ for( sal_uInt16 n = rFmt.aItems.size(); n; )
+ aItems.push_back( rFmt.aItems[ --n ].Clone() );
+}
+
+SwNumRulesWithName::_SwNumFmtGlobal::_SwNumFmtGlobal( SvStream& rStream,
+ sal_uInt16 nVersion )
+ : nCharPoolId( USHRT_MAX )
+{
+ rtl_TextEncoding eEncoding = osl_getThreadTextEncoding();
+ {
+ sal_uInt16 nUS;
+ short nShort;
+ sal_Char cChar;
+ sal_Bool bFlag;
+ OUString sStr;
+
+ rStream.ReadUInt16( nUS ); aFmt.SetNumberingType((sal_Int16)nUS );
+ if( VERSION_53A > nVersion )
+ {
+ rStream.ReadChar( cChar ); aFmt.SetBulletChar( cChar );
+ }
+ else
+ {
+ rStream.ReadUInt16( nUS ); aFmt.SetBulletChar( nUS );
+ }
+
+ rStream.ReadUChar( bFlag ); aFmt.SetIncludeUpperLevels( bFlag );
+
+ if( VERSION_30B == nVersion )
+ {
+ sal_Int32 nL;
+ rStream.ReadChar( cChar ); aFmt.SetStart( (sal_uInt16)cChar );
+
+ sStr = rStream.ReadUniOrByteString(eEncoding);
+ aFmt.SetPrefix( sStr );
+ sStr = rStream.ReadUniOrByteString(eEncoding);
+ aFmt.SetSuffix( sStr );
+ rStream.ReadUInt16( nUS ); aFmt.SetNumAdjust( SvxAdjust( nUS ) );
+ rStream.ReadInt32( nL ); aFmt.SetLSpace( lNumIndent );
+ rStream.ReadInt32( nL ); aFmt.SetFirstLineOffset( (short)nL );
+ }
+ else // old start-value was a Byte
+ {
+ rStream.ReadUInt16( nUS ); aFmt.SetStart( nUS );
+ sStr = rStream.ReadUniOrByteString(eEncoding);
+ aFmt.SetPrefix( sStr );
+ sStr = rStream.ReadUniOrByteString(eEncoding);
+ aFmt.SetSuffix( sStr );
+ rStream.ReadUInt16( nUS ); aFmt.SetNumAdjust( SvxAdjust( nUS ) );
+ rStream.ReadUInt16( nUS ); aFmt.SetAbsLSpace( nUS );
+ rStream.ReadInt16( nShort ); aFmt.SetFirstLineOffset( nShort );
+ rStream.ReadUInt16( nUS ); aFmt.SetCharTextDistance( nUS );
+ rStream.ReadInt16( nShort ); aFmt.SetLSpace( nShort );
+ rStream.ReadUChar( bFlag );
+ }
+
+ sal_uInt16 nFamily;
+ sal_uInt16 nCharSet;
+ short nWidth;
+ short nHeight;
+ sal_uInt16 nPitch;
+ OUString aName;
+
+ aName = rStream.ReadUniOrByteString(eEncoding);
+ rStream.ReadUInt16( nFamily ).ReadUInt16( nCharSet ).ReadInt16( nWidth ).ReadInt16( nHeight ).ReadUInt16( nPitch );
+
+ if( !aName.isEmpty() )
+ {
+ Font aFont( static_cast<FontFamily>(nFamily), Size( nWidth, nHeight ) );
+ aFont.SetName( aName );
+ aFont.SetCharSet( (rtl_TextEncoding)nCharSet );
+ aFont.SetPitch( (FontPitch)nPitch );
+
+ aFmt.SetBulletFont( &aFont );
+ }
+ else
+ nCharSet = RTL_TEXTENCODING_SYMBOL;
+
+ if( VERSION_53A > nVersion )
+ {
+ sal_Char cEncoded(aFmt.GetBulletChar());
+ aFmt.SetBulletChar(OUString(&cEncoded, 1, nCharSet).toChar());
+ }
+ }
+
+ if( VERSION_30B != nVersion )
+ {
+ sal_uInt16 nItemCount;
+ rStream.ReadUInt16( nCharPoolId );
+ sCharFmtName = rStream.ReadUniOrByteString(eEncoding);
+ rStream.ReadUInt16( nItemCount );
+
+ while( nItemCount-- )
+ {
+ sal_uInt16 nWhich, nVers;
+ rStream.ReadUInt16( nWhich ).ReadUInt16( nVers );
+ aItems.push_back( GetDfltAttr( nWhich )->Create( rStream, nVers ) );
+ }
+ }
+
+ if( VERSION_40A == nVersion && SVX_NUM_BITMAP == aFmt.GetNumberingType() )
+ {
+ sal_uInt8 cF;
+ sal_Int32 nWidth(0), nHeight(0);
+
+ rStream.ReadInt32( nWidth ).ReadInt32( nHeight );
+
+ Size aSz(nWidth, nHeight);
+
+ rStream.ReadUChar( cF );
+ if( cF )
+ {
+ SvxBrushItem* pBrush = 0;
+ SwFmtVertOrient* pVOrient = 0;
+ sal_uInt16 nVer;
+
+ if( cF & 1 )
+ {
+ rStream.ReadUInt16( nVer );
+ pBrush = (SvxBrushItem*)GetDfltAttr( RES_BACKGROUND )
+ ->Create( rStream, nVer );
+ }
+
+ if( cF & 2 )
+ {
+ rStream.ReadUInt16( nVer );
+ pVOrient = (SwFmtVertOrient*)GetDfltAttr( RES_VERT_ORIENT )
+ ->Create( rStream, nVer );
+ }
+ sal_Int16 eOrient = text::VertOrientation::NONE;
+ if(pVOrient)
+ eOrient = (sal_Int16)pVOrient->GetVertOrient();
+ aFmt.SetGraphicBrush( pBrush, &aSz, pVOrient ? &eOrient : 0 );
+ }
+ }
+}
+
+SwNumRulesWithName::_SwNumFmtGlobal::~_SwNumFmtGlobal()
+{
+}
+
+void SwNumRulesWithName::_SwNumFmtGlobal::Store( SvStream& rStream )
+{
+ rtl_TextEncoding eEncoding = osl_getThreadTextEncoding();
+ {
+ OUString aName;
+ sal_uInt16 nFamily = FAMILY_DONTKNOW, nCharSet = 0, nPitch = 0;
+ short nWidth = 0, nHeight = 0;
+
+ const Font* pFnt = aFmt.GetBulletFont();
+ if( pFnt )
+ {
+ aName = pFnt->GetName();
+ nFamily = (sal_uInt16)pFnt->GetFamily();
+ nCharSet = (sal_uInt16)pFnt->GetCharSet();
+ nWidth = (short)pFnt->GetSize().Width();
+ nHeight = (short)pFnt->GetSize().Height();
+ nPitch = (sal_uInt16)pFnt->GetPitch();
+ }
+
+ rStream.WriteUInt16( sal_uInt16(aFmt.GetNumberingType()) )
+ .WriteUInt16( aFmt.GetBulletChar() )
+ .WriteUChar( static_cast<sal_Bool>(aFmt.GetIncludeUpperLevels() > 0) )
+ .WriteUInt16( aFmt.GetStart() );
+ rStream.WriteUniOrByteString( aFmt.GetPrefix(), eEncoding );
+ rStream.WriteUniOrByteString( aFmt.GetSuffix(), eEncoding );
+ rStream.WriteUInt16( sal_uInt16( aFmt.GetNumAdjust() ) )
+ .WriteInt16( aFmt.GetAbsLSpace() )
+ .WriteInt16( aFmt.GetFirstLineOffset() )
+ .WriteInt16( aFmt.GetCharTextDistance() )
+ .WriteInt16( aFmt.GetLSpace() )
+ .WriteUChar( sal_False );//aFmt.IsRelLSpace();
+ rStream.WriteUniOrByteString( aName, eEncoding );
+ rStream.WriteUInt16( nFamily )
+ .WriteUInt16( nCharSet )
+ .WriteInt16( nWidth )
+ .WriteInt16( nHeight )
+ .WriteUInt16( nPitch );
+ }
+ rStream.WriteUInt16( nCharPoolId );
+ rStream.WriteUniOrByteString( sCharFmtName, eEncoding );
+ rStream.WriteUInt16( static_cast<sal_uInt16>(aItems.size()) );
+
+ for( sal_uInt16 n = aItems.size(); n; )
+ {
+ SfxPoolItem* pItem = &aItems[ --n ];
+ sal_uInt16 nIVers = pItem->GetVersion( SOFFICE_FILEFORMAT_50 );
+ OSL_ENSURE( nIVers != USHRT_MAX,
+ "Was'n das: Item-Version USHRT_MAX in der aktuellen Version" );
+ rStream.WriteUInt16( pItem->Which() )
+ .WriteUInt16( nIVers );
+ pItem->Store( rStream, nIVers );
+ }
+
+ // Extensions for 40A
+
+ if( SVX_NUM_BITMAP == aFmt.GetNumberingType() )
+ {
+ rStream.WriteInt32( (sal_Int32)aFmt.GetGraphicSize().Width() )
+ .WriteInt32( (sal_Int32)aFmt.GetGraphicSize().Height() );
+ sal_uInt8 cFlg = ( 0 != aFmt.GetBrush() ? 1 : 0 ) +
+ ( 0 != aFmt.GetGraphicOrientation() ? 2 : 0 );
+ rStream.WriteUChar( cFlg );
+
+ if( aFmt.GetBrush() )
+ {
+ sal_uInt16 nVersion = aFmt.GetBrush()->GetVersion( SOFFICE_FILEFORMAT_50 );
+ rStream.WriteUInt16( nVersion );
+ aFmt.GetBrush()->Store( rStream, nVersion );
+ }
+ if( aFmt.GetGraphicOrientation() )
+ {
+ sal_uInt16 nVersion = aFmt.GetGraphicOrientation()->GetVersion( SOFFICE_FILEFORMAT_50 );
+ rStream.WriteUInt16( nVersion );
+ aFmt.GetGraphicOrientation()->Store( rStream, nVersion );
+ }
+ }
+}
+
+void SwNumRulesWithName::_SwNumFmtGlobal::ChgNumFmt( SwWrtShell& rSh,
+ SwNumFmt& rNew ) const
+{
+ SwCharFmt* pFmt = 0;
+ if( !sCharFmtName.isEmpty() )
+ {
+ // at first, look for the name
+ sal_uInt16 nArrLen = rSh.GetCharFmtCount();
+ for( sal_uInt16 i = 1; i < nArrLen; ++i )
+ {
+ pFmt = &rSh.GetCharFmt( i );
+ if (pFmt->GetName()==sCharFmtName)
+ // exists, so leave attributes as they are!
+ break;
+ pFmt = 0;
+ }
+
+ if( !pFmt )
+ {
+ if( IsPoolUserFmt( nCharPoolId ) )
+ {
+ pFmt = rSh.MakeCharFmt( sCharFmtName );
+ pFmt->SetAuto( false );
+ }
+ else
+ pFmt = rSh.GetCharFmtFromPool( nCharPoolId );
+
+ if( !pFmt->GetDepends() ) // set attributes
+ for( sal_uInt16 n = aItems.size(); n; )
+ pFmt->SetFmtAttr( aItems[ --n ] );
+ }
+ }
+ ((SwNumFmt&)aFmt).SetCharFmt( pFmt );
+ rNew = aFmt;
+ if( pFmt )
+ ((SwNumFmt&)aFmt).SetCharFmt( 0 );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/config/usrpref.cxx b/sw/source/core/uibase/config/usrpref.cxx
new file mode 100644
index 000000000000..7c47d4518486
--- /dev/null
+++ b/sw/source/core/uibase/config/usrpref.cxx
@@ -0,0 +1,592 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <tools/stream.hxx>
+#include <unotools/syslocale.hxx>
+
+#include "swtypes.hxx"
+#include "hintids.hxx"
+#include "uitool.hxx"
+#include "usrpref.hxx"
+#include "crstate.hxx"
+#include <linguistic/lngprops.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <unotools/localedatawrapper.hxx>
+
+#include <unomid.h>
+
+using namespace utl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+void SwMasterUsrPref::SetUsrPref(const SwViewOption &rCopy)
+{
+ *((SwViewOption*)this) = rCopy;
+}
+
+SwMasterUsrPref::SwMasterUsrPref(sal_Bool bWeb) :
+ eFldUpdateFlags(AUTOUPD_OFF),
+ nLinkUpdateMode(0),
+ bIsHScrollMetricSet(sal_False),
+ bIsVScrollMetricSet(sal_False),
+ nDefTab( MM50 * 4 ),
+ bIsSquaredPageMode(false),
+ bIsAlignMathObjectsToBaseline(false),
+ aContentConfig(bWeb, *this),
+ aLayoutConfig(bWeb, *this),
+ aGridConfig(bWeb, *this),
+ aCursorConfig(*this),
+ pWebColorConfig(bWeb ? new SwWebColorConfig(*this) : 0),
+ bApplyCharUnit(sal_False)
+{
+ MeasurementSystem eSystem = SvtSysLocale().GetLocaleData().getMeasurementSystemEnum();
+ eUserMetric = MEASURE_METRIC == eSystem ? FUNIT_CM : FUNIT_INCH;
+ eHScrollMetric = eVScrollMetric = eUserMetric;
+
+ aContentConfig.Load();
+ aLayoutConfig.Load();
+ aGridConfig.Load();
+ aCursorConfig.Load();
+ if(pWebColorConfig)
+ pWebColorConfig->Load();
+}
+
+SwMasterUsrPref::~SwMasterUsrPref()
+{
+ delete pWebColorConfig;
+}
+
+Sequence<OUString> SwContentViewConfig::GetPropertyNames()
+{
+ static const char* aPropNames[] =
+ {
+ "Display/GraphicObject", // 0
+ "Display/Table", // 1
+ "Display/DrawingControl", // 2
+ "Display/FieldCode", // 3
+ "Display/Note", // 4
+ "Display/ShowContentTips", // 5
+ "NonprintingCharacter/MetaCharacters", // 6
+ "NonprintingCharacter/ParagraphEnd", // 7
+ "NonprintingCharacter/OptionalHyphen", // 8
+ "NonprintingCharacter/Space", // 9
+ "NonprintingCharacter/Break", // 10
+ "NonprintingCharacter/ProtectedSpace", // 11
+ "NonprintingCharacter/Tab", // 12 //not in Writer/Web
+ "NonprintingCharacter/HiddenText", // 13
+ "NonprintingCharacter/HiddenParagraph", // 14
+ "NonprintingCharacter/HiddenCharacter", // 15
+ "Update/Link", // 16
+ "Update/Field", // 17
+ "Update/Chart" // 18
+
+ };
+ const int nCount = bWeb ? 12 : 19;
+ Sequence<OUString> aNames(nCount);
+ OUString* pNames = aNames.getArray();
+ for(int i = 0; i < nCount; i++)
+ {
+ pNames[i] = OUString::createFromAscii(aPropNames[i]);
+ }
+ return aNames;
+}
+
+SwContentViewConfig::SwContentViewConfig(sal_Bool bIsWeb, SwMasterUsrPref& rPar) :
+ ConfigItem(bIsWeb ? OUString("Office.WriterWeb/Content") : OUString("Office.Writer/Content")),
+ rParent(rPar),
+ bWeb(bIsWeb)
+{
+ Load();
+ EnableNotification( GetPropertyNames() );
+}
+
+SwContentViewConfig::~SwContentViewConfig()
+{
+}
+
+void SwContentViewConfig::Notify( const Sequence< OUString > & /*rPropertyNames*/ )
+{
+ Load();
+}
+
+void SwContentViewConfig::Commit()
+{
+ Sequence<OUString> aNames = GetPropertyNames();
+
+ Sequence<Any> aValues(aNames.getLength());
+ Any* pValues = aValues.getArray();
+
+ for(int nProp = 0; nProp < aNames.getLength(); nProp++)
+ {
+ sal_Bool bVal = sal_False;
+ switch(nProp)
+ {
+ case 0: bVal = rParent.IsGraphic(); break;// "Display/GraphicObject",
+ case 1: bVal = rParent.IsTable(); break;// "Display/Table",
+ case 2: bVal = rParent.IsDraw(); break;// "Display/DrawingControl",
+ case 3: bVal = rParent.IsFldName(); break;// "Display/FieldCode",
+ case 4: bVal = rParent.IsPostIts(); break;// "Display/Note",
+ case 5: bVal = rParent.IsShowContentTips(); break; // "Display/ShowContentTips"
+ case 6: bVal = rParent.IsViewMetaChars(); break; //"NonprintingCharacter/MetaCharacters"
+ case 7: bVal = rParent.IsParagraph(sal_True); break;// "NonprintingCharacter/ParagraphEnd",
+ case 8: bVal = rParent.IsSoftHyph(); break;// "NonprintingCharacter/OptionalHyphen",
+ case 9: bVal = rParent.IsBlank(sal_True); break;// "NonprintingCharacter/Space",
+ case 10: bVal = rParent.IsLineBreak(sal_True);break;// "NonprintingCharacter/Break",
+ case 11: bVal = rParent.IsHardBlank(); break;// "NonprintingCharacter/ProtectedSpace",
+ case 12: bVal = rParent.IsTab(sal_True); break;// "NonprintingCharacter/Tab",
+ case 13: bVal = rParent.IsShowHiddenField(); break;// "NonprintingCharacter/Fields: HiddenText",
+ case 14: bVal = rParent.IsShowHiddenPara(); break;// "NonprintingCharacter/Fields: HiddenParagraph",
+ case 15: bVal = rParent.IsShowHiddenChar(sal_True); break;// "NonprintingCharacter/HiddenCharacter",
+ case 16: pValues[nProp] <<= rParent.GetUpdateLinkMode(); break;// "Update/Link",
+ case 17: bVal = rParent.IsUpdateFields(); break;// "Update/Field",
+ case 18: bVal = rParent.IsUpdateCharts(); break;// "Update/Chart"
+ }
+ if(nProp != 16)
+ pValues[nProp].setValue(&bVal, ::getBooleanCppuType());
+ }
+ PutProperties(aNames, aValues);
+}
+
+void SwContentViewConfig::Load()
+{
+ Sequence<OUString> aNames = GetPropertyNames();
+ Sequence<Any> aValues = GetProperties(aNames);
+ const Any* pValues = aValues.getConstArray();
+ OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
+ if(aValues.getLength() == aNames.getLength())
+ {
+ for(int nProp = 0; nProp < aNames.getLength(); nProp++)
+ {
+ if(pValues[nProp].hasValue())
+ {
+ sal_Bool bSet = nProp != 16 ? *(sal_Bool*)pValues[nProp].getValue() : sal_False;
+ switch(nProp)
+ {
+ case 0: rParent.SetGraphic(bSet); break;// "Display/GraphicObject",
+ case 1: rParent.SetTable(bSet); break;// "Display/Table",
+ case 2: rParent.SetDraw(bSet); break;// "Display/DrawingControl",
+ case 3: rParent.SetFldName(bSet); break;// "Display/FieldCode",
+ case 4: rParent.SetPostIts(bSet); break;// "Display/Note",
+ case 5: rParent.SetShowContentTips(bSet); break;// "Display/ShowContentTips",
+ case 6: rParent.SetViewMetaChars(bSet); break; //"NonprintingCharacter/MetaCharacters"
+ case 7: rParent.SetParagraph(bSet); break;// "NonprintingCharacter/ParagraphEnd",
+ case 8: rParent.SetSoftHyph(bSet); break;// "NonprintingCharacter/OptionalHyphen",
+ case 9: rParent.SetBlank(bSet); break;// "NonprintingCharacter/Space",
+ case 10: rParent.SetLineBreak(bSet);break;// "NonprintingCharacter/Break",
+ case 11: rParent.SetHardBlank(bSet); break;// "NonprintingCharacter/ProtectedSpace",
+ case 12: rParent.SetTab(bSet); break;// "NonprintingCharacter/Tab",
+ case 13: rParent.SetShowHiddenField(bSet); break;// "NonprintingCharacter/Fields: HiddenText",
+ case 14: rParent.SetShowHiddenPara(bSet); break;// "NonprintingCharacter/Fields: HiddenParagraph",
+ case 15: rParent.SetShowHiddenChar(bSet); break;// "NonprintingCharacter/HiddenCharacter",
+ case 16:
+ {
+ sal_Int32 nSet = 0;
+ pValues[nProp] >>= nSet;
+ rParent.SetUpdateLinkMode(nSet, sal_True);
+ }
+ break;// "Update/Link",
+ case 17: rParent.SetUpdateFields(bSet, sal_True); break;// "Update/Field",
+ case 18: rParent.SetUpdateCharts(bSet, sal_True); break;// "Update/Chart"
+ }
+ }
+ }
+ }
+}
+
+Sequence<OUString> SwLayoutViewConfig::GetPropertyNames()
+{
+ static const char* aPropNames[] =
+ {
+ "Line/Guide", // 0
+ "Window/HorizontalScroll", // 1
+ "Window/VerticalScroll", // 2
+ "Window/ShowRulers", // 3
+ "Window/HorizontalRuler", // 4
+ "Window/VerticalRuler", // 5
+ "Window/HorizontalRulerUnit", // 6
+ "Window/VerticalRulerUnit", // 7
+ "Window/SmoothScroll", // 8
+ "Zoom/Value", // 9
+ "Zoom/Type", //10
+ "Other/IsAlignMathObjectsToBaseline", //11
+ "Other/MeasureUnit", //12
+ // below properties are not available in WriterWeb
+ "Other/TabStop", //13
+ "Window/IsVerticalRulerRight", //14
+ "ViewLayout/Columns", //15
+ "ViewLayout/BookMode", //16
+ "Other/IsSquaredPageMode", //17
+ "Other/ApplyCharUnit", //18
+ "Window/ShowScrollBarTips" //19
+ };
+ const int nCount = bWeb ? 13 : 20;
+ Sequence<OUString> aNames(nCount);
+ OUString* pNames = aNames.getArray();
+ for(int i = 0; i < nCount; i++)
+ {
+ pNames[i] = OUString::createFromAscii(aPropNames[i]);
+ }
+ return aNames;
+}
+
+SwLayoutViewConfig::SwLayoutViewConfig(sal_Bool bIsWeb, SwMasterUsrPref& rPar) :
+ ConfigItem(bIsWeb ? OUString("Office.WriterWeb/Layout") : OUString("Office.Writer/Layout"),
+ CONFIG_MODE_DELAYED_UPDATE|CONFIG_MODE_RELEASE_TREE),
+ rParent(rPar),
+ bWeb(bIsWeb)
+{
+}
+
+SwLayoutViewConfig::~SwLayoutViewConfig()
+{
+}
+
+void SwLayoutViewConfig::Commit()
+{
+ Sequence<OUString> aNames = GetPropertyNames();
+
+ Sequence<Any> aValues(aNames.getLength());
+ Any* pValues = aValues.getArray();
+
+ for(int nProp = 0; nProp < aNames.getLength(); nProp++)
+ {
+ Any &rVal = pValues[nProp];
+ switch(nProp)
+ {
+ case 0: rVal <<= (sal_Bool) rParent.IsCrossHair(); break; // "Line/Guide",
+ case 1: rVal <<= (sal_Bool) rParent.IsViewHScrollBar(); break; // "Window/HorizontalScroll",
+ case 2: rVal <<= (sal_Bool) rParent.IsViewVScrollBar(); break; // "Window/VerticalScroll",
+ case 3: rVal <<= (sal_Bool) rParent.IsViewAnyRuler(); break; // "Window/ShowRulers"
+ // #i14593# use IsView*Ruler(sal_True) instead of IsView*Ruler()
+ // this preserves the single ruler states even if "Window/ShowRulers" is off
+ case 4: rVal <<= (sal_Bool) rParent.IsViewHRuler(sal_True); break; // "Window/HorizontalRuler",
+ case 5: rVal <<= (sal_Bool) rParent.IsViewVRuler(sal_True); break; // "Window/VerticalRuler",
+ case 6:
+ if(rParent.bIsHScrollMetricSet)
+ rVal <<= (sal_Int32)rParent.eHScrollMetric; // "Window/HorizontalRulerUnit"
+ break;
+ case 7:
+ if(rParent.bIsVScrollMetricSet)
+ rVal <<= (sal_Int32)rParent.eVScrollMetric; // "Window/VerticalRulerUnit"
+ break;
+ case 8: rVal <<= (sal_Bool) rParent.IsSmoothScroll(); break; // "Window/SmoothScroll",
+ case 9: rVal <<= (sal_Int32)rParent.GetZoom(); break; // "Zoom/Value",
+ case 10: rVal <<= (sal_Int32)rParent.GetZoomType(); break; // "Zoom/Type",
+ case 11: rVal <<= (sal_Bool) rParent.IsAlignMathObjectsToBaseline(); break; // "Other/IsAlignMathObjectsToBaseline"
+ case 12: rVal <<= (sal_Int32)rParent.GetMetric(); break; // "Other/MeasureUnit",
+ case 13: rVal <<= static_cast<sal_Int32>(TWIP_TO_MM100(rParent.GetDefTab())); break;// "Other/TabStop",
+ case 14: rVal <<= (sal_Bool) rParent.IsVRulerRight(); break; // "Window/IsVerticalRulerRight",
+ case 15: rVal <<= (sal_Int32)rParent.GetViewLayoutColumns(); break; // "ViewLayout/Columns",
+ case 16: rVal <<= (sal_Bool) rParent.IsViewLayoutBookMode(); break; // "ViewLayout/BookMode",
+ case 17: rVal <<= (sal_Bool) rParent.IsSquaredPageMode(); break; // "Other/IsSquaredPageMode",
+ case 18: rVal <<= (sal_Bool) rParent.IsApplyCharUnit(); break; // "Other/ApplyCharUnit",
+ case 19: rVal <<= (sal_Bool) rParent.IsShowScrollBarTips(); break; // "Window/ShowScrollBarTips",
+ }
+ }
+ PutProperties(aNames, aValues);
+}
+
+void SwLayoutViewConfig::Load()
+{
+ Sequence<OUString> aNames = GetPropertyNames();
+ Sequence<Any> aValues = GetProperties(aNames);
+ const Any* pValues = aValues.getConstArray();
+ OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
+ if(aValues.getLength() == aNames.getLength())
+ {
+ for(int nProp = 0; nProp < aNames.getLength(); nProp++)
+ {
+ if(pValues[nProp].hasValue())
+ {
+ sal_Int32 nInt32Val = 0;
+ sal_Bool bSet = sal_False;
+ pValues[nProp] >>= nInt32Val;
+ pValues[nProp] >>= bSet;
+
+ switch(nProp)
+ {
+ case 0: rParent.SetCrossHair(bSet); break;// "Line/Guide",
+ case 1: rParent.SetViewHScrollBar(bSet); break;// "Window/HorizontalScroll",
+ case 2: rParent.SetViewVScrollBar(bSet); break;// "Window/VerticalScroll",
+ case 3: rParent.SetViewAnyRuler(bSet);break; // "Window/ShowRulers"
+ case 4: rParent.SetViewHRuler(bSet); break;// "Window/HorizontalRuler",
+ case 5: rParent.SetViewVRuler(bSet); break;// "Window/VerticalRuler",
+ case 6:
+ {
+ rParent.bIsHScrollMetricSet = sal_True;
+ rParent.eHScrollMetric = ((FieldUnit)nInt32Val); // "Window/HorizontalRulerUnit"
+ }
+ break;
+ case 7:
+ {
+ rParent.bIsVScrollMetricSet = sal_True;
+ rParent.eVScrollMetric = ((FieldUnit)nInt32Val); // "Window/VerticalRulerUnit"
+ }
+ break;
+ case 8: rParent.SetSmoothScroll(bSet); break;// "Window/SmoothScroll",
+ case 9: rParent.SetZoom( static_cast< sal_uInt16 >(nInt32Val) ); break;// "Zoom/Value",
+ case 10: rParent.SetZoomType( static_cast< SvxZoomType >(nInt32Val) ); break;// "Zoom/Type",
+ case 11: rParent.SetAlignMathObjectsToBaseline(bSet); break;// "Other/IsAlignMathObjectsToBaseline"
+ case 12: rParent.SetMetric((FieldUnit)nInt32Val, sal_True); break;// "Other/MeasureUnit",
+ case 13: rParent.SetDefTab(MM100_TO_TWIP(nInt32Val), sal_True); break;// "Other/TabStop",
+ case 14: rParent.SetVRulerRight(bSet); break;// "Window/IsVerticalRulerRight",
+ case 15: rParent.SetViewLayoutColumns( static_cast<sal_uInt16>(nInt32Val) ); break;// "ViewLayout/Columns",
+ case 16: rParent.SetViewLayoutBookMode(bSet); break;// "ViewLayout/BookMode",
+ case 17: rParent.SetDefaultPageMode(bSet,sal_True); break;// "Other/IsSquaredPageMode",
+ case 18: rParent.SetApplyCharUnit(bSet); break;// "Other/ApplyUserChar"
+ case 19: rParent.SetShowScrollBarTips(bSet); break;// "Window/ShowScrollBarTips",
+ }
+ }
+ }
+ }
+}
+
+void SwLayoutViewConfig::Notify( const ::com::sun::star::uno::Sequence< OUString >& ) {}
+
+Sequence<OUString> SwGridConfig::GetPropertyNames()
+{
+ static const char* aPropNames[] =
+ {
+ "Option/SnapToGrid", // 0
+ "Option/VisibleGrid", // 1
+ "Option/Synchronize", // 2
+ "Resolution/XAxis", // 3
+ "Resolution/YAxis", // 4
+ "Subdivision/XAxis", // 5
+ "Subdivision/YAxis" // 6
+ };
+ const int nCount = 7;
+ Sequence<OUString> aNames(nCount);
+ OUString* pNames = aNames.getArray();
+ for(int i = 0; i < nCount; i++)
+ {
+ pNames[i] = OUString::createFromAscii(aPropNames[i]);
+ }
+ return aNames;
+}
+
+SwGridConfig::SwGridConfig(sal_Bool bIsWeb, SwMasterUsrPref& rPar) :
+ ConfigItem(bIsWeb ? OUString("Office.WriterWeb/Grid") : OUString("Office.Writer/Grid"),
+ CONFIG_MODE_DELAYED_UPDATE|CONFIG_MODE_RELEASE_TREE),
+ rParent(rPar)
+{
+}
+
+SwGridConfig::~SwGridConfig()
+{
+}
+
+void SwGridConfig::Commit()
+{
+ Sequence<OUString> aNames = GetPropertyNames();
+
+ Sequence<Any> aValues(aNames.getLength());
+ Any* pValues = aValues.getArray();
+
+ for(int nProp = 0; nProp < aNames.getLength(); nProp++)
+ {
+ sal_Bool bSet;
+ switch(nProp)
+ {
+ case 0: bSet = rParent.IsSnap(); break;// "Option/SnapToGrid",
+ case 1: bSet = rParent.IsGridVisible(); break;//"Option/VisibleGrid",
+ case 2: bSet = rParent.IsSynchronize(); break;// "Option/Synchronize",
+ case 3: pValues[nProp] <<= (sal_Int32)TWIP_TO_MM100(rParent.GetSnapSize().Width()); break;// "Resolution/XAxis",
+ case 4: pValues[nProp] <<= (sal_Int32)TWIP_TO_MM100(rParent.GetSnapSize().Height()); break;// "Resolution/YAxis",
+ case 5: pValues[nProp] <<= (sal_Int16)rParent.GetDivisionX(); break;// "Subdivision/XAxis",
+ case 6: pValues[nProp] <<= (sal_Int16)rParent.GetDivisionY(); break;// "Subdivision/YAxis"
+ }
+ if(nProp < 3)
+ pValues[nProp].setValue(&bSet, ::getBooleanCppuType());
+ }
+ PutProperties(aNames, aValues);
+}
+
+void SwGridConfig::Load()
+{
+ Sequence<OUString> aNames = GetPropertyNames();
+ Sequence<Any> aValues = GetProperties(aNames);
+ const Any* pValues = aValues.getConstArray();
+ OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
+ if(aValues.getLength() == aNames.getLength())
+ {
+ Size aSnap(rParent.GetSnapSize());
+ for(int nProp = 0; nProp < aNames.getLength(); nProp++)
+ {
+ if(pValues[nProp].hasValue())
+ {
+ sal_Bool bSet = nProp < 3 ? *(sal_Bool*)pValues[nProp].getValue() : sal_False;
+ sal_Int32 nSet = 0;
+ if(nProp >= 3)
+ pValues[nProp] >>= nSet;
+ switch(nProp)
+ {
+ case 0: rParent.SetSnap(bSet); break;// "Option/SnapToGrid",
+ case 1: rParent.SetGridVisible(bSet); break;//"Option/VisibleGrid",
+ case 2: rParent.SetSynchronize(bSet); break;// "Option/Synchronize",
+ case 3: aSnap.Width() = MM100_TO_TWIP(nSet); break;// "Resolution/XAxis",
+ case 4: aSnap.Height() = MM100_TO_TWIP(nSet); break;// "Resolution/YAxis",
+ case 5: rParent.SetDivisionX((short)nSet); break;// "Subdivision/XAxis",
+ case 6: rParent.SetDivisionY((short)nSet); break;// "Subdivision/YAxis"
+ }
+ }
+ }
+ rParent.SetSnapSize(aSnap);
+ }
+}
+
+void SwGridConfig::Notify( const ::com::sun::star::uno::Sequence< OUString >& ) {}
+
+Sequence<OUString> SwCursorConfig::GetPropertyNames()
+{
+ static const char* aPropNames[] =
+ {
+ "DirectCursor/UseDirectCursor", // 0
+ "DirectCursor/Insert", // 1
+ "Option/ProtectedArea" // 2
+ };
+ const int nCount = 3;
+ Sequence<OUString> aNames(nCount);
+ OUString* pNames = aNames.getArray();
+ for(int i = 0; i < nCount; i++)
+ pNames[i] = OUString::createFromAscii(aPropNames[i]);
+ return aNames;
+}
+
+SwCursorConfig::SwCursorConfig(SwMasterUsrPref& rPar) :
+ ConfigItem("Office.Writer/Cursor",
+ CONFIG_MODE_DELAYED_UPDATE|CONFIG_MODE_RELEASE_TREE),
+ rParent(rPar)
+{
+}
+
+SwCursorConfig::~SwCursorConfig()
+{
+}
+
+void SwCursorConfig::Commit()
+{
+ Sequence<OUString> aNames = GetPropertyNames();
+
+ Sequence<Any> aValues(aNames.getLength());
+ Any* pValues = aValues.getArray();
+
+ for(int nProp = 0; nProp < aNames.getLength(); nProp++)
+ {
+ sal_Bool bSet;
+ switch(nProp)
+ {
+ case 0: bSet = rParent.IsShadowCursor(); break;// "DirectCursor/UseDirectCursor",
+ case 1: pValues[nProp] <<= (sal_Int32)rParent.GetShdwCrsrFillMode(); break;// "DirectCursor/Insert",
+ case 2: bSet = rParent.IsCursorInProtectedArea(); break;// "Option/ProtectedArea"
+ }
+ if(nProp != 1 )
+ pValues[nProp].setValue(&bSet, ::getBooleanCppuType());
+ }
+ PutProperties(aNames, aValues);
+}
+
+void SwCursorConfig::Load()
+{
+ Sequence<OUString> aNames = GetPropertyNames();
+ Sequence<Any> aValues = GetProperties(aNames);
+ const Any* pValues = aValues.getConstArray();
+ OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
+ if(aValues.getLength() == aNames.getLength())
+ {
+
+ for(int nProp = 0; nProp < aNames.getLength(); nProp++)
+ {
+ if(pValues[nProp].hasValue())
+ {
+ sal_Bool bSet = sal_False;
+ sal_Int32 nSet = 0;
+ if(nProp != 1 )
+ bSet = *(sal_Bool*)pValues[nProp].getValue();
+ else
+ pValues[nProp] >>= nSet;
+ switch(nProp)
+ {
+ case 0: rParent.SetShadowCursor(bSet); break;// "DirectCursor/UseDirectCursor",
+ case 1: rParent.SetShdwCrsrFillMode((sal_uInt8)nSet); break;// "DirectCursor/Insert",
+ case 2: rParent.SetCursorInProtectedArea(bSet); break;// "Option/ProtectedArea"
+ }
+ }
+ }
+
+ }
+}
+
+void SwCursorConfig::Notify( const ::com::sun::star::uno::Sequence< OUString >& ) {}
+
+SwWebColorConfig::SwWebColorConfig(SwMasterUsrPref& rPar) :
+ ConfigItem("Office.WriterWeb/Background",
+ CONFIG_MODE_DELAYED_UPDATE|CONFIG_MODE_RELEASE_TREE),
+ rParent(rPar),
+ aPropNames(1)
+{
+ aPropNames.getArray()[0] = "Color";
+}
+
+SwWebColorConfig::~SwWebColorConfig()
+{
+}
+
+void SwWebColorConfig::Commit()
+{
+ Sequence<Any> aValues(aPropNames.getLength());
+ Any* pValues = aValues.getArray();
+ for(int nProp = 0; nProp < aPropNames.getLength(); nProp++)
+ {
+ switch(nProp)
+ {
+ case 0: pValues[nProp] <<= (sal_Int32)rParent.GetRetoucheColor().GetColor(); break;// "Color",
+ }
+ }
+ PutProperties(aPropNames, aValues);
+}
+
+void SwWebColorConfig::Notify( const ::com::sun::star::uno::Sequence< OUString >& ) {}
+
+void SwWebColorConfig::Load()
+{
+ Sequence<Any> aValues = GetProperties(aPropNames);
+ const Any* pValues = aValues.getConstArray();
+ OSL_ENSURE(aValues.getLength() == aPropNames.getLength(), "GetProperties failed");
+ if(aValues.getLength() == aPropNames.getLength())
+ {
+ for(int nProp = 0; nProp < aPropNames.getLength(); nProp++)
+ {
+ if(pValues[nProp].hasValue())
+ {
+ switch(nProp)
+ {
+ case 0:
+ sal_Int32 nSet = 0;
+ pValues[nProp] >>= nSet; rParent.SetRetoucheColor(nSet);
+ break;// "Color",
+ }
+ }
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/config/viewopt.cxx b/sw/source/core/uibase/config/viewopt.cxx
new file mode 100644
index 000000000000..688e99829e64
--- /dev/null
+++ b/sw/source/core/uibase/config/viewopt.cxx
@@ -0,0 +1,550 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <sfx2/htmlmode.hxx>
+#include <svtools/htmlcfg.hxx>
+
+#include <svx/svxids.hrc>
+#include <editeng/svxenum.hxx>
+#include <editeng/svxacorr.hxx>
+#include <unotools/localedatawrapper.hxx>
+#include <vcl/region.hxx>
+#include <vcl/outdev.hxx>
+#include <vcl/window.hxx>
+#include <swmodule.hxx>
+#include <swtypes.hxx>
+#include <viewopt.hxx>
+#include <wdocsh.hxx>
+#include <swrect.hxx>
+#include <crstate.hxx>
+#include <svtools/colorcfg.hxx>
+#include <svtools/accessibilityoptions.hxx>
+#include <unotools/syslocale.hxx>
+
+#include <editeng/acorrcfg.hxx>
+
+#ifdef DBG_UTIL
+bool SwViewOption::s_bTest9 = false; //DrawingLayerNotLoading
+#endif
+Color SwViewOption::aDocBoundColor(COL_LIGHTGRAY);
+Color SwViewOption::aObjectBoundColor(COL_LIGHTGRAY);
+Color SwViewOption::aDocColor(COL_LIGHTGRAY);
+Color SwViewOption::aAppBackgroundColor(COL_LIGHTGRAY);
+Color SwViewOption::aTableBoundColor(COL_LIGHTGRAY);
+Color SwViewOption::aIndexShadingsColor(COL_LIGHTGRAY);
+Color SwViewOption::aLinksColor(COL_BLUE);
+Color SwViewOption::aVisitedLinksColor(COL_RED);
+Color SwViewOption::aDirectCursorColor(COL_BLUE);
+Color SwViewOption::aTextGridColor(COL_LIGHTGRAY);
+Color SwViewOption::aSpellColor(COL_LIGHTRED);
+Color SwViewOption::aSmarttagColor(COL_LIGHTMAGENTA);
+Color SwViewOption::aFontColor(COL_BLACK);
+Color SwViewOption::aFieldShadingsColor(COL_LIGHTGRAY);
+Color SwViewOption::aSectionBoundColor(COL_LIGHTGRAY);
+Color SwViewOption::aPageBreakColor(COL_BLUE);
+Color SwViewOption::aScriptIndicatorColor(COL_GREEN);
+Color SwViewOption::aShadowColor(COL_GRAY);
+Color SwViewOption::aHeaderFooterMarkColor(COL_BLUE);
+
+sal_Int32 SwViewOption::nAppearanceFlags = VIEWOPT_DOC_BOUNDARIES|VIEWOPT_OBJECT_BOUNDARIES;
+sal_uInt16 SwViewOption::nPixelTwips = 0; // one pixel on the screen
+
+static const char aPostItStr[] = " ";
+
+bool SwViewOption::IsEqualFlags( const SwViewOption &rOpt ) const
+{
+ return nCoreOptions == rOpt.nCoreOptions
+ && nCore2Options == rOpt.nCore2Options
+ && aSnapSize == rOpt.aSnapSize
+ && mnViewLayoutColumns == rOpt.mnViewLayoutColumns
+ && nDivisionX == rOpt.GetDivisionX()
+ && nDivisionY == rOpt.GetDivisionY()
+ && nPagePrevRow == rOpt.GetPagePrevRow()
+ && nPagePrevCol == rOpt.GetPagePrevCol()
+ && aRetoucheColor == rOpt.GetRetoucheColor()
+ && mbFormView == rOpt.IsFormView()
+ && mbBrowseMode == rOpt.getBrowseMode()
+ && mbViewLayoutBookMode == rOpt.mbViewLayoutBookMode
+ && bShowPlaceHolderFields == rOpt.bShowPlaceHolderFields
+ && bIdle == rOpt.bIdle
+#ifdef DBG_UTIL
+ // correspond to the statements in ui/config/cfgvw.src
+ && m_bTest1 == rOpt.IsTest1()
+ && m_bTest2 == rOpt.IsTest2()
+ && m_bTest3 == rOpt.IsTest3()
+ && m_bTest4 == rOpt.IsTest4()
+ && m_bTest5 == rOpt.IsTest5()
+ && m_bTest6 == rOpt.IsTest6()
+ && m_bTest7 == rOpt.IsTest7()
+ && m_bTest8 == rOpt.IsTest8()
+ && m_bTest10 == rOpt.IsTest10()
+#endif
+ ;
+}
+
+void SwViewOption::DrawRect( OutputDevice *pOut,
+ const SwRect &rRect, long nCol ) const
+{
+ if ( pOut->GetOutDevType() != OUTDEV_PRINTER )
+ {
+ const Color aCol( nCol );
+ const Color aOldColor( pOut->GetFillColor() );
+ pOut->SetFillColor( aCol );
+ pOut->DrawRect( rRect.SVRect() );
+ pOut->SetFillColor( aOldColor );
+ }
+ else
+ DrawRectPrinter( pOut, rRect );
+}
+
+void SwViewOption::DrawRectPrinter( OutputDevice *pOut,
+ const SwRect &rRect ) const
+{
+ Color aOldColor(pOut->GetLineColor());
+ Color aOldFillColor( pOut->GetFillColor() );
+ pOut->SetLineColor( Color(COL_BLACK) );
+ pOut->SetFillColor( Color(COL_TRANSPARENT ));
+ pOut->DrawRect( rRect.SVRect() );
+ pOut->SetFillColor( aOldFillColor );
+ pOut->SetLineColor( aOldColor );
+}
+
+sal_uInt16 SwViewOption::GetPostItsWidth( const OutputDevice *pOut ) const
+{
+ OSL_ENSURE( pOut, "no Outdev" );
+ return sal_uInt16(pOut->GetTextWidth( OUString(aPostItStr )));
+}
+
+void SwViewOption::PaintPostIts( OutputDevice *pOut, const SwRect &rRect, sal_Bool bIsScript ) const
+{
+ if( pOut && bIsScript )
+ {
+ Color aOldLineColor( pOut->GetLineColor() );
+ pOut->SetLineColor( Color(COL_GRAY ) );
+ // to make it look nice, we subtract two pixels everywhere
+ sal_uInt16 nPix = GetPixelTwips() * 2;
+ if( rRect.Width() <= 2 * nPix || rRect.Height() <= 2 * nPix )
+ nPix = 0;
+ const Point aTopLeft( rRect.Left() + nPix, rRect.Top() + nPix );
+ const Point aBotRight( rRect.Right() - nPix, rRect.Bottom() - nPix );
+ const SwRect aRect( aTopLeft, aBotRight );
+ DrawRect( pOut, aRect, aScriptIndicatorColor.GetColor() );
+ pOut->SetLineColor( aOldLineColor );
+ }
+}
+
+SwViewOption::SwViewOption() :
+ sSymbolFont( "symbol" ),
+ aRetoucheColor( COL_TRANSPARENT ),
+ mnViewLayoutColumns( 0 ),
+ nPagePrevRow( 1 ),
+ nPagePrevCol( 2 ),
+ nShdwCrsrFillMode( FILL_TAB ),
+ bReadonly(sal_False),
+ bStarOneSetting(sal_False),
+ bIsPagePreview(sal_False),
+ bSelectionInReadonly(sal_False),
+ mbFormView(sal_False),
+ mbBrowseMode(sal_False),
+ mbBookView(sal_False),
+ mbViewLayoutBookMode(sal_False),
+ bShowPlaceHolderFields( sal_True ),
+ nZoom( 100 ),
+ eZoom( SVX_ZOOM_PERCENT ),
+ nTblDest(TBL_DEST_CELL)
+{
+ // Initialisation is a little simpler now
+ // all Bits to 0
+ nCoreOptions =
+ VIEWOPT_1_HARDBLANK |
+ VIEWOPT_1_SOFTHYPH |
+ VIEWOPT_1_REF |
+ VIEWOPT_1_GRAPHIC |
+ VIEWOPT_1_TABLE |
+ VIEWOPT_1_DRAW |
+ VIEWOPT_1_CONTROL |
+ VIEWOPT_1_PAGEBACK |
+ VIEWOPT_1_POSTITS;
+
+ nCore2Options =
+ VIEWOPT_CORE2_BLACKFONT |
+ VIEWOPT_CORE2_HIDDENPARA;
+
+ nUIOptions =
+ VIEWOPT_2_MODIFIED |
+ VIEWOPT_2_GRFKEEPZOOM |
+ VIEWOPT_2_ANY_RULER;
+
+ if(MEASURE_METRIC != SvtSysLocale().GetLocaleData().getMeasurementSystemEnum())
+ aSnapSize.Width() = aSnapSize.Height() = 720; // 1/2"
+ else
+ aSnapSize.Width() = aSnapSize.Height() = 567; // 1 cm
+ nDivisionX = nDivisionY = 1;
+
+ bSelectionInReadonly = SW_MOD()->GetAccessibilityOptions().IsSelectionInReadonly();
+
+ bIdle = true;
+
+#ifdef DBG_UTIL
+ // correspond to the statements in ui/config/cfgvw.src
+ m_bTest1 = m_bTest2 = m_bTest3 = m_bTest4 =
+ m_bTest5 = m_bTest6 = m_bTest7 = m_bTest8 = m_bTest10 = false;
+#endif
+}
+
+SwViewOption::SwViewOption(const SwViewOption& rVOpt)
+{
+ bReadonly = sal_False;
+ bSelectionInReadonly = sal_False;
+ // #114856# Formular view
+ mbFormView = rVOpt.mbFormView;
+ nZoom = rVOpt.nZoom ;
+ aSnapSize = rVOpt.aSnapSize ;
+ mnViewLayoutColumns = rVOpt.mnViewLayoutColumns ;
+ nDivisionX = rVOpt.nDivisionX ;
+ nDivisionY = rVOpt.nDivisionY ;
+ nPagePrevRow = rVOpt.nPagePrevRow;
+ nPagePrevCol = rVOpt.nPagePrevCol;
+ bIsPagePreview = rVOpt.bIsPagePreview;
+ eZoom = rVOpt.eZoom ;
+ nTblDest = rVOpt.nTblDest ;
+ nUIOptions = rVOpt.nUIOptions ;
+ nCoreOptions = rVOpt.nCoreOptions ;
+ nCore2Options = rVOpt.nCore2Options ;
+ aRetoucheColor = rVOpt.GetRetoucheColor();
+ sSymbolFont = rVOpt.sSymbolFont;
+ nShdwCrsrFillMode = rVOpt.nShdwCrsrFillMode;
+ bStarOneSetting = rVOpt.bStarOneSetting;
+ mbBookView = rVOpt.mbBookView;
+ mbBrowseMode = rVOpt.mbBrowseMode;
+ mbViewLayoutBookMode = rVOpt.mbViewLayoutBookMode;
+ bShowPlaceHolderFields = rVOpt.bShowPlaceHolderFields;
+ bIdle = rVOpt.bIdle;
+
+#ifdef DBG_UTIL
+ m_bTest1 = rVOpt.m_bTest1;
+ m_bTest2 = rVOpt.m_bTest2;
+ m_bTest3 = rVOpt.m_bTest3;
+ m_bTest4 = rVOpt.m_bTest4;
+ m_bTest5 = rVOpt.m_bTest5;
+ m_bTest6 = rVOpt.m_bTest6;
+ m_bTest7 = rVOpt.m_bTest7;
+ m_bTest8 = rVOpt.m_bTest8;
+ m_bTest10 = rVOpt.m_bTest10;
+#endif
+}
+
+SwViewOption& SwViewOption::operator=( const SwViewOption &rVOpt )
+{
+ // #114856# Formular view
+ mbFormView = rVOpt.mbFormView ;
+ nZoom = rVOpt.nZoom ;
+ aSnapSize = rVOpt.aSnapSize ;
+ mnViewLayoutColumns = rVOpt.mnViewLayoutColumns ;
+ nDivisionX = rVOpt.nDivisionX ;
+ nDivisionY = rVOpt.nDivisionY ;
+ nPagePrevRow = rVOpt.nPagePrevRow;
+ nPagePrevCol = rVOpt.nPagePrevCol;
+ bIsPagePreview = rVOpt.bIsPagePreview;
+ eZoom = rVOpt.eZoom ;
+ nTblDest = rVOpt.nTblDest ;
+ nUIOptions = rVOpt.nUIOptions ;
+ nCoreOptions = rVOpt.nCoreOptions;
+ nCore2Options = rVOpt.nCore2Options;
+ aRetoucheColor = rVOpt.GetRetoucheColor();
+ sSymbolFont = rVOpt.sSymbolFont;
+ nShdwCrsrFillMode = rVOpt.nShdwCrsrFillMode;
+ bStarOneSetting = rVOpt.bStarOneSetting;
+ mbBookView = rVOpt.mbBookView;
+ mbBrowseMode = rVOpt.mbBrowseMode;
+ mbViewLayoutBookMode = rVOpt.mbViewLayoutBookMode;
+ bShowPlaceHolderFields = rVOpt.bShowPlaceHolderFields;
+ bIdle = rVOpt.bIdle;
+
+#ifdef DBG_UTIL
+ m_bTest1 = rVOpt.m_bTest1;
+ m_bTest2 = rVOpt.m_bTest2;
+ m_bTest3 = rVOpt.m_bTest3;
+ m_bTest4 = rVOpt.m_bTest4;
+ m_bTest5 = rVOpt.m_bTest5;
+ m_bTest6 = rVOpt.m_bTest6;
+ m_bTest7 = rVOpt.m_bTest7;
+ m_bTest8 = rVOpt.m_bTest8;
+ m_bTest10 = rVOpt.m_bTest10;
+#endif
+ return *this;
+}
+
+SwViewOption::~SwViewOption()
+{
+}
+
+void SwViewOption::Init( Window *pWin )
+{
+ if( !nPixelTwips && pWin )
+ {
+ nPixelTwips = (sal_uInt16)pWin->PixelToLogic( Size(1,1) ).Height();
+ }
+}
+
+sal_Bool SwViewOption::IsAutoCompleteWords() const
+{
+ const SvxSwAutoFmtFlags& rFlags = SvxAutoCorrCfg::Get().GetAutoCorrect()->GetSwFlags();
+ return rFlags.bAutoCmpltCollectWords;
+}
+
+AuthorCharAttr::AuthorCharAttr() :
+ nItemId (SID_ATTR_CHAR_UNDERLINE),
+ nAttr (UNDERLINE_SINGLE),
+ nColor (COL_TRANSPARENT)
+{
+}
+
+sal_uInt16 GetHtmlMode(const SwDocShell* pShell)
+{
+ sal_uInt16 nRet = 0;
+ if(!pShell || PTR_CAST(SwWebDocShell, pShell))
+ {
+ nRet = HTMLMODE_ON | HTMLMODE_SOME_STYLES;
+ SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get();
+ switch ( rHtmlOpt.GetExportMode() )
+ {
+ case HTML_CFG_MSIE:
+ nRet |= HTMLMODE_FULL_STYLES;
+ break;
+ case HTML_CFG_NS40:
+ // no special features for this browser
+ break;
+ case HTML_CFG_WRITER:
+ nRet |= HTMLMODE_FULL_STYLES;
+ break;
+ }
+ }
+ return nRet;
+}
+
+Color& SwViewOption::GetDocColor()
+{
+ return aDocColor;
+}
+
+Color& SwViewOption::GetDocBoundariesColor()
+{
+ return aDocBoundColor;
+}
+
+Color& SwViewOption::GetObjectBoundariesColor()
+{
+ return aObjectBoundColor;
+}
+
+Color& SwViewOption::GetAppBackgroundColor()
+{
+ return aAppBackgroundColor;
+}
+
+Color& SwViewOption::GetTableBoundariesColor()
+{
+ return aTableBoundColor;
+}
+
+Color& SwViewOption::GetIndexShadingsColor()
+{
+ return aIndexShadingsColor;
+}
+
+Color& SwViewOption::GetLinksColor()
+{
+ return aLinksColor;
+}
+
+Color& SwViewOption::GetVisitedLinksColor()
+{
+ return aVisitedLinksColor;
+}
+
+Color& SwViewOption::GetDirectCursorColor()
+{
+ return aDirectCursorColor;
+}
+
+Color& SwViewOption::GetTextGridColor()
+{
+ return aTextGridColor;
+}
+
+Color& SwViewOption::GetSpellColor()
+{
+ return aSpellColor;
+}
+
+Color& SwViewOption::GetSmarttagColor()
+{
+ return aSmarttagColor;
+}
+
+Color& SwViewOption::GetShadowColor()
+{
+ return aShadowColor;
+}
+
+Color& SwViewOption::GetFontColor()
+{
+ return aFontColor;
+}
+
+Color& SwViewOption::GetFieldShadingsColor()
+{
+ return aFieldShadingsColor;
+}
+
+Color& SwViewOption::GetSectionBoundColor()
+{
+ return aSectionBoundColor;
+}
+
+Color& SwViewOption::GetPageBreakColor()
+{
+ return aPageBreakColor;
+}
+
+Color& SwViewOption::GetHeaderFooterMarkColor()
+{
+ return aHeaderFooterMarkColor;
+}
+
+void SwViewOption::ApplyColorConfigValues(const svtools::ColorConfig& rConfig )
+{
+ aDocColor.SetColor(rConfig.GetColorValue(svtools::DOCCOLOR).nColor);
+
+ svtools::ColorConfigValue aValue = rConfig.GetColorValue(svtools::DOCBOUNDARIES);
+ aDocBoundColor.SetColor(aValue.nColor);
+ nAppearanceFlags = 0;
+ if(aValue.bIsVisible)
+ nAppearanceFlags |= VIEWOPT_DOC_BOUNDARIES;
+
+ aAppBackgroundColor.SetColor(rConfig.GetColorValue(svtools::APPBACKGROUND).nColor);
+
+ aValue = rConfig.GetColorValue(svtools::OBJECTBOUNDARIES);
+ aObjectBoundColor.SetColor(aValue.nColor);
+ if(aValue.bIsVisible)
+ nAppearanceFlags |= VIEWOPT_OBJECT_BOUNDARIES;
+
+ aValue = rConfig.GetColorValue(svtools::TABLEBOUNDARIES);
+ aTableBoundColor.SetColor(aValue.nColor);
+ if(aValue.bIsVisible)
+ nAppearanceFlags |= VIEWOPT_TABLE_BOUNDARIES;
+
+ aValue = rConfig.GetColorValue(svtools::WRITERIDXSHADINGS);
+ aIndexShadingsColor.SetColor(aValue.nColor);
+ if(aValue.bIsVisible)
+ nAppearanceFlags |= VIEWOPT_INDEX_SHADINGS;
+
+ aValue = rConfig.GetColorValue(svtools::LINKS);
+ aLinksColor.SetColor(aValue.nColor);
+ if(aValue.bIsVisible)
+ nAppearanceFlags |= VIEWOPT_LINKS;
+
+ aValue = rConfig.GetColorValue(svtools::LINKSVISITED);
+ aVisitedLinksColor.SetColor(aValue.nColor);
+ if(aValue.bIsVisible)
+ nAppearanceFlags |= VIEWOPT_VISITED_LINKS;
+
+ aValue = rConfig.GetColorValue(svtools::SHADOWCOLOR);
+ aShadowColor.SetColor(aValue.nColor);
+ if(aValue.bIsVisible)
+ nAppearanceFlags |= VIEWOPT_SHADOW;
+
+ aDirectCursorColor.SetColor(rConfig.GetColorValue(svtools::WRITERDIRECTCURSOR).nColor);
+
+ aTextGridColor.SetColor(rConfig.GetColorValue(svtools::WRITERTEXTGRID).nColor);
+
+ aSpellColor.SetColor(rConfig.GetColorValue(svtools::SPELL).nColor);
+
+ aSmarttagColor.SetColor(rConfig.GetColorValue(svtools::SMARTTAGS).nColor);
+
+ aFontColor.SetColor(rConfig.GetColorValue(svtools::FONTCOLOR).nColor);
+
+ aValue = rConfig.GetColorValue(svtools::WRITERFIELDSHADINGS);
+ aFieldShadingsColor.SetColor(aValue.nColor);
+ if(aValue.bIsVisible)
+ nAppearanceFlags |= VIEWOPT_FIELD_SHADINGS;
+
+ aValue = rConfig.GetColorValue(svtools::WRITERSECTIONBOUNDARIES);
+ aSectionBoundColor.SetColor(aValue.nColor);
+ if(aValue.bIsVisible)
+ nAppearanceFlags |= VIEWOPT_SECTION_BOUNDARIES;
+
+ aValue = rConfig.GetColorValue(svtools::WRITERPAGEBREAKS);
+ aPageBreakColor.SetColor(aValue.nColor);
+
+ aValue = rConfig.GetColorValue(svtools::WRITERHEADERFOOTERMARK);
+ aHeaderFooterMarkColor.SetColor(aValue.nColor);
+
+ aScriptIndicatorColor.SetColor(rConfig.GetColorValue(svtools::WRITERSCRIPTINDICATOR).nColor);
+}
+
+void SwViewOption::SetAppearanceFlag(sal_Int32 nFlag, sal_Bool bSet, sal_Bool bSaveInConfig )
+{
+ if(bSet)
+ nAppearanceFlags |= nFlag;
+ else
+ nAppearanceFlags &= ~nFlag;
+ if(bSaveInConfig)
+ {
+ //create an editable svtools::ColorConfig and store the change
+ svtools::EditableColorConfig aEditableConfig;
+ struct FlagToConfig_Impl
+ {
+ sal_Int32 nFlag;
+ svtools::ColorConfigEntry eEntry;
+ };
+ static const FlagToConfig_Impl aFlags[] =
+ {
+ { VIEWOPT_DOC_BOUNDARIES , svtools::DOCBOUNDARIES },
+ { VIEWOPT_OBJECT_BOUNDARIES , svtools::OBJECTBOUNDARIES },
+ { VIEWOPT_TABLE_BOUNDARIES , svtools::TABLEBOUNDARIES },
+ { VIEWOPT_INDEX_SHADINGS , svtools::WRITERIDXSHADINGS },
+ { VIEWOPT_LINKS , svtools::LINKS },
+ { VIEWOPT_VISITED_LINKS , svtools::LINKSVISITED },
+ { VIEWOPT_FIELD_SHADINGS , svtools::WRITERFIELDSHADINGS },
+ { VIEWOPT_SECTION_BOUNDARIES , svtools::WRITERSECTIONBOUNDARIES },
+ { VIEWOPT_SHADOW , svtools::SHADOWCOLOR },
+ { 0 , svtools::ColorConfigEntryCount }
+ };
+ sal_uInt16 nPos = 0;
+ while(aFlags[nPos].nFlag)
+ {
+ if(0 != (nFlag&aFlags[nPos].nFlag))
+ {
+ svtools::ColorConfigValue aValue = aEditableConfig.GetColorValue(aFlags[nPos].eEntry);
+ aValue.bIsVisible = bSet;
+ aEditableConfig.SetColorValue(aFlags[nPos].eEntry, aValue);
+ }
+ nPos++;
+ }
+ }
+}
+
+sal_Bool SwViewOption::IsAppearanceFlag(sal_Int32 nFlag)
+{
+ return 0 != (nAppearanceFlags & nFlag);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/dbui/dbmgr.cxx b/sw/source/core/uibase/dbui/dbmgr.cxx
new file mode 100644
index 000000000000..2905c6799529
--- /dev/null
+++ b/sw/source/core/uibase/dbui/dbmgr.cxx
@@ -0,0 +1,2960 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <cstdarg>
+
+#include <stdio.h>
+#include <unotxdoc.hxx>
+#include <com/sun/star/text/NotePrintMode.hpp>
+#include <sfx2/app.hxx>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdb/XDocumentDataSource.hpp>
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/lang/XEventListener.hpp>
+#include <com/sun/star/util/NumberFormatter.hpp>
+#include <com/sun/star/sdb/DatabaseContext.hpp>
+#include <com/sun/star/sdb/TextConnectionSettings.hpp>
+#include <com/sun/star/sdb/XCompletedConnection.hpp>
+#include <com/sun/star/sdb/XCompletedExecution.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/text/MailMergeEvent.hpp>
+#include <com/sun/star/frame/XStorable.hpp>
+#include <com/sun/star/task/InteractionHandler.hpp>
+#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
+#include <com/sun/star/ui/dialogs/XFilePicker.hpp>
+#include <com/sun/star/ui/dialogs/XFilterManager.hpp>
+#include <com/sun/star/uno/XNamingService.hpp>
+#include <com/sun/star/util/XCloseable.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <sfx2/fcontnr.hxx>
+#include <sfx2/filedlghelper.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <dbconfig.hxx>
+#include <swdbtoolsclient.hxx>
+#include <pagedesc.hxx>
+#include <vcl/lstbox.hxx>
+#include <unotools/tempfile.hxx>
+#include <unotools/pathoptions.hxx>
+#include <svl/urihelper.hxx>
+#include <svl/zforlist.hxx>
+#include <svl/zformat.hxx>
+#include <svl/stritem.hxx>
+#include <svl/eitem.hxx>
+#include <vcl/oldprintadaptor.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/progress.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svl/mailenum.hxx>
+#include <cmdid.h>
+#include <swmodule.hxx>
+#include <view.hxx>
+#include <docsh.hxx>
+#include <edtwin.hxx>
+#include <wrtsh.hxx>
+#include <fldbas.hxx>
+#include <initui.hxx>
+#include <swundo.hxx>
+#include <flddat.hxx>
+#include <modcfg.hxx>
+#include <shellio.hxx>
+#include <dbui.hxx>
+#include <dbmgr.hxx>
+#include <doc.hxx>
+#include <swwait.hxx>
+#include <swunohelper.hxx>
+#include <dbui.hrc>
+#include <globals.hrc>
+#include <statstr.hrc>
+#include <mmconfigitem.hxx>
+#include <sfx2/request.hxx>
+#include <hintids.hxx>
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include <com/sun/star/sdbc/XRowSet.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdb/XQueriesSupplier.hpp>
+#include <com/sun/star/sdb/XColumn.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+#include <com/sun/star/mail/MailAttachment.hpp>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/property.hxx>
+#include <comphelper/string.hxx>
+#include <comphelper/types.hxx>
+#include <mailmergehelper.hxx>
+#include <maildispatcher.hxx>
+#include <svtools/htmlcfg.hxx>
+#include <i18nlangtag/languagetag.hxx>
+#include <com/sun/star/util/XNumberFormatTypes.hpp>
+#include <editeng/langitem.hxx>
+#include <svl/numuno.hxx>
+
+#include <unomailmerge.hxx>
+#include <sfx2/event.hxx>
+#include <vcl/msgbox.hxx>
+#include <svx/dataaccessdescriptor.hxx>
+#include <osl/mutex.hxx>
+#include <rtl/textenc.h>
+#include <ndindex.hxx>
+#include <pam.hxx>
+#include <swcrsr.hxx>
+#include <swevent.hxx>
+#include <osl/file.hxx>
+#include <swabstdlg.hxx>
+#include <fmthdft.hxx>
+#include <envelp.hrc>
+#include <vector>
+#include <unomid.h>
+#include <section.hxx>
+#include <rootfrm.hxx>
+
+#include <boost/scoped_ptr.hpp>
+
+using namespace ::osl;
+using namespace ::svx;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::text;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::task;
+using namespace ::com::sun::star::ui::dialogs;
+
+#define DB_SEP_SPACE 0
+#define DB_SEP_TAB 1
+#define DB_SEP_RETURN 2
+#define DB_SEP_NEWLINE 3
+
+const sal_Char cCursor[] = "Cursor";
+const sal_Char cCommand[] = "Command";
+const sal_Char cCommandType[] = "CommandType";
+const sal_Char cDataSourceName[] = "DataSourceName";
+const sal_Char cSelection[] = "Selection";
+const sal_Char cActiveConnection[] = "ActiveConnection";
+
+// Use nameless namespace to avoid to rubbish the global namespace
+
+namespace
+{
+
+bool lcl_getCountFromResultSet( sal_Int32& rCount, const uno::Reference<XResultSet>& xResultSet )
+{
+ uno::Reference<XPropertySet> xPrSet(xResultSet, UNO_QUERY);
+ if(xPrSet.is())
+ {
+ try
+ {
+ sal_Bool bFinal = sal_False;
+ Any aFinal = xPrSet->getPropertyValue("IsRowCountFinal");
+ aFinal >>= bFinal;
+ if(!bFinal)
+ {
+ xResultSet->last();
+ xResultSet->first();
+ }
+ Any aCount = xPrSet->getPropertyValue("RowCount");
+ if( aCount >>= rCount )
+ return true;
+ }
+ catch(const Exception&)
+ {
+ }
+ }
+ return false;
+}
+// copy compatibility options
+void lcl_CopyCompatibilityOptions( SwWrtShell& rSourceShell, SwWrtShell& rTargetShell)
+{
+ IDocumentSettingAccess* pIDsa = rSourceShell.getIDocumentSettingAccess();
+
+ rTargetShell.SetParaSpaceMax( pIDsa->get(IDocumentSettingAccess::PARA_SPACE_MAX));
+ rTargetShell.SetParaSpaceMaxAtPages(pIDsa->get(IDocumentSettingAccess::PARA_SPACE_MAX_AT_PAGES));
+ rTargetShell.SetTabCompat( pIDsa->get(IDocumentSettingAccess::TAB_COMPAT));
+ rTargetShell.SetAddExtLeading( pIDsa->get(IDocumentSettingAccess::ADD_EXT_LEADING));
+ rTargetShell.SetUseVirDev( pIDsa->get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE));
+ rTargetShell.SetAddParaSpacingToTableCells( pIDsa->get(IDocumentSettingAccess::ADD_PARA_SPACING_TO_TABLE_CELLS));
+ rTargetShell.SetUseFormerLineSpacing( pIDsa->get(IDocumentSettingAccess::OLD_LINE_SPACING));
+ rTargetShell.SetUseFormerObjectPositioning( pIDsa->get(IDocumentSettingAccess::USE_FORMER_OBJECT_POS));
+ rTargetShell.SetConsiderWrapOnObjPos( pIDsa->get(IDocumentSettingAccess::CONSIDER_WRAP_ON_OBJECT_POSITION));
+ rTargetShell.SetUseFormerTextWrapping( pIDsa->get(IDocumentSettingAccess::USE_FORMER_TEXT_WRAPPING));
+}
+}
+
+class SwConnectionDisposedListener_Impl : public cppu::WeakImplHelper1
+< lang::XEventListener >
+{
+ SwNewDBMgr& rDBMgr;
+
+ virtual void SAL_CALL disposing( const EventObject& Source ) throw (RuntimeException, std::exception);
+public:
+ SwConnectionDisposedListener_Impl(SwNewDBMgr& rMgr);
+ ~SwConnectionDisposedListener_Impl();
+
+};
+
+struct SwNewDBMgr_Impl
+{
+ SwDSParam* pMergeData;
+ AbstractMailMergeDlg* pMergeDialog;
+ uno::Reference<lang::XEventListener> xDisposeListener;
+
+ SwNewDBMgr_Impl(SwNewDBMgr& rDBMgr)
+ :pMergeData(0)
+ ,pMergeDialog(0)
+ ,xDisposeListener(new SwConnectionDisposedListener_Impl(rDBMgr))
+ {}
+};
+
+static void lcl_InitNumberFormatter(SwDSParam& rParam, uno::Reference<XDataSource> xSource)
+{
+ uno::Reference<XComponentContext> xContext = ::comphelper::getProcessComponentContext();
+ rParam.xFormatter = uno::Reference<util::XNumberFormatter>(util::NumberFormatter::create(xContext), UNO_QUERY);
+ if(!xSource.is())
+ xSource = SwNewDBMgr::getDataSourceAsParent(rParam.xConnection, rParam.sDataSource);
+
+ uno::Reference<XPropertySet> xSourceProps(xSource, UNO_QUERY);
+ if(xSourceProps.is())
+ {
+ Any aFormats = xSourceProps->getPropertyValue("NumberFormatsSupplier");
+ if(aFormats.hasValue())
+ {
+ uno::Reference<XNumberFormatsSupplier> xSuppl;
+ aFormats >>= xSuppl;
+ if(xSuppl.is())
+ {
+ uno::Reference< XPropertySet > xSettings = xSuppl->getNumberFormatSettings();
+ Any aNull = xSettings->getPropertyValue("NullDate");
+ aNull >>= rParam.aNullDate;
+ if(rParam.xFormatter.is())
+ rParam.xFormatter->attachNumberFormatsSupplier(xSuppl);
+ }
+ }
+ }
+}
+
+static sal_Bool lcl_MoveAbsolute(SwDSParam* pParam, long nAbsPos)
+{
+ sal_Bool bRet = sal_False;
+ try
+ {
+ if(pParam->bScrollable)
+ {
+ bRet = pParam->xResultSet->absolute( nAbsPos );
+ }
+ else
+ {
+ OSL_FAIL("no absolute positioning available");
+ }
+ }
+ catch(const Exception&)
+ {
+ }
+ return bRet;
+}
+
+static sal_Bool lcl_GetColumnCnt(SwDSParam* pParam,
+ const OUString& rColumnName, long nLanguage, OUString& rResult, double* pNumber)
+{
+ uno::Reference< XColumnsSupplier > xColsSupp( pParam->xResultSet, UNO_QUERY );
+ uno::Reference<XNameAccess> xCols;
+ try
+ {
+ xCols = xColsSupp->getColumns();
+ }
+ catch(const lang::DisposedException&)
+ {
+ }
+ if(!xCols.is() || !xCols->hasByName(rColumnName))
+ return sal_False;
+ Any aCol = xCols->getByName(rColumnName);
+ uno::Reference< XPropertySet > xColumnProps;
+ aCol >>= xColumnProps;
+
+ SwDBFormatData aFormatData;
+ if(!pParam->xFormatter.is())
+ {
+ uno::Reference<XDataSource> xSource = SwNewDBMgr::getDataSourceAsParent(
+ pParam->xConnection,pParam->sDataSource);
+ lcl_InitNumberFormatter(*pParam, xSource );
+ }
+ aFormatData.aNullDate = pParam->aNullDate;
+ aFormatData.xFormatter = pParam->xFormatter;
+
+ aFormatData.aLocale = LanguageTag( (LanguageType)nLanguage ).getLocale();
+
+ rResult = SwNewDBMgr::GetDBField( xColumnProps, aFormatData, pNumber);
+ return sal_True;
+};
+
+/*--------------------------------------------------------------------
+ Description: import data
+ --------------------------------------------------------------------*/
+sal_Bool SwNewDBMgr::MergeNew(const SwMergeDescriptor& rMergeDesc )
+{
+ OSL_ENSURE(!bInMerge && !pImpl->pMergeData, "merge already activated!");
+
+ SwDBData aData;
+ aData.nCommandType = CommandType::TABLE;
+ uno::Reference<XResultSet> xResSet;
+ Sequence<Any> aSelection;
+ uno::Reference< XConnection> xConnection;
+
+ aData.sDataSource = rMergeDesc.rDescriptor.getDataSource();
+ rMergeDesc.rDescriptor[daCommand] >>= aData.sCommand;
+ rMergeDesc.rDescriptor[daCommandType] >>= aData.nCommandType;
+
+ if ( rMergeDesc.rDescriptor.has(daCursor) )
+ rMergeDesc.rDescriptor[daCursor] >>= xResSet;
+ if ( rMergeDesc.rDescriptor.has(daSelection) )
+ rMergeDesc.rDescriptor[daSelection] >>= aSelection;
+ if ( rMergeDesc.rDescriptor.has(daConnection) )
+ rMergeDesc.rDescriptor[daConnection] >>= xConnection;
+
+ if(aData.sDataSource.isEmpty() || aData.sCommand.isEmpty() || !xResSet.is())
+ {
+ return sal_False;
+ }
+
+ pImpl->pMergeData = new SwDSParam(aData, xResSet, aSelection);
+ SwDSParam* pTemp = FindDSData(aData, sal_False);
+ if(pTemp)
+ *pTemp = *pImpl->pMergeData;
+ else
+ {
+ // calls from the calculator may have added a connection with an invalid commandtype
+ //"real" data base connections added here have to re-use the already available
+ //DSData and set the correct CommandType
+ SwDBData aTempData(aData);
+ aData.nCommandType = -1;
+ pTemp = FindDSData(aData, sal_False);
+ if(pTemp)
+ *pTemp = *pImpl->pMergeData;
+ else
+ {
+ SwDSParam* pInsert = new SwDSParam(*pImpl->pMergeData);
+ aDataSourceParams.push_back(pInsert);
+ try
+ {
+ uno::Reference<XComponent> xComponent(pInsert->xConnection, UNO_QUERY);
+ if(xComponent.is())
+ xComponent->addEventListener(pImpl->xDisposeListener);
+ }
+ catch(const Exception&)
+ {
+ }
+ }
+ }
+ if(!pImpl->pMergeData->xConnection.is())
+ pImpl->pMergeData->xConnection = xConnection;
+ // add an XEventListener
+
+ try{
+ //set to start position
+ if(pImpl->pMergeData->aSelection.getLength())
+ {
+ sal_Int32 nPos = 0;
+ pImpl->pMergeData->aSelection.getConstArray()[ pImpl->pMergeData->nSelectionIndex++ ] >>= nPos;
+ pImpl->pMergeData->bEndOfDB = !pImpl->pMergeData->xResultSet->absolute( nPos );
+ pImpl->pMergeData->CheckEndOfDB();
+ if(pImpl->pMergeData->nSelectionIndex >= pImpl->pMergeData->aSelection.getLength())
+ pImpl->pMergeData->bEndOfDB = sal_True;
+ }
+ else
+ {
+ pImpl->pMergeData->bEndOfDB = !pImpl->pMergeData->xResultSet->first();
+ pImpl->pMergeData->CheckEndOfDB();
+ }
+ }
+ catch(const Exception&)
+ {
+ pImpl->pMergeData->bEndOfDB = sal_True;
+ pImpl->pMergeData->CheckEndOfDB();
+ OSL_FAIL("exception in MergeNew()");
+ }
+
+ uno::Reference<XDataSource> xSource = SwNewDBMgr::getDataSourceAsParent(xConnection,aData.sDataSource);
+
+ lcl_InitNumberFormatter(*pImpl->pMergeData, xSource);
+
+ rMergeDesc.rSh.ChgDBData(aData);
+ bInMerge = sal_True;
+
+ if (IsInitDBFields())
+ {
+ // with database fields without DB-Name, use DB-Name from Doc
+ std::vector<OUString> aDBNames;
+ aDBNames.push_back(OUString());
+ SwDBData aInsertData = rMergeDesc.rSh.GetDBData();
+ OUString sDBName = aInsertData.sDataSource;
+ sDBName += OUString(DB_DELIM);
+ sDBName += aInsertData.sCommand;
+ sDBName += OUString(DB_DELIM);
+ sDBName += OUString::number(aInsertData.nCommandType);
+ rMergeDesc.rSh.ChangeDBFields( aDBNames, sDBName);
+ SetInitDBFields(sal_False);
+ }
+
+ sal_Bool bRet = sal_True;
+ switch(rMergeDesc.nMergeType)
+ {
+ case DBMGR_MERGE:
+ bRet = Merge(&rMergeDesc.rSh);
+ break;
+
+ case DBMGR_MERGE_MAILMERGE: // printing merge from 'old' merge dialog or from UNO-component
+ case DBMGR_MERGE_MAILING:
+ case DBMGR_MERGE_MAILFILES:
+ case DBMGR_MERGE_SINGLE_FILE:
+ // save files and send them as e-Mail if required
+ bRet = MergeMailFiles(&rMergeDesc.rSh,
+ rMergeDesc);
+ break;
+
+ default:
+ // insert selected entries
+ // (was: InsertRecord)
+ ImportFromConnection(&rMergeDesc.rSh);
+ break;
+ }
+
+ EndMerge();
+ return bRet;
+}
+
+/*--------------------------------------------------------------------
+ Description: import data
+ --------------------------------------------------------------------*/
+sal_Bool SwNewDBMgr::Merge(SwWrtShell* pSh)
+{
+ pSh->StartAllAction();
+
+ pSh->SwViewShell::UpdateFlds(sal_True);
+ pSh->SetModified();
+
+ pSh->EndAllAction();
+
+ return sal_True;
+}
+
+void SwNewDBMgr::ImportFromConnection( SwWrtShell* pSh )
+{
+ if(pImpl->pMergeData && !pImpl->pMergeData->bEndOfDB)
+ {
+ {
+ pSh->StartAllAction();
+ pSh->StartUndo(UNDO_EMPTY);
+ sal_Bool bGroupUndo(pSh->DoesGroupUndo());
+ pSh->DoGroupUndo(sal_False);
+
+ if( pSh->HasSelection() )
+ pSh->DelRight();
+
+ boost::scoped_ptr<SwWait> pWait;
+
+ {
+ sal_uLong i = 0;
+ do {
+
+ ImportDBEntry(pSh);
+ if( 10 == ++i )
+ pWait.reset(new SwWait( *pSh->GetView().GetDocShell(), true));
+
+ } while(ToNextMergeRecord());
+ }
+
+ pSh->DoGroupUndo(bGroupUndo);
+ pSh->EndUndo(UNDO_EMPTY);
+ pSh->EndAllAction();
+ }
+ }
+}
+
+static OUString lcl_FindColumn(const OUString& sFormatStr,sal_uInt16 &nUsedPos, sal_uInt8 &nSeparator)
+{
+ OUString sReturn;
+ sal_uInt16 nLen = sFormatStr.getLength();
+ nSeparator = 0xff;
+ while(nUsedPos < nLen && nSeparator == 0xff)
+ {
+ sal_Unicode cAkt = sFormatStr[nUsedPos];
+ switch(cAkt)
+ {
+ case ',':
+ nSeparator = DB_SEP_SPACE;
+ break;
+ case ';':
+ nSeparator = DB_SEP_RETURN;
+ break;
+ case ':':
+ nSeparator = DB_SEP_TAB;
+ break;
+ case '#':
+ nSeparator = DB_SEP_NEWLINE;
+ break;
+ default:
+ sReturn += OUString(cAkt);
+ }
+ nUsedPos++;
+
+ }
+ return sReturn;
+}
+
+void SwNewDBMgr::ImportDBEntry(SwWrtShell* pSh)
+{
+ if(pImpl->pMergeData && !pImpl->pMergeData->bEndOfDB)
+ {
+ uno::Reference< XColumnsSupplier > xColsSupp( pImpl->pMergeData->xResultSet, UNO_QUERY );
+ uno::Reference<XNameAccess> xCols = xColsSupp->getColumns();
+ OUString sFormatStr;
+ sal_uInt16 nFmtLen = sFormatStr.getLength();
+ if( nFmtLen )
+ {
+ const char cSpace = ' ';
+ const char cTab = '\t';
+ sal_uInt16 nUsedPos = 0;
+ sal_uInt8 nSeparator;
+ OUString sColumn = lcl_FindColumn(sFormatStr, nUsedPos, nSeparator);
+ while( !sColumn.isEmpty() )
+ {
+ if(!xCols->hasByName(sColumn))
+ return;
+ Any aCol = xCols->getByName(sColumn);
+ uno::Reference< XPropertySet > xColumnProp;
+ aCol >>= xColumnProp;
+ if(xColumnProp.is())
+ {
+ SwDBFormatData aDBFormat;
+ OUString sInsert = GetDBField( xColumnProp, aDBFormat);
+ if( DB_SEP_SPACE == nSeparator )
+ sInsert += OUString(cSpace);
+ else if( DB_SEP_TAB == nSeparator)
+ sInsert += OUString(cTab);
+ pSh->Insert(sInsert);
+ if( DB_SEP_RETURN == nSeparator)
+ pSh->SplitNode();
+ else if(DB_SEP_NEWLINE == nSeparator)
+ pSh->InsertLineBreak();
+ }
+ else
+ {
+ // column not found -> show error
+ OUStringBuffer sInsert;
+ sInsert.append('?').append(sColumn).append('?');
+ pSh->Insert(sInsert.makeStringAndClear());
+ }
+ sColumn = lcl_FindColumn(sFormatStr, nUsedPos, nSeparator);
+ }
+ pSh->SplitNode();
+ }
+ else
+ {
+ OUString sStr;
+ Sequence<OUString> aColNames = xCols->getElementNames();
+ const OUString* pColNames = aColNames.getConstArray();
+ long nLength = aColNames.getLength();
+ for(long i = 0; i < nLength; i++)
+ {
+ Any aCol = xCols->getByName(pColNames[i]);
+ uno::Reference< XPropertySet > xColumnProp;
+ aCol >>= xColumnProp;
+ SwDBFormatData aDBFormat;
+ sStr += GetDBField( xColumnProp, aDBFormat);
+ if (i < nLength - 1)
+ sStr += "\t";
+ }
+ pSh->SwEditShell::Insert2(sStr);
+ pSh->SwFEShell::SplitNode(); // line feed
+ }
+ }
+}
+
+/*--------------------------------------------------------------------
+ Description: fill Listbox with tablelist
+ --------------------------------------------------------------------*/
+sal_Bool SwNewDBMgr::GetTableNames(ListBox* pListBox, const OUString& rDBName)
+{
+ sal_Bool bRet = sal_False;
+ OUString sOldTableName(pListBox->GetSelectEntry());
+ pListBox->Clear();
+ SwDSParam* pParam = FindDSConnection(rDBName, sal_False);
+ uno::Reference< XConnection> xConnection;
+ if(pParam && pParam->xConnection.is())
+ xConnection = pParam->xConnection;
+ else
+ {
+ OUString sDBName(rDBName);
+ if ( !sDBName.isEmpty() )
+ xConnection = RegisterConnection( sDBName );
+ }
+ if(xConnection.is())
+ {
+ uno::Reference<XTablesSupplier> xTSupplier = uno::Reference<XTablesSupplier>(xConnection, UNO_QUERY);
+ if(xTSupplier.is())
+ {
+ uno::Reference<XNameAccess> xTbls = xTSupplier->getTables();
+ Sequence<OUString> aTbls = xTbls->getElementNames();
+ const OUString* pTbls = aTbls.getConstArray();
+ for(long i = 0; i < aTbls.getLength(); i++)
+ {
+ sal_uInt16 nEntry = pListBox->InsertEntry(pTbls[i]);
+ pListBox->SetEntryData(nEntry, (void*)0);
+ }
+ }
+ uno::Reference<XQueriesSupplier> xQSupplier = uno::Reference<XQueriesSupplier>(xConnection, UNO_QUERY);
+ if(xQSupplier.is())
+ {
+ uno::Reference<XNameAccess> xQueries = xQSupplier->getQueries();
+ Sequence<OUString> aQueries = xQueries->getElementNames();
+ const OUString* pQueries = aQueries.getConstArray();
+ for(long i = 0; i < aQueries.getLength(); i++)
+ {
+ sal_uInt16 nEntry = pListBox->InsertEntry(pQueries[i]);
+ pListBox->SetEntryData(nEntry, (void*)1);
+ }
+ }
+ if (!sOldTableName.isEmpty())
+ pListBox->SelectEntry(sOldTableName);
+ bRet = sal_True;
+ }
+ return bRet;
+}
+
+/*--------------------------------------------------------------------
+ Description: fill Listbox with column names of a database
+ --------------------------------------------------------------------*/
+sal_Bool SwNewDBMgr::GetColumnNames(ListBox* pListBox,
+ const OUString& rDBName, const OUString& rTableName, sal_Bool bAppend)
+{
+ if (!bAppend)
+ pListBox->Clear();
+ SwDBData aData;
+ aData.sDataSource = rDBName;
+ aData.sCommand = rTableName;
+ aData.nCommandType = -1;
+ SwDSParam* pParam = FindDSData(aData, sal_False);
+ uno::Reference< XConnection> xConnection;
+ if(pParam && pParam->xConnection.is())
+ xConnection = pParam->xConnection;
+ else
+ {
+ OUString sDBName(rDBName);
+ xConnection = RegisterConnection( sDBName );
+ }
+ uno::Reference< XColumnsSupplier> xColsSupp = SwNewDBMgr::GetColumnSupplier(xConnection, rTableName);
+ if(xColsSupp.is())
+ {
+ uno::Reference<XNameAccess> xCols = xColsSupp->getColumns();
+ const Sequence<OUString> aColNames = xCols->getElementNames();
+ const OUString* pColNames = aColNames.getConstArray();
+ for(int nCol = 0; nCol < aColNames.getLength(); nCol++)
+ {
+ pListBox->InsertEntry(pColNames[nCol]);
+ }
+ ::comphelper::disposeComponent( xColsSupp );
+ }
+ return(sal_True);
+}
+
+sal_Bool SwNewDBMgr::GetColumnNames(ListBox* pListBox,
+ uno::Reference< XConnection> xConnection,
+ const OUString& rTableName, sal_Bool bAppend)
+{
+ if (!bAppend)
+ pListBox->Clear();
+ uno::Reference< XColumnsSupplier> xColsSupp = SwNewDBMgr::GetColumnSupplier(xConnection, rTableName);
+ if(xColsSupp.is())
+ {
+ uno::Reference<XNameAccess> xCols = xColsSupp->getColumns();
+ const Sequence<OUString> aColNames = xCols->getElementNames();
+ const OUString* pColNames = aColNames.getConstArray();
+ for(int nCol = 0; nCol < aColNames.getLength(); nCol++)
+ {
+ pListBox->InsertEntry(pColNames[nCol]);
+ }
+ ::comphelper::disposeComponent( xColsSupp );
+ }
+ return(sal_True);
+}
+
+/*--------------------------------------------------------------------
+ Description: CTOR
+ --------------------------------------------------------------------*/
+SwNewDBMgr::SwNewDBMgr() :
+ bInitDBFields(sal_False),
+ bInMerge(sal_False),
+ bMergeSilent(sal_False),
+ bMergeLock(sal_False),
+ pImpl(new SwNewDBMgr_Impl(*this)),
+ pMergeEvtSrc(NULL)
+{
+}
+
+SwNewDBMgr::~SwNewDBMgr()
+{
+ for(sal_uInt16 nPos = 0; nPos < aDataSourceParams.size(); nPos++)
+ {
+ SwDSParam* pParam = &aDataSourceParams[nPos];
+ if(pParam->xConnection.is())
+ {
+ try
+ {
+ uno::Reference<XComponent> xComp(pParam->xConnection, UNO_QUERY);
+ if(xComp.is())
+ xComp->dispose();
+ }
+ catch(const RuntimeException&)
+ {
+ //may be disposed already since multiple entries may have used the same connection
+ }
+ }
+ }
+ delete pImpl;
+}
+
+/*--------------------------------------------------------------------
+ Description: save bulk letters as single documents
+ --------------------------------------------------------------------*/
+static OUString lcl_FindUniqueName(SwWrtShell* pTargetShell, const OUString& rStartingPageDesc, sal_uLong nDocNo )
+{
+ do
+ {
+ OUString sTest = rStartingPageDesc;
+ sTest += OUString::number( nDocNo );
+ if( !pTargetShell->FindPageDescByName( sTest ) )
+ return sTest;
+ ++nDocNo;
+ }while(true);
+}
+
+static void lcl_CopyDynamicDefaults( const SwDoc& rSource, SwDoc& rTarget )
+{
+ sal_uInt16 aRangeOfDefaults[] = {
+ RES_FRMATR_BEGIN, RES_FRMATR_END-1,
+ RES_CHRATR_BEGIN, RES_CHRATR_END-1,
+ RES_PARATR_BEGIN, RES_PARATR_END-1,
+ RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END-1,
+ RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1,
+ 0
+ };
+
+ SfxItemSet aNewDefaults( rTarget.GetAttrPool(), aRangeOfDefaults );
+
+ sal_uInt16 nWhich;
+ sal_uInt16 nRange = 0;
+ while( aRangeOfDefaults[nRange] != 0)
+ {
+ for( nWhich = aRangeOfDefaults[nRange]; nWhich < aRangeOfDefaults[nRange + 1]; ++nWhich )
+ {
+ const SfxPoolItem& rSourceAttr = rSource.GetDefault( nWhich );
+ if( rSourceAttr != rTarget.GetDefault( nWhich ) )
+ aNewDefaults.Put( rSourceAttr );
+ }
+ nRange += 2;
+ }
+ if( aNewDefaults.Count() )
+ rTarget.SetDefault( aNewDefaults );
+}
+
+static void lcl_CopyFollowPageDesc(
+ SwWrtShell& rTargetShell,
+ const SwPageDesc& rSourcePageDesc,
+ const SwPageDesc& rTargetPageDesc,
+ const sal_uLong nDocNo )
+{
+ //now copy the follow page desc, too
+ const SwPageDesc* pFollowPageDesc = rSourcePageDesc.GetFollow();
+ OUString sFollowPageDesc = pFollowPageDesc->GetName();
+ if( sFollowPageDesc != rSourcePageDesc.GetName() )
+ {
+ SwDoc* pTargetDoc = rTargetShell.GetDoc();
+ OUString sNewFollowPageDesc = lcl_FindUniqueName(&rTargetShell, sFollowPageDesc, nDocNo );
+ sal_uInt16 nNewDesc = pTargetDoc->MakePageDesc( sNewFollowPageDesc );
+ SwPageDesc& rTargetFollowPageDesc = pTargetDoc->GetPageDesc( nNewDesc );
+
+ pTargetDoc->CopyPageDesc( *pFollowPageDesc, rTargetFollowPageDesc, false );
+ SwPageDesc aDesc( rTargetPageDesc );
+ aDesc.SetFollow( &rTargetFollowPageDesc );
+ pTargetDoc->ChgPageDesc( rTargetPageDesc.GetName(), aDesc );
+ }
+}
+
+static void lcl_RemoveSectionLinks( SwWrtShell& rWorkShell )
+{
+ //reset all links of the sections of synchronized labels
+ sal_uInt16 nSections = rWorkShell.GetSectionFmtCount();
+ for( sal_uInt16 nSection = 0; nSection < nSections; ++nSection )
+ {
+ SwSectionData aSectionData( *rWorkShell.GetSectionFmt( nSection ).GetSection() );
+ if( aSectionData.GetType() == FILE_LINK_SECTION )
+ {
+ aSectionData.SetType( CONTENT_SECTION );
+ aSectionData.SetLinkFileName( OUString() );
+ rWorkShell.UpdateSection( nSection, aSectionData );
+ }
+ }
+ rWorkShell.SetLabelDoc( sal_False );
+}
+
+sal_Bool SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell,
+ const SwMergeDescriptor& rMergeDescriptor)
+{
+ //check if the doc is synchronized and contains at least one linked section
+ bool bSynchronizedDoc = pSourceShell->IsLabelDoc() && pSourceShell->GetSectionFmtCount() > 1;
+ sal_Bool bNoError = sal_True;
+ bool bEMail = rMergeDescriptor.nMergeType == DBMGR_MERGE_MAILING;
+ const bool bAsSingleFile = rMergeDescriptor.nMergeType == DBMGR_MERGE_SINGLE_FILE;
+
+ ::rtl::Reference< MailDispatcher > xMailDispatcher;
+ OUString sBodyMimeType;
+ rtl_TextEncoding eEncoding = ::osl_getThreadTextEncoding();
+
+ if(bEMail)
+ {
+ xMailDispatcher.set( new MailDispatcher(rMergeDescriptor.xSmtpServer));
+ if(!rMergeDescriptor.bSendAsAttachment && rMergeDescriptor.bSendAsHTML)
+ {
+ sBodyMimeType = "text/html; charset=";
+ sBodyMimeType += OUString::createFromAscii(
+ rtl_getBestMimeCharsetFromTextEncoding( eEncoding ));
+ SvxHtmlOptions& rHtmlOptions = SvxHtmlOptions::Get();
+ eEncoding = rHtmlOptions.GetTextEncoding();
+ }
+ else
+ sBodyMimeType =
+ OUString("text/plain; charset=UTF-8; format=flowed");
+ }
+
+ uno::Reference< XPropertySet > xColumnProp;
+ {
+ bool bColumnName = !sEMailAddrFld.isEmpty();
+
+ if (bColumnName)
+ {
+ uno::Reference< XColumnsSupplier > xColsSupp( pImpl->pMergeData->xResultSet, UNO_QUERY );
+ uno::Reference<XNameAccess> xCols = xColsSupp->getColumns();
+ if(!xCols->hasByName(sEMailAddrFld))
+ return sal_False;
+ Any aCol = xCols->getByName(sEMailAddrFld);
+ aCol >>= xColumnProp;
+ }
+
+ // Try saving the source document
+ SfxDispatcher* pSfxDispatcher = pSourceShell->GetView().GetViewFrame()->GetDispatcher();
+ SwDocShell* pSourceDocSh = pSourceShell->GetView().GetDocShell();
+ pSfxDispatcher->Execute( pSourceDocSh->HasName() ? SID_SAVEDOC : SID_SAVEASDOC, SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD);
+ if( !pSourceDocSh->IsModified() )
+ {
+ const SfxFilter* pStoreToFilter = SwIoSystem::GetFileFilter(
+ pSourceDocSh->GetMedium()->GetURLObject().GetMainURL( INetURLObject::NO_DECODE ), ::aEmptyOUStr );
+ SfxFilterContainer* pFilterContainer = SwDocShell::Factory().GetFilterContainer();
+ const OUString* pStoreToFilterOptions = 0;
+
+ // if a save_to filter is set then use it - otherwise use the default
+ if( bEMail && !rMergeDescriptor.bSendAsAttachment )
+ {
+ OUString sExtension = rMergeDescriptor.bSendAsHTML ? OUString("html") : OUString("txt");
+ pStoreToFilter = pFilterContainer->GetFilter4Extension(sExtension, SFX_FILTER_EXPORT);
+ }
+ else if( !rMergeDescriptor.sSaveToFilter.isEmpty())
+ {
+ const SfxFilter* pFilter =
+ pFilterContainer->GetFilter4FilterName( rMergeDescriptor.sSaveToFilter );
+ if(pFilter)
+ {
+ pStoreToFilter = pFilter;
+ if(!rMergeDescriptor.sSaveToFilterOptions.isEmpty())
+ pStoreToFilterOptions = &rMergeDescriptor.sSaveToFilterOptions;
+ }
+ }
+ bCancel = sal_False;
+
+ // in case of creating a single resulting file this has to be created here
+ SwWrtShell* pTargetShell = 0;
+
+ // the shell will be explicitly closed at the end of the method, but it is
+ // still more safe to use SfxObjectShellLock here
+ SfxObjectShellLock xTargetDocShell;
+
+ SwView* pTargetView = 0;
+ boost::scoped_ptr< utl::TempFile > aTempFile;
+ OUString sModifiedStartingPageDesc;
+ OUString sStartingPageDesc;
+ sal_uInt16 nStartingPageNo = 0;
+ bool bPageStylesWithHeaderFooter = false;
+ if(bAsSingleFile || rMergeDescriptor.bCreateSingleFile)
+ {
+ // create a target docshell to put the merged document into
+ xTargetDocShell = new SwDocShell( SFX_CREATE_MODE_STANDARD );
+ xTargetDocShell->DoInitNew( 0 );
+ SfxViewFrame* pTargetFrame = SfxViewFrame::LoadHiddenDocument( *xTargetDocShell, 0 );
+
+ pTargetView = static_cast<SwView*>( pTargetFrame->GetViewShell() );
+
+ //initiate SelectShell() to create sub shells
+ pTargetView->AttrChangedNotify( &pTargetView->GetWrtShell() );
+ pTargetShell = pTargetView->GetWrtShellPtr();
+ //copy the styles from the source to the target document
+ pTargetView->GetDocShell()->_LoadStyles( *pSourceDocSh, sal_True );
+ //determine the page style and number used at the start of the source document
+ pSourceShell->SttEndDoc(sal_True);
+ nStartingPageNo = pSourceShell->GetVirtPageNum();
+ sStartingPageDesc = sModifiedStartingPageDesc = pSourceShell->GetPageDesc(
+ pSourceShell->GetCurPageDesc()).GetName();
+ // copy compatibility options
+ lcl_CopyCompatibilityOptions( *pSourceShell, *pTargetShell);
+ // #72821# copy dynamic defaults
+ lcl_CopyDynamicDefaults( *pSourceShell->GetDoc(), *pTargetShell->GetDoc() );
+ // #i72517#
+ const SwPageDesc* pSourcePageDesc = pSourceShell->FindPageDescByName( sStartingPageDesc );
+ const SwFrmFmt& rMaster = pSourcePageDesc->GetMaster();
+ bPageStylesWithHeaderFooter = rMaster.GetHeader().IsActive() ||
+ rMaster.GetFooter().IsActive();
+
+ }
+
+ PrintMonitor aPrtMonDlg(&pSourceShell->GetView().GetEditWin(), PrintMonitor::MONITOR_TYPE_PRINT);
+ aPrtMonDlg.m_pDocName->SetText(pSourceShell->GetView().GetDocShell()->GetTitle(22));
+
+ aPrtMonDlg.m_pCancel->SetClickHdl(LINK(this, SwNewDBMgr, PrtCancelHdl));
+ if (!IsMergeSilent())
+ aPrtMonDlg.Show();
+
+ // Progress, to prohibit KeyInputs
+ SfxProgress aProgress(pSourceDocSh, ::aEmptyOUStr, 1);
+
+ // lock all dispatchers
+ SfxViewFrame* pViewFrm = SfxViewFrame::GetFirst(pSourceDocSh);
+ while (pViewFrm)
+ {
+ pViewFrm->GetDispatcher()->Lock(sal_True);
+ pViewFrm = SfxViewFrame::GetNext(*pViewFrm, pSourceDocSh);
+ }
+ sal_uLong nDocNo = 1;
+
+ long nStartRow, nEndRow;
+ bool bFreezedLayouts = false;
+ // collect temporary files
+ ::std::vector< OUString> aFilesToRemove;
+ do
+ {
+ nStartRow = pImpl->pMergeData ? pImpl->pMergeData->xResultSet->getRow() : 0;
+ {
+ OUString sPath(sSubject);
+
+ OUString sAddress;
+ if( !bEMail && bColumnName )
+ {
+ SwDBFormatData aDBFormat;
+ aDBFormat.xFormatter = pImpl->pMergeData->xFormatter;
+ aDBFormat.aNullDate = pImpl->pMergeData->aNullDate;
+ sAddress = GetDBField( xColumnProp, aDBFormat);
+ if (sAddress.isEmpty())
+ sAddress = "_";
+ sPath += sAddress;
+ }
+
+ // create a new temporary file name - only done once in case of bCreateSingleFile
+ if( 1 == nDocNo || (!rMergeDescriptor.bCreateSingleFile && !bAsSingleFile) )
+ {
+ INetURLObject aEntry(sPath);
+ OUString sLeading;
+ //#i97667# if the name is from a database field then it will be used _as is_
+ if( !sAddress.isEmpty() )
+ sLeading = sAddress;
+ else
+ sLeading = aEntry.GetBase();
+ aEntry.removeSegment();
+ sPath = aEntry.GetMainURL( INetURLObject::NO_DECODE );
+ OUString sExt(comphelper::string::stripStart(pStoreToFilter->GetDefaultExtension(), '*'));
+ aTempFile.reset(
+ new utl::TempFile(sLeading,&sExt,&sPath ));
+ if( bAsSingleFile )
+ aTempFile->EnableKillingFile();
+ }
+
+ if( !aTempFile->IsValid() )
+ {
+ ErrorHandler::HandleError( ERRCODE_IO_NOTSUPPORTED );
+ bNoError = sal_False;
+ bCancel = sal_True;
+ }
+ else
+ {
+ INetURLObject aTempFileURL(aTempFile->GetURL());
+ aPrtMonDlg.m_pPrinter->SetText( aTempFileURL.GetBase() );
+ OUString sStat(SW_RES(STR_STATSTR_LETTER)); // Brief
+ sStat += " ";
+ sStat += OUString::number( nDocNo );
+ aPrtMonDlg.m_pPrintInfo->SetText(sStat);
+
+ // computation time for Save-Monitor:
+ for (sal_uInt16 i = 0; i < 25; i++)
+ Application::Reschedule();
+
+ // The SfxObjectShell will be closed explicitly later but it is more safe to use SfxObjectShellLock here
+ SfxObjectShellLock xWorkDocSh;
+ // copy the source document
+ if( 1 == nDocNo && (bAsSingleFile || rMergeDescriptor.bCreateSingleFile) )
+ {
+ uno::Reference< util::XCloneable > xClone( pSourceDocSh->GetModel(), uno::UNO_QUERY);
+ uno::Reference< lang::XUnoTunnel > xWorkDocShell( xClone->createClone(), uno::UNO_QUERY);
+ SwXTextDocument* pWorkModel = reinterpret_cast<SwXTextDocument*>(xWorkDocShell->getSomething(SwXTextDocument::getUnoTunnelId()));
+ xWorkDocSh = pWorkModel->GetDocShell();
+ }
+ else
+ xWorkDocSh = pSourceDocSh->GetDoc()->CreateCopy( true );
+
+ {
+ //create a view frame for the document
+ SfxViewFrame* pWorkFrame = SfxViewFrame::LoadHiddenDocument( *xWorkDocSh, 0 );
+ //request the layout calculation
+ SwWrtShell& rWorkShell =
+ static_cast< SwView* >(pWorkFrame->GetViewShell())->GetWrtShell();
+ rWorkShell.CalcLayout();
+ SwDoc* pWorkDoc = ((SwDocShell*)(&xWorkDocSh))->GetDoc();
+ SwNewDBMgr* pOldDBMgr = pWorkDoc->GetNewDBMgr();
+ pWorkDoc->SetNewDBMgr( this );
+ SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE, SwDocShell::GetEventName(STR_SW_EVENT_FIELD_MERGE), xWorkDocSh));
+ pWorkDoc->UpdateFlds(NULL, false);
+ SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE_FINISHED, SwDocShell::GetEventName(STR_SW_EVENT_FIELD_MERGE_FINISHED), xWorkDocSh));
+
+ pWorkDoc->RemoveInvisibleContent();
+
+ // launch MailMergeEvent if required
+ const SwXMailMerge *pEvtSrc = GetMailMergeEvtSrc();
+ if(pEvtSrc)
+ {
+ uno::Reference< XInterface > xRef( (XMailMergeBroadcaster *) pEvtSrc );
+ text::MailMergeEvent aEvt( xRef, xWorkDocSh->GetModel() );
+ pEvtSrc->LaunchMailMergeEvent( aEvt );
+ }
+
+ if(rMergeDescriptor.bCreateSingleFile || bAsSingleFile )
+ {
+ OSL_ENSURE( pTargetShell, "no target shell available!" );
+ // copy created file into the target document
+ rWorkShell.ConvertFieldsToText();
+ rWorkShell.SetNumberingRestart();
+ if( bSynchronizedDoc )
+ {
+ lcl_RemoveSectionLinks( rWorkShell );
+ }
+
+ // insert the document into the target document
+ rWorkShell.SttEndDoc(sal_False);
+ rWorkShell.SttEndDoc(sal_True);
+ rWorkShell.SelAll();
+ pTargetShell->SwCrsrShell::SttEndDoc( sal_False );
+ //#i72517# the headers and footers are still those from the source - update in case of fields inside header/footer
+ if( !nDocNo && bPageStylesWithHeaderFooter )
+ pTargetShell->GetView().GetDocShell()->_LoadStyles( *rWorkShell.GetView().GetDocShell(), sal_True );
+ //#i72517# put the styles to the target document
+ //if the source uses headers or footers each new copy need to copy a new page styles
+ if(bPageStylesWithHeaderFooter)
+ {
+ //create a new pagestyle
+ //copy the pagedesc from the current document to the new document and change the name of the to-be-applied style
+
+ SwDoc* pTargetDoc = pTargetShell->GetDoc();
+ SwPageDesc* pSourcePageDesc = rWorkShell.FindPageDescByName( sStartingPageDesc );
+ OUString sNewPageDescName = lcl_FindUniqueName(pTargetShell, sStartingPageDesc, nDocNo );
+ pTargetDoc->MakePageDesc( sNewPageDescName );
+ SwPageDesc* pTargetPageDesc = pTargetShell->FindPageDescByName( sNewPageDescName );
+ if(pSourcePageDesc && pTargetPageDesc)
+ {
+ pTargetDoc->CopyPageDesc( *pSourcePageDesc, *pTargetPageDesc, false );
+ sModifiedStartingPageDesc = sNewPageDescName;
+ lcl_CopyFollowPageDesc( *pTargetShell, *pSourcePageDesc, *pTargetPageDesc, nDocNo );
+ }
+ }
+
+ if(nDocNo > 1)
+ pTargetShell->InsertPageBreak( &sModifiedStartingPageDesc, nStartingPageNo );
+ else
+ pTargetShell->SetPageStyle(sModifiedStartingPageDesc);
+ OSL_ENSURE(!pTargetShell->GetTableFmt(),"target document ends with a table - paragraph should be appended");
+ //#i51359# add a second paragraph in case there's only one
+ {
+ SwNodeIndex aIdx( pWorkDoc->GetNodes().GetEndOfExtras(), 2 );
+ SwPosition aTestPos( aIdx );
+ SwCursor aTestCrsr(aTestPos,0,false);
+ if(!aTestCrsr.MovePara(fnParaNext, fnParaStart))
+ {
+ //append a paragraph
+ pWorkDoc->AppendTxtNode( aTestPos );
+ }
+ }
+ pTargetShell->Paste( rWorkShell.GetDoc(), sal_True );
+
+ //convert fields in page styles (header/footer - has to be done after the first document has been pasted
+ if(1 == nDocNo)
+ {
+ pTargetShell->CalcLayout();
+ pTargetShell->ConvertFieldsToText();
+ }
+ }
+ else
+ {
+ OUString sFileURL = aTempFileURL.GetMainURL( INetURLObject::NO_DECODE );
+ SfxMedium* pDstMed = new SfxMedium(
+ sFileURL,
+ STREAM_STD_READWRITE );
+ pDstMed->SetFilter( pStoreToFilter );
+ if(pDstMed->GetItemSet())
+ {
+ if(pStoreToFilterOptions )
+ pDstMed->GetItemSet()->Put(SfxStringItem(SID_FILE_FILTEROPTIONS, *pStoreToFilterOptions));
+ if(rMergeDescriptor.aSaveToFilterData.getLength())
+ pDstMed->GetItemSet()->Put(SfxUsrAnyItem(SID_FILTER_DATA, makeAny(rMergeDescriptor.aSaveToFilterData)));
+ }
+
+ //convert fields to text if we are exporting to PDF
+ //this prevents a second merge while updating the fields in SwXTextDocument::getRendererCount()
+ if( pStoreToFilter && pStoreToFilter->GetFilterName().equalsAscii("writer_pdf_Export"))
+ rWorkShell.ConvertFieldsToText();
+ xWorkDocSh->DoSaveAs(*pDstMed);
+ xWorkDocSh->DoSaveCompleted(pDstMed);
+ if( xWorkDocSh->GetError() )
+ {
+ // error message ??
+ ErrorHandler::HandleError( xWorkDocSh->GetError() );
+ bCancel = sal_True;
+ bNoError = sal_False;
+ }
+ if( bEMail )
+ {
+ SwDBFormatData aDBFormat;
+ aDBFormat.xFormatter = pImpl->pMergeData->xFormatter;
+ aDBFormat.aNullDate = pImpl->pMergeData->aNullDate;
+ OUString sMailAddress = GetDBField( xColumnProp, aDBFormat);
+ if(!SwMailMergeHelper::CheckMailAddress( sMailAddress ))
+ {
+ OSL_FAIL("invalid e-Mail address in database column");
+ }
+ else
+ {
+ SwMailMessage* pMessage = new SwMailMessage;
+ uno::Reference< mail::XMailMessage > xMessage = pMessage;
+ if(rMergeDescriptor.pMailMergeConfigItem->IsMailReplyTo())
+ pMessage->setReplyToAddress(rMergeDescriptor.pMailMergeConfigItem->GetMailReplyTo());
+ pMessage->addRecipient( sMailAddress );
+ pMessage->SetSenderAddress( rMergeDescriptor.pMailMergeConfigItem->GetMailAddress() );
+ OUString sBody;
+ if(rMergeDescriptor.bSendAsAttachment)
+ {
+ sBody = rMergeDescriptor.sMailBody;
+ mail::MailAttachment aAttach;
+ aAttach.Data = new SwMailTransferable(
+ sFileURL,
+ rMergeDescriptor.sAttachmentName,
+ pStoreToFilter->GetMimeType());
+ aAttach.ReadableName = rMergeDescriptor.sAttachmentName;
+ pMessage->addAttachment( aAttach );
+ }
+ else
+ {
+ {
+ //read in the temporary file and use it as mail body
+ SfxMedium aMedium( sFileURL, STREAM_READ);
+ SvStream* pInStream = aMedium.GetInStream();
+ OSL_ENSURE(pInStream, "no output file created?");
+ if(pInStream)
+ {
+ pInStream->SetStreamCharSet( eEncoding );
+ OString sLine;
+ sal_Bool bDone = pInStream->ReadLine( sLine );
+ while ( bDone )
+ {
+ sBody += OStringToOUString(sLine, eEncoding);
+ sBody += "\n";
+ bDone = pInStream->ReadLine( sLine );
+ }
+ }
+ }
+ }
+ pMessage->setSubject( rMergeDescriptor.sSubject );
+ uno::Reference< datatransfer::XTransferable> xBody =
+ new SwMailTransferable(
+ sBody,
+ sBodyMimeType);
+ pMessage->setBody( xBody );
+
+ if(rMergeDescriptor.aCopiesTo.getLength())
+ {
+ const OUString* pCopies = rMergeDescriptor.aCopiesTo.getConstArray();
+ for( sal_Int32 nToken = 0; nToken < rMergeDescriptor.aCopiesTo.getLength(); ++nToken)
+ pMessage->addCcRecipient( pCopies[nToken] );
+ }
+ if(rMergeDescriptor.aBlindCopiesTo.getLength())
+ {
+ const OUString* pCopies = rMergeDescriptor.aBlindCopiesTo.getConstArray();
+ for( sal_Int32 nToken = 0; nToken < rMergeDescriptor.aBlindCopiesTo.getLength(); ++nToken)
+ pMessage->addBccRecipient( pCopies[nToken] );
+ }
+ xMailDispatcher->enqueueMailMessage( xMessage );
+ if(!xMailDispatcher->isStarted())
+ xMailDispatcher->start();
+ //schedule for removal
+ aFilesToRemove.push_back(sFileURL);
+ }
+ }
+ }
+ pWorkDoc->SetNewDBMgr( pOldDBMgr );
+ }
+ xWorkDocSh->DoClose();
+ }
+ }
+ nDocNo++;
+ nEndRow = pImpl->pMergeData ? pImpl->pMergeData->xResultSet->getRow() : 0;
+
+ // Freeze the layouts of the target document after the first inserted
+ // sub-document, to get the correct PageDesc.
+ if(!bFreezedLayouts && (rMergeDescriptor.bCreateSingleFile || bAsSingleFile))
+ {
+ std::set<SwRootFrm*> aAllLayouts = pTargetShell->GetDoc()->GetAllLayouts();
+ std::for_each( aAllLayouts.begin(), aAllLayouts.end(),
+ ::std::bind2nd(::std::mem_fun(&SwRootFrm::FreezeLayout), true));
+ bFreezedLayouts = true;
+ }
+ } while( !bCancel &&
+ (bSynchronizedDoc && (nStartRow != nEndRow)? ExistsNextRecord() : ToNextMergeRecord()));
+
+ // Unfreeze target document layouts and correct all PageDescs.
+ if(rMergeDescriptor.bCreateSingleFile || bAsSingleFile)
+ {
+ std::set<SwRootFrm*> aAllLayouts = pTargetShell->GetDoc()->GetAllLayouts();
+ std::for_each( aAllLayouts.begin(), aAllLayouts.end(),
+ ::std::bind2nd(::std::mem_fun(&SwRootFrm::FreezeLayout), false));
+ std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::mem_fun(&SwRootFrm::AllCheckPageDescs));
+ }
+
+ aPrtMonDlg.Show( false );
+
+ // save the single output document
+ if(rMergeDescriptor.bCreateSingleFile || bAsSingleFile)
+ {
+ if( rMergeDescriptor.nMergeType != DBMGR_MERGE_MAILMERGE )
+ {
+ OSL_ENSURE( aTempFile.get(), "Temporary file not available" );
+ OUString sSub(sSubject);
+ INetURLObject aTempFileURL(bAsSingleFile ? sSub : aTempFile->GetURL());
+ SfxMedium* pDstMed = new SfxMedium(
+ aTempFileURL.GetMainURL( INetURLObject::NO_DECODE ),
+ STREAM_STD_READWRITE );
+ pDstMed->SetFilter( pStoreToFilter );
+ if(pDstMed->GetItemSet())
+ {
+ if(pStoreToFilterOptions )
+ pDstMed->GetItemSet()->Put(SfxStringItem(SID_FILE_FILTEROPTIONS, *pStoreToFilterOptions));
+ if(rMergeDescriptor.aSaveToFilterData.getLength())
+ pDstMed->GetItemSet()->Put(SfxUsrAnyItem(SID_FILTER_DATA, makeAny(rMergeDescriptor.aSaveToFilterData)));
+ }
+
+ xTargetDocShell->DoSaveAs(*pDstMed);
+ xTargetDocShell->DoSaveCompleted(pDstMed);
+ if( xTargetDocShell->GetError() )
+ {
+ // error message ??
+ ErrorHandler::HandleError( xTargetDocShell->GetError() );
+ bNoError = sal_False;
+ }
+ }
+ else if( pTargetView ) // must be available!
+ {
+ //print the target document
+ #if OSL_DEBUG_LEVEL > 1
+ sal_Bool _bVal;
+ sal_Int16 _nVal;
+ OUString _sVal;
+ const beans::PropertyValue* pDbgPrintOptions = rMergeDescriptor.aPrintOptions.getConstArray();
+ for( sal_Int32 nOption = 0; nOption < rMergeDescriptor.aPrintOptions.getLength(); ++nOption)
+ {
+ OUString aName( pDbgPrintOptions[nOption].Name );
+ uno::Any aVal( pDbgPrintOptions[nOption].Value );
+ aVal >>= _bVal;
+ aVal >>= _nVal;
+ aVal >>= _sVal;
+ }
+ #endif
+ // printing should be done synchronously otherwise the document
+ // might already become invalid during the process
+ uno::Sequence< beans::PropertyValue > aOptions( rMergeDescriptor.aPrintOptions );
+
+ aOptions.realloc( 1 );
+ aOptions[ 0 ].Name = "Wait";
+ aOptions[ 0 ].Value <<= sal_True ;
+ // move print options
+ const beans::PropertyValue* pPrintOptions = rMergeDescriptor.aPrintOptions.getConstArray();
+ for( sal_Int32 nOption = 0, nIndex = 1 ; nOption < rMergeDescriptor.aPrintOptions.getLength(); ++nOption)
+ {
+ if( pPrintOptions[nOption].Name == "CopyCount" || pPrintOptions[nOption].Name == "FileName"
+ || pPrintOptions[nOption].Name == "Collate" || pPrintOptions[nOption].Name == "Pages"
+ || pPrintOptions[nOption].Name == "Wait" || pPrintOptions[nOption].Name == "PrinterName" )
+ {
+ // add an option
+ aOptions.realloc( nIndex + 1 );
+ aOptions[ nIndex ].Name = pPrintOptions[nOption].Name;
+ aOptions[ nIndex++ ].Value = pPrintOptions[nOption].Value ;
+ }
+ }
+
+ pTargetView->ExecPrint( aOptions, IsMergeSilent(), rMergeDescriptor.bPrintAsync );
+ }
+ xTargetDocShell->DoClose();
+ }
+
+ //remove the temporary files
+ ::std::vector<OUString>::iterator aFileIter;
+ for(aFileIter = aFilesToRemove.begin();
+ aFileIter != aFilesToRemove.end(); ++aFileIter)
+ SWUnoHelper::UCB_DeleteFile( *aFileIter );
+
+ // unlock all dispatchers
+ pViewFrm = SfxViewFrame::GetFirst(pSourceDocSh);
+ while (pViewFrm)
+ {
+ pViewFrm->GetDispatcher()->Lock(sal_False);
+ pViewFrm = SfxViewFrame::GetNext(*pViewFrm, pSourceDocSh);
+ }
+
+ SW_MOD()->SetView(&pSourceShell->GetView());
+ }
+ }
+
+ if(bEMail)
+ {
+ xMailDispatcher->stop();
+ xMailDispatcher->shutdown();
+ }
+
+ return bNoError;
+}
+
+void SwNewDBMgr::MergeCancel()
+{
+ bCancel = sal_True;
+}
+
+IMPL_LINK_INLINE_START( SwNewDBMgr, PrtCancelHdl, Button *, pButton )
+{
+ pButton->GetParent()->Hide();
+ MergeCancel();
+ return 0;
+}
+IMPL_LINK_INLINE_END( SwNewDBMgr, PrtCancelHdl, Button *, pButton )
+
+/*--------------------------------------------------------------------
+ Description: determine the column's Numberformat and transfer
+ to the forwarded Formatter, if applicable.
+ --------------------------------------------------------------------*/
+sal_uLong SwNewDBMgr::GetColumnFmt( const OUString& rDBName,
+ const OUString& rTableName,
+ const OUString& rColNm,
+ SvNumberFormatter* pNFmtr,
+ long nLanguage )
+{
+ sal_uLong nRet = 0;
+ if(pNFmtr)
+ {
+ uno::Reference< XDataSource> xSource;
+ uno::Reference< XConnection> xConnection;
+ bool bUseMergeData = false;
+ uno::Reference< XColumnsSupplier> xColsSupp;
+ bool bDisposeConnection = false;
+ if(pImpl->pMergeData &&
+ pImpl->pMergeData->sDataSource.equals(rDBName) && pImpl->pMergeData->sCommand.equals(rTableName))
+ {
+ xConnection = pImpl->pMergeData->xConnection;
+ xSource = SwNewDBMgr::getDataSourceAsParent(xConnection,rDBName);
+ bUseMergeData = true;
+ xColsSupp = xColsSupp.query( pImpl->pMergeData->xResultSet );
+ }
+ if(!xConnection.is())
+ {
+ SwDBData aData;
+ aData.sDataSource = rDBName;
+ aData.sCommand = rTableName;
+ aData.nCommandType = -1;
+ SwDSParam* pParam = FindDSData(aData, sal_False);
+ if(pParam && pParam->xConnection.is())
+ {
+ xConnection = pParam->xConnection;
+ xColsSupp = xColsSupp.query( pParam->xResultSet );
+ }
+ else
+ {
+ OUString sDBName(rDBName);
+ xConnection = RegisterConnection( sDBName );
+ bDisposeConnection = true;
+ }
+ if(bUseMergeData)
+ pImpl->pMergeData->xConnection = xConnection;
+ }
+ bool bDispose = !xColsSupp.is();
+ if(bDispose)
+ {
+ xColsSupp = SwNewDBMgr::GetColumnSupplier(xConnection, rTableName);
+ }
+ if(xColsSupp.is())
+ {
+ uno::Reference<XNameAccess> xCols;
+ try
+ {
+ xCols = xColsSupp->getColumns();
+ }
+ catch(const Exception&)
+ {
+ OSL_FAIL("Exception in getColumns()");
+ }
+ if(!xCols.is() || !xCols->hasByName(rColNm))
+ return nRet;
+ Any aCol = xCols->getByName(rColNm);
+ uno::Reference< XPropertySet > xColumn;
+ aCol >>= xColumn;
+ nRet = GetColumnFmt(xSource, xConnection, xColumn, pNFmtr, nLanguage);
+ if(bDispose)
+ {
+ ::comphelper::disposeComponent( xColsSupp );
+ }
+ if(bDisposeConnection)
+ {
+ ::comphelper::disposeComponent( xConnection );
+ }
+ }
+ else
+ nRet = pNFmtr->GetFormatIndex( NF_NUMBER_STANDARD, LANGUAGE_SYSTEM );
+ }
+ return nRet;
+}
+
+sal_uLong SwNewDBMgr::GetColumnFmt( uno::Reference< XDataSource> xSource,
+ uno::Reference< XConnection> xConnection,
+ uno::Reference< XPropertySet> xColumn,
+ SvNumberFormatter* pNFmtr,
+ long nLanguage )
+{
+ // set the NumberFormat in the doc if applicable
+ sal_uLong nRet = 0;
+
+ if(!xSource.is())
+ {
+ uno::Reference<XChild> xChild(xConnection, UNO_QUERY);
+ if ( xChild.is() )
+ xSource = uno::Reference<XDataSource>(xChild->getParent(), UNO_QUERY);
+ }
+ if(xSource.is() && xConnection.is() && xColumn.is() && pNFmtr)
+ {
+ SvNumberFormatsSupplierObj* pNumFmt = new SvNumberFormatsSupplierObj( pNFmtr );
+ uno::Reference< util::XNumberFormatsSupplier > xDocNumFmtsSupplier = pNumFmt;
+ uno::Reference< XNumberFormats > xDocNumberFormats = xDocNumFmtsSupplier->getNumberFormats();
+ uno::Reference< XNumberFormatTypes > xDocNumberFormatTypes(xDocNumberFormats, UNO_QUERY);
+
+ com::sun::star::lang::Locale aLocale( LanguageTag( (LanguageType)nLanguage ).getLocale());
+
+ //get the number formatter of the data source
+ uno::Reference<XPropertySet> xSourceProps(xSource, UNO_QUERY);
+ uno::Reference< XNumberFormats > xNumberFormats;
+ if(xSourceProps.is())
+ {
+ Any aFormats = xSourceProps->getPropertyValue("NumberFormatsSupplier");
+ if(aFormats.hasValue())
+ {
+ uno::Reference<XNumberFormatsSupplier> xSuppl;
+ aFormats >>= xSuppl;
+ if(xSuppl.is())
+ {
+ xNumberFormats = xSuppl->getNumberFormats();
+ }
+ }
+ }
+ bool bUseDefault = true;
+ try
+ {
+ Any aFormatKey = xColumn->getPropertyValue("FormatKey");
+ if(aFormatKey.hasValue())
+ {
+ sal_Int32 nFmt = 0;
+ aFormatKey >>= nFmt;
+ if(xNumberFormats.is())
+ {
+ try
+ {
+ uno::Reference<XPropertySet> xNumProps = xNumberFormats->getByKey( nFmt );
+ Any aFormatString = xNumProps->getPropertyValue("FormatString");
+ Any aLocaleVal = xNumProps->getPropertyValue("Locale");
+ OUString sFormat;
+ aFormatString >>= sFormat;
+ lang::Locale aLoc;
+ aLocaleVal >>= aLoc;
+ nFmt = xDocNumberFormats->queryKey( sFormat, aLoc, sal_False );
+ if(NUMBERFORMAT_ENTRY_NOT_FOUND == sal::static_int_cast< sal_uInt32, sal_Int32>(nFmt))
+ nFmt = xDocNumberFormats->addNew( sFormat, aLoc );
+ nRet = nFmt;
+ bUseDefault = false;
+ }
+ catch(const Exception&)
+ {
+ OSL_FAIL("illegal number format key");
+ }
+ }
+ }
+ }
+ catch(const Exception&)
+ {
+ OSL_FAIL("no FormatKey property found");
+ }
+ if(bUseDefault)
+ nRet = SwNewDBMgr::GetDbtoolsClient().getDefaultNumberFormat(xColumn, xDocNumberFormatTypes, aLocale);
+ }
+ return nRet;
+}
+
+sal_Int32 SwNewDBMgr::GetColumnType( const OUString& rDBName,
+ const OUString& rTableName,
+ const OUString& rColNm )
+{
+ sal_Int32 nRet = DataType::SQLNULL;
+ SwDBData aData;
+ aData.sDataSource = rDBName;
+ aData.sCommand = rTableName;
+ aData.nCommandType = -1;
+ SwDSParam* pParam = FindDSData(aData, sal_False);
+ uno::Reference< XConnection> xConnection;
+ uno::Reference< XColumnsSupplier > xColsSupp;
+ bool bDispose = false;
+ if(pParam && pParam->xConnection.is())
+ {
+ xConnection = pParam->xConnection;
+ xColsSupp = uno::Reference< XColumnsSupplier >( pParam->xResultSet, UNO_QUERY );
+ }
+ else
+ {
+ OUString sDBName(rDBName);
+ xConnection = RegisterConnection( sDBName );
+ }
+ if( !xColsSupp.is() )
+ {
+ xColsSupp = SwNewDBMgr::GetColumnSupplier(xConnection, rTableName);
+ bDispose = true;
+ }
+ if(xColsSupp.is())
+ {
+ uno::Reference<XNameAccess> xCols = xColsSupp->getColumns();
+ if(xCols->hasByName(rColNm))
+ {
+ Any aCol = xCols->getByName(rColNm);
+ uno::Reference<XPropertySet> xCol;
+ aCol >>= xCol;
+ Any aType = xCol->getPropertyValue("Type");
+ aType >>= nRet;
+ }
+ if(bDispose)
+ ::comphelper::disposeComponent( xColsSupp );
+ }
+ return nRet;
+}
+
+uno::Reference< sdbc::XConnection> SwNewDBMgr::GetConnection(const OUString& rDataSource,
+ uno::Reference<XDataSource>& rxSource)
+{
+ Reference< sdbc::XConnection> xConnection;
+ Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
+ try
+ {
+ Reference<XCompletedConnection> xComplConnection(SwNewDBMgr::GetDbtoolsClient().getDataSource(rDataSource, xContext),UNO_QUERY);
+ if ( xComplConnection.is() )
+ {
+ rxSource.set(xComplConnection,UNO_QUERY);
+ Reference< XInteractionHandler > xHandler( InteractionHandler::createWithParent(xContext, 0), UNO_QUERY_THROW );
+ xConnection = xComplConnection->connectWithCompletion( xHandler );
+ }
+ }
+ catch(const Exception&)
+ {
+ }
+
+ return xConnection;
+}
+
+uno::Reference< sdbcx::XColumnsSupplier> SwNewDBMgr::GetColumnSupplier(uno::Reference<sdbc::XConnection> xConnection,
+ const OUString& rTableOrQuery,
+ sal_uInt8 eTableOrQuery)
+{
+ Reference< sdbcx::XColumnsSupplier> xRet;
+ try
+ {
+ if(eTableOrQuery == SW_DB_SELECT_UNKNOWN)
+ {
+ //search for a table with the given command name
+ Reference<XTablesSupplier> xTSupplier = Reference<XTablesSupplier>(xConnection, UNO_QUERY);
+ if(xTSupplier.is())
+ {
+ Reference<XNameAccess> xTbls = xTSupplier->getTables();
+ eTableOrQuery = xTbls->hasByName(rTableOrQuery) ?
+ SW_DB_SELECT_TABLE : SW_DB_SELECT_QUERY;
+ }
+ }
+ sal_Int32 nCommandType = SW_DB_SELECT_TABLE == eTableOrQuery ?
+ CommandType::TABLE : CommandType::QUERY;
+ Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
+ Reference<XRowSet> xRowSet(xMgr->createInstance("com.sun.star.sdb.RowSet"), UNO_QUERY);
+
+ OUString sDataSource;
+ Reference<XDataSource> xSource = SwNewDBMgr::getDataSourceAsParent(xConnection, sDataSource);
+ Reference<XPropertySet> xSourceProperties(xSource, UNO_QUERY);
+ if(xSourceProperties.is())
+ {
+ xSourceProperties->getPropertyValue("Name") >>= sDataSource;
+ }
+
+ Reference<XPropertySet> xRowProperties(xRowSet, UNO_QUERY);
+ xRowProperties->setPropertyValue("DataSourceName", makeAny(sDataSource));
+ xRowProperties->setPropertyValue("Command", makeAny(OUString(rTableOrQuery)));
+ xRowProperties->setPropertyValue("CommandType", makeAny(nCommandType));
+ xRowProperties->setPropertyValue("FetchSize", makeAny((sal_Int32)10));
+ xRowProperties->setPropertyValue("ActiveConnection", makeAny(xConnection));
+ xRowSet->execute();
+ xRet = Reference<XColumnsSupplier>( xRowSet, UNO_QUERY );
+ }
+ catch(const uno::Exception&)
+ {
+ OSL_FAIL("Exception in SwDBMgr::GetColumnSupplier");
+ }
+
+ return xRet;
+}
+
+OUString SwNewDBMgr::GetDBField(uno::Reference<XPropertySet> xColumnProps,
+ const SwDBFormatData& rDBFormatData,
+ double* pNumber)
+{
+ uno::Reference< XColumn > xColumn(xColumnProps, UNO_QUERY);
+ OUString sRet;
+ OSL_ENSURE(xColumn.is(), "SwNewDBMgr::::ImportDBField: illegal arguments");
+ if(!xColumn.is())
+ return sRet;
+
+ Any aType = xColumnProps->getPropertyValue("Type");
+ sal_Int32 eDataType = 0;
+ aType >>= eDataType;
+ switch(eDataType)
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ case DataType::LONGVARCHAR:
+ try
+ {
+ sRet = xColumn->getString();
+ }
+ catch(const SQLException&)
+ {
+ }
+ break;
+ case DataType::BIT:
+ case DataType::BOOLEAN:
+ case DataType::TINYINT:
+ case DataType::SMALLINT:
+ case DataType::INTEGER:
+ case DataType::BIGINT:
+ case DataType::FLOAT:
+ case DataType::REAL:
+ case DataType::DOUBLE:
+ case DataType::NUMERIC:
+ case DataType::DECIMAL:
+ case DataType::DATE:
+ case DataType::TIME:
+ case DataType::TIMESTAMP:
+ {
+
+ try
+ {
+ SwDbtoolsClient& aClient = SwNewDBMgr::GetDbtoolsClient();
+ sRet = aClient.getFormattedValue(
+ xColumnProps,
+ rDBFormatData.xFormatter,
+ rDBFormatData.aLocale,
+ rDBFormatData.aNullDate);
+ if (pNumber)
+ {
+ double fVal = xColumn->getDouble();
+ if(!xColumn->wasNull())
+ {
+ *pNumber = fVal;
+ }
+ }
+ }
+ catch(const Exception&)
+ {
+ OSL_FAIL("exception caught");
+ }
+
+ }
+ break;
+ }
+
+ return sRet;
+}
+
+// releases the merge data source table or query after merge is completed
+void SwNewDBMgr::EndMerge()
+{
+ OSL_ENSURE(bInMerge, "merge is not active");
+ bInMerge = sal_False;
+ delete pImpl->pMergeData;
+ pImpl->pMergeData = 0;
+}
+
+// checks if a desired data source table or query is open
+sal_Bool SwNewDBMgr::IsDataSourceOpen(const OUString& rDataSource,
+ const OUString& rTableOrQuery, sal_Bool bMergeOnly)
+{
+ if(pImpl->pMergeData)
+ {
+ return !bMergeLock &&
+ ((rDataSource == pImpl->pMergeData->sDataSource &&
+ rTableOrQuery == pImpl->pMergeData->sCommand)
+ ||(rDataSource.isEmpty() && rTableOrQuery.isEmpty()))
+ &&
+ pImpl->pMergeData->xResultSet.is();
+ }
+ else if(!bMergeOnly)
+ {
+ SwDBData aData;
+ aData.sDataSource = rDataSource;
+ aData.sCommand = rTableOrQuery;
+ aData.nCommandType = -1;
+ SwDSParam* pFound = FindDSData(aData, sal_False);
+ return (pFound && pFound->xResultSet.is());
+ }
+ return sal_False;
+}
+
+// read column data at a specified position
+sal_Bool SwNewDBMgr::GetColumnCnt(const OUString& rSourceName, const OUString& rTableName,
+ const OUString& rColumnName, sal_uInt32 nAbsRecordId,
+ long nLanguage,
+ OUString& rResult, double* pNumber)
+{
+ sal_Bool bRet = sal_False;
+ SwDSParam* pFound = 0;
+ //check if it's the merge data source
+ if(pImpl->pMergeData &&
+ rSourceName == pImpl->pMergeData->sDataSource &&
+ rTableName == pImpl->pMergeData->sCommand)
+ {
+ pFound = pImpl->pMergeData;
+ }
+ else
+ {
+ SwDBData aData;
+ aData.sDataSource = rSourceName;
+ aData.sCommand = rTableName;
+ aData.nCommandType = -1;
+ pFound = FindDSData(aData, sal_False);
+ }
+ if (!pFound)
+ return sal_False;
+ //check validity of supplied record Id
+ if(pFound->aSelection.getLength())
+ {
+ //the destination has to be an element of the selection
+ const Any* pSelection = pFound->aSelection.getConstArray();
+ bool bFound = false;
+ for(sal_Int32 nPos = 0; !bFound && nPos < pFound->aSelection.getLength(); nPos++)
+ {
+ sal_Int32 nSelection = 0;
+ pSelection[nPos] >>= nSelection;
+ if(nSelection == static_cast<sal_Int32>(nAbsRecordId))
+ bFound = true;
+ }
+ if(!bFound)
+ return sal_False;
+ }
+ if(pFound->xResultSet.is() && !pFound->bAfterSelection)
+ {
+ sal_Int32 nOldRow = 0;
+ try
+ {
+ nOldRow = pFound->xResultSet->getRow();
+ }
+ catch(const Exception&)
+ {
+ return sal_False;
+ }
+ //position to the desired index
+ sal_Bool bMove = sal_True;
+ if ( nOldRow != static_cast<sal_Int32>(nAbsRecordId) )
+ bMove = lcl_MoveAbsolute(pFound, nAbsRecordId);
+ if(bMove)
+ {
+ bRet = lcl_GetColumnCnt(pFound, rColumnName, nLanguage, rResult, pNumber);
+ }
+ if ( nOldRow != static_cast<sal_Int32>(nAbsRecordId) )
+ bMove = lcl_MoveAbsolute(pFound, nOldRow);
+ }
+ return bRet;
+}
+
+// reads the column data at the current position
+sal_Bool SwNewDBMgr::GetMergeColumnCnt(const OUString& rColumnName, sal_uInt16 nLanguage,
+ OUString &rResult, double *pNumber, sal_uInt32 * /*pFormat*/)
+{
+ if(!pImpl->pMergeData || !pImpl->pMergeData->xResultSet.is() || pImpl->pMergeData->bAfterSelection )
+ {
+ rResult = "";
+ return sal_False;
+ }
+
+ sal_Bool bRet = lcl_GetColumnCnt(pImpl->pMergeData, rColumnName, nLanguage, rResult, pNumber);
+ return bRet;
+}
+
+sal_Bool SwNewDBMgr::ToNextMergeRecord()
+{
+ OSL_ENSURE(pImpl->pMergeData && pImpl->pMergeData->xResultSet.is(), "no data source in merge");
+ return ToNextRecord(pImpl->pMergeData);
+}
+
+sal_Bool SwNewDBMgr::ToNextRecord(
+ const OUString& rDataSource, const OUString& rCommand, sal_Int32 /*nCommandType*/)
+{
+ SwDSParam* pFound = 0;
+ if(pImpl->pMergeData &&
+ rDataSource == pImpl->pMergeData->sDataSource &&
+ rCommand == pImpl->pMergeData->sCommand)
+ pFound = pImpl->pMergeData;
+ else
+ {
+ SwDBData aData;
+ aData.sDataSource = rDataSource;
+ aData.sCommand = rCommand;
+ aData.nCommandType = -1;
+ pFound = FindDSData(aData, sal_False);
+ }
+ return ToNextRecord(pFound);
+}
+
+sal_Bool SwNewDBMgr::ToNextRecord(SwDSParam* pParam)
+{
+ sal_Bool bRet = sal_True;
+ if(!pParam || !pParam->xResultSet.is() || pParam->bEndOfDB ||
+ (pParam->aSelection.getLength() && pParam->aSelection.getLength() <= pParam->nSelectionIndex))
+ {
+ if(pParam)
+ pParam->CheckEndOfDB();
+ return sal_False;
+ }
+ try
+ {
+ if(pParam->aSelection.getLength())
+ {
+ sal_Int32 nPos = 0;
+ pParam->aSelection.getConstArray()[ pParam->nSelectionIndex++ ] >>= nPos;
+ pParam->bEndOfDB = !pParam->xResultSet->absolute( nPos );
+ pParam->CheckEndOfDB();
+ bRet = !pParam->bEndOfDB;
+ if(pParam->nSelectionIndex >= pParam->aSelection.getLength())
+ pParam->bEndOfDB = sal_True;
+ }
+ else
+ {
+ sal_Int32 nBefore = pParam->xResultSet->getRow();
+ pParam->bEndOfDB = !pParam->xResultSet->next();
+ if( !pParam->bEndOfDB && nBefore == pParam->xResultSet->getRow())
+ {
+ //next returned true but it didn't move
+ pParam->bEndOfDB = sal_True;
+ }
+
+ pParam->CheckEndOfDB();
+ bRet = !pParam->bEndOfDB;
+ ++pParam->nSelectionIndex;
+ }
+ }
+ catch(const Exception&)
+ {
+ }
+ return bRet;
+}
+
+/* ------------------------------------------------------------------------
+ synchronized labels contain a next record field at their end
+ to assure that the next page can be created in mail merge
+ the cursor position must be validated
+ ---------------------------------------------------------------------------*/
+sal_Bool SwNewDBMgr::ExistsNextRecord() const
+{
+ return pImpl->pMergeData && !pImpl->pMergeData->bEndOfDB;
+}
+
+sal_uInt32 SwNewDBMgr::GetSelectedRecordId()
+{
+ sal_uInt32 nRet = 0;
+ OSL_ENSURE(pImpl->pMergeData && pImpl->pMergeData->xResultSet.is(), "no data source in merge");
+ if(!pImpl->pMergeData || !pImpl->pMergeData->xResultSet.is())
+ return sal_False;
+ try
+ {
+ nRet = pImpl->pMergeData->xResultSet->getRow();
+ }
+ catch(const Exception&)
+ {
+ }
+ return nRet;
+}
+
+sal_Bool SwNewDBMgr::ToRecordId(sal_Int32 nSet)
+{
+ OSL_ENSURE(pImpl->pMergeData && pImpl->pMergeData->xResultSet.is(), "no data source in merge");
+ if(!pImpl->pMergeData || !pImpl->pMergeData->xResultSet.is()|| nSet < 0)
+ return sal_False;
+ sal_Bool bRet = sal_False;
+ sal_Int32 nAbsPos = nSet;
+
+ if(nAbsPos >= 0)
+ {
+ bRet = lcl_MoveAbsolute(pImpl->pMergeData, nAbsPos);
+ pImpl->pMergeData->bEndOfDB = !bRet;
+ pImpl->pMergeData->CheckEndOfDB();
+ }
+ return bRet;
+}
+
+sal_Bool SwNewDBMgr::OpenDataSource(const OUString& rDataSource, const OUString& rTableOrQuery,
+ sal_Int32 nCommandType, bool bCreate)
+{
+ SwDBData aData;
+ aData.sDataSource = rDataSource;
+ aData.sCommand = rTableOrQuery;
+ aData.nCommandType = nCommandType;
+
+ SwDSParam* pFound = FindDSData(aData, sal_True);
+ uno::Reference< XDataSource> xSource;
+ if(pFound->xResultSet.is())
+ return sal_True;
+ SwDSParam* pParam = FindDSConnection(rDataSource, sal_False);
+ uno::Reference< XConnection> xConnection;
+ if(pParam && pParam->xConnection.is())
+ pFound->xConnection = pParam->xConnection;
+ else if(bCreate)
+ {
+ OUString sDataSource(rDataSource);
+ pFound->xConnection = RegisterConnection( sDataSource );
+ }
+ if(pFound->xConnection.is())
+ {
+ try
+ {
+ uno::Reference< sdbc::XDatabaseMetaData > xMetaData = pFound->xConnection->getMetaData();
+ try
+ {
+ pFound->bScrollable = xMetaData
+ ->supportsResultSetType((sal_Int32)ResultSetType::SCROLL_INSENSITIVE);
+ }
+ catch(const Exception&)
+ {
+ // DB driver may not be ODBC 3.0 compliant
+ pFound->bScrollable = sal_True;
+ }
+ pFound->xStatement = pFound->xConnection->createStatement();
+ OUString aQuoteChar = xMetaData->getIdentifierQuoteString();
+ OUString sStatement("SELECT * FROM ");
+ sStatement = "SELECT * FROM ";
+ sStatement += aQuoteChar;
+ sStatement += rTableOrQuery;
+ sStatement += aQuoteChar;
+ pFound->xResultSet = pFound->xStatement->executeQuery( sStatement );
+
+ //after executeQuery the cursor must be positioned
+ pFound->bEndOfDB = !pFound->xResultSet->next();
+ pFound->bAfterSelection = sal_False;
+ pFound->CheckEndOfDB();
+ ++pFound->nSelectionIndex;
+ }
+ catch (const Exception&)
+ {
+ pFound->xResultSet = 0;
+ pFound->xStatement = 0;
+ pFound->xConnection = 0;
+ }
+ }
+ return pFound->xResultSet.is();
+}
+
+uno::Reference< XConnection> SwNewDBMgr::RegisterConnection(OUString& rDataSource)
+{
+ SwDSParam* pFound = SwNewDBMgr::FindDSConnection(rDataSource, sal_True);
+ uno::Reference< XDataSource> xSource;
+ if(!pFound->xConnection.is())
+ {
+ pFound->xConnection = SwNewDBMgr::GetConnection(rDataSource, xSource );
+ try
+ {
+ uno::Reference<XComponent> xComponent(pFound->xConnection, UNO_QUERY);
+ if(xComponent.is())
+ xComponent->addEventListener(pImpl->xDisposeListener);
+ }
+ catch(const Exception&)
+ {
+ }
+ }
+ return pFound->xConnection;
+}
+
+sal_uInt32 SwNewDBMgr::GetSelectedRecordId(
+ const OUString& rDataSource, const OUString& rTableOrQuery, sal_Int32 nCommandType)
+{
+ sal_uInt32 nRet = 0xffffffff;
+ //check for merge data source first
+ if(pImpl->pMergeData && rDataSource == pImpl->pMergeData->sDataSource &&
+ rTableOrQuery == pImpl->pMergeData->sCommand &&
+ (nCommandType == -1 || nCommandType == pImpl->pMergeData->nCommandType) &&
+ pImpl->pMergeData->xResultSet.is())
+ nRet = GetSelectedRecordId();
+ else
+ {
+ SwDBData aData;
+ aData.sDataSource = rDataSource;
+ aData.sCommand = rTableOrQuery;
+ aData.nCommandType = nCommandType;
+ SwDSParam* pFound = FindDSData(aData, sal_False);
+ if(pFound && pFound->xResultSet.is())
+ {
+ try
+ { //if a selection array is set the current row at the result set may not be set yet
+ if(pFound->aSelection.getLength())
+ {
+ sal_Int32 nSelIndex = pFound->nSelectionIndex;
+ if(nSelIndex >= pFound->aSelection.getLength())
+ nSelIndex = pFound->aSelection.getLength() -1;
+ pFound->aSelection.getConstArray()[nSelIndex] >>= nRet;
+
+ }
+ else
+ nRet = pFound->xResultSet->getRow();
+ }
+ catch(const Exception&)
+ {
+ }
+ }
+ }
+ return nRet;
+}
+
+// close all data sources - after fields were updated
+void SwNewDBMgr::CloseAll(sal_Bool bIncludingMerge)
+{
+ //the only thing done here is to reset the selection index
+ //all connections stay open
+ for(sal_uInt16 nPos = 0; nPos < aDataSourceParams.size(); nPos++)
+ {
+ SwDSParam* pParam = &aDataSourceParams[nPos];
+ if(bIncludingMerge || pParam != pImpl->pMergeData)
+ {
+ pParam->nSelectionIndex = 0;
+ pParam->bAfterSelection = sal_False;
+ pParam->bEndOfDB = sal_False;
+ try
+ {
+ if(!bInMerge && pParam->xResultSet.is())
+ pParam->xResultSet->first();
+ }
+ catch(const Exception&)
+ {}
+ }
+ }
+}
+
+SwDSParam* SwNewDBMgr::FindDSData(const SwDBData& rData, sal_Bool bCreate)
+{
+ //prefer merge data if available
+ if(pImpl->pMergeData && rData.sDataSource == pImpl->pMergeData->sDataSource &&
+ rData.sCommand == pImpl->pMergeData->sCommand &&
+ (rData.nCommandType == -1 || rData.nCommandType == pImpl->pMergeData->nCommandType ||
+ (bCreate && pImpl->pMergeData->nCommandType == -1)))
+ {
+ return pImpl->pMergeData;
+ }
+
+ SwDSParam* pFound = 0;
+ for(sal_uInt16 nPos = aDataSourceParams.size(); nPos; nPos--)
+ {
+ SwDSParam* pParam = &aDataSourceParams[nPos - 1];
+ if(rData.sDataSource == pParam->sDataSource &&
+ rData.sCommand == pParam->sCommand &&
+ (rData.nCommandType == -1 || rData.nCommandType == pParam->nCommandType ||
+ (bCreate && pParam->nCommandType == -1)))
+ {
+ // calls from the calculator may add a connection with an invalid commandtype
+ //later added "real" data base connections have to re-use the already available
+ //DSData and set the correct CommandType
+ if(bCreate && pParam->nCommandType == -1)
+ pParam->nCommandType = rData.nCommandType;
+ pFound = pParam;
+ break;
+ }
+ }
+ if(bCreate)
+ {
+ if(!pFound)
+ {
+ pFound = new SwDSParam(rData);
+ aDataSourceParams.push_back(pFound);
+ try
+ {
+ uno::Reference<XComponent> xComponent(pFound->xConnection, UNO_QUERY);
+ if(xComponent.is())
+ xComponent->addEventListener(pImpl->xDisposeListener);
+ }
+ catch(const Exception&)
+ {
+ }
+ }
+ }
+ return pFound;
+}
+
+SwDSParam* SwNewDBMgr::FindDSConnection(const OUString& rDataSource, sal_Bool bCreate)
+{
+ //prefer merge data if available
+ if(pImpl->pMergeData && rDataSource == pImpl->pMergeData->sDataSource )
+ {
+ return pImpl->pMergeData;
+ }
+ SwDSParam* pFound = 0;
+ for(sal_uInt16 nPos = 0; nPos < aDataSourceParams.size(); nPos++)
+ {
+ SwDSParam* pParam = &aDataSourceParams[nPos];
+ if(rDataSource == pParam->sDataSource)
+ {
+ pFound = pParam;
+ break;
+ }
+ }
+ if(bCreate && !pFound)
+ {
+ SwDBData aData;
+ aData.sDataSource = rDataSource;
+ pFound = new SwDSParam(aData);
+ aDataSourceParams.push_back(pFound);
+ try
+ {
+ uno::Reference<XComponent> xComponent(pFound->xConnection, UNO_QUERY);
+ if(xComponent.is())
+ xComponent->addEventListener(pImpl->xDisposeListener);
+ }
+ catch(const Exception&)
+ {
+ }
+ }
+ return pFound;
+}
+
+const SwDBData& SwNewDBMgr::GetAddressDBName()
+{
+ return SW_MOD()->GetDBConfig()->GetAddressSource();
+}
+
+Sequence<OUString> SwNewDBMgr::GetExistingDatabaseNames()
+{
+ Reference<XComponentContext> xContext( ::comphelper::getProcessComponentContext() );
+ Reference<XDatabaseContext> xDBContext = DatabaseContext::create(xContext);
+ return xDBContext->getElementNames();
+}
+
+OUString SwNewDBMgr::LoadAndRegisterDataSource()
+{
+ sfx2::FileDialogHelper aDlgHelper( TemplateDescription::FILEOPEN_SIMPLE, 0 );
+ Reference < XFilePicker > xFP = aDlgHelper.GetFilePicker();
+
+ OUString sHomePath(SvtPathOptions().GetWorkPath());
+ aDlgHelper.SetDisplayDirectory( sHomePath );
+
+ Reference<XFilterManager> xFltMgr(xFP, UNO_QUERY);
+
+ OUString sFilterAll(SW_RES(STR_FILTER_ALL));
+ OUString sFilterAllData(SW_RES(STR_FILTER_ALL_DATA));
+ OUString sFilterSXB(SW_RES(STR_FILTER_SXB));
+ OUString sFilterSXC(SW_RES(STR_FILTER_SXC));
+ OUString sFilterDBF(SW_RES(STR_FILTER_DBF));
+ OUString sFilterXLS(SW_RES(STR_FILTER_XLS));
+ OUString sFilterTXT(SW_RES(STR_FILTER_TXT));
+ OUString sFilterCSV(SW_RES(STR_FILTER_CSV));
+#ifdef WNT
+ OUString sFilterMDB(SW_RES(STR_FILTER_MDB));
+ OUString sFilterACCDB(SW_RES(STR_FILTER_ACCDB));
+#endif
+ xFltMgr->appendFilter( sFilterAll, "*" );
+ xFltMgr->appendFilter( sFilterAllData, "*.ods;*.sxc;*.dbf;*.xls;*.txt;*.csv");
+
+ xFltMgr->appendFilter( sFilterSXB, "*.odb" );
+ xFltMgr->appendFilter( sFilterSXC, "*.ods;*.sxc" );
+ xFltMgr->appendFilter( sFilterDBF, "*.dbf" );
+ xFltMgr->appendFilter( sFilterXLS, "*.xls" );
+ xFltMgr->appendFilter( sFilterTXT, "*.txt" );
+ xFltMgr->appendFilter( sFilterCSV, "*.csv" );
+#ifdef WNT
+ xFltMgr->appendFilter( sFilterMDB, "*.mdb" );
+ xFltMgr->appendFilter( sFilterACCDB, "*.accdb" );
+#endif
+
+ xFltMgr->setCurrentFilter( sFilterAll ) ;
+ OUString sFind;
+ bool bTextConnection = false;
+ if( ERRCODE_NONE == aDlgHelper.Execute() )
+ {
+ OUString sURL = xFP->getFiles().getConstArray()[0];
+ //data sources have to be registered depending on their extensions
+ INetURLObject aURL( sURL );
+ OUString sExt( aURL.GetExtension() );
+ Any aURLAny;
+ Any aTableFilterAny;
+ Any aSuppressVersionsAny;
+ Any aInfoAny;
+ INetURLObject aTempURL(aURL);
+ bool bStore = true;
+ if(sExt == "odb")
+ {
+ bStore = false;
+ }
+ else if(sExt.equalsIgnoreAsciiCase("sxc")
+ || sExt.equalsIgnoreAsciiCase("ods")
+ || sExt.equalsIgnoreAsciiCase("xls"))
+ {
+ OUString sDBURL("sdbc:calc:");
+ sDBURL += aTempURL.GetMainURL(INetURLObject::NO_DECODE);
+ aURLAny <<= sDBURL;
+ }
+ else if(sExt.equalsIgnoreAsciiCase("dbf"))
+ {
+ aTempURL.removeSegment();
+ aTempURL.removeFinalSlash();
+ OUString sDBURL("sdbc:dbase:");
+ sDBURL += aTempURL.GetMainURL(INetURLObject::NO_DECODE);
+ aURLAny <<= sDBURL;
+ //set the filter to the file name without extension
+ Sequence<OUString> aFilters(1);
+ aFilters[0] = aURL.getBase();
+ aTableFilterAny <<= aFilters;
+ }
+ else if(sExt.equalsIgnoreAsciiCase("csv") || sExt.equalsIgnoreAsciiCase("txt"))
+ {
+ aTempURL.removeSegment();
+ aTempURL.removeFinalSlash();
+ OUString sDBURL("sdbc:flat:");
+ //only the 'path' has to be added
+ sDBURL += aTempURL.GetMainURL(INetURLObject::NO_DECODE);
+ aURLAny <<= sDBURL;
+
+ bTextConnection = true;
+ //set the filter to the file name without extension
+ Sequence<OUString> aFilters(1);
+ aFilters[0] = aURL.getBase();
+ aTableFilterAny <<= aFilters;
+ }
+#ifdef WNT
+ else if(sExt.equalsIgnoreAsciiCase("mdb"))
+ {
+ OUString sDBURL("sdbc:ado:access:PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=");
+ sDBURL += aTempURL.PathToFileName();
+ aURLAny <<= sDBURL;
+ aSuppressVersionsAny <<= makeAny(true);
+ }
+ else if(sExt.equalsIgnoreAsciiCase("accdb"))
+ {
+ OUString sDBURL("sdbc:ado:PROVIDER=Microsoft.ACE.OLEDB.12.0;DATA SOURCE=");
+ sDBURL += aTempURL.PathToFileName();
+ aURLAny <<= sDBURL;
+ aSuppressVersionsAny <<= makeAny(true);
+ }
+#endif
+ try
+ {
+ Reference<XComponentContext> xContext( ::comphelper::getProcessComponentContext() );
+ Reference<XDatabaseContext> xDBContext = DatabaseContext::create(xContext);
+
+ OUString sNewName = INetURLObject::decode( aURL.getName(),
+ INET_HEX_ESCAPE,
+ INetURLObject::DECODE_UNAMBIGUOUS,
+ RTL_TEXTENCODING_UTF8 );
+ sal_Int32 nExtLen = aURL.GetExtension().getLength();
+ sNewName = sNewName.replaceAt( sNewName.getLength() - nExtLen - 1, nExtLen + 1, "" );
+
+ //find a unique name if sNewName already exists
+ sFind = sNewName;
+ sal_Int32 nIndex = 0;
+ while(xDBContext->hasByName(sFind))
+ {
+ sFind = sNewName;
+ sFind += OUString::number(++nIndex);
+ }
+
+ Reference<XInterface> xNewInstance;
+ if(!bStore)
+ {
+ //odb-file
+ Any aDataSource = xDBContext->getByName(aTempURL.GetMainURL(INetURLObject::NO_DECODE));
+ aDataSource >>= xNewInstance;
+ }
+ else
+ {
+ xNewInstance = xDBContext->createInstance();
+ Reference<XPropertySet> xDataProperties(xNewInstance, UNO_QUERY);
+
+ if(aURLAny.hasValue())
+ xDataProperties->setPropertyValue("URL", aURLAny);
+ if(aTableFilterAny.hasValue())
+ xDataProperties->setPropertyValue("TableFilter", aTableFilterAny);
+ if(aSuppressVersionsAny.hasValue())
+ xDataProperties->setPropertyValue("SuppressVersionColumns", aSuppressVersionsAny);
+ if(aInfoAny.hasValue())
+ xDataProperties->setPropertyValue("Info", aInfoAny);
+
+ if( bTextConnection )
+ {
+ uno::Reference < sdb::XTextConnectionSettings > xSettingsDlg = sdb::TextConnectionSettings::create(xContext);
+ if( xSettingsDlg->execute() )
+ {
+ uno::Any aSettings = xDataProperties->getPropertyValue( "Settings" );
+ uno::Reference < beans::XPropertySet > xDSSettings;
+ aSettings >>= xDSSettings;
+ ::comphelper::copyProperties(
+ uno::Reference < beans::XPropertySet >( xSettingsDlg, uno::UNO_QUERY_THROW ),
+ xDSSettings );
+ xDSSettings->setPropertyValue( "Extension", uno::makeAny( sExt ));
+ }
+ }
+
+ Reference<XDocumentDataSource> xDS(xNewInstance, UNO_QUERY_THROW);
+ Reference<XStorable> xStore(xDS->getDatabaseDocument(), UNO_QUERY_THROW);
+ OUString sOutputExt = ".odb";
+ OUString sTmpName;
+ {
+ utl::TempFile aTempFile(sNewName , &sOutputExt, &sHomePath);
+ aTempFile.EnableKillingFile(true);
+ sTmpName = aTempFile.GetURL();
+ }
+ xStore->storeAsURL(sTmpName, Sequence< PropertyValue >());
+ }
+ xDBContext->registerObject( sFind, xNewInstance );
+
+ }
+ catch(const Exception&)
+ {
+ }
+ }
+ return sFind;
+
+}
+
+void SwNewDBMgr::ExecuteFormLetter( SwWrtShell& rSh,
+ const Sequence<PropertyValue>& rProperties,
+ sal_Bool bWithDataSourceBrowser)
+{
+ //prevent second call
+ if(pImpl->pMergeDialog)
+ return ;
+ OUString sDataSource, sDataTableOrQuery;
+ Sequence<Any> aSelection;
+
+ sal_Int32 nCmdType = CommandType::TABLE;
+ uno::Reference< XConnection> xConnection;
+
+ ODataAccessDescriptor aDescriptor(rProperties);
+ sDataSource = aDescriptor.getDataSource();
+ OSL_VERIFY(aDescriptor[daCommand] >>= sDataTableOrQuery);
+ OSL_VERIFY(aDescriptor[daCommandType] >>= nCmdType);
+
+ if ( aDescriptor.has(daSelection) )
+ aDescriptor[daSelection] >>= aSelection;
+ if ( aDescriptor.has(daConnection) )
+ aDescriptor[daConnection] >>= xConnection;
+
+ if(sDataSource.isEmpty() || sDataTableOrQuery.isEmpty())
+ {
+ OSL_FAIL("PropertyValues missing or unset");
+ return;
+ }
+
+ //always create a connection for the dialog and dispose it after the dialog has been closed
+ SwDSParam* pFound = 0;
+ if(!xConnection.is())
+ {
+ xConnection = SwNewDBMgr::RegisterConnection(sDataSource);
+ pFound = FindDSConnection(sDataSource, sal_True);
+ }
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "Dialogdiet fail!");
+ pImpl->pMergeDialog = pFact->CreateMailMergeDlg( DLG_MAILMERGE,
+ &rSh.GetView().GetViewFrame()->GetWindow(), rSh,
+ sDataSource,
+ sDataTableOrQuery,
+ nCmdType,
+ xConnection,
+ bWithDataSourceBrowser ? 0 : &aSelection);
+ OSL_ENSURE(pImpl->pMergeDialog, "Dialogdiet fail!");
+ if(pImpl->pMergeDialog->Execute() == RET_OK)
+ {
+ aDescriptor[daSelection] <<= pImpl->pMergeDialog->GetSelection();
+
+ uno::Reference<XResultSet> xResSet = pImpl->pMergeDialog->GetResultSet();
+ if(xResSet.is())
+ aDescriptor[daCursor] <<= xResSet;
+
+ // SfxObjectShellRef is ok, since there should be no control over the document lifetime here
+ SfxObjectShellRef xDocShell = rSh.GetView().GetViewFrame()->GetObjectShell();
+ SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE, SwDocShell::GetEventName(STR_SW_EVENT_MAIL_MERGE), xDocShell));
+ {
+ //copy rSh to aTempFile
+ OUString sTempURL;
+ const SfxFilter *pSfxFlt = SwIoSystem::GetFilterOfFormat(
+ OUString(FILTER_XML),
+ SwDocShell::Factory().GetFilterContainer() );
+ try
+ {
+
+ uno::Sequence< beans::PropertyValue > aValues(1);
+ beans::PropertyValue* pValues = aValues.getArray();
+ pValues[0].Name = "FilterName";
+ pValues[0].Value <<= OUString(pSfxFlt->GetFilterName());
+ uno::Reference< XStorable > xStore( xDocShell->GetModel(), uno::UNO_QUERY);
+ sTempURL = URIHelper::SmartRel2Abs( INetURLObject(), utl::TempFile::CreateTempName() );
+ xStore->storeToURL( sTempURL, aValues );
+ }
+ catch(const uno::Exception&)
+ {
+ }
+ if( xDocShell->GetError() )
+ {
+ // error message ??
+ ErrorHandler::HandleError( xDocShell->GetError() );
+ }
+ else
+ {
+ // the shell will be explicitly closed, but it is more safe to use SfxObjectShellLock here
+ // especially for the case that the loading has failed
+ SfxObjectShellLock xWorkDocSh( new SwDocShell( SFX_CREATE_MODE_INTERNAL ));
+ SfxMedium* pWorkMed = new SfxMedium( sTempURL, STREAM_STD_READ );
+ pWorkMed->SetFilter( pSfxFlt );
+ if( xWorkDocSh->DoLoad(pWorkMed) )
+ {
+ SfxViewFrame *pFrame = SfxViewFrame::LoadHiddenDocument( *xWorkDocSh, 0 );
+ SwView *pView = (SwView*) pFrame->GetViewShell();
+ pView->AttrChangedNotify( &pView->GetWrtShell() );// in order for SelectShell to be called
+ //set the current DBMgr
+ SwDoc* pWorkDoc = pView->GetWrtShell().GetDoc();
+ SwNewDBMgr* pWorkDBMgr = pWorkDoc->GetNewDBMgr();
+ pWorkDoc->SetNewDBMgr( this );
+
+ SwMergeDescriptor aMergeDesc( pImpl->pMergeDialog->GetMergeType(), pView->GetWrtShell(), aDescriptor );
+ aMergeDesc.sSaveToFilter = pImpl->pMergeDialog->GetSaveFilter();
+ aMergeDesc.bCreateSingleFile = !pImpl->pMergeDialog->IsSaveIndividualDocs();
+ if( !aMergeDesc.bCreateSingleFile && pImpl->pMergeDialog->IsGenerateFromDataBase() )
+ {
+ aMergeDesc.sAddressFromColumn = pImpl->pMergeDialog->GetColumnName();
+ aMergeDesc.sSubject = pImpl->pMergeDialog->GetPath();
+ }
+
+ MergeNew(aMergeDesc);
+
+ pWorkDoc->SetNewDBMgr( pWorkDBMgr );
+ //close the temporary file
+ uno::Reference< util::XCloseable > xClose( xWorkDocSh->GetModel(), uno::UNO_QUERY );
+ if (xClose.is())
+ {
+ try
+ {
+ //! 'sal_True' -> transfer ownership to vetoing object if vetoed!
+ //! I.e. now that object is responsible for closing the model and doc shell.
+ xClose->close( sal_True );
+ }
+ catch (const uno::Exception&)
+ {
+ }
+ }
+ }
+ }
+ //remove the temporary file
+ SWUnoHelper::UCB_DeleteFile( sTempURL );
+ }
+ SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE_END, SwDocShell::GetEventName(STR_SW_EVENT_MAIL_MERGE_END), rSh.GetView().GetViewFrame()->GetObjectShell()));
+
+ // reset the cursor inside
+ xResSet = NULL;
+ aDescriptor[daCursor] <<= xResSet;
+ }
+ if(pFound)
+ {
+ for(sal_uInt16 nPos = 0; nPos < aDataSourceParams.size(); nPos++)
+ {
+ SwDSParam* pParam = &aDataSourceParams[nPos];
+ if(pParam == pFound)
+ {
+ try
+ {
+ uno::Reference<XComponent> xComp(pParam->xConnection, UNO_QUERY);
+ if(xComp.is())
+ xComp->dispose();
+ }
+ catch(const RuntimeException&)
+ {
+ //may be disposed already since multiple entries may have used the same connection
+ }
+ break;
+ }
+ //pFound doesn't need to be removed/deleted -
+ //this has been done by the SwConnectionDisposedListener_Impl already
+ }
+ }
+ DELETEZ(pImpl->pMergeDialog);
+}
+
+void SwNewDBMgr::InsertText(SwWrtShell& rSh,
+ const Sequence< PropertyValue>& rProperties)
+{
+ OUString sDataSource, sDataTableOrQuery;
+ uno::Reference<XResultSet> xResSet;
+ Sequence<Any> aSelection;
+ sal_Int16 nCmdType = CommandType::TABLE;
+ const PropertyValue* pValues = rProperties.getConstArray();
+ uno::Reference< XConnection> xConnection;
+ for(sal_Int32 nPos = 0; nPos < rProperties.getLength(); nPos++)
+ {
+ if ( pValues[nPos].Name == cDataSourceName )
+ pValues[nPos].Value >>= sDataSource;
+ else if ( pValues[nPos].Name == cCommand )
+ pValues[nPos].Value >>= sDataTableOrQuery;
+ else if ( pValues[nPos].Name == cCursor )
+ pValues[nPos].Value >>= xResSet;
+ else if ( pValues[nPos].Name == cSelection )
+ pValues[nPos].Value >>= aSelection;
+ else if ( pValues[nPos].Name == cCommandType )
+ pValues[nPos].Value >>= nCmdType;
+ else if ( pValues[nPos].Name == cActiveConnection )
+ pValues[nPos].Value >>= xConnection;
+ }
+ if(sDataSource.isEmpty() || sDataTableOrQuery.isEmpty() || !xResSet.is())
+ {
+ OSL_FAIL("PropertyValues missing or unset");
+ return;
+ }
+ Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
+ uno::Reference<XDataSource> xSource;
+ uno::Reference<XChild> xChild(xConnection, UNO_QUERY);
+ if(xChild.is())
+ xSource = uno::Reference<XDataSource>(xChild->getParent(), UNO_QUERY);
+ if(!xSource.is())
+ xSource = SwNewDBMgr::GetDbtoolsClient().getDataSource(sDataSource, xContext);
+ uno::Reference< XColumnsSupplier > xColSupp( xResSet, UNO_QUERY );
+ SwDBData aDBData;
+ aDBData.sDataSource = sDataSource;
+ aDBData.sCommand = sDataTableOrQuery;
+ aDBData.nCommandType = nCmdType;
+
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+
+ boost::scoped_ptr<AbstractSwInsertDBColAutoPilot> pDlg(pFact->CreateSwInsertDBColAutoPilot( rSh.GetView(),
+ xSource,
+ xColSupp,
+ aDBData ));
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ if( RET_OK == pDlg->Execute() )
+ {
+ OUString sDummy;
+ if(!xConnection.is())
+ xConnection = xSource->getConnection(sDummy, sDummy);
+ try
+ {
+ pDlg->DataToDoc( aSelection , xSource, xConnection, xResSet);
+ }
+ catch(const Exception&)
+ {
+ OSL_FAIL("exception caught");
+ }
+ }
+}
+
+SwDbtoolsClient* SwNewDBMgr::pDbtoolsClient = NULL;
+
+SwDbtoolsClient& SwNewDBMgr::GetDbtoolsClient()
+{
+ if ( !pDbtoolsClient )
+ pDbtoolsClient = new SwDbtoolsClient;
+ return *pDbtoolsClient;
+}
+
+void SwNewDBMgr::RemoveDbtoolsClient()
+{
+ delete pDbtoolsClient;
+ pDbtoolsClient = 0;
+}
+
+uno::Reference<XDataSource> SwNewDBMgr::getDataSourceAsParent(const uno::Reference< XConnection>& _xConnection,const OUString& _sDataSourceName)
+{
+ uno::Reference<XDataSource> xSource;
+ try
+ {
+ uno::Reference<XChild> xChild(_xConnection, UNO_QUERY);
+ if ( xChild.is() )
+ xSource = uno::Reference<XDataSource>(xChild->getParent(), UNO_QUERY);
+ if ( !xSource.is() )
+ xSource = SwNewDBMgr::GetDbtoolsClient().getDataSource(_sDataSourceName, ::comphelper::getProcessComponentContext());
+ }
+ catch(const Exception&)
+ {
+ OSL_FAIL("exception in getDataSourceAsParent caught");
+ }
+ return xSource;
+}
+
+uno::Reference<XResultSet> SwNewDBMgr::createCursor(const OUString& _sDataSourceName,
+ const OUString& _sCommand,
+ sal_Int32 _nCommandType,
+ const uno::Reference<XConnection>& _xConnection
+ )
+{
+ uno::Reference<XResultSet> xResultSet;
+ try
+ {
+ uno::Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
+ if( xMgr.is() )
+ {
+ uno::Reference<XInterface> xInstance = xMgr->createInstance("com.sun.star.sdb.RowSet");
+ uno::Reference<XPropertySet> xRowSetPropSet(xInstance, UNO_QUERY);
+ if(xRowSetPropSet.is())
+ {
+ xRowSetPropSet->setPropertyValue("DataSourceName", makeAny(_sDataSourceName));
+ xRowSetPropSet->setPropertyValue("ActiveConnection", makeAny(_xConnection));
+ xRowSetPropSet->setPropertyValue("Command", makeAny(_sCommand));
+ xRowSetPropSet->setPropertyValue("CommandType", makeAny(_nCommandType));
+
+ uno::Reference< XCompletedExecution > xRowSet(xInstance, UNO_QUERY);
+
+ if ( xRowSet.is() )
+ {
+ uno::Reference< XInteractionHandler > xHandler( InteractionHandler::createWithParent(comphelper::getComponentContext(xMgr), 0), UNO_QUERY_THROW );
+ xRowSet->executeWithCompletion(xHandler);
+ }
+ xResultSet = uno::Reference<XResultSet>(xRowSet, UNO_QUERY);
+ }
+ }
+ }
+ catch(const Exception&)
+ {
+ OSL_FAIL("Caught exception while creating a new RowSet!");
+ }
+ return xResultSet;
+}
+
+// merge all data into one resulting document and return the number of merged documents
+sal_Int32 SwNewDBMgr::MergeDocuments( SwMailMergeConfigItem& rMMConfig,
+ SwView& rSourceView )
+{
+ // check the availability of all data in the config item
+ uno::Reference< XResultSet> xResultSet = rMMConfig.GetResultSet();
+ if(!xResultSet.is())
+ return 0;
+ bInMerge = sal_True;
+ sal_Int32 nRet = 0;
+ pImpl->pMergeData = new SwDSParam(
+ rMMConfig.GetCurrentDBData(), xResultSet, rMMConfig.GetSelection());
+
+ try{
+ //set to start position
+ if(pImpl->pMergeData->aSelection.getLength())
+ {
+ sal_Int32 nPos = 0;
+ pImpl->pMergeData->aSelection.getConstArray()[ pImpl->pMergeData->nSelectionIndex++ ] >>= nPos;
+ pImpl->pMergeData->bEndOfDB = !pImpl->pMergeData->xResultSet->absolute( nPos );
+ pImpl->pMergeData->CheckEndOfDB();
+ if(pImpl->pMergeData->nSelectionIndex >= pImpl->pMergeData->aSelection.getLength())
+ pImpl->pMergeData->bEndOfDB = sal_True;
+ }
+ else
+ {
+ pImpl->pMergeData->bEndOfDB = !pImpl->pMergeData->xResultSet->first();
+ pImpl->pMergeData->CheckEndOfDB();
+ }
+ }
+ catch(const Exception&)
+ {
+ pImpl->pMergeData->bEndOfDB = sal_True;
+ pImpl->pMergeData->CheckEndOfDB();
+ OSL_FAIL("exception in MergeNew()");
+ }
+
+ //bCancel is set from the PrintMonitor
+ bCancel = sal_False;
+
+ CreateMonitor aMonitorDlg(&rSourceView.GetEditWin());
+ aMonitorDlg.SetCancelHdl(LINK(this, SwNewDBMgr, PrtCancelHdl));
+ if (!IsMergeSilent())
+ {
+ aMonitorDlg.Show();
+ aMonitorDlg.Invalidate();
+ aMonitorDlg.Update();
+ // the print monitor needs some time to act
+ for( sal_uInt16 i = 0; i < 25; i++)
+ Application::Reschedule();
+ }
+
+ SwWrtShell& rSourceShell = rSourceView.GetWrtShell();
+ bool bSynchronizedDoc = rSourceShell.IsLabelDoc() && rSourceShell.GetSectionFmtCount() > 1;
+ //save the settings of the first
+ rSourceShell.SttEndDoc(sal_True);
+ sal_uInt16 nStartingPageNo = rSourceShell.GetVirtPageNum();
+ OUString sModifiedStartingPageDesc;
+ OUString sStartingPageDesc = sModifiedStartingPageDesc = rSourceShell.GetPageDesc(
+ rSourceShell.GetCurPageDesc()).GetName();
+
+ try
+ {
+ // create a target docshell to put the merged document into
+ SfxObjectShellRef xTargetDocShell( new SwDocShell( SFX_CREATE_MODE_STANDARD ) );
+ xTargetDocShell->DoInitNew( 0 );
+ SfxViewFrame* pTargetFrame = SfxViewFrame::LoadHiddenDocument( *xTargetDocShell, 0 );
+
+ //the created window has to be located at the same position as the source window
+ Window& rTargetWindow = pTargetFrame->GetFrame().GetWindow();
+ Window& rSourceWindow = rSourceView.GetViewFrame()->GetFrame().GetWindow();
+ rTargetWindow.SetPosPixel(rSourceWindow.GetPosPixel());
+
+ SwView* pTargetView = static_cast<SwView*>( pTargetFrame->GetViewShell() );
+ rMMConfig.SetTargetView(pTargetView);
+ //initiate SelectShell() to create sub shells
+ pTargetView->AttrChangedNotify( &pTargetView->GetWrtShell() );
+ SwWrtShell* pTargetShell = pTargetView->GetWrtShellPtr();
+ // #i63806#
+ const SwPageDesc* pSourcePageDesc = rSourceShell.FindPageDescByName( sStartingPageDesc );
+ const SwFrmFmt& rMaster = pSourcePageDesc->GetMaster();
+ bool bPageStylesWithHeaderFooter = rMaster.GetHeader().IsActive() ||
+ rMaster.GetFooter().IsActive();
+
+ // copy compatibility options
+ lcl_CopyCompatibilityOptions( rSourceShell, *pTargetShell);
+ // #72821# copy dynamic defaults
+ lcl_CopyDynamicDefaults( *rSourceShell.GetDoc(), *pTargetShell->GetDoc() );
+
+ long nStartRow, nEndRow;
+ sal_uLong nDocNo = 1;
+ sal_Int32 nDocCount = 0;
+ if( !IsMergeSilent() && lcl_getCountFromResultSet( nDocCount, pImpl->pMergeData->xResultSet ) )
+ aMonitorDlg.SetTotalCount( nDocCount );
+
+ do
+ {
+ nStartRow = pImpl->pMergeData->xResultSet->getRow();
+ if (!IsMergeSilent())
+ {
+ aMonitorDlg.SetCurrentPosition( nDocNo );
+ aMonitorDlg.Invalidate();
+ aMonitorDlg.Update();
+ // the print monitor needs some time to act
+ for( sal_uInt16 i = 0; i < 25; i++)
+ Application::Reschedule();
+ }
+
+ // copy the source document
+ // the copy will be closed later, but it is more safe to use SfxObjectShellLock here
+ SfxObjectShellLock xWorkDocSh;
+ if(nDocNo == 1 )
+ {
+ uno::Reference< util::XCloneable > xClone( rSourceView.GetDocShell()->GetModel(), uno::UNO_QUERY);
+ uno::Reference< lang::XUnoTunnel > xWorkDocShell( xClone->createClone(), uno::UNO_QUERY);
+ SwXTextDocument* pWorkModel = reinterpret_cast<SwXTextDocument*>(xWorkDocShell->getSomething(SwXTextDocument::getUnoTunnelId()));
+ xWorkDocSh = pWorkModel->GetDocShell();
+ }
+ else
+ {
+ xWorkDocSh = rSourceView.GetDocShell()->GetDoc()->CreateCopy(true);
+ }
+ //create a ViewFrame
+ SwView* pWorkView = static_cast< SwView* >( SfxViewFrame::LoadHiddenDocument( *xWorkDocSh, 0 )->GetViewShell() );
+ SwWrtShell& rWorkShell = pWorkView->GetWrtShell();
+ pWorkView->AttrChangedNotify( &rWorkShell );// in order for SelectShell to be called
+
+ // merge the data
+ SwDoc* pWorkDoc = rWorkShell.GetDoc();
+ SwNewDBMgr* pWorkDBMgr = pWorkDoc->GetNewDBMgr();
+ pWorkDoc->SetNewDBMgr( this );
+ pWorkDoc->EmbedAllLinks();
+ SwUndoId nLastUndoId(UNDO_EMPTY);
+ if (rWorkShell.GetLastUndoInfo(0, & nLastUndoId))
+ {
+ if (UNDO_UI_DELETE_INVISIBLECNTNT == nLastUndoId)
+ {
+ rWorkShell.Undo();
+ }
+ }
+ // #i69485# lock fields to prevent access to the result set while calculating layout
+ rWorkShell.LockExpFlds();
+ // create a layout
+ rWorkShell.CalcLayout();
+ rWorkShell.UnlockExpFlds();
+ SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE, SwDocShell::GetEventName(STR_SW_EVENT_FIELD_MERGE), rWorkShell.GetView().GetViewFrame()->GetObjectShell()));
+ rWorkShell.SwViewShell::UpdateFlds();
+ SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE_FINISHED, SwDocShell::GetEventName(STR_SW_EVENT_FIELD_MERGE_FINISHED), rWorkShell.GetView().GetViewFrame()->GetObjectShell()));
+
+ // strip invisible content and convert fields to text
+ rWorkShell.RemoveInvisibleContent();
+ rWorkShell.ConvertFieldsToText();
+ rWorkShell.SetNumberingRestart();
+ if( bSynchronizedDoc )
+ {
+ lcl_RemoveSectionLinks( rWorkShell );
+ }
+
+ // insert the document into the target document
+ rWorkShell.SttEndDoc(sal_False);
+ rWorkShell.SttEndDoc(sal_True);
+ rWorkShell.SelAll();
+ pTargetShell->SttEndDoc(sal_False);
+
+ //#i63806# put the styles to the target document
+ //if the source uses headers or footers each new copy need to copy a new page styles
+ if(bPageStylesWithHeaderFooter)
+ {
+ //create a new pagestyle
+ //copy the pagedesc from the current document to the new document and change the name of the to-be-applied style
+
+ SwDoc* pTargetDoc = pTargetShell->GetDoc();
+ OUString sNewPageDescName = lcl_FindUniqueName(pTargetShell, sStartingPageDesc, nDocNo );
+ pTargetShell->GetDoc()->MakePageDesc( sNewPageDescName );
+ SwPageDesc* pTargetPageDesc = pTargetShell->FindPageDescByName( sNewPageDescName );
+ const SwPageDesc* pWorkPageDesc = rWorkShell.FindPageDescByName( sStartingPageDesc );
+
+ if(pWorkPageDesc && pTargetPageDesc)
+ {
+ pTargetDoc->CopyPageDesc( *pWorkPageDesc, *pTargetPageDesc, false );
+ sModifiedStartingPageDesc = sNewPageDescName;
+ lcl_CopyFollowPageDesc( *pTargetShell, *pWorkPageDesc, *pTargetPageDesc, nDocNo );
+ }
+ }
+ if(nDocNo == 1 || bPageStylesWithHeaderFooter)
+ {
+ pTargetView->GetDocShell()->_LoadStyles( *rSourceView.GetDocShell(), sal_True );
+ }
+ if(nDocNo > 1)
+ {
+ pTargetShell->InsertPageBreak( &sModifiedStartingPageDesc, nStartingPageNo );
+ }
+ else
+ {
+ pTargetShell->SetPageStyle(sModifiedStartingPageDesc);
+ }
+ sal_uInt16 nPageCountBefore = pTargetShell->GetPageCnt();
+ OSL_ENSURE(!pTargetShell->GetTableFmt(),"target document ends with a table - paragraph should be appended");
+ //#i51359# add a second paragraph in case there's only one
+ {
+ SwNodeIndex aIdx( pWorkDoc->GetNodes().GetEndOfExtras(), 2 );
+ SwPosition aTestPos( aIdx );
+ SwCursor aTestCrsr(aTestPos,0,false);
+ if(!aTestCrsr.MovePara(fnParaNext, fnParaStart))
+ {
+ //append a paragraph
+ pWorkDoc->AppendTxtNode( aTestPos );
+ }
+ }
+ pTargetShell->Paste( rWorkShell.GetDoc(), sal_True );
+ //convert fields in page styles (header/footer - has to be done after the first document has been pasted
+ if(1 == nDocNo)
+ {
+ pTargetShell->CalcLayout();
+ pTargetShell->ConvertFieldsToText();
+ }
+ //add the document info to the config item
+ SwDocMergeInfo aMergeInfo;
+ aMergeInfo.nStartPageInTarget = nPageCountBefore;
+ //#i72820# calculate layout to be able to find the correct page index
+ pTargetShell->CalcLayout();
+ aMergeInfo.nEndPageInTarget = pTargetShell->GetPageCnt();
+ aMergeInfo.nDBRow = nStartRow;
+ rMMConfig.AddMergedDocument( aMergeInfo );
+ ++nRet;
+
+ // the print monitor needs some time to act
+ for( sal_uInt16 i = 0; i < 25; i++)
+ Application::Reschedule();
+
+ //restore the ole DBMgr
+ pWorkDoc->SetNewDBMgr( pWorkDBMgr );
+ //now the temporary document should be closed
+ SfxObjectShellRef xDocSh(pWorkView->GetDocShell());
+ xDocSh->DoClose();
+ nEndRow = pImpl->pMergeData->xResultSet->getRow();
+ ++nDocNo;
+ } while( !bCancel &&
+ (bSynchronizedDoc && (nStartRow != nEndRow)? ExistsNextRecord() : ToNextMergeRecord()));
+
+ //deselect all, go out of the frame and go to the beginning of the document
+ Point aPt(LONG_MIN, LONG_MIN);
+ pTargetShell->SelectObj(aPt, SW_LEAVE_FRAME);
+ if (pTargetShell->IsSelFrmMode())
+ {
+ pTargetShell->UnSelectFrm();
+ pTargetShell->LeaveSelFrmMode();
+ }
+ pTargetShell->EnterStdMode();
+ pTargetShell->SttDoc();
+
+ }
+ catch(const Exception&)
+ {
+ OSL_FAIL("exception caught in SwNewDBMgr::MergeDocuments");
+ }
+ DELETEZ(pImpl->pMergeData);
+ bInMerge = sal_False;
+ return nRet;
+}
+
+SwConnectionDisposedListener_Impl::SwConnectionDisposedListener_Impl(SwNewDBMgr& rMgr) :
+ rDBMgr(rMgr)
+{
+};
+
+SwConnectionDisposedListener_Impl::~SwConnectionDisposedListener_Impl()
+{
+};
+
+void SwConnectionDisposedListener_Impl::disposing( const EventObject& rSource )
+ throw (RuntimeException, std::exception)
+{
+ ::SolarMutexGuard aGuard;
+ uno::Reference<XConnection> xSource(rSource.Source, UNO_QUERY);
+ for(sal_uInt16 nPos = rDBMgr.aDataSourceParams.size(); nPos; nPos--)
+ {
+ SwDSParam* pParam = &rDBMgr.aDataSourceParams[nPos - 1];
+ if(pParam->xConnection.is() &&
+ (xSource == pParam->xConnection))
+ {
+ rDBMgr.aDataSourceParams.erase(rDBMgr.aDataSourceParams.begin() + nPos - 1);
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/dbui/dbtree.cxx b/sw/source/core/uibase/dbui/dbtree.cxx
new file mode 100644
index 000000000000..7eb15a02c677
--- /dev/null
+++ b/sw/source/core/uibase/dbui/dbtree.cxx
@@ -0,0 +1,524 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <sot/formats.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdb/DatabaseContext.hpp>
+#include <com/sun/star/sdb/XQueriesSupplier.hpp>
+#include <com/sun/star/sdb/XDatabaseAccess.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/sdb/XCompletedConnection.hpp>
+#include <com/sun/star/container/XContainerListener.hpp>
+#include <com/sun/star/container/XContainer.hpp>
+#include <cppuhelper/implbase1.hxx>
+#include <svx/dbaexchange.hxx>
+
+#include <dbmgr.hxx>
+#include <swmodule.hxx>
+#include <view.hxx>
+#include <wrtsh.hxx>
+#include <dbtree.hxx>
+#include <osl/mutex.hxx>
+#include <vcl/builder.hxx>
+#include <vcl/svapp.hxx>
+#include "svtools/treelistentry.hxx"
+
+#include <helpid.h>
+#include <utlui.hrc>
+
+#include <unomid.h>
+
+#include <boost/ptr_container/ptr_vector.hpp>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::task;
+using namespace ::com::sun::star::beans;
+
+struct SwConnectionData
+{
+ OUString sSourceName;
+ Reference<XConnection> xConnection;
+};
+
+typedef boost::ptr_vector<SwConnectionData> SwConnectionArr;
+
+class SwDBTreeList_Impl : public cppu::WeakImplHelper1 < XContainerListener >
+{
+ Reference< XDatabaseContext > xDBContext;
+ SwConnectionArr aConnections;
+ SwWrtShell* pWrtSh;
+
+ public:
+ SwDBTreeList_Impl(SwWrtShell* pShell) :
+ pWrtSh(pShell) {}
+ ~SwDBTreeList_Impl();
+
+ virtual void SAL_CALL elementInserted( const ContainerEvent& Event ) throw (RuntimeException, std::exception);
+ virtual void SAL_CALL elementRemoved( const ContainerEvent& Event ) throw (RuntimeException, std::exception);
+ virtual void SAL_CALL elementReplaced( const ContainerEvent& Event ) throw (RuntimeException, std::exception);
+ virtual void SAL_CALL disposing( const EventObject& Source ) throw (RuntimeException, std::exception);
+
+ sal_Bool HasContext();
+ SwWrtShell* GetWrtShell() { return pWrtSh;}
+ void SetWrtShell(SwWrtShell& rSh) { pWrtSh = &rSh;}
+ Reference<XDatabaseContext> GetContext() const {return xDBContext;}
+ Reference<XConnection> GetConnection(const OUString& rSourceName);
+};
+
+SwDBTreeList_Impl::~SwDBTreeList_Impl()
+{
+ if(xDBContext.is())
+ {
+ m_refCount++;
+ //block necessary due to solaris' compiler behaviour to
+ //remove temporaries at the block's end
+ {
+ xDBContext->removeContainerListener( this );
+ }
+ m_refCount--;
+ }
+}
+
+void SwDBTreeList_Impl::elementInserted( const ContainerEvent& ) throw (RuntimeException, std::exception)
+{
+ // information not needed
+}
+
+void SwDBTreeList_Impl::elementRemoved( const ContainerEvent& rEvent ) throw (RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ OUString sSource;
+ rEvent.Accessor >>= sSource;
+ for(SwConnectionArr::iterator i = aConnections.begin(); i != aConnections.end(); ++i)
+ {
+ if(i->sSourceName == sSource)
+ {
+ aConnections.erase(i);
+ break;
+ }
+ }
+}
+
+void SwDBTreeList_Impl::disposing( const EventObject& ) throw (RuntimeException, std::exception)
+{
+ xDBContext = 0;
+}
+
+void SwDBTreeList_Impl::elementReplaced( const ContainerEvent& rEvent ) throw (RuntimeException, std::exception)
+{
+ elementRemoved(rEvent);
+}
+
+sal_Bool SwDBTreeList_Impl::HasContext()
+{
+ if(!xDBContext.is())
+ {
+ Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
+ xDBContext = DatabaseContext::create(xContext);
+ xDBContext->addContainerListener( this );
+ }
+ return xDBContext.is();
+}
+
+Reference<XConnection> SwDBTreeList_Impl::GetConnection(const OUString& rSourceName)
+{
+ Reference<XConnection> xRet;
+ for(SwConnectionArr::const_iterator i = aConnections.begin(); i != aConnections.end(); ++i)
+ {
+ if(i->sSourceName == rSourceName)
+ {
+ xRet = i->xConnection;
+ break;
+ }
+ }
+ if(!xRet.is() && xDBContext.is() && pWrtSh)
+ {
+ SwConnectionData* pPtr = new SwConnectionData();
+ pPtr->sSourceName = rSourceName;
+ xRet = pWrtSh->GetNewDBMgr()->RegisterConnection(pPtr->sSourceName);
+ aConnections.push_back(pPtr);
+ }
+ return xRet;
+}
+
+SwDBTreeList::SwDBTreeList(Window *pParent, WinBits nStyle)
+ : SvTreeListBox(pParent, nStyle)
+ , aImageList(SW_RES(ILIST_DB_DLG))
+ , bInitialized(false)
+ , bShowColumns(false)
+ , pImpl(new SwDBTreeList_Impl(NULL))
+{
+ if (IsVisible())
+ InitTreeList();
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSwDBTreeList(Window *pParent, VclBuilder::stringmap &rMap)
+{
+ WinBits nStyle = WB_TABSTOP;
+ OString sBorder = VclBuilder::extractCustomProperty(rMap);
+ if (!sBorder.isEmpty())
+ nStyle |= WB_BORDER;
+ return new SwDBTreeList(pParent, nStyle);
+}
+
+Size SwDBTreeList::GetOptimalSize() const
+{
+ return LogicToPixel(Size(100, 62), MapMode(MAP_APPFONT));
+}
+
+SwDBTreeList::~SwDBTreeList()
+{
+ delete pImpl;
+}
+
+void SwDBTreeList::InitTreeList()
+{
+ if(!pImpl->HasContext() && pImpl->GetWrtShell())
+ return;
+ SetSelectionMode(SINGLE_SELECTION);
+ SetStyle(GetStyle()|WB_HASLINES|WB_CLIPCHILDREN|WB_HASBUTTONS|WB_HASBUTTONSATROOT|WB_HSCROLL);
+ // don't set font, so that the Control's font is being applied!
+ SetSpaceBetweenEntries(0);
+ SetNodeBitmaps( aImageList.GetImage(IMG_COLLAPSE),
+ aImageList.GetImage(IMG_EXPAND ) );
+
+ SetDragDropMode(SV_DRAGDROP_APP_COPY);
+
+ GetModel()->SetCompareHdl(LINK(this, SwDBTreeList, DBCompare));
+
+ Sequence< OUString > aDBNames = pImpl->GetContext()->getElementNames();
+ const OUString* pDBNames = aDBNames.getConstArray();
+ long nCount = aDBNames.getLength();
+
+ Image aImg = aImageList.GetImage(IMG_DB);
+ for(long i = 0; i < nCount; i++)
+ {
+ OUString sDBName(pDBNames[i]);
+ InsertEntry(sDBName, aImg, aImg, NULL, sal_True);
+ }
+ OUString sDBName(sDefDBName.getToken(0, DB_DELIM));
+ OUString sTableName(sDefDBName.getToken(1, DB_DELIM));
+ OUString sColumnName(sDefDBName.getToken(2, DB_DELIM));
+ Select(sDBName, sTableName, sColumnName);
+
+ bInitialized = true;
+}
+
+void SwDBTreeList::AddDataSource(const OUString& rSource)
+{
+ Image aImg = aImageList.GetImage(IMG_DB);
+ SvTreeListEntry* pEntry = InsertEntry(rSource, aImg, aImg, NULL, sal_True);
+ SvTreeListBox::Select(pEntry);
+}
+
+void SwDBTreeList::ShowColumns(sal_Bool bShowCol)
+{
+ if (bShowCol != bShowColumns)
+ {
+ bShowColumns = bShowCol;
+ OUString sTableName;
+ OUString sColumnName;
+ const OUString sDBName(GetDBName(sTableName, sColumnName));
+
+ SetUpdateMode(sal_False);
+
+ SvTreeListEntry* pEntry = First();
+
+ while (pEntry)
+ {
+ pEntry = (SvTreeListEntry*)GetRootLevelParent( pEntry );
+ Collapse(pEntry); // zuklappen
+
+ SvTreeListEntry* pChild;
+ while ((pChild = FirstChild(pEntry)) != 0L)
+ GetModel()->Remove(pChild);
+
+ pEntry = Next(pEntry);
+ }
+
+ if (!sDBName.isEmpty())
+ {
+ Select(sDBName, sTableName, sColumnName); // force RequestingChildren
+ }
+ SetUpdateMode(sal_True);
+ }
+}
+
+void SwDBTreeList::RequestingChildren(SvTreeListEntry* pParent)
+{
+ if (!pParent->HasChildren())
+ {
+ if (GetParent(pParent)) // column names
+ {
+ try
+ {
+
+ OUString sSourceName = GetEntryText(GetParent(pParent));
+ OUString sTableName = GetEntryText(pParent);
+
+ if(!pImpl->GetContext()->hasByName(sSourceName))
+ return;
+ Reference<XConnection> xConnection = pImpl->GetConnection(sSourceName);
+ bool bTable = pParent->GetUserData() == 0;
+ Reference<XColumnsSupplier> xColsSupplier;
+ if(bTable)
+ {
+ Reference<XTablesSupplier> xTSupplier = Reference<XTablesSupplier>(xConnection, UNO_QUERY);
+ if(xTSupplier.is())
+ {
+ Reference<XNameAccess> xTbls = xTSupplier->getTables();
+ OSL_ENSURE(xTbls->hasByName(sTableName), "table not available anymore?");
+ try
+ {
+ Any aTable = xTbls->getByName(sTableName);
+ Reference<XPropertySet> xPropSet;
+ aTable >>= xPropSet;
+ xColsSupplier = Reference<XColumnsSupplier>(xPropSet, UNO_QUERY);
+ }
+ catch (const Exception&)
+ {
+ }
+ }
+ }
+ else
+ {
+ Reference<XQueriesSupplier> xQSupplier = Reference<XQueriesSupplier>(xConnection, UNO_QUERY);
+ if(xQSupplier.is())
+ {
+ Reference<XNameAccess> xQueries = xQSupplier->getQueries();
+ OSL_ENSURE(xQueries->hasByName(sTableName), "table not available anymore?");
+ try
+ {
+ Any aQuery = xQueries->getByName(sTableName);
+ Reference<XPropertySet> xPropSet;
+ aQuery >>= xPropSet;
+ xColsSupplier = Reference<XColumnsSupplier>(xPropSet, UNO_QUERY);
+ }
+ catch (const Exception&)
+ {
+ }
+ }
+ }
+
+ if(xColsSupplier.is())
+ {
+ Reference <XNameAccess> xCols = xColsSupplier->getColumns();
+ Sequence< OUString> aColNames = xCols->getElementNames();
+ const OUString* pColNames = aColNames.getConstArray();
+ long nCount = aColNames.getLength();
+ for (long i = 0; i < nCount; i++)
+ {
+ OUString sName = pColNames[i];
+ InsertEntry(sName, pParent);
+ }
+ }
+ }
+ catch (const Exception&)
+ {
+ }
+ }
+ else // table names
+ {
+ try
+ {
+ OUString sSourceName = GetEntryText(pParent);
+ if(!pImpl->GetContext()->hasByName(sSourceName))
+ return;
+ Reference<XConnection> xConnection = pImpl->GetConnection(sSourceName);
+ if (xConnection.is())
+ {
+ Reference<XTablesSupplier> xTSupplier = Reference<XTablesSupplier>(xConnection, UNO_QUERY);
+ if(xTSupplier.is())
+ {
+ Reference<XNameAccess> xTbls = xTSupplier->getTables();
+ Sequence< OUString> aTblNames = xTbls->getElementNames();
+ OUString sTableName;
+ long nCount = aTblNames.getLength();
+ const OUString* pTblNames = aTblNames.getConstArray();
+ Image aImg = aImageList.GetImage(IMG_DBTABLE);
+ for (long i = 0; i < nCount; i++)
+ {
+ sTableName = pTblNames[i];
+ SvTreeListEntry* pTableEntry = InsertEntry(sTableName, aImg, aImg, pParent, bShowColumns);
+ //to discriminate between queries and tables the user data of table entries is set
+ pTableEntry->SetUserData((void*)0);
+ }
+ }
+
+ Reference<XQueriesSupplier> xQSupplier = Reference<XQueriesSupplier>(xConnection, UNO_QUERY);
+ if(xQSupplier.is())
+ {
+ Reference<XNameAccess> xQueries = xQSupplier->getQueries();
+ Sequence< OUString> aQueryNames = xQueries->getElementNames();
+ OUString sQueryName;
+ long nCount = aQueryNames.getLength();
+ const OUString* pQueryNames = aQueryNames.getConstArray();
+ Image aImg = aImageList.GetImage(IMG_DBQUERY);
+ for (long i = 0; i < nCount; i++)
+ {
+ sQueryName = pQueryNames[i];
+ SvTreeListEntry* pQueryEntry = InsertEntry(sQueryName, aImg, aImg, pParent, bShowColumns);
+ pQueryEntry->SetUserData((void*)1);
+ }
+ }
+ }
+ }
+ catch (const Exception&)
+ {
+ }
+ }
+ }
+}
+
+IMPL_LINK( SwDBTreeList, DBCompare, SvSortData*, pData )
+{
+ SvTreeListEntry* pRight = (SvTreeListEntry*)(pData->pRight );
+
+ if (GetParent(pRight) && GetParent(GetParent(pRight)))
+ return 1; // don't sort column names
+
+ return DefaultCompare(pData); // otherwise call base class
+}
+
+OUString SwDBTreeList::GetDBName(OUString& rTableName, OUString& rColumnName, sal_Bool* pbIsTable)
+{
+ OUString sDBName;
+ SvTreeListEntry* pEntry = FirstSelected();
+
+ if (pEntry && GetParent(pEntry))
+ {
+ if (GetParent(GetParent(pEntry)))
+ {
+ rColumnName = GetEntryText(pEntry);
+ pEntry = GetParent(pEntry); // column name was selected
+ }
+ sDBName = GetEntryText(GetParent(pEntry));
+ if(pbIsTable)
+ {
+ *pbIsTable = pEntry->GetUserData() == 0;
+ }
+ rTableName = GetEntryText(pEntry);
+ }
+ return sDBName;
+}
+
+/*------------------------------------------------------------------------
+ Description: Format: database.table
+------------------------------------------------------------------------*/
+void SwDBTreeList::Select(const OUString& rDBName, const OUString& rTableName, const OUString& rColumnName)
+{
+ SvTreeListEntry* pParent;
+ SvTreeListEntry* pChild;
+ sal_uInt16 nParent = 0;
+ sal_uInt16 nChild = 0;
+
+ while ((pParent = GetEntry(nParent++)) != NULL)
+ {
+ if (rDBName == GetEntryText(pParent))
+ {
+ if (!pParent->HasChildren())
+ RequestingChildren(pParent);
+ while ((pChild = GetEntry(pParent, nChild++)) != NULL)
+ {
+ if (rTableName == GetEntryText(pChild))
+ {
+ pParent = pChild;
+
+ if (bShowColumns && !rColumnName.isEmpty())
+ {
+ nChild = 0;
+
+ if (!pParent->HasChildren())
+ RequestingChildren(pParent);
+
+ while ((pChild = GetEntry(pParent, nChild++)) != NULL)
+ if (rColumnName == GetEntryText(pChild))
+ break;
+ }
+ if (!pChild)
+ pChild = pParent;
+
+ MakeVisible(pChild);
+ SvTreeListBox::Select(pChild);
+ return;
+ }
+ }
+ }
+ }
+}
+
+void SwDBTreeList::StartDrag( sal_Int8 /*nAction*/, const Point& /*rPosPixel*/ )
+{
+ OUString sTableName;
+ OUString sColumnName;
+ OUString sDBName( GetDBName( sTableName, sColumnName ));
+ if (!sDBName.isEmpty())
+ {
+ TransferDataContainer* pContainer = new TransferDataContainer;
+ ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > xRef( pContainer );
+ if( !sColumnName.isEmpty() )
+ {
+ // drag database field
+ svx::OColumnTransferable aColTransfer(
+ sDBName,
+ OUString(),
+ sdb::CommandType::TABLE,
+ sTableName,
+ sColumnName,
+ (CTF_FIELD_DESCRIPTOR|CTF_COLUMN_DESCRIPTOR) );
+ aColTransfer.addDataToContainer( pContainer );
+ }
+
+ sDBName += "." + sTableName;
+ if (!sColumnName.isEmpty())
+ {
+ sDBName += "." + sColumnName;
+ }
+
+ pContainer->CopyString( FORMAT_STRING, sDBName );
+ pContainer->StartDrag( this, DND_ACTION_COPY | DND_ACTION_LINK,
+ Link() );
+ }
+}
+
+sal_Int8 SwDBTreeList::AcceptDrop( const AcceptDropEvent& /*rEvt*/ )
+{
+ return DND_ACTION_NONE;
+}
+
+void SwDBTreeList::SetWrtShell(SwWrtShell& rSh)
+{
+ pImpl->SetWrtShell(rSh);
+ if (IsVisible() && !bInitialized)
+ InitTreeList();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/dbui/dbui.cxx b/sw/source/core/uibase/dbui/dbui.cxx
new file mode 100644
index 000000000000..8247f5c8bfe0
--- /dev/null
+++ b/sw/source/core/uibase/dbui/dbui.cxx
@@ -0,0 +1,87 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "wrtsh.hxx"
+
+#include "dbui.hrc"
+#include "dbui.hxx"
+
+PrintMonitor::PrintMonitor(Window *pParent, PrintMonitorType eType )
+ : ModelessDialog(pParent, "PrintMonitorDialog",
+ "modules/swriter/ui/printmonitordialog.ui")
+{
+ get(m_pCancel, "cancel");
+ get(m_pDocName, "docname");
+ get(m_pPrinter, "printer");
+ get(m_pPrintInfo, "printinfo");
+ switch (eType)
+ {
+ case MONITOR_TYPE_SAVE:
+ SetText(get<FixedText>("alttitle")->GetText());
+ get(m_pPrinting, "saving");
+ break;
+ case MONITOR_TYPE_PRINT:
+ get(m_pPrinting, "printing");
+ break;
+ }
+ m_pPrinting->Show();
+}
+
+// Progress Indicator for Creation of personalized Mail Merge documents:
+CreateMonitor::CreateMonitor( Window *pParent )
+ : ModelessDialog(pParent, "MMCreatingDialog",
+ "modules/swriter/ui/mmcreatingdialog.ui")
+ , m_sCountingPattern()
+ , m_sVariable_Total("%Y")
+ , m_sVariable_Position("%X")
+ , m_nTotalCount(0)
+ , m_nCurrentPosition(0)
+{
+ get(m_pCancelButton, "cancel");
+ get(m_pCounting, "progress");
+ m_sCountingPattern = m_pCounting->GetText();
+ m_pCounting->SetText("...");
+}
+
+void CreateMonitor::UpdateCountingText()
+{
+ OUString sText(m_sCountingPattern);
+ sText = sText.replaceAll( m_sVariable_Total, OUString::number( m_nTotalCount ) );
+ sText = sText.replaceAll( m_sVariable_Position, OUString::number( m_nCurrentPosition ) );
+ m_pCounting->SetText(sText);
+}
+
+void CreateMonitor::SetTotalCount( sal_Int32 nTotal )
+{
+ m_nTotalCount = nTotal;
+ UpdateCountingText();
+}
+
+void CreateMonitor::SetCurrentPosition( sal_Int32 nCurrent )
+{
+ m_nCurrentPosition = nCurrent;
+ UpdateCountingText();
+}
+
+void CreateMonitor::SetCancelHdl( const Link& rLink )
+{
+ m_pCancelButton->SetClickHdl( rLink );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/dbui/maildispatcher.cxx b/sw/source/core/uibase/dbui/maildispatcher.cxx
new file mode 100644
index 000000000000..2208f1a122be
--- /dev/null
+++ b/sw/source/core/uibase/dbui/maildispatcher.cxx
@@ -0,0 +1,275 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "maildispatcher.hxx"
+#include "imaildsplistener.hxx"
+
+#include <algorithm>
+
+using namespace ::com::sun::star;
+
+typedef std::list< ::rtl::Reference<IMailDispatcherListener> > MailDispatcherListenerContainer_t;
+
+namespace /* private */
+{
+ /* Generic event notifier for started,
+ stopped, and idle events which are
+ very similary */
+ class GenericEventNotifier
+ {
+ public:
+ // pointer to virtual function typedef
+ typedef void (IMailDispatcherListener::*GenericNotificationFunc_t)(::rtl::Reference<MailDispatcher>);
+
+ GenericEventNotifier(
+ GenericNotificationFunc_t notification_function,
+ ::rtl::Reference<MailDispatcher> mail_dispatcher) :
+ notification_function_(notification_function),
+ mail_dispatcher_(mail_dispatcher)
+ {}
+
+ void operator() (::rtl::Reference<IMailDispatcherListener> listener) const
+ { (listener.get()->*notification_function_)(mail_dispatcher_); }
+
+ private:
+ GenericNotificationFunc_t notification_function_;
+ ::rtl::Reference<MailDispatcher> mail_dispatcher_;
+ };
+
+ class MailDeliveryNotifier
+ {
+ public:
+ MailDeliveryNotifier(::rtl::Reference<MailDispatcher> xMailDispatcher, uno::Reference<mail::XMailMessage> message) :
+ mail_dispatcher_(xMailDispatcher),
+ message_(message)
+ {}
+
+ void operator() (::rtl::Reference<IMailDispatcherListener> listener) const
+ { listener->mailDelivered(mail_dispatcher_, message_); }
+
+ private:
+ ::rtl::Reference<MailDispatcher> mail_dispatcher_;
+ uno::Reference<mail::XMailMessage> message_;
+ };
+
+ class MailDeliveryErrorNotifier
+ {
+ public:
+ MailDeliveryErrorNotifier(
+ ::rtl::Reference<MailDispatcher> xMailDispatcher,
+ uno::Reference<mail::XMailMessage> message,
+ const OUString& error_message) :
+ mail_dispatcher_(xMailDispatcher),
+ message_(message),
+ error_message_(error_message)
+ {}
+
+ void operator() (::rtl::Reference<IMailDispatcherListener> listener) const
+ { listener->mailDeliveryError(mail_dispatcher_, message_, error_message_); }
+
+ private:
+ ::rtl::Reference<MailDispatcher> mail_dispatcher_;
+ uno::Reference<mail::XMailMessage> message_;
+ OUString error_message_;
+ };
+
+} // namespace private
+
+MailDispatcher::MailDispatcher(uno::Reference<mail::XSmtpService> mailserver) :
+ mailserver_ (mailserver),
+ run_(false),
+ shutdown_requested_(false)
+{
+ wakening_call_.reset();
+ mail_dispatcher_active_.reset();
+
+ if (!create())
+ throw uno::RuntimeException();
+
+ // wait until the mail dispatcher thread is really alive
+ // and has aquired a reference to this instance of the
+ // class
+ mail_dispatcher_active_.wait();
+}
+
+MailDispatcher::~MailDispatcher()
+{
+}
+
+void MailDispatcher::enqueueMailMessage(uno::Reference<mail::XMailMessage> message)
+{
+ ::osl::MutexGuard thread_status_guard(thread_status_mutex_);
+ ::osl::MutexGuard message_container_guard(message_container_mutex_);
+
+ OSL_PRECOND(!shutdown_requested_, "MailDispatcher thread is shuting down already");
+
+ messages_.push_back(message);
+ if (run_)
+ wakening_call_.set();
+}
+
+uno::Reference<mail::XMailMessage> MailDispatcher::dequeueMailMessage()
+{
+ ::osl::MutexGuard guard(message_container_mutex_);
+ uno::Reference<mail::XMailMessage> message;
+ if(!messages_.empty())
+ {
+ message = messages_.front();
+ messages_.pop_front();
+ }
+ return message;
+}
+
+void MailDispatcher::start()
+{
+ OSL_PRECOND(!isStarted(), "MailDispatcher is already started!");
+
+ ::osl::ClearableMutexGuard thread_status_guard(thread_status_mutex_);
+
+ OSL_PRECOND(!shutdown_requested_, "MailDispatcher thread is shuting down already");
+
+ if (!shutdown_requested_)
+ {
+ run_ = true;
+ wakening_call_.set();
+ thread_status_guard.clear();
+
+ MailDispatcherListenerContainer_t listeners_cloned(cloneListener());
+ std::for_each(listeners_cloned.begin(), listeners_cloned.end(), GenericEventNotifier(&IMailDispatcherListener::started, this));
+ }
+}
+
+void MailDispatcher::stop()
+{
+ OSL_PRECOND(isStarted(), "MailDispatcher not started!");
+
+ ::osl::ClearableMutexGuard thread_status_guard(thread_status_mutex_);
+
+ OSL_PRECOND(!shutdown_requested_, "MailDispatcher thread is shuting down already");
+
+ if (!shutdown_requested_)
+ {
+ run_ = false;
+ wakening_call_.reset();
+ thread_status_guard.clear();
+
+ MailDispatcherListenerContainer_t listeners_cloned(cloneListener());
+ std::for_each(listeners_cloned.begin(), listeners_cloned.end(), GenericEventNotifier(&IMailDispatcherListener::stopped, this));
+ }
+}
+
+void MailDispatcher::shutdown()
+{
+ ::osl::MutexGuard thread_status_guard(thread_status_mutex_);
+
+ OSL_PRECOND(!shutdown_requested_, "MailDispatcher thread is shuting down already");
+
+ shutdown_requested_ = true;
+ wakening_call_.set();
+}
+
+bool MailDispatcher::isStarted() const
+{
+ return run_;
+}
+
+void MailDispatcher::addListener(::rtl::Reference<IMailDispatcherListener> listener)
+{
+ OSL_PRECOND(!shutdown_requested_, "MailDispatcher thread is shuting down already");
+
+ ::osl::MutexGuard guard(listener_container_mutex_);
+ listeners_.push_back(listener);
+}
+
+std::list< ::rtl::Reference<IMailDispatcherListener> > MailDispatcher::cloneListener()
+{
+ ::osl::MutexGuard guard(listener_container_mutex_);
+ return listeners_;
+}
+
+void MailDispatcher::sendMailMessageNotifyListener(uno::Reference<mail::XMailMessage> message)
+{
+ try
+ {
+ mailserver_->sendMailMessage(message);
+ MailDispatcherListenerContainer_t listeners_cloned(cloneListener());
+ std::for_each(listeners_cloned.begin(), listeners_cloned.end(), MailDeliveryNotifier(this, message));
+ }
+ catch (const mail::MailException& ex)
+ {
+ MailDispatcherListenerContainer_t listeners_cloned(cloneListener());
+ std::for_each(listeners_cloned.begin(), listeners_cloned.end(), MailDeliveryErrorNotifier(this, message, ex.Message));
+ }
+ catch (const uno::RuntimeException& ex)
+ {
+ MailDispatcherListenerContainer_t listeners_cloned(cloneListener());
+ std::for_each(listeners_cloned.begin(), listeners_cloned.end(), MailDeliveryErrorNotifier(this, message, ex.Message));
+ }
+}
+
+void MailDispatcher::run()
+{
+ // aquire a self reference in order to avoid race
+ // conditions. The last client of this class must
+ // call shutdown before releasing his last reference
+ // to this class in order to shutdown this thread
+ // which will release his (the very last reference
+ // to the class and so force their destruction
+ m_xSelfReference = this;
+
+ // signal that the mail dispatcher thread is now alive
+ mail_dispatcher_active_.set();
+
+ for(;;)
+ {
+ wakening_call_.wait();
+
+ ::osl::ClearableMutexGuard thread_status_guard(thread_status_mutex_);
+ if (shutdown_requested_)
+ break;
+
+ ::osl::ClearableMutexGuard message_container_guard(message_container_mutex_);
+
+ if (messages_.size())
+ {
+ thread_status_guard.clear();
+ uno::Reference<mail::XMailMessage> message = messages_.front();
+ messages_.pop_front();
+ message_container_guard.clear();
+ sendMailMessageNotifyListener(message);
+ }
+ else // idle - put ourself to sleep
+ {
+ wakening_call_.reset();
+ message_container_guard.clear();
+ thread_status_guard.clear();
+ MailDispatcherListenerContainer_t listeners_cloned(cloneListener());
+ std::for_each(listeners_cloned.begin(), listeners_cloned.end(), GenericEventNotifier(&IMailDispatcherListener::idle, this));
+ }
+ } // end for SSH ALI
+}
+
+void MailDispatcher::onTerminated()
+{
+ //keep the reference until the end of onTerminated() because of the call order in the
+ //_threadFunc() from osl/thread.hxx
+ m_xSelfReference = 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/dbui/mailmergechildwindow.cxx b/sw/source/core/uibase/dbui/mailmergechildwindow.cxx
new file mode 100644
index 000000000000..67966f12abf5
--- /dev/null
+++ b/sw/source/core/uibase/dbui/mailmergechildwindow.cxx
@@ -0,0 +1,666 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/dispatch.hxx>
+
+#include <cmdid.h>
+#include <swmodule.hxx>
+#include <view.hxx>
+#include <edtwin.hxx>
+#include <vcl/layout.hxx>
+#include <vcl/svapp.hxx>
+#include <mailmergechildwindow.hxx>
+#include <../../../ui/dbui/mmoutputpage.hxx>
+#include <mmconfigitem.hxx>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/string.hxx>
+#include "com/sun/star/mail/XSmtpService.hpp"
+#include "com/sun/star/mail/MailServiceType.hpp"
+#include <rtl/ref.hxx>
+#include <maildispatcher.hxx>
+#include <imaildsplistener.hxx>
+#include <swunohelper.hxx>
+#include <svtools/svmedit.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/image.hxx>
+#include <mailmergechildwindow.hrc>
+#include <dbui.hrc>
+#include <helpid.h>
+
+using namespace ::com::sun::star;
+
+SFX_IMPL_FLOATINGWINDOW( SwMailMergeChildWindow, FN_MAILMERGE_CHILDWINDOW )
+
+SwMailMergeChildWindow::SwMailMergeChildWindow( Window* _pParent,
+ sal_uInt16 nId,
+ SfxBindings* pBindings,
+ SfxChildWinInfo* pInfo ) :
+ SfxChildWindow( _pParent, nId )
+{
+ pWindow = new SwMailMergeChildWin( pBindings, this, _pParent);
+
+ if (!pInfo->aSize.Width() || !pInfo->aSize.Height())
+ {
+ SwView* pActiveView = ::GetActiveView();
+ if(pActiveView)
+ {
+ const SwEditWin &rEditWin = pActiveView->GetEditWin();
+ pWindow->SetPosPixel(rEditWin.OutputToScreenPixel(Point(0, 0)));
+ }
+ else
+ pWindow->SetPosPixel(_pParent->OutputToScreenPixel(Point(0, 0)));
+ pInfo->aPos = pWindow->GetPosPixel();
+ pInfo->aSize = pWindow->GetSizePixel();
+ }
+
+ ((SwMailMergeChildWin *)pWindow)->Initialize(pInfo);
+ pWindow->Show();
+}
+
+SwMailMergeChildWin::SwMailMergeChildWin( SfxBindings* _pBindings,
+ SfxChildWindow* pChild,
+ Window *pParent) :
+ SfxFloatingWindow(_pBindings, pChild, pParent, SW_RES(DLG_MAILMERGECHILD)),
+ m_aBackTB(this, SW_RES( TB_BACK ))
+{
+ m_aBackTB.SetSelectHdl(LINK(this, SwMailMergeChildWin, BackHdl));
+ sal_uInt16 nIResId = ILIST_TBX;
+ ResId aResId( nIResId, *pSwResMgr );
+ ImageList aIList(aResId);
+ FreeResource();
+
+ m_aBackTB.SetItemImage( 1, aIList.GetImage(FN_SHOW_ROOT) );
+ m_aBackTB.SetButtonType( BUTTON_SYMBOLTEXT );
+ Size aSz = m_aBackTB.CalcWindowSizePixel(1);
+ m_aBackTB.SetPosSizePixel( Point(), aSz );
+ SetOutputSizePixel(aSz);
+ m_aBackTB.Show();
+}
+
+SwMailMergeChildWin::~SwMailMergeChildWin()
+{
+}
+
+IMPL_LINK_NOARG(SwMailMergeChildWin, BackHdl)
+{
+ GetBindings().GetDispatcher()->Execute(FN_MAILMERGE_WIZARD, SFX_CALLMODE_ASYNCHRON);
+ return 0;
+}
+
+void SwMailMergeChildWin::FillInfo(SfxChildWinInfo& rInfo) const
+{
+ SfxFloatingWindow::FillInfo(rInfo);
+ rInfo.aWinState = OString();
+ rInfo.bVisible = sal_False;
+}
+
+struct SwSendMailDialog_Impl
+{
+ friend class SwSendMailDialog;
+ ::osl::Mutex aDescriptorMutex;
+
+ ::std::vector< SwMailDescriptor > aDescriptors;
+ sal_uInt32 nCurrentDescriptor;
+ sal_uInt32 nDocumentCount;
+ ::rtl::Reference< MailDispatcher > xMailDispatcher;
+ ::rtl::Reference< IMailDispatcherListener> xMailListener;
+ uno::Reference< mail::XMailService > xConnectedMailService;
+ uno::Reference< mail::XMailService > xConnectedInMailService;
+ Timer aRemoveTimer;
+
+ SwSendMailDialog_Impl() :
+ nCurrentDescriptor(0),
+ nDocumentCount(0)
+ {
+ aRemoveTimer.SetTimeout(500);
+ }
+
+ ~SwSendMailDialog_Impl()
+ {
+ // Shutdown must be called when the last reference to the
+ // mail dispatcher will be released in order to force a
+ // shutdown of the mail dispatcher thread.
+ // 'join' with the mail dispatcher thread leads to a
+ // deadlock (SolarMutex).
+ if( xMailDispatcher.is() && !xMailDispatcher->isShutdownRequested() )
+ xMailDispatcher->shutdown();
+ }
+ const SwMailDescriptor* GetNextDescriptor();
+};
+
+const SwMailDescriptor* SwSendMailDialog_Impl::GetNextDescriptor()
+{
+ ::osl::MutexGuard aGuard(aDescriptorMutex);
+ if(nCurrentDescriptor < aDescriptors.size())
+ {
+ ++nCurrentDescriptor;
+ return &aDescriptors[nCurrentDescriptor - 1];
+ }
+ return 0;
+}
+
+class SwMailDispatcherListener_Impl : public IMailDispatcherListener
+{
+ SwSendMailDialog* m_pSendMailDialog;
+
+public:
+ SwMailDispatcherListener_Impl(SwSendMailDialog& rParentDlg);
+ ~SwMailDispatcherListener_Impl();
+
+ virtual void started(::rtl::Reference<MailDispatcher> xMailDispatcher);
+ virtual void stopped(::rtl::Reference<MailDispatcher> xMailDispatcher);
+ virtual void idle(::rtl::Reference<MailDispatcher> xMailDispatcher);
+ virtual void mailDelivered(::rtl::Reference<MailDispatcher> xMailDispatcher,
+ uno::Reference< mail::XMailMessage> xMailMessage);
+ virtual void mailDeliveryError(::rtl::Reference<MailDispatcher> xMailDispatcher,
+ uno::Reference< mail::XMailMessage> xMailMessage, const OUString& sErrorMessage);
+
+ static void DeleteAttachments( uno::Reference< mail::XMailMessage >& xMessage );
+};
+
+SwMailDispatcherListener_Impl::SwMailDispatcherListener_Impl(SwSendMailDialog& rParentDlg) :
+ m_pSendMailDialog(&rParentDlg)
+{
+}
+
+SwMailDispatcherListener_Impl::~SwMailDispatcherListener_Impl()
+{
+}
+
+void SwMailDispatcherListener_Impl::started(::rtl::Reference<MailDispatcher> /*xMailDispatcher*/)
+{
+}
+
+void SwMailDispatcherListener_Impl::stopped(
+ ::rtl::Reference<MailDispatcher> /*xMailDispatcher*/)
+{
+}
+
+void SwMailDispatcherListener_Impl::idle(::rtl::Reference<MailDispatcher> /*xMailDispatcher*/)
+{
+ SolarMutexGuard aGuard;
+ m_pSendMailDialog->AllMailsSent();
+}
+
+void SwMailDispatcherListener_Impl::mailDelivered(
+ ::rtl::Reference<MailDispatcher> /*xMailDispatcher*/,
+ uno::Reference< mail::XMailMessage> xMailMessage)
+{
+ SolarMutexGuard aGuard;
+ m_pSendMailDialog->DocumentSent( xMailMessage, true, 0 );
+ DeleteAttachments( xMailMessage );
+}
+
+void SwMailDispatcherListener_Impl::mailDeliveryError(
+ ::rtl::Reference<MailDispatcher> /*xMailDispatcher*/,
+ uno::Reference< mail::XMailMessage> xMailMessage,
+ const OUString& sErrorMessage)
+{
+ SolarMutexGuard aGuard;
+ m_pSendMailDialog->DocumentSent( xMailMessage, false, &sErrorMessage );
+ DeleteAttachments( xMailMessage );
+}
+
+void SwMailDispatcherListener_Impl::DeleteAttachments( uno::Reference< mail::XMailMessage >& xMessage )
+{
+ uno::Sequence< mail::MailAttachment > aAttachments = xMessage->getAttachments();
+
+ for(sal_Int32 nFile = 0; nFile < aAttachments.getLength(); ++nFile)
+ {
+ try
+ {
+ uno::Reference< beans::XPropertySet > xTransferableProperties( aAttachments[nFile].Data, uno::UNO_QUERY_THROW);
+ if( xTransferableProperties.is() )
+ {
+ OUString sURL;
+ xTransferableProperties->getPropertyValue("URL") >>= sURL;
+ if(!sURL.isEmpty())
+ SWUnoHelper::UCB_DeleteFile( sURL );
+ }
+ }
+ catch (const uno::Exception&)
+ {
+ }
+ }
+}
+
+class SwSendWarningBox_Impl : public MessageDialog
+{
+ VclMultiLineEdit *m_pDetailED;
+public:
+ SwSendWarningBox_Impl(Window* pParent, const OUString& rDetails);
+};
+
+SwSendWarningBox_Impl::SwSendWarningBox_Impl(Window* pParent, const OUString& rDetails)
+ : MessageDialog(pParent, "WarnEmailDialog", "modules/swriter/ui/warnemaildialog.ui")
+{
+ get(m_pDetailED, "errors");
+ m_pDetailED->SetMaxTextWidth(80 * m_pDetailED->approximate_char_width());
+ m_pDetailED->set_width_request(80 * m_pDetailED->approximate_char_width());
+ m_pDetailED->set_height_request(8 * m_pDetailED->GetTextHeight());
+ m_pDetailED->SetText(rDetails);
+}
+
+#define ITEMID_TASK 1
+#define ITEMID_STATUS 2
+
+SwSendMailDialog::SwSendMailDialog(Window *pParent, SwMailMergeConfigItem& rConfigItem) :
+ ModelessDialog /*SfxModalDialog*/(pParent, SW_RES(DLG_MM_SENDMAILS)),
+ m_aStatusFL( this, SW_RES( FL_STATUS )),
+ m_aStatusFT( this, SW_RES( FT_STATUS1 )),
+ m_aTransferStatusFL( this, SW_RES( FL_TRANSFERSTATUS )),
+ m_aTransferStatusFT( this, SW_RES( FT_TRANSFERSTATUS )),
+ m_PausedFI(this, SW_RES( FI_PAUSED )),
+ m_aProgressBar( this, SW_RES( PB_PROGRESS )),
+ m_aErrorStatusFT( this, SW_RES( FT_ERRORSTATUS )),
+ m_aDetailsPB( this, SW_RES( PB_DETAILS )),
+ m_aStatusHB( this, WB_BUTTONSTYLE | WB_BOTTOMBORDER ),
+ m_aStatusLB( this, SW_RES( LB_STATUS )),
+ m_aSeparatorFL( this, SW_RES( FL_SEPARATOR )),
+ m_aStopPB( this, SW_RES( PB_STOP )),
+ m_aClosePB( this, SW_RES( PB_CLOSE )),
+ m_sMore(m_aDetailsPB.GetText()),
+ m_sLess(SW_RES(ST_LESS)),
+ m_sContinue(SW_RES( ST_CONTINUE )),
+ m_sStop(m_aStopPB.GetText()),
+ m_sSend(SW_RES(ST_SEND)),
+ m_sTransferStatus(m_aTransferStatusFT.GetText()),
+ m_sErrorStatus( m_aErrorStatusFT.GetText()),
+ m_sSendingTo( SW_RES(ST_SENDINGTO )),
+ m_sCompleted( SW_RES(ST_COMPLETED )),
+ m_sFailed( SW_RES(ST_FAILED )),
+ m_sTerminateQuery( SW_RES( ST_TERMINATEQUERY )),
+ m_bCancel(false),
+ m_bDesctructionEnabled(false),
+ m_aImageList( SW_RES( ILIST ) ),
+ m_pImpl(new SwSendMailDialog_Impl),
+ m_pConfigItem(&rConfigItem),
+ m_nSendCount(0),
+ m_nErrorCount(0)
+{
+ m_nStatusHeight = m_aSeparatorFL.GetPosPixel().Y() - m_aStatusLB.GetPosPixel().Y();
+ OUString sTask(SW_RES(ST_TASK));
+ OUString sStatus(SW_RES(ST_STATUS));
+ m_aStatusLB.SetHelpId(HID_MM_SENDMAILS_STATUSLB);
+
+ FreeResource();
+
+ m_aDetailsPB.SetClickHdl(LINK( this, SwSendMailDialog, DetailsHdl_Impl));
+ m_aStopPB.SetClickHdl(LINK( this, SwSendMailDialog, StopHdl_Impl));
+ m_aClosePB.SetClickHdl(LINK( this, SwSendMailDialog, CloseHdl_Impl));
+
+ Size aLBSize(m_aStatusLB.GetSizePixel());
+ m_aStatusHB.SetSizePixel(aLBSize);
+ Size aHeadSize(m_aStatusHB.CalcWindowSizePixel());
+ aHeadSize.Width() = aLBSize.Width();
+ m_aStatusHB.SetSizePixel(aHeadSize);
+ Point aLBPos(m_aStatusLB.GetPosPixel());
+ m_aStatusHB.SetPosPixel(aLBPos);
+ aLBPos.Y() += aHeadSize.Height();
+ aLBSize.Height() -= aHeadSize.Height();
+ m_aStatusLB.SetPosSizePixel(aLBPos, aLBSize);
+
+ Size aSz(m_aStatusHB.GetOutputSizePixel());
+ long nPos1 = aSz.Width()/3 * 2;
+ long nPos2 = aSz.Width()/3;
+ m_aStatusHB.InsertItem( ITEMID_TASK, sTask,
+ nPos1,
+ HIB_LEFT | HIB_VCENTER );
+ m_aStatusHB.InsertItem( ITEMID_STATUS, sStatus,
+ nPos2,
+ HIB_LEFT | HIB_VCENTER );
+ m_aStatusHB.SetHelpId(HID_MM_ADDRESSLIST_HB );
+ m_aStatusHB.Show();
+
+ m_aStatusLB.SetHelpId(HID_MM_MAILSTATUS_TLB);
+ static long nTabs[] = {3, 0, nPos1, aSz.Width() };
+ m_aStatusLB.SetStyle( m_aStatusLB.GetStyle() | WB_SORT | WB_HSCROLL | WB_CLIPCHILDREN | WB_TABSTOP );
+ m_aStatusLB.SetSelectionMode( SINGLE_SELECTION );
+ m_aStatusLB.SetTabs(&nTabs[0], MAP_PIXEL);
+ m_aStatusLB.SetSpaceBetweenEntries(3);
+
+ DetailsHdl_Impl( &m_aDetailsPB );
+ UpdateTransferStatus();
+}
+
+SwSendMailDialog::~SwSendMailDialog()
+{
+ if(m_pImpl->xMailDispatcher.is())
+ {
+ try
+ {
+ if(m_pImpl->xMailDispatcher->isStarted())
+ m_pImpl->xMailDispatcher->stop();
+ if(m_pImpl->xConnectedMailService.is() && m_pImpl->xConnectedMailService->isConnected())
+ m_pImpl->xConnectedMailService->disconnect();
+ if(m_pImpl->xConnectedInMailService.is() && m_pImpl->xConnectedInMailService->isConnected())
+ m_pImpl->xConnectedInMailService->disconnect();
+
+ uno::Reference<mail::XMailMessage> xMessage =
+ m_pImpl->xMailDispatcher->dequeueMailMessage();
+ while(xMessage.is())
+ {
+ SwMailDispatcherListener_Impl::DeleteAttachments( xMessage );
+ xMessage = m_pImpl->xMailDispatcher->dequeueMailMessage();
+ }
+ }
+ catch (const uno::Exception&)
+ {
+ }
+ }
+ delete m_pImpl;
+}
+
+void SwSendMailDialog::AddDocument( SwMailDescriptor& rDesc )
+{
+ ::osl::MutexGuard aGuard(m_pImpl->aDescriptorMutex);
+ m_pImpl->aDescriptors.push_back(rDesc);
+ // if the dialog is already running then continue sending of documents
+ if(m_pImpl->xMailDispatcher.is())
+ {
+ IterateMails();
+ }
+
+}
+
+void SwSendMailDialog::SetDocumentCount( sal_Int32 nAllDocuments )
+{
+ m_pImpl->nDocumentCount = nAllDocuments;
+ UpdateTransferStatus();
+}
+
+static void lcl_Move(Control& rCtrl, long nYOffset)
+{
+ Point aPos(rCtrl.GetPosPixel());
+ aPos.Y() += nYOffset;
+ rCtrl.SetPosPixel(aPos);
+}
+
+IMPL_LINK_NOARG(SwSendMailDialog, DetailsHdl_Impl)
+{
+ long nMove = 0;
+ if(m_aStatusLB.IsVisible())
+ {
+ m_aStatusLB.Hide();
+ m_aStatusHB.Hide();
+ nMove = - m_nStatusHeight;
+ m_aDetailsPB.SetText(m_sMore);
+ }
+ else
+ {
+ m_aStatusLB.Show();
+ m_aStatusHB.Show();
+ nMove = m_nStatusHeight;
+ m_aDetailsPB.SetText(m_sLess);
+ }
+ lcl_Move(m_aSeparatorFL, nMove);
+ lcl_Move(m_aStopPB, nMove);
+ lcl_Move(m_aClosePB, nMove);
+ Size aDlgSize = GetSizePixel(); aDlgSize.Height() += nMove; SetSizePixel(aDlgSize);
+
+ return 0;
+}
+
+IMPL_LINK( SwSendMailDialog, StopHdl_Impl, PushButton*, pButton )
+{
+ m_bCancel = true;
+ if(m_pImpl->xMailDispatcher.is())
+ {
+ if(m_pImpl->xMailDispatcher->isStarted())
+ {
+ m_pImpl->xMailDispatcher->stop();
+ pButton->SetText(m_sContinue);
+ m_PausedFI.Show();
+ }
+ else
+ {
+ m_pImpl->xMailDispatcher->start();
+ pButton->SetText(m_sStop);
+ m_PausedFI.Show(false);
+ }
+ }
+ return 0;
+}
+
+IMPL_LINK_NOARG(SwSendMailDialog, CloseHdl_Impl)
+{
+ ModelessDialog::Show( false );
+ return 0;
+}
+
+IMPL_STATIC_LINK_NOINSTANCE( SwSendMailDialog, StartSendMails, SwSendMailDialog*, pDialog )
+{
+ pDialog->SendMails();
+ return 0;
+}
+
+IMPL_STATIC_LINK( SwSendMailDialog, RemoveThis, Timer*, pTimer )
+{
+ if( pThis->m_pImpl->xMailDispatcher.is() )
+ {
+ if(pThis->m_pImpl->xMailDispatcher->isStarted())
+ pThis->m_pImpl->xMailDispatcher->stop();
+ if(!pThis->m_pImpl->xMailDispatcher->isShutdownRequested())
+ pThis->m_pImpl->xMailDispatcher->shutdown();
+ }
+
+ if( pThis->m_bDesctructionEnabled &&
+ (!pThis->m_pImpl->xMailDispatcher.is() ||
+ !pThis->m_pImpl->xMailDispatcher->isRunning()))
+ {
+ delete pThis;
+ }
+ else
+ {
+ pTimer->Start();
+ }
+ return 0;
+}
+
+IMPL_STATIC_LINK_NOINSTANCE( SwSendMailDialog, StopSendMails, SwSendMailDialog*, pDialog )
+{
+ if(pDialog->m_pImpl->xMailDispatcher.is() &&
+ pDialog->m_pImpl->xMailDispatcher->isStarted())
+ {
+ pDialog->m_pImpl->xMailDispatcher->stop();
+ pDialog->m_aStopPB.SetText(pDialog->m_sContinue);
+ pDialog->m_PausedFI.Show();
+ }
+ return 0;
+}
+
+void SwSendMailDialog::SendMails()
+{
+ if(!m_pConfigItem)
+ {
+ OSL_FAIL("config item not set");
+ return;
+ }
+ EnterWait();
+ //get a mail server connection
+ uno::Reference< mail::XSmtpService > xSmtpServer =
+ SwMailMergeHelper::ConnectToSmtpServer( *m_pConfigItem,
+ m_pImpl->xConnectedInMailService,
+ aEmptyOUStr, aEmptyOUStr, this );
+ bool bIsLoggedIn = xSmtpServer.is() && xSmtpServer->isConnected();
+ LeaveWait();
+ if(!bIsLoggedIn)
+ {
+ OSL_FAIL("create error message");
+ return;
+ }
+ m_pImpl->xMailDispatcher.set( new MailDispatcher(xSmtpServer));
+ IterateMails();
+ m_pImpl->xMailListener = new SwMailDispatcherListener_Impl(*this);
+ m_pImpl->xMailDispatcher->addListener(m_pImpl->xMailListener);
+ if(!m_bCancel)
+ {
+ m_pImpl->xMailDispatcher->start();
+ }
+}
+
+void SwSendMailDialog::IterateMails()
+{
+ const SwMailDescriptor* pCurrentMailDescriptor = m_pImpl->GetNextDescriptor();
+ while( pCurrentMailDescriptor )
+ {
+ if(!SwMailMergeHelper::CheckMailAddress( pCurrentMailDescriptor->sEMail ))
+ {
+ Image aInsertImg = m_aImageList.GetImage( FN_FORMULA_CANCEL );
+
+ OUString sMessage = m_sSendingTo;
+ OUString sTmp(pCurrentMailDescriptor->sEMail);
+ sTmp += "\t";
+ sTmp += m_sFailed;
+ m_aStatusLB.InsertEntry( sMessage.replaceFirst("%1", sTmp), aInsertImg, aInsertImg);
+ ++m_nSendCount;
+ ++m_nErrorCount;
+ UpdateTransferStatus( );
+ pCurrentMailDescriptor = m_pImpl->GetNextDescriptor();
+ continue;
+ }
+ SwMailMessage* pMessage = new SwMailMessage;
+ uno::Reference< mail::XMailMessage > xMessage = pMessage;
+ if(m_pConfigItem->IsMailReplyTo())
+ pMessage->setReplyToAddress(m_pConfigItem->GetMailReplyTo());
+ pMessage->addRecipient( pCurrentMailDescriptor->sEMail );
+ pMessage->SetSenderName( m_pConfigItem->GetMailDisplayName() );
+ pMessage->SetSenderAddress( m_pConfigItem->GetMailAddress() );
+ if(!pCurrentMailDescriptor->sAttachmentURL.isEmpty())
+ {
+ mail::MailAttachment aAttach;
+ aAttach.Data =
+ new SwMailTransferable(
+ pCurrentMailDescriptor->sAttachmentURL,
+ pCurrentMailDescriptor->sAttachmentName,
+ pCurrentMailDescriptor->sMimeType );
+ aAttach.ReadableName = pCurrentMailDescriptor->sAttachmentName;
+ pMessage->addAttachment( aAttach );
+ }
+ pMessage->setSubject( pCurrentMailDescriptor->sSubject );
+ uno::Reference< datatransfer::XTransferable> xBody =
+ new SwMailTransferable(
+ pCurrentMailDescriptor->sBodyContent,
+ pCurrentMailDescriptor->sBodyMimeType);
+ pMessage->setBody( xBody );
+
+ //CC and BCC are tokenized by ';'
+ if(!pCurrentMailDescriptor->sCC.isEmpty())
+ {
+ OUString sTokens( pCurrentMailDescriptor->sCC );
+ sal_uInt16 nTokens = comphelper::string::getTokenCount(sTokens, ';');
+ sal_Int32 nPos = 0;
+ for( sal_uInt16 nToken = 0; nToken < nTokens; ++nToken)
+ {
+ OUString sTmp = sTokens.getToken( 0, ';', nPos);
+ if( !sTmp.isEmpty() )
+ pMessage->addCcRecipient( sTmp );
+ }
+ }
+ if(!pCurrentMailDescriptor->sBCC.isEmpty())
+ {
+ OUString sTokens( pCurrentMailDescriptor->sBCC );
+ sal_uInt16 nTokens = comphelper::string::getTokenCount(sTokens, ';');
+ sal_Int32 nPos = 0;
+ for( sal_uInt16 nToken = 0; nToken < nTokens; ++nToken)
+ {
+ OUString sTmp = sTokens.getToken( 0, ';', nPos);
+ if( !sTmp.isEmpty() )
+ pMessage->addBccRecipient( sTmp );
+ }
+ }
+ m_pImpl->xMailDispatcher->enqueueMailMessage( xMessage );
+ pCurrentMailDescriptor = m_pImpl->GetNextDescriptor();
+ }
+ UpdateTransferStatus();
+}
+
+void SwSendMailDialog::ShowDialog()
+{
+ Application::PostUserEvent( STATIC_LINK( this, SwSendMailDialog,
+ StartSendMails ), this );
+ ModelessDialog::Show();
+}
+
+void SwSendMailDialog::StateChanged( StateChangedType nStateChange )
+{
+ ModelessDialog::StateChanged( nStateChange );
+ if(STATE_CHANGE_VISIBLE == nStateChange && !IsVisible())
+ {
+ m_pImpl->aRemoveTimer.SetTimeoutHdl( STATIC_LINK( this, SwSendMailDialog,
+ RemoveThis ) );
+ m_pImpl->aRemoveTimer.Start();
+ }
+}
+
+void SwSendMailDialog::DocumentSent( uno::Reference< mail::XMailMessage> xMessage,
+ bool bResult,
+ const OUString* pError )
+{
+ //sending should stop on send errors
+ if(pError &&
+ m_pImpl->xMailDispatcher.is() && m_pImpl->xMailDispatcher->isStarted())
+ {
+ Application::PostUserEvent( STATIC_LINK( this, SwSendMailDialog,
+ StopSendMails ), this );
+ }
+ Image aInsertImg = m_aImageList.GetImage( bResult ? FN_FORMULA_APPLY : FN_FORMULA_CANCEL );
+
+ OUString sMessage = m_sSendingTo;
+ OUString sTmp(xMessage->getRecipients()[0]);
+ sTmp += "\t";
+ sTmp += bResult ? m_sCompleted : m_sFailed;
+ m_aStatusLB.InsertEntry( sMessage.replaceFirst("%1", sTmp), aInsertImg, aInsertImg);
+ ++m_nSendCount;
+ if(!bResult)
+ ++m_nErrorCount;
+
+ UpdateTransferStatus( );
+
+ if (pError)
+ {
+ SwSendWarningBox_Impl* pDlg = new SwSendWarningBox_Impl(0, *pError);
+ pDlg->Execute();
+ delete pDlg;
+ }
+}
+
+void SwSendMailDialog::UpdateTransferStatus()
+{
+ OUString sStatus( m_sTransferStatus );
+ sStatus = sStatus.replaceFirst("%1", OUString::number(m_nSendCount) );
+ sStatus = sStatus.replaceFirst("%2", OUString::number(m_pImpl->aDescriptors.size()));
+ m_aTransferStatusFT.SetText(sStatus);
+
+ sStatus = m_sErrorStatus.replaceFirst("%1", OUString::number(m_nErrorCount) );
+ m_aErrorStatusFT.SetText(sStatus);
+
+ if(m_pImpl->aDescriptors.size())
+ m_aProgressBar.SetValue((sal_uInt16)(m_nSendCount * 100 / m_pImpl->aDescriptors.size()));
+ else
+ m_aProgressBar.SetValue(0);
+}
+
+void SwSendMailDialog::AllMailsSent()
+{
+ m_aStopPB.Enable(false);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/dbui/mailmergechildwindow.hrc b/sw/source/core/uibase/dbui/mailmergechildwindow.hrc
new file mode 100644
index 000000000000..1ba778b63506
--- /dev/null
+++ b/sw/source/core/uibase/dbui/mailmergechildwindow.hrc
@@ -0,0 +1,47 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#define TB_BACK 1
+#define ILIST_TBX 90
+
+#define FL_SEPARATOR 7
+
+#define FL_STATUS 60
+#define FT_STATUS1 61
+#define FL_TRANSFERSTATUS 62
+#define FT_TRANSFERSTATUS 63
+#define PB_PROGRESS 64
+#define FT_ERRORSTATUS 65
+#define PB_DETAILS 66
+#define LB_STATUS 67
+#define FI_PAUSED 68
+#define PB_STOP 69
+#define PB_CLOSE 70
+#define ST_CONTINUE 71
+#define ST_LESS 72
+#define ST_TASK 73
+#define ST_STATUS 74
+#define ILIST 75
+#define ST_SEND 77
+#define ST_SENDINGTO 78
+#define ST_COMPLETED 79
+#define ST_FAILED 80
+#define ST_TERMINATEQUERY 81
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/dbui/mailmergechildwindow.src b/sw/source/core/uibase/dbui/mailmergechildwindow.src
new file mode 100644
index 000000000000..9e0961803af8
--- /dev/null
+++ b/sw/source/core/uibase/dbui/mailmergechildwindow.src
@@ -0,0 +1,210 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#include "mailmergechildwindow.hrc"
+#include "dbui.hrc"
+#include "helpid.h"
+#include <cmdid.h>
+
+#define WIDTH 100
+#define HEIGHT 16
+
+#define WORKAROUND \
+ Text [ en-US ] = "Return to Mail Merge Wizard" ; \
+
+
+FloatingWindow DLG_MAILMERGECHILD\
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( WIDTH , HEIGHT ) ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ Sizeable = FALSE ;
+ Zoomable = TRUE ;
+ HelpID = HID_MAILMERGECHILD ;
+ Hide = TRUE ;
+ Text [ en-US ] = "Mail Merge Wizard";\
+ ToolBox TB_BACK\
+ {
+ MenuStrings = TRUE ;
+ SVLook = TRUE ;
+ ItemList =
+ {
+ ToolBoxItem\
+ {
+ Identifier = 1;
+ HelpID = HID_RETURN_TO_MAILMERGE ;
+ Left = TRUE;
+ WORKAROUND
+ };
+ };
+ };
+ #define IMGLIST1_IDS\
+ IdList = \
+ { \
+ FN_SHOW_ROOT; \
+ }; \
+ IdCount = 1
+
+ ImageList ILIST_TBX
+ {
+ Prefix = "sc";
+ MaskColor = IMAGE_MASK_COLOR;
+ IMGLIST1_IDS;
+ };
+};
+
+//FloatingWindow DLG_MM_SENDMAILS
+ModelessDialog DLG_MM_SENDMAILS
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ HelpID = HID_MM_SENDMAILS;
+ Size = MAP_APPFONT ( 250 , 221 ) ;
+ Moveable = TRUE ;
+ Closeable = TRUE;
+
+ Text [ en-US ] = "Sending E-mail messages";
+
+ FixedLine FL_STATUS
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 238 , 8 ) ;
+ Text[ en-US ] = "Connection status";
+ };
+ FixedText FT_STATUS1
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 226 , 8 ) ;
+ Text[ en-US ] = "The connection to the outgoing mail server has been established";
+ };
+ String ST_SEND
+ {
+ Text[ en-US ] = "Sending e-mails...";
+ };
+ FixedLine FL_TRANSFERSTATUS
+ {
+ Pos = MAP_APPFONT ( 6 , 28 ) ;
+ Size = MAP_APPFONT ( 238 , 8 ) ;
+ Text[ en-US ] = "Transfer status";
+ };
+ FixedText FT_TRANSFERSTATUS
+ {
+ Pos = MAP_APPFONT ( 12, 39 ) ;
+ Size = MAP_APPFONT ( 110 , 8 ) ;
+ Text[ en-US ] = "%1 of %2 e-mails sent";
+ };
+ FixedText FI_PAUSED
+ {
+ Pos = MAP_APPFONT ( 125, 39 ) ;
+ Size = MAP_APPFONT ( 100 , 8 ) ;
+ Hide = TRUE;
+ Text[ en-US ] = "Sending paused";
+ };
+ Window PB_PROGRESS
+ {
+ Pos = MAP_APPFONT ( 12 , 50 ) ;
+ Size = MAP_APPFONT ( 226 , 14 ) ;
+ Border = TRUE;
+ };
+ FixedText FT_ERRORSTATUS
+ {
+ Pos = MAP_APPFONT ( 12 , 67 ) ;
+ Size = MAP_APPFONT ( 226 , 8 ) ;
+ Text[ en-US ] = "E-mails not sent: %1";
+ };
+ PushButton PB_DETAILS
+ {
+ Pos = MAP_APPFONT ( 188 , 81 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text[ en-US ] = "More >>";
+ };
+ String ST_LESS
+ {
+ Text[ en-US ] = "<< Less";
+ };
+
+ Control LB_STATUS
+ {
+ Pos = MAP_APPFONT ( 12 , 101 ) ;
+ Size = MAP_APPFONT ( 226 , 80 ) ;
+ Border = TRUE;
+ };
+ FixedLine FL_SEPARATOR
+ {
+ Pos = MAP_APPFONT ( 0 , 187 ) ;
+ Size = MAP_APPFONT ( 250 , 8 ) ;
+ };
+ PushButton PB_STOP
+ {
+ Pos = MAP_APPFONT ( 141 , 201 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text[ en-US ] = "~Stop";
+ };
+ PushButton PB_CLOSE
+ {
+ Pos = MAP_APPFONT ( 194 , 201 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text[ en-US ] = "C~lose";
+ };
+ String ST_CONTINUE
+ {
+ Text[ en-US ] = "~Continue";
+ };
+ #define IMGLIST2_IDS\
+ IdList = \
+ { \
+ FN_FORMULA_CANCEL ;\
+ FN_FORMULA_APPLY ;\
+ }; \
+ IdCount = 2
+
+ ImageList ILIST
+ {
+ Prefix = "sc";
+ MaskColor = IMAGE_MASK_COLOR;
+ IMGLIST2_IDS;
+ };
+ String ST_TASK
+ {
+ Text[ en-US ] = "Task";
+ };
+ String ST_STATUS
+ {
+ Text[ en-US ] = "Status";
+ };
+ String ST_SENDINGTO
+ {
+ Text[ en-US ] = "Sending to: %1";
+ };
+ String ST_COMPLETED
+ {
+ Text[ en-US ] = "Successfully sent";
+ };
+ String ST_FAILED
+ {
+ Text[ en-US ] = "Sending failed";
+ };
+ String ST_TERMINATEQUERY
+ {
+ Text[ en-US ] = "There are still e-mail messages in your %PRODUCTNAME Outbox.\nWould you like to exit anyway?";
+ };
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/dbui/mailmergehelper.cxx b/sw/source/core/uibase/dbui/mailmergehelper.cxx
new file mode 100644
index 000000000000..26e60f2537f4
--- /dev/null
+++ b/sw/source/core/uibase/dbui/mailmergehelper.cxx
@@ -0,0 +1,906 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <swtypes.hxx>
+#include <mailmergehelper.hxx>
+#include <svtools/stdctrl.hxx>
+#include <mmconfigitem.hxx>
+#include <docsh.hxx>
+#include <sfx2/filedlghelper.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/fcontnr.hxx>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdb/XColumn.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
+#include <com/sun/star/ui/dialogs/XFilePicker.hpp>
+#include "com/sun/star/mail/MailServiceProvider.hpp"
+#include "com/sun/star/mail/XSmtpService.hpp"
+#include <comphelper/processfactory.hxx>
+#include <comphelper/string.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/settings.hxx>
+
+#include <sfx2/passwd.hxx>
+
+#include <dbui.hrc>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+
+namespace SwMailMergeHelper
+{
+
+OUString CallSaveAsDialog(OUString& rFilter)
+{
+ ::sfx2::FileDialogHelper aDialog( ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION,
+ 0,
+ OUString::createFromAscii(SwDocShell::Factory().GetShortName()) );
+
+ if (aDialog.Execute()!=ERRCODE_NONE)
+ {
+ return OUString();
+ }
+
+ rFilter = aDialog.GetRealFilter();
+ uno::Reference < ui::dialogs::XFilePicker > xFP = aDialog.GetFilePicker();
+ return xFP->getFiles().getConstArray()[0];
+}
+
+/*
+ simple address check: check for '@'
+ for at least one '.' after the '@'
+ and for at least to characters before and after the dot
+*/
+bool CheckMailAddress( const OUString& rMailAddress )
+{
+ OUString sAddress(rMailAddress);
+ if (!(comphelper::string::getTokenCount(sAddress, '@') == 2))
+ return false;
+ sAddress = sAddress.getToken(1, '@');
+ if (comphelper::string::getTokenCount(sAddress, '.') < 2)
+ return false;
+ if(sAddress.getToken( 0, '.').getLength() < 2 || sAddress.getToken( 1, '.').getLength() < 2)
+ return false;
+ return true;
+}
+
+uno::Reference< mail::XSmtpService > ConnectToSmtpServer(
+ SwMailMergeConfigItem& rConfigItem,
+ uno::Reference< mail::XMailService >& rxInMailService,
+ const OUString& rInMailServerPassword,
+ const OUString& rOutMailServerPassword,
+ Window* pDialogParentWindow )
+{
+ uno::Reference< mail::XSmtpService > xSmtpServer;
+ uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
+ try
+ {
+ uno::Reference< mail::XMailServiceProvider > xMailServiceProvider(
+ mail::MailServiceProvider::create( xContext ) );
+ xSmtpServer = uno::Reference< mail::XSmtpService > (
+ xMailServiceProvider->create(
+ mail::MailServiceType_SMTP
+ ), uno::UNO_QUERY);
+
+ uno::Reference< mail::XConnectionListener> xConnectionListener(new SwConnectionListener());
+
+ if(rConfigItem.IsAuthentication() && rConfigItem.IsSMTPAfterPOP())
+ {
+ uno::Reference< mail::XMailService > xInMailService =
+ xMailServiceProvider->create(
+ rConfigItem.IsInServerPOP() ?
+ mail::MailServiceType_POP3 : mail::MailServiceType_IMAP);
+ //authenticate at the POP or IMAP server first
+ OUString sPasswd = rConfigItem.GetInServerPassword();
+ if(!rInMailServerPassword.isEmpty())
+ sPasswd = rInMailServerPassword;
+ uno::Reference<mail::XAuthenticator> xAuthenticator =
+ new SwAuthenticator(
+ rConfigItem.GetInServerUserName(),
+ sPasswd,
+ pDialogParentWindow);
+
+ xInMailService->addConnectionListener(xConnectionListener);
+ //check connection
+ uno::Reference< uno::XCurrentContext> xConnectionContext =
+ new SwConnectionContext(
+ rConfigItem.GetInServerName(),
+ rConfigItem.GetInServerPort(),
+ OUString("Insecure"));
+ xInMailService->connect(xConnectionContext, xAuthenticator);
+ rxInMailService = xInMailService;
+ }
+ uno::Reference< mail::XAuthenticator> xAuthenticator;
+ if(rConfigItem.IsAuthentication() &&
+ !rConfigItem.IsSMTPAfterPOP() &&
+ !rConfigItem.GetMailUserName().isEmpty())
+ {
+ OUString sPasswd = rConfigItem.GetMailPassword();
+ if(!rOutMailServerPassword.isEmpty())
+ sPasswd = rOutMailServerPassword;
+ xAuthenticator =
+ new SwAuthenticator(rConfigItem.GetMailUserName(),
+ sPasswd,
+ pDialogParentWindow);
+ }
+ else
+ xAuthenticator = new SwAuthenticator();
+ //just to check if the server exists
+ xSmtpServer->getSupportedConnectionTypes();
+ //check connection
+
+ uno::Reference< uno::XCurrentContext> xConnectionContext =
+ new SwConnectionContext(
+ rConfigItem.GetMailServer(),
+ rConfigItem.GetMailPort(),
+ rConfigItem.IsSecureConnection() ? OUString("Ssl") : OUString("Insecure") );
+ xSmtpServer->connect(xConnectionContext, xAuthenticator);
+ rxInMailService = uno::Reference< mail::XMailService >( xSmtpServer, uno::UNO_QUERY );
+ }
+ catch (const uno::Exception&)
+ {
+ OSL_FAIL("exception caught");
+ }
+ return xSmtpServer;
+}
+
+} //namespace
+
+SwBoldFixedInfo::SwBoldFixedInfo(Window* pParent, const ResId& rResId) :
+ FixedInfo(pParent, rResId)
+{
+ Font aFont = GetFont();
+ aFont.SetWeight( WEIGHT_BOLD );
+ SetFont( aFont );
+}
+
+SwBoldFixedInfo::~SwBoldFixedInfo()
+{
+}
+
+struct SwAddressPreview_Impl
+{
+ ::std::vector< OUString > aAddresses;
+ sal_uInt16 nRows;
+ sal_uInt16 nColumns;
+ sal_uInt16 nSelectedAddress;
+ bool bEnableScrollBar;
+
+ SwAddressPreview_Impl() :
+ nRows(1),
+ nColumns(1),
+ nSelectedAddress(0),
+ bEnableScrollBar(false)
+ {
+ }
+};
+
+SwAddressPreview::SwAddressPreview(Window* pParent, const ResId& rResId)
+ : Window( pParent, rResId )
+ , aVScrollBar(this, WB_VSCROLL)
+ , pImpl(new SwAddressPreview_Impl())
+{
+ aVScrollBar.SetScrollHdl(LINK(this, SwAddressPreview, ScrollHdl));
+ positionScrollBar();
+ Show();
+}
+
+SwAddressPreview::SwAddressPreview(Window* pParent, WinBits nStyle)
+ : Window( pParent, nStyle )
+ , aVScrollBar(this, WB_VSCROLL)
+ , pImpl(new SwAddressPreview_Impl())
+{
+ aVScrollBar.SetScrollHdl(LINK(this, SwAddressPreview, ScrollHdl));
+ positionScrollBar();
+ Show();
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSwAddressPreview(Window *pParent, VclBuilder::stringmap &rMap)
+{
+ WinBits nWinStyle = WB_DIALOGCONTROL;
+ OString sBorder = VclBuilder::extractCustomProperty(rMap);
+ if (!sBorder.isEmpty())
+ nWinStyle |= WB_BORDER;
+ return new SwAddressPreview(pParent, nWinStyle);
+}
+
+void SwAddressPreview::positionScrollBar()
+{
+ Size aSize(GetOutputSizePixel());
+ Size aScrollSize(aVScrollBar.get_preferred_size().Width(), aSize.Height());
+ aVScrollBar.SetSizePixel(aScrollSize);
+ Point aSrollPos(aSize.Width() - aScrollSize.Width(), 0);
+ aVScrollBar.SetPosPixel(aSrollPos);
+}
+
+void SwAddressPreview::Resize()
+{
+ Window::Resize();
+ positionScrollBar();
+}
+
+IMPL_LINK_NOARG(SwAddressPreview, ScrollHdl)
+{
+ Invalidate();
+ return 0;
+}
+
+void SwAddressPreview::AddAddress(const OUString& rAddress)
+{
+ pImpl->aAddresses.push_back(rAddress);
+ UpdateScrollBar();
+}
+
+void SwAddressPreview::SetAddress(const OUString& rAddress)
+{
+ pImpl->aAddresses.clear();
+ pImpl->aAddresses.push_back(rAddress);
+ aVScrollBar.Show(false);
+ Invalidate();
+}
+
+sal_uInt16 SwAddressPreview::GetSelectedAddress()const
+{
+ OSL_ENSURE(pImpl->nSelectedAddress < pImpl->aAddresses.size(), "selection invalid");
+ return pImpl->nSelectedAddress;
+}
+
+void SwAddressPreview::SelectAddress(sal_uInt16 nSelect)
+{
+ OSL_ENSURE(pImpl->nSelectedAddress < pImpl->aAddresses.size(), "selection invalid");
+ pImpl->nSelectedAddress = nSelect;
+ // now make it visible..
+ sal_uInt16 nSelectRow = nSelect / pImpl->nColumns;
+ sal_uInt16 nStartRow = (sal_uInt16)aVScrollBar.GetThumbPos();
+ if( (nSelectRow < nStartRow) || (nSelectRow >= (nStartRow + pImpl->nRows) ))
+ aVScrollBar.SetThumbPos( nSelectRow );
+}
+
+void SwAddressPreview::Clear()
+{
+ pImpl->aAddresses.clear();
+ pImpl->nSelectedAddress = 0;
+ UpdateScrollBar();
+}
+
+void SwAddressPreview::ReplaceSelectedAddress(const OUString& rNew)
+{
+ pImpl->aAddresses[pImpl->nSelectedAddress] = rNew;
+ Invalidate();
+}
+
+void SwAddressPreview::RemoveSelectedAddress()
+{
+ pImpl->aAddresses.erase(pImpl->aAddresses.begin() + pImpl->nSelectedAddress);
+ if(pImpl->nSelectedAddress)
+ --pImpl->nSelectedAddress;
+ UpdateScrollBar();
+ Invalidate();
+}
+
+void SwAddressPreview::SetLayout(sal_uInt16 nRows, sal_uInt16 nColumns)
+{
+ pImpl->nRows = nRows;
+ pImpl->nColumns = nColumns;
+ UpdateScrollBar();
+}
+
+void SwAddressPreview::EnableScrollBar(bool bEnable)
+{
+ pImpl->bEnableScrollBar = bEnable;
+}
+
+void SwAddressPreview::UpdateScrollBar()
+{
+ if(pImpl->nColumns)
+ {
+ aVScrollBar.SetVisibleSize(pImpl->nRows);
+ sal_uInt16 nResultingRows = (sal_uInt16)(pImpl->aAddresses.size() + pImpl->nColumns - 1) / pImpl->nColumns;
+ ++nResultingRows;
+ aVScrollBar.Show(pImpl->bEnableScrollBar && nResultingRows > pImpl->nRows);
+ aVScrollBar.SetRange(Range(0, nResultingRows));
+ if(aVScrollBar.GetThumbPos() > nResultingRows)
+ aVScrollBar.SetThumbPos(nResultingRows);
+ }
+}
+
+void SwAddressPreview::Paint(const Rectangle&)
+{
+ const StyleSettings& rSettings = GetSettings().GetStyleSettings();
+ SetFillColor(rSettings.GetWindowColor());
+ SetLineColor( Color(COL_TRANSPARENT) );
+ DrawRect( Rectangle(Point(0, 0), GetOutputSizePixel()) );
+ Color aPaintColor(IsEnabled() ? rSettings.GetWindowTextColor() : rSettings.GetDisableColor());
+ SetLineColor(aPaintColor);
+ Font aFont(GetFont());
+ aFont.SetColor(aPaintColor);
+ SetFont(aFont);
+
+ Size aSize = GetOutputSizePixel();
+ sal_uInt16 nStartRow = 0;
+ if(aVScrollBar.IsVisible())
+ {
+ aSize.Width() -= aVScrollBar.GetSizePixel().Width();
+ nStartRow = (sal_uInt16)aVScrollBar.GetThumbPos();
+ }
+ Size aPartSize( aSize.Width()/pImpl->nColumns, aSize.Height()/pImpl->nRows );
+ aPartSize.Width() -= 2;
+ aPartSize.Height() -= 2;
+
+ sal_uInt16 nAddress = nStartRow * pImpl->nColumns;
+ const sal_uInt16 nNumAddresses = static_cast< sal_uInt16 >(pImpl->aAddresses.size());
+ for(sal_uInt16 nRow = 0; nRow < pImpl->nRows ; ++nRow)
+ {
+ for(sal_uInt16 nCol = 0; nCol < pImpl->nColumns; ++nCol)
+ {
+ if(nAddress >= nNumAddresses)
+ break;
+ Point aPos(nCol * aPartSize.Width(), (nRow) * aPartSize.Height());
+ aPos.Move(1,1);
+ bool bIsSelected = nAddress == pImpl->nSelectedAddress;
+ if((pImpl->nColumns * pImpl->nRows) == 1)
+ bIsSelected = false;
+ OUString adr(pImpl->aAddresses[nAddress]);
+ DrawText_Impl(adr,aPos,aPartSize,bIsSelected);
+ ++nAddress;
+ }
+ }
+ SetClipRegion();
+}
+
+void SwAddressPreview::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ Window::MouseButtonDown(rMEvt);
+ if(rMEvt.IsLeft() && ( pImpl->nRows || pImpl->nColumns))
+ {
+ //determine the selected address
+ const Point& rMousePos = rMEvt.GetPosPixel();
+ Size aSize(GetOutputSizePixel());
+ Size aPartSize( aSize.Width()/pImpl->nColumns, aSize.Height()/pImpl->nRows );
+ sal_uInt32 nRow = rMousePos.Y() / aPartSize.Height() ;
+ if(aVScrollBar.IsVisible())
+ {
+ nRow += (sal_uInt16)aVScrollBar.GetThumbPos();
+ }
+ sal_uInt32 nCol = rMousePos.X() / aPartSize.Width();
+ sal_uInt32 nSelect = nRow * pImpl->nColumns + nCol;
+
+ if( nSelect < pImpl->aAddresses.size() &&
+ pImpl->nSelectedAddress != (sal_uInt16)nSelect)
+ {
+ pImpl->nSelectedAddress = (sal_uInt16)nSelect;
+ m_aSelectHdl.Call(this);
+ }
+ Invalidate();
+ }
+}
+
+void SwAddressPreview::KeyInput( const KeyEvent& rKEvt )
+{
+ sal_uInt16 nKey = rKEvt.GetKeyCode().GetCode();
+ if(pImpl->nRows || pImpl->nColumns)
+ {
+ sal_uInt32 nSelectedRow = (pImpl->nSelectedAddress + 1)/ pImpl->nColumns;
+ sal_uInt32 nSelectedColumn = pImpl->nSelectedAddress % nSelectedRow;
+ switch(nKey)
+ {
+ case KEY_UP:
+ if(nSelectedRow)
+ --nSelectedRow;
+ break;
+ case KEY_DOWN:
+ if(pImpl->aAddresses.size() > sal_uInt32(pImpl->nSelectedAddress + pImpl->nColumns))
+ ++nSelectedRow;
+ break;
+ case KEY_LEFT:
+ if(nSelectedColumn)
+ --nSelectedColumn;
+ break;
+ case KEY_RIGHT:
+ if(nSelectedColumn < sal_uInt32(pImpl->nColumns - 1) &&
+ pImpl->aAddresses.size() - 1 > pImpl->nSelectedAddress )
+ ++nSelectedColumn;
+ break;
+ }
+ sal_uInt32 nSelect = nSelectedRow * pImpl->nColumns + nSelectedColumn;
+ if( nSelect < pImpl->aAddresses.size() &&
+ pImpl->nSelectedAddress != (sal_uInt16)nSelect)
+ {
+ pImpl->nSelectedAddress = (sal_uInt16)nSelect;
+ m_aSelectHdl.Call(this);
+ Invalidate();
+ }
+ }
+ else
+ Window::KeyInput(rKEvt);
+}
+
+void SwAddressPreview::StateChanged( StateChangedType nStateChange )
+{
+ if(nStateChange == STATE_CHANGE_ENABLE)
+ Invalidate();
+ Window::StateChanged(nStateChange);
+}
+
+void SwAddressPreview::DrawText_Impl(
+ const OUString& rAddress, const Point& rTopLeft, const Size& rSize, bool bIsSelected)
+{
+ SetClipRegion( Region( Rectangle(rTopLeft, rSize)) );
+ if(bIsSelected)
+ {
+ //selection rectangle
+ SetFillColor(Color(COL_TRANSPARENT));
+ DrawRect(Rectangle(rTopLeft, rSize));
+ }
+ sal_Int32 nHeight = GetTextHeight();
+ OUString sAddress(rAddress);
+ sal_uInt16 nTokens = comphelper::string::getTokenCount(sAddress, '\n');
+ Point aStart = rTopLeft;
+ //put it away from the border
+ aStart.Move( 2, 2);
+ for(sal_uInt16 nToken = 0; nToken < nTokens; nToken++)
+ {
+ DrawText( aStart, sAddress.getToken(nToken, '\n') );
+ aStart.Y() += nHeight;
+ }
+}
+
+OUString SwAddressPreview::FillData(
+ const OUString& rAddress,
+ SwMailMergeConfigItem& rConfigItem,
+ const Sequence< OUString>* pAssignments)
+{
+ //find the column names in the address string (with name assignment!) and
+ //exchange the placeholder (like <Firstname>) with the database content
+ //unassigned columns are expanded to <not assigned>
+ Reference< XColumnsSupplier > xColsSupp( rConfigItem.GetResultSet(), UNO_QUERY);
+ Reference <XNameAccess> xColAccess = xColsSupp.is() ? xColsSupp->getColumns() : 0;
+ Sequence< OUString> aAssignment = pAssignments ?
+ *pAssignments :
+ rConfigItem.GetColumnAssignment(
+ rConfigItem.GetCurrentDBData() );
+ const OUString* pAssignment = aAssignment.getConstArray();
+ const ResStringArray& rDefHeaders = rConfigItem.GetDefaultAddressHeaders();
+ OUString sAddress(rAddress);
+ OUString sNotAssigned = "<" + OUString(SW_RES(STR_NOTASSIGNED)) + ">";
+
+ sal_Bool bIncludeCountry = rConfigItem.IsIncludeCountry();
+ const OUString rExcludeCountry = rConfigItem.GetExcludeCountry();
+ bool bSpecialReplacementForCountry = (!bIncludeCountry || !rExcludeCountry.isEmpty());
+ OUString sCountryColumn;
+ if( bSpecialReplacementForCountry )
+ {
+ sCountryColumn = rDefHeaders.GetString(MM_PART_COUNTRY);
+ Sequence< OUString> aSpecialAssignment =
+ rConfigItem.GetColumnAssignment( rConfigItem.GetCurrentDBData() );
+ if(aSpecialAssignment.getLength() > MM_PART_COUNTRY && aSpecialAssignment[MM_PART_COUNTRY].getLength())
+ sCountryColumn = aSpecialAssignment[MM_PART_COUNTRY];
+ }
+
+ SwAddressIterator aIter(sAddress);
+ sAddress = "";
+ while(aIter.HasMore())
+ {
+ SwMergeAddressItem aItem = aIter.Next();
+ if(aItem.bIsColumn)
+ {
+ //get the default column name
+
+ //find the appropriate assignment
+ OUString sConvertedColumn = aItem.sText;
+ for(sal_uInt16 nColumn = 0;
+ nColumn < rDefHeaders.Count() && nColumn < aAssignment.getLength();
+ ++nColumn)
+ {
+ if (rDefHeaders.GetString(nColumn).equals(aItem.sText) &&
+ !pAssignment[nColumn].isEmpty())
+ {
+ sConvertedColumn = pAssignment[nColumn];
+ break;
+ }
+ }
+ if(!sConvertedColumn.isEmpty() &&
+ xColAccess.is() &&
+ xColAccess->hasByName(sConvertedColumn))
+ {
+ //get the content and exchange it in the address string
+ Any aCol = xColAccess->getByName(sConvertedColumn);
+ Reference< XColumn > xColumn;
+ aCol >>= xColumn;
+ if(xColumn.is())
+ {
+ try
+ {
+ OUString sReplace = xColumn->getString();
+
+ if( bSpecialReplacementForCountry && sCountryColumn == sConvertedColumn )
+ {
+ if( !rExcludeCountry.isEmpty() && sReplace != rExcludeCountry )
+ aItem.sText = sReplace;
+ else
+ aItem.sText = "";
+ }
+ else
+ {
+ aItem.sText = sReplace;
+ }
+ }
+ catch (const sdbc::SQLException&)
+ {
+ OSL_FAIL("SQLException caught");
+ }
+ }
+ }
+ else
+ {
+ aItem.sText = sNotAssigned;
+ }
+
+ }
+ sAddress += aItem.sText;
+ }
+ return sAddress;
+}
+
+SwMergeAddressItem SwAddressIterator::Next()
+{
+ //currently the string may either start with a '<' then it's a column
+ //otherwise it's simple text maybe containing a return
+ SwMergeAddressItem aRet;
+ if(!sAddress.isEmpty())
+ {
+ if(sAddress[0] == '<')
+ {
+ aRet.bIsColumn = true;
+ sal_Int32 nClose = sAddress.indexOf('>');
+ OSL_ENSURE(nClose != -1, "closing '>' not found");
+ if( nClose != -1 )
+ {
+ aRet.sText = sAddress.copy(1, nClose - 1);
+ sAddress = sAddress.copy(nClose + 1);
+ }
+ else
+ {
+ aRet.sText = sAddress.copy(1, 1);
+ sAddress = sAddress.copy(1);
+ }
+ }
+ else
+ {
+ sal_Int32 nOpen = sAddress.indexOf('<');
+ sal_Int32 nReturn = sAddress.indexOf('\n');
+ if(nReturn == 0)
+ {
+ aRet.bIsReturn = true;
+ aRet.sText = "\n";
+ sAddress = sAddress.copy(1);
+ }
+ else if(-1 == nOpen && -1 == nReturn)
+ {
+ aRet.sText = sAddress;
+ sAddress = "";
+ }
+ else
+ {
+ if (nOpen == -1)
+ nOpen = sAddress.getLength();
+ if (nReturn == -1)
+ nReturn = sAddress.getLength();
+ sal_Int32 nTarget = ::std::min(nOpen, nReturn);
+ aRet.sText = sAddress.copy(0, nTarget);
+ sAddress = sAddress.copy(nTarget);
+ }
+ }
+ }
+ return aRet;
+
+}
+
+SwAuthenticator::~SwAuthenticator()
+{
+}
+
+OUString SwAuthenticator::getUserName( ) throw (RuntimeException, std::exception)
+{
+ return m_aUserName;
+}
+
+OUString SwAuthenticator::getPassword( ) throw (RuntimeException, std::exception)
+{
+ if(!m_aUserName.isEmpty() && m_aPassword.isEmpty() && m_pParentWindow)
+ {
+ SfxPasswordDialog* pPasswdDlg =
+ new SfxPasswordDialog( m_pParentWindow );
+ pPasswdDlg->SetMinLen( 0 );
+ if(RET_OK == pPasswdDlg->Execute())
+ m_aPassword = pPasswdDlg->GetPassword();
+ }
+ return m_aPassword;
+}
+
+SwConnectionContext::SwConnectionContext(
+ const OUString& rMailServer, sal_Int16 nPort,
+ const OUString& rConnectionType) :
+ m_sMailServer(rMailServer),
+ m_nPort(nPort),
+ m_sConnectionType(rConnectionType)
+{
+}
+
+SwConnectionContext::~SwConnectionContext()
+{
+}
+
+uno::Any SwConnectionContext::getValueByName( const OUString& rName )
+ throw (uno::RuntimeException, std::exception)
+{
+ uno::Any aRet;
+ if( rName.equalsAscii( "ServerName" ))
+ aRet <<= m_sMailServer;
+ else if( rName.equalsAscii( "Port" ))
+ aRet <<= (sal_Int32) m_nPort;
+ else if( rName.equalsAscii( "ConnectionType" ))
+ aRet <<= m_sConnectionType;
+ return aRet;
+}
+
+SwConnectionListener::~SwConnectionListener()
+{
+}
+
+void SwConnectionListener::connected(const lang::EventObject& /*aEvent*/)
+ throw (uno::RuntimeException, std::exception)
+{
+}
+
+void SwConnectionListener::disconnected(const lang::EventObject& /*aEvent*/)
+ throw (uno::RuntimeException, std::exception)
+{
+}
+
+void SwConnectionListener::disposing(const lang::EventObject& /*aEvent*/)
+ throw(uno::RuntimeException, std::exception)
+{
+}
+
+SwMailTransferable::SwMailTransferable(const OUString& rBody, const OUString& rMimeType) :
+ cppu::WeakComponentImplHelper2< datatransfer::XTransferable, beans::XPropertySet >(m_aMutex),
+ m_aMimeType( rMimeType ),
+ m_sBody( rBody ),
+ m_bIsBody( true )
+{
+}
+
+SwMailTransferable::SwMailTransferable(const OUString& rURL,
+ const OUString& rName, const OUString& rMimeType) :
+ cppu::WeakComponentImplHelper2< datatransfer::XTransferable, beans::XPropertySet >(m_aMutex),
+ m_aMimeType( rMimeType ),
+ m_aURL(rURL),
+ m_aName( rName ),
+ m_bIsBody( false )
+{
+}
+
+SwMailTransferable::~SwMailTransferable()
+{
+}
+
+uno::Any SwMailTransferable::getTransferData( const datatransfer::DataFlavor& /*aFlavor*/ )
+ throw (datatransfer::UnsupportedFlavorException,
+ io::IOException, uno::RuntimeException, std::exception)
+{
+ uno::Any aRet;
+ if( m_bIsBody )
+ aRet <<= OUString(m_sBody);
+ else
+ {
+ Sequence<sal_Int8> aData;
+ SfxMedium aMedium( m_aURL, STREAM_STD_READ );
+ SvStream* pStream = aMedium.GetInStream();
+ if ( aMedium.GetErrorCode() == ERRCODE_NONE && pStream)
+ {
+ pStream->Seek(STREAM_SEEK_TO_END);
+ aData.realloc(pStream->Tell());
+ pStream->Seek(0);
+ sal_Int8 * pData = aData.getArray();
+ pStream->Read( pData, aData.getLength() );
+ }
+ aRet <<= aData;
+ }
+ return aRet;
+}
+
+uno::Sequence< datatransfer::DataFlavor > SwMailTransferable::getTransferDataFlavors( )
+ throw (uno::RuntimeException, std::exception)
+{
+ uno::Sequence< datatransfer::DataFlavor > aRet(1);
+ aRet[0].MimeType = m_aMimeType;
+ if( m_bIsBody )
+ {
+ aRet[0].DataType = getCppuType((OUString*)0);
+ }
+ else
+ {
+ aRet[0].HumanPresentableName = m_aName;
+ aRet[0].DataType = getCppuType((uno::Sequence<sal_Int8>*)0);
+ }
+ return aRet;
+}
+
+sal_Bool SwMailTransferable::isDataFlavorSupported(
+ const datatransfer::DataFlavor& aFlavor )
+ throw (uno::RuntimeException, std::exception)
+{
+ return (aFlavor.MimeType == m_aMimeType);
+}
+
+uno::Reference< beans::XPropertySetInfo > SwMailTransferable::getPropertySetInfo( ) throw(uno::RuntimeException, std::exception)
+{
+ return uno::Reference< beans::XPropertySetInfo >();
+}
+
+void SwMailTransferable::setPropertyValue( const OUString& , const uno::Any& )
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException,
+ lang::WrappedTargetException, uno::RuntimeException, std::exception)
+{
+}
+
+uno::Any SwMailTransferable::getPropertyValue( const OUString& rPropertyName )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
+{
+ uno::Any aRet;
+ if ( rPropertyName == "URL" )
+ aRet <<= m_aURL;
+ return aRet;
+}
+
+void SwMailTransferable::addPropertyChangeListener(
+ const OUString&, const uno::Reference< beans::XPropertyChangeListener >& )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
+{
+}
+
+void SwMailTransferable::removePropertyChangeListener(
+ const OUString&,
+ const uno::Reference< beans::XPropertyChangeListener >& )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
+{
+}
+
+void SwMailTransferable::addVetoableChangeListener(
+ const OUString&,
+ const uno::Reference< beans::XVetoableChangeListener >& )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
+{
+}
+
+void SwMailTransferable::removeVetoableChangeListener(
+ const OUString& ,
+ const uno::Reference< beans::XVetoableChangeListener >& )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
+{
+}
+
+SwMailMessage::SwMailMessage() :
+ cppu::WeakComponentImplHelper1< mail::XMailMessage>(m_aMutex)
+{
+}
+
+SwMailMessage::~SwMailMessage()
+{
+}
+
+OUString SwMailMessage::getSenderName() throw (uno::RuntimeException, std::exception)
+{
+ return m_sSenderName;
+}
+
+OUString SwMailMessage::getSenderAddress() throw (uno::RuntimeException, std::exception)
+{
+ return m_sSenderAddress;
+}
+
+OUString SwMailMessage::getReplyToAddress() throw (uno::RuntimeException, std::exception)
+{
+ return m_sReplyToAddress;
+}
+
+void SwMailMessage::setReplyToAddress( const OUString& _replytoaddress ) throw (uno::RuntimeException, std::exception)
+{
+ m_sReplyToAddress = _replytoaddress;
+}
+
+OUString SwMailMessage::getSubject() throw (uno::RuntimeException, std::exception)
+{
+ return m_sSubject;
+}
+
+void SwMailMessage::setSubject( const OUString& _subject ) throw (uno::RuntimeException, std::exception)
+{
+ m_sSubject = _subject;
+}
+
+uno::Reference< datatransfer::XTransferable > SwMailMessage::getBody() throw (uno::RuntimeException, std::exception)
+{
+ return m_xBody;
+}
+
+void SwMailMessage::setBody(
+ const uno::Reference< datatransfer::XTransferable >& rBody )
+ throw (uno::RuntimeException, std::exception)
+{
+ m_xBody = rBody;
+}
+
+void SwMailMessage::addRecipient( const OUString& rRecipientAddress )
+ throw (uno::RuntimeException, std::exception)
+{
+ m_aRecipients.realloc(m_aRecipients.getLength() + 1);
+ m_aRecipients[m_aRecipients.getLength() - 1] = rRecipientAddress;
+}
+
+void SwMailMessage::addCcRecipient( const OUString& rRecipientAddress )
+ throw (uno::RuntimeException, std::exception)
+{
+ m_aCcRecipients.realloc(m_aCcRecipients.getLength() + 1);
+ m_aCcRecipients[m_aCcRecipients.getLength() - 1] = rRecipientAddress;
+
+}
+
+void SwMailMessage::addBccRecipient( const OUString& rRecipientAddress ) throw (uno::RuntimeException, std::exception)
+{
+ m_aBccRecipients.realloc(m_aBccRecipients.getLength() + 1);
+ m_aBccRecipients[m_aBccRecipients.getLength() - 1] = rRecipientAddress;
+}
+
+uno::Sequence< OUString > SwMailMessage::getRecipients( ) throw (uno::RuntimeException, std::exception)
+{
+ return m_aRecipients;
+}
+
+uno::Sequence< OUString > SwMailMessage::getCcRecipients( ) throw (uno::RuntimeException, std::exception)
+{
+ return m_aCcRecipients;
+}
+
+uno::Sequence< OUString > SwMailMessage::getBccRecipients( ) throw (uno::RuntimeException, std::exception)
+{
+ return m_aBccRecipients;
+}
+
+void SwMailMessage::addAttachment( const mail::MailAttachment& rMailAttachment )
+ throw (uno::RuntimeException, std::exception)
+{
+ m_aAttachments.realloc(m_aAttachments.getLength() + 1);
+ m_aAttachments[m_aAttachments.getLength() - 1] = rMailAttachment;
+}
+
+uno::Sequence< mail::MailAttachment > SwMailMessage::getAttachments( )
+ throw (uno::RuntimeException, std::exception)
+{
+ return m_aAttachments;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/dbui/mmconfigitem.cxx b/sw/source/core/uibase/dbui/mmconfigitem.cxx
new file mode 100644
index 000000000000..ad8a2393adec
--- /dev/null
+++ b/sw/source/core/uibase/dbui/mmconfigitem.cxx
@@ -0,0 +1,1739 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <mmconfigitem.hxx>
+#include <swtypes.hxx>
+#include <osl/diagnose.h>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/sdb/XCompletedConnection.hpp>
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include "com/sun/star/mail/MailServiceType.hpp"
+#include "com/sun/star/mail/XMailService.hpp"
+#include "com/sun/star/mail/MailServiceProvider.hpp"
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sdbc/XRowSet.hpp>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/types.hxx>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <rtl/instance.hxx>
+#include <unotools/configitem.hxx>
+#include <mailmergehelper.hxx>
+#include <swunohelper.hxx>
+#include <dbmgr.hxx>
+#include <view.hxx>
+#include <wrtsh.hxx>
+#include <dbui.hrc>
+#include <vector>
+#include <unomid.h>
+
+using namespace utl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+
+const char* cAddressDataAssignments = "AddressDataAssignments";
+const char* cDBColumnAssignments = "DBColumnAssignments";
+const char* cDataSourceName = "DataSource/DataSourceName";
+const char* cDataTableName = "DataSource/DataTableName" ;
+const char* cDataCommandType = "DataSource/DataCommandType";
+
+#define SECURE_PORT 465
+#define DEFAULT_PORT 25
+#define POP_PORT 110
+
+struct DBAddressDataAssignment
+{
+ SwDBData aDBData;
+ Sequence< OUString> aDBColumnAssignments;
+ //if loaded the name of the node has to be saved
+ OUString sConfigNodeName;
+ //all created or changed assignments need to be stored
+ bool bColumnAssignmentsChanged;
+
+ DBAddressDataAssignment() :
+ bColumnAssignmentsChanged(false)
+ {}
+};
+
+class SwMailMergeConfigItem_Impl : public utl::ConfigItem
+{
+ friend class SwMailMergeConfigItem;
+ Reference< XDataSource> xSource;
+ SharedConnection xConnection;
+ Reference< XColumnsSupplier> xColumnsSupplier;
+ Reference< XStatement> xStatement;
+ Reference< XResultSet> xResultSet;
+ SwDBData aDBData;
+ OUString sFilter;
+ sal_Int32 nResultSetCursorPos;
+
+ ::std::vector<DBAddressDataAssignment> aAddressDataAssignments;
+ ::std::vector< OUString> aAddressBlocks;
+ sal_Int32 nCurrentAddressBlock;
+ sal_Bool bIsAddressBlock;
+ sal_Bool bIsHideEmptyParagraphs;
+
+ sal_Bool bIsOutputToLetter;
+ sal_Bool bIncludeCountry;
+ OUString sExcludeCountry;
+
+ sal_Bool bIsGreetingLine;
+ sal_Bool bIsIndividualGreetingLine;
+ ::std::vector< OUString> aFemaleGreetingLines;
+ sal_Int32 nCurrentFemaleGreeting;
+ ::std::vector< OUString> aMaleGreetingLines;
+ sal_Int32 nCurrentMaleGreeting;
+ ::std::vector< OUString> aNeutralGreetingLines;
+ sal_Int32 nCurrentNeutralGreeting;
+ OUString sFemaleGenderValue;
+ uno::Sequence< OUString> aSavedDocuments;
+
+ sal_Bool bIsGreetingLineInMail;
+ sal_Bool bIsIndividualGreetingLineInMail;
+
+ //mail settings
+ OUString sMailDisplayName;
+ OUString sMailAddress;
+ OUString sMailReplyTo;
+ OUString sMailServer;
+ OUString sMailUserName;
+ OUString sMailPassword;
+
+ sal_Bool bIsSMPTAfterPOP;
+ OUString sInServerName;
+ sal_Int16 nInServerPort;
+ sal_Bool bInServerPOP;
+ OUString sInServerUserName;
+ OUString sInServerPassword;
+
+ sal_Int16 nMailPort;
+ sal_Bool bIsMailReplyTo;
+ sal_Bool bIsDefaultPort;
+ sal_Bool bIsSecureConnection;
+ sal_Bool bIsAuthentication;
+
+ sal_Bool bIsEMailSupported;
+
+ ResStringArray m_AddressHeaderSA;
+
+ //these addresses are not stored in the configuration
+ ::std::vector< SwDocMergeInfo > aMergeInfos;
+
+ //we do overwrite the usersettings in a special case
+ //than we do remind the usersettings here
+ sal_Bool bUserSettingWereOverwritten;
+ sal_Bool bIsAddressBlock_LastUserSetting;
+ sal_Bool bIsGreetingLineInMail_LastUserSetting;
+ sal_Bool bIsGreetingLine_LastUserSetting;
+
+ const Sequence< OUString>& GetPropertyNames();
+
+public:
+ SwMailMergeConfigItem_Impl();
+ ~SwMailMergeConfigItem_Impl();
+
+ virtual void Commit();
+ virtual void Notify( const ::com::sun::star::uno::Sequence< OUString >& aPropertyNames );
+ const Sequence< OUString>
+ GetAddressBlocks(sal_Bool bConvertToConfig = sal_False) const;
+ void SetAddressBlocks(
+ const Sequence< OUString>& rBlocks,
+ sal_Bool bConvertFromConfig = sal_False);
+ const uno::Sequence< OUString>
+ GetGreetings(SwMailMergeConfigItem::Gender eType,
+ sal_Bool bConvertToConfig = sal_False) const;
+ void SetGreetings(SwMailMergeConfigItem::Gender eType,
+ const uno::Sequence< OUString>& rBlocks,
+ sal_Bool bConvertFromConfig = sal_False);
+
+ void SetCurrentAddressBlockIndex( sal_Int32 nSet );
+ sal_Int32 GetCurrentAddressBlockIndex() const
+ { return nCurrentAddressBlock; }
+ sal_Int32 GetCurrentGreeting(SwMailMergeConfigItem::Gender eType) const;
+ void SetCurrentGreeting(SwMailMergeConfigItem::Gender eType, sal_Int32 nIndex);
+
+};
+
+SwMailMergeConfigItem_Impl::SwMailMergeConfigItem_Impl() :
+ ConfigItem("Office.Writer/MailMergeWizard", 0),
+ nResultSetCursorPos(-1),
+ nCurrentAddressBlock(0),
+ bIsAddressBlock(sal_True),
+ bIsHideEmptyParagraphs(sal_False),
+ bIsOutputToLetter(sal_True),
+ bIncludeCountry(sal_False),
+ bIsGreetingLine(sal_True),
+ nCurrentFemaleGreeting(0),
+ nCurrentMaleGreeting(0),
+ nCurrentNeutralGreeting(0),
+
+ bIsSMPTAfterPOP(sal_False),
+ nInServerPort( POP_PORT ),
+ bInServerPOP( sal_True ),
+ nMailPort(0),
+ bIsMailReplyTo(sal_False),
+ bIsDefaultPort(sal_False),
+ bIsSecureConnection(sal_False),
+ bIsAuthentication(sal_False),
+
+ bIsEMailSupported(sal_False),
+ m_AddressHeaderSA( SW_RES( SA_ADDRESS_HEADER )),
+ bUserSettingWereOverwritten(sal_False),
+ bIsAddressBlock_LastUserSetting(sal_False),
+ bIsGreetingLineInMail_LastUserSetting(sal_False),
+ bIsGreetingLine_LastUserSetting(sal_False)
+{
+ const Sequence<OUString>& rNames = GetPropertyNames();
+ Sequence<Any> aValues = GetProperties(rNames);
+ const Any* pValues = aValues.getConstArray();
+ OSL_ENSURE(aValues.getLength() == rNames.getLength(), "GetProperties failed");
+ if(aValues.getLength() == rNames.getLength())
+ {
+ for(int nProp = 0; nProp < rNames.getLength(); nProp++)
+ {
+ switch(nProp)
+ {
+ case 0: pValues[nProp] >>= bIsOutputToLetter; break;
+ case 1: pValues[nProp] >>= bIncludeCountry; break;
+ case 2: pValues[nProp] >>= sExcludeCountry; break;
+ case 3:
+ {
+ Sequence< OUString> aBlocks;
+ pValues[nProp] >>= aBlocks;
+ SetAddressBlocks(aBlocks, sal_True);
+ }
+ break;
+ case 4: pValues[nProp] >>= bIsAddressBlock; break;
+ case 5: pValues[nProp] >>= bIsGreetingLine; break;
+ case 6: pValues[nProp] >>= bIsIndividualGreetingLine; break;
+ case 7 :
+ case 8 :
+ case 9 :
+ {
+ Sequence< OUString> aGreetings;
+ pValues[nProp] >>= aGreetings;
+ SetGreetings(SwMailMergeConfigItem::Gender(
+ SwMailMergeConfigItem::FEMALE + nProp - 7), aGreetings, sal_True);
+ }
+ break;
+
+ case 10: pValues[nProp] >>= nCurrentFemaleGreeting; break;
+ case 11: pValues[nProp] >>= nCurrentMaleGreeting; break;
+ case 12: pValues[nProp] >>= nCurrentNeutralGreeting; break;
+ case 13: pValues[nProp] >>= sFemaleGenderValue; break;
+ case 14: pValues[nProp] >>= sMailDisplayName; break;
+ case 15: pValues[nProp] >>= sMailAddress; break;
+ case 16: pValues[nProp] >>= bIsMailReplyTo; break;
+ case 17: pValues[nProp] >>= sMailReplyTo; break;
+ case 18: pValues[nProp] >>= sMailServer; break;
+ case 19:
+ bIsDefaultPort =
+ (pValues[nProp] >>= nMailPort) ?
+ sal_False : sal_True;
+ break;
+ case 20: pValues[nProp] >>= bIsSecureConnection; break;
+ case 21: pValues[nProp] >>= bIsAuthentication; break;
+ case 22: pValues[nProp] >>= sMailUserName; break;
+ case 23: pValues[nProp] >>= sMailPassword; break;
+ case 24 :pValues[nProp] >>= aDBData.sDataSource; break;
+ case 25 :pValues[nProp] >>= aDBData.sCommand; break;
+ case 26 :
+ {
+ short nTemp = 0;
+ if(pValues[nProp] >>= nTemp)
+ aDBData.nCommandType = nTemp;
+ }
+ break;
+ case 27: pValues[nProp] >>= sFilter; break;
+ case 28: pValues[nProp] >>= aSavedDocuments; break;
+ case 29:
+ pValues[nProp] >>= bIsEMailSupported;
+ break;
+ case 30: pValues[nProp] >>= bIsGreetingLineInMail; break;
+ case 31: pValues[nProp] >>= bIsIndividualGreetingLineInMail; break;
+ case 32: pValues[nProp] >>= bIsSMPTAfterPOP; break;
+ case 33: pValues[nProp] >>= sInServerName; break;
+ case 34: pValues[nProp] >>= nInServerPort; break;
+ case 35: pValues[nProp] >>= bInServerPOP; break;
+ case 36: pValues[nProp] >>= sInServerUserName; break;
+ case 37: pValues[nProp] >>= sInServerPassword; break;
+ case 38: pValues[nProp] >>= bIsHideEmptyParagraphs; break;
+ case 39: pValues[nProp] >>= nCurrentAddressBlock; break;
+ }
+ }
+ }
+ //read the list of data base assignments
+ Sequence<OUString> aAssignments = GetNodeNames(OUString::createFromAscii(cAddressDataAssignments));
+ if(aAssignments.getLength())
+ {
+ //create a list of property names to load the URLs of all data bases
+ const OUString* pAssignments = aAssignments.getConstArray();
+ Sequence< OUString > aAssignProperties(4 * aAssignments.getLength());
+ OUString* pAssignProperties = aAssignProperties.getArray();
+ sal_Int32 nAssign;
+ for(nAssign = 0; nAssign < aAssignProperties.getLength(); nAssign += 4)
+ {
+ OUString sAssignPath = OUString::createFromAscii(cAddressDataAssignments);
+ sAssignPath += "/";
+ sAssignPath += pAssignments[nAssign / 4];
+ sAssignPath += "/";
+ pAssignProperties[nAssign] = sAssignPath;
+ pAssignProperties[nAssign] += OUString::createFromAscii(cDataSourceName);
+ pAssignProperties[nAssign + 1] = sAssignPath;
+ pAssignProperties[nAssign + 1] += OUString::createFromAscii(cDataTableName);
+ pAssignProperties[nAssign + 2] = sAssignPath;
+ pAssignProperties[nAssign + 2] += OUString::createFromAscii(cDataCommandType);
+ pAssignProperties[nAssign + 3] = sAssignPath;
+ pAssignProperties[nAssign + 3] += OUString::createFromAscii(cDBColumnAssignments);
+ }
+ Sequence<Any> aAssignValues = GetProperties(aAssignProperties);
+ const Any* pAssignValues = aAssignValues.getConstArray();
+ for(nAssign = 0; nAssign < aAssignValues.getLength(); nAssign += 4 )
+ {
+ DBAddressDataAssignment aAssignment;
+ pAssignValues[nAssign] >>= aAssignment.aDBData.sDataSource;
+ pAssignValues[nAssign + 1] >>= aAssignment.aDBData.sCommand;
+ pAssignValues[nAssign + 2] >>= aAssignment.aDBData.nCommandType;
+ pAssignValues[nAssign + 3] >>= aAssignment.aDBColumnAssignments;
+ aAssignment.sConfigNodeName = pAssignments[nAssign / 4];
+ aAddressDataAssignments.push_back(aAssignment);
+ }
+ }
+ //check if the saved documents still exist
+ if(aSavedDocuments.getLength())
+ {
+ uno::Sequence< OUString > aTempDocuments(aSavedDocuments.getLength());
+ OUString* pTempDocuments = aTempDocuments.getArray();
+ sal_Int32 nIndex = 0;
+ for(sal_Int32 i = 0; i < aSavedDocuments.getLength(); ++i)
+ {
+ if(SWUnoHelper::UCB_IsFile( aSavedDocuments[i] ))
+ {
+ pTempDocuments[nIndex++] = aSavedDocuments[i];
+ }
+ }
+ if(nIndex < aSavedDocuments.getLength())
+ {
+ aSavedDocuments = aTempDocuments;
+ aSavedDocuments.realloc(nIndex);
+ }
+ }
+
+}
+
+SwMailMergeConfigItem_Impl::~SwMailMergeConfigItem_Impl()
+{
+}
+
+void SwMailMergeConfigItem_Impl::SetCurrentAddressBlockIndex( sal_Int32 nSet )
+{
+ if(aAddressBlocks.size() >= sal::static_int_cast<sal_uInt32, sal_Int32>(nSet))
+ {
+ nCurrentAddressBlock = nSet;
+ SetModified();
+ }
+}
+
+static OUString lcl_CreateNodeName(Sequence<OUString>& rAssignments )
+{
+ const OUString* pNames = rAssignments.getConstArray();
+ sal_Int32 nStart = rAssignments.getLength();
+ OUString sNewName;
+ bool bFound;
+ do
+ {
+ bFound = false;
+ sNewName = "_";
+ sNewName += OUString::number(nStart);
+ //search if the name exists
+ for(sal_Int32 nAssign = 0; nAssign < rAssignments.getLength(); ++nAssign)
+ {
+ if(pNames[nAssign] == sNewName)
+ {
+ bFound = true;
+ ++nStart;
+ break;
+ }
+ }
+ }
+ while(bFound);
+ // add the new name to the array of existing names
+ rAssignments.realloc(rAssignments.getLength() + 1);
+ rAssignments.getArray()[rAssignments.getLength() - 1] = sNewName;
+ return sNewName;
+}
+
+static void lcl_ConvertToNumbers(OUString& rBlock, const ResStringArray& rHeaders )
+{
+ //convert the strings used for UI to numbers used for the configuration
+ OUString sBlock(rBlock.replaceAll("\n", OUString("\\n")));
+ for(sal_uInt16 i = 0; i < rHeaders.Count(); ++i)
+ {
+ OUString sHeader = "<" + rHeaders.GetString( i ) + ">";
+ OUString sReplace = "<" + OUString('0' + i) + ">";
+ sBlock = sBlock.replaceAll(sHeader, sReplace);
+ }
+ rBlock = sBlock;
+}
+
+static void lcl_ConvertFromNumbers(OUString& rBlock, const ResStringArray& rHeaders)
+{
+ //convert the numbers used for the configuration to strings used for UI to numbers
+ //doesn't use ReplaceAll to prevent expansion of numbers inside of the headers
+ OUString sBlock(rBlock.replaceAll("\\n", OUString('\n')));
+ SwAddressIterator aGreetingIter(sBlock);
+ sBlock = OUString();
+ while(aGreetingIter.HasMore())
+ {
+ SwMergeAddressItem aNext = aGreetingIter.Next();
+ if(aNext.bIsColumn)
+ {
+ //the text should be 1 characters long
+ sal_Unicode cChar = aNext.sText[0];
+ if(cChar >= '0' && cChar <= 'c')
+ {
+ sBlock += "<";
+ sal_uInt16 nHeader = cChar - '0';
+ if(nHeader < rHeaders.Count())
+ sBlock += rHeaders.GetString( nHeader );
+ sBlock += ">";
+ }
+ else
+ {
+ OSL_FAIL("parse error in address block or greeting line");
+ }
+ }
+ else
+ sBlock += aNext.sText;
+ }
+ rBlock = sBlock;
+}
+
+const Sequence<OUString>& SwMailMergeConfigItem_Impl::GetPropertyNames()
+{
+ static Sequence<OUString> aNames;
+ if(!aNames.getLength())
+ {
+ static const char* aPropNames[] =
+ {
+ "OutputToLetter", // 0
+ "IncludeCountry", // 1
+ "ExcludeCountry", // 2
+ "AddressBlockSettings", // 3
+ "IsAddressBlock", // 4
+ "IsGreetingLine", // 5
+ "IsIndividualGreetingLine", // 6
+ "FemaleGreetingLines", // 7
+ "MaleGreetingLines", // 8
+ "NeutralGreetingLines", // 9
+ "CurrentFemaleGreeting", // 10
+ "CurrentMaleGreeting", // 11
+ "CurrentNeutralGreeting", // 12
+ "FemaleGenderValue", // 13
+ "MailDisplayName", // 14
+ "MailAddress", // 15
+ "IsMailReplyTo", // 16
+ "MailReplyTo", // 17
+ "MailServer", // 18
+ "MailPort", // 19
+ "IsSecureConnection", // 20
+ "IsAuthentication", // 21
+ "MailUserName", // 22
+ "MailPassword", // 23
+ "DataSource/DataSourceName",// 24
+ "DataSource/DataTableName", // 25
+ "DataSource/DataCommandType",// 26
+ "Filter", // 27
+ "SavedDocuments", // 28
+ "EMailSupported", // 29
+ "IsEMailGreetingLine", //30
+ "IsEMailIndividualGreetingLine", //31
+ "IsSMPTAfterPOP", //32
+ "InServerName", //33
+ "InServerPort", //34
+ "InServerIsPOP", //35
+ "InServerUserName", //36
+ "InServerPassword", //37
+ "IsHideEmptyParagraphs", //38
+ "CurrentAddressBlock" //39
+
+ };
+ const int nCount = sizeof(aPropNames)/sizeof(const char*);
+ aNames.realloc(nCount);
+ OUString* pNames = aNames.getArray();
+ for(int i = 0; i < nCount; i++)
+ pNames[i] = OUString::createFromAscii(aPropNames[i]);
+ }
+ return aNames;
+}
+
+void SwMailMergeConfigItem_Impl::Notify( const ::com::sun::star::uno::Sequence< OUString >& ) {}
+
+void SwMailMergeConfigItem_Impl::Commit()
+{
+ Sequence<OUString> aNames = GetPropertyNames();
+ Sequence<Any> aValues(aNames.getLength());
+ Any* pValues = aValues.getArray();
+
+ for(int nProp = 0; nProp < aNames.getLength(); nProp++)
+ {
+ switch(nProp)
+ {
+ case 0: pValues[nProp] <<= bIsOutputToLetter; break;
+ case 1: pValues[nProp] <<= bIncludeCountry; break;
+ case 2: pValues[nProp] <<= sExcludeCountry; break;
+ case 3: pValues[nProp] <<= GetAddressBlocks(sal_True); break;
+ case 4:
+ {
+ if( bUserSettingWereOverwritten == sal_True )
+ pValues[nProp] <<= bIsAddressBlock_LastUserSetting;
+ else
+ pValues[nProp] <<= bIsAddressBlock;
+ break;
+ }
+ case 5:
+ {
+ if( bUserSettingWereOverwritten == sal_True )
+ pValues[nProp] <<= bIsGreetingLine_LastUserSetting;
+ else
+ pValues[nProp] <<= bIsGreetingLine;
+ break;
+ }
+ case 6: pValues[nProp] <<= bIsIndividualGreetingLine; break;
+ case 7:
+ case 8:
+ case 9:
+ pValues[nProp] <<= GetGreetings(
+ SwMailMergeConfigItem::Gender(
+ SwMailMergeConfigItem::FEMALE + nProp - 7), sal_True);
+ break;
+ case 10: pValues[nProp] <<= nCurrentFemaleGreeting; break;
+ case 11: pValues[nProp] <<= nCurrentMaleGreeting; break;
+ case 12: pValues[nProp] <<= nCurrentNeutralGreeting; break;
+ case 13: pValues[nProp] <<= sFemaleGenderValue; break;
+ case 14: pValues[nProp] <<= sMailDisplayName; break;
+ case 15: pValues[nProp] <<= sMailAddress; break;
+ case 16: pValues[nProp] <<= bIsMailReplyTo; break;
+ case 17: pValues[nProp] <<= sMailReplyTo; break;
+ case 18: pValues[nProp] <<= sMailServer; break;
+ case 19: if(!bIsDefaultPort)
+ pValues[nProp] <<= nMailPort;
+ break;
+ case 20: pValues[nProp] <<= bIsSecureConnection; break;
+ case 21: pValues[nProp] <<= bIsAuthentication; break;
+ case 22: pValues[nProp] <<= sMailUserName; break;
+ case 23: pValues[nProp] <<= sMailPassword; break;
+ case 24 :pValues[nProp] <<= aDBData.sDataSource; break;
+ case 25 :pValues[nProp] <<= aDBData.sCommand; break;
+ case 26 :pValues[nProp] <<= (short)aDBData.nCommandType; break;
+ case 27 :pValues[nProp] <<= sFilter; break;
+ case 28 :pValues[nProp] <<= aSavedDocuments; break;
+ case 29: pValues[nProp] <<= bIsEMailSupported; break;
+ case 30:
+ {
+ if( bUserSettingWereOverwritten == sal_True )
+ pValues[nProp] <<= bIsGreetingLineInMail_LastUserSetting;
+ else
+ pValues[nProp] <<= bIsGreetingLineInMail;
+ break;
+ }
+ case 31: pValues[nProp] <<= bIsIndividualGreetingLineInMail; break;
+ case 32: pValues[nProp] <<= bIsSMPTAfterPOP; break;
+ case 33: pValues[nProp] <<= sInServerName; break;
+ case 34: pValues[nProp] <<= nInServerPort; break;
+ case 35: pValues[nProp] <<= bInServerPOP; break;
+ case 36: pValues[nProp] <<= sInServerUserName; break;
+ case 37: pValues[nProp] <<= sInServerPassword; break;
+ case 38: pValues[nProp] <<= bIsHideEmptyParagraphs; break;
+ case 39: pValues[nProp] <<= nCurrentAddressBlock; break;
+ }
+ }
+ PutProperties(aNames, aValues);
+ //store the changed / new assignments
+
+ //load the existing node names to find new names
+ Sequence<OUString> aAssignments = GetNodeNames(OUString::createFromAscii(cAddressDataAssignments));
+
+ ::std::vector<DBAddressDataAssignment>::iterator aAssignIter;
+ for(aAssignIter = aAddressDataAssignments.begin();
+ aAssignIter != aAddressDataAssignments.end(); ++aAssignIter)
+ {
+ if(aAssignIter->bColumnAssignmentsChanged)
+ {
+ //create a new node name
+ OUString sNewNode = !aAssignIter->sConfigNodeName.isEmpty() ?
+ aAssignIter->sConfigNodeName :
+ lcl_CreateNodeName(aAssignments);
+ OUString sSlash = "/";
+ OUString sNodePath = OUString::createFromAscii(cAddressDataAssignments);
+ sNodePath += sSlash;
+ sNodePath += sNewNode;
+ sNodePath += sSlash;
+ //only one new entry is written
+ Sequence< PropertyValue > aNewValues(4);
+ PropertyValue* pNewValues = aNewValues.getArray();
+ pNewValues[0].Name = sNodePath;
+ pNewValues[0].Name += OUString::createFromAscii(cDataSourceName);
+ pNewValues[0].Value <<= aAssignIter->aDBData.sDataSource;
+ pNewValues[1].Name = sNodePath;
+ pNewValues[1].Name += OUString::createFromAscii(cDataTableName);
+ pNewValues[1].Value <<= aAssignIter->aDBData.sCommand;
+ pNewValues[2].Name = sNodePath;
+ pNewValues[2].Name += OUString::createFromAscii(cDataCommandType);
+ pNewValues[2].Value <<= aAssignIter->aDBData.nCommandType;
+ pNewValues[3].Name = sNodePath;
+ pNewValues[3].Name += OUString::createFromAscii(cDBColumnAssignments);
+ pNewValues[3].Value <<= aAssignIter->aDBColumnAssignments;
+
+ SetSetProperties(OUString::createFromAscii(cAddressDataAssignments), aNewValues);
+ }
+ }
+
+ bUserSettingWereOverwritten = sal_False;
+}
+
+const Sequence< OUString> SwMailMergeConfigItem_Impl::GetAddressBlocks(
+ sal_Bool bConvertToConfig) const
+{
+ Sequence< OUString> aRet(aAddressBlocks.size());
+ OUString* pRet = aRet.getArray();
+ for(sal_uInt32 nBlock = 0; nBlock < aAddressBlocks.size(); nBlock++)
+ {
+ pRet[nBlock] = aAddressBlocks[nBlock];
+ if(bConvertToConfig)
+ lcl_ConvertToNumbers(pRet[nBlock], m_AddressHeaderSA);
+ }
+ return aRet;
+}
+
+void SwMailMergeConfigItem_Impl::SetAddressBlocks(
+ const Sequence< OUString>& rBlocks,
+ sal_Bool bConvertFromConfig)
+{
+ aAddressBlocks.clear();
+ for(sal_Int32 nBlock = 0; nBlock < rBlocks.getLength(); nBlock++)
+ {
+ OUString sBlock = rBlocks[nBlock];
+ if(bConvertFromConfig)
+ lcl_ConvertFromNumbers(sBlock, m_AddressHeaderSA);
+ aAddressBlocks.push_back(sBlock);
+ }
+ nCurrentAddressBlock = 0;
+ SetModified();
+}
+
+const Sequence< OUString> SwMailMergeConfigItem_Impl::GetGreetings(
+ SwMailMergeConfigItem::Gender eType, sal_Bool bConvertToConfig) const
+{
+ const ::std::vector< OUString>& rGreetings =
+ eType == SwMailMergeConfigItem::FEMALE ? aFemaleGreetingLines :
+ eType == SwMailMergeConfigItem::MALE ? aMaleGreetingLines :
+ aNeutralGreetingLines;
+ Sequence< OUString> aRet(rGreetings.size());
+ OUString* pRet = aRet.getArray();
+ for(sal_uInt32 nGreeting = 0; nGreeting < rGreetings.size(); nGreeting++)
+ {
+ pRet[nGreeting] = rGreetings[nGreeting];
+ if(bConvertToConfig)
+ lcl_ConvertToNumbers(pRet[nGreeting], m_AddressHeaderSA);
+ }
+ return aRet;
+}
+
+void SwMailMergeConfigItem_Impl::SetGreetings(
+ SwMailMergeConfigItem::Gender eType,
+ const Sequence< OUString>& rSetGreetings,
+ sal_Bool bConvertFromConfig)
+{
+ ::std::vector< OUString>& rGreetings =
+ eType == SwMailMergeConfigItem::FEMALE ? aFemaleGreetingLines :
+ eType == SwMailMergeConfigItem::MALE ? aMaleGreetingLines :
+ aNeutralGreetingLines;
+
+ rGreetings.clear();
+ for(sal_Int32 nGreeting = 0; nGreeting < rSetGreetings.getLength(); nGreeting++)
+ {
+ OUString sGreeting = rSetGreetings[nGreeting];
+ if(bConvertFromConfig)
+ lcl_ConvertFromNumbers(sGreeting, m_AddressHeaderSA);
+ rGreetings.push_back(sGreeting);
+ }
+ SetModified();
+}
+
+sal_Int32 SwMailMergeConfigItem_Impl::GetCurrentGreeting(
+ SwMailMergeConfigItem::Gender eType) const
+{
+ sal_Int32 nRet;
+ switch(eType)
+ {
+ case SwMailMergeConfigItem::FEMALE: nRet = nCurrentFemaleGreeting ; break;
+ case SwMailMergeConfigItem::MALE: nRet = nCurrentMaleGreeting ; break;
+ default: nRet = nCurrentNeutralGreeting; break;
+ }
+ return nRet;
+}
+
+void SwMailMergeConfigItem_Impl::SetCurrentGreeting(
+ SwMailMergeConfigItem::Gender eType, sal_Int32 nIndex)
+{
+ bool bChanged = false;
+ switch(eType)
+ {
+ case SwMailMergeConfigItem::FEMALE:
+ bChanged = nCurrentFemaleGreeting != nIndex;
+ nCurrentFemaleGreeting = nIndex;
+ break;
+ case SwMailMergeConfigItem::MALE:
+ bChanged = nCurrentMaleGreeting != nIndex;
+ nCurrentMaleGreeting = nIndex;
+ break;
+ default:
+ bChanged = nCurrentNeutralGreeting != nIndex;
+ nCurrentNeutralGreeting = nIndex;
+ }
+ if(bChanged)
+ SetModified();
+}
+
+namespace
+{
+ static SwMailMergeConfigItem_Impl* pOptions = NULL;
+ static sal_Int32 nRefCount = 0;
+
+ class theMailMergeConfigMutex : public rtl::Static<osl::Mutex, theMailMergeConfigMutex> {};
+}
+
+SwMailMergeConfigItem::SwMailMergeConfigItem() :
+ m_bAddressInserted(false),
+ m_bMergeDone(false),
+ m_bGreetingInserted(false),
+ m_nGreetingMoves(0),
+ m_nStartPrint(0),
+ m_nEndPrint(0),
+ m_pSourceView(0),
+ m_pTargetView(0)
+{
+ // Global access, must be guarded (multithreading)
+ ::osl::MutexGuard aGuard( theMailMergeConfigMutex::get() );
+ if ( !pOptions )
+ pOptions = new SwMailMergeConfigItem_Impl;
+ ++nRefCount;
+ m_pImpl = pOptions;
+}
+
+SwMailMergeConfigItem::~SwMailMergeConfigItem()
+{
+ // Global access, must be guarded (multithreading)
+ ::osl::MutexGuard aGuard( theMailMergeConfigMutex::get() );
+ if ( !--nRefCount )
+ {
+ DELETEZ( pOptions );
+ }
+}
+
+void SwMailMergeConfigItem::Commit()
+{
+ if(m_pImpl->IsModified())
+ m_pImpl->Commit();
+}
+
+const ResStringArray& SwMailMergeConfigItem::GetDefaultAddressHeaders() const
+{
+ return m_pImpl->m_AddressHeaderSA;
+}
+
+void SwMailMergeConfigItem::SetAddressBlocks(
+ const Sequence< OUString>& rBlocks)
+{
+ m_pImpl->SetAddressBlocks(rBlocks);
+}
+
+const Sequence< OUString> SwMailMergeConfigItem::GetAddressBlocks() const
+{
+ return m_pImpl->GetAddressBlocks();
+}
+
+bool SwMailMergeConfigItem::IsAddressBlock()const
+{
+ return m_pImpl->bIsAddressBlock && IsOutputToLetter();
+}
+
+void SwMailMergeConfigItem::SetAddressBlock(sal_Bool bSet)
+{
+ m_pImpl->bUserSettingWereOverwritten = sal_False;
+ if(m_pImpl->bIsAddressBlock != bSet)
+ {
+ m_pImpl->bIsAddressBlock = bSet;
+ m_pImpl->SetModified();
+ }
+}
+
+sal_Bool SwMailMergeConfigItem::IsHideEmptyParagraphs() const
+{
+ return m_pImpl->bIsHideEmptyParagraphs;
+}
+
+void SwMailMergeConfigItem::SetHideEmptyParagraphs(sal_Bool bSet)
+{
+ if(m_pImpl->bIsHideEmptyParagraphs != bSet)
+ {
+ m_pImpl->bIsHideEmptyParagraphs = bSet;
+ m_pImpl->SetModified();
+ }
+}
+
+sal_Bool SwMailMergeConfigItem::IsIncludeCountry() const
+{
+ return m_pImpl->bIncludeCountry;
+}
+
+OUString& SwMailMergeConfigItem::GetExcludeCountry() const
+{
+ return m_pImpl->sExcludeCountry;
+}
+
+void SwMailMergeConfigItem::SetCountrySettings(sal_Bool bSet, const OUString& rCountry)
+{
+ if(m_pImpl->sExcludeCountry != rCountry ||
+ m_pImpl->bIncludeCountry != bSet)
+ {
+ m_pImpl->bIncludeCountry = bSet;
+ m_pImpl->sExcludeCountry = bSet ? rCountry : OUString();
+ m_pImpl->SetModified();
+ }
+}
+
+void SwMailMergeConfigItem::SetCurrentConnection(
+ Reference< XDataSource> xSource,
+ SharedConnection xConnection,
+ Reference< XColumnsSupplier> xColumnsSupplier,
+ const SwDBData& rDBData)
+{
+ m_pImpl->xSource = xSource ;
+ m_pImpl->xConnection = xConnection ;
+ m_pImpl->xColumnsSupplier = xColumnsSupplier;
+ m_pImpl->aDBData = rDBData;
+ m_pImpl->xResultSet = 0;
+ m_pImpl->nResultSetCursorPos = 0;
+ m_pImpl->SetModified();
+}
+
+Reference< XDataSource> SwMailMergeConfigItem::GetSource()
+{
+ return m_pImpl->xSource;
+}
+
+SharedConnection SwMailMergeConfigItem::GetConnection()
+{
+ return m_pImpl->xConnection;
+}
+
+Reference< XColumnsSupplier> SwMailMergeConfigItem::GetColumnsSupplier()
+{
+ if(!m_pImpl->xColumnsSupplier.is() && m_pImpl->xConnection.is())
+ {
+ m_pImpl->xColumnsSupplier = SwNewDBMgr::GetColumnSupplier(m_pImpl->xConnection,
+ m_pImpl->aDBData.sCommand,
+ m_pImpl->aDBData.nCommandType == CommandType::TABLE ?
+ SW_DB_SELECT_TABLE : SW_DB_SELECT_QUERY );
+ }
+ return m_pImpl->xColumnsSupplier;
+}
+
+const SwDBData& SwMailMergeConfigItem::GetCurrentDBData() const
+{
+ return m_pImpl->aDBData;
+}
+
+void SwMailMergeConfigItem::SetCurrentDBData( const SwDBData& rDBData)
+{
+ if(m_pImpl->aDBData != rDBData)
+ {
+ m_pImpl->aDBData = rDBData;
+ m_pImpl->xConnection.clear();
+ m_pImpl->xSource = 0;
+ m_pImpl->xColumnsSupplier = 0;
+ m_pImpl->SetModified();
+ }
+}
+
+Reference< XResultSet> SwMailMergeConfigItem::GetResultSet() const
+{
+ if(!m_pImpl->xConnection.is() && !m_pImpl->aDBData.sDataSource.isEmpty())
+ {
+ m_pImpl->xConnection.reset(
+ SwNewDBMgr::GetConnection( m_pImpl->aDBData.sDataSource, m_pImpl->xSource ),
+ SharedConnection::TakeOwnership
+ );
+ }
+ if(!m_pImpl->xResultSet.is() && m_pImpl->xConnection.is())
+ {
+ try
+ {
+ Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
+
+ Reference<XRowSet> xRowSet( xMgr->createInstance("com.sun.star.sdb.RowSet"), UNO_QUERY );
+ Reference<XPropertySet> xRowProperties(xRowSet, UNO_QUERY);
+ xRowProperties->setPropertyValue("DataSourceName", makeAny(m_pImpl->aDBData.sDataSource));
+ xRowProperties->setPropertyValue("Command", makeAny(m_pImpl->aDBData.sCommand));
+ xRowProperties->setPropertyValue("CommandType", makeAny(m_pImpl->aDBData.nCommandType));
+ xRowProperties->setPropertyValue("FetchSize", makeAny((sal_Int32)10));
+ xRowProperties->setPropertyValue("ActiveConnection", makeAny(m_pImpl->xConnection.getTyped()));
+ try
+ {
+ xRowProperties->setPropertyValue("ApplyFilter", makeAny(!m_pImpl->sFilter.isEmpty()));
+ xRowProperties->setPropertyValue("Filter", makeAny(m_pImpl->sFilter));
+ }
+ catch (const Exception&)
+ {
+ OSL_FAIL("exception caught in xResultSet->SetFilter()");
+ }
+ xRowSet->execute();
+ m_pImpl->xResultSet = xRowSet.get();
+ m_pImpl->xResultSet->first();
+ m_pImpl->nResultSetCursorPos = 1;
+ }
+ catch (const Exception&)
+ {
+ OSL_FAIL("exception caught in: SwMailMergeConfigItem::GetResultSet() ");
+ }
+ }
+ return m_pImpl->xResultSet;
+}
+
+void SwMailMergeConfigItem::DisposeResultSet()
+{
+ m_pImpl->xConnection.clear();
+ if(m_pImpl->xResultSet.is())
+ {
+ ::comphelper::disposeComponent( m_pImpl->xResultSet );
+ }
+}
+
+OUString& SwMailMergeConfigItem::GetFilter() const
+{
+ return m_pImpl->sFilter;
+}
+
+void SwMailMergeConfigItem::SetFilter(OUString& rFilter)
+{
+ if(m_pImpl->sFilter != rFilter)
+ {
+ m_pImpl->sFilter = rFilter;
+ m_pImpl->SetModified();
+ Reference<XPropertySet> xRowProperties(m_pImpl->xResultSet, UNO_QUERY);
+ if(xRowProperties.is())
+ {
+ try
+ {
+ xRowProperties->setPropertyValue("ApplyFilter", makeAny(!m_pImpl->sFilter.isEmpty()));
+ xRowProperties->setPropertyValue("Filter", makeAny(m_pImpl->sFilter));
+ uno::Reference<XRowSet> xRowSet( m_pImpl->xResultSet, UNO_QUERY_THROW );
+ xRowSet->execute();
+ }
+ catch (const Exception&)
+ {
+ OSL_FAIL("exception caught in SwMailMergeConfigItem::SetFilter()");
+ }
+ }
+ }
+}
+
+sal_Int32 SwMailMergeConfigItem::MoveResultSet(sal_Int32 nTarget)
+{
+ if(!m_pImpl->xResultSet.is())
+ GetResultSet();
+ if(m_pImpl->xResultSet.is())
+ {
+ try
+ {
+ //no action if the resultset is already at the right position
+ if(m_pImpl->xResultSet->getRow() != nTarget)
+ {
+ if(nTarget > 0)
+ {
+ sal_Bool bMoved = m_pImpl->xResultSet->absolute(nTarget);
+ if(!bMoved)
+ {
+ if(nTarget > 1)
+ m_pImpl->xResultSet->last();
+ else if(nTarget == 1)
+ m_pImpl->xResultSet->first();
+ }
+ }
+ else if(nTarget == -1)
+ m_pImpl->xResultSet->last();
+ m_pImpl->nResultSetCursorPos = m_pImpl->xResultSet->getRow();
+ }
+ }
+ catch (const Exception&)
+ {
+ }
+ }
+ return m_pImpl->nResultSetCursorPos;
+}
+
+bool SwMailMergeConfigItem::IsResultSetFirstLast(bool& bIsFirst, bool& bIsLast)
+{
+ bool bRet = false;
+ if(!m_pImpl->xResultSet.is())
+ GetResultSet();
+ if(m_pImpl->xResultSet.is())
+ {
+ try
+ {
+ bIsFirst = m_pImpl->xResultSet->isFirst();
+ bIsLast = m_pImpl->xResultSet->isLast();
+ bRet = true;
+ }
+ catch (const Exception&)
+ {
+ }
+ }
+ return bRet;
+}
+
+sal_Int32 SwMailMergeConfigItem::GetResultSetPosition() const
+{
+ return m_pImpl->nResultSetCursorPos;
+}
+
+bool SwMailMergeConfigItem::IsRecordExcluded(sal_Int32 nRecord)
+{
+ bool bRet = false;
+ if(nRecord > 0 && nRecord < m_aSelection.getLength())
+ {
+ sal_Int32 nTemp = 0;
+ m_aSelection[nRecord - 1] >>= nTemp;
+ bRet = nTemp < 1;
+ }
+ return bRet;
+}
+
+void SwMailMergeConfigItem::ExcludeRecord(sal_Int32 nRecord, bool bExclude)
+{
+ //nRecord is based on 1
+ //the selection array contains Anys for all records
+ //excluded records contain a '-1'
+ if(!m_aSelection.getLength() || nRecord > m_aSelection.getLength())
+ {
+ if(bExclude)
+ {
+ //if no selection array is available we need to create one containing the
+ //entries for all available records
+ if(!m_pImpl->xResultSet.is())
+ GetResultSet();
+ if(m_pImpl->xResultSet.is())
+ {
+ m_pImpl->xResultSet->last();
+ sal_Int32 nEnd = m_pImpl->xResultSet->getRow();
+ sal_Int32 nStart = m_aSelection.getLength();
+ m_aSelection.realloc(nEnd);
+ Any* pSelection = m_aSelection.getArray();
+ for(sal_Int32 nIndex = nStart; nIndex < nEnd; ++nIndex)
+ {
+ if((nRecord - 1) != nIndex)
+ pSelection[nIndex] <<= nIndex + 1;
+ else
+ pSelection[nIndex] <<= (sal_Int32) -1;
+ }
+ }
+ }
+ }
+ else
+ {
+ if(nRecord > 0 && m_aSelection.getLength() > nRecord)
+ {
+ m_aSelection[nRecord - 1] <<= bExclude ? -1 : nRecord;
+ }
+ }
+}
+
+Sequence< Any > SwMailMergeConfigItem::GetSelection() const
+{
+ Sequence< Any > aRet(m_aSelection.getLength());
+ sal_Int32 nRetIndex = 0;
+ sal_Int32 nRet;
+ for(sal_Int32 nIndex = 0; nIndex < m_aSelection.getLength(); ++nIndex)
+ {
+ m_aSelection[nIndex] >>= nRet;
+ if(nRet > 0)
+ {
+ aRet[nRetIndex] <<= nRet;
+ ++nRetIndex;
+ }
+ }
+ aRet.realloc(nRetIndex);
+ return aRet;
+}
+
+const uno::Sequence< OUString>&
+ SwMailMergeConfigItem::GetSavedDocuments() const
+{
+ return m_pImpl->aSavedDocuments;
+}
+
+void SwMailMergeConfigItem::AddSavedDocument(OUString rName)
+{
+ const OUString* pDocs = m_pImpl->aSavedDocuments.getConstArray();
+ bool bFound = false;
+ for(sal_Int32 nDoc = 0; nDoc < m_pImpl->aSavedDocuments.getLength(); ++nDoc)
+ {
+ if(pDocs[nDoc] == rName)
+ {
+ bFound = true;
+ break;
+ }
+ }
+ if(!bFound)
+ {
+ m_pImpl->aSavedDocuments.realloc(m_pImpl->aSavedDocuments.getLength() + 1);
+ m_pImpl->aSavedDocuments[m_pImpl->aSavedDocuments.getLength() - 1] = rName;
+ }
+}
+
+sal_Bool SwMailMergeConfigItem::IsOutputToLetter()const
+{
+ return m_pImpl->bIsOutputToLetter || !IsMailAvailable();
+}
+
+void SwMailMergeConfigItem::SetOutputToLetter(sal_Bool bSet)
+{
+ if(m_pImpl->bIsOutputToLetter != bSet)
+ {
+ m_pImpl->bIsOutputToLetter = bSet;
+ m_pImpl->SetModified();
+ }
+}
+
+sal_Bool SwMailMergeConfigItem::IsIndividualGreeting(sal_Bool bInEMail) const
+{
+ return bInEMail ?
+ m_pImpl->bIsIndividualGreetingLineInMail :
+ m_pImpl->bIsIndividualGreetingLine;
+}
+
+void SwMailMergeConfigItem::SetIndividualGreeting(
+ sal_Bool bSet, sal_Bool bInEMail)
+{
+ if(bInEMail)
+ {
+ if(m_pImpl->bIsIndividualGreetingLineInMail != bSet)
+ {
+ m_pImpl->bIsIndividualGreetingLineInMail = bSet;
+ m_pImpl->SetModified();
+ }
+ }
+ else
+ {
+ if(m_pImpl->bIsIndividualGreetingLine != bSet)
+ {
+ m_pImpl->bIsIndividualGreetingLine = bSet;
+ m_pImpl->SetModified();
+ }
+ }
+}
+
+sal_Bool SwMailMergeConfigItem::IsGreetingLine(sal_Bool bInEMail) const
+{
+ return bInEMail ? m_pImpl->bIsGreetingLineInMail : m_pImpl->bIsGreetingLine;
+}
+
+void SwMailMergeConfigItem::SetGreetingLine(sal_Bool bSet, sal_Bool bInEMail)
+{
+ m_pImpl->bUserSettingWereOverwritten = sal_False;
+ if(bInEMail)
+ {
+ if(m_pImpl->bIsGreetingLineInMail != bSet)
+ {
+ m_pImpl->bIsGreetingLineInMail = bSet;
+ m_pImpl->SetModified();
+ }
+ }
+ else
+ {
+ if(m_pImpl->bIsGreetingLine != bSet)
+ {
+ m_pImpl->bIsGreetingLine = bSet;
+ m_pImpl->SetModified();
+ }
+ }
+}
+
+const Sequence< OUString> SwMailMergeConfigItem::GetGreetings(
+ Gender eType ) const
+{
+ return m_pImpl->GetGreetings(eType);
+}
+
+void SwMailMergeConfigItem::SetGreetings(
+ Gender eType, const Sequence< OUString>& rSetGreetings)
+{
+ m_pImpl->SetGreetings( eType, rSetGreetings);
+}
+
+sal_Int32 SwMailMergeConfigItem::GetCurrentGreeting(
+ SwMailMergeConfigItem::Gender eType) const
+{
+ return m_pImpl->GetCurrentGreeting(eType);
+}
+
+void SwMailMergeConfigItem::SetCurrentGreeting(Gender eType, sal_Int32 nIndex)
+{
+ m_pImpl->SetCurrentGreeting(eType, nIndex);
+}
+
+const OUString& SwMailMergeConfigItem::GetFemaleGenderValue() const
+{
+ return m_pImpl->sFemaleGenderValue;
+}
+
+void SwMailMergeConfigItem::SetFemaleGenderValue(const OUString rValue)
+{
+ if( m_pImpl->sFemaleGenderValue != rValue )
+ {
+ m_pImpl->sFemaleGenderValue = rValue;
+ m_pImpl->SetModified();
+ }
+}
+
+Sequence< OUString> SwMailMergeConfigItem::GetColumnAssignment(
+ const SwDBData& rDBData ) const
+{
+ Sequence< OUString> aRet;
+ ::std::vector<DBAddressDataAssignment>::iterator aAssignIter;
+ for(aAssignIter = m_pImpl->aAddressDataAssignments.begin();
+ aAssignIter != m_pImpl->aAddressDataAssignments.end(); ++aAssignIter)
+ {
+ if(aAssignIter->aDBData == rDBData)
+ {
+ aRet = aAssignIter->aDBColumnAssignments;
+ break;
+ }
+ }
+ return aRet;
+}
+
+// returns the name that is assigned as e-mail column of the current data base
+OUString SwMailMergeConfigItem::GetAssignedColumn(sal_uInt32 nColumn) const
+{
+ OUString sRet;
+ Sequence< OUString> aAssignment = GetColumnAssignment( m_pImpl->aDBData );
+ if(aAssignment.getLength() > sal::static_int_cast< sal_Int32, sal_uInt32>(nColumn) && !aAssignment[nColumn].isEmpty())
+ sRet = aAssignment[nColumn];
+ else if(nColumn < m_pImpl->m_AddressHeaderSA.Count())
+ sRet = m_pImpl->m_AddressHeaderSA.GetString(nColumn);
+ return sRet;
+}
+
+void SwMailMergeConfigItem::SetColumnAssignment( const SwDBData& rDBData,
+ const Sequence< OUString>& rList)
+{
+ ::std::vector<DBAddressDataAssignment>::iterator aAssignIter;
+ bool bFound = false;
+ for(aAssignIter = m_pImpl->aAddressDataAssignments.begin();
+ aAssignIter != m_pImpl->aAddressDataAssignments.end(); ++aAssignIter)
+ {
+ if(aAssignIter->aDBData == rDBData)
+ {
+ if(aAssignIter->aDBColumnAssignments != rList)
+ {
+ aAssignIter->aDBColumnAssignments = rList;
+ aAssignIter->bColumnAssignmentsChanged = true;
+ }
+ bFound = true;
+ break;
+ }
+ }
+ if(!bFound)
+ {
+ DBAddressDataAssignment aAssignment;
+ aAssignment.aDBData = rDBData;
+ aAssignment.aDBColumnAssignments = rList;
+ aAssignment.bColumnAssignmentsChanged = true;
+ m_pImpl->aAddressDataAssignments.push_back(aAssignment);
+ }
+ m_pImpl->SetModified();
+}
+
+bool SwMailMergeConfigItem::IsAddressFieldsAssigned() const
+{
+ bool bResult = true;
+ Reference< XResultSet> xResultSet = GetResultSet();
+ uno::Reference< XColumnsSupplier > xColsSupp( xResultSet, UNO_QUERY );
+ if(!xColsSupp.is())
+ return false;
+ uno::Reference<container::XNameAccess> xCols = xColsSupp->getColumns();
+
+ const ResStringArray& rHeaders = GetDefaultAddressHeaders();
+ Sequence< OUString> aAssignment =
+ GetColumnAssignment( GetCurrentDBData() );
+ const OUString* pAssignment = aAssignment.getConstArray();
+ const Sequence< OUString> aBlocks = GetAddressBlocks();
+
+ if(aBlocks.getLength() <= m_pImpl->GetCurrentAddressBlockIndex())
+ return false;
+ SwAddressIterator aIter(aBlocks[m_pImpl->GetCurrentAddressBlockIndex()]);
+ while(aIter.HasMore())
+ {
+ SwMergeAddressItem aItem = aIter.Next();
+ if(aItem.bIsColumn)
+ {
+ OUString sConvertedColumn = aItem.sText;
+ for(sal_uInt16 nColumn = 0;
+ nColumn < rHeaders.Count() && nColumn < aAssignment.getLength();
+ ++nColumn)
+ {
+ if (rHeaders.GetString(nColumn).equals(aItem.sText) &&
+ !pAssignment[nColumn].isEmpty())
+ {
+ sConvertedColumn = pAssignment[nColumn];
+ break;
+ }
+ }
+ //find out if the column exists in the data base
+ if(!xCols->hasByName(sConvertedColumn))
+ {
+ bResult = false;
+ break;
+ }
+ }
+ }
+ return bResult;
+}
+
+bool SwMailMergeConfigItem::IsGreetingFieldsAssigned() const
+{
+ bool bResult = true;
+
+ if(!IsIndividualGreeting(sal_False))
+ return true;
+
+ Reference< XResultSet> xResultSet = GetResultSet();
+ uno::Reference< XColumnsSupplier > xColsSupp( xResultSet, UNO_QUERY );
+ if(!xColsSupp.is())
+ return false;
+ const ResStringArray& rHeaders = GetDefaultAddressHeaders();
+ uno::Reference<container::XNameAccess> xCols = xColsSupp->getColumns();
+
+ Sequence< OUString> aAssignment =
+ GetColumnAssignment( GetCurrentDBData() );
+ const OUString* pAssignment = aAssignment.getConstArray();
+
+ const Sequence< OUString> rFemaleEntries = GetGreetings(SwMailMergeConfigItem::FEMALE);
+ sal_Int32 nCurrentFemale = GetCurrentGreeting(SwMailMergeConfigItem::FEMALE);
+ const Sequence< OUString> rMaleEntries = GetGreetings(SwMailMergeConfigItem::MALE);
+ sal_Int32 nCurrentMale = GetCurrentGreeting(SwMailMergeConfigItem::MALE);
+ OUString sMale, sFemale;
+ if(rFemaleEntries.getLength() > nCurrentFemale)
+ sFemale = rFemaleEntries[nCurrentFemale];
+ if(rMaleEntries.getLength() > nCurrentMale)
+ sMale = rMaleEntries[nCurrentMale];
+
+ OUString sAddress( sFemale );
+ sAddress += sMale;
+ SwAddressIterator aIter(sAddress);
+ while(aIter.HasMore())
+ {
+ SwMergeAddressItem aItem = aIter.Next();
+ if(aItem.bIsColumn)
+ {
+ OUString sConvertedColumn = aItem.sText;
+ for(sal_uInt16 nColumn = 0;
+ nColumn < rHeaders.Count() && nColumn < aAssignment.getLength();
+ ++nColumn)
+ {
+ if (rHeaders.GetString(nColumn).equals(aItem.sText) &&
+ !pAssignment[nColumn].isEmpty())
+ {
+ sConvertedColumn = pAssignment[nColumn];
+ break;
+ }
+ }
+ //find out if the column exists in the data base
+ if(!xCols->hasByName(sConvertedColumn))
+ {
+ bResult = false;
+ break;
+ }
+ }
+ }
+ return bResult;
+}
+
+OUString SwMailMergeConfigItem::GetMailDisplayName() const
+{
+ return m_pImpl->sMailDisplayName;
+}
+
+void SwMailMergeConfigItem::SetMailDisplayName(const OUString& rName)
+{
+ if(m_pImpl->sMailDisplayName != rName)
+ {
+ m_pImpl->sMailDisplayName = rName;
+ m_pImpl->SetModified();
+ }
+}
+
+OUString SwMailMergeConfigItem::GetMailAddress() const
+{
+ return m_pImpl->sMailAddress;
+}
+
+void SwMailMergeConfigItem::SetMailAddress(const OUString& rAddress)
+{
+ if(m_pImpl->sMailAddress != rAddress )
+ {
+ m_pImpl->sMailAddress = rAddress;
+ m_pImpl->SetModified();
+ }
+}
+
+sal_Bool SwMailMergeConfigItem::IsMailReplyTo() const
+{
+ return m_pImpl->bIsMailReplyTo;
+}
+
+void SwMailMergeConfigItem::SetMailReplyTo(sal_Bool bSet)
+{
+ if(m_pImpl->bIsMailReplyTo != bSet)
+ {
+ m_pImpl->bIsMailReplyTo = bSet;
+ m_pImpl->SetModified();
+ }
+}
+
+OUString SwMailMergeConfigItem::GetMailReplyTo() const
+{
+ return m_pImpl->sMailReplyTo;
+}
+
+void SwMailMergeConfigItem::SetMailReplyTo(const OUString& rReplyTo)
+{
+ if(m_pImpl->sMailReplyTo != rReplyTo)
+ {
+ m_pImpl->sMailReplyTo = rReplyTo;
+ m_pImpl->SetModified();
+ }
+}
+
+OUString SwMailMergeConfigItem::GetMailServer() const
+{
+ return m_pImpl->sMailServer;
+}
+
+void SwMailMergeConfigItem::SetMailServer(const OUString& rAddress)
+{
+ if(m_pImpl->sMailServer != rAddress)
+ {
+ m_pImpl->sMailServer = rAddress;
+ m_pImpl->SetModified();
+ }
+}
+
+sal_Int16 SwMailMergeConfigItem::GetMailPort() const
+{
+ return m_pImpl->bIsDefaultPort ?
+ (m_pImpl->bIsSecureConnection ? SECURE_PORT : DEFAULT_PORT) :
+ m_pImpl->nMailPort;
+}
+
+void SwMailMergeConfigItem::SetMailPort(sal_Int16 nSet)
+{
+ if(m_pImpl->nMailPort != nSet || m_pImpl->bIsDefaultPort)
+ {
+ m_pImpl->nMailPort = nSet;
+ m_pImpl->bIsDefaultPort = sal_False;
+ m_pImpl->SetModified();
+ }
+}
+
+sal_Bool SwMailMergeConfigItem::IsSecureConnection() const
+{
+ return m_pImpl->bIsSecureConnection;
+}
+
+void SwMailMergeConfigItem::SetSecureConnection(sal_Bool bSet)
+{
+ if(m_pImpl->bIsSecureConnection != bSet)
+ {
+ m_pImpl->bIsSecureConnection = bSet;
+ m_pImpl->SetModified();
+ }
+}
+
+sal_Bool SwMailMergeConfigItem::IsAuthentication() const
+{
+ return m_pImpl->bIsAuthentication;
+}
+
+void SwMailMergeConfigItem::SetAuthentication(sal_Bool bSet)
+{
+ if(m_pImpl->bIsAuthentication != bSet)
+ {
+ m_pImpl->bIsAuthentication = bSet;
+ m_pImpl->SetModified();
+ }
+}
+
+OUString SwMailMergeConfigItem::GetMailUserName() const
+{
+ return m_pImpl->sMailUserName;
+}
+
+void SwMailMergeConfigItem::SetMailUserName(const OUString& rName)
+{
+ if(m_pImpl->sMailUserName != rName)
+ {
+ m_pImpl->sMailUserName = rName;
+ m_pImpl->SetModified();
+ }
+}
+
+OUString SwMailMergeConfigItem::GetMailPassword() const
+{
+ return m_pImpl->sMailPassword;
+}
+
+void SwMailMergeConfigItem::SetMailPassword(const OUString& rPassword)
+{
+ if(m_pImpl->sMailPassword != rPassword)
+ {
+ m_pImpl->sMailPassword = rPassword;
+ m_pImpl->SetModified();
+ }
+}
+
+sal_Bool SwMailMergeConfigItem::IsSMTPAfterPOP() const
+{
+ return m_pImpl->bIsSMPTAfterPOP;
+}
+
+void SwMailMergeConfigItem::SetSMTPAfterPOP(sal_Bool bSet)
+{
+ if( m_pImpl->bIsSMPTAfterPOP != bSet)
+ {
+ m_pImpl->bIsSMPTAfterPOP = bSet;
+ m_pImpl->SetModified();
+ }
+}
+
+OUString SwMailMergeConfigItem::GetInServerName() const
+{
+ return m_pImpl->sInServerName;
+}
+
+void SwMailMergeConfigItem::SetInServerName(const OUString& rServer)
+{
+ if(m_pImpl->sInServerName != rServer)
+ {
+ m_pImpl->sInServerName = rServer;
+ m_pImpl->SetModified();
+ }
+}
+
+sal_Int16 SwMailMergeConfigItem::GetInServerPort() const
+{
+ return m_pImpl->nInServerPort;
+}
+
+void SwMailMergeConfigItem::SetInServerPort(sal_Int16 nSet)
+{
+ if( m_pImpl->nInServerPort != nSet)
+ {
+ m_pImpl->nInServerPort = nSet;
+ m_pImpl->SetModified();
+ }
+}
+
+sal_Bool SwMailMergeConfigItem::IsInServerPOP() const
+{
+ return m_pImpl->bInServerPOP;
+}
+
+void SwMailMergeConfigItem::SetInServerPOP(sal_Bool bSet)
+{
+ if( m_pImpl->bInServerPOP != bSet)
+ {
+ m_pImpl->bInServerPOP = bSet;
+ m_pImpl->SetModified();
+ }
+}
+
+OUString SwMailMergeConfigItem::GetInServerUserName() const
+{
+ return m_pImpl->sInServerUserName;
+}
+
+void SwMailMergeConfigItem::SetInServerUserName(const OUString& rName)
+{
+ if( m_pImpl->sInServerUserName != rName)
+ {
+ m_pImpl->sInServerUserName = rName;
+ m_pImpl->SetModified();
+ }
+}
+
+OUString SwMailMergeConfigItem::GetInServerPassword() const
+{
+ return m_pImpl->sInServerPassword;
+}
+
+void SwMailMergeConfigItem::SetInServerPassword(const OUString& rPassword)
+{
+ if(m_pImpl->sInServerPassword != rPassword)
+ {
+ m_pImpl->sInServerPassword = rPassword;
+ m_pImpl->SetModified();
+ }
+}
+
+void SwMailMergeConfigItem::DocumentReloaded()
+{
+ m_bMergeDone = false;
+ m_bGreetingInserted = false;
+ m_bAddressInserted = false;
+ m_rAddressBlockFrame = OUString();
+}
+
+bool SwMailMergeConfigItem::IsMailAvailable() const
+{
+ return m_pImpl->bIsEMailSupported;
+}
+
+void SwMailMergeConfigItem::AddMergedDocument(SwDocMergeInfo& rInfo)
+{
+ m_pImpl->aMergeInfos.push_back(rInfo);
+}
+
+SwDocMergeInfo& SwMailMergeConfigItem::GetDocumentMergeInfo(sal_uInt32 nDocument)
+{
+ OSL_ENSURE(m_pImpl->aMergeInfos.size() > nDocument,"invalid document index");
+ return m_pImpl->aMergeInfos[nDocument];
+}
+
+sal_uInt32 SwMailMergeConfigItem::GetMergedDocumentCount() const
+{
+ return m_pImpl->aMergeInfos.size();
+}
+
+static SwView* lcl_ExistsView(SwView* pView)
+{
+ const TypeId aType(TYPE(SwView));
+ SfxViewShell* pViewShell = SfxViewShell::GetFirst( &aType, sal_False );
+ while(pViewShell)
+ {
+ if(pViewShell == pView)
+ return pView;
+
+ pViewShell = SfxViewShell::GetNext( *pViewShell, &aType, sal_False );
+ }
+ return 0;
+}
+
+SwView* SwMailMergeConfigItem::GetTargetView()
+{
+ //make sure that the pointer is really valid - the document may have been closed manually
+ if(m_pTargetView)
+ {
+ m_pTargetView = lcl_ExistsView(m_pTargetView);
+ }
+ return m_pTargetView;
+}
+
+void SwMailMergeConfigItem::SetTargetView(SwView* pView)
+{
+ m_pTargetView = pView;
+ //reset the document merge counter
+ if(!m_pTargetView)
+ {
+ m_pImpl->aMergeInfos.clear();
+ }
+}
+
+SwView* SwMailMergeConfigItem::GetSourceView()
+{
+ m_pSourceView = lcl_ExistsView(m_pSourceView);
+ return m_pSourceView;
+}
+
+void SwMailMergeConfigItem::SetSourceView(SwView* pView)
+{
+ m_pSourceView = pView;
+
+ if(pView)
+ {
+ std::vector<OUString> aDBNameList;
+ std::vector<OUString> aAllDBNames;
+ pView->GetWrtShell().GetAllUsedDB( aDBNameList, &aAllDBNames );
+ if(!aDBNameList.empty())
+ {
+ // if fields are available there is usually no need of an addressblock and greeting
+ if(!m_pImpl->bUserSettingWereOverwritten)
+ {
+ if( m_pImpl->bIsAddressBlock == sal_True
+ || m_pImpl->bIsGreetingLineInMail == sal_True
+ || m_pImpl->bIsGreetingLine == sal_True )
+ {
+ //store user settings
+ m_pImpl->bUserSettingWereOverwritten = sal_True;
+ m_pImpl->bIsAddressBlock_LastUserSetting = m_pImpl->bIsAddressBlock;
+ m_pImpl->bIsGreetingLineInMail_LastUserSetting = m_pImpl->bIsGreetingLineInMail;
+ m_pImpl->bIsGreetingLine_LastUserSetting = m_pImpl->bIsGreetingLine;
+
+ //set all to false
+ m_pImpl->bIsAddressBlock = sal_False;
+ m_pImpl->bIsGreetingLineInMail = sal_False;
+ m_pImpl->bIsGreetingLine = sal_False;
+
+ m_pImpl->SetModified();
+ }
+ }
+ }
+ else if( m_pImpl->bUserSettingWereOverwritten )
+ {
+ //restore last user settings:
+ m_pImpl->bIsAddressBlock = m_pImpl->bIsAddressBlock_LastUserSetting;
+ m_pImpl->bIsGreetingLineInMail = m_pImpl->bIsGreetingLineInMail_LastUserSetting;
+ m_pImpl->bIsGreetingLine = m_pImpl->bIsGreetingLine_LastUserSetting;
+
+ m_pImpl->bUserSettingWereOverwritten = sal_False;
+ }
+ }
+}
+
+void SwMailMergeConfigItem::SetCurrentAddressBlockIndex( sal_Int32 nSet )
+{
+ m_pImpl->SetCurrentAddressBlockIndex( nSet );
+}
+
+sal_Int32 SwMailMergeConfigItem::GetCurrentAddressBlockIndex() const
+{
+ return m_pImpl->GetCurrentAddressBlockIndex();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/dbui/swdbtoolsclient.cxx b/sw/source/core/uibase/dbui/swdbtoolsclient.cxx
new file mode 100644
index 000000000000..9fdc6a3ce930
--- /dev/null
+++ b/sw/source/core/uibase/dbui/swdbtoolsclient.cxx
@@ -0,0 +1,232 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#include <com/sun/star/sdb/SQLContext.hpp>
+#include <swdbtoolsclient.hxx>
+#include <osl/diagnose.h>
+#include <tools/solar.h>
+
+using namespace ::connectivity::simple;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdb;
+
+//= SwDbtoolsClient
+
+namespace
+{
+
+ // this namespace contains access to all static members of the class SwDbtoolsClient
+ // to make the initialize of the dll a little bit faster
+
+ ::osl::Mutex& getDbtoolsClientMutex()
+ {
+ static ::osl::Mutex aMutex;
+ return aMutex;
+ }
+
+ sal_Int32& getDbToolsClientClients()
+ {
+ static sal_Int32 nClients = 0;
+ return nClients;
+ }
+
+ oslModule& getDbToolsClientModule()
+ {
+ static oslModule hDbtoolsModule = NULL;
+ return hDbtoolsModule;
+ }
+
+ createDataAccessToolsFactoryFunction& getDbToolsClientFactoryFunction()
+ {
+ static createDataAccessToolsFactoryFunction pFactoryCreationFunc = NULL;
+ return pFactoryCreationFunc;
+ }
+
+}
+
+SwDbtoolsClient::SwDbtoolsClient()
+{
+}
+
+SwDbtoolsClient::~SwDbtoolsClient()
+{
+ if(m_xDataAccessFactory.is())
+ {
+ // clear the factory _before_ revoking the client
+ // (the revocation may unload the DBT lib)
+ m_xDataAccessFactory = NULL;
+ // revoke the client
+ revokeClient();
+ }
+}
+
+#ifndef DISABLE_DYNLOADING
+
+extern "C" { static void SAL_CALL thisModule() {} }
+
+#else
+
+extern "C" void * createDataAccessToolsFactory();
+
+#endif
+
+void SwDbtoolsClient::registerClient()
+{
+ ::osl::MutexGuard aGuard(getDbtoolsClientMutex());
+ if (1 == ++getDbToolsClientClients())
+ {
+ OSL_ENSURE(NULL == getDbToolsClientModule(), "SwDbtoolsClient::registerClient: inconsistence: already have a module!");
+ OSL_ENSURE(NULL == getDbToolsClientFactoryFunction(), "SwDbtoolsClient::registerClient: inconsistence: already have a factory function!");
+
+#ifndef DISABLE_DYNLOADING
+ const OUString sModuleName(SVLIBRARY("dbtools"));
+
+ // load the dbtools library
+ getDbToolsClientModule() = osl_loadModuleRelative(
+ &thisModule, sModuleName.pData, 0);
+ OSL_ENSURE(NULL != getDbToolsClientModule(), "SwDbtoolsClient::registerClient: could not load the dbtools library!");
+ if (NULL != getDbToolsClientModule())
+ {
+ // get the symbol for the method creating the factory
+ const OUString sFactoryCreationFunc("createDataAccessToolsFactory");
+ // reinterpret_cast<createDataAccessToolsFactoryFunction> removed for gcc permissive
+ getDbToolsClientFactoryFunction() = reinterpret_cast< createDataAccessToolsFactoryFunction >(
+ osl_getFunctionSymbol(getDbToolsClientModule(), sFactoryCreationFunc.pData));
+
+ if (NULL == getDbToolsClientFactoryFunction())
+ { // did not find the symbol
+ OSL_FAIL("SwDbtoolsClient::registerClient: could not find the symbol for creating the factory!");
+ osl_unloadModule(getDbToolsClientModule());
+ getDbToolsClientModule() = NULL;
+ }
+ }
+#else
+ getDbToolsClientFactoryFunction() = createDataAccessToolsFactory;
+#endif
+ }
+}
+
+void SwDbtoolsClient::revokeClient()
+{
+ ::osl::MutexGuard aGuard(getDbtoolsClientMutex());
+ if (0 == --getDbToolsClientClients())
+ {
+#ifndef DISABLE_DYNLOADING
+ getDbToolsClientFactoryFunction() = NULL;
+ if (getDbToolsClientModule())
+ osl_unloadModule(getDbToolsClientModule());
+#endif
+ getDbToolsClientModule() = NULL;
+ }
+}
+
+void SwDbtoolsClient::getFactory()
+{
+ if(!m_xDataAccessFactory.is())
+ {
+ registerClient();
+ if(getDbToolsClientFactoryFunction())
+ { // loading the lib succeeded
+ void* pUntypedFactory = (*getDbToolsClientFactoryFunction())();
+ IDataAccessToolsFactory* pDBTFactory = static_cast<IDataAccessToolsFactory*>(pUntypedFactory);
+ OSL_ENSURE(pDBTFactory, "SwDbtoolsClient::SwDbtoolsClient: no factory returned!");
+ if (pDBTFactory)
+ {
+ m_xDataAccessFactory = pDBTFactory;
+ // by definition, the factory was aquired once
+ m_xDataAccessFactory->release();
+ }
+ }
+ }
+}
+
+::rtl::Reference< ::connectivity::simple::IDataAccessTools >
+ SwDbtoolsClient::getDataAccessTools()
+{
+ if(!m_xDataAccessTools.is())
+ {
+ getFactory();
+ if(m_xDataAccessFactory.is())
+ m_xDataAccessTools = m_xDataAccessFactory->getDataAccessTools();
+ }
+ return m_xDataAccessTools;
+}
+
+::rtl::Reference< ::connectivity::simple::IDataAccessTypeConversion >
+ SwDbtoolsClient::getAccessTypeConversion()
+{
+ if(!m_xAccessTypeConversion.is())
+ {
+ getFactory();
+ if(m_xDataAccessFactory.is())
+ m_xAccessTypeConversion = m_xDataAccessFactory->getTypeConversionHelper();
+ }
+ return m_xAccessTypeConversion;
+}
+
+Reference< XDataSource > SwDbtoolsClient::getDataSource(
+ const OUString& rRegisteredName,
+ const Reference<XComponentContext>& rxContext
+ )
+{
+ Reference< XDataSource > xRet;
+ ::rtl::Reference< ::connectivity::simple::IDataAccessTools > xAccess = getDataAccessTools();
+ if(xAccess.is())
+ xRet = xAccess->getDataSource(rRegisteredName, rxContext);
+ return xRet;
+}
+
+sal_Int32 SwDbtoolsClient::getDefaultNumberFormat(
+ const Reference< XPropertySet >& rxColumn,
+ const Reference< XNumberFormatTypes >& rxTypes,
+ const lang::Locale& rLocale
+ )
+{
+ sal_Int32 nRet = -1;
+ ::rtl::Reference< ::connectivity::simple::IDataAccessTools > xAccess = getDataAccessTools();
+ if(xAccess.is())
+ nRet = xAccess->getDefaultNumberFormat( rxColumn, rxTypes, rLocale);
+ return nRet;
+}
+
+OUString SwDbtoolsClient::getFormattedValue(
+ const uno::Reference< beans::XPropertySet>& _rxColumn,
+ const uno::Reference< util::XNumberFormatter>& _rxFormatter,
+ const lang::Locale& _rLocale,
+ const util::Date& _rNullDate
+ )
+
+{
+ ::rtl::Reference< ::connectivity::simple::IDataAccessTypeConversion > xConversion =
+ getAccessTypeConversion();
+ OUString sRet;
+ if(xConversion.is())
+ sRet = xConversion->getFormattedValue(_rxColumn, _rxFormatter, _rLocale, _rNullDate);
+ return sRet;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/dialog/SwSpellDialogChildWindow.cxx b/sw/source/core/uibase/dialog/SwSpellDialogChildWindow.cxx
new file mode 100644
index 000000000000..a9a7c503a3e3
--- /dev/null
+++ b/sw/source/core/uibase/dialog/SwSpellDialogChildWindow.cxx
@@ -0,0 +1,843 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <SwSpellDialogChildWindow.hxx>
+#include <vcl/msgbox.hxx>
+#include <editeng/svxacorr.hxx>
+#include <editeng/acorrcfg.hxx>
+#include <svx/svxids.hrc>
+#include <sfx2/app.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#include <editeng/unolingu.hxx>
+#include <editeng/editeng.hxx>
+#include <editeng/editview.hxx>
+#include <wrtsh.hxx>
+#include <sfx2/printer.hxx>
+#include <svx/svdoutl.hxx>
+#include <svx/svdview.hxx>
+#include <svx/svditer.hxx>
+#include <svx/svdogrp.hxx>
+#include <unotools/linguprops.hxx>
+#include <unotools/lingucfg.hxx>
+#include <doc.hxx>
+#include <docsh.hxx>
+#include <docary.hxx>
+#include <frmfmt.hxx>
+#include <dcontact.hxx>
+#include <edtwin.hxx>
+#include <pam.hxx>
+#include <drawbase.hxx>
+#include <unotextrange.hxx>
+#include <dialog.hrc>
+#include <cmdid.h>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::text;
+using namespace ::com::sun::star::linguistic2;
+using namespace ::com::sun::star::beans;
+
+SFX_IMPL_CHILDWINDOW_WITHID(SwSpellDialogChildWindow, FN_SPELL_GRAMMAR_DIALOG)
+
+#define SPELL_START_BODY 0 // body text area
+#define SPELL_START_OTHER 1 // frame, footnote, header, footer
+#define SPELL_START_DRAWTEXT 2 // started in a draw text object
+
+struct SpellState
+{
+ bool m_bInitialCall;
+ bool m_bLockFocus; // lock the focus notification while a modal dialog is active
+ bool m_bLostFocus;
+
+ // restart and progress information
+ sal_uInt16 m_SpellStartPosition;
+ bool m_bBodySpelled; // body already spelled
+ bool m_bOtherSpelled; // frames, footnotes, headers and footers spelled
+ bool m_bStartedInOther; // started the spelling insided of the _other_ area
+ bool m_bStartedInSelection; // there was an initial text selection
+ SwPaM* pOtherCursor; // position where the spelling inside the _other_ area started
+ bool m_bDrawingsSpelled; // all drawings spelled
+ Reference<XTextRange> m_xStartRange; // text range that marks the start of spelling
+ const SdrObject* m_pStartDrawing; // draw text object spelling started in
+ ESelection m_aStartDrawingSelection; // draw text start selection
+ bool m_bRestartDrawing; // the first selected drawing object is found again
+
+ // lose/get focus information to decide if spelling can be continued
+ ShellModes m_eSelMode;
+ const SwNode* m_pPointNode;
+ const SwNode* m_pMarkNode;
+ sal_Int32 m_nPointPos;
+ sal_Int32 m_nMarkPos;
+ const SdrOutliner* m_pOutliner;
+ ESelection m_aESelection;
+
+ // iterating over draw text objects
+ std::list<SdrTextObj*> m_aTextObjects;
+ bool m_bTextObjectsCollected;
+
+ SpellState() :
+ m_bInitialCall(true),
+ m_bLockFocus(false),
+ m_bLostFocus(false),
+ m_SpellStartPosition(SPELL_START_BODY),
+ m_bBodySpelled(false),
+ m_bOtherSpelled(false),
+ m_bStartedInOther(false),
+ m_bStartedInSelection(false),
+ pOtherCursor(0),
+ m_bDrawingsSpelled(false),
+ m_pStartDrawing(0),
+ m_bRestartDrawing(false),
+
+ m_eSelMode(SHELL_MODE_OBJECT), // initially invalid
+ m_pPointNode(0),
+ m_pMarkNode(0),
+ m_nPointPos(0),
+ m_nMarkPos(0),
+ m_pOutliner(0),
+ m_bTextObjectsCollected(false)
+ {}
+
+ ~SpellState() {delete pOtherCursor;}
+
+ // reset state in ::InvalidateSpellDialog
+ void Reset()
+ { m_bInitialCall = true;
+ m_bBodySpelled = m_bOtherSpelled = m_bDrawingsSpelled = false;
+ m_xStartRange = 0;
+ m_pStartDrawing = 0;
+ m_bRestartDrawing = false;
+ m_bTextObjectsCollected = false;
+ m_aTextObjects.clear();
+ m_bStartedInOther = false;
+ delete pOtherCursor;
+ pOtherCursor = 0;
+ }
+};
+
+static void lcl_LeaveDrawText(SwWrtShell& rSh)
+{
+ if(rSh.GetDrawView())
+ {
+ rSh.GetDrawView()->SdrEndTextEdit( sal_True );
+ Point aPt(LONG_MIN, LONG_MIN);
+ // go out of the frame
+ rSh.SelectObj(aPt, SW_LEAVE_FRAME);
+ rSh.EnterStdMode();
+ rSh.GetView().AttrChangedNotify(&rSh);
+ }
+}
+
+SwSpellDialogChildWindow::SwSpellDialogChildWindow (
+ Window* _pParent,
+ sal_uInt16 nId,
+ SfxBindings* pBindings,
+ SfxChildWinInfo* pInfo) :
+ svx::SpellDialogChildWindow (
+ _pParent, nId, pBindings, pInfo),
+ m_pSpellState(new SpellState)
+{
+ OUString aPropName(UPN_IS_GRAMMAR_INTERACTIVE);
+ SvtLinguConfig().GetProperty( aPropName ) >>= m_bIsGrammarCheckingOn;
+}
+
+SwSpellDialogChildWindow::~SwSpellDialogChildWindow ()
+{
+ SwWrtShell* pWrtShell = GetWrtShell_Impl();
+ if(!m_pSpellState->m_bInitialCall && pWrtShell)
+ pWrtShell->SpellEnd();
+ delete m_pSpellState;
+}
+
+SfxChildWinInfo SwSpellDialogChildWindow::GetInfo (void) const
+{
+ SfxChildWinInfo aInfo = svx::SpellDialogChildWindow::GetInfo();
+ aInfo.bVisible = sal_False;
+ return aInfo;
+}
+
+svx::SpellPortions SwSpellDialogChildWindow::GetNextWrongSentence(bool bRecheck)
+{
+ svx::SpellPortions aRet;
+ SwWrtShell* pWrtShell = GetWrtShell_Impl();
+ if(pWrtShell)
+ {
+ if (!bRecheck)
+ {
+ // first set continuation point for spell/grammar check to the
+ // end of the current sentence
+ pWrtShell->MoveContinuationPosToEndOfCheckedSentence();
+ }
+
+ ShellModes eSelMode = pWrtShell->GetView().GetShellMode();
+ bool bDrawText = SHELL_MODE_DRAWTEXT == eSelMode;
+ bool bNormalText =
+ SHELL_MODE_TABLE_TEXT == eSelMode ||
+ SHELL_MODE_LIST_TEXT == eSelMode ||
+ SHELL_MODE_TABLE_LIST_TEXT == eSelMode ||
+ SHELL_MODE_TEXT == eSelMode;
+ // Writer text outside of the body
+ bool bOtherText = false;
+
+ if( m_pSpellState->m_bInitialCall )
+ {
+ // if no text selection exists the cursor has to be set into the text
+ if(!bDrawText && !bNormalText)
+ {
+ if(!MakeTextSelection_Impl(*pWrtShell, eSelMode))
+ return aRet;
+ else
+ {
+ // the selection type has to be checked again - both text types are possible
+ if(0 != (pWrtShell->GetSelectionType()& nsSelectionType::SEL_DRW_TXT))
+ bDrawText = true;
+ bNormalText = !bDrawText;
+ }
+ }
+ if(bNormalText)
+ {
+ // set cursor to the start of the sentence
+ if(!pWrtShell->HasSelection())
+ pWrtShell->GoStartSentence();
+ else
+ {
+ pWrtShell->ExpandToSentenceBorders();
+ m_pSpellState->m_bStartedInSelection = true;
+ }
+ // determine if the selection is outside of the body text
+ bOtherText = !(pWrtShell->GetFrmType(0,sal_True) & FRMTYPE_BODY);
+ m_pSpellState->m_SpellStartPosition = bOtherText ? SPELL_START_OTHER : SPELL_START_BODY;
+ if(bOtherText)
+ {
+ m_pSpellState->pOtherCursor = new SwPaM(*pWrtShell->GetCrsr()->GetPoint());
+ m_pSpellState->m_bStartedInOther = true;
+ pWrtShell->SpellStart( DOCPOS_OTHERSTART, DOCPOS_OTHEREND, DOCPOS_CURR );
+ }
+ else
+ {
+ SwPaM* pCrsr = pWrtShell->GetCrsr();
+ // mark the start position only if not at start of doc
+ if(!pWrtShell->IsStartOfDoc())
+ {
+ m_pSpellState->m_xStartRange =
+ SwXTextRange::CreateXTextRange(
+ *pWrtShell->GetDoc(),
+ *pCrsr->Start(), pCrsr->End());
+ }
+ pWrtShell->SpellStart( DOCPOS_START, DOCPOS_END, DOCPOS_CURR );
+ }
+ }
+ else
+ {
+ SdrView* pSdrView = pWrtShell->GetDrawView();
+ m_pSpellState->m_SpellStartPosition = SPELL_START_DRAWTEXT;
+ m_pSpellState->m_pStartDrawing = pSdrView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
+ OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
+ // start checking at the top of the drawing object
+ pOLV->SetSelection( ESelection() );
+ m_pSpellState->m_aStartDrawingSelection = ESelection();
+/*
+Note: spelling in a selection only, or starting in a mid of a drawing object requires
+further changes elsewhere. (Especially if it should work in sc and sd as well.)
+The code below would only be part of the solution.
+(Keeping it a as a comment for the time being)
+ ESelection aCurSel( pOLV->GetSelection() );
+ ESelection aSentenceSel( pOLV->GetEditView().GetEditEngine()->SelectSentence( aCurSel ) );
+ if (!aCurSel.HasRange())
+ {
+ aSentenceSel.nEndPara = aSentenceSel.nStartPara;
+ aSentenceSel.nEndPos = aSentenceSel.nStartPos;
+ }
+ pOLV->SetSelection( aSentenceSel );
+ m_pSpellState->m_aStartDrawingSelection = aSentenceSel;
+*/
+ }
+
+ m_pSpellState->m_bInitialCall = false;
+ }
+ if( bDrawText )
+ {
+ // spell inside of the current draw text
+ if(!SpellDrawText_Impl(*pWrtShell, aRet))
+ {
+ if(!FindNextDrawTextError_Impl(*pWrtShell) || !SpellDrawText_Impl(*pWrtShell, aRet))
+ {
+ lcl_LeaveDrawText(*pWrtShell);
+ // now the drawings have been spelled
+ m_pSpellState->m_bDrawingsSpelled = true;
+ // the spelling continues at the other content
+ // if there's any that has not been spelled yet
+ if(!m_pSpellState->m_bOtherSpelled && pWrtShell->HasOtherCnt())
+ {
+ pWrtShell->SpellStart(DOCPOS_OTHERSTART, DOCPOS_OTHEREND, DOCPOS_OTHERSTART );
+ if(!pWrtShell->SpellSentence(aRet, m_bIsGrammarCheckingOn))
+ {
+ pWrtShell->SpellEnd();
+ m_pSpellState->m_bOtherSpelled = true;
+ }
+ }
+ else
+ m_pSpellState->m_bOtherSpelled = true;
+ // if no result has been found try at the body text - completely
+ if(!m_pSpellState->m_bBodySpelled && !aRet.size())
+ {
+ pWrtShell->SpellStart(DOCPOS_START, DOCPOS_END, DOCPOS_START );
+ if(!pWrtShell->SpellSentence(aRet, m_bIsGrammarCheckingOn))
+ {
+ m_pSpellState->m_bBodySpelled = true;
+ pWrtShell->SpellEnd();
+ }
+ }
+
+ }
+ }
+ }
+ else
+ {
+ // spell inside of the Writer text
+ if(!pWrtShell->SpellSentence(aRet, m_bIsGrammarCheckingOn))
+ {
+ // if there is a selection (within body or header/footer text)
+ // then spell/grammar checking should not move outside of it.
+ if (!m_pSpellState->m_bStartedInSelection)
+ {
+ // find out which text has been spelled body or other
+ bOtherText = !(pWrtShell->GetFrmType(0,sal_True) & FRMTYPE_BODY);
+ if(bOtherText && m_pSpellState->m_bStartedInOther && m_pSpellState->pOtherCursor)
+ {
+ m_pSpellState->m_bStartedInOther = false;
+ pWrtShell->SetSelection(*m_pSpellState->pOtherCursor);
+ pWrtShell->SpellEnd();
+ delete m_pSpellState->pOtherCursor;
+ m_pSpellState->pOtherCursor = 0;
+ pWrtShell->SpellStart(DOCPOS_OTHERSTART, DOCPOS_CURR, DOCPOS_OTHERSTART );
+ pWrtShell->SpellSentence(aRet, m_bIsGrammarCheckingOn);
+ }
+ if(!aRet.size())
+ {
+ // end spelling
+ pWrtShell->SpellEnd();
+ if(bOtherText)
+ {
+ m_pSpellState->m_bOtherSpelled = true;
+ // has the body been spelled?
+ if(!m_pSpellState->m_bBodySpelled)
+ {
+ pWrtShell->SpellStart(DOCPOS_START, DOCPOS_END, DOCPOS_START );
+ if(!pWrtShell->SpellSentence(aRet, m_bIsGrammarCheckingOn))
+ {
+ m_pSpellState->m_bBodySpelled = true;
+ pWrtShell->SpellEnd();
+ }
+ }
+ }
+ else
+ {
+ m_pSpellState->m_bBodySpelled = true;
+ if(!m_pSpellState->m_bOtherSpelled && pWrtShell->HasOtherCnt())
+ {
+ pWrtShell->SpellStart(DOCPOS_OTHERSTART, DOCPOS_OTHEREND, DOCPOS_OTHERSTART );
+ if(!pWrtShell->SpellSentence(aRet, m_bIsGrammarCheckingOn))
+ {
+ pWrtShell->SpellEnd();
+ m_pSpellState->m_bOtherSpelled = true;
+ }
+ }
+ else
+ m_pSpellState->m_bOtherSpelled = true;
+ }
+ }
+
+ // search for a draw text object that contains error and spell it
+ if(!aRet.size() &&
+ (m_pSpellState->m_bDrawingsSpelled ||
+ !FindNextDrawTextError_Impl(*pWrtShell) || !SpellDrawText_Impl(*pWrtShell, aRet)))
+ {
+ lcl_LeaveDrawText(*pWrtShell);
+ m_pSpellState->m_bDrawingsSpelled = true;
+ }
+ }
+ }
+ }
+ // now only the rest of the body text can be spelled -
+ // if the spelling started inside of the body
+ bool bCloseMessage = true;
+ if(!aRet.size() && !m_pSpellState->m_bStartedInSelection)
+ {
+ OSL_ENSURE(m_pSpellState->m_bDrawingsSpelled &&
+ m_pSpellState->m_bOtherSpelled && m_pSpellState->m_bBodySpelled,
+ "not all parts of the document are already spelled");
+ if(m_pSpellState->m_xStartRange.is())
+ {
+ LockFocusNotification( true );
+ sal_uInt16 nRet = QueryBox( GetWindow(), SW_RES(RID_QB_SPELL_CONTINUE)).Execute();
+ if(RET_YES == nRet)
+ {
+ SwUnoInternalPaM aPam(*pWrtShell->GetDoc());
+ if (::sw::XTextRangeToSwPaM(aPam,
+ m_pSpellState->m_xStartRange))
+ {
+ pWrtShell->SetSelection(aPam);
+ pWrtShell->SpellStart(DOCPOS_START, DOCPOS_CURR, DOCPOS_START);
+ if(!pWrtShell->SpellSentence(aRet, m_bIsGrammarCheckingOn))
+ pWrtShell->SpellEnd();
+ }
+ m_pSpellState->m_xStartRange = 0;
+ LockFocusNotification( false );
+ // take care that the now valid selection is stored
+ LoseFocus();
+ }
+ else
+ bCloseMessage = false; // no closing message if a wrap around has been denied
+ }
+ }
+ if(!aRet.size())
+ {
+ if(bCloseMessage)
+ {
+ LockFocusNotification( true );
+ OUString sInfo(SW_RES(STR_SPELLING_COMPLETED));
+ // #i84610#
+ Window* pTemp = GetWindow(); // temporary needed for g++ 3.3.5
+ InfoBox(pTemp, sInfo ).Execute();
+ LockFocusNotification( false );
+ // take care that the now valid selection is stored
+ LoseFocus();
+ }
+
+ // close the spelling dialog
+ GetBindings().GetDispatcher()->Execute(FN_SPELL_GRAMMAR_DIALOG, SFX_CALLMODE_ASYNCHRON);
+ }
+ }
+ return aRet;
+
+}
+
+void SwSpellDialogChildWindow::ApplyChangedSentence(const svx::SpellPortions& rChanged, bool bRecheck)
+{
+ SwWrtShell* pWrtShell = GetWrtShell_Impl();
+ OSL_ENSURE(!m_pSpellState->m_bInitialCall, "ApplyChangedSentence in initial call or after resume");
+ if(pWrtShell && !m_pSpellState->m_bInitialCall)
+ {
+ ShellModes eSelMode = pWrtShell->GetView().GetShellMode();
+ bool bDrawText = SHELL_MODE_DRAWTEXT == eSelMode;
+ bool bNormalText =
+ SHELL_MODE_TABLE_TEXT == eSelMode ||
+ SHELL_MODE_LIST_TEXT == eSelMode ||
+ SHELL_MODE_TABLE_LIST_TEXT == eSelMode ||
+ SHELL_MODE_TEXT == eSelMode;
+
+ // evaluate if the same sentence should be rechecked or not.
+ // Sentences that got grammar checked should always be rechecked in order
+ // to detect possible errors that get introduced with the changes
+ bRecheck |= pWrtShell->HasLastSentenceGotGrammarChecked();
+
+ if(bNormalText)
+ pWrtShell->ApplyChangedSentence(rChanged, bRecheck);
+ else if(bDrawText )
+ {
+ SdrView* pDrView = pWrtShell->GetDrawView();
+ SdrOutliner *pOutliner = pDrView->GetTextEditOutliner();
+ pOutliner->ApplyChangedSentence(pDrView->GetTextEditOutlinerView()->GetEditView(), rChanged, bRecheck);
+ }
+ }
+}
+
+void SwSpellDialogChildWindow::AddAutoCorrection(
+ const OUString& rOld, const OUString& rNew, LanguageType eLanguage)
+{
+ SvxAutoCorrect* pACorr = SvxAutoCorrCfg::Get().GetAutoCorrect();
+ pACorr->PutText( rOld, rNew, eLanguage );
+}
+
+bool SwSpellDialogChildWindow::HasAutoCorrection()
+{
+ return true;
+}
+
+bool SwSpellDialogChildWindow::HasGrammarChecking()
+{
+ return SvtLinguConfig().HasGrammarChecker();
+}
+
+bool SwSpellDialogChildWindow::IsGrammarChecking()
+{
+ return m_bIsGrammarCheckingOn;
+}
+
+void SwSpellDialogChildWindow::SetGrammarChecking(bool bOn)
+{
+ uno::Any aVal;
+ aVal <<= bOn;
+ m_bIsGrammarCheckingOn = bOn;
+ OUString aPropName(UPN_IS_GRAMMAR_INTERACTIVE);
+ SvtLinguConfig().SetProperty( aPropName, aVal );
+ // set current spell position to the start of the current sentence to
+ // continue with this sentence after grammar checking state has been changed
+ SwWrtShell* pWrtShell = GetWrtShell_Impl();
+ if(pWrtShell)
+ {
+ ShellModes eSelMode = pWrtShell->GetView().GetShellMode();
+ bool bDrawText = SHELL_MODE_DRAWTEXT == eSelMode;
+ bool bNormalText =
+ SHELL_MODE_TABLE_TEXT == eSelMode ||
+ SHELL_MODE_LIST_TEXT == eSelMode ||
+ SHELL_MODE_TABLE_LIST_TEXT == eSelMode ||
+ SHELL_MODE_TEXT == eSelMode;
+ if( bNormalText )
+ pWrtShell->PutSpellingToSentenceStart();
+ else if( bDrawText )
+ {
+ SdrView* pSdrView = pWrtShell->GetDrawView();
+ SdrOutliner* pOutliner = pSdrView ? pSdrView->GetTextEditOutliner() : 0;
+ OSL_ENSURE(pOutliner, "No Outliner in SwSpellDialogChildWindow::SetGrammarChecking");
+ if(pOutliner)
+ {
+ pOutliner->PutSpellingToSentenceStart( pSdrView->GetTextEditOutlinerView()->GetEditView() );
+ }
+ }
+ }
+}
+
+void SwSpellDialogChildWindow::GetFocus()
+{
+ if(m_pSpellState->m_bLockFocus)
+ return;
+ bool bInvalidate = false;
+ SwWrtShell* pWrtShell = GetWrtShell_Impl();
+ if(pWrtShell && !m_pSpellState->m_bInitialCall)
+ {
+ ShellModes eSelMode = pWrtShell->GetView().GetShellMode();
+ if(eSelMode != m_pSpellState->m_eSelMode)
+ {
+ // prevent initial invalidation
+ if(m_pSpellState->m_bLostFocus)
+ bInvalidate = true;
+ }
+ else
+ {
+ switch(m_pSpellState->m_eSelMode)
+ {
+ case SHELL_MODE_TEXT:
+ case SHELL_MODE_LIST_TEXT:
+ case SHELL_MODE_TABLE_TEXT:
+ case SHELL_MODE_TABLE_LIST_TEXT:
+ {
+ SwPaM* pCursor = pWrtShell->GetCrsr();
+ if(m_pSpellState->m_pPointNode != pCursor->GetNode(true) ||
+ m_pSpellState->m_pMarkNode != pCursor->GetNode(false)||
+ m_pSpellState->m_nPointPos != pCursor->GetPoint()->nContent.GetIndex()||
+ m_pSpellState->m_nMarkPos != pCursor->GetMark()->nContent.GetIndex())
+ bInvalidate = true;
+ }
+ break;
+ case SHELL_MODE_DRAWTEXT:
+ {
+ SdrView* pSdrView = pWrtShell->GetDrawView();
+ SdrOutliner* pOutliner = pSdrView ? pSdrView->GetTextEditOutliner() : 0;
+ if(!pOutliner || m_pSpellState->m_pOutliner != pOutliner)
+ bInvalidate = true;
+ else
+ {
+ OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
+ OSL_ENSURE(pOLV, "no OutlinerView in SwSpellDialogChildWindow::GetFocus()");
+ if(!pOLV || !m_pSpellState->m_aESelection.IsEqual(pOLV->GetSelection()))
+ bInvalidate = true;
+ }
+ }
+ break;
+ default: bInvalidate = true;
+ }
+ }
+ }
+ else
+ {
+ bInvalidate = true;
+ }
+ if(bInvalidate)
+ InvalidateSpellDialog();
+}
+
+void SwSpellDialogChildWindow::LoseFocus()
+{
+ // prevent initial invalidation
+ m_pSpellState->m_bLostFocus = true;
+ if(m_pSpellState->m_bLockFocus)
+ return;
+ SwWrtShell* pWrtShell = GetWrtShell_Impl();
+ if(pWrtShell)
+ {
+ m_pSpellState->m_eSelMode = pWrtShell->GetView().GetShellMode();
+ m_pSpellState->m_pPointNode = m_pSpellState->m_pMarkNode = 0;
+ m_pSpellState->m_nPointPos = m_pSpellState->m_nMarkPos = 0;
+ m_pSpellState->m_pOutliner = 0;
+
+ switch(m_pSpellState->m_eSelMode)
+ {
+ case SHELL_MODE_TEXT:
+ case SHELL_MODE_LIST_TEXT:
+ case SHELL_MODE_TABLE_TEXT:
+ case SHELL_MODE_TABLE_LIST_TEXT:
+ {
+ // store a node pointer and a pam-position to be able to check on next GetFocus();
+ SwPaM* pCursor = pWrtShell->GetCrsr();
+ m_pSpellState->m_pPointNode = pCursor->GetNode(true);
+ m_pSpellState->m_pMarkNode = pCursor->GetNode(false);
+ m_pSpellState->m_nPointPos = pCursor->GetPoint()->nContent.GetIndex();
+ m_pSpellState->m_nMarkPos = pCursor->GetMark()->nContent.GetIndex();
+
+ }
+ break;
+ case SHELL_MODE_DRAWTEXT:
+ {
+ SdrView* pSdrView = pWrtShell->GetDrawView();
+ SdrOutliner* pOutliner = pSdrView->GetTextEditOutliner();
+ m_pSpellState->m_pOutliner = pOutliner;
+ OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
+ OSL_ENSURE(pOutliner && pOLV, "no Outliner/OutlinerView in SwSpellDialogChildWindow::LoseFocus()");
+ if(pOLV)
+ {
+ m_pSpellState->m_aESelection = pOLV->GetSelection();
+ }
+ }
+ break;
+ default:;// prevent warning
+ }
+ }
+ else
+ m_pSpellState->m_eSelMode = SHELL_MODE_OBJECT;
+}
+
+void SwSpellDialogChildWindow::InvalidateSpellDialog()
+{
+ SwWrtShell* pWrtShell = GetWrtShell_Impl();
+ if(!m_pSpellState->m_bInitialCall && pWrtShell)
+ pWrtShell->SpellEnd(0, false);
+ m_pSpellState->Reset();
+ svx::SpellDialogChildWindow::InvalidateSpellDialog();
+}
+
+SwWrtShell* SwSpellDialogChildWindow::GetWrtShell_Impl()
+{
+ SfxDispatcher* pDispatch = GetBindings().GetDispatcher();
+ SwView* pView = 0;
+ if(pDispatch)
+ {
+ sal_uInt16 nShellIdx = 0;
+ SfxShell* pShell;
+ while(0 != (pShell = pDispatch->GetShell(nShellIdx++)))
+ if(pShell->ISA(SwView))
+ {
+ pView = static_cast<SwView* >(pShell);
+ break;
+ }
+ }
+ return pView ? pView->GetWrtShellPtr(): 0;
+}
+
+// set the cursor into the body text - necessary if any object is selected
+// on start of the spelling dialog
+bool SwSpellDialogChildWindow::MakeTextSelection_Impl(SwWrtShell& rShell, ShellModes eSelMode)
+{
+ SwView& rView = rShell.GetView();
+ switch(eSelMode)
+ {
+ case SHELL_MODE_TEXT:
+ case SHELL_MODE_LIST_TEXT:
+ case SHELL_MODE_TABLE_TEXT:
+ case SHELL_MODE_TABLE_LIST_TEXT:
+ case SHELL_MODE_DRAWTEXT:
+ OSL_FAIL("text already active in SwSpellDialogChildWindow::MakeTextSelection_Impl()");
+ break;
+
+ case SHELL_MODE_FRAME:
+ {
+ rShell.UnSelectFrm();
+ rShell.LeaveSelFrmMode();
+ rView.AttrChangedNotify(&rShell);
+ }
+ break;
+
+ case SHELL_MODE_DRAW:
+ case SHELL_MODE_DRAW_CTRL:
+ case SHELL_MODE_DRAW_FORM:
+ case SHELL_MODE_BEZIER:
+ if(FindNextDrawTextError_Impl(rShell))
+ {
+ rView.AttrChangedNotify(&rShell);
+ break;
+ }
+ // otherwise no break to deselect the object
+ case SHELL_MODE_GRAPHIC:
+ case SHELL_MODE_OBJECT:
+ {
+ if ( rShell.IsDrawCreate() )
+ {
+ rView.GetDrawFuncPtr()->BreakCreate();
+ rView.AttrChangedNotify(&rShell);
+ }
+ else if ( rShell.HasSelection() || rView.IsDrawMode() )
+ {
+ SdrView *pSdrView = rShell.GetDrawView();
+ if(pSdrView && pSdrView->AreObjectsMarked() &&
+ pSdrView->GetHdlList().GetFocusHdl())
+ {
+ ((SdrHdlList&)pSdrView->GetHdlList()).ResetFocusHdl();
+ }
+ else
+ {
+ rView.LeaveDrawCreate();
+ Point aPt(LONG_MIN, LONG_MIN);
+ // go out of the frame
+ rShell.SelectObj(aPt, SW_LEAVE_FRAME);
+ SfxBindings& rBind = rView.GetViewFrame()->GetBindings();
+ rBind.Invalidate( SID_ATTR_SIZE );
+ rShell.EnterStdMode();
+ rView.AttrChangedNotify(&rShell);
+ }
+ }
+ }
+ break;
+ default:; // prevent warning
+ }
+ return true;
+}
+
+// select the next draw text object that has a spelling error
+bool SwSpellDialogChildWindow::FindNextDrawTextError_Impl(SwWrtShell& rSh)
+{
+ bool bNextDoc = false;
+ SdrView* pDrView = rSh.GetDrawView();
+ if(!pDrView)
+ return bNextDoc;
+ SwView& rView = rSh.GetView();
+ SwDoc* pDoc = rView.GetDocShell()->GetDoc();
+ const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
+ // start at the current draw object - if there is any selected
+ SdrTextObj* pCurrentTextObj = 0;
+ if ( rMarkList.GetMarkCount() == 1 )
+ {
+ SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+ if( pObj && pObj->ISA(SdrTextObj) )
+ pCurrentTextObj = static_cast<SdrTextObj*>(pObj);
+ }
+ // at first fill the list of drawing objects
+ if(!m_pSpellState->m_bTextObjectsCollected )
+ {
+ m_pSpellState->m_bTextObjectsCollected = true;
+ std::list<SdrTextObj*> aTextObjs;
+ SwDrawContact::GetTextObjectsFromFmt( aTextObjs, pDoc );
+ if(pCurrentTextObj)
+ {
+ m_pSpellState->m_aTextObjects.remove(pCurrentTextObj);
+ m_pSpellState->m_aTextObjects.push_back(pCurrentTextObj);
+ }
+ }
+ if(m_pSpellState->m_aTextObjects.size())
+ {
+ Reference< XSpellChecker1 > xSpell( GetSpellChecker() );
+ while(!bNextDoc && m_pSpellState->m_aTextObjects.size())
+ {
+ std::list<SdrTextObj*>::iterator aStart = m_pSpellState->m_aTextObjects.begin();
+ SdrTextObj* pTextObj = *aStart;
+ if(m_pSpellState->m_pStartDrawing == pTextObj)
+ m_pSpellState->m_bRestartDrawing = true;
+ m_pSpellState->m_aTextObjects.erase(aStart);
+ OutlinerParaObject* pParaObj = pTextObj->GetOutlinerParaObject();
+ if ( pParaObj )
+ {
+ bool bHasSpellError = false;
+ {
+ SdrOutliner aTmpOutliner(pDoc->GetDrawModel()->
+ GetDrawOutliner().GetEmptyItemSet().GetPool(),
+ OUTLINERMODE_TEXTOBJECT );
+ aTmpOutliner.SetRefDevice( pDoc->getPrinter( false ) );
+ MapMode aMapMode (MAP_TWIP);
+ aTmpOutliner.SetRefMapMode(aMapMode);
+ aTmpOutliner.SetPaperSize( pTextObj->GetLogicRect().GetSize() );
+ aTmpOutliner.SetSpeller( xSpell );
+
+ OutlinerView* pOutlView = new OutlinerView( &aTmpOutliner, &(rView.GetEditWin()) );
+ pOutlView->GetOutliner()->SetRefDevice( rSh.getIDocumentDeviceAccess()->getPrinter( false ) );
+ aTmpOutliner.InsertView( pOutlView );
+ Point aPt;
+ Size aSize(1,1);
+ Rectangle aRect( aPt, aSize );
+ pOutlView->SetOutputArea( aRect );
+ aTmpOutliner.SetText( *pParaObj );
+ aTmpOutliner.ClearModifyFlag();
+ bHasSpellError = EE_SPELL_OK != aTmpOutliner.HasSpellErrors();
+ aTmpOutliner.RemoveView( pOutlView );
+ delete pOutlView;
+ }
+ if(bHasSpellError)
+ {
+ // now the current one has to be deselected
+ if(pCurrentTextObj)
+ pDrView->SdrEndTextEdit( sal_True );
+ // and the found one should be activated
+ rSh.MakeVisible(pTextObj->GetLogicRect());
+ Point aTmp( 0,0 );
+ rSh.SelectObj( aTmp, 0, pTextObj );
+ SdrPageView* pPV = pDrView->GetSdrPageView();
+ rView.BeginTextEdit( pTextObj, pPV, &rView.GetEditWin(), false, true );
+ rView.AttrChangedNotify(&rSh);
+ bNextDoc = true;
+ }
+ }
+ }
+ }
+ return bNextDoc;
+}
+
+bool SwSpellDialogChildWindow::SpellDrawText_Impl(SwWrtShell& rSh, ::svx::SpellPortions& rPortions)
+{
+ bool bRet = false;
+ SdrView* pSdrView = rSh.GetDrawView();
+ SdrOutliner* pOutliner = pSdrView ? pSdrView->GetTextEditOutliner() : 0;
+ OSL_ENSURE(pOutliner, "No Outliner in SwSpellDialogChildWindow::SpellDrawText_Impl");
+ if(pOutliner)
+ {
+ bRet = pOutliner->SpellSentence(pSdrView->GetTextEditOutlinerView()->GetEditView(), rPortions, m_bIsGrammarCheckingOn);
+ // find out if the current selection is in the first spelled drawing object
+ // and behind the initial selection
+ if(bRet && m_pSpellState->m_bRestartDrawing)
+ {
+ OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
+ ESelection aCurrentSelection = pOLV->GetSelection();
+ if(m_pSpellState->m_aStartDrawingSelection.nEndPara < aCurrentSelection.nEndPara ||
+ (m_pSpellState->m_aStartDrawingSelection.nEndPara == aCurrentSelection.nEndPara &&
+ m_pSpellState->m_aStartDrawingSelection.nEndPos < aCurrentSelection.nEndPos))
+ {
+ bRet = false;
+ rPortions.clear();
+ }
+ }
+ }
+ return bRet;
+}
+
+void SwSpellDialogChildWindow::LockFocusNotification(bool bLock)
+{
+ OSL_ENSURE(m_pSpellState->m_bLockFocus != bLock, "invalid locking - no change of state");
+ m_pSpellState->m_bLockFocus = bLock;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/dialog/regionsw.cxx b/sw/source/core/uibase/dialog/regionsw.cxx
new file mode 100644
index 000000000000..4085c67717f9
--- /dev/null
+++ b/sw/source/core/uibase/dialog/regionsw.cxx
@@ -0,0 +1,242 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <hintids.hxx>
+#include <uitool.hxx>
+#include <comphelper/string.hxx>
+#include <svl/urihelper.hxx>
+#include <svl/PasswordHelper.hxx>
+#include <vcl/msgbox.hxx>
+#include <svl/stritem.hxx>
+#include <svl/eitem.hxx>
+#include <sot/formats.hxx>
+#include <sfx2/passwd.hxx>
+#include <sfx2/docfilt.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/linkmgr.hxx>
+#include <editeng/sizeitem.hxx>
+#include <svtools/htmlcfg.hxx>
+#include <section.hxx>
+#include <docary.hxx>
+#include <regionsw.hxx>
+#include <basesh.hxx>
+#include <wdocsh.hxx>
+#include <view.hxx>
+#include <swmodule.hxx>
+#include <wrtsh.hxx>
+#include <swundo.hxx>
+#include <column.hxx>
+#include <fmtfsize.hxx>
+#include <shellio.hxx>
+#include <helpid.h>
+#include <cmdid.h>
+#include <regionsw.hrc>
+#include <comcore.hrc>
+#include <globals.hrc>
+#include <sfx2/bindings.hxx>
+#include <sfx2/htmlmode.hxx>
+#include <svx/dlgutil.hxx>
+#include "swabstdlg.hxx"
+#include <boost/scoped_ptr.hpp>
+
+void SwBaseShell::InsertRegionDialog(SfxRequest& rReq)
+{
+ SwWrtShell& rSh = GetShell();
+ const SfxItemSet *pSet = rReq.GetArgs();
+
+ SfxItemSet aSet(GetPool(),
+ RES_COL, RES_COL,
+ RES_LR_SPACE, RES_LR_SPACE,
+ RES_COLUMNBALANCE, RES_FRAMEDIR,
+ RES_BACKGROUND, RES_BACKGROUND,
+ RES_FRM_SIZE, RES_FRM_SIZE,
+ RES_FTN_AT_TXTEND, RES_END_AT_TXTEND,
+ SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE,
+ 0);
+
+ if (!pSet || pSet->Count()==0)
+ {
+ SwRect aRect;
+ rSh.CalcBoundRect(aRect, FLY_AS_CHAR);
+
+ long nWidth = aRect.Width();
+ aSet.Put(SwFmtFrmSize(ATT_VAR_SIZE, nWidth));
+
+ // height=width for more consistent preview (analog to edit region)
+ aSet.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE, Size(nWidth, nWidth)));
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "Dialogdiet fail!");
+ AbstractInsertSectionTabDialog* aTabDlg = pFact->CreateInsertSectionTabDialog(
+ &GetView().GetViewFrame()->GetWindow(), aSet , rSh);
+ OSL_ENSURE(aTabDlg, "Dialogdiet fail!");
+ aTabDlg->Execute();
+ rReq.Ignore();
+ delete aTabDlg;
+ }
+ else
+ {
+ const SfxPoolItem *pItem = 0;
+ OUString aTmpStr;
+ if ( SFX_ITEM_SET ==
+ pSet->GetItemState(FN_PARAM_REGION_NAME, true, &pItem) )
+ {
+ const OUString sRemoveWhenUniStringIsGone = ((const SfxStringItem *)pItem)->GetValue();
+ aTmpStr = rSh.GetUniqueSectionName(&sRemoveWhenUniStringIsGone);
+ }
+ else
+ aTmpStr = rSh.GetUniqueSectionName();
+
+ SwSectionData aSection(CONTENT_SECTION, aTmpStr);
+ rReq.SetReturnValue(SfxStringItem(FN_INSERT_REGION, aTmpStr));
+
+ aSet.Put( *pSet );
+ if(SFX_ITEM_SET == pSet->GetItemState(SID_ATTR_COLUMNS, false, &pItem)||
+ SFX_ITEM_SET == pSet->GetItemState(FN_INSERT_REGION, false, &pItem))
+ {
+ SwFmtCol aCol;
+ SwRect aRect;
+ rSh.CalcBoundRect(aRect, FLY_AS_CHAR);
+ long nWidth = aRect.Width();
+
+ sal_uInt16 nCol = ((SfxUInt16Item *)pItem)->GetValue();
+ if(nCol)
+ {
+ aCol.Init( nCol, 0, static_cast< sal_uInt16 >(nWidth) );
+ aSet.Put(aCol);
+ }
+ }
+ else if(SFX_ITEM_SET == pSet->GetItemState(RES_COL, false, &pItem))
+ {
+ aSet.Put(*pItem);
+ }
+
+ const sal_Bool bHidden = SFX_ITEM_SET ==
+ pSet->GetItemState(FN_PARAM_REGION_HIDDEN, true, &pItem)?
+ (sal_Bool)((const SfxBoolItem *)pItem)->GetValue():sal_False;
+ const sal_Bool bProtect = SFX_ITEM_SET ==
+ pSet->GetItemState(FN_PARAM_REGION_PROTECT, true, &pItem)?
+ (sal_Bool)((const SfxBoolItem *)pItem)->GetValue():sal_False;
+ // #114856# edit in readonly sections
+ const sal_Bool bEditInReadonly = SFX_ITEM_SET ==
+ pSet->GetItemState(FN_PARAM_REGION_EDIT_IN_READONLY, true, &pItem)?
+ (sal_Bool)((const SfxBoolItem *)pItem)->GetValue():sal_False;
+
+ aSection.SetProtectFlag(bProtect);
+ aSection.SetHidden(bHidden);
+ // #114856# edit in readonly sections
+ aSection.SetEditInReadonlyFlag(bEditInReadonly);
+
+ if(SFX_ITEM_SET ==
+ pSet->GetItemState(FN_PARAM_REGION_CONDITION, true, &pItem))
+ aSection.SetCondition(((const SfxStringItem *)pItem)->GetValue());
+
+ OUString aFile, aSub;
+ if(SFX_ITEM_SET ==
+ pSet->GetItemState(FN_PARAM_1, true, &pItem))
+ aFile = ((const SfxStringItem *)pItem)->GetValue();
+
+ if(SFX_ITEM_SET ==
+ pSet->GetItemState(FN_PARAM_3, true, &pItem))
+ aSub = ((const SfxStringItem *)pItem)->GetValue();
+
+ if(!aFile.isEmpty() || !aSub.isEmpty())
+ {
+ OUString sLinkFileName = OUString(sfx2::cTokenSeparator);
+ sLinkFileName += OUString(sfx2::cTokenSeparator);
+ sLinkFileName = comphelper::string::setToken(sLinkFileName, 0, sfx2::cTokenSeparator, aFile);
+
+ if(SFX_ITEM_SET ==
+ pSet->GetItemState(FN_PARAM_2, true, &pItem))
+ {
+ sLinkFileName = comphelper::string::setToken(sLinkFileName, 1, sfx2::cTokenSeparator,
+ ((const SfxStringItem *)pItem)->GetValue());
+ }
+
+ sLinkFileName += aSub;
+ aSection.SetType( FILE_LINK_SECTION );
+ aSection.SetLinkFileName(sLinkFileName);
+ }
+ rSh.InsertSection(aSection, aSet.Count() ? &aSet : 0);
+ rReq.Done();
+ }
+}
+
+IMPL_STATIC_LINK( SwWrtShell, InsertRegionDialog, SwSectionData*, pSect )
+{
+ boost::scoped_ptr<SwSectionData> xSectionData(pSect);
+ if (xSectionData.get())
+ {
+ SfxItemSet aSet(pThis->GetView().GetPool(),
+ RES_COL, RES_COL,
+ RES_BACKGROUND, RES_BACKGROUND,
+ RES_FRM_SIZE, RES_FRM_SIZE,
+ SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE,
+ 0);
+ SwRect aRect;
+ pThis->CalcBoundRect(aRect, FLY_AS_CHAR);
+ long nWidth = aRect.Width();
+ aSet.Put(SwFmtFrmSize(ATT_VAR_SIZE, nWidth));
+ // height=width for more consistent preview (analog to edit region)
+ aSet.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE, Size(nWidth, nWidth)));
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "Dialogdiet fail!");
+ AbstractInsertSectionTabDialog* aTabDlg = pFact->CreateInsertSectionTabDialog(
+ &pThis->GetView().GetViewFrame()->GetWindow(),aSet , *pThis);
+ OSL_ENSURE(aTabDlg, "Dialogdiet fail!");
+ aTabDlg->SetSectionData(*xSectionData);
+ aTabDlg->Execute();
+
+ delete aTabDlg;
+ }
+ return 0;
+}
+
+void SwBaseShell::EditRegionDialog(SfxRequest& rReq)
+{
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ sal_uInt16 nSlot = rReq.GetSlot();
+ const SfxPoolItem* pItem = 0;
+ if(pArgs)
+ pArgs->GetItemState(nSlot, false, &pItem);
+ SwWrtShell& rWrtShell = GetShell();
+
+ switch ( nSlot )
+ {
+ case FN_EDIT_REGION:
+ {
+ Window* pParentWin = &GetView().GetViewFrame()->GetWindow();
+ {
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "Dialogdiet fail!");
+ AbstractEditRegionDlg* pEditRegionDlg = pFact->CreateEditRegionDlg(pParentWin, rWrtShell);
+ OSL_ENSURE(pEditRegionDlg, "Dialogdiet fail!");
+ if(pItem && pItem->ISA(SfxStringItem))
+ {
+ pEditRegionDlg->SelectSection(((const SfxStringItem*)pItem)->GetValue());
+ }
+ pEditRegionDlg->Execute();
+ delete pEditRegionDlg;
+ }
+ }
+ break;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/dialog/regionsw.hrc b/sw/source/core/uibase/dialog/regionsw.hrc
new file mode 100644
index 000000000000..b7d45f309c8d
--- /dev/null
+++ b/sw/source/core/uibase/dialog/regionsw.hrc
@@ -0,0 +1,42 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef _REGIONSW_HRC
+#define _REGIONSW_HRC
+
+#include "dialog.hrc"
+
+#define ST_INSERT 45
+
+/* global resources */
+#define STR_REG_DUPLICATE (RC_REGIONSW_BEGIN+6)
+#define STR_INFO_DUPLICATE (RC_REGIONSW_BEGIN+7)
+
+#define QB_CONNECT (RC_REGIONSW_BEGIN+10)
+#define REG_WRONG_PASSWORD (RC_REGIONSW_BEGIN+11)
+#define REG_WRONG_PASSWD_REPEAT (RC_REGIONSW_BEGIN+12)
+
+//ImageList elements
+#define BMP_HIDE 1
+#define BMP_NO_HIDE 2
+#define BMP_PROT_HIDE 3
+#define BMP_PROT_NO_HIDE 4
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/dialog/regionsw.src b/sw/source/core/uibase/dialog/regionsw.src
new file mode 100644
index 000000000000..fa1e976bfa49
--- /dev/null
+++ b/sw/source/core/uibase/dialog/regionsw.src
@@ -0,0 +1,119 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "regionsw.hrc"
+#include "cmdid.h"
+#include "globals.hrc"
+#include "helpid.h"
+/*************************************************************************
+
+ Dialog "paste region"
+
+*************************************************************************/
+#define FT_SUBREG_TEXT \
+ Text [ en-US ] = "~Section" ; \
+
+#define CB_HIDE_TEXT \
+ Text [ en-US ] = "H~ide" ;\
+
+#define FL_HIDE_TEXT \
+ Text [ en-US ] = "Hide" ;\
+
+#define CB_CONDITION_TEXT \
+ Text [ en-US ] = "~With Condition" ;\
+
+#define FL_PROPERTIES_TEXT \
+ Text [ en-US ] = "Properties" ;\
+
+#define CB_EDIT_IN_READONLY_TEXT \
+ Text [ en-US ] = "E~ditable in read-only document" ;\
+
+#define FL_FILE_TEXT \
+ Text [ en-US ] = "Link" ;\
+
+#define CB_FILE_TEXT\
+ Text [ en-US ] = "~Link";\
+
+#define CB_DDE_TEXT \
+ Text [ en-US ] = "DD~E" ;\
+
+#define FT_DDE_TEXT \
+ Text [ en-US ] = "DDE ~command" ;\
+
+#define FT_FILE_TEXT \
+ Text [ en-US ] = "~File name" ;\
+
+
+#define GB_HIDE_TEXT \
+ Text [ en-US ] = "Hide";\
+
+#define GB_OPTIONS_TEXT \
+ Text [ en-US ] = "Options" ;\
+
+#define FL_PROTECT_TEXT \
+ Text [ en-US ] = "Write protection";\
+
+#define CB_PASSWD_TEXT\
+ Text [ en-US ] = "Wit~h password";\
+
+#define DLG_IMAGE_IDLIST \
+ IdList = \
+ { \
+ BMP_HIDE /*1*/ ;\
+ BMP_NO_HIDE /*2*/ ;\
+ BMP_PROT_HIDE /*3*/ ;\
+ BMP_PROT_NO_HIDE /*4*/ ;\
+ }; \
+ IdCount = { 4 ; };
+
+ImageList IL_SECTION_BITMAPS
+{
+ Prefix = "re";
+ MaskColor = IMAGE_MASK_COLOR ;
+ DLG_IMAGE_IDLIST
+};
+
+String STR_REG_DUPLICATE
+{
+ Text [ en-US ] = "Section name changed:" ;
+};
+String STR_INFO_DUPLICATE
+{
+ Text [ en-US ] = "Duplicate section name" ;
+};
+QueryBox QB_CONNECT
+{
+ Buttons = WB_YES_NO ;
+ DefButton = WB_DEF_NO ;
+ Message [ en-US ] = "A file connection will delete the contents of the current section. Connect anyway?" ;
+};
+InfoBox REG_WRONG_PASSWORD
+{
+ BUTTONS = WB_OK ;
+ DEFBUTTON = WB_DEF_OK ;
+ Message [ en-US ] = "The password entered is invalid." ;
+};
+InfoBox REG_WRONG_PASSWD_REPEAT
+{
+ BUTTONS = WB_OK ;
+ DEFBUTTON = WB_DEF_OK ;
+ Message [ en-US ] = "The password has not been set." ;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/dialog/swabstdlg.cxx b/sw/source/core/uibase/dialog/swabstdlg.cxx
new file mode 100644
index 000000000000..8cf41aa5604d
--- /dev/null
+++ b/sw/source/core/uibase/dialog/swabstdlg.cxx
@@ -0,0 +1,59 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <config_features.h>
+#include <config_libraries.h>
+
+#include "swabstdlg.hxx"
+
+#include <osl/module.hxx>
+
+typedef SwAbstractDialogFactory* (SAL_CALL *SwFuncPtrCreateDialogFactory)();
+
+#ifndef DISABLE_DYNLOADING
+
+extern "C" { static void SAL_CALL thisModule() {} }
+
+#else
+
+extern "C" SwAbstractDialogFactory* SwCreateDialogFactory();
+
+#endif
+
+SwAbstractDialogFactory* SwAbstractDialogFactory::Create()
+{
+ SwFuncPtrCreateDialogFactory fp = 0;
+#if HAVE_FEATURE_DESKTOP
+#ifndef DISABLE_DYNLOADING
+ static ::osl::Module aDialogLibrary;
+ static const OUString sLibName(LIBO_LIBRARY(swui));
+ if ( aDialogLibrary.is() || aDialogLibrary.loadRelative( &thisModule, sLibName,
+ SAL_LOADMODULE_GLOBAL | SAL_LOADMODULE_LAZY ) )
+ fp = ( SwAbstractDialogFactory* (SAL_CALL*)() )
+ aDialogLibrary.getFunctionSymbol( OUString("SwCreateDialogFactory"));
+#else
+ fp = SwCreateDialogFactory();
+#endif
+#endif
+ if ( fp )
+ return fp();
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/dialog/swwrtshitem.cxx b/sw/source/core/uibase/dialog/swwrtshitem.cxx
new file mode 100644
index 000000000000..591a6b5403f5
--- /dev/null
+++ b/sw/source/core/uibase/dialog/swwrtshitem.cxx
@@ -0,0 +1,43 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "swwrtshitem.hxx"
+TYPEINIT1(SwWrtShellItem,SfxPoolItem);
+SwWrtShellItem::SwWrtShellItem( sal_uInt16 _nWhich, SwWrtShell* pSh )
+ : SfxPoolItem( _nWhich ), pWrtSh( pSh )
+{
+
+}
+SwWrtShellItem::SwWrtShellItem( const SwWrtShellItem& rItem) :
+ SfxPoolItem( rItem.Which() ),
+ pWrtSh( rItem.pWrtSh )
+{
+}
+
+bool SwWrtShellItem::operator==( const SfxPoolItem& rItem) const
+{
+ return ((SwWrtShellItem&)rItem).pWrtSh == pWrtSh;
+}
+
+SfxPoolItem* SwWrtShellItem::Clone( SfxItemPool * /*pPool*/ ) const
+{
+ return new SwWrtShellItem( *this );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/dialog/wordcountwrapper.cxx b/sw/source/core/uibase/dialog/wordcountwrapper.cxx
new file mode 100644
index 000000000000..78cf4ee95a5b
--- /dev/null
+++ b/sw/source/core/uibase/dialog/wordcountwrapper.cxx
@@ -0,0 +1,49 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <swtypes.hxx>
+#include <wordcountdialog.hxx>
+#include <docstat.hxx>
+#include <dialog.hrc>
+#include <cmdid.h>
+
+SFX_IMPL_CHILDWINDOW_WITHID(SwWordCountWrapper, FN_WORDCOUNT_DIALOG)
+
+SwWordCountWrapper::SwWordCountWrapper( Window *pParentWindow,
+ sal_uInt16 nId,
+ SfxBindings* pBindings,
+ SfxChildWinInfo* pInfo ) :
+ SfxChildWindow(pParentWindow, nId)
+{
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+ pAbstDlg = pFact->CreateSwWordCountDialog(pBindings, this, pParentWindow, pInfo);
+ OSL_ENSURE(pAbstDlg, "Dialog construction failed!");
+ pWindow = pAbstDlg->GetWindow();
+
+ eChildAlignment = SFX_ALIGN_NOALIGNMENT;
+}
+
+SfxChildWinInfo SwWordCountWrapper::GetInfo() const
+{
+ SfxChildWinInfo aInfo = SfxChildWindow::GetInfo();
+ return aInfo;
+}
+
+void SwWordCountWrapper::UpdateCounts()
+{
+ pAbstDlg->UpdateCounts();
+}
+
+void SwWordCountWrapper::SetCounts(const SwDocStat &rCurrCnt, const SwDocStat &rDocStat)
+{
+ pAbstDlg->SetCounts(rCurrCnt, rDocStat);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/dochdl/gloshdl.cxx b/sw/source/core/uibase/dochdl/gloshdl.cxx
new file mode 100644
index 000000000000..6aa1d5800964
--- /dev/null
+++ b/sw/source/core/uibase/dochdl/gloshdl.cxx
@@ -0,0 +1,753 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <hintids.hxx>
+#include <editeng/wghtitem.hxx>
+#include <editeng/adjustitem.hxx>
+#ifndef __RSC //autogen
+#include <tools/errinf.hxx>
+#endif
+#include <vcl/msgbox.hxx>
+#include <svl/macitem.hxx>
+#include <sfx2/fcontnr.hxx>
+#include <sfx2/docfile.hxx>
+#include <svl/urihelper.hxx>
+#include <unotools/transliterationwrapper.hxx>
+#include <poolfmt.hxx>
+#include <fmtcol.hxx>
+#include <docary.hxx>
+#include <wrtsh.hxx>
+#include <uitool.hxx>
+#include <view.hxx>
+#include <swevent.hxx>
+#include <gloshdl.hxx>
+#include <glosdoc.hxx>
+#include <shellio.hxx>
+#include <swundo.hxx>
+#include <expfld.hxx>
+#include <initui.hxx>
+#include <gloslst.hxx>
+#include <swdtflvr.hxx>
+#include <docsh.hxx>
+#include <crsskip.hxx>
+
+#include <dochdl.hrc>
+#include <swerror.h>
+#include <frmmgr.hxx>
+#include <vcl/lstbox.hxx>
+
+#include <editeng/acorrcfg.hxx>
+#include "swabstdlg.hxx"
+#include <misc.hrc>
+
+#include <IDocumentFieldsAccess.hxx>
+
+using namespace ::com::sun::star;
+
+const short RET_EDIT = 100;
+
+// PUBLIC METHODS -------------------------------------------------------
+struct TextBlockInfo_Impl
+{
+ OUString sTitle;
+ OUString sLongName;
+ OUString sGroupName;
+};
+typedef boost::ptr_vector<TextBlockInfo_Impl> TextBlockInfoArr;
+SV_IMPL_REF( SwDocShell )
+
+// Dialog for edit templates
+void SwGlossaryHdl::GlossaryDlg()
+{
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "Dialogdiet fail!");
+ AbstractGlossaryDlg* pDlg = pFact->CreateGlossaryDlg(pViewFrame, this, pWrtShell);
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ OUString sName;
+ OUString sShortName;
+
+ if( RET_EDIT == pDlg->Execute() )
+ {
+ sName = pDlg->GetCurrGrpName();
+ sShortName = pDlg->GetCurrShortName();
+ }
+
+ delete pDlg;
+ DELETEZ(pCurGrp);
+ if(HasGlossaryList())
+ {
+ GetGlossaryList()->ClearGroups();
+ }
+
+ if( !sName.isEmpty() || !sShortName.isEmpty() )
+ rStatGlossaries.EditGroupDoc( sName, sShortName );
+}
+
+// set the default group; if called from the dialog
+// the group is created temporarily for faster access
+void SwGlossaryHdl::SetCurGroup(const OUString &rGrp, sal_Bool bApi, sal_Bool bAlwaysCreateNew )
+{
+ OUString sGroup(rGrp);
+ if (sGroup.indexOf(GLOS_DELIM)<0 && !FindGroupName(sGroup))
+ {
+ sGroup += OUString(GLOS_DELIM) + "0";
+ }
+ if(pCurGrp)
+ {
+ bool bPathEqual = false;
+ if(!bAlwaysCreateNew)
+ {
+ INetURLObject aTemp( pCurGrp->GetFileName() );
+ const OUString sCurBase = aTemp.getBase();
+ aTemp.removeSegment();
+ const OUString sCurEntryPath = aTemp.GetMainURL(INetURLObject::NO_DECODE);
+ const std::vector<OUString> & rPathArr = rStatGlossaries.GetPathArray();
+ sal_uInt16 nCurrentPath = USHRT_MAX;
+ for (size_t nPath = 0; nPath < rPathArr.size(); ++nPath)
+ {
+ if (sCurEntryPath == rPathArr[nPath])
+ {
+ nCurrentPath = static_cast<sal_uInt16>(nPath);
+ break;
+ }
+ }
+ const OUString sPath = sGroup.getToken(1, GLOS_DELIM);
+ sal_uInt16 nComparePath = (sal_uInt16)sPath.toInt32();
+ if(nCurrentPath == nComparePath &&
+ sGroup.getToken(0, GLOS_DELIM) == sCurBase)
+ bPathEqual = true;
+ }
+
+ // When path changed, the name is not reliable
+ if(!bAlwaysCreateNew && bPathEqual)
+ return;
+ }
+ aCurGrp = sGroup;
+ if(!bApi)
+ {
+ if(pCurGrp)
+ {
+ rStatGlossaries.PutGroupDoc(pCurGrp);
+ pCurGrp = 0;
+ }
+ pCurGrp = rStatGlossaries.GetGroupDoc(aCurGrp, sal_True);
+ }
+}
+
+sal_uInt16 SwGlossaryHdl::GetGroupCnt() const
+{
+ return rStatGlossaries.GetGroupCnt();
+}
+
+OUString SwGlossaryHdl::GetGroupName( sal_uInt16 nId, OUString* pTitle )
+{
+ OUString sRet = rStatGlossaries.GetGroupName(nId);
+ if(pTitle)
+ {
+ SwTextBlocks* pGroup = rStatGlossaries.GetGroupDoc(sRet, sal_False);
+ if(pGroup && !pGroup->GetError())
+ {
+ *pTitle = pGroup->GetName();
+ if (pTitle->isEmpty())
+ {
+ *pTitle = sRet.getToken(0, GLOS_DELIM);
+ pGroup->SetName(*pTitle);
+ }
+ rStatGlossaries.PutGroupDoc( pGroup );
+ }
+ else
+ sRet = OUString();
+ }
+ return sRet;
+}
+
+sal_Bool SwGlossaryHdl::NewGroup(OUString &rGrpName, const OUString& rTitle)
+{
+ if (rGrpName.indexOf(GLOS_DELIM)<0)
+ FindGroupName(rGrpName);
+ return rStatGlossaries.NewGroupDoc(rGrpName, rTitle);
+}
+
+sal_Bool SwGlossaryHdl::RenameGroup(const OUString& rOld, OUString& rNew, const OUString& rNewTitle)
+{
+ sal_Bool bRet = sal_False;
+ OUString sOldGroup(rOld);
+ if (rOld.indexOf(GLOS_DELIM)<0)
+ FindGroupName(sOldGroup);
+ if(rOld == rNew)
+ {
+ SwTextBlocks* pGroup = rStatGlossaries.GetGroupDoc(sOldGroup, sal_False);
+ if(pGroup)
+ {
+ pGroup->SetName(rNewTitle);
+ rStatGlossaries.PutGroupDoc( pGroup );
+ bRet = sal_True;
+ }
+ }
+ else
+ {
+ OUString sNewGroup(rNew);
+ if (sNewGroup.indexOf(GLOS_DELIM)<0)
+ {
+ sNewGroup += OUString(GLOS_DELIM) + "0";
+ }
+ bRet = rStatGlossaries.RenameGroupDoc(sOldGroup, sNewGroup, rNewTitle);
+ rNew = sNewGroup;
+ }
+ return bRet;
+}
+
+sal_Bool SwGlossaryHdl::CopyOrMove( const OUString& rSourceGroupName, OUString& rSourceShortName,
+ const OUString& rDestGroupName, const OUString& rLongName, sal_Bool bMove )
+{
+ SwTextBlocks* pSourceGroup = rStatGlossaries.GetGroupDoc(rSourceGroupName, sal_False);
+
+ SwTextBlocks* pDestGroup = rStatGlossaries.GetGroupDoc(rDestGroupName, sal_False);
+ if(pDestGroup->IsReadOnly() || (bMove && pSourceGroup->IsReadOnly()) )
+ return sal_False;
+
+ //The index must be determined here because rSourceShortName maybe changed in CopyBlock
+ sal_uInt16 nDeleteIdx = pSourceGroup->GetIndex( rSourceShortName );
+ OSL_ENSURE(USHRT_MAX != nDeleteIdx, "entry not found");
+ sal_uLong nRet = pSourceGroup->CopyBlock( *pDestGroup, rSourceShortName, rLongName );
+ if(!nRet && bMove)
+ {
+ // the index must be existing
+ nRet = pSourceGroup->Delete( nDeleteIdx ) ? 0 : 1;
+ }
+ rStatGlossaries.PutGroupDoc( pSourceGroup );
+ rStatGlossaries.PutGroupDoc( pDestGroup );
+ return !nRet;
+}
+
+// delete a autotext-file-group
+sal_Bool SwGlossaryHdl::DelGroup(const OUString &rGrpName)
+{
+ OUString sGroup(rGrpName);
+ if (sGroup.indexOf(GLOS_DELIM)<0)
+ FindGroupName(sGroup);
+ if( rStatGlossaries.DelGroupDoc(sGroup) )
+ {
+ if(pCurGrp)
+ {
+ if (pCurGrp->GetName() == sGroup)
+ DELETEZ(pCurGrp);
+ }
+ return sal_True;
+ }
+ return sal_False;
+}
+
+// ask for number of autotexts
+sal_uInt16 SwGlossaryHdl::GetGlossaryCnt()
+{
+ return pCurGrp ? pCurGrp->GetCount() : 0;
+}
+
+OUString SwGlossaryHdl::GetGlossaryName( sal_uInt16 nId )
+{
+ OSL_ENSURE(nId < GetGlossaryCnt(), "Textbausteinarray ueberindiziert.");
+ return pCurGrp->GetLongName( nId );
+}
+
+OUString SwGlossaryHdl::GetGlossaryShortName(sal_uInt16 nId)
+{
+ OSL_ENSURE(nId < GetGlossaryCnt(), "Textbausteinarray ueberindiziert.");
+ return pCurGrp->GetShortName( nId );
+}
+
+// ask for short name
+OUString SwGlossaryHdl::GetGlossaryShortName(const OUString &rName)
+{
+ OUString sReturn;
+ SwTextBlocks *pTmp =
+ pCurGrp ? pCurGrp: rStatGlossaries.GetGroupDoc( aCurGrp, sal_False );
+ if(pTmp)
+ {
+ sal_uInt16 nIdx = pTmp->GetLongIndex( rName );
+ if( nIdx != (sal_uInt16) -1 )
+ sReturn = pTmp->GetShortName( nIdx );
+ if( !pCurGrp )
+ rStatGlossaries.PutGroupDoc( pTmp );
+ }
+ return sReturn;
+}
+
+// short name for autotext already used?
+sal_Bool SwGlossaryHdl::HasShortName(const OUString& rShortName) const
+{
+ SwTextBlocks *pBlock = pCurGrp ? pCurGrp
+ : rStatGlossaries.GetGroupDoc( aCurGrp );
+ sal_Bool bRet = pBlock->GetIndex( rShortName ) != (sal_uInt16) -1;
+ if( !pCurGrp )
+ rStatGlossaries.PutGroupDoc( pBlock );
+ return bRet;
+}
+
+sal_Bool SwGlossaryHdl::ConvertToNew(SwTextBlocks& /*rOld*/)
+{
+ return sal_True;
+}
+
+// Create autotext
+sal_Bool SwGlossaryHdl::NewGlossary(const OUString& rName, const OUString& rShortName,
+ sal_Bool bCreateGroup, sal_Bool bNoAttr)
+{
+ SwTextBlocks *pTmp =
+ pCurGrp ? pCurGrp: rStatGlossaries.GetGroupDoc( aCurGrp, bCreateGroup );
+ //pTmp == 0 if the AutoText path setting is wrong
+ if(!pTmp)
+ return sal_False;
+ if(!ConvertToNew(*pTmp))
+ return sal_False;
+
+ OUString sOnlyTxt;
+ OUString* pOnlyTxt = 0;
+ if( bNoAttr )
+ {
+ if( !pWrtShell->GetSelectedText( sOnlyTxt, GETSELTXT_PARABRK_TO_ONLYCR ))
+ return sal_False;
+ pOnlyTxt = &sOnlyTxt;
+ }
+
+ const SvxAutoCorrCfg& rCfg = SvxAutoCorrCfg::Get();
+
+ const sal_uInt16 nSuccess = pWrtShell->MakeGlossary( *pTmp, rName, rShortName,
+ rCfg.IsSaveRelFile(), pOnlyTxt );
+ if(nSuccess == (sal_uInt16) -1 )
+ {
+ InfoBox(pWrtShell->GetView().GetWindow(), SW_RES(MSG_ERR_INSERT_GLOS)).Execute();
+ }
+ if( !pCurGrp )
+ rStatGlossaries.PutGroupDoc( pTmp );
+ return sal_Bool( nSuccess != (sal_uInt16) -1 );
+}
+
+// Delete a autotext
+sal_Bool SwGlossaryHdl::DelGlossary(const OUString &rShortName)
+{
+ SwTextBlocks *pGlossary = pCurGrp ? pCurGrp
+ : rStatGlossaries.GetGroupDoc(aCurGrp);
+ //pTmp == 0 if the AutoText path setting is wrong
+ if(!pGlossary || !ConvertToNew(*pGlossary))
+ return sal_False;
+
+ sal_uInt16 nIdx = pGlossary->GetIndex( rShortName );
+ if( nIdx != (sal_uInt16) -1 )
+ pGlossary->Delete( nIdx );
+ if( !pCurGrp )
+ rStatGlossaries.PutGroupDoc( pGlossary );
+ return sal_True;
+}
+
+// expand short name
+sal_Bool SwGlossaryHdl::ExpandGlossary()
+{
+ OSL_ENSURE(pWrtShell->CanInsert(), "illegal");
+ SwTextBlocks *pGlossary;
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "Dialogdiet fail!");
+ ::GlossaryGetCurrGroup fnGetCurrGroup = pFact->GetGlossaryCurrGroupFunc();
+ OSL_ENSURE(fnGetCurrGroup, "Dialogdiet fail!");
+ OUString sGroupName( (*fnGetCurrGroup)() );
+ if (sGroupName.indexOf(GLOS_DELIM)<0)
+ FindGroupName(sGroupName);
+ pGlossary = rStatGlossaries.GetGroupDoc(sGroupName);
+
+ OUString aShortName;
+
+ // use this at text selection
+ if(pWrtShell->SwCrsrShell::HasSelection() && !pWrtShell->IsBlockMode())
+ {
+ aShortName = pWrtShell->GetSelTxt();
+ }
+ else
+ {
+ if(pWrtShell->IsAddMode())
+ pWrtShell->LeaveAddMode();
+ else if(pWrtShell->IsBlockMode())
+ pWrtShell->LeaveBlockMode();
+ else if(pWrtShell->IsExtMode())
+ pWrtShell->LeaveExtMode();
+ // select word
+ pWrtShell->SelNearestWrd();
+ // ask for word
+ if(pWrtShell->IsSelection())
+ aShortName = pWrtShell->GetSelTxt();
+ }
+ return pGlossary ? Expand( aShortName, &rStatGlossaries, pGlossary ) : sal_False;
+}
+
+sal_Bool SwGlossaryHdl::Expand( const OUString& rShortName,
+ SwGlossaries *pGlossaries,
+ SwTextBlocks *pGlossary )
+{
+ TextBlockInfoArr aFoundArr;
+ OUString aShortName( rShortName );
+ sal_Bool bCancel = sal_False;
+ // search for text block
+ // - don't prefer current group depending on configuration setting
+ const SvxAutoCorrCfg& rCfg = SvxAutoCorrCfg::Get();
+ sal_uInt16 nFound = !rCfg.IsSearchInAllCategories() ? pGlossary->GetIndex( aShortName ) : -1;
+ // if not found then search in all groups
+ if( nFound == (sal_uInt16) -1 )
+ {
+ const ::utl::TransliterationWrapper& rSCmp = GetAppCmpStrIgnore();
+ SwGlossaryList* pGlossaryList = ::GetGlossaryList();
+ sal_uInt16 nGroupCount = pGlossaryList->GetGroupCount();
+ for(sal_uInt16 i = 1; i <= nGroupCount; i++)
+ {
+ OUString sTitle = pGlossaryList->GetGroupTitle(i - 1);
+ // get group name with path-extension
+ OUString sGroupName = pGlossaryList->GetGroupName(i - 1, false);
+ if(sGroupName == pGlossary->GetName())
+ continue;
+ sal_uInt16 nBlockCount = pGlossaryList->GetBlockCount(i -1);
+ if(nBlockCount)
+ {
+ for(sal_uInt16 j = 0; j < nBlockCount; j++)
+ {
+ OUString sLongName(pGlossaryList->GetBlockLongName(i - 1, j));
+ OUString sShortName(pGlossaryList->GetBlockShortName(i - 1, j));
+ if( rSCmp.isEqual( rShortName, sShortName ))
+ {
+ TextBlockInfo_Impl* pData = new TextBlockInfo_Impl;
+ pData->sTitle = sTitle;
+ pData->sLongName = sLongName;
+ pData->sGroupName = sGroupName;
+ aFoundArr.push_back(pData);
+ }
+ }
+ }
+ }
+ if( !aFoundArr.empty() ) // one was found
+ {
+ pGlossaries->PutGroupDoc(pGlossary);
+ if(1 == aFoundArr.size())
+ {
+ TextBlockInfo_Impl* pData = &aFoundArr.front();
+ pGlossary = (SwTextBlocks *)pGlossaries->GetGroupDoc(pData->sGroupName);
+ nFound = pGlossary->GetIndex( aShortName );
+ }
+ else
+ {
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+
+ AbstractSwSelGlossaryDlg* pDlg = pFact->CreateSwSelGlossaryDlg(0, aShortName);
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ for(sal_uInt16 i = 0; i < aFoundArr.size(); ++i)
+ {
+ TextBlockInfo_Impl* pData = &aFoundArr[i];
+ pDlg->InsertGlos(pData->sTitle, pData->sLongName);
+ }
+ pDlg->SelectEntryPos(0);
+ const sal_Int32 nRet = RET_OK == pDlg->Execute()?
+ pDlg->GetSelectedIdx():
+ LISTBOX_ENTRY_NOTFOUND;
+ delete pDlg;
+ if(LISTBOX_ENTRY_NOTFOUND != nRet)
+ {
+ TextBlockInfo_Impl* pData = &aFoundArr[nRet];
+ pGlossary = (SwTextBlocks *)pGlossaries->GetGroupDoc(pData->sGroupName);
+ nFound = pGlossary->GetIndex( aShortName );
+ }
+ else
+ {
+ nFound = (sal_uInt16) -1;
+ bCancel = sal_True;
+ }
+ }
+ }
+ }
+
+ // not found
+ if( nFound == (sal_uInt16) -1 )
+ {
+ if( !bCancel )
+ {
+ pGlossaries->PutGroupDoc(pGlossary);
+
+ const sal_Int32 nMaxLen = 50;
+ if(pWrtShell->IsSelection() && aShortName.getLength() > nMaxLen)
+ {
+ aShortName = aShortName.copy(0, nMaxLen) + " ...";
+ }
+ OUString aTmp( SW_RES(STR_NOGLOS));
+ aTmp = aTmp.replaceFirst("%1", aShortName);
+ InfoBox( pWrtShell->GetView().GetWindow(), aTmp ).Execute();
+ }
+
+ return sal_False;
+ }
+ else
+ {
+ SvxMacro aStartMacro(aEmptyOUStr, aEmptyOUStr, STARBASIC);
+ SvxMacro aEndMacro(aEmptyOUStr, aEmptyOUStr, STARBASIC);
+ GetMacros( aShortName, aStartMacro, aEndMacro, pGlossary );
+
+ // StartAction must not be before HasSelection and DelRight,
+ // otherwise the possible Shell change gets delayed and
+ // API-programs would hang.
+ // Moreover the event macro must also not be called in an action
+ pWrtShell->StartUndo(UNDO_INSGLOSSARY);
+ if( aStartMacro.HasMacro() )
+ pWrtShell->ExecMacro( aStartMacro );
+ if(pWrtShell->HasSelection())
+ pWrtShell->DelLeft();
+ pWrtShell->StartAllAction();
+
+ // cache all InputFields
+ SwInputFieldList aFldLst( pWrtShell, sal_True );
+
+ pWrtShell->InsertGlossary(*pGlossary, aShortName);
+ pWrtShell->EndAllAction();
+ if( aEndMacro.HasMacro() )
+ {
+ pWrtShell->ExecMacro( aEndMacro );
+ }
+ pWrtShell->EndUndo(UNDO_INSGLOSSARY);
+
+ // demand input for all new InputFields
+ if( aFldLst.BuildSortLst() )
+ pWrtShell->UpdateInputFlds( &aFldLst );
+ }
+ pGlossaries->PutGroupDoc(pGlossary);
+ return sal_True;
+}
+
+// add autotext
+bool SwGlossaryHdl::InsertGlossary(const OUString &rName)
+{
+ OSL_ENSURE(pWrtShell->CanInsert(), "illegal");
+
+ SwTextBlocks *pGlos =
+ pCurGrp? pCurGrp: rStatGlossaries.GetGroupDoc(aCurGrp);
+
+ if (!pGlos)
+ return false;
+
+ SvxMacro aStartMacro(aEmptyOUStr, aEmptyOUStr, STARBASIC);
+ SvxMacro aEndMacro(aEmptyOUStr, aEmptyOUStr, STARBASIC);
+ GetMacros( rName, aStartMacro, aEndMacro, pGlos );
+
+ // StartAction must not be before HasSelection and DelRight,
+ // otherwise the possible Shell change gets delayed and
+ // API-programs would hang.
+ // Moreover the event macro must also not be called in an action
+ if( aStartMacro.HasMacro() )
+ pWrtShell->ExecMacro( aStartMacro );
+ if( pWrtShell->HasSelection() )
+ pWrtShell->DelRight();
+ pWrtShell->StartAllAction();
+
+ // cache all InputFields
+ SwInputFieldList aFldLst( pWrtShell, sal_True );
+
+ pWrtShell->InsertGlossary(*pGlos, rName);
+ pWrtShell->EndAllAction();
+ if( aEndMacro.HasMacro() )
+ {
+ pWrtShell->ExecMacro( aEndMacro );
+ }
+
+ // demand input for all new InputFields
+ if( aFldLst.BuildSortLst() )
+ pWrtShell->UpdateInputFlds( &aFldLst );
+
+ if(!pCurGrp)
+ rStatGlossaries.PutGroupDoc(pGlos);
+ return true;
+}
+
+// set / ask for macro
+void SwGlossaryHdl::SetMacros(const OUString& rShortName,
+ const SvxMacro* pStart,
+ const SvxMacro* pEnd,
+ SwTextBlocks *pGlossary )
+{
+ SwTextBlocks *pGlos = pGlossary ? pGlossary :
+ pCurGrp ? pCurGrp
+ : rStatGlossaries.GetGroupDoc( aCurGrp );
+ SvxMacroTableDtor aMacroTbl;
+ if( pStart )
+ aMacroTbl.Insert( SW_EVENT_START_INS_GLOSSARY, *pStart);
+ if( pEnd )
+ aMacroTbl.Insert( SW_EVENT_END_INS_GLOSSARY, *pEnd);
+ sal_uInt16 nIdx = pGlos->GetIndex( rShortName );
+ if( !pGlos->SetMacroTable( nIdx, aMacroTbl ) && pGlos->GetError() )
+ ErrorHandler::HandleError( pGlos->GetError() );
+
+ if(!pCurGrp && !pGlossary)
+ rStatGlossaries.PutGroupDoc(pGlos);
+}
+
+void SwGlossaryHdl::GetMacros( const OUString &rShortName,
+ SvxMacro& rStart,
+ SvxMacro& rEnd,
+ SwTextBlocks *pGlossary )
+{
+ SwTextBlocks *pGlos = pGlossary ? pGlossary
+ : pCurGrp ? pCurGrp
+ : rStatGlossaries.GetGroupDoc(aCurGrp);
+ sal_uInt16 nIndex = pGlos->GetIndex( rShortName );
+ if( nIndex != USHRT_MAX )
+ {
+ SvxMacroTableDtor aMacroTbl;
+ if( pGlos->GetMacroTable( nIndex, aMacroTbl ) )
+ {
+ SvxMacro *pMacro = aMacroTbl.Get( SW_EVENT_START_INS_GLOSSARY );
+ if( pMacro )
+ rStart = *pMacro;
+
+ pMacro = aMacroTbl.Get( SW_EVENT_END_INS_GLOSSARY );
+ if( pMacro )
+ rEnd = *pMacro;
+ }
+ }
+
+ if( !pCurGrp && !pGlossary )
+ rStatGlossaries.PutGroupDoc( pGlos );
+}
+
+// ctor, dtor
+SwGlossaryHdl::SwGlossaryHdl(SfxViewFrame* pVwFrm, SwWrtShell *pSh)
+ : rStatGlossaries( *::GetGlossaries() ),
+ aCurGrp( rStatGlossaries.GetDefName() ),
+ pViewFrame( pVwFrm ),
+ pWrtShell( pSh ),
+ pCurGrp( 0 )
+{
+}
+
+SwGlossaryHdl::~SwGlossaryHdl()
+{
+ if( pCurGrp )
+ rStatGlossaries.PutGroupDoc( pCurGrp );
+}
+
+// rename an autotext
+sal_Bool SwGlossaryHdl::Rename(const OUString& rOldShort, const OUString& rNewShortName,
+ const OUString& rNewName )
+{
+ sal_Bool bRet = sal_False;
+ SwTextBlocks *pGlossary = pCurGrp ? pCurGrp
+ : rStatGlossaries.GetGroupDoc(aCurGrp);
+ if(pGlossary)
+ {
+ if(!ConvertToNew(*pGlossary))
+ return sal_False;
+
+ sal_uInt16 nIdx = pGlossary->GetIndex( rOldShort );
+ sal_uInt16 nOldLongIdx = pGlossary->GetLongIndex( rNewName );
+ sal_uInt16 nOldIdx = pGlossary->GetIndex( rNewShortName );
+
+ if( nIdx != USHRT_MAX &&
+ (nOldLongIdx == USHRT_MAX || nOldLongIdx == nIdx )&&
+ (nOldIdx == USHRT_MAX || nOldIdx == nIdx ))
+ {
+ pGlossary->Rename( nIdx, &rNewShortName, &rNewName );
+ bRet = pGlossary->GetError() == 0;
+ }
+ if( !pCurGrp )
+ rStatGlossaries.PutGroupDoc(pGlossary);
+ }
+ return bRet;
+}
+
+sal_Bool SwGlossaryHdl::IsReadOnly( const OUString* pGrpNm ) const
+{
+ SwTextBlocks *pGlossary = 0;
+
+ if (pGrpNm)
+ pGlossary = rStatGlossaries.GetGroupDoc( *pGrpNm );
+ else if (pCurGrp)
+ pGlossary = pCurGrp;
+ else
+ pGlossary = rStatGlossaries.GetGroupDoc(aCurGrp);
+
+ sal_Bool bRet = pGlossary ? pGlossary->IsReadOnly() : sal_True;
+ if( pGrpNm || !pCurGrp )
+ delete pGlossary;
+ return bRet;
+}
+
+sal_Bool SwGlossaryHdl::IsOld() const
+{
+ SwTextBlocks *pGlossary = pCurGrp ? pCurGrp
+ : rStatGlossaries.GetGroupDoc(aCurGrp);
+ sal_Bool bRet = pGlossary ? pGlossary->IsOld() : sal_False;
+ if( !pCurGrp )
+ delete pGlossary;
+ return bRet;
+}
+
+// find group without path index
+sal_Bool SwGlossaryHdl::FindGroupName(OUString& rGroup)
+{
+ return rStatGlossaries.FindGroupName(rGroup);
+}
+
+sal_Bool SwGlossaryHdl::CopyToClipboard(SwWrtShell& rSh, const OUString& rShortName)
+{
+ SwTextBlocks *pGlossary = pCurGrp ? pCurGrp
+ : rStatGlossaries.GetGroupDoc(aCurGrp);
+
+ SwTransferable* pTransfer = new SwTransferable( rSh );
+/*??*/uno::Reference<
+ datatransfer::XTransferable > xRef( pTransfer );
+
+ int nRet = pTransfer->CopyGlossary( *pGlossary, rShortName );
+ if( !pCurGrp )
+ rStatGlossaries.PutGroupDoc( pGlossary );
+ return 0 != nRet;
+}
+
+sal_Bool SwGlossaryHdl::ImportGlossaries( const OUString& rName )
+{
+ sal_Bool bRet = sal_False;
+ if( !rName.isEmpty() )
+ {
+ const SfxFilter* pFilter = 0;
+ SfxMedium* pMed = new SfxMedium( rName, STREAM_READ, 0, 0 );
+ SfxFilterMatcher aMatcher( OUString("swriter") );
+ pMed->UseInteractionHandler( sal_True );
+ if( !aMatcher.GuessFilter( *pMed, &pFilter, sal_False ) )
+ {
+ SwTextBlocks *pGlossary = NULL;
+ pMed->SetFilter( pFilter );
+ Reader* pR = SwReaderWriter::GetReader( pFilter->GetUserData() );
+ if( pR && 0 != ( pGlossary = pCurGrp ? pCurGrp
+ : rStatGlossaries.GetGroupDoc(aCurGrp)) )
+ {
+ SwReader aReader( *pMed, rName );
+ if( aReader.HasGlossaries( *pR ) )
+ {
+ const SvxAutoCorrCfg& rCfg = SvxAutoCorrCfg::Get();
+ bRet = aReader.ReadGlossaries( *pR, *pGlossary,
+ rCfg.IsSaveRelFile() );
+ }
+ }
+ }
+ DELETEZ(pMed);
+ }
+ return bRet;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/dochdl/swdtflvr.cxx b/sw/source/core/uibase/dochdl/swdtflvr.cxx
new file mode 100644
index 000000000000..9d4acca9e51c
--- /dev/null
+++ b/sw/source/core/uibase/dochdl/swdtflvr.cxx
@@ -0,0 +1,3783 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <com/sun/star/embed/XVisualObject.hpp>
+#include <com/sun/star/embed/XTransactedObject.hpp>
+#include <com/sun/star/embed/Aspects.hpp>
+#include <com/sun/star/embed/XEmbedObjectClipboardCreator.hpp>
+#include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
+#include <com/sun/star/embed/MSOLEObjectSystemCreator.hpp>
+
+#include <svtools/embedtransfer.hxx>
+#include <svtools/insdlg.hxx>
+#include <unotools/tempfile.hxx>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/servicehelper.hxx>
+#include <comphelper/storagehelper.hxx>
+#include <comphelper/string.hxx>
+#include <unotools/ucbstreamhelper.hxx>
+#include <sot/filelist.hxx>
+#include <svx/svxdlg.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <osl/endian.h>
+#include <sfx2/linkmgr.hxx>
+#include <tools/urlobj.hxx>
+#include <vcl/wrkwin.hxx>
+#include <vcl/msgbox.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svl/stritem.hxx>
+#include <svtools/imap.hxx>
+#include <sot/storage.hxx>
+#include <vcl/graph.hxx>
+#include <svl/urihelper.hxx>
+#include <svx/svdmodel.hxx>
+#include <svx/xexch.hxx>
+#include <svx/xmlexchg.hxx>
+#include <svx/dbaexchange.hxx>
+#include <svx/clipfmtitem.hxx>
+#include <sfx2/mieclip.hxx>
+#include <svx/svdetc.hxx>
+#include <svx/xoutbmp.hxx>
+#include <svl/urlbmk.hxx>
+#include <svtools/htmlout.hxx>
+#include <svx/hlnkitem.hxx>
+#include <svtools/inetimg.hxx>
+#include <editeng/paperinf.hxx>
+#include <svx/fmview.hxx>
+#include <editeng/scripttypeitem.hxx>
+#include <sfx2/docfilt.hxx>
+#include <svtools/imapobj.hxx>
+#include <sfx2/docfile.hxx>
+#include <unotools/transliterationwrapper.hxx>
+#include <unotools/streamwrap.hxx>
+#include <vcl/graphicfilter.hxx>
+
+#include <svx/unomodel.hxx>
+#include <fmturl.hxx>
+#include <fmtinfmt.hxx>
+#include <fmtfsize.hxx>
+#include <swdtflvr.hxx>
+#include <shellio.hxx>
+#include <ddefld.hxx>
+#include <doc.hxx>
+#include <IDocumentUndoRedo.hxx>
+#include <pagedesc.hxx>
+#include <IMark.hxx>
+#include <docary.hxx>
+#include <section.hxx>
+#include <ndtxt.hxx>
+#include <edtwin.hxx>
+#include <navicont.hxx>
+#include <swcont.hxx>
+#include <wrtsh.hxx>
+#include <swmodule.hxx>
+#include <view.hxx>
+#include <docsh.hxx>
+#include <wdocsh.hxx>
+#include <fldbas.hxx>
+#include <swundo.hxx>
+#include <pam.hxx>
+#include <ndole.hxx>
+#include <swwait.hxx>
+#include <viewopt.hxx>
+#include <swerror.h>
+#include <SwCapObjType.hxx>
+#include <cmdid.h>
+#include <dochdl.hrc>
+#include <comcore.hrc>
+#include <sot/stg.hxx>
+#include <svx/svditer.hxx>
+#include <editeng/eeitem.hxx>
+#include <editeng/fhgtitem.hxx>
+#include <svx/svdpage.hxx>
+#include <avmedia/mediawindow.hxx>
+#include <swcrsr.hxx>
+#include <SwRewriter.hxx>
+#include <globals.hrc>
+#include <app.hrc>
+#include <osl/mutex.hxx>
+#include <vcl/svapp.hxx>
+#include <swserv.hxx>
+#include <switerator.hxx>
+
+#include <vcl/GraphicNativeTransform.hxx>
+#include <vcl/GraphicNativeMetadata.hxx>
+
+#include <boost/scoped_ptr.hpp>
+
+extern bool bFrmDrag;
+extern bool bDDINetAttr;
+extern bool bExecuteDrag;
+
+#define OLESIZE 11905 - 2 * lMinBorder, 6 * MM50
+
+#define SWTRANSFER_OBJECTTYPE_DRAWMODEL 0x00000001
+#define SWTRANSFER_OBJECTTYPE_HTML 0x00000002
+#define SWTRANSFER_OBJECTTYPE_RTF 0x00000004
+#define SWTRANSFER_OBJECTTYPE_STRING 0x00000008
+#define SWTRANSFER_OBJECTTYPE_SWOLE 0x00000010
+#define SWTRANSFER_OBJECTTYPE_DDE 0x00000020
+
+using namespace ::svx;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::datatransfer;
+using namespace nsTransferBufferType;
+
+#define DDE_TXT_ENCODING osl_getThreadTextEncoding()
+
+class SwTrnsfrDdeLink : public ::sfx2::SvBaseLink
+{
+ OUString sName;
+ ::sfx2::SvLinkSourceRef refObj;
+ SwTransferable& rTrnsfr;
+ SwDocShell* pDocShell;
+ sal_uLong nOldTimeOut;
+ sal_Bool bDelBookmrk : 1;
+ sal_Bool bInDisconnect : 1;
+
+ sal_Bool FindDocShell();
+
+ using sfx2::SvBaseLink::Disconnect;
+
+protected:
+ virtual ~SwTrnsfrDdeLink();
+
+public:
+ SwTrnsfrDdeLink( SwTransferable& rTrans, SwWrtShell& rSh );
+
+ virtual ::sfx2::SvBaseLink::UpdateResult DataChanged(
+ const OUString& rMimeType, const ::com::sun::star::uno::Any & rValue );
+ virtual void Closed();
+
+ sal_Bool WriteData( SvStream& rStrm );
+
+ void Disconnect( sal_Bool bRemoveDataAdvise );
+};
+
+// helper class for Action and Undo enclosing
+class SwTrnsfrActionAndUndo
+{
+ SwWrtShell *pSh;
+ SwUndoId eUndoId;
+public:
+ SwTrnsfrActionAndUndo( SwWrtShell *pS, SwUndoId nId,
+ const SwRewriter * pRewriter = 0,
+ sal_Bool bDelSel = sal_False)
+ : pSh( pS ), eUndoId( nId )
+ {
+ pSh->StartUndo( eUndoId, pRewriter );
+ if( bDelSel )
+ pSh->DelRight();
+ pSh->StartAllAction();
+ }
+ ~SwTrnsfrActionAndUndo()
+ {
+ pSh->EndUndo();
+ pSh->EndAllAction();
+ }
+};
+
+SwTransferable::SwTransferable( SwWrtShell& rSh )
+ : pWrtShell( &rSh ),
+ pCreatorView( 0 ),
+ pClpDocFac( 0 ),
+ pClpGraphic( 0 ),
+ pClpBitmap( 0 ),
+ pOrigGrf( 0 ),
+ pBkmk( 0 ),
+ pImageMap( 0 ),
+ pTargetURL( 0 ),
+ eBufferType( TRNSFR_NONE )
+{
+ rSh.GetView().AddTransferable(*this);
+ SwDocShell* pDShell = rSh.GetDoc()->GetDocShell();
+ if( pDShell )
+ {
+ pDShell->FillTransferableObjectDescriptor( aObjDesc );
+ if( pDShell->GetMedium() )
+ {
+ const INetURLObject& rURLObj = pDShell->GetMedium()->GetURLObject();
+ aObjDesc.maDisplayName = URIHelper::removePassword(
+ rURLObj.GetMainURL( INetURLObject::NO_DECODE ),
+ INetURLObject::WAS_ENCODED,
+ INetURLObject::DECODE_UNAMBIGUOUS );
+ }
+
+ PrepareOLE( aObjDesc );
+ }
+}
+
+SwTransferable::~SwTransferable()
+{
+ Application::GetSolarMutex().acquire();
+
+ // the DDELink still needs the WrtShell!
+ if( refDdeLink.Is() )
+ {
+ ((SwTrnsfrDdeLink*)&refDdeLink)->Disconnect( sal_True );
+ refDdeLink.Clear();
+ }
+
+ pWrtShell = 0;
+
+ // release reference to the document so that aDocShellRef will delete
+ // it (if aDocShellRef is set). Otherwise, the OLE nodes keep references
+ // to their sub-storage when the storage is already dead.
+ delete pClpDocFac;
+
+ // first close, then the Ref. can be cleared as well, so that
+ // the DocShell really gets deleted!
+ if( aDocShellRef.Is() )
+ {
+ SfxObjectShell * pObj = aDocShellRef;
+ SwDocShell* pDocSh = (SwDocShell*)pObj;
+ pDocSh->DoClose();
+ }
+ aDocShellRef.Clear();
+
+ SwModule* pMod = SW_MOD();
+ if(pMod)
+ {
+ if ( pMod->pDragDrop == this )
+ pMod->pDragDrop = 0;
+ else if ( pMod->pXSelection == this )
+ pMod->pXSelection = 0;
+ }
+
+ delete pClpGraphic;
+ delete pClpBitmap;
+ delete pImageMap;
+ delete pTargetURL;
+ delete pBkmk;
+
+ eBufferType = TRNSFR_NONE;
+
+ Application::GetSolarMutex().release();
+}
+
+static SwDoc * lcl_GetDoc(SwDocFac & rDocFac)
+{
+ SwDoc *const pDoc = rDocFac.GetDoc();
+ OSL_ENSURE( pDoc, "Document not found" );
+ if (pDoc)
+ {
+ pDoc->SetClipBoard( true );
+ }
+ return pDoc;
+}
+
+void SwTransferable::ObjectReleased()
+{
+ SwModule *pMod = SW_MOD();
+ if( this == pMod->pDragDrop )
+ pMod->pDragDrop = 0;
+ else if( this == pMod->pXSelection )
+ pMod->pXSelection = 0;
+}
+
+void SwTransferable::AddSupportedFormats()
+{
+ // only need if we are the current XSelection Object
+ SwModule *pMod = SW_MOD();
+ if( this == pMod->pXSelection )
+ {
+ SetDataForDragAndDrop( Point( 0,0) );
+ }
+}
+
+void SwTransferable::InitOle( SfxObjectShell* pDoc, SwDoc& rDoc )
+{
+ //set OleVisArea. Upper left corner of the page and size of
+ //RealSize in Twips.
+ const Size aSz( OLESIZE );
+ SwRect aVis( Point( DOCUMENTBORDER, DOCUMENTBORDER ), aSz );
+ pDoc->SetVisArea( aVis.SVRect() );
+ rDoc.set(IDocumentSettingAccess::BROWSE_MODE, true );
+}
+
+uno::Reference < embed::XEmbeddedObject > SwTransferable::FindOLEObj( sal_Int64& nAspect ) const
+{
+ uno::Reference < embed::XEmbeddedObject > xObj;
+ if( pClpDocFac )
+ {
+ SwIterator<SwCntntNode,SwFmtColl> aIter( *pClpDocFac->GetDoc()->GetDfltGrfFmtColl() );
+ for( SwCntntNode* pNd = aIter.First(); pNd; pNd = aIter.Next() )
+ if( ND_OLENODE == pNd->GetNodeType() )
+ {
+ xObj = ((SwOLENode*)pNd)->GetOLEObj().GetOleRef();
+ nAspect = ((SwOLENode*)pNd)->GetAspect();
+ break;
+ }
+ }
+ return xObj;
+}
+
+const Graphic* SwTransferable::FindOLEReplacementGraphic() const
+{
+ if( pClpDocFac )
+ {
+ SwIterator<SwCntntNode,SwFmtColl> aIter( *pClpDocFac->GetDoc()->GetDfltGrfFmtColl() );
+ for( SwCntntNode* pNd = aIter.First(); pNd; pNd = aIter.Next() )
+ if( ND_OLENODE == pNd->GetNodeType() )
+ {
+ return ((SwOLENode*)pNd)->GetGraphic();
+ }
+ }
+
+ return NULL;
+}
+
+void SwTransferable::RemoveDDELinkFormat( const Window& rWin )
+{
+ RemoveFormat( SOT_FORMATSTR_ID_LINK );
+ CopyToClipboard( (Window*)&rWin );
+}
+
+namespace
+{
+ //Resolves: fdo#40717 surely when we create a clipboard document we should
+ //overwrite the clipboard documents styles and settings with that of the
+ //source, so that we can WYSIWYG paste. If we want that the destinations
+ //styles are used over the source styles, that's a matter of the
+ //destination paste code to handle, not the source paste code.
+ void lclOverWriteDoc(SwWrtShell &rSrcWrtShell, SwDoc &rDest)
+ {
+ const SwDoc &rSrc = *rSrcWrtShell.GetDoc();
+
+ rDest.ReplaceCompatabilityOptions(rSrc);
+ rDest.ReplaceDefaults(rSrc);
+
+ //It would probably make most sense here to only insert the styles used
+ //by the selection, e.g. apply SwDoc::IsUsed on styles ?
+ rDest.ReplaceStyles(rSrc, false);
+
+ rSrcWrtShell.Copy(&rDest);
+ }
+
+ void lclCheckAndPerformRotation(Graphic& aGraphic)
+ {
+ GraphicNativeMetadata aMetadata;
+ if ( aMetadata.read(aGraphic) )
+ {
+ sal_uInt16 aRotation = aMetadata.getRotation();
+ if (aRotation != 0)
+ {
+ MessageDialog aQueryBox( 0,"QueryRotateIntoStandardOrientationDialog","modules/swriter/ui/queryrotateintostandarddialog.ui");
+ if (aQueryBox.Execute() == RET_YES)
+ {
+ GraphicNativeTransform aTransform( aGraphic );
+ aTransform.rotate( aRotation );
+ }
+ }
+ }
+ }
+}
+
+sal_Bool SwTransferable::GetData( const DataFlavor& rFlavor )
+{
+ sal_uInt32 nFormat = SotExchange::GetFormat( rFlavor );
+
+ // we can only fullfil the request if
+ // 1) we have data for this format
+ // 2) we have either a clipboard document (pClpDocFac), or
+ // we have a SwWrtShell (so we can generate a new clipboard document)
+ if( !HasFormat( nFormat ) || ( pClpDocFac == NULL && pWrtShell == NULL ) )
+ return sal_False;
+
+ if( !pClpDocFac )
+ {
+ SelectionType nSelectionType = pWrtShell->GetSelectionType();
+
+ // when pending we will not get the correct type, but nsSelectionType::SEL_TXT
+ // as fallback. This *happens* durning D&D, so we need to check if we are in
+ // the fallback and just try to get a graphic
+ const bool bPending(pWrtShell->BasicActionPend());
+
+ // SEL_GRF kommt vom ContentType der editsh
+ if(bPending || ((nsSelectionType::SEL_GRF | nsSelectionType::SEL_DRW_FORM) & nSelectionType))
+ {
+ pClpGraphic = new Graphic;
+ if( !pWrtShell->GetDrawObjGraphic( FORMAT_GDIMETAFILE, *pClpGraphic ))
+ pOrigGrf = pClpGraphic;
+ pClpBitmap = new Graphic;
+ if( !pWrtShell->GetDrawObjGraphic( FORMAT_BITMAP, *pClpBitmap ))
+ pOrigGrf = pClpBitmap;
+
+ // is it an URL-Button ?
+ OUString sURL;
+ OUString sDesc;
+ if( pWrtShell->GetURLFromButton( sURL, sDesc ) )
+ {
+ pBkmk = new INetBookmark( sURL, sDesc );
+ eBufferType = TRNSFR_INETFLD;
+ }
+ }
+
+ pClpDocFac = new SwDocFac;
+ SwDoc *const pTmpDoc = lcl_GetDoc(*pClpDocFac);
+
+ pTmpDoc->LockExpFlds(); // never update fields - leave text as it is
+ lclOverWriteDoc(*pWrtShell, *pTmpDoc);
+
+ // in CORE a new one was created (OLE-Objekte copied!)
+ aDocShellRef = pTmpDoc->GetTmpDocShell();
+ if( aDocShellRef.Is() )
+ SwTransferable::InitOle( aDocShellRef, *pTmpDoc );
+ pTmpDoc->SetTmpDocShell( (SfxObjectShell*)NULL );
+
+ if( nSelectionType & nsSelectionType::SEL_TXT && !pWrtShell->HasMark() )
+ {
+ SwContentAtPos aCntntAtPos( SwContentAtPos::SW_INETATTR );
+
+ Point aPos( SwEditWin::GetDDStartPosX(), SwEditWin::GetDDStartPosY());
+
+ sal_Bool bSelect = bExecuteDrag &&
+ pWrtShell->GetView().GetDocShell() &&
+ !pWrtShell->GetView().GetDocShell()->IsReadOnly();
+ if( pWrtShell->GetContentAtPos( aPos, aCntntAtPos, bSelect ) )
+ {
+ pBkmk = new INetBookmark(
+ ((SwFmtINetFmt*)aCntntAtPos.aFnd.pAttr)->GetValue(),
+ aCntntAtPos.sStr );
+ eBufferType = TRNSFR_INETFLD;
+ if( bSelect )
+ pWrtShell->SelectTxtAttr( RES_TXTATR_INETFMT );
+ }
+ }
+ if( pWrtShell->IsFrmSelected() )
+ {
+ SfxItemSet aSet( pWrtShell->GetAttrPool(), RES_URL, RES_URL );
+ pWrtShell->GetFlyFrmAttr( aSet );
+ const SwFmtURL& rURL = (SwFmtURL&)aSet.Get( RES_URL );
+ if( rURL.GetMap() )
+ pImageMap = new ImageMap( *rURL.GetMap() );
+ else if( !rURL.GetURL().isEmpty() )
+ pTargetURL = new INetImage( aEmptyOUStr, rURL.GetURL(),
+ rURL.GetTargetFrameName(),
+ aEmptyOUStr, Size() );
+ }
+ }
+
+ sal_Bool bOK = sal_False;
+ if( TRNSFR_OLE == eBufferType )
+ {
+ //TODO/MBA: testing - is this the "single OLE object" case?!
+ // get OLE-Object from ClipDoc and get the data from that.
+ sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT; // will be set in the next statement
+ uno::Reference < embed::XEmbeddedObject > xObj = FindOLEObj( nAspect );
+ const Graphic* pOLEGraph = FindOLEReplacementGraphic();
+ if( xObj.is() )
+ {
+ TransferableDataHelper aD( new SvEmbedTransferHelper( xObj, pOLEGraph, nAspect ) );
+ uno::Any aAny( aD.GetAny( rFlavor ));
+ if( aAny.hasValue() )
+ bOK = SetAny( aAny, rFlavor );
+ }
+
+ // the following solution will be used in the case when the object can not generate the image
+ // TODO/LATER: in future the transferhelper must probably be created based on object and the replacement stream
+ if ( nFormat == SOT_FORMAT_GDIMETAFILE )
+ {
+ pOLEGraph = FindOLEReplacementGraphic();
+ if ( pOLEGraph )
+ bOK = SetGDIMetaFile( pOLEGraph->GetGDIMetaFile(), rFlavor );
+ }
+ }
+ else
+ {
+ switch( nFormat )
+ {
+ case SOT_FORMATSTR_ID_LINK:
+ if( refDdeLink.Is() )
+ bOK = SetObject( &refDdeLink,
+ SWTRANSFER_OBJECTTYPE_DDE, rFlavor );
+ break;
+
+ case SOT_FORMATSTR_ID_OBJECTDESCRIPTOR:
+ case SOT_FORMATSTR_ID_LINKSRCDESCRIPTOR:
+ bOK = SetTransferableObjectDescriptor( aObjDesc, rFlavor );
+ break;
+
+ case SOT_FORMATSTR_ID_DRAWING:
+ {
+ SwDoc *const pDoc = lcl_GetDoc(*pClpDocFac);
+ bOK = SetObject( pDoc->GetDrawModel(),
+ SWTRANSFER_OBJECTTYPE_DRAWMODEL, rFlavor );
+ }
+ break;
+
+ case SOT_FORMAT_STRING:
+ {
+ SwDoc *const pDoc = lcl_GetDoc(*pClpDocFac);
+ bOK = SetObject( pDoc, SWTRANSFER_OBJECTTYPE_STRING, rFlavor );
+ }
+ break;
+ case SOT_FORMAT_RTF:
+ {
+ SwDoc *const pDoc = lcl_GetDoc(*pClpDocFac);
+ bOK = SetObject( pDoc, SWTRANSFER_OBJECTTYPE_RTF, rFlavor );
+ }
+ break;
+
+ case SOT_FORMATSTR_ID_HTML:
+ {
+ SwDoc *const pDoc = lcl_GetDoc(*pClpDocFac);
+ bOK = SetObject( pDoc, SWTRANSFER_OBJECTTYPE_HTML, rFlavor );
+ }
+ break;
+
+ case SOT_FORMATSTR_ID_SVXB:
+ if( eBufferType & TRNSFR_GRAPHIC && pOrigGrf )
+ bOK = SetGraphic( *pOrigGrf, rFlavor );
+ break;
+
+ case SOT_FORMAT_GDIMETAFILE:
+ if( eBufferType & TRNSFR_GRAPHIC )
+ bOK = SetGDIMetaFile( pClpGraphic->GetGDIMetaFile(), rFlavor );
+ break;
+ case SOT_FORMAT_BITMAP:
+ case SOT_FORMATSTR_ID_PNG:
+ // Neither pClpBitmap nor pClpGraphic are necessarily set
+ if( (eBufferType & TRNSFR_GRAPHIC) && (pClpBitmap != 0 || pClpGraphic != 0))
+ bOK = SetBitmapEx( (pClpBitmap ? pClpBitmap : pClpGraphic)->GetBitmapEx(), rFlavor );
+ break;
+
+ case SOT_FORMATSTR_ID_SVIM:
+ if( pImageMap )
+ bOK = SetImageMap( *pImageMap, rFlavor );
+ break;
+
+ case SOT_FORMATSTR_ID_INET_IMAGE:
+ if( pTargetURL )
+ bOK = SetINetImage( *pTargetURL, rFlavor );
+ break;
+
+ case SOT_FORMATSTR_ID_SOLK:
+ case SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK:
+ case SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR:
+ case SOT_FORMATSTR_ID_FILECONTENT:
+ case SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR:
+ case SOT_FORMAT_FILE:
+ if( (TRNSFR_INETFLD & eBufferType) && pBkmk )
+ bOK = SetINetBookmark( *pBkmk, rFlavor );
+ break;
+
+ case SOT_FORMATSTR_ID_EMBED_SOURCE:
+ if( !aDocShellRef.Is() )
+ {
+ SwDoc *const pDoc = lcl_GetDoc(*pClpDocFac);
+ SwDocShell* pNewDocSh = new SwDocShell( pDoc,
+ SFX_CREATE_MODE_EMBEDDED );
+ aDocShellRef = pNewDocSh;
+ aDocShellRef->DoInitNew( NULL );
+ SwTransferable::InitOle( aDocShellRef, *pDoc );
+ }
+ bOK = SetObject( &aDocShellRef, SWTRANSFER_OBJECTTYPE_SWOLE,
+ rFlavor );
+ break;
+ }
+ }
+ return bOK;
+}
+
+sal_Bool SwTransferable::WriteObject( SotStorageStreamRef& xStream,
+ void* pObject, sal_uInt32 nObjectType,
+ const DataFlavor& /*rFlavor*/ )
+{
+ sal_Bool bRet = sal_False;
+ WriterRef xWrt;
+
+ switch( nObjectType )
+ {
+ case SWTRANSFER_OBJECTTYPE_DRAWMODEL:
+ {
+ // don't change the sequence of commands
+ SdrModel *pModel = (SdrModel*)pObject;
+ xStream->SetBufferSize( 16348 );
+
+ // 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
+ OSL_ENSURE(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);
+ }
+ }
+ }
+
+ {
+ uno::Reference<io::XOutputStream> xDocOut( new utl::OOutputStreamWrapper( *xStream ) );
+ if( SvxDrawingLayerExport( pModel, xDocOut ) )
+ xStream->Commit();
+ }
+
+ bRet = ERRCODE_NONE == xStream->GetError();
+ }
+ break;
+
+ case SWTRANSFER_OBJECTTYPE_SWOLE:
+ {
+ SfxObjectShell* pEmbObj = (SfxObjectShell*) pObject;
+ 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 BaseURL for clipboard
+ SfxMedium aMedium( xWorkStore, OUString() );
+ bRet = pEmbObj->DoSaveObjectAs( aMedium, sal_False );
+ pEmbObj->DoSaveCompleted();
+
+ uno::Reference< embed::XTransactedObject > xTransact( xWorkStore, uno::UNO_QUERY );
+ if ( xTransact.is() )
+ xTransact->commit();
+
+ boost::scoped_ptr<SvStream> pSrcStm(::utl::UcbStreamHelper::CreateStream( aTempFile.GetURL(), STREAM_READ ));
+ if( pSrcStm )
+ {
+ xStream->SetBufferSize( 0xff00 );
+ xStream->WriteStream( *pSrcStm );
+ pSrcStm.reset();
+ }
+
+ bRet = sal_True;
+
+ xWorkStore->dispose();
+ xWorkStore = uno::Reference < embed::XStorage >();
+ xStream->Commit();
+ }
+ catch (const uno::Exception&)
+ {
+ }
+
+ bRet = ( xStream->GetError() == ERRCODE_NONE );
+ }
+ break;
+
+ case SWTRANSFER_OBJECTTYPE_DDE:
+ {
+ xStream->SetBufferSize( 1024 );
+ SwTrnsfrDdeLink* pDdeLnk = (SwTrnsfrDdeLink*)pObject;
+ if( pDdeLnk->WriteData( *xStream ) )
+ {
+ xStream->Commit();
+ bRet = ERRCODE_NONE == xStream->GetError();
+ }
+ }
+ break;
+
+ case SWTRANSFER_OBJECTTYPE_HTML:
+ GetHTMLWriter( aEmptyOUStr, OUString(), xWrt );
+ break;
+
+ case SWTRANSFER_OBJECTTYPE_RTF:
+ GetRTFWriter( aEmptyOUStr, OUString(), xWrt );
+ break;
+
+ case SWTRANSFER_OBJECTTYPE_STRING:
+ GetASCWriter( aEmptyOUStr, OUString(), xWrt );
+ if( xWrt.Is() )
+ {
+ SwAsciiOptions aAOpt;
+ aAOpt.SetCharSet( RTL_TEXTENCODING_UTF8 );
+ xWrt->SetAsciiOptions( aAOpt );
+
+ // no start char for clipboard
+ xWrt->bUCS2_WithStartChar = sal_False;
+ }
+ break;
+ }
+
+ if( xWrt.Is() )
+ {
+ SwDoc* pDoc = (SwDoc*)pObject;
+ xWrt->bWriteClipboardDoc = sal_True;
+ xWrt->bWriteOnlyFirstTable = 0 != (TRNSFR_TABELLE & eBufferType);
+ xWrt->SetShowProgress( sal_False );
+
+#if defined(DEBUGPASTE)
+ SvFileStream aPasteDebug(OUString(
+ "PASTEBUFFER.debug"), STREAM_WRITE|STREAM_TRUNC);
+ SwWriter aDbgWrt( aPasteDebug, *pDoc );
+ aDbgWrt.Write( xWrt );
+#endif
+
+ SwWriter aWrt( *xStream, *pDoc );
+ if( !IsError( aWrt.Write( xWrt )) )
+ {
+ xStream->WriteChar( '\0' ); // terminate with a zero
+ xStream->Commit();
+ bRet = sal_True;
+ }
+ }
+
+ return bRet;
+}
+
+int SwTransferable::Cut()
+{
+ int nRet = Copy( sal_True );
+ if( nRet )
+ DeleteSelection();
+ return nRet;
+}
+
+void SwTransferable::DeleteSelection()
+{
+ if(!pWrtShell)
+ return;
+ // ask for type of selection before action-bracketing
+ const int nSelection = pWrtShell->GetSelectionType();
+ pWrtShell->StartUndo( UNDO_DELETE );
+ if( ( nsSelectionType::SEL_TXT | nsSelectionType::SEL_TBL ) & nSelection )
+ pWrtShell->IntelligentCut( nSelection );
+ pWrtShell->DelRight();
+ pWrtShell->EndUndo( UNDO_DELETE );
+}
+
+int SwTransferable::PrepareForCopy( sal_Bool bIsCut )
+{
+ int nRet = 1;
+ if(!pWrtShell)
+ return 0;
+
+ OUString sGrfNm;
+ const int nSelection = pWrtShell->GetSelectionType();
+ if( nSelection == nsSelectionType::SEL_GRF )
+ {
+ pClpGraphic = new Graphic;
+ if( !pWrtShell->GetDrawObjGraphic( FORMAT_GDIMETAFILE, *pClpGraphic ))
+ pOrigGrf = pClpGraphic;
+ pClpBitmap = new Graphic;
+ if( !pWrtShell->GetDrawObjGraphic( FORMAT_BITMAP, *pClpBitmap ))
+ pOrigGrf = pClpBitmap;
+
+ pClpDocFac = new SwDocFac;
+ SwDoc *const pDoc = lcl_GetDoc(*pClpDocFac);
+ pWrtShell->Copy( pDoc );
+
+ if (pOrigGrf && !pOrigGrf->GetBitmap().IsEmpty())
+ AddFormat( SOT_FORMATSTR_ID_SVXB );
+
+ PrepareOLE( aObjDesc );
+ AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR );
+
+ const Graphic* pGrf = pWrtShell->GetGraphic();
+ if( pGrf && pGrf->IsSupportedGraphic() )
+ {
+ AddFormat( FORMAT_GDIMETAFILE );
+ AddFormat( SOT_FORMATSTR_ID_PNG );
+ AddFormat( FORMAT_BITMAP );
+ }
+ eBufferType = TRNSFR_GRAPHIC;
+ pWrtShell->GetGrfNms( &sGrfNm, 0 );
+ }
+ else if ( nSelection == nsSelectionType::SEL_OLE )
+ {
+ pClpDocFac = new SwDocFac;
+ SwDoc *const pDoc = lcl_GetDoc(*pClpDocFac);
+ aDocShellRef = new SwDocShell( pDoc, SFX_CREATE_MODE_EMBEDDED);
+ aDocShellRef->DoInitNew( NULL );
+ pWrtShell->Copy( pDoc );
+
+ AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE );
+
+ // --> OD #i98753#
+ // set size of embedded object at the object description structure
+ aObjDesc.maSize = OutputDevice::LogicToLogic( pWrtShell->GetObjSize(), MAP_TWIP, MAP_100TH_MM );
+ // <--
+ PrepareOLE( aObjDesc );
+ AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR );
+
+ AddFormat( FORMAT_GDIMETAFILE );
+ eBufferType = TRNSFR_OLE;
+ }
+ // Is there anything to provide anyway?
+ else if ( pWrtShell->IsSelection() || pWrtShell->IsFrmSelected() ||
+ pWrtShell->IsObjSelected() )
+ {
+ boost::scoped_ptr<SwWait> pWait;
+ if( pWrtShell->ShouldWait() )
+ pWait.reset(new SwWait( *pWrtShell->GetView().GetDocShell(), true ));
+
+ pClpDocFac = new SwDocFac;
+
+ // create additional cursor so that equal treatment of keyboard
+ // and mouse selection is possible.
+ // In AddMode with keyboard selection, the new cursor is not created
+ // before the cursor is moved after end of selection.
+ if( pWrtShell->IsAddMode() && pWrtShell->SwCrsrShell::HasSelection() )
+ pWrtShell->CreateCrsr();
+
+ SwDoc *const pTmpDoc = lcl_GetDoc(*pClpDocFac);
+
+ pTmpDoc->LockExpFlds(); // Never update fields - leave text as is
+ lclOverWriteDoc(*pWrtShell, *pTmpDoc);
+
+ {
+ IDocumentMarkAccess* const pMarkAccess = pTmpDoc->getIDocumentMarkAccess();
+ ::std::vector< ::sw::mark::IMark* > vDdeMarks;
+ // find all DDE-Bookmarks
+ for(IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getAllMarksBegin();
+ ppMark != pMarkAccess->getAllMarksEnd();
+ ++ppMark)
+ {
+ if(IDocumentMarkAccess::DDE_BOOKMARK == IDocumentMarkAccess::GetType(**ppMark))
+ vDdeMarks.push_back(ppMark->get());
+ }
+ // remove all DDE-Bookmarks, they are invalid inside the clipdoc!
+ for(::std::vector< ::sw::mark::IMark* >::iterator ppMark = vDdeMarks.begin();
+ ppMark != vDdeMarks.end();
+ ++ppMark)
+ pMarkAccess->deleteMark(*ppMark);
+ }
+
+ // a new one was created in CORE (OLE objects copied!)
+ aDocShellRef = pTmpDoc->GetTmpDocShell();
+ if( aDocShellRef.Is() )
+ SwTransferable::InitOle( aDocShellRef, *pTmpDoc );
+ pTmpDoc->SetTmpDocShell( (SfxObjectShell*)NULL );
+
+ if( pWrtShell->IsObjSelected() )
+ eBufferType = TRNSFR_DRAWING;
+ else
+ {
+ eBufferType = TRNSFR_DOCUMENT;
+ if (pWrtShell->IntelligentCut(nSelection, sal_False) != SwWrtShell::NO_WORD)
+ eBufferType = (TransferBufferType)(TRNSFR_DOCUMENT_WORD | eBufferType);
+ }
+
+ int bDDELink = pWrtShell->IsSelection();
+ if( nSelection & nsSelectionType::SEL_TBL_CELLS )
+ {
+ eBufferType = (TransferBufferType)(TRNSFR_TABELLE | eBufferType);
+ bDDELink = pWrtShell->HasWholeTabSelection();
+ }
+
+ //When someone needs it, we 'OLE' him something
+ AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE );
+
+ //put RTF ahead of the OLE's Metafile to have less loss
+ if( !pWrtShell->IsObjSelected() )
+ {
+ AddFormat( FORMAT_RTF );
+ AddFormat( SOT_FORMATSTR_ID_HTML );
+ }
+ if( pWrtShell->IsSelection() )
+ AddFormat( FORMAT_STRING );
+
+ if( nSelection & ( nsSelectionType::SEL_DRW | nsSelectionType::SEL_DRW_FORM ))
+ {
+ AddFormat( SOT_FORMATSTR_ID_DRAWING );
+ if ( nSelection & nsSelectionType::SEL_DRW )
+ {
+ AddFormat( FORMAT_GDIMETAFILE );
+ AddFormat( SOT_FORMATSTR_ID_PNG );
+ AddFormat( FORMAT_BITMAP );
+ }
+ eBufferType = (TransferBufferType)( TRNSFR_GRAPHIC | eBufferType );
+
+ pClpGraphic = new Graphic;
+ if( !pWrtShell->GetDrawObjGraphic( FORMAT_GDIMETAFILE, *pClpGraphic ))
+ pOrigGrf = pClpGraphic;
+ pClpBitmap = new Graphic;
+ if( !pWrtShell->GetDrawObjGraphic( FORMAT_BITMAP, *pClpBitmap ))
+ pOrigGrf = pClpBitmap;
+
+ // is it an URL-Button ?
+ OUString sURL;
+ OUString sDesc;
+ if( pWrtShell->GetURLFromButton( sURL, sDesc ) )
+ {
+ AddFormat( FORMAT_STRING );
+ AddFormat( SOT_FORMATSTR_ID_SOLK );
+ AddFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK );
+ AddFormat( SOT_FORMATSTR_ID_FILECONTENT );
+ AddFormat( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR );
+ AddFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR );
+ eBufferType = (TransferBufferType)( TRNSFR_INETFLD | eBufferType );
+ nRet = sal_True;
+ }
+ }
+
+ // at Cut, DDE-Link doesn't make sense!!
+ SwDocShell* pDShell;
+ if( !bIsCut && bDDELink &&
+ 0 != ( pDShell = pWrtShell->GetDoc()->GetDocShell()) &&
+ SFX_CREATE_MODE_STANDARD == pDShell->GetCreateMode() )
+ {
+ AddFormat( SOT_FORMATSTR_ID_LINK );
+ refDdeLink = new SwTrnsfrDdeLink( *this, *pWrtShell );
+ }
+
+ //ObjectDescriptor was already filly from the old DocShell.
+ //Now adjust it. Thus in GetData the first query can still
+ //be answered with delayed rendering.
+ aObjDesc.mbCanLink = sal_False;
+ Size aSz( OLESIZE );
+ aObjDesc.maSize = OutputDevice::LogicToLogic( aSz, MAP_TWIP, MAP_100TH_MM );
+
+ PrepareOLE( aObjDesc );
+ AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR );
+ }
+ else
+ nRet = 0;
+
+ if( pWrtShell->IsFrmSelected() )
+ {
+ SfxItemSet aSet( pWrtShell->GetAttrPool(), RES_URL, RES_URL );
+ pWrtShell->GetFlyFrmAttr( aSet );
+ const SwFmtURL& rURL = (SwFmtURL&)aSet.Get( RES_URL );
+ if( rURL.GetMap() )
+ {
+ pImageMap = new ImageMap( *rURL.GetMap() );
+ AddFormat( SOT_FORMATSTR_ID_SVIM );
+ }
+ else if( !rURL.GetURL().isEmpty() )
+ {
+ pTargetURL = new INetImage( sGrfNm, rURL.GetURL(),
+ rURL.GetTargetFrameName(),
+ aEmptyOUStr, Size() );
+ AddFormat( SOT_FORMATSTR_ID_INET_IMAGE );
+ }
+ }
+
+ return nRet;
+}
+
+int SwTransferable::Copy( sal_Bool bIsCut )
+{
+ int nRet = PrepareForCopy( bIsCut );
+ if ( nRet )
+ {
+ CopyToClipboard( &pWrtShell->GetView().GetEditWin() );
+ }
+ return nRet;
+}
+
+int SwTransferable::CalculateAndCopy()
+{
+ if(!pWrtShell)
+ return 0;
+ SwWait aWait( *pWrtShell->GetView().GetDocShell(), true );
+
+ OUString aStr( pWrtShell->Calculate() );
+
+ pClpDocFac = new SwDocFac;
+ SwDoc *const pDoc = lcl_GetDoc(*pClpDocFac);
+ pWrtShell->Copy(pDoc, & aStr);
+ eBufferType = TRNSFR_DOCUMENT;
+ AddFormat( FORMAT_STRING );
+
+ CopyToClipboard( &pWrtShell->GetView().GetEditWin() );
+
+ return 1;
+}
+
+int SwTransferable::CopyGlossary( SwTextBlocks& rGlossary,
+ const OUString& rStr )
+{
+ if(!pWrtShell)
+ return 0;
+ SwWait aWait( *pWrtShell->GetView().GetDocShell(), true );
+
+ pClpDocFac = new SwDocFac;
+ SwDoc *const pCDoc = lcl_GetDoc(*pClpDocFac);
+
+ SwNodes& rNds = pCDoc->GetNodes();
+ SwNodeIndex aNodeIdx( *rNds.GetEndOfContent().StartOfSectionNode() );
+ SwCntntNode* pCNd = rNds.GoNext( &aNodeIdx ); // go to 1st ContentNode
+ SwPaM aPam( *pCNd );
+
+ pCDoc->LockExpFlds(); // never update fields - leave text as it is
+
+ pCDoc->InsertGlossary( rGlossary, rStr, aPam, 0 );
+
+ // a new one was created in CORE (OLE-Objects copied!)
+ aDocShellRef = pCDoc->GetTmpDocShell();
+ if( aDocShellRef.Is() )
+ SwTransferable::InitOle( aDocShellRef, *pCDoc );
+ pCDoc->SetTmpDocShell( (SfxObjectShell*)NULL );
+
+ eBufferType = TRNSFR_DOCUMENT;
+
+ //When someone needs it, we 'OLE' her something.
+ AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE );
+ AddFormat( FORMAT_RTF );
+ AddFormat( SOT_FORMATSTR_ID_HTML );
+ AddFormat( FORMAT_STRING );
+
+ //ObjectDescriptor was already filled from the old DocShell.
+ //Now adjust it. Thus in GetData the first query can still
+ //be answered with delayed rendering.
+ aObjDesc.mbCanLink = sal_False;
+ Size aSz( OLESIZE );
+ aObjDesc.maSize = OutputDevice::LogicToLogic( aSz, MAP_TWIP, MAP_100TH_MM );
+
+ PrepareOLE( aObjDesc );
+ AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR );
+
+ CopyToClipboard( &pWrtShell->GetView().GetEditWin() );
+
+ return 1;
+}
+
+static inline uno::Reference < XTransferable > * lcl_getTransferPointer ( uno::Reference < XTransferable > &xRef )
+{
+ return &xRef;
+}
+
+sal_Bool SwTransferable::IsPaste( const SwWrtShell& rSh,
+ const TransferableDataHelper& rData )
+{
+ // Check the common case first: We can always paste our own data!
+ // If _only_ the internal format can be pasted, this check will
+ // yield 'true', while the one below would give a (wrong) result 'false'.
+
+ bool bIsPaste = ( GetSwTransferable( rData ) != NULL );
+
+ // if it's not our own data, we need to have a closer look:
+ if( ! bIsPaste )
+ {
+ // determine the proper paste action, and return true if we find one
+ uno::Reference<XTransferable> xTransferable( rData.GetXTransferable() );
+
+ sal_uInt16 nDestination = SwTransferable::GetSotDestination( rSh );
+ sal_uInt16 nSourceOptions =
+ (( EXCHG_DEST_DOC_TEXTFRAME == nDestination ||
+ EXCHG_DEST_SWDOC_FREE_AREA == nDestination ||
+ EXCHG_DEST_DOC_TEXTFRAME_WEB == nDestination ||
+ EXCHG_DEST_SWDOC_FREE_AREA_WEB == nDestination )
+ ? EXCHG_IN_ACTION_COPY
+ : EXCHG_IN_ACTION_MOVE);
+
+ sal_uLong nFormat; // output param for GetExchangeAction
+ sal_uInt16 nEventAction; // output param for GetExchangeAction
+ sal_uInt16 nAction = SotExchange::GetExchangeAction(
+ rData.GetDataFlavorExVector(),
+ nDestination,
+ nSourceOptions, /* ?? */
+ EXCHG_IN_ACTION_DEFAULT, /* ?? */
+ nFormat, nEventAction, 0,
+ lcl_getTransferPointer ( xTransferable ) );
+
+ // if we find a suitable action, we can paste!
+ bIsPaste = (EXCHG_INOUT_ACTION_NONE != nAction);
+ }
+
+ return bIsPaste;
+}
+
+bool SwTransferable::Paste( SwWrtShell& rSh, TransferableDataHelper& rData )
+{
+ sal_uInt16 nEventAction, nAction=0,
+ nDestination = SwTransferable::GetSotDestination( rSh );
+ sal_uLong nFormat = 0;
+
+ if( GetSwTransferable( rData ) )
+ {
+ nAction = EXCHG_OUT_ACTION_INSERT_PRIVATE;
+ }
+ else
+ {
+ sal_uInt16 nSourceOptions =
+ (( EXCHG_DEST_DOC_TEXTFRAME == nDestination ||
+ EXCHG_DEST_SWDOC_FREE_AREA == nDestination ||
+ EXCHG_DEST_DOC_TEXTFRAME_WEB == nDestination ||
+ EXCHG_DEST_SWDOC_FREE_AREA_WEB == nDestination )
+ ? EXCHG_IN_ACTION_COPY
+ : EXCHG_IN_ACTION_MOVE);
+ uno::Reference<XTransferable> xTransferable( rData.GetXTransferable() );
+ nAction = SotExchange::GetExchangeAction(
+ rData.GetDataFlavorExVector(),
+ nDestination,
+ nSourceOptions, /* ?? */
+ EXCHG_IN_ACTION_DEFAULT, /* ?? */
+ nFormat, nEventAction, 0,
+ lcl_getTransferPointer ( xTransferable ) );
+ }
+
+ // special case for tables from draw application
+ if( EXCHG_OUT_ACTION_INSERT_DRAWOBJ == (nAction & EXCHG_ACTION_MASK) )
+ {
+ if( rData.HasFormat( SOT_FORMAT_RTF ) )
+ {
+ nAction = EXCHG_OUT_ACTION_INSERT_STRING | (nAction & ~EXCHG_ACTION_MASK);
+ nFormat = SOT_FORMAT_RTF;
+ }
+ }
+
+ return EXCHG_INOUT_ACTION_NONE != nAction &&
+ SwTransferable::PasteData( rData, rSh, nAction, nFormat,
+ nDestination, sal_False, sal_False );
+}
+
+bool SwTransferable::PasteData( TransferableDataHelper& rData,
+ SwWrtShell& rSh, sal_uInt16 nAction, sal_uLong nFormat,
+ sal_uInt16 nDestination, sal_Bool bIsPasteFmt,
+ sal_Bool bIsDefault,
+ const Point* pPt, sal_Int8 nDropAction,
+ sal_Bool bPasteSelection )
+{
+ SwWait aWait( *rSh.GetView().GetDocShell(), false );
+ boost::scoped_ptr<SwTrnsfrActionAndUndo> pAction;
+ SwModule* pMod = SW_MOD();
+
+ bool nRet = false;
+ bool bCallAutoCaption = false;
+
+ if( pPt )
+ {
+ // external Drop
+ if( bPasteSelection ? !pMod->pXSelection : !pMod->pDragDrop )
+ {
+ switch( nDestination )
+ {
+ case EXCHG_DEST_DOC_LNKD_GRAPH_W_IMAP:
+ case EXCHG_DEST_DOC_LNKD_GRAPHOBJ:
+ case EXCHG_DEST_DOC_GRAPH_W_IMAP:
+ case EXCHG_DEST_DOC_GRAPHOBJ:
+ case EXCHG_DEST_DOC_OLEOBJ:
+ case EXCHG_DEST_DOC_DRAWOBJ:
+ case EXCHG_DEST_DOC_URLBUTTON:
+ case EXCHG_DEST_DOC_GROUPOBJ:
+ // select frames/objects
+ SwTransferable::SetSelInShell( rSh, sal_True, pPt );
+ break;
+
+ default:
+ SwTransferable::SetSelInShell( rSh, sal_False, pPt );
+ break;
+ }
+ }
+ }
+ else if( ( !GetSwTransferable( rData ) || bIsPasteFmt ) &&
+ !rSh.IsTableMode() && rSh.HasSelection() )
+ {
+ // then delete the selections
+
+ //don't delete selected content
+ // - at table-selection
+ // - at ReRead of a graphic/DDEData
+ // - at D&D, for the right selection was taken care of
+ // in Drop-Handler
+ sal_Bool bDelSel = sal_False;
+ switch( nDestination )
+ {
+ case EXCHG_DEST_DOC_TEXTFRAME:
+ case EXCHG_DEST_SWDOC_FREE_AREA:
+ case EXCHG_DEST_DOC_TEXTFRAME_WEB:
+ case EXCHG_DEST_SWDOC_FREE_AREA_WEB:
+ bDelSel = sal_True;
+ break;
+ }
+
+ if( bDelSel )
+ // #i34830#
+ pAction.reset(new SwTrnsfrActionAndUndo( &rSh, UNDO_PASTE_CLIPBOARD, NULL,
+ sal_True ));
+ }
+
+ SwTransferable *pTrans=0, *pTunneledTrans=GetSwTransferable( rData );
+
+ // check for private drop
+ bool bPrivateDrop(pPt && (bPasteSelection ? 0 != (pTrans = pMod->pXSelection) : 0 != (pTrans = pMod->pDragDrop)));
+ bool bNeedToSelectBeforePaste(false);
+
+ if(bPrivateDrop && DND_ACTION_LINK == nDropAction)
+ {
+ // internal drop on object, suppress bPrivateDrop to change internal fill
+ bPrivateDrop = false;
+ bNeedToSelectBeforePaste = true;
+ }
+
+ if(bPrivateDrop && pPt && DND_ACTION_MOVE == nDropAction)
+ {
+ // check if dragged over a useful target. If yes, use as content exchange
+ // drop as if from external
+ const SwFrmFmt* pSwFrmFmt = rSh.GetFmtFromObj(*pPt);
+
+ if(pSwFrmFmt && 0 != dynamic_cast< const SwDrawFrmFmt* >(pSwFrmFmt))
+ {
+ bPrivateDrop = false;
+ bNeedToSelectBeforePaste = true;
+ }
+ }
+
+ if(bPrivateDrop)
+ {
+ // then internal Drag & Drop or XSelection
+ nRet = pTrans->PrivateDrop( rSh, *pPt, DND_ACTION_MOVE == nDropAction,
+ bPasteSelection );
+ }
+ else if( !pPt && pTunneledTrans &&
+ EXCHG_OUT_ACTION_INSERT_PRIVATE == nAction )
+ {
+ // then internal paste
+ nRet = pTunneledTrans->PrivatePaste( rSh );
+ }
+ else if( EXCHG_INOUT_ACTION_NONE != nAction )
+ {
+ if( !pAction )
+ {
+ pAction.reset(new SwTrnsfrActionAndUndo( &rSh, UNDO_PASTE_CLIPBOARD));
+ }
+
+ // in Drag&Drop MessageBoxes must not be showed
+ sal_Bool bMsg = 0 == pPt;
+ sal_uInt8 nActionFlags = static_cast< sal_uInt8 >(( nAction >> 8 ) & 0xFF);
+
+ sal_uInt16 nClearedAction = ( nAction & EXCHG_ACTION_MASK );
+ // delete selections
+
+ switch( nClearedAction )
+ {
+ case EXCHG_OUT_ACTION_INSERT_PRIVATE:
+ OSL_ENSURE( pPt, "EXCHG_OUT_ACTION_INSERT_PRIVATE: what should happen here?" );
+ break;
+
+ case EXCHG_OUT_ACTION_MOVE_PRIVATE:
+ OSL_ENSURE( pPt, "EXCHG_OUT_ACTION_MOVE_PRIVATE: what should happen here?" );
+ break;
+
+ case EXCHG_IN_ACTION_MOVE:
+ case EXCHG_IN_ACTION_COPY:
+ case EXCHG_IN_ACTION_LINK:
+ case EXCHG_OUT_ACTION_INSERT_HTML:
+ case EXCHG_OUT_ACTION_INSERT_STRING:
+ case EXCHG_OUT_ACTION_INSERT_IMAGEMAP:
+ case EXCHG_OUT_ACTION_REPLACE_IMAGEMAP:
+
+ // then we have to use the format
+ switch( nFormat )
+ {
+ case SOT_FORMATSTR_ID_DRAWING:
+ nRet = SwTransferable::_PasteSdrFormat( rData, rSh,
+ SW_PASTESDR_INSERT, pPt,
+ nActionFlags, bNeedToSelectBeforePaste);
+ break;
+
+ case SOT_FORMATSTR_ID_HTML:
+ case SOT_FORMATSTR_ID_HTML_SIMPLE:
+ case SOT_FORMATSTR_ID_HTML_NO_COMMENT:
+ case SOT_FORMAT_RTF:
+ case SOT_FORMAT_STRING:
+ nRet = SwTransferable::_PasteFileContent( rData, rSh,
+ nFormat, bMsg );
+ break;
+
+ case SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK:
+ {
+ INetBookmark aBkmk;
+ if( rData.GetINetBookmark( nFormat, aBkmk ) )
+ {
+ SwFmtINetFmt aFmt( aBkmk.GetURL(), OUString() );
+ rSh.InsertURL( aFmt, aBkmk.GetDescription() );
+ nRet = true;
+ }
+ }
+ break;
+
+ case SOT_FORMATSTR_ID_SD_OLE:
+ nRet = SwTransferable::_PasteOLE( rData, rSh, nFormat,
+ nActionFlags, bMsg );
+ break;
+
+ case SOT_FORMATSTR_ID_SVIM:
+ nRet = SwTransferable::_PasteImageMap( rData, rSh );
+ break;
+
+ case SOT_FORMATSTR_ID_SVXB:
+ case SOT_FORMAT_BITMAP:
+ case SOT_FORMATSTR_ID_PNG:
+ case SOT_FORMAT_GDIMETAFILE:
+ nRet = SwTransferable::_PasteGrf( rData, rSh, nFormat,
+ SW_PASTESDR_INSERT,pPt,
+ nActionFlags, nDropAction, bNeedToSelectBeforePaste);
+ break;
+
+ case SOT_FORMATSTR_ID_XFORMS:
+ case SOT_FORMATSTR_ID_SBA_FIELDDATAEXCHANGE:
+ case SOT_FORMATSTR_ID_SBA_DATAEXCHANGE:
+ case SOT_FORMATSTR_ID_SBA_CTRLDATAEXCHANGE:
+ nRet = SwTransferable::_PasteDBData( rData, rSh, nFormat,
+ EXCHG_IN_ACTION_LINK == nClearedAction,
+ pPt, bMsg );
+ break;
+
+ case SOT_FORMAT_FILE:
+ nRet = SwTransferable::_PasteFileName( rData, rSh, nFormat,
+ ( EXCHG_IN_ACTION_MOVE == nClearedAction
+ ? SW_PASTESDR_REPLACE
+ : EXCHG_IN_ACTION_LINK == nClearedAction
+ ? SW_PASTESDR_SETATTR
+ : SW_PASTESDR_INSERT),
+ pPt, nActionFlags, bMsg, 0 );
+ break;
+
+ case SOT_FORMAT_FILE_LIST:
+ // then insert as graphics only
+ nRet = SwTransferable::_PasteFileList( rData, rSh,
+ EXCHG_IN_ACTION_LINK == nClearedAction,
+ pPt, bMsg );
+ break;
+
+ case SOT_FORMATSTR_ID_SONLK:
+ if( pPt )
+ {
+ NaviContentBookmark aBkmk;
+ if( aBkmk.Paste( rData ) )
+ {
+ if(bIsDefault)
+ {
+ switch(aBkmk.GetDefaultDragType())
+ {
+ case REGION_MODE_NONE: nClearedAction = EXCHG_IN_ACTION_COPY; break;
+ case REGION_MODE_EMBEDDED: nClearedAction = EXCHG_IN_ACTION_MOVE; break;
+ case REGION_MODE_LINK: nClearedAction = EXCHG_IN_ACTION_LINK; break;
+ }
+ }
+ rSh.NavigatorPaste( aBkmk, nClearedAction );
+ nRet = true;
+ }
+ }
+ break;
+
+ case SOT_FORMATSTR_ID_INET_IMAGE:
+ case SOT_FORMATSTR_ID_NETSCAPE_IMAGE:
+ nRet = SwTransferable::_PasteTargetURL( rData, rSh,
+ SW_PASTESDR_INSERT,
+ pPt, sal_True );
+ break;
+
+ default:
+ OSL_ENSURE( pPt, "unknown format" );
+ }
+ break;
+
+ case EXCHG_OUT_ACTION_INSERT_FILE:
+ {
+ bool graphicInserted;
+ nRet = SwTransferable::_PasteFileName( rData, rSh, nFormat,
+ SW_PASTESDR_INSERT, pPt,
+ nActionFlags, bMsg,
+ &graphicInserted );
+ if( graphicInserted )
+ bCallAutoCaption = true;
+ }
+ break;
+
+ case EXCHG_OUT_ACTION_INSERT_OLE:
+ nRet = SwTransferable::_PasteOLE( rData, rSh, nFormat,
+ nActionFlags,bMsg );
+ break;
+
+ case EXCHG_OUT_ACTION_INSERT_DDE:
+ {
+ sal_Bool bReRead = 0 != CNT_HasGrf( rSh.GetCntType() );
+ nRet = SwTransferable::_PasteDDE( rData, rSh, bReRead, bMsg );
+ }
+ break;
+
+ case EXCHG_OUT_ACTION_INSERT_HYPERLINK:
+ {
+ OUString sURL, sDesc;
+ if( SOT_FORMAT_FILE == nFormat )
+ {
+ if( rData.GetString( nFormat, sURL ) && !sURL.isEmpty() )
+ {
+ SwTransferable::_CheckForURLOrLNKFile( rData, sURL, &sDesc );
+ if( sDesc.isEmpty() )
+ sDesc = sURL;
+ nRet = true;
+ }
+ }
+ else
+ {
+ INetBookmark aBkmk;
+ if( rData.GetINetBookmark( nFormat, aBkmk ) )
+ {
+ sURL = aBkmk.GetURL();
+ sDesc = aBkmk.GetDescription();
+ nRet = true;
+ }
+ }
+
+ if( nRet )
+ {
+ SwFmtINetFmt aFmt( sURL, OUString() );
+ rSh.InsertURL( aFmt, sDesc );
+ }
+ }
+ break;
+
+ case EXCHG_OUT_ACTION_GET_ATTRIBUTES:
+ switch( nFormat )
+ {
+ case SOT_FORMATSTR_ID_DRAWING:
+ nRet = SwTransferable::_PasteSdrFormat( rData, rSh,
+ SW_PASTESDR_SETATTR, pPt,
+ nActionFlags, bNeedToSelectBeforePaste);
+ break;
+ case SOT_FORMATSTR_ID_SVXB:
+ case SOT_FORMAT_GDIMETAFILE:
+ case SOT_FORMAT_BITMAP:
+ case SOT_FORMATSTR_ID_PNG:
+ case SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK:
+ case SOT_FORMAT_FILE:
+ case SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR:
+ case SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR:
+ nRet = SwTransferable::_PasteGrf( rData, rSh, nFormat,
+ SW_PASTESDR_SETATTR, pPt,
+ nActionFlags, nDropAction, bNeedToSelectBeforePaste);
+ break;
+ default:
+ OSL_FAIL( "unknown format" );
+ }
+
+ break;
+
+ case EXCHG_OUT_ACTION_INSERT_DRAWOBJ:
+ nRet = SwTransferable::_PasteSdrFormat( rData, rSh,
+ SW_PASTESDR_INSERT, pPt,
+ nActionFlags, bNeedToSelectBeforePaste);
+ break;
+ case EXCHG_OUT_ACTION_INSERT_SVXB:
+ case EXCHG_OUT_ACTION_INSERT_GDIMETAFILE:
+ case EXCHG_OUT_ACTION_INSERT_BITMAP:
+ case EXCHG_OUT_ACTION_INSERT_GRAPH:
+ nRet = SwTransferable::_PasteGrf( rData, rSh, nFormat,
+ SW_PASTESDR_INSERT, pPt,
+ nActionFlags, nDropAction, bNeedToSelectBeforePaste);
+ break;
+
+ case EXCHG_OUT_ACTION_REPLACE_DRAWOBJ:
+ nRet = SwTransferable::_PasteSdrFormat( rData, rSh,
+ SW_PASTESDR_REPLACE, pPt,
+ nActionFlags, bNeedToSelectBeforePaste);
+ break;
+
+ case EXCHG_OUT_ACTION_REPLACE_SVXB:
+ case EXCHG_OUT_ACTION_REPLACE_GDIMETAFILE:
+ case EXCHG_OUT_ACTION_REPLACE_BITMAP:
+ case EXCHG_OUT_ACTION_REPLACE_GRAPH:
+ nRet = SwTransferable::_PasteGrf( rData, rSh, nFormat,
+ SW_PASTESDR_REPLACE,pPt,
+ nActionFlags, nDropAction, bNeedToSelectBeforePaste);
+ break;
+
+ case EXCHG_OUT_ACTION_INSERT_INTERACTIVE:
+ nRet = SwTransferable::_PasteAsHyperlink( rData, rSh, nFormat );
+ break;
+
+ default:
+ OSL_FAIL("unknown action" );
+ }
+ }
+
+ if( !bPasteSelection && rSh.IsFrmSelected() )
+ {
+ rSh.EnterSelFrmMode();
+ //force ::SelectShell
+ rSh.GetView().StopShellTimer();
+ }
+
+ pAction.reset();
+ if( bCallAutoCaption )
+ rSh.GetView().AutoCaption( GRAPHIC_CAP );
+
+ return nRet;
+}
+
+sal_uInt16 SwTransferable::GetSotDestination( const SwWrtShell& rSh,
+ const Point* pPt )
+{
+ sal_uInt16 nRet = EXCHG_INOUT_ACTION_NONE;
+
+ ObjCntType eOType;
+ if( pPt )
+ {
+ SdrObject *pObj = 0;
+ eOType = rSh.GetObjCntType( *pPt, pObj );
+ }
+ else
+ eOType = rSh.GetObjCntTypeOfSelection();
+
+ switch( eOType )
+ {
+ case OBJCNT_GRF:
+ {
+ sal_Bool bIMap, bLink;
+ if( pPt )
+ {
+ bIMap = 0 != rSh.GetFmtFromObj( *pPt )->GetURL().GetMap();
+ OUString aDummy;
+ rSh.GetGrfAtPos( *pPt, aDummy, bLink );
+ }
+ else
+ {
+ bIMap = 0 != rSh.GetFlyFrmFmt()->GetURL().GetMap();
+ OUString aDummy;
+ rSh.GetGrfNms( &aDummy, 0 );
+ bLink = !aDummy.isEmpty();
+ }
+
+ if( bLink && bIMap )
+ nRet = EXCHG_DEST_DOC_LNKD_GRAPH_W_IMAP;
+ else if( bLink )
+ nRet = EXCHG_DEST_DOC_LNKD_GRAPHOBJ;
+ else if( bIMap )
+ nRet = EXCHG_DEST_DOC_GRAPH_W_IMAP;
+ else
+ nRet = EXCHG_DEST_DOC_GRAPHOBJ;
+ }
+ break;
+
+ case OBJCNT_FLY:
+ if( rSh.GetView().GetDocShell()->ISA(SwWebDocShell) )
+ nRet = EXCHG_DEST_DOC_TEXTFRAME_WEB;
+ else
+ nRet = EXCHG_DEST_DOC_TEXTFRAME;
+ break;
+ case OBJCNT_OLE: nRet = EXCHG_DEST_DOC_OLEOBJ; break;
+
+ case OBJCNT_CONTROL: /* no Action avail */
+ case OBJCNT_SIMPLE: nRet = EXCHG_DEST_DOC_DRAWOBJ; break;
+ case OBJCNT_URLBUTTON: nRet = EXCHG_DEST_DOC_URLBUTTON; break;
+ case OBJCNT_GROUPOBJ: nRet = EXCHG_DEST_DOC_GROUPOBJ; break;
+
+ // what do we do at multiple selections???
+ default:
+ {
+ if( rSh.GetView().GetDocShell()->ISA(SwWebDocShell) )
+ nRet = EXCHG_DEST_SWDOC_FREE_AREA_WEB;
+ else
+ nRet = EXCHG_DEST_SWDOC_FREE_AREA;
+ }
+ }
+
+ return nRet;
+}
+
+bool SwTransferable::_PasteFileContent( TransferableDataHelper& rData,
+ SwWrtShell& rSh, sal_uLong nFmt, sal_Bool bMsg )
+{
+ sal_uInt16 nResId = MSG_CLPBRD_FORMAT_ERROR;
+ bool nRet = false;
+
+ MSE40HTMLClipFormatObj aMSE40ClpObj;
+
+ SotStorageStreamRef xStrm;
+ SvStream* pStream = 0;
+ SwRead pRead = 0;
+ OUString sData;
+ switch( nFmt )
+ {
+ case SOT_FORMAT_STRING:
+ {
+ pRead = ReadAscii;
+ if( rData.GetString( nFmt, sData ) )
+ {
+ pStream = new SvMemoryStream( (void*)sData.getStr(),
+ sData.getLength() * sizeof( sal_Unicode ),
+ STREAM_READ );
+#ifdef OSL_BIGENDIAN
+ pStream->SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN );
+#else
+ pStream->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
+#endif
+
+ SwAsciiOptions aAOpt;
+ aAOpt.SetCharSet( RTL_TEXTENCODING_UCS2 );
+ pRead->GetReaderOpt().SetASCIIOpts( aAOpt );
+ break;
+ }
+ }
+ // no break - because then test if we get a stream
+
+ default:
+ if( rData.GetSotStorageStream( nFmt, xStrm ) )
+ {
+ if( ( SOT_FORMATSTR_ID_HTML_SIMPLE == nFmt ) ||
+ ( SOT_FORMATSTR_ID_HTML_NO_COMMENT == nFmt ) )
+ {
+ pStream = aMSE40ClpObj.IsValid( *xStrm );
+ pRead = ReadHTML;
+ pRead->SetReadUTF8( sal_True );
+
+ sal_Bool bNoComments =
+ ( nFmt == SOT_FORMATSTR_ID_HTML_NO_COMMENT );
+ pRead->SetIgnoreHTMLComments( bNoComments );
+ }
+ else
+ {
+ pStream = &xStrm;
+ if( SOT_FORMAT_RTF == nFmt )
+ pRead = SwReaderWriter::GetReader( READER_WRITER_RTF );
+ else if( !pRead )
+ {
+ pRead = ReadHTML;
+ pRead->SetReadUTF8( sal_True );
+ }
+ }
+ }
+ break;
+ }
+
+ if( pStream && pRead )
+ {
+ Link aOldLink( rSh.GetChgLnk() );
+ rSh.SetChgLnk( Link() );
+
+ const SwPosition& rInsPos = *rSh.GetCrsr()->Start();
+ SwReader aReader( *pStream, aEmptyOUStr, OUString(), *rSh.GetCrsr() );
+ rSh.SaveTblBoxCntnt( &rInsPos );
+ if( IsError( aReader.Read( *pRead )) )
+ nResId = ERR_CLPBRD_READ;
+ else
+ nResId = 0, nRet = true;
+
+ rSh.SetChgLnk( aOldLink );
+ if( nRet )
+ rSh.CallChgLnk();
+ }
+ else
+ nResId = MSG_CLPBRD_FORMAT_ERROR;
+
+ // Exist a SvMemoryStream? (data in the OUString and xStrm is empty)
+ if( pStream && !xStrm.Is() )
+ delete pStream;
+
+ if( bMsg && nResId )
+ {
+ InfoBox( 0, SW_RES( nResId )).Execute();
+ }
+ return nRet;
+}
+
+bool SwTransferable::_PasteOLE( TransferableDataHelper& rData, SwWrtShell& rSh,
+ sal_uLong nFmt, sal_uInt8 nActionFlags, sal_Bool bMsg )
+{
+ bool nRet = false;
+ TransferableObjectDescriptor aObjDesc;
+ uno::Reference < io::XInputStream > xStrm;
+ uno::Reference < embed::XStorage > xStore;
+ Reader* pRead = 0;
+
+ // Get the preferred format
+ SotFormatStringId nId;
+ if( rData.HasFormat( SOT_FORMATSTR_ID_EMBEDDED_OBJ ) )
+ nId = SOT_FORMATSTR_ID_EMBEDDED_OBJ;
+ else if( rData.HasFormat( SOT_FORMATSTR_ID_EMBED_SOURCE ) &&
+ rData.HasFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR ))
+ nId = SOT_FORMATSTR_ID_EMBED_SOURCE;
+ else
+ nId = 0;
+
+ if( nId && rData.GetInputStream( nId, xStrm ) && xStrm.is() )
+ {
+ // if there is an embedded object, first try if it's a writer object
+ // this will be inserted into the document by using a Reader
+ try
+ {
+ xStore = comphelper::OStorageHelper::GetStorageFromInputStream( xStrm );
+ switch( SotStorage::GetFormatID( xStore ) )
+ {
+ case SOT_FORMATSTR_ID_STARWRITER_60:
+ case SOT_FORMATSTR_ID_STARWRITERWEB_60:
+ case SOT_FORMATSTR_ID_STARWRITERGLOB_60:
+ case SOT_FORMATSTR_ID_STARWRITER_8:
+ case SOT_FORMATSTR_ID_STARWRITERWEB_8:
+ case SOT_FORMATSTR_ID_STARWRITERGLOB_8:
+ pRead = ReadXML;
+ break;
+ default:
+ try
+ {
+ uno::Reference < lang::XComponent > xComp( xStore, uno::UNO_QUERY );
+ xComp->dispose();
+ xStore = 0;
+ }
+ catch (const uno::Exception&)
+ {
+ }
+
+ break;
+ }
+ }
+ catch (const uno::Exception&)
+ {
+ // it wasn't a storage, but maybe it's a useful stream
+ }
+
+ nFmt = nId;
+ }
+
+ if( pRead )
+ {
+ SwPaM &rPAM = *rSh.GetCrsr();
+ SwReader aReader( xStore, aEmptyOUStr, rPAM );
+ if( !IsError( aReader.Read( *pRead )) )
+ nRet = true;
+ else if( bMsg )
+ InfoBox( 0, SW_RES(ERR_CLPBRD_READ) ).Execute();
+ }
+ else
+ {
+ // temporary storage until the object is inserted
+ uno::Reference< embed::XStorage > xTmpStor;
+ uno::Reference < embed::XEmbeddedObject > xObj;
+ OUString aName;
+ comphelper::EmbeddedObjectContainer aCnt;
+
+ if ( xStrm.is() )
+ {
+ if ( !rData.GetTransferableObjectDescriptor( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR, aObjDesc ) )
+ {
+ OSL_ENSURE( !xStrm.is(), "An object without descriptor in clipboard!");
+ }
+ }
+ else
+ {
+ if( rData.HasFormat( nFmt = SOT_FORMATSTR_ID_OBJECTDESCRIPTOR_OLE ) && rData.GetTransferableObjectDescriptor( nFmt, aObjDesc ) )
+ {
+ if ( !rData.GetInputStream( SOT_FORMATSTR_ID_EMBED_SOURCE_OLE, xStrm ) )
+ rData.GetInputStream( SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE, xStrm );
+
+ if ( !xStrm.is() )
+ {
+ // This is MSOLE object that should be created by direct using of system clipboard
+ try
+ {
+ xTmpStor = ::comphelper::OStorageHelper::GetTemporaryStorage();
+ uno::Reference < embed::XEmbedObjectClipboardCreator > xClipboardCreator =
+ embed::MSOLEObjectSystemCreator::create( ::comphelper::getProcessComponentContext() );
+
+ embed::InsertedObjectInfo aInfo = xClipboardCreator->createInstanceInitFromClipboard(
+ xTmpStor,
+ OUString( "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;
+ }
+ catch (const uno::Exception&)
+ {
+ }
+ }
+ }
+ }
+
+ if ( xStrm.is() && !xObj.is() )
+ xObj = aCnt.InsertEmbeddedObject( xStrm, aName );
+
+ if( xObj.is() )
+ {
+ svt::EmbeddedObjectRef xObjRef( xObj, aObjDesc.mnViewAspect );
+
+ // try to get the replacement image from the clipboard
+ Graphic aGraphic;
+ sal_uLong nGrFormat = 0;
+
+ // limit the size of the preview metafile to 100000 actions
+ GDIMetaFile aMetafile;
+ if (rData.GetGDIMetaFile(FORMAT_GDIMETAFILE, aMetafile, 100000))
+ {
+ nGrFormat = SOT_FORMAT_GDIMETAFILE;
+ aGraphic = aMetafile;
+ }
+
+ // insert replacement image ( if there is one ) into the object helper
+ if ( nGrFormat )
+ {
+ DataFlavor aDataFlavor;
+ SotExchange::GetFormatDataFlavor( nGrFormat, aDataFlavor );
+ xObjRef.SetGraphic( aGraphic, aDataFlavor.MimeType );
+ }
+ else if ( aObjDesc.mnViewAspect == embed::Aspects::MSOLE_ICON )
+ {
+ // it is important to have an icon, let an empty graphic be used
+ // if no other graphic is provided
+ // TODO/LATER: in future a default bitmap could be used
+ OUString aMimeType;
+ MapMode aMapMode( MAP_100TH_MM );
+ aGraphic.SetPrefSize( Size( 2500, 2500 ) );
+ aGraphic.SetPrefMapMode( aMapMode );
+ xObjRef.SetGraphic( aGraphic, aMimeType );
+ }
+
+ //set size. This is a hack because of handing over, size should be
+ //passed to the InsertOle!!!!!!!!!!
+ Size aSize;
+ if ( aObjDesc.mnViewAspect == embed::Aspects::MSOLE_ICON )
+ {
+ if( aObjDesc.maSize.Width() && aObjDesc.maSize.Height() )
+ aSize = aObjDesc.maSize;
+ else
+ {
+ MapMode aMapMode( MAP_100TH_MM );
+ aSize = xObjRef.GetSize( &aMapMode );
+ }
+ }
+ else if( aObjDesc.maSize.Width() && aObjDesc.maSize.Height() )
+ {
+ aSize = Size( aObjDesc.maSize ); //always 100TH_MM
+ MapUnit aUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( aObjDesc.mnViewAspect ) );
+ aSize = OutputDevice::LogicToLogic( aSize, MAP_100TH_MM, aUnit );
+ awt::Size aSz;
+ try
+ {
+ aSz = xObj->getVisualAreaSize( aObjDesc.mnViewAspect );
+ }
+ catch (const embed::NoVisualAreaSizeException&)
+ {
+ // in this case the provided size is used
+ }
+
+ if ( aSz.Width != aSize.Width() || aSz.Height != aSize.Height() )
+ {
+ aSz.Width = aSize.Width();
+ aSz.Height = aSize.Height();
+ xObj->setVisualAreaSize( aObjDesc.mnViewAspect, aSz );
+ }
+ }
+ else
+ {
+ // the descriptor contains the wrong object size
+ // the following call will let the MSOLE objects cache the size if it is possible
+ // it should be done while the object is running
+ try
+ {
+ xObj->getVisualAreaSize( aObjDesc.mnViewAspect );
+ }
+ catch (const uno::Exception&)
+ {
+ }
+ }
+ //End of Hack!
+
+ rSh.InsertOleObject( xObjRef );
+ nRet = true;
+
+ if( nRet && ( nActionFlags &
+ ( EXCHG_OUT_ACTION_FLAG_INSERT_TARGETURL >> 8) ))
+ SwTransferable::_PasteTargetURL( rData, rSh, 0, 0, sal_False );
+
+ // let the object be unloaded if possible
+ SwOLEObj::UnloadObject( xObj, rSh.GetDoc(), embed::Aspects::MSOLE_CONTENT );
+ }
+ }
+ return nRet;
+}
+
+bool SwTransferable::_PasteTargetURL( TransferableDataHelper& rData,
+ SwWrtShell& rSh, sal_uInt16 nAction,
+ const Point* pPt, sal_Bool bInsertGRF )
+{
+ bool nRet = false;
+ INetImage aINetImg;
+ if( ( rData.HasFormat( SOT_FORMATSTR_ID_INET_IMAGE ) &&
+ rData.GetINetImage( SOT_FORMATSTR_ID_INET_IMAGE, aINetImg )) ||
+ ( rData.HasFormat( SOT_FORMATSTR_ID_NETSCAPE_IMAGE ) &&
+ rData.GetINetImage( SOT_FORMATSTR_ID_NETSCAPE_IMAGE, aINetImg )) )
+ {
+ if( !aINetImg.GetImageURL().isEmpty() && bInsertGRF )
+ {
+ OUString sURL( aINetImg.GetImageURL() );
+ SwTransferable::_CheckForURLOrLNKFile( rData, sURL );
+
+ //!!! check at FileSystem - only then it make sense to test graphics !!!
+ Graphic aGraphic;
+ GraphicFilter &rFlt = GraphicFilter::GetGraphicFilter();
+ nRet = GRFILTER_OK == GraphicFilter::LoadGraphic( sURL, aEmptyOUStr, aGraphic, &rFlt );
+
+ if( nRet )
+ {
+ //Check and Perform rotation if needed
+ lclCheckAndPerformRotation(aGraphic);
+
+ switch( nAction )
+ {
+ case SW_PASTESDR_INSERT:
+ SwTransferable::SetSelInShell( rSh, sal_False, pPt );
+ rSh.Insert( sURL, aEmptyOUStr, aGraphic );
+ break;
+
+ case SW_PASTESDR_REPLACE:
+ if( rSh.IsObjSelected() )
+ {
+ rSh.ReplaceSdrObj( sURL, aEmptyOUStr, &aGraphic );
+ Point aPt( pPt ? *pPt : rSh.GetCrsrDocPos() );
+ SwTransferable::SetSelInShell( rSh, sal_True, &aPt );
+ }
+ else
+ rSh.ReRead( sURL, aEmptyOUStr, &aGraphic );
+ break;
+
+ case SW_PASTESDR_SETATTR:
+ if( rSh.IsObjSelected() )
+ rSh.Paste( aGraphic, OUString() );
+ else if( OBJCNT_GRF == rSh.GetObjCntTypeOfSelection() )
+ rSh.ReRead( sURL, aEmptyOUStr, &aGraphic );
+ else
+ {
+ SwTransferable::SetSelInShell( rSh, sal_False, pPt );
+ rSh.Insert( sURL, aEmptyOUStr, aGraphic );
+ }
+ break;
+ default:
+ nRet = false;
+ }
+ }
+ }
+ else
+ nRet = true;
+ }
+
+ if( nRet )
+ {
+ SfxItemSet aSet( rSh.GetAttrPool(), RES_URL, RES_URL );
+ rSh.GetFlyFrmAttr( aSet );
+ SwFmtURL aURL( (SwFmtURL&)aSet.Get( RES_URL ) );
+
+ if( aURL.GetURL() != aINetImg.GetTargetURL() ||
+ aURL.GetTargetFrameName() != aINetImg.GetTargetFrame() )
+ {
+ aURL.SetURL( aINetImg.GetTargetURL(), false );
+ aURL.SetTargetFrameName( aINetImg.GetTargetFrame() );
+ aSet.Put( aURL );
+ rSh.SetFlyFrmAttr( aSet );
+ }
+ }
+ return nRet;
+}
+
+void SwTransferable::SetSelInShell( SwWrtShell& rSh, sal_Bool bSelectFrm,
+ const Point* pPt )
+{
+ if( bSelectFrm )
+ {
+ // select frames/objects
+ if( pPt && !rSh.GetView().GetViewFrame()->GetDispatcher()->IsLocked() )
+ {
+ rSh.GetView().NoRotate();
+ if( rSh.SelectObj( *pPt ))
+ {
+ rSh.HideCrsr();
+ rSh.EnterSelFrmMode( pPt );
+ bFrmDrag = true;
+ }
+ }
+ }
+ else
+ {
+ if( rSh.IsFrmSelected() || rSh.IsObjSelected() )
+ {
+ rSh.UnSelectFrm();
+ rSh.LeaveSelFrmMode();
+ rSh.GetView().GetEditWin().StopInsFrm();
+ bFrmDrag = false;
+ }
+ else if( rSh.GetView().GetDrawFuncPtr() )
+ rSh.GetView().GetEditWin().StopInsFrm();
+
+ rSh.EnterStdMode();
+ if( pPt )
+ rSh.SwCrsrShell::SetCrsr( *pPt, sal_True );
+ }
+}
+
+bool SwTransferable::_PasteDDE( TransferableDataHelper& rData,
+ SwWrtShell& rWrtShell, sal_Bool bReReadGrf,
+ sal_Bool bMsg )
+{
+ // data from Clipboardformat
+ OUString aApp, aTopic, aItem;
+
+ {
+ SotStorageStreamRef xStrm;
+ if( !rData.GetSotStorageStream( SOT_FORMATSTR_ID_LINK, xStrm ))
+ {
+ OSL_ENSURE( !&rWrtShell, "DDE Data not found." );
+ return false;
+ } // report useful error!!
+
+ rtl_TextEncoding eEncoding = DDE_TXT_ENCODING;
+ aApp = read_zeroTerminated_uInt8s_ToOUString(*xStrm, eEncoding);
+ aTopic = read_zeroTerminated_uInt8s_ToOUString(*xStrm, eEncoding);
+ aItem = read_zeroTerminated_uInt8s_ToOUString(*xStrm, eEncoding);
+ }
+
+ OUString aCmd;
+ sfx2::MakeLnkName( aCmd, &aApp, aTopic, aItem );
+
+ // do we want to read in a graphic now?
+ sal_uLong nFormat;
+ if( !rData.HasFormat( FORMAT_RTF ) &&
+ !rData.HasFormat( SOT_FORMATSTR_ID_HTML ) &&
+ !rData.HasFormat( FORMAT_STRING ) &&
+ (rData.HasFormat( nFormat = FORMAT_GDIMETAFILE ) ||
+ rData.HasFormat( nFormat = FORMAT_BITMAP )) )
+ {
+ Graphic aGrf;
+ bool nRet = rData.GetGraphic( nFormat, aGrf );
+ if( nRet )
+ {
+ OUString sLnkTyp("DDE");
+ if ( bReReadGrf )
+ rWrtShell.ReRead( aCmd, sLnkTyp, &aGrf );
+ else
+ rWrtShell.Insert( aCmd, sLnkTyp, aGrf );
+ }
+ return nRet;
+ }
+
+ SwFieldType* pTyp = 0;
+ sal_uInt16 i = 1,j;
+ OUString aName;
+ sal_Bool bAlreadyThere = sal_False, bDoublePaste = sal_False;
+ sal_uInt16 nSize = rWrtShell.GetFldTypeCount();
+ const ::utl::TransliterationWrapper& rColl = ::GetAppCmpStrIgnore();
+
+ do {
+ aName = aApp;
+ aName += OUString::number( i );
+ for( j = INIT_FLDTYPES; j < nSize; j++ )
+ {
+ pTyp = rWrtShell.GetFldType( j );
+ if( RES_DDEFLD == pTyp->Which() )
+ {
+ OUString sTmp( ((SwDDEFieldType*)pTyp)->GetCmd() );
+ if( rColl.isEqual( sTmp, aCmd ) &&
+ sfx2::LINKUPDATE_ALWAYS == ((SwDDEFieldType*)pTyp)->GetType() )
+ {
+ aName = pTyp->GetName();
+ bDoublePaste = sal_True;
+ break;
+ }
+ else if( rColl.isEqual( aName, pTyp->GetName() ) )
+ break;
+ }
+ }
+ if( j == nSize )
+ bAlreadyThere = sal_False;
+ else
+ {
+ bAlreadyThere = sal_True;
+ i++;
+ }
+ }
+ while( bAlreadyThere && !bDoublePaste );
+
+ if( !bDoublePaste )
+ {
+ SwDDEFieldType aType( aName, aCmd, sfx2::LINKUPDATE_ALWAYS );
+ pTyp = rWrtShell.InsertFldType( aType );
+ }
+
+ SwDDEFieldType* pDDETyp = (SwDDEFieldType*)pTyp;
+
+ OUString aExpand;
+ if( rData.GetString( FORMAT_STRING, aExpand ))
+ {
+ do { // middle checked loop
+
+ // When data comes from a spreadsheet, we add a DDE-table
+ if( ( rData.HasFormat( SOT_FORMATSTR_ID_SYLK ) ||
+ rData.HasFormat( SOT_FORMATSTR_ID_SYLK_BIGCAPS ) ) &&
+ !aExpand.isEmpty() &&
+ ( 1 < comphelper::string::getTokenCount(aExpand, '\n') ||
+ comphelper::string::getTokenCount(aExpand, '\t') ) )
+ {
+ OUString sTmp( aExpand );
+ sal_Int32 nRows = comphelper::string::getTokenCount(sTmp, '\n');
+ if( nRows )
+ --nRows;
+ sTmp = sTmp.getToken( 0, '\n' );
+ sal_Int32 nCols = comphelper::string::getTokenCount(sTmp, '\t');
+
+ // at least one column & row must be there
+ if( !nRows || !nCols )
+ {
+ if( bMsg )
+ InfoBox(0, SW_RESSTR(STR_NO_TABLE)).Execute();
+ pDDETyp = 0;
+ break;
+ }
+
+ rWrtShell.InsertDDETable(
+ SwInsertTableOptions( tabopts::SPLIT_LAYOUT, 1 ), // TODO MULTIHEADER
+ pDDETyp, nRows, nCols );
+ }
+ else if( 1 < comphelper::string::getTokenCount(aExpand, '\n') )
+ {
+ // multiple paragraphs -> insert a protected section
+ if( rWrtShell.HasSelection() )
+ rWrtShell.DelRight();
+
+ SwSectionData aSect( DDE_LINK_SECTION, aName );
+ aSect.SetLinkFileName( aCmd );
+ aSect.SetProtectFlag(true);
+ rWrtShell.InsertSection( aSect );
+
+ pDDETyp = 0; // remove FieldTypes again
+ }
+ else
+ {
+ // Einfuegen
+ SwDDEField aSwDDEField( pDDETyp );
+ rWrtShell.Insert( aSwDDEField );
+ }
+
+ } while( false );
+ }
+ else
+ pDDETyp = 0; // remove FieldTypes again
+
+ if( !pDDETyp && !bDoublePaste )
+ {
+ // remove FieldType again - error occurred!
+ for( j = nSize; j >= INIT_FLDTYPES; --j )
+ if( pTyp == rWrtShell.GetFldType( j ) )
+ {
+ rWrtShell.RemoveFldType( j );
+ break;
+ }
+ }
+
+ return true;
+}
+
+bool SwTransferable::_PasteSdrFormat( TransferableDataHelper& rData,
+ SwWrtShell& rSh, sal_uInt16 nAction,
+ const Point* pPt, sal_uInt8 nActionFlags, bool bNeedToSelectBeforePaste)
+{
+ bool nRet = false;
+ SotStorageStreamRef xStrm;
+ if( rData.GetSotStorageStream( SOT_FORMATSTR_ID_DRAWING, xStrm ))
+ {
+ xStrm->SetVersion( SOFFICE_FILEFORMAT_50 );
+
+ if(bNeedToSelectBeforePaste && pPt)
+ {
+ // if this is an internal drag, need to set the target right (select it), else
+ // still the source will be selected
+ SwTransferable::SetSelInShell( rSh, sal_True, pPt );
+ }
+
+ rSh.Paste( *xStrm, nAction, pPt );
+ nRet = true;
+
+ if( nRet && ( nActionFlags &
+ ( EXCHG_OUT_ACTION_FLAG_INSERT_TARGETURL >> 8) ))
+ SwTransferable::_PasteTargetURL( rData, rSh, 0, 0, sal_False );
+ }
+ return nRet;
+}
+
+bool SwTransferable::_PasteGrf( TransferableDataHelper& rData, SwWrtShell& rSh,
+ sal_uLong nFmt, sal_uInt16 nAction, const Point* pPt,
+ sal_uInt8 nActionFlags, sal_Int8 nDropAction, bool bNeedToSelectBeforePaste)
+{
+ bool nRet = false;
+
+ Graphic aGraphic;
+ INetBookmark aBkmk;
+ sal_Bool bCheckForGrf = sal_False, bCheckForImageMap = sal_False;
+
+ switch( nFmt )
+ {
+ case SOT_FORMAT_BITMAP:
+ case SOT_FORMATSTR_ID_PNG:
+ case SOT_FORMAT_GDIMETAFILE:
+ nRet = rData.GetGraphic( nFmt, aGraphic );
+ break;
+
+ case SOT_FORMATSTR_ID_SVXB:
+ {
+ SotStorageStreamRef xStm;
+
+ if(rData.GetSotStorageStream(SOT_FORMATSTR_ID_SVXB, xStm))
+ {
+ ReadGraphic( *xStm, aGraphic );
+ nRet = (GRAPHIC_NONE != aGraphic.GetType() && GRAPHIC_DEFAULT != aGraphic.GetType());
+ }
+
+ break;
+ }
+
+ case SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK:
+ case SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR:
+ case SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR:
+ if( ( nRet = rData.GetINetBookmark( nFmt, aBkmk ) ))
+ {
+ if( SW_PASTESDR_SETATTR == nAction )
+ nFmt = SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK;
+ else
+ bCheckForGrf = sal_True;
+ }
+ break;
+
+ case SOT_FORMAT_FILE:
+ {
+ OUString sTxt;
+ if( ( nRet = rData.GetString( nFmt, sTxt ) ) )
+ {
+ OUString sDesc;
+ SwTransferable::_CheckForURLOrLNKFile( rData, sTxt, &sDesc );
+
+ aBkmk = INetBookmark(
+ URIHelper::SmartRel2Abs(INetURLObject(), sTxt, Link(), false ),
+ sDesc );
+ bCheckForGrf = sal_True;
+ bCheckForImageMap = SW_PASTESDR_REPLACE == nAction;
+ }
+ }
+ break;
+
+ default:
+ nRet = rData.GetGraphic( nFmt, aGraphic );
+ break;
+ }
+
+ if( bCheckForGrf )
+ {
+ //!!! check at FileSystem - only then it makes sense to test the graphics !!!
+ GraphicFilter &rFlt = GraphicFilter::GetGraphicFilter();
+ nRet = GRFILTER_OK == GraphicFilter::LoadGraphic( aBkmk.GetURL(), aEmptyOUStr,
+ aGraphic, &rFlt );
+
+ if( !nRet && SW_PASTESDR_SETATTR == nAction &&
+ SOT_FORMAT_FILE == nFmt &&
+ // only at frame selection
+ rSh.IsFrmSelected() )
+ {
+ // then set as hyperlink after the graphic
+ nFmt = SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK;
+ nRet = true;
+ }
+ }
+
+ if(pPt && bNeedToSelectBeforePaste)
+ {
+ // when using internal D&Ds, still the source object is selected and
+ // this is necessary to get the correct source data which is also
+ // dependent from selection. After receiving the drag data it is
+ // now tiime to select the correct target object
+ SwTransferable::SetSelInShell( rSh, sal_True, pPt );
+ }
+
+ if( nRet )
+ {
+ //Check and Perform rotation if needed
+ lclCheckAndPerformRotation(aGraphic);
+
+ OUString sURL;
+ if( rSh.GetView().GetDocShell()->ISA(SwWebDocShell)
+ // #i123922# if link action is noted, also take URL
+ || DND_ACTION_LINK == nDropAction)
+ {
+ sURL = aBkmk.GetURL();
+ }
+
+ switch( nAction )
+ {
+ case SW_PASTESDR_INSERT:
+ {
+ SwTransferable::SetSelInShell( rSh, sal_False, pPt );
+ rSh.Insert( sURL, aEmptyOUStr, aGraphic );
+ break;
+ }
+
+ case SW_PASTESDR_REPLACE:
+ {
+ if( rSh.IsObjSelected() )
+ {
+ // #i123922# for D&D on draw objects, do for now the same for
+ // SW_PASTESDR_REPLACE (D&D) as for SW_PASTESDR_SETATTR (D&D and
+ // CTRL+SHIFT). The code below replaces the draw object with
+ // a writer graphic; maybe this is an option later again if wanted
+ rSh.Paste( aGraphic, sURL );
+
+ // rSh.ReplaceSdrObj( sURL, aEmptyOUStr, &aGraphic );
+ // Point aPt( pPt ? *pPt : rSh.GetCrsrDocPos() );
+ // SwTransferable::SetSelInShell( rSh, sal_True, &aPt );
+ }
+ else
+ {
+ // set graphic at writer graphic without link
+ rSh.ReRead( sURL, aEmptyOUStr, &aGraphic );
+ }
+
+ break;
+ }
+
+ case SW_PASTESDR_SETATTR:
+ {
+ if( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK == nFmt )
+ {
+ if( rSh.IsFrmSelected() )
+ {
+ SfxItemSet aSet( rSh.GetAttrPool(), RES_URL, RES_URL );
+ rSh.GetFlyFrmAttr( aSet );
+ SwFmtURL aURL( (SwFmtURL&)aSet.Get( RES_URL ) );
+ aURL.SetURL( aBkmk.GetURL(), false );
+ aSet.Put( aURL );
+ rSh.SetFlyFrmAttr( aSet );
+ }
+ }
+ else if( rSh.IsObjSelected() )
+ {
+ // set as attribute at DrawObject
+ rSh.Paste( aGraphic, sURL );
+ }
+ else if( OBJCNT_GRF == rSh.GetObjCntTypeOfSelection() )
+ {
+ // set as linked graphic at writer graphic frame
+ rSh.ReRead( sURL, aEmptyOUStr, &aGraphic );
+ }
+ else
+ {
+ SwTransferable::SetSelInShell( rSh, sal_False, pPt );
+ rSh.Insert( aBkmk.GetURL(), aEmptyOUStr, aGraphic );
+ }
+ break;
+ }
+ default:
+ {
+ nRet = false;
+ break;
+ }
+ }
+ }
+
+ if( nRet )
+ {
+
+ if( nActionFlags &
+ (( EXCHG_OUT_ACTION_FLAG_INSERT_IMAGEMAP |
+ EXCHG_OUT_ACTION_FLAG_REPLACE_IMAGEMAP ) >> 8) )
+ SwTransferable::_PasteImageMap( rData, rSh );
+
+ if( nActionFlags &
+ ( EXCHG_OUT_ACTION_FLAG_INSERT_TARGETURL >> 8) )
+ SwTransferable::_PasteTargetURL( rData, rSh, 0, 0, sal_False );
+ }
+ else if( bCheckForImageMap )
+ {
+ // or should the file be an ImageMap-File?
+ ImageMap aMap;
+ SfxMedium aMed( INetURLObject(aBkmk.GetURL()).GetFull(),
+ STREAM_STD_READ );
+ SvStream* pStream = aMed.GetInStream();
+ if( pStream != NULL &&
+ !pStream->GetError() &&
+ // mba: no BaseURL for clipboard functionality
+ aMap.Read( *pStream, IMAP_FORMAT_DETECT, OUString() ) == IMAP_ERR_OK &&
+ aMap.GetIMapObjectCount() )
+ {
+ SfxItemSet aSet( rSh.GetAttrPool(), RES_URL, RES_URL );
+ rSh.GetFlyFrmAttr( aSet );
+ SwFmtURL aURL( (SwFmtURL&)aSet.Get( RES_URL ) );
+ aURL.SetMap( &aMap );
+ aSet.Put( aURL );
+ rSh.SetFlyFrmAttr( aSet );
+ nRet = true;
+ }
+ }
+
+ return nRet;
+}
+
+bool SwTransferable::_PasteImageMap( TransferableDataHelper& rData,
+ SwWrtShell& rSh )
+{
+ bool nRet = false;
+ if( rData.HasFormat( SOT_FORMATSTR_ID_SVIM ))
+ {
+ SfxItemSet aSet( rSh.GetAttrPool(), RES_URL, RES_URL );
+ rSh.GetFlyFrmAttr( aSet );
+ SwFmtURL aURL( (SwFmtURL&)aSet.Get( RES_URL ) );
+ const ImageMap* pOld = aURL.GetMap();
+
+ // set or replace, that is the question
+ ImageMap aImageMap;
+ if( rData.GetImageMap( SOT_FORMATSTR_ID_SVIM, aImageMap ) &&
+ ( !pOld || aImageMap != *pOld ))
+ {
+ aURL.SetMap( &aImageMap );
+ aSet.Put( aURL );
+ rSh.SetFlyFrmAttr( aSet );
+ }
+ nRet = true;
+ }
+ return nRet;
+}
+
+bool SwTransferable::_PasteAsHyperlink( TransferableDataHelper& rData,
+ SwWrtShell& rSh, sal_uLong nFmt )
+{
+ bool nRet = false;
+ OUString sFile;
+ if( rData.GetString( nFmt, sFile ) && !sFile.isEmpty() )
+ {
+ OUString sDesc;
+ SwTransferable::_CheckForURLOrLNKFile( rData, sFile, &sDesc );
+
+ // first, make the URL absolute
+ INetURLObject aURL;
+ aURL.SetSmartProtocol( INET_PROT_FILE );
+ aURL.SetSmartURL( sFile );
+ sFile = aURL.GetMainURL( INetURLObject::NO_DECODE );
+
+ switch( rSh.GetObjCntTypeOfSelection() )
+ {
+ case OBJCNT_FLY:
+ case OBJCNT_GRF:
+ case OBJCNT_OLE:
+ {
+ SfxItemSet aSet( rSh.GetAttrPool(), RES_URL, RES_URL );
+ rSh.GetFlyFrmAttr( aSet );
+ SwFmtURL aURL2( (SwFmtURL&)aSet.Get( RES_URL ) );
+ aURL2.SetURL( sFile, false );
+ if( aURL2.GetName().isEmpty() )
+ aURL2.SetName( sFile );
+ aSet.Put( aURL2 );
+ rSh.SetFlyFrmAttr( aSet );
+ }
+ break;
+
+ default:
+ {
+ rSh.InsertURL( SwFmtINetFmt( sFile, OUString() ),
+ sDesc.isEmpty() ? sFile : sDesc);
+ }
+ }
+ nRet = true;
+ }
+ return nRet;
+}
+
+bool SwTransferable::_PasteFileName( TransferableDataHelper& rData,
+ SwWrtShell& rSh, sal_uLong nFmt,
+ sal_uInt16 nAction, const Point* pPt,
+ sal_uInt8 nActionFlags, sal_Bool /* bMsg */,
+ bool * graphicInserted)
+{
+ bool nRet = SwTransferable::_PasteGrf( rData, rSh, nFmt, nAction,
+ pPt, nActionFlags, 0, false);
+ if (graphicInserted != 0) {
+ *graphicInserted = nRet;
+ }
+ if( !nRet )
+ {
+ OUString sFile, sDesc;
+ if( rData.GetString( nFmt, sFile ) && !sFile.isEmpty() )
+ {
+ INetURLObject aMediaURL;
+
+ aMediaURL.SetSmartURL( sFile );
+ const OUString aMediaURLStr( aMediaURL.GetMainURL( INetURLObject::NO_DECODE ) );
+
+ if( ::avmedia::MediaWindow::isMediaURL( aMediaURLStr, ""/*TODO?*/ ) )
+ {
+ const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA, aMediaURLStr );
+ rSh.GetView().GetViewFrame()->GetDispatcher()->Execute(
+ SID_INSERT_AVMEDIA, SFX_CALLMODE_SYNCHRON,
+ &aMediaURLItem, 0L );
+ }
+ else
+ {
+ sal_Bool bIsURLFile = SwTransferable::_CheckForURLOrLNKFile( rData, sFile, &sDesc );
+
+ //Own FileFormat? --> insert, not for StarWriter/Web
+ OUString sFileURL = URIHelper::SmartRel2Abs(INetURLObject(), sFile, Link(), false );
+ const SfxFilter* pFlt = SW_PASTESDR_SETATTR == nAction
+ ? 0 : SwIoSystem::GetFileFilter(
+ sFileURL, aEmptyOUStr );
+ if( pFlt && !rSh.GetView().GetDocShell()->ISA(SwWebDocShell) )
+ {
+ // and then pull up the insert-region-dialog by PostUser event
+ SwSectionData * pSect = new SwSectionData(
+ FILE_LINK_SECTION,
+ rSh.GetDoc()->GetUniqueSectionName() );
+ pSect->SetLinkFileName( sFileURL );
+ pSect->SetProtectFlag( true );
+
+ Application::PostUserEvent( STATIC_LINK( &rSh, SwWrtShell,
+ InsertRegionDialog ), pSect );
+ nRet = true;
+ }
+ else if( SW_PASTESDR_SETATTR == nAction ||
+ ( bIsURLFile && SW_PASTESDR_INSERT == nAction ))
+ {
+ //we can insert foreign files as links after all
+
+ // first, make the URL absolute
+ INetURLObject aURL;
+ aURL.SetSmartProtocol( INET_PROT_FILE );
+ aURL.SetSmartURL( sFile );
+ sFile = aURL.GetMainURL( INetURLObject::NO_DECODE );
+
+ switch( rSh.GetObjCntTypeOfSelection() )
+ {
+ case OBJCNT_FLY:
+ case OBJCNT_GRF:
+ case OBJCNT_OLE:
+ {
+ SfxItemSet aSet( rSh.GetAttrPool(), RES_URL, RES_URL );
+ rSh.GetFlyFrmAttr( aSet );
+ SwFmtURL aURL2( (SwFmtURL&)aSet.Get( RES_URL ) );
+ aURL2.SetURL( sFile, false );
+ if( aURL2.GetName().isEmpty() )
+ aURL2.SetName( sFile );
+ aSet.Put( aURL2 );
+ rSh.SetFlyFrmAttr( aSet );
+ }
+ break;
+
+ default:
+ {
+ rSh.InsertURL( SwFmtINetFmt( sFile, OUString() ),
+ sDesc.isEmpty() ? sFile : sDesc );
+ }
+ }
+ nRet = true;
+ }
+ }
+ }
+ }
+ return nRet;
+}
+
+bool SwTransferable::_PasteDBData( TransferableDataHelper& rData,
+ SwWrtShell& rSh, sal_uLong nFmt, sal_Bool bLink,
+ const Point* pDragPt, sal_Bool bMsg )
+{
+ bool nRet = false;
+ OUString sTxt;
+ if( rData.GetString( nFmt, sTxt ) && !sTxt.isEmpty() )
+ {
+ sal_uInt16 nWh = SOT_FORMATSTR_ID_SBA_CTRLDATAEXCHANGE == nFmt
+ ? 0
+ : SOT_FORMATSTR_ID_SBA_DATAEXCHANGE == nFmt
+ ? (bLink
+ ? FN_QRY_MERGE_FIELD
+ : FN_QRY_INSERT)
+ : (bLink
+ ? 0
+ : FN_QRY_INSERT_FIELD );
+ DataFlavorExVector& rVector = rData.GetDataFlavorExVector();
+ sal_Bool bHaveColumnDescriptor = OColumnTransferable::canExtractColumnDescriptor(rVector, CTF_COLUMN_DESCRIPTOR | CTF_CONTROL_EXCHANGE);
+ if ( SOT_FORMATSTR_ID_XFORMS == nFmt )
+ {
+ SdrObject* pObj;
+ rSh.MakeDrawView();
+ FmFormView* pFmView = PTR_CAST( FmFormView, rSh.GetDrawView() );
+ if(pFmView) {
+ const OXFormsDescriptor &rDesc = OXFormsTransferable::extractDescriptor(rData);
+ if(0 != (pObj = pFmView->CreateXFormsControl(rDesc)))
+ {
+ rSh.SwFEShell::InsertDrawObj( *pObj, *pDragPt );
+ }
+ }
+ }
+ else if( nWh )
+ {
+ SfxUsrAnyItem* pConnectionItem = 0;
+ SfxUsrAnyItem* pCursorItem = 0;
+ SfxUsrAnyItem* pColumnItem = 0;
+ SfxUsrAnyItem* pSourceItem = 0;
+ SfxUsrAnyItem* pCommandItem = 0;
+ SfxUsrAnyItem* pCommandTypeItem = 0;
+ SfxUsrAnyItem* pColumnNameItem = 0;
+ SfxUsrAnyItem* pSelectionItem = 0;
+
+ sal_Bool bDataAvailable = sal_True;
+ ODataAccessDescriptor aDesc;
+ if(bHaveColumnDescriptor)
+ aDesc = OColumnTransferable::extractColumnDescriptor(rData);
+ else if(ODataAccessObjectTransferable::canExtractObjectDescriptor(rVector) )
+ aDesc = ODataAccessObjectTransferable::extractObjectDescriptor(rData);
+ else
+ bDataAvailable = sal_False;
+
+ if ( bDataAvailable )
+ {
+ pConnectionItem = new SfxUsrAnyItem(FN_DB_CONNECTION_ANY, aDesc[daConnection]);
+ pColumnItem = new SfxUsrAnyItem(FN_DB_COLUMN_ANY, aDesc[daColumnObject]);
+ pSourceItem = new SfxUsrAnyItem(FN_DB_DATA_SOURCE_ANY, makeAny(aDesc.getDataSource()));
+ pCommandItem = new SfxUsrAnyItem(FN_DB_DATA_COMMAND_ANY, aDesc[daCommand]);
+ pCommandTypeItem = new SfxUsrAnyItem(FN_DB_DATA_COMMAND_TYPE_ANY, aDesc[daCommandType]);
+ pColumnNameItem = new SfxUsrAnyItem(FN_DB_DATA_COLUMN_NAME_ANY, aDesc[daColumnName]);
+ pSelectionItem = new SfxUsrAnyItem(FN_DB_DATA_SELECTION_ANY, aDesc[daSelection]);
+ pCursorItem = new SfxUsrAnyItem(FN_DB_DATA_CURSOR_ANY, aDesc[daCursor]);
+ }
+
+ SwView& rView = rSh.GetView();
+ //force ::SelectShell
+ rView.StopShellTimer();
+
+ SfxStringItem aDataDesc( nWh, sTxt );
+ rView.GetViewFrame()->GetDispatcher()->Execute(
+ nWh, SFX_CALLMODE_ASYNCHRON, &aDataDesc,
+ pConnectionItem, pColumnItem,
+ pSourceItem, pCommandItem, pCommandTypeItem,
+ pColumnNameItem, pSelectionItem, pCursorItem,0L);
+ delete pConnectionItem;
+ delete pColumnItem;
+ delete pSourceItem;
+ delete pCommandItem;
+ delete pCommandTypeItem;
+ delete pColumnNameItem;
+ delete pSelectionItem;
+ delete pCursorItem;
+ }
+ else
+ {
+ SdrObject* pObj;
+ rSh.MakeDrawView();
+ FmFormView* pFmView = PTR_CAST( FmFormView, rSh.GetDrawView() );
+ if (pFmView && bHaveColumnDescriptor)
+ {
+ if ( 0 != (pObj = pFmView->CreateFieldControl( OColumnTransferable::extractColumnDescriptor(rData) ) ) )
+ rSh.SwFEShell::InsertDrawObj( *pObj, *pDragPt );
+ }
+ }
+ nRet = true;
+ }
+ else if( bMsg )
+ {
+ InfoBox( 0, SW_RES(MSG_CLPBRD_FORMAT_ERROR)).Execute();
+ }
+ return nRet;
+}
+
+bool SwTransferable::_PasteFileList( TransferableDataHelper& rData,
+ SwWrtShell& rSh, sal_Bool bLink,
+ const Point* pPt, sal_Bool bMsg )
+{
+ bool nRet = false;
+ FileList aFileList;
+ if( rData.GetFileList( SOT_FORMAT_FILE_LIST, aFileList ) &&
+ aFileList.Count() )
+ {
+ sal_uInt16 nAct = bLink ? SW_PASTESDR_SETATTR : SW_PASTESDR_INSERT;
+ OUString sFlyNm;
+ // iterate over the filelist
+ for( sal_uLong n = 0, nEnd = aFileList.Count(); n < nEnd; ++n )
+ {
+ TransferDataContainer* pHlp = new TransferDataContainer;
+ pHlp->CopyString( FORMAT_FILE, aFileList.GetFile( n ));
+ TransferableDataHelper aData( pHlp );
+
+ if( SwTransferable::_PasteFileName( aData, rSh, SOT_FORMAT_FILE, nAct,
+ pPt, sal_False, bMsg, 0 ))
+ {
+ if( bLink )
+ {
+ sFlyNm = rSh.GetFlyName();
+ SwTransferable::SetSelInShell( rSh, sal_False, pPt );
+ }
+ nRet = true;
+ }
+ }
+ if( !sFlyNm.isEmpty() )
+ rSh.GotoFly( sFlyNm );
+ }
+ else if( bMsg )
+ {
+ InfoBox( 0, SW_RES(MSG_CLPBRD_FORMAT_ERROR)).Execute();
+ }
+ return nRet;
+}
+
+sal_Bool SwTransferable::_CheckForURLOrLNKFile( TransferableDataHelper& rData,
+ OUString& rFileName, OUString* pTitle )
+{
+ sal_Bool bIsURLFile = sal_False;
+ INetBookmark aBkmk;
+ if( rData.GetINetBookmark( SOT_FORMATSTR_ID_SOLK, aBkmk ) )
+ {
+ rFileName = aBkmk.GetURL();
+ if( pTitle )
+ *pTitle = aBkmk.GetDescription();
+ bIsURLFile = sal_True;
+ }
+ else
+ {
+ sal_Int32 nLen = rFileName.getLength();
+ if( 4 < nLen && '.' == rFileName[ nLen - 4 ])
+ {
+ OUString sExt( rFileName.copy( nLen - 3 ));
+ if( sExt.equalsIgnoreAsciiCase( "url" ))
+ {
+ OSL_ENSURE( !&rFileName, "how do we read today .URL - Files?" );
+ }
+ }
+ }
+ return bIsURLFile;
+}
+
+sal_Bool SwTransferable::IsPasteSpecial( const SwWrtShell& rWrtShell,
+ const TransferableDataHelper& rData )
+{
+ // we can paste-special if there's an entry in the paste-special-format list
+ SvxClipboardFmtItem aClipboardFmtItem(0);
+ FillClipFmtItem( rWrtShell, rData, aClipboardFmtItem);
+ return aClipboardFmtItem.Count() > 0;
+}
+
+bool SwTransferable::PasteFormat( SwWrtShell& rSh,
+ TransferableDataHelper& rData,
+ sal_uLong nFormat )
+{
+ SwWait aWait( *rSh.GetView().GetDocShell(), false );
+ bool nRet = false;
+
+ sal_uLong nPrivateFmt = FORMAT_PRIVATE;
+ SwTransferable *pClipboard = GetSwTransferable( rData );
+ if( pClipboard &&
+ ((TRNSFR_DOCUMENT|TRNSFR_GRAPHIC|TRNSFR_OLE) & pClipboard->eBufferType ))
+ nPrivateFmt = SOT_FORMATSTR_ID_EMBED_SOURCE;
+
+ if( pClipboard && nPrivateFmt == nFormat )
+ nRet = pClipboard->PrivatePaste( rSh );
+ else if( rData.HasFormat( nFormat ) )
+ {
+ uno::Reference<XTransferable> xTransferable( rData.GetXTransferable() );
+ sal_uInt16 nEventAction,
+ nDestination = SwTransferable::GetSotDestination( rSh ),
+ nSourceOptions =
+ (( EXCHG_DEST_DOC_TEXTFRAME == nDestination ||
+ EXCHG_DEST_SWDOC_FREE_AREA == nDestination ||
+ EXCHG_DEST_DOC_TEXTFRAME_WEB == nDestination ||
+ EXCHG_DEST_SWDOC_FREE_AREA_WEB == nDestination )
+ ? EXCHG_IN_ACTION_COPY
+ : EXCHG_IN_ACTION_MOVE),
+ nAction = SotExchange::GetExchangeAction(
+ rData.GetDataFlavorExVector(),
+ nDestination,
+ nSourceOptions, /* ?? */
+ EXCHG_IN_ACTION_DEFAULT, /* ?? */
+ nFormat, nEventAction, nFormat,
+ lcl_getTransferPointer ( xTransferable ) );
+
+ if( EXCHG_INOUT_ACTION_NONE != nAction )
+ nRet = SwTransferable::PasteData( rData, rSh, nAction, nFormat,
+ nDestination, sal_True, sal_False );
+ }
+ return nRet;
+}
+
+bool SwTransferable::_TestAllowedFormat( const TransferableDataHelper& rData,
+ sal_uLong nFormat, sal_uInt16 nDestination )
+{
+ sal_uInt16 nAction = EXCHG_INOUT_ACTION_NONE, nEventAction;
+ if( rData.HasFormat( nFormat )) {
+ uno::Reference<XTransferable> xTransferable( rData.GetXTransferable() );
+ nAction = SotExchange::GetExchangeAction(
+ rData.GetDataFlavorExVector(),
+ nDestination, EXCHG_IN_ACTION_COPY,
+ EXCHG_IN_ACTION_COPY, nFormat,
+ nEventAction, nFormat,
+ lcl_getTransferPointer ( xTransferable ) );
+ }
+ return EXCHG_INOUT_ACTION_NONE != nAction;
+}
+
+/**
+ * the list of formats which will be offered to the user in the 'Paste
+ * Special...' dialog and the paste button menu
+ */
+static sal_uInt16 aPasteSpecialIds[] =
+{
+ SOT_FORMATSTR_ID_HTML,
+ SOT_FORMATSTR_ID_HTML_SIMPLE,
+ SOT_FORMATSTR_ID_HTML_NO_COMMENT,
+ FORMAT_RTF,
+ FORMAT_STRING,
+ SOT_FORMATSTR_ID_SONLK,
+ SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK,
+ SOT_FORMATSTR_ID_DRAWING,
+ SOT_FORMATSTR_ID_SVXB,
+ FORMAT_GDIMETAFILE,
+ FORMAT_BITMAP,
+ SOT_FORMATSTR_ID_SVIM,
+ SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR,
+ 0
+};
+
+bool SwTransferable::PasteUnformatted( SwWrtShell& rSh, TransferableDataHelper& rData )
+{
+ // Plain text == unformatted
+ return SwTransferable::PasteFormat( rSh, rData, SOT_FORMAT_STRING );
+}
+
+bool SwTransferable::PasteSpecial( SwWrtShell& rSh, TransferableDataHelper& rData, sal_uLong& rFormatUsed )
+{
+ bool nRet = false;
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ boost::scoped_ptr<SfxAbstractPasteDialog> pDlg(pFact->CreatePasteDialog( &rSh.GetView().GetEditWin() ));
+
+ DataFlavorExVector aFormats( rData.GetDataFlavorExVector() );
+ TransferableObjectDescriptor aDesc;
+
+ sal_uInt16 nDest = SwTransferable::GetSotDestination( rSh );
+
+ SwTransferable *pClipboard = GetSwTransferable( rData );
+ if( pClipboard )
+ {
+ aDesc = pClipboard->aObjDesc;
+ sal_uInt16 nResId;
+ if( pClipboard->eBufferType & TRNSFR_DOCUMENT )
+ nResId = STR_PRIVATETEXT;
+ else if( pClipboard->eBufferType & TRNSFR_GRAPHIC )
+ nResId = STR_PRIVATEGRAPHIC;
+ else if( pClipboard->eBufferType == TRNSFR_OLE )
+ nResId = STR_PRIVATEOLE;
+ else
+ nResId = 0;
+
+ if( nResId )
+ {
+ if( STR_PRIVATEOLE == nResId || STR_PRIVATEGRAPHIC == nResId )
+ {
+ // add SOT_FORMATSTR_ID_EMBED_SOURCE to the formats. This
+ // format display then the private format name.
+ DataFlavorEx aFlavorEx;
+ aFlavorEx.mnSotId = SOT_FORMATSTR_ID_EMBED_SOURCE;
+ aFormats.insert( aFormats.begin(), aFlavorEx );
+ }
+ pDlg->SetObjName( pClipboard->aObjDesc.maClassName,
+ SW_RES( nResId ) );
+ pDlg->Insert( SOT_FORMATSTR_ID_EMBED_SOURCE, aEmptyOUStr );
+ }
+ }
+ else
+ {
+ if( rData.HasFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR ) )
+ rData.GetTransferableObjectDescriptor(
+ SOT_FORMATSTR_ID_OBJECTDESCRIPTOR, aDesc );
+
+ if( SwTransferable::_TestAllowedFormat( rData, SOT_FORMATSTR_ID_EMBED_SOURCE, nDest ))
+ pDlg->Insert( SOT_FORMATSTR_ID_EMBED_SOURCE, aEmptyOUStr );
+ if( SwTransferable::_TestAllowedFormat( rData, SOT_FORMATSTR_ID_LINK_SOURCE, nDest ))
+ pDlg->Insert( SOT_FORMATSTR_ID_LINK_SOURCE, aEmptyOUStr );
+ }
+
+ if( SwTransferable::_TestAllowedFormat( rData, SOT_FORMATSTR_ID_LINK, nDest ))
+ pDlg->Insert( SOT_FORMATSTR_ID_LINK, SW_RES(STR_DDEFORMAT) );
+
+ for( sal_uInt16* pIds = aPasteSpecialIds; *pIds; ++pIds )
+ if( SwTransferable::_TestAllowedFormat( rData, *pIds, nDest ))
+ pDlg->Insert( *pIds, aEmptyOUStr );
+
+ sal_uLong nFormat = pDlg->GetFormat( rData.GetTransferable() );
+
+ if( nFormat )
+ nRet = SwTransferable::PasteFormat( rSh, rData, nFormat );
+
+ if ( nRet )
+ rFormatUsed = nFormat;
+
+ return nRet;
+}
+
+void SwTransferable::FillClipFmtItem( const SwWrtShell& rSh,
+ const TransferableDataHelper& rData,
+ SvxClipboardFmtItem & rToFill )
+{
+ sal_uInt16 nDest = SwTransferable::GetSotDestination( rSh );
+
+ SwTransferable *pClipboard = GetSwTransferable( rData );
+ if( pClipboard )
+ {
+ sal_uInt16 nResId;
+ if( pClipboard->eBufferType & TRNSFR_DOCUMENT )
+ nResId = STR_PRIVATETEXT;
+ else if( pClipboard->eBufferType & TRNSFR_GRAPHIC )
+ nResId = STR_PRIVATEGRAPHIC;
+ else if( pClipboard->eBufferType == TRNSFR_OLE )
+ nResId = STR_PRIVATEOLE;
+ else
+ nResId = 0;
+
+ if( nResId )
+ rToFill.AddClipbrdFormat( SOT_FORMATSTR_ID_EMBED_SOURCE,
+ SW_RESSTR( nResId ) );
+ }
+ else
+ {
+ TransferableObjectDescriptor aDesc;
+ if( rData.HasFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR ) )
+ ((TransferableDataHelper&)rData).GetTransferableObjectDescriptor(
+ SOT_FORMATSTR_ID_OBJECTDESCRIPTOR, aDesc );
+
+ if( SwTransferable::_TestAllowedFormat( rData, SOT_FORMATSTR_ID_EMBED_SOURCE, nDest ))
+ rToFill.AddClipbrdFormat( SOT_FORMATSTR_ID_EMBED_SOURCE,
+ aDesc.maTypeName );
+ if( SwTransferable::_TestAllowedFormat( rData, SOT_FORMATSTR_ID_LINK_SOURCE, nDest ))
+ rToFill.AddClipbrdFormat( SOT_FORMATSTR_ID_LINK_SOURCE );
+
+ SotFormatStringId nFormat;
+ if ( rData.HasFormat(nFormat = SOT_FORMATSTR_ID_EMBED_SOURCE_OLE) || rData.HasFormat(nFormat = SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE) )
+ {
+ OUString sName,sSource;
+ if ( SvPasteObjectHelper::GetEmbeddedName(rData,sName,sSource,nFormat) )
+ rToFill.AddClipbrdFormat( nFormat, sName );
+ }
+ }
+
+ if( SwTransferable::_TestAllowedFormat( rData, SOT_FORMATSTR_ID_LINK, nDest ))
+ rToFill.AddClipbrdFormat( SOT_FORMATSTR_ID_LINK, SW_RESSTR(STR_DDEFORMAT) );
+
+ for( sal_uInt16* pIds = aPasteSpecialIds; *pIds; ++pIds )
+ if( SwTransferable::_TestAllowedFormat( rData, *pIds, nDest ))
+ rToFill.AddClipbrdFormat( *pIds, aEmptyOUStr );
+}
+
+void SwTransferable::SetDataForDragAndDrop( const Point& rSttPos )
+{
+ if(!pWrtShell)
+ return;
+ OUString sGrfNm;
+ const int nSelection = pWrtShell->GetSelectionType();
+ if( nsSelectionType::SEL_GRF == nSelection)
+ {
+ AddFormat( SOT_FORMATSTR_ID_SVXB );
+ const Graphic* pGrf = pWrtShell->GetGraphic();
+ if ( pGrf && pGrf->IsSupportedGraphic() )
+ {
+ AddFormat( FORMAT_GDIMETAFILE );
+ AddFormat( SOT_FORMATSTR_ID_PNG );
+ AddFormat( FORMAT_BITMAP );
+ }
+ eBufferType = TRNSFR_GRAPHIC;
+ pWrtShell->GetGrfNms( &sGrfNm, 0 );
+ }
+ else if( nsSelectionType::SEL_OLE == nSelection )
+ {
+ AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE );
+ PrepareOLE( aObjDesc );
+ AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR );
+ AddFormat( FORMAT_GDIMETAFILE );
+ eBufferType = TRNSFR_OLE;
+ }
+ //Is there anything to provide anyway?
+ else if ( pWrtShell->IsSelection() || pWrtShell->IsFrmSelected() ||
+ pWrtShell->IsObjSelected() )
+ {
+ if( pWrtShell->IsObjSelected() )
+ eBufferType = TRNSFR_DRAWING;
+ else
+ {
+ eBufferType = TRNSFR_DOCUMENT;
+ if( SwWrtShell::NO_WORD !=
+ pWrtShell->IntelligentCut( nSelection, sal_False ))
+ eBufferType = TransferBufferType( TRNSFR_DOCUMENT_WORD
+ | eBufferType);
+ }
+
+ if( nSelection & nsSelectionType::SEL_TBL_CELLS )
+ eBufferType = (TransferBufferType)(TRNSFR_TABELLE | eBufferType);
+
+ AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE );
+
+ //put RTF ahead of the OLE's Metafile for less loss
+ if( !pWrtShell->IsObjSelected() )
+ {
+ AddFormat( FORMAT_RTF );
+ AddFormat( SOT_FORMATSTR_ID_HTML );
+ }
+ if( pWrtShell->IsSelection() )
+ AddFormat( FORMAT_STRING );
+
+ if( nSelection & ( nsSelectionType::SEL_DRW | nsSelectionType::SEL_DRW_FORM ))
+ {
+ AddFormat( SOT_FORMATSTR_ID_DRAWING );
+ if ( nSelection & nsSelectionType::SEL_DRW )
+ {
+ AddFormat( FORMAT_GDIMETAFILE );
+ AddFormat( SOT_FORMATSTR_ID_PNG );
+ AddFormat( FORMAT_BITMAP );
+ }
+ eBufferType = (TransferBufferType)( TRNSFR_GRAPHIC | eBufferType );
+
+ pClpGraphic = new Graphic;
+ if( !pWrtShell->GetDrawObjGraphic( FORMAT_GDIMETAFILE, *pClpGraphic ))
+ pOrigGrf = pClpGraphic;
+ pClpBitmap = new Graphic;
+ if( !pWrtShell->GetDrawObjGraphic( FORMAT_BITMAP, *pClpBitmap ))
+ pOrigGrf = pClpBitmap;
+
+ // is it an URL-Button ?
+ OUString sURL;
+ OUString sDesc;
+ if( pWrtShell->GetURLFromButton( sURL, sDesc ) )
+ {
+ AddFormat( FORMAT_STRING );
+ AddFormat( SOT_FORMATSTR_ID_SOLK );
+ AddFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK );
+ AddFormat( SOT_FORMATSTR_ID_FILECONTENT );
+ AddFormat( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR );
+ AddFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR );
+ eBufferType = (TransferBufferType)( TRNSFR_INETFLD | eBufferType );
+ }
+ }
+
+ //ObjectDescriptor was already filled from the old DocShell.
+ //Now adjust it. Thus in GetData the first query can still
+ //be answered with delayed rendering.
+ aObjDesc.mbCanLink = sal_False;
+ aObjDesc.maDragStartPos = rSttPos;
+ aObjDesc.maSize = OutputDevice::LogicToLogic( Size( OLESIZE ),
+ MAP_TWIP, MAP_100TH_MM );
+ PrepareOLE( aObjDesc );
+ AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR );
+ }
+ else if( nSelection & nsSelectionType::SEL_TXT && !pWrtShell->HasMark() )
+ {
+ // is only one field - selected?
+ SwContentAtPos aCntntAtPos( SwContentAtPos::SW_INETATTR );
+ Point aPos( SwEditWin::GetDDStartPosX(), SwEditWin::GetDDStartPosY());
+
+ if( pWrtShell->GetContentAtPos( aPos, aCntntAtPos ) )
+ {
+ AddFormat( FORMAT_STRING );
+ AddFormat( SOT_FORMATSTR_ID_SOLK );
+ AddFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK );
+ AddFormat( SOT_FORMATSTR_ID_FILECONTENT );
+ AddFormat( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR );
+ AddFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR );
+ eBufferType = TRNSFR_INETFLD;
+ }
+ }
+
+ if( pWrtShell->IsFrmSelected() )
+ {
+ SfxItemSet aSet( pWrtShell->GetAttrPool(), RES_URL, RES_URL );
+ pWrtShell->GetFlyFrmAttr( aSet );
+ const SwFmtURL& rURL = (SwFmtURL&)aSet.Get( RES_URL );
+ if( rURL.GetMap() )
+ {
+ pImageMap = new ImageMap( *rURL.GetMap() );
+ AddFormat( SOT_FORMATSTR_ID_SVIM );
+ }
+ else if( !rURL.GetURL().isEmpty() )
+ {
+ pTargetURL = new INetImage( sGrfNm, rURL.GetURL(),
+ rURL.GetTargetFrameName(),
+ aEmptyOUStr, Size() );
+ AddFormat( SOT_FORMATSTR_ID_INET_IMAGE );
+ }
+ }
+}
+
+void SwTransferable::StartDrag( Window* pWin, const Point& rPos )
+{
+ if(!pWrtShell)
+ return;
+ bOldIdle = pWrtShell->GetViewOptions()->IsIdle();
+ bCleanUp = sal_True;
+
+ ((SwViewOption *)pWrtShell->GetViewOptions())->SetIdle( sal_False );
+
+ if( pWrtShell->IsSelFrmMode() )
+ pWrtShell->ShowCrsr();
+
+ SW_MOD()->pDragDrop = this;
+
+ SetDataForDragAndDrop( rPos );
+
+ sal_Int8 nDragOptions = DND_ACTION_COPYMOVE | DND_ACTION_LINK;
+ SwDocShell* pDShell = pWrtShell->GetView().GetDocShell();
+ if( ( pDShell && pDShell->IsReadOnly() ) || pWrtShell->HasReadonlySel() )
+ nDragOptions &= ~DND_ACTION_MOVE;
+
+ TransferableHelper::StartDrag( pWin, nDragOptions );
+}
+
+void SwTransferable::DragFinished( sal_Int8 nAction )
+{
+ //And the last finishing work so that all statuses are right
+ if( DND_ACTION_MOVE == nAction )
+ {
+ if( bCleanUp )
+ {
+ //It was dropped outside of Writer. We still have to
+ //delete.
+
+ pWrtShell->StartAllAction();
+ pWrtShell->StartUndo( UNDO_UI_DRAG_AND_MOVE );
+ if ( pWrtShell->IsTableMode() )
+ pWrtShell->DeleteTblSel();
+ else
+ {
+ if ( !(pWrtShell->IsSelFrmMode() || pWrtShell->IsObjSelected()) )
+ //SmartCut, take one of the blanks along
+ pWrtShell->IntelligentCut( pWrtShell->GetSelectionType(), sal_True );
+ pWrtShell->DelRight();
+ }
+ pWrtShell->EndUndo( UNDO_UI_DRAG_AND_MOVE );
+ pWrtShell->EndAllAction();
+ }
+ else
+ {
+ const int nSelection = pWrtShell->GetSelectionType();
+ if( ( nsSelectionType::SEL_FRM | nsSelectionType::SEL_GRF |
+ nsSelectionType::SEL_OLE | nsSelectionType::SEL_DRW ) & nSelection )
+ {
+ pWrtShell->EnterSelFrmMode();
+ }
+ }
+ }
+ pWrtShell->GetView().GetEditWin().DragFinished();
+
+ if( pWrtShell->IsSelFrmMode() )
+ pWrtShell->HideCrsr();
+ else
+ pWrtShell->ShowCrsr();
+
+ ((SwViewOption *)pWrtShell->GetViewOptions())->SetIdle( bOldIdle );
+}
+
+bool SwTransferable::PrivatePaste( SwWrtShell& rShell )
+{
+ // first, ask for the SelectionType, then action-bracketing !!!!
+ // (otherwise it's not pasted into a TableSelection!!!)
+ OSL_ENSURE( !rShell.ActionPend(), "Paste must never have an ActionPend" );
+ if ( !pClpDocFac )
+ return false; // the return value of the SwFEShell::Paste also is sal_Bool!
+
+ const int nSelection = rShell.GetSelectionType();
+
+ SwRewriter aRewriter;
+
+ SwTrnsfrActionAndUndo aAction( &rShell, UNDO_PASTE_CLIPBOARD);
+
+ bool bKillPaMs = false;
+
+ //Delete selected content, not at table-selection and table in Clipboard
+ if( rShell.HasSelection() && !( nSelection & nsSelectionType::SEL_TBL_CELLS))
+ {
+ bKillPaMs = true;
+ rShell.SetRetainSelection( true );
+ rShell.DelRight();
+ // when a Fly was selected, a valid cursor position has to be found now
+ // (parked Cursor!)
+ if( ( nsSelectionType::SEL_FRM | nsSelectionType::SEL_GRF |
+ nsSelectionType::SEL_OLE | nsSelectionType::SEL_DRW |
+ nsSelectionType::SEL_DRW_FORM ) & nSelection )
+ {
+ // position the cursor again
+ Point aPt( rShell.GetCharRect().Pos() );
+ rShell.SwCrsrShell::SetCrsr( aPt, sal_True );
+ }
+ rShell.SetRetainSelection( false );
+ }
+
+ sal_Bool bInWrd = sal_False, bEndWrd = sal_False, bSttWrd = sal_False,
+ bSmart = 0 != (TRNSFR_DOCUMENT_WORD & eBufferType);
+ if( bSmart )
+ {
+ // Why not for other Scripts? If TRNSFR_DOCUMENT_WORD is set, we have a word
+ // in the buffer, word in this context means 'something with spaces at beginning
+ // and end'. In this case we definitely want these spaces to be inserted here.
+ bInWrd = rShell.IsInWrd();
+ bEndWrd = rShell.IsEndWrd();
+ bSmart = bInWrd || bEndWrd;
+ if( bSmart )
+ {
+ bSttWrd = rShell.IsSttWrd();
+ if( bSmart && !bSttWrd && (bInWrd || bEndWrd) )
+ rShell.SwEditShell::Insert(' ');
+ }
+ }
+
+ bool nRet = rShell.Paste( pClpDocFac->GetDoc() );
+
+ if( bKillPaMs )
+ rShell.KillPams();
+
+ // If Smart Paste then insert blank
+ if( nRet && bSmart && ((bInWrd && !bEndWrd )|| bSttWrd) )
+ rShell.SwEditShell::Insert(' ');
+
+ return nRet;
+}
+
+bool SwTransferable::PrivateDrop( SwWrtShell& rSh, const Point& rDragPt,
+ sal_Bool bMove, sal_Bool bIsXSelection )
+{
+ int cWord = 0;
+ sal_Bool bInWrd = sal_False;
+ sal_Bool bEndWrd = sal_False;
+ sal_Bool bSttWrd = sal_False;
+ bool bSttPara = false;
+ sal_Bool bTblSel = sal_False;
+ sal_Bool bFrmSel = sal_False;
+
+ SwWrtShell& rSrcSh = *GetShell();
+
+ rSh.UnSetVisCrsr();
+
+ if( TRNSFR_INETFLD == eBufferType )
+ {
+ if( rSh.GetFmtFromObj( rDragPt ) )
+ {
+ INetBookmark aTmp;
+ if( (TRNSFR_INETFLD & eBufferType) && pBkmk )
+ aTmp = *pBkmk;
+
+ // select target graphic
+ if( rSh.SelectObj( rDragPt ) )
+ {
+ rSh.HideCrsr();
+ rSh.EnterSelFrmMode( &rDragPt );
+ bFrmDrag = true;
+ }
+
+ const int nSelection = rSh.GetSelectionType();
+
+ // not yet consider Draw objects
+ if( nsSelectionType::SEL_GRF & nSelection )
+ {
+ SfxItemSet aSet( rSh.GetAttrPool(), RES_URL, RES_URL );
+ rSh.GetFlyFrmAttr( aSet );
+ SwFmtURL aURL( (SwFmtURL&)aSet.Get( RES_URL ) );
+ aURL.SetURL( aTmp.GetURL(), false );
+ aSet.Put( aURL );
+ rSh.SetFlyFrmAttr( aSet );
+ return true;
+ }
+
+ if( nsSelectionType::SEL_DRW & nSelection )
+ {
+ rSh.LeaveSelFrmMode();
+ rSh.UnSelectFrm();
+ rSh.ShowCrsr();
+ bFrmDrag = false;
+ }
+ }
+ }
+
+ if( &rSh != &rSrcSh && (nsSelectionType::SEL_GRF & rSh.GetSelectionType()) &&
+ TRNSFR_GRAPHIC == eBufferType )
+ {
+ // ReRead the graphic
+ OUString sGrfNm;
+ OUString sFltNm;
+ rSrcSh.GetGrfNms( &sGrfNm, &sFltNm );
+ rSh.ReRead( sGrfNm, sFltNm, rSrcSh.GetGraphic() );
+ return true;
+ }
+
+ //not in selections or selected frames
+ if( rSh.ChgCurrPam( rDragPt ) ||
+ ( rSh.IsSelFrmMode() && rSh.IsInsideSelectedObj( rDragPt )) )
+ return false;
+
+ if( rSrcSh.IsTableMode() )
+ bTblSel = sal_True;
+ else if( rSrcSh.IsSelFrmMode() || rSrcSh.IsObjSelected() )
+ {
+ // don't move position-protected objects!
+ if( bMove && rSrcSh.IsSelObjProtected( FLYPROTECT_POS ) )
+ return false;
+
+ bFrmSel = sal_True;
+ }
+
+ const int nSel = rSrcSh.GetSelectionType();
+
+ SwUndoId eUndoId = bMove ? UNDO_UI_DRAG_AND_MOVE : UNDO_UI_DRAG_AND_COPY;
+
+ SwRewriter aRewriter;
+
+ aRewriter.AddRule(UndoArg1, rSrcSh.GetSelDescr());
+
+ if(rSrcSh.GetDoc() != rSh.GetDoc())
+ rSrcSh.StartUndo( eUndoId, &aRewriter );
+ rSh.StartUndo( eUndoId, &aRewriter );
+
+ rSh.StartAction();
+ rSrcSh.StartAction();
+
+ if( &rSrcSh != &rSh )
+ {
+ rSh.EnterStdMode();
+ rSh.SwCrsrShell::SetCrsr( rDragPt, sal_True );
+ cWord = rSrcSh.IntelligentCut( nSel, sal_False );
+ }
+ else if( !bTblSel && !bFrmSel )
+ {
+ if( !rSh.IsAddMode() )
+ {
+ // #i87233#
+ if ( rSh.IsBlockMode() )
+ {
+ // preserve order of cursors for block mode
+ rSh.GoPrevCrsr();
+ }
+
+ rSh.SwCrsrShell::CreateCrsr();
+ }
+ rSh.SwCrsrShell::SetCrsr( rDragPt, sal_True, false );
+ rSh.GoPrevCrsr();
+ cWord = rSh.IntelligentCut( rSh.GetSelectionType(), sal_False );
+ rSh.GoNextCrsr();
+ }
+
+ bInWrd = rSh.IsInWrd();
+ bEndWrd = rSh.IsEndWrd();
+ bSttWrd = !bEndWrd && rSh.IsSttWrd();
+ bSttPara= rSh.IsSttPara();
+
+ Point aSttPt( SwEditWin::GetDDStartPosX(), SwEditWin::GetDDStartPosY() );
+
+ // at first, select INetFelder!
+ if( TRNSFR_INETFLD == eBufferType )
+ {
+ if( &rSrcSh == &rSh )
+ {
+ rSh.GoPrevCrsr();
+ rSh.SwCrsrShell::SetCrsr( aSttPt, sal_True );
+ rSh.SelectTxtAttr( RES_TXTATR_INETFMT );
+ if( rSh.ChgCurrPam( rDragPt ) )
+ {
+ // don't copy/move inside of yourself
+ rSh.DestroyCrsr();
+ rSh.EndUndo();
+ rSh.EndAction();
+ rSh.EndAction();
+ return false;
+ }
+ rSh.GoNextCrsr();
+ }
+ else
+ {
+ rSrcSh.SwCrsrShell::SetCrsr( aSttPt, sal_True );
+ rSrcSh.SelectTxtAttr( RES_TXTATR_INETFMT );
+ }
+
+ // is there an URL attribute at the insert point? Then replace that,
+ // so simply put up a selection?
+ rSh.DelINetAttrWithText();
+ bDDINetAttr = true;
+ }
+
+ if ( rSrcSh.IsSelFrmMode() )
+ {
+ //Hack: fool the special treatment
+ aSttPt -= aSttPt - rSrcSh.GetObjRect().Pos();
+ }
+
+ sal_Bool bRet = rSrcSh.SwFEShell::Copy( &rSh, aSttPt, rDragPt, bMove,
+ !bIsXSelection );
+
+ if( !bIsXSelection )
+ {
+ rSrcSh.Push();
+ if ( bRet && bMove && !bFrmSel )
+ {
+ if ( bTblSel )
+ {
+ /* delete table contents not cells */
+ rSrcSh.Delete();
+ }
+ else
+ {
+ //SmartCut, take one of the blanks along.
+ rSh.SwCrsrShell::DestroyCrsr();
+ if ( cWord == SwWrtShell::WORD_SPACE_BEFORE )
+ rSh.ExtendSelection( sal_False );
+ else if ( cWord == SwWrtShell::WORD_SPACE_AFTER )
+ rSh.ExtendSelection();
+ rSrcSh.DelRight();
+ }
+ }
+ rSrcSh.KillPams();
+ rSrcSh.Pop( sal_False );
+
+ /* after dragging a table selection inside one shell
+ set cursor to the drop position. */
+ if( &rSh == &rSrcSh && ( bTblSel || rSh.IsBlockMode() ) )
+ {
+ rSrcSh.SwCrsrShell::SetCrsr(rDragPt);
+ rSrcSh.GetSwCrsr()->SetMark();
+ }
+ }
+
+ if( bRet && !bTblSel && !bFrmSel )
+ {
+ if( (bInWrd || bEndWrd) &&
+ (cWord == SwWrtShell::WORD_SPACE_AFTER ||
+ cWord == SwWrtShell::WORD_SPACE_BEFORE) )
+ {
+ if ( bSttWrd || (bInWrd && !bEndWrd))
+ rSh.SwEditShell::Insert(' ', bIsXSelection);
+ if ( !bSttWrd || (bInWrd && !bSttPara) )
+ {
+ rSh.SwapPam();
+ if ( !bSttWrd )
+ rSh.SwEditShell::Insert(' ', bIsXSelection);
+ rSh.SwapPam();
+ }
+ }
+
+ if( bIsXSelection )
+ {
+ if( &rSrcSh == &rSh && !rSh.IsAddMode() )
+ {
+ rSh.SwCrsrShell::DestroyCrsr();
+ rSh.GoPrevCrsr();
+ }
+ else
+ {
+ rSh.SwapPam();
+ rSh.SwCrsrShell::ClearMark();
+ }
+ }
+ else
+ {
+ if( rSh.IsAddMode() )
+ rSh.SwCrsrShell::CreateCrsr();
+ else
+ {
+ // turn on selection mode
+ rSh.SttSelect();
+ rSh.EndSelect();
+ }
+ }
+ }
+
+ if( bRet && bMove && bFrmSel )
+ rSrcSh.LeaveSelFrmMode();
+
+ if( rSrcSh.GetDoc() != rSh.GetDoc() )
+ rSrcSh.EndUndo();
+ rSh.EndUndo();
+
+ // put the shell in the right state
+ if( &rSrcSh != &rSh && ( rSh.IsFrmSelected() || rSh.IsObjSelected() ))
+ rSh.EnterSelFrmMode();
+
+ rSrcSh.EndAction();
+ rSh.EndAction();
+ return true;
+}
+
+// Interfaces for Selection
+void SwTransferable::CreateSelection( SwWrtShell& rSh,
+ const SwViewShell * _pCreatorView )
+{
+ SwModule *pMod = SW_MOD();
+ SwTransferable* pNew = new SwTransferable( rSh );
+
+ pNew->pCreatorView = _pCreatorView;
+
+ uno::Reference< XTransferable > xRef( pNew );
+ pMod->pXSelection = pNew;
+ pNew->CopyToSelection( rSh.GetWin() );
+}
+
+void SwTransferable::ClearSelection( SwWrtShell& rSh,
+ const SwViewShell * _pCreatorView)
+{
+ SwModule *pMod = SW_MOD();
+ if( pMod->pXSelection &&
+ ((!pMod->pXSelection->pWrtShell) || (pMod->pXSelection->pWrtShell == &rSh)) &&
+ (!_pCreatorView || (pMod->pXSelection->pCreatorView == _pCreatorView)) )
+ {
+ TransferableHelper::ClearSelection( rSh.GetWin() );
+ }
+}
+
+namespace
+{
+ class theSwTransferableUnoTunnelId : public rtl::Static< UnoTunnelIdInit, SwTransferable > {};
+}
+
+const Sequence< sal_Int8 >& SwTransferable::getUnoTunnelId()
+{
+ return theSwTransferableUnoTunnelId::get().getSeq();
+}
+
+sal_Int64 SwTransferable::getSomething( const Sequence< sal_Int8 >& rId ) throw( RuntimeException, std::exception )
+{
+ sal_Int64 nRet;
+ if( ( rId.getLength() == 16 ) &&
+ ( 0 == memcmp( getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) ) )
+ {
+ nRet = sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this ) );
+ }
+ else
+ nRet = TransferableHelper::getSomething(rId);
+ return nRet;
+}
+
+SwTransferable* SwTransferable::GetSwTransferable( const TransferableDataHelper& rData )
+{
+ SwTransferable* pSwTransferable = NULL;
+
+ uno::Reference<XUnoTunnel> xTunnel( rData.GetTransferable(), UNO_QUERY );
+ if ( xTunnel.is() )
+ {
+ sal_Int64 nHandle = xTunnel->getSomething( getUnoTunnelId() );
+ if ( nHandle )
+ pSwTransferable = (SwTransferable*) (sal_IntPtr) nHandle;
+ }
+
+ return pSwTransferable;
+
+}
+
+SwTrnsfrDdeLink::SwTrnsfrDdeLink( SwTransferable& rTrans, SwWrtShell& rSh )
+ : rTrnsfr( rTrans ), pDocShell( 0 ),
+ bDelBookmrk( sal_False ), bInDisconnect( sal_False )
+{
+ // we only end up here with table- or text selection
+ if( nsSelectionType::SEL_TBL_CELLS & rSh.GetSelectionType() )
+ {
+ SwFrmFmt* pFmt = rSh.GetTableFmt();
+ if( pFmt )
+ sName = pFmt->GetName();
+ }
+ else
+ {
+ // creating a temp. bookmark without undo
+ sal_Bool bUndo = rSh.DoesUndo();
+ rSh.DoUndo( sal_False );
+ sal_Bool bIsModified = rSh.IsModified();
+
+ ::sw::mark::IMark* pMark = rSh.SetBookmark(
+ KeyCode(),
+ OUString(),
+ OUString(),
+ IDocumentMarkAccess::DDE_BOOKMARK);
+ if(pMark)
+ {
+ sName = pMark->GetName();
+ bDelBookmrk = sal_True;
+ if( !bIsModified )
+ rSh.ResetModified();
+ }
+ else
+ sName = "";
+ rSh.DoUndo( bUndo );
+ }
+
+ if( !sName.isEmpty() &&
+ 0 != ( pDocShell = rSh.GetDoc()->GetDocShell() ) )
+ {
+ // then we create our "server" and connect to it
+ refObj = pDocShell->DdeCreateLinkSource( sName );
+ if( refObj.Is() )
+ {
+ refObj->AddConnectAdvise( this );
+ refObj->AddDataAdvise( this,
+ aEmptyOUStr,
+ ADVISEMODE_NODATA | ADVISEMODE_ONLYONCE );
+ nOldTimeOut = refObj->GetUpdateTimeout();
+ refObj->SetUpdateTimeout( 0 );
+ }
+ }
+}
+
+SwTrnsfrDdeLink::~SwTrnsfrDdeLink()
+{
+ if( refObj.Is() )
+ Disconnect( sal_True );
+}
+
+::sfx2::SvBaseLink::UpdateResult SwTrnsfrDdeLink::DataChanged( const OUString& ,
+ const uno::Any& )
+{
+ // well, that's it with the link
+ if( !bInDisconnect )
+ {
+ if( FindDocShell() && pDocShell->GetView() )
+ rTrnsfr.RemoveDDELinkFormat( pDocShell->GetView()->GetEditWin() );
+ Disconnect( sal_False );
+ }
+ return SUCCESS;
+}
+
+sal_Bool SwTrnsfrDdeLink::WriteData( SvStream& rStrm )
+{
+ if( !refObj.Is() || !FindDocShell() )
+ return sal_False;
+
+ rtl_TextEncoding eEncoding = DDE_TXT_ENCODING;
+ const OString aAppNm(OUStringToOString(
+ GetpApp()->GetAppName(), eEncoding));
+ const OString aTopic(OUStringToOString(
+ pDocShell->GetTitle(SFX_TITLE_FULLNAME), eEncoding));
+ const OString aName(OUStringToOString(sName, eEncoding));
+
+ sal_Char* pMem = new sal_Char[ aAppNm.getLength() + aTopic.getLength() + aName.getLength() + 4 ];
+
+ sal_Int32 nLen = aAppNm.getLength();
+ memcpy( pMem, aAppNm.getStr(), nLen );
+ pMem[ nLen++ ] = 0;
+ memcpy( pMem + nLen, aTopic.getStr(), aTopic.getLength() );
+ nLen = nLen + aTopic.getLength();
+ pMem[ nLen++ ] = 0;
+ memcpy( pMem + nLen, aName.getStr(), aName.getLength() );
+ nLen = nLen + aName.getLength();
+ pMem[ nLen++ ] = 0;
+ pMem[ nLen++ ] = 0;
+
+ rStrm.Write( pMem, nLen );
+ delete[] pMem;
+
+ IDocumentMarkAccess* const pMarkAccess = pDocShell->GetDoc()->getIDocumentMarkAccess();
+ IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->findMark(sName);
+ if(ppMark != pMarkAccess->getAllMarksEnd()
+ && IDocumentMarkAccess::GetType(**ppMark) != IDocumentMarkAccess::BOOKMARK)
+ {
+ // the mark is still a DdeBookmark
+ // we replace it with a Bookmark, so it will get saved etc.
+ ::sw::mark::IMark* const pMark = ppMark->get();
+ SwServerObject* const pServerObject = dynamic_cast<SwServerObject *>(&refObj);
+
+ // collecting state of old mark
+ SwPaM aPaM(pMark->GetMarkStart());
+ *aPaM.GetPoint() = pMark->GetMarkStart();
+ if(pMark->IsExpanded())
+ {
+ aPaM.SetMark();
+ *aPaM.GetMark() = pMark->GetMarkEnd();
+ }
+ OUString sMarkName = pMark->GetName();
+
+ // remove mark
+ pServerObject->SetNoServer(); // this removes the connection between SwServerObject and mark
+ // N.B. ppMark was not loaded from file and cannot have xml:id
+ pMarkAccess->deleteMark(ppMark);
+
+ // recreate as Bookmark
+ ::sw::mark::IMark* const pNewMark = pMarkAccess->makeMark(
+ aPaM,
+ sMarkName,
+ IDocumentMarkAccess::BOOKMARK);
+ pServerObject->SetDdeBookmark(*pNewMark);
+ }
+
+ bDelBookmrk = false;
+ return true;
+}
+
+void SwTrnsfrDdeLink::Disconnect( sal_Bool bRemoveDataAdvise )
+{
+ // don't accept DataChanged anymore, when already in Disconnect!
+ // (DTOR from Bookmark sends a DataChanged!)
+ sal_Bool bOldDisconnect = bInDisconnect;
+ bInDisconnect = sal_True;
+
+ // destroy the unused bookmark again (without Undo!)?
+ if( bDelBookmrk && refObj.Is() && FindDocShell() )
+ {
+ SwDoc* pDoc = pDocShell->GetDoc();
+ ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
+
+ // #i58448#
+ Link aSavedOle2Link( pDoc->GetOle2Link() );
+ pDoc->SetOle2Link( Link() );
+
+ sal_Bool bIsModified = pDoc->IsModified();
+
+ IDocumentMarkAccess* const pMarkAccess = pDoc->getIDocumentMarkAccess();
+ pMarkAccess->deleteMark(pMarkAccess->findMark(sName));
+
+ if( !bIsModified )
+ pDoc->ResetModified();
+ // #i58448#
+ pDoc->SetOle2Link( aSavedOle2Link );
+
+ bDelBookmrk = sal_False;
+ }
+
+ if( refObj.Is() )
+ {
+ refObj->SetUpdateTimeout( nOldTimeOut );
+ refObj->RemoveConnectAdvise( this );
+ if( bRemoveDataAdvise )
+ // in a DataChanged the SelectionObject must NEVER be deleted
+ // is already handled by the base class
+ // (ADVISEMODE_ONLYONCE!!!!)
+ // but always in normal Disconnect!
+ refObj->RemoveAllDataAdvise( this );
+ refObj.Clear();
+ }
+ bInDisconnect = bOldDisconnect;
+}
+
+sal_Bool SwTrnsfrDdeLink::FindDocShell()
+{
+ TypeId aType( TYPE( SwDocShell ) );
+ SfxObjectShell* pTmpSh = SfxObjectShell::GetFirst( &aType );
+ while( pTmpSh )
+ {
+ if( pTmpSh == pDocShell ) // that's what we want to have
+ {
+ if( pDocShell->GetDoc() )
+ return sal_True;
+ break; // the Doc is not there anymore, so leave!
+ }
+ pTmpSh = SfxObjectShell::GetNext( *pTmpSh, &aType );
+ }
+
+ pDocShell = 0;
+ return sal_False;
+}
+
+void SwTrnsfrDdeLink::Closed()
+{
+ if( !bInDisconnect && refObj.Is() )
+ {
+ refObj->RemoveAllDataAdvise( this );
+ refObj->RemoveConnectAdvise( this );
+ refObj.Clear();
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/docvw/AnchorOverlayObject.cxx b/sw/source/core/uibase/docvw/AnchorOverlayObject.cxx
new file mode 100644
index 000000000000..5ea13c2cfe93
--- /dev/null
+++ b/sw/source/core/uibase/docvw/AnchorOverlayObject.cxx
@@ -0,0 +1,449 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <AnchorOverlayObject.hxx>
+#include <SidebarWindowsConsts.hxx>
+
+#include <swrect.hxx>
+#include <view.hxx>
+#include <svx/sdrpaintwindow.hxx>
+#include <svx/svdview.hxx>
+#include <svx/sdr/overlay/overlaymanager.hxx>
+
+#include <sw_primitivetypes2d.hxx>
+#include <drawinglayer/primitive2d/primitivetools2d.hxx>
+#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
+#include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
+#include <drawinglayer/primitive2d/shadowprimitive2d.hxx>
+
+namespace sw { namespace sidebarwindows {
+
+// helper class: Primitive for discrete visualisation
+class AnchorPrimitive : public drawinglayer::primitive2d::DiscreteMetricDependentPrimitive2D
+{
+private:
+ basegfx::B2DPolygon maTriangle;
+ basegfx::B2DPolygon maLine;
+ basegfx::B2DPolygon maLineTop;
+ const AnchorState maAnchorState;
+ basegfx::BColor maColor;
+
+ // discrete line width
+ double mfDiscreteLineWidth;
+
+ // bitfield
+ bool mbShadow : 1;
+ bool mbLineSolid : 1;
+
+protected:
+ virtual drawinglayer::primitive2d::Primitive2DSequence create2DDecomposition(
+ const drawinglayer::geometry::ViewInformation2D& rViewInformation) const;
+
+public:
+ AnchorPrimitive( const basegfx::B2DPolygon& rTriangle,
+ const basegfx::B2DPolygon& rLine,
+ const basegfx::B2DPolygon& rLineTop,
+ AnchorState aAnchorState,
+ const basegfx::BColor& rColor,
+ double fDiscreteLineWidth,
+ bool bShadow,
+ bool bLineSolid )
+ : drawinglayer::primitive2d::DiscreteMetricDependentPrimitive2D(),
+ maTriangle(rTriangle),
+ maLine(rLine),
+ maLineTop(rLineTop),
+ maAnchorState(aAnchorState),
+ maColor(rColor),
+ mfDiscreteLineWidth(fDiscreteLineWidth),
+ mbShadow(bShadow),
+ mbLineSolid(bLineSolid)
+ {}
+
+ // data access
+ const basegfx::B2DPolygon& getTriangle() const { return maTriangle; }
+ const basegfx::B2DPolygon& getLine() const { return maLine; }
+ const basegfx::B2DPolygon& getLineTop() const { return maLineTop; }
+ AnchorState getAnchorState() const { return maAnchorState; }
+ const basegfx::BColor& getColor() const { return maColor; }
+ double getDiscreteLineWidth() const { return mfDiscreteLineWidth; }
+ bool getShadow() const { return mbShadow; }
+ bool getLineSolid() const { return mbLineSolid; }
+
+ virtual bool operator==( const drawinglayer::primitive2d::BasePrimitive2D& rPrimitive ) const;
+
+ DeclPrimitive2DIDBlock()
+};
+
+drawinglayer::primitive2d::Primitive2DSequence AnchorPrimitive::create2DDecomposition(
+ const drawinglayer::geometry::ViewInformation2D& /*rViewInformation*/) const
+{
+ drawinglayer::primitive2d::Primitive2DSequence aRetval;
+
+ if ( AS_TRI == maAnchorState ||
+ AS_ALL == maAnchorState ||
+ AS_START == maAnchorState )
+ {
+ // create triangle
+ const drawinglayer::primitive2d::Primitive2DReference aTriangle(
+ new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(
+ basegfx::B2DPolyPolygon(getTriangle()),
+ getColor()));
+
+ drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, aTriangle);
+ }
+
+ // prepare view-independent LineWidth and color
+ const drawinglayer::attribute::LineAttribute aLineAttribute(
+ getColor(),
+ getDiscreteLineWidth() * getDiscreteUnit());
+
+ if ( AS_ALL == maAnchorState ||
+ AS_START == maAnchorState )
+ {
+ // create line start
+ if(getLineSolid())
+ {
+ const drawinglayer::primitive2d::Primitive2DReference aSolidLine(
+ new drawinglayer::primitive2d::PolygonStrokePrimitive2D(
+ getLine(),
+ aLineAttribute));
+
+ drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, aSolidLine);
+ }
+ else
+ {
+ ::std::vector< double > aDotDashArray;
+ const double fDistance(3.0 * 15.0);
+ const double fDashLen(5.0 * 15.0);
+
+ aDotDashArray.push_back(fDashLen);
+ aDotDashArray.push_back(fDistance);
+
+ const drawinglayer::attribute::StrokeAttribute aStrokeAttribute(
+ aDotDashArray,
+ fDistance + fDashLen);
+
+ const drawinglayer::primitive2d::Primitive2DReference aStrokedLine(
+ new drawinglayer::primitive2d::PolygonStrokePrimitive2D(
+ getLine(),
+ aLineAttribute,
+ aStrokeAttribute));
+
+ drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, aStrokedLine);
+ }
+ }
+
+ if(aRetval.hasElements() && getShadow())
+ {
+ // shadow is only for triangle and line start, and in upper left
+ // and lower right direction, in different colors
+ const double fColorChange(20.0 / 255.0);
+ const basegfx::B3DTuple aColorChange(fColorChange, fColorChange, fColorChange);
+ basegfx::BColor aLighterColor(getColor() + aColorChange);
+ basegfx::BColor aDarkerColor(getColor() - aColorChange);
+
+ aLighterColor.clamp();
+ aDarkerColor.clamp();
+
+ // create shadow sequence
+ drawinglayer::primitive2d::Primitive2DSequence aShadows(2);
+ basegfx::B2DHomMatrix aTransform;
+
+ aTransform.set(0, 2, -getDiscreteUnit());
+ aTransform.set(1, 2, -getDiscreteUnit());
+
+ aShadows[0] = drawinglayer::primitive2d::Primitive2DReference(
+ new drawinglayer::primitive2d::ShadowPrimitive2D(
+ aTransform,
+ aLighterColor,
+ aRetval));
+
+ aTransform.set(0, 2, getDiscreteUnit());
+ aTransform.set(1, 2, getDiscreteUnit());
+
+ aShadows[1] = drawinglayer::primitive2d::Primitive2DReference(
+ new drawinglayer::primitive2d::ShadowPrimitive2D(
+ aTransform,
+ aDarkerColor,
+ aRetval));
+
+ // add shadow before geometry to make it be proccessed first
+ const drawinglayer::primitive2d::Primitive2DSequence aTemporary(aRetval);
+
+ aRetval = aShadows;
+ drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(aRetval, aTemporary);
+ }
+
+ if ( AS_ALL == maAnchorState ||
+ AS_END == maAnchorState )
+ {
+ // LineTop has to be created, too, but uses no shadow, so add after
+ // the other parts are created
+ const drawinglayer::primitive2d::Primitive2DReference aLineTop(
+ new drawinglayer::primitive2d::PolygonStrokePrimitive2D(
+ getLineTop(),
+ aLineAttribute));
+
+ drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, aLineTop);
+ }
+
+ return aRetval;
+}
+
+bool AnchorPrimitive::operator==( const drawinglayer::primitive2d::BasePrimitive2D& rPrimitive ) const
+{
+ if(drawinglayer::primitive2d::DiscreteMetricDependentPrimitive2D::operator==(rPrimitive))
+ {
+ const AnchorPrimitive& rCompare = static_cast< const AnchorPrimitive& >(rPrimitive);
+
+ return (getTriangle() == rCompare.getTriangle()
+ && getLine() == rCompare.getLine()
+ && getLineTop() == rCompare.getLineTop()
+ && getAnchorState() == rCompare.getAnchorState()
+ && getColor() == rCompare.getColor()
+ && getDiscreteLineWidth() == rCompare.getDiscreteLineWidth()
+ && getShadow() == rCompare.getShadow()
+ && getLineSolid() == rCompare.getLineSolid());
+ }
+
+ return false;
+}
+
+ImplPrimitive2DIDBlock(AnchorPrimitive, PRIMITIVE2D_ID_SWSIDEBARANCHORPRIMITIVE)
+
+/*static*/ AnchorOverlayObject* AnchorOverlayObject::CreateAnchorOverlayObject(
+ SwView& rDocView,
+ const SwRect& aAnchorRect,
+ const long& aPageBorder,
+ const Point& aLineStart,
+ const Point& aLineEnd,
+ const Color& aColorAnchor )
+{
+ AnchorOverlayObject* pAnchorOverlayObject( 0 );
+ if ( rDocView.GetDrawView() )
+ {
+ SdrPaintWindow* pPaintWindow = rDocView.GetDrawView()->GetPaintWindow(0);
+ if( pPaintWindow )
+ {
+ rtl::Reference< ::sdr::overlay::OverlayManager > xOverlayManager = pPaintWindow->GetOverlayManager();
+
+ if ( xOverlayManager.is() )
+ {
+ pAnchorOverlayObject = new AnchorOverlayObject(
+ basegfx::B2DPoint( aAnchorRect.Left() , aAnchorRect.Bottom()-5*15),
+ basegfx::B2DPoint( aAnchorRect.Left()-5*15 , aAnchorRect.Bottom()+5*15),
+ basegfx::B2DPoint( aAnchorRect.Left()+5*15 , aAnchorRect.Bottom()+5*15),
+ basegfx::B2DPoint( aAnchorRect.Left(), aAnchorRect.Bottom()+2*15),
+ basegfx::B2DPoint( aPageBorder ,aAnchorRect.Bottom()+2*15),
+ basegfx::B2DPoint( aLineStart.X(),aLineStart.Y()),
+ basegfx::B2DPoint( aLineEnd.X(),aLineEnd.Y()) ,
+ aColorAnchor,
+ false,
+ false);
+ xOverlayManager->add(*pAnchorOverlayObject);
+ }
+ }
+ }
+
+ return pAnchorOverlayObject;
+}
+
+/*static*/ void AnchorOverlayObject::DestroyAnchorOverlayObject( AnchorOverlayObject* pAnchor )
+{
+ if ( pAnchor )
+ {
+ if ( pAnchor->getOverlayManager() )
+ {
+ // remove this object from the chain
+ pAnchor->getOverlayManager()->remove(*pAnchor);
+ }
+ delete pAnchor;
+ }
+}
+
+AnchorOverlayObject::AnchorOverlayObject( const basegfx::B2DPoint& rBasePos,
+ const basegfx::B2DPoint& rSecondPos,
+ const basegfx::B2DPoint& rThirdPos,
+ const basegfx::B2DPoint& rFourthPos,
+ const basegfx::B2DPoint& rFifthPos,
+ const basegfx::B2DPoint& rSixthPos,
+ const basegfx::B2DPoint& rSeventhPos,
+ const Color aBaseColor,
+ const bool bShadowedEffect,
+ const bool bLineSolid)
+ : OverlayObjectWithBasePosition( rBasePos, aBaseColor )
+ , maSecondPosition(rSecondPos)
+ , maThirdPosition(rThirdPos)
+ , maFourthPosition(rFourthPos)
+ , maFifthPosition(rFifthPos)
+ , maSixthPosition(rSixthPos)
+ , maSeventhPosition(rSeventhPos)
+ , maTriangle()
+ , maLine()
+ , maLineTop()
+ , mHeight(0)
+ , mAnchorState(AS_ALL)
+ , mbShadowedEffect(bShadowedEffect)
+ , mbLineSolid(bLineSolid)
+{
+}
+
+AnchorOverlayObject::~AnchorOverlayObject()
+{
+}
+
+void AnchorOverlayObject::implEnsureGeometry()
+{
+ if(!maTriangle.count())
+ {
+ maTriangle.append(getBasePosition());
+ maTriangle.append(GetSecondPosition());
+ maTriangle.append(GetThirdPosition());
+ maTriangle.setClosed(true);
+ }
+
+ if(!maLine.count())
+ {
+ maLine.append(GetFourthPosition());
+ maLine.append(GetFifthPosition());
+ maLine.append(GetSixthPosition());
+ }
+
+ if(!maLineTop.count())
+ {
+ maLineTop.append(GetSixthPosition());
+ maLineTop.append(GetSeventhPosition());
+ }
+}
+
+void AnchorOverlayObject::implResetGeometry()
+{
+ maTriangle.clear();
+ maLine.clear();
+ maLineTop.clear();
+}
+
+drawinglayer::primitive2d::Primitive2DSequence AnchorOverlayObject::createOverlayObjectPrimitive2DSequence()
+{
+ implEnsureGeometry();
+
+ static double aDiscreteLineWidth(1.6);
+ const drawinglayer::primitive2d::Primitive2DReference aReference(
+ new AnchorPrimitive( maTriangle,
+ maLine,
+ maLineTop,
+ GetAnchorState(),
+ getBaseColor().getBColor(),
+ ANCHORLINE_WIDTH * aDiscreteLineWidth,
+ getShadowedEffect(),
+ getLineSolid()) );
+
+ return drawinglayer::primitive2d::Primitive2DSequence(&aReference, 1);
+}
+
+void AnchorOverlayObject::SetAllPosition( const basegfx::B2DPoint& rPoint1,
+ const basegfx::B2DPoint& rPoint2,
+ const basegfx::B2DPoint& rPoint3,
+ const basegfx::B2DPoint& rPoint4,
+ const basegfx::B2DPoint& rPoint5,
+ const basegfx::B2DPoint& rPoint6,
+ const basegfx::B2DPoint& rPoint7)
+{
+ if ( rPoint1 != getBasePosition() ||
+ rPoint2 != GetSecondPosition() ||
+ rPoint3 != GetThirdPosition() ||
+ rPoint4 != GetFourthPosition() ||
+ rPoint5 != GetFifthPosition() ||
+ rPoint6 != GetSixthPosition() ||
+ rPoint7 != GetSeventhPosition() )
+ {
+ maBasePosition = rPoint1;
+ maSecondPosition = rPoint2;
+ maThirdPosition = rPoint3;
+ maFourthPosition = rPoint4;
+ maFifthPosition = rPoint5;
+ maSixthPosition = rPoint6;
+ maSeventhPosition = rPoint7;
+
+ implResetGeometry();
+ objectChange();
+ }
+}
+
+void AnchorOverlayObject::SetSixthPosition(const basegfx::B2DPoint& rNew)
+{
+ if(rNew != maSixthPosition)
+ {
+ maSixthPosition = rNew;
+ implResetGeometry();
+ objectChange();
+ }
+}
+
+void AnchorOverlayObject::SetSeventhPosition(const basegfx::B2DPoint& rNew)
+{
+ if(rNew != maSeventhPosition)
+ {
+ maSeventhPosition = rNew;
+ implResetGeometry();
+ objectChange();
+ }
+}
+
+void AnchorOverlayObject::SetTriPosition(const basegfx::B2DPoint& rPoint1,const basegfx::B2DPoint& rPoint2,const basegfx::B2DPoint& rPoint3,
+ const basegfx::B2DPoint& rPoint4,const basegfx::B2DPoint& rPoint5)
+{
+ if(rPoint1 != getBasePosition()
+ || rPoint2 != GetSecondPosition()
+ || rPoint3 != GetThirdPosition()
+ || rPoint4 != GetFourthPosition()
+ || rPoint5 != GetFifthPosition())
+ {
+ maBasePosition = rPoint1;
+ maSecondPosition = rPoint2;
+ maThirdPosition = rPoint3;
+ maFourthPosition = rPoint4;
+ maFifthPosition = rPoint5;
+
+ implResetGeometry();
+ objectChange();
+ }
+}
+
+void AnchorOverlayObject::setLineSolid( const bool bNew )
+{
+ if ( bNew != getLineSolid() )
+ {
+ mbLineSolid = bNew;
+ objectChange();
+ }
+}
+
+void AnchorOverlayObject::SetAnchorState( const AnchorState aState)
+{
+ if ( mAnchorState != aState)
+ {
+ mAnchorState = aState;
+ objectChange();
+ }
+}
+
+} } // end of namespace sw::annotation
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/docvw/AnchorOverlayObject.hxx b/sw/source/core/uibase/docvw/AnchorOverlayObject.hxx
new file mode 100644
index 000000000000..7c86e1abe013
--- /dev/null
+++ b/sw/source/core/uibase/docvw/AnchorOverlayObject.hxx
@@ -0,0 +1,133 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SW_SOURCE_UI_DOCVW_ANCHOROVERLAYOBJECT_HXX
+#define INCLUDED_SW_SOURCE_UI_DOCVW_ANCHOROVERLAYOBJECT_HXX
+
+#include <svx/sdr/overlay/overlayobject.hxx>
+
+#include <basegfx/polygon/b2dpolygon.hxx>
+
+class SwView;
+class SwRect;
+class Point;
+
+namespace sw { namespace sidebarwindows {
+
+enum AnchorState
+{
+ AS_ALL,
+ AS_START,
+ AS_END,
+ AS_TRI
+};
+
+class AnchorOverlayObject: public sdr::overlay::OverlayObjectWithBasePosition
+{
+ public:
+ static AnchorOverlayObject* CreateAnchorOverlayObject( SwView& rDocView,
+ const SwRect& aAnchorRect,
+ const long& aPageBorder,
+ const Point& aLineStart,
+ const Point& aLineEnd,
+ const Color& aColorAnchor );
+ static void DestroyAnchorOverlayObject( AnchorOverlayObject* pAnchor );
+
+ inline const basegfx::B2DPoint& GetSecondPosition() const { return maSecondPosition; }
+ const basegfx::B2DPoint& GetThirdPosition() const { return maThirdPosition; }
+ const basegfx::B2DPoint& GetFourthPosition() const { return maFourthPosition; }
+ const basegfx::B2DPoint& GetFifthPosition() const { return maFifthPosition; }
+ const basegfx::B2DPoint& GetSixthPosition() const { return maSixthPosition; }
+ const basegfx::B2DPoint& GetSeventhPosition() const { return maSeventhPosition; }
+
+ void SetAllPosition( const basegfx::B2DPoint& rPoint1,
+ const basegfx::B2DPoint& rPoint2,
+ const basegfx::B2DPoint& rPoint3,
+ const basegfx::B2DPoint& rPoint4,
+ const basegfx::B2DPoint& rPoint5,
+ const basegfx::B2DPoint& rPoint6,
+ const basegfx::B2DPoint& rPoint7 );
+ void SetTriPosition( const basegfx::B2DPoint& rPoint1,
+ const basegfx::B2DPoint& rPoint2,
+ const basegfx::B2DPoint& rPoint3,
+ const basegfx::B2DPoint& rPoint4,
+ const basegfx::B2DPoint& rPoint5 );
+ void SetSixthPosition( const basegfx::B2DPoint& rNew );
+ void SetSeventhPosition( const basegfx::B2DPoint& rNew );
+
+ void setLineSolid( const bool bNew );
+ inline bool getLineSolid() const { return mbLineSolid; }
+
+ inline void SetHeight( const unsigned long aHeight ) { mHeight = aHeight; };
+
+ bool getShadowedEffect() const { return mbShadowedEffect; }
+
+ void SetAnchorState( const AnchorState aState );
+ inline AnchorState GetAnchorState() const { return mAnchorState; }
+
+ protected:
+ /* 6------------7
+ 1 /
+ /4\ ---------------5
+ 2 - 3
+ */
+
+ basegfx::B2DPoint maSecondPosition;
+ basegfx::B2DPoint maThirdPosition;
+ basegfx::B2DPoint maFourthPosition;
+ basegfx::B2DPoint maFifthPosition;
+ basegfx::B2DPoint maSixthPosition;
+ basegfx::B2DPoint maSeventhPosition;
+
+ // helpers to fill and reset geometry
+ void implEnsureGeometry();
+ void implResetGeometry();
+
+ // geometry creation for OverlayObject
+ virtual drawinglayer::primitive2d::Primitive2DSequence createOverlayObjectPrimitive2DSequence();
+
+ private:
+ // object's geometry
+ basegfx::B2DPolygon maTriangle;
+ basegfx::B2DPolygon maLine;
+ basegfx::B2DPolygon maLineTop;
+ unsigned long mHeight;
+ AnchorState mAnchorState;
+
+ bool mbShadowedEffect : 1;
+ bool mbLineSolid : 1;
+
+ AnchorOverlayObject( const basegfx::B2DPoint& rBasePos,
+ const basegfx::B2DPoint& rSecondPos,
+ const basegfx::B2DPoint& rThirdPos,
+ const basegfx::B2DPoint& rFourthPos,
+ const basegfx::B2DPoint& rFifthPos,
+ const basegfx::B2DPoint& rSixthPos,
+ const basegfx::B2DPoint& rSeventhPos,
+ const Color aBaseColor,
+ const bool bShadowedEffect,
+ const bool bLineSolid );
+ virtual ~AnchorOverlayObject();
+};
+
+} } // end of namespace sw::annotation
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/docvw/AnnotationMenuButton.cxx b/sw/source/core/uibase/docvw/AnnotationMenuButton.cxx
new file mode 100644
index 000000000000..f54378d6d17a
--- /dev/null
+++ b/sw/source/core/uibase/docvw/AnnotationMenuButton.cxx
@@ -0,0 +1,203 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <AnnotationMenuButton.hxx>
+
+#include <annotation.hrc>
+#include <app.hrc>
+#include <access.hrc>
+
+#include <unotools/useroptions.hxx>
+
+#include <vcl/svapp.hxx>
+#include <vcl/menu.hxx>
+#include <vcl/decoview.hxx>
+#include <vcl/gradient.hxx>
+#include <vcl/settings.hxx>
+
+#include <cmdid.h>
+#include <SidebarWin.hxx>
+
+namespace sw { namespace annotation {
+
+Color ColorFromAlphaColor( const sal_uInt8 aTransparency,
+ const Color &aFront,
+ const Color &aBack )
+{
+ return Color((sal_uInt8)(aFront.GetRed() * aTransparency/(double)255 + aBack.GetRed() * (1-aTransparency/(double)255)),
+ (sal_uInt8)(aFront.GetGreen() * aTransparency/(double)255 + aBack.GetGreen() * (1-aTransparency/(double)255)),
+ (sal_uInt8)(aFront.GetBlue() * aTransparency/(double)255 + aBack.GetBlue() * (1-aTransparency/(double)255)));
+}
+
+AnnotationMenuButton::AnnotationMenuButton( sw::sidebarwindows::SwSidebarWin& rSidebarWin )
+ : MenuButton( &rSidebarWin )
+ , mrSidebarWin( rSidebarWin )
+{
+ AddEventListener( LINK( &mrSidebarWin, sw::sidebarwindows::SwSidebarWin, WindowEventListener ) );
+
+ SetAccessibleName( SW_RES( STR_ACCESS_ANNOTATION_BUTTON_NAME ) );
+ SetAccessibleDescription( SW_RES( STR_ACCESS_ANNOTATION_BUTTON_DESC ) );
+ SetQuickHelpText( GetAccessibleDescription() );
+}
+
+AnnotationMenuButton::~AnnotationMenuButton()
+{
+ RemoveEventListener( LINK( &mrSidebarWin, sw::sidebarwindows::SwSidebarWin, WindowEventListener ) );
+}
+
+void AnnotationMenuButton::Select()
+{
+ mrSidebarWin.ExecuteCommand( GetCurItemId() );
+}
+
+void AnnotationMenuButton::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ PopupMenu* pButtonPopup( GetPopupMenu() );
+ if ( mrSidebarWin.IsReadOnly() )
+ {
+ pButtonPopup->EnableItem( FN_REPLY, false );
+ pButtonPopup->EnableItem( FN_DELETE_COMMENT, false );
+ pButtonPopup->EnableItem( FN_DELETE_NOTE_AUTHOR, false );
+ pButtonPopup->EnableItem( FN_DELETE_ALL_NOTES, false );
+ }
+ else
+ {
+ pButtonPopup->EnableItem( FN_DELETE_COMMENT, !mrSidebarWin.IsProtected() );
+ pButtonPopup->EnableItem( FN_DELETE_NOTE_AUTHOR, true );
+ pButtonPopup->EnableItem( FN_DELETE_ALL_NOTES, true );
+ }
+
+ if ( mrSidebarWin.IsProtected() )
+ {
+ pButtonPopup->EnableItem( FN_REPLY, false );
+ }
+ else
+ {
+ SvtUserOptions aUserOpt;
+ OUString sAuthor;
+ if ( (sAuthor = aUserOpt.GetFullName()).isEmpty() )
+ {
+ if ( (sAuthor = aUserOpt.GetID()).isEmpty() )
+ {
+ sAuthor = SW_RES( STR_REDLINE_UNKNOWN_AUTHOR );
+ }
+ }
+ // do not allow to reply to ourself and no answer possible if this note is in a protected section
+ if ( sAuthor == mrSidebarWin.GetAuthor() )
+ {
+ pButtonPopup->EnableItem( FN_REPLY, false );
+ }
+ else
+ {
+ pButtonPopup->EnableItem( FN_REPLY, true );
+ }
+ }
+
+ MenuButton::MouseButtonDown( rMEvt );
+}
+
+void AnnotationMenuButton::Paint( const Rectangle& /*rRect*/ )
+{
+ if ( Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
+ SetFillColor(COL_BLACK);
+ else
+ SetFillColor( mrSidebarWin.ColorDark() );
+ SetLineColor();
+ const Rectangle aRect( Rectangle( Point( 0, 0 ), PixelToLogic( GetSizePixel() ) ) );
+ DrawRect( aRect );
+
+ if ( Application::GetSettings().GetStyleSettings().GetHighContrastMode())
+ {
+ //draw rect around button
+ SetFillColor(COL_BLACK);
+ SetLineColor(COL_WHITE);
+ }
+ else
+ {
+ //draw button
+ Gradient aGradient;
+ if ( IsMouseOver() )
+ aGradient = Gradient( GradientStyle_LINEAR,
+ ColorFromAlphaColor( 80, mrSidebarWin.ColorAnchor(), mrSidebarWin.ColorDark() ),
+ ColorFromAlphaColor( 15, mrSidebarWin.ColorAnchor(), mrSidebarWin.ColorDark() ));
+ else
+ aGradient = Gradient( GradientStyle_LINEAR,
+ ColorFromAlphaColor( 15, mrSidebarWin.ColorAnchor(), mrSidebarWin.ColorDark() ),
+ ColorFromAlphaColor( 80, mrSidebarWin.ColorAnchor(), mrSidebarWin.ColorDark() ));
+ DrawGradient( aRect, aGradient );
+
+ //draw rect around button
+ SetFillColor();
+ SetLineColor( ColorFromAlphaColor( 90, mrSidebarWin.ColorAnchor(), mrSidebarWin.ColorDark() ));
+ }
+ DrawRect( aRect );
+
+ if ( mrSidebarWin.IsPreview() )
+ {
+ Font aOldFont( mrSidebarWin.GetFont() );
+ Font aFont(aOldFont);
+ Color aCol( COL_BLACK);
+ aFont.SetColor( aCol );
+ aFont.SetHeight(200);
+ aFont.SetWeight(WEIGHT_MEDIUM);
+ SetFont( aFont );
+ DrawText( aRect ,
+ OUString("Edit Note"),
+ TEXT_DRAW_CENTER );
+ SetFont( aOldFont );
+ }
+ else
+ {
+ Rectangle aSymbolRect( aRect );
+ // 25% distance to the left and right button border
+ const long nBorderDistanceLeftAndRight = ((aSymbolRect.GetWidth()*250)+500)/1000;
+ aSymbolRect.Left()+=nBorderDistanceLeftAndRight;
+ aSymbolRect.Right()-=nBorderDistanceLeftAndRight;
+ // 40% distance to the top button border
+ const long nBorderDistanceTop = ((aSymbolRect.GetHeight()*400)+500)/1000;
+ aSymbolRect.Top()+=nBorderDistanceTop;
+ // 15% distance to the bottom button border
+ const long nBorderDistanceBottom = ((aSymbolRect.GetHeight()*150)+500)/1000;
+ aSymbolRect.Bottom()-=nBorderDistanceBottom;
+ DecorationView aDecoView( this );
+ aDecoView.DrawSymbol( aSymbolRect, SYMBOL_SPIN_DOWN,
+ ( Application::GetSettings().GetStyleSettings().GetHighContrastMode()
+ ? Color( COL_WHITE )
+ : Color( COL_BLACK ) ) );
+ }
+}
+
+void AnnotationMenuButton::KeyInput( const KeyEvent& rKeyEvt )
+{
+ const KeyCode& rKeyCode = rKeyEvt.GetKeyCode();
+ const sal_uInt16 nKey = rKeyCode.GetCode();
+ if ( nKey == KEY_TAB )
+ {
+ mrSidebarWin.ActivatePostIt();
+ mrSidebarWin.GrabFocus();
+ }
+ else
+ {
+ MenuButton::KeyInput( rKeyEvt );
+ }
+}
+
+} } // end of namespace sw::annotation
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/docvw/AnnotationMenuButton.hxx b/sw/source/core/uibase/docvw/AnnotationMenuButton.hxx
new file mode 100644
index 000000000000..c1334e8e077b
--- /dev/null
+++ b/sw/source/core/uibase/docvw/AnnotationMenuButton.hxx
@@ -0,0 +1,53 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SW_SOURCE_UI_DOCVW_ANNOTATIONMENUBUTTON_HXX
+#define INCLUDED_SW_SOURCE_UI_DOCVW_ANNOTATIONMENUBUTTON_HXX
+
+#include <vcl/menubtn.hxx>
+
+namespace sw { namespace sidebarwindows {
+ class SwSidebarWin;
+} }
+
+namespace sw { namespace annotation {
+
+class AnnotationMenuButton : public MenuButton
+{
+ public:
+ AnnotationMenuButton( sw::sidebarwindows::SwSidebarWin& rSidebarWin );
+ ~AnnotationMenuButton();
+
+ // overloaded <MenuButton> methods
+ virtual void Select();
+
+ // overloaded <Window> methods
+ virtual void MouseButtonDown( const MouseEvent& rMEvt );
+ virtual void Paint( const Rectangle& rRect );
+ virtual void KeyInput( const KeyEvent& rKeyEvt );
+
+ private:
+ sw::sidebarwindows::SwSidebarWin& mrSidebarWin;
+};
+
+} } // end of namespace sw::annotation
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/docvw/AnnotationWin.cxx b/sw/source/core/uibase/docvw/AnnotationWin.cxx
new file mode 100644
index 000000000000..4d8215efd400
--- /dev/null
+++ b/sw/source/core/uibase/docvw/AnnotationWin.cxx
@@ -0,0 +1,318 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <AnnotationWin.hxx>
+
+#include <AnnotationMenuButton.hxx>
+#include <PostItMgr.hxx>
+
+#include <annotation.hrc>
+#include <popup.hrc>
+#include <cmdid.h>
+
+#include <vcl/menu.hxx>
+
+#include <svl/undo.hxx>
+#include <unotools/syslocale.hxx>
+#include <svl/languageoptions.hxx>
+
+#include <editeng/postitem.hxx>
+#include <editeng/fhgtitem.hxx>
+#include <editeng/langitem.hxx>
+
+#include <editeng/editview.hxx>
+#include <editeng/outliner.hxx>
+#include <editeng/editeng.hxx>
+#include <editeng/editobj.hxx>
+
+#include <docufld.hxx>
+#include <txtfld.hxx>
+#include <ndtxt.hxx>
+#include <view.hxx>
+#include <wrtsh.hxx>
+#include <docsh.hxx>
+#include <doc.hxx>
+#include <IDocumentUndoRedo.hxx>
+#include <SwUndoField.hxx>
+
+#include <boost/scoped_ptr.hpp>
+
+namespace sw { namespace annotation {
+
+SwAnnotationWin::SwAnnotationWin( SwEditWin& rEditWin,
+ WinBits nBits,
+ SwPostItMgr& aMgr,
+ SwPostItBits aBits,
+ SwSidebarItem& rSidebarItem,
+ SwFmtFld* aField )
+ : SwSidebarWin( rEditWin, nBits, aMgr, aBits, rSidebarItem )
+ , mpFmtFld(aField)
+ , mpFld( static_cast<SwPostItField*>(aField->GetField()))
+ , mpButtonPopup(0)
+{
+}
+
+SwAnnotationWin::~SwAnnotationWin()
+{
+ delete mpButtonPopup;
+}
+
+void SwAnnotationWin::SetPostItText()
+{
+ //If the cursor was visible, then make it visible again after
+ //changing text, e.g. fdo#33599
+ Cursor *pCursor = GetOutlinerView()->GetEditView().GetCursor();
+ bool bCursorVisible = pCursor ? pCursor->IsVisible() : false;
+
+ //If the new text is the same as the old text, keep the same insertion
+ //point .e.g. fdo#33599
+ mpFld = static_cast<SwPostItField*>(mpFmtFld->GetField());
+ OUString sNewText = mpFld->GetPar2();
+ bool bTextUnchanged = sNewText.equals(Engine()->GetEditEngine().GetText());
+ ESelection aOrigSelection(GetOutlinerView()->GetEditView().GetSelection());
+
+ // get text from SwPostItField and insert into our textview
+ Engine()->SetModifyHdl( Link() );
+ Engine()->EnableUndo( false );
+ if( mpFld->GetTextObject() )
+ Engine()->SetText( *mpFld->GetTextObject() );
+ else
+ {
+ Engine()->Clear();
+ GetOutlinerView()->SetAttribs(DefaultItem());
+ GetOutlinerView()->InsertText(sNewText,false);
+ }
+
+ Engine()->ClearModifyFlag();
+ Engine()->GetUndoManager().Clear();
+ Engine()->EnableUndo( true );
+ Engine()->SetModifyHdl( LINK( this, SwAnnotationWin, ModifyHdl ) );
+ if (bTextUnchanged)
+ GetOutlinerView()->GetEditView().SetSelection(aOrigSelection);
+ if (bCursorVisible)
+ GetOutlinerView()->ShowCursor();
+ Invalidate();
+}
+
+void SwAnnotationWin::UpdateData()
+{
+ if ( Engine()->IsModified() )
+ {
+ IDocumentUndoRedo & rUndoRedo(
+ DocView().GetDocShell()->GetDoc()->GetIDocumentUndoRedo());
+ boost::scoped_ptr<SwField> pOldField;
+ if (rUndoRedo.DoesUndo())
+ {
+ pOldField.reset(mpFld->Copy());
+ }
+ mpFld->SetPar2(Engine()->GetEditEngine().GetText());
+ mpFld->SetTextObject(Engine()->CreateParaObject());
+ if (rUndoRedo.DoesUndo())
+ {
+ SwTxtFld *const pTxtFld = mpFmtFld->GetTxtFld();
+ SwPosition aPosition( pTxtFld->GetTxtNode() );
+ aPosition.nContent = *pTxtFld->GetStart();
+ rUndoRedo.AppendUndo(
+ new SwUndoFieldFromDoc(aPosition, *pOldField, *mpFld, 0, true));
+ }
+ // so we get a new layout of notes (anchor position is still the same and we would otherwise not get one)
+ Mgr().SetLayout();
+ // #i98686# if we have several views, all notes should update their text
+ mpFmtFld->Broadcast(SwFmtFldHint( 0, SWFMTFLD_CHANGED));
+ DocView().GetDocShell()->SetModified();
+ }
+ Engine()->ClearModifyFlag();
+ Engine()->GetUndoManager().Clear();
+}
+
+void SwAnnotationWin::Delete()
+{
+ SwSidebarWin::Delete();
+ // we delete the field directly, the Mgr cleans up the PostIt by listening
+ DocView().GetWrtShellPtr()->GotoField(*mpFmtFld);
+ GrabFocusToDocument();
+ DocView().GetWrtShellPtr()->DelRight();
+}
+
+void SwAnnotationWin::GotoPos()
+{
+ DocView().GetDocShell()->GetWrtShell()->GotoField(*mpFmtFld);
+}
+
+sal_uInt32 SwAnnotationWin::MoveCaret()
+{
+ // if this is an answer, do not skip over all following ones, but insert directly behind the current one
+ // but when just leaving a note, skip all following ones as well to continue typing
+ return Mgr().IsAnswer()
+ ? 1
+ : 1 + CountFollowing();
+}
+
+//returns true, if there is another note right before this note
+bool SwAnnotationWin::CalcFollow()
+{
+ SwTxtFld* pTxtFld = mpFmtFld->GetTxtFld();
+ SwPosition aPosition( pTxtFld->GetTxtNode() );
+ aPosition.nContent = *pTxtFld->GetStart();
+ SwTxtAttr * const pTxtAttr =
+ pTxtFld->GetTxtNode().GetTxtAttrForCharAt(
+ aPosition.nContent.GetIndex() - 1,
+ RES_TXTATR_ANNOTATION );
+ const SwField* pFld = pTxtAttr ? pTxtAttr->GetFmtFld().GetField() : 0;
+ return pFld && (pFld->Which()== RES_POSTITFLD);
+}
+
+// counts how many SwPostItField we have right after the current one
+sal_uInt32 SwAnnotationWin::CountFollowing()
+{
+ sal_uInt32 aCount = 1; // we start with 1, so we have to subtract one at the end again
+ SwTxtFld* pTxtFld = mpFmtFld->GetTxtFld();
+ SwPosition aPosition( pTxtFld->GetTxtNode() );
+ aPosition.nContent = *pTxtFld->GetStart();
+
+ SwTxtAttr * pTxtAttr = pTxtFld->GetTxtNode().GetTxtAttrForCharAt(
+ aPosition.nContent.GetIndex() + 1,
+ RES_TXTATR_ANNOTATION );
+ SwField* pFld = pTxtAttr
+ ? const_cast<SwField*>(pTxtAttr->GetFmtFld().GetField())
+ : 0;
+ while ( pFld && ( pFld->Which()== RES_POSTITFLD ) )
+ {
+ aCount++;
+ pTxtAttr = pTxtFld->GetTxtNode().GetTxtAttrForCharAt(
+ aPosition.nContent.GetIndex() + aCount,
+ RES_TXTATR_ANNOTATION );
+ pFld = pTxtAttr
+ ? const_cast<SwField*>(pTxtAttr->GetFmtFld().GetField())
+ : 0;
+ }
+ return aCount - 1;
+}
+
+MenuButton* SwAnnotationWin::CreateMenuButton()
+{
+ mpButtonPopup = new PopupMenu(SW_RES(MN_ANNOTATION_BUTTON));
+ OUString aText = mpButtonPopup->GetItemText( FN_DELETE_NOTE_AUTHOR );
+ SwRewriter aRewriter;
+ aRewriter.AddRule(UndoArg1,GetAuthor());
+ aText = aRewriter.Apply(aText);
+ mpButtonPopup->SetItemText(FN_DELETE_NOTE_AUTHOR,aText);
+ MenuButton* pMenuButton = new AnnotationMenuButton( *this );
+ pMenuButton->SetPopupMenu( mpButtonPopup );
+ pMenuButton->Show();
+ return pMenuButton;
+}
+
+void SwAnnotationWin::InitAnswer(OutlinerParaObject* pText)
+{
+ //collect our old meta data
+ SwSidebarWin* pWin = Mgr().GetNextPostIt(KEY_PAGEUP, this);
+ const SvtSysLocale aSysLocale;
+ const LocaleDataWrapper& rLocalData = aSysLocale.GetLocaleData();
+ SwRewriter aRewriter;
+ aRewriter.AddRule(UndoArg1, pWin->GetAuthor());
+ const OUString aText = aRewriter.Apply(SW_RESSTR(STR_REPLY))
+ + " (" + rLocalData.getDate( pWin->GetDate())
+ + ", " + rLocalData.getTime( pWin->GetTime(), false)
+ + "): \"";
+ GetOutlinerView()->InsertText(aText,false);
+
+ // insert old, selected text or "..."
+ // TODO: iterate over all paragraphs, not only first one to find out if it is empty
+ if (!pText->GetTextObject().GetText(0).isEmpty())
+ GetOutlinerView()->GetEditView().InsertText(pText->GetTextObject());
+ else
+ GetOutlinerView()->InsertText(OUString("..."),false);
+ GetOutlinerView()->InsertText(OUString("\"\n"),false);
+
+ GetOutlinerView()->SetSelection(ESelection(0,0,EE_PARA_ALL,EE_TEXTPOS_ALL));
+ SfxItemSet aAnswerSet( DocView().GetDocShell()->GetPool() );
+ aAnswerSet.Put(SvxFontHeightItem(200,80,EE_CHAR_FONTHEIGHT));
+ aAnswerSet.Put(SvxPostureItem(ITALIC_NORMAL,EE_CHAR_ITALIC));
+ GetOutlinerView()->SetAttribs(aAnswerSet);
+ GetOutlinerView()->SetSelection(ESelection(EE_PARA_MAX_COUNT,EE_TEXTPOS_MAX_COUNT,EE_PARA_MAX_COUNT,EE_TEXTPOS_MAX_COUNT));
+
+ //remove all attributes and reset our standard ones
+ GetOutlinerView()->GetEditView().RemoveAttribsKeepLanguages(true);
+ GetOutlinerView()->SetAttribs(DefaultItem());
+ // lets insert an undo step so the initial text can be easily deleted
+ // but do not use UpdateData() directly, would set modified state again and reentrance into Mgr
+ Engine()->SetModifyHdl( Link() );
+ IDocumentUndoRedo & rUndoRedo(
+ DocView().GetDocShell()->GetDoc()->GetIDocumentUndoRedo());
+ boost::scoped_ptr<SwField> pOldField;
+ if (rUndoRedo.DoesUndo())
+ {
+ pOldField.reset(mpFld->Copy());
+ }
+ mpFld->SetPar2(Engine()->GetEditEngine().GetText());
+ mpFld->SetTextObject(Engine()->CreateParaObject());
+ if (rUndoRedo.DoesUndo())
+ {
+ SwTxtFld *const pTxtFld = mpFmtFld->GetTxtFld();
+ SwPosition aPosition( pTxtFld->GetTxtNode() );
+ aPosition.nContent = *pTxtFld->GetStart();
+ rUndoRedo.AppendUndo(
+ new SwUndoFieldFromDoc(aPosition, *pOldField, *mpFld, 0, true));
+ }
+ Engine()->SetModifyHdl( LINK( this, SwAnnotationWin, ModifyHdl ) );
+ Engine()->ClearModifyFlag();
+ Engine()->GetUndoManager().Clear();
+}
+
+SvxLanguageItem SwAnnotationWin::GetLanguage(void)
+{
+ // set initial language for outliner
+ sal_uInt16 nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( mpFld->GetLanguage() );
+ sal_uInt16 nLangWhichId = 0;
+ switch (nScriptType)
+ {
+ case SCRIPTTYPE_LATIN : nLangWhichId = EE_CHAR_LANGUAGE ; break;
+ case SCRIPTTYPE_ASIAN : nLangWhichId = EE_CHAR_LANGUAGE_CJK; break;
+ case SCRIPTTYPE_COMPLEX : nLangWhichId = EE_CHAR_LANGUAGE_CTL; break;
+ default: OSL_FAIL("GetLanguage: wrong script type");
+ }
+ return SvxLanguageItem(mpFld->GetLanguage(),nLangWhichId);
+}
+
+bool SwAnnotationWin::IsProtected()
+{
+ return SwSidebarWin::IsProtected() ||
+ GetLayoutStatus() == SwPostItHelper::DELETED ||
+ ( mpFmtFld ? mpFmtFld->IsProtect() : false );
+}
+
+OUString SwAnnotationWin::GetAuthor()
+{
+ return mpFld->GetPar1();
+}
+
+Date SwAnnotationWin::GetDate()
+{
+ return mpFld->GetDate();
+}
+
+Time SwAnnotationWin::GetTime()
+{
+ return mpFld->GetTime();
+}
+
+} } // end of namespace sw::annotation
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/docvw/DashedLine.cxx b/sw/source/core/uibase/docvw/DashedLine.cxx
new file mode 100644
index 000000000000..e9e343b3dc27
--- /dev/null
+++ b/sw/source/core/uibase/docvw/DashedLine.cxx
@@ -0,0 +1,97 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <DashedLine.hxx>
+
+#include <basegfx/color/bcolortools.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
+#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
+#include <drawinglayer/processor2d/baseprocessor2d.hxx>
+#include <drawinglayer/processor2d/processorfromoutputdevice.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/settings.hxx>
+
+SwDashedLine::SwDashedLine( Window* pParent, Color& ( *pColorFn )() ) :
+ FixedLine( pParent, WB_DIALOGCONTROL | WB_HORZ ),
+ m_pColorFn( pColorFn )
+{
+}
+
+SwDashedLine::~SwDashedLine( )
+{
+}
+
+void SwDashedLine::Paint( const Rectangle& )
+{
+ const drawinglayer::geometry::ViewInformation2D aNewViewInfos;
+ drawinglayer::processor2d::BaseProcessor2D * pProcessor =
+ drawinglayer::processor2d::createBaseProcessor2DFromOutputDevice(
+ *this, aNewViewInfos );
+
+ // Compute the start and end points
+ const Rectangle aRect( Rectangle( Point( 0, 0 ), PixelToLogic( GetSizePixel() ) ) );
+ double nHalfWidth = double( aRect.Top() + aRect.Bottom() ) / 2.0;
+
+ basegfx::B2DPoint aStart( double( aRect.Left() ), nHalfWidth );
+ basegfx::B2DPoint aEnd( double( aRect.Right() ), nHalfWidth );
+
+ basegfx::B2DPolygon aPolygon;
+ aPolygon.append( aStart );
+ aPolygon.append( aEnd );
+
+ drawinglayer::primitive2d::Primitive2DSequence aSeq( 1 );
+
+ const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
+
+ std::vector< double > aStrokePattern;
+ basegfx::BColor aColor = m_pColorFn().getBColor();
+ if ( rSettings.GetHighContrastMode( ) )
+ {
+ // Only a solid line in high contrast mode
+ aColor = rSettings.GetDialogTextColor().getBColor();
+ }
+ else
+ {
+ // Get a color for the contrast
+ basegfx::BColor aHslLine = basegfx::tools::rgb2hsl( aColor );
+ double nLuminance = aHslLine.getZ();
+ nLuminance += ( 1.0 - nLuminance ) * 0.75;
+ if ( aHslLine.getZ() > 0.7 )
+ nLuminance = aHslLine.getZ() * 0.7;
+ aHslLine.setZ( nLuminance );
+ const basegfx::BColor aOtherColor = basegfx::tools::hsl2rgb( aHslLine );
+
+ // Compute the plain line
+ drawinglayer::primitive2d::PolygonHairlinePrimitive2D * pPlainLine =
+ new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(
+ aPolygon, aOtherColor );
+
+ aSeq[0] = drawinglayer::primitive2d::Primitive2DReference( pPlainLine );
+ // Dashed line in twips
+ aStrokePattern.push_back( 3 );
+ aStrokePattern.push_back( 3 );
+
+ aSeq.realloc( 2 );
+ }
+
+ // Compute the dashed line primitive
+ drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D * pLine =
+ new drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D (
+ basegfx::B2DPolyPolygon( aPolygon ),
+ drawinglayer::attribute::LineAttribute( m_pColorFn().getBColor() ),
+ drawinglayer::attribute::StrokeAttribute( aStrokePattern ) );
+
+ aSeq[ aSeq.getLength() - 1 ] = drawinglayer::primitive2d::Primitive2DReference( pLine );
+
+ pProcessor->process( aSeq );
+ delete pProcessor;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/docvw/FrameControlsManager.cxx b/sw/source/core/uibase/docvw/FrameControlsManager.cxx
new file mode 100644
index 000000000000..67d8006f4aa5
--- /dev/null
+++ b/sw/source/core/uibase/docvw/FrameControlsManager.cxx
@@ -0,0 +1,159 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <edtwin.hxx>
+#include <FrameControlsManager.hxx>
+#include <HeaderFooterWin.hxx>
+#include <PageBreakWin.hxx>
+#include <pagefrm.hxx>
+#include <viewopt.hxx>
+#include <view.hxx>
+#include <wrtsh.hxx>
+
+using namespace std;
+
+SwFrameControlsManager::SwFrameControlsManager( SwEditWin* pEditWin ) :
+ m_pEditWin( pEditWin ),
+ m_aControls( )
+{
+}
+
+SwFrameControlsManager::~SwFrameControlsManager()
+{
+}
+
+SwFrameControlsManager::SwFrameControlsManager( const SwFrameControlsManager& rCopy ) :
+ m_pEditWin( rCopy.m_pEditWin ),
+ m_aControls( rCopy.m_aControls )
+{
+}
+
+const SwFrameControlsManager& SwFrameControlsManager::operator=( const SwFrameControlsManager& rCopy )
+{
+ m_pEditWin = rCopy.m_pEditWin;
+ m_aControls = rCopy.m_aControls;
+ return *this;
+}
+
+SwFrameControlPtr SwFrameControlsManager::GetControl( FrameControlType eType, const SwFrm* pFrm )
+{
+ SwFrameControlPtrMap& rControls = m_aControls[eType];
+
+ SwFrameControlPtrMap::iterator aIt = rControls.find(pFrm);
+
+ if (aIt != rControls.end())
+ return aIt->second;
+
+ return SwFrameControlPtr();
+}
+
+void SwFrameControlsManager::RemoveControls( const SwFrm* pFrm )
+{
+ map< FrameControlType, SwFrameControlPtrMap >::iterator pIt = m_aControls.begin();
+
+ while ( pIt != m_aControls.end() )
+ {
+ SwFrameControlPtrMap& rMap = pIt->second;
+ rMap.erase(pFrm);
+ ++pIt;
+ }
+}
+
+void SwFrameControlsManager::RemoveControlsByType( FrameControlType eType, const SwFrm* pFrm )
+{
+ SwFrameControlPtrMap& rMap = m_aControls[eType];
+ rMap.erase(pFrm);
+}
+
+void SwFrameControlsManager::HideControls( FrameControlType eType )
+{
+ SwFrameControlPtrMap::iterator pIt = m_aControls[eType].begin();
+ while ( pIt != m_aControls[eType].end() )
+ {
+ pIt->second->ShowAll( false );
+ ++pIt;
+ }
+}
+
+void SwFrameControlsManager::SetReadonlyControls( bool bReadonly )
+{
+ map< FrameControlType, SwFrameControlPtrMap >::iterator pIt = m_aControls.begin();
+
+ while ( pIt != m_aControls.end() )
+ {
+ SwFrameControlPtrMap::iterator aCtrlIt = pIt->second.begin();
+ while ( aCtrlIt != pIt->second.end() )
+ {
+ aCtrlIt->second->SetReadonly( bReadonly );
+ ++aCtrlIt;
+ }
+ ++pIt;
+ }
+}
+
+void SwFrameControlsManager::SetHeaderFooterControl( const SwPageFrm* pPageFrm, FrameControlType eType, Point aOffset )
+{
+ OSL_ASSERT( eType == Header || eType == Footer );
+
+ // Check if we already have the control
+ SwFrameControlPtr pControl;
+ const bool bHeader = ( eType == Header );
+
+ SwFrameControlPtrMap& rControls = m_aControls[eType];
+
+ SwFrameControlPtrMap::iterator lb = rControls.lower_bound(pPageFrm);
+ if (lb != rControls.end() && !(rControls.key_comp()(pPageFrm, lb->first)))
+ pControl = lb->second;
+ else
+ {
+ SwFrameControlPtr pNewControl( new SwHeaderFooterWin( m_pEditWin, pPageFrm, bHeader ) );
+ const SwViewOption* pViewOpt = m_pEditWin->GetView().GetWrtShell().GetViewOptions();
+ pNewControl->SetReadonly( pViewOpt->IsReadonly() );
+ rControls.insert(lb, make_pair(pPageFrm, pNewControl));
+ pControl.swap( pNewControl );
+ }
+
+ Rectangle aPageRect = m_pEditWin->LogicToPixel( pPageFrm->Frm().SVRect() );
+
+ SwHeaderFooterWin* pHFWin = dynamic_cast< SwHeaderFooterWin* >( pControl.get() );
+ assert(pHFWin->IsHeader() == bHeader);
+ pHFWin->SetOffset( aOffset, aPageRect.Left(), aPageRect.Right() );
+
+ if ( !pHFWin->IsVisible() )
+ pControl->ShowAll( true );
+}
+
+void SwFrameControlsManager::SetPageBreakControl( const SwPageFrm* pPageFrm )
+{
+ // Check if we already have the control
+ SwFrameControlPtr pControl;
+
+ SwFrameControlPtrMap& rControls = m_aControls[PageBreak];
+
+ SwFrameControlPtrMap::iterator lb = rControls.lower_bound(pPageFrm);
+ if (lb != rControls.end() && !(rControls.key_comp()(pPageFrm, lb->first)))
+ pControl = lb->second;
+ else
+ {
+ SwFrameControlPtr pNewControl( new SwPageBreakWin( m_pEditWin, pPageFrm ) );
+ const SwViewOption* pViewOpt = m_pEditWin->GetView().GetWrtShell().GetViewOptions();
+ pNewControl->SetReadonly( pViewOpt->IsReadonly() );
+
+ rControls.insert(lb, make_pair(pPageFrm, pNewControl));
+
+ pControl.swap( pNewControl );
+ }
+
+ SwPageBreakWin* pWin = dynamic_cast< SwPageBreakWin* >( pControl.get() );
+ pWin->UpdatePosition();
+ if ( !pWin->IsVisible() )
+ pControl->ShowAll( true );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/docvw/HeaderFooterWin.cxx b/sw/source/core/uibase/docvw/HeaderFooterWin.cxx
new file mode 100644
index 000000000000..b68c59a194d8
--- /dev/null
+++ b/sw/source/core/uibase/docvw/HeaderFooterWin.cxx
@@ -0,0 +1,520 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <app.hrc>
+#include <docvw.hrc>
+#include <globals.hrc>
+#include <popup.hrc>
+#include <svtools/svtools.hrc>
+
+#include <cmdid.h>
+#include <DashedLine.hxx>
+#include <docsh.hxx>
+#include <edtwin.hxx>
+#include <fmthdft.hxx>
+#include <HeaderFooterWin.hxx>
+#include <pagedesc.hxx>
+#include <pagefrm.hxx>
+#include <SwRewriter.hxx>
+#include <view.hxx>
+#include <viewopt.hxx>
+#include <wrtsh.hxx>
+
+#include <basegfx/color/bcolortools.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/range/b2drectangle.hxx>
+#include <basegfx/vector/b2dsize.hxx>
+#include <drawinglayer/attribute/fillgradientattribute.hxx>
+#include <drawinglayer/attribute/fontattribute.hxx>
+#include <drawinglayer/primitive2d/fillgradientprimitive2d.hxx>
+#include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx>
+#include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
+#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
+#include <drawinglayer/primitive2d/textlayoutdevice.hxx>
+#include <drawinglayer/primitive2d/textprimitive2d.hxx>
+#include <editeng/boxitem.hxx>
+#include <svtools/svtresid.hxx>
+#include <svx/hdft.hxx>
+#include <drawinglayer/processor2d/processorfromoutputdevice.hxx>
+#include <vcl/decoview.hxx>
+#include <vcl/gradient.hxx>
+#include <vcl/menubtn.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/settings.hxx>
+
+#define TEXT_PADDING 5
+#define BOX_DISTANCE 10
+#define BUTTON_WIDTH 18
+
+using namespace basegfx;
+using namespace basegfx::tools;
+using namespace drawinglayer::attribute;
+
+namespace
+{
+ static basegfx::BColor lcl_GetFillColor( basegfx::BColor aLineColor )
+ {
+ basegfx::BColor aHslLine = basegfx::tools::rgb2hsl( aLineColor );
+ double nLuminance = aHslLine.getZ() * 2.5;
+ if ( nLuminance == 0 )
+ nLuminance = 0.5;
+ else if ( nLuminance >= 1.0 )
+ nLuminance = aHslLine.getZ() * 0.4;
+ aHslLine.setZ( nLuminance );
+ return basegfx::tools::hsl2rgb( aHslLine );
+ }
+
+ static basegfx::BColor lcl_GetLighterGradientColor( basegfx::BColor aDarkColor )
+ {
+ basegfx::BColor aHslDark = basegfx::tools::rgb2hsl( aDarkColor );
+ double nLuminance = aHslDark.getZ() * 255 + 20;
+ aHslDark.setZ( nLuminance / 255.0 );
+ return basegfx::tools::hsl2rgb( aHslDark );
+ }
+
+ static B2DPolygon lcl_GetPolygon( const Rectangle& rRect, bool bHeader )
+ {
+ const double nRadius = 3;
+ const double nKappa((M_SQRT2 - 1.0) * 4.0 / 3.0);
+
+ B2DPolygon aPolygon;
+ aPolygon.append( B2DPoint( rRect.Left(), rRect.Top() ) );
+
+ {
+ B2DPoint aCorner( rRect.Left(), rRect.Bottom() );
+ B2DPoint aStart( rRect.Left(), rRect.Bottom() - nRadius );
+ B2DPoint aEnd( rRect.Left() + nRadius, rRect.Bottom() );
+ aPolygon.append( aStart );
+ aPolygon.appendBezierSegment(
+ interpolate( aStart, aCorner, nKappa ),
+ interpolate( aEnd, aCorner, nKappa ),
+ aEnd );
+ }
+
+ {
+ B2DPoint aCorner( rRect.Right(), rRect.Bottom() );
+ B2DPoint aStart( rRect.Right() - nRadius, rRect.Bottom() );
+ B2DPoint aEnd( rRect.Right(), rRect.Bottom() - nRadius );
+ aPolygon.append( aStart );
+ aPolygon.appendBezierSegment(
+ interpolate( aStart, aCorner, nKappa ),
+ interpolate( aEnd, aCorner, nKappa ),
+ aEnd );
+ }
+
+ aPolygon.append( B2DPoint( rRect.Right(), rRect.Top() ) );
+
+ if ( !bHeader )
+ {
+ B2DRectangle aBRect( rRect.Left(), rRect.Top(), rRect.Right(), rRect.Bottom() );
+ B2DHomMatrix aRotation = createRotateAroundPoint(
+ aBRect.getCenterX(), aBRect.getCenterY(), M_PI );
+ aPolygon.transform( aRotation );
+ }
+
+ return aPolygon;
+ }
+}
+
+SwHeaderFooterWin::SwHeaderFooterWin( SwEditWin* pEditWin, const SwPageFrm* pPageFrm, bool bHeader ) :
+ MenuButton( pEditWin, WB_DIALOGCONTROL ),
+ SwFrameControl( pEditWin, pPageFrm ),
+ m_sLabel( ),
+ m_bIsHeader( bHeader ),
+ m_pPopupMenu( NULL ),
+ m_pLine( NULL ),
+ m_bIsAppearing( false ),
+ m_nFadeRate( 100 ),
+ m_aFadeTimer( )
+{
+ // Get the font and configure it
+ Font aFont = GetSettings().GetStyleSettings().GetToolFont();
+ SetZoomedPointFont( aFont );
+
+ // Use pixels for the rest of the drawing
+ SetMapMode( MapMode ( MAP_PIXEL ) );
+
+ // Create the line control
+ m_pLine = new SwDashedLine( GetEditWin(), &SwViewOption::GetHeaderFooterMarkColor );
+ m_pLine->SetZOrder( this, WINDOW_ZORDER_BEFOR );
+
+ // Create and set the PopupMenu
+ m_pPopupMenu = new PopupMenu( SW_RES( MN_HEADERFOOTER_BUTTON ) );
+
+ // Rewrite the menu entries' text
+ if ( m_bIsHeader )
+ {
+ m_pPopupMenu->SetItemText( FN_HEADERFOOTER_EDIT, SW_RESSTR( STR_FORMAT_HEADER ) );
+ m_pPopupMenu->SetItemText( FN_HEADERFOOTER_DELETE, SW_RESSTR( STR_DELETE_HEADER ) );
+ }
+ else
+ {
+ m_pPopupMenu->SetItemText( FN_HEADERFOOTER_EDIT, SW_RESSTR( STR_FORMAT_FOOTER ) );
+ m_pPopupMenu->SetItemText( FN_HEADERFOOTER_DELETE, SW_RESSTR( STR_DELETE_FOOTER ) );
+ }
+
+ SetPopupMenu( m_pPopupMenu );
+
+ m_aFadeTimer.SetTimeout( 50 );
+ m_aFadeTimer.SetTimeoutHdl( LINK( this, SwHeaderFooterWin, FadeHandler ) );
+}
+
+SwHeaderFooterWin::~SwHeaderFooterWin( )
+{
+ delete m_pPopupMenu;
+ delete m_pLine;
+}
+
+const SwPageFrm* SwHeaderFooterWin::GetPageFrame( )
+{
+ return static_cast< const SwPageFrm * >( GetFrame( ) );
+}
+
+void SwHeaderFooterWin::SetOffset( Point aOffset, long nXLineStart, long nXLineEnd )
+{
+ // Compute the text to show
+ m_sLabel = SW_RESSTR( STR_HEADER_TITLE );
+ if ( !m_bIsHeader )
+ m_sLabel = SW_RESSTR( STR_FOOTER_TITLE );
+ sal_Int32 nPos = m_sLabel.lastIndexOf( "%1" );
+ m_sLabel = m_sLabel.replaceAt( nPos, 2, GetPageFrame()->GetPageDesc()->GetName() );
+
+ // Compute the text size and get the box position & size from it
+ Rectangle aTextRect;
+ GetTextBoundRect( aTextRect, OUString( m_sLabel ) );
+ Rectangle aTextPxRect = LogicToPixel( aTextRect );
+ FontMetric aFontMetric = GetFontMetric( GetFont() );
+ Size aBoxSize ( aTextPxRect.GetWidth() + BUTTON_WIDTH + TEXT_PADDING * 2,
+ aFontMetric.GetLineHeight() + TEXT_PADDING * 2 );
+
+ long nYFooterOff = 0;
+ if ( !m_bIsHeader )
+ nYFooterOff = aBoxSize.Height();
+
+ Point aBoxPos( aOffset.X() - aBoxSize.Width() - BOX_DISTANCE,
+ aOffset.Y() - nYFooterOff );
+
+ if ( Application::GetSettings().GetLayoutRTL() )
+ {
+ aBoxPos.setX( aOffset.X() + BOX_DISTANCE );
+ }
+
+ // Set the position & Size of the window
+ SetPosSizePixel( aBoxPos, aBoxSize );
+
+ double nYLinePos = aBoxPos.Y();
+ if ( !m_bIsHeader )
+ nYLinePos += aBoxSize.Height();
+ Point aLinePos( nXLineStart, nYLinePos );
+ Size aLineSize( nXLineEnd - nXLineStart, 1 );
+ m_pLine->SetPosSizePixel( aLinePos, aLineSize );
+}
+
+void SwHeaderFooterWin::ShowAll( bool bShow )
+{
+ if ( !PopupMenu::IsInExecute() )
+ {
+ m_bIsAppearing = bShow;
+
+ if ( m_aFadeTimer.IsActive( ) )
+ m_aFadeTimer.Stop();
+ m_aFadeTimer.Start( );
+ }
+}
+
+bool SwHeaderFooterWin::Contains( const Point &rDocPt ) const
+{
+ Rectangle aRect( GetPosPixel(), GetSizePixel() );
+ if ( aRect.IsInside( rDocPt ) )
+ return true;
+
+ Rectangle aLineRect( m_pLine->GetPosPixel(), m_pLine->GetSizePixel() );
+ if ( aLineRect.IsInside( rDocPt ) )
+ return true;
+
+ return false;
+}
+
+void SwHeaderFooterWin::Paint( const Rectangle& )
+{
+ const Rectangle aRect( Rectangle( Point( 0, 0 ), PixelToLogic( GetSizePixel() ) ) );
+ drawinglayer::primitive2d::Primitive2DSequence aSeq( 3 );
+
+ B2DPolygon aPolygon = lcl_GetPolygon( aRect, m_bIsHeader );
+
+ // Colors
+ basegfx::BColor aLineColor = SwViewOption::GetHeaderFooterMarkColor().getBColor();
+ basegfx::BColor aFillColor = lcl_GetFillColor( aLineColor );
+ basegfx::BColor aLighterColor = lcl_GetLighterGradientColor( aFillColor );
+
+ const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
+ if ( rSettings.GetHighContrastMode() )
+ {
+ aFillColor = rSettings.GetDialogColor( ).getBColor();
+ aLineColor = rSettings.GetDialogTextColor( ).getBColor();
+
+ aSeq[0] = drawinglayer::primitive2d::Primitive2DReference( new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(
+ B2DPolyPolygon( aPolygon ), aFillColor ) );
+ }
+ else
+ {
+ B2DRectangle aGradientRect( aRect.Left(), aRect.Top(), aRect.Right(), aRect.Bottom() );
+ double nAngle = M_PI;
+ if ( m_bIsHeader )
+ nAngle = 0;
+ FillGradientAttribute aFillAttrs( GRADIENTSTYLE_LINEAR, 0.0, 0.0, 0.0, nAngle,
+ aLighterColor, aFillColor, 10 );
+ aSeq[0] = drawinglayer::primitive2d::Primitive2DReference( new drawinglayer::primitive2d::FillGradientPrimitive2D(
+ aGradientRect, aFillAttrs ) );
+ }
+
+ // Create the border lines primitive
+ aSeq[1] = drawinglayer::primitive2d::Primitive2DReference( new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(
+ aPolygon, aLineColor ) );
+
+ // Create the text primitive
+ B2DVector aFontSize;
+ FontAttribute aFontAttr = drawinglayer::primitive2d::getFontAttributeFromVclFont(
+ aFontSize, GetFont(), false, false );
+
+ FontMetric aFontMetric = GetFontMetric( GetFont() );
+ double nTextOffsetY = aFontMetric.GetAscent() + TEXT_PADDING;
+ Point aTextPos( TEXT_PADDING, nTextOffsetY );
+
+ basegfx::B2DHomMatrix aTextMatrix( createScaleTranslateB2DHomMatrix(
+ aFontSize.getX(), aFontSize.getY(),
+ double( aTextPos.X() ), double( aTextPos.Y() ) ) );
+
+ aSeq[2] = drawinglayer::primitive2d::Primitive2DReference( new drawinglayer::primitive2d::TextSimplePortionPrimitive2D(
+ aTextMatrix,
+ OUString( m_sLabel ), 0, m_sLabel.getLength(),
+ std::vector< double >( ),
+ aFontAttr,
+ com::sun::star::lang::Locale(),
+ aLineColor ) );
+
+ // Create the 'plus' or 'arrow' primitive
+ B2DRectangle aSignArea( B2DPoint( aRect.Right() - BUTTON_WIDTH, 0.0 ),
+ B2DSize( aRect.Right(), aRect.getHeight() ) );
+
+ B2DPolygon aSign;
+ if ( IsEmptyHeaderFooter( ) )
+ {
+ // Create the + polygon
+ double nLeft = aSignArea.getMinX() + TEXT_PADDING;
+ double nRight = aSignArea.getMaxX() - TEXT_PADDING;
+ double nHalfW = ( nRight - nLeft ) / 2.0;
+
+ double nTop = aSignArea.getCenterY() - nHalfW;
+ double nBottom = aSignArea.getCenterY() + nHalfW;
+
+ aSign.append( B2DPoint( nLeft, aSignArea.getCenterY() - 1.0 ) );
+ aSign.append( B2DPoint( aSignArea.getCenterX() - 1.0, aSignArea.getCenterY() - 1.0 ) );
+ aSign.append( B2DPoint( aSignArea.getCenterX() - 1.0, nTop ) );
+ aSign.append( B2DPoint( aSignArea.getCenterX() + 1.0, nTop ) );
+ aSign.append( B2DPoint( aSignArea.getCenterX() + 1.0, aSignArea.getCenterY() - 1.0 ) );
+ aSign.append( B2DPoint( nRight, aSignArea.getCenterY() - 1.0 ) );
+ aSign.append( B2DPoint( nRight, aSignArea.getCenterY() + 1.0 ) );
+ aSign.append( B2DPoint( aSignArea.getCenterX() + 1.0, aSignArea.getCenterY() + 1.0 ) );
+ aSign.append( B2DPoint( aSignArea.getCenterX() + 1.0, nBottom ) );
+ aSign.append( B2DPoint( aSignArea.getCenterX() - 1.0, nBottom ) );
+ aSign.append( B2DPoint( aSignArea.getCenterX() - 1.0, aSignArea.getCenterY() + 1.0 ) );
+ aSign.append( B2DPoint( nLeft, aSignArea.getCenterY() + 1.0 ) );
+ aSign.setClosed( true );
+ }
+ else
+ {
+ // Create the v polygon
+ B2DPoint aLeft( aSignArea.getMinX() + TEXT_PADDING, aSignArea.getCenterY() );
+ B2DPoint aRight( aSignArea.getMaxX() - TEXT_PADDING, aSignArea.getCenterY() );
+ B2DPoint aBottom( ( aLeft.getX() + aRight.getX() ) / 2.0, aLeft.getY() + 4.0 );
+ aSign.append( aLeft );
+ aSign.append( aRight );
+ aSign.append( aBottom );
+ aSign.setClosed( true );
+ }
+
+ BColor aSignColor = Color( COL_BLACK ).getBColor( );
+ if ( Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
+ aSignColor = Color( COL_WHITE ).getBColor( );
+
+ aSeq.realloc( aSeq.getLength() + 1 );
+ aSeq[ aSeq.getLength() - 1 ] = drawinglayer::primitive2d::Primitive2DReference( new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(
+ B2DPolyPolygon( aSign ), aSignColor ) );
+
+ // Create the processor and process the primitives
+ const drawinglayer::geometry::ViewInformation2D aNewViewInfos;
+ drawinglayer::processor2d::BaseProcessor2D * pProcessor =
+ drawinglayer::processor2d::createBaseProcessor2DFromOutputDevice(
+ *this, aNewViewInfos );
+
+ // TODO Ghost it all if needed
+ drawinglayer::primitive2d::Primitive2DSequence aGhostedSeq( 1 );
+ double nFadeRate = double( m_nFadeRate ) / 100.0;
+ const basegfx::BColorModifierSharedPtr aBColorModifier(
+ new basegfx::BColorModifier_interpolate(
+ Color( COL_WHITE ).getBColor(),
+ 1.0 - nFadeRate));
+ aGhostedSeq[0] = drawinglayer::primitive2d::Primitive2DReference( new drawinglayer::primitive2d::ModifiedColorPrimitive2D(
+ aSeq, aBColorModifier ) );
+
+ pProcessor->process( aGhostedSeq );
+ delete pProcessor;
+}
+
+bool SwHeaderFooterWin::IsEmptyHeaderFooter( )
+{
+ bool bResult = true;
+
+ // Actually check it
+ const SwPageDesc* pDesc = GetPageFrame()->GetPageDesc();
+
+ bool const bFirst(GetPageFrame()->OnFirstPage());
+ const SwFrmFmt *const pFmt = (GetPageFrame()->OnRightPage())
+ ? pDesc->GetRightFmt(bFirst)
+ : pDesc->GetLeftFmt(bFirst);
+
+ if ( pFmt )
+ {
+ if ( m_bIsHeader )
+ bResult = !pFmt->GetHeader().IsActive();
+ else
+ bResult = !pFmt->GetFooter().IsActive();
+ }
+
+ return bResult;
+}
+
+void SwHeaderFooterWin::ExecuteCommand( sal_uInt16 nSlot )
+{
+ SwView& rView = GetEditWin()->GetView();
+ SwWrtShell& rSh = rView.GetWrtShell();
+
+ const OUString& rStyleName = GetPageFrame()->GetPageDesc()->GetName();
+ switch ( nSlot )
+ {
+ case FN_HEADERFOOTER_EDIT:
+ {
+ OString sPageId = m_bIsHeader ? OString("header") : OString("footer");
+ rView.GetDocShell()->FormatPage(rStyleName, sPageId, rSh);
+ }
+ break;
+ case FN_HEADERFOOTER_BORDERBACK:
+ {
+ const SwPageDesc* pDesc = GetPageFrame()->GetPageDesc();
+ const SwFrmFmt& rMaster = pDesc->GetMaster();
+ SwFrmFmt* pHFFmt = const_cast< SwFrmFmt* >( rMaster.GetFooter().GetFooterFmt() );
+ if ( m_bIsHeader )
+ pHFFmt = const_cast< SwFrmFmt* >( rMaster.GetHeader().GetHeaderFmt() );
+
+ SfxItemPool* pPool = pHFFmt->GetAttrSet().GetPool();
+ SfxItemSet aSet( *pPool,
+ RES_BACKGROUND, RES_BACKGROUND,
+ RES_BOX, RES_BOX,
+ SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
+ RES_SHADOW, RES_SHADOW, 0 );
+
+ aSet.Put( pHFFmt->GetAttrSet() );
+
+ // Create a box info item... needed by the dialog
+ SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
+ const SfxPoolItem *pBoxInfo;
+ if ( SFX_ITEM_SET == pHFFmt->GetAttrSet().GetItemState( SID_ATTR_BORDER_INNER,
+ true, &pBoxInfo) )
+ aBoxInfo = *(SvxBoxInfoItem*)pBoxInfo;
+
+ aBoxInfo.SetTable( false );
+ aBoxInfo.SetDist( true);
+ aBoxInfo.SetMinDist( false );
+ aBoxInfo.SetDefDist( MIN_BORDER_DIST );
+ aBoxInfo.SetValid( VALID_DISABLE );
+ aSet.Put( aBoxInfo );
+
+ if ( svx::ShowBorderBackgroundDlg( this, &aSet, true ) )
+ {
+ const SfxPoolItem* pItem;
+ if ( SFX_ITEM_SET == aSet.GetItemState( RES_BACKGROUND, false, &pItem ) ) {
+ pHFFmt->SetFmtAttr( *pItem );
+ rView.GetDocShell()->SetModified(true);
+ }
+
+ if ( SFX_ITEM_SET == aSet.GetItemState( RES_BOX, false, &pItem ) ) {
+ pHFFmt->SetFmtAttr( *pItem );
+ rView.GetDocShell()->SetModified(true);
+ }
+
+ if ( SFX_ITEM_SET == aSet.GetItemState( RES_SHADOW, false, &pItem ) ) {
+ pHFFmt->SetFmtAttr( *pItem );
+ rView.GetDocShell()->SetModified(true);
+ }
+ }
+ }
+ break;
+ case FN_HEADERFOOTER_DELETE:
+ {
+ rSh.ChangeHeaderOrFooter( rStyleName, m_bIsHeader, false, true );
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+void SwHeaderFooterWin::SetReadonly( bool bReadonly )
+{
+ ShowAll( !bReadonly );
+}
+
+void SwHeaderFooterWin::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ if ( IsEmptyHeaderFooter( ) )
+ {
+ SwView& rView = GetEditWin()->GetView();
+ SwWrtShell& rSh = rView.GetWrtShell();
+
+ const OUString& rStyleName = GetPageFrame()->GetPageDesc()->GetName();
+ rSh.ChangeHeaderOrFooter( rStyleName, m_bIsHeader, true, false );
+ }
+ else
+ MenuButton::MouseButtonDown( rMEvt );
+}
+
+void SwHeaderFooterWin::Select( )
+{
+ ExecuteCommand( GetCurItemId() );
+}
+
+IMPL_LINK_NOARG(SwHeaderFooterWin, FadeHandler)
+{
+ if ( m_bIsAppearing && m_nFadeRate > 0 )
+ m_nFadeRate -= 25;
+ else if ( !m_bIsAppearing && m_nFadeRate < 100 )
+ m_nFadeRate += 25;
+
+ if ( m_nFadeRate != 100 && !IsVisible() )
+ {
+ Show( true );
+ m_pLine->Show( true );
+ }
+ else if ( m_nFadeRate == 100 && IsVisible( ) )
+ {
+ Show( false );
+ m_pLine->Show( false );
+ }
+ else
+ Invalidate();
+
+ if ( IsVisible( ) && m_nFadeRate > 0 && m_nFadeRate < 100 )
+ m_aFadeTimer.Start();
+
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/docvw/OverlayRanges.cxx b/sw/source/core/uibase/docvw/OverlayRanges.cxx
new file mode 100755
index 000000000000..7b44a9b3bdb9
--- /dev/null
+++ b/sw/source/core/uibase/docvw/OverlayRanges.cxx
@@ -0,0 +1,180 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <OverlayRanges.hxx>
+#include <view.hxx>
+#include <svx/sdrpaintwindow.hxx>
+#include <svx/svdview.hxx>
+#include <svx/sdr/overlay/overlaymanager.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/polygon/b2dpolypolygon.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/polygon/b2dpolypolygoncutter.hxx>
+#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
+#include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx>
+
+namespace
+{
+ // combine ranges geometrically to a single, ORed polygon
+ basegfx::B2DPolyPolygon impCombineRangesToPolyPolygon(const std::vector< basegfx::B2DRange >& rRanges)
+ {
+ const sal_uInt32 nCount(rRanges.size());
+ basegfx::B2DPolyPolygon aRetval;
+
+ for(sal_uInt32 a(0); a < nCount; a++)
+ {
+ const basegfx::B2DPolygon aDiscretePolygon(basegfx::tools::createPolygonFromRect(rRanges[a]));
+
+ if(0 == a)
+ {
+ aRetval.append(aDiscretePolygon);
+ }
+ else
+ {
+ aRetval = basegfx::tools::solvePolygonOperationOr(aRetval, basegfx::B2DPolyPolygon(aDiscretePolygon));
+ }
+ }
+
+ return aRetval;
+ }
+}
+
+namespace sw
+{
+ namespace overlay
+ {
+ drawinglayer::primitive2d::Primitive2DSequence OverlayRanges::createOverlayObjectPrimitive2DSequence()
+ {
+ const sal_uInt32 nCount(getRanges().size());
+ drawinglayer::primitive2d::Primitive2DSequence aRetval;
+ aRetval.realloc(nCount);
+ for ( sal_uInt32 a = 0; a < nCount; ++a )
+ {
+ const basegfx::BColor aRGBColor(getBaseColor().getBColor());
+ const basegfx::B2DPolygon aPolygon(basegfx::tools::createPolygonFromRect(maRanges[a]));
+ aRetval[a] = drawinglayer::primitive2d::Primitive2DReference(
+ new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(
+ basegfx::B2DPolyPolygon(aPolygon),
+ aRGBColor));
+ }
+ // embed all rectangles in transparent paint
+ const SvtOptionsDrawinglayer aSvtOptionsDrawinglayer;
+ const sal_uInt16 nTransparence( aSvtOptionsDrawinglayer.GetTransparentSelectionPercent() );
+ const double fTransparence( nTransparence / 100.0 );
+ const drawinglayer::primitive2d::Primitive2DReference aUnifiedTransparence(
+ new drawinglayer::primitive2d::UnifiedTransparencePrimitive2D(
+ aRetval,
+ fTransparence));
+
+ if ( mbShowSolidBorder )
+ {
+ const basegfx::BColor aRGBColor(getBaseColor().getBColor());
+ const basegfx::B2DPolyPolygon aPolyPolygon(impCombineRangesToPolyPolygon(getRanges()));
+ const drawinglayer::primitive2d::Primitive2DReference aOutline(
+ new drawinglayer::primitive2d::PolyPolygonHairlinePrimitive2D(
+ aPolyPolygon,
+ aRGBColor));
+
+ aRetval.realloc(2);
+ aRetval[0] = aUnifiedTransparence;
+ aRetval[1] = aOutline;
+ }
+ else
+ {
+ aRetval = drawinglayer::primitive2d::Primitive2DSequence(&aUnifiedTransparence, 1);
+ }
+
+ return aRetval;
+ }
+
+ /*static*/ OverlayRanges* OverlayRanges::CreateOverlayRange(
+ SwView& rDocView,
+ const Color& rColor,
+ const std::vector< basegfx::B2DRange >& rRanges,
+ const bool bShowSolidBorder )
+ {
+ OverlayRanges* pOverlayRanges = NULL;
+
+ SdrView* pView = rDocView.GetDrawView();
+ if ( pView != NULL )
+ {
+ SdrPaintWindow* pCandidate = pView->GetPaintWindow(0);
+ rtl::Reference<sdr::overlay::OverlayManager> xTargetOverlay = pCandidate->GetOverlayManager();
+
+ if ( xTargetOverlay.is() )
+ {
+ pOverlayRanges = new sw::overlay::OverlayRanges( rColor, rRanges, bShowSolidBorder );
+ xTargetOverlay->add( *pOverlayRanges );
+ }
+ }
+
+ return pOverlayRanges;
+ }
+
+ OverlayRanges::OverlayRanges(
+ const Color& rColor,
+ const std::vector< basegfx::B2DRange >& rRanges,
+ const bool bShowSolidBorder )
+ : sdr::overlay::OverlayObject( rColor )
+ , maRanges( rRanges )
+ , mbShowSolidBorder( bShowSolidBorder )
+ {
+ // no AA for highlight overlays
+ allowAntiAliase(false);
+ }
+
+ OverlayRanges::~OverlayRanges()
+ {
+ if( getOverlayManager() )
+ {
+ getOverlayManager()->remove(*this);
+ }
+ }
+
+ void OverlayRanges::setRanges(const std::vector< basegfx::B2DRange >& rNew)
+ {
+ if(rNew != maRanges)
+ {
+ maRanges = rNew;
+ objectChange();
+ }
+ }
+
+ void OverlayRanges::ShowSolidBorder()
+ {
+ if ( !mbShowSolidBorder )
+ {
+ mbShowSolidBorder = true;
+ objectChange();
+ }
+ }
+
+ void OverlayRanges::HideSolidBorder()
+ {
+ if ( mbShowSolidBorder )
+ {
+ mbShowSolidBorder = false;
+ objectChange();
+ }
+ }
+
+ } // end of namespace overlay
+} // end of namespace sdr
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/docvw/OverlayRanges.hxx b/sw/source/core/uibase/docvw/OverlayRanges.hxx
new file mode 100755
index 000000000000..ccbe668211aa
--- /dev/null
+++ b/sw/source/core/uibase/docvw/OverlayRanges.hxx
@@ -0,0 +1,78 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef _SW_OVERLAY_OVERLAYRANGES_HXX
+#define _SW_OVERLAY_OVERLAYRANGES_HXX
+
+#include <svx/sdr/overlay/overlayobject.hxx>
+#include <basegfx/range/b2drange.hxx>
+
+#include <vector>
+
+class SwView;
+
+namespace sw
+{
+ namespace overlay
+ {
+ class OverlayRanges : public sdr::overlay::OverlayObject
+ {
+ protected:
+ // geometry of overlay
+ std::vector< basegfx::B2DRange > maRanges;
+
+ bool mbShowSolidBorder;
+
+ // geometry creation for OverlayObject
+ virtual drawinglayer::primitive2d::Primitive2DSequence createOverlayObjectPrimitive2DSequence();
+
+ public:
+ static OverlayRanges* CreateOverlayRange(
+ SwView& rDocView,
+ const Color& rColor,
+ const std::vector< basegfx::B2DRange >& rRanges,
+ const bool bShowSolidBorder );
+
+ virtual ~OverlayRanges();
+
+ // data read access
+ inline const std::vector< basegfx::B2DRange >& getRanges() const
+ {
+ return maRanges;
+ }
+
+ // data write access
+ void setRanges(const std::vector< basegfx::B2DRange >& rNew);
+
+ void ShowSolidBorder();
+ void HideSolidBorder();
+
+ private:
+ OverlayRanges(
+ const Color& rColor,
+ const std::vector< basegfx::B2DRange >& rRanges,
+ const bool bShowSolidBorder );
+
+ };
+ } // end of namespace overlay
+} // end of namespace sw
+
+#endif //_SW_OVERLAY_OVERLAYRANGES_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/docvw/PageBreakWin.cxx b/sw/source/core/uibase/docvw/PageBreakWin.cxx
new file mode 100644
index 000000000000..1380fdfcc469
--- /dev/null
+++ b/sw/source/core/uibase/docvw/PageBreakWin.cxx
@@ -0,0 +1,463 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <globals.hrc>
+#include <popup.hrc>
+#include <utlui.hrc>
+
+#include <cmdid.h>
+#include <cntfrm.hxx>
+#include <DashedLine.hxx>
+#include <doc.hxx>
+#include <edtwin.hxx>
+#include <fmtpdsc.hxx>
+#include <IDocumentUndoRedo.hxx>
+#include <PageBreakWin.hxx>
+#include <pagefrm.hxx>
+#include <PostItMgr.hxx>
+#include <uiitems.hxx>
+#include <view.hxx>
+#include <viewopt.hxx>
+#include <wrtsh.hxx>
+
+#include <basegfx/color/bcolortools.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/range/b2drectangle.hxx>
+#include <drawinglayer/primitive2d/discretebitmapprimitive2d.hxx>
+#include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx>
+#include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
+#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
+#include <drawinglayer/processor2d/processorfromoutputdevice.hxx>
+#include <editeng/formatbreakitem.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svl/stritem.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/settings.hxx>
+
+#define BUTTON_WIDTH 30
+#define BUTTON_HEIGHT 19
+#define ARROW_WIDTH 9
+
+using namespace basegfx;
+using namespace basegfx::tools;
+
+namespace
+{
+ class SwBreakDashedLine : public SwDashedLine
+ {
+ private:
+ SwPageBreakWin* m_pWin;
+
+ public:
+ SwBreakDashedLine( Window* pParent, Color& ( *pColorFn )(), SwPageBreakWin* pWin ) :
+ SwDashedLine( pParent, pColorFn ),
+ m_pWin( pWin ) {};
+
+ virtual void MouseMove( const MouseEvent& rMEvt );
+ };
+
+ void SwBreakDashedLine::MouseMove( const MouseEvent& rMEvt )
+ {
+ if ( rMEvt.IsLeaveWindow() )
+ {
+ // don't fade if we just move to the 'button'
+ Point aEventPos( GetPosPixel() + rMEvt.GetPosPixel() );
+ if ( !m_pWin->Contains( aEventPos ) || !m_pWin->IsVisible() )
+ m_pWin->Fade( false );
+ }
+ else if ( !m_pWin->IsVisible() )
+ {
+ m_pWin->Fade( true );
+ }
+
+ if ( !rMEvt.IsSynthetic() && !m_pWin->IsVisible() )
+ {
+ Point* pPtr = new Point( rMEvt.GetPosPixel() );
+ m_pWin->UpdatePosition( pPtr );
+ }
+ }
+}
+
+SwPageBreakWin::SwPageBreakWin( SwEditWin* pEditWin, const SwPageFrm* pPageFrm ) :
+ MenuButton( pEditWin, WB_DIALOGCONTROL ),
+ SwFrameControl( pEditWin, pPageFrm ),
+ m_pPopupMenu( NULL ),
+ m_pLine( NULL ),
+ m_bIsAppearing( false ),
+ m_nFadeRate( 100 ),
+ m_nDelayAppearing( 0 ),
+ m_bDestroyed( false ),
+ m_pMousePt( NULL )
+{
+ // Use pixels for the rest of the drawing
+ SetMapMode( MapMode ( MAP_PIXEL ) );
+
+ // Create the line control
+ m_pLine = new SwBreakDashedLine( GetEditWin(), &SwViewOption::GetPageBreakColor, this );
+
+ // Create the popup menu
+ m_pPopupMenu = new PopupMenu( SW_RES( MN_PAGEBREAK_BUTTON ) );
+ m_pPopupMenu->SetDeactivateHdl( LINK( this, SwPageBreakWin, HideHandler ) );
+ SetPopupMenu( m_pPopupMenu );
+
+ m_aFadeTimer.SetTimeout( 50 );
+ m_aFadeTimer.SetTimeoutHdl( LINK( this, SwPageBreakWin, FadeHandler ) );
+}
+
+SwPageBreakWin::~SwPageBreakWin( )
+{
+ m_bDestroyed = true;
+ m_aFadeTimer.Stop();
+
+ delete m_pPopupMenu;
+ delete m_pLine;
+ delete m_pMousePt;
+}
+
+void SwPageBreakWin::Paint( const Rectangle& )
+{
+ const Rectangle aRect( Rectangle( Point( 0, 0 ), PixelToLogic( GetSizePixel() ) ) );
+
+ // Properly paint the control
+ BColor aColor = SwViewOption::GetPageBreakColor().getBColor();
+
+ BColor aHslLine = rgb2hsl( aColor );
+ double nLuminance = aHslLine.getZ();
+ nLuminance += ( 1.0 - nLuminance ) * 0.75;
+ if ( aHslLine.getZ() > 0.7 )
+ nLuminance = aHslLine.getZ() * 0.7;
+ aHslLine.setZ( nLuminance );
+ BColor aOtherColor = hsl2rgb( aHslLine );
+
+ const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
+ if ( rSettings.GetHighContrastMode( ) )
+ {
+ aColor = rSettings.GetDialogTextColor().getBColor();
+ aOtherColor = rSettings.GetDialogColor( ).getBColor();
+ }
+
+ bool bRtl = Application::GetSettings().GetLayoutRTL();
+
+ drawinglayer::primitive2d::Primitive2DSequence aSeq( 3 );
+ B2DRectangle aBRect( double( aRect.Left() ), double( aRect.Top( ) ),
+ double( aRect.Right() ), double( aRect.Bottom( ) ) );
+ B2DPolygon aPolygon = createPolygonFromRect( aBRect, 3.0 / BUTTON_WIDTH, 3.0 / BUTTON_HEIGHT );
+
+ // Create the polygon primitives
+ aSeq[0] = Primitive2DReference( new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(
+ B2DPolyPolygon( aPolygon ), aOtherColor ) );
+ aSeq[1] = Primitive2DReference( new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(
+ aPolygon, aColor ) );
+
+ // Create the primitive for the image
+ Image aImg( SW_RES( IMG_PAGE_BREAK ) );
+ double nImgOfstX = 3.0;
+ if ( bRtl )
+ nImgOfstX = aRect.Right() - aImg.GetSizePixel().Width() - 3.0;
+ aSeq[2] = Primitive2DReference( new drawinglayer::primitive2d::DiscreteBitmapPrimitive2D(
+ aImg.GetBitmapEx(), B2DPoint( nImgOfstX, 1.0 ) ) );
+
+ double nTop = double( aRect.getHeight() ) / 2.0;
+ double nBottom = nTop + 4.0;
+ double nLeft = aRect.getWidth( ) - ARROW_WIDTH - 6.0;
+ if ( bRtl )
+ nLeft = ARROW_WIDTH - 2.0;
+ double nRight = nLeft + 8.0;
+
+ B2DPolygon aTriangle;
+ aTriangle.append( B2DPoint( nLeft, nTop ) );
+ aTriangle.append( B2DPoint( nRight, nTop ) );
+ aTriangle.append( B2DPoint( ( nLeft + nRight ) / 2.0, nBottom ) );
+ aTriangle.setClosed( true );
+
+ BColor aTriangleColor = Color( COL_BLACK ).getBColor( );
+ if ( Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
+ aTriangleColor = Color( COL_WHITE ).getBColor( );
+
+ aSeq.realloc( aSeq.getLength() + 1 );
+ aSeq[ aSeq.getLength() - 1 ] = Primitive2DReference( new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(
+ B2DPolyPolygon( aTriangle ), aTriangleColor ) );
+
+ Primitive2DSequence aGhostedSeq( 1 );
+ double nFadeRate = double( m_nFadeRate ) / 100.0;
+ const basegfx::BColorModifierSharedPtr aBColorModifier(
+ new basegfx::BColorModifier_interpolate(
+ Color( COL_WHITE ).getBColor(),
+ 1.0 - nFadeRate));
+ aGhostedSeq[0] = Primitive2DReference( new drawinglayer::primitive2d::ModifiedColorPrimitive2D(
+ aSeq, aBColorModifier ) );
+
+ // Create the processor and process the primitives
+ const drawinglayer::geometry::ViewInformation2D aNewViewInfos;
+ drawinglayer::processor2d::BaseProcessor2D * pProcessor =
+ drawinglayer::processor2d::createBaseProcessor2DFromOutputDevice(
+ *this, aNewViewInfos );
+
+ pProcessor->process( aGhostedSeq );
+ delete pProcessor;
+}
+
+void SwPageBreakWin::Select( )
+{
+ SwFrameControlPtr pThis = GetEditWin()->GetFrameControlsManager( ).GetControl( PageBreak, GetFrame() );
+
+ switch( GetCurItemId( ) )
+ {
+ case FN_PAGEBREAK_EDIT:
+ {
+ const SwLayoutFrm* pBodyFrm = static_cast< const SwLayoutFrm* >( GetPageFrame()->Lower() );
+ while ( pBodyFrm && !pBodyFrm->IsBodyFrm() )
+ pBodyFrm = static_cast< const SwLayoutFrm* >( pBodyFrm->GetNext() );
+
+ SwEditWin* pEditWin = GetEditWin();
+
+ if ( pBodyFrm )
+ {
+ SwWrtShell& rSh = pEditWin->GetView().GetWrtShell();
+ sal_Bool bOldLock = rSh.IsViewLocked();
+ rSh.LockView( sal_True );
+
+ if ( pBodyFrm->Lower()->IsTabFrm() )
+ {
+ rSh.Push( );
+ rSh.ClearMark();
+
+ SwCntntFrm *pCnt = const_cast< SwCntntFrm* >( pBodyFrm->ContainsCntnt() );
+ SwCntntNode* pNd = pCnt->GetNode();
+ rSh.SetSelection( *pNd );
+
+ SfxStringItem aItem(pEditWin->GetView().GetPool().GetWhich(FN_FORMAT_TABLE_DLG), "textflow");
+ pEditWin->GetView().GetViewFrame()->GetDispatcher()->Execute(
+ FN_FORMAT_TABLE_DLG, SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD, &aItem, NULL );
+
+ rSh.Pop( sal_False );
+ }
+ else
+ {
+ SwCntntFrm *pCnt = const_cast< SwCntntFrm* >( pBodyFrm->ContainsCntnt() );
+ SwCntntNode* pNd = pCnt->GetNode();
+
+ SwPaM aPaM( *pNd );
+ SwPaMItem aPaMItem( pEditWin->GetView().GetPool( ).GetWhich( FN_PARAM_PAM ), &aPaM );
+ SfxStringItem aItem( pEditWin->GetView().GetPool( ).GetWhich( SID_PARA_DLG ), "textflow" );
+ pEditWin->GetView().GetViewFrame()->GetDispatcher()->Execute(
+ SID_PARA_DLG, SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD, &aItem, &aPaMItem, NULL );
+ }
+ rSh.LockView( bOldLock );
+ pEditWin->GrabFocus( );
+ }
+ }
+ break;
+ case FN_PAGEBREAK_DELETE:
+ {
+ const SwLayoutFrm* pBodyFrm = static_cast< const SwLayoutFrm* >( GetPageFrame()->Lower() );
+ while ( pBodyFrm && !pBodyFrm->IsBodyFrm() )
+ pBodyFrm = static_cast< const SwLayoutFrm* >( pBodyFrm->GetNext() );
+
+ if ( pBodyFrm )
+ {
+ SwCntntFrm *pCnt = const_cast< SwCntntFrm* >( pBodyFrm->ContainsCntnt() );
+ SwCntntNode* pNd = pCnt->GetNode();
+
+ pNd->GetDoc()->GetIDocumentUndoRedo( ).StartUndo( UNDO_UI_DELETE_PAGE_BREAK, NULL );
+
+ SfxItemSet aSet( GetEditWin()->GetView().GetWrtShell().GetAttrPool(),
+ RES_PAGEDESC, RES_PAGEDESC,
+ RES_BREAK, RES_BREAK,
+ NULL );
+ aSet.Put( SvxFmtBreakItem( SVX_BREAK_NONE, RES_BREAK ) );
+ aSet.Put( SwFmtPageDesc( NULL ) );
+
+ SwPaM aPaM( *pNd );
+ pNd->GetDoc()->InsertItemSet( aPaM, aSet, nsSetAttrMode::SETATTR_DEFAULT );
+
+ pNd->GetDoc()->GetIDocumentUndoRedo( ).EndUndo( UNDO_UI_DELETE_PAGE_BREAK, NULL );
+ }
+ }
+ break;
+ }
+
+ // Only fade if there is more than this temporary shared pointer:
+ // The main reference has been deleted due to a page break removal
+ if ( pThis.use_count() > 1 )
+ Fade( false );
+}
+
+void SwPageBreakWin::MouseMove( const MouseEvent& rMEvt )
+{
+ if ( rMEvt.IsLeaveWindow() )
+ {
+ // don't fade if we just move to the 'line', or the popup menu is open
+ Point aEventPos( rMEvt.GetPosPixel() + rMEvt.GetPosPixel() );
+ if ( !Contains( aEventPos ) && !PopupMenu::IsInExecute() )
+ Fade( false );
+ }
+ else if ( !IsVisible() )
+ Fade( true );
+}
+
+void SwPageBreakWin::Activate( )
+{
+ Fade( true );
+ MenuButton::Activate();
+}
+
+void SwPageBreakWin::UpdatePosition( const Point* pEvtPt )
+{
+ if ( pEvtPt != NULL )
+ {
+ if ( pEvtPt == m_pMousePt )
+ return;
+ delete m_pMousePt;
+ m_pMousePt = pEvtPt;
+ }
+
+ const SwPageFrm* pPageFrm = GetPageFrame();
+ const SwFrm* pPrevPage = pPageFrm;
+ do
+ {
+ pPrevPage = pPrevPage->GetPrev();
+ }
+ while ( pPrevPage && ( ( pPrevPage->Frm().Top( ) == pPageFrm->Frm().Top( ) )
+ || static_cast< const SwPageFrm* >( pPrevPage )->IsEmptyPage( ) ) );
+
+ Rectangle aBoundRect = GetEditWin()->LogicToPixel( pPageFrm->GetBoundRect().SVRect() );
+ Rectangle aFrmRect = GetEditWin()->LogicToPixel( pPageFrm->Frm().SVRect() );
+
+ long nYLineOffset = ( aBoundRect.Top() + aFrmRect.Top() ) / 2;
+ if ( pPrevPage )
+ {
+ Rectangle aPrevFrmRect = GetEditWin()->LogicToPixel( pPrevPage->Frm().SVRect() );
+ nYLineOffset = ( aPrevFrmRect.Bottom() + aFrmRect.Top() ) / 2;
+ }
+
+ // Get the page + sidebar coords
+ long nPgLeft = aFrmRect.Left();
+ long nPgRight = aFrmRect.Right();
+
+ unsigned long nSidebarWidth = 0;
+ const SwPostItMgr* pPostItMngr = GetEditWin()->GetView().GetWrtShell().GetPostItMgr();
+ if ( pPostItMngr && pPostItMngr->HasNotes() && pPostItMngr->ShowNotes() )
+ nSidebarWidth = pPostItMngr->GetSidebarBorderWidth( true ) + pPostItMngr->GetSidebarWidth( true );
+
+ if ( pPageFrm->SidebarPosition( ) == sw::sidebarwindows::SIDEBAR_LEFT )
+ nPgLeft -= nSidebarWidth;
+ else if ( pPageFrm->SidebarPosition( ) == sw::sidebarwindows::SIDEBAR_RIGHT )
+ nPgRight += nSidebarWidth;
+
+ Size aBtnSize( BUTTON_WIDTH + ARROW_WIDTH, BUTTON_HEIGHT );
+
+ // Place the button on the left or right?
+ Rectangle aVisArea = GetEditWin()->LogicToPixel( GetEditWin()->GetView().GetVisArea() );
+
+ long nLineLeft = std::max( nPgLeft, aVisArea.Left() );
+ long nLineRight = std::min( nPgRight, aVisArea.Right() );
+ long nBtnLeft = nLineLeft;
+
+ if ( m_pMousePt )
+ {
+ nBtnLeft = nLineLeft + m_pMousePt->X() - aBtnSize.getWidth() / 2;
+
+ if ( nBtnLeft < nLineLeft )
+ nBtnLeft = nLineLeft;
+ else if ( ( nBtnLeft + aBtnSize.getWidth() ) > nLineRight )
+ nBtnLeft = nLineRight - aBtnSize.getWidth();
+ }
+
+ // Set the button position
+ Point aBtnPos( nBtnLeft, nYLineOffset - BUTTON_HEIGHT / 2 );
+ SetPosSizePixel( aBtnPos, aBtnSize );
+
+ // Set the line position
+ Point aLinePos( nLineLeft, nYLineOffset - 5 );
+ Size aLineSize( nLineRight - nLineLeft, 10 );
+ m_pLine->SetPosSizePixel( aLinePos, aLineSize );
+}
+
+void SwPageBreakWin::ShowAll( bool bShow )
+{
+ m_pLine->Show( bShow );
+}
+
+bool SwPageBreakWin::Contains( const Point &rDocPt ) const
+{
+ Rectangle aRect( GetPosPixel(), GetSizePixel() );
+ if ( aRect.IsInside( rDocPt ) )
+ return true;
+
+ Rectangle aLineRect( m_pLine->GetPosPixel(), m_pLine->GetSizePixel() );
+ if ( aLineRect.IsInside( rDocPt ) )
+ return true;
+
+ return false;
+}
+
+const SwPageFrm* SwPageBreakWin::GetPageFrame( )
+{
+ return static_cast< const SwPageFrm * >( GetFrame( ) );
+}
+
+void SwPageBreakWin::SetReadonly( bool bReadonly )
+{
+ ShowAll( !bReadonly );
+}
+
+void SwPageBreakWin::Fade( bool bFadeIn )
+{
+ m_bIsAppearing = bFadeIn;
+ if ( bFadeIn )
+ m_nDelayAppearing = 0;
+
+ if ( !m_bDestroyed && m_aFadeTimer.IsActive( ) )
+ m_aFadeTimer.Stop();
+ if ( !m_bDestroyed )
+ m_aFadeTimer.Start( );
+}
+
+IMPL_LINK_NOARG(SwPageBreakWin, HideHandler)
+{
+ Fade( false );
+
+ return 0;
+}
+
+IMPL_LINK_NOARG(SwPageBreakWin, FadeHandler)
+{
+ const int TICKS_BEFORE_WE_APPEAR = 10;
+ if ( m_bIsAppearing && m_nDelayAppearing < TICKS_BEFORE_WE_APPEAR )
+ {
+ ++m_nDelayAppearing;
+ m_aFadeTimer.Start();
+ return 0;
+ }
+
+ if ( m_bIsAppearing && m_nFadeRate > 0 )
+ m_nFadeRate -= 25;
+ else if ( !m_bIsAppearing && m_nFadeRate < 100 )
+ m_nFadeRate += 25;
+
+ if ( m_nFadeRate != 100 && !IsVisible() )
+ Show();
+ else if ( m_nFadeRate == 100 && IsVisible( ) )
+ Hide();
+ else
+ {
+ UpdatePosition();
+ Invalidate();
+ }
+
+ if ( IsVisible( ) && m_nFadeRate > 0 && m_nFadeRate < 100 )
+ m_aFadeTimer.Start();
+
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/docvw/PostItMgr.cxx b/sw/source/core/uibase/docvw/PostItMgr.cxx
new file mode 100644
index 000000000000..82f078c445db
--- /dev/null
+++ b/sw/source/core/uibase/docvw/PostItMgr.cxx
@@ -0,0 +1,1939 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "PostItMgr.hxx"
+#include <postithelper.hxx>
+
+#include <SidebarWin.hxx>
+#include <AnnotationWin.hxx>
+#include <frmsidebarwincontainer.hxx>
+#include <accmap.hxx>
+
+#include <SidebarWindowsConsts.hxx>
+#include <AnchorOverlayObject.hxx>
+#include <ShadowOverlayObject.hxx>
+
+#include <vcl/svapp.hxx>
+#include <vcl/scrbar.hxx>
+#include <vcl/outdev.hxx>
+#include <vcl/settings.hxx>
+
+#include <viewopt.hxx>
+
+#include <view.hxx>
+#include <docsh.hxx>
+#include <wrtsh.hxx>
+#include <doc.hxx>
+#include <fldbas.hxx>
+#include <fmtfld.hxx>
+#include <docufld.hxx>
+#include <edtwin.hxx>
+#include <txtfld.hxx>
+#include <txtannotationfld.hxx>
+#include <ndtxt.hxx>
+#include <redline.hxx>
+#include <docary.hxx>
+#include <SwRewriter.hxx>
+#include <tools/color.hxx>
+
+#include <swmodule.hxx>
+#include <annotation.hrc>
+#include "cmdid.h"
+
+#include <sfx2/request.hxx>
+#include <sfx2/event.hxx>
+#include <svl/srchitem.hxx>
+
+#include <svl/languageoptions.hxx>
+#include <svtools/langtab.hxx>
+#include <svl/smplhint.hxx>
+
+#include <svx/svdview.hxx>
+#include <editeng/eeitem.hxx>
+#include <editeng/langitem.hxx>
+#include <editeng/outliner.hxx>
+
+#include <i18nlangtag/mslangid.hxx>
+#include <i18nlangtag/lang.h>
+
+#include "swevent.hxx"
+#include "switerator.hxx"
+
+// distance between Anchor Y and initial note position
+#define POSTIT_INITIAL_ANCHOR_DISTANCE 20
+//distance between two postits
+#define POSTIT_SPACE_BETWEEN 8
+#define POSTIT_MINIMUMSIZE_WITH_META 60
+#define POSTIT_SCROLL_SIDEBAR_HEIGHT 20
+
+// if we layout more often we stop, this should never happen
+#define MAX_LOOP_COUNT 50
+
+using namespace sw::sidebarwindows;
+
+bool comp_pos(const SwSidebarItem* a, const SwSidebarItem* b)
+{
+ // sort by anchor position
+ SwPosition aPosAnchorA = a->GetAnchorPosition();
+ SwPosition aPosAnchorB = b->GetAnchorPosition();
+
+ bool aAnchorAInFooter = false;
+ bool aAnchorBInFooter = false;
+
+ // is the anchor placed in Footnote or the Footer?
+ if( aPosAnchorA.nNode.GetNode().FindFootnoteStartNode() || aPosAnchorA.nNode.GetNode().FindFooterStartNode() )
+ aAnchorAInFooter = true;
+ if( aPosAnchorB.nNode.GetNode().FindFootnoteStartNode() || aPosAnchorB.nNode.GetNode().FindFooterStartNode() )
+ aAnchorBInFooter = true;
+
+ // fdo#34800
+ // if AnchorA is in footnote, and AnchorB isn't
+ // we do not want to change over the position
+ if( aAnchorAInFooter && !aAnchorBInFooter )
+ return false;
+ // if aAnchorA is not placed in a footnote, and aAnchorB is
+ // force a change over
+ else if( !aAnchorAInFooter && aAnchorBInFooter )
+ return true;
+ // If neither or both are in the footer, compare the positions.
+ // Since footnotes are in Inserts section of nodes array and footers
+ // in Autotext section, all footnotes precede any footers so no need
+ // to check that.
+ else
+ return aPosAnchorA < aPosAnchorB;
+}
+
+SwPostItMgr::SwPostItMgr(SwView* pView)
+ : mpView(pView)
+ , mpWrtShell(mpView->GetDocShell()->GetWrtShell())
+ , mpEditWin(&mpView->GetEditWin())
+ , mnEventId(0)
+ , mbWaitingForCalcRects(false)
+ , mpActivePostIt(0)
+ , mbLayout(false)
+ , mbLayoutHeight(0)
+ , mbLayouting(false)
+ , mbReadOnly(mpView->GetDocShell()->IsReadOnly())
+ , mbDeleteNote(true)
+ , mpAnswer(0)
+ , mbIsShowAnchor( false )
+ , mpFrmSidebarWinContainer( 0 )
+{
+ if(!mpView->GetDrawView() )
+ mpView->GetWrtShell().MakeDrawView();
+
+ SwNoteProps aProps;
+ mbIsShowAnchor = aProps.IsShowAnchor();
+
+ //make sure we get the colour yellow always, even if not the first one of comments or redlining
+ SW_MOD()->GetRedlineAuthor();
+
+ // collect all PostIts and redline comments that exist after loading the document
+ // don't check for existance for any of them, don't focus them
+ AddPostIts(false,false);
+ /* this code can be used once we want redline comments in the Sidebar
+ AddRedlineComments(false,false);
+ */
+ // we want to receive stuff like SFX_HINT_DOCCHANGED
+ StartListening(*mpView->GetDocShell());
+ if (!mvPostItFlds.empty())
+ {
+ mbWaitingForCalcRects = true;
+ mnEventId = Application::PostUserEvent( LINK( this, SwPostItMgr, CalcHdl), 0 );
+ }
+}
+
+SwPostItMgr::~SwPostItMgr()
+{
+ if ( mnEventId )
+ Application::RemoveUserEvent( mnEventId );
+ // forget about all our Sidebar windows
+ RemoveSidebarWin();
+ EndListening( *mpView->GetDocShell() );
+
+ for(std::vector<SwPostItPageItem*>::iterator i = mPages.begin(); i != mPages.end() ; ++i)
+ delete (*i);
+ mPages.clear();
+
+ delete mpFrmSidebarWinContainer;
+ mpFrmSidebarWinContainer = 0;
+}
+
+void SwPostItMgr::CheckForRemovedPostIts()
+{
+ bool bRemoved = false;
+ for(std::list<SwSidebarItem*>::iterator i = mvPostItFlds.begin(); i != mvPostItFlds.end(); )
+ {
+ std::list<SwSidebarItem*>::iterator it = i++;
+ if ( !(*it)->UseElement() )
+ {
+ SwSidebarItem* p = (*it);
+ mvPostItFlds.remove(*it);
+ if (GetActiveSidebarWin() == p->pPostIt)
+ SetActiveSidebarWin(0);
+ if (p->pPostIt)
+ delete p->pPostIt;
+ delete p;
+ bRemoved = true;
+ }
+ }
+
+ if ( bRemoved )
+ {
+ // make sure that no deleted items remain in page lists
+ // todo: only remove deleted ones?!
+ if ( mvPostItFlds.empty() )
+ {
+ PreparePageContainer();
+ PrepareView();
+ }
+ else
+ // if postits are their make sure that page lists are not empty
+ // otherwise sudden paints can cause pain (in BorderOverPageBorder)
+ CalcRects();
+ }
+}
+
+void SwPostItMgr::InsertItem(SfxBroadcaster* pItem, bool bCheckExistance, bool bFocus)
+{
+ if (bCheckExistance)
+ {
+ for(std::list<SwSidebarItem*>::iterator i = mvPostItFlds.begin(); i != mvPostItFlds.end() ; ++i)
+ {
+ if ( (*i)->GetBroadCaster() == pItem )
+ return;
+ }
+ }
+ mbLayout = bFocus;
+ if (pItem->ISA(SwFmtFld))
+ mvPostItFlds.push_back(new SwAnnotationItem(static_cast<SwFmtFld&>(*pItem), true, bFocus) );
+ OSL_ENSURE(pItem->ISA(SwFmtFld),"Mgr::InsertItem: seems like new stuff was added");
+ StartListening(*pItem);
+}
+
+void SwPostItMgr::RemoveItem( SfxBroadcaster* pBroadcast )
+{
+ EndListening(*pBroadcast);
+ for(std::list<SwSidebarItem*>::iterator i = mvPostItFlds.begin(); i != mvPostItFlds.end() ; ++i)
+ {
+ if ( (*i)->GetBroadCaster() == pBroadcast )
+ {
+ SwSidebarItem* p = (*i);
+ if (GetActiveSidebarWin() == p->pPostIt)
+ SetActiveSidebarWin(0);
+ mvPostItFlds.remove(*i);
+ delete p->pPostIt;
+ delete p;
+ break;
+ }
+ }
+ mbLayout = true;
+ PrepareView();
+}
+
+void SwPostItMgr::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
+{
+ if ( rHint.IsA(TYPE(SfxEventHint) ) )
+ {
+ sal_uInt32 nId = ((SfxEventHint&)rHint).GetEventId();
+ if ( nId == SW_EVENT_LAYOUT_FINISHED )
+ {
+ if ( !mbWaitingForCalcRects && !mvPostItFlds.empty())
+ {
+ mbWaitingForCalcRects = true;
+ mnEventId = Application::PostUserEvent( LINK( this, SwPostItMgr, CalcHdl), 0 );
+ }
+ }
+ }
+ else if ( rHint.IsA(TYPE(SfxSimpleHint) ) )
+ {
+ sal_uInt32 nId = ((SfxSimpleHint&)rHint).GetId();
+ switch ( nId )
+ {
+ case SFX_HINT_MODECHANGED:
+ {
+ if ( mbReadOnly != !!(mpView->GetDocShell()->IsReadOnly()) )
+ {
+ mbReadOnly = !mbReadOnly;
+ SetReadOnlyState();
+ mbLayout = true;
+ }
+ break;
+ }
+ case SFX_HINT_DOCCHANGED:
+ {
+ if ( mpView->GetDocShell() == &rBC )
+ {
+ if ( !mbWaitingForCalcRects && !mvPostItFlds.empty())
+ {
+ mbWaitingForCalcRects = true;
+ mnEventId = Application::PostUserEvent( LINK( this, SwPostItMgr, CalcHdl), 0 );
+ }
+ }
+ break;
+ }
+ case SFX_HINT_USER04:
+ {
+ // if we are in a SplitNode/Cut operation, do not delete note and then add again, as this will flicker
+ mbDeleteNote = !mbDeleteNote;
+ break;
+ }
+ case SFX_HINT_DYING:
+ {
+ if ( mpView->GetDocShell() != &rBC )
+ {
+ // field to be removed is the broadcaster
+ OSL_FAIL("Notification for removed SwFmtFld was not sent!");
+ RemoveItem(&rBC);
+ }
+ break;
+ }
+ }
+ }
+ else if ( rHint.IsA(TYPE(SwFmtFldHint) ) )
+ {
+ const SwFmtFldHint& rFmtHint = static_cast<const SwFmtFldHint&>(rHint);
+ SwFmtFld* pFld = const_cast <SwFmtFld*>( rFmtHint.GetField() );
+ switch ( rFmtHint.Which() )
+ {
+ case SWFMTFLD_INSERTED :
+ {
+ if (!pFld)
+ {
+ AddPostIts(true);
+ break;
+ }
+ // get field to be inserted from hint
+ if ( pFld->IsFldInDoc() )
+ {
+ bool bEmpty = !HasNotes();
+ InsertItem( pFld, true, false );
+ if (bEmpty && !mvPostItFlds.empty())
+ PrepareView(true);
+ }
+ else
+ {
+ OSL_FAIL("Inserted field not in document!" );
+ }
+ break;
+ }
+ case SWFMTFLD_REMOVED:
+ {
+ if (mbDeleteNote)
+ {
+ if (!pFld)
+ {
+ CheckForRemovedPostIts();
+ break;
+ }
+ RemoveItem(pFld);
+ }
+ break;
+ }
+ case SWFMTFLD_FOCUS:
+ {
+ if (rFmtHint.GetView()== mpView)
+ Focus(rBC);
+ break;
+ }
+ case SWFMTFLD_CHANGED:
+ {
+ SwFmtFld* pFmtFld = dynamic_cast<SwFmtFld*>(&rBC);
+ for(std::list<SwSidebarItem*>::iterator i = mvPostItFlds.begin(); i != mvPostItFlds.end() ; ++i)
+ {
+ if ( pFmtFld == (*i)->GetBroadCaster() )
+ {
+ if ((*i)->pPostIt)
+ {
+ (*i)->pPostIt->SetPostItText();
+ mbLayout = true;
+ }
+ break;
+ }
+ }
+ break;
+ }
+
+ case SWFMTFLD_LANGUAGE:
+ {
+ SwFmtFld* pFmtFld = dynamic_cast<SwFmtFld*>(&rBC);
+ for(std::list<SwSidebarItem*>::iterator i = mvPostItFlds.begin(); i != mvPostItFlds.end() ; ++i)
+ {
+ if ( pFmtFld == (*i)->GetBroadCaster() )
+ {
+ if ((*i)->pPostIt)
+ {
+ const sal_uInt16 nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( (*i)->GetFmtFld().GetField()->GetLanguage() );
+ sal_uInt16 nLangWhichId = 0;
+ switch (nScriptType)
+ {
+ case SCRIPTTYPE_LATIN : nLangWhichId = EE_CHAR_LANGUAGE ; break;
+ case SCRIPTTYPE_ASIAN : nLangWhichId = EE_CHAR_LANGUAGE_CJK; break;
+ case SCRIPTTYPE_COMPLEX : nLangWhichId = EE_CHAR_LANGUAGE_CTL; break;
+ }
+ (*i)->pPostIt->SetLanguage(
+ SvxLanguageItem(
+ (*i)->GetFmtFld().GetField()->GetLanguage(),
+ nLangWhichId) );
+ }
+ break;
+ }
+ }
+ break;
+ }
+ }
+ }
+}
+
+void SwPostItMgr::Focus(SfxBroadcaster& rBC)
+{
+ if (!mpWrtShell->GetViewOptions()->IsPostIts())
+ {
+ SfxRequest aRequest(mpView->GetViewFrame(),FN_VIEW_NOTES);
+ mpView->ExecViewOptions(aRequest);
+ }
+
+ for(std::list<SwSidebarItem*>::iterator i = mvPostItFlds.begin(); i != mvPostItFlds.end() ; ++i)
+ {
+ // field to get the focus is the broadcaster
+ if ( &rBC == (*i)->GetBroadCaster() )
+ {
+ if ((*i)->pPostIt)
+ {
+ (*i)->pPostIt->GrabFocus();
+ MakeVisible((*i)->pPostIt);
+ }
+ else
+ {
+ // when the layout algorithm starts, this postit is created and receives focus
+ (*i)->bFocus = true;
+ }
+ }
+ }
+}
+
+bool SwPostItMgr::CalcRects()
+{
+ if ( mnEventId )
+ {
+ // if CalcRects() was forced and an event is still pending: remove it
+ // it is superfluous and also may cause reentrance problems if triggered while layouting
+ Application::RemoveUserEvent( mnEventId );
+ mnEventId = 0;
+ }
+
+ bool bChange = false;
+ bool bRepair = false;
+ PreparePageContainer();
+ if ( !mvPostItFlds.empty() )
+ {
+ for(std::list<SwSidebarItem*>::iterator i = mvPostItFlds.begin(); i != mvPostItFlds.end() ; ++i)
+ {
+ SwSidebarItem* pItem = (*i);
+ if ( !pItem->UseElement() )
+ {
+ OSL_FAIL("PostIt is not in doc or other wrong use");
+ bRepair = true;
+ continue;
+ }
+
+ const SwRect aOldAnchorRect( pItem->maLayoutInfo.mPosition );
+ const SwPostItHelper::SwLayoutStatus eOldLayoutStatus = pItem->mLayoutStatus;
+ const sal_uLong nOldStartNodeIdx( pItem->maLayoutInfo.mnStartNodeIdx );
+ const sal_Int32 nOldStartContent( pItem->maLayoutInfo.mnStartContent );
+ {
+ // update layout information
+ const SwTxtAnnotationFld* pTxtAnnotationFld =
+ dynamic_cast< const SwTxtAnnotationFld* >( pItem->GetFmtFld().GetTxtFld() );
+ const ::sw::mark::IMark* pAnnotationMark =
+ pTxtAnnotationFld != NULL ? pTxtAnnotationFld->GetAnnotationMark() : NULL;
+ if ( pAnnotationMark != NULL )
+ {
+ pItem->mLayoutStatus =
+ SwPostItHelper::getLayoutInfos(
+ pItem->maLayoutInfo,
+ pItem->GetAnchorPosition(),
+ &pAnnotationMark->GetMarkStart() );
+ }
+ else
+ {
+ pItem->mLayoutStatus =
+ SwPostItHelper::getLayoutInfos( pItem->maLayoutInfo, pItem->GetAnchorPosition() );
+ }
+ }
+ bChange = bChange
+ || pItem->maLayoutInfo.mPosition != aOldAnchorRect
+ || pItem->mLayoutStatus != eOldLayoutStatus
+ || pItem->maLayoutInfo.mnStartNodeIdx != nOldStartNodeIdx
+ || pItem->maLayoutInfo.mnStartContent != nOldStartContent;
+ }
+
+ // show notes in right order in navigator
+ //prevent Anchors during layout to overlap, e.g. when moving a frame
+ Sort(SORT_POS);
+
+ // sort the items into the right page vector, so layout can be done by page
+ for(std::list<SwSidebarItem*>::iterator i = mvPostItFlds.begin(); i != mvPostItFlds.end() ; ++i)
+ {
+ SwSidebarItem* pItem = (*i);
+ if( SwPostItHelper::INVISIBLE == pItem->mLayoutStatus )
+ {
+ if (pItem->pPostIt)
+ pItem->pPostIt->HideNote();
+ continue;
+ }
+
+ if( SwPostItHelper::HIDDEN == pItem->mLayoutStatus )
+ {
+ if (!mpWrtShell->GetViewOptions()->IsShowHiddenChar())
+ {
+ if (pItem->pPostIt)
+ pItem->pPostIt->HideNote();
+ continue;
+ }
+ }
+
+ const unsigned long aPageNum = pItem->maLayoutInfo.mnPageNumber;
+ if (aPageNum > mPages.size())
+ {
+ const unsigned long nNumberOfPages = mPages.size();
+ for (unsigned int j=0; j<aPageNum - nNumberOfPages; ++j)
+ mPages.push_back( new SwPostItPageItem());
+ }
+ mPages[aPageNum-1]->mList->push_back(pItem);
+ mPages[aPageNum-1]->mPageRect = pItem->maLayoutInfo.mPageFrame;
+ mPages[aPageNum-1]->eSidebarPosition = pItem->maLayoutInfo.meSidebarPosition;
+ }
+
+ if (!bChange && mpWrtShell->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE))
+ {
+ long nLayoutHeight = SwPostItHelper::getLayoutHeight( mpWrtShell->GetLayout() );
+ if( nLayoutHeight > mbLayoutHeight )
+ {
+ if (mPages[0]->bScrollbar || HasScrollbars())
+ bChange = true;
+ }
+ else if( nLayoutHeight < mbLayoutHeight )
+ {
+ if (mPages[0]->bScrollbar || !BorderOverPageBorder(1))
+ bChange = true;
+ }
+ }
+ }
+
+ if ( bRepair )
+ CheckForRemovedPostIts();
+
+ mbLayoutHeight = SwPostItHelper::getLayoutHeight( mpWrtShell->GetLayout() );
+ mbWaitingForCalcRects = false;
+ return bChange;
+}
+
+bool SwPostItMgr::HasScrollbars() const
+{
+ for(std::list<SwSidebarItem*>::const_iterator i = mvPostItFlds.begin(); i != mvPostItFlds.end() ; ++i)
+ {
+ if ((*i)->bShow && (*i)->pPostIt && (*i)->pPostIt->HasScrollbar())
+ return true;
+ }
+ return false;
+}
+
+void SwPostItMgr::PreparePageContainer()
+{
+ // we do not just delete the SwPostItPageItem, so offset/scrollbar is not lost
+ long lPageSize = mpWrtShell->GetNumPages();
+ long lContainerSize = mPages.size();
+
+ if (lContainerSize < lPageSize)
+ {
+ for (int i=0; i<lPageSize - lContainerSize;i++)
+ mPages.push_back( new SwPostItPageItem());
+ }
+ else if (lContainerSize > lPageSize)
+ {
+ for (int i=mPages.size()-1; i >= lPageSize;--i)
+ {
+ delete mPages[i];
+ mPages.pop_back();
+ }
+ }
+ // only clear the list, DO NOT delete the objects itself
+ for(std::vector<SwPostItPageItem*>::iterator i = mPages.begin(); i != mPages.end() ; ++i)
+ {
+ (*i)->mList->clear();
+ if (mvPostItFlds.empty())
+ (*i)->bScrollbar = false;
+
+ }
+}
+
+void SwPostItMgr::LayoutPostIts()
+{
+ if ( !mvPostItFlds.empty() && !mbWaitingForCalcRects )
+ {
+ mbLayouting = true;
+
+ //loop over all pages and do the layout
+ // - create SwPostIt if necessary
+ // - place SwPostIts on their initial position
+ // - calculate necessary height for all PostIts together
+ bool bUpdate = false;
+ for (unsigned long n=0;n<mPages.size();n++)
+ {
+ // only layout if there are notes on this page
+ if (mPages[n]->mList->size()>0)
+ {
+ std::list<SwSidebarWin*> aVisiblePostItList;
+ unsigned long lNeededHeight = 0;
+ long mlPageBorder = 0;
+ long mlPageEnd = 0;
+
+ for(SwSidebarItem_iterator i = mPages[n]->mList->begin(); i != mPages[n]->mList->end(); ++i)
+ {
+ SwSidebarItem* pItem = (*i);
+ SwSidebarWin* pPostIt = pItem->pPostIt;
+
+ if (mPages[n]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT )
+ {
+ // x value for notes positioning
+ mlPageBorder = mpEditWin->LogicToPixel( Point( mPages[n]->mPageRect.Left(), 0)).X() - GetSidebarWidth(true);// - GetSidebarBorderWidth(true);
+ //bending point
+ mlPageEnd =
+ mpWrtShell->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE)
+ ? pItem->maLayoutInfo.mPagePrtArea.Left()
+ : mPages[n]->mPageRect.Left() + 350;
+ }
+ else if (mPages[n]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_RIGHT )
+ {
+ // x value for notes positioning
+ mlPageBorder = mpEditWin->LogicToPixel( Point(mPages[n]->mPageRect.Right(), 0)).X() + GetSidebarBorderWidth(true);
+ //bending point
+ mlPageEnd =
+ mpWrtShell->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE)
+ ? pItem->maLayoutInfo.mPagePrtArea.Right() :
+ mPages[n]->mPageRect.Right() - 350;
+ }
+
+ if (pItem->bShow)
+ {
+ long Y = mpEditWin->LogicToPixel( Point(0,pItem->maLayoutInfo.mPosition.Bottom())).Y();
+ long aPostItHeight = 0;
+ if (!pPostIt)
+ {
+ pPostIt = (*i)->GetSidebarWindow( mpView->GetEditWin(),
+ WB_DIALOGCONTROL,
+ *this,
+ 0 );
+ pPostIt->InitControls();
+ pPostIt->SetReadonly(mbReadOnly);
+ pItem->pPostIt = pPostIt;
+ if (mpAnswer)
+ {
+ if (pPostIt->CalcFollow()) //do we really have another note in front of this one
+ static_cast<sw::annotation::SwAnnotationWin*>(pPostIt)->InitAnswer(mpAnswer);
+ delete mpAnswer;
+ mpAnswer = 0;
+ }
+ }
+
+ pPostIt->SetChangeTracking(
+ pItem->mLayoutStatus,
+ GetColorAnchor(pItem->maLayoutInfo.mRedlineAuthor));
+ pPostIt->SetSidebarPosition(mPages[n]->eSidebarPosition);
+ pPostIt->SetFollow(pPostIt->CalcFollow());
+ aPostItHeight = ( pPostIt->GetPostItTextHeight() < pPostIt->GetMinimumSizeWithoutMeta()
+ ? pPostIt->GetMinimumSizeWithoutMeta()
+ : pPostIt->GetPostItTextHeight() )
+ + pPostIt->GetMetaHeight();
+ pPostIt->SetPosSizePixelRect( mlPageBorder ,
+ Y - GetInitialAnchorDistance(),
+ GetNoteWidth() ,
+ aPostItHeight,
+ pItem->maLayoutInfo.mPosition,
+ mlPageEnd );
+ pPostIt->ChangeSidebarItem( *pItem );
+
+ if (pItem->bFocus)
+ {
+ mbLayout = true;
+ pPostIt->GrabFocus();
+ pItem->bFocus = false;
+ }
+ // only the visible postits are used for the final layout
+ aVisiblePostItList.push_back(pPostIt);
+ lNeededHeight += pPostIt->IsFollow() ? aPostItHeight : aPostItHeight+GetSpaceBetween();
+ }
+ else // we don't want to see it
+ {
+ if (pPostIt)
+ pPostIt->HideNote();
+ }
+ }
+
+ if ((!aVisiblePostItList.empty()) && ShowNotes())
+ {
+ bool bOldScrollbar = mPages[n]->bScrollbar;
+ if (ShowNotes())
+ mPages[n]->bScrollbar = LayoutByPage(aVisiblePostItList, mPages[n]->mPageRect.SVRect(), lNeededHeight);
+ else
+ mPages[n]->bScrollbar = false;
+ if (!mPages[n]->bScrollbar)
+ {
+ mPages[n]->lOffset = 0;
+ }
+ else
+ {
+ //when we changed our zoom level, the offset value can be to big, so lets check for the largest possible zoom value
+ long aAvailableHeight = mpEditWin->LogicToPixel(Size(0,mPages[n]->mPageRect.Height())).Height() - 2 * GetSidebarScrollerHeight();
+ long lOffset = -1 * GetScrollSize() * (aVisiblePostItList.size() - aAvailableHeight / GetScrollSize());
+ if (mPages[n]->lOffset < lOffset)
+ mPages[n]->lOffset = lOffset;
+ }
+ bUpdate = (bOldScrollbar != mPages[n]->bScrollbar) || bUpdate;
+ const long aSidebarheight = mPages[n]->bScrollbar ? mpEditWin->PixelToLogic(Size(0,GetSidebarScrollerHeight())).Height() : 0;
+ /*
+ TODO
+ - enlarge all notes till GetNextBorder(), as we resized to average value before
+ */
+ //lets hide the ones which overlap the page
+ for(SwSidebarWin_iterator i = aVisiblePostItList.begin(); i != aVisiblePostItList.end() ; ++i)
+ {
+ if (mPages[n]->lOffset != 0)
+ (*i)->TranslateTopPosition(mPages[n]->lOffset);
+
+ bool bBottom = mpEditWin->PixelToLogic(Point(0,(*i)->VirtualPos().Y()+(*i)->VirtualSize().Height())).Y() <= (mPages[n]->mPageRect.Bottom()-aSidebarheight);
+ bool bTop = mpEditWin->PixelToLogic(Point(0,(*i)->VirtualPos().Y())).Y() >= (mPages[n]->mPageRect.Top()+aSidebarheight);
+ if ( bBottom && bTop )
+ {
+ (*i)->ShowNote();
+ }
+ else
+ {
+ if (mpEditWin->PixelToLogic(Point(0,(*i)->VirtualPos().Y())).Y() < (mPages[n]->mPageRect.Top()+aSidebarheight))
+ {
+ if ( mPages[n]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT )
+ (*i)->ShowAnchorOnly(Point( mPages[n]->mPageRect.Left(),
+ mPages[n]->mPageRect.Top()));
+ else if ( mPages[n]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_RIGHT )
+ (*i)->ShowAnchorOnly(Point( mPages[n]->mPageRect.Right(),
+ mPages[n]->mPageRect.Top()));
+ }
+ else
+ {
+ if ( mPages[n]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT )
+ (*i)->ShowAnchorOnly(Point(mPages[n]->mPageRect.Left(),
+ mPages[n]->mPageRect.Bottom()));
+ else if ( mPages[n]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_RIGHT )
+ (*i)->ShowAnchorOnly(Point(mPages[n]->mPageRect.Right(),
+ mPages[n]->mPageRect.Bottom()));
+ }
+ OSL_ENSURE(mPages[n]->bScrollbar,"SwPostItMgr::LayoutByPage(): note overlaps, but bScrollbar is not true");
+ }
+ }
+ }
+ else
+ {
+ for(SwSidebarWin_iterator i = aVisiblePostItList.begin(); i != aVisiblePostItList.end() ; ++i)
+ (*i)->SetPosAndSize();
+
+ bool bOldScrollbar = mPages[n]->bScrollbar;
+ mPages[n]->bScrollbar = false;
+ bUpdate = (bOldScrollbar != mPages[n]->bScrollbar) || bUpdate;
+ }
+ aVisiblePostItList.clear();
+ }
+ else
+ {
+ bUpdate = true;
+ mPages[n]->bScrollbar = false;
+ }
+ }
+
+ if (!ShowNotes())
+ { // we do not want to see the notes anymore -> Options-Writer-View-Notes
+ bool bRepair = false;
+ for(SwSidebarItem_iterator i = mvPostItFlds.begin(); i != mvPostItFlds.end() ; ++i)
+ {
+ SwSidebarItem* pItem = (*i);
+ if ( !pItem->UseElement() )
+ {
+ OSL_FAIL("PostIt is not in doc!");
+ bRepair = true;
+ continue;
+ }
+
+ if ((*i)->pPostIt)
+ {
+ (*i)->pPostIt->HideNote();
+ if ((*i)->pPostIt->HasChildPathFocus())
+ {
+ SetActiveSidebarWin(0);
+ (*i)->pPostIt->GrabFocusToDocument();
+ }
+ }
+ }
+
+ if ( bRepair )
+ CheckForRemovedPostIts();
+ }
+
+ // notes scrollbar is otherwise not drawn correctly for some cases
+ // scrollbar area is enough
+ if (bUpdate)
+ mpEditWin->Invalidate();
+ mbLayouting = false;
+ }
+}
+
+bool SwPostItMgr::BorderOverPageBorder(unsigned long aPage) const
+{
+ if ( mPages[aPage-1]->mList->empty() )
+ {
+ OSL_FAIL("Notes SidePane painted but no rects and page lists calculated!");
+ return false;
+ }
+
+ SwSidebarItem_iterator aItem = mPages[aPage-1]->mList->end();
+ --aItem;
+ OSL_ENSURE ((*aItem)->pPostIt,"BorderOverPageBorder: NULL postIt, should never happen");
+ if ((*aItem)->pPostIt)
+ {
+ const long aSidebarheight = mPages[aPage-1]->bScrollbar ? mpEditWin->PixelToLogic(Size(0,GetSidebarScrollerHeight())).Height() : 0;
+ const long aEndValue = mpEditWin->PixelToLogic(Point(0,(*aItem)->pPostIt->GetPosPixel().Y()+(*aItem)->pPostIt->GetSizePixel().Height())).Y();
+ return aEndValue <= mPages[aPage-1]->mPageRect.Bottom()-aSidebarheight;
+ }
+ else
+ return false;
+}
+
+void SwPostItMgr::Scroll(const long lScroll,const unsigned long aPage)
+{
+ OSL_ENSURE((lScroll % GetScrollSize() )==0,"SwPostItMgr::Scroll: scrolling by wrong value");
+ // do not scroll more than necessary up or down
+ if ( ((mPages[aPage-1]->lOffset == 0) && (lScroll>0)) || ( BorderOverPageBorder(aPage) && (lScroll<0)) )
+ return;
+
+ const bool bOldUp = ArrowEnabled(KEY_PAGEUP,aPage);
+ const bool bOldDown = ArrowEnabled(KEY_PAGEDOWN,aPage);
+ const long aSidebarheight = mpEditWin->PixelToLogic(Size(0,GetSidebarScrollerHeight())).Height();
+ for(SwSidebarItem_iterator i = mPages[aPage-1]->mList->begin(); i != mPages[aPage-1]->mList->end(); ++i)
+ {
+ SwSidebarWin* pPostIt = (*i)->pPostIt;
+ // if this is an answer, we should take the normal position and not the real, slightly moved position
+ pPostIt->SetVirtualPosSize(pPostIt->GetPosPixel(),pPostIt->GetSizePixel());
+ pPostIt->TranslateTopPosition(lScroll);
+
+ if ((*i)->bShow)
+ {
+ bool bBottom = mpEditWin->PixelToLogic(Point(0,pPostIt->VirtualPos().Y()+pPostIt->VirtualSize().Height())).Y() <= (mPages[aPage-1]->mPageRect.Bottom()-aSidebarheight);
+ bool bTop = mpEditWin->PixelToLogic(Point(0,pPostIt->VirtualPos().Y())).Y() >= (mPages[aPage-1]->mPageRect.Top()+aSidebarheight);
+ if ( bBottom && bTop)
+ {
+ pPostIt->ShowNote();
+ }
+ else
+ {
+ if ( mpEditWin->PixelToLogic(Point(0,pPostIt->VirtualPos().Y())).Y() < (mPages[aPage-1]->mPageRect.Top()+aSidebarheight))
+ {
+ if (mPages[aPage-1]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT)
+ pPostIt->ShowAnchorOnly(Point(mPages[aPage-1]->mPageRect.Left(),mPages[aPage-1]->mPageRect.Top()));
+ else if (mPages[aPage-1]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_RIGHT)
+ pPostIt->ShowAnchorOnly(Point(mPages[aPage-1]->mPageRect.Right(),mPages[aPage-1]->mPageRect.Top()));
+ }
+ else
+ {
+ if (mPages[aPage-1]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT)
+ pPostIt->ShowAnchorOnly(Point(mPages[aPage-1]->mPageRect.Left(),mPages[aPage-1]->mPageRect.Bottom()));
+ else if (mPages[aPage-1]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_RIGHT)
+ pPostIt->ShowAnchorOnly(Point(mPages[aPage-1]->mPageRect.Right(),mPages[aPage-1]->mPageRect.Bottom()));
+ }
+ }
+ }
+ }
+ mPages[aPage-1]->lOffset += lScroll;
+ if ( (bOldUp != ArrowEnabled(KEY_PAGEUP,aPage)) ||(bOldDown != ArrowEnabled(KEY_PAGEDOWN,aPage)) )
+ {
+ mpEditWin->Invalidate(GetBottomScrollRect(aPage));
+ mpEditWin->Invalidate(GetTopScrollRect(aPage));
+ }
+}
+
+void SwPostItMgr::AutoScroll(const SwSidebarWin* pPostIt,const unsigned long aPage )
+{
+ // otherwise all notes are visible
+ if (mPages[aPage-1]->bScrollbar)
+ {
+ const long aSidebarheight = mpEditWin->PixelToLogic(Size(0,GetSidebarScrollerHeight())).Height();
+ const bool bBottom = mpEditWin->PixelToLogic(Point(0,pPostIt->GetPosPixel().Y()+pPostIt->GetSizePixel().Height())).Y() <= (mPages[aPage-1]->mPageRect.Bottom()-aSidebarheight);
+ const bool bTop = mpEditWin->PixelToLogic(Point(0,pPostIt->GetPosPixel().Y())).Y() >= (mPages[aPage-1]->mPageRect.Top()+aSidebarheight);
+ if ( !(bBottom && bTop))
+ {
+ const long aDiff = bBottom ? mpEditWin->LogicToPixel(Point(0,mPages[aPage-1]->mPageRect.Top() + aSidebarheight)).Y() - pPostIt->GetPosPixel().Y() :
+ mpEditWin->LogicToPixel(Point(0,mPages[aPage-1]->mPageRect.Bottom() - aSidebarheight)).Y() - (pPostIt->GetPosPixel().Y()+pPostIt->GetSizePixel().Height());
+ // this just adds the missing value to get the next a* GetScrollSize() after aDiff
+ // e.g aDiff= 61 POSTIT_SCOLL=50 --> lScroll = 100
+ const long lScroll = bBottom ? (aDiff + ( GetScrollSize() - (aDiff % GetScrollSize()))) : (aDiff - (GetScrollSize() + (aDiff % GetScrollSize())));
+ Scroll(lScroll, aPage);
+ }
+ }
+}
+
+void SwPostItMgr::MakeVisible(const SwSidebarWin* pPostIt,long aPage )
+{
+ if (aPage == -1)
+ {
+ // we dont know the page yet, lets find it ourselves
+ for (unsigned long n=0;n<mPages.size();n++)
+ {
+ if (mPages[n]->mList->size()>0)
+ {
+ for(SwSidebarItem_iterator i = mPages[n]->mList->begin(); i != mPages[n]->mList->end(); ++i)
+ {
+ if ((*i)->pPostIt==pPostIt)
+ {
+ aPage = n+1;
+ break;
+ }
+ }
+ }
+ }
+ }
+ if (aPage!=-1)
+ AutoScroll(pPostIt,aPage);
+ Rectangle aNoteRect (Point(pPostIt->GetPosPixel().X(),pPostIt->GetPosPixel().Y()-5),pPostIt->GetSizePixel());
+ if (!aNoteRect.IsEmpty())
+ mpWrtShell->MakeVisible(SwRect(mpEditWin->PixelToLogic(aNoteRect)));
+}
+
+bool SwPostItMgr::ArrowEnabled(sal_uInt16 aDirection,unsigned long aPage) const
+{
+ switch (aDirection)
+ {
+ case KEY_PAGEUP:
+ {
+ return (mPages[aPage-1]->lOffset != 0);
+ }
+ case KEY_PAGEDOWN:
+ {
+ return (!BorderOverPageBorder(aPage));
+ }
+ default: return false;
+ }
+}
+
+Color SwPostItMgr::GetArrowColor(sal_uInt16 aDirection,unsigned long aPage) const
+{
+ if (ArrowEnabled(aDirection,aPage))
+ {
+ if (Application::GetSettings().GetStyleSettings().GetHighContrastMode())
+ return Color(COL_WHITE);
+ else
+ return COL_NOTES_SIDEPANE_ARROW_ENABLED;
+ }
+ else
+ {
+ return COL_NOTES_SIDEPANE_ARROW_DISABLED;
+ }
+}
+
+bool SwPostItMgr::LayoutByPage(std::list<SwSidebarWin*> &aVisiblePostItList,const Rectangle aBorder, long lNeededHeight)
+{
+ /*** General layout idea:***/
+ // - if we have space left, we always move the current one up,
+ // otherwise the next one down
+ // - first all notes are resized
+ // - then the real layout starts
+ /*************************************************************/
+
+ //rBorder is the page rect
+ const Rectangle rBorder = mpEditWin->LogicToPixel( aBorder);
+ long lTopBorder = rBorder.Top() + 5;
+ long lBottomBorder = rBorder.Bottom() - 5;
+ const long lVisibleHeight = lBottomBorder - lTopBorder; //rBorder.GetHeight() ;
+ long lTranslatePos = 0;
+ bool bScrollbars = false;
+
+ // do all necessary resizings
+ if (lVisibleHeight < lNeededHeight)
+ {
+ // ok, now we have to really resize and adding scrollbars
+ const long lAverageHeight = (lVisibleHeight - aVisiblePostItList.size()*GetSpaceBetween()) / aVisiblePostItList.size();
+ if (lAverageHeight<GetMinimumSizeWithMeta())
+ {
+ bScrollbars = true;
+ lTopBorder += GetSidebarScrollerHeight() + 10;
+ lBottomBorder -= (GetSidebarScrollerHeight() + 10);
+ for(SwSidebarWin_iterator i = aVisiblePostItList.begin(); i != aVisiblePostItList.end() ; ++i)
+ (*i)->SetSize(Size((*i)->VirtualSize().getWidth(),(*i)->GetMinimumSizeWithMeta()));
+ }
+ else
+ {
+ for(SwSidebarWin_iterator i = aVisiblePostItList.begin(); i != aVisiblePostItList.end() ; ++i)
+ {
+ if ( (*i)->VirtualSize().getHeight() > lAverageHeight)
+ (*i)->SetSize(Size((*i)->VirtualSize().getWidth(),lAverageHeight));
+ }
+ }
+ }
+
+ //start the real layout so nothing overlaps anymore
+ if (aVisiblePostItList.size()>1)
+ {
+ long lSpaceUsed = 0;
+ int loop = 0;
+ bool bDone = false;
+ // if no window is moved anymore we are finished
+ while (!bDone)
+ {
+ loop++;
+ bDone = true;
+ lSpaceUsed = lTopBorder + GetSpaceBetween();
+ for(SwSidebarWin_iterator i = aVisiblePostItList.begin(); i != aVisiblePostItList.end() ; ++i)
+ {
+ SwSidebarWin_iterator aNextPostIt = i;
+ ++aNextPostIt;
+
+ if (aNextPostIt != aVisiblePostItList.end())
+ {
+ lTranslatePos = ( (*i)->VirtualPos().Y() + (*i)->VirtualSize().Height()) - (*aNextPostIt)->VirtualPos().Y();
+ if (lTranslatePos > 0) // note windows overlaps the next one
+ {
+ // we are not done yet, loop at least once more
+ bDone = false;
+ // if there is space left, move the current note up
+ // it could also happen that there is no space left for the first note due to a scrollbar
+ // then we also jump into, so we move the current one up and the next one down
+ if ( (lSpaceUsed <= (*i)->VirtualPos().Y()) || (i==aVisiblePostItList.begin()))
+ {
+ // we have space left, so let's move the current one up
+ if ( ((*i)->VirtualPos().Y()- lTranslatePos - GetSpaceBetween()) > lTopBorder)
+ {
+ if ((*aNextPostIt)->IsFollow())
+ (*i)->TranslateTopPosition(-1*(lTranslatePos+ANCHORLINE_WIDTH));
+ else
+ (*i)->TranslateTopPosition(-1*(lTranslatePos+GetSpaceBetween()));
+ }
+ else
+ {
+ long lMoveUp = (*i)->VirtualPos().Y() - lTopBorder;
+ (*i)->TranslateTopPosition(-1* lMoveUp);
+ if ((*aNextPostIt)->IsFollow())
+ (*aNextPostIt)->TranslateTopPosition( (lTranslatePos+ANCHORLINE_WIDTH) - lMoveUp);
+ else
+ (*aNextPostIt)->TranslateTopPosition( (lTranslatePos+GetSpaceBetween()) - lMoveUp);
+ }
+ }
+ else
+ {
+ // no space left, left move the next one down
+ if ((*aNextPostIt)->IsFollow())
+ (*aNextPostIt)->TranslateTopPosition(lTranslatePos+ANCHORLINE_WIDTH);
+ else
+ (*aNextPostIt)->TranslateTopPosition(lTranslatePos+GetSpaceBetween());
+ }
+ }
+ else
+ {
+ // the first one could overlap the topborder instead of a second note
+ if (i==aVisiblePostItList.begin())
+ {
+ long lMoveDown = lTopBorder - (*i)->VirtualPos().Y();
+ if (lMoveDown>0)
+ {
+ bDone = false;
+ (*i)->TranslateTopPosition( lMoveDown);
+ }
+ }
+ }
+ if ( (*aNextPostIt)->IsFollow() )
+ lSpaceUsed += (*i)->VirtualSize().Height() + ANCHORLINE_WIDTH;
+ else
+ lSpaceUsed += (*i)->VirtualSize().Height() + GetSpaceBetween();
+ }
+ else
+ {
+ //(*i) is the last visible item
+ SwSidebarWin_iterator aPrevPostIt = i;
+ --aPrevPostIt;
+ lTranslatePos = ( (*aPrevPostIt)->VirtualPos().Y() + (*aPrevPostIt)->VirtualSize().Height() ) - (*i)->VirtualPos().Y();
+ if (lTranslatePos > 0)
+ {
+ bDone = false;
+ if ( ((*i)->VirtualPos().Y()+ (*i)->VirtualSize().Height()+lTranslatePos) < lBottomBorder)
+ {
+ if ( (*i)->IsFollow() )
+ (*i)->TranslateTopPosition(lTranslatePos+ANCHORLINE_WIDTH);
+ else
+ (*i)->TranslateTopPosition(lTranslatePos+GetSpaceBetween());
+ }
+ else
+ {
+ (*i)->TranslateTopPosition(lBottomBorder - ((*i)->VirtualPos().Y()+ (*i)->VirtualSize().Height()) );
+ }
+ }
+ else
+ {
+ // note does not overlap, but we might be over the lower border
+ // only do this if there are no scrollbars, otherwise notes are supposed to overlap the border
+ if (!bScrollbars && ((*i)->VirtualPos().Y()+ (*i)->VirtualSize().Height() > lBottomBorder) )
+ {
+ bDone = false;
+ (*i)->TranslateTopPosition(lBottomBorder - ((*i)->VirtualPos().Y()+ (*i)->VirtualSize().Height()));
+ }
+ }
+ }
+ }
+ // security check so we don't loop forever
+ if (loop>MAX_LOOP_COUNT)
+ {
+ OSL_FAIL("PostItMgr::Layout(): We are looping forever");
+ break;
+ }
+ }
+ }
+ else
+ {
+ // only one left, make sure it is not hidden at the top or bottom
+ SwSidebarWin_iterator i = aVisiblePostItList.begin();
+ lTranslatePos = lTopBorder - (*i)->VirtualPos().Y();
+ if (lTranslatePos>0)
+ {
+ (*i)->TranslateTopPosition(lTranslatePos+GetSpaceBetween());
+ }
+ lTranslatePos = lBottomBorder - ((*i)->VirtualPos().Y()+ (*i)->VirtualSize().Height());
+ if (lTranslatePos<0)
+ {
+ (*i)->TranslateTopPosition(lTranslatePos);
+ }
+ }
+ return bScrollbars;
+ }
+
+void SwPostItMgr::AddPostIts(bool bCheckExistance, bool bFocus)
+{
+ bool bEmpty = mvPostItFlds.empty();
+ SwFieldType* pType = mpView->GetDocShell()->GetDoc()->GetFldType(RES_POSTITFLD, OUString(),false);
+ SwIterator<SwFmtFld,SwFieldType> aIter( *pType );
+ SwFmtFld* pSwFmtFld = aIter.First();
+ while(pSwFmtFld)
+ {
+ if ( pSwFmtFld->GetTxtFld())
+ {
+ if ( pSwFmtFld->IsFldInDoc() )
+ InsertItem(pSwFmtFld,bCheckExistance,bFocus);
+ }
+ pSwFmtFld = aIter.Next();
+ }
+
+ // if we just added the first one we have to update the view for centering
+ if (bEmpty && !mvPostItFlds.empty())
+ PrepareView(true);
+}
+
+void SwPostItMgr::RemoveSidebarWin()
+{
+ if (!mvPostItFlds.empty())
+ {
+ for(std::list<SwSidebarItem*>::iterator i = mvPostItFlds.begin(); i != mvPostItFlds.end() ; ++i)
+ {
+ EndListening( *(const_cast<SfxBroadcaster*>((*i)->GetBroadCaster())) );
+ if ((*i)->pPostIt)
+ delete (*i)->pPostIt;
+ delete (*i);
+ }
+ mvPostItFlds.clear();
+ }
+
+ // all postits removed, no items should be left in pages
+ PreparePageContainer();
+}
+
+// copy to new vector, otherwise RemoveItem would operate and delete stuff on mvPostItFlds as well
+// RemoveItem will clean up the core field and visible postit if necessary
+// we cannot just delete everything as before, as postits could move into change tracking
+void SwPostItMgr::Delete(OUString aAuthor)
+{
+ mpWrtShell->StartAllAction();
+ if ( HasActiveSidebarWin() && (GetActiveSidebarWin()->GetAuthor()==aAuthor) )
+ {
+ SetActiveSidebarWin(0);
+ }
+ SwRewriter aRewriter;
+ aRewriter.AddRule(UndoArg1, SW_RESSTR(STR_DELETE_AUTHOR_NOTES) + aAuthor);
+ mpWrtShell->StartUndo( UNDO_DELETE, &aRewriter );
+
+ std::vector<const SwFmtFld*> aTmp;
+ aTmp.reserve( mvPostItFlds.size() );
+ for(std::list<SwSidebarItem*>::iterator pPostIt = mvPostItFlds.begin(); pPostIt!= mvPostItFlds.end() ; ++pPostIt)
+ {
+ if (((*pPostIt)->pPostIt->GetAuthor() == aAuthor) )
+ aTmp.push_back( &(*pPostIt)->GetFmtFld() );
+ }
+ for(std::vector<const SwFmtFld*>::iterator i = aTmp.begin(); i != aTmp.end() ; ++i)
+ {
+ mpWrtShell->GotoField( *(*i) );
+ mpWrtShell->DelRight();
+ }
+ mpWrtShell->EndUndo();
+ PrepareView();
+ mpWrtShell->EndAllAction();
+ mbLayout = true;
+ CalcRects();
+ LayoutPostIts();
+}
+
+void SwPostItMgr::Delete()
+{
+ mpWrtShell->StartAllAction();
+ SetActiveSidebarWin(0);
+ SwRewriter aRewriter;
+ aRewriter.AddRule(UndoArg1, SW_RES(STR_DELETE_ALL_NOTES) );
+ mpWrtShell->StartUndo( UNDO_DELETE, &aRewriter );
+
+ std::vector<const SwFmtFld*> aTmp;
+ aTmp.reserve( mvPostItFlds.size() );
+ for(std::list<SwSidebarItem*>::iterator pPostIt = mvPostItFlds.begin(); pPostIt!= mvPostItFlds.end() ; ++pPostIt)
+ {
+ aTmp.push_back( &(*pPostIt)->GetFmtFld() );
+ }
+ for(std::vector<const SwFmtFld*>::iterator i = aTmp.begin(); i != aTmp.end() ; ++i)
+ {
+ mpWrtShell->GotoField( *(*i) );
+ mpWrtShell->DelRight();
+ }
+
+ mpWrtShell->EndUndo();
+ PrepareView();
+ mpWrtShell->EndAllAction();
+ mbLayout = true;
+ CalcRects();
+ LayoutPostIts();
+}
+void SwPostItMgr::Hide( const OUString& rAuthor )
+{
+ for(SwSidebarItem_iterator i = mvPostItFlds.begin(); i != mvPostItFlds.end() ; ++i)
+ {
+ if ( (*i)->pPostIt && ((*i)->pPostIt->GetAuthor() == rAuthor) )
+ {
+ (*i)->bShow = false;
+ (*i)->pPostIt->HideNote();
+ }
+ }
+
+ LayoutPostIts();
+}
+
+void SwPostItMgr::Hide()
+{
+ for(SwSidebarItem_iterator i = mvPostItFlds.begin(); i != mvPostItFlds.end() ; ++i)
+ {
+ (*i)->bShow = false;
+ (*i)->pPostIt->HideNote();
+ }
+}
+
+void SwPostItMgr::Show()
+{
+ for(SwSidebarItem_iterator i = mvPostItFlds.begin(); i != mvPostItFlds.end() ; ++i)
+ {
+ (*i)->bShow = true;
+ }
+ LayoutPostIts();
+}
+
+void SwPostItMgr::Sort(const short aType)
+{
+ if (mvPostItFlds.size()>1 )
+ {
+ switch (aType)
+ {
+ case SORT_POS:
+ mvPostItFlds.sort(comp_pos);
+ break;
+ }
+ }
+}
+
+SwSidebarWin* SwPostItMgr::GetSidebarWin( const SfxBroadcaster* pBroadcaster) const
+{
+ for(const_iterator i = mvPostItFlds.begin(); i != mvPostItFlds.end() ; ++i)
+ {
+ if ( (*i)->GetBroadCaster() == pBroadcaster)
+ return (*i)->pPostIt;
+ }
+ return NULL;
+}
+
+sw::annotation::SwAnnotationWin* SwPostItMgr::GetAnnotationWin(const SwPostItField* pFld) const
+{
+ for(const_iterator i = mvPostItFlds.begin(); i != mvPostItFlds.end() ; ++i)
+ {
+ if ( (*i)->GetFmtFld().GetField() == pFld )
+ return dynamic_cast<sw::annotation::SwAnnotationWin*>((*i)->pPostIt);
+ }
+ return NULL;
+}
+
+SwSidebarWin* SwPostItMgr::GetNextPostIt( sal_uInt16 aDirection,
+ SwSidebarWin* aPostIt )
+{
+ if (mvPostItFlds.size()>1)
+ {
+ for(SwSidebarItem_iterator i = mvPostItFlds.begin(); i != mvPostItFlds.end() ; ++i)
+ {
+ if ( (*i)->pPostIt == aPostIt)
+ {
+ SwSidebarItem_iterator iNextPostIt = i;
+ if (aDirection == KEY_PAGEUP)
+ {
+ if ( iNextPostIt == mvPostItFlds.begin() )
+ {
+ return NULL;
+ }
+ --iNextPostIt;
+ }
+ else
+ {
+ ++iNextPostIt;
+ if ( iNextPostIt == mvPostItFlds.end() )
+ {
+ return NULL;
+ }
+ }
+ // lets quit, we are back at the beginning
+ if ( (*iNextPostIt)->pPostIt == aPostIt)
+ return NULL;
+ return (*iNextPostIt)->pPostIt;
+ }
+ }
+ return NULL;
+ }
+ else
+ return NULL;
+}
+
+long SwPostItMgr::GetNextBorder()
+{
+ for (unsigned long n=0;n<mPages.size();n++)
+ {
+ for(SwSidebarItem_iterator b = mPages[n]->mList->begin(); b!= mPages[n]->mList->end(); ++b)
+ {
+ if ((*b)->pPostIt == mpActivePostIt)
+ {
+ SwSidebarItem_iterator aNext = b;
+ ++aNext;
+ bool bFollow = (aNext == mPages[n]->mList->end()) ? false : (*aNext)->pPostIt->IsFollow();
+ if ( mPages[n]->bScrollbar || bFollow )
+ {
+ return -1;
+ }
+ else
+ {
+ //if this is the last item, return the bottom border otherwise the next item
+ if (aNext == mPages[n]->mList->end())
+ return mpEditWin->LogicToPixel(Point(0,mPages[n]->mPageRect.Bottom())).Y() - GetSpaceBetween();
+ else
+ return (*aNext)->pPostIt->GetPosPixel().Y() - GetSpaceBetween();
+ }
+ }
+ }
+ }
+
+ OSL_FAIL("SwPostItMgr::GetNextBorder(): We have to find a next border here");
+ return -1;
+}
+
+void SwPostItMgr::SetShadowState(const SwPostItField* pFld,bool bCursor)
+{
+ if (pFld)
+ {
+ if (pFld !=mShadowState.mpShadowFld)
+ {
+ if (mShadowState.mpShadowFld)
+ {
+ // reset old one if still alive
+ // TODO: does not work properly if mouse and cursor was set
+ sw::annotation::SwAnnotationWin* pOldPostIt =
+ GetAnnotationWin(mShadowState.mpShadowFld);
+ if (pOldPostIt && pOldPostIt->Shadow() && (pOldPostIt->Shadow()->GetShadowState() != SS_EDIT))
+ pOldPostIt->SetViewState(VS_NORMAL);
+ }
+ //set new one, if it is not currently edited
+ sw::annotation::SwAnnotationWin* pNewPostIt = GetAnnotationWin(pFld);
+ if (pNewPostIt && pNewPostIt->Shadow() && (pNewPostIt->Shadow()->GetShadowState() != SS_EDIT))
+ {
+ pNewPostIt->SetViewState(VS_VIEW);
+ //remember our new field
+ mShadowState.mpShadowFld = pFld;
+ mShadowState.bCursor = false;
+ mShadowState.bMouse = false;
+ }
+ }
+ if (bCursor)
+ mShadowState.bCursor = true;
+ else
+ mShadowState.bMouse = true;
+ }
+ else
+ {
+ if (mShadowState.mpShadowFld)
+ {
+ if (bCursor)
+ mShadowState.bCursor = false;
+ else
+ mShadowState.bMouse = false;
+ if (!mShadowState.bCursor && !mShadowState.bMouse)
+ {
+ // reset old one if still alive
+ sw::annotation::SwAnnotationWin* pOldPostIt = GetAnnotationWin(mShadowState.mpShadowFld);
+ if (pOldPostIt && pOldPostIt->Shadow() && (pOldPostIt->Shadow()->GetShadowState() != SS_EDIT))
+ {
+ pOldPostIt->SetViewState(VS_NORMAL);
+ mShadowState.mpShadowFld = 0;
+ }
+ }
+ }
+ }
+}
+
+void SwPostItMgr::PrepareView(bool bIgnoreCount)
+{
+ if (!HasNotes() || bIgnoreCount)
+ {
+ mpWrtShell->StartAllAction();
+ SwRootFrm* pLayout = mpWrtShell->GetLayout();
+ if ( pLayout )
+ SwPostItHelper::setSidebarChanged( pLayout,
+ mpWrtShell->getIDocumentSettingAccess()->get( IDocumentSettingAccess::BROWSE_MODE ) );
+ mpWrtShell->EndAllAction();
+ }
+}
+
+bool SwPostItMgr::ShowScrollbar(const unsigned long aPage) const
+{
+ if (mPages.size() > aPage-1)
+ return (mPages[aPage-1]->bScrollbar && !mbWaitingForCalcRects);
+ else
+ return false;
+}
+
+bool SwPostItMgr::IsHit(const Point &aPointPixel)
+{
+ if (HasNotes() && ShowNotes())
+ {
+ const Point aPoint = mpEditWin->PixelToLogic(aPointPixel);
+ const SwRootFrm* pLayout = mpWrtShell->GetLayout();
+ SwRect aPageFrm;
+ const unsigned long nPageNum = SwPostItHelper::getPageInfo( aPageFrm, pLayout, aPoint );
+ if( nPageNum )
+ {
+ Rectangle aRect;
+ OSL_ENSURE(mPages.size()>nPageNum-1,"SwPostitMgr:: page container size wrong");
+ aRect = mPages[nPageNum-1]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT
+ ? Rectangle(Point(aPageFrm.Left()-GetSidebarWidth()-GetSidebarBorderWidth(),aPageFrm.Top()),Size(GetSidebarWidth(),aPageFrm.Height()))
+ : Rectangle( Point(aPageFrm.Right()+GetSidebarBorderWidth(),aPageFrm.Top()) , Size(GetSidebarWidth(),aPageFrm.Height()));
+ if (aRect.IsInside(aPoint))
+ {
+ // we hit the note's sidebar
+ // lets now test for the arrow area
+ if (mPages[nPageNum-1]->bScrollbar)
+ return ScrollbarHit(nPageNum,aPoint);
+ else
+ return false;
+ }
+ }
+ }
+ return false;
+}
+Rectangle SwPostItMgr::GetBottomScrollRect(const unsigned long aPage) const
+{
+ SwRect aPageRect = mPages[aPage-1]->mPageRect;
+ Point aPointBottom = mPages[aPage-1]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT
+ ? Point(aPageRect.Left() - GetSidebarWidth() - GetSidebarBorderWidth() + mpEditWin->PixelToLogic(Size(2,0)).Width(),aPageRect.Bottom()- mpEditWin->PixelToLogic(Size(0,2+GetSidebarScrollerHeight())).Height())
+ : Point(aPageRect.Right() + GetSidebarBorderWidth() + mpEditWin->PixelToLogic(Size(2,0)).Width(),aPageRect.Bottom()- mpEditWin->PixelToLogic(Size(0,2+GetSidebarScrollerHeight())).Height());
+ Size aSize(GetSidebarWidth() - mpEditWin->PixelToLogic(Size(4,0)).Width(), mpEditWin->PixelToLogic(Size(0,GetSidebarScrollerHeight())).Height()) ;
+ return Rectangle(aPointBottom,aSize);
+}
+
+Rectangle SwPostItMgr::GetTopScrollRect(const unsigned long aPage) const
+{
+ SwRect aPageRect = mPages[aPage-1]->mPageRect;
+ Point aPointTop = mPages[aPage-1]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT
+ ? Point(aPageRect.Left() - GetSidebarWidth() -GetSidebarBorderWidth()+ mpEditWin->PixelToLogic(Size(2,0)).Width(),aPageRect.Top() + mpEditWin->PixelToLogic(Size(0,2)).Height())
+ : Point(aPageRect.Right() + GetSidebarBorderWidth() + mpEditWin->PixelToLogic(Size(2,0)).Width(),aPageRect.Top() + mpEditWin->PixelToLogic(Size(0,2)).Height());
+ Size aSize(GetSidebarWidth() - mpEditWin->PixelToLogic(Size(4,0)).Width(), mpEditWin->PixelToLogic(Size(0,GetSidebarScrollerHeight())).Height()) ;
+ return Rectangle(aPointTop,aSize);
+}
+
+//IMPORTANT: if you change the rects here, also change SwPageFrm::PaintNotesSidebar()
+bool SwPostItMgr::ScrollbarHit(const unsigned long aPage,const Point &aPoint)
+{
+ SwRect aPageRect = mPages[aPage-1]->mPageRect;
+ Point aPointBottom = mPages[aPage-1]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT
+ ? Point(aPageRect.Left() - GetSidebarWidth()-GetSidebarBorderWidth() + mpEditWin->PixelToLogic(Size(2,0)).Width(),aPageRect.Bottom()- mpEditWin->PixelToLogic(Size(0,2+GetSidebarScrollerHeight())).Height())
+ : Point(aPageRect.Right() + GetSidebarBorderWidth()+ mpEditWin->PixelToLogic(Size(2,0)).Width(),aPageRect.Bottom()- mpEditWin->PixelToLogic(Size(0,2+GetSidebarScrollerHeight())).Height());
+
+ Point aPointTop = mPages[aPage-1]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT
+ ? Point(aPageRect.Left() - GetSidebarWidth()-GetSidebarBorderWidth()+ mpEditWin->PixelToLogic(Size(2,0)).Width(),aPageRect.Top() + mpEditWin->PixelToLogic(Size(0,2)).Height())
+ : Point(aPageRect.Right()+GetSidebarBorderWidth()+ mpEditWin->PixelToLogic(Size(2,0)).Width(),aPageRect.Top() + mpEditWin->PixelToLogic(Size(0,2)).Height());
+
+ Rectangle aRectBottom(GetBottomScrollRect(aPage));
+ Rectangle aRectTop(GetTopScrollRect(aPage));
+
+ if (aRectBottom.IsInside(aPoint))
+ {
+ if (aPoint.X() < long((aPointBottom.X() + GetSidebarWidth()/3)))
+ Scroll( GetScrollSize(),aPage);
+ else
+ Scroll( -1*GetScrollSize(), aPage);
+ return true;
+ }
+ else if (aRectTop.IsInside(aPoint))
+ {
+ if (aPoint.X() < long((aPointTop.X() + GetSidebarWidth()/3*2)))
+ Scroll(GetScrollSize(), aPage);
+ else
+ Scroll(-1*GetScrollSize(), aPage);
+ return true;
+ }
+ return false;
+}
+
+void SwPostItMgr::CorrectPositions()
+{
+ if ( mbWaitingForCalcRects || mbLayouting || mvPostItFlds.empty() )
+ return;
+
+ // find first valid note
+ SwSidebarWin *pFirstPostIt = 0;
+ for(SwSidebarItem_iterator i = mvPostItFlds.begin(); i != mvPostItFlds.end() ; ++i)
+ {
+ pFirstPostIt = (*i)->pPostIt;
+ if (pFirstPostIt)
+ break;
+ }
+
+ //if we have not found a valid note, forget about it and leave
+ if (!pFirstPostIt)
+ return;
+
+ // yeah, I know, if this is a left page it could be wrong, but finding the page and the note is probably not even faster than just doing it
+ // check, if anchor overlay object exists.
+ const long aAnchorX = pFirstPostIt->Anchor()
+ ? mpEditWin->LogicToPixel( Point((long)(pFirstPostIt->Anchor()->GetSixthPosition().getX()),0)).X()
+ : 0;
+ const long aAnchorY = pFirstPostIt->Anchor()
+ ? mpEditWin->LogicToPixel( Point(0,(long)(pFirstPostIt->Anchor()->GetSixthPosition().getY()))).Y() + 1
+ : 0;
+ if (Point(aAnchorX,aAnchorY) != pFirstPostIt->GetPosPixel())
+ {
+ long aAnchorPosX = 0;
+ long aAnchorPosY = 0;
+ for (unsigned long n=0;n<mPages.size();n++)
+ {
+ for(SwSidebarItem_iterator i = mPages[n]->mList->begin(); i != mPages[n]->mList->end(); ++i)
+ {
+ // check, if anchor overlay object exists.
+ if ( (*i)->bShow && (*i)->pPostIt && (*i)->pPostIt->Anchor() )
+ {
+ aAnchorPosX = mPages[n]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT
+ ? mpEditWin->LogicToPixel( Point((long)((*i)->pPostIt->Anchor()->GetSeventhPosition().getX()),0)).X()
+ : mpEditWin->LogicToPixel( Point((long)((*i)->pPostIt->Anchor()->GetSixthPosition().getX()),0)).X();
+ aAnchorPosY = mpEditWin->LogicToPixel( Point(0,(long)((*i)->pPostIt->Anchor()->GetSixthPosition().getY()))).Y() + 1;
+ (*i)->pPostIt->SetPosPixel(Point(aAnchorPosX,aAnchorPosY));
+ }
+ }
+ }
+ }
+}
+
+bool SwPostItMgr::ShowNotes() const
+{
+ // we only want to see notes if Options - Writer - View - Notes is ticked
+ return mpWrtShell->GetViewOptions()->IsPostIts();
+}
+
+bool SwPostItMgr::HasNotes() const
+{
+ return !mvPostItFlds.empty();
+}
+
+unsigned long SwPostItMgr::GetSidebarWidth(bool bPx) const
+{
+ unsigned long aWidth = (unsigned long)(mpWrtShell->GetViewOptions()->GetZoom() * 1.8);
+ if (bPx)
+ return aWidth;
+ else
+ return mpEditWin->PixelToLogic(Size( aWidth ,0)).Width();
+}
+
+unsigned long SwPostItMgr::GetSidebarBorderWidth(bool bPx) const
+{
+ if (bPx)
+ return 2;
+ else
+ return mpEditWin->PixelToLogic(Size(2,0)).Width();
+}
+
+unsigned long SwPostItMgr::GetNoteWidth()
+{
+ return GetSidebarWidth(true);
+}
+
+Color SwPostItMgr::GetColorDark(sal_uInt16 aAuthorIndex)
+{
+ if (!Application::GetSettings().GetStyleSettings().GetHighContrastMode())
+ {
+ static const Color aArrayNormal[] = {
+ COL_AUTHOR1_NORMAL, COL_AUTHOR2_NORMAL, COL_AUTHOR3_NORMAL,
+ COL_AUTHOR4_NORMAL, COL_AUTHOR5_NORMAL, COL_AUTHOR6_NORMAL,
+ COL_AUTHOR7_NORMAL, COL_AUTHOR8_NORMAL, COL_AUTHOR9_NORMAL };
+
+ return Color( aArrayNormal[ aAuthorIndex % (sizeof( aArrayNormal )/ sizeof( aArrayNormal[0] ))]);
+ }
+ else
+ return Color(COL_WHITE);
+}
+
+Color SwPostItMgr::GetColorLight(sal_uInt16 aAuthorIndex)
+{
+ if (!Application::GetSettings().GetStyleSettings().GetHighContrastMode())
+ {
+ static const Color aArrayLight[] = {
+ COL_AUTHOR1_LIGHT, COL_AUTHOR2_LIGHT, COL_AUTHOR3_LIGHT,
+ COL_AUTHOR4_LIGHT, COL_AUTHOR5_LIGHT, COL_AUTHOR6_LIGHT,
+ COL_AUTHOR7_LIGHT, COL_AUTHOR8_LIGHT, COL_AUTHOR9_LIGHT };
+
+ return Color( aArrayLight[ aAuthorIndex % (sizeof( aArrayLight )/ sizeof( aArrayLight[0] ))]);
+ }
+ else
+ return Color(COL_WHITE);
+}
+
+Color SwPostItMgr::GetColorAnchor(sal_uInt16 aAuthorIndex)
+{
+ if (!Application::GetSettings().GetStyleSettings().GetHighContrastMode())
+ {
+ static const Color aArrayAnchor[] = {
+ COL_AUTHOR1_DARK, COL_AUTHOR2_DARK, COL_AUTHOR3_DARK,
+ COL_AUTHOR4_DARK, COL_AUTHOR5_DARK, COL_AUTHOR6_DARK,
+ COL_AUTHOR7_DARK, COL_AUTHOR8_DARK, COL_AUTHOR9_DARK };
+
+ return Color( aArrayAnchor[ aAuthorIndex % (sizeof( aArrayAnchor ) / sizeof( aArrayAnchor[0] ))]);
+ }
+ else
+ return Color(COL_WHITE);
+}
+
+void SwPostItMgr::SetActiveSidebarWin( SwSidebarWin* p)
+{
+ if ( p != mpActivePostIt )
+ {
+ // we need the temp variable so we can set mpActivePostIt before we call DeactivatePostIt
+ // therefore we get a new layout in DOCCHANGED when switching from postit to document,
+ // otherwise, GetActivePostIt() would still hold our old postit
+ SwSidebarWin* pActive = mpActivePostIt;
+ mpActivePostIt = p;
+ if (pActive)
+ {
+ pActive->DeactivatePostIt();
+ mShadowState.mpShadowFld = 0;
+ }
+ if (mpActivePostIt)
+ {
+ mpActivePostIt->GotoPos();
+ mpView->SetAnnotationMode(true);
+ mpView->AttrChangedNotify(0);
+ mpView->SetAnnotationMode(false);
+ mpActivePostIt->ActivatePostIt();
+ }
+ }
+}
+
+IMPL_LINK( SwPostItMgr, CalcHdl, void*, /* pVoid*/ )
+{
+ mnEventId = 0;
+ if ( mbLayouting )
+ {
+ OSL_FAIL("Reentrance problem in Layout Manager!");
+ mbWaitingForCalcRects = false;
+ return 0;
+ }
+
+ // do not change order, even if it would seem so in the first place, we need the calcrects always
+ if (CalcRects() || mbLayout)
+ {
+ mbLayout = false;
+ LayoutPostIts();
+ }
+ return 0;
+}
+
+void SwPostItMgr::Rescale()
+{
+ for(std::list<SwSidebarItem*>::iterator i = mvPostItFlds.begin(); i != mvPostItFlds.end() ; ++i)
+ if ( (*i)->pPostIt )
+ (*i)->pPostIt->Rescale();
+}
+
+sal_Int32 SwPostItMgr::GetInitialAnchorDistance() const
+{
+ const Fraction& f( mpEditWin->GetMapMode().GetScaleY() );
+ return POSTIT_INITIAL_ANCHOR_DISTANCE * f.GetNumerator() / f.GetDenominator();
+}
+
+sal_Int32 SwPostItMgr::GetSpaceBetween() const
+{
+ const Fraction& f( mpEditWin->GetMapMode().GetScaleY() );
+ return ( POSTIT_SPACE_BETWEEN ) * f.GetNumerator() / f.GetDenominator();
+}
+
+sal_Int32 SwPostItMgr::GetScrollSize() const
+{
+ const Fraction& f( mpEditWin->GetMapMode().GetScaleY() );
+ return ( POSTIT_SPACE_BETWEEN + POSTIT_MINIMUMSIZE_WITH_META ) * f.GetNumerator() / f.GetDenominator();
+}
+
+sal_Int32 SwPostItMgr::GetMinimumSizeWithMeta() const
+{
+ const Fraction& f( mpEditWin->GetMapMode().GetScaleY() );
+ return POSTIT_MINIMUMSIZE_WITH_META * f.GetNumerator() / f.GetDenominator();
+}
+
+sal_Int32 SwPostItMgr::GetSidebarScrollerHeight() const
+{
+ const Fraction& f( mpEditWin->GetMapMode().GetScaleY() );
+ return POSTIT_SCROLL_SIDEBAR_HEIGHT * f.GetNumerator() / f.GetDenominator();
+}
+
+void SwPostItMgr::SetSpellChecking()
+{
+ for(std::list<SwSidebarItem*>::iterator i = mvPostItFlds.begin(); i != mvPostItFlds.end() ; ++i)
+ if ( (*i)->pPostIt )
+ (*i)->pPostIt->SetSpellChecking();
+}
+
+void SwPostItMgr::SetReadOnlyState()
+{
+ for(std::list<SwSidebarItem*>::iterator i = mvPostItFlds.begin(); i != mvPostItFlds.end() ; ++i)
+ if ( (*i)->pPostIt )
+ (*i)->pPostIt->SetReadonly( mbReadOnly );
+}
+
+void SwPostItMgr::CheckMetaText()
+{
+ for(std::list<SwSidebarItem*>::iterator i = mvPostItFlds.begin(); i != mvPostItFlds.end() ; ++i)
+ if ( (*i)->pPostIt )
+ (*i)->pPostIt->CheckMetaText();
+
+}
+
+sal_uInt16 SwPostItMgr::Replace(SvxSearchItem* pItem)
+{
+ SwSidebarWin* pWin = GetActiveSidebarWin();
+ sal_uInt16 aResult = pWin->GetOutlinerView()->StartSearchAndReplace( *pItem );
+ if (!aResult)
+ SetActiveSidebarWin(0);
+ return aResult;
+}
+
+sal_uInt16 SwPostItMgr::FinishSearchReplace(const ::com::sun::star::util::SearchOptions& rSearchOptions, bool bSrchForward)
+{
+ SwSidebarWin* pWin = GetActiveSidebarWin();
+ SvxSearchItem aItem(SID_SEARCH_ITEM );
+ aItem.SetSearchOptions(rSearchOptions);
+ aItem.SetBackward(!bSrchForward);
+ sal_uInt16 aResult = pWin->GetOutlinerView()->StartSearchAndReplace( aItem );
+ if (!aResult)
+ SetActiveSidebarWin(0);
+ return aResult;
+}
+
+sal_uInt16 SwPostItMgr::SearchReplace(const SwFmtFld &pFld, const ::com::sun::star::util::SearchOptions& rSearchOptions, bool bSrchForward)
+{
+ sal_uInt16 aResult = 0;
+ SwSidebarWin* pWin = GetSidebarWin(&pFld);
+ if (pWin)
+ {
+ ESelection aOldSelection = pWin->GetOutlinerView()->GetSelection();
+ if (bSrchForward)
+ pWin->GetOutlinerView()->SetSelection(ESelection(0,0,0,0));
+ else
+ pWin->GetOutlinerView()->SetSelection(
+ ESelection(EE_PARA_MAX_COUNT,EE_TEXTPOS_MAX_COUNT,EE_PARA_MAX_COUNT,EE_TEXTPOS_MAX_COUNT));
+ SvxSearchItem aItem(SID_SEARCH_ITEM );
+ aItem.SetSearchOptions(rSearchOptions);
+ aItem.SetBackward(!bSrchForward);
+ aResult = pWin->GetOutlinerView()->StartSearchAndReplace( aItem );
+ if (!aResult)
+ pWin->GetOutlinerView()->SetSelection(aOldSelection);
+ else
+ {
+ SetActiveSidebarWin(pWin);
+ MakeVisible(pWin);
+ }
+ }
+ return aResult;
+}
+
+void SwPostItMgr::AssureStdModeAtShell()
+{
+ // deselect any drawing or frame and leave editing mode
+ SdrView* pSdrView = mpWrtShell->GetDrawView();
+ if ( pSdrView && pSdrView->IsTextEdit() )
+ {
+ sal_Bool bLockView = mpWrtShell->IsViewLocked();
+ mpWrtShell->LockView( sal_True );
+ mpWrtShell->EndTextEdit();
+ mpWrtShell->LockView( bLockView );
+ }
+
+ if( mpWrtShell->IsSelFrmMode() || mpWrtShell->IsObjSelected())
+ {
+ mpWrtShell->UnSelectFrm();
+ mpWrtShell->LeaveSelFrmMode();
+ mpWrtShell->GetView().LeaveDrawCreate();
+ mpWrtShell->EnterStdMode();
+
+ mpWrtShell->DrawSelChanged();
+ mpView->StopShellTimer();
+ }
+}
+
+bool SwPostItMgr::HasActiveSidebarWin() const
+{
+ return mpActivePostIt != 0;
+}
+
+bool SwPostItMgr::HasActiveAnnotationWin() const
+{
+ return HasActiveSidebarWin() &&
+ dynamic_cast<sw::annotation::SwAnnotationWin*>(mpActivePostIt) != 0;
+}
+
+void SwPostItMgr::GrabFocusOnActiveSidebarWin()
+{
+ if ( HasActiveSidebarWin() )
+ {
+ mpActivePostIt->GrabFocus();
+ }
+}
+
+void SwPostItMgr::UpdateDataOnActiveSidebarWin()
+{
+ if ( HasActiveSidebarWin() )
+ {
+ mpActivePostIt->UpdateData();
+ }
+}
+
+void SwPostItMgr::DeleteActiveSidebarWin()
+{
+ if ( HasActiveSidebarWin() )
+ {
+ mpActivePostIt->Delete();
+ }
+}
+
+void SwPostItMgr::HideActiveSidebarWin()
+{
+ if ( HasActiveSidebarWin() )
+ {
+ mpActivePostIt->Hide();
+ }
+}
+
+void SwPostItMgr::ToggleInsModeOnActiveSidebarWin()
+{
+ if ( HasActiveSidebarWin() )
+ {
+ mpActivePostIt->ToggleInsMode();
+ }
+}
+
+void SwPostItMgr::ConnectSidebarWinToFrm( const SwFrm& rFrm,
+ const SwFmtFld& rFmtFld,
+ SwSidebarWin& rSidebarWin )
+{
+ if ( mpFrmSidebarWinContainer == 0 )
+ {
+ mpFrmSidebarWinContainer = new SwFrmSidebarWinContainer();
+ }
+
+ const bool bInserted = mpFrmSidebarWinContainer->insert( rFrm, rFmtFld, rSidebarWin );
+ if ( bInserted &&
+ mpWrtShell->GetAccessibleMap() )
+ {
+ mpWrtShell->GetAccessibleMap()->InvalidatePosOrSize( 0, 0, &rSidebarWin, SwRect() );
+ }
+}
+
+void SwPostItMgr::DisconnectSidebarWinFromFrm( const SwFrm& rFrm,
+ SwSidebarWin& rSidebarWin )
+{
+ if ( mpFrmSidebarWinContainer != 0 )
+ {
+ const bool bRemoved = mpFrmSidebarWinContainer->remove( rFrm, rSidebarWin );
+ if ( bRemoved &&
+ mpWrtShell->GetAccessibleMap() )
+ {
+ mpWrtShell->GetAccessibleMap()->Dispose( 0, 0, &rSidebarWin );
+ }
+ }
+}
+
+bool SwPostItMgr::HasFrmConnectedSidebarWins( const SwFrm& rFrm )
+{
+ bool bRet( false );
+
+ if ( mpFrmSidebarWinContainer != 0 )
+ {
+ bRet = !mpFrmSidebarWinContainer->empty( rFrm );
+ }
+
+ return bRet;
+}
+
+Window* SwPostItMgr::GetSidebarWinForFrmByIndex( const SwFrm& rFrm,
+ const sal_Int32 nIndex )
+{
+ Window* pSidebarWin( 0 );
+
+ if ( mpFrmSidebarWinContainer != 0 )
+ {
+ pSidebarWin = mpFrmSidebarWinContainer->get( rFrm, nIndex );
+ }
+
+ return pSidebarWin;
+}
+
+void SwPostItMgr::GetAllSidebarWinForFrm( const SwFrm& rFrm,
+ std::vector< Window* >* pChildren )
+{
+ if ( mpFrmSidebarWinContainer != 0 )
+ {
+ mpFrmSidebarWinContainer->getAll( rFrm, pChildren );
+ }
+}
+
+void SwNoteProps::Commit() {}
+void SwNoteProps::Notify( const ::com::sun::star::uno::Sequence< OUString >& ) {}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/docvw/ShadowOverlayObject.cxx b/sw/source/core/uibase/docvw/ShadowOverlayObject.cxx
new file mode 100644
index 000000000000..efb1a5d68e27
--- /dev/null
+++ b/sw/source/core/uibase/docvw/ShadowOverlayObject.cxx
@@ -0,0 +1,252 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <ShadowOverlayObject.hxx>
+
+#include <view.hxx>
+#include <svx/sdrpaintwindow.hxx>
+#include <svx/svdview.hxx>
+#include <svx/sdr/overlay/overlaymanager.hxx>
+
+#include <sw_primitivetypes2d.hxx>
+#include <drawinglayer/primitive2d/primitivetools2d.hxx>
+#include <drawinglayer/primitive2d/fillgradientprimitive2d.hxx>
+
+namespace sw { namespace sidebarwindows {
+
+// helper SwPostItShadowPrimitive
+
+// Used to allow view-dependent primitive definition. For that purpose, the
+// initially created primitive (this one) always has to be view-independent,
+// but the decomposition is made view-dependent. Very simple primitive which
+// just remembers the discrete data and applies it at decomposition time.
+class ShadowPrimitive : public drawinglayer::primitive2d::DiscreteMetricDependentPrimitive2D
+{
+private:
+ basegfx::B2DPoint maBasePosition;
+ basegfx::B2DPoint maSecondPosition;
+ ShadowState maShadowState;
+
+protected:
+ virtual drawinglayer::primitive2d::Primitive2DSequence create2DDecomposition(
+ const drawinglayer::geometry::ViewInformation2D& rViewInformation) const;
+
+public:
+ ShadowPrimitive(
+ const basegfx::B2DPoint& rBasePosition,
+ const basegfx::B2DPoint& rSecondPosition,
+ ShadowState aShadowState)
+ : drawinglayer::primitive2d::DiscreteMetricDependentPrimitive2D(),
+ maBasePosition(rBasePosition),
+ maSecondPosition(rSecondPosition),
+ maShadowState(aShadowState)
+ {}
+
+ // data access
+ const basegfx::B2DPoint& getBasePosition() const { return maBasePosition; }
+ const basegfx::B2DPoint& getSecondPosition() const { return maSecondPosition; }
+ ShadowState getShadowState() const { return maShadowState; }
+
+ virtual bool operator==( const drawinglayer::primitive2d::BasePrimitive2D& rPrimitive ) const;
+
+ DeclPrimitive2DIDBlock()
+};
+
+drawinglayer::primitive2d::Primitive2DSequence ShadowPrimitive::create2DDecomposition(
+ const drawinglayer::geometry::ViewInformation2D& /*rViewInformation*/) const
+{
+ // get logic sizes in object coordinate system
+ drawinglayer::primitive2d::Primitive2DSequence xRetval;
+ basegfx::B2DRange aRange(getBasePosition());
+
+ switch(maShadowState)
+ {
+ case SS_NORMAL:
+ {
+ aRange.expand(basegfx::B2DTuple(getSecondPosition().getX(), getSecondPosition().getY() + (2.0 * getDiscreteUnit())));
+ const ::drawinglayer::attribute::FillGradientAttribute aFillGradientAttribute(
+ drawinglayer::attribute::GRADIENTSTYLE_LINEAR,
+ 0.0,
+ 0.5,
+ 0.5,
+ 1800.0 * F_PI1800,
+ basegfx::BColor(230.0/255.0,230.0/255.0,230.0/255.0),
+ basegfx::BColor(180.0/255.0,180.0/255.0,180.0/255.0),
+ 2);
+
+ const drawinglayer::primitive2d::Primitive2DReference xReference(
+ new drawinglayer::primitive2d::FillGradientPrimitive2D(
+ aRange,
+ aFillGradientAttribute));
+
+ xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
+ break;
+ }
+ case SS_VIEW:
+ {
+ aRange.expand(basegfx::B2DTuple(getSecondPosition().getX(), getSecondPosition().getY() + (4.0 * getDiscreteUnit())));
+ const drawinglayer::attribute::FillGradientAttribute aFillGradientAttribute(
+ drawinglayer::attribute::GRADIENTSTYLE_LINEAR,
+ 0.0,
+ 0.5,
+ 0.5,
+ 1800.0 * F_PI1800,
+ basegfx::BColor(230.0/255.0,230.0/255.0,230.0/255.0),
+ basegfx::BColor(180.0/255.0,180.0/255.0,180.0/255.0),
+ 4);
+
+ const drawinglayer::primitive2d::Primitive2DReference xReference(
+ new drawinglayer::primitive2d::FillGradientPrimitive2D(
+ aRange,
+ aFillGradientAttribute));
+
+ xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
+ break;
+ }
+ case SS_EDIT:
+ {
+ aRange.expand(basegfx::B2DTuple(getSecondPosition().getX(), getSecondPosition().getY() + (4.0 * getDiscreteUnit())));
+ const drawinglayer::attribute::FillGradientAttribute aFillGradientAttribute(
+ drawinglayer::attribute::GRADIENTSTYLE_LINEAR,
+ 0.0,
+ 0.5,
+ 0.5,
+ 1800.0 * F_PI1800,
+ basegfx::BColor(230.0/255.0,230.0/255.0,230.0/255.0),
+ basegfx::BColor(83.0/255.0,83.0/255.0,83.0/255.0),
+ 4);
+
+ const drawinglayer::primitive2d::Primitive2DReference xReference(
+ new drawinglayer::primitive2d::FillGradientPrimitive2D(
+ aRange,
+ aFillGradientAttribute));
+
+ xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+
+ return xRetval;
+}
+
+bool ShadowPrimitive::operator==( const drawinglayer::primitive2d::BasePrimitive2D& rPrimitive ) const
+{
+ if(drawinglayer::primitive2d::DiscreteMetricDependentPrimitive2D::operator==(rPrimitive))
+ {
+ const ShadowPrimitive& rCompare = static_cast< const ShadowPrimitive& >(rPrimitive);
+
+ return (getBasePosition() == rCompare.getBasePosition()
+ && getSecondPosition() == rCompare.getSecondPosition()
+ && getShadowState() == rCompare.getShadowState());
+ }
+
+ return false;
+}
+
+ImplPrimitive2DIDBlock(ShadowPrimitive, PRIMITIVE2D_ID_SWSIDEBARSHADOWPRIMITIVE)
+
+/* static */ ShadowOverlayObject* ShadowOverlayObject::CreateShadowOverlayObject( SwView& rDocView )
+{
+ ShadowOverlayObject* pShadowOverlayObject( 0 );
+
+ if ( rDocView.GetDrawView() )
+ {
+ SdrPaintWindow* pPaintWindow = rDocView.GetDrawView()->GetPaintWindow(0);
+ if( pPaintWindow )
+ {
+ rtl::Reference< ::sdr::overlay::OverlayManager > xOverlayManager = pPaintWindow->GetOverlayManager();
+
+ if ( xOverlayManager.is() )
+ {
+ pShadowOverlayObject = new ShadowOverlayObject( basegfx::B2DPoint(0,0),
+ basegfx::B2DPoint(0,0),
+ Color(0,0,0),
+ SS_NORMAL );
+ xOverlayManager->add(*pShadowOverlayObject);
+ }
+ }
+ }
+
+ return pShadowOverlayObject;
+}
+
+/* static */ void ShadowOverlayObject::DestroyShadowOverlayObject( ShadowOverlayObject* pShadow )
+{
+ if ( pShadow )
+ {
+ if ( pShadow->getOverlayManager() )
+ {
+ pShadow->getOverlayManager()->remove(*pShadow);
+ }
+ delete pShadow;
+ }
+}
+
+ShadowOverlayObject::ShadowOverlayObject( const basegfx::B2DPoint& rBasePos,
+ const basegfx::B2DPoint& rSecondPosition,
+ Color aBaseColor,
+ ShadowState aState )
+ : OverlayObjectWithBasePosition(rBasePos, aBaseColor)
+ , maSecondPosition(rSecondPosition)
+ , mShadowState(aState)
+{
+}
+
+ShadowOverlayObject::~ShadowOverlayObject()
+{
+}
+
+drawinglayer::primitive2d::Primitive2DSequence ShadowOverlayObject::createOverlayObjectPrimitive2DSequence()
+{
+ const drawinglayer::primitive2d::Primitive2DReference aReference(
+ new ShadowPrimitive( getBasePosition(),
+ GetSecondPosition(),
+ GetShadowState() ) );
+ return drawinglayer::primitive2d::Primitive2DSequence(&aReference, 1);
+}
+
+void ShadowOverlayObject::SetShadowState(ShadowState aState)
+{
+ if (mShadowState != aState)
+ {
+ mShadowState = aState;
+
+ objectChange();
+ }
+}
+
+void ShadowOverlayObject::SetPosition( const basegfx::B2DPoint& rPoint1,
+ const basegfx::B2DPoint& rPoint2)
+{
+ if(!rPoint1.equal(getBasePosition()) || !rPoint2.equal(GetSecondPosition()))
+ {
+ maBasePosition = rPoint1;
+ maSecondPosition = rPoint2;
+
+ objectChange();
+ }
+}
+
+} } // end of namespace sw::sidebarwindows
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/docvw/ShadowOverlayObject.hxx b/sw/source/core/uibase/docvw/ShadowOverlayObject.hxx
new file mode 100644
index 000000000000..d692ec86a75b
--- /dev/null
+++ b/sw/source/core/uibase/docvw/ShadowOverlayObject.hxx
@@ -0,0 +1,70 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SW_SOURCE_UI_DOCVW_SHADOWOVERLAYOBJECT_HXX
+#define INCLUDED_SW_SOURCE_UI_DOCVW_SHADOWOVERLAYOBJECT_HXX
+
+#include <svx/sdr/overlay/overlayobject.hxx>
+
+class SwView;
+
+namespace sw { namespace sidebarwindows {
+
+enum ShadowState
+{
+ SS_NORMAL,
+ SS_VIEW,
+ SS_EDIT
+};
+
+class ShadowOverlayObject: public sdr::overlay::OverlayObjectWithBasePosition
+{
+ protected:
+ // geometry creation for OverlayObject
+ virtual drawinglayer::primitive2d::Primitive2DSequence createOverlayObjectPrimitive2DSequence();
+
+ private:
+ basegfx::B2DPoint maSecondPosition;
+ ShadowState mShadowState;
+
+ ShadowOverlayObject( const basegfx::B2DPoint& rBasePos,
+ const basegfx::B2DPoint& rSecondPosition,
+ Color aBaseColor,
+ ShadowState aState );
+ virtual ~ShadowOverlayObject();
+
+ public:
+ void SetShadowState(ShadowState aState);
+ inline ShadowState GetShadowState() {return mShadowState;}
+
+ inline const basegfx::B2DPoint& GetSecondPosition() const { return maSecondPosition; }
+ void SetSecondPosition( const basegfx::B2DPoint& rNew );
+
+ void SetPosition( const basegfx::B2DPoint& rPoint1,
+ const basegfx::B2DPoint& rPoint2 );
+
+ static ShadowOverlayObject* CreateShadowOverlayObject( SwView& rDocView );
+ static void DestroyShadowOverlayObject( ShadowOverlayObject* pShadow );
+};
+
+} } // end of namespace sw::sidebarwindows
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/docvw/SidebarTxtControl.cxx b/sw/source/core/uibase/docvw/SidebarTxtControl.cxx
new file mode 100644
index 000000000000..292950dd8c36
--- /dev/null
+++ b/sw/source/core/uibase/docvw/SidebarTxtControl.cxx
@@ -0,0 +1,408 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <SidebarTxtControl.hxx>
+
+#include <SidebarTxtControlAcc.hxx>
+
+#include <SidebarWin.hxx>
+#include <PostItMgr.hxx>
+
+#include <cmdid.h>
+#include <docvw.hrc>
+
+#include <unotools/securityoptions.hxx>
+
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/mnumgr.hxx>
+
+#include <vcl/svapp.hxx>
+#include <vcl/help.hxx>
+#include <vcl/layout.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/gradient.hxx>
+#include <vcl/scrbar.hxx>
+#include <vcl/settings.hxx>
+
+#include <editeng/outliner.hxx>
+#include <editeng/editeng.hxx>
+#include <editeng/editview.hxx>
+#include <editeng/flditem.hxx>
+
+#include <uitool.hxx>
+#include <view.hxx>
+#include <wrtsh.hxx>
+#include <shellres.hxx>
+#include <SwRewriter.hxx>
+
+namespace sw { namespace sidebarwindows {
+
+SidebarTxtControl::SidebarTxtControl( SwSidebarWin& rSidebarWin,
+ WinBits nBits,
+ SwView& rDocView,
+ SwPostItMgr& rPostItMgr )
+ : Control( &rSidebarWin, nBits )
+ , mrSidebarWin( rSidebarWin )
+ , mrDocView( rDocView )
+ , mrPostItMgr( rPostItMgr )
+{
+ AddEventListener( LINK( &mrSidebarWin, SwSidebarWin, WindowEventListener ) );
+}
+
+SidebarTxtControl::~SidebarTxtControl()
+{
+ RemoveEventListener( LINK( &mrSidebarWin, SwSidebarWin, WindowEventListener ) );
+}
+
+OutlinerView* SidebarTxtControl::GetTextView() const
+{
+ return mrSidebarWin.GetOutlinerView();
+}
+
+void SidebarTxtControl::GetFocus()
+{
+ Window::GetFocus();
+ if ( !mrSidebarWin.IsMouseOver() )
+ {
+ Invalidate();
+ }
+}
+
+void SidebarTxtControl::LoseFocus()
+{
+ // write the visible text back into the SwField
+ mrSidebarWin.UpdateData();
+
+ Window::LoseFocus();
+ if ( !mrSidebarWin.IsMouseOver() )
+ {
+ Invalidate();
+ }
+}
+
+void SidebarTxtControl::RequestHelp(const HelpEvent &rEvt)
+{
+ sal_uInt16 nResId = 0;
+ switch( mrSidebarWin.GetLayoutStatus() )
+ {
+ case SwPostItHelper::INSERTED: nResId = STR_REDLINE_INSERT; break;
+ case SwPostItHelper::DELETED: nResId = STR_REDLINE_DELETE; break;
+ default: nResId = 0;
+ }
+
+ SwContentAtPos aCntntAtPos( SwContentAtPos::SW_REDLINE );
+ if ( nResId &&
+ mrDocView.GetWrtShell().GetContentAtPos( mrSidebarWin.GetAnchorPos(), aCntntAtPos ) )
+ {
+ OUString sTxt = SW_RESSTR( nResId ) + ": " +
+ aCntntAtPos.aFnd.pRedl->GetAuthorString() + " - " +
+ GetAppLangDateTimeString( aCntntAtPos.aFnd.pRedl->GetTimeStamp() );
+ Help::ShowQuickHelp( this,PixelToLogic(Rectangle(rEvt.GetMousePosPixel(),Size(50,10))),sTxt);
+ }
+}
+
+void SidebarTxtControl::Paint( const Rectangle& rRect)
+{
+ if ( !Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
+ {
+ if ( mrSidebarWin.IsMouseOverSidebarWin() ||
+ HasFocus() )
+ {
+ DrawGradient( Rectangle( Point(0,0), PixelToLogic(GetSizePixel()) ),
+ Gradient( GradientStyle_LINEAR,
+ mrSidebarWin.ColorDark(),
+ mrSidebarWin.ColorDark() ) );
+ }
+ else
+ {
+ DrawGradient( Rectangle( Point(0,0), PixelToLogic(GetSizePixel()) ),
+ Gradient( GradientStyle_LINEAR,
+ mrSidebarWin.ColorLight(),
+ mrSidebarWin.ColorDark()));
+ }
+ }
+
+ if ( GetTextView() )
+ {
+ GetTextView()->Paint( rRect );
+ }
+
+ if ( mrSidebarWin.GetLayoutStatus()==SwPostItHelper::DELETED )
+ {
+ SetLineColor(mrSidebarWin.GetChangeColor());
+ DrawLine( PixelToLogic( GetPosPixel() ),
+ PixelToLogic( GetPosPixel() +
+ Point( GetSizePixel().Width(),
+ GetSizePixel().Height() ) ) );
+ DrawLine( PixelToLogic( GetPosPixel() +
+ Point( GetSizePixel().Width(),0) ),
+ PixelToLogic( GetPosPixel() +
+ Point( 0, GetSizePixel().Height() ) ) );
+ }
+}
+
+void SidebarTxtControl::KeyInput( const KeyEvent& rKeyEvt )
+{
+ const KeyCode& rKeyCode = rKeyEvt.GetKeyCode();
+ sal_uInt16 nKey = rKeyCode.GetCode();
+ if ( ( rKeyCode.IsMod1() && rKeyCode.IsMod2() ) &&
+ ( (nKey == KEY_PAGEUP) || (nKey == KEY_PAGEDOWN) ) )
+ {
+ mrSidebarWin.SwitchToPostIt(nKey);
+ }
+ else if ( nKey == KEY_ESCAPE ||
+ ( rKeyCode.IsMod1() &&
+ ( nKey == KEY_PAGEUP ||
+ nKey == KEY_PAGEDOWN ) ) )
+ {
+ mrSidebarWin.SwitchToFieldPos();
+ }
+ else if ( nKey == KEY_INSERT )
+ {
+ if ( !rKeyCode.IsMod1() && !rKeyCode.IsMod2() )
+ {
+ mrSidebarWin.ToggleInsMode();
+ }
+ }
+ else
+ {
+ //let's make sure we see our note
+ mrPostItMgr.MakeVisible(&mrSidebarWin);
+
+ long aOldHeight = mrSidebarWin.GetPostItTextHeight();
+ bool bDone = false;
+
+ /// HACK: need to switch off processing of Undo/Redo in Outliner
+ if ( !( (nKey == KEY_Z || nKey == KEY_Y) && rKeyCode.IsMod1()) )
+ {
+ bool bIsProtected = mrSidebarWin.IsProtected();
+ if ( !bIsProtected ||
+ ( bIsProtected &&
+ !mrSidebarWin.GetOutlinerView()->GetOutliner()->GetEditEngine().DoesKeyChangeText(rKeyEvt)) )
+ {
+ bDone = GetTextView() && GetTextView()->PostKeyEvent( rKeyEvt );
+ }
+ else
+ {
+ MessageDialog(this, "InfoReadonlyDialog",
+ "modules/swriter/ui/inforeadonlydialog.ui").Execute();
+ }
+ }
+ if (bDone)
+ mrSidebarWin.ResizeIfNecessary( aOldHeight, mrSidebarWin.GetPostItTextHeight() );
+ else
+ {
+ // write back data first when showing navigator
+ if ( nKey==KEY_F5 )
+ mrSidebarWin.UpdateData();
+ if (!mrDocView.KeyInput(rKeyEvt))
+ Window::KeyInput(rKeyEvt);
+ }
+ }
+
+ mrDocView.GetViewFrame()->GetBindings().InvalidateAll(sal_False);
+}
+
+void SidebarTxtControl::MouseMove( const MouseEvent& rMEvt )
+{
+ if ( GetTextView() )
+ {
+ OutlinerView* pOutlinerView( GetTextView() );
+ pOutlinerView->MouseMove( rMEvt );
+ // mba: why does OutlinerView not handle the modifier setting?!
+ // this forces the postit to handle *all* pointer types
+ SetPointer( pOutlinerView->GetPointer( rMEvt.GetPosPixel() ) );
+
+ const EditView& aEV = pOutlinerView->GetEditView();
+ const SvxFieldItem* pItem = aEV.GetFieldUnderMousePointer();
+ if ( pItem )
+ {
+ const SvxFieldData* pFld = pItem->GetField();
+ const SvxURLField* pURL = PTR_CAST( SvxURLField, pFld );
+ if ( pURL )
+ {
+ OUString sURL( pURL->GetURL() );
+ SvtSecurityOptions aSecOpts;
+ if ( aSecOpts.IsOptionSet( SvtSecurityOptions::E_CTRLCLICK_HYPERLINK) )
+ sURL = SwViewShell::GetShellRes()->aLinkCtrlClick + ": " + sURL;
+ else
+ sURL = SwViewShell::GetShellRes()->aLinkClick + ": " + sURL;
+ Help::ShowQuickHelp( this,PixelToLogic(Rectangle(GetPosPixel(),Size(50,10))),sURL);
+ }
+ }
+ }
+}
+
+void SidebarTxtControl::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ if ( GetTextView() )
+ {
+ SvtSecurityOptions aSecOpts;
+ bool bExecuteMod = aSecOpts.IsOptionSet( SvtSecurityOptions::E_CTRLCLICK_HYPERLINK);
+
+ if ( !bExecuteMod || (bExecuteMod && rMEvt.GetModifier() == KEY_MOD1))
+ {
+ const EditView& aEV = GetTextView()->GetEditView();
+ const SvxFieldItem* pItem = aEV.GetFieldUnderMousePointer();
+ if ( pItem )
+ {
+ const SvxFieldData* pFld = pItem->GetField();
+ const SvxURLField* pURL = PTR_CAST( SvxURLField, pFld );
+ if ( pURL )
+ {
+ GetTextView()->MouseButtonDown( rMEvt );
+ SwWrtShell &rSh = mrDocView.GetWrtShell();
+ OUString sURL( pURL->GetURL() );
+ OUString sTarget( pURL->GetTargetFrame() );
+ ::LoadURL(rSh, sURL, URLLOAD_NOFILTER, sTarget);
+ return;
+ }
+ }
+ }
+ }
+
+ GrabFocus();
+ if ( GetTextView() )
+ {
+ GetTextView()->MouseButtonDown( rMEvt );
+ }
+ mrDocView.GetViewFrame()->GetBindings().InvalidateAll(sal_False);
+}
+
+void SidebarTxtControl::MouseButtonUp( const MouseEvent& rMEvt )
+{
+ if ( GetTextView() )
+ GetTextView()->MouseButtonUp( rMEvt );
+}
+
+IMPL_LINK( SidebarTxtControl, OnlineSpellCallback, SpellCallbackInfo*, pInfo )
+{
+ if ( pInfo->nCommand == SPELLCMD_STARTSPELLDLG )
+ {
+ mrDocView.GetViewFrame()->GetDispatcher()->Execute( FN_SPELL_GRAMMAR_DIALOG, SFX_CALLMODE_ASYNCHRON);
+ }
+ return 0;
+}
+
+IMPL_LINK( SidebarTxtControl, Select, Menu*, pSelMenu )
+{
+ mrSidebarWin.ExecuteCommand( pSelMenu->GetCurItemId() );
+ return 0;
+}
+
+void SidebarTxtControl::Command( const CommandEvent& rCEvt )
+{
+ if ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU )
+ {
+ if ( !mrSidebarWin.IsProtected() &&
+ GetTextView() &&
+ GetTextView()->IsWrongSpelledWordAtPos( rCEvt.GetMousePosPixel(), true ))
+ {
+ Link aLink = LINK(this, SidebarTxtControl, OnlineSpellCallback);
+ GetTextView()->ExecuteSpellPopup(rCEvt.GetMousePosPixel(),&aLink);
+ }
+ else
+ {
+ SfxPopupMenuManager* pMgr = mrDocView.GetViewFrame()->GetDispatcher()->Popup(0, this,&rCEvt.GetMousePosPixel());
+ ((PopupMenu*)pMgr->GetSVMenu())->SetSelectHdl( LINK(this, SidebarTxtControl, Select) );
+
+ {
+ OUString aText = ((PopupMenu*)pMgr->GetSVMenu())->GetItemText( FN_DELETE_NOTE_AUTHOR );
+ SwRewriter aRewriter;
+ aRewriter.AddRule(UndoArg1, mrSidebarWin.GetAuthor());
+ aText = aRewriter.Apply(aText);
+ ((PopupMenu*)pMgr->GetSVMenu())->SetItemText(FN_DELETE_NOTE_AUTHOR,aText);
+ }
+
+ Point aPos;
+ if (rCEvt.IsMouseEvent())
+ aPos = rCEvt.GetMousePosPixel();
+ else
+ {
+ const Size aSize = GetSizePixel();
+ aPos = Point( aSize.getWidth()/2, aSize.getHeight()/2 );
+ }
+
+ //!! call different Execute function to get rid of the new thesaurus sub menu
+ //!! pointer created in the call to Popup.
+ //!! Otherwise we would have a memory leak (see also #i107205#)
+ pMgr->Execute( aPos, this );
+ delete pMgr;
+ }
+ }
+ else
+ if (rCEvt.GetCommand() == COMMAND_WHEEL)
+ {
+ if (mrSidebarWin.IsScrollbarVisible())
+ {
+ const CommandWheelData* pData = rCEvt.GetWheelData();
+ if (pData->IsShift() || pData->IsMod1() || pData->IsMod2())
+ {
+ mrDocView.HandleWheelCommands(rCEvt);
+ }
+ else
+ {
+ HandleScrollCommand( rCEvt, 0 , mrSidebarWin.Scrollbar());
+ }
+ }
+ else
+ {
+ mrDocView.HandleWheelCommands(rCEvt);
+ }
+ }
+ else
+ {
+ if ( GetTextView() )
+ GetTextView()->Command( rCEvt );
+ else
+ Window::Command(rCEvt);
+ }
+}
+
+OUString SidebarTxtControl::GetSurroundingText() const
+{
+ if (GetTextView())
+ return GetTextView()->GetSurroundingText();
+ return OUString();
+}
+
+Selection SidebarTxtControl::GetSurroundingTextSelection() const
+{
+ if( GetTextView() )
+ return GetTextView()->GetSurroundingTextSelection();
+ else
+ return Selection( 0, 0 );
+}
+
+css::uno::Reference< css::accessibility::XAccessible > SidebarTxtControl::CreateAccessible()
+{
+
+ SidebarTxtControlAccessible* pAcc( new SidebarTxtControlAccessible( *this ) );
+ css::uno::Reference< css::awt::XWindowPeer > xWinPeer( pAcc );
+ SetWindowPeer( xWinPeer, pAcc );
+
+ css::uno::Reference< css::accessibility::XAccessible > xAcc( xWinPeer, css::uno::UNO_QUERY );
+ return xAcc;
+}
+
+} } // end of namespace sw::sidebarwindows
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/docvw/SidebarTxtControl.hxx b/sw/source/core/uibase/docvw/SidebarTxtControl.hxx
new file mode 100644
index 000000000000..37829b290a5a
--- /dev/null
+++ b/sw/source/core/uibase/docvw/SidebarTxtControl.hxx
@@ -0,0 +1,75 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SW_SOURCE_UI_DOCVW_SIDEBARTXTCONTROL_HXX
+#define INCLUDED_SW_SOURCE_UI_DOCVW_SIDEBARTXTCONTROL_HXX
+
+#include <vcl/ctrl.hxx>
+
+class OutlinerView;
+class SwView;
+class SwPostItMgr;
+struct SpellCallbackInfo;
+
+namespace sw { namespace sidebarwindows {
+
+class SwSidebarWin;
+
+class SidebarTxtControl : public Control
+{
+ private:
+ SwSidebarWin& mrSidebarWin;
+ SwView& mrDocView;
+ SwPostItMgr& mrPostItMgr;
+
+ protected:
+ virtual void Paint( const Rectangle& rRect);
+ virtual void KeyInput( const KeyEvent& rKeyEvt );
+ 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 LoseFocus();
+ virtual void RequestHelp(const HelpEvent &rEvt);
+ virtual OUString GetSurroundingText() const;
+ virtual Selection GetSurroundingTextSelection() const;
+
+ DECL_LINK( Select, Menu* );
+
+ public:
+ SidebarTxtControl( SwSidebarWin& rSidebarWin,
+ WinBits nBits,
+ SwView& rDocView,
+ SwPostItMgr& rPostItMgr );
+ ~SidebarTxtControl();
+
+ virtual void GetFocus();
+
+ OutlinerView* GetTextView() const;
+
+ DECL_LINK( OnlineSpellCallback, SpellCallbackInfo*);
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
+};
+
+} } // end of namespace sw::sidebarwindows
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/docvw/SidebarTxtControlAcc.cxx b/sw/source/core/uibase/docvw/SidebarTxtControlAcc.cxx
new file mode 100644
index 000000000000..b833bc708570
--- /dev/null
+++ b/sw/source/core/uibase/docvw/SidebarTxtControlAcc.cxx
@@ -0,0 +1,293 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <SidebarTxtControlAcc.hxx>
+
+#include <SidebarTxtControl.hxx>
+
+#include <svl/brdcst.hxx>
+#include <toolkit/awt/vclxaccessiblecomponent.hxx>
+#include <editeng/unoedsrc.hxx>
+#include <editeng/unoforou.hxx>
+#include <editeng/unoviwou.hxx>
+#include <editeng/unoedhlp.hxx>
+#include <svx/AccessibleTextHelper.hxx>
+#include <editeng/outliner.hxx>
+
+#include <boost/scoped_ptr.hpp>
+
+namespace sw { namespace sidebarwindows {
+
+// declaration and implementation of <SvxEditSource>
+// for <::accessibiliy::AccessibleTextHelper> instance
+class SidebarTextEditSource : public SvxEditSource,
+ public SfxBroadcaster
+{
+ public:
+ SidebarTextEditSource( SidebarTxtControl& rSidebarTxtControl );
+ virtual ~SidebarTextEditSource();
+
+ virtual SvxEditSource* Clone() const;
+
+ virtual SvxTextForwarder* GetTextForwarder();
+ virtual SvxViewForwarder* GetViewForwarder();
+ virtual SvxEditViewForwarder* GetEditViewForwarder( bool bCreate = false ) SAL_OVERRIDE;
+
+ virtual void UpdateData();
+
+ virtual SfxBroadcaster& GetBroadcaster() const;
+ DECL_LINK( NotifyHdl, EENotify* );
+
+ private:
+ SidebarTxtControl& mrSidebarTxtControl;
+ SvxOutlinerForwarder mTextForwarder;
+ SvxDrawOutlinerViewForwarder mViewForwarder;
+};
+
+SidebarTextEditSource::SidebarTextEditSource( SidebarTxtControl& rSidebarTxtControl )
+ : SvxEditSource()
+ , mrSidebarTxtControl( rSidebarTxtControl )
+ , mTextForwarder( *(rSidebarTxtControl.GetTextView()->GetOutliner()), false )
+ , mViewForwarder( *(rSidebarTxtControl.GetTextView()) )
+{
+ if ( mrSidebarTxtControl.GetTextView() )
+ {
+ mrSidebarTxtControl.GetTextView()->GetOutliner()->SetNotifyHdl( LINK(this, SidebarTextEditSource, NotifyHdl) );
+ }
+}
+
+SidebarTextEditSource::~SidebarTextEditSource()
+{
+ if ( mrSidebarTxtControl.GetTextView() )
+ {
+ mrSidebarTxtControl.GetTextView()->GetOutliner()->SetNotifyHdl( Link() );
+ }
+}
+
+SvxEditSource* SidebarTextEditSource::Clone() const
+{
+ return new SidebarTextEditSource( mrSidebarTxtControl );
+}
+
+SvxTextForwarder* SidebarTextEditSource::GetTextForwarder()
+{
+ return &mTextForwarder;
+}
+
+SvxViewForwarder* SidebarTextEditSource::GetViewForwarder()
+{
+ return &mViewForwarder;
+}
+
+SvxEditViewForwarder* SidebarTextEditSource::GetEditViewForwarder( bool /*bCreate*/ )
+{
+ return &mViewForwarder;
+}
+
+void SidebarTextEditSource::UpdateData()
+{
+ // nothing to do
+}
+
+SfxBroadcaster& SidebarTextEditSource::GetBroadcaster() const
+{
+ return *( const_cast< SidebarTextEditSource* > (this) );
+}
+
+IMPL_LINK(SidebarTextEditSource, NotifyHdl, EENotify*, pNotify)
+{
+ if ( pNotify )
+ {
+ boost::scoped_ptr< SfxHint > aHint( SvxEditSourceHelper::EENotification2Hint( pNotify ) );
+
+ if( aHint.get() )
+ {
+ Broadcast( *aHint.get() );
+ }
+ }
+
+ return 0;
+}
+
+// declaration and implementation of accessible context for <SidebarTxtControl> instance
+class SidebarTxtControlAccessibleContext : public VCLXAccessibleComponent
+{
+ public:
+ explicit SidebarTxtControlAccessibleContext( SidebarTxtControl& rSidebarTxtControl );
+ virtual ~SidebarTxtControlAccessibleContext();
+
+ virtual sal_Int32 SAL_CALL
+ getAccessibleChildCount()
+ throw (::com::sun::star::uno::RuntimeException, std::exception);
+ 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, std::exception);
+
+ virtual void SAL_CALL
+ addAccessibleEventListener (
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessibleEventListener >& xListener)
+ throw (::com::sun::star::uno::RuntimeException, std::exception);
+ virtual void SAL_CALL
+ removeAccessibleEventListener (
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessibleEventListener >& xListener)
+ throw (::com::sun::star::uno::RuntimeException, std::exception);
+
+ protected:
+ virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent );
+
+ private:
+ SidebarTxtControl& mrSidebarTxtControl;
+ ::accessibility::AccessibleTextHelper* mpAccessibleTextHelper;
+
+ ::osl::Mutex maMutex;
+
+ void defunc();
+};
+
+SidebarTxtControlAccessibleContext::SidebarTxtControlAccessibleContext( SidebarTxtControl& rSidebarTxtControl )
+ : VCLXAccessibleComponent( rSidebarTxtControl.GetWindowPeer() )
+ , mrSidebarTxtControl( rSidebarTxtControl )
+ , mpAccessibleTextHelper( 0 )
+ , maMutex()
+{
+ ::std::auto_ptr<SvxEditSource> pEditSource(
+ new SidebarTextEditSource( mrSidebarTxtControl ) );
+ mpAccessibleTextHelper = new ::accessibility::AccessibleTextHelper( pEditSource );
+ mpAccessibleTextHelper->SetEventSource( mrSidebarTxtControl.GetWindowPeer() );
+}
+
+SidebarTxtControlAccessibleContext::~SidebarTxtControlAccessibleContext()
+{
+ defunc();
+}
+
+void SidebarTxtControlAccessibleContext::defunc()
+{
+ delete mpAccessibleTextHelper;
+ mpAccessibleTextHelper = 0;
+}
+
+sal_Int32 SAL_CALL SidebarTxtControlAccessibleContext::getAccessibleChildCount()
+ throw (::com::sun::star::uno::RuntimeException, std::exception)
+{
+ osl::MutexGuard aGuard( maMutex );
+
+ sal_Int32 nChildCount( 0 );
+
+ if ( mpAccessibleTextHelper )
+ {
+ nChildCount = mpAccessibleTextHelper->GetChildCount();
+ }
+
+ return nChildCount;
+}
+
+css::uno::Reference< css::accessibility::XAccessible > SAL_CALL SidebarTxtControlAccessibleContext::getAccessibleChild( sal_Int32 i )
+ throw ( css::lang::IndexOutOfBoundsException, css::uno::RuntimeException, std::exception )
+{
+ osl::MutexGuard aGuard( maMutex );
+
+ css::uno::Reference< css::accessibility::XAccessible > xChild;
+
+ if ( mpAccessibleTextHelper )
+ {
+ xChild = mpAccessibleTextHelper->GetChild( i );
+ }
+
+ return xChild;
+}
+
+void SAL_CALL SidebarTxtControlAccessibleContext::addAccessibleEventListener (
+ const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener)
+ throw (css::uno::RuntimeException, std::exception)
+{
+ osl::MutexGuard aGuard( maMutex );
+
+ if ( mpAccessibleTextHelper )
+ {
+ mpAccessibleTextHelper->AddEventListener(xListener);
+ }
+}
+
+void SAL_CALL SidebarTxtControlAccessibleContext::removeAccessibleEventListener (
+ const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener)
+ throw (css::uno::RuntimeException, std::exception)
+{
+ osl::MutexGuard aGuard( maMutex );
+
+ if ( mpAccessibleTextHelper )
+ {
+ mpAccessibleTextHelper->RemoveEventListener(xListener);
+ }
+}
+
+void SidebarTxtControlAccessibleContext::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
+{
+ if ( mpAccessibleTextHelper )
+ {
+ switch ( rVclWindowEvent.GetId() )
+ {
+ case VCLEVENT_OBJECT_DYING:
+ {
+ defunc();
+ }
+ break;
+ case VCLEVENT_WINDOW_GETFOCUS:
+ case VCLEVENT_CONTROL_GETFOCUS:
+ {
+ mpAccessibleTextHelper->SetFocus( sal_True );
+ }
+ break;
+ case VCLEVENT_WINDOW_LOSEFOCUS:
+ case VCLEVENT_CONTROL_LOSEFOCUS:
+ {
+ mpAccessibleTextHelper->SetFocus( sal_False );
+ }
+ break;
+ }
+ }
+
+ VCLXAccessibleComponent::ProcessWindowEvent( rVclWindowEvent );
+}
+
+// implementaion of accessible for <SidebarTxtControl> instance
+SidebarTxtControlAccessible::SidebarTxtControlAccessible( SidebarTxtControl& rSidebarTxtControl )
+ : VCLXWindow()
+ , mrSidebarTxtControl( rSidebarTxtControl )
+{
+ SetWindow( &mrSidebarTxtControl );
+}
+
+SidebarTxtControlAccessible::~SidebarTxtControlAccessible()
+{
+}
+
+css::uno::Reference< css::accessibility::XAccessibleContext > SidebarTxtControlAccessible::CreateAccessibleContext()
+{
+ SidebarTxtControlAccessibleContext* pAccContext(
+ new SidebarTxtControlAccessibleContext( mrSidebarTxtControl ) );
+ css::uno::Reference< css::accessibility::XAccessibleContext > xAcc( pAccContext );
+ return xAcc;
+}
+
+} } // end of namespace sw::sidebarwindows
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/docvw/SidebarTxtControlAcc.hxx b/sw/source/core/uibase/docvw/SidebarTxtControlAcc.hxx
new file mode 100644
index 000000000000..051c5ecd7758
--- /dev/null
+++ b/sw/source/core/uibase/docvw/SidebarTxtControlAcc.hxx
@@ -0,0 +1,46 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SW_SOURCE_UI_DOCVW_SIDEBARTXTCONTROLACC_HXX
+#define INCLUDED_SW_SOURCE_UI_DOCVW_SIDEBARTXTCONTROLACC_HXX
+
+#include <toolkit/awt/vclxwindow.hxx>
+
+namespace sw { namespace sidebarwindows {
+
+class SidebarTxtControl;
+
+class SidebarTxtControlAccessible : public VCLXWindow
+{
+ public:
+ explicit SidebarTxtControlAccessible( SidebarTxtControl& rSidebarTxtControl );
+ virtual ~SidebarTxtControlAccessible();
+
+ virtual com::sun::star::uno::Reference< com::sun::star::accessibility::XAccessibleContext >
+ CreateAccessibleContext();
+
+ private:
+ SidebarTxtControl& mrSidebarTxtControl;
+};
+
+} } // end of namespace sw::sidebarwindows
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/docvw/SidebarWin.cxx b/sw/source/core/uibase/docvw/SidebarWin.cxx
new file mode 100644
index 000000000000..14553ad2e564
--- /dev/null
+++ b/sw/source/core/uibase/docvw/SidebarWin.cxx
@@ -0,0 +1,1354 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <sal/config.h>
+
+#include <cstdlib>
+
+#include <SidebarWin.hxx>
+#include <SidebarWinAcc.hxx>
+#include <PostItMgr.hxx>
+
+#include <SidebarTxtControl.hxx>
+#include <AnchorOverlayObject.hxx>
+#include <ShadowOverlayObject.hxx>
+#include <OverlayRanges.hxx>
+
+#include <annotation.hrc>
+#include <popup.hrc>
+#include <docvw.hrc>
+#include <app.hrc>
+#include <access.hrc>
+
+#include <viewopt.hxx>
+#include <cmdid.h>
+
+#include <editeng/fontitem.hxx>
+#include <editeng/fhgtitem.hxx>
+#include <editeng/langitem.hxx>
+#include <editeng/editview.hxx>
+#include <editeng/outliner.hxx>
+#include <editeng/editeng.hxx>
+#include <editeng/eeitem.hxx>
+
+#include <svl/zforlist.hxx>
+#include <svl/undo.hxx>
+#include <svl/stritem.hxx>
+
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+
+#include <vcl/scrbar.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/menubtn.hxx>
+#include <vcl/settings.hxx>
+
+#include <edtwin.hxx>
+#include <view.hxx>
+#include <docsh.hxx>
+#include <wrtsh.hxx>
+#include <doc.hxx>
+#include <swmodule.hxx>
+#include <langhelper.hxx>
+
+#include <txtannotationfld.hxx>
+#include <ndtxt.hxx>
+
+#include <sw_primitivetypes2d.hxx>
+#include <drawinglayer/primitive2d/primitivetools2d.hxx>
+#include <drawinglayer/primitive2d/fillgradientprimitive2d.hxx>
+#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
+#include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
+#include <drawinglayer/primitive2d/shadowprimitive2d.hxx>
+
+namespace sw { namespace sidebarwindows {
+
+#define METABUTTON_WIDTH 16
+#define METABUTTON_HEIGHT 18
+#define METABUTTON_AREA_WIDTH 30
+#define POSTIT_META_HEIGHT (sal_Int32) 30
+#define POSTIT_MINIMUMSIZE_WITHOUT_META 50
+
+SwSidebarWin::SwSidebarWin( SwEditWin& rEditWin,
+ WinBits nBits,
+ SwPostItMgr& aMgr,
+ SwPostItBits aBits,
+ SwSidebarItem& rSidebarItem )
+ : Window(&rEditWin, nBits)
+ , mrMgr(aMgr)
+ , mrView( rEditWin.GetView() )
+ , nFlags(aBits)
+ , mnEventId(0)
+ , mpOutlinerView(0)
+ , mpOutliner(0)
+ , mpSidebarTxtControl(0)
+ , mpVScrollbar(0)
+ , mpMetadataAuthor(0)
+ , mpMetadataDate(0)
+ , mpMenuButton(0)
+ , mpAnchor( NULL )
+ , mpShadow( NULL )
+ , mpTextRangeOverlay( NULL )
+ , mColorAnchor()
+ , mColorDark()
+ , mColorLight()
+ , mChangeColor()
+ , meSidebarPosition( sw::sidebarwindows::SIDEBAR_NONE )
+ , mPosSize()
+ , mAnchorRect()
+ , mPageBorder( 0 )
+ , mbMouseOver( false )
+ , mLayoutStatus( SwPostItHelper::INVISIBLE )
+ , mbReadonly( false )
+ , mbIsFollow( false )
+ , mrSidebarItem( rSidebarItem )
+ , mpAnchorFrm( rSidebarItem.maLayoutInfo.mpAnchorFrm )
+{
+ mpShadow = ShadowOverlayObject::CreateShadowOverlayObject( mrView );
+ if ( mpShadow )
+ {
+ mpShadow->setVisible(false);
+ }
+
+ mrMgr.ConnectSidebarWinToFrm( *(mrSidebarItem.maLayoutInfo.mpAnchorFrm),
+ mrSidebarItem.GetFmtFld(),
+ *this );
+}
+
+SwSidebarWin::~SwSidebarWin()
+{
+ mrMgr.DisconnectSidebarWinFromFrm( *(mrSidebarItem.maLayoutInfo.mpAnchorFrm),
+ *this );
+
+ Disable();
+
+ if ( mpSidebarTxtControl )
+ {
+ if ( mpOutlinerView )
+ {
+ mpOutlinerView->SetWindow( 0 );
+ }
+ delete mpSidebarTxtControl;
+ mpSidebarTxtControl = 0;
+ }
+
+ if ( mpOutlinerView )
+ {
+ delete mpOutlinerView;
+ mpOutlinerView = 0;
+ }
+
+ if (mpOutliner)
+ {
+ delete mpOutliner;
+ mpOutliner = 0;
+ }
+
+ if (mpMetadataAuthor)
+ {
+ mpMetadataAuthor->RemoveEventListener( LINK( this, SwSidebarWin, WindowEventListener ) );
+ delete mpMetadataAuthor;
+ mpMetadataAuthor = 0;
+ }
+
+ if (mpMetadataDate)
+ {
+ mpMetadataDate->RemoveEventListener( LINK( this, SwSidebarWin, WindowEventListener ) );
+ delete mpMetadataDate;
+ mpMetadataDate = 0;
+ }
+
+ if (mpVScrollbar)
+ {
+ mpVScrollbar->RemoveEventListener( LINK( this, SwSidebarWin, WindowEventListener ) );
+ delete mpVScrollbar;
+ mpVScrollbar = 0;
+ }
+
+ AnchorOverlayObject::DestroyAnchorOverlayObject( mpAnchor );
+ mpAnchor = NULL;
+
+ ShadowOverlayObject::DestroyShadowOverlayObject( mpShadow );
+ mpShadow = NULL;
+
+ delete mpTextRangeOverlay;
+ mpTextRangeOverlay = NULL;
+
+ delete mpMenuButton;
+ mpMenuButton = 0;
+
+ if (mnEventId)
+ Application::RemoveUserEvent( mnEventId );
+}
+
+void SwSidebarWin::Paint( const Rectangle& rRect)
+{
+ Window::Paint(rRect);
+
+ if (mpMetadataAuthor->IsVisible() )
+ {
+ //draw left over space
+ if ( Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
+ {
+ SetFillColor(COL_BLACK);
+ }
+ else
+ {
+ SetFillColor(mColorDark);
+ }
+ SetLineColor();
+ DrawRect( PixelToLogic(
+ Rectangle( Point( mpMetadataAuthor->GetPosPixel().X() +
+ mpMetadataAuthor->GetSizePixel().Width(),
+ mpMetadataAuthor->GetPosPixel().Y() ),
+ Size( GetMetaButtonAreaWidth(),
+ mpMetadataAuthor->GetSizePixel().Height() +
+ mpMetadataDate->GetSizePixel().Height() ) ) ) );
+ }
+}
+
+void SwSidebarWin::SetPosSizePixelRect( long nX,
+ long nY,
+ long nWidth,
+ long nHeight,
+ const SwRect& aAnchorRect,
+ const long aPageBorder)
+{
+ mPosSize = Rectangle(Point(nX,nY),Size(nWidth,nHeight));
+ mAnchorRect = aAnchorRect;
+ mPageBorder = aPageBorder;
+}
+
+void SwSidebarWin::SetSize( const Size& rNewSize )
+{
+ mPosSize.SetSize(rNewSize);
+}
+
+void SwSidebarWin::SetVirtualPosSize( const Point& aPoint, const Size& aSize)
+{
+ mPosSize = Rectangle(aPoint,aSize);
+}
+
+void SwSidebarWin::TranslateTopPosition(const long aAmount)
+{
+ mPosSize.Move(0,aAmount);
+}
+
+void SwSidebarWin::ShowAnchorOnly(const Point &aPoint)
+{
+ HideNote();
+ SetPosAndSize();
+ if (mpAnchor)
+ {
+ mpAnchor->SetSixthPosition(basegfx::B2DPoint(aPoint.X(),aPoint.Y()));
+ mpAnchor->SetSeventhPosition(basegfx::B2DPoint(aPoint.X(),aPoint.Y()));
+ mpAnchor->SetAnchorState(AS_ALL);
+ mpAnchor->setVisible(true);
+ }
+ if (mpShadow)
+ mpShadow->setVisible(false);
+}
+
+SfxItemSet SwSidebarWin::DefaultItem()
+{
+ SfxItemSet aItem( mrView.GetDocShell()->GetPool() );
+ aItem.Put(SvxFontHeightItem(200,100,EE_CHAR_FONTHEIGHT));
+ aItem.Put(SvxFontItem(FAMILY_SWISS,
+ GetSettings().GetStyleSettings().GetFieldFont().GetName(),
+ OUString(),
+ PITCH_DONTKNOW,
+ RTL_TEXTENCODING_DONTKNOW,
+ EE_CHAR_FONTINFO));
+ return aItem;
+}
+
+void SwSidebarWin::InitControls()
+{
+ AddEventListener( LINK( this, SwSidebarWin, WindowEventListener ) );
+
+ // actual window which holds the user text
+ mpSidebarTxtControl = new SidebarTxtControl( *this,
+ WB_NODIALOGCONTROL,
+ mrView, mrMgr );
+ mpSidebarTxtControl->SetPointer(Pointer(POINTER_TEXT));
+
+ // window controls for author and date
+ mpMetadataAuthor = new Edit( this, 0 );
+ mpMetadataAuthor->SetAccessibleName( SW_RES( STR_ACCESS_ANNOTATION_AUTHOR_NAME ) );
+ mpMetadataAuthor->EnableRTL(Application::GetSettings().GetLayoutRTL());
+ mpMetadataAuthor->SetReadOnly();
+ mpMetadataAuthor->AlwaysDisableInput(true);
+ mpMetadataAuthor->SetCallHandlersOnInputDisabled(true);
+ mpMetadataAuthor->AddEventListener( LINK( this, SwSidebarWin, WindowEventListener ) );
+ // we should leave this setting alone, but for this we need a better layout algo
+ // with variable meta size height
+ {
+ AllSettings aSettings = mpMetadataAuthor->GetSettings();
+ StyleSettings aStyleSettings = aSettings.GetStyleSettings();
+ Font aFont = aStyleSettings.GetFieldFont();
+ aFont.SetHeight(8);
+ aStyleSettings.SetFieldFont(aFont);
+ aSettings.SetStyleSettings(aStyleSettings);
+ mpMetadataAuthor->SetSettings(aSettings);
+ }
+
+ mpMetadataDate = new Edit( this, 0 );
+ mpMetadataDate->SetAccessibleName( SW_RES( STR_ACCESS_ANNOTATION_DATE_NAME ) );
+ mpMetadataDate->EnableRTL(Application::GetSettings().GetLayoutRTL());
+ mpMetadataDate->SetReadOnly();
+ mpMetadataDate->AlwaysDisableInput(true);
+ mpMetadataDate->SetCallHandlersOnInputDisabled(true);
+ mpMetadataDate->AddEventListener( LINK( this, SwSidebarWin, WindowEventListener ) );
+ // we should leave this setting alone, but for this we need a better layout algo
+ // with variable meta size height
+ {
+ AllSettings aSettings = mpMetadataDate->GetSettings();
+ StyleSettings aStyleSettings = aSettings.GetStyleSettings();
+ Font aFont = aStyleSettings.GetFieldFont();
+ aFont.SetHeight(8);
+ aStyleSettings.SetFieldFont(aFont);
+ aSettings.SetStyleSettings(aStyleSettings);
+ mpMetadataDate->SetSettings(aSettings);
+ }
+
+ SwDocShell* aShell = mrView.GetDocShell();
+ mpOutliner = new Outliner(&aShell->GetPool(),OUTLINERMODE_TEXTOBJECT);
+ aShell->GetDoc()->SetCalcFieldValueHdl( mpOutliner );
+ mpOutliner->SetUpdateMode( true );
+ Rescale();
+
+ mpSidebarTxtControl->EnableRTL( false );
+ mpOutlinerView = new OutlinerView ( mpOutliner, mpSidebarTxtControl );
+ mpOutlinerView->SetBackgroundColor(COL_TRANSPARENT);
+ mpOutliner->InsertView(mpOutlinerView );
+ mpOutlinerView->SetOutputArea( PixelToLogic( Rectangle(0,0,1,1) ) );
+
+ mpOutlinerView->SetAttribs(DefaultItem());
+
+ //create Scrollbars
+ mpVScrollbar = new ScrollBar(this, WB_3DLOOK |WB_VSCROLL|WB_DRAG);
+ mpVScrollbar->EnableNativeWidget(false);
+ mpVScrollbar->EnableRTL( false );
+ mpVScrollbar->SetScrollHdl(LINK(this, SwSidebarWin, ScrollHdl));
+ mpVScrollbar->EnableDrag();
+ mpVScrollbar->AddEventListener( LINK( this, SwSidebarWin, WindowEventListener ) );
+
+ const SwViewOption* pVOpt = mrView.GetWrtShellPtr()->GetViewOptions();
+ sal_uLong nCntrl = mpOutliner->GetControlWord();
+ // TODO: crash when AUTOCOMPLETE enabled
+ nCntrl |= EE_CNTRL_MARKFIELDS | EE_CNTRL_PASTESPECIAL | EE_CNTRL_AUTOCORRECT | EV_CNTRL_AUTOSCROLL | EE_CNTRL_URLSFXEXECUTE; // | EE_CNTRL_AUTOCOMPLETE;
+ if (pVOpt->IsFieldShadings())
+ nCntrl |= EE_CNTRL_MARKFIELDS;
+ else
+ nCntrl &= ~EE_CNTRL_MARKFIELDS;
+ if (pVOpt->IsOnlineSpell())
+ nCntrl |= EE_CNTRL_ONLINESPELLING;
+ else
+ nCntrl &= ~EE_CNTRL_ONLINESPELLING;
+ mpOutliner->SetControlWord(nCntrl);
+
+ sal_uInt16 aIndex = SW_MOD()->InsertRedlineAuthor(GetAuthor());
+ SetColor( mrMgr.GetColorDark(aIndex),
+ mrMgr.GetColorLight(aIndex),
+ mrMgr.GetColorAnchor(aIndex));
+
+ CheckMetaText();
+
+ mpMenuButton = CreateMenuButton();
+
+ SetLanguage(GetLanguage());
+ GetOutlinerView()->StartSpeller();
+ SetPostItText();
+ Engine()->CompleteOnlineSpelling();
+
+ mpSidebarTxtControl->Show();
+ mpMetadataAuthor->Show();
+ mpMetadataDate->Show();
+ mpVScrollbar->Show();
+}
+
+void SwSidebarWin::CheckMetaText()
+{
+ const SvtSysLocale aSysLocale;
+ const LocaleDataWrapper& rLocalData = aSysLocale.GetLocaleData();
+ OUString sMeta = GetAuthor();
+ if (sMeta.isEmpty())
+ {
+ sMeta = SW_RESSTR(STR_NOAUTHOR);
+ }
+ else if (sMeta.getLength() > 23)
+ {
+ sMeta = sMeta.copy(0, 20) + "...";
+ }
+ if ( mpMetadataAuthor->GetText() != sMeta )
+ {
+ mpMetadataAuthor->SetText(sMeta);
+ }
+
+ Date aSysDate( Date::SYSTEM );
+ Date aDate = GetDate();
+ if (aDate==aSysDate)
+ {
+ sMeta = SW_RESSTR(STR_POSTIT_TODAY);
+ }
+ else if (aDate == Date(aSysDate-1))
+ {
+ sMeta = SW_RESSTR(STR_POSTIT_YESTERDAY);
+ }
+ else if (aDate.IsValidAndGregorian() )
+ {
+ sMeta = rLocalData.getDate(aDate);
+ }
+ else
+ {
+ sMeta = SW_RESSTR(STR_NODATE);
+ }
+ if (GetTime()!=0)
+ {
+ sMeta += " " + rLocalData.getTime( GetTime(),false );
+ }
+ if ( mpMetadataDate->GetText() != sMeta )
+ {
+ mpMetadataDate->SetText(sMeta);
+ }
+}
+
+void SwSidebarWin::Rescale()
+{
+ MapMode aMode = GetParent()->GetMapMode();
+ aMode.SetOrigin( Point() );
+ mpOutliner->SetRefMapMode( aMode );
+ SetMapMode( aMode );
+ mpSidebarTxtControl->SetMapMode( aMode );
+ if ( mpMetadataAuthor )
+ {
+ Font aFont( mpMetadataAuthor->GetSettings().GetStyleSettings().GetFieldFont() );
+ sal_Int32 nHeight = aFont.GetHeight();
+ nHeight = nHeight * aMode.GetScaleY().GetNumerator() / aMode.GetScaleY().GetDenominator();
+ aFont.SetHeight( nHeight );
+ mpMetadataAuthor->SetControlFont( aFont );
+ }
+ if ( mpMetadataDate )
+ {
+ Font aFont( mpMetadataDate->GetSettings().GetStyleSettings().GetFieldFont() );
+ sal_Int32 nHeight = aFont.GetHeight();
+ nHeight = nHeight * aMode.GetScaleY().GetNumerator() / aMode.GetScaleY().GetDenominator();
+ aFont.SetHeight( nHeight );
+ mpMetadataDate->SetControlFont( aFont );
+ }
+}
+
+void SwSidebarWin::SetPosAndSize()
+{
+ bool bChange = false;
+
+ if (GetSizePixel() != mPosSize.GetSize())
+ {
+ bChange = true;
+ SetSizePixel(mPosSize.GetSize());
+ DoResize();
+ }
+
+ if (GetPosPixel().X() != mPosSize.TopLeft().X() || (std::abs(GetPosPixel().Y() - mPosSize.TopLeft().Y()) > 5) )
+ {
+ bChange = true;
+ SetPosPixel(mPosSize.TopLeft());
+
+ Point aLineStart;
+ Point aLineEnd ;
+ switch ( meSidebarPosition )
+ {
+ case sw::sidebarwindows::SIDEBAR_LEFT:
+ {
+ aLineStart = EditWin()->PixelToLogic( Point(GetPosPixel().X()+GetSizePixel().Width(),GetPosPixel().Y()-1) );
+ aLineEnd = EditWin()->PixelToLogic( Point(GetPosPixel().X(),GetPosPixel().Y()-1) );
+ }
+ break;
+ case sw::sidebarwindows::SIDEBAR_RIGHT:
+ {
+ aLineStart = EditWin()->PixelToLogic( Point(GetPosPixel().X(),GetPosPixel().Y()-1) );
+ aLineEnd = EditWin()->PixelToLogic( Point(GetPosPixel().X()+GetSizePixel().Width(),GetPosPixel().Y()-1) );
+ }
+ break;
+ default:
+ OSL_FAIL( "<SwSidebarWin::SetPosAndSize()> - unexpected position of sidebar" );
+ break;
+ }
+
+ if (!IsPreview())
+ {
+ if (mpAnchor)
+ {
+ mpAnchor->SetAllPosition( basegfx::B2DPoint( mAnchorRect.Left() , mAnchorRect.Bottom() - 5* 15),
+ basegfx::B2DPoint( mAnchorRect.Left()-5*15 , mAnchorRect.Bottom()+5*15),
+ basegfx::B2DPoint( mAnchorRect.Left()+5*15 , mAnchorRect.Bottom()+5*15),
+ basegfx::B2DPoint( mAnchorRect.Left(), mAnchorRect.Bottom()+2*15),
+ basegfx::B2DPoint( mPageBorder ,mAnchorRect.Bottom()+2*15),
+ basegfx::B2DPoint( aLineStart.X(),aLineStart.Y()),
+ basegfx::B2DPoint( aLineEnd.X(),aLineEnd.Y()));
+ mpAnchor->SetHeight(mAnchorRect.Height());
+ }
+ else
+ {
+ mpAnchor = AnchorOverlayObject::CreateAnchorOverlayObject( mrView,
+ mAnchorRect,
+ mPageBorder,
+ aLineStart,
+ aLineEnd,
+ mColorAnchor );
+ if ( mpAnchor )
+ {
+ mpAnchor->SetHeight(mAnchorRect.Height());
+ mpAnchor->setVisible(true);
+ mpAnchor->SetAnchorState(AS_TRI);
+ if (HasChildPathFocus())
+ {
+ mpAnchor->setLineSolid(true);
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ if ( mpAnchor &&
+ ( mpAnchor->getBasePosition() != basegfx::B2DPoint( mAnchorRect.Left() , mAnchorRect.Bottom()-5*15) ) )
+ {
+ mpAnchor->SetTriPosition( basegfx::B2DPoint( mAnchorRect.Left() , mAnchorRect.Bottom() - 5* 15),
+ basegfx::B2DPoint( mAnchorRect.Left()-5*15 , mAnchorRect.Bottom()+5*15),
+ basegfx::B2DPoint( mAnchorRect.Left()+5*15 , mAnchorRect.Bottom()+5*15),
+ basegfx::B2DPoint( mAnchorRect.Left(), mAnchorRect.Bottom()+2*15),
+ basegfx::B2DPoint( mPageBorder , mAnchorRect.Bottom()+2*15));
+ }
+ }
+
+ if (bChange)
+ {
+ Point aStart = EditWin()->PixelToLogic(GetPosPixel()+Point(0,GetSizePixel().Height()));
+ Point aEnd = EditWin()->PixelToLogic(GetPosPixel()+Point(GetSizePixel().Width()-1,GetSizePixel().Height()));
+ mpShadow->SetPosition(basegfx::B2DPoint(aStart.X(),aStart.Y()), basegfx::B2DPoint(aEnd.X(),aEnd.Y()));
+ }
+
+ if (mrMgr.ShowNotes())
+ {
+ if (IsFollow() && !HasChildPathFocus())
+ {
+ // #i111964#
+ if ( mpAnchor )
+ {
+ mpAnchor->SetAnchorState(AS_END);
+ }
+ }
+ else
+ {
+ // #i111964#
+ if ( mpAnchor )
+ {
+ mpAnchor->SetAnchorState(AS_ALL);
+ }
+ SwSidebarWin* pWin = GetTopReplyNote();
+ // #i111964#
+ if ( pWin && pWin->Anchor() )
+ {
+ pWin->Anchor()->SetAnchorState(AS_END);
+ }
+ }
+ }
+
+ // text range overlay
+ if ( mrSidebarItem.maLayoutInfo.mnStartNodeIdx != 0
+ && mrSidebarItem.maLayoutInfo.mnStartContent != -1 )
+ {
+ std::vector< basegfx::B2DRange > aAnnotationTextRanges;
+ {
+ const SwTxtAnnotationFld* pTxtAnnotationFld =
+ dynamic_cast< const SwTxtAnnotationFld* >( mrSidebarItem.GetFmtFld().GetTxtFld() );
+ if ( pTxtAnnotationFld != NULL
+ && pTxtAnnotationFld->GetpTxtNode() != NULL )
+ {
+ SwTxtNode* pTxtNode = pTxtAnnotationFld->GetpTxtNode();
+ SwNodes& rNds = pTxtNode->GetDoc()->GetNodes();
+ SwCntntNode* const pCntntNd = rNds[mrSidebarItem.maLayoutInfo.mnStartNodeIdx]->GetCntntNode();
+ SwPosition aStartPos( *pCntntNd, mrSidebarItem.maLayoutInfo.mnStartContent );
+ SwShellCrsr* pTmpCrsr = NULL;
+ const bool bTableCrsrNeeded = pTxtNode->FindTableBoxStartNode() != pCntntNd->FindTableBoxStartNode();
+ if ( bTableCrsrNeeded )
+ {
+ SwShellTableCrsr* pTableCrsr = new SwShellTableCrsr( DocView().GetWrtShell(), aStartPos );
+ pTableCrsr->SetMark();
+ pTableCrsr->GetMark()->nNode = *pTxtNode;
+ pTableCrsr->GetMark()->nContent.Assign( pTxtNode, *(pTxtAnnotationFld->GetStart())+1 );
+ pTableCrsr->NewTableSelection();
+ pTmpCrsr = pTableCrsr;
+ }
+ else
+ {
+ SwShellCrsr* pCrsr = new SwShellCrsr( DocView().GetWrtShell(), aStartPos );
+ pCrsr->SetMark();
+ pCrsr->GetMark()->nNode = *pTxtNode;
+ pCrsr->GetMark()->nContent.Assign( pTxtNode, *(pTxtAnnotationFld->GetStart())+1 );
+ pTmpCrsr = pCrsr;
+ }
+ ::boost::scoped_ptr<SwShellCrsr> pTmpCrsrForAnnotationTextRange( pTmpCrsr );
+
+ pTmpCrsrForAnnotationTextRange->FillRects();
+
+ for( sal_uInt16 a(0); a < pTmpCrsrForAnnotationTextRange->size(); ++a )
+ {
+ const SwRect aNextRect((*pTmpCrsrForAnnotationTextRange)[a]);
+ const Rectangle aPntRect(aNextRect.SVRect());
+
+ aAnnotationTextRanges.push_back(basegfx::B2DRange(
+ aPntRect.Left(), aPntRect.Top(),
+ aPntRect.Right() + 1, aPntRect.Bottom() + 1));
+ }
+ }
+ }
+
+ if ( mpTextRangeOverlay != NULL )
+ {
+ mpTextRangeOverlay->setRanges( aAnnotationTextRanges );
+ if ( mpAnchor != NULL && mpAnchor->getLineSolid() )
+ {
+ mpTextRangeOverlay->ShowSolidBorder();
+ }
+ else
+ {
+ mpTextRangeOverlay->HideSolidBorder();
+ }
+ }
+ else
+ {
+ mpTextRangeOverlay =
+ sw::overlay::OverlayRanges::CreateOverlayRange(
+ DocView(),
+ mColorAnchor,
+ aAnnotationTextRanges,
+ mpAnchor != NULL ? mpAnchor->getLineSolid() : false );
+ }
+ }
+ else
+ {
+ delete mpTextRangeOverlay;
+ mpTextRangeOverlay = NULL;
+ }
+}
+
+void SwSidebarWin::DoResize()
+{
+ long aTextHeight = LogicToPixel( mpOutliner->CalcTextSize()).Height();
+ long aHeight = GetSizePixel().Height();
+ unsigned long aWidth = GetSizePixel().Width();
+
+ aHeight -= GetMetaHeight();
+ mpMetadataAuthor->Show();
+ mpMetadataDate->Show();
+ mpSidebarTxtControl->SetQuickHelpText(OUString());
+
+ if ((aTextHeight > aHeight) && !IsPreview())
+ { // we need vertical scrollbars and have to reduce the width
+ aWidth -= GetScrollbarWidth();
+ mpVScrollbar->Show();
+ }
+ else
+ {
+ mpVScrollbar->Hide();
+ }
+
+ {
+ const Size aSizeOfMetadataControls( GetSizePixel().Width() - GetMetaButtonAreaWidth(),
+ GetMetaHeight()/2 );
+ mpMetadataAuthor->setPosSizePixel( 0,
+ aHeight,
+ aSizeOfMetadataControls.Width(),
+ aSizeOfMetadataControls.Height() );
+ mpMetadataDate->setPosSizePixel( 0,
+ aHeight + aSizeOfMetadataControls.Height(),
+ aSizeOfMetadataControls.Width(),
+ aSizeOfMetadataControls.Height() );
+ }
+
+ mpOutliner->SetPaperSize( PixelToLogic( Size(aWidth,aHeight) ) ) ;
+ if (!mpVScrollbar->IsVisible())
+ { // if we do not have a scrollbar anymore, we want to see the complete text
+ mpOutlinerView->SetVisArea( PixelToLogic( Rectangle(0,0,aWidth,aHeight) ) );
+ }
+ mpOutlinerView->SetOutputArea( PixelToLogic( Rectangle(0,0,aWidth,aHeight) ) );
+
+ if (!Application::GetSettings().GetLayoutRTL())
+ {
+ mpSidebarTxtControl->setPosSizePixel(0, 0, aWidth, aHeight);
+ mpVScrollbar->setPosSizePixel( aWidth, 0, GetScrollbarWidth(), aHeight);
+ }
+ else
+ {
+ mpSidebarTxtControl->setPosSizePixel( ( (aTextHeight > aHeight) && !IsPreview()
+ ? GetScrollbarWidth() : 0 ) , 0,
+ aWidth, aHeight);
+ mpVScrollbar->setPosSizePixel( 0, 0, GetScrollbarWidth(), aHeight);
+ }
+
+ mpVScrollbar->SetVisibleSize( PixelToLogic(Size(0,aHeight)).Height() );
+ mpVScrollbar->SetPageSize( PixelToLogic(Size(0,aHeight)).Height() * 8 / 10 );
+ mpVScrollbar->SetLineSize( mpOutliner->GetTextHeight() / 10 );
+ SetScrollbar();
+ mpVScrollbar->SetRange( Range(0, mpOutliner->GetTextHeight()));
+
+ //calculate rects for meta- button
+ const Fraction& fx( GetMapMode().GetScaleX() );
+ const Fraction& fy( GetMapMode().GetScaleY() );
+
+ const Point aPos( mpMetadataAuthor->GetPosPixel());
+ Rectangle aRectMetaButton;
+ if (IsPreview())
+ {
+ aRectMetaButton = PixelToLogic(
+ Rectangle( Point( aPos.X()+GetSizePixel().Width()-(METABUTTON_WIDTH*4+10)*fx.GetNumerator()/fx.GetDenominator(),
+ aPos.Y()+5*fy.GetNumerator()/fy.GetDenominator() ),
+ Size( METABUTTON_WIDTH*4*fx.GetNumerator()/fx.GetDenominator(),
+ METABUTTON_HEIGHT*fy.GetNumerator()/fy.GetDenominator() ) ) );
+ }
+ else
+ {
+ aRectMetaButton = PixelToLogic(
+ Rectangle( Point( aPos.X()+GetSizePixel().Width()-(METABUTTON_WIDTH+10)*fx.GetNumerator()/fx.GetDenominator(),
+ aPos.Y()+5*fy.GetNumerator()/fy.GetDenominator() ),
+ Size( METABUTTON_WIDTH*fx.GetNumerator()/fx.GetDenominator(),
+ METABUTTON_HEIGHT*fy.GetNumerator()/fy.GetDenominator() ) ) );
+ }
+
+ {
+ const Rectangle aRectMetaButtonPixel( LogicToPixel( aRectMetaButton ) );
+ mpMenuButton->setPosSizePixel( aRectMetaButtonPixel.Left(),
+ aRectMetaButtonPixel.Top(),
+ aRectMetaButtonPixel.GetWidth(),
+ aRectMetaButtonPixel.GetHeight() );
+ }
+}
+
+void SwSidebarWin::SetSizePixel( const Size& rNewSize )
+{
+ Window::SetSizePixel(rNewSize);
+
+ if (mpShadow)
+ {
+ Point aStart = EditWin()->PixelToLogic(GetPosPixel()+Point(0,GetSizePixel().Height()));
+ Point aEnd = EditWin()->PixelToLogic(GetPosPixel()+Point(GetSizePixel().Width()-1,GetSizePixel().Height()));
+ mpShadow->SetPosition(basegfx::B2DPoint(aStart.X(),aStart.Y()), basegfx::B2DPoint(aEnd.X(),aEnd.Y()));
+ }
+}
+
+void SwSidebarWin::SetScrollbar()
+{
+ mpVScrollbar->SetThumbPos(mpOutlinerView->GetVisArea().Top());
+}
+
+void SwSidebarWin::ResizeIfNecessary(long aOldHeight, long aNewHeight)
+{
+ if (aOldHeight != aNewHeight)
+ {
+ //check for lower border or next note
+ long aBorder = mrMgr.GetNextBorder();
+ if (aBorder != -1)
+ {
+ if (aNewHeight > GetMinimumSizeWithoutMeta())
+ {
+ long aNewLowerValue = GetPosPixel().Y() + aNewHeight + GetMetaHeight();
+ if (aNewLowerValue < aBorder)
+ SetSizePixel(Size(GetSizePixel().Width(),aNewHeight+GetMetaHeight()));
+ else
+ SetSizePixel(Size(GetSizePixel().Width(),aBorder - GetPosPixel().Y()));
+ DoResize();
+ Invalidate();
+ }
+ else
+ {
+ if (GetSizePixel().Height() != GetMinimumSizeWithoutMeta() + GetMetaHeight())
+ SetSizePixel(Size(GetSizePixel().Width(),GetMinimumSizeWithoutMeta() + GetMetaHeight()));
+ DoResize();
+ Invalidate();
+ }
+ }
+ else
+ {
+ DoResize();
+ Invalidate();
+ }
+ }
+ else
+ {
+ SetScrollbar();
+ }
+}
+
+void SwSidebarWin::SetColor(Color aColorDark,Color aColorLight, Color aColorAnchor)
+{
+ mColorDark = aColorDark;
+ mColorLight = aColorLight;
+ mColorAnchor = aColorAnchor;
+
+ if ( !Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
+ {
+ {
+ mpMetadataAuthor->SetControlBackground(mColorDark);
+ AllSettings aSettings = mpMetadataAuthor->GetSettings();
+ StyleSettings aStyleSettings = aSettings.GetStyleSettings();
+ aStyleSettings.SetFieldTextColor(aColorAnchor);
+ aSettings.SetStyleSettings(aStyleSettings);
+ mpMetadataAuthor->SetSettings(aSettings);
+ }
+
+ {
+ mpMetadataDate->SetControlBackground(mColorDark);
+ AllSettings aSettings = mpMetadataDate->GetSettings();
+ StyleSettings aStyleSettings = aSettings.GetStyleSettings();
+ aStyleSettings.SetFieldTextColor(aColorAnchor);
+ aSettings.SetStyleSettings(aStyleSettings);
+ mpMetadataDate->SetSettings(aSettings);
+ }
+
+ AllSettings aSettings2 = mpVScrollbar->GetSettings();
+ StyleSettings aStyleSettings2 = aSettings2.GetStyleSettings();
+ aStyleSettings2.SetButtonTextColor(Color(0,0,0));
+ aStyleSettings2.SetCheckedColor(mColorLight); // backgound
+ aStyleSettings2.SetShadowColor(mColorAnchor);
+ aStyleSettings2.SetFaceColor(mColorDark);
+ aSettings2.SetStyleSettings(aStyleSettings2);
+ mpVScrollbar->SetSettings(aSettings2);
+ }
+}
+
+void SwSidebarWin::SetSidebarPosition(sw::sidebarwindows::SidebarPosition eSidebarPosition)
+{
+ meSidebarPosition = eSidebarPosition;
+}
+
+void SwSidebarWin::SetReadonly(sal_Bool bSet)
+{
+ mbReadonly = bSet;
+ GetOutlinerView()->SetReadOnly(bSet);
+}
+
+void SwSidebarWin::SetLanguage(const SvxLanguageItem aNewItem)
+{
+ Link pLink = Engine()->GetModifyHdl();
+ Engine()->SetModifyHdl( Link() );
+ ESelection aOld = GetOutlinerView()->GetSelection();
+
+ ESelection aNewSelection( 0, 0, Engine()->GetParagraphCount()-1, EE_TEXTPOS_ALL );
+ GetOutlinerView()->SetSelection( aNewSelection );
+ SfxItemSet aEditAttr(GetOutlinerView()->GetAttribs());
+ aEditAttr.Put(aNewItem);
+ GetOutlinerView()->SetAttribs( aEditAttr );
+
+ GetOutlinerView()->SetSelection(aOld);
+ Engine()->SetModifyHdl( pLink );
+
+ const SwViewOption* pVOpt = mrView.GetWrtShellPtr()->GetViewOptions();
+ sal_uLong nCntrl = Engine()->GetControlWord();
+ // turn off
+ nCntrl &= ~EE_CNTRL_ONLINESPELLING;
+ Engine()->SetControlWord(nCntrl);
+
+ //turn back on
+ if (pVOpt->IsOnlineSpell())
+ nCntrl |= EE_CNTRL_ONLINESPELLING;
+ else
+ nCntrl &= ~EE_CNTRL_ONLINESPELLING;
+ Engine()->SetControlWord(nCntrl);
+
+ Engine()->CompleteOnlineSpelling();
+ Invalidate();
+}
+
+void SwSidebarWin::DataChanged( const DataChangedEvent& aEvent)
+{
+ Window::DataChanged( aEvent );
+}
+
+void SwSidebarWin::GetFocus()
+{
+ if (mpSidebarTxtControl)
+ mpSidebarTxtControl->GrabFocus();
+}
+
+void SwSidebarWin::LoseFocus()
+{
+}
+
+void SwSidebarWin::ShowNote()
+{
+ SetPosAndSize();
+ if (!IsVisible())
+ Window::Show();
+ if (mpShadow && !mpShadow->isVisible())
+ mpShadow->setVisible(true);
+ if (mpAnchor && !mpAnchor->isVisible())
+ mpAnchor->setVisible(true);
+}
+
+void SwSidebarWin::HideNote()
+{
+ if (IsVisible())
+ Window::Hide();
+ if (mpAnchor)
+ {
+ if (mrMgr.IsShowAnchor())
+ mpAnchor->SetAnchorState(AS_TRI);
+ else
+ mpAnchor->setVisible(false);
+ }
+ if (mpShadow && mpShadow->isVisible())
+ mpShadow->setVisible(false);
+}
+
+void SwSidebarWin::ActivatePostIt()
+{
+ mrMgr.AssureStdModeAtShell();
+
+ mpOutliner->ClearModifyFlag();
+ mpOutliner->GetUndoManager().Clear();
+
+ CheckMetaText();
+ SetViewState(VS_EDIT);
+ GetOutlinerView()->ShowCursor();
+
+ mpOutlinerView->GetEditView().SetInsertMode(mrView.GetWrtShellPtr()->IsInsMode());
+
+ if ( !Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
+ GetOutlinerView()->SetBackgroundColor(mColorDark);
+}
+
+void SwSidebarWin::DeactivatePostIt()
+{
+ // remove selection, #i87073#
+ if (GetOutlinerView()->GetEditView().HasSelection())
+ {
+ ESelection aSelection = GetOutlinerView()->GetEditView().GetSelection();
+ aSelection.nEndPara = aSelection.nStartPara;
+ aSelection.nEndPos = aSelection.nStartPos;
+ GetOutlinerView()->GetEditView().SetSelection(aSelection);
+ }
+
+ mpOutliner->CompleteOnlineSpelling();
+
+ SetViewState(VS_NORMAL);
+ // write the visible text back into the SwField
+ UpdateData();
+
+ if ( !Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
+ GetOutlinerView()->SetBackgroundColor(COL_TRANSPARENT);
+
+ if ( !IsProtected() && Engine()->GetEditEngine().GetText().isEmpty() )
+ {
+ mnEventId = Application::PostUserEvent( LINK( this, SwSidebarWin, DeleteHdl), 0 );
+ }
+}
+
+void SwSidebarWin::ToggleInsMode()
+{
+ if (!mrView.GetWrtShell().IsRedlineOn())
+ {
+ //change outliner
+ mpOutlinerView->GetEditView().SetInsertMode(!mpOutlinerView->GetEditView().IsInsertMode());
+ //change document
+ mrView.GetWrtShell().ToggleInsMode();
+ //update statusbar
+ SfxBindings &rBnd = mrView.GetViewFrame()->GetBindings();
+ rBnd.Invalidate(SID_ATTR_INSERT);
+ rBnd.Update(SID_ATTR_INSERT);
+ }
+}
+
+void SwSidebarWin::ExecuteCommand(sal_uInt16 nSlot)
+{
+ mrMgr.AssureStdModeAtShell();
+
+ switch (nSlot)
+ {
+ case FN_POSTIT:
+ case FN_REPLY:
+ {
+ // if this note is empty, it will be deleted once losing the focus, so no reply, but only a new note
+ // will be created
+ if (!Engine()->GetEditEngine().GetText().isEmpty())
+ {
+ OutlinerParaObject* pPara = new OutlinerParaObject(*GetOutlinerView()->GetEditView().CreateTextObject());
+ mrMgr.RegisterAnswer(pPara);
+ }
+ if (mrMgr.HasActiveSidebarWin())
+ mrMgr.SetActiveSidebarWin(0);
+ SwitchToFieldPos();
+ mrView.GetViewFrame()->GetDispatcher()->Execute(FN_POSTIT);
+ break;
+ }
+ case FN_DELETE_COMMENT:
+
+ //Delete(); // do not kill the parent of our open popup menu
+ mnEventId = Application::PostUserEvent( LINK( this, SwSidebarWin, DeleteHdl), 0 );
+ break;
+ case FN_DELETE_ALL_NOTES:
+ case FN_HIDE_ALL_NOTES:
+ // not possible as slot as this would require that "this" is the active postit
+ mrView.GetViewFrame()->GetBindings().Execute( nSlot, 0, 0, SFX_CALLMODE_ASYNCHRON );
+ break;
+ case FN_DELETE_NOTE_AUTHOR:
+ case FN_HIDE_NOTE_AUTHOR:
+ {
+ // not possible as slot as this would require that "this" is the active postit
+ SfxStringItem aItem( nSlot, GetAuthor() );
+ const SfxPoolItem* aItems[2];
+ aItems[0] = &aItem;
+ aItems[1] = 0;
+ mrView.GetViewFrame()->GetBindings().Execute( nSlot, aItems, 0, SFX_CALLMODE_ASYNCHRON );
+ }
+ break;
+ default:
+ mrView.GetViewFrame()->GetBindings().Execute( nSlot );
+ break;
+ }
+}
+
+SwEditWin* SwSidebarWin::EditWin()
+{
+ return &mrView.GetEditWin();
+}
+
+long SwSidebarWin::GetPostItTextHeight()
+{
+ return mpOutliner ? LogicToPixel(mpOutliner->CalcTextSize()).Height() : 0;
+}
+
+void SwSidebarWin::SwitchToPostIt(sal_uInt16 aDirection)
+{
+ SwSidebarWin* pPostIt = mrMgr.GetNextPostIt(aDirection, this);
+ if (pPostIt)
+ pPostIt->GrabFocus();
+}
+
+IMPL_LINK( SwSidebarWin, WindowEventListener, VclSimpleEvent*, pEvent )
+{
+ VclWindowEvent* pWinEvent = dynamic_cast<VclWindowEvent*>(pEvent);
+ if ( pWinEvent )
+ {
+ if ( pWinEvent->GetId() == VCLEVENT_WINDOW_MOUSEMOVE )
+ {
+ MouseEvent* pMouseEvt = (MouseEvent*)pWinEvent->GetData();
+ if ( pMouseEvt->IsEnterWindow() )
+ {
+ mbMouseOver = true;
+ if ( !HasFocus() )
+ {
+ SetViewState(VS_VIEW);
+ Invalidate();
+ }
+ }
+ else if ( pMouseEvt->IsLeaveWindow())
+ {
+ if (!IsPreview())
+ {
+ mbMouseOver = false;
+ if ( !HasFocus() )
+ {
+ SetViewState(VS_NORMAL);
+ Invalidate();
+ }
+ }
+ }
+ }
+ else if ( pWinEvent->GetId() == VCLEVENT_WINDOW_ACTIVATE &&
+ pWinEvent->GetWindow() == mpSidebarTxtControl )
+ {
+ const sal_Bool bLockView = mrView.GetWrtShell().IsViewLocked();
+ mrView.GetWrtShell().LockView( sal_True );
+
+ if ( !IsPreview() )
+ {
+ mrMgr.SetActiveSidebarWin( this );
+ }
+
+ mrView.GetWrtShell().LockView( bLockView );
+ mrMgr.MakeVisible( this );
+ }
+ }
+ return sal_True;
+}
+
+void SwSidebarWin::Delete()
+{
+ if ( mrMgr.GetActiveSidebarWin() == this)
+ {
+ mrMgr.SetActiveSidebarWin(0);
+ // if the note is empty, the previous line will send a delete event, but we are already there
+ if (mnEventId)
+ {
+ Application::RemoveUserEvent( mnEventId );
+ mnEventId = 0;
+ }
+ }
+}
+
+IMPL_LINK(SwSidebarWin, ScrollHdl, ScrollBar*, pScroll)
+{
+ long nDiff = GetOutlinerView()->GetEditView().GetVisArea().Top() - pScroll->GetThumbPos();
+ GetOutlinerView()->Scroll( 0, nDiff );
+ return 0;
+}
+
+IMPL_LINK_NOARG(SwSidebarWin, ModifyHdl)
+{
+ mrView.GetDocShell()->SetModified(sal_True);
+ return 0;
+}
+
+IMPL_LINK_NOARG(SwSidebarWin, DeleteHdl)
+{
+ mnEventId = 0;
+ Delete();
+ return 0;
+}
+
+void SwSidebarWin::ResetAttributes()
+{
+ mpOutlinerView->RemoveAttribsKeepLanguages(true);
+ mpOutliner->RemoveFields(true);
+ mpOutlinerView->SetAttribs(DefaultItem());
+}
+
+sal_Int32 SwSidebarWin::GetScrollbarWidth()
+{
+ return mrView.GetWrtShell().GetViewOptions()->GetZoom() / 10;
+}
+
+sal_Int32 SwSidebarWin::GetMetaButtonAreaWidth()
+{
+ const Fraction& f( GetMapMode().GetScaleX() );
+ if (IsPreview())
+ return 3 * METABUTTON_AREA_WIDTH * f.GetNumerator() / f.GetDenominator();
+ else
+ return METABUTTON_AREA_WIDTH * f.GetNumerator() / f.GetDenominator();
+}
+
+sal_Int32 SwSidebarWin::GetMetaHeight()
+{
+ const Fraction& f( GetMapMode().GetScaleY() );
+ return POSTIT_META_HEIGHT * f.GetNumerator() / f.GetDenominator();
+}
+
+sal_Int32 SwSidebarWin::GetMinimumSizeWithMeta()
+{
+ return mrMgr.GetMinimumSizeWithMeta();
+}
+
+sal_Int32 SwSidebarWin::GetMinimumSizeWithoutMeta()
+{
+ const Fraction& f( GetMapMode().GetScaleY() );
+ return POSTIT_MINIMUMSIZE_WITHOUT_META * f.GetNumerator() / f.GetDenominator();
+}
+
+void SwSidebarWin::SetSpellChecking()
+{
+ const SwViewOption* pVOpt = mrView.GetWrtShellPtr()->GetViewOptions();
+ sal_uLong nCntrl = mpOutliner->GetControlWord();
+ if (pVOpt->IsOnlineSpell())
+ nCntrl |= EE_CNTRL_ONLINESPELLING;
+ else
+ nCntrl &= ~EE_CNTRL_ONLINESPELLING;
+ mpOutliner->SetControlWord(nCntrl);
+
+ mpOutliner->CompleteOnlineSpelling();
+ Invalidate();
+}
+
+void SwSidebarWin::SetViewState(ViewState bViewState)
+{
+ switch (bViewState)
+ {
+ case VS_EDIT:
+ {
+ if (mpAnchor)
+ {
+ mpAnchor->SetAnchorState(AS_ALL);
+ SwSidebarWin* pWin = GetTopReplyNote();
+ // #i111964#
+ if ( pWin && pWin->Anchor() )
+ {
+ pWin->Anchor()->SetAnchorState(AS_END);
+ }
+ mpAnchor->setLineSolid(true);
+ if ( mpTextRangeOverlay != NULL )
+ {
+ mpTextRangeOverlay->ShowSolidBorder();
+ }
+ }
+ if (mpShadow)
+ mpShadow->SetShadowState(SS_EDIT);
+ break;
+ }
+ case VS_VIEW:
+ {
+ if (mpAnchor)
+ {
+ mpAnchor->setLineSolid(true);
+ if ( mpTextRangeOverlay != NULL )
+ {
+ mpTextRangeOverlay->ShowSolidBorder();
+ }
+ }
+ if (mpShadow)
+ mpShadow->SetShadowState(SS_VIEW);
+ break;
+ }
+ case VS_NORMAL:
+ {
+ if (mpAnchor)
+ {
+ if (IsFollow())
+ {
+ // if there is no visible parent note, we want to see the complete anchor ??
+ //if (IsAnyStackParentVisible())
+ mpAnchor->SetAnchorState(AS_END);
+ SwSidebarWin* pTopWinSelf = GetTopReplyNote();
+ SwSidebarWin* pTopWinActive = mrMgr.HasActiveSidebarWin()
+ ? mrMgr.GetActiveSidebarWin()->GetTopReplyNote()
+ : 0;
+ // #i111964#
+ if ( pTopWinSelf && ( pTopWinSelf != pTopWinActive ) &&
+ pTopWinSelf->Anchor() )
+ {
+ if ( pTopWinSelf != mrMgr.GetActiveSidebarWin() )
+ {
+ pTopWinSelf->Anchor()->setLineSolid(false);
+ if ( pTopWinSelf->TextRange() != NULL )
+ {
+ pTopWinSelf->TextRange()->HideSolidBorder();
+ }
+ }
+ pTopWinSelf->Anchor()->SetAnchorState(AS_ALL);
+ }
+ }
+ mpAnchor->setLineSolid(false);
+ if ( mpTextRangeOverlay != NULL )
+ {
+ mpTextRangeOverlay->HideSolidBorder();
+ }
+ }
+ if ( mpShadow )
+ {
+ mpShadow->SetShadowState(SS_NORMAL);
+ }
+ break;
+ }
+ }
+}
+
+SwSidebarWin* SwSidebarWin::GetTopReplyNote()
+{
+ SwSidebarWin* pTopNote = 0;
+ SwSidebarWin* pSidebarWin = IsFollow() ? mrMgr.GetNextPostIt(KEY_PAGEUP, this) : 0;
+ while (pSidebarWin)
+ {
+ pTopNote = pSidebarWin;
+ pSidebarWin = pSidebarWin->IsFollow() ? mrMgr.GetNextPostIt(KEY_PAGEUP, pSidebarWin) : 0;
+ }
+ return pTopNote;
+}
+
+void SwSidebarWin::SwitchToFieldPos()
+{
+ if ( mrMgr.GetActiveSidebarWin() == this )
+ mrMgr.SetActiveSidebarWin(0);
+ GotoPos();
+ sal_uInt32 aCount = MoveCaret();
+ if (aCount)
+ mrView.GetDocShell()->GetWrtShell()->SwCrsrShell::Right(aCount, 0, sal_False);
+ GrabFocusToDocument();
+}
+
+SvxLanguageItem SwSidebarWin::GetLanguage(void)
+{
+ return SvxLanguageItem(SwLangHelper::GetLanguage(mrView.GetWrtShell(),RES_CHRATR_LANGUAGE),RES_CHRATR_LANGUAGE);
+}
+
+void SwSidebarWin::SetChangeTracking( const SwPostItHelper::SwLayoutStatus aLayoutStatus,
+ const Color& aChangeColor )
+{
+ if ( (mLayoutStatus != aLayoutStatus) ||
+ (mChangeColor != aChangeColor) )
+ {
+ mLayoutStatus = aLayoutStatus;
+ mChangeColor = aChangeColor;
+ Invalidate();
+ }
+}
+
+bool SwSidebarWin::HasScrollbar() const
+{
+ return mpVScrollbar != 0;
+}
+
+bool SwSidebarWin::IsScrollbarVisible() const
+{
+ return HasScrollbar() && mpVScrollbar->IsVisible();
+}
+
+void SwSidebarWin::ChangeSidebarItem( SwSidebarItem& rSidebarItem )
+{
+ const bool bAnchorChanged = mpAnchorFrm != rSidebarItem.maLayoutInfo.mpAnchorFrm;
+ if ( bAnchorChanged )
+ {
+ mrMgr.DisconnectSidebarWinFromFrm( *(mpAnchorFrm), *this );
+ }
+
+ mrSidebarItem = rSidebarItem;
+ mpAnchorFrm = mrSidebarItem.maLayoutInfo.mpAnchorFrm;
+
+ if ( GetWindowPeer() )
+ {
+ SidebarWinAccessible* pAcc =
+ static_cast<SidebarWinAccessible*>( GetWindowPeer() );
+ OSL_ENSURE( dynamic_cast<SidebarWinAccessible*>( GetWindowPeer() ),
+ "<SwSidebarWin::ChangeSidebarItem(..)> - unexpected type of window peer -> crash possible!" );
+ pAcc->ChangeSidebarItem( mrSidebarItem );
+ }
+
+ if ( bAnchorChanged )
+ {
+ mrMgr.ConnectSidebarWinToFrm( *(mrSidebarItem.maLayoutInfo.mpAnchorFrm),
+ mrSidebarItem.GetFmtFld(),
+ *this );
+ }
+}
+
+css::uno::Reference< css::accessibility::XAccessible > SwSidebarWin::CreateAccessible()
+{
+ SidebarWinAccessible* pAcc( new SidebarWinAccessible( *this,
+ mrView.GetWrtShell(),
+ mrSidebarItem ) );
+ css::uno::Reference< css::awt::XWindowPeer > xWinPeer( pAcc );
+ SetWindowPeer( xWinPeer, pAcc );
+
+ css::uno::Reference< css::accessibility::XAccessible > xAcc( xWinPeer, css::uno::UNO_QUERY );
+ return xAcc;
+}
+
+} } // eof of namespace sw::sidebarwindows
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/docvw/SidebarWinAcc.cxx b/sw/source/core/uibase/docvw/SidebarWinAcc.cxx
new file mode 100644
index 000000000000..99ba832a60db
--- /dev/null
+++ b/sw/source/core/uibase/docvw/SidebarWinAcc.cxx
@@ -0,0 +1,143 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <SidebarWinAcc.hxx>
+
+#include <SidebarWin.hxx>
+#include <viewsh.hxx>
+#include <accmap.hxx>
+#include <toolkit/awt/vclxaccessiblecomponent.hxx>
+
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+
+namespace sw { namespace sidebarwindows {
+
+// declaration and implementation of accessible context for <SidebarWinAccessible> instance
+class SidebarWinAccessibleContext : public VCLXAccessibleComponent
+{
+ public:
+ explicit SidebarWinAccessibleContext( SwSidebarWin& rSidebarWin,
+ SwViewShell& rViewShell,
+ const SwFrm* pAnchorFrm )
+ : VCLXAccessibleComponent( rSidebarWin.GetWindowPeer() )
+ , mrViewShell( rViewShell )
+ , mpAnchorFrm( pAnchorFrm )
+ , maMutex()
+ {
+ rSidebarWin.SetAccessibleRole( css::accessibility::AccessibleRole::COMMENT );
+ }
+
+ virtual ~SidebarWinAccessibleContext()
+ {}
+
+ void ChangeAnchor( const SwFrm* pAnchorFrm )
+ {
+ osl::MutexGuard aGuard(maMutex);
+
+ mpAnchorFrm = pAnchorFrm;
+ }
+
+ virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL
+ getAccessibleParent() throw (css::uno::RuntimeException, std::exception)
+ {
+ osl::MutexGuard aGuard(maMutex);
+
+ css::uno::Reference< css::accessibility::XAccessible > xAccParent;
+
+ if ( mpAnchorFrm &&
+ mrViewShell.GetAccessibleMap() )
+ {
+ xAccParent = mrViewShell.GetAccessibleMap()->GetContext( mpAnchorFrm, sal_False );
+ }
+
+ return xAccParent;
+ }
+
+ virtual sal_Int32 SAL_CALL getAccessibleIndexInParent() throw (css::uno::RuntimeException, std::exception)
+ {
+ osl::MutexGuard aGuard(maMutex);
+
+ sal_Int32 nIndex( -1 );
+
+ if ( mpAnchorFrm && GetWindow() &&
+ mrViewShell.GetAccessibleMap() )
+ {
+ nIndex = mrViewShell.GetAccessibleMap()->GetChildIndex( *mpAnchorFrm,
+ *GetWindow() );
+ }
+
+ return nIndex;
+ }
+
+ private:
+ SwViewShell& mrViewShell;
+ const SwFrm* mpAnchorFrm;
+
+ ::osl::Mutex maMutex;
+};
+
+// implementaion of accessible for <SwSidebarWin> instance
+SidebarWinAccessible::SidebarWinAccessible( SwSidebarWin& rSidebarWin,
+ SwViewShell& rViewShell,
+ const SwSidebarItem& rSidebarItem )
+ : VCLXWindow()
+ , mrSidebarWin( rSidebarWin )
+ , mrViewShell( rViewShell )
+ , mpAnchorFrm( rSidebarItem.maLayoutInfo.mpAnchorFrm )
+ , bAccContextCreated( false )
+{
+ SetWindow( &mrSidebarWin );
+}
+
+SidebarWinAccessible::~SidebarWinAccessible()
+{
+}
+
+void SidebarWinAccessible::ChangeSidebarItem( const SwSidebarItem& rSidebarItem )
+{
+ if ( bAccContextCreated )
+ {
+ css::uno::Reference< css::accessibility::XAccessibleContext > xAcc
+ = getAccessibleContext();
+ if ( xAcc.is() )
+ {
+ SidebarWinAccessibleContext* pAccContext =
+ dynamic_cast<SidebarWinAccessibleContext*>(xAcc.get());
+ if ( pAccContext )
+ {
+ pAccContext->ChangeAnchor( rSidebarItem.maLayoutInfo.mpAnchorFrm );
+ }
+ }
+ }
+}
+
+css::uno::Reference< css::accessibility::XAccessibleContext > SidebarWinAccessible::CreateAccessibleContext()
+{
+ SidebarWinAccessibleContext* pAccContext =
+ new SidebarWinAccessibleContext( mrSidebarWin,
+ mrViewShell,
+ mpAnchorFrm );
+ css::uno::Reference< css::accessibility::XAccessibleContext > xAcc( pAccContext );
+ bAccContextCreated = true;
+ return xAcc;
+}
+
+} } // end of namespace sw::sidebarwindows
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/docvw/SidebarWinAcc.hxx b/sw/source/core/uibase/docvw/SidebarWinAcc.hxx
new file mode 100644
index 000000000000..c86516d5ce99
--- /dev/null
+++ b/sw/source/core/uibase/docvw/SidebarWinAcc.hxx
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SW_SOURCE_UI_DOCVW_SIDEBARWINACC_HXX
+#define INCLUDED_SW_SOURCE_UI_DOCVW_SIDEBARWINACC_HXX
+
+#include <toolkit/awt/vclxwindow.hxx>
+
+class SwViewShell;
+class SwSidebarItem;
+class SwFrm;
+
+namespace sw { namespace sidebarwindows {
+
+class SwSidebarWin;
+
+class SidebarWinAccessible : public VCLXWindow
+{
+ public:
+ explicit SidebarWinAccessible( SwSidebarWin& rSidebarWin,
+ SwViewShell& rViewShell,
+ const SwSidebarItem& rSidebarItem );
+ virtual ~SidebarWinAccessible();
+
+ virtual com::sun::star::uno::Reference< com::sun::star::accessibility::XAccessibleContext >
+ CreateAccessibleContext();
+
+ void ChangeSidebarItem( const SwSidebarItem& rSidebarItem );
+
+ private:
+ SwSidebarWin& mrSidebarWin;
+ SwViewShell& mrViewShell;
+ const SwFrm* mpAnchorFrm;
+ bool bAccContextCreated;
+};
+
+} } // end of namespace sw::sidebarwindows
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/docvw/annotation.hrc b/sw/source/core/uibase/docvw/annotation.hrc
new file mode 100644
index 000000000000..7daf55524899
--- /dev/null
+++ b/sw/source/core/uibase/docvw/annotation.hrc
@@ -0,0 +1,45 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef _ANNOTATION_HRC
+#define _ANNOTATION_HRC
+
+#include "rcid.hrc"
+
+#define STR_POSTIT_TODAY (RC_ANNOTATION_BEGIN + 1)
+#define STR_POSTIT_YESTERDAY (RC_ANNOTATION_BEGIN + 2)
+
+#define STR_DELETE_ALL_NOTES (RC_ANNOTATION_BEGIN + 3)
+#define STR_DELETE_AUTHOR_NOTES (RC_ANNOTATION_BEGIN + 4)
+
+#define STR_NODATE (RC_ANNOTATION_BEGIN + 5)
+#define STR_NOAUTHOR (RC_ANNOTATION_BEGIN + 6)
+
+#define STR_REPLY (RC_ANNOTATION_BEGIN + 7)
+
+
+#define ANNOTATION_ACT_END STR_REPLY
+#if ANNOTATION_ACT_END > RC_ANNOTATION_END
+#error Resource-Id Ueberlauf in #file, #line
+#endif
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/docvw/docvw.hrc b/sw/source/core/uibase/docvw/docvw.hrc
new file mode 100644
index 000000000000..7f5e5b6e9786
--- /dev/null
+++ b/sw/source/core/uibase/docvw/docvw.hrc
@@ -0,0 +1,91 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef _DOCVW_HRC
+#define _DOCVW_HRC
+
+#include "rcid.hrc"
+
+#define MN_READONLY_POPUP (RC_DOCVW_BEGIN + 1)
+#define MN_READONLY_OPENURL (RC_DOCVW_BEGIN + 2)
+#define MN_READONLY_OPENURLNEW (RC_DOCVW_BEGIN + 3)
+#define MN_READONLY_EDITDOC (RC_DOCVW_BEGIN + 4)
+// free (5)
+#define MN_READONLY_BROWSE_BACKWARD (RC_DOCVW_BEGIN + 6)
+#define MN_READONLY_BROWSE_FORWARD (RC_DOCVW_BEGIN + 7)
+#define MN_READONLY_SELECTION_MODE (RC_DOCVW_BEGIN + 8)
+#define MN_READONLY_SAVEGRAPHIC (RC_DOCVW_BEGIN + 11)
+#define MN_READONLY_SAVEBACKGROUND (RC_DOCVW_BEGIN + 12)
+#define MN_READONLY_COPYLINK (RC_DOCVW_BEGIN + 13)
+#define MN_READONLY_COPYGRAPHIC (RC_DOCVW_BEGIN + 14)
+#define MN_READONLY_LOADGRAPHIC (RC_DOCVW_BEGIN + 15)
+#define MN_READONLY_GRAPHICOFF (RC_DOCVW_BEGIN + 16)
+#define MN_READONLY_PLUGINOFF (RC_DOCVW_BEGIN + 17)
+#define MN_READONLY_TOGALLERYLINK (RC_DOCVW_BEGIN + 18)
+#define MN_READONLY_TOGALLERYCOPY (RC_DOCVW_BEGIN + 19)
+#define MN_READONLY_SOURCEVIEW (RC_DOCVW_BEGIN + 20)
+#define MN_READONLY_RELOAD_FRAME (RC_DOCVW_BEGIN + 21)
+#define MN_READONLY_RELOAD (RC_DOCVW_BEGIN + 22)
+#define MN_READONLY_COPY (RC_DOCVW_BEGIN + 23)
+
+//For the following we need space for the gallery-themes
+#define MN_READONLY_GRAPHICTOGALLERY (RC_DOCVW_BEGIN + 24)
+#define MN_READONLY_BACKGROUNDTOGALLERY (RC_DOCVW_BEGIN + 60)
+
+
+#define STR_CHAIN_OK (RC_DOCVW_BEGIN + 2)
+#define STR_CHAIN_NOT_EMPTY (RC_DOCVW_BEGIN + 3)
+#define STR_CHAIN_IS_IN_CHAIN (RC_DOCVW_BEGIN + 4)
+#define STR_CHAIN_WRONG_AREA (RC_DOCVW_BEGIN + 5)
+#define STR_CHAIN_NOT_FOUND (RC_DOCVW_BEGIN + 6)
+#define STR_CHAIN_SOURCE_CHAINED (RC_DOCVW_BEGIN + 7)
+#define STR_CHAIN_SELF (RC_DOCVW_BEGIN + 8)
+#define STR_REDLINE_INSERT (RC_DOCVW_BEGIN + 9)
+#define STR_REDLINE_DELETE (RC_DOCVW_BEGIN + 10)
+#define STR_REDLINE_FORMAT (RC_DOCVW_BEGIN + 11)
+#define STR_REDLINE_TABLE (RC_DOCVW_BEGIN + 12)
+#define STR_REDLINE_FMTCOLL (RC_DOCVW_BEGIN + 13)
+#define STR_ENDNOTE (RC_DOCVW_BEGIN + 14)
+#define STR_FTNNOTE (RC_DOCVW_BEGIN + 15)
+
+#define STR_TABLE_COL_ADJUST (RC_DOCVW_BEGIN + 16)
+#define STR_TABLE_ROW_ADJUST (RC_DOCVW_BEGIN + 17)
+#define STR_TABLE_SELECT_ALL (RC_DOCVW_BEGIN + 18)
+#define STR_TABLE_SELECT_ROW (RC_DOCVW_BEGIN + 19)
+#define STR_TABLE_SELECT_COL (RC_DOCVW_BEGIN + 20)
+
+#define STR_SMARTTAG_CLICK (RC_DOCVW_BEGIN + 21)
+
+#define STR_HEADER_TITLE (RC_DOCVW_BEGIN + 22)
+#define STR_FOOTER_TITLE (RC_DOCVW_BEGIN + 23)
+#define STR_DELETE_HEADER (RC_DOCVW_BEGIN + 24)
+#define STR_FORMAT_HEADER (RC_DOCVW_BEGIN + 25)
+#define STR_DELETE_FOOTER (RC_DOCVW_BEGIN + 26)
+#define STR_FORMAT_FOOTER (RC_DOCVW_BEGIN + 27)
+
+#define DOCVW_ACT_END STR_SMARTTAG_CLICK
+
+#if DOCVW_ACT_END > RC_DOCVW_END
+#error Resource-Id Ueberlauf in #file, #line
+#endif
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/docvw/docvw.src b/sw/source/core/uibase/docvw/docvw.src
new file mode 100644
index 000000000000..ff10f368a012
--- /dev/null
+++ b/sw/source/core/uibase/docvw/docvw.src
@@ -0,0 +1,307 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "docvw.hrc"
+#include "cmdid.h"
+#include "helpid.h"
+#define SEPARATOR MenuItem { Separator = TRUE; };
+Menu MN_READONLY_POPUP
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = MN_READONLY_OPENURL ;
+ HelpId = CMD_SID_OPENDOC ;
+ Text [ en-US ] = "~Open" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_READONLY_OPENURLNEW ;
+ HelpId = CMD_SID_OPENDOC ;
+ Text [ en-US ] = "Open in New Window" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_READONLY_EDITDOC ;
+ HelpId = CMD_SID_EDITDOC ;
+ Text [ en-US ] = "~Edit" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_READONLY_SELECTION_MODE ;
+ HelpId = CMD_FN_READONLY_SELECTION_MODE ;
+ Text [ en-US ] = "Select Text";
+ };
+ MenuItem
+ {
+ Identifier = MN_READONLY_RELOAD;
+ HelpId = CMD_SID_RELOAD;
+ Text [ en-US ] = "Re~load";
+ };
+ MenuItem
+ {
+ Identifier = MN_READONLY_RELOAD_FRAME;
+ HelpId = CMD_SID_RELOAD;
+ Text [ en-US ] = "Reload Frame";
+ };
+ MenuItem
+ {
+ Identifier = MN_READONLY_SOURCEVIEW ;
+ HelpId = HID_SOURCEVIEW ;
+ Text [ en-US ] = "HT~ML Source" ;
+ };
+ SEPARATOR
+ MenuItem
+ {
+ Identifier = MN_READONLY_BROWSE_BACKWARD ;
+ HelpId = CMD_SID_BROWSE_BACKWARD ;
+ Text [ en-US ] = "Backwards" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_READONLY_BROWSE_FORWARD ;
+ HelpId = CMD_SID_BROWSE_FORWARD ;
+ Text [ en-US ] = "~Forward" ;
+ };
+ SEPARATOR
+ MenuItem
+ {
+ Identifier = MN_READONLY_SAVEGRAPHIC ;
+ HelpID = HID_MN_READONLY_SAVEGRAPHIC ;
+ Text [ en-US ] = "Save Image..." ;
+ };
+ MenuItem
+ {
+ Identifier = MN_READONLY_GRAPHICTOGALLERY ;
+ HelpID = HID_MN_READONLY_GRAPHICTOGALLERY ;
+ SubMenu = Menu
+ {
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = MN_READONLY_TOGALLERYLINK ;
+ HelpID = HID_MN_READONLY_TOGALLERYLINK ;
+ Text [ en-US ] = "As Link" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_READONLY_TOGALLERYCOPY ;
+ HelpID = HID_MN_READONLY_TOGALLERYCOPY ;
+ Text [ en-US ] = "Copy" ;
+ };
+ SEPARATOR
+ };
+ };
+ Text [ en-US ] = "Add Image" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_READONLY_SAVEBACKGROUND ;
+ HelpID = HID_MN_READONLY_SAVEBACKGROUND ;
+ Text [ en-US ] = "Save Background..." ;
+ };
+ MenuItem
+ {
+ Identifier = MN_READONLY_BACKGROUNDTOGALLERY ;
+ HelpID = HID_MN_READONLY_BACKGROUNDTOGALLERY ;
+ SubMenu = Menu
+ {
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = MN_READONLY_TOGALLERYLINK ;
+ HelpID = HID_MN_READONLY_TOGALLERYLINK ;
+ Text [ en-US ] = "As Link" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_READONLY_TOGALLERYCOPY ;
+ HelpID = HID_MN_READONLY_TOGALLERYCOPY ;
+ Text [ en-US ] = "Copy" ;
+ };
+ SEPARATOR
+ };
+ };
+ Text [ en-US ] = "Add Background" ;
+ };
+ SEPARATOR
+ MenuItem
+ {
+ Identifier = MN_READONLY_COPYLINK ;
+ HelpID = HID_MN_READONLY_COPYLINK ;
+ Text [ en-US ] = "Copy ~Link" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_READONLY_COPYGRAPHIC ;
+ HelpID = HID_MN_READONLY_COPYGRAPHIC ;
+ Text [ en-US ] = "Copy ~Image" ;
+ };
+ SEPARATOR
+ MenuItem
+ {
+ Identifier = MN_READONLY_LOADGRAPHIC ;
+ HelpID = HID_MN_READONLY_LOADGRAPHIC ;
+ Text [ en-US ] = "Load Image" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_READONLY_GRAPHICOFF ;
+ HelpID = HID_MN_READONLY_GRAPHICOFF ;
+ Text [ en-US ] = "Image Off" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_READONLY_PLUGINOFF ;
+ HelpID = HID_MN_READONLY_PLUGINOFF ;
+ Text [ en-US ] = "Plug-ins Off" ;
+ };
+ SEPARATOR
+ MenuItem
+ {
+ Identifier = SID_WIN_FULLSCREEN;
+ HelpId = CMD_SID_WIN_FULLSCREEN;
+ Text [ en-US ] = "Leave Full-Screen Mode" ;
+ };
+ SEPARATOR
+ MenuItem
+ {
+ Identifier = MN_READONLY_COPY ;
+ HelpId = CMD_SID_COPY;
+ Text [ en-US ] = "~Copy" ;
+ };
+ };
+};
+String STR_CHAIN_OK
+{
+ Text [ en-US ] = "Click the left mouse button to link the frames." ;
+};
+String STR_CHAIN_NOT_EMPTY
+{
+ Text [ en-US ] = "Target frame not empty." ;
+};
+String STR_CHAIN_IS_IN_CHAIN
+{
+ Text [ en-US ] = "Target frame is already linked." ;
+};
+String STR_CHAIN_WRONG_AREA
+{
+ Text [ en-US ] = "The target frame for the link is in an invalid area." ;
+};
+String STR_CHAIN_NOT_FOUND
+{
+ Text [ en-US ] = "Target frame not found at current position." ;
+};
+String STR_CHAIN_SOURCE_CHAINED
+{
+ Text [ en-US ] = "The source frame is already the source of a link." ;
+};
+String STR_CHAIN_SELF
+{
+ Text [ en-US ] = "A closed link is not possible." ;
+};
+String STR_REDLINE_INSERT
+{
+ Text [ en-US ] = "Inserted" ;
+};
+String STR_REDLINE_DELETE
+{
+ Text [ en-US ] = "Deleted" ;
+};
+String STR_REDLINE_FORMAT
+{
+ Text [ en-US ] = "Formatted" ;
+};
+String STR_REDLINE_TABLE
+{
+ Text [ en-US ] = "Table changed" ;
+};
+String STR_REDLINE_FMTCOLL
+{
+ Text [ en-US ] = "Applied Paragraph Styles";
+};
+String STR_ENDNOTE
+{
+ Text [ en-US ] = "Endnote: " ;
+};
+String STR_FTNNOTE
+{
+ Text [ en-US ] = "Footnote: " ;
+};
+
+String STR_TABLE_COL_ADJUST
+{
+ Text [ en-US ] = "Adjust table column" ;
+};
+String STR_TABLE_ROW_ADJUST
+{
+ Text [ en-US ] = "Adjust table row" ;
+};
+String STR_TABLE_SELECT_ALL
+{
+ Text [ en-US ] = "Select whole table" ;
+};
+String STR_TABLE_SELECT_ROW
+{
+ Text [ en-US ] = "Select table row" ;
+};
+String STR_TABLE_SELECT_COL
+{
+ Text [ en-US ] = "Select table column" ;
+};
+
+String STR_SMARTTAG_CLICK
+{
+ Text [ en-US ] = "%s-click to open Smart Tag menu" ;
+};
+
+String STR_HEADER_TITLE
+{
+ Text [ en-US ] = "Header (%1)" ;
+};
+
+String STR_FOOTER_TITLE
+{
+ Text [ en-US ] = "Footer (%1)" ;
+};
+
+String STR_DELETE_HEADER
+{
+ Text [ en-US ] = "Delete Header..." ;
+};
+
+String STR_FORMAT_HEADER
+{
+ Text [ en-US ] = "Format Header..." ;
+};
+
+String STR_DELETE_FOOTER
+{
+ Text [ en-US ] = "Delete Footer..." ;
+};
+
+String STR_FORMAT_FOOTER
+{
+ Text [ en-US ] = "Format Footer..." ;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/docvw/edtdd.cxx b/sw/source/core/uibase/docvw/edtdd.cxx
new file mode 100644
index 000000000000..da9d0fb9cc4e
--- /dev/null
+++ b/sw/source/core/uibase/docvw/edtdd.cxx
@@ -0,0 +1,495 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <hintids.hxx>
+
+#include <svx/svdview.hxx>
+#include <editeng/outliner.hxx>
+#include <svx/svdobj.hxx>
+#include <sot/exchange.hxx>
+#include <sot/formats.hxx>
+#include <sfx2/bindings.hxx>
+
+#include <sfx2/viewfrm.hxx>
+#include <fmturl.hxx>
+#include <frmfmt.hxx>
+#include <wrtsh.hxx>
+#include <edtwin.hxx>
+#include <view.hxx>
+#include <viewopt.hxx>
+#include <swdtflvr.hxx>
+#include <swmodule.hxx>
+#include <docsh.hxx>
+#include <wdocsh.hxx>
+#include <swundo.hxx>
+
+using namespace ::com::sun::star;
+
+// no include "dbgoutsw.hxx" here!!!!!!
+
+extern bool bNoInterrupt;
+extern bool bFrmDrag;
+extern bool bDDTimerStarted;
+
+bool bExecuteDrag = false;
+
+void SwEditWin::StartDDTimer()
+{
+ m_aTimer.SetTimeoutHdl(LINK(this, SwEditWin, DDHandler));
+ m_aTimer.SetTimeout(480);
+ m_aTimer.Start();
+ bDDTimerStarted = true;
+}
+
+void SwEditWin::StopDDTimer(SwWrtShell *pSh, const Point &rPt)
+{
+ m_aTimer.Stop();
+ bDDTimerStarted = false;
+ if(!pSh->IsSelFrmMode())
+ pSh->SetCursor(&rPt, false);
+ m_aTimer.SetTimeoutHdl(LINK(this,SwEditWin, TimerHandler));
+}
+
+void SwEditWin::StartDrag( sal_Int8 /*nAction*/, const Point& rPosPixel )
+{
+ SwWrtShell &rSh = m_rView.GetWrtShell();
+ if( rSh.GetDrawView() )
+ {
+ CommandEvent aDragEvent( rPosPixel, COMMAND_STARTDRAG, true );
+ if( rSh.GetDrawView()->Command( aDragEvent, this ) )
+ {
+ m_rView.GetViewFrame()->GetBindings().InvalidateAll(sal_False);
+ return; // Event evaluated by SdrView
+ }
+ }
+
+ if ( !m_pApplyTempl && !rSh.IsDrawCreate() && !IsDrawAction())
+ {
+ sal_Bool bStart = sal_False, bDelSelect = sal_False;
+ SdrObject *pObj = NULL;
+ Point aDocPos( PixelToLogic( rPosPixel ) );
+ if ( !rSh.IsInSelect() && rSh.ChgCurrPam( aDocPos, sal_True, sal_True))
+ //We are not selecting and aren't at a selection
+ bStart = sal_True;
+ else if ( !bFrmDrag && rSh.IsSelFrmMode() &&
+ rSh.IsInsideSelectedObj( aDocPos ) )
+ {
+ //We are not dragging internally and are not at an
+ //object (frame, draw object)
+
+ bStart = sal_True;
+ }
+ else if( !bFrmDrag && m_rView.GetDocShell()->IsReadOnly() &&
+ OBJCNT_NONE != rSh.GetObjCntType( aDocPos, pObj ))
+ {
+ rSh.LockPaint();
+ if( rSh.SelectObj( aDocPos, 0, pObj ))
+ bStart = bDelSelect = sal_True;
+ else
+ rSh.UnlockPaint();
+ }
+ else
+ {
+ SwContentAtPos aSwContentAtPos( SwContentAtPos::SW_INETATTR );
+ bStart = rSh.GetContentAtPos( aDocPos,
+ aSwContentAtPos,
+ sal_False );
+ }
+
+ if ( bStart && !m_bIsInDrag )
+ {
+ m_bMBPressed = sal_False;
+ ReleaseMouse();
+ bFrmDrag = false;
+ bExecuteDrag = true;
+ SwEditWin::m_nDDStartPosY = aDocPos.Y();
+ SwEditWin::m_nDDStartPosX = aDocPos.X();
+ m_aMovePos = aDocPos;
+ StartExecuteDrag();
+ if( bDelSelect )
+ {
+ rSh.UnSelectFrm();
+ rSh.UnlockPaint();
+ }
+ }
+ }
+}
+
+void SwEditWin::StartExecuteDrag()
+{
+ if( !bExecuteDrag || m_bIsInDrag )
+ return;
+
+ m_bIsInDrag = sal_True;
+
+ SwTransferable* pTransfer = new SwTransferable( m_rView.GetWrtShell() );
+ uno::Reference<
+ datatransfer::XTransferable > xRef( pTransfer );
+
+ pTransfer->StartDrag( this, m_aMovePos );
+}
+
+void SwEditWin::DragFinished()
+{
+ DropCleanup();
+ m_aTimer.SetTimeoutHdl( LINK(this,SwEditWin, TimerHandler) );
+ m_bIsInDrag = sal_False;
+}
+
+void SwEditWin::DropCleanup()
+{
+ SwWrtShell &rSh = m_rView.GetWrtShell();
+
+ // reset statuses
+ bNoInterrupt = false;
+ if ( m_bOldIdleSet )
+ {
+ ((SwViewOption*)rSh.GetViewOptions())->SetIdle( m_bOldIdle );
+ m_bOldIdleSet = sal_False;
+ }
+ if ( m_pUserMarker )
+ CleanupDropUserMarker();
+ else
+ rSh.UnSetVisCrsr();
+
+}
+
+void SwEditWin::CleanupDropUserMarker()
+{
+ if ( m_pUserMarker )
+ {
+ delete m_pUserMarker;
+ m_pUserMarker = 0;
+ m_pUserMarkerObj = 0;
+ }
+}
+
+//exhibition hack (MA,MBA)
+void SwView::SelectShellForDrop()
+{
+ if ( !GetCurShell() )
+ SelectShell();
+}
+
+sal_Int8 SwEditWin::ExecuteDrop( const ExecuteDropEvent& rEvt )
+{
+ GetView().SelectShellForDrop();
+ DropCleanup();
+ sal_Int8 nRet = DND_ACTION_NONE;
+
+ //A Drop to an open OutlinerView doesn't concern us (also see QueryDrop)
+ SwWrtShell &rSh = m_rView.GetWrtShell();
+ const Point aDocPt( PixelToLogic( rEvt.maPosPixel ));
+ SdrObject *pObj = 0;
+ OutlinerView* pOLV;
+ rSh.GetObjCntType( aDocPt, pObj );
+
+ if( pObj && 0 != ( pOLV = rSh.GetDrawView()->GetTextEditOutlinerView() ))
+ {
+ Rectangle aRect( pOLV->GetOutputArea() );
+ aRect.Union( pObj->GetLogicRect() );
+ const Point aPos = pOLV->GetWindow()->PixelToLogic(rEvt.maPosPixel);
+ if ( aRect.IsInside(aPos) )
+ {
+ rSh.StartAllAction();
+ rSh.EndAllAction();
+ return nRet;
+ }
+ }
+
+ // There's a special treatment for file lists with a single
+ // element, that depends on the actual content of the
+ // Transferable to be accessible. Since the transferable
+ // may only be accessed after the drop has been accepted
+ // (according to KA due to Java D&D), we'll have to
+ // reevaluate the drop action once more _with_ the
+ // Transferable.
+ sal_uInt16 nEventAction;
+ sal_Int8 nUserOpt = rEvt.mbDefault ? EXCHG_IN_ACTION_DEFAULT
+ : rEvt.mnAction;
+ m_nDropAction = SotExchange::GetExchangeAction(
+ GetDataFlavorExVector(),
+ m_nDropDestination,
+ rEvt.mnAction,
+ nUserOpt, m_nDropFormat, nEventAction, 0,
+ &rEvt.maDropEvent.Transferable );
+
+ TransferableDataHelper aData( rEvt.maDropEvent.Transferable );
+ nRet = rEvt.mnAction;
+ if( !SwTransferable::PasteData( aData, rSh, m_nDropAction, m_nDropFormat,
+ m_nDropDestination, sal_False, rEvt.mbDefault, &aDocPt, nRet))
+ nRet = DND_ACTION_NONE;
+ else if ( SW_MOD()->pDragDrop )
+ //Don't clean up anymore at internal D&D!
+ SW_MOD()->pDragDrop->SetCleanUp( sal_False );
+
+ return nRet;
+}
+
+sal_uInt16 SwEditWin::GetDropDestination( const Point& rPixPnt, SdrObject ** ppObj )
+{
+ SwWrtShell &rSh = m_rView.GetWrtShell();
+ const Point aDocPt( PixelToLogic( rPixPnt ) );
+ if( rSh.ChgCurrPam( aDocPt )
+ || rSh.IsOverReadOnlyPos( aDocPt )
+ || rSh.DocPtInsideInputFld( aDocPt ) )
+ return 0;
+
+ SdrObject *pObj = NULL;
+ const ObjCntType eType = rSh.GetObjCntType( aDocPt, pObj );
+
+ //Drop to OutlinerView (TextEdit in Drawing) should decide it on its own!
+ if( pObj )
+ {
+ OutlinerView* pOLV = rSh.GetDrawView()->GetTextEditOutlinerView();
+ if ( pOLV )
+ {
+ Rectangle aRect( pOLV->GetOutputArea() );
+ aRect.Union( pObj->GetLogicRect() );
+ const Point aPos = pOLV->GetWindow()->PixelToLogic( rPixPnt );
+ if( aRect.IsInside( aPos ) )
+ return 0;
+ }
+ }
+
+ //What do we want to drop on now?
+ sal_uInt16 nDropDestination = 0;
+
+ //Did anything else arrive from the DrawingEngine?
+ if( OBJCNT_NONE != eType )
+ {
+ switch ( eType )
+ {
+ case OBJCNT_GRF:
+ {
+ sal_Bool bLink,
+ bIMap = 0 != rSh.GetFmtFromObj( aDocPt )->GetURL().GetMap();
+ OUString aDummy;
+ rSh.GetGrfAtPos( aDocPt, aDummy, bLink );
+ if ( bLink && bIMap )
+ nDropDestination = EXCHG_DEST_DOC_LNKD_GRAPH_W_IMAP;
+ else if ( bLink )
+ nDropDestination = EXCHG_DEST_DOC_LNKD_GRAPHOBJ;
+ else if ( bIMap )
+ nDropDestination = EXCHG_DEST_DOC_GRAPH_W_IMAP;
+ else
+ nDropDestination = EXCHG_DEST_DOC_GRAPHOBJ;
+ }
+ break;
+ case OBJCNT_FLY:
+ if( rSh.GetView().GetDocShell()->ISA(SwWebDocShell) )
+ nDropDestination = EXCHG_DEST_DOC_TEXTFRAME_WEB;
+ else
+ nDropDestination = EXCHG_DEST_DOC_TEXTFRAME;
+ break;
+ case OBJCNT_OLE: nDropDestination = EXCHG_DEST_DOC_OLEOBJ; break;
+ case OBJCNT_CONTROL: /* no Action avail */
+ case OBJCNT_SIMPLE: nDropDestination = EXCHG_DEST_DOC_DRAWOBJ; break;
+ case OBJCNT_URLBUTTON: nDropDestination = EXCHG_DEST_DOC_URLBUTTON; break;
+ case OBJCNT_GROUPOBJ: nDropDestination = EXCHG_DEST_DOC_GROUPOBJ; break;
+
+ default: OSL_ENSURE( !this, "new ObjectType?" );
+ }
+ }
+ if ( !nDropDestination )
+ {
+ if( rSh.GetView().GetDocShell()->ISA(SwWebDocShell) )
+ nDropDestination = EXCHG_DEST_SWDOC_FREE_AREA_WEB;
+ else
+ nDropDestination = EXCHG_DEST_SWDOC_FREE_AREA;
+ }
+ if( ppObj )
+ *ppObj = pObj;
+ return nDropDestination;
+}
+
+sal_Int8 SwEditWin::AcceptDrop( const AcceptDropEvent& rEvt )
+{
+ if( rEvt.mbLeaving )
+ {
+ DropCleanup();
+ return rEvt.mnAction;
+ }
+
+ if( m_rView.GetDocShell()->IsReadOnly() )
+ return DND_ACTION_NONE;
+
+ SwWrtShell &rSh = m_rView.GetWrtShell();
+
+ Point aPixPt( rEvt.maPosPixel );
+
+ // If the cursor is near the inner boundary
+ // we attempt to scroll towards the desired direction.
+ Point aPoint;
+ Rectangle aWin(aPoint,GetOutputSizePixel());
+ const int nMargin = 10;
+ aWin.Left() += nMargin;
+ aWin.Top() += nMargin;
+ aWin.Right() -= nMargin;
+ aWin.Bottom() -= nMargin;
+ if(!aWin.IsInside(aPixPt)) {
+ static sal_uLong last_tick = 0;
+ sal_uLong current_tick = Time::GetSystemTicks();
+ if((current_tick-last_tick) > 500) {
+ last_tick = current_tick;
+ if(!m_bOldIdleSet) {
+ m_bOldIdle = rSh.GetViewOptions()->IsIdle();
+ ((SwViewOption *)rSh.GetViewOptions())->SetIdle(sal_False);
+ m_bOldIdleSet = sal_True;
+ }
+ CleanupDropUserMarker();
+ if(aPixPt.X() > aWin.Right()) aPixPt.X() += nMargin;
+ if(aPixPt.X() < aWin.Left()) aPixPt.X() -= nMargin;
+ if(aPixPt.Y() > aWin.Bottom()) aPixPt.Y() += nMargin;
+ if(aPixPt.Y() < aWin.Top()) aPixPt.Y() -= nMargin;
+ Point aDocPt(PixelToLogic(aPixPt));
+ SwRect rect(aDocPt,Size(1,1));
+ rSh.MakeVisible(rect);
+ }
+ }
+
+ if(m_bOldIdleSet) {
+ ((SwViewOption *)rSh.GetViewOptions())->SetIdle( m_bOldIdle );
+ m_bOldIdleSet = sal_False;
+ }
+
+ SdrObject *pObj = NULL;
+ m_nDropDestination = GetDropDestination( aPixPt, &pObj );
+ if( !m_nDropDestination )
+ return DND_ACTION_NONE;
+
+ sal_uInt16 nEventAction;
+ sal_Int8 nUserOpt = rEvt.mbDefault ? EXCHG_IN_ACTION_DEFAULT
+ : rEvt.mnAction;
+
+ m_nDropAction = SotExchange::GetExchangeAction(
+ GetDataFlavorExVector(),
+ m_nDropDestination,
+ rEvt.mnAction,
+ nUserOpt, m_nDropFormat, nEventAction );
+
+ if( EXCHG_INOUT_ACTION_NONE != m_nDropAction )
+ {
+ const Point aDocPt( PixelToLogic( aPixPt ) );
+
+ //With the default action we still want to have a say.
+ SwModule *pMod = SW_MOD();
+ if( pMod->pDragDrop )
+ {
+ sal_Bool bCleanup = sal_False;
+ //Drawing objects in Headers/Footers are not allowed
+
+ SwWrtShell *pSrcSh = pMod->pDragDrop->GetShell();
+ if( (pSrcSh->GetSelFrmType() == FRMTYPE_DRAWOBJ) &&
+ pSrcSh->IsSelContainsControl() &&
+ (rSh.GetFrmType( &aDocPt, sal_False ) & (FRMTYPE_HEADER|FRMTYPE_FOOTER)) )
+ {
+ bCleanup = sal_True;
+ }
+ // don't more position protected objects!
+ else if( DND_ACTION_MOVE == rEvt.mnAction &&
+ pSrcSh->IsSelObjProtected( FLYPROTECT_POS ) )
+ {
+ bCleanup = sal_True;
+ }
+ else if( rEvt.mbDefault )
+ {
+ // internal Drag&Drop: within same Doc a Move
+ // otherwise a Copy - Task 54974
+ nEventAction = pSrcSh->GetDoc() == rSh.GetDoc()
+ ? DND_ACTION_MOVE
+ : DND_ACTION_COPY;
+ }
+ if ( bCleanup )
+ {
+ CleanupDropUserMarker();
+ rSh.UnSetVisCrsr();
+ return DND_ACTION_NONE;
+ }
+ }
+ else
+ {
+ //D&D from outside of SW should be a Copy per default.
+ if( EXCHG_IN_ACTION_DEFAULT == nEventAction &&
+ DND_ACTION_MOVE == rEvt.mnAction )
+ nEventAction = DND_ACTION_COPY;
+
+ if( (SOT_FORMATSTR_ID_SBA_FIELDDATAEXCHANGE == m_nDropFormat &&
+ EXCHG_IN_ACTION_LINK == m_nDropAction) ||
+ SOT_FORMATSTR_ID_SBA_CTRLDATAEXCHANGE == m_nDropFormat )
+ {
+ SdrMarkView* pMView = PTR_CAST( SdrMarkView, rSh.GetDrawView() );
+ if( pMView && !pMView->IsDesignMode() )
+ return DND_ACTION_NONE;
+ }
+ }
+
+ if ( EXCHG_IN_ACTION_DEFAULT != nEventAction )
+ nUserOpt = (sal_Int8)nEventAction;
+
+ // show DropCursor or UserMarker ?
+ if( EXCHG_DEST_SWDOC_FREE_AREA_WEB == m_nDropDestination ||
+ EXCHG_DEST_SWDOC_FREE_AREA == m_nDropDestination )
+ {
+ CleanupDropUserMarker();
+ SwContentAtPos aCont( SwContentAtPos::SW_CONTENT_CHECK );
+ if(rSh.GetContentAtPos(aDocPt, aCont))
+ rSh.SwCrsrShell::SetVisCrsr( aDocPt );
+ }
+ else
+ {
+ rSh.UnSetVisCrsr();
+
+ if ( m_pUserMarkerObj != pObj )
+ {
+ CleanupDropUserMarker();
+ m_pUserMarkerObj = pObj;
+
+ if(m_pUserMarkerObj)
+ {
+ m_pUserMarker = new SdrDropMarkerOverlay( *rSh.GetDrawView(), *m_pUserMarkerObj );
+ }
+ }
+ }
+ return nUserOpt;
+ }
+
+ CleanupDropUserMarker();
+ rSh.UnSetVisCrsr();
+ return DND_ACTION_NONE;
+}
+
+IMPL_LINK_NOARG(SwEditWin, DDHandler)
+{
+ bDDTimerStarted = false;
+ m_aTimer.Stop();
+ m_aTimer.SetTimeout(240);
+ m_bMBPressed = sal_False;
+ ReleaseMouse();
+ bFrmDrag = false;
+
+ if ( m_rView.GetViewFrame() )
+ {
+ bExecuteDrag = true;
+ StartExecuteDrag();
+ }
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/docvw/edtwin.cxx b/sw/source/core/uibase/docvw/edtwin.cxx
new file mode 100644
index 000000000000..10794255f42b
--- /dev/null
+++ b/sw/source/core/uibase/docvw/edtwin.cxx
@@ -0,0 +1,6157 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <config_features.h>
+
+#include <swtypes.hxx>
+#include <hintids.hxx>
+#include <com/sun/star/accessibility/XAccessible.hpp>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/string.hxx>
+#include <com/sun/star/i18n/XBreakIterator.hpp>
+#include <com/sun/star/i18n/ScriptType.hpp>
+#include <com/sun/star/i18n/InputSequenceCheckMode.hpp>
+
+#include <com/sun/star/i18n/UnicodeScript.hpp>
+
+#include <vcl/help.hxx>
+#include <vcl/graph.hxx>
+#include <vcl/msgbox.hxx>
+#include <sot/storage.hxx>
+#include <svl/macitem.hxx>
+#include <unotools/securityoptions.hxx>
+#include <basic/sbxvar.hxx>
+#include <svl/ctloptions.hxx>
+#include <basic/sbx.hxx>
+#include <svl/eitem.hxx>
+#include <svl/stritem.hxx>
+#include <sfx2/ipclient.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svl/ptitem.hxx>
+#include <editeng/sizeitem.hxx>
+#include <editeng/langitem.hxx>
+#include <sfx2/htmlmode.hxx>
+#include <svx/svdview.hxx>
+#include <svx/svdhdl.hxx>
+#include <svx/svdoutl.hxx>
+#include <editeng/editeng.hxx>
+#include <editeng/svxacorr.hxx>
+#include <editeng/scripttypeitem.hxx>
+#include <editeng/flditem.hxx>
+#include <editeng/colritem.hxx>
+#include <editeng/brushitem.hxx>
+#include <editeng/wghtitem.hxx>
+#include <editeng/udlnitem.hxx>
+#include <editeng/postitem.hxx>
+#include <editeng/protitem.hxx>
+#include <unotools/charclass.hxx>
+#include <basegfx/color/bcolortools.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+
+#include <touch/touch-impl.h>
+
+#include <editeng/acorrcfg.hxx>
+#include <SwSmartTagMgr.hxx>
+#include <edtwin.hxx>
+#include <view.hxx>
+#include <wrtsh.hxx>
+#include <IDocumentSettingAccess.hxx>
+#include <fldbas.hxx>
+#include <swmodule.hxx>
+#include <docsh.hxx>
+#include <viewopt.hxx>
+#include <drawbase.hxx>
+#include <dselect.hxx>
+#include <textsh.hxx>
+#include <shdwcrsr.hxx>
+#include <txatbase.hxx>
+#include <fmtanchr.hxx>
+#include <fmtornt.hxx>
+#include <fmtfsize.hxx>
+#include <fmtclds.hxx>
+#include <fmthdft.hxx>
+#include <frmfmt.hxx>
+#include <modcfg.hxx>
+#include <fmtcol.hxx>
+#include <wview.hxx>
+#include <listsh.hxx>
+#include <gloslst.hxx>
+#include <inputwin.hxx>
+#include <gloshdl.hxx>
+#include <swundo.hxx>
+#include <drwtxtsh.hxx>
+#include <fchrfmt.hxx>
+#include <fmturl.hxx>
+#include <romenu.hxx>
+#include <initui.hxx>
+#include <frmatr.hxx>
+#include <extinput.hxx>
+#include <acmplwrd.hxx>
+#include <swcalwrp.hxx>
+#include <swdtflvr.hxx>
+#include <wdocsh.hxx>
+#include <crsskip.hxx>
+#include <breakit.hxx>
+#include <checkit.hxx>
+#include <pagefrm.hxx>
+#include <HeaderFooterWin.hxx>
+
+#include <helpid.h>
+#include <cmdid.h>
+#include <docvw.hrc>
+#include <uitool.hxx>
+#include <fmtfollowtextflow.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <charfmt.hxx>
+#include <numrule.hxx>
+#include <pagedesc.hxx>
+#include <svtools/ruler.hxx>
+#include "formatclipboard.hxx"
+#include <osl/mutex.hxx>
+#include <vcl/svapp.hxx>
+#include <docstat.hxx>
+#include <wordcountdialog.hxx>
+#include <swwait.hxx>
+
+#include <IMark.hxx>
+#include <doc.hxx>
+#include <xmloff/odffields.hxx>
+
+#include <PostItMgr.hxx>
+
+#include <algorithm>
+#include <vector>
+
+#include "../../core/inc/rootfrm.hxx"
+
+#include <unotools/syslocaleoptions.hxx>
+
+using namespace sw::mark;
+using namespace ::com::sun::star;
+
+/**
+ * Globals
+ */
+static bool bInputLanguageSwitched = false;
+extern bool bNoInterrupt; // in mainwn.cxx
+
+// Usually in MouseButtonUp a selection is revoked when the selection is
+// not currently being pulled open. Unfortunately in MouseButtonDown there
+// is being selected at double/triple click. That selection is completely
+// finished in the Handler and thus can't be distinguished in the Up.
+// To resolve this bHoldSelection is set in Down at evaluated in Up.
+static bool bHoldSelection = false;
+
+bool bFrmDrag = false;
+bool bValidCrsrPos = false;
+bool bModePushed = false;
+bool bDDTimerStarted = false;
+bool bFlushCharBuffer = false;
+bool bDDINetAttr = false;
+SdrHdlKind eSdrMoveHdl = HDL_USER;
+
+QuickHelpData* SwEditWin::m_pQuickHlpData = 0;
+
+long SwEditWin::m_nDDStartPosY = 0;
+long SwEditWin::m_nDDStartPosX = 0;
+/**
+ * The initial color shown on the button is set in /core/svx/source/tbxctrls/tbxcolorupdate.cxx
+ * (ToolboxButtonColorUpdater::ToolboxButtonColorUpdater()) .
+ * The initial color used by the button is set in /core/svx/source/tbxcntrls/tbcontrl.cxx
+ * (SvxColorExtToolBoxControl::SvxColorExtToolBoxControl())
+ * and in case of writer for text(background)color also in /core/sw/source/ui/docvw/edtwin.cxx
+ * (SwEditWin::aTextBackColor and SwEditWin::aTextBackColor)
+ */
+Color SwEditWin::m_aTextBackColor(COL_YELLOW);
+Color SwEditWin::m_aTextColor(COL_RED);
+bool SwEditWin::m_bTransparentBackColor = false; // background not transparent
+
+extern bool bExecuteDrag;
+
+static SfxShell* lcl_GetShellFromDispatcher( SwView& rView, TypeId nType );
+
+DBG_NAME(edithdl)
+
+class SwAnchorMarker
+{
+ SdrHdl* pHdl;
+ Point aHdlPos;
+ Point aLastPos;
+ bool bTopRightHandle;
+public:
+ SwAnchorMarker( SdrHdl* pH )
+ : pHdl( pH )
+ , aHdlPos( pH->GetPos() )
+ , aLastPos( pH->GetPos() )
+ , bTopRightHandle( pH->GetKind() == HDL_ANCHOR_TR )
+ {}
+ const Point& GetLastPos() const { return aLastPos; }
+ void SetLastPos( const Point& rNew ) { aLastPos = rNew; }
+ void SetPos( const Point& rNew ) { pHdl->SetPos( rNew ); }
+ const Point& GetPos() { return pHdl->GetPos(); }
+ const Point& GetHdlPos() { return aHdlPos; }
+ SdrHdl* GetHdl() const { return pHdl; }
+ void ChgHdl( SdrHdl* pNew )
+ {
+ pHdl = pNew;
+ if ( pHdl )
+ {
+ bTopRightHandle = (pHdl->GetKind() == HDL_ANCHOR_TR);
+ }
+ }
+ const Point GetPosForHitTest( const OutputDevice& rOut )
+ {
+ Point aHitTestPos( GetPos() );
+ aHitTestPos = rOut.LogicToPixel( aHitTestPos );
+ if ( bTopRightHandle )
+ {
+ aHitTestPos += Point( -1, 1 );
+ }
+ else
+ {
+ aHitTestPos += Point( 1, 1 );
+ }
+ aHitTestPos = rOut.PixelToLogic( aHitTestPos );
+
+ return aHitTestPos;
+ }
+};
+
+/// Assists with auto-completion of AutoComplete words and AutoText names.
+struct QuickHelpData
+{
+ /// Strings that at least partially match an input word.
+ std::vector<OUString> m_aHelpStrings;
+ /// Index of the current help string.
+ sal_uInt16 nCurArrPos;
+ /// Length of the input word associated with the help data.
+ sal_uInt16 nLen;
+
+ /// Help data stores AutoText names rather than AutoComplete words.
+ bool m_bIsAutoText;
+ /// Display help string as a tip rather than inline.
+ bool m_bIsTip;
+ /// Tip ID when a help string is displayed as a tip.
+ sal_uLong nTipId;
+ /// Append a space character to the displayed help string (if appropriate).
+ bool m_bAppendSpace;
+
+ /// Help string is currently displayed.
+ bool m_bIsDisplayed;
+
+ QuickHelpData() { ClearCntnt(); }
+
+ void Move( QuickHelpData& rCpy );
+ void ClearCntnt();
+ void Start( SwWrtShell& rSh, sal_uInt16 nWrdLen );
+ void Stop( SwWrtShell& rSh );
+
+ bool HasCntnt() const { return !m_aHelpStrings.empty() && 0 != nLen; }
+
+ /// Next help string.
+ void Next( bool bEndLess )
+ {
+ if( ++nCurArrPos >= m_aHelpStrings.size() )
+ nCurArrPos = (bEndLess && !m_bIsAutoText ) ? 0 : nCurArrPos-1;
+ }
+ /// Previous help string.
+ void Previous( bool bEndLess )
+ {
+ if( 0 == nCurArrPos-- )
+ nCurArrPos = (bEndLess && !m_bIsAutoText ) ? m_aHelpStrings.size()-1 : 0;
+ }
+
+ // Fills internal structures with hopefully helpful information.
+ void FillStrArr( SwWrtShell& rSh, const OUString& rWord );
+ void SortAndFilter(const OUString &rOrigWord);
+};
+
+/**
+ * Avoid minimal movement shiver
+ */
+#define HIT_PIX 2 /* hit tolerance in pixel */
+#define MIN_MOVE 4
+
+inline bool IsMinMove(const Point &rStartPos, const Point &rLPt)
+{
+ return std::abs(rStartPos.X() - rLPt.X()) > MIN_MOVE ||
+ std::abs(rStartPos.Y() - rLPt.Y()) > MIN_MOVE;
+}
+
+/**
+ * For MouseButtonDown - determine whether a DrawObject
+ * an NO SwgFrame was hit! Shift/Ctrl should only result
+ * in selecting, with DrawObjects; at SwgFlys to trigger
+ * hyperlinks if applicable (DownLoad/NewWindow!)
+ */
+inline bool IsDrawObjSelectable( const SwWrtShell& rSh, const Point& rPt )
+{
+ bool bRet = true;
+ SdrObject* pObj;
+ switch( rSh.GetObjCntType( rPt, pObj ))
+ {
+ case OBJCNT_NONE:
+ case OBJCNT_FLY:
+ case OBJCNT_GRF:
+ case OBJCNT_OLE:
+ bRet = false;
+ break;
+ default:; //prevent warning
+ }
+ return bRet;
+}
+
+/*
+ * Switch pointer
+ */
+void SwEditWin::UpdatePointer(const Point &rLPt, sal_uInt16 nModifier )
+{
+ SwWrtShell &rSh = m_rView.GetWrtShell();
+ if( m_pApplyTempl )
+ {
+ PointerStyle eStyle = POINTER_FILL;
+ if ( rSh.IsOverReadOnlyPos( rLPt ) )
+ {
+ delete m_pUserMarker;
+ m_pUserMarker = 0L;
+
+ eStyle = POINTER_NOTALLOWED;
+ }
+ else
+ {
+ SwRect aRect;
+ SwRect* pRect = &aRect;
+ const SwFrmFmt* pFmt = 0;
+
+ bool bFrameIsValidTarget = false;
+ if( m_pApplyTempl->m_pFormatClipboard )
+ bFrameIsValidTarget = m_pApplyTempl->m_pFormatClipboard->HasContentForThisType( nsSelectionType::SEL_FRM );
+ else if( !m_pApplyTempl->nColor )
+ bFrameIsValidTarget = ( m_pApplyTempl->eType == SFX_STYLE_FAMILY_FRAME );
+
+ if( bFrameIsValidTarget &&
+ 0 !=(pFmt = rSh.GetFmtFromObj( rLPt, &pRect )) &&
+ PTR_CAST(SwFlyFrmFmt, pFmt))
+ {
+ //turn on highlight for frame
+ Rectangle aTmp( pRect->SVRect() );
+
+ if ( !m_pUserMarker )
+ {
+ m_pUserMarker = new SdrDropMarkerOverlay( *rSh.GetDrawView(), aTmp );
+ }
+ }
+ else
+ {
+ delete m_pUserMarker;
+ m_pUserMarker = 0L;
+ }
+
+ rSh.SwCrsrShell::SetVisCrsr( rLPt );
+ }
+ SetPointer( eStyle );
+ return;
+ }
+
+ if( !rSh.VisArea().Width() )
+ return;
+
+ SET_CURR_SHELL(&rSh);
+
+ if ( IsChainMode() )
+ {
+ SwRect aRect;
+ int nChainable = rSh.Chainable( aRect, *rSh.GetFlyFrmFmt(), rLPt );
+ PointerStyle eStyle = nChainable
+ ? POINTER_CHAIN_NOTALLOWED : POINTER_CHAIN;
+ if ( !nChainable )
+ {
+ Rectangle aTmp( aRect.SVRect() );
+
+ if ( !m_pUserMarker )
+ {
+ m_pUserMarker = new SdrDropMarkerOverlay( *rSh.GetDrawView(), aTmp );
+ }
+ }
+ else
+ {
+ delete m_pUserMarker;
+ m_pUserMarker = 0L;
+ }
+
+ SetPointer( eStyle );
+ return;
+ }
+
+ sal_Bool bExecHyperlinks = m_rView.GetDocShell()->IsReadOnly();
+ if ( !bExecHyperlinks )
+ {
+ SvtSecurityOptions aSecOpts;
+ const sal_Bool bSecureOption = aSecOpts.IsOptionSet( SvtSecurityOptions::E_CTRLCLICK_HYPERLINK );
+ if ( ( bSecureOption && nModifier == KEY_MOD1 ) ||
+ ( !bSecureOption && nModifier != KEY_MOD1 ) )
+ bExecHyperlinks = sal_True;
+ }
+
+ const bool bExecSmarttags = nModifier == KEY_MOD1;
+
+ SdrView *pSdrView = rSh.GetDrawView();
+ bool bPrefSdrPointer = false;
+ bool bHitHandle = false;
+ bool bCntAtPos = false;
+ bool bIsDocReadOnly = m_rView.GetDocShell()->IsReadOnly() &&
+ rSh.IsCrsrReadonly();
+ m_aActHitType = SDRHIT_NONE;
+ PointerStyle eStyle = POINTER_TEXT;
+ if ( !pSdrView )
+ bCntAtPos = true;
+ else if ( (bHitHandle = pSdrView->PickHandle( rLPt ) != 0) )
+ {
+ m_aActHitType = SDRHIT_OBJECT;
+ bPrefSdrPointer = true;
+ }
+ else
+ {
+ const bool bNotInSelObj = !rSh.IsInsideSelectedObj( rLPt );
+ if ( m_rView.GetDrawFuncPtr() && !m_bInsDraw && bNotInSelObj )
+ {
+ m_aActHitType = SDRHIT_OBJECT;
+ if (IsObjectSelect())
+ eStyle = POINTER_ARROW;
+ else
+ bPrefSdrPointer = true;
+ }
+ else
+ {
+ SdrObject* pObj; SdrPageView* pPV;
+ pSdrView->SetHitTolerancePixel( HIT_PIX );
+ if ( bNotInSelObj && bExecHyperlinks &&
+ pSdrView->PickObj( rLPt, pSdrView->getHitTolLog(), pObj, pPV, SDRSEARCH_PICKMACRO ))
+ {
+ SdrObjMacroHitRec aTmp;
+ aTmp.aPos = rLPt;
+ aTmp.pPageView = pPV;
+ SetPointer( pObj->GetMacroPointer( aTmp ) );
+ return;
+ }
+ else
+ {
+ // dvo: IsObjSelectable() eventually calls SdrView::PickObj, so
+ // apparently this is used to determine whether this is a
+ // drawling layer object or not.
+ if ( rSh.IsObjSelectable( rLPt ) )
+ {
+ if (pSdrView->IsTextEdit())
+ {
+ m_aActHitType = SDRHIT_NONE;
+ bPrefSdrPointer = true;
+ }
+ else
+ {
+ SdrViewEvent aVEvt;
+ SdrHitKind eHit = pSdrView->PickAnything(rLPt, aVEvt);
+
+ if (eHit == SDRHIT_URLFIELD && bExecHyperlinks)
+ {
+ m_aActHitType = SDRHIT_OBJECT;
+ bPrefSdrPointer = true;
+ }
+ else
+ {
+ // if we're over a selected object, we show an
+ // ARROW by default. We only show a MOVE if 1) the
+ // object is selected, and 2) it may be moved
+ // (i.e., position is not protected).
+ bool bMovable =
+ (!bNotInSelObj) &&
+ (rSh.IsObjSelected() || rSh.IsFrmSelected()) &&
+ (!rSh.IsSelObjProtected(FLYPROTECT_POS));
+
+ SdrObject* pSelectableObj = rSh.GetObjAt(rLPt);
+ // Don't update pointer if this is a background image only.
+ if (pSelectableObj->GetLayer() != rSh.GetDoc()->GetHellId())
+ eStyle = bMovable ? POINTER_MOVE : POINTER_ARROW;
+ m_aActHitType = SDRHIT_OBJECT;
+ }
+ }
+ }
+ else
+ {
+ if ( rSh.IsFrmSelected() && !bNotInSelObj )
+ {
+ // dvo: this branch appears to be dead and should be
+ // removed in a future version. Reason: The condition
+ // !bNotInSelObj means that this branch will only be
+ // executed in the cursor points inside a selected
+ // object. However, if this is the case, the previous
+ // if( rSh.IsObjSelectable(rLPt) ) must always be true:
+ // rLPt is inside a selected object, then obviously
+ // rLPt is over a selectable object.
+ if (rSh.IsSelObjProtected(FLYPROTECT_SIZE))
+ eStyle = POINTER_NOTALLOWED;
+ else
+ eStyle = POINTER_MOVE;
+ m_aActHitType = SDRHIT_OBJECT;
+ }
+ else
+ {
+ if ( m_rView.GetDrawFuncPtr() )
+ bPrefSdrPointer = true;
+ else
+ bCntAtPos = true;
+ }
+ }
+ }
+ }
+ }
+ if ( bPrefSdrPointer )
+ {
+ if (bIsDocReadOnly || (rSh.IsObjSelected() && rSh.IsSelObjProtected(FLYPROTECT_CONTENT)))
+ SetPointer( POINTER_NOTALLOWED );
+ else
+ {
+ if (m_rView.GetDrawFuncPtr() && m_rView.GetDrawFuncPtr()->IsInsertForm() && !bHitHandle)
+ SetPointer( POINTER_DRAW_RECT );
+ else
+ SetPointer( pSdrView->GetPreferredPointer( rLPt, rSh.GetOut() ) );
+ }
+ }
+ else
+ {
+ if( !rSh.IsPageAtPos( rLPt ) || m_pAnchorMarker )
+ eStyle = POINTER_ARROW;
+ else
+ {
+ // Even if we already have something, prefer URLs if possible.
+ SwContentAtPos aUrlPos(SwContentAtPos::SW_INETATTR);
+ if (bCntAtPos || rSh.GetContentAtPos(rLPt, aUrlPos))
+ {
+ SwContentAtPos aSwContentAtPos(
+ SwContentAtPos::SW_CLICKFIELD|
+ SwContentAtPos::SW_INETATTR|
+ SwContentAtPos::SW_FTN |
+ SwContentAtPos::SW_SMARTTAG );
+ if( rSh.GetContentAtPos( rLPt, aSwContentAtPos) )
+ {
+ const bool bClickToFollow = SwContentAtPos::SW_INETATTR == aSwContentAtPos.eCntntAtPos ||
+ SwContentAtPos::SW_SMARTTAG == aSwContentAtPos.eCntntAtPos;
+
+ if( !bClickToFollow ||
+ (SwContentAtPos::SW_INETATTR == aSwContentAtPos.eCntntAtPos && bExecHyperlinks) ||
+ (SwContentAtPos::SW_SMARTTAG == aSwContentAtPos.eCntntAtPos && bExecSmarttags) )
+ eStyle = POINTER_REFHAND;
+ }
+ }
+ }
+
+ // which kind of text pointer have we to show - horz / vert - ?
+ if( POINTER_TEXT == eStyle && rSh.IsInVerticalText( &rLPt ))
+ eStyle = POINTER_TEXT_VERTICAL;
+
+ SetPointer( eStyle );
+ }
+}
+
+/**
+ * Increase timer for selection
+ */
+IMPL_LINK_NOARG(SwEditWin, TimerHandler)
+{
+ DBG_PROFSTART(edithdl);
+
+ SwWrtShell &rSh = m_rView.GetWrtShell();
+ Point aModPt( m_aMovePos );
+ const SwRect aOldVis( rSh.VisArea() );
+ bool bDone = false;
+
+ if ( !rSh.VisArea().IsInside( aModPt ) )
+ {
+ if ( m_bInsDraw )
+ {
+ const int nMaxScroll = 40;
+ m_rView.Scroll( Rectangle(aModPt,Size(1,1)), nMaxScroll, nMaxScroll);
+ bDone = true;
+ }
+ else if ( bFrmDrag )
+ {
+ rSh.Drag(&aModPt, false);
+ bDone = true;
+ }
+ if ( !bDone )
+ aModPt = rSh.GetCntntPos( aModPt,aModPt.Y() > rSh.VisArea().Bottom() );
+ }
+ if ( !bDone && !(bFrmDrag || m_bInsDraw) )
+ {
+ if ( m_pRowColumnSelectionStart )
+ {
+ Point aPos( aModPt );
+ rSh.SelectTableRowCol( *m_pRowColumnSelectionStart, &aPos, m_bIsRowDrag );
+ }
+ else
+ rSh.SetCursor( &aModPt, false );
+
+ // It can be that a "jump" over a table cannot be accomplished like
+ // that. So we jump over the table by Up/Down here.
+ const SwRect& rVisArea = rSh.VisArea();
+ if( aOldVis == rVisArea && !rSh.IsStartOfDoc() && !rSh.IsEndOfDoc() )
+ {
+ // take the center point of VisArea to
+ // decide in which direction the user want.
+ if( aModPt.Y() < ( rVisArea.Top() + rVisArea.Height() / 2 ) )
+ rSh.Up( sal_True, 1 );
+ else
+ rSh.Down( sal_True, 1 );
+ }
+ }
+
+ m_aMovePos += rSh.VisArea().Pos() - aOldVis.Pos();
+ JustifyAreaTimer();
+ DBG_PROFSTOP(edithdl);
+ return 0;
+}
+
+void SwEditWin::JustifyAreaTimer()
+{
+ const Rectangle &rVisArea = GetView().GetVisArea();
+#ifdef UNX
+ const long coMinLen = 100;
+#else
+ const long coMinLen = 50;
+#endif
+ long nTimeout = 800,
+ nDiff = std::max(
+ std::max( m_aMovePos.Y() - rVisArea.Bottom(), rVisArea.Top() - m_aMovePos.Y() ),
+ std::max( m_aMovePos.X() - rVisArea.Right(), rVisArea.Left() - m_aMovePos.X()));
+ m_aTimer.SetTimeout( std::max( coMinLen, nTimeout - nDiff*2L) );
+}
+
+void SwEditWin::LeaveArea(const Point &rPos)
+{
+ m_aMovePos = rPos;
+ JustifyAreaTimer();
+ if( !m_aTimer.IsActive() )
+ m_aTimer.Start();
+ delete m_pShadCrsr, m_pShadCrsr = 0;
+}
+
+inline void SwEditWin::EnterArea()
+{
+ m_aTimer.Stop();
+}
+
+/**
+ * Insert mode for frames
+ */
+void SwEditWin::InsFrm(sal_uInt16 nCols)
+{
+ StdDrawMode( OBJ_NONE, sal_False );
+ m_bInsFrm = sal_True;
+ m_nInsFrmColCount = nCols;
+}
+
+void SwEditWin::StdDrawMode( SdrObjKind eSdrObjectKind, sal_Bool bObjSelect )
+{
+ SetSdrDrawMode( eSdrObjectKind );
+
+ if (bObjSelect)
+ m_rView.SetDrawFuncPtr(new DrawSelection( &m_rView.GetWrtShell(), this, &m_rView ));
+ else
+ m_rView.SetDrawFuncPtr(new SwDrawBase( &m_rView.GetWrtShell(), this, &m_rView ));
+
+ m_rView.SetSelDrawSlot();
+ SetSdrDrawMode( eSdrObjectKind );
+ if (bObjSelect)
+ m_rView.GetDrawFuncPtr()->Activate( SID_OBJECT_SELECT );
+ else
+ m_rView.GetDrawFuncPtr()->Activate( sal::static_int_cast< sal_uInt16 >(eSdrObjectKind) );
+ m_bInsFrm = sal_False;
+ m_nInsFrmColCount = 1;
+}
+
+void SwEditWin::StopInsFrm()
+{
+ if (m_rView.GetDrawFuncPtr())
+ {
+ m_rView.GetDrawFuncPtr()->Deactivate();
+ m_rView.SetDrawFuncPtr(NULL);
+ }
+ m_rView.LeaveDrawCreate(); // leave construction mode
+ m_bInsFrm = sal_False;
+ m_nInsFrmColCount = 1;
+}
+
+sal_Bool SwEditWin::IsInputSequenceCheckingRequired( const OUString &rText, const SwPaM& rCrsr ) const
+{
+ const SvtCTLOptions& rCTLOptions = SW_MOD()->GetCTLOptions();
+ if ( !rCTLOptions.IsCTLFontEnabled() ||
+ !rCTLOptions.IsCTLSequenceChecking() )
+ return sal_False;
+
+ if ( 0 == rCrsr.Start()->nContent.GetIndex() ) /* first char needs not to be checked */
+ return sal_False;
+
+ SwBreakIt *pBreakIter = SwBreakIt::Get();
+ uno::Reference < i18n::XBreakIterator > xBI = pBreakIter->GetBreakIter();
+ long nCTLScriptPos = -1;
+
+ if (xBI.is())
+ {
+ if (xBI->getScriptType( rText, 0 ) == i18n::ScriptType::COMPLEX)
+ nCTLScriptPos = 0;
+ else
+ nCTLScriptPos = xBI->nextScript( rText, 0, i18n::ScriptType::COMPLEX );
+ }
+
+ return (0 <= nCTLScriptPos && nCTLScriptPos <= rText.getLength());
+}
+
+//return INVALID_HINT if language should not be explictly overridden, the correct
+//HintId to use for the eBufferLanguage otherwise
+static sal_uInt16 lcl_isNonDefaultLanguage(LanguageType eBufferLanguage, SwView& rView,
+ const OUString &rInBuffer)
+{
+ sal_uInt16 nWhich = INVALID_HINT;
+
+ //If the option to IgnoreLanguageChange is set, short-circuit this method
+ //which results in the document/paragraph language remaining the same
+ //despite a change to the keyboard/input language
+ SvtSysLocaleOptions aSysLocaleOptions;
+ if(aSysLocaleOptions.IsIgnoreLanguageChange())
+ {
+ return INVALID_HINT;
+ }
+
+ bool bLang = true;
+ if(eBufferLanguage != LANGUAGE_DONTKNOW)
+ {
+ switch( GetI18NScriptTypeOfLanguage( eBufferLanguage ))
+ {
+ case i18n::ScriptType::ASIAN: nWhich = RES_CHRATR_CJK_LANGUAGE; break;
+ case i18n::ScriptType::COMPLEX: nWhich = RES_CHRATR_CTL_LANGUAGE; break;
+ case i18n::ScriptType::LATIN: nWhich = RES_CHRATR_LANGUAGE; break;
+ default: bLang = false;
+ }
+ if(bLang)
+ {
+ SfxItemSet aLangSet(rView.GetPool(), nWhich, nWhich);
+ SwWrtShell& rSh = rView.GetWrtShell();
+ rSh.GetCurAttr(aLangSet);
+ if(SFX_ITEM_DEFAULT <= aLangSet.GetItemState(nWhich, true))
+ {
+ LanguageType eLang = static_cast<const SvxLanguageItem&>(aLangSet.Get(nWhich)).GetLanguage();
+ if ( eLang == eBufferLanguage )
+ {
+ // current language attribute equal to language reported from system
+ bLang = false;
+ }
+ else if ( !bInputLanguageSwitched && RES_CHRATR_LANGUAGE == nWhich )
+ {
+ // special case: switching between two "LATIN" languages
+ // In case the current keyboard setting might be suitable
+ // for both languages we can't safely assume that the user
+ // wants to use the language reported from the system,
+ // except if we knew that it was explicitly switched (thus
+ // the check for "bInputLangeSwitched").
+
+ // The language reported by the system could be just the
+ // system default language that the user is not even aware
+ // of, because no language selection tool is installed at
+ // all. In this case the OOo language should get preference
+ // as it might have been selected by the user explicitly.
+
+ // Usually this case happens if the OOo language is
+ // different to the system language but the system keyboard
+ // is still suitable for the OOo language (e.g. writing
+ // English texts with a German keyboard).
+
+ // For non-latin keyboards overwriting the attribute is
+ // still valid. We do this for kyrillic and greek ATM. In
+ // future versions of OOo this should be replaced by a
+ // configuration switch that allows to give the preference
+ // to the OOo setting or the system setting explicitly
+ // and/or a better handling of the script type.
+ i18n::UnicodeScript eType = !rInBuffer.isEmpty() ?
+ (i18n::UnicodeScript)GetAppCharClass().getScript( rInBuffer, 0 ) :
+ i18n::UnicodeScript_kScriptCount;
+
+ bool bSystemIsNonLatin = false;
+ switch ( eType )
+ {
+ case i18n::UnicodeScript_kGreek:
+ case i18n::UnicodeScript_kCyrillic:
+ // in case other UnicodeScripts require special
+ // keyboards they can be added here
+ bSystemIsNonLatin = true;
+ break;
+ default:
+ break;
+ }
+
+ bool bOOoLangIsNonLatin = MsLangId::isNonLatinWestern( eLang);
+
+ bLang = (bSystemIsNonLatin != bOOoLangIsNonLatin);
+ }
+ }
+ }
+ }
+ return bLang ? nWhich : INVALID_HINT;
+}
+
+/**
+ * Character buffer is inserted into the document
+ */
+void SwEditWin::FlushInBuffer()
+{
+ if ( !m_aInBuffer.isEmpty() )
+ {
+ SwWrtShell& rSh = m_rView.GetWrtShell();
+
+ // generate new sequence input checker if not already done
+ if ( !pCheckIt )
+ pCheckIt = new SwCheckIt;
+
+ uno::Reference < i18n::XExtendedInputSequenceChecker > xISC = pCheckIt->xCheck;
+ if ( xISC.is() && IsInputSequenceCheckingRequired( m_aInBuffer, *rSh.GetCrsr() ) )
+ {
+
+ // apply (Thai) input sequence checking/correction
+
+ rSh.Push(); // push current cursor to stack
+
+ // get text from the beginning (i.e left side) of current selection
+ // to the start of the paragraph
+ rSh.NormalizePam(); // make point be the first (left) one
+ if (!rSh.GetCrsr()->HasMark())
+ rSh.GetCrsr()->SetMark();
+ rSh.GetCrsr()->GetMark()->nContent = 0;
+
+ const OUString aOldText( rSh.GetCrsr()->GetTxt() );
+ const sal_Int32 nOldLen = aOldText.getLength();
+
+ SvtCTLOptions& rCTLOptions = SW_MOD()->GetCTLOptions();
+
+ sal_Int32 nExpandSelection = 0;
+ if (nOldLen > 0)
+ {
+ sal_Int32 nTmpPos = nOldLen;
+ sal_Int16 nCheckMode = rCTLOptions.IsCTLSequenceCheckingRestricted() ?
+ i18n::InputSequenceCheckMode::STRICT : i18n::InputSequenceCheckMode::BASIC;
+
+ OUString aNewText( aOldText );
+ if (rCTLOptions.IsCTLSequenceCheckingTypeAndReplace())
+ {
+ for( sal_Int32 k = 0; k < m_aInBuffer.getLength(); ++k)
+ {
+ const sal_Unicode cChar = m_aInBuffer[k];
+ const sal_Int32 nPrevPos =xISC->correctInputSequence( aNewText, nTmpPos - 1, cChar, nCheckMode );
+
+ // valid sequence or sequence could be corrected:
+ if (nPrevPos != aNewText.getLength())
+ nTmpPos = nPrevPos + 1;
+ }
+
+ // find position of first character that has changed
+ sal_Int32 nNewLen = aNewText.getLength();
+ const sal_Unicode *pOldTxt = aOldText.getStr();
+ const sal_Unicode *pNewTxt = aNewText.getStr();
+ sal_Int32 nChgPos = 0;
+ while ( nChgPos < nOldLen && nChgPos < nNewLen &&
+ pOldTxt[nChgPos] == pNewTxt[nChgPos] )
+ ++nChgPos;
+
+ const sal_Int32 nChgLen = nNewLen - nChgPos;
+ if (nChgLen)
+ {
+ m_aInBuffer = aNewText.copy( nChgPos, nChgLen );
+ nExpandSelection = nOldLen - nChgPos;
+ }
+ else
+ m_aInBuffer = "";
+ }
+ else
+ {
+ for( sal_Int32 k = 0; k < m_aInBuffer.getLength(); ++k )
+ {
+ const sal_Unicode cChar = m_aInBuffer[k];
+ if (xISC->checkInputSequence( aNewText, nTmpPos - 1, cChar, nCheckMode ))
+ {
+ // character can be inserted:
+ aNewText += OUString( (sal_Unicode) cChar );
+ ++nTmpPos;
+ }
+ }
+ m_aInBuffer = aNewText.copy( aOldText.getLength() ); // copy new text to be inserted to buffer
+ }
+ }
+
+ // at this point now we will insert the buffer text 'normally' some lines below...
+
+ rSh.Pop( sal_False ); // pop old cursor from stack
+
+ if (m_aInBuffer.isEmpty())
+ return;
+
+ // if text prior to the original selection needs to be changed
+ // as well, we now expand the selection accordingly.
+ SwPaM &rCrsr = *rSh.GetCrsr();
+ const sal_Int32 nCrsrStartPos = rCrsr.Start()->nContent.GetIndex();
+ OSL_ENSURE( nCrsrStartPos >= nExpandSelection, "cannot expand selection as specified!!" );
+ if (nExpandSelection && nCrsrStartPos >= nExpandSelection)
+ {
+ if (!rCrsr.HasMark())
+ rCrsr.SetMark();
+ rCrsr.Start()->nContent -= nExpandSelection;
+ }
+ }
+
+ uno::Reference< frame::XDispatchRecorder > xRecorder =
+ m_rView.GetViewFrame()->GetBindings().GetRecorder();
+ if ( xRecorder.is() )
+ {
+ // determine shell
+ SfxShell *pSfxShell = lcl_GetShellFromDispatcher( m_rView, TYPE(SwTextShell) );
+ // generate request and record
+ if (pSfxShell)
+ {
+ SfxRequest aReq( m_rView.GetViewFrame(), FN_INSERT_STRING );
+ aReq.AppendItem( SfxStringItem( FN_INSERT_STRING, m_aInBuffer ) );
+ aReq.Done();
+ }
+ }
+
+ sal_uInt16 nWhich = lcl_isNonDefaultLanguage(m_eBufferLanguage, m_rView, m_aInBuffer);
+ if (nWhich != INVALID_HINT )
+ {
+ SvxLanguageItem aLangItem( m_eBufferLanguage, nWhich );
+ rSh.SetAttrItem( aLangItem );
+ }
+
+ rSh.Insert( m_aInBuffer );
+ m_eBufferLanguage = LANGUAGE_DONTKNOW;
+ m_aInBuffer = "";
+ bFlushCharBuffer = false;
+ }
+}
+
+#define MOVE_LEFT_SMALL 0
+#define MOVE_UP_SMALL 1
+#define MOVE_RIGHT_BIG 2
+#define MOVE_DOWN_BIG 3
+#define MOVE_LEFT_BIG 4
+#define MOVE_UP_BIG 5
+#define MOVE_RIGHT_SMALL 6
+#define MOVE_DOWN_SMALL 7
+
+// #i121236# Support for shift key in writer
+#define MOVE_LEFT_HUGE 8
+#define MOVE_UP_HUGE 9
+#define MOVE_RIGHT_HUGE 10
+#define MOVE_DOWN_HUGE 11
+
+void SwEditWin::ChangeFly( sal_uInt8 nDir, sal_Bool bWeb )
+{
+ SwWrtShell &rSh = m_rView.GetWrtShell();
+ SwRect aTmp = rSh.GetFlyRect();
+ if( aTmp.HasArea() &&
+ !rSh.IsSelObjProtected( FLYPROTECT_POS ) )
+ {
+ SfxItemSet aSet(rSh.GetAttrPool(),
+ RES_FRM_SIZE, RES_FRM_SIZE,
+ RES_VERT_ORIENT, RES_ANCHOR,
+ RES_COL, RES_COL,
+ RES_PROTECT, RES_PROTECT,
+ RES_FOLLOW_TEXT_FLOW, RES_FOLLOW_TEXT_FLOW, 0);
+ rSh.GetFlyFrmAttr( aSet );
+ RndStdIds eAnchorId = ((SwFmtAnchor&)aSet.Get(RES_ANCHOR)).GetAnchorId();
+ Size aSnap;
+ bool bHuge(MOVE_LEFT_HUGE == nDir ||
+ MOVE_UP_HUGE == nDir ||
+ MOVE_RIGHT_HUGE == nDir ||
+ MOVE_DOWN_HUGE == nDir);
+
+ if(MOVE_LEFT_SMALL == nDir ||
+ MOVE_UP_SMALL == nDir ||
+ MOVE_RIGHT_SMALL == nDir ||
+ MOVE_DOWN_SMALL == nDir )
+ {
+ aSnap = PixelToLogic(Size(1,1));
+ }
+ else
+ {
+ aSnap = rSh.GetViewOptions()->GetSnapSize();
+ short nDiv = rSh.GetViewOptions()->GetDivisionX();
+ if ( nDiv > 0 )
+ aSnap.Width() = std::max( (sal_uLong)1, (sal_uLong)aSnap.Width() / nDiv );
+ nDiv = rSh.GetViewOptions()->GetDivisionY();
+ if ( nDiv > 0 )
+ aSnap.Height() = std::max( (sal_uLong)1, (sal_uLong)aSnap.Height() / nDiv );
+ }
+
+ if(bHuge)
+ {
+ // #i121236# 567twips == 1cm, but just take three times the normal snap
+ aSnap = Size(aSnap.Width() * 3, aSnap.Height() * 3);
+ }
+
+ SwRect aBoundRect;
+ Point aRefPoint;
+ // adjustment for allowing vertical position
+ // aligned to page for fly frame anchored to paragraph or to character.
+ {
+ SwFmtVertOrient aVert( (SwFmtVertOrient&)aSet.Get(RES_VERT_ORIENT) );
+ const bool bFollowTextFlow =
+ static_cast<const SwFmtFollowTextFlow&>(aSet.Get(RES_FOLLOW_TEXT_FLOW)).GetValue();
+ const SwPosition* pToCharCntntPos = ((SwFmtAnchor&)aSet.Get(RES_ANCHOR)).GetCntntAnchor();
+ rSh.CalcBoundRect( aBoundRect, eAnchorId,
+ text::RelOrientation::FRAME, aVert.GetRelationOrient(),
+ pToCharCntntPos, bFollowTextFlow,
+ false, &aRefPoint );
+ }
+ long nLeft = std::min( aTmp.Left() - aBoundRect.Left(), aSnap.Width() );
+ long nRight = std::min( aBoundRect.Right() - aTmp.Right(), aSnap.Width() );
+ long nUp = std::min( aTmp.Top() - aBoundRect.Top(), aSnap.Height() );
+ long nDown = std::min( aBoundRect.Bottom() - aTmp.Bottom(), aSnap.Height() );
+
+ switch ( nDir )
+ {
+ case MOVE_LEFT_BIG:
+ case MOVE_LEFT_HUGE:
+ case MOVE_LEFT_SMALL: aTmp.Left( aTmp.Left() - nLeft );
+ break;
+
+ case MOVE_UP_BIG:
+ case MOVE_UP_HUGE:
+ case MOVE_UP_SMALL: aTmp.Top( aTmp.Top() - nUp );
+ break;
+
+ case MOVE_RIGHT_SMALL:
+ if( aTmp.Width() < aSnap.Width() + MINFLY )
+ break;
+ nRight = aSnap.Width(); // no break
+ case MOVE_RIGHT_HUGE:
+ case MOVE_RIGHT_BIG: aTmp.Left( aTmp.Left() + nRight );
+ break;
+
+ case MOVE_DOWN_SMALL:
+ if( aTmp.Height() < aSnap.Height() + MINFLY )
+ break;
+ nDown = aSnap.Height(); // no break
+ case MOVE_DOWN_HUGE:
+ case MOVE_DOWN_BIG: aTmp.Top( aTmp.Top() + nDown );
+ break;
+
+ default: OSL_ENSURE(true, "ChangeFly: Unknown direction." );
+ }
+ bool bSet = false;
+ if ((FLY_AS_CHAR == eAnchorId) && ( nDir % 2 ))
+ {
+ long aDiff = aTmp.Top() - aRefPoint.Y();
+ if( aDiff > 0 )
+ aDiff = 0;
+ else if ( aDiff < -aTmp.Height() )
+ aDiff = -aTmp.Height();
+ SwFmtVertOrient aVert( (SwFmtVertOrient&)aSet.Get(RES_VERT_ORIENT) );
+ sal_Int16 eNew;
+ if( bWeb )
+ {
+ eNew = aVert.GetVertOrient();
+ bool bDown = 0 != ( nDir & 0x02 );
+ switch( eNew )
+ {
+ case text::VertOrientation::CHAR_TOP:
+ if( bDown ) eNew = text::VertOrientation::CENTER;
+ break;
+ case text::VertOrientation::CENTER:
+ eNew = bDown ? text::VertOrientation::TOP : text::VertOrientation::CHAR_TOP;
+ break;
+ case text::VertOrientation::TOP:
+ if( !bDown ) eNew = text::VertOrientation::CENTER;
+ break;
+ case text::VertOrientation::LINE_TOP:
+ if( bDown ) eNew = text::VertOrientation::LINE_CENTER;
+ break;
+ case text::VertOrientation::LINE_CENTER:
+ eNew = bDown ? text::VertOrientation::LINE_BOTTOM : text::VertOrientation::LINE_TOP;
+ break;
+ case text::VertOrientation::LINE_BOTTOM:
+ if( !bDown ) eNew = text::VertOrientation::LINE_CENTER;
+ break;
+ default:; //prevent warning
+ }
+ }
+ else
+ {
+ aVert.SetPos( aDiff );
+ eNew = text::VertOrientation::NONE;
+ }
+ aVert.SetVertOrient( eNew );
+ aSet.Put( aVert );
+ bSet = true;
+ }
+ if (bWeb && (FLY_AT_PARA == eAnchorId)
+ && ( nDir==MOVE_LEFT_SMALL || nDir==MOVE_RIGHT_BIG ))
+ {
+ SwFmtHoriOrient aHori( (SwFmtHoriOrient&)aSet.Get(RES_HORI_ORIENT) );
+ sal_Int16 eNew;
+ eNew = aHori.GetHoriOrient();
+ switch( eNew )
+ {
+ case text::HoriOrientation::RIGHT:
+ if( nDir==MOVE_LEFT_SMALL )
+ eNew = text::HoriOrientation::LEFT;
+ break;
+ case text::HoriOrientation::LEFT:
+ if( nDir==MOVE_RIGHT_BIG )
+ eNew = text::HoriOrientation::RIGHT;
+ break;
+ default:; //prevent warning
+ }
+ if( eNew != aHori.GetHoriOrient() )
+ {
+ aHori.SetHoriOrient( eNew );
+ aSet.Put( aHori );
+ bSet = true;
+ }
+ }
+ rSh.StartAllAction();
+ if( bSet )
+ rSh.SetFlyFrmAttr( aSet );
+ bool bSetPos = (FLY_AS_CHAR != eAnchorId);
+ if(bSetPos && bWeb)
+ {
+ if (FLY_AT_PAGE != eAnchorId)
+ {
+ bSetPos = false;
+ }
+ else
+ {
+ bSetPos = true;
+ }
+ }
+ if( bSetPos )
+ rSh.SetFlyPos( aTmp.Pos() );
+ rSh.EndAllAction();
+ }
+}
+
+void SwEditWin::ChangeDrawing( sal_uInt8 nDir )
+{
+ // start undo action in order to get only one
+ // undo action for this change.
+ SwWrtShell &rSh = m_rView.GetWrtShell();
+ rSh.StartUndo();
+
+ long nX = 0;
+ long nY = 0;
+ const bool bOnePixel(
+ MOVE_LEFT_SMALL == nDir ||
+ MOVE_UP_SMALL == nDir ||
+ MOVE_RIGHT_SMALL == nDir ||
+ MOVE_DOWN_SMALL == nDir);
+ const bool bHuge(
+ MOVE_LEFT_HUGE == nDir ||
+ MOVE_UP_HUGE == nDir ||
+ MOVE_RIGHT_HUGE == nDir ||
+ MOVE_DOWN_HUGE == nDir);
+ sal_uInt16 nAnchorDir = SW_MOVE_UP;
+ switch(nDir)
+ {
+ case MOVE_LEFT_SMALL:
+ case MOVE_LEFT_HUGE:
+ case MOVE_LEFT_BIG:
+ nX = -1;
+ nAnchorDir = SW_MOVE_LEFT;
+ break;
+ case MOVE_UP_SMALL:
+ case MOVE_UP_HUGE:
+ case MOVE_UP_BIG:
+ nY = -1;
+ break;
+ case MOVE_RIGHT_SMALL:
+ case MOVE_RIGHT_HUGE:
+ case MOVE_RIGHT_BIG:
+ nX = +1;
+ nAnchorDir = SW_MOVE_RIGHT;
+ break;
+ case MOVE_DOWN_SMALL:
+ case MOVE_DOWN_HUGE:
+ case MOVE_DOWN_BIG:
+ nY = +1;
+ nAnchorDir = SW_MOVE_DOWN;
+ break;
+ }
+
+ if(0 != nX || 0 != nY)
+ {
+ sal_uInt8 nProtect = rSh.IsSelObjProtected( FLYPROTECT_POS|FLYPROTECT_SIZE );
+ Size aSnap( rSh.GetViewOptions()->GetSnapSize() );
+ short nDiv = rSh.GetViewOptions()->GetDivisionX();
+ if ( nDiv > 0 )
+ aSnap.Width() = std::max( (sal_uLong)1, (sal_uLong)aSnap.Width() / nDiv );
+ nDiv = rSh.GetViewOptions()->GetDivisionY();
+ if ( nDiv > 0 )
+ aSnap.Height() = std::max( (sal_uLong)1, (sal_uLong)aSnap.Height() / nDiv );
+
+ if(bOnePixel)
+ {
+ aSnap = PixelToLogic(Size(1,1));
+ }
+ else if(bHuge)
+ {
+ // #i121236# 567twips == 1cm, but just take three times the normal snap
+ aSnap = Size(aSnap.Width() * 3, aSnap.Height() * 3);
+ }
+
+ nX *= aSnap.Width();
+ nY *= aSnap.Height();
+
+ SdrView *pSdrView = rSh.GetDrawView();
+ const SdrHdlList& rHdlList = pSdrView->GetHdlList();
+ SdrHdl* pHdl = rHdlList.GetFocusHdl();
+ rSh.StartAllAction();
+ if(0L == pHdl)
+ {
+ // now move the selected draw objects
+ // if the object's position is not protected
+ if(0 == (nProtect&FLYPROTECT_POS))
+ {
+ // Check if object is anchored as character and move direction
+ sal_Bool bDummy1, bDummy2;
+ const bool bVertAnchor = rSh.IsFrmVertical( sal_True, bDummy1, bDummy2 );
+ bool bHoriMove = !bVertAnchor == !( nDir % 2 );
+ bool bMoveAllowed =
+ !bHoriMove || (rSh.GetAnchorId() != FLY_AS_CHAR);
+ if ( bMoveAllowed )
+ {
+ pSdrView->MoveAllMarked(Size(nX, nY));
+ rSh.SetModified();
+ }
+ }
+ }
+ else
+ {
+ // move handle with index nHandleIndex
+ if(pHdl && (nX || nY))
+ {
+ if( HDL_ANCHOR == pHdl->GetKind() ||
+ HDL_ANCHOR_TR == pHdl->GetKind() )
+ {
+ // anchor move cannot be allowed when position is protected
+ if(0 == (nProtect&FLYPROTECT_POS))
+ rSh.MoveAnchor( nAnchorDir );
+ }
+ //now resize if size is protected
+ else if(0 == (nProtect&FLYPROTECT_SIZE))
+ {
+ // now move the Handle (nX, nY)
+ Point aStartPoint(pHdl->GetPos());
+ Point aEndPoint(pHdl->GetPos() + Point(nX, nY));
+ const SdrDragStat& rDragStat = pSdrView->GetDragStat();
+
+ // start dragging
+ pSdrView->BegDragObj(aStartPoint, 0, pHdl, 0);
+
+ if(pSdrView->IsDragObj())
+ {
+ sal_Bool bWasNoSnap = static_cast< sal_Bool >(rDragStat.IsNoSnap());
+ sal_Bool bWasSnapEnabled = pSdrView->IsSnapEnabled();
+
+ // switch snapping off
+ if(!bWasNoSnap)
+ ((SdrDragStat&)rDragStat).SetNoSnap(true);
+ if(bWasSnapEnabled)
+ pSdrView->SetSnapEnabled(sal_False);
+
+ pSdrView->MovAction(aEndPoint);
+ pSdrView->EndDragObj();
+ rSh.SetModified();
+
+ // restore snap
+ if(!bWasNoSnap)
+ ((SdrDragStat&)rDragStat).SetNoSnap(bWasNoSnap);
+ if(bWasSnapEnabled)
+ pSdrView->SetSnapEnabled(bWasSnapEnabled);
+ }
+ }
+ }
+ }
+ rSh.EndAllAction();
+ }
+
+ rSh.EndUndo();
+}
+
+/**
+ * KeyEvents
+ */
+void SwEditWin::KeyInput(const KeyEvent &rKEvt)
+{
+ SwWrtShell &rSh = m_rView.GetWrtShell();
+
+ if( rKEvt.GetKeyCode().GetCode() == KEY_ESCAPE &&
+ m_pApplyTempl && m_pApplyTempl->m_pFormatClipboard )
+ {
+ m_pApplyTempl->m_pFormatClipboard->Erase();
+ SetApplyTemplate(SwApplyTemplate());
+ m_rView.GetViewFrame()->GetBindings().Invalidate(SID_FORMATPAINTBRUSH);
+ }
+ else if ( rKEvt.GetKeyCode().GetCode() == KEY_ESCAPE &&
+ rSh.IsHeaderFooterEdit( ) )
+ {
+ bool bHeader = FRMTYPE_HEADER & rSh.GetFrmType(0,sal_False);
+ if ( bHeader )
+ rSh.SttPg();
+ else
+ rSh.EndPg();
+ rSh.ToggleHeaderFooterEdit();
+ }
+
+ SfxObjectShell *pObjSh = (SfxObjectShell*)m_rView.GetViewFrame()->GetObjectShell();
+ if ( m_bLockInput || (pObjSh && pObjSh->GetProgress()) )
+ // When the progress bar is active or a progress is
+ // running on a document, no order is being taken
+ return;
+
+ delete m_pShadCrsr, m_pShadCrsr = 0;
+ m_aKeyInputFlushTimer.Stop();
+
+ bool bIsDocReadOnly = m_rView.GetDocShell()->IsReadOnly() &&
+ rSh.IsCrsrReadonly();
+
+ //if the language changes the buffer must be flushed
+ LanguageType eNewLanguage = GetInputLanguage();
+ if(!bIsDocReadOnly && m_eBufferLanguage != eNewLanguage && !m_aInBuffer.isEmpty())
+ {
+ FlushInBuffer();
+ }
+ m_eBufferLanguage = eNewLanguage;
+
+ QuickHelpData aTmpQHD;
+ if( m_pQuickHlpData->m_bIsDisplayed )
+ {
+ aTmpQHD.Move( *m_pQuickHlpData );
+ m_pQuickHlpData->Stop( rSh );
+ }
+
+ // OS:the DrawView also needs a readonly-Flag as well
+ if ( !bIsDocReadOnly && rSh.GetDrawView() && rSh.GetDrawView()->KeyInput( rKEvt, this ) )
+ {
+ rSh.GetView().GetViewFrame()->GetBindings().InvalidateAll( sal_False );
+ rSh.SetModified();
+ return; // Event evaluated by SdrView
+ }
+
+ if ( m_rView.GetDrawFuncPtr() && m_bInsFrm )
+ {
+ StopInsFrm();
+ rSh.Edit();
+ }
+
+ bool bFlushBuffer = false;
+ bool bNormalChar = false;
+ bool bAppendSpace = m_pQuickHlpData->m_bAppendSpace;
+ m_pQuickHlpData->m_bAppendSpace = false;
+
+ if ( getenv("SW_DEBUG") && rKEvt.GetKeyCode().GetCode() == KEY_F12 )
+ {
+ if( rKEvt.GetKeyCode().IsShift())
+ {
+ GetView().GetDocShell()->GetDoc()->dumpAsXml();
+ return;
+ }
+ else
+ {
+ SwRootFrm* pLayout = GetView().GetDocShell()->GetWrtShell()->GetLayout();
+ pLayout->dumpAsXml( );
+ return;
+ }
+ }
+
+ KeyEvent aKeyEvent( rKEvt );
+ // look for vertical mappings
+ if( !bIsDocReadOnly && !rSh.IsSelFrmMode() && !rSh.IsObjSelected() )
+ {
+ // must changed from switch to if, because the Linux
+ // compiler has problem with the code. Has to remove if the new general
+ // handler exist.
+ sal_uInt16 nKey = rKEvt.GetKeyCode().GetCode();
+
+ if( KEY_UP == nKey || KEY_DOWN == nKey ||
+ KEY_LEFT == nKey || KEY_RIGHT == nKey )
+ {
+ // In general, we want to map the direction keys if we are inside
+ // some vertical formatted text.
+ // 1. Exception: For a table cursor in a horizontal table, the
+ // directions should never be mapped.
+ // 2. Exception: For a table cursor in a vertical table, the
+ // directions should always be mapped.
+ const bool bVertText = rSh.IsInVerticalText();
+ const bool bTblCrsr = rSh.GetTableCrsr();
+ const bool bVertTable = rSh.IsTableVertical();
+ if( ( bVertText && ( !bTblCrsr || bVertTable ) ) ||
+ ( bTblCrsr && bVertTable ) )
+ {
+ // Attempt to integrate cursor travelling for mongolian layout does not work.
+ // Thus, back to previous mapping of cursor keys to direction keys.
+ if( KEY_UP == nKey ) nKey = KEY_LEFT;
+ else if( KEY_DOWN == nKey ) nKey = KEY_RIGHT;
+ else if( KEY_LEFT == nKey ) nKey = KEY_DOWN;
+ else if( KEY_RIGHT == nKey ) nKey = KEY_UP;
+ }
+
+ if ( rSh.IsInRightToLeftText() )
+ {
+ if( KEY_LEFT == nKey ) nKey = KEY_RIGHT;
+ else if( KEY_RIGHT == nKey ) nKey = KEY_LEFT;
+ }
+
+ aKeyEvent = KeyEvent( rKEvt.GetCharCode(),
+ KeyCode( nKey, rKEvt.GetKeyCode().GetModifier() ),
+ rKEvt.GetRepeat() );
+ }
+ }
+
+ const KeyCode& rKeyCode = aKeyEvent.GetKeyCode();
+ sal_Unicode aCh = aKeyEvent.GetCharCode();
+
+ // enable switching to notes ankor with Ctrl - Alt - Page Up/Down
+ // pressing this inside a note will switch to next/previous note
+ if ((rKeyCode.IsMod1() && rKeyCode.IsMod2()) && ((rKeyCode.GetCode() == KEY_PAGEUP) || (rKeyCode.GetCode() == KEY_PAGEDOWN)))
+ {
+ const bool bNext = rKeyCode.GetCode()==KEY_PAGEDOWN ? true : false;
+ const SwFieldType* pFldType = rSh.GetFldType( 0, RES_POSTITFLD );
+ rSh.MoveFldType( pFldType, bNext );
+ return;
+ }
+
+ const SwFrmFmt* pFlyFmt = rSh.GetFlyFrmFmt();
+ if( pFlyFmt )
+ {
+ sal_uInt16 nEvent;
+
+ if( 32 <= aCh &&
+ 0 == (( KEY_MOD1 | KEY_MOD2 ) & rKeyCode.GetModifier() ))
+ nEvent = SW_EVENT_FRM_KEYINPUT_ALPHA;
+ else
+ nEvent = SW_EVENT_FRM_KEYINPUT_NOALPHA;
+
+ const SvxMacro* pMacro = pFlyFmt->GetMacro().GetMacroTable().Get( nEvent );
+ if( pMacro )
+ {
+ SbxArrayRef xArgs = new SbxArray;
+ SbxVariableRef xVar = new SbxVariable;
+ xVar->PutString( pFlyFmt->GetName() );
+ xArgs->Put( &xVar, 1 );
+
+ xVar = new SbxVariable;
+ if( SW_EVENT_FRM_KEYINPUT_ALPHA == nEvent )
+ xVar->PutChar( aCh );
+ else
+ xVar->PutUShort( rKeyCode.GetModifier() | rKeyCode.GetCode() );
+ xArgs->Put( &xVar, 2 );
+
+ OUString sRet;
+ rSh.ExecMacro( *pMacro, &sRet, &xArgs );
+ if( !sRet.isEmpty() && sRet.toInt32()!=0 )
+ return ;
+ }
+ }
+ int nLclSelectionType;
+ //A is converted to 1
+ if( rKeyCode.GetFullCode() == (KEY_A | KEY_MOD1 |KEY_SHIFT)
+ && rSh.HasDrawView() &&
+ (0 != (nLclSelectionType = rSh.GetSelectionType()) &&
+ ((nLclSelectionType & (nsSelectionType::SEL_FRM|nsSelectionType::SEL_GRF)) ||
+ ((nLclSelectionType & (nsSelectionType::SEL_DRW|nsSelectionType::SEL_DRW_FORM)) &&
+ rSh.GetDrawView()->GetMarkedObjectList().GetMarkCount() == 1))))
+ {
+ SdrHdlList& rHdlList = (SdrHdlList&)rSh.GetDrawView()->GetHdlList();
+ SdrHdl* pAnchor = rHdlList.GetHdl(HDL_ANCHOR);
+ if ( ! pAnchor )
+ pAnchor = rHdlList.GetHdl(HDL_ANCHOR_TR);
+ if(pAnchor)
+ rHdlList.SetFocusHdl(pAnchor);
+ return;
+ }
+
+ SvxAutoCorrCfg* pACfg = 0;
+ SvxAutoCorrect* pACorr = 0;
+
+ uno::Reference< frame::XDispatchRecorder > xRecorder =
+ m_rView.GetViewFrame()->GetBindings().GetRecorder();
+ if ( !xRecorder.is() )
+ {
+ pACfg = &SvxAutoCorrCfg::Get();
+ pACorr = pACfg->GetAutoCorrect();
+ }
+
+ SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
+
+ TblChgWidthHeightType eTblChgMode = nsTblChgWidthHeightType::WH_COL_LEFT; // initialization just for warning-free code
+ sal_uInt16 nTblChgSize = 0;
+ bool bStopKeyInputTimer = true;
+ OUString sFmlEntry;
+
+ enum SW_KeyState { KS_Start,
+ KS_CheckKey, KS_InsChar, KS_InsTab,
+ KS_NoNum, KS_NumOff, KS_NumOrNoNum, KS_NumDown, KS_NumUp,
+ KS_NumIndentInc, KS_NumIndentDec,
+
+ KS_OutlineLvOff,
+ KS_NextCell, KS_PrevCell, KS_OutlineUp, KS_OutlineDown,
+ KS_GlossaryExpand, KS_NextPrevGlossary,
+ KS_AutoFmtByInput,
+ KS_NextObject, KS_PrevObject,
+ KS_KeyToView,
+ KS_LaunchOLEObject, KS_GoIntoFly, KS_GoIntoDrawing,
+ KS_EnterDrawHandleMode,
+ KS_CheckDocReadOnlyKeys,
+ KS_CheckAutoCorrect, KS_EditFormula,
+ KS_ColLeftBig, KS_ColRightBig,
+ KS_ColLeftSmall, KS_ColRightSmall,
+ KS_ColTopBig, KS_ColBottomBig,
+ KS_ColTopSmall, KS_ColBottomSmall,
+ KS_CellLeftBig, KS_CellRightBig,
+ KS_CellLeftSmall, KS_CellRightSmall,
+ KS_CellTopBig, KS_CellBottomBig,
+ KS_CellTopSmall, KS_CellBottomSmall,
+
+ KS_InsDel_ColLeftBig, KS_InsDel_ColRightBig,
+ KS_InsDel_ColLeftSmall, KS_InsDel_ColRightSmall,
+ KS_InsDel_ColTopBig, KS_InsDel_ColBottomBig,
+ KS_InsDel_ColTopSmall, KS_InsDel_ColBottomSmall,
+ KS_InsDel_CellLeftBig, KS_InsDel_CellRightBig,
+ KS_InsDel_CellLeftSmall, KS_InsDel_CellRightSmall,
+ KS_InsDel_CellTopBig, KS_InsDel_CellBottomBig,
+ KS_InsDel_CellTopSmall, KS_InsDel_CellBottomSmall,
+ KS_TblColCellInsDel,
+
+ KS_Fly_Change, KS_Draw_Change,
+ KS_SpecialInsert,
+ KS_EnterCharCell,
+ KS_GotoNextFieldMark,
+ KS_GotoPrevFieldMark,
+ KS_End };
+
+ SW_KeyState eKeyState = bIsDocReadOnly ? KS_CheckDocReadOnlyKeys : KS_CheckKey;
+ SW_KeyState eNextKeyState = KS_End;
+ sal_uInt8 nDir = 0;
+
+ if (m_nKS_NUMDOWN_Count > 0)
+ m_nKS_NUMDOWN_Count--;
+
+ if (m_nKS_NUMINDENTINC_Count > 0)
+ m_nKS_NUMINDENTINC_Count--;
+
+ while( KS_End != eKeyState )
+ {
+ SW_KeyState eFlyState = KS_KeyToView;
+
+ switch( eKeyState )
+ {
+ case KS_CheckKey:
+ eKeyState = KS_KeyToView; // default forward to View
+
+#if OSL_DEBUG_LEVEL > 1
+//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ // for switching curor behaviour in ReadOnly regions
+ if( 0x7210 == rKeyCode.GetFullCode() )
+ rSh.SetReadOnlyAvailable( !rSh.IsReadOnlyAvailable() );
+ else
+//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+#endif
+
+ if( !rKeyCode.IsMod2() && '=' == aCh &&
+ !rSh.IsTableMode() && rSh.GetTableFmt() &&
+ rSh.IsSttPara() &&
+ !rSh.HasReadonlySel() )
+ {
+ // at the beginning of the table's cell a '=' ->
+ // call EditRow (F2-functionality)
+ rSh.Push();
+ if( !rSh.MoveSection( fnSectionCurr, fnSectionStart) &&
+ !rSh.IsTableBoxTextFormat() )
+ {
+ // is at the beginning of the box
+ eKeyState = KS_EditFormula;
+ if( rSh.HasMark() )
+ rSh.SwapPam();
+ else
+ rSh.SttSelect();
+ rSh.MoveSection( fnSectionCurr, fnSectionEnd );
+ rSh.Pop( sal_True );
+ rSh.EndSelect();
+ sFmlEntry = "=";
+ }
+ else
+ rSh.Pop( sal_False );
+ }
+ else
+ {
+ if( pACorr && aTmpQHD.HasCntnt() && !rSh.HasSelection() &&
+ !rSh.HasReadonlySel() && !aTmpQHD.m_bIsAutoText &&
+ pACorr->GetSwFlags().nAutoCmpltExpandKey ==
+ (rKeyCode.GetModifier() | rKeyCode.GetCode()) )
+ {
+ eKeyState = KS_GlossaryExpand;
+ break;
+ }
+
+ switch( rKeyCode.GetModifier() | rKeyCode.GetCode() )
+ {
+ case KEY_RIGHT | KEY_MOD2:
+ eKeyState = KS_ColRightBig;
+ eFlyState = KS_Fly_Change;
+ nDir = MOVE_RIGHT_SMALL;
+ goto KEYINPUT_CHECKTABLE;
+
+ case KEY_LEFT | KEY_MOD2:
+ eKeyState = KS_ColRightSmall;
+ eFlyState = KS_Fly_Change;
+ nDir = MOVE_LEFT_SMALL;
+ goto KEYINPUT_CHECKTABLE;
+
+ case KEY_RIGHT | KEY_MOD2 | KEY_SHIFT:
+ eKeyState = KS_ColLeftSmall;
+ goto KEYINPUT_CHECKTABLE;
+
+ case KEY_LEFT | KEY_MOD2 | KEY_SHIFT:
+ eKeyState = KS_ColLeftBig;
+ goto KEYINPUT_CHECKTABLE;
+
+ case KEY_RIGHT | KEY_MOD2 | KEY_MOD1:
+ eKeyState = KS_CellRightBig;
+ goto KEYINPUT_CHECKTABLE;
+
+ case KEY_LEFT | KEY_MOD2 | KEY_MOD1:
+ eKeyState = KS_CellRightSmall;
+ goto KEYINPUT_CHECKTABLE;
+
+ case KEY_RIGHT | KEY_MOD2 | KEY_SHIFT | KEY_MOD1:
+ eKeyState = KS_CellLeftSmall;
+ goto KEYINPUT_CHECKTABLE;
+
+ case KEY_LEFT | KEY_MOD2 | KEY_SHIFT | KEY_MOD1:
+ eKeyState = KS_CellLeftBig;
+ goto KEYINPUT_CHECKTABLE;
+
+ case KEY_UP | KEY_MOD2:
+ eKeyState = KS_ColBottomSmall;
+ eFlyState = KS_Fly_Change;
+ nDir = MOVE_UP_SMALL;
+ goto KEYINPUT_CHECKTABLE;
+
+ case KEY_DOWN | KEY_MOD2:
+ eKeyState = KS_ColBottomBig;
+ eFlyState = KS_Fly_Change;
+ nDir = MOVE_DOWN_SMALL;
+ goto KEYINPUT_CHECKTABLE;
+
+ case KEY_UP | KEY_MOD2 | KEY_MOD1:
+ eKeyState = KS_CellBottomSmall;
+ goto KEYINPUT_CHECKTABLE;
+
+ case KEY_DOWN | KEY_MOD2 | KEY_MOD1:
+ eKeyState = KS_CellBottomBig;
+ goto KEYINPUT_CHECKTABLE;
+
+ case KEY_UP | KEY_MOD2 | KEY_SHIFT | KEY_MOD1:
+ eKeyState = KS_CellTopBig;
+ goto KEYINPUT_CHECKTABLE;
+
+ case KEY_DOWN | KEY_MOD2 | KEY_SHIFT | KEY_MOD1:
+ eKeyState = KS_CellTopSmall;
+ goto KEYINPUT_CHECKTABLE;
+
+KEYINPUT_CHECKTABLE:
+ if( rSh.IsTableMode() || !rSh.GetTableFmt() )
+ {
+ if(KS_KeyToView != eFlyState)
+ {
+ if(!pFlyFmt && KS_KeyToView != eFlyState &&
+ (rSh.GetSelectionType() & (nsSelectionType::SEL_DRW|nsSelectionType::SEL_DRW_FORM)) &&
+ rSh.GetDrawView()->AreObjectsMarked())
+ eKeyState = KS_Draw_Change;
+ }
+
+ if( pFlyFmt )
+ eKeyState = eFlyState;
+ else if( KS_Draw_Change != eKeyState)
+ eKeyState = KS_EnterCharCell;
+ }
+ break;
+
+ // huge object move
+ case KEY_RIGHT | KEY_SHIFT:
+ case KEY_LEFT | KEY_SHIFT:
+ case KEY_UP | KEY_SHIFT:
+ case KEY_DOWN | KEY_SHIFT:
+ {
+ const int nSelectionType = rSh.GetSelectionType();
+ if ( ( pFlyFmt
+ && ( nSelectionType & (nsSelectionType::SEL_FRM|nsSelectionType::SEL_OLE|nsSelectionType::SEL_GRF) ) )
+ || ( ( nSelectionType & (nsSelectionType::SEL_DRW|nsSelectionType::SEL_DRW_FORM) )
+ && rSh.GetDrawView()->AreObjectsMarked() ) )
+ {
+ eKeyState = pFlyFmt ? KS_Fly_Change : KS_Draw_Change;
+ switch ( rKeyCode.GetCode() )
+ {
+ case KEY_RIGHT: nDir = MOVE_RIGHT_HUGE; break;
+ case KEY_LEFT: nDir = MOVE_LEFT_HUGE; break;
+ case KEY_UP: nDir = MOVE_UP_HUGE; break;
+ case KEY_DOWN: nDir = MOVE_DOWN_HUGE; break;
+ }
+ }
+ break;
+ }
+
+ case KEY_LEFT:
+ case KEY_LEFT | KEY_MOD1:
+ {
+ bool bMod1 = 0 != (rKeyCode.GetModifier() & KEY_MOD1);
+ if(!bMod1)
+ {
+ eFlyState = KS_Fly_Change;
+ nDir = MOVE_LEFT_BIG;
+ }
+ eTblChgMode = nsTblChgWidthHeightType::WH_FLAG_INSDEL |
+ ( bMod1
+ ? nsTblChgWidthHeightType::WH_CELL_LEFT
+ : nsTblChgWidthHeightType::WH_COL_LEFT );
+ nTblChgSize = pModOpt->GetTblVInsert();
+ }
+ goto KEYINPUT_CHECKTABLE_INSDEL;
+ case KEY_RIGHT | KEY_MOD1:
+ {
+ eTblChgMode = nsTblChgWidthHeightType::WH_FLAG_INSDEL | nsTblChgWidthHeightType::WH_CELL_RIGHT;
+ nTblChgSize = pModOpt->GetTblVInsert();
+ }
+ goto KEYINPUT_CHECKTABLE_INSDEL;
+ case KEY_UP:
+ case KEY_UP | KEY_MOD1:
+ {
+ bool bMod1 = 0 != (rKeyCode.GetModifier() & KEY_MOD1);
+ if(!bMod1)
+ {
+ eFlyState = KS_Fly_Change;
+ nDir = MOVE_UP_BIG;
+ }
+ eTblChgMode = nsTblChgWidthHeightType::WH_FLAG_INSDEL |
+ ( bMod1
+ ? nsTblChgWidthHeightType::WH_CELL_TOP
+ : nsTblChgWidthHeightType::WH_ROW_TOP );
+ nTblChgSize = pModOpt->GetTblHInsert();
+ }
+ goto KEYINPUT_CHECKTABLE_INSDEL;
+ case KEY_DOWN:
+ case KEY_DOWN | KEY_MOD1:
+ {
+ bool bMod1 = 0 != (rKeyCode.GetModifier() & KEY_MOD1);
+ if(!bMod1)
+ {
+ eFlyState = KS_Fly_Change;
+ nDir = MOVE_DOWN_BIG;
+ }
+ eTblChgMode = nsTblChgWidthHeightType::WH_FLAG_INSDEL |
+ ( bMod1
+ ? nsTblChgWidthHeightType::WH_CELL_BOTTOM
+ : nsTblChgWidthHeightType::WH_ROW_BOTTOM );
+ nTblChgSize = pModOpt->GetTblHInsert();
+ }
+ goto KEYINPUT_CHECKTABLE_INSDEL;
+
+KEYINPUT_CHECKTABLE_INSDEL:
+ if( rSh.IsTableMode() || !rSh.GetTableFmt() ||
+ !m_bTblInsDelMode ||
+ false /* table protected */
+ )
+ {
+ const int nSelectionType = rSh.GetSelectionType();
+
+ eKeyState = KS_KeyToView;
+ if(KS_KeyToView != eFlyState)
+ {
+ if((nSelectionType & (nsSelectionType::SEL_DRW|nsSelectionType::SEL_DRW_FORM)) &&
+ rSh.GetDrawView()->AreObjectsMarked())
+ eKeyState = KS_Draw_Change;
+ else if(nSelectionType & (nsSelectionType::SEL_FRM|nsSelectionType::SEL_OLE|nsSelectionType::SEL_GRF))
+ eKeyState = KS_Fly_Change;
+ }
+ }
+ else
+ {
+ if( !m_bTblIsInsMode )
+ eTblChgMode = eTblChgMode | nsTblChgWidthHeightType::WH_FLAG_BIGGER;
+ eKeyState = KS_TblColCellInsDel;
+ }
+ break;
+
+ case KEY_DELETE:
+ if ( !rSh.HasReadonlySel() )
+ {
+ if (rSh.IsInFrontOfLabel() && rSh.NumOrNoNum(false))
+ eKeyState = KS_NumOrNoNum;
+ }
+ else
+ {
+ MessageDialog(this, "InfoReadonlyDialog",
+ "modules/swriter/ui/inforeadonlydialog.ui").Execute();
+ eKeyState = KS_End;
+ }
+ break;
+
+ case KEY_DELETE | KEY_MOD2:
+ if( !rSh.IsTableMode() && rSh.GetTableFmt() )
+ {
+ eKeyState = KS_End;
+ m_bTblInsDelMode = sal_True;
+ m_bTblIsInsMode = sal_False;
+ m_aKeyInputTimer.Start();
+ bStopKeyInputTimer = false;
+ }
+ break;
+ case KEY_INSERT | KEY_MOD2:
+ if( !rSh.IsTableMode() && rSh.GetTableFmt() )
+ {
+ eKeyState = KS_End;
+ m_bTblInsDelMode = sal_True;
+ m_bTblIsInsMode = sal_True;
+ m_aKeyInputTimer.Start();
+ bStopKeyInputTimer = false;
+ }
+ break;
+
+ case KEY_RETURN:
+ {
+ if ( !rSh.HasReadonlySel()
+ && !rSh.CrsrInsideInputFld() )
+ {
+ const int nSelectionType = rSh.GetSelectionType();
+ if(nSelectionType & nsSelectionType::SEL_OLE)
+ eKeyState = KS_LaunchOLEObject;
+ else if(nSelectionType & nsSelectionType::SEL_FRM)
+ eKeyState = KS_GoIntoFly;
+ else if((nSelectionType & nsSelectionType::SEL_DRW) &&
+ 0 == (nSelectionType & nsSelectionType::SEL_DRW_TXT) &&
+ rSh.GetDrawView()->GetMarkedObjectList().GetMarkCount() == 1)
+ eKeyState = KS_GoIntoDrawing;
+ else if( aTmpQHD.HasCntnt() && !rSh.HasSelection() &&
+ aTmpQHD.m_bIsAutoText )
+ eKeyState = KS_GlossaryExpand;
+
+ //RETURN and empty paragraph in numbering -> end numbering
+ else if( m_aInBuffer.isEmpty() &&
+ rSh.GetCurNumRule() &&
+ !rSh.GetCurNumRule()->IsOutlineRule() &&
+ !rSh.HasSelection() &&
+ rSh.IsSttPara() && rSh.IsEndPara() )
+ eKeyState = KS_NumOff, eNextKeyState = KS_OutlineLvOff;
+
+ //RETURN for new paragraph with AutoFormating
+ else if( pACfg && pACfg->IsAutoFmtByInput() &&
+ !(nSelectionType & (nsSelectionType::SEL_GRF |
+ nsSelectionType::SEL_OLE | nsSelectionType::SEL_FRM |
+ nsSelectionType::SEL_TBL_CELLS | nsSelectionType::SEL_DRW |
+ nsSelectionType::SEL_DRW_TXT)) )
+ eKeyState = KS_CheckAutoCorrect, eNextKeyState = KS_AutoFmtByInput;
+ else
+ eNextKeyState = eKeyState, eKeyState = KS_CheckAutoCorrect;
+ }
+ }
+ break;
+ case KEY_RETURN | KEY_MOD2:
+ {
+ if ( !rSh.HasReadonlySel()
+ && !rSh.IsSttPara()
+ && rSh.GetCurNumRule()
+ && !rSh.CrsrInsideInputFld() )
+ {
+ eKeyState = KS_NoNum;
+ }
+ else if( rSh.CanSpecialInsert() )
+ eKeyState = KS_SpecialInsert;
+ }
+ break;
+ case KEY_BACKSPACE:
+ case KEY_BACKSPACE | KEY_SHIFT:
+ if ( !rSh.HasReadonlySel()
+ && !rSh.CrsrInsideInputFld() )
+ {
+ bool bDone = false;
+ // try to add comment for code snip:
+ // Remove the paragraph indent, if the cursor is at the
+ // beginning of a paragraph, there is no selection
+ // and no numbering rule found at the current paragraph
+ // Also try to remove indent, if current paragraph
+ // has numbering rule, but isn't counted and only
+ // key <backspace> is hit.
+ const bool bOnlyBackspaceKey( KEY_BACKSPACE == rKeyCode.GetFullCode() );
+ if ( rSh.IsSttPara()
+ && !rSh.HasSelection()
+ && ( rSh.GetCurNumRule() == NULL
+ || ( rSh.IsNoNum() && bOnlyBackspaceKey ) ) )
+ {
+ bDone = rSh.TryRemoveIndent();
+ }
+
+ if (bDone)
+ eKeyState = KS_End;
+ else
+ {
+ if ( rSh.IsSttPara() && !rSh.IsNoNum() )
+ {
+ if (m_nKS_NUMDOWN_Count > 0 &&
+ 0 < rSh.GetNumLevel())
+ {
+ eKeyState = KS_NumUp;
+ m_nKS_NUMDOWN_Count = 2;
+ bDone = true;
+ }
+ else if (m_nKS_NUMINDENTINC_Count > 0)
+ {
+ eKeyState = KS_NumIndentDec;
+ m_nKS_NUMINDENTINC_Count = 2;
+ bDone = true;
+ }
+ }
+
+ // If the cursor is in an empty paragraph, which has
+ // a numbering, but not the outline numbering, and
+ // there is no selection, the numbering has to be
+ // deleted on key <Backspace>.
+ // Otherwise method <SwEditShell::NumOrNoNum(..)>
+ // should only change the <IsCounted()> state of
+ // the current paragraph depending of the key.
+ // On <backspace> it is set to <false>,
+ // on <shift-backspace> it is set to <true>.
+ // Thus, assure that method <SwEditShell::NumOrNum(..)>
+ // is only called for the intended purpose.
+ if ( !bDone && rSh.IsSttPara() )
+ {
+ bool bCallNumOrNoNum( false );
+ if ( bOnlyBackspaceKey && !rSh.IsNoNum() )
+ {
+ bCallNumOrNoNum = true;
+ }
+ else if ( !bOnlyBackspaceKey && rSh.IsNoNum() )
+ {
+ bCallNumOrNoNum = true;
+ }
+ else if ( bOnlyBackspaceKey
+ && rSh.IsSttPara()
+ && rSh.IsEndPara()
+ && !rSh.HasSelection() )
+ {
+ const SwNumRule* pCurrNumRule( rSh.GetCurNumRule() );
+ if ( pCurrNumRule != NULL
+ && pCurrNumRule != rSh.GetOutlineNumRule() )
+ {
+ bCallNumOrNoNum = true;
+ }
+ }
+ if ( bCallNumOrNoNum
+ && rSh.NumOrNoNum( !bOnlyBackspaceKey, true ) )
+ {
+ eKeyState = KS_NumOrNoNum;
+ }
+ }
+ }
+ }
+ else
+ {
+ MessageDialog(this, "InfoReadonlyDialog",
+ "modules/swriter/ui/inforeadonlydialog.ui").Execute();
+ eKeyState = KS_End;
+ }
+ break;
+
+ case KEY_RIGHT:
+ {
+ eFlyState = KS_Fly_Change;
+ nDir = MOVE_RIGHT_BIG;
+ eTblChgMode = nsTblChgWidthHeightType::WH_FLAG_INSDEL | nsTblChgWidthHeightType::WH_COL_RIGHT;
+ nTblChgSize = pModOpt->GetTblVInsert();
+ goto KEYINPUT_CHECKTABLE_INSDEL;
+ }
+ case KEY_TAB:
+ {
+
+ if (rSh.IsFormProtected() || rSh.GetCurrentFieldmark() || rSh.GetChar(sal_False)==CH_TXT_ATR_FORMELEMENT)
+ {
+ eKeyState=KS_GotoNextFieldMark;
+ }
+ else if ( !rSh.IsMultiSelection() && rSh.CrsrInsideInputFld() )
+ {
+ GetView().GetViewFrame()->GetDispatcher()->Execute( FN_GOTO_NEXT_INPUTFLD );
+ eKeyState = KS_End;
+ }
+ else if( rSh.GetCurNumRule()
+ && rSh.IsSttOfPara()
+ && !rSh.HasReadonlySel() )
+ {
+ if ( rSh.IsFirstOfNumRule() &&
+ numfunc::ChangeIndentOnTabAtFirstPosOfFirstListItem() )
+ eKeyState = KS_NumIndentInc;
+ else
+ eKeyState = KS_NumDown;
+ }
+ else if ( rSh.GetTableFmt() )
+ {
+ if( rSh.HasSelection() || rSh.HasReadonlySel() )
+ eKeyState = KS_NextCell;
+ else
+ eKeyState = KS_CheckAutoCorrect, eNextKeyState = KS_NextCell;
+ }
+ else if ( rSh.GetSelectionType() &
+ (nsSelectionType::SEL_GRF |
+ nsSelectionType::SEL_FRM |
+ nsSelectionType::SEL_OLE |
+ nsSelectionType::SEL_DRW |
+ nsSelectionType::SEL_DRW_FORM))
+
+ eKeyState = KS_NextObject;
+ else
+ {
+ eKeyState = KS_InsTab;
+ if( rSh.IsSttOfPara() && !rSh.HasReadonlySel() )
+ {
+ SwTxtFmtColl* pColl = rSh.GetCurTxtFmtColl();
+ if( pColl &&
+
+ pColl->IsAssignedToListLevelOfOutlineStyle()
+ && MAXLEVEL-1 > pColl->GetAssignedOutlineStyleLevel() )
+ eKeyState = KS_OutlineDown;
+ }
+ }
+ }
+ break;
+ case KEY_TAB | KEY_SHIFT:
+ {
+ if (rSh.IsFormProtected() || rSh.GetCurrentFieldmark()|| rSh.GetChar(sal_False)==CH_TXT_ATR_FORMELEMENT)
+ {
+ eKeyState=KS_GotoPrevFieldMark;
+ }
+ else if ( !rSh.IsMultiSelection() && rSh.CrsrInsideInputFld() )
+ {
+ GetView().GetViewFrame()->GetDispatcher()->Execute( FN_GOTO_PREV_INPUTFLD );
+ eKeyState = KS_End;
+ }
+ else if( rSh.GetCurNumRule()
+ && rSh.IsSttOfPara()
+ && !rSh.HasReadonlySel() )
+ {
+
+ if ( rSh.IsFirstOfNumRule() &&
+ numfunc::ChangeIndentOnTabAtFirstPosOfFirstListItem() )
+ eKeyState = KS_NumIndentDec;
+ else
+ eKeyState = KS_NumUp;
+ }
+ else if ( rSh.GetTableFmt() )
+ {
+ if( rSh.HasSelection() || rSh.HasReadonlySel() )
+ eKeyState = KS_PrevCell;
+ else
+ eKeyState = KS_CheckAutoCorrect, eNextKeyState = KS_PrevCell;
+ }
+ else if ( rSh.GetSelectionType() &
+ (nsSelectionType::SEL_GRF |
+ nsSelectionType::SEL_FRM |
+ nsSelectionType::SEL_OLE |
+ nsSelectionType::SEL_DRW |
+ nsSelectionType::SEL_DRW_FORM))
+
+ eKeyState = KS_PrevObject;
+ else
+ {
+ eKeyState = KS_End;
+ if( rSh.IsSttOfPara() && !rSh.HasReadonlySel() )
+ {
+ SwTxtFmtColl* pColl = rSh.GetCurTxtFmtColl();
+ if( pColl &&
+ pColl->IsAssignedToListLevelOfOutlineStyle() &&
+ 0 < pColl->GetAssignedOutlineStyleLevel())
+ eKeyState = KS_OutlineUp;
+ }
+ }
+ }
+ break;
+ case KEY_TAB | KEY_MOD1:
+ case KEY_TAB | KEY_MOD2:
+ if( !rSh.HasReadonlySel() )
+ {
+ if( aTmpQHD.HasCntnt() && !rSh.HasSelection() )
+ {
+ // Next auto-complete suggestion
+ aTmpQHD.Next( pACorr &&
+ pACorr->GetSwFlags().bAutoCmpltEndless );
+ eKeyState = KS_NextPrevGlossary;
+ }
+ else if( rSh.GetTableFmt() )
+ eKeyState = KS_InsTab;
+ else if((rSh.GetSelectionType() &
+ (nsSelectionType::SEL_DRW|nsSelectionType::SEL_DRW_FORM|
+ nsSelectionType::SEL_FRM|nsSelectionType::SEL_OLE|nsSelectionType::SEL_GRF)) &&
+ rSh.GetDrawView()->AreObjectsMarked())
+ eKeyState = KS_EnterDrawHandleMode;
+ else
+ {
+ eKeyState = KS_InsTab;
+ }
+ }
+ break;
+
+ case KEY_TAB | KEY_MOD1 | KEY_SHIFT:
+ {
+ if( aTmpQHD.HasCntnt() && !rSh.HasSelection() &&
+ !rSh.HasReadonlySel() )
+ {
+ // Previous auto-complete suggestion.
+ aTmpQHD.Previous( pACorr &&
+ pACorr->GetSwFlags().bAutoCmpltEndless );
+ eKeyState = KS_NextPrevGlossary;
+ }
+ else if((rSh.GetSelectionType() & (nsSelectionType::SEL_DRW|nsSelectionType::SEL_DRW_FORM|
+ nsSelectionType::SEL_FRM|nsSelectionType::SEL_OLE|nsSelectionType::SEL_GRF)) &&
+ rSh.GetDrawView()->AreObjectsMarked())
+ {
+ eKeyState = KS_EnterDrawHandleMode;
+ }
+ }
+ break;
+ case KEY_F2 :
+ if( !rSh.HasReadonlySel() )
+ {
+ const int nSelectionType = rSh.GetSelectionType();
+ if(nSelectionType & nsSelectionType::SEL_FRM)
+ eKeyState = KS_GoIntoFly;
+ else if((nSelectionType & nsSelectionType::SEL_DRW))
+ eKeyState = KS_GoIntoDrawing;
+ }
+ break;
+ }
+ }
+ break;
+ case KS_CheckDocReadOnlyKeys:
+ {
+ eKeyState = KS_KeyToView;
+ switch( rKeyCode.GetModifier() | rKeyCode.GetCode() )
+ {
+ case KEY_TAB:
+ case KEY_TAB | KEY_SHIFT:
+ bNormalChar = false;
+ eKeyState = KS_End;
+ if ( rSh.GetSelectionType() &
+ (nsSelectionType::SEL_GRF |
+ nsSelectionType::SEL_FRM |
+ nsSelectionType::SEL_OLE |
+ nsSelectionType::SEL_DRW |
+ nsSelectionType::SEL_DRW_FORM))
+
+ {
+ eKeyState = rKeyCode.GetModifier() & KEY_SHIFT ?
+ KS_PrevObject : KS_NextObject;
+ }
+ else if ( !rSh.IsMultiSelection() && rSh.CrsrInsideInputFld() )
+ {
+ GetView().GetViewFrame()->GetDispatcher()->Execute(
+ KEY_SHIFT != rKeyCode.GetModifier() ? FN_GOTO_NEXT_INPUTFLD : FN_GOTO_PREV_INPUTFLD );
+ }
+ else
+ {
+ rSh.SelectNextPrevHyperlink( KEY_SHIFT != rKeyCode.GetModifier() );
+ }
+ break;
+ case KEY_RETURN:
+ {
+ const int nSelectionType = rSh.GetSelectionType();
+ if(nSelectionType & nsSelectionType::SEL_FRM)
+ eKeyState = KS_GoIntoFly;
+ else
+ {
+ SfxItemSet aSet(rSh.GetAttrPool(), RES_TXTATR_INETFMT, RES_TXTATR_INETFMT);
+ rSh.GetCurAttr(aSet);
+ if(SFX_ITEM_SET == aSet.GetItemState(RES_TXTATR_INETFMT, false))
+ {
+ const SfxPoolItem& rItem = aSet.Get(RES_TXTATR_INETFMT, sal_True);
+ bNormalChar = false;
+ eKeyState = KS_End;
+ rSh.ClickToINetAttr((const SwFmtINetFmt&)rItem, URLLOAD_NOFILTER);
+ }
+ }
+ }
+ break;
+ }
+ }
+ break;
+
+ case KS_EnterCharCell:
+ {
+ eKeyState = KS_KeyToView;
+ switch ( rKeyCode.GetModifier() | rKeyCode.GetCode() )
+ {
+ case KEY_RIGHT | KEY_MOD2:
+ rSh.Right( CRSR_SKIP_CHARS, sal_False, 1, sal_False );
+ eKeyState = KS_End;
+ FlushInBuffer();
+ break;
+ case KEY_LEFT | KEY_MOD2:
+ rSh.Left( CRSR_SKIP_CHARS, sal_False, 1, sal_False );
+ eKeyState = KS_End;
+ FlushInBuffer();
+ break;
+ }
+ }
+ break;
+
+ case KS_KeyToView:
+ {
+ eKeyState = KS_End;
+ bNormalChar =
+ !rKeyCode.IsMod2() &&
+ rKeyCode.GetModifier() != (KEY_MOD1) &&
+ rKeyCode.GetModifier() != (KEY_MOD1|KEY_SHIFT) &&
+ SW_ISPRINTABLE( aCh );
+
+ if( bNormalChar && rSh.IsInFrontOfLabel() )
+ {
+ rSh.NumOrNoNum(false);
+ }
+
+ if( !m_aInBuffer.isEmpty() && ( !bNormalChar || bIsDocReadOnly ))
+ FlushInBuffer();
+
+ if( m_rView.KeyInput( aKeyEvent ) )
+ bFlushBuffer = true, bNormalChar = false;
+ else
+ {
+ // Because Sfx accelerators are only called when they were
+ // enabled at the last status update, copy has to called
+ // 'forcefully' by us if necessary.
+ if( rKeyCode.GetFunction() == KEYFUNC_COPY )
+ GetView().GetViewFrame()->GetBindings().Execute(SID_COPY);
+
+ if( !bIsDocReadOnly && bNormalChar )
+ {
+ const int nSelectionType = rSh.GetSelectionType();
+ if((nSelectionType & nsSelectionType::SEL_DRW) &&
+ 0 == (nSelectionType & nsSelectionType::SEL_DRW_TXT) &&
+ rSh.GetDrawView()->GetMarkedObjectList().GetMarkCount() == 1)
+ {
+ SdrObject* pObj = rSh.GetDrawView()->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
+ if(pObj)
+ {
+ EnterDrawTextMode(pObj->GetLogicRect().Center());
+ if ( m_rView.GetCurShell()->ISA(SwDrawTextShell) )
+ ((SwDrawTextShell*)m_rView.GetCurShell())->Init();
+ rSh.GetDrawView()->KeyInput( rKEvt, this );
+ }
+ }
+ else if(nSelectionType & nsSelectionType::SEL_FRM)
+ {
+ rSh.UnSelectFrm();
+ rSh.LeaveSelFrmMode();
+ m_rView.AttrChangedNotify(&rSh);
+ rSh.MoveSection( fnSectionCurr, fnSectionEnd );
+ }
+ eKeyState = KS_InsChar;
+ }
+ else
+ {
+ bNormalChar = false;
+ Window::KeyInput( aKeyEvent );
+ }
+ }
+ }
+ break;
+ case KS_LaunchOLEObject:
+ {
+ rSh.LaunchOLEObj();
+ eKeyState = KS_End;
+ }
+ break;
+ case KS_GoIntoFly:
+ {
+ rSh.UnSelectFrm();
+ rSh.LeaveSelFrmMode();
+ m_rView.AttrChangedNotify(&rSh);
+ rSh.MoveSection( fnSectionCurr, fnSectionEnd );
+ eKeyState = KS_End;
+ }
+ break;
+ case KS_GoIntoDrawing:
+ {
+ SdrObject* pObj = rSh.GetDrawView()->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
+ if(pObj)
+ {
+ EnterDrawTextMode(pObj->GetLogicRect().Center());
+ if ( m_rView.GetCurShell()->ISA(SwDrawTextShell) )
+ ((SwDrawTextShell*)m_rView.GetCurShell())->Init();
+ }
+ eKeyState = KS_End;
+ }
+ break;
+ case KS_EnterDrawHandleMode:
+ {
+ const SdrHdlList& rHdlList = rSh.GetDrawView()->GetHdlList();
+ sal_Bool bForward(!aKeyEvent.GetKeyCode().IsShift());
+
+ ((SdrHdlList&)rHdlList).TravelFocusHdl(bForward);
+ eKeyState = KS_End;
+ }
+ break;
+ case KS_InsTab:
+ if( m_rView.ISA( SwWebView )) // no Tab for WebView
+ {
+ // then it should be passed along
+ Window::KeyInput( aKeyEvent );
+ eKeyState = KS_End;
+ break;
+ }
+ aCh = '\t';
+ // no break!
+ case KS_InsChar:
+ if (rSh.GetChar(sal_False)==CH_TXT_ATR_FORMELEMENT)
+ {
+ ::sw::mark::ICheckboxFieldmark* pFieldmark =
+ dynamic_cast< ::sw::mark::ICheckboxFieldmark* >
+ (rSh.GetCurrentFieldmark());
+ OSL_ENSURE(pFieldmark,
+ "Where is my FieldMark??");
+ if(pFieldmark)
+ {
+ pFieldmark->SetChecked(!pFieldmark->IsChecked());
+ OSL_ENSURE(pFieldmark->IsExpanded(),
+ "where is the otherpos?");
+ if (pFieldmark->IsExpanded())
+ {
+ rSh.CalcLayout();
+ }
+ }
+ eKeyState = KS_End;
+ }
+ else if ( !rSh.HasReadonlySel()
+ || rSh.CrsrInsideInputFld() )
+ {
+ const sal_Bool bIsNormalChar =
+ GetAppCharClass().isLetterNumeric( OUString( aCh ), 0 );
+ if( bAppendSpace && bIsNormalChar &&
+ (!m_aInBuffer.isEmpty() || !rSh.IsSttPara() || !rSh.IsEndPara() ))
+ {
+ // insert a blank ahead of the character. this ends up
+ // between the expanded text and the new "non-word-separator".
+ m_aInBuffer += " ";
+ }
+
+ const sal_Bool bIsAutoCorrectChar = SvxAutoCorrect::IsAutoCorrectChar( aCh );
+ const bool bRunNext = pACorr != NULL && pACorr->HasRunNext();
+ if( !aKeyEvent.GetRepeat() && pACorr && ( bIsAutoCorrectChar || bRunNext ) &&
+ pACfg->IsAutoFmtByInput() &&
+ (( pACorr->IsAutoCorrFlag( ChgWeightUnderl ) &&
+ ( '*' == aCh || '_' == aCh ) ) ||
+ ( pACorr->IsAutoCorrFlag( ChgQuotes ) && ('\"' == aCh ))||
+ ( pACorr->IsAutoCorrFlag( ChgSglQuotes ) && ( '\'' == aCh))))
+ {
+ FlushInBuffer();
+ rSh.AutoCorrect( *pACorr, aCh );
+ if( '\"' != aCh && '\'' != aCh ) // only call when "*_"!
+ rSh.UpdateAttr();
+ }
+ else if( !aKeyEvent.GetRepeat() && pACorr && ( bIsAutoCorrectChar || bRunNext ) &&
+ pACfg->IsAutoFmtByInput() &&
+ pACorr->IsAutoCorrFlag( CptlSttSntnc | CptlSttWrd |
+ ChgOrdinalNumber | AddNonBrkSpace |
+ ChgToEnEmDash | SetINetAttr |
+ Autocorrect ) &&
+ '\"' != aCh && '\'' != aCh && '*' != aCh && '_' != aCh
+ )
+ {
+ FlushInBuffer();
+ rSh.AutoCorrect( *pACorr, aCh );
+ }
+ else
+ {
+ OUStringBuffer aBuf(m_aInBuffer);
+ comphelper::string::padToLength(aBuf,
+ m_aInBuffer.getLength() + aKeyEvent.GetRepeat() + 1, aCh);
+ m_aInBuffer = aBuf.makeStringAndClear();
+ bFlushCharBuffer = Application::AnyInput( VCL_INPUT_KEYBOARD );
+ bFlushBuffer = !bFlushCharBuffer;
+ if( bFlushCharBuffer )
+ m_aKeyInputFlushTimer.Start();
+ }
+ eKeyState = KS_End;
+ }
+ else
+ {
+ MessageDialog(this, "InfoReadonlyDialog",
+ "modules/swriter/ui/inforeadonlydialog.ui").Execute();
+ eKeyState = KS_End;
+ }
+ break;
+
+ case KS_CheckAutoCorrect:
+ {
+ if( pACorr && pACfg->IsAutoFmtByInput() &&
+ pACorr->IsAutoCorrFlag( CptlSttSntnc | CptlSttWrd |
+ ChgOrdinalNumber |
+ ChgToEnEmDash | SetINetAttr |
+ Autocorrect ) &&
+ !rSh.HasReadonlySel() )
+ {
+ FlushInBuffer();
+ rSh.AutoCorrect( *pACorr, static_cast< sal_Unicode >('\0') );
+ }
+ eKeyState = eNextKeyState;
+ }
+ break;
+
+ default:
+ {
+ sal_uInt16 nSlotId = 0;
+ FlushInBuffer();
+ switch( eKeyState )
+ {
+ case KS_SpecialInsert:
+ rSh.DoSpecialInsert();
+ break;
+
+ case KS_NoNum:
+ rSh.NoNum();
+ break;
+
+ case KS_NumOff:
+ // shell change - so record in advance
+ rSh.DelNumRules();
+ eKeyState = eNextKeyState;
+ break;
+ case KS_OutlineLvOff: // delete autofmt outlinelevel later
+ break;
+
+ case KS_NumDown:
+ rSh.NumUpDown( true );
+ m_nKS_NUMDOWN_Count = 2;
+ break;
+ case KS_NumUp:
+ rSh.NumUpDown( false );
+ break;
+
+ case KS_NumIndentInc:
+ rSh.ChangeIndentOfAllListLevels(360);
+ m_nKS_NUMINDENTINC_Count = 2;
+ break;
+
+ case KS_GotoNextFieldMark:
+ {
+ ::sw::mark::IFieldmark const * const pFieldmark = rSh.GetFieldmarkAfter();
+ if(pFieldmark) rSh.GotoFieldmark(pFieldmark);
+ }
+ break;
+
+ case KS_GotoPrevFieldMark:
+ {
+ ::sw::mark::IFieldmark const * const pFieldmark = rSh.GetFieldmarkBefore();
+ if( pFieldmark )
+ rSh.GotoFieldmark(pFieldmark);
+ }
+ break;
+
+ case KS_NumIndentDec:
+ rSh.ChangeIndentOfAllListLevels(-360);
+ break;
+
+ case KS_OutlineDown:
+ rSh.OutlineUpDown( 1 );
+ break;
+ case KS_OutlineUp:
+ rSh.OutlineUpDown( -1 );
+ break;
+
+ case KS_NextCell:
+ // always 'flush' in tables
+ rSh.GoNextCell();
+ nSlotId = FN_GOTO_NEXT_CELL;
+ break;
+ case KS_PrevCell:
+ rSh.GoPrevCell();
+ nSlotId = FN_GOTO_PREV_CELL;
+ break;
+ case KS_AutoFmtByInput:
+ rSh.SplitNode( sal_True );
+ break;
+
+ case KS_NextObject:
+ case KS_PrevObject:
+ if(rSh.GotoObj( KS_NextObject == eKeyState, GOTOOBJ_GOTO_ANY))
+ {
+ if( rSh.IsFrmSelected() &&
+ m_rView.GetDrawFuncPtr() )
+ {
+ m_rView.GetDrawFuncPtr()->Deactivate();
+ m_rView.SetDrawFuncPtr(NULL);
+ m_rView.LeaveDrawCreate();
+ m_rView.AttrChangedNotify( &rSh );
+ }
+ rSh.HideCrsr();
+ rSh.EnterSelFrmMode();
+ }
+ break;
+ case KS_GlossaryExpand:
+ {
+ // replace the word or abbreviation with the auto text
+ rSh.StartUndo( UNDO_START );
+
+ OUString sFnd( aTmpQHD.m_aHelpStrings[ aTmpQHD.nCurArrPos ] );
+ if( aTmpQHD.m_bIsAutoText )
+ {
+ SwGlossaryList* pList = ::GetGlossaryList();
+ OUString sShrtNm;
+ OUString sGroup;
+ if(pList->GetShortName( sFnd, sShrtNm, sGroup))
+ {
+ rSh.SttSelect();
+ rSh.ExtendSelection( sal_False, aTmpQHD.nLen );
+ SwGlossaryHdl* pGlosHdl = GetView().GetGlosHdl();
+ pGlosHdl->SetCurGroup(sGroup, sal_True);
+ pGlosHdl->InsertGlossary( sShrtNm);
+ m_pQuickHlpData->m_bAppendSpace = true;
+ }
+ }
+ else
+ {
+ sFnd = sFnd.copy( aTmpQHD.nLen );
+ rSh.Insert( sFnd );
+ m_pQuickHlpData->m_bAppendSpace = !pACorr ||
+ pACorr->GetSwFlags().bAutoCmpltAppendBlanc;
+ }
+ rSh.EndUndo( UNDO_END );
+ }
+ break;
+
+ case KS_NextPrevGlossary:
+ m_pQuickHlpData->Move( aTmpQHD );
+ m_pQuickHlpData->Start( rSh, USHRT_MAX );
+ break;
+
+ case KS_EditFormula:
+ {
+ const sal_uInt16 nId = SwInputChild::GetChildWindowId();
+
+ SfxViewFrame* pVFrame = GetView().GetViewFrame();
+ pVFrame->ToggleChildWindow( nId );
+ SwInputChild* pChildWin = (SwInputChild*)pVFrame->
+ GetChildWindow( nId );
+ if( pChildWin )
+ pChildWin->SetFormula( sFmlEntry );
+ }
+ break;
+
+ case KS_ColLeftBig: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_COL_LEFT|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblHMove() ); break;
+ case KS_ColRightBig: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_COL_RIGHT|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblHMove() ); break;
+ case KS_ColLeftSmall: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_COL_LEFT, pModOpt->GetTblHMove() ); break;
+ case KS_ColRightSmall: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_COL_RIGHT, pModOpt->GetTblHMove() ); break;
+ case KS_ColBottomBig: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_ROW_BOTTOM|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblVMove() ); break;
+ case KS_ColBottomSmall: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_ROW_BOTTOM, pModOpt->GetTblVMove() ); break;
+ case KS_CellLeftBig: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_CELL_LEFT|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblHMove() ); break;
+ case KS_CellRightBig: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_CELL_RIGHT|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblHMove() ); break;
+ case KS_CellLeftSmall: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_CELL_LEFT, pModOpt->GetTblHMove() ); break;
+ case KS_CellRightSmall: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_CELL_RIGHT, pModOpt->GetTblHMove() ); break;
+ case KS_CellTopBig: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_CELL_TOP|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblVMove() ); break;
+ case KS_CellBottomBig: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_CELL_BOTTOM|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblVMove() ); break;
+ case KS_CellTopSmall: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_CELL_TOP, pModOpt->GetTblVMove() ); break;
+ case KS_CellBottomSmall: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_CELL_BOTTOM, pModOpt->GetTblVMove() ); break;
+
+ case KS_InsDel_ColLeftBig: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_COL_LEFT|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblHInsert() ); break;
+ case KS_InsDel_ColRightBig: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_COL_RIGHT|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblHInsert() ); break;
+ case KS_InsDel_ColLeftSmall: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_COL_LEFT, pModOpt->GetTblHInsert() ); break;
+ case KS_InsDel_ColRightSmall: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_COL_RIGHT, pModOpt->GetTblHInsert() ); break;
+ case KS_InsDel_ColTopBig: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_ROW_TOP|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblVInsert() ); break;
+ case KS_InsDel_ColBottomBig: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_ROW_BOTTOM|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblVInsert() ); break;
+ case KS_InsDel_ColTopSmall: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_ROW_TOP, pModOpt->GetTblVInsert() ); break;
+ case KS_InsDel_ColBottomSmall: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_ROW_BOTTOM, pModOpt->GetTblVInsert() ); break;
+ case KS_InsDel_CellLeftBig: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_CELL_LEFT|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblHInsert() ); break;
+ case KS_InsDel_CellRightBig: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_CELL_RIGHT|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblHInsert() ); break;
+ case KS_InsDel_CellLeftSmall: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_CELL_LEFT, pModOpt->GetTblHInsert() ); break;
+ case KS_InsDel_CellRightSmall: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_CELL_RIGHT, pModOpt->GetTblHInsert() ); break;
+ case KS_InsDel_CellTopBig: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_CELL_TOP|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblVInsert() ); break;
+ case KS_InsDel_CellBottomBig: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_CELL_BOTTOM|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblVInsert() ); break;
+ case KS_InsDel_CellTopSmall: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_CELL_TOP, pModOpt->GetTblVInsert() ); break;
+ case KS_InsDel_CellBottomSmall: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_CELL_BOTTOM, pModOpt->GetTblVInsert() ); break;
+
+ case KS_TblColCellInsDel:
+ rSh.SetColRowWidthHeight( eTblChgMode, nTblChgSize );
+ break;
+ case KS_Fly_Change:
+ {
+ SdrView *pSdrView = rSh.GetDrawView();
+ const SdrHdlList& rHdlList = pSdrView->GetHdlList();
+ if(rHdlList.GetFocusHdl())
+ ChangeDrawing( nDir );
+ else
+ ChangeFly( nDir, m_rView.ISA( SwWebView ) );
+ }
+ break;
+ case KS_Draw_Change :
+ ChangeDrawing( nDir );
+ break;
+ default:
+ break;
+ }
+ if( nSlotId && m_rView.GetViewFrame()->GetBindings().GetRecorder().is() )
+ {
+ SfxRequest aReq(m_rView.GetViewFrame(), nSlotId );
+ aReq.Done();
+ }
+ eKeyState = KS_End;
+ }
+ }
+ }
+
+ if( bStopKeyInputTimer )
+ {
+ m_aKeyInputTimer.Stop();
+ m_bTblInsDelMode = sal_False;
+ }
+
+ // in case the buffered characters are inserted
+ if( bFlushBuffer && !m_aInBuffer.isEmpty() )
+ {
+ // bFlushCharBuffer was not resetted here
+ // why not?
+ bool bSave = bFlushCharBuffer;
+ FlushInBuffer();
+ bFlushCharBuffer = bSave;
+
+ // maybe show Tip-Help
+ OUString sWord;
+ if( bNormalChar && pACfg && pACorr &&
+ ( pACfg->IsAutoTextTip() ||
+ pACorr->GetSwFlags().bAutoCompleteWords ) &&
+ rSh.GetPrevAutoCorrWord( *pACorr, sWord ) )
+ {
+ ShowAutoTextCorrectQuickHelp(sWord, pACfg, pACorr);
+ }
+ }
+
+ // get the word count dialog to update itself
+ SwWordCountWrapper *pWrdCnt = (SwWordCountWrapper*)GetView().GetViewFrame()->GetChildWindow(SwWordCountWrapper::GetChildWindowId());
+ if( pWrdCnt )
+ pWrdCnt->UpdateCounts();
+
+}
+
+/**
+ * MouseEvents
+ */
+void SwEditWin::RstMBDownFlags()
+{
+ // Not on all systems a MouseButtonUp is used ahead
+ // of the modal dialog (like on WINDOWS).
+ // So reset the statuses here and release the mouse
+ // for the dialog.
+ m_bMBPressed = sal_False;
+ bNoInterrupt = false;
+ EnterArea();
+ ReleaseMouse();
+}
+
+/**
+ * Determines if the current position has a clickable url over a background
+ * frame. In that case, ctrl-click should select the url, not the frame.
+ */
+static bool lcl_urlOverBackground(SwWrtShell& rSh, const Point& rDocPos)
+{
+ SwContentAtPos aSwContentAtPos(SwContentAtPos::SW_INETATTR);
+ SdrObject* pSelectableObj = rSh.GetObjAt(rDocPos);
+
+ return rSh.GetContentAtPos(rDocPos, aSwContentAtPos) && pSelectableObj->GetLayer() == rSh.GetDoc()->GetHellId();
+}
+
+#if !HAVE_FEATURE_DESKTOP
+
+// As such these two functions could be more or less anywhere, I have
+// them now in this source file because the act of moving a selection
+// end point is somewhat the same as what happens when one
+// shift-clicks on either side of an existing selection.
+
+void touch_lo_selection_start_move_impl(const void *documentHandle,
+ int x,
+ int y)
+{
+ SwWrtShell *pWrtShell = reinterpret_cast<SwWrtShell*>(const_cast<void*>(documentHandle));
+
+ if (!pWrtShell)
+ return;
+
+ const OutputDevice *pOut = pWrtShell->GetWin();
+ if (!pOut)
+ pOut = pWrtShell->GetOut();
+
+ const Point aDocPos( pOut->PixelToLogic( Point(x, y) ) );
+
+ // Don't allow moving the start of the selection beyond the end
+ // (point) of the selection.
+
+ SwRect startCharRect;
+ pWrtShell->GetCharRectAt(startCharRect, pWrtShell->GetCrsr()->GetPoint());
+ const Point startCharPos = startCharRect.Center();
+
+ if (startCharPos.Y() < aDocPos.Y() ||
+ (startCharPos.Y() == aDocPos.Y() && startCharPos.X() - startCharRect.Width() <= aDocPos.X()))
+ return;
+
+ pWrtShell->ChgCurrPam( aDocPos );
+
+ // Keep mark normally at the start and point at the end,
+ // just exchange for the duration of moving the start.
+ pWrtShell->GetCrsr()->Exchange();
+ {
+ SwMvContext aMvContext( pWrtShell );
+ pWrtShell->SwCrsrShell::SetCrsr( aDocPos );
+ }
+ pWrtShell->GetCrsr()->Exchange();
+}
+
+void touch_lo_selection_end_move_impl(const void *documentHandle,
+ int x,
+ int y)
+{
+ SwWrtShell *pWrtShell = reinterpret_cast<SwWrtShell*>(const_cast<void*>(documentHandle));
+
+ if (!pWrtShell)
+ return;
+
+ const OutputDevice *pOut = pWrtShell->GetWin();
+ if (!pOut)
+ pOut = pWrtShell->GetOut();
+
+ const Point aDocPos( pOut->PixelToLogic( Point(x, y) ) );
+
+ // Don't allow moving the end of the selection beyond the start
+ // (mark) of the selection.
+
+ SwRect endCharRect;
+ pWrtShell->GetCharRectAt(endCharRect, pWrtShell->GetCrsr()->GetMark());
+ const Point endCharPos = endCharRect.Center();
+
+ if (endCharPos.Y() > aDocPos.Y() ||
+ (endCharPos.Y() == aDocPos.Y() && endCharPos.X() + endCharRect.Width() >= aDocPos.X()))
+ return;
+
+ pWrtShell->ChgCurrPam( aDocPos );
+
+ {
+ SwMvContext aMvContext( pWrtShell );
+ pWrtShell->SwCrsrShell::SetCrsr( aDocPos );
+ }
+}
+
+#endif
+
+void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt)
+{
+ SwWrtShell &rSh = m_rView.GetWrtShell();
+
+ // 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 mouse
+ // button down 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)
+ SfxInPlaceClient* pIPClient = rSh.GetSfxViewShell()->GetIPClient();
+ bool bIsOleActive = ( pIPClient && pIPClient->IsObjectInPlaceActive() );
+
+ if ( bIsOleActive && PopupMenu::IsInExecute() )
+ return;
+
+ MouseEvent rMEvt(_rMEvt);
+
+ if (m_rView.GetPostItMgr()->IsHit(rMEvt.GetPosPixel()))
+ return;
+
+ m_rView.GetPostItMgr()->SetActiveSidebarWin(0);
+
+ GrabFocus();
+
+ //ignore key modifiers for format paintbrush
+ {
+ bool bExecFormatPaintbrush = m_pApplyTempl && m_pApplyTempl->m_pFormatClipboard
+ && m_pApplyTempl->m_pFormatClipboard->HasContent();
+ if( bExecFormatPaintbrush )
+ rMEvt = MouseEvent( _rMEvt.GetPosPixel(), _rMEvt.GetClicks(),
+ _rMEvt.GetMode(), _rMEvt.GetButtons() );
+ }
+
+ m_bWasShdwCrsr = 0 != m_pShadCrsr;
+ delete m_pShadCrsr, m_pShadCrsr = 0;
+
+ const Point aDocPos( PixelToLogic( rMEvt.GetPosPixel() ) );
+
+ // How many clicks do we need to select a fly frame?
+ FrameControlType eControl;
+ bool bOverFly = false;
+ bool bPageAnchored = false;
+ bool bOverHeaderFooterFly = IsOverHeaderFooterFly( aDocPos, eControl, bOverFly, bPageAnchored );
+
+ sal_Bool bIsDocReadOnly = m_rView.GetDocShell()->IsReadOnly();
+ if (bOverHeaderFooterFly && (!bIsDocReadOnly && rSh.GetCurFld()))
+ // We have a field here, that should have priority over header/footer fly.
+ bOverHeaderFooterFly = false;
+
+ int nNbFlyClicks = 1;
+ // !bOverHeaderFooterFly doesn't mean we have a frame to select
+ if ( !bPageAnchored && ( ( rSh.IsHeaderFooterEdit( ) && !bOverHeaderFooterFly && bOverFly ) ||
+ ( !rSh.IsHeaderFooterEdit( ) && bOverHeaderFooterFly ) ) )
+ {
+ nNbFlyClicks = 2;
+ if ( _rMEvt.GetClicks( ) < nNbFlyClicks )
+ return;
+ }
+
+ // Are we clicking on a blank header/footer area?
+ if ( IsInHeaderFooter( aDocPos, eControl ) || bOverHeaderFooterFly )
+ {
+ const SwPageFrm* pPageFrm = rSh.GetLayout()->GetPageAtPos( aDocPos );
+
+ // Is it active?
+ bool bActive = true;
+ const SwPageDesc* pDesc = pPageFrm->GetPageDesc();
+
+ const SwFrmFmt* pFmt = pDesc->GetLeftFmt();
+ if ( pPageFrm->OnRightPage() )
+ pFmt = pDesc->GetRightFmt();
+
+ if ( pFmt )
+ {
+ if ( eControl == Header )
+ bActive = pFmt->GetHeader().IsActive();
+ else
+ bActive = pFmt->GetFooter().IsActive();
+ }
+
+ if ( !bActive )
+ {
+ SwPaM aPam( *rSh.GetCurrentShellCursor().GetPoint() );
+ bool bWasInHeader = aPam.GetPoint( )->nNode.GetNode( ).FindHeaderStartNode( ) != NULL;
+ bool bWasInFooter = aPam.GetPoint( )->nNode.GetNode( ).FindFooterStartNode( ) != NULL;
+
+ // Is the cursor in a part like similar to the one we clicked on? For example,
+ // if the cursor is in a header and we click on an empty header... don't change anything to
+ // keep consistent behaviour due to header edit mode (and the same for the footer as well).
+
+ // Otherwise, we hide the header/footer control if a separator is shown, and vice versa.
+ if ( !( bWasInHeader && eControl == Header ) &&
+ !( bWasInFooter && eControl == Footer ) )
+ {
+ rSh.SetShowHeaderFooterSeparator( eControl, !rSh.IsShowHeaderFooterSeparator( eControl ) );
+ }
+
+ // Repaint everything
+ Invalidate();
+ }
+ else
+ {
+ // Make sure we have the proper Header/Footer separators shown
+ // as these may be changed if clicking on an empty Header/Footer
+ rSh.SetShowHeaderFooterSeparator( Header, eControl == Header );
+ rSh.SetShowHeaderFooterSeparator( Footer, eControl == Footer );
+
+ if ( !rSh.IsHeaderFooterEdit() )
+ rSh.ToggleHeaderFooterEdit();
+
+ // Repaint everything
+ rSh.GetWin()->Invalidate();
+ }
+ }
+ else
+ {
+ if ( rSh.IsHeaderFooterEdit( ) )
+ rSh.ToggleHeaderFooterEdit( );
+ else
+ {
+ // Make sure that the separators are hidden
+ rSh.SetShowHeaderFooterSeparator( Header, false );
+ rSh.SetShowHeaderFooterSeparator( Footer, false );
+
+ // Repaint everything
+ // FIXME fdo#67358 for unknown reasons this causes painting
+ // problems when resizing table columns, so disable it
+// rSh.GetWin()->Invalidate();
+ }
+ }
+
+ if ( IsChainMode() )
+ {
+ SetChainMode( sal_False );
+ SwRect aDummy;
+ SwFlyFrmFmt *pFmt = (SwFlyFrmFmt*)rSh.GetFlyFrmFmt();
+ if ( !rSh.Chainable( aDummy, *pFmt, aDocPos ) )
+ rSh.Chain( *pFmt, aDocPos );
+ UpdatePointer( aDocPos, rMEvt.GetModifier() );
+ return;
+ }
+
+ // After GrabFocus a shell should be pushed. That should actually
+ // work but in practice ...
+ m_rView.SelectShellForDrop();
+
+ bool bCallBase = true;
+
+ if( m_pQuickHlpData->m_bIsDisplayed )
+ m_pQuickHlpData->Stop( rSh );
+ m_pQuickHlpData->m_bAppendSpace = false;
+
+ if( rSh.FinishOLEObj() )
+ return; // end InPlace and the click doesn't count anymore
+
+ SET_CURR_SHELL( &rSh );
+
+ SdrView *pSdrView = rSh.GetDrawView();
+ if ( pSdrView )
+ {
+ if (pSdrView->MouseButtonDown( rMEvt, this ) )
+ {
+ rSh.GetView().GetViewFrame()->GetBindings().InvalidateAll(sal_False);
+ return; // SdrView's event evaluated
+ }
+ }
+
+ m_bIsInMove = sal_False;
+ m_aStartPos = rMEvt.GetPosPixel();
+ m_aRszMvHdlPt.X() = 0, m_aRszMvHdlPt.Y() = 0;
+
+ sal_uInt8 nMouseTabCol = 0;
+ const bool bTmp = !rSh.IsDrawCreate() && !m_pApplyTempl && !rSh.IsInSelect() &&
+ rMEvt.GetClicks() == 1 && MOUSE_LEFT == rMEvt.GetButtons();
+ if ( bTmp &&
+ 0 != (nMouseTabCol = rSh.WhichMouseTabCol( aDocPos ) ) &&
+ !rSh.IsObjSelectable( aDocPos ) )
+ {
+ // Enhanced table selection
+ if ( SW_TABSEL_HORI <= nMouseTabCol && SW_TABCOLSEL_VERT >= nMouseTabCol )
+ {
+ rSh.EnterStdMode();
+ rSh.SelectTableRowCol( aDocPos );
+ if( SW_TABSEL_HORI != nMouseTabCol && SW_TABSEL_HORI_RTL != nMouseTabCol)
+ {
+ m_pRowColumnSelectionStart = new Point( aDocPos );
+ m_bIsRowDrag = SW_TABROWSEL_HORI == nMouseTabCol||
+ SW_TABROWSEL_HORI_RTL == nMouseTabCol ||
+ SW_TABCOLSEL_VERT == nMouseTabCol;
+ m_bMBPressed = sal_True;
+ CaptureMouse();
+ }
+ return;
+ }
+
+ if ( !rSh.IsTableMode() )
+ {
+ // comes from table columns out of the document.
+ if(SW_TABCOL_VERT == nMouseTabCol || SW_TABCOL_HORI == nMouseTabCol)
+ m_rView.SetTabColFromDoc( sal_True );
+ else
+ m_rView.SetTabRowFromDoc( sal_True );
+
+ m_rView.SetTabColFromDocPos( aDocPos );
+ m_rView.InvalidateRulerPos();
+ SfxBindings& rBind = m_rView.GetViewFrame()->GetBindings();
+ rBind.Update();
+ if ( RulerColumnDrag( rMEvt,
+ (SW_TABCOL_VERT == nMouseTabCol || SW_TABROW_HORI == nMouseTabCol)) )
+ {
+ m_rView.SetTabColFromDoc( sal_False );
+ m_rView.SetTabRowFromDoc( sal_False );
+ m_rView.InvalidateRulerPos();
+ rBind.Update();
+ bCallBase = false;
+ }
+ else
+ {
+ return;
+ }
+ }
+ }
+ else if (bTmp &&
+ rSh.IsNumLabel(aDocPos))
+ {
+ SwTxtNode* pNodeAtPos = rSh.GetNumRuleNodeAtPos( aDocPos );
+ m_rView.SetNumRuleNodeFromDoc( pNodeAtPos );
+ m_rView.InvalidateRulerPos();
+ SfxBindings& rBind = m_rView.GetViewFrame()->GetBindings();
+ rBind.Update();
+
+ if ( RulerMarginDrag( rMEvt,
+ rSh.IsVerticalModeAtNdAndPos( *pNodeAtPos, aDocPos ) ) )
+ {
+ m_rView.SetNumRuleNodeFromDoc( NULL );
+ m_rView.InvalidateRulerPos();
+ rBind.Update();
+ bCallBase = false;
+ }
+ else
+ {
+ // Make sure the pointer is set to 0, otherwise it may point to
+ // nowhere after deleting the corresponding text node.
+ m_rView.SetNumRuleNodeFromDoc( NULL );
+ return;
+ }
+ }
+
+ if ( rSh.IsInSelect() )
+ rSh.EndSelect();
+
+ // query against LEFT because otherwise for example also a right
+ // click releases the selection.
+ if ( MOUSE_LEFT == rMEvt.GetButtons() )
+ {
+ sal_Bool bOnlyText = sal_False;
+ m_bMBPressed = sal_True;
+ bNoInterrupt = true;
+ m_nKS_NUMDOWN_Count = 0;
+
+ CaptureMouse();
+
+ // reset curor position if applicable
+ rSh.ResetCursorStack();
+
+ switch ( rMEvt.GetModifier() + rMEvt.GetButtons() )
+ {
+ case MOUSE_LEFT:
+ case MOUSE_LEFT + KEY_SHIFT:
+ case MOUSE_LEFT + KEY_MOD2:
+ if( rSh.IsObjSelected() )
+ {
+ SdrHdl* pHdl;
+ if( !bIsDocReadOnly &&
+ !m_pAnchorMarker &&
+ 0 != ( pHdl = pSdrView->PickHandle(aDocPos) ) &&
+ ( pHdl->GetKind() == HDL_ANCHOR ||
+ pHdl->GetKind() == HDL_ANCHOR_TR ) )
+ {
+ // #i121463# Set selected during drag
+ pHdl->SetSelected(true);
+ m_pAnchorMarker = new SwAnchorMarker( pHdl );
+ UpdatePointer( aDocPos, rMEvt.GetModifier() );
+ return;
+ }
+ }
+ if ( EnterDrawMode( rMEvt, aDocPos ) )
+ {
+ bNoInterrupt = false;
+ return;
+ }
+ else if ( m_rView.GetDrawFuncPtr() && m_bInsFrm )
+ {
+ StopInsFrm();
+ rSh.Edit();
+ }
+
+ // Without SHIFT because otherwise Toggle doesn't work at selection
+ if (rMEvt.GetClicks() == 1)
+ {
+ if ( rSh.IsSelFrmMode())
+ {
+ SdrHdl* pHdl = rSh.GetDrawView()->PickHandle(aDocPos);
+ bool bHitHandle = pHdl && pHdl->GetKind() != HDL_ANCHOR &&
+ pHdl->GetKind() != HDL_ANCHOR_TR;
+
+ if ((rSh.IsInsideSelectedObj(aDocPos) || bHitHandle) &&
+ !(rMEvt.GetModifier() == KEY_SHIFT && !bHitHandle))
+ {
+ rSh.EnterSelFrmMode( &aDocPos );
+ if ( !m_pApplyTempl )
+ {
+ // only if no position to size was hit.
+ if (!bHitHandle)
+ {
+ SdrObject* pObj;
+ SdrPageView* pPV;
+ if (pSdrView->PickObj(aDocPos, pSdrView->getHitTolLog(), pObj, pPV, SDRSEARCH_ALSOONMASTER | SDRSEARCH_BEFOREMARK))
+ {
+ pSdrView->UnmarkAllObj();
+ pSdrView->MarkObj(pObj,pPV,false,false);
+ return;
+ }
+ StartDDTimer();
+ SwEditWin::m_nDDStartPosY = aDocPos.Y();
+ SwEditWin::m_nDDStartPosX = aDocPos.X();
+ }
+ bFrmDrag = true;
+ }
+ bNoInterrupt = false;
+ return;
+ }
+ }
+ }
+ }
+
+ sal_Bool bExecHyperlinks = m_rView.GetDocShell()->IsReadOnly();
+ if ( !bExecHyperlinks )
+ {
+ SvtSecurityOptions aSecOpts;
+ const sal_Bool bSecureOption = aSecOpts.IsOptionSet( SvtSecurityOptions::E_CTRLCLICK_HYPERLINK );
+ if ( ( bSecureOption && rMEvt.GetModifier() == KEY_MOD1 ) ||
+ ( !bSecureOption && rMEvt.GetModifier() != KEY_MOD1 ) )
+ bExecHyperlinks = sal_True;
+ }
+
+ // Enhanced selection
+ sal_uInt8 nNumberOfClicks = static_cast< sal_uInt8 >(rMEvt.GetClicks() % 4);
+ if ( 0 == nNumberOfClicks && 0 < rMEvt.GetClicks() )
+ nNumberOfClicks = 4;
+
+ bool bExecDrawTextLink = false;
+
+ switch ( rMEvt.GetModifier() + rMEvt.GetButtons() )
+ {
+ case MOUSE_LEFT:
+ case MOUSE_LEFT + KEY_MOD1:
+ case MOUSE_LEFT + KEY_MOD2:
+ {
+
+ bool bHandledFlyClick = false;
+ if ( nNumberOfClicks == nNbFlyClicks )
+ {
+ bHandledFlyClick = true;
+ // only try to select frame, if pointer already was
+ // switched accordingly
+ if ( m_aActHitType != SDRHIT_NONE && !rSh.IsSelFrmMode() &&
+ !GetView().GetViewFrame()->GetDispatcher()->IsLocked() &&
+ !bExecDrawTextLink)
+ {
+ // Test if there is a draw object at that position and if it should be selected.
+ sal_Bool bShould = rSh.ShouldObjectBeSelected(aDocPos);
+
+ if(bShould)
+ {
+ m_rView.NoRotate();
+ rSh.HideCrsr();
+
+ bool bUnLockView = !rSh.IsViewLocked();
+ rSh.LockView( sal_True );
+ sal_Bool bSelObj = rSh.SelectObj( aDocPos,
+ rMEvt.IsMod1() ? SW_ENTER_GROUP : 0);
+ if( bUnLockView )
+ rSh.LockView( sal_False );
+
+ if( bSelObj )
+ {
+ // if the frame was deselected in the macro
+ // the cursor just has to be displayed again
+ if( FRMTYPE_NONE == rSh.GetSelFrmType() )
+ rSh.ShowCrsr();
+ else
+ {
+ if (rSh.IsFrmSelected() && m_rView.GetDrawFuncPtr())
+ {
+ m_rView.GetDrawFuncPtr()->Deactivate();
+ m_rView.SetDrawFuncPtr(NULL);
+ m_rView.LeaveDrawCreate();
+ m_rView.AttrChangedNotify( &rSh );
+ }
+
+ rSh.EnterSelFrmMode( &aDocPos );
+ bFrmDrag = true;
+ UpdatePointer( aDocPos, rMEvt.GetModifier() );
+ }
+ return;
+ }
+ else
+ bOnlyText = static_cast< sal_Bool >(rSh.IsObjSelectable( aDocPos ));
+
+ if (!m_rView.GetDrawFuncPtr())
+ rSh.ShowCrsr();
+ }
+ else
+ bOnlyText = KEY_MOD1 != rMEvt.GetModifier();
+ }
+ else if ( rSh.IsSelFrmMode() &&
+ (m_aActHitType == SDRHIT_NONE ||
+ !rSh.IsInsideSelectedObj( aDocPos )))
+ {
+ m_rView.NoRotate();
+ SdrHdl *pHdl;
+ if( !bIsDocReadOnly && !m_pAnchorMarker && 0 !=
+ ( pHdl = pSdrView->PickHandle(aDocPos) ) &&
+ ( pHdl->GetKind() == HDL_ANCHOR ||
+ pHdl->GetKind() == HDL_ANCHOR_TR ) )
+ {
+ m_pAnchorMarker = new SwAnchorMarker( pHdl );
+ UpdatePointer( aDocPos, rMEvt.GetModifier() );
+ return;
+ }
+ else
+ {
+ bool bUnLockView = !rSh.IsViewLocked();
+ rSh.LockView( sal_True );
+ sal_uInt8 nFlag = rMEvt.IsShift() ? SW_ADD_SELECT :0;
+ if( rMEvt.IsMod1() )
+ nFlag = nFlag | SW_ENTER_GROUP;
+
+ if ( rSh.IsSelFrmMode() )
+ {
+ rSh.UnSelectFrm();
+ rSh.LeaveSelFrmMode();
+ m_rView.AttrChangedNotify(&rSh);
+ }
+
+ sal_Bool bSelObj = rSh.SelectObj( aDocPos, nFlag );
+ if( bUnLockView )
+ rSh.LockView( sal_False );
+
+ if( !bSelObj )
+ {
+ // move cursor here so that it is not drawn in the
+ // frame first; ShowCrsr() happens in LeaveSelFrmMode()
+ bValidCrsrPos = !(CRSR_POSCHG & rSh.SetCursor(&aDocPos, false));
+ rSh.LeaveSelFrmMode();
+ m_rView.AttrChangedNotify( &rSh );
+ bCallBase = false;
+ }
+ else
+ {
+ rSh.HideCrsr();
+ rSh.EnterSelFrmMode( &aDocPos );
+ rSh.SelFlyGrabCrsr();
+ rSh.MakeSelVisible();
+ bFrmDrag = true;
+ if( rSh.IsFrmSelected() &&
+ m_rView.GetDrawFuncPtr() )
+ {
+ m_rView.GetDrawFuncPtr()->Deactivate();
+ m_rView.SetDrawFuncPtr(NULL);
+ m_rView.LeaveDrawCreate();
+ m_rView.AttrChangedNotify( &rSh );
+ }
+ UpdatePointer( aDocPos, rMEvt.GetModifier() );
+ return;
+ }
+ }
+ }
+ }
+
+ switch ( nNumberOfClicks )
+ {
+ case 1:
+ {
+ UpdatePointer( aDocPos, rMEvt.GetModifier() );
+ SwEditWin::m_nDDStartPosY = aDocPos.Y();
+ SwEditWin::m_nDDStartPosX = aDocPos.X();
+
+ // hit an URL in DrawText object?
+ if (bExecHyperlinks && pSdrView)
+ {
+ SdrViewEvent aVEvt;
+ pSdrView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
+
+ if (aVEvt.eEvent == SDREVENT_EXECUTEURL)
+ bExecDrawTextLink = true;
+ }
+ break;
+ }
+ case 2:
+ {
+ bFrmDrag = false;
+ if ( !bHandledFlyClick && !bIsDocReadOnly && rSh.IsInsideSelectedObj(aDocPos) &&
+ 0 == rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) )
+ {
+ /* This is no good: on the one hand GetSelectionType is used as flag field
+ * (take a look into the GetSelectionType method) and on the other hand the
+ * return value is used in a switch without proper masking (very nice), this must lead to trouble
+ */
+ switch ( rSh.GetSelectionType() &~ ( nsSelectionType::SEL_FONTWORK | nsSelectionType::SEL_EXTRUDED_CUSTOMSHAPE ) )
+ {
+ case nsSelectionType::SEL_GRF:
+ RstMBDownFlags();
+ GetView().GetViewFrame()->GetBindings().Execute(
+ FN_FORMAT_GRAFIC_DLG, 0, 0,
+ SFX_CALLMODE_RECORD|SFX_CALLMODE_SLOT);
+ return;
+
+ // double click on OLE object --> OLE-InPlace
+ case nsSelectionType::SEL_OLE:
+ if (!rSh.IsSelObjProtected(FLYPROTECT_CONTENT))
+ {
+ RstMBDownFlags();
+ rSh.LaunchOLEObj();
+ }
+ return;
+
+ case nsSelectionType::SEL_FRM:
+ RstMBDownFlags();
+ GetView().GetViewFrame()->GetBindings().Execute(
+ FN_FORMAT_FRAME_DLG, 0, 0, SFX_CALLMODE_RECORD|SFX_CALLMODE_SLOT);
+ return;
+
+ case nsSelectionType::SEL_DRW:
+ RstMBDownFlags();
+ EnterDrawTextMode(aDocPos);
+ if ( m_rView.GetCurShell()->ISA(SwDrawTextShell) )
+ ((SwDrawTextShell*)m_rView.GetCurShell())->Init();
+ return;
+ }
+ }
+
+ // if the cursor position was corrected or if a Fly
+ // was selected in ReadOnlyMode, no word selection.
+ if ( !bValidCrsrPos || rSh.IsFrmSelected() )
+ return;
+
+ SwField *pFld;
+ sal_Bool bFtn = sal_False;
+
+ if( !bIsDocReadOnly &&
+ ( 0 != ( pFld = rSh.GetCurFld() ) ||
+ 0 != ( bFtn = rSh.GetCurFtn() )) )
+ {
+ RstMBDownFlags();
+ if( bFtn )
+ GetView().GetViewFrame()->GetBindings().Execute( FN_EDIT_FOOTNOTE );
+ else
+ {
+ sal_uInt16 nTypeId = pFld->GetTypeId();
+ SfxViewFrame* pVFrame = GetView().GetViewFrame();
+ switch( nTypeId )
+ {
+ case TYP_POSTITFLD:
+ case TYP_SCRIPTFLD:
+ {
+ // if it's a Readonly region, status has to be enabled
+ sal_uInt16 nSlot = TYP_POSTITFLD == nTypeId ? FN_POSTIT : FN_JAVAEDIT;
+ SfxBoolItem aItem(nSlot, true);
+ pVFrame->GetBindings().SetState(aItem);
+ pVFrame->GetBindings().Execute(nSlot);
+ break;
+ }
+ case TYP_AUTHORITY :
+ pVFrame->GetBindings().Execute(FN_EDIT_AUTH_ENTRY_DLG);
+ break;
+ default:
+ pVFrame->GetBindings().Execute(FN_EDIT_FIELD);
+ }
+ }
+ return;
+ }
+ // in extended mode double and triple
+ // click has no effect.
+ if ( rSh.IsExtMode() || rSh.IsBlockMode() )
+ return;
+
+ // select work, AdditionalMode if applicable
+ if ( KEY_MOD1 == rMEvt.GetModifier() && !rSh.IsAddMode() )
+ {
+ rSh.EnterAddMode();
+ rSh.SelWrd( &aDocPos );
+ rSh.LeaveAddMode();
+ }
+ else
+ rSh.SelWrd( &aDocPos );
+ bHoldSelection = true;
+ return;
+ }
+ case 3:
+ case 4:
+ {
+ bFrmDrag = false;
+ // in extended mode double and triple
+ // click has no effect.
+ if ( rSh.IsExtMode() )
+ return;
+
+ // if the cursor position was corrected or if a Fly
+ // was selected in ReadOnlyMode, no word selection.
+ if ( !bValidCrsrPos || rSh.IsFrmSelected() )
+ return;
+
+ // select line, AdditionalMode if applicable
+ const bool bMod = KEY_MOD1 == rMEvt.GetModifier() &&
+ !rSh.IsAddMode();
+
+ if ( bMod )
+ rSh.EnterAddMode();
+
+ // Enhanced selection
+ if ( 3 == nNumberOfClicks )
+ rSh.SelSentence( &aDocPos );
+ else
+ rSh.SelPara( &aDocPos );
+
+ if ( bMod )
+ rSh.LeaveAddMode();
+
+ bHoldSelection = true;
+ return;
+ }
+
+ default:
+ return;
+ }
+ }
+ /* no break */
+ case MOUSE_LEFT + KEY_SHIFT:
+ case MOUSE_LEFT + KEY_SHIFT + KEY_MOD1:
+ {
+ sal_Bool bLockView = m_bWasShdwCrsr;
+
+ switch ( rMEvt.GetModifier() )
+ {
+ case KEY_MOD1 + KEY_SHIFT:
+ {
+ if ( !m_bInsDraw && IsDrawObjSelectable( rSh, aDocPos ) )
+ {
+ m_rView.NoRotate();
+ rSh.HideCrsr();
+ if ( rSh.IsSelFrmMode() )
+ rSh.SelectObj(aDocPos, SW_ADD_SELECT | SW_ENTER_GROUP);
+ else
+ { if ( rSh.SelectObj( aDocPos, SW_ADD_SELECT | SW_ENTER_GROUP ) )
+ {
+ rSh.EnterSelFrmMode( &aDocPos );
+ SwEditWin::m_nDDStartPosY = aDocPos.Y();
+ SwEditWin::m_nDDStartPosX = aDocPos.X();
+ bFrmDrag = true;
+ return;
+ }
+ }
+ }
+ else if( rSh.IsSelFrmMode() &&
+ rSh.GetDrawView()->PickHandle( aDocPos ))
+ {
+ bFrmDrag = true;
+ bNoInterrupt = false;
+ return;
+ }
+ }
+ break;
+ case KEY_MOD1:
+ if ( !bExecDrawTextLink )
+ {
+ if ( !m_bInsDraw && IsDrawObjSelectable( rSh, aDocPos ) && !lcl_urlOverBackground( rSh, aDocPos ) )
+ {
+ m_rView.NoRotate();
+ rSh.HideCrsr();
+ if ( rSh.IsSelFrmMode() )
+ rSh.SelectObj(aDocPos, SW_ENTER_GROUP);
+ else
+ { if ( rSh.SelectObj( aDocPos, SW_ENTER_GROUP ) )
+ {
+ rSh.EnterSelFrmMode( &aDocPos );
+ SwEditWin::m_nDDStartPosY = aDocPos.Y();
+ SwEditWin::m_nDDStartPosX = aDocPos.X();
+ bFrmDrag = true;
+ return;
+ }
+ }
+ }
+ else if( rSh.IsSelFrmMode() &&
+ rSh.GetDrawView()->PickHandle( aDocPos ))
+ {
+ bFrmDrag = true;
+ bNoInterrupt = false;
+ return;
+ }
+ else
+ {
+ if ( !rSh.IsAddMode() && !rSh.IsExtMode() && !rSh.IsBlockMode() )
+ {
+ rSh.PushMode();
+ bModePushed = true;
+
+ bool bUnLockView = !rSh.IsViewLocked();
+ rSh.LockView( sal_True );
+ rSh.EnterAddMode();
+ if( bUnLockView )
+ rSh.LockView( sal_False );
+ }
+ bCallBase = false;
+ }
+ }
+ break;
+ case KEY_MOD2:
+ {
+ if ( !rSh.IsAddMode() && !rSh.IsExtMode() && !rSh.IsBlockMode() )
+ {
+ rSh.PushMode();
+ bModePushed = true;
+ bool bUnLockView = !rSh.IsViewLocked();
+ rSh.LockView( sal_True );
+ rSh.EnterBlockMode();
+ if( bUnLockView )
+ rSh.LockView( sal_False );
+ }
+ bCallBase = false;
+ }
+ break;
+ case KEY_SHIFT:
+ {
+ if ( !m_bInsDraw && IsDrawObjSelectable( rSh, aDocPos ) )
+ {
+ m_rView.NoRotate();
+ rSh.HideCrsr();
+ if ( rSh.IsSelFrmMode() )
+ {
+ rSh.SelectObj(aDocPos, SW_ADD_SELECT);
+
+ const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
+ if (rMarkList.GetMark(0) == NULL)
+ {
+ rSh.LeaveSelFrmMode();
+ m_rView.AttrChangedNotify(&rSh);
+ bFrmDrag = false;
+ }
+ }
+ else
+ { if ( rSh.SelectObj( aDocPos ) )
+ {
+ rSh.EnterSelFrmMode( &aDocPos );
+ SwEditWin::m_nDDStartPosY = aDocPos.Y();
+ SwEditWin::m_nDDStartPosX = aDocPos.X();
+ bFrmDrag = true;
+ return;
+ }
+ }
+ }
+ else
+ {
+ if ( rSh.IsSelFrmMode() &&
+ rSh.IsInsideSelectedObj( aDocPos ) )
+ {
+ rSh.EnterSelFrmMode( &aDocPos );
+ SwEditWin::m_nDDStartPosY = aDocPos.Y();
+ SwEditWin::m_nDDStartPosX = aDocPos.X();
+ bFrmDrag = true;
+ return;
+ }
+ if ( rSh.IsSelFrmMode() )
+ {
+ rSh.UnSelectFrm();
+ rSh.LeaveSelFrmMode();
+ m_rView.AttrChangedNotify(&rSh);
+ bFrmDrag = false;
+ }
+ if ( !rSh.IsExtMode() )
+ {
+ // don't start a selection when an
+ // URL field or a graphic is clicked
+ bool bSttSelect = rSh.HasSelection() ||
+ Pointer(POINTER_REFHAND) != GetPointer();
+
+ if( !bSttSelect )
+ {
+ bSttSelect = true;
+ if( bExecHyperlinks )
+ {
+ SwContentAtPos aCntntAtPos(
+ SwContentAtPos::SW_FTN |
+ SwContentAtPos::SW_INETATTR );
+
+ if( rSh.GetContentAtPos( aDocPos, aCntntAtPos ) )
+ {
+ if( !rSh.IsViewLocked() &&
+ !rSh.IsReadOnlyAvailable() &&
+ aCntntAtPos.IsInProtectSect() )
+ bLockView = sal_True;
+
+ bSttSelect = false;
+ }
+ else if( rSh.IsURLGrfAtPos( aDocPos ))
+ bSttSelect = false;
+ }
+ }
+
+ if( bSttSelect )
+ rSh.SttSelect();
+ }
+ }
+ bCallBase = false;
+ break;
+ }
+ default:
+ if( !rSh.IsViewLocked() )
+ {
+ SwContentAtPos aCntntAtPos( SwContentAtPos::SW_CLICKFIELD |
+ SwContentAtPos::SW_INETATTR );
+ if( rSh.GetContentAtPos( aDocPos, aCntntAtPos, sal_False ) &&
+ !rSh.IsReadOnlyAvailable() &&
+ aCntntAtPos.IsInProtectSect() )
+ bLockView = sal_True;
+ }
+ }
+
+ if ( rSh.IsGCAttr() )
+ {
+ rSh.GCAttr();
+ rSh.ClearGCAttr();
+ }
+
+ SwContentAtPos aFieldAtPos(SwContentAtPos::SW_FIELD);
+
+ // Are we clicking on a field?
+ if (rSh.GetContentAtPos(aDocPos, aFieldAtPos))
+ {
+ bool bEditableField = (aFieldAtPos.pFndTxtAttr != NULL
+ && aFieldAtPos.pFndTxtAttr->Which() == RES_TXTATR_INPUTFIELD);
+
+ if (!bEditableField)
+ {
+ rSh.SetCursor(&aDocPos, bOnlyText);
+ // Unfortunately the cursor may be on field
+ // position or on position after field depending on which
+ // half of the field was clicked on.
+ SwTxtAttr const*const pTxtFld(aFieldAtPos.pFndTxtAttr);
+ if (rSh.GetCurrentShellCursor().GetPoint()->nContent
+ .GetIndex() != *pTxtFld->GetStart())
+ {
+ assert(rSh.GetCurrentShellCursor().GetPoint()->nContent
+ .GetIndex() == (*pTxtFld->GetStart() + 1));
+ rSh.Left( CRSR_SKIP_CHARS, false, 1, false );
+ }
+ // don't go into the !bOverSelect block below - it moves
+ // the cursor
+ break;
+ }
+ }
+
+ sal_Bool bOverSelect = rSh.ChgCurrPam( aDocPos ), bOverURLGrf = sal_False;
+ if( !bOverSelect )
+ bOverURLGrf = bOverSelect = 0 != rSh.IsURLGrfAtPos( aDocPos );
+
+ if ( !bOverSelect )
+ {
+ const bool bTmpNoInterrupt = bNoInterrupt;
+ bNoInterrupt = false;
+
+ if( !rSh.IsViewLocked() && bLockView )
+ rSh.LockView( sal_True );
+ else
+ bLockView = sal_False;
+
+ int nTmpSetCrsr = 0;
+
+ { // only temporary generate Move-Kontext because otherwise
+ // the query to the content form doesn't work!!!
+ SwMvContext aMvContext( &rSh );
+ nTmpSetCrsr = rSh.SetCursor(&aDocPos, bOnlyText);
+ bValidCrsrPos = !(CRSR_POSCHG & nTmpSetCrsr);
+ bCallBase = false;
+ }
+
+ // notify the edit window that from now on we do not use the input language
+ if ( !(CRSR_POSOLD & nTmpSetCrsr) )
+ SetUseInputLanguage( sal_False );
+
+ if( bLockView )
+ rSh.LockView( sal_False );
+
+ bNoInterrupt = bTmpNoInterrupt;
+ }
+ if ( !bOverURLGrf && !bOnlyText )
+ {
+ const int nSelType = rSh.GetSelectionType();
+ // Check in general, if an object is selectable at given position.
+ // Thus, also text fly frames in background become selectable via Ctrl-Click.
+ if ( ( nSelType & nsSelectionType::SEL_OLE ||
+ nSelType & nsSelectionType::SEL_GRF ||
+ rSh.IsObjSelectable( aDocPos ) ) && !lcl_urlOverBackground( rSh, aDocPos ) )
+ {
+ SwMvContext aMvContext( &rSh );
+ if( !rSh.IsFrmSelected() )
+ rSh.GotoNextFly();
+ rSh.EnterSelFrmMode();
+ bCallBase = false;
+ }
+ }
+ // don't reset here any longer so that, in case through MouseMove
+ // with pressed Ctrl key a multiple-selection should happen,
+ // the previous selection is not released in Drag.
+ break;
+ }
+ }
+ }
+ if (bCallBase)
+ Window::MouseButtonDown(rMEvt);
+}
+
+/**
+ * MouseMove
+ */
+void SwEditWin::MouseMove(const MouseEvent& _rMEvt)
+{
+ MouseEvent rMEvt(_rMEvt);
+
+ //ignore key modifiers for format paintbrush
+ {
+ bool bExecFormatPaintbrush = m_pApplyTempl && m_pApplyTempl->m_pFormatClipboard
+ && m_pApplyTempl->m_pFormatClipboard->HasContent();
+ if( bExecFormatPaintbrush )
+ rMEvt = MouseEvent( _rMEvt.GetPosPixel(), _rMEvt.GetClicks(),
+ _rMEvt.GetMode(), _rMEvt.GetButtons() );
+ }
+
+ // as long as an action is running the MouseMove should be disconnected
+ // otherwise bug 40102 occurs
+ SwWrtShell &rSh = m_rView.GetWrtShell();
+ if( rSh.ActionPend() )
+ return ;
+
+ if( m_pShadCrsr && 0 != (rMEvt.GetModifier() + rMEvt.GetButtons() ) )
+ delete m_pShadCrsr, m_pShadCrsr = 0;
+
+ sal_Bool bIsDocReadOnly = m_rView.GetDocShell()->IsReadOnly();
+
+ SET_CURR_SHELL( &rSh );
+
+ //aPixPt == Point in Pixel, relative to ChildWin
+ //aDocPt == Point in Twips, document coordinates
+ const Point aPixPt( rMEvt.GetPosPixel() );
+ const Point aDocPt( PixelToLogic( aPixPt ) );
+
+ if ( IsChainMode() )
+ {
+ UpdatePointer( aDocPt, rMEvt.GetModifier() );
+ return;
+ }
+
+ SdrView *pSdrView = rSh.GetDrawView();
+
+ const SwCallMouseEvent aLastCallEvent( m_aSaveCallEvent );
+ m_aSaveCallEvent.Clear();
+
+ if ( !bIsDocReadOnly && pSdrView && pSdrView->MouseMove(rMEvt,this) )
+ {
+ SetPointer( POINTER_TEXT );
+ return; // evaluate SdrView's event
+ }
+
+ const Point aOldPt( rSh.VisArea().Pos() );
+ const sal_Bool bInsWin = rSh.VisArea().IsInside( aDocPt );
+
+ if( m_pShadCrsr && !bInsWin )
+ delete m_pShadCrsr, m_pShadCrsr = 0;
+
+ if( bInsWin && m_pRowColumnSelectionStart )
+ {
+ EnterArea();
+ Point aPos( aDocPt );
+ if( rSh.SelectTableRowCol( *m_pRowColumnSelectionStart, &aPos, m_bIsRowDrag ))
+ return;
+ }
+
+ // position is necessary for OS/2 because obviously after a MB-Down
+ // a MB-Move is called immediately.
+ if( bDDTimerStarted )
+ {
+ Point aDD( SwEditWin::m_nDDStartPosX, SwEditWin::m_nDDStartPosY );
+ aDD = LogicToPixel( aDD );
+ Rectangle aRect( aDD.X()-3, aDD.Y()-3, aDD.X()+3, aDD.Y()+3 );
+ if ( !aRect.IsInside( aPixPt ) )
+ StopDDTimer( &rSh, aDocPt );
+ }
+
+ if(m_rView.GetDrawFuncPtr())
+ {
+ if( m_bInsDraw )
+ {
+ m_rView.GetDrawFuncPtr()->MouseMove( rMEvt );
+ if ( !bInsWin )
+ {
+ Point aTmp( aDocPt );
+ aTmp += rSh.VisArea().Pos() - aOldPt;
+ LeaveArea( aTmp );
+ }
+ else
+ EnterArea();
+ return;
+ }
+ else if(!rSh.IsFrmSelected() && !rSh.IsObjSelected())
+ {
+ SfxBindings &rBnd = rSh.GetView().GetViewFrame()->GetBindings();
+ Point aRelPos = rSh.GetRelativePagePosition(aDocPt);
+ if(aRelPos.X() >= 0)
+ {
+ FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, &GetView()));
+ SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)));
+ const SfxPointItem aTmp1( SID_ATTR_POSITION, aRelPos );
+ rBnd.SetState( aTmp1 );
+ }
+ else
+ {
+ rBnd.Invalidate(SID_ATTR_POSITION);
+ }
+ rBnd.Invalidate(SID_ATTR_SIZE);
+ const SfxStringItem aCell( SID_TABLE_CELL, OUString() );
+ rBnd.SetState( aCell );
+ }
+ }
+
+ sal_uInt8 nMouseTabCol;
+ if( !bIsDocReadOnly && bInsWin && !m_pApplyTempl && !rSh.IsInSelect() )
+ {
+ if ( SW_TABCOL_NONE != (nMouseTabCol = rSh.WhichMouseTabCol( aDocPt ) ) &&
+ !rSh.IsObjSelectable( aDocPt ) )
+ {
+ sal_uInt16 nPointer = USHRT_MAX;
+ bool bChkTblSel = false;
+
+ switch ( nMouseTabCol )
+ {
+ case SW_TABCOL_VERT :
+ case SW_TABROW_HORI :
+ nPointer = POINTER_VSIZEBAR;
+ bChkTblSel = true;
+ break;
+ case SW_TABROW_VERT :
+ case SW_TABCOL_HORI :
+ nPointer = POINTER_HSIZEBAR;
+ bChkTblSel = true;
+ break;
+ // Enhanced table selection
+ case SW_TABSEL_HORI :
+ nPointer = POINTER_TAB_SELECT_SE;
+ break;
+ case SW_TABSEL_HORI_RTL :
+ case SW_TABSEL_VERT :
+ nPointer = POINTER_TAB_SELECT_SW;
+ break;
+ case SW_TABCOLSEL_HORI :
+ case SW_TABROWSEL_VERT :
+ nPointer = POINTER_TAB_SELECT_S;
+ break;
+ case SW_TABROWSEL_HORI :
+ nPointer = POINTER_TAB_SELECT_E;
+ break;
+ case SW_TABROWSEL_HORI_RTL :
+ case SW_TABCOLSEL_VERT :
+ nPointer = POINTER_TAB_SELECT_W;
+ break;
+ }
+
+ if ( USHRT_MAX != nPointer &&
+ // i#35543 - Enhanced table selection is explicitly allowed in table mode
+ ( !bChkTblSel || !rSh.IsTableMode() ) )
+ {
+ SetPointer( nPointer );
+ }
+
+ return;
+ }
+ else if (rSh.IsNumLabel(aDocPt, RULER_MOUSE_MARGINWIDTH))
+ {
+ // i#42921 - consider vertical mode
+ SwTxtNode* pNodeAtPos = rSh.GetNumRuleNodeAtPos( aDocPt );
+ const sal_uInt16 nPointer =
+ rSh.IsVerticalModeAtNdAndPos( *pNodeAtPos, aDocPt )
+ ? POINTER_VSIZEBAR
+ : POINTER_HSIZEBAR;
+ SetPointer( nPointer );
+
+ return;
+ }
+ }
+
+ bool bDelShadCrsr = true;
+
+ switch ( rMEvt.GetModifier() + rMEvt.GetButtons() )
+ {
+ case MOUSE_LEFT:
+ if( m_pAnchorMarker )
+ {
+ // Now we need to refresh the SdrHdl pointer of m_pAnchorMarker.
+ // This looks a little bit tricky, but it solves the following
+ // problem: the m_pAnchorMarker contains a pointer to an SdrHdl,
+ // if the FindAnchorPos-call cause a scrolling of the visible
+ // area, it's possible that the SdrHdl will be destroyed and a
+ // new one will initialized at the original position(GetHdlPos).
+ // So the m_pAnchorMarker has to find the right SdrHdl, if it's
+ // the old one, it will find it with position aOld, if this one
+ // is destroyed, it will find a new one at position GetHdlPos().
+
+ const Point aOld = m_pAnchorMarker->GetPosForHitTest( *(rSh.GetOut()) );
+ Point aNew = rSh.FindAnchorPos( aDocPt );
+ SdrHdl* pHdl;
+ if( (0!=( pHdl = pSdrView->PickHandle( aOld ) )||
+ 0 !=(pHdl = pSdrView->PickHandle( m_pAnchorMarker->GetHdlPos()) ) ) &&
+ ( pHdl->GetKind() == HDL_ANCHOR ||
+ pHdl->GetKind() == HDL_ANCHOR_TR ) )
+ {
+ m_pAnchorMarker->ChgHdl( pHdl );
+ if( aNew.X() || aNew.Y() )
+ {
+ m_pAnchorMarker->SetPos( aNew );
+ m_pAnchorMarker->SetLastPos( aDocPt );
+ }
+ }
+ else
+ {
+ delete m_pAnchorMarker;
+ m_pAnchorMarker = NULL;
+ }
+ }
+ if ( m_bInsDraw )
+ {
+ if ( !m_bMBPressed )
+ break;
+ if ( m_bIsInMove || IsMinMove( m_aStartPos, aPixPt ) )
+ {
+ if ( !bInsWin )
+ LeaveArea( aDocPt );
+ else
+ EnterArea();
+ if ( m_rView.GetDrawFuncPtr() )
+ {
+ pSdrView->SetOrtho(false);
+ m_rView.GetDrawFuncPtr()->MouseMove( rMEvt );
+ }
+ m_bIsInMove = sal_True;
+ }
+ return;
+ }
+
+ {
+ SwWordCountWrapper *pWrdCnt = (SwWordCountWrapper*)GetView().GetViewFrame()->GetChildWindow(SwWordCountWrapper::GetChildWindowId());
+ if (pWrdCnt)
+ pWrdCnt->UpdateCounts();
+ }
+
+ case MOUSE_LEFT + KEY_SHIFT:
+ case MOUSE_LEFT + KEY_SHIFT + KEY_MOD1:
+ if ( !m_bMBPressed )
+ break;
+ case MOUSE_LEFT + KEY_MOD1:
+ if ( bFrmDrag && rSh.IsSelFrmMode() )
+ {
+ if( !m_bMBPressed )
+ break;
+
+ if ( m_bIsInMove || IsMinMove( m_aStartPos, aPixPt ) )
+ {
+ // event processing for resizing
+ if( pSdrView->AreObjectsMarked() )
+ {
+ const SwFrmFmt* pFlyFmt;
+ const SvxMacro* pMacro;
+
+ const Point aSttPt( PixelToLogic( m_aStartPos ) );
+
+ // can we start?
+ if( HDL_USER == eSdrMoveHdl )
+ {
+ SdrHdl* pHdl = pSdrView->PickHandle( aSttPt );
+ eSdrMoveHdl = pHdl ? pHdl->GetKind() : HDL_MOVE;
+ }
+
+ sal_uInt16 nEvent = HDL_MOVE == eSdrMoveHdl
+ ? SW_EVENT_FRM_MOVE
+ : SW_EVENT_FRM_RESIZE;
+
+ if( 0 != ( pFlyFmt = rSh.GetFlyFrmFmt() ) &&
+ 0 != ( pMacro = pFlyFmt->GetMacro().GetMacroTable().
+ Get( nEvent )) &&
+ // or notify only e.g. every 20 Twip?
+ m_aRszMvHdlPt != aDocPt )
+ {
+ m_aRszMvHdlPt = aDocPt;
+ sal_uInt16 nPos = 0;
+ SbxArrayRef xArgs = new SbxArray;
+ SbxVariableRef xVar = new SbxVariable;
+ xVar->PutString( pFlyFmt->GetName() );
+ xArgs->Put( &xVar, ++nPos );
+
+ if( SW_EVENT_FRM_RESIZE == nEvent )
+ {
+ xVar = new SbxVariable;
+ xVar->PutUShort( static_cast< sal_uInt16 >(eSdrMoveHdl) );
+ xArgs->Put( &xVar, ++nPos );
+ }
+
+ xVar = new SbxVariable;
+ xVar->PutLong( aDocPt.X() - aSttPt.X() );
+ xArgs->Put( &xVar, ++nPos );
+ xVar = new SbxVariable;
+ xVar->PutLong( aDocPt.Y() - aSttPt.Y() );
+ xArgs->Put( &xVar, ++nPos );
+
+ OUString sRet;
+
+ ReleaseMouse();
+
+ rSh.ExecMacro( *pMacro, &sRet, &xArgs );
+
+ CaptureMouse();
+
+ if( !sRet.isEmpty() && sRet.toInt32()!=0 )
+ return ;
+ }
+ }
+ // event processing for resizing
+
+ if( bIsDocReadOnly )
+ break;
+
+ bool bIsSelectionGfx = rSh.GetSelectionType() & nsSelectionType::SEL_GRF;
+ bool bisResize = eSdrMoveHdl != HDL_MOVE;
+
+ if ( rMEvt.IsShift() )
+ {
+ pSdrView->SetAngleSnapEnabled(!bIsSelectionGfx);
+ if (bisResize)
+ pSdrView->SetOrtho(!bIsSelectionGfx);
+ else
+ pSdrView->SetOrtho(true);
+ }
+ else
+ {
+ pSdrView->SetAngleSnapEnabled(bIsSelectionGfx);
+ if (bisResize)
+ pSdrView->SetOrtho(bIsSelectionGfx);
+ else
+ pSdrView->SetOrtho(false);
+ }
+
+ rSh.Drag( &aDocPt, rMEvt.IsShift() );
+ m_bIsInMove = sal_True;
+ }
+ else if( bIsDocReadOnly )
+ break;
+
+ if ( !bInsWin )
+ {
+ Point aTmp( aDocPt );
+ aTmp += rSh.VisArea().Pos() - aOldPt;
+ LeaveArea( aTmp );
+ }
+ else if(m_bIsInMove)
+ EnterArea();
+ return;
+ }
+ if ( !rSh.IsSelFrmMode() && !bDDINetAttr &&
+ (IsMinMove( m_aStartPos,aPixPt ) || m_bIsInMove) &&
+ (rSh.IsInSelect() || !rSh.ChgCurrPam( aDocPt )) )
+ {
+ if ( pSdrView )
+ {
+ if ( rMEvt.IsShift() )
+ pSdrView->SetOrtho(true);
+ else
+ pSdrView->SetOrtho(false);
+ }
+ if ( !bInsWin )
+ {
+ Point aTmp( aDocPt );
+ aTmp += rSh.VisArea().Pos() - aOldPt;
+ LeaveArea( aTmp );
+ }
+ else
+ {
+ if( !rMEvt.IsSynthetic() &&
+ !(( MOUSE_LEFT + KEY_MOD1 ==
+ rMEvt.GetModifier() + rMEvt.GetButtons() ) &&
+ rSh.Is_FnDragEQBeginDrag() && !rSh.IsAddMode() ))
+ {
+ rSh.Drag( &aDocPt, false );
+
+ bValidCrsrPos = !(CRSR_POSCHG & rSh.SetCursor(&aDocPt, false));
+ EnterArea();
+ }
+ }
+ }
+ bDDINetAttr = false;
+ break;
+ case 0:
+ {
+ if ( m_pApplyTempl )
+ {
+ UpdatePointer(aDocPt, 0); // maybe a frame has to be marked here
+ break;
+ }
+ // change ui if mouse is over SwPostItField
+ // TODO: do the same thing for redlines SW_REDLINE
+ SwRect aFldRect;
+ SwContentAtPos aCntntAtPos( SwContentAtPos::SW_FIELD);
+ if( rSh.GetContentAtPos( aDocPt, aCntntAtPos, sal_False, &aFldRect ) )
+ {
+ const SwField* pFld = aCntntAtPos.aFnd.pFld;
+ if (pFld->Which()== RES_POSTITFLD)
+ {
+ m_rView.GetPostItMgr()->SetShadowState(reinterpret_cast<const SwPostItField*>(pFld),false);
+ }
+ else
+ m_rView.GetPostItMgr()->SetShadowState(0,false);
+ }
+ else
+ m_rView.GetPostItMgr()->SetShadowState(0,false);
+ }
+ // no break;
+ case KEY_SHIFT:
+ case KEY_MOD2:
+ case KEY_MOD1:
+ if ( !m_bInsDraw )
+ {
+ bool bTstShdwCrsr = true;
+
+ UpdatePointer( aDocPt, rMEvt.GetModifier() );
+
+ const SwFrmFmt* pFmt = 0;
+ const SwFmtINetFmt* pINet = 0;
+ SwContentAtPos aCntntAtPos( SwContentAtPos::SW_INETATTR );
+ if( rSh.GetContentAtPos( aDocPt, aCntntAtPos ) )
+ pINet = (SwFmtINetFmt*)aCntntAtPos.aFnd.pAttr;
+
+ const void* pTmp = pINet;
+
+ if( pINet ||
+ 0 != ( pTmp = pFmt = rSh.GetFmtFromAnyObj( aDocPt )))
+ {
+ bTstShdwCrsr = false;
+ if( pTmp == pINet )
+ m_aSaveCallEvent.Set( pINet );
+ else
+ {
+ IMapObject* pIMapObj = pFmt->GetIMapObject( aDocPt );
+ if( pIMapObj )
+ m_aSaveCallEvent.Set( pFmt, pIMapObj );
+ else
+ m_aSaveCallEvent.Set( EVENT_OBJECT_URLITEM, pFmt );
+ }
+
+ // should be be over a InternetField with an
+ // embedded macro?
+ if( m_aSaveCallEvent != aLastCallEvent )
+ {
+ if( aLastCallEvent.HasEvent() )
+ rSh.CallEvent( SFX_EVENT_MOUSEOUT_OBJECT,
+ aLastCallEvent, true );
+ // 0 says that the object doesn't have any table
+ if( !rSh.CallEvent( SFX_EVENT_MOUSEOVER_OBJECT,
+ m_aSaveCallEvent ))
+ m_aSaveCallEvent.Clear();
+ }
+ }
+ else if( aLastCallEvent.HasEvent() )
+ {
+ // cursor was on an object
+ rSh.CallEvent( SFX_EVENT_MOUSEOUT_OBJECT,
+ aLastCallEvent, true );
+ }
+
+ if( bTstShdwCrsr && bInsWin && !bIsDocReadOnly &&
+ !m_bInsFrm &&
+ !rSh.GetViewOptions()->getBrowseMode() &&
+ rSh.GetViewOptions()->IsShadowCursor() &&
+ !(rMEvt.GetModifier() + rMEvt.GetButtons()) &&
+ !rSh.HasSelection() && !GetConnectMetaFile() )
+ {
+ SwRect aRect;
+ sal_Int16 eOrient;
+ SwFillMode eMode = (SwFillMode)rSh.GetViewOptions()->GetShdwCrsrFillMode();
+ if( rSh.GetShadowCrsrPos( aDocPt, eMode, aRect, eOrient ))
+ {
+ if( !m_pShadCrsr )
+ m_pShadCrsr = new SwShadowCursor( *this,
+ SwViewOption::GetDirectCursorColor() );
+ if( text::HoriOrientation::RIGHT != eOrient && text::HoriOrientation::CENTER != eOrient )
+ eOrient = text::HoriOrientation::LEFT;
+ m_pShadCrsr->SetPos( aRect.Pos(), aRect.Height(), static_cast< sal_uInt16 >(eOrient) );
+ bDelShadCrsr = false;
+ }
+ }
+ }
+ break;
+ case MOUSE_LEFT + KEY_MOD2:
+ if( rSh.IsBlockMode() && !rMEvt.IsSynthetic() )
+ {
+ rSh.Drag( &aDocPt, false );
+ bValidCrsrPos = !(CRSR_POSCHG & rSh.SetCursor(&aDocPt, false));
+ EnterArea();
+ }
+ break;
+ }
+
+ if( bDelShadCrsr && m_pShadCrsr )
+ delete m_pShadCrsr, m_pShadCrsr = 0;
+ m_bWasShdwCrsr = sal_False;
+}
+
+/**
+ * Button Up
+ */
+void SwEditWin::MouseButtonUp(const MouseEvent& rMEvt)
+{
+ bool bCallBase = true;
+
+ sal_Bool bCallShadowCrsr = m_bWasShdwCrsr;
+ m_bWasShdwCrsr = sal_False;
+ if( m_pShadCrsr )
+ delete m_pShadCrsr, m_pShadCrsr = 0;
+
+ if( m_pRowColumnSelectionStart )
+ DELETEZ( m_pRowColumnSelectionStart );
+
+ SdrHdlKind eOldSdrMoveHdl = eSdrMoveHdl;
+ eSdrMoveHdl = HDL_USER; // for MoveEvents - reset again
+
+ // preventively reset
+ m_rView.SetTabColFromDoc( sal_False );
+ m_rView.SetNumRuleNodeFromDoc(NULL);
+
+ SwWrtShell &rSh = m_rView.GetWrtShell();
+ SET_CURR_SHELL( &rSh );
+ SdrView *pSdrView = rSh.GetDrawView();
+ if ( pSdrView )
+ {
+ pSdrView->SetOrtho(false);
+
+ if ( pSdrView->MouseButtonUp( rMEvt,this ) )
+ {
+ rSh.GetView().GetViewFrame()->GetBindings().InvalidateAll(sal_False);
+ return; // SdrView's event evaluated
+ }
+ }
+ // only process MouseButtonUp when the Down went to that windows as well.
+ if ( !m_bMBPressed )
+ {
+ // Undo for the watering can is already in CommandHdl
+ // that's the way it should be!
+
+ return;
+ }
+
+ Point aDocPt( PixelToLogic( rMEvt.GetPosPixel() ) );
+
+ if ( bDDTimerStarted )
+ {
+ StopDDTimer( &rSh, aDocPt );
+ m_bMBPressed = sal_False;
+ if ( rSh.IsSelFrmMode() )
+ {
+ rSh.EndDrag( &aDocPt, false );
+ bFrmDrag = false;
+ }
+ bNoInterrupt = false;
+ ReleaseMouse();
+ return;
+ }
+
+ if( m_pAnchorMarker )
+ {
+ if(m_pAnchorMarker->GetHdl())
+ {
+ // #i121463# delete selected after drag
+ m_pAnchorMarker->GetHdl()->SetSelected(false);
+ }
+
+ Point aPnt( m_pAnchorMarker->GetLastPos() );
+ DELETEZ( m_pAnchorMarker );
+ if( aPnt.X() || aPnt.Y() )
+ rSh.FindAnchorPos( aPnt, sal_True );
+ }
+ if ( m_bInsDraw && m_rView.GetDrawFuncPtr() )
+ {
+ if ( m_rView.GetDrawFuncPtr()->MouseButtonUp( rMEvt ) )
+ {
+ if (m_rView.GetDrawFuncPtr()) // could have been destroyed in MouseButtonUp
+ {
+ m_rView.GetDrawFuncPtr()->Deactivate();
+
+ if (!m_rView.IsDrawMode())
+ {
+ m_rView.SetDrawFuncPtr(NULL);
+ SfxBindings& rBind = m_rView.GetViewFrame()->GetBindings();
+ rBind.Invalidate( SID_ATTR_SIZE );
+ rBind.Invalidate( SID_TABLE_CELL );
+ }
+ }
+
+ if ( rSh.IsObjSelected() )
+ {
+ rSh.EnterSelFrmMode();
+ if (!m_rView.GetDrawFuncPtr())
+ StdDrawMode( OBJ_NONE, sal_True );
+ }
+ else if ( rSh.IsFrmSelected() )
+ {
+ rSh.EnterSelFrmMode();
+ StopInsFrm();
+ }
+ else
+ {
+ const Point aDocPos( PixelToLogic( m_aStartPos ) );
+ bValidCrsrPos = !(CRSR_POSCHG & rSh.SetCursor(&aDocPos, false));
+ rSh.Edit();
+ }
+
+ m_rView.AttrChangedNotify( &rSh );
+ }
+ else if (rMEvt.GetButtons() == MOUSE_RIGHT && rSh.IsDrawCreate())
+ m_rView.GetDrawFuncPtr()->BreakCreate(); // abort drawing
+
+ bNoInterrupt = false;
+ ReleaseMouse();
+ return;
+ }
+ bool bPopMode = false;
+ switch ( rMEvt.GetModifier() + rMEvt.GetButtons() )
+ {
+ case MOUSE_LEFT:
+ if ( m_bInsDraw && rSh.IsDrawCreate() )
+ {
+ if ( m_rView.GetDrawFuncPtr() && m_rView.GetDrawFuncPtr()->MouseButtonUp(rMEvt) == sal_True )
+ {
+ m_rView.GetDrawFuncPtr()->Deactivate();
+ m_rView.AttrChangedNotify( &rSh );
+ if ( rSh.IsObjSelected() )
+ rSh.EnterSelFrmMode();
+ if ( m_rView.GetDrawFuncPtr() && m_bInsFrm )
+ StopInsFrm();
+ }
+ bCallBase = false;
+ break;
+ }
+ case MOUSE_LEFT + KEY_MOD1:
+ case MOUSE_LEFT + KEY_MOD2:
+ case MOUSE_LEFT + KEY_SHIFT + KEY_MOD1:
+ if ( bFrmDrag && rSh.IsSelFrmMode() )
+ {
+ if ( rMEvt.IsMod1() ) // copy and don't move.
+ {
+ // abort drag, use internal Copy instead
+ Rectangle aRect;
+ rSh.GetDrawView()->TakeActionRect( aRect );
+ if (!aRect.IsEmpty())
+ {
+ rSh.BreakDrag();
+ Point aEndPt, aSttPt;
+ if ( rSh.GetSelFrmType() & FRMTYPE_FLY_ATCNT )
+ {
+ aEndPt = aRect.TopLeft();
+ aSttPt = rSh.GetDrawView()->GetAllMarkedRect().TopLeft();
+ }
+ else
+ {
+ aEndPt = aRect.Center();
+ aSttPt = rSh.GetDrawView()->GetAllMarkedRect().Center();
+ }
+ if ( aSttPt != aEndPt )
+ {
+ rSh.StartUndo( UNDO_UI_DRAG_AND_COPY );
+ rSh.Copy(&rSh, aSttPt, aEndPt, sal_False);
+ rSh.EndUndo( UNDO_UI_DRAG_AND_COPY );
+ }
+ }
+ else {
+ rSh.EndDrag( &aDocPt, false );
+ }
+ }
+ else
+ {
+ {
+ const SwFrmFmt* pFlyFmt;
+ const SvxMacro* pMacro;
+
+ sal_uInt16 nEvent = HDL_MOVE == eOldSdrMoveHdl
+ ? SW_EVENT_FRM_MOVE
+ : SW_EVENT_FRM_RESIZE;
+
+ if( 0 != ( pFlyFmt = rSh.GetFlyFrmFmt() ) &&
+ 0 != ( pMacro = pFlyFmt->GetMacro().GetMacroTable().
+ Get( nEvent )) )
+ {
+ const Point aSttPt( PixelToLogic( m_aStartPos ) );
+ m_aRszMvHdlPt = aDocPt;
+ sal_uInt16 nPos = 0;
+ SbxArrayRef xArgs = new SbxArray;
+ SbxVariableRef xVar = new SbxVariable;
+ xVar->PutString( pFlyFmt->GetName() );
+ xArgs->Put( &xVar, ++nPos );
+
+ if( SW_EVENT_FRM_RESIZE == nEvent )
+ {
+ xVar = new SbxVariable;
+ xVar->PutUShort( static_cast< sal_uInt16 >(eOldSdrMoveHdl) );
+ xArgs->Put( &xVar, ++nPos );
+ }
+
+ xVar = new SbxVariable;
+ xVar->PutLong( aDocPt.X() - aSttPt.X() );
+ xArgs->Put( &xVar, ++nPos );
+ xVar = new SbxVariable;
+ xVar->PutLong( aDocPt.Y() - aSttPt.Y() );
+ xArgs->Put( &xVar, ++nPos );
+
+ xVar = new SbxVariable;
+ xVar->PutUShort( 1 );
+ xArgs->Put( &xVar, ++nPos );
+
+ ReleaseMouse();
+
+ rSh.ExecMacro( *pMacro, 0, &xArgs );
+
+ CaptureMouse();
+ }
+ }
+ rSh.EndDrag( &aDocPt, false );
+ }
+ bFrmDrag = false;
+ bCallBase = false;
+ break;
+ }
+ bPopMode = true;
+ // no break
+ case MOUSE_LEFT + KEY_SHIFT:
+ if (rSh.IsSelFrmMode())
+ {
+
+ rSh.EndDrag( &aDocPt, false );
+ bFrmDrag = false;
+ bCallBase = false;
+ break;
+ }
+
+ if( bHoldSelection )
+ {
+ // the EndDrag should be called in any case
+ bHoldSelection = false;
+ rSh.EndDrag( &aDocPt, false );
+ }
+ else
+ {
+ SwContentAtPos aFieldAtPos ( SwContentAtPos::SW_FIELD );
+ if ( !rSh.IsInSelect() && rSh.ChgCurrPam( aDocPt ) && !rSh.GetContentAtPos( aDocPt, aFieldAtPos ) )
+ {
+ const bool bTmpNoInterrupt = bNoInterrupt;
+ bNoInterrupt = false;
+ { // create only temporary move context because otherwise
+ // the query to the content form doesn't work!!!
+ SwMvContext aMvContext( &rSh );
+ const Point aDocPos( PixelToLogic( m_aStartPos ) );
+ bValidCrsrPos = !(CRSR_POSCHG & rSh.SetCursor(&aDocPos, false));
+ }
+ bNoInterrupt = bTmpNoInterrupt;
+
+ }
+ else
+ {
+ sal_Bool bInSel = rSh.IsInSelect();
+ rSh.EndDrag( &aDocPt, false );
+
+ // Internetfield? --> call link (load doc!!)
+ if( !bInSel )
+ {
+ sal_uInt16 nFilter = URLLOAD_NOFILTER;
+ if( KEY_MOD1 == rMEvt.GetModifier() )
+ nFilter |= URLLOAD_NEWVIEW;
+
+ sal_Bool bExecHyperlinks = m_rView.GetDocShell()->IsReadOnly();
+ if ( !bExecHyperlinks )
+ {
+ SvtSecurityOptions aSecOpts;
+ const sal_Bool bSecureOption = aSecOpts.IsOptionSet( SvtSecurityOptions::E_CTRLCLICK_HYPERLINK );
+ if ( ( bSecureOption && rMEvt.GetModifier() == KEY_MOD1 ) ||
+ ( !bSecureOption && rMEvt.GetModifier() != KEY_MOD1 ) )
+ bExecHyperlinks = sal_True;
+ }
+
+ const bool bExecSmarttags = rMEvt.GetModifier() == KEY_MOD1;
+
+ if(m_pApplyTempl)
+ bExecHyperlinks = sal_False;
+
+ SwContentAtPos aCntntAtPos( SwContentAtPos::SW_FIELD |
+ SwContentAtPos::SW_INETATTR |
+ SwContentAtPos::SW_SMARTTAG | SwContentAtPos::SW_FORMCTRL);
+
+ if( rSh.GetContentAtPos( aDocPt, aCntntAtPos, sal_False ) )
+ {
+ // Do it again if we're not on a field/hyperlink to update the cursor accordingly
+ if ( SwContentAtPos::SW_FIELD != aCntntAtPos.eCntntAtPos
+ && SwContentAtPos::SW_INETATTR != aCntntAtPos.eCntntAtPos )
+ rSh.GetContentAtPos( aDocPt, aCntntAtPos, sal_True );
+
+ sal_Bool bViewLocked = rSh.IsViewLocked();
+ if( !bViewLocked && !rSh.IsReadOnlyAvailable() &&
+ aCntntAtPos.IsInProtectSect() )
+ rSh.LockView( sal_True );
+
+ ReleaseMouse();
+
+ if( SwContentAtPos::SW_FIELD == aCntntAtPos.eCntntAtPos )
+ {
+ bool bAddMode(false);
+ // AdditionalMode if applicable
+ if (KEY_MOD1 == rMEvt.GetModifier()
+ && !rSh.IsAddMode())
+ {
+ bAddMode = true;
+ rSh.EnterAddMode();
+ }
+ if ( aCntntAtPos.pFndTxtAttr != NULL
+ && aCntntAtPos.pFndTxtAttr->Which() == RES_TXTATR_INPUTFIELD )
+ {
+ // select content of Input Field, but exclude CH_TXT_ATR_INPUTFIELDSTART
+ // and CH_TXT_ATR_INPUTFIELDEND
+ rSh.SttSelect();
+ rSh.SelectTxt( *(aCntntAtPos.pFndTxtAttr->GetStart()) + 1,
+ *(aCntntAtPos.pFndTxtAttr->End()) - 1 );
+ }
+ else
+ {
+ rSh.ClickToField( *aCntntAtPos.aFnd.pFld );
+ }
+ // a bit of a mystery what this is good for?
+ // in this case we assume it's valid since we
+ // just selected a field
+ bValidCrsrPos = true;
+ if (bAddMode)
+ {
+ rSh.LeaveAddMode();
+ }
+ }
+ else if ( SwContentAtPos::SW_SMARTTAG == aCntntAtPos.eCntntAtPos )
+ {
+ // execute smarttag menu
+ if ( bExecSmarttags && SwSmartTagMgr::Get().IsSmartTagsEnabled() )
+ m_rView.ExecSmartTagPopup( aDocPt );
+ }
+ else if ( SwContentAtPos::SW_FORMCTRL == aCntntAtPos.eCntntAtPos )
+ {
+ OSL_ENSURE( aCntntAtPos.aFnd.pFldmark != NULL, "where is my field ptr???");
+ if ( aCntntAtPos.aFnd.pFldmark != NULL)
+ {
+ IFieldmark *fieldBM = const_cast< IFieldmark* > ( aCntntAtPos.aFnd.pFldmark );
+ if ( fieldBM->GetFieldname( ) == ODF_FORMCHECKBOX )
+ {
+ ICheckboxFieldmark* pCheckboxFm = dynamic_cast<ICheckboxFieldmark*>(fieldBM);
+ pCheckboxFm->SetChecked(!pCheckboxFm->IsChecked());
+ pCheckboxFm->Invalidate();
+ rSh.InvalidateWindows( m_rView.GetVisArea() );
+ } else if ( fieldBM->GetFieldname() == ODF_FORMDROPDOWN ) {
+ m_rView.ExecFieldPopup( aDocPt, fieldBM );
+ fieldBM->Invalidate();
+ rSh.InvalidateWindows( m_rView.GetVisArea() );
+ } else {
+ // unknown type..
+ }
+ }
+ }
+ else if ( SwContentAtPos::SW_INETATTR == aCntntAtPos.eCntntAtPos )
+ {
+ if ( bExecHyperlinks && aCntntAtPos.aFnd.pAttr )
+ rSh.ClickToINetAttr( *(SwFmtINetFmt*)aCntntAtPos.aFnd.pAttr, nFilter );
+ }
+
+ rSh.LockView( bViewLocked );
+ bCallShadowCrsr = sal_False;
+ }
+ else
+ {
+ aCntntAtPos = SwContentAtPos( SwContentAtPos::SW_FTN );
+ if( !rSh.GetContentAtPos( aDocPt, aCntntAtPos, sal_True ) && bExecHyperlinks )
+ {
+ SdrViewEvent aVEvt;
+
+ if (pSdrView)
+ pSdrView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
+
+ if (pSdrView && aVEvt.eEvent == SDREVENT_EXECUTEURL)
+ {
+ // hit URL field
+ const SvxURLField *pField = aVEvt.pURLField;
+ if (pField)
+ {
+ OUString sURL(pField->GetURL());
+ OUString sTarget(pField->GetTargetFrame());
+ ::LoadURL(rSh, sURL, nFilter, sTarget);
+ }
+ bCallShadowCrsr = sal_False;
+ }
+ else
+ {
+ // hit graphic
+ ReleaseMouse();
+ if( rSh.ClickToINetGrf( aDocPt, nFilter ))
+ bCallShadowCrsr = sal_False;
+ }
+ }
+ }
+
+ if( bCallShadowCrsr &&
+ rSh.GetViewOptions()->IsShadowCursor() &&
+ MOUSE_LEFT == (rMEvt.GetModifier() + rMEvt.GetButtons()) &&
+ !rSh.HasSelection() &&
+ !GetConnectMetaFile() &&
+ rSh.VisArea().IsInside( aDocPt ))
+ {
+ SwUndoId nLastUndoId(UNDO_EMPTY);
+ if (rSh.GetLastUndoInfo(0, & nLastUndoId))
+ {
+ if (UNDO_INS_FROM_SHADOWCRSR == nLastUndoId)
+ {
+ rSh.Undo();
+ }
+ }
+ SwFillMode eMode = (SwFillMode)rSh.GetViewOptions()->GetShdwCrsrFillMode();
+ rSh.SetShadowCrsrPos( aDocPt, eMode );
+ }
+ }
+ }
+ bCallBase = false;
+
+ }
+
+ // reset pushed mode in Down again if applicable
+ if ( bPopMode && bModePushed )
+ {
+ rSh.PopMode();
+ bModePushed = false;
+ bCallBase = false;
+ }
+ break;
+
+ default:
+ ReleaseMouse();
+ return;
+ }
+
+ if( m_pApplyTempl )
+ {
+ int eSelection = rSh.GetSelectionType();
+ SwFormatClipboard* pFormatClipboard = m_pApplyTempl->m_pFormatClipboard;
+ if( pFormatClipboard )//apply format paintbrush
+ {
+ //get some parameters
+ SwWrtShell& rWrtShell = m_rView.GetWrtShell();
+ SfxStyleSheetBasePool* pPool=0;
+ bool bNoCharacterFormats = false;
+ bool bNoParagraphFormats = true;
+ {
+ SwDocShell* pDocSh = m_rView.GetDocShell();
+ if(pDocSh)
+ pPool = pDocSh->GetStyleSheetPool();
+ if( (rMEvt.GetModifier()&KEY_MOD1) && (rMEvt.GetModifier()&KEY_SHIFT) )
+ {
+ bNoCharacterFormats = true;
+ bNoParagraphFormats = false;
+ }
+ else if( rMEvt.GetModifier() & KEY_MOD1 )
+ bNoParagraphFormats = false;
+ }
+ //execute paste
+ pFormatClipboard->Paste( rWrtShell, pPool, bNoCharacterFormats, bNoParagraphFormats );
+
+ //if the clipboard is empty after paste remove the ApplyTemplate
+ if(!pFormatClipboard->HasContent())
+ SetApplyTemplate(SwApplyTemplate());
+ }
+ else if( m_pApplyTempl->nColor )
+ {
+ sal_uInt16 nId = 0;
+ switch( m_pApplyTempl->nColor )
+ {
+ case SID_ATTR_CHAR_COLOR_EXT:
+ case SID_ATTR_CHAR_COLOR2:
+ nId = RES_CHRATR_COLOR;
+ break;
+ case SID_ATTR_CHAR_COLOR_BACKGROUND_EXT:
+ case SID_ATTR_CHAR_COLOR_BACKGROUND:
+ nId = RES_CHRATR_BACKGROUND;
+ break;
+ }
+ if( nId && (nsSelectionType::SEL_TXT|nsSelectionType::SEL_TBL) & eSelection)
+ {
+ if( rSh.IsSelection() && !rSh.HasReadonlySel() )
+ {
+ if(nId == RES_CHRATR_BACKGROUND)
+ {
+ Color aColor( COL_TRANSPARENT );
+ if( !SwEditWin::m_bTransparentBackColor )
+ aColor = SwEditWin::m_aTextBackColor;
+ rSh.SetAttrItem( SvxBrushItem( aColor, nId ) );
+ }
+ else
+ rSh.SetAttrItem( SvxColorItem(SwEditWin::m_aTextColor, nId) );
+ rSh.UnSetVisCrsr();
+ rSh.EnterStdMode();
+ rSh.SetVisCrsr(aDocPt);
+
+ m_pApplyTempl->bUndo = true;
+ bCallBase = false;
+ m_aTemplateTimer.Stop();
+ }
+ else if(rMEvt.GetClicks() == 1)
+ {
+ // no selection -> so turn off watering can
+ m_aTemplateTimer.Start();
+ }
+ }
+ }
+ else
+ {
+ OUString aStyleName;
+ switch ( m_pApplyTempl->eType )
+ {
+ case SFX_STYLE_FAMILY_PARA:
+ if( (( nsSelectionType::SEL_TXT | nsSelectionType::SEL_TBL )
+ & eSelection ) && !rSh.HasReadonlySel() )
+ {
+ rSh.SetTxtFmtColl( m_pApplyTempl->aColl.pTxtColl );
+ m_pApplyTempl->bUndo = true;
+ bCallBase = false;
+ if ( m_pApplyTempl->aColl.pTxtColl )
+ aStyleName = m_pApplyTempl->aColl.pTxtColl->GetName();
+ }
+ break;
+ case SFX_STYLE_FAMILY_CHAR:
+ if( (( nsSelectionType::SEL_TXT | nsSelectionType::SEL_TBL )
+ & eSelection ) && !rSh.HasReadonlySel() )
+ {
+ rSh.SetAttrItem( SwFmtCharFmt(m_pApplyTempl->aColl.pCharFmt) );
+ rSh.UnSetVisCrsr();
+ rSh.EnterStdMode();
+ rSh.SetVisCrsr(aDocPt);
+ m_pApplyTempl->bUndo = true;
+ bCallBase = false;
+ if ( m_pApplyTempl->aColl.pCharFmt )
+ aStyleName = m_pApplyTempl->aColl.pCharFmt->GetName();
+ }
+ break;
+ case SFX_STYLE_FAMILY_FRAME :
+ {
+ const SwFrmFmt* pFmt = rSh.GetFmtFromObj( aDocPt );
+ if(PTR_CAST(SwFlyFrmFmt, pFmt))
+ {
+ rSh.SetFrmFmt( m_pApplyTempl->aColl.pFrmFmt, false, &aDocPt );
+ m_pApplyTempl->bUndo = true;
+ bCallBase = false;
+ if( m_pApplyTempl->aColl.pFrmFmt )
+ aStyleName = m_pApplyTempl->aColl.pFrmFmt->GetName();
+ }
+ break;
+ }
+ case SFX_STYLE_FAMILY_PAGE:
+ // no Undo with page templates
+ rSh.ChgCurPageDesc( *m_pApplyTempl->aColl.pPageDesc );
+ if ( m_pApplyTempl->aColl.pPageDesc )
+ aStyleName = m_pApplyTempl->aColl.pPageDesc->GetName();
+ bCallBase = false;
+ break;
+ case SFX_STYLE_FAMILY_PSEUDO:
+ if( !rSh.HasReadonlySel() )
+ {
+ rSh.SetCurNumRule( *m_pApplyTempl->aColl.pNumRule,
+ false,
+ m_pApplyTempl->aColl.pNumRule->GetDefaultListId() );
+ bCallBase = false;
+ m_pApplyTempl->bUndo = true;
+ if( m_pApplyTempl->aColl.pNumRule )
+ aStyleName = m_pApplyTempl->aColl.pNumRule->GetName();
+ }
+ break;
+ }
+
+ uno::Reference< frame::XDispatchRecorder > xRecorder =
+ m_rView.GetViewFrame()->GetBindings().GetRecorder();
+ if ( !aStyleName.isEmpty() && xRecorder.is() )
+ {
+ SfxShell *pSfxShell = lcl_GetShellFromDispatcher( m_rView, TYPE(SwTextShell) );
+ if ( pSfxShell )
+ {
+ SfxRequest aReq( m_rView.GetViewFrame(), SID_STYLE_APPLY );
+ aReq.AppendItem( SfxStringItem( SID_STYLE_APPLY, aStyleName ) );
+ aReq.AppendItem( SfxUInt16Item( SID_STYLE_FAMILY, (sal_uInt16) m_pApplyTempl->eType ) );
+ aReq.Done();
+ }
+ }
+ }
+
+ }
+ ReleaseMouse();
+ // Only processed MouseEvents arrive here; only at these the moduses can
+ // be resetted.
+ m_bMBPressed = sal_False;
+
+ // Make this call just to be sure. Selecting has finished surely by now.
+ // Otherwise the timeout's timer could give problems.
+ EnterArea();
+ bNoInterrupt = false;
+
+ if (bCallBase)
+ Window::MouseButtonUp(rMEvt);
+}
+
+/**
+ * Apply template
+ */
+void SwEditWin::SetApplyTemplate(const SwApplyTemplate &rTempl)
+{
+ static sal_Bool bIdle = sal_False;
+ DELETEZ(m_pApplyTempl);
+ SwWrtShell &rSh = m_rView.GetWrtShell();
+
+ if(rTempl.m_pFormatClipboard)
+ {
+ m_pApplyTempl = new SwApplyTemplate( rTempl );
+ SetPointer( POINTER_FILL );//@todo #i20119# maybe better a new brush pointer here in future
+ rSh.NoEdit( false );
+ bIdle = rSh.GetViewOptions()->IsIdle();
+ ((SwViewOption *)rSh.GetViewOptions())->SetIdle( sal_False );
+ }
+ else if(rTempl.nColor)
+ {
+ m_pApplyTempl = new SwApplyTemplate( rTempl );
+ SetPointer( POINTER_FILL );
+ rSh.NoEdit( false );
+ bIdle = rSh.GetViewOptions()->IsIdle();
+ ((SwViewOption *)rSh.GetViewOptions())->SetIdle( sal_False );
+ }
+ else if( rTempl.eType )
+ {
+ m_pApplyTempl = new SwApplyTemplate( rTempl );
+ SetPointer( POINTER_FILL );
+ rSh.NoEdit( false );
+ bIdle = rSh.GetViewOptions()->IsIdle();
+ ((SwViewOption *)rSh.GetViewOptions())->SetIdle( sal_False );
+ }
+ else
+ {
+ SetPointer( POINTER_TEXT );
+ rSh.UnSetVisCrsr();
+
+ ((SwViewOption *)rSh.GetViewOptions())->SetIdle( bIdle );
+ if ( !rSh.IsSelFrmMode() )
+ rSh.Edit();
+ }
+
+ static sal_uInt16 aInva[] =
+ {
+ SID_STYLE_WATERCAN,
+ SID_ATTR_CHAR_COLOR_EXT,
+ SID_ATTR_CHAR_COLOR_BACKGROUND_EXT,
+ 0
+ };
+ m_rView.GetViewFrame()->GetBindings().Invalidate(aInva);
+}
+
+/**
+ * Ctor
+ */
+SwEditWin::SwEditWin(Window *pParent, SwView &rMyView):
+ Window(pParent, WinBits(WB_CLIPCHILDREN | WB_DIALOGCONTROL)),
+ DropTargetHelper( this ),
+ DragSourceHelper( this ),
+
+ m_eBufferLanguage(LANGUAGE_DONTKNOW),
+ m_pApplyTempl(0),
+ m_pAnchorMarker( 0 ),
+ m_pUserMarker( 0 ),
+ m_pUserMarkerObj( 0 ),
+ m_pShadCrsr( 0 ),
+ m_pRowColumnSelectionStart( 0 ),
+
+ m_rView( rMyView ),
+
+ m_aActHitType(SDRHIT_NONE),
+ m_nDropFormat( 0 ),
+ m_nDropAction( 0 ),
+ m_nDropDestination( 0 ),
+
+ m_eBezierMode(SID_BEZIER_INSERT),
+ m_nInsFrmColCount( 1 ),
+ m_eDrawMode(OBJ_NONE),
+
+ m_bMBPressed(false),
+ m_bInsDraw(false),
+ m_bInsFrm(false),
+ m_bIsInMove(false),
+ m_bIsInDrag(false),
+ m_bOldIdle(false),
+ m_bOldIdleSet(false),
+ m_bTblInsDelMode(false),
+ m_bTblIsInsMode(false),
+ m_bChainMode(false),
+ m_bWasShdwCrsr(false),
+ m_bLockInput(false),
+ m_bIsRowDrag(false),
+ m_bUseInputLanguage(false),
+ m_bObjectSelect(false),
+ m_nKS_NUMDOWN_Count(0),
+ m_nKS_NUMINDENTINC_Count(0),
+ m_aFrameControlsManager( this )
+{
+ SetHelpId(HID_EDIT_WIN);
+ EnableChildTransparentMode();
+ SetDialogControlFlags( WINDOW_DLGCTRL_RETURN | WINDOW_DLGCTRL_WANTFOCUS );
+
+ m_bMBPressed = m_bInsDraw = m_bInsFrm =
+ m_bIsInDrag = m_bOldIdle = m_bOldIdleSet = m_bChainMode = m_bWasShdwCrsr = sal_False;
+ // initially use the input language
+ m_bUseInputLanguage = sal_True;
+
+ SetMapMode(MapMode(MAP_TWIP));
+
+ SetPointer( POINTER_TEXT );
+ m_aTimer.SetTimeoutHdl(LINK(this, SwEditWin, TimerHandler));
+
+ m_bTblInsDelMode = sal_False;
+ m_aKeyInputTimer.SetTimeout( 3000 );
+ m_aKeyInputTimer.SetTimeoutHdl(LINK(this, SwEditWin, KeyInputTimerHandler));
+
+ m_aKeyInputFlushTimer.SetTimeout( 200 );
+ m_aKeyInputFlushTimer.SetTimeoutHdl(LINK(this, SwEditWin, KeyInputFlushHandler));
+
+ // TemplatePointer for colors should be resetted without
+ // selection after single click
+ m_aTemplateTimer.SetTimeout(400);
+ m_aTemplateTimer.SetTimeoutHdl(LINK(this, SwEditWin, TemplateTimerHdl));
+
+ // temporary solution!!! Should set the font of the current
+ // insert position at every curor movement!
+ if( !rMyView.GetDocShell()->IsReadOnly() )
+ {
+ Font aFont;
+ SetInputContext( InputContext( aFont, INPUTCONTEXT_TEXT |
+ INPUTCONTEXT_EXTTEXTINPUT ) );
+ }
+}
+
+SwEditWin::~SwEditWin()
+{
+ m_aKeyInputTimer.Stop();
+ delete m_pShadCrsr;
+ delete m_pRowColumnSelectionStart;
+ if( m_pQuickHlpData->m_bIsDisplayed && m_rView.GetWrtShellPtr() )
+ m_pQuickHlpData->Stop( m_rView.GetWrtShell() );
+ bExecuteDrag = false;
+ delete m_pApplyTempl;
+ m_rView.SetDrawFuncPtr(NULL);
+
+ delete m_pUserMarker;
+ delete m_pAnchorMarker;
+}
+
+/**
+ * Turn on DrawTextEditMode
+ */
+void SwEditWin::EnterDrawTextMode( const Point& aDocPos )
+{
+ if ( m_rView.EnterDrawTextMode(aDocPos) == sal_True )
+ {
+ if (m_rView.GetDrawFuncPtr())
+ {
+ m_rView.GetDrawFuncPtr()->Deactivate();
+ m_rView.SetDrawFuncPtr(NULL);
+ m_rView.LeaveDrawCreate();
+ }
+ m_rView.NoRotate();
+ m_rView.AttrChangedNotify( &m_rView.GetWrtShell() );
+ }
+}
+
+/**
+ * Turn on DrawMode
+ */
+sal_Bool SwEditWin::EnterDrawMode(const MouseEvent& rMEvt, const Point& aDocPos)
+{
+ SwWrtShell &rSh = m_rView.GetWrtShell();
+ SdrView *pSdrView = rSh.GetDrawView();
+
+ if ( m_rView.GetDrawFuncPtr() )
+ {
+ if (rSh.IsDrawCreate())
+ return sal_True;
+
+ sal_Bool bRet = m_rView.GetDrawFuncPtr()->MouseButtonDown( rMEvt );
+ m_rView.AttrChangedNotify( &rSh );
+ return bRet;
+ }
+
+ if ( pSdrView && pSdrView->IsTextEdit() )
+ {
+ bool bUnLockView = !rSh.IsViewLocked();
+ rSh.LockView( sal_True );
+
+ rSh.EndTextEdit(); // clicked aside, end Edit
+ rSh.SelectObj( aDocPos );
+ if ( !rSh.IsObjSelected() && !rSh.IsFrmSelected() )
+ rSh.LeaveSelFrmMode();
+ else
+ {
+ SwEditWin::m_nDDStartPosY = aDocPos.Y();
+ SwEditWin::m_nDDStartPosX = aDocPos.X();
+ bFrmDrag = true;
+ }
+ if( bUnLockView )
+ rSh.LockView( sal_False );
+ m_rView.AttrChangedNotify( &rSh );
+ return sal_True;
+ }
+ return sal_False;
+}
+
+sal_Bool SwEditWin::IsDrawSelMode()
+{
+ return IsObjectSelect();
+}
+
+void SwEditWin::GetFocus()
+{
+ if ( m_rView.GetPostItMgr()->HasActiveSidebarWin() )
+ {
+ m_rView.GetPostItMgr()->GrabFocusOnActiveSidebarWin();
+ }
+ else
+ {
+ m_rView.GotFocus();
+ Window::GetFocus();
+ m_rView.GetWrtShell().InvalidateAccessibleFocus();
+ }
+}
+
+void SwEditWin::LoseFocus()
+{
+ m_rView.GetWrtShell().InvalidateAccessibleFocus();
+ Window::LoseFocus();
+ if( m_pQuickHlpData->m_bIsDisplayed )
+ m_pQuickHlpData->Stop( m_rView.GetWrtShell() );
+ m_rView.LostFocus();
+}
+
+void SwEditWin::Command( const CommandEvent& rCEvt )
+{
+ SwWrtShell &rSh = m_rView.GetWrtShell();
+
+ if ( !m_rView.GetViewFrame() )
+ {
+ // If ViewFrame dies shortly, no popup anymore!
+ Window::Command(rCEvt);
+ return;
+ }
+
+ // The command event is send to the window after a possible context
+ // menu from an inplace client has been closed. Now we have the chance
+ // to deactivate the inplace client without any problem regarding parent
+ // windows and code on the stack.
+ SfxInPlaceClient* pIPClient = rSh.GetSfxViewShell()->GetIPClient();
+ bool bIsOleActive = ( pIPClient && pIPClient->IsObjectInPlaceActive() );
+ if ( bIsOleActive && ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU ))
+ {
+ rSh.FinishOLEObj();
+ return;
+ }
+
+ bool bCallBase = true;
+
+ switch ( rCEvt.GetCommand() )
+ {
+ case COMMAND_CONTEXTMENU:
+ {
+ const sal_uInt16 nId = SwInputChild::GetChildWindowId();
+ SwInputChild* pChildWin = (SwInputChild*)GetView().GetViewFrame()->
+ GetChildWindow( nId );
+
+ if (m_rView.GetPostItMgr()->IsHit(rCEvt.GetMousePosPixel()))
+ return;
+
+ Point aDocPos( PixelToLogic( rCEvt.GetMousePosPixel() ) );
+ if ( !rCEvt.IsMouseEvent() )
+ aDocPos = rSh.GetCharRect().Center();
+
+ // Don't trigger the command on a frame anchored to header/footer is not editing it
+ FrameControlType eControl;
+ bool bOverFly = false;
+ bool bPageAnchored = false;
+ bool bOverHeaderFooterFly = IsOverHeaderFooterFly( aDocPos, eControl, bOverFly, bPageAnchored );
+ // !bOverHeaderFooterFly doesn't mean we have a frame to select
+ if ( !bPageAnchored && rCEvt.IsMouseEvent( ) &&
+ ( ( rSh.IsHeaderFooterEdit( ) && !bOverHeaderFooterFly && bOverFly ) ||
+ ( !rSh.IsHeaderFooterEdit( ) && bOverHeaderFooterFly ) ) )
+ {
+ return;
+ }
+
+ if((!pChildWin || pChildWin->GetView() != &m_rView) &&
+ !rSh.IsDrawCreate() && !IsDrawAction())
+ {
+ SET_CURR_SHELL( &rSh );
+ if (!m_pApplyTempl)
+ {
+ if (bNoInterrupt)
+ {
+ ReleaseMouse();
+ bNoInterrupt = false;
+ m_bMBPressed = sal_False;
+ }
+ if ( rCEvt.IsMouseEvent() )
+ {
+ SelectMenuPosition(rSh, rCEvt.GetMousePosPixel());
+ m_rView.StopShellTimer();
+ }
+ const Point aPixPos = LogicToPixel( aDocPos );
+
+ if ( m_rView.GetDocShell()->IsReadOnly() )
+ {
+ SwReadOnlyPopup* pROPopup = new SwReadOnlyPopup( aDocPos, m_rView );
+
+ ui::ContextMenuExecuteEvent aEvent;
+ aEvent.SourceWindow = VCLUnoHelper::GetInterface( this );
+ aEvent.ExecutePosition.X = aPixPos.X();
+ aEvent.ExecutePosition.Y = aPixPos.Y();
+ Menu* pMenu = 0;
+ OUString sMenuName("private:resource/ReadonlyContextMenu");
+ if( GetView().TryContextMenuInterception( *pROPopup, sMenuName, pMenu, aEvent ) )
+ {
+ if ( pMenu )
+ {
+ sal_uInt16 nExecId = ((PopupMenu*)pMenu)->Execute(this, aPixPos);
+ if( !::ExecuteMenuCommand( *static_cast<PopupMenu*>(pMenu), *m_rView.GetViewFrame(), nExecId ))
+ pROPopup->Execute(this, nExecId);
+ }
+ else
+ pROPopup->Execute(this, aPixPos);
+ }
+ delete pROPopup;
+ }
+ else if ( !m_rView.ExecSpellPopup( aDocPos ) )
+ GetView().GetViewFrame()->GetDispatcher()->ExecutePopup( 0, this, &aPixPos);
+ }
+ else if (m_pApplyTempl->bUndo)
+ rSh.Do(SwWrtShell::UNDO);
+ bCallBase = false;
+ }
+ }
+ break;
+
+ case COMMAND_WHEEL:
+ case COMMAND_STARTAUTOSCROLL:
+ case COMMAND_AUTOSCROLL:
+ if( m_pShadCrsr )
+ delete m_pShadCrsr, m_pShadCrsr = 0;
+ bCallBase = !m_rView.HandleWheelCommands( rCEvt );
+ break;
+
+ case COMMAND_STARTEXTTEXTINPUT:
+ {
+ bool bIsDocReadOnly = m_rView.GetDocShell()->IsReadOnly() &&
+ rSh.IsCrsrReadonly();
+ if(!bIsDocReadOnly)
+ {
+ if( rSh.HasDrawView() && rSh.GetDrawView()->IsTextEdit() )
+ {
+ bCallBase = false;
+ rSh.GetDrawView()->GetTextEditOutlinerView()->Command( rCEvt );
+ }
+ else
+ {
+ if( rSh.HasSelection() )
+ rSh.DelRight();
+
+ bCallBase = false;
+ LanguageType eInputLanguage = GetInputLanguage();
+ rSh.CreateExtTextInput(eInputLanguage);
+ }
+ }
+ break;
+ }
+ case COMMAND_ENDEXTTEXTINPUT:
+ {
+ bool bIsDocReadOnly = m_rView.GetDocShell()->IsReadOnly() &&
+ rSh.IsCrsrReadonly();
+ if(!bIsDocReadOnly)
+ {
+ if( rSh.HasDrawView() && rSh.GetDrawView()->IsTextEdit() )
+ {
+ bCallBase = false;
+ rSh.GetDrawView()->GetTextEditOutlinerView()->Command( rCEvt );
+ }
+ else
+ {
+ bCallBase = false;
+ OUString sRecord = rSh.DeleteExtTextInput();
+ uno::Reference< frame::XDispatchRecorder > xRecorder =
+ m_rView.GetViewFrame()->GetBindings().GetRecorder();
+
+ if ( !sRecord.isEmpty() )
+ {
+ // convert quotes in IME text
+ // works on the last input character, this is escpecially in Korean text often done
+ // quotes that are inside of the string are not replaced!
+ const sal_Unicode aCh = sRecord[sRecord.getLength() - 1];
+ SvxAutoCorrCfg& rACfg = SvxAutoCorrCfg::Get();
+ SvxAutoCorrect* pACorr = rACfg.GetAutoCorrect();
+ if(pACorr &&
+ (( pACorr->IsAutoCorrFlag( ChgQuotes ) && ('\"' == aCh ))||
+ ( pACorr->IsAutoCorrFlag( ChgSglQuotes ) && ( '\'' == aCh))))
+ {
+ rSh.DelLeft();
+ rSh.AutoCorrect( *pACorr, aCh );
+ }
+
+ if ( xRecorder.is() )
+ {
+ // determine Shell
+ SfxShell *pSfxShell = lcl_GetShellFromDispatcher( m_rView, TYPE(SwTextShell) );
+ // generate request and record
+ if (pSfxShell)
+ {
+ SfxRequest aReq( m_rView.GetViewFrame(), FN_INSERT_STRING );
+ aReq.AppendItem( SfxStringItem( FN_INSERT_STRING, sRecord ) );
+ aReq.Done();
+ }
+ }
+ }
+ }
+ }
+ }
+ break;
+ case COMMAND_EXTTEXTINPUT:
+ {
+ bool bIsDocReadOnly = m_rView.GetDocShell()->IsReadOnly() &&
+ rSh.IsCrsrReadonly();
+ if(!bIsDocReadOnly)
+ {
+ if( m_pQuickHlpData->m_bIsDisplayed )
+ m_pQuickHlpData->Stop( rSh );
+
+ OUString sWord;
+ if( rSh.HasDrawView() && rSh.GetDrawView()->IsTextEdit() )
+ {
+ bCallBase = false;
+ rSh.GetDrawView()->GetTextEditOutlinerView()->Command( rCEvt );
+ }
+ else
+ {
+ const CommandExtTextInputData* pData = rCEvt.GetExtTextInputData();
+ if( pData )
+ {
+ sWord = pData->GetText();
+ bCallBase = false;
+ rSh.SetExtTextInputData( *pData );
+ }
+ }
+ uno::Reference< frame::XDispatchRecorder > xRecorder =
+ m_rView.GetViewFrame()->GetBindings().GetRecorder();
+ if(!xRecorder.is())
+ {
+ SvxAutoCorrCfg& rACfg = SvxAutoCorrCfg::Get();
+ SvxAutoCorrect* pACorr = rACfg.GetAutoCorrect();
+ if( pACorr &&
+ // If autocompletion required...
+ ( rACfg.IsAutoTextTip() ||
+ pACorr->GetSwFlags().bAutoCompleteWords ) &&
+ // ... and extraction of last word from text input was successful...
+ rSh.GetPrevAutoCorrWord( *pACorr, sWord ) )
+ {
+ // ... request for auto completion help to be shown.
+ ShowAutoTextCorrectQuickHelp(sWord, &rACfg, pACorr, true);
+ }
+ }
+ }
+ }
+ break;
+ case COMMAND_CURSORPOS:
+ // will be handled by the base class
+ break;
+
+ case COMMAND_PASTESELECTION:
+ if( !m_rView.GetDocShell()->IsReadOnly() )
+ {
+ TransferableDataHelper aDataHelper(
+ TransferableDataHelper::CreateFromSelection( this ));
+ if( !aDataHelper.GetXTransferable().is() )
+ break;
+
+ sal_uLong nDropFormat;
+ sal_uInt16 nEventAction, nDropAction, nDropDestination;
+ nDropDestination = GetDropDestination( rCEvt.GetMousePosPixel() );
+ if( !nDropDestination )
+ break;
+
+ nDropAction = SotExchange::GetExchangeAction(
+ aDataHelper.GetDataFlavorExVector(),
+ nDropDestination, EXCHG_IN_ACTION_COPY,
+ EXCHG_IN_ACTION_COPY, nDropFormat,
+ nEventAction );
+ if( EXCHG_INOUT_ACTION_NONE != nDropAction )
+ {
+ const Point aDocPt( PixelToLogic( rCEvt.GetMousePosPixel() ) );
+ SwTransferable::PasteData( aDataHelper, rSh, nDropAction,
+ nDropFormat, nDropDestination, sal_False,
+ sal_False, &aDocPt, EXCHG_IN_ACTION_COPY,
+ sal_True );
+ }
+ }
+ break;
+ case COMMAND_MODKEYCHANGE :
+ {
+ const CommandModKeyData* pCommandData = (const CommandModKeyData*)rCEvt.GetData();
+ if(pCommandData->IsMod1() && !pCommandData->IsMod2())
+ {
+ sal_uInt16 nSlot = 0;
+ if(pCommandData->IsLeftShift() && !pCommandData->IsRightShift())
+ nSlot = SID_ATTR_PARA_LEFT_TO_RIGHT;
+ else if(!pCommandData->IsLeftShift() && pCommandData->IsRightShift())
+ nSlot = SID_ATTR_PARA_RIGHT_TO_LEFT;
+ if(nSlot && SW_MOD()->GetCTLOptions().IsCTLFontEnabled())
+ GetView().GetViewFrame()->GetDispatcher()->Execute(nSlot);
+ }
+ }
+ break;
+ case COMMAND_HANGUL_HANJA_CONVERSION :
+ GetView().GetViewFrame()->GetDispatcher()->Execute(SID_HANGUL_HANJA_CONVERSION);
+ break;
+ case COMMAND_INPUTLANGUAGECHANGE :
+ // i#42732 - update state of fontname if input language changes
+ bInputLanguageSwitched = true;
+ SetUseInputLanguage( sal_True );
+ break;
+ case COMMAND_SELECTIONCHANGE:
+ {
+ const CommandSelectionChangeData *pData = rCEvt.GetSelectionChangeData();
+ rSh.SttCrsrMove();
+ rSh.GoStartSentence();
+ rSh.GetCrsr()->GetPoint()->nContent += sal::static_int_cast<sal_uInt16, sal_uLong>(pData->GetStart());
+ rSh.SetMark();
+ rSh.GetCrsr()->GetMark()->nContent += sal::static_int_cast<sal_uInt16, sal_uLong>(pData->GetEnd() - pData->GetStart());
+ rSh.EndCrsrMove( sal_True );
+ }
+ break;
+ case COMMAND_PREPARERECONVERSION:
+ if( rSh.HasSelection() )
+ {
+ SwPaM *pCrsr = (SwPaM*)rSh.GetCrsr();
+
+ if( rSh.IsMultiSelection() )
+ {
+ if( pCrsr && !pCrsr->HasMark() &&
+ pCrsr->GetPoint() == pCrsr->GetMark() )
+ {
+ rSh.GoPrevCrsr();
+ pCrsr = (SwPaM*)rSh.GetCrsr();
+ }
+
+ // Cancel all selections other than the last selected one.
+ while( rSh.GetCrsr()->GetNext() != rSh.GetCrsr() )
+ delete rSh.GetCrsr()->GetNext();
+ }
+
+ if( pCrsr )
+ {
+ sal_uLong nPosNodeIdx = pCrsr->GetPoint()->nNode.GetIndex();
+ const sal_Int32 nPosIdx = pCrsr->GetPoint()->nContent.GetIndex();
+ sal_uLong nMarkNodeIdx = pCrsr->GetMark()->nNode.GetIndex();
+ const sal_Int32 nMarkIdx = pCrsr->GetMark()->nContent.GetIndex();
+
+ if( !rSh.GetCrsr()->HasMark() )
+ rSh.GetCrsr()->SetMark();
+
+ rSh.SttCrsrMove();
+
+ if( nPosNodeIdx < nMarkNodeIdx )
+ {
+ rSh.GetCrsr()->GetPoint()->nNode = nPosNodeIdx;
+ rSh.GetCrsr()->GetPoint()->nContent = nPosIdx;
+ rSh.GetCrsr()->GetMark()->nNode = nPosNodeIdx;
+ rSh.GetCrsr()->GetMark()->nContent =
+ rSh.GetCrsr()->GetCntntNode( true )->Len();
+ }
+ else if( nPosNodeIdx == nMarkNodeIdx )
+ {
+ rSh.GetCrsr()->GetPoint()->nNode = nPosNodeIdx;
+ rSh.GetCrsr()->GetPoint()->nContent = nPosIdx;
+ rSh.GetCrsr()->GetMark()->nNode = nMarkNodeIdx;
+ rSh.GetCrsr()->GetMark()->nContent = nMarkIdx;
+ }
+ else
+ {
+ rSh.GetCrsr()->GetMark()->nNode = nMarkNodeIdx;
+ rSh.GetCrsr()->GetMark()->nContent = nMarkIdx;
+ rSh.GetCrsr()->GetPoint()->nNode = nMarkNodeIdx;
+ rSh.GetCrsr()->GetPoint()->nContent =
+ rSh.GetCrsr()->GetCntntNode( false )->Len();
+ }
+
+ rSh.EndCrsrMove( sal_True );
+ }
+ }
+ break;
+ case COMMAND_QUERYCHARPOSITION:
+ {
+ sal_Bool bVertical = rSh.IsInVerticalText();
+ const SwPosition& rPos = *rSh.GetCrsr()->GetPoint();
+ SwDocShell* pDocSh = m_rView.GetDocShell();
+ SwDoc *pDoc = pDocSh->GetDoc();
+ SwExtTextInput* pInput = pDoc->GetExtTextInput( rPos.nNode.GetNode(), rPos.nContent.GetIndex() );
+ if ( pInput )
+ {
+ const SwPosition& rStart = *pInput->Start();
+ const SwPosition& rEnd = *pInput->End();
+ int nSize = 0;
+ for ( SwIndex nIndex = rStart.nContent; nIndex < rEnd.nContent; ++nIndex )
+ {
+ ++nSize;
+ }
+ Window& rWin = rSh.GetView().GetEditWin();
+ if ( nSize == 0 )
+ {
+ // When the composition does not exist, use Caret rect instead.
+ SwRect aCaretRect ( rSh.GetCharRect() );
+ Rectangle aRect( aCaretRect.Left(), aCaretRect.Top(), aCaretRect.Right(), aCaretRect.Bottom() );
+ rWin.SetCompositionCharRect( &aRect, 1, bVertical );
+ }
+ else
+ {
+ Rectangle* aRects = new Rectangle[ nSize ];
+ int nRectIndex = 0;
+ for ( SwIndex nIndex = rStart.nContent; nIndex < rEnd.nContent; ++nIndex )
+ {
+ const SwPosition aPos( rStart.nNode, nIndex );
+ SwRect aRect ( rSh.GetCharRect() );
+ rSh.GetCharRectAt( aRect, &aPos );
+ aRects[ nRectIndex ] = Rectangle( aRect.Left(), aRect.Top(), aRect.Right(), aRect.Bottom() );
+ ++nRectIndex;
+ }
+ rWin.SetCompositionCharRect( aRects, nSize, bVertical );
+ delete[] aRects;
+ }
+ }
+ bCallBase = false;
+ }
+ break;
+#if OSL_DEBUG_LEVEL > 0
+ default:
+ OSL_ENSURE( !this, "unknown command." );
+#endif
+ }
+ if (bCallBase)
+ Window::Command(rCEvt);
+}
+
+/* i#18686 select the object/cursor at the mouse
+ position of the context menu request */
+sal_Bool SwEditWin::SelectMenuPosition(SwWrtShell& rSh, const Point& rMousePos )
+{
+ sal_Bool bRet = sal_False;
+ const Point aDocPos( PixelToLogic( rMousePos ) );
+ const bool bIsInsideSelectedObj( rSh.IsInsideSelectedObj( aDocPos ) );
+ //create a synthetic mouse event out of the coordinates
+ MouseEvent aMEvt(rMousePos);
+ SdrView *pSdrView = rSh.GetDrawView();
+ if ( pSdrView )
+ {
+ // no close of insert_draw and reset of
+ // draw mode, if context menu position is inside a selected object.
+ if ( !bIsInsideSelectedObj && m_rView.GetDrawFuncPtr() )
+ {
+
+ m_rView.GetDrawFuncPtr()->Deactivate();
+ m_rView.SetDrawFuncPtr(NULL);
+ m_rView.LeaveDrawCreate();
+ SfxBindings& rBind = m_rView.GetViewFrame()->GetBindings();
+ rBind.Invalidate( SID_ATTR_SIZE );
+ rBind.Invalidate( SID_TABLE_CELL );
+ }
+
+ // if draw text is active and there's a text selection
+ // at the mouse position then do nothing
+ if(rSh.GetSelectionType() & nsSelectionType::SEL_DRW_TXT)
+ {
+ OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
+ ESelection aSelection = pOLV->GetSelection();
+ if(!aSelection.IsZero())
+ {
+ SdrOutliner* pOutliner = pSdrView->GetTextEditOutliner();
+ sal_Bool bVertical = pOutliner->IsVertical();
+ const EditEngine& rEditEng = pOutliner->GetEditEngine();
+ Point aEEPos(aDocPos);
+ const Rectangle& rOutputArea = pOLV->GetOutputArea();
+ // regard vertical mode
+ if(bVertical)
+ {
+ aEEPos -= rOutputArea.TopRight();
+ //invert the horizontal direction and exchange X and Y
+ long nTemp = -aEEPos.X();
+ aEEPos.X() = aEEPos.Y();
+ aEEPos.Y() = nTemp;
+ }
+ else
+ aEEPos -= rOutputArea.TopLeft();
+
+ EPosition aDocPosition = rEditEng.FindDocPosition(aEEPos);
+ ESelection aCompare(aDocPosition.nPara, aDocPosition.nIndex);
+ // make it a forward selection - otherwise the IsLess/IsGreater do not work :-(
+ aSelection.Adjust();
+ if(!aCompare.IsLess(aSelection) && !aCompare.IsGreater(aSelection))
+ {
+ return sal_False;
+ }
+ }
+
+ }
+
+ if (pSdrView->MouseButtonDown( aMEvt, this ) )
+ {
+ pSdrView->MouseButtonUp( aMEvt, this );
+ rSh.GetView().GetViewFrame()->GetBindings().InvalidateAll(sal_False);
+ return sal_True;
+ }
+ }
+ rSh.ResetCursorStack();
+
+ if ( EnterDrawMode( aMEvt, aDocPos ) )
+ {
+ return sal_True;
+ }
+ if ( m_rView.GetDrawFuncPtr() && m_bInsFrm )
+ {
+ StopInsFrm();
+ rSh.Edit();
+ }
+
+ UpdatePointer( aDocPos, 0 );
+
+ if( !rSh.IsSelFrmMode() &&
+ !GetView().GetViewFrame()->GetDispatcher()->IsLocked() )
+ {
+ // Test if there is a draw object at that position and if it should be selected.
+ sal_Bool bShould = rSh.ShouldObjectBeSelected(aDocPos);
+
+ if(bShould)
+ {
+ m_rView.NoRotate();
+ rSh.HideCrsr();
+
+ bool bUnLockView = !rSh.IsViewLocked();
+ rSh.LockView( sal_True );
+ sal_Bool bSelObj = rSh.SelectObj( aDocPos, 0);
+ if( bUnLockView )
+ rSh.LockView( sal_False );
+
+ if( bSelObj )
+ {
+ bRet = sal_True;
+ // in case the frame was deselected in the macro
+ // just the cursor has to be displayed again.
+ if( FRMTYPE_NONE == rSh.GetSelFrmType() )
+ rSh.ShowCrsr();
+ else
+ {
+ if (rSh.IsFrmSelected() && m_rView.GetDrawFuncPtr())
+ {
+ m_rView.GetDrawFuncPtr()->Deactivate();
+ m_rView.SetDrawFuncPtr(NULL);
+ m_rView.LeaveDrawCreate();
+ m_rView.AttrChangedNotify( &rSh );
+ }
+
+ rSh.EnterSelFrmMode( &aDocPos );
+ bFrmDrag = true;
+ UpdatePointer( aDocPos, 0 );
+ return bRet;
+ }
+ }
+
+ if (!m_rView.GetDrawFuncPtr())
+ rSh.ShowCrsr();
+ }
+ }
+ else if ( rSh.IsSelFrmMode() &&
+ (m_aActHitType == SDRHIT_NONE ||
+ !bIsInsideSelectedObj))
+ {
+ m_rView.NoRotate();
+ bool bUnLockView = !rSh.IsViewLocked();
+ rSh.LockView( sal_True );
+ sal_uInt8 nFlag = 0;
+
+ if ( rSh.IsSelFrmMode() )
+ {
+ rSh.UnSelectFrm();
+ rSh.LeaveSelFrmMode();
+ m_rView.AttrChangedNotify(&rSh);
+ bRet = sal_True;
+ }
+
+ sal_Bool bSelObj = rSh.SelectObj( aDocPos, nFlag );
+ if( bUnLockView )
+ rSh.LockView( sal_False );
+
+ if( !bSelObj )
+ {
+ // move cursor here so that it is not drawn in the
+ // frame at first; ShowCrsr() happens in LeaveSelFrmMode()
+ bValidCrsrPos = !(CRSR_POSCHG & rSh.SetCursor(&aDocPos, false));
+ rSh.LeaveSelFrmMode();
+ m_rView.LeaveDrawCreate();
+ m_rView.AttrChangedNotify( &rSh );
+ bRet = sal_True;
+ }
+ else
+ {
+ rSh.HideCrsr();
+ rSh.EnterSelFrmMode( &aDocPos );
+ rSh.SelFlyGrabCrsr();
+ rSh.MakeSelVisible();
+ bFrmDrag = true;
+ if( rSh.IsFrmSelected() &&
+ m_rView.GetDrawFuncPtr() )
+ {
+ m_rView.GetDrawFuncPtr()->Deactivate();
+ m_rView.SetDrawFuncPtr(NULL);
+ m_rView.LeaveDrawCreate();
+ m_rView.AttrChangedNotify( &rSh );
+ }
+ UpdatePointer( aDocPos, 0 );
+ bRet = sal_True;
+ }
+ }
+ else if ( rSh.IsSelFrmMode() && bIsInsideSelectedObj )
+ {
+ // Object at the mouse cursor is already selected - do nothing
+ return sal_False;
+ }
+
+ if ( rSh.IsGCAttr() )
+ {
+ rSh.GCAttr();
+ rSh.ClearGCAttr();
+ }
+
+ sal_Bool bOverSelect = rSh.ChgCurrPam( aDocPos ), bOverURLGrf = sal_False;
+ if( !bOverSelect )
+ bOverURLGrf = bOverSelect = 0 != rSh.IsURLGrfAtPos( aDocPos );
+
+ if ( !bOverSelect )
+ {
+ { // create only temporary move context because otherwise
+ // the query against the content form doesn't work!!!
+ SwMvContext aMvContext( &rSh );
+ rSh.SetCursor(&aDocPos, false);
+ bRet = sal_True;
+ }
+ }
+ if( !bOverURLGrf )
+ {
+ const int nSelType = rSh.GetSelectionType();
+ if( nSelType == nsSelectionType::SEL_OLE ||
+ nSelType == nsSelectionType::SEL_GRF )
+ {
+ SwMvContext aMvContext( &rSh );
+ if( !rSh.IsFrmSelected() )
+ rSh.GotoNextFly();
+ rSh.EnterSelFrmMode();
+ bRet = sal_True;
+ }
+ }
+ return bRet;
+}
+
+static SfxShell* lcl_GetShellFromDispatcher( SwView& rView, TypeId nType )
+{
+ // determine Shell
+ SfxShell* pShell;
+ SfxDispatcher* pDispatcher = rView.GetViewFrame()->GetDispatcher();
+ for(sal_uInt16 i = 0; true; ++i )
+ {
+ pShell = pDispatcher->GetShell( i );
+ if( !pShell || pShell->IsA( nType ) )
+ break;
+ }
+ return pShell;
+}
+
+IMPL_LINK_NOARG(SwEditWin, KeyInputFlushHandler)
+{
+ FlushInBuffer();
+ return 0;
+}
+
+IMPL_LINK_NOARG(SwEditWin, KeyInputTimerHandler)
+{
+ m_bTblInsDelMode = sal_False;
+ return 0;
+}
+
+void SwEditWin::_InitStaticData()
+{
+ m_pQuickHlpData = new QuickHelpData();
+}
+
+void SwEditWin::_FinitStaticData()
+{
+ delete m_pQuickHlpData;
+}
+/* i#3370 - remove quick help to prevent saving
+ * of autocorrection suggestions */
+void SwEditWin::StopQuickHelp()
+{
+ if( HasFocus() && m_pQuickHlpData && m_pQuickHlpData->m_bIsDisplayed )
+ m_pQuickHlpData->Stop( m_rView.GetWrtShell() );
+}
+
+IMPL_LINK_NOARG(SwEditWin, TemplateTimerHdl)
+{
+ SetApplyTemplate(SwApplyTemplate());
+ return 0;
+}
+
+void SwEditWin::SetChainMode( sal_Bool bOn )
+{
+ if ( !m_bChainMode )
+ StopInsFrm();
+
+ if ( m_pUserMarker )
+ {
+ delete m_pUserMarker;
+ m_pUserMarker = 0L;
+ }
+
+ m_bChainMode = bOn;
+
+ static sal_uInt16 aInva[] =
+ {
+ FN_FRAME_CHAIN, FN_FRAME_UNCHAIN, 0
+ };
+ m_rView.GetViewFrame()->GetBindings().Invalidate(aInva);
+}
+
+uno::Reference< ::com::sun::star::accessibility::XAccessible > SwEditWin::CreateAccessible()
+{
+ SolarMutexGuard aGuard; // this should have happened already!!!
+ SwWrtShell *pSh = m_rView.GetWrtShellPtr();
+ OSL_ENSURE( pSh, "no writer shell, no accessible object" );
+ uno::Reference<
+ ::com::sun::star::accessibility::XAccessible > xAcc;
+ if( pSh )
+ xAcc = pSh->CreateAccessible();
+
+ return xAcc;
+}
+
+void QuickHelpData::Move( QuickHelpData& rCpy )
+{
+ m_aHelpStrings.clear();
+ m_aHelpStrings.swap( rCpy.m_aHelpStrings );
+
+ m_bIsDisplayed = rCpy.m_bIsDisplayed;
+ nLen = rCpy.nLen;
+ nCurArrPos = rCpy.nCurArrPos;
+ m_bAppendSpace = rCpy.m_bAppendSpace;
+ m_bIsTip = rCpy.m_bIsTip;
+ m_bIsAutoText = rCpy.m_bIsAutoText;
+}
+
+void QuickHelpData::ClearCntnt()
+{
+ nLen = nCurArrPos = 0;
+ m_bIsDisplayed = m_bAppendSpace = false;
+ nTipId = 0;
+ m_aHelpStrings.clear();
+ m_bIsTip = true;
+ m_bIsAutoText = true;
+}
+
+void QuickHelpData::Start( SwWrtShell& rSh, sal_uInt16 nWrdLen )
+{
+ if( USHRT_MAX != nWrdLen )
+ {
+ nLen = nWrdLen;
+ nCurArrPos = 0;
+ }
+ m_bIsDisplayed = true;
+
+ Window& rWin = rSh.GetView().GetEditWin();
+ if( m_bIsTip )
+ {
+ Point aPt( rWin.OutputToScreenPixel( rWin.LogicToPixel(
+ rSh.GetCharRect().Pos() )));
+ aPt.Y() -= 3;
+ nTipId = Help::ShowTip( &rWin, Rectangle( aPt, Size( 1, 1 )),
+ m_aHelpStrings[ nCurArrPos ],
+ QUICKHELP_LEFT | QUICKHELP_BOTTOM );
+ }
+ else
+ {
+ OUString sStr( m_aHelpStrings[ nCurArrPos ] );
+ sStr = sStr.copy( nLen );
+ sal_uInt16 nL = sStr.getLength();
+ const sal_uInt16 nVal = EXTTEXTINPUT_ATTR_DOTTEDUNDERLINE |
+ EXTTEXTINPUT_ATTR_HIGHLIGHT;
+ const std::vector<sal_uInt16> aAttrs( nL, nVal );
+ CommandExtTextInputData aCETID( sStr, &aAttrs[0], nL,
+ 0, false );
+
+ //fdo#33092. If the current input language is the default
+ //language that text would appear in if typed, then don't
+ //force a language on for the ExtTextInput.
+ LanguageType eInputLanguage = rWin.GetInputLanguage();
+ if (lcl_isNonDefaultLanguage(eInputLanguage,
+ rSh.GetView(), sStr) == INVALID_HINT)
+ {
+ eInputLanguage = LANGUAGE_DONTKNOW;
+ }
+
+ rSh.CreateExtTextInput(eInputLanguage);
+ rSh.SetExtTextInputData( aCETID );
+ }
+}
+
+void QuickHelpData::Stop( SwWrtShell& rSh )
+{
+ if( !m_bIsTip )
+ rSh.DeleteExtTextInput( 0, sal_False );
+ else if( nTipId )
+ Help::HideTip( nTipId );
+ ClearCntnt();
+}
+
+void QuickHelpData::FillStrArr( SwWrtShell& rSh, const OUString& rWord )
+{
+ enum Capitalization { CASE_LOWER, CASE_UPPER, CASE_SENTENCE, CASE_OTHER };
+
+ // Determine word capitalization
+ const CharClass& rCC = GetAppCharClass();
+ const OUString sWordLower = rCC.lowercase( rWord );
+ Capitalization aWordCase = CASE_OTHER;
+ if ( !rWord.isEmpty() )
+ {
+ if ( rWord[0] == sWordLower[0] )
+ {
+ if ( rWord == sWordLower )
+ aWordCase = CASE_LOWER;
+ }
+ else
+ {
+ // First character is not lower case i.e. assume upper or title case
+ OUString sWordSentence = sWordLower;
+ sWordSentence = sWordSentence.replaceAt( 0, 1, OUString(rWord[0]) );
+ if ( rWord == sWordSentence )
+ aWordCase = CASE_SENTENCE;
+ else
+ {
+ if ( rWord == rCC.uppercase( rWord ) )
+ aWordCase = CASE_UPPER;
+ }
+ }
+ }
+
+ salhelper::SingletonRef<SwCalendarWrapper>* pCalendar = s_getCalendarWrapper();
+ (*pCalendar)->LoadDefaultCalendar( rSh.GetCurLang() );
+
+ // Add matching calendar month and day names
+ uno::Sequence< i18n::CalendarItem2 > aNames( (*pCalendar)->getMonths() );
+ for ( sal_uInt16 i = 0; i < 2; ++i )
+ {
+ for ( long n = 0; n < aNames.getLength(); ++n )
+ {
+ const OUString& rStr( aNames[n].FullName );
+ // Check string longer than word and case insensitive match
+ if( rStr.getLength() > rWord.getLength() &&
+ rCC.lowercase( rStr, 0, rWord.getLength() ) == sWordLower )
+ {
+ //fdo#61251 if it's an exact match, ensure unchanged replacement
+ //exists as a candidate
+ if (rStr.startsWith(rWord))
+ m_aHelpStrings.push_back(rStr);
+
+ if ( aWordCase == CASE_LOWER )
+ m_aHelpStrings.push_back( rCC.lowercase( rStr ) );
+ else if ( aWordCase == CASE_SENTENCE )
+ {
+ OUString sTmp = rCC.lowercase( rStr );
+ sTmp = sTmp.replaceAt( 0, 1, OUString(rStr[0]) );
+ m_aHelpStrings.push_back( sTmp );
+ }
+ else if ( aWordCase == CASE_UPPER )
+ m_aHelpStrings.push_back( rCC.uppercase( rStr ) );
+ else // CASE_OTHER - use retrieved capitalization
+ m_aHelpStrings.push_back( rStr );
+ }
+ }
+ // Data for second loop iteration
+ if ( i == 0 )
+ aNames = (*pCalendar)->getDays();
+ }
+
+ // Add matching words from AutoCompleteWord list
+ const SwAutoCompleteWord& rACList = rSh.GetAutoCompleteWords();
+ std::vector<OUString> strings;
+
+ if ( rACList.GetWordsMatching( rWord, strings ) )
+ {
+ for (unsigned int i= 0; i<strings.size(); i++)
+ {
+ OUString aCompletedString = strings[i];
+ //fdo#61251 if it's an exact match, ensure unchanged replacement
+ //exists as a candidate
+ if (aCompletedString.startsWith(rWord))
+ m_aHelpStrings.push_back(aCompletedString);
+ if ( aWordCase == CASE_LOWER )
+ m_aHelpStrings.push_back( rCC.lowercase( aCompletedString ) );
+ else if ( aWordCase == CASE_SENTENCE )
+ {
+ OUString sTmp = rCC.lowercase( aCompletedString );
+ sTmp = sTmp.replaceAt( 0, 1, OUString(aCompletedString[0]) );
+ m_aHelpStrings.push_back( sTmp );
+ }
+ else if ( aWordCase == CASE_UPPER )
+ m_aHelpStrings.push_back( rCC.uppercase( aCompletedString ) );
+ else // CASE_OTHER - use retrieved capitalization
+ m_aHelpStrings.push_back( aCompletedString );
+ }
+ }
+
+}
+
+namespace {
+
+class CompareIgnoreCaseAsciiFavorExact
+ : public std::binary_function<const OUString&, const OUString&, bool>
+{
+ const OUString &m_rOrigWord;
+public:
+ CompareIgnoreCaseAsciiFavorExact(const OUString& rOrigWord)
+ : m_rOrigWord(rOrigWord)
+ {
+ }
+
+ bool operator()(const OUString& s1, const OUString& s2) const
+ {
+ int nRet = s1.compareToIgnoreAsciiCase(s2);
+ if (nRet == 0)
+ {
+ //fdo#61251 sort stuff that starts with the exact rOrigWord before
+ //another ignore-case candidate
+ int n1StartsWithOrig = s1.startsWith(m_rOrigWord) ? 0 : 1;
+ int n2StartsWithOrig = s2.startsWith(m_rOrigWord) ? 0 : 1;
+ return n1StartsWithOrig < n2StartsWithOrig;
+ }
+ return nRet < 0;
+ }
+};
+
+struct EqualIgnoreCaseAscii
+{
+ bool operator()(const OUString& s1, const OUString& s2) const
+ {
+ return s1.equalsIgnoreAsciiCase(s2);
+ }
+};
+
+} // anonymous namespace
+
+// TODO Implement an i18n aware sort
+void QuickHelpData::SortAndFilter(const OUString &rOrigWord)
+{
+ std::sort( m_aHelpStrings.begin(),
+ m_aHelpStrings.end(),
+ CompareIgnoreCaseAsciiFavorExact(rOrigWord) );
+
+ std::vector<OUString>::iterator it = std::unique( m_aHelpStrings.begin(),
+ m_aHelpStrings.end(),
+ EqualIgnoreCaseAscii() );
+ m_aHelpStrings.erase( it, m_aHelpStrings.end() );
+
+ nCurArrPos = 0;
+}
+
+void SwEditWin::ShowAutoTextCorrectQuickHelp(
+ const OUString& rWord, SvxAutoCorrCfg* pACfg, SvxAutoCorrect* pACorr,
+ bool bFromIME )
+{
+ SwWrtShell& rSh = m_rView.GetWrtShell();
+ m_pQuickHlpData->ClearCntnt();
+ if( pACfg->IsAutoTextTip() )
+ {
+ SwGlossaryList* pList = ::GetGlossaryList();
+ pList->HasLongName( rWord, &m_pQuickHlpData->m_aHelpStrings );
+ }
+
+ if( m_pQuickHlpData->m_aHelpStrings.empty() &&
+ pACorr->GetSwFlags().bAutoCompleteWords )
+ {
+ m_pQuickHlpData->m_bIsAutoText = false;
+ m_pQuickHlpData->m_bIsTip = bFromIME ||
+ !pACorr ||
+ pACorr->GetSwFlags().bAutoCmpltShowAsTip;
+
+ // Get the necessary data to show help text.
+ m_pQuickHlpData->FillStrArr( rSh, rWord );
+ }
+
+ if( !m_pQuickHlpData->m_aHelpStrings.empty() )
+ {
+ m_pQuickHlpData->SortAndFilter(rWord);
+ m_pQuickHlpData->Start( rSh, rWord.getLength() );
+ }
+}
+
+bool SwEditWin::IsInHeaderFooter( const Point &rDocPt, FrameControlType &rControl ) const
+{
+ SwWrtShell &rSh = m_rView.GetWrtShell();
+ const SwPageFrm* pPageFrm = rSh.GetLayout()->GetPageAtPos( rDocPt );
+
+ if ( pPageFrm && pPageFrm->IsOverHeaderFooterArea( rDocPt, rControl ) )
+ return true;
+
+ if ( rSh.IsShowHeaderFooterSeparator( Header ) || rSh.IsShowHeaderFooterSeparator( Footer ) )
+ {
+ SwFrameControlsManager &rMgr = rSh.GetView().GetEditWin().GetFrameControlsManager();
+ Point aPoint( LogicToPixel( rDocPt ) );
+
+ if ( rSh.IsShowHeaderFooterSeparator( Header ) )
+ {
+ SwFrameControlPtr pControl = rMgr.GetControl( Header, pPageFrm );
+ if ( pControl.get() && pControl->Contains( aPoint ) )
+ {
+ rControl = Header;
+ return true;
+ }
+ }
+
+ if ( rSh.IsShowHeaderFooterSeparator( Footer ) )
+ {
+ SwFrameControlPtr pControl = rMgr.GetControl( Footer, pPageFrm );
+ if ( pControl.get() && pControl->Contains( aPoint ) )
+ {
+ rControl = Footer;
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+bool SwEditWin::IsOverHeaderFooterFly( const Point& rDocPos, FrameControlType& rControl, bool& bOverFly, bool& bPageAnchored ) const
+{
+ bool bRet = false;
+ Point aPt( rDocPos );
+ SwWrtShell &rSh = m_rView.GetWrtShell();
+ SwPaM aPam( *rSh.GetCurrentShellCursor().GetPoint() );
+ rSh.GetLayout()->GetCrsrOfst( aPam.GetPoint(), aPt, NULL, true );
+
+ const SwStartNode* pStartFly = aPam.GetPoint()->nNode.GetNode().FindFlyStartNode();
+ if ( pStartFly )
+ {
+ bOverFly = true;
+ SwFrmFmt* pFlyFmt = pStartFly->GetFlyFmt( );
+ if ( pFlyFmt )
+ {
+ const SwPosition* pAnchor = pFlyFmt->GetAnchor( ).GetCntntAnchor( );
+ if ( pAnchor )
+ {
+ bool bInHeader = pAnchor->nNode.GetNode( ).FindHeaderStartNode( ) != NULL;
+ bool bInFooter = pAnchor->nNode.GetNode( ).FindFooterStartNode( ) != NULL;
+
+ bRet = bInHeader || bInFooter;
+ if ( bInHeader )
+ rControl = Header;
+ else if ( bInFooter )
+ rControl = Footer;
+ }
+ else
+ bPageAnchored = pFlyFmt->GetAnchor( ).GetAnchorId( ) == FLY_AT_PAGE;
+ }
+ }
+ else
+ bOverFly = false;
+ return bRet;
+}
+
+void SwEditWin::SetUseInputLanguage( sal_Bool bNew )
+{
+ if ( bNew || m_bUseInputLanguage )
+ {
+ SfxBindings& rBind = GetView().GetViewFrame()->GetBindings();
+ rBind.Invalidate( SID_ATTR_CHAR_FONT );
+ rBind.Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
+ }
+ m_bUseInputLanguage = bNew;
+}
+
+OUString SwEditWin::GetSurroundingText() const
+{
+ OUString sReturn;
+ SwWrtShell& rSh = m_rView.GetWrtShell();
+ if( rSh.HasSelection() && !rSh.IsMultiSelection() && rSh.IsSelOnePara() )
+ rSh.GetSelectedText( sReturn, GETSELTXT_PARABRK_TO_ONLYCR );
+ else if( !rSh.HasSelection() )
+ {
+ SwPosition *pPos = rSh.GetCrsr()->GetPoint();
+ const sal_Int32 nPos = pPos->nContent.GetIndex();
+
+ // get the sentence around the cursor
+ rSh.HideCrsr();
+ rSh.GoStartSentence();
+ rSh.SetMark();
+ rSh.GoEndSentence();
+ rSh.GetSelectedText( sReturn, GETSELTXT_PARABRK_TO_ONLYCR );
+
+ pPos->nContent = nPos;
+ rSh.ClearMark();
+ rSh.HideCrsr();
+ }
+
+ return sReturn;
+}
+
+Selection SwEditWin::GetSurroundingTextSelection() const
+{
+ SwWrtShell& rSh = m_rView.GetWrtShell();
+ if( rSh.HasSelection() )
+ {
+ OUString sReturn;
+ rSh.GetSelectedText( sReturn, GETSELTXT_PARABRK_TO_ONLYCR );
+ return Selection( 0, sReturn.getLength() );
+ }
+ else
+ {
+ // Return the position of the visible cursor in the sentence
+ // around the visible cursor.
+ SwPosition *pPos = rSh.GetCrsr()->GetPoint();
+ const sal_Int32 nPos = pPos->nContent.GetIndex();
+
+ rSh.HideCrsr();
+ rSh.GoStartSentence();
+ const sal_Int32 nStartPos = rSh.GetCrsr()->GetPoint()->nContent.GetIndex();
+
+ pPos->nContent = nPos;
+ rSh.ClearMark();
+ rSh.ShowCrsr();
+
+ return Selection( nPos - nStartPos, nPos - nStartPos );
+ }
+}
+
+// MT: Removed Windows::SwitchView() introduced with IA2 CWS.
+// There are other notifications for this when the active view has changed, so please update the code to use that event mechanism
+void SwEditWin::SwitchView()
+{
+#ifdef ACCESSIBLE_LAYOUT
+ if (!Application::IsAccessibilityEnabled())
+ {
+ return ;
+ }
+ rView.GetWrtShell().InvalidateAccessibleFocus();
+#endif
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/docvw/edtwin2.cxx b/sw/source/core/uibase/docvw/edtwin2.cxx
new file mode 100644
index 000000000000..f2779a03262e
--- /dev/null
+++ b/sw/source/core/uibase/docvw/edtwin2.cxx
@@ -0,0 +1,526 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <comphelper/string.hxx>
+#include <hintids.hxx>
+
+#include <doc.hxx>
+#if OSL_DEBUG_LEVEL > 1
+#include <stdio.h>
+#endif
+#include <osl/thread.h>
+#include <vcl/help.hxx>
+#include <svl/stritem.hxx>
+#include <unotools/securityoptions.hxx>
+#include <tools/urlobj.hxx>
+#include <txtrfmrk.hxx>
+#include <fmtrfmrk.hxx>
+#include <editeng/flditem.hxx>
+#include <svl/urihelper.hxx>
+#include <svx/svdotext.hxx>
+#include <editeng/outliner.hxx>
+#include <svl/itemiter.hxx>
+#include <svx/svdview.hxx>
+#include <svx/svdpagv.hxx>
+#include <swmodule.hxx>
+#include <modcfg.hxx>
+#include <view.hxx>
+#include <wrtsh.hxx>
+#include <docsh.hxx>
+#include <edtwin.hxx>
+#include <dpage.hxx>
+#include <shellres.hxx>
+#include <docufld.hxx>
+#include <dbfld.hxx>
+#include <reffld.hxx>
+#include <cellatr.hxx>
+#include <shdwcrsr.hxx>
+#include <fmtcol.hxx>
+#include <charfmt.hxx>
+#include <fmtftn.hxx>
+#include <redline.hxx>
+#include <tox.hxx>
+#include <txttxmrk.hxx>
+#include <uitool.hxx>
+#include <viewopt.hxx>
+#include <docvw.hrc>
+#include <utlui.hrc>
+
+#include <PostItMgr.hxx>
+#include <fmtfld.hxx>
+
+// #i104300#
+#include <IDocumentMarkAccess.hxx>
+#include <ndtxt.hxx>
+
+static OUString lcl_GetRedlineHelp( const SwRangeRedline& rRedl, sal_Bool bBalloon )
+{
+ sal_uInt16 nResId = 0;
+ switch( rRedl.GetType() )
+ {
+ case nsRedlineType_t::REDLINE_INSERT: nResId = STR_REDLINE_INSERT; break;
+ case nsRedlineType_t::REDLINE_DELETE: nResId = STR_REDLINE_DELETE; break;
+ case nsRedlineType_t::REDLINE_FORMAT: nResId = STR_REDLINE_FORMAT; break;
+ case nsRedlineType_t::REDLINE_TABLE: nResId = STR_REDLINE_TABLE; break;
+ case nsRedlineType_t::REDLINE_FMTCOLL: nResId = STR_REDLINE_FMTCOLL; break;
+ }
+
+ OUStringBuffer sBuf;
+ if( nResId )
+ {
+ sBuf.append(SW_RESSTR(nResId));
+ sBuf.append(": ");
+ sBuf.append(rRedl.GetAuthorString());
+ sBuf.append(" - ");
+ sBuf.append(GetAppLangDateTimeString(rRedl.GetTimeStamp()));
+ if( bBalloon && !rRedl.GetComment().isEmpty() )
+ sBuf.append('\n').append(rRedl.GetComment());
+ }
+ return sBuf.makeStringAndClear();
+}
+
+void SwEditWin::RequestHelp(const HelpEvent &rEvt)
+{
+ SwWrtShell &rSh = m_rView.GetWrtShell();
+ bool bQuickBalloon = 0 != (rEvt.GetMode() & ( HELPMODE_QUICK | HELPMODE_BALLOON ));
+ if(bQuickBalloon && !rSh.GetViewOptions()->IsShowContentTips())
+ return;
+ bool bContinue = true;
+ SET_CURR_SHELL(&rSh);
+ OUString sTxt;
+ Point aPos( PixelToLogic( ScreenToOutputPixel( rEvt.GetMousePosPixel() ) ));
+ sal_Bool bBalloon = static_cast< sal_Bool >(rEvt.GetMode() & HELPMODE_BALLOON);
+
+ SdrView *pSdrView = rSh.GetDrawView();
+
+ if( bQuickBalloon )
+ {
+ if( pSdrView )
+ {
+ SdrPageView* pPV = pSdrView->GetSdrPageView();
+ SwDPage* pPage = pPV ? ((SwDPage*)pPV->GetPage()) : 0;
+ bContinue = pPage && pPage->RequestHelp(this, pSdrView, rEvt);
+ }
+ }
+
+ if( bContinue && bQuickBalloon)
+ {
+ SwRect aFldRect;
+ SwContentAtPos aCntntAtPos( SwContentAtPos::SW_FIELD |
+ SwContentAtPos::SW_INETATTR |
+ SwContentAtPos::SW_FTN |
+ SwContentAtPos::SW_REDLINE |
+ SwContentAtPos::SW_TOXMARK |
+ SwContentAtPos::SW_REFMARK |
+ SwContentAtPos::SW_SMARTTAG |
+#ifdef DBG_UTIL
+ SwContentAtPos::SW_TABLEBOXVALUE |
+ ( bBalloon ? SwContentAtPos::SW_CURR_ATTRS : 0) |
+#endif
+ SwContentAtPos::SW_TABLEBOXFML );
+
+ if( rSh.GetContentAtPos( aPos, aCntntAtPos, sal_False, &aFldRect ) )
+ {
+ sal_uInt16 nStyle = 0; // style of quick help
+ switch( aCntntAtPos.eCntntAtPos )
+ {
+ case SwContentAtPos::SW_TABLEBOXFML:
+ sTxt = "= ";
+ sTxt += ((SwTblBoxFormula*)aCntntAtPos.aFnd.pAttr)->GetFormula();
+ break;
+#ifdef DBG_UTIL
+ case SwContentAtPos::SW_TABLEBOXVALUE:
+ {
+ sTxt = OStringToOUString(OString::number(
+ ((SwTblBoxValue*)aCntntAtPos.aFnd.pAttr)->GetValue()),
+ osl_getThreadTextEncoding());
+ }
+ break;
+ case SwContentAtPos::SW_CURR_ATTRS:
+ sTxt = aCntntAtPos.sStr;
+ break;
+#endif
+
+ case SwContentAtPos::SW_INETATTR:
+ {
+ sTxt = ((SfxStringItem*)aCntntAtPos.aFnd.pAttr)->GetValue();
+ sTxt = URIHelper::removePassword( sTxt,
+ INetURLObject::WAS_ENCODED,
+ INetURLObject::DECODE_UNAMBIGUOUS);
+ //#i63832# remove the link target type
+ sal_Int32 nFound = sTxt.indexOf(cMarkSeparator);
+ if( nFound != -1 && (++nFound) < sTxt.getLength() )
+ {
+ OUString sSuffix( sTxt.copy(nFound) );
+ if( sSuffix == "table" ||
+ sSuffix == "frame" ||
+ sSuffix == "region" ||
+ sSuffix == "outline" ||
+ sSuffix == "text" ||
+ sSuffix == "graphic" ||
+ sSuffix == "ole" )
+ sTxt = sTxt.copy( 0, nFound - 1);
+ }
+ // #i104300#
+ // special handling if target is a cross-reference bookmark
+ {
+ OUString sTmpSearchStr = sTxt.copy( 1 );
+ IDocumentMarkAccess* const pMarkAccess =
+ rSh.getIDocumentMarkAccess();
+ IDocumentMarkAccess::const_iterator_t ppBkmk =
+ pMarkAccess->findBookmark( sTmpSearchStr );
+ if ( ppBkmk != pMarkAccess->getBookmarksEnd() &&
+ IDocumentMarkAccess::GetType( *(ppBkmk->get()) )
+ == IDocumentMarkAccess::CROSSREF_HEADING_BOOKMARK )
+ {
+ SwTxtNode* pTxtNode = ppBkmk->get()->GetMarkStart().nNode.GetNode().GetTxtNode();
+ if ( pTxtNode )
+ {
+ sTxt = pTxtNode->GetExpandTxt( 0, pTxtNode->Len(), true, true );
+
+ if( !sTxt.isEmpty() )
+ {
+ OUStringBuffer sTmp(comphelper::string::remove(sTxt, 0xad));
+ for (sal_Int32 i = 0; i < sTmp.getLength(); ++i)
+ {
+ if (sTmp[i] < 0x20)
+ sTmp[i] = 0x20;
+ else if (sTmp[i] == 0x2011)
+ sTmp[i] = '-';
+ }
+ sTxt = sTmp.makeStringAndClear();
+ }
+ }
+ }
+ }
+ // #i80029#
+ sal_Bool bExecHyperlinks = m_rView.GetDocShell()->IsReadOnly();
+ if ( !bExecHyperlinks )
+ {
+ SvtSecurityOptions aSecOpts;
+ bExecHyperlinks = !aSecOpts.IsOptionSet( SvtSecurityOptions::E_CTRLCLICK_HYPERLINK );
+
+ sTxt = ": " + sTxt;
+ if ( !bExecHyperlinks )
+ sTxt = SwViewShell::GetShellRes()->aLinkCtrlClick + sTxt;
+ else
+ sTxt = SwViewShell::GetShellRes()->aLinkClick + sTxt;
+ }
+ break;
+ }
+ case SwContentAtPos::SW_SMARTTAG:
+ {
+ KeyCode aCode( KEY_SPACE );
+ KeyCode aModifiedCode( KEY_SPACE, KEY_MOD1 );
+ OUString aModStr( aModifiedCode.GetName() );
+ aModStr = aModStr.replaceFirst(aCode.GetName(), OUString());
+ aModStr = aModStr.replaceAll("+", OUString());
+ sTxt = SW_RESSTR(STR_SMARTTAG_CLICK).replaceAll("%s", aModStr);
+ }
+ break;
+
+ case SwContentAtPos::SW_FTN:
+ if( aCntntAtPos.pFndTxtAttr && aCntntAtPos.aFnd.pAttr )
+ {
+ const SwFmtFtn* pFtn = (SwFmtFtn*)aCntntAtPos.aFnd.pAttr;
+ OUString sTmp;
+ pFtn->GetFtnText( sTmp );
+ sTxt = SW_RESSTR( pFtn->IsEndNote()
+ ? STR_ENDNOTE : STR_FTNNOTE ) + sTmp;
+ bBalloon = sal_True;
+ if( aCntntAtPos.IsInRTLText() )
+ nStyle |= QUICKHELP_BIDI_RTL;
+ }
+ break;
+
+ case SwContentAtPos::SW_REDLINE:
+ sTxt = lcl_GetRedlineHelp(*aCntntAtPos.aFnd.pRedl, bBalloon);
+ break;
+
+ case SwContentAtPos::SW_TOXMARK:
+ sTxt = aCntntAtPos.sStr;
+ if( !sTxt.isEmpty() && aCntntAtPos.pFndTxtAttr )
+ {
+ const SwTOXType* pTType = aCntntAtPos.pFndTxtAttr->
+ GetTOXMark().GetTOXType();
+ if( pTType && !pTType->GetTypeName().isEmpty() )
+ {
+ sTxt = ": " + sTxt;
+ sTxt = pTType->GetTypeName() + sTxt;
+ }
+ }
+ break;
+ case SwContentAtPos::SW_REFMARK:
+ if(aCntntAtPos.aFnd.pAttr)
+ {
+ sTxt = SW_RESSTR(STR_CONTENT_TYPE_SINGLE_REFERENCE);
+ sTxt += ": ";
+ sTxt += ((const SwFmtRefMark*)aCntntAtPos.aFnd.pAttr)->GetRefName();
+ }
+ break;
+
+ default:
+ {
+ SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
+ if(!pModOpt->IsHideFieldTips())
+ {
+ const SwField* pFld = aCntntAtPos.aFnd.pFld;
+ switch( pFld->Which() )
+ {
+ case RES_SETEXPFLD:
+ case RES_TABLEFLD:
+ case RES_GETEXPFLD:
+ {
+ sal_uInt16 nOldSubType = pFld->GetSubType();
+ ((SwField*)pFld)->SetSubType(nsSwExtendedSubType::SUB_CMD);
+ sTxt = pFld->ExpandField(true);
+ ((SwField*)pFld)->SetSubType(nOldSubType);
+ }
+ break;
+
+ case RES_POSTITFLD:
+ {
+ break;
+ }
+ case RES_INPUTFLD: // BubbleHelp, because the suggestion could be quite long
+ bBalloon = sal_True;
+ /* no break */
+ case RES_JUMPEDITFLD:
+ sTxt = pFld->GetPar2();
+ break;
+
+ case RES_DBFLD:
+ sTxt = pFld->GetFieldName();
+ break;
+
+ case RES_USERFLD:
+ case RES_HIDDENTXTFLD:
+ sTxt = pFld->GetPar1();
+ break;
+
+ case RES_DOCSTATFLD:
+ break;
+
+ case RES_MACROFLD:
+ sTxt = ((const SwMacroField*)pFld)->GetMacro();
+ break;
+
+ case RES_GETREFFLD:
+ {
+ // #i85090#
+ const SwGetRefField* pRefFld( dynamic_cast<const SwGetRefField*>(pFld) );
+ OSL_ENSURE( pRefFld,
+ "<SwEditWin::RequestHelp(..)> - unexpected type of <pFld>" );
+ if ( pRefFld )
+ {
+ if ( pRefFld->IsRefToHeadingCrossRefBookmark() ||
+ pRefFld->IsRefToNumItemCrossRefBookmark() )
+ {
+ sTxt = pRefFld->GetExpandedTxtOfReferencedTxtNode();
+ if ( sTxt.getLength() > 80 )
+ {
+ sTxt = sTxt.copy(0, 80) + "...";
+ }
+ }
+ else
+ {
+ sTxt = ((SwGetRefField*)pFld)->GetSetRefName();
+ }
+ }
+ }
+ break;
+ }
+ }
+
+ if( sTxt.isEmpty() )
+ {
+ aCntntAtPos.eCntntAtPos = SwContentAtPos::SW_REDLINE;
+ if( rSh.GetContentAtPos( aPos, aCntntAtPos, sal_False, &aFldRect ) )
+ sTxt = lcl_GetRedlineHelp(*aCntntAtPos.aFnd.pRedl, bBalloon);
+ }
+ }
+ }
+ if (!sTxt.isEmpty())
+ {
+ if( bBalloon )
+ Help::ShowBalloon( this, rEvt.GetMousePosPixel(), sTxt );
+ else
+ {
+ // the show the help
+ Rectangle aRect( aFldRect.SVRect() );
+ Point aPt( OutputToScreenPixel( LogicToPixel( aRect.TopLeft() )));
+ aRect.Left() = aPt.X();
+ aRect.Top() = aPt.Y();
+ aPt = OutputToScreenPixel( LogicToPixel( aRect.BottomRight() ));
+ aRect.Right() = aPt.X();
+ aRect.Bottom() = aPt.Y();
+ Help::ShowQuickHelp( this, aRect, sTxt, nStyle );
+ }
+ }
+
+ bContinue = false;
+ }
+ if( bContinue )
+ {
+ sal_uInt8 nTabCols = rSh.WhichMouseTabCol(aPos);
+ sal_uInt16 nTabRes = 0;
+ switch(nTabCols)
+ {
+ case SW_TABCOL_HORI:
+ case SW_TABCOL_VERT:
+ nTabRes = STR_TABLE_COL_ADJUST;
+ break;
+ case SW_TABROW_HORI:
+ case SW_TABROW_VERT:
+ nTabRes = STR_TABLE_ROW_ADJUST;
+ break;
+ // #i32329# Enhanced table selection
+ case SW_TABSEL_HORI:
+ case SW_TABSEL_HORI_RTL:
+ case SW_TABSEL_VERT:
+ nTabRes = STR_TABLE_SELECT_ALL;
+ break;
+ case SW_TABROWSEL_HORI:
+ case SW_TABROWSEL_HORI_RTL:
+ case SW_TABROWSEL_VERT:
+ nTabRes = STR_TABLE_SELECT_ROW;
+ break;
+ case SW_TABCOLSEL_HORI:
+ case SW_TABCOLSEL_VERT:
+ nTabRes = STR_TABLE_SELECT_COL;
+ break;
+ }
+ if(nTabRes)
+ {
+ sTxt = SW_RESSTR(nTabRes);
+ Size aTxtSize( GetTextWidth(sTxt), GetTextHeight());
+ Rectangle aRect(rEvt.GetMousePosPixel(), aTxtSize);
+ Help::ShowQuickHelp(this, aRect, sTxt);
+ }
+ bContinue = false;
+ }
+ }
+
+ if( bContinue && pSdrView && bQuickBalloon)
+ {
+ SdrViewEvent aVEvt;
+ SdrHitKind eHit = pSdrView->PickAnything(aPos, aVEvt);
+ const SvxURLField *pField;
+ SdrObject* pObj = NULL;
+
+ if ((pField = aVEvt.pURLField) != 0)
+ {
+ // hit an URL field
+ if (pField)
+ {
+ pObj = aVEvt.pObj;
+ sTxt = pField->GetURL();
+
+ bContinue = false;
+ }
+ }
+ if (bContinue && eHit == SDRHIT_TEXTEDIT)
+ {
+ // look for URL field in DrawText object that is opened for editing
+ OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
+ const SvxFieldItem* pFieldItem;
+
+ if (pSdrView->AreObjectsMarked())
+ {
+ const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
+
+ if (rMarkList.GetMarkCount() == 1)
+ pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+ }
+
+ if (pObj && pObj->ISA(SdrTextObj) && pOLV &&
+ (pFieldItem = pOLV->GetFieldUnderMousePointer()) != 0)
+ {
+ pField = dynamic_cast<const SvxURLField*>(pFieldItem->GetField());
+
+ if (pField )
+ {
+ sTxt = ((const SvxURLField*) pField)->GetURL();
+ bContinue = false;
+ }
+ }
+ }
+ if (!sTxt.isEmpty() && pObj)
+ {
+ sTxt = URIHelper::removePassword( sTxt, INetURLObject::WAS_ENCODED,
+ INetURLObject::DECODE_UNAMBIGUOUS);
+
+ Rectangle aLogicPix = LogicToPixel(pObj->GetLogicRect());
+ Rectangle aScreenRect(OutputToScreenPixel(aLogicPix.TopLeft()),
+ OutputToScreenPixel(aLogicPix.BottomRight()));
+
+ if (bBalloon)
+ Help::ShowBalloon(this, rEvt.GetMousePosPixel(), aScreenRect, sTxt);
+ else
+ Help::ShowQuickHelp(this, aScreenRect, sTxt);
+ }
+ }
+
+ if( bContinue )
+ Window::RequestHelp( rEvt );
+}
+
+void SwEditWin::PrePaint()
+{
+ SwWrtShell* pWrtShell = GetView().GetWrtShellPtr();
+
+ if(pWrtShell)
+ {
+ pWrtShell->PrePaint();
+ }
+}
+
+void SwEditWin::Paint(const Rectangle& rRect)
+{
+ SwWrtShell* pWrtShell = GetView().GetWrtShellPtr();
+ if(!pWrtShell)
+ return;
+ bool bPaintShadowCrsr = false;
+ if( m_pShadCrsr )
+ {
+ Rectangle aRect( m_pShadCrsr->GetRect());
+ // fully resides inside?
+ if( rRect.IsInside( aRect ) )
+ // dann aufheben
+ delete m_pShadCrsr, m_pShadCrsr = 0;
+ else if( rRect.IsOver( aRect ))
+ {
+ // resides somewhat above, then everything is clipped outside
+ // and we have to make the "inner part" at the end of the
+ // Paint visible again. Otherwise Paint errors occur!
+ bPaintShadowCrsr = true;
+ }
+ }
+
+ if ( GetView().GetVisArea().GetWidth() <= 0 ||
+ GetView().GetVisArea().GetHeight() <= 0 )
+ Invalidate( rRect );
+ else
+ pWrtShell->Paint( rRect );
+
+ if( bPaintShadowCrsr )
+ m_pShadCrsr->Paint();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/docvw/edtwin3.cxx b/sw/source/core/uibase/docvw/edtwin3.cxx
new file mode 100644
index 000000000000..a860d484df12
--- /dev/null
+++ b/sw/source/core/uibase/docvw/edtwin3.cxx
@@ -0,0 +1,193 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <hintids.hxx>
+#include <vcl/settings.hxx>
+#include <svx/ruler.hxx>
+#include <viewopt.hxx>
+#include "view.hxx"
+#include "wrtsh.hxx"
+#include "basesh.hxx"
+#include "pview.hxx"
+#include "mdiexp.hxx"
+#include "edtwin.hxx"
+#include "swmodule.hxx"
+#include "modcfg.hxx"
+#include "swtable.hxx"
+#include "docsh.hxx"
+#include "pagedesc.hxx"
+#include <frmatr.hxx>
+#include <editeng/frmdiritem.hxx>
+
+// Core-Notify
+void ScrollMDI( SwViewShell* pVwSh, const SwRect &rRect,
+ sal_uInt16 nRangeX, sal_uInt16 nRangeY)
+{
+ SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
+ if (pSfxVwSh && pSfxVwSh->ISA(SwView))
+ ((SwView *)pSfxVwSh)->Scroll( rRect.SVRect(), nRangeX, nRangeY );
+}
+
+// Docmdi - movable
+sal_Bool IsScrollMDI( SwViewShell* pVwSh, const SwRect &rRect )
+{
+ SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
+ if (pSfxVwSh && pSfxVwSh->ISA(SwView))
+ return (((SwView *)pSfxVwSh)->IsScroll(rRect.SVRect()));
+ return sal_False;
+}
+
+// Notify for size change
+void SizeNotify(SwViewShell* pVwSh, const Size &rSize)
+{
+ SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
+ if (pSfxVwSh)
+ {
+ if (pSfxVwSh->ISA(SwView))
+ ((SwView *)pSfxVwSh)->DocSzChgd(rSize);
+ else if (pSfxVwSh->ISA(SwPagePreview))
+ ((SwPagePreview *)pSfxVwSh)->DocSzChgd( rSize );
+ }
+}
+
+// Notify for page number update
+void PageNumNotify( SwViewShell* pVwSh, sal_uInt16 nPhyNum, sal_uInt16 nVirtNum,
+ const OUString& rPgStr)
+{
+ SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
+ if ( pSfxVwSh && pSfxVwSh->ISA(SwView) &&
+ ((SwView*)pSfxVwSh)->GetCurShell() )
+ ((SwView *)pSfxVwSh)->UpdatePageNums(nPhyNum, nVirtNum, rPgStr);
+}
+
+void FrameNotify( SwViewShell* pVwSh, FlyMode eMode )
+{
+ if ( pVwSh->ISA(SwCrsrShell) )
+ SwBaseShell::SetFrmMode( eMode, (SwWrtShell*)pVwSh );
+}
+
+// Notify for page number update
+sal_Bool SwEditWin::RulerColumnDrag( const MouseEvent& rMEvt, sal_Bool bVerticalMode)
+{
+ SvxRuler& rRuler = bVerticalMode ? m_rView.GetVRuler() : m_rView.GetHRuler();
+ return (!rRuler.StartDocDrag( rMEvt, RULER_TYPE_BORDER ) &&
+ !rRuler.StartDocDrag( rMEvt, RULER_TYPE_MARGIN1) &&
+ !rRuler.StartDocDrag( rMEvt, RULER_TYPE_MARGIN2));
+}
+
+// #i23726#
+// #i42921# - add 3rd parameter <bVerticalMode> in order
+// to consider vertical layout
+sal_Bool SwEditWin::RulerMarginDrag( const MouseEvent& rMEvt,
+ const bool bVerticalMode )
+{
+ SvxRuler& rRuler = bVerticalMode ? m_rView.GetVRuler() : m_rView.GetHRuler();
+ return !rRuler.StartDocDrag( rMEvt, RULER_TYPE_INDENT);
+}
+
+void SwAccessibilityScrollMDI(SwViewShell* pVwSh, const SwRect& rRect , sal_uInt16 nRangeX, sal_uInt16 nRangeY, sal_Bool isLeftTop)
+{
+ SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
+ if (pSfxVwSh && pSfxVwSh->ISA(SwView))
+ {
+ SwView* pView = (SwView *)pSfxVwSh;
+
+ Size aSz( rRect.Left(), rRect.Top());
+ aSz = pView->GetEditWin().PixelToLogic( aSz );
+
+ Point aTopLeft( aSz.Width(), aSz.Height() );
+ Point aPoint;
+ Rectangle aRect(aTopLeft,aPoint);
+
+ sal_Bool bIsCrsrAtTop = pView->IsCrsrAtTop();
+ sal_Bool bIsCrsrAtCenter = pView->IsCrsrAtCenter();
+ if(isLeftTop)
+ pView->SetCrsrAtTop(sal_True);
+
+ pView->Scroll( aRect, nRangeX, nRangeY );
+
+ if(isLeftTop)
+ pView->SetCrsrAtTop(bIsCrsrAtTop, bIsCrsrAtCenter);
+ }
+
+}
+
+TblChgMode GetTblChgDefaultMode()
+{
+ SwModuleOptions* pOpt = SW_MOD()->GetModuleConfig();
+ return pOpt ? pOpt->GetTblMode() : TBLVAR_CHGABS;
+}
+
+void RepaintPagePreview( SwViewShell* pVwSh, const SwRect& rRect )
+{
+ SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
+ if (pSfxVwSh && pSfxVwSh->ISA( SwPagePreview ))
+ ((SwPagePreview *)pSfxVwSh)->RepaintCoreRect( rRect );
+}
+
+bool JumpToSwMark( SwViewShell* pVwSh, const OUString& rMark )
+{
+ SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
+ if( pSfxVwSh && pSfxVwSh->ISA( SwView ) )
+ return ((SwView *)pSfxVwSh)->JumpToSwMark( rMark );
+ return false;
+}
+
+void SwEditWin::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ Window::DataChanged( rDCEvt );
+
+ SwWrtShell* pSh = GetView().GetWrtShellPtr();
+ // DataChanged() is sometimes called prior to creating
+ // the SwWrtShell
+ if(!pSh)
+ return;
+ sal_Bool bViewWasLocked = pSh->IsViewLocked(), bUnlockPaint = sal_False;
+ pSh->LockView( sal_True );
+ switch( rDCEvt.GetType() )
+ {
+ case DATACHANGED_SETTINGS:
+ // rearrange ScrollBars, respectively trigger resize, because
+ // the ScrollBar size can have change. For that, in the reset
+ // handler, the size of the ScrollBars also has to be queried
+ // from the settings.
+ if( rDCEvt.GetFlags() & SETTINGS_STYLE )
+ {
+ pSh->LockPaint();
+ bUnlockPaint = sal_True;
+ SwViewShell::DeleteReplacementBitmaps();
+ GetView().InvalidateBorder(); //Scrollbar work
+ }
+ break;
+
+ case DATACHANGED_PRINTER:
+ case DATACHANGED_DISPLAY:
+ case DATACHANGED_FONTS:
+ case DATACHANGED_FONTSUBSTITUTION:
+ pSh->LockPaint();
+ bUnlockPaint = sal_True;
+ GetView().GetDocShell()->UpdateFontList(); //e.g. printer change
+ break;
+ }
+ pSh->LockView( bViewWasLocked );
+ if( bUnlockPaint )
+ pSh->UnlockPaint();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/docvw/frmsidebarwincontainer.cxx b/sw/source/core/uibase/docvw/frmsidebarwincontainer.cxx
new file mode 100644
index 000000000000..3760f9778446
--- /dev/null
+++ b/sw/source/core/uibase/docvw/frmsidebarwincontainer.cxx
@@ -0,0 +1,204 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <frmsidebarwincontainer.hxx>
+
+#include <map>
+#include <fmtfld.hxx>
+#include <txtfld.hxx>
+#include <SidebarWin.hxx>
+
+namespace {
+ struct SidebarWinKey
+ {
+ const sal_Int32 mnIndex;
+
+ explicit SidebarWinKey( const sal_Int32 nIndex )
+ : mnIndex( nIndex )
+ {}
+
+ bool operator < ( const SidebarWinKey& rSidebarWinKey ) const
+ {
+ return mnIndex < rSidebarWinKey.mnIndex;
+ }
+ };
+
+ struct SidebarWinOrder
+ {
+ bool operator()( const SidebarWinKey& rSidebarWinKeyA,
+ const SidebarWinKey& rSidebarWinKeyB ) const
+ {
+ return rSidebarWinKeyA < rSidebarWinKeyB;
+ }
+ };
+
+ typedef ::std::map < SidebarWinKey, sw::sidebarwindows::SwSidebarWin*, SidebarWinOrder > SidebarWinContainer;
+
+ struct FrmKey
+ {
+ const SwFrm* mpFrm;
+
+ explicit FrmKey( const SwFrm* pFrm )
+ : mpFrm( pFrm )
+ {}
+
+ bool operator < ( const FrmKey& rFrmKey ) const
+ {
+ return mpFrm < rFrmKey.mpFrm;
+ }
+ };
+
+ struct FrmOrder
+ {
+ bool operator()( const FrmKey& rFrmKeyA,
+ const FrmKey& rFrmKeyB ) const
+ {
+ return rFrmKeyA < rFrmKeyB;
+ }
+ };
+
+ typedef ::std::map < FrmKey, SidebarWinContainer, FrmOrder > _FrmSidebarWinContainer;
+}
+
+namespace sw { namespace sidebarwindows {
+
+class FrmSidebarWinContainer : public _FrmSidebarWinContainer
+{
+};
+
+SwFrmSidebarWinContainer::SwFrmSidebarWinContainer()
+ : mpFrmSidebarWinContainer( new FrmSidebarWinContainer() )
+{}
+
+SwFrmSidebarWinContainer::~SwFrmSidebarWinContainer()
+{
+ mpFrmSidebarWinContainer->clear();
+ delete mpFrmSidebarWinContainer;
+}
+
+bool SwFrmSidebarWinContainer::insert( const SwFrm& rFrm,
+ const SwFmtFld& rFmtFld,
+ SwSidebarWin& rSidebarWin )
+{
+ bool bInserted( false );
+
+ FrmKey aFrmKey( &rFrm );
+ SidebarWinContainer& rSidebarWinContainer = (*mpFrmSidebarWinContainer)[ aFrmKey ];
+
+ SidebarWinKey aSidebarWinKey( *(rFmtFld.GetTxtFld()->GetStart()) );
+ if ( rSidebarWinContainer.empty() ||
+ rSidebarWinContainer.find( aSidebarWinKey) == rSidebarWinContainer.end() )
+ {
+ rSidebarWinContainer[ aSidebarWinKey ] = &rSidebarWin;
+ bInserted = true;
+ }
+
+ return bInserted;
+}
+
+bool SwFrmSidebarWinContainer::remove( const SwFrm& rFrm,
+ const SwSidebarWin& rSidebarWin )
+{
+ bool bRemoved( false );
+
+ FrmKey aFrmKey( &rFrm );
+ FrmSidebarWinContainer::iterator aFrmIter = mpFrmSidebarWinContainer->find( aFrmKey );
+ if ( aFrmIter != mpFrmSidebarWinContainer->end() )
+ {
+ SidebarWinContainer& rSidebarWinContainer = (*aFrmIter).second;
+ for ( SidebarWinContainer::iterator aIter = rSidebarWinContainer.begin();
+ aIter != rSidebarWinContainer.end();
+ ++aIter )
+ {
+ if ( (*aIter).second == &rSidebarWin )
+ {
+ rSidebarWinContainer.erase( aIter );
+ bRemoved = true;
+ break;
+ }
+ }
+ }
+
+ return bRemoved;
+}
+
+bool SwFrmSidebarWinContainer::empty( const SwFrm& rFrm )
+{
+ bool bEmpty( true );
+
+ FrmKey aFrmKey( &rFrm );
+ FrmSidebarWinContainer::iterator aFrmIter = mpFrmSidebarWinContainer->find( aFrmKey );
+ if ( aFrmIter != mpFrmSidebarWinContainer->end() )
+ {
+ bEmpty = (*aFrmIter).second.empty();
+ }
+
+ return bEmpty;
+}
+
+SwSidebarWin* SwFrmSidebarWinContainer::get( const SwFrm& rFrm,
+ const sal_Int32 nIndex )
+{
+ SwSidebarWin* pRet( 0 );
+
+ FrmKey aFrmKey( &rFrm );
+ FrmSidebarWinContainer::iterator aFrmIter = mpFrmSidebarWinContainer->find( aFrmKey );
+ if ( aFrmIter != mpFrmSidebarWinContainer->end() )
+ {
+ SidebarWinContainer& rSidebarWinContainer = (*aFrmIter).second;
+ sal_Int32 nCounter( nIndex );
+ for ( SidebarWinContainer::iterator aIter = rSidebarWinContainer.begin();
+ nCounter >= 0 && aIter != rSidebarWinContainer.end();
+ ++aIter )
+ {
+ if ( nCounter == 0 )
+ {
+ pRet = (*aIter).second;
+ break;
+ }
+
+ --nCounter;
+ }
+ }
+
+ return pRet;
+}
+
+void SwFrmSidebarWinContainer::getAll( const SwFrm& rFrm,
+ std::vector< Window* >* pSidebarWins )
+{
+ pSidebarWins->clear();
+
+ FrmKey aFrmKey( &rFrm );
+ FrmSidebarWinContainer::iterator aFrmIter = mpFrmSidebarWinContainer->find( aFrmKey );
+ if ( aFrmIter != mpFrmSidebarWinContainer->end() )
+ {
+ SidebarWinContainer& rSidebarWinContainer = (*aFrmIter).second;
+ for ( SidebarWinContainer::iterator aIter = rSidebarWinContainer.begin();
+ aIter != rSidebarWinContainer.end();
+ ++aIter )
+ {
+ pSidebarWins->push_back( (*aIter).second );
+ }
+ }
+}
+
+} } // eof of namespace sw::sidebarwindows::
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/docvw/frmsidebarwincontainer.hxx b/sw/source/core/uibase/docvw/frmsidebarwincontainer.hxx
new file mode 100644
index 000000000000..51e657a551e1
--- /dev/null
+++ b/sw/source/core/uibase/docvw/frmsidebarwincontainer.hxx
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_DOCVW_FRMSIDEBARWINCONTAINER_HXX
+#define INCLUDED_SW_SOURCE_UI_DOCVW_FRMSIDEBARWINCONTAINER_HXX
+
+#include <sal/types.h>
+#include <vector>
+
+class SwFrm;
+class SwFmtFld;
+class Window;
+
+namespace sw { namespace sidebarwindows {
+
+class SwSidebarWin;
+class FrmSidebarWinContainer;
+
+class SwFrmSidebarWinContainer
+{
+ public:
+ SwFrmSidebarWinContainer();
+ ~SwFrmSidebarWinContainer();
+
+ bool insert( const SwFrm& rFrm,
+ const SwFmtFld& rFmtFld,
+ SwSidebarWin& rSidebarWin );
+
+ bool remove( const SwFrm& rFrm,
+ const SwSidebarWin& rSidebarWin );
+
+ bool empty( const SwFrm& rFrm );
+
+ SwSidebarWin* get( const SwFrm& rFrm,
+ const sal_Int32 nIndex );
+
+ void getAll( const SwFrm& rFrm,
+ std::vector< Window* >* pSidebarWins );
+
+ private:
+ FrmSidebarWinContainer* mpFrmSidebarWinContainer;
+};
+
+} } // eof of namespace sw::sidebarwindows::
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/docvw/romenu.cxx b/sw/source/core/uibase/docvw/romenu.cxx
new file mode 100644
index 000000000000..bbed8b0a7589
--- /dev/null
+++ b/sw/source/core/uibase/docvw/romenu.cxx
@@ -0,0 +1,368 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <hintids.hxx>
+
+#include <svl/eitem.hxx>
+#include <svl/stritem.hxx>
+#include <svtools/imap.hxx>
+#include <svtools/inetimg.hxx>
+#include <svtools/transfer.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svx/gallery.hxx>
+#include <svx/graphichelper.hxx>
+#include <editeng/brushitem.hxx>
+
+#include <frmatr.hxx>
+#include <fmturl.hxx>
+#include <fmtinfmt.hxx>
+#include <docsh.hxx>
+#include <view.hxx>
+#include <wrtsh.hxx>
+#include <viewopt.hxx>
+#include <swmodule.hxx>
+#include <romenu.hxx>
+#include <pagedesc.hxx>
+#include <modcfg.hxx>
+
+#include <cmdid.h>
+#include <helpid.h>
+#include <docvw.hrc>
+
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star;
+using namespace ::sfx2;
+
+SwReadOnlyPopup::~SwReadOnlyPopup()
+{
+ delete pImageMap;
+ delete pTargetURL;
+}
+
+void SwReadOnlyPopup::Check( sal_uInt16 nMID, sal_uInt16 nSID, SfxDispatcher &rDis )
+{
+ SfxPoolItem *_pItem = 0;
+ SfxItemState eState = rDis.GetBindings()->QueryState( nSID, _pItem );
+ if (eState >= SFX_ITEM_AVAILABLE)
+ {
+ EnableItem( nMID, true );
+ if (_pItem)
+ {
+ CheckItem ( nMID, !_pItem->ISA(SfxVoidItem) &&
+ _pItem->ISA(SfxBoolItem) &&
+ ((SfxBoolItem*)_pItem)->GetValue());
+ //remove full screen entry when not in full screen mode
+ if( SID_WIN_FULLSCREEN == nSID && !IsItemChecked(SID_WIN_FULLSCREEN) )
+ EnableItem(nMID, false);
+ }
+ }
+ else
+ EnableItem( nMID, false );
+
+ delete _pItem;
+}
+
+SwReadOnlyPopup::SwReadOnlyPopup( const Point &rDPos, SwView &rV ) :
+ PopupMenu( SW_RES(MN_READONLY_POPUP) ),
+ rView ( rV ),
+ rDocPos( rDPos ),
+ pImageMap( 0 ),
+ pTargetURL( 0 )
+{
+ bGrfToGalleryAsLnk = SW_MOD()->GetModuleConfig()->IsGrfToGalleryAsLnk();
+ SwWrtShell &rSh = rView.GetWrtShell();
+ rSh.IsURLGrfAtPos( rDocPos, &sURL, &sTargetFrameName, &sDescription );
+ if ( sURL.isEmpty() )
+ {
+ SwContentAtPos aCntntAtPos( SwContentAtPos::SW_INETATTR );
+ if( rSh.GetContentAtPos( rDocPos, aCntntAtPos, sal_False))
+ {
+ SwFmtINetFmt &rIItem = *(SwFmtINetFmt*)aCntntAtPos.aFnd.pAttr;
+ sURL = rIItem.GetValue();
+ sTargetFrameName = rIItem.GetTargetFrame();
+ sDescription = aCntntAtPos.sStr;
+ }
+ }
+
+ sal_Bool bLink = sal_False;
+ const Graphic *pGrf;
+ if ( 0 == (pGrf = rSh.GetGrfAtPos( rDocPos, sGrfName, bLink )) )
+ {
+ EnableItem( MN_READONLY_SAVEGRAPHIC, false );
+ EnableItem( MN_READONLY_COPYGRAPHIC, false );
+ }
+ else
+ {
+ aGraphic = *pGrf;
+ const SwFrmFmt* pGrfFmt = rSh.GetFmtFromObj( rDocPos );
+ const SfxPoolItem* pURLItem;
+ if( pGrfFmt && SFX_ITEM_SET == pGrfFmt->GetItemState(
+ RES_URL, sal_True, &pURLItem ))
+ {
+ const SwFmtURL& rURL = *(SwFmtURL*)pURLItem;
+ if( rURL.GetMap() )
+ pImageMap = new ImageMap( *rURL.GetMap() );
+ else if( !rURL.GetURL().isEmpty() )
+ pTargetURL = new INetImage( bLink ? sGrfName : OUString(),
+ rURL.GetURL(),
+ rURL.GetTargetFrameName(),
+ OUString(), Size() );
+ }
+ }
+
+ bool bEnableGraphicToGallery = bLink;
+ if ( bEnableGraphicToGallery )
+ {
+ if (GalleryExplorer::FillThemeList( aThemeList ))
+ {
+ PopupMenu *pMenu = GetPopupMenu(MN_READONLY_GRAPHICTOGALLERY);
+ pMenu->CheckItem( MN_READONLY_TOGALLERYLINK, bGrfToGalleryAsLnk );
+ pMenu->CheckItem( MN_READONLY_TOGALLERYCOPY, !bGrfToGalleryAsLnk );
+
+ for ( sal_uInt16 i=0; i < aThemeList.size(); ++i )
+ pMenu->InsertItem( MN_READONLY_GRAPHICTOGALLERY+i + 3, aThemeList[ i ] );
+ }
+ else
+ bEnableGraphicToGallery = false;
+ }
+
+ EnableItem( MN_READONLY_GRAPHICTOGALLERY, bEnableGraphicToGallery );
+
+ SfxViewFrame * pVFrame = rV.GetViewFrame();
+ SfxDispatcher &rDis = *pVFrame->GetDispatcher();
+ const SwPageDesc &rDesc = rSh.GetPageDesc( rSh.GetCurPageDesc() );
+ pItem = &rDesc.GetMaster().GetBackground();
+ sal_Bool bEnableBackGallery = sal_False,
+ bEnableBack = sal_False;
+
+ if ( GPOS_NONE != pItem->GetGraphicPos() )
+ {
+ bEnableBack = sal_True;
+ if ( !pItem->GetGraphicLink().isEmpty() )
+ {
+ if ( aThemeList.empty() )
+ GalleryExplorer::FillThemeList( aThemeList );
+
+ if ( !aThemeList.empty() )
+ {
+ PopupMenu *pMenu = GetPopupMenu(MN_READONLY_BACKGROUNDTOGALLERY);
+ pMenu->CheckItem( MN_READONLY_TOGALLERYLINK, bGrfToGalleryAsLnk );
+ pMenu->CheckItem( MN_READONLY_TOGALLERYCOPY, !bGrfToGalleryAsLnk );
+ bEnableBackGallery = sal_True;
+
+ for ( sal_uInt16 i=0; i < aThemeList.size(); ++i )
+ pMenu->InsertItem( MN_READONLY_GRAPHICTOGALLERY+i + 3, aThemeList[ i ] );
+ }
+ }
+ }
+ EnableItem( MN_READONLY_SAVEBACKGROUND, bEnableBack );
+ EnableItem( MN_READONLY_BACKGROUNDTOGALLERY, bEnableBackGallery );
+
+ if ( !rSh.GetViewOptions()->IsGraphic() )
+ CheckItem( MN_READONLY_GRAPHICOFF );
+ else
+ EnableItem( MN_READONLY_LOADGRAPHIC, false );
+
+ sal_Bool bReloadFrame = 0 != rSh.GetView().GetViewFrame()->GetFrame().GetParentFrame();
+ EnableItem( MN_READONLY_RELOAD_FRAME,
+ bReloadFrame );
+ EnableItem( MN_READONLY_RELOAD, !bReloadFrame);
+
+ Check( MN_READONLY_EDITDOC, SID_EDITDOC, rDis );
+ Check( MN_READONLY_SELECTION_MODE, FN_READONLY_SELECTION_MODE, rDis );
+ Check( MN_READONLY_SOURCEVIEW, SID_SOURCEVIEW, rDis );
+ Check( MN_READONLY_BROWSE_BACKWARD, SID_BROWSE_BACKWARD,rDis );
+ Check( MN_READONLY_BROWSE_FORWARD, SID_BROWSE_FORWARD, rDis );
+#ifdef WNT
+ Check( MN_READONLY_PLUGINOFF, SID_PLUGINS_ACTIVE, rDis );
+#endif
+ Check( MN_READONLY_OPENURL, SID_OPENDOC, rDis );
+ Check( MN_READONLY_OPENURLNEW, SID_OPENDOC, rDis );
+
+ SfxPoolItem* pState = NULL;
+
+ SfxItemState eState = pVFrame->GetBindings().QueryState( SID_COPY, pState );
+ Check( MN_READONLY_COPY, SID_COPY, rDis );
+ if(eState < SFX_ITEM_AVAILABLE)
+ EnableItem( MN_READONLY_COPY, false );
+ delete pState;
+ pState = NULL;
+
+ eState = pVFrame->GetBindings().QueryState( SID_EDITDOC, pState );
+ if (
+ eState < SFX_ITEM_DEFAULT ||
+ (rSh.IsGlobalDoc() && rView.GetDocShell()->IsReadOnlyUI())
+ )
+ {
+ EnableItem( MN_READONLY_EDITDOC, false );
+ }
+ delete pState;
+
+ if ( sURL.isEmpty() )
+ {
+ EnableItem( MN_READONLY_OPENURL, false );
+ EnableItem( MN_READONLY_OPENURLNEW, false );
+ EnableItem( MN_READONLY_COPYLINK, false );
+ }
+ Check( SID_WIN_FULLSCREEN, SID_WIN_FULLSCREEN, rDis );
+
+ RemoveDisabledEntries( true, true );
+}
+
+void SwReadOnlyPopup::Execute( Window* pWin, const Point &rPixPos )
+{
+ sal_uInt16 nId = PopupMenu::Execute(
+ pWin,
+ rPixPos );
+ Execute(pWin, nId);
+}
+
+// execute the resulting ID only - necessary to support XContextMenuInterception
+void SwReadOnlyPopup::Execute( Window* pWin, sal_uInt16 nId )
+{
+ SwWrtShell &rSh = rView.GetWrtShell();
+ SfxDispatcher &rDis = *rView.GetViewFrame()->GetDispatcher();
+ if ( nId >= MN_READONLY_GRAPHICTOGALLERY )
+ {
+ OUString sTmp;
+ sal_uInt16 nSaveId;
+ if ( nId >= MN_READONLY_BACKGROUNDTOGALLERY )
+ {
+ nId -= MN_READONLY_BACKGROUNDTOGALLERY+3;
+ nSaveId = MN_READONLY_SAVEBACKGROUND;
+ sTmp = pItem->GetGraphicLink();
+ }
+ else
+ {
+ nId -= MN_READONLY_GRAPHICTOGALLERY+3;
+ nSaveId = MN_READONLY_SAVEGRAPHIC;
+ sTmp = sGrfName;
+ }
+ if ( !bGrfToGalleryAsLnk )
+ sTmp = SaveGraphic( nSaveId );
+
+ if ( !sTmp.isEmpty() )
+ GalleryExplorer::InsertURL( aThemeList[nId], sTmp );
+
+ return;
+ }
+
+ TransferDataContainer* pClipCntnr = 0;
+
+ sal_uInt16 nExecId = USHRT_MAX;
+ sal_uInt16 nFilter = USHRT_MAX;
+ switch( nId )
+ {
+ case SID_WIN_FULLSCREEN : nExecId = SID_WIN_FULLSCREEN; break;
+ case MN_READONLY_OPENURL: nFilter = URLLOAD_NOFILTER; break;
+ case MN_READONLY_OPENURLNEW: nFilter = URLLOAD_NEWVIEW; break;
+ case MN_READONLY_COPY: nExecId = SID_COPY; break;
+
+ case MN_READONLY_EDITDOC: nExecId = SID_EDITDOC; break;
+ case MN_READONLY_SELECTION_MODE: nExecId = FN_READONLY_SELECTION_MODE; break;
+ case MN_READONLY_RELOAD:
+ case MN_READONLY_RELOAD_FRAME:
+ rSh.GetView().GetViewFrame()->GetDispatcher()->Execute(SID_RELOAD);
+ break;
+
+ case MN_READONLY_BROWSE_BACKWARD: nExecId = SID_BROWSE_BACKWARD;break;
+ case MN_READONLY_BROWSE_FORWARD: nExecId = SID_BROWSE_FORWARD; break;
+ case MN_READONLY_SOURCEVIEW: nExecId = SID_SOURCEVIEW; break;
+ case MN_READONLY_SAVEGRAPHIC:
+ case MN_READONLY_SAVEBACKGROUND:
+ {
+ SaveGraphic( nId );
+ break;
+ }
+ case MN_READONLY_COPYLINK:
+ pClipCntnr = new TransferDataContainer;
+ pClipCntnr->CopyString( sURL );
+ break;
+
+ case MN_READONLY_COPYGRAPHIC:
+ pClipCntnr = new TransferDataContainer;
+ pClipCntnr->CopyGraphic( aGraphic );
+
+ if( pImageMap )
+ pClipCntnr->CopyImageMap( *pImageMap );
+ if( pTargetURL )
+ pClipCntnr->CopyINetImage( *pTargetURL );
+ break;
+
+ case MN_READONLY_LOADGRAPHIC:
+ {
+ sal_Bool bModified = rSh.IsModified();
+ SwViewOption aOpt( *rSh.GetViewOptions() );
+ aOpt.SetGraphic( sal_True );
+ rSh.ApplyViewOptions( aOpt );
+ if(!bModified)
+ rSh.ResetModified();
+ break;
+ }
+ case MN_READONLY_GRAPHICOFF: nExecId = FN_VIEW_GRAPHIC; break;
+#ifdef WNT
+ case MN_READONLY_PLUGINOFF: nExecId = SID_PLUGINS_ACTIVE; break;
+#endif
+ case MN_READONLY_TOGALLERYLINK:
+ SW_MOD()->GetModuleConfig()->SetGrfToGalleryAsLnk( sal_True );
+ break;
+ case MN_READONLY_TOGALLERYCOPY:
+ SW_MOD()->GetModuleConfig()->SetGrfToGalleryAsLnk( sal_False );
+ break;
+
+ default: //forward the id to the SfxBindings
+ nExecId = nId;
+ }
+ if( USHRT_MAX != nExecId )
+ rDis.GetBindings()->Execute( nExecId );
+ if( USHRT_MAX != nFilter )
+ ::LoadURL(rSh, sURL, nFilter, sTargetFrameName);
+
+ if( pClipCntnr )
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > xRef( pClipCntnr );
+ if( pClipCntnr->HasAnyData() )
+ pClipCntnr->CopyToClipboard( pWin );
+ }
+}
+
+OUString SwReadOnlyPopup::SaveGraphic( sal_uInt16 nId )
+{
+ // fish out the graphic's name
+ if ( MN_READONLY_SAVEBACKGROUND == nId )
+ {
+ if ( !pItem->GetGraphicLink().isEmpty() )
+ sGrfName = pItem->GetGraphicLink();
+ ((SvxBrushItem*)pItem)->SetDoneLink( Link() );
+ const Graphic *pGrf = pItem->GetGraphic();
+ if ( pGrf )
+ {
+ aGraphic = *pGrf;
+ if ( !pItem->GetGraphicLink().isEmpty() )
+ sGrfName = pItem->GetGraphicLink();
+ }
+ else
+ return OUString();
+ }
+ return GraphicHelper::ExportGraphic( aGraphic, sGrfName );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/docvw/romenu.hxx b/sw/source/core/uibase/docvw/romenu.hxx
new file mode 100644
index 000000000000..e0242db41504
--- /dev/null
+++ b/sw/source/core/uibase/docvw/romenu.hxx
@@ -0,0 +1,64 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_DOCVW_ROMENU_HXX
+#define INCLUDED_SW_SOURCE_UI_DOCVW_ROMENU_HXX
+
+#include <vcl/graph.hxx>
+#include <vcl/menu.hxx>
+#include <svl/stritem.hxx>
+
+class SwView;
+class SfxDispatcher;
+class SvxBrushItem;
+class ImageMap;
+class INetImage;
+
+class SwReadOnlyPopup : public PopupMenu
+{
+ SwView &rView;
+ const SvxBrushItem *pItem;
+ const Point &rDocPos;
+ Graphic aGraphic;
+ OUString sURL,
+ sTargetFrameName,
+ sDescription;
+ OUString sGrfName;
+ std::vector<OUString> aThemeList;
+ sal_Bool bGrfToGalleryAsLnk;
+ ImageMap* pImageMap;
+ INetImage* pTargetURL;
+
+ void Check( sal_uInt16 nMID, sal_uInt16 nSID, SfxDispatcher &rDis );
+ OUString SaveGraphic( sal_uInt16 nId );
+
+ using PopupMenu::Execute;
+
+public:
+ SwReadOnlyPopup( const Point &rDPos, SwView &rV );
+ ~SwReadOnlyPopup();
+
+ void Execute( Window* pWin, const Point &rPPos );
+ void Execute( Window* pWin, sal_uInt16 nId );
+};
+
+void GetPreferredExtension( OUString &rExt, const Graphic &rGrf );
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/docvw/srcedtw.cxx b/sw/source/core/uibase/docvw/srcedtw.cxx
new file mode 100644
index 000000000000..65c6f25c02c5
--- /dev/null
+++ b/sw/source/core/uibase/docvw/srcedtw.cxx
@@ -0,0 +1,993 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "sal/config.h"
+
+#include <hintids.hxx>
+#include <cmdid.h>
+
+#include <com/sun/star/beans/XMultiPropertySet.hpp>
+#include <com/sun/star/beans/XPropertiesChangeListener.hpp>
+#include <cppuhelper/implbase1.hxx>
+#include <officecfg/Office/Common.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/log.hxx>
+#include <vcl/textview.hxx>
+#include <svx/svxids.hrc>
+#include <vcl/scrbar.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/app.hxx>
+#include <svtools/htmltokn.h>
+#include <vcl/txtattr.hxx>
+#include <vcl/settings.hxx>
+#include <svtools/colorcfg.hxx>
+#include <editeng/flstitem.hxx>
+#include <vcl/metric.hxx>
+#include <svtools/ctrltool.hxx>
+#include <tools/time.hxx>
+#include <swmodule.hxx>
+#include <docsh.hxx>
+#include <srcview.hxx>
+#include <helpid.h>
+#include <deque>
+
+struct SwTextPortion
+{
+ sal_uInt16 nLine;
+ sal_uInt16 nStart, nEnd;
+ svtools::ColorConfigEntry eType;
+};
+
+#define MAX_SYNTAX_HIGHLIGHT 20
+#define MAX_HIGHLIGHTTIME 200
+#define SYNTAX_HIGHLIGHT_TIMEOUT 200
+
+typedef std::deque<SwTextPortion> SwTextPortions;
+
+static void lcl_Highlight(const OUString& rSource, SwTextPortions& aPortionList)
+{
+ const sal_Unicode cOpenBracket = '<';
+ const sal_Unicode cCloseBracket= '>';
+ const sal_Unicode cSlash = '/';
+ const sal_Unicode cExclamation = '!';
+ const sal_Unicode cMinus = '-';
+ const sal_Unicode cSpace = ' ';
+ const sal_Unicode cTab = 0x09;
+ const sal_Unicode cLF = 0x0a;
+ const sal_Unicode cCR = 0x0d;
+
+ const sal_uInt16 nStrLen = rSource.getLength();
+ sal_uInt16 nInsert = 0; // number of inserted portions
+ sal_uInt16 nActPos = 0; // position, where '<' was found
+ sal_uInt16 nOffset = 0; // Offset of nActPos to '<'
+ sal_uInt16 nPortStart = USHRT_MAX; // for the TextPortion
+ sal_uInt16 nPortEnd = 0;
+ SwTextPortion aText;
+ while(nActPos < nStrLen)
+ {
+ svtools::ColorConfigEntry eFoundType = svtools::HTMLUNKNOWN;
+ if((nActPos < nStrLen - 2) && (rSource[nActPos] == cOpenBracket))
+ {
+ // insert 'empty' portion
+ if(nPortEnd < nActPos - 1 )
+ {
+ aText.nLine = 0;
+ // don't move at the beginning
+ aText.nStart = nPortEnd;
+ if(nInsert)
+ aText.nStart += 1;
+ aText.nEnd = nActPos - 1;
+ aText.eType = svtools::HTMLUNKNOWN;
+ aPortionList.push_back( aText );
+ nInsert++;
+ }
+ sal_Unicode cFollowFirst = rSource[nActPos + 1];
+ sal_Unicode cFollowNext = rSource[nActPos + 2];
+ if(cExclamation == cFollowFirst)
+ {
+ // "<!" SGML or comment
+ if(cMinus == cFollowNext &&
+ nActPos < nStrLen - 3 && cMinus == rSource[nActPos + 3])
+ {
+ eFoundType = svtools::HTMLCOMMENT;
+ }
+ else
+ eFoundType = svtools::HTMLSGML;
+ nPortStart = nActPos;
+ nPortEnd = nActPos + 1;
+ }
+ else if(cSlash == cFollowFirst)
+ {
+ // "</" ignore slash
+ nPortStart = nActPos;
+ nActPos++;
+ nOffset++;
+ }
+ if(svtools::HTMLUNKNOWN == eFoundType)
+ {
+ // now here a keyword could follow
+ sal_uInt16 nSrchPos = nActPos;
+ while(++nSrchPos < nStrLen - 1)
+ {
+ sal_Unicode cNext = rSource[nSrchPos];
+ if( cNext == cSpace ||
+ cNext == cTab ||
+ cNext == cLF ||
+ cNext == cCR)
+ break;
+ else if(cNext == cCloseBracket)
+ {
+ break;
+ }
+ }
+ if(nSrchPos > nActPos + 1)
+ {
+ // some string was found
+ OUString sToken = rSource.copy(nActPos + 1, nSrchPos - nActPos - 1 );
+ sToken = sToken.toAsciiUpperCase();
+ int nToken = ::GetHTMLToken(sToken);
+ if(nToken)
+ {
+ // Token was found
+ eFoundType = svtools::HTMLKEYWORD;
+ nPortEnd = nSrchPos;
+ nPortStart = nActPos;
+ }
+ else
+ {
+ // what was that?
+ SAL_WARN(
+ "sw.level2",
+ "Token " << sToken
+ << " not recognised!");
+ }
+
+ }
+ }
+ // now we still have to look for '>'
+ if(svtools::HTMLUNKNOWN != eFoundType)
+ {
+ bool bFound = false;
+ for(sal_uInt16 i = nPortEnd; i < nStrLen; i++)
+ if(cCloseBracket == rSource[i])
+ {
+ bFound = true;
+ nPortEnd = i;
+ break;
+ }
+ if(!bFound && (eFoundType == svtools::HTMLCOMMENT))
+ {
+ // comment without ending in this line
+ bFound = true;
+ nPortEnd = nStrLen - 1;
+ }
+
+ if(bFound ||(eFoundType == svtools::HTMLCOMMENT))
+ {
+ SwTextPortion aTextPortion;
+ aTextPortion.nLine = 0;
+ aTextPortion.nStart = nPortStart + 1;
+ aTextPortion.nEnd = nPortEnd;
+ aTextPortion.eType = eFoundType;
+ aPortionList.push_back( aTextPortion );
+ nInsert++;
+ eFoundType = svtools::HTMLUNKNOWN;
+ }
+
+ }
+ }
+ nActPos++;
+ }
+ if(nInsert && nPortEnd < nActPos - 1)
+ {
+ aText.nLine = 0;
+ aText.nStart = nPortEnd + 1;
+ aText.nEnd = nActPos - 1;
+ aText.eType = svtools::HTMLUNKNOWN;
+ aPortionList.push_back( aText );
+ nInsert++;
+ }
+}
+
+class SwSrcEditWindow::ChangesListener:
+ public cppu::WeakImplHelper1< css::beans::XPropertiesChangeListener >
+{
+public:
+ ChangesListener(SwSrcEditWindow & editor): editor_(editor) {}
+
+private:
+ virtual ~ChangesListener() {}
+
+ virtual void SAL_CALL disposing(css::lang::EventObject const &)
+ throw (css::uno::RuntimeException, std::exception)
+ {
+ osl::MutexGuard g(editor_.mutex_);
+ editor_.notifier_.clear();
+ }
+
+ virtual void SAL_CALL propertiesChange(
+ css::uno::Sequence< css::beans::PropertyChangeEvent > const &)
+ throw (css::uno::RuntimeException, std::exception)
+ {
+ SolarMutexGuard g;
+ editor_.SetFont();
+ }
+
+ SwSrcEditWindow & editor_;
+};
+
+SwSrcEditWindow::SwSrcEditWindow( Window* pParent, SwSrcView* pParentView ) :
+ Window( pParent, WB_BORDER|WB_CLIPCHILDREN ),
+
+ pTextEngine(0),
+
+ pOutWin(0),
+ pHScrollbar(0),
+ pVScrollbar(0),
+
+ pSrcView(pParentView),
+
+ nCurTextWidth(0),
+ nStartLine(USHRT_MAX),
+ eSourceEncoding(osl_getThreadTextEncoding()),
+ bDoSyntaxHighlight(sal_True),
+ bHighlighting(sal_False)
+{
+ SetHelpId(HID_SOURCE_EDITWIN);
+ CreateTextEngine();
+
+ // Using "this" in ctor is a little fishy, but should work here at least as
+ // long as there are no derivations:
+ listener_ = new ChangesListener(*this);
+ css::uno::Reference< css::beans::XMultiPropertySet > n(
+ officecfg::Office::Common::Font::SourceViewFont::get(),
+ css::uno::UNO_QUERY_THROW);
+ {
+ osl::MutexGuard g(mutex_);
+ notifier_ = n;
+ }
+ css::uno::Sequence< OUString > s(2);
+ s[0] = "FontHeight";
+ s[1] = "FontName";
+ n->addPropertiesChangeListener(s, listener_.get());
+}
+
+ SwSrcEditWindow::~SwSrcEditWindow()
+{
+ css::uno::Reference< css::beans::XMultiPropertySet > n;
+ {
+ osl::MutexGuard g(mutex_);
+ n = notifier_;
+ }
+ if (n.is()) {
+ n->removePropertiesChangeListener(listener_.get());
+ }
+ aSyntaxIdleTimer.Stop();
+ if ( pTextEngine )
+ {
+ EndListening( *pTextEngine );
+ pTextEngine->RemoveView( pTextView );
+
+ delete pHScrollbar;
+ delete pVScrollbar;
+
+ delete pTextView;
+ delete pTextEngine;
+ }
+ delete pOutWin;
+}
+
+void SwSrcEditWindow::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ Window::DataChanged( rDCEvt );
+
+ switch ( rDCEvt.GetType() )
+ {
+ case DATACHANGED_SETTINGS:
+ // newly rearrange ScrollBars or trigger Resize, because
+ // ScrollBar size could have changed. For this, in the
+ // Resize handler the size of ScrollBars has to be queried
+ // from the settings as well.
+ if( rDCEvt.GetFlags() & SETTINGS_STYLE )
+ Resize();
+ break;
+ }
+}
+
+void SwSrcEditWindow::Resize()
+{
+ // ScrollBars, etc. happens in Adjust...
+ if ( pTextView )
+ {
+ long nVisY = pTextView->GetStartDocPos().Y();
+ pTextView->ShowCursor();
+ Size aOutSz( GetOutputSizePixel() );
+ long nMaxVisAreaStart = pTextView->GetTextEngine()->GetTextHeight() - aOutSz.Height();
+ if ( nMaxVisAreaStart < 0 )
+ nMaxVisAreaStart = 0;
+ if ( pTextView->GetStartDocPos().Y() > nMaxVisAreaStart )
+ {
+ Point aStartDocPos( pTextView->GetStartDocPos() );
+ aStartDocPos.Y() = nMaxVisAreaStart;
+ pTextView->SetStartDocPos( aStartDocPos );
+ pTextView->ShowCursor();
+ }
+ long nScrollStd = GetSettings().GetStyleSettings().GetScrollBarSize();
+ Size aScrollSz(aOutSz.Width() - nScrollStd, nScrollStd );
+ Point aScrollPos(0, aOutSz.Height() - nScrollStd);
+
+ pHScrollbar->SetPosSizePixel( aScrollPos, aScrollSz);
+
+ aScrollSz.Width() = aScrollSz.Height();
+ aScrollSz.Height() = aOutSz.Height();
+ aScrollPos = Point(aOutSz.Width() - nScrollStd, 0);
+
+ pVScrollbar->SetPosSizePixel( aScrollPos, aScrollSz);
+ aOutSz.Width() -= nScrollStd;
+ aOutSz.Height() -= nScrollStd;
+ pOutWin->SetOutputSizePixel(aOutSz);
+ InitScrollBars();
+
+ // set line in first Resize
+ if(USHRT_MAX != nStartLine)
+ {
+ if(nStartLine < pTextEngine->GetParagraphCount())
+ {
+ TextSelection aSel(TextPaM( nStartLine, 0 ), TextPaM( nStartLine, 0x0 ));
+ pTextView->SetSelection(aSel);
+ pTextView->ShowCursor();
+ }
+ nStartLine = USHRT_MAX;
+ }
+
+ if ( nVisY != pTextView->GetStartDocPos().Y() )
+ Invalidate();
+ }
+
+}
+
+void TextViewOutWin::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ Window::DataChanged( rDCEvt );
+
+ switch( rDCEvt.GetType() )
+ {
+ case DATACHANGED_SETTINGS:
+ // query settings
+ if( rDCEvt.GetFlags() & SETTINGS_STYLE )
+ {
+ const Color &rCol = GetSettings().GetStyleSettings().GetWindowColor();
+ SetBackground( rCol );
+ Font aFont( pTextView->GetTextEngine()->GetFont() );
+ aFont.SetFillColor( rCol );
+ pTextView->GetTextEngine()->SetFont( aFont );
+ }
+ break;
+ }
+}
+
+void TextViewOutWin::MouseMove( const MouseEvent &rEvt )
+{
+ if ( pTextView )
+ pTextView->MouseMove( rEvt );
+}
+
+void TextViewOutWin::MouseButtonUp( const MouseEvent &rEvt )
+{
+ if ( pTextView )
+ {
+ pTextView->MouseButtonUp( rEvt );
+ SfxBindings& rBindings = ((SwSrcEditWindow*)GetParent())->GetSrcView()->GetViewFrame()->GetBindings();
+ rBindings.Invalidate( SID_TABLE_CELL );
+ rBindings.Invalidate( SID_CUT );
+ rBindings.Invalidate( SID_COPY );
+ }
+}
+
+void TextViewOutWin::MouseButtonDown( const MouseEvent &rEvt )
+{
+ GrabFocus();
+ if ( pTextView )
+ pTextView->MouseButtonDown( rEvt );
+}
+
+void TextViewOutWin::Command( const CommandEvent& rCEvt )
+{
+ switch(rCEvt.GetCommand())
+ {
+ case COMMAND_CONTEXTMENU:
+ ((SwSrcEditWindow*)GetParent())->GetSrcView()->GetViewFrame()->
+ GetDispatcher()->ExecutePopup();
+ break;
+ case COMMAND_WHEEL:
+ case COMMAND_STARTAUTOSCROLL:
+ case COMMAND_AUTOSCROLL:
+ {
+ const CommandWheelData* pWData = rCEvt.GetWheelData();
+ if( !pWData || COMMAND_WHEEL_ZOOM != pWData->GetMode() )
+ {
+ ((SwSrcEditWindow*)GetParent())->HandleWheelCommand( rCEvt );
+ }
+ }
+ break;
+
+ default:
+ if ( pTextView )
+ pTextView->Command( rCEvt );
+ else
+ Window::Command(rCEvt);
+ }
+}
+
+void TextViewOutWin::KeyInput( const KeyEvent& rKEvt )
+{
+ sal_Bool bDone = sal_False;
+ SwSrcEditWindow* pSrcEditWin = (SwSrcEditWindow*)GetParent();
+ bool bChange = !pSrcEditWin->IsReadonly() || !TextEngine::DoesKeyChangeText( rKEvt );
+ if(bChange)
+ bDone = pTextView->KeyInput( rKEvt );
+
+ SfxBindings& rBindings = ((SwSrcEditWindow*)GetParent())->GetSrcView()->GetViewFrame()->GetBindings();
+ if ( !bDone )
+ {
+ if ( !SfxViewShell::Current()->KeyInput( rKEvt ) )
+ Window::KeyInput( rKEvt );
+ }
+ else
+ {
+ rBindings.Invalidate( SID_TABLE_CELL );
+ if ( rKEvt.GetKeyCode().GetGroup() == KEYGROUP_CURSOR )
+ rBindings.Update( SID_BASICIDE_STAT_POS );
+ if (pSrcEditWin->GetTextEngine()->IsModified() )
+ {
+ rBindings.Invalidate( SID_SAVEDOC );
+ rBindings.Invalidate( SID_DOC_MODIFIED );
+ }
+ if( rKEvt.GetKeyCode().GetCode() == KEY_INSERT )
+ rBindings.Invalidate( SID_ATTR_INSERT );
+ }
+
+ rBindings.Invalidate( SID_CUT );
+ rBindings.Invalidate( SID_COPY );
+
+ SwDocShell* pDocShell = pSrcEditWin->GetSrcView()->GetDocShell();
+ if(pSrcEditWin->GetTextEngine()->IsModified())
+ {
+ pDocShell->SetModified();
+ }
+}
+
+void TextViewOutWin::Paint( const Rectangle& rRect )
+{
+ pTextView->Paint( rRect );
+}
+
+void SwSrcEditWindow::CreateTextEngine()
+{
+ const Color &rCol = GetSettings().GetStyleSettings().GetWindowColor();
+ pOutWin = new TextViewOutWin(this, 0);
+ pOutWin->SetBackground(Wallpaper(rCol));
+ pOutWin->SetPointer(Pointer(POINTER_TEXT));
+ pOutWin->Show();
+
+ // create Scrollbars
+ pHScrollbar = new ScrollBar(this, WB_3DLOOK |WB_HSCROLL|WB_DRAG);
+ pHScrollbar->EnableRTL( false ); // --- RTL --- no mirroring for scrollbars
+ pHScrollbar->SetScrollHdl(LINK(this, SwSrcEditWindow, ScrollHdl));
+ pHScrollbar->Show();
+
+ pVScrollbar = new ScrollBar(this, WB_3DLOOK |WB_VSCROLL|WB_DRAG);
+ pVScrollbar->EnableRTL( false ); // --- RTL --- no mirroring for scrollbars
+ pVScrollbar->SetScrollHdl(LINK(this, SwSrcEditWindow, ScrollHdl));
+ pHScrollbar->EnableDrag();
+ pVScrollbar->Show();
+
+ pTextEngine = new ExtTextEngine;
+ pTextView = new ExtTextView( pTextEngine, pOutWin );
+ pTextView->SetAutoIndentMode(true);
+ pOutWin->SetTextView(pTextView);
+
+ pTextEngine->SetUpdateMode( false );
+ pTextEngine->InsertView( pTextView );
+
+ Font aFont;
+ aFont.SetTransparent( false );
+ aFont.SetFillColor( rCol );
+ SetPointFont( aFont );
+ aFont = GetFont();
+ aFont.SetFillColor( rCol );
+ pOutWin->SetFont( aFont );
+ pTextEngine->SetFont( aFont );
+
+ aSyntaxIdleTimer.SetTimeout( SYNTAX_HIGHLIGHT_TIMEOUT );
+ aSyntaxIdleTimer.SetTimeoutHdl( LINK( this, SwSrcEditWindow, SyntaxTimerHdl ) );
+
+ pTextEngine->EnableUndo( true );
+ pTextEngine->SetUpdateMode( true );
+
+ pTextView->ShowCursor( true, true );
+ InitScrollBars();
+ StartListening( *pTextEngine );
+
+ SfxBindings& rBind = GetSrcView()->GetViewFrame()->GetBindings();
+ rBind.Invalidate( SID_TABLE_CELL );
+}
+
+void SwSrcEditWindow::SetScrollBarRanges()
+{
+ // Extra method, not InitScrollBars, because also for TextEngine events.
+
+ pHScrollbar->SetRange( Range( 0, nCurTextWidth-1 ) );
+ pVScrollbar->SetRange( Range(0, pTextEngine->GetTextHeight()-1) );
+}
+
+void SwSrcEditWindow::InitScrollBars()
+{
+ SetScrollBarRanges();
+
+ Size aOutSz( pOutWin->GetOutputSizePixel() );
+ pVScrollbar->SetVisibleSize( aOutSz.Height() );
+ pVScrollbar->SetPageSize( aOutSz.Height() * 8 / 10 );
+ pVScrollbar->SetLineSize( pOutWin->GetTextHeight() );
+ pVScrollbar->SetThumbPos( pTextView->GetStartDocPos().Y() );
+ pHScrollbar->SetVisibleSize( aOutSz.Width() );
+ pHScrollbar->SetPageSize( aOutSz.Width() * 8 / 10 );
+ pHScrollbar->SetLineSize( pOutWin->GetTextWidth(OUString('x')) );
+ pHScrollbar->SetThumbPos( pTextView->GetStartDocPos().X() );
+
+}
+
+IMPL_LINK(SwSrcEditWindow, ScrollHdl, ScrollBar*, pScroll)
+{
+ if(pScroll == pVScrollbar)
+ {
+ long nDiff = pTextView->GetStartDocPos().Y() - pScroll->GetThumbPos();
+ GetTextView()->Scroll( 0, nDiff );
+ pTextView->ShowCursor( false, true );
+ pScroll->SetThumbPos( pTextView->GetStartDocPos().Y() );
+ }
+ else
+ {
+ long nDiff = pTextView->GetStartDocPos().X() - pScroll->GetThumbPos();
+ GetTextView()->Scroll( nDiff, 0 );
+ pTextView->ShowCursor( false, true );
+ pScroll->SetThumbPos( pTextView->GetStartDocPos().X() );
+ }
+ GetSrcView()->GetViewFrame()->GetBindings().Invalidate( SID_TABLE_CELL );
+ return 0;
+}
+
+IMPL_LINK( SwSrcEditWindow, SyntaxTimerHdl, Timer *, pTimer )
+{
+ Time aSyntaxCheckStart( Time::SYSTEM );
+ SAL_WARN_IF(pTextView == 0, "sw", "No View yet, but syntax highlighting?!");
+
+ bHighlighting = sal_True;
+ sal_uInt16 nCount = 0;
+ // at first the region around the cursor is processed
+ TextSelection aSel = pTextView->GetSelection();
+ sal_uInt16 nCur = (sal_uInt16)aSel.GetStart().GetPara();
+ if(nCur > 40)
+ nCur -= 40;
+ else
+ nCur = 0;
+ if(!aSyntaxLineTable.empty())
+ for(sal_uInt16 i = 0; i < 80 && nCount < 40; i++, nCur++)
+ {
+ if(aSyntaxLineTable.find(nCur) != aSyntaxLineTable.end())
+ {
+ DoSyntaxHighlight( nCur );
+ aSyntaxLineTable.erase( nCur );
+ nCount++;
+ if(aSyntaxLineTable.empty())
+ break;
+ if((Time( Time::SYSTEM ).GetTime() - aSyntaxCheckStart.GetTime()) > MAX_HIGHLIGHTTIME )
+ {
+ pTimer->SetTimeout( 2 * SYNTAX_HIGHLIGHT_TIMEOUT );
+ break;
+ }
+ }
+ }
+
+ // when there is still anything left by then, go on from the beginning
+ while ( !aSyntaxLineTable.empty() && nCount < MAX_SYNTAX_HIGHLIGHT)
+ {
+ sal_uInt16 nLine = *aSyntaxLineTable.begin();
+ DoSyntaxHighlight( nLine );
+ aSyntaxLineTable.erase(nLine);
+ nCount ++;
+ if(Time( Time::SYSTEM ).GetTime() - aSyntaxCheckStart.GetTime() > MAX_HIGHLIGHTTIME)
+ {
+ pTimer->SetTimeout( 2 * SYNTAX_HIGHLIGHT_TIMEOUT );
+ break;
+ }
+ }
+
+ if(!aSyntaxLineTable.empty() && !pTimer->IsActive())
+ pTimer->Start();
+ // SyntaxTimerHdl is called when text changed
+ // => good opportunity to determine text width!
+ long nPrevTextWidth = nCurTextWidth;
+ nCurTextWidth = pTextEngine->CalcTextWidth() + 25; // kleine Toleranz
+ if ( nCurTextWidth != nPrevTextWidth )
+ SetScrollBarRanges();
+ bHighlighting = sal_False;
+
+ return 0;
+}
+
+void SwSrcEditWindow::DoSyntaxHighlight( sal_uInt16 nPara )
+{
+ // Because of DelayedSyntaxHighlight it could happen,
+ // that the line doesn't exist anymore!
+ if ( nPara < pTextEngine->GetParagraphCount() )
+ {
+ sal_Bool bTempModified = IsModified();
+ pTextEngine->RemoveAttribs( nPara, true );
+ OUString aSource( pTextEngine->GetText( nPara ) );
+ pTextEngine->SetUpdateMode( false );
+ ImpDoHighlight( aSource, nPara );
+ TextView* pTmp = pTextEngine->GetActiveView();
+ pTmp->SetAutoScroll(false);
+ pTextEngine->SetActiveView(0);
+ pTextEngine->SetUpdateMode( true );
+ pTextEngine->SetActiveView(pTmp);
+ pTmp->SetAutoScroll(true);
+ pTmp->ShowCursor( false/*pTmp->IsAutoScroll()*/ );
+
+ if(!bTempModified)
+ ClearModifyFlag();
+ }
+}
+
+void SwSrcEditWindow::DoDelayedSyntaxHighlight( sal_uInt16 nPara )
+{
+ if ( !bHighlighting && bDoSyntaxHighlight )
+ {
+ aSyntaxLineTable.insert( nPara );
+ aSyntaxIdleTimer.Start();
+ }
+}
+
+void SwSrcEditWindow::ImpDoHighlight( const OUString& rSource, sal_uInt16 nLineOff )
+{
+ SwTextPortions aPortionList;
+ lcl_Highlight(rSource, aPortionList);
+
+ size_t nCount = aPortionList.size();
+ if ( !nCount )
+ return;
+
+ SwTextPortion& rLast = aPortionList[nCount-1];
+ if ( rLast.nStart > rLast.nEnd ) // Only until Bug from MD is resolved
+ {
+ nCount--;
+ aPortionList.pop_back();
+ if ( !nCount )
+ return;
+ }
+
+ {
+ // Only blanks and tabs have to be attributed along.
+ // When two identical attributes are placed consecutively,
+ // it optimises the TextEngine.
+ sal_uInt16 nLastEnd = 0;
+
+ for ( size_t i = 0; i < nCount; i++ )
+ {
+ SwTextPortion& r = aPortionList[i];
+ SAL_WARN_IF(
+ r.nLine != aPortionList[0].nLine, "sw.level2",
+ "multiple lines after all?");
+ if ( r.nStart > r.nEnd ) // only until Bug from MD is resolved
+ continue;
+
+ if ( r.nStart > nLastEnd )
+ {
+ // Can I rely on the fact that all except blank and tab
+ // are being highlighted?!
+ r.nStart = nLastEnd;
+ }
+ nLastEnd = r.nEnd+1;
+ if ( ( i == (nCount-1) ) && ( r.nEnd < rSource.getLength() ) )
+ r.nEnd = rSource.getLength();
+ }
+ }
+
+ for ( size_t i = 0; i < aPortionList.size(); i++ )
+ {
+ SwTextPortion& r = aPortionList[i];
+ if ( r.nStart > r.nEnd ) // only until Bug from MD is resolved
+ continue;
+ if(r.eType != svtools::HTMLSGML &&
+ r.eType != svtools::HTMLCOMMENT &&
+ r.eType != svtools::HTMLKEYWORD &&
+ r.eType != svtools::HTMLUNKNOWN)
+ r.eType = svtools::HTMLUNKNOWN;
+ Color aColor((ColorData)SW_MOD()->GetColorConfig().GetColorValue((svtools::ColorConfigEntry)r.eType).nColor);
+ sal_uInt16 nLine = nLineOff+r.nLine;
+ pTextEngine->SetAttrib( TextAttribFontColor( aColor ), nLine, r.nStart, r.nEnd+1, true );
+ }
+}
+
+void SwSrcEditWindow::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
+{
+ if ( rHint.ISA( TextHint ) )
+ {
+ const TextHint& rTextHint = (const TextHint&)rHint;
+ if( rTextHint.GetId() == TEXT_HINT_VIEWSCROLLED )
+ {
+ pHScrollbar->SetThumbPos( pTextView->GetStartDocPos().X() );
+ pVScrollbar->SetThumbPos( pTextView->GetStartDocPos().Y() );
+ }
+ else if( rTextHint.GetId() == TEXT_HINT_TEXTHEIGHTCHANGED )
+ {
+ if ( (long)pTextEngine->GetTextHeight() < pOutWin->GetOutputSizePixel().Height() )
+ pTextView->Scroll( 0, pTextView->GetStartDocPos().Y() );
+ pVScrollbar->SetThumbPos( pTextView->GetStartDocPos().Y() );
+ SetScrollBarRanges();
+ }
+ else if( ( rTextHint.GetId() == TEXT_HINT_PARAINSERTED ) ||
+ ( rTextHint.GetId() == TEXT_HINT_PARACONTENTCHANGED ) )
+ {
+ DoDelayedSyntaxHighlight( (sal_uInt16)rTextHint.GetValue() );
+ }
+ }
+}
+
+void SwSrcEditWindow::Invalidate(sal_uInt16 )
+{
+ pOutWin->Invalidate();
+ Window::Invalidate();
+
+}
+
+void SwSrcEditWindow::Command( const CommandEvent& rCEvt )
+{
+ switch(rCEvt.GetCommand())
+ {
+ case COMMAND_WHEEL:
+ case COMMAND_STARTAUTOSCROLL:
+ case COMMAND_AUTOSCROLL:
+ {
+ const CommandWheelData* pWData = rCEvt.GetWheelData();
+ if( !pWData || COMMAND_WHEEL_ZOOM != pWData->GetMode() )
+ HandleScrollCommand( rCEvt, pHScrollbar, pVScrollbar );
+ }
+ break;
+ default:
+ Window::Command(rCEvt);
+ }
+}
+
+void SwSrcEditWindow::HandleWheelCommand( const CommandEvent& rCEvt )
+{
+ pTextView->Command(rCEvt);
+ HandleScrollCommand( rCEvt, pHScrollbar, pVScrollbar );
+}
+
+void SwSrcEditWindow::GetFocus()
+{
+ pOutWin->GrabFocus();
+}
+
+static bool lcl_GetLanguagesForEncoding(rtl_TextEncoding eEnc, LanguageType aLanguages[])
+{
+ switch(eEnc)
+ {
+ case RTL_TEXTENCODING_UTF7 :
+ case RTL_TEXTENCODING_UTF8 :
+ // don#t fill - all LANGUAGE_SYSTEM means unicode font has to be used
+ break;
+
+ case RTL_TEXTENCODING_ISO_8859_3:
+ case RTL_TEXTENCODING_ISO_8859_1 :
+ case RTL_TEXTENCODING_MS_1252 :
+ case RTL_TEXTENCODING_APPLE_ROMAN :
+ case RTL_TEXTENCODING_IBM_850 :
+ case RTL_TEXTENCODING_ISO_8859_14 :
+ case RTL_TEXTENCODING_ISO_8859_15 :
+ //fill with western languages
+ aLanguages[0] = LANGUAGE_GERMAN;
+ aLanguages[1] = LANGUAGE_FRENCH;
+ aLanguages[2] = LANGUAGE_ITALIAN;
+ aLanguages[3] = LANGUAGE_SPANISH;
+ break;
+
+ case RTL_TEXTENCODING_IBM_865 :
+ //scandinavian
+ aLanguages[0] = LANGUAGE_FINNISH;
+ aLanguages[1] = LANGUAGE_NORWEGIAN;
+ aLanguages[2] = LANGUAGE_SWEDISH;
+ aLanguages[3] = LANGUAGE_DANISH;
+ break;
+
+ case RTL_TEXTENCODING_ISO_8859_10 :
+ case RTL_TEXTENCODING_ISO_8859_13 :
+ case RTL_TEXTENCODING_ISO_8859_2 :
+ case RTL_TEXTENCODING_IBM_852 :
+ case RTL_TEXTENCODING_MS_1250 :
+ case RTL_TEXTENCODING_APPLE_CENTEURO :
+ aLanguages[0] = LANGUAGE_POLISH;
+ aLanguages[1] = LANGUAGE_CZECH;
+ aLanguages[2] = LANGUAGE_HUNGARIAN;
+ aLanguages[3] = LANGUAGE_SLOVAK;
+ break;
+
+ case RTL_TEXTENCODING_ISO_8859_4 :
+ case RTL_TEXTENCODING_IBM_775 :
+ case RTL_TEXTENCODING_MS_1257 :
+ aLanguages[0] = LANGUAGE_LATVIAN ;
+ aLanguages[1] = LANGUAGE_LITHUANIAN;
+ aLanguages[2] = LANGUAGE_ESTONIAN ;
+ break;
+
+ case RTL_TEXTENCODING_IBM_863 : aLanguages[0] = LANGUAGE_FRENCH_CANADIAN; break;
+ case RTL_TEXTENCODING_APPLE_FARSI : aLanguages[0] = LANGUAGE_FARSI; break;
+ case RTL_TEXTENCODING_APPLE_ROMANIAN:aLanguages[0] = LANGUAGE_ROMANIAN; break;
+
+ case RTL_TEXTENCODING_IBM_861 :
+ case RTL_TEXTENCODING_APPLE_ICELAND :
+ aLanguages[0] = LANGUAGE_ICELANDIC;
+ break;
+
+ case RTL_TEXTENCODING_APPLE_CROATIAN:aLanguages[0] = LANGUAGE_CROATIAN; break;
+
+ case RTL_TEXTENCODING_IBM_437 :
+ case RTL_TEXTENCODING_ASCII_US : aLanguages[0] = LANGUAGE_ENGLISH; break;
+
+ case RTL_TEXTENCODING_IBM_862 :
+ case RTL_TEXTENCODING_MS_1255 :
+ case RTL_TEXTENCODING_APPLE_HEBREW :
+ case RTL_TEXTENCODING_ISO_8859_8 :
+ aLanguages[0] = LANGUAGE_HEBREW;
+ break;
+
+ case RTL_TEXTENCODING_IBM_857 :
+ case RTL_TEXTENCODING_MS_1254 :
+ case RTL_TEXTENCODING_APPLE_TURKISH:
+ case RTL_TEXTENCODING_ISO_8859_9 :
+ aLanguages[0] = LANGUAGE_TURKISH;
+ break;
+
+ case RTL_TEXTENCODING_IBM_860 :
+ aLanguages[0] = LANGUAGE_PORTUGUESE;
+ break;
+
+ case RTL_TEXTENCODING_IBM_869 :
+ case RTL_TEXTENCODING_MS_1253 :
+ case RTL_TEXTENCODING_APPLE_GREEK :
+ case RTL_TEXTENCODING_ISO_8859_7 :
+ case RTL_TEXTENCODING_IBM_737 :
+ aLanguages[0] = LANGUAGE_GREEK;
+ break;
+
+ case RTL_TEXTENCODING_KOI8_R :
+ case RTL_TEXTENCODING_ISO_8859_5 :
+ case RTL_TEXTENCODING_IBM_855 :
+ case RTL_TEXTENCODING_MS_1251 :
+ case RTL_TEXTENCODING_IBM_866 :
+ case RTL_TEXTENCODING_APPLE_CYRILLIC :
+ aLanguages[0] = LANGUAGE_RUSSIAN;
+ break;
+
+ case RTL_TEXTENCODING_APPLE_UKRAINIAN:
+ case RTL_TEXTENCODING_KOI8_U:
+ aLanguages[0] = LANGUAGE_UKRAINIAN;
+ break;
+
+ case RTL_TEXTENCODING_IBM_864 :
+ case RTL_TEXTENCODING_MS_1256 :
+ case RTL_TEXTENCODING_ISO_8859_6 :
+ case RTL_TEXTENCODING_APPLE_ARABIC :
+ aLanguages[0] = LANGUAGE_ARABIC_SAUDI_ARABIA;
+ break;
+
+ case RTL_TEXTENCODING_APPLE_CHINTRAD :
+ case RTL_TEXTENCODING_MS_950 :
+ case RTL_TEXTENCODING_GBT_12345 :
+ case RTL_TEXTENCODING_BIG5 :
+ case RTL_TEXTENCODING_EUC_TW :
+ case RTL_TEXTENCODING_BIG5_HKSCS :
+ aLanguages[0] = LANGUAGE_CHINESE_TRADITIONAL;
+ break;
+
+ case RTL_TEXTENCODING_EUC_JP :
+ case RTL_TEXTENCODING_ISO_2022_JP :
+ case RTL_TEXTENCODING_JIS_X_0201 :
+ case RTL_TEXTENCODING_JIS_X_0208 :
+ case RTL_TEXTENCODING_JIS_X_0212 :
+ case RTL_TEXTENCODING_APPLE_JAPANESE :
+ case RTL_TEXTENCODING_MS_932 :
+ case RTL_TEXTENCODING_SHIFT_JIS :
+ aLanguages[0] = LANGUAGE_JAPANESE;
+ break;
+
+ case RTL_TEXTENCODING_GB_2312 :
+ case RTL_TEXTENCODING_MS_936 :
+ case RTL_TEXTENCODING_GBK :
+ case RTL_TEXTENCODING_GB_18030 :
+ case RTL_TEXTENCODING_APPLE_CHINSIMP :
+ case RTL_TEXTENCODING_EUC_CN :
+ case RTL_TEXTENCODING_ISO_2022_CN :
+ aLanguages[0] = LANGUAGE_CHINESE_SIMPLIFIED;
+ break;
+
+ case RTL_TEXTENCODING_APPLE_KOREAN :
+ case RTL_TEXTENCODING_MS_949 :
+ case RTL_TEXTENCODING_EUC_KR :
+ case RTL_TEXTENCODING_ISO_2022_KR :
+ case RTL_TEXTENCODING_MS_1361 :
+ aLanguages[0] = LANGUAGE_KOREAN;
+ break;
+
+ case RTL_TEXTENCODING_APPLE_THAI :
+ case RTL_TEXTENCODING_MS_874 :
+ case RTL_TEXTENCODING_TIS_620 :
+ aLanguages[0] = LANGUAGE_THAI;
+ break;
+ default: aLanguages[0] = Application::GetSettings().GetUILanguageTag().getLanguageType();
+ }
+ return aLanguages[0] != LANGUAGE_SYSTEM;
+}
+void SwSrcEditWindow::SetFont()
+{
+ OUString sFontName(
+ officecfg::Office::Common::Font::SourceViewFont::FontName::get().
+ get_value_or(OUString()));
+ if(sFontName.isEmpty())
+ {
+ LanguageType aLanguages[5] =
+ {
+ LANGUAGE_SYSTEM, LANGUAGE_SYSTEM, LANGUAGE_SYSTEM, LANGUAGE_SYSTEM, LANGUAGE_SYSTEM
+ };
+ Font aFont;
+ if(lcl_GetLanguagesForEncoding(eSourceEncoding, aLanguages))
+ {
+ //TODO: check for multiple languages
+ aFont = OutputDevice::GetDefaultFont(DEFAULTFONT_FIXED, aLanguages[0], 0, this);
+ }
+ else
+ aFont = OutputDevice::GetDefaultFont(DEFAULTFONT_SANS_UNICODE,
+ Application::GetSettings().GetLanguageTag().getLanguageType(), 0, this);
+ sFontName = aFont.GetName();
+ }
+ const SvxFontListItem* pFontListItem =
+ (const SvxFontListItem* )pSrcView->GetDocShell()->GetItem( SID_ATTR_CHAR_FONTLIST );
+ const FontList* pList = pFontListItem->GetFontList();
+ FontInfo aInfo = pList->Get(sFontName,WEIGHT_NORMAL, ITALIC_NONE);
+
+ const Font& rFont = GetTextEngine()->GetFont();
+ Font aFont(aInfo);
+ Size aSize(rFont.GetSize());
+ //font height is stored in point and set in twip
+ aSize.Height() =
+ officecfg::Office::Common::Font::SourceViewFont::FontHeight::get() * 20;
+ aFont.SetSize(pOutWin->LogicToPixel(aSize, MAP_TWIP));
+ GetTextEngine()->SetFont( aFont );
+ pOutWin->SetFont(aFont);
+}
+
+void SwSrcEditWindow::SetTextEncoding(rtl_TextEncoding eEncoding)
+{
+ eSourceEncoding = eEncoding;
+ SetFont();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/envelp/envimg.cxx b/sw/source/core/uibase/envelp/envimg.cxx
new file mode 100644
index 000000000000..6bdbe02f6e31
--- /dev/null
+++ b/sw/source/core/uibase/envelp/envimg.cxx
@@ -0,0 +1,355 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <hintids.hxx>
+#include <comphelper/string.hxx>
+#include <tools/stream.hxx>
+#include <tools/resid.hxx>
+#include <sfx2/app.hxx>
+#include <editeng/paperinf.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <unotools/useroptions.hxx>
+#include <tools/shl.hxx>
+#include <swmodule.hxx>
+#include <swtypes.hxx>
+#include <envimg.hxx>
+
+#include <cmdid.h>
+#include <envelp.hrc>
+
+#include <unomid.h>
+
+#ifdef WNT
+#define NEXTLINE OUString("\r\n")
+#else
+#define NEXTLINE '\n'
+#endif
+
+using namespace utl;
+using namespace ::com::sun::star::uno;
+
+TYPEINIT1_AUTOFACTORY( SwEnvItem, SfxPoolItem );
+
+SW_DLLPUBLIC OUString MakeSender()
+{
+ SvtUserOptions& rUserOpt = SW_MOD()->GetUserOptions();
+
+ OUString sRet;
+ OUString sSenderToken(SW_RES(STR_SENDER_TOKENS));
+ sal_Int32 nTokenCount = comphelper::string::getTokenCount(sSenderToken, ';');
+ sal_Int32 nSttPos = 0;
+ bool bLastLength = true;
+ for( sal_Int32 i = 0; i < nTokenCount; i++ )
+ {
+ OUString sToken = sSenderToken.getToken( 0, ';', nSttPos );
+ if (sToken == "COMPANY")
+ {
+ sal_Int32 nOldLen = sRet.getLength();
+ sRet += rUserOpt.GetCompany();
+ bLastLength = sRet.getLength() != nOldLen;
+ }
+ else if (sToken == "CR")
+ {
+ if(bLastLength)
+ sRet += OUString(NEXTLINE);
+ bLastLength = true;
+ }
+ else if (sToken == "FIRSTNAME")
+ sRet += rUserOpt.GetFirstName();
+ else if (sToken == "LASTNAME")
+ sRet += rUserOpt.GetLastName();
+ else if (sToken == "ADDRESS")
+ sRet += rUserOpt.GetStreet();
+ else if (sToken == "COUNTRY")
+ sRet += rUserOpt.GetCountry();
+ else if (sToken == "POSTALCODE")
+ sRet += rUserOpt.GetZip();
+ else if (sToken == "CITY")
+ sRet += rUserOpt.GetCity();
+ else if (sToken == "STATEPROV")
+ sRet += rUserOpt.GetState();
+ else if (!sToken.isEmpty()) //spaces
+ sRet += sToken;
+ }
+ return sRet;
+}
+
+SwEnvItem::SwEnvItem() :
+ SfxPoolItem(FN_ENVELOP)
+{
+ aAddrText = aEmptyOUStr;
+ bSend = sal_True;
+ aSendText = MakeSender();
+ lSendFromLeft = 566; // 1 cm
+ lSendFromTop = 566; // 1 cm
+ Size aEnvSz = SvxPaperInfo::GetPaperSize(PAPER_ENV_C65);
+ lWidth = aEnvSz.Width();
+ lHeight = aEnvSz.Height();
+ eAlign = ENV_HOR_LEFT;
+ bPrintFromAbove = sal_True;
+ lShiftRight = 0;
+ lShiftDown = 0;
+
+ lAddrFromLeft = std::max(lWidth, lHeight) / 2;
+ lAddrFromTop = std::min(lWidth, lHeight) / 2;
+}
+
+SwEnvItem::SwEnvItem(const SwEnvItem& rItem) :
+ SfxPoolItem(FN_ENVELOP),
+ aAddrText (rItem.aAddrText),
+ bSend (rItem.bSend),
+ aSendText (rItem.aSendText),
+ lAddrFromLeft (rItem.lAddrFromLeft),
+ lAddrFromTop (rItem.lAddrFromTop),
+ lSendFromLeft (rItem.lSendFromLeft),
+ lSendFromTop (rItem.lSendFromTop),
+ lWidth (rItem.lWidth),
+ lHeight (rItem.lHeight),
+ eAlign (rItem.eAlign),
+ bPrintFromAbove(rItem.bPrintFromAbove),
+ lShiftRight (rItem.lShiftRight),
+ lShiftDown (rItem.lShiftDown)
+{
+}
+
+SwEnvItem& SwEnvItem::operator =(const SwEnvItem& rItem)
+{
+ aAddrText = rItem.aAddrText;
+ bSend = rItem.bSend;
+ aSendText = rItem.aSendText;
+ lSendFromLeft = rItem.lSendFromLeft;
+ lSendFromTop = rItem.lSendFromTop;
+ lAddrFromLeft = rItem.lAddrFromLeft;
+ lAddrFromTop = rItem.lAddrFromTop;
+ lWidth = rItem.lWidth;
+ lHeight = rItem.lHeight;
+ eAlign = rItem.eAlign;
+ bPrintFromAbove = rItem.bPrintFromAbove;
+ lShiftRight = rItem.lShiftRight;
+ lShiftDown = rItem.lShiftDown;
+ return *this;
+}
+
+bool SwEnvItem::operator ==(const SfxPoolItem& rItem) const
+{
+ const SwEnvItem& rEnv = (const SwEnvItem&) rItem;
+
+ return aAddrText == rEnv.aAddrText &&
+ bSend == rEnv.bSend &&
+ aSendText == rEnv.aSendText &&
+ lSendFromLeft == rEnv.lSendFromLeft &&
+ lSendFromTop == rEnv.lSendFromTop &&
+ lAddrFromLeft == rEnv.lAddrFromLeft &&
+ lAddrFromTop == rEnv.lAddrFromTop &&
+ lWidth == rEnv.lWidth &&
+ lHeight == rEnv.lHeight &&
+ eAlign == rEnv.eAlign &&
+ bPrintFromAbove == rEnv.bPrintFromAbove &&
+ lShiftRight == rEnv.lShiftRight &&
+ lShiftDown == rEnv.lShiftDown;
+}
+
+SfxPoolItem* SwEnvItem::Clone(SfxItemPool*) const
+{
+ return new SwEnvItem(*this);
+}
+
+SwEnvCfgItem::SwEnvCfgItem() :
+ ConfigItem("Office.Writer/Envelope")
+{
+ Sequence<OUString> aNames = GetPropertyNames();
+ Sequence<Any> aValues = GetProperties(aNames);
+ EnableNotification(aNames);
+ const Any* pValues = aValues.getConstArray();
+ OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
+ if(aValues.getLength() == aNames.getLength())
+ {
+ for(int nProp = 0; nProp < aNames.getLength(); nProp++)
+ {
+ if(pValues[nProp].hasValue())
+ {
+ switch(nProp)
+ {
+ case 0: pValues[nProp] >>= aEnvItem.aAddrText; break;// "Inscription/Addressee",
+ case 1: pValues[nProp] >>= aEnvItem.aSendText; break;// "Inscription/Sender",
+ case 2: aEnvItem.bSend = *(sal_Bool*)pValues[nProp].getValue(); break;// "Inscription/UseSender",
+ case 3:
+ pValues[nProp] >>= aEnvItem.lAddrFromLeft;// "Format/AddresseeFromLeft",
+ aEnvItem.lAddrFromLeft = MM100_TO_TWIP(aEnvItem.lAddrFromLeft);
+ break;
+ case 4:
+ pValues[nProp] >>= aEnvItem.lAddrFromTop; // "Format/AddresseeFromTop",
+ aEnvItem.lAddrFromTop = MM100_TO_TWIP(aEnvItem.lAddrFromTop);
+ break;
+ case 5:
+ pValues[nProp] >>= aEnvItem.lSendFromLeft; // "Format/SenderFromLeft",
+ aEnvItem.lSendFromLeft = MM100_TO_TWIP(aEnvItem.lSendFromLeft);
+ break;
+ case 6:
+ pValues[nProp] >>= aEnvItem.lSendFromTop;// "Format/SenderFromTop",
+ aEnvItem.lSendFromTop = MM100_TO_TWIP(aEnvItem.lSendFromTop);
+ break;
+ case 7:
+ pValues[nProp] >>= aEnvItem.lWidth; // "Format/Width",
+ aEnvItem.lWidth = MM100_TO_TWIP(aEnvItem.lWidth);
+ break;
+ case 8:
+ pValues[nProp] >>= aEnvItem.lHeight; // "Format/Height",
+ aEnvItem.lHeight = MM100_TO_TWIP(aEnvItem.lHeight);
+ break;
+ case 9:
+ {
+ sal_Int32 nTemp = 0;
+ pValues[nProp] >>= nTemp; aEnvItem.eAlign = (SwEnvAlign)nTemp; break;// "Print/Alignment",
+ }
+ case 10: aEnvItem.bPrintFromAbove = *(sal_Bool*)pValues[nProp].getValue(); break;// "Print/FromAbove",
+ case 11:
+ pValues[nProp] >>= aEnvItem.lShiftRight;
+ aEnvItem.lShiftRight = MM100_TO_TWIP(aEnvItem.lShiftRight);// "Print/Right",
+ break;
+ case 12:
+ pValues[nProp] >>= aEnvItem.lShiftDown;
+ aEnvItem.lShiftDown = MM100_TO_TWIP(aEnvItem.lShiftDown);
+ break;// "Print/Down"
+ }
+ }
+ }
+ }
+}
+
+SwEnvCfgItem::~SwEnvCfgItem()
+{
+}
+
+void SwEnvCfgItem::Commit()
+{
+ Sequence<OUString> aNames = GetPropertyNames();
+ Sequence<Any> aValues(aNames.getLength());
+ Any* pValues = aValues.getArray();
+
+ const Type& rType = ::getBooleanCppuType();
+ for(int nProp = 0; nProp < aNames.getLength(); nProp++)
+ {
+ switch(nProp)
+ {
+ case 0: pValues[nProp] <<= aEnvItem.aAddrText; break;// "Inscription/Addressee",
+ case 1: pValues[nProp] <<= aEnvItem.aSendText; break;// "Inscription/Sender",
+ case 2: pValues[nProp].setValue(&aEnvItem.bSend, rType);break;// "Inscription/UseSender",
+ case 3: pValues[nProp] <<= static_cast <sal_Int32>(TWIP_TO_MM100(aEnvItem.lAddrFromLeft)) ; break;// "Format/AddresseeFromLeft",
+ case 4: pValues[nProp] <<= static_cast <sal_Int32>(TWIP_TO_MM100(aEnvItem.lAddrFromTop)) ; break;// "Format/AddresseeFromTop",
+ case 5: pValues[nProp] <<= static_cast <sal_Int32>(TWIP_TO_MM100(aEnvItem.lSendFromLeft)) ; break;// "Format/SenderFromLeft",
+ case 6: pValues[nProp] <<= static_cast <sal_Int32>(TWIP_TO_MM100(aEnvItem.lSendFromTop)) ; break;// "Format/SenderFromTop",
+ case 7: pValues[nProp] <<= static_cast <sal_Int32>(TWIP_TO_MM100(aEnvItem.lWidth)) ; break;// "Format/Width",
+ case 8: pValues[nProp] <<= static_cast <sal_Int32>(TWIP_TO_MM100(aEnvItem.lHeight)) ; break;// "Format/Height",
+ case 9: pValues[nProp] <<= sal_Int32(aEnvItem.eAlign); break;// "Print/Alignment",
+ case 10: pValues[nProp].setValue(&aEnvItem.bPrintFromAbove, rType); break;// "Print/FromAbove",
+ case 11: pValues[nProp] <<= static_cast <sal_Int32>(TWIP_TO_MM100(aEnvItem.lShiftRight));break; // "Print/Right",
+ case 12: pValues[nProp] <<= static_cast <sal_Int32>(TWIP_TO_MM100(aEnvItem.lShiftDown)); break;// "Print/Down"
+ }
+ }
+ PutProperties(aNames, aValues);
+}
+
+void SwEnvCfgItem::Notify( const ::com::sun::star::uno::Sequence< OUString >& ) {}
+
+Sequence<OUString> SwEnvCfgItem::GetPropertyNames()
+{
+ static const char* aPropNames[] =
+ {
+ "Inscription/Addressee", // 0
+ "Inscription/Sender", // 1
+ "Inscription/UseSender", // 2
+ "Format/AddresseeFromLeft", // 3
+ "Format/AddresseeFromTop", // 4
+ "Format/SenderFromLeft", // 5
+ "Format/SenderFromTop", // 6
+ "Format/Width", // 7
+ "Format/Height", // 8
+ "Print/Alignment", // 9
+ "Print/FromAbove", // 10
+ "Print/Right", // 11
+ "Print/Down" // 12
+ };
+ const int nCount = 13;
+ Sequence<OUString> aNames(nCount);
+ OUString* pNames = aNames.getArray();
+
+ for(int i = 0; i < nCount; i++)
+ pNames[i] = OUString::createFromAscii(aPropNames[i]);
+
+ return aNames;
+}
+
+bool SwEnvItem::QueryValue( Any& rVal, sal_uInt8 nMemberId ) const
+{
+ bool bRet = true;
+ switch(nMemberId & ~CONVERT_TWIPS)
+ {
+ case MID_ENV_ADDR_TEXT : rVal <<= aAddrText; break;
+ case MID_ENV_SEND : rVal <<= bSend; break;
+ case MID_SEND_TEXT : rVal <<= aSendText; break;
+ case MID_ENV_ADDR_FROM_LEFT : rVal <<= lAddrFromLeft; break;
+ case MID_ENV_ADDR_FROM_TOP : rVal <<= lAddrFromTop; break;
+ case MID_ENV_SEND_FROM_LEFT : rVal <<= lSendFromLeft; break;
+ case MID_ENV_SEND_FROM_TOP : rVal <<= lSendFromTop; break;
+ case MID_ENV_WIDTH : rVal <<= lWidth; break;
+ case MID_ENV_HEIGHT : rVal <<= lHeight; break;
+ case MID_ENV_ALIGN : rVal <<= (sal_Int16) eAlign; break;
+ case MID_ENV_PRINT_FROM_ABOVE : rVal <<= bPrintFromAbove; break;
+ case MID_ENV_SHIFT_RIGHT : rVal <<= lShiftRight; break;
+ case MID_ENV_SHIFT_DOWN : rVal <<= lShiftDown; break;
+ default:
+ OSL_FAIL("Wrong memberId");
+ bRet = false;
+ }
+ return bRet;
+}
+
+bool SwEnvItem::PutValue(const Any& rVal, sal_uInt8 nMemberId)
+{
+ bool bRet = false;
+ switch(nMemberId & ~CONVERT_TWIPS)
+ {
+ case MID_ENV_ADDR_TEXT : bRet = (rVal >>= aAddrText); break;
+ case MID_ENV_SEND : bRet = (rVal >>= bSend); break;
+ case MID_SEND_TEXT : bRet = (rVal >>= aSendText); break;
+ case MID_ENV_ADDR_FROM_LEFT : bRet = (rVal >>= lAddrFromLeft); break;
+ case MID_ENV_ADDR_FROM_TOP : bRet = (rVal >>= lAddrFromTop); break;
+ case MID_ENV_SEND_FROM_LEFT : bRet = (rVal >>= lSendFromLeft); break;
+ case MID_ENV_SEND_FROM_TOP : bRet = (rVal >>= lSendFromTop); break;
+ case MID_ENV_WIDTH : bRet = (rVal >>= lWidth); break;
+ case MID_ENV_HEIGHT : bRet = (rVal >>= lHeight); break;
+ case MID_ENV_ALIGN :
+ {
+ sal_Int16 nTemp = 0;
+ bRet = (rVal >>= nTemp);
+ if (bRet)
+ eAlign = SwEnvAlign(nTemp);
+ break;
+ }
+ case MID_ENV_PRINT_FROM_ABOVE : bRet = (rVal >>= bPrintFromAbove); break;
+ case MID_ENV_SHIFT_RIGHT : bRet = (rVal >>= lShiftRight); break;
+ case MID_ENV_SHIFT_DOWN : bRet = (rVal >>= lShiftDown); break;
+ default:
+ OSL_FAIL("Wrong memberId");
+ }
+ return bRet;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/envelp/label.hrc b/sw/source/core/uibase/envelp/label.hrc
new file mode 100644
index 000000000000..702c3db94e2a
--- /dev/null
+++ b/sw/source/core/uibase/envelp/label.hrc
@@ -0,0 +1,42 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef _LABEL_HRC
+#define _LABEL_HRC
+
+#include "envelp.hrc"
+
+// local resources *********************************************************
+
+#define BTN_SYNC 20
+
+// global resources ********************************************************
+#define STR_CUSTOM (RC_LABEL_BEGIN + 1)
+
+// overflow check ********************************************************
+
+#define LABEL_ACT_END STR_CUSTOM
+
+#if LABEL_ACT_END > RC_LABEL_END
+#error Resource-Ueberlauf in #file, #line
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/envelp/labelcfg.cxx b/sw/source/core/uibase/envelp/labelcfg.cxx
new file mode 100644
index 000000000000..8630ea098465
--- /dev/null
+++ b/sw/source/core/uibase/envelp/labelcfg.cxx
@@ -0,0 +1,358 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <config_folders.h>
+
+#include <swtypes.hxx>
+#include <labelcfg.hxx>
+#include <labimp.hxx>
+#include <comphelper/string.hxx>
+#include <rtl/bootstrap.hxx>
+#include <unotools/configpaths.hxx>
+#include <xmlreader/xmlreader.hxx>
+
+#include <unomid.h>
+
+using namespace utl;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+
+static inline void lcl_assertEndingItem(xmlreader::XmlReader& reader)
+{
+ int nsId;
+ xmlreader::Span name;
+ xmlreader::XmlReader::Result res;
+ res = reader.nextItem(xmlreader::XmlReader::TEXT_NONE, &name, &nsId);
+ assert(res == xmlreader::XmlReader::RESULT_END);
+ (void) res;
+}
+
+static inline OUString lcl_getValue(xmlreader::XmlReader& reader,
+ const xmlreader::Span& span)
+{
+ int nsId;
+ xmlreader::Span name;
+ xmlreader::XmlReader::Result res;
+ res = reader.nextItem(xmlreader::XmlReader::TEXT_NONE, &name, &nsId);
+ assert(res == xmlreader::XmlReader::RESULT_BEGIN && name.equals(span));
+ res = reader.nextItem(xmlreader::XmlReader::TEXT_RAW, &name, &nsId);
+ assert(res == xmlreader::XmlReader::RESULT_TEXT);
+ (void) res; (void) span;
+ OUString sTmp = name.convertFromUtf8();
+ lcl_assertEndingItem(reader);
+ return sTmp;
+}
+
+static Sequence<OUString> lcl_CreatePropertyNames(const OUString& rPrefix)
+{
+ Sequence<OUString> aProperties(2);
+ OUString* pProperties = aProperties.getArray();
+ for(sal_Int32 nProp = 0; nProp < 2; nProp++)
+ pProperties[nProp] = rPrefix;
+
+ pProperties[ 0] += "Name";
+ pProperties[ 1] += "Measure";
+ return aProperties;
+}
+
+SwLabelConfig::SwLabelConfig() :
+ ConfigItem("Office.Labels/Manufacturer")
+{
+ OUString uri("$BRAND_BASE_DIR/" LIBO_SHARE_FOLDER "/labels/labels.xml");
+ rtl::Bootstrap::expandMacros(uri);
+ xmlreader::XmlReader reader(uri);
+ int nsId;
+ xmlreader::Span name;
+ xmlreader::XmlReader::Result res;
+ OUString sManufacturer;
+ OUString sName;
+ OUString sMeasure;
+
+ // fill m_aLabels and m_aManufacturers with the predefined labels
+ res = reader.nextItem(
+ xmlreader::XmlReader::TEXT_NONE, &name, &nsId);
+ assert(
+ res == xmlreader::XmlReader::RESULT_BEGIN
+ && name.equals("manufacturers"));
+ res = reader.nextItem(
+ xmlreader::XmlReader::TEXT_NONE, &name, &nsId);
+ while (res != xmlreader::XmlReader::RESULT_END)
+ {
+ // Opening manufacturer
+ assert(
+ res == xmlreader::XmlReader::RESULT_BEGIN
+ && name.equals("manufacturer"));
+ // Get the name
+ reader.nextAttribute(&nsId, &name);
+ assert(
+ nsId == xmlreader::XmlReader::NAMESPACE_NONE
+ && name.equals("name"));
+ sManufacturer = reader.getAttributeValue(false).convertFromUtf8();
+
+ for(;;) {
+ // Opening label or ending manufacturer
+ res = reader.nextItem(
+ xmlreader::XmlReader::TEXT_NONE, &name, &nsId);
+ if (res == xmlreader::XmlReader::RESULT_END)
+ break;
+ assert(
+ res == xmlreader::XmlReader::RESULT_BEGIN
+ && name.equals("label"));
+ // Get name value
+ sName = lcl_getValue(reader, xmlreader::Span("name"));
+ // Get measure value
+ sMeasure = lcl_getValue(reader, xmlreader::Span("measure"));
+ // Ending label mark
+ lcl_assertEndingItem(reader);
+ if ( m_aLabels.find( sManufacturer ) == m_aLabels.end() )
+ m_aManufacturers.push_back( sManufacturer );
+ m_aLabels[sManufacturer][sName].m_aMeasure = sMeasure;
+ m_aLabels[sManufacturer][sName].m_bPredefined = true;
+ }
+ // Get next manufacturer or end
+ res = reader.nextItem(
+ xmlreader::XmlReader::TEXT_NONE, &name, &nsId);
+ };
+ res = reader.nextItem(
+ xmlreader::XmlReader::TEXT_NONE, &name, &nsId);
+ assert(res == xmlreader::XmlReader::RESULT_DONE);
+
+ // add to m_aLabels and m_aManufacturers the custom labels
+ const Sequence<OUString>& rMan = GetNodeNames( OUString() );
+ const OUString* pMan = rMan.getConstArray();
+ for ( sal_Int32 nMan = 0; nMan < rMan.getLength(); nMan++ )
+ {
+ sManufacturer = pMan[nMan];
+ const Sequence<OUString> aLabels = GetNodeNames( sManufacturer );
+ const OUString* pLabels = aLabels.getConstArray();
+ for( sal_Int32 nLabel = 0; nLabel < aLabels.getLength(); nLabel++ )
+ {
+ OUString sPrefix( sManufacturer );
+ sPrefix += "/";
+ sPrefix += pLabels[nLabel];
+ sPrefix += "/";
+ Sequence<OUString> aPropNames = lcl_CreatePropertyNames( sPrefix );
+ Sequence<Any> aValues = GetProperties( aPropNames );
+ const Any* pValues = aValues.getConstArray();
+ if (aValues.getLength() >= 1)
+ if(pValues[0].hasValue())
+ pValues[0] >>= sName;
+ if (aValues.getLength() >= 2)
+ if(pValues[1].hasValue())
+ pValues[1] >>= sMeasure;
+ if ( m_aLabels.find( sManufacturer ) == m_aLabels.end() )
+ m_aManufacturers.push_back( sManufacturer );
+ m_aLabels[sManufacturer][sName].m_aMeasure = sMeasure;
+ m_aLabels[sManufacturer][sName].m_bPredefined = false;
+ }
+ }
+}
+
+SwLabelConfig::~SwLabelConfig()
+{
+}
+
+// the config item is not writable ?:
+void SwLabelConfig::Commit() {}
+
+void SwLabelConfig::Notify( const ::com::sun::star::uno::Sequence< OUString >& ) {}
+
+static SwLabRec* lcl_CreateSwLabRec(const OUString& rType, const OUString& rMeasure, const OUString& rManufacturer)
+{
+ SwLabRec* pNewRec = new SwLabRec;
+ pNewRec->aMake = rManufacturer;
+ pNewRec->lPWidth = 0;
+ pNewRec->lPHeight = 0;
+ pNewRec->aType = rType;
+ //all values are contained as colon-separated 1/100 mm values
+ //except for the continuous flag ('C'/'S') and nCols, nRows (sal_Int32)
+ OUString sMeasure(rMeasure);
+ sal_uInt16 nTokenCount = comphelper::string::getTokenCount(sMeasure, ';');
+ for(sal_uInt16 i = 0; i < nTokenCount; i++)
+ {
+ OUString sToken(sMeasure.getToken(i, ';' ));
+ int nVal = sToken.toInt32();
+ switch(i)
+ {
+ case 0 : pNewRec->bCont = sToken[0] == 'C'; break;
+ case 1 : pNewRec->lHDist = MM100_TO_TWIP(nVal); break;
+ case 2 : pNewRec->lVDist = MM100_TO_TWIP(nVal); break;
+ case 3 : pNewRec->lWidth = MM100_TO_TWIP(nVal); break;
+ case 4 : pNewRec->lHeight = MM100_TO_TWIP(nVal); break;
+ case 5 : pNewRec->lLeft = MM100_TO_TWIP(nVal); break;
+ case 6 : pNewRec->lUpper = MM100_TO_TWIP(nVal); break;
+ case 7 : pNewRec->nCols = nVal; break;
+ case 8 : pNewRec->nRows = nVal; break;
+ case 9 : pNewRec->lPWidth = MM100_TO_TWIP(nVal); break;
+ case 10 : pNewRec->lPHeight = MM100_TO_TWIP(nVal); break;
+ }
+ }
+ // lines added for compatibility with custom label definitions saved before patch fdo#44516
+ if (pNewRec->lPWidth == 0 || pNewRec->lPHeight == 0)
+ {
+ // old style definition (no paper dimensions), calculate probable values
+ pNewRec->lPWidth = 2 * pNewRec->lLeft + (pNewRec->nCols - 1) * pNewRec->lHDist + pNewRec->lWidth;
+ pNewRec->lPHeight = ( pNewRec->bCont ? pNewRec->nRows * pNewRec->lVDist : 2 * pNewRec->lUpper + (pNewRec->nRows - 1) * pNewRec->lVDist + pNewRec->lHeight );
+ }
+ return pNewRec;
+}
+
+static Sequence<PropertyValue> lcl_CreateProperties(
+ Sequence<OUString>& rPropNames, OUString& rMeasure, const SwLabRec& rRec)
+{
+ const OUString* pNames = rPropNames.getConstArray();
+ Sequence<PropertyValue> aRet(rPropNames.getLength());
+ PropertyValue* pValues = aRet.getArray();
+ OUString sColon(";");
+
+ for(sal_Int32 nProp = 0; nProp < rPropNames.getLength(); nProp++)
+ {
+ pValues[nProp].Name = pNames[nProp];
+ switch(nProp)
+ {
+ case 0: pValues[nProp].Value <<= OUString(rRec.aType); break;
+ case 1:
+ {
+ rMeasure = "";
+ rMeasure += rRec.bCont ? OUString( "C" ) : OUString( "S" ); rMeasure += sColon;
+ rMeasure += OUString::number( TWIP_TO_MM100( rRec.lHDist ) ); rMeasure += sColon;
+ rMeasure += OUString::number( TWIP_TO_MM100( rRec.lVDist ) ); rMeasure += sColon;
+ rMeasure += OUString::number( TWIP_TO_MM100( rRec.lWidth ) ); rMeasure += sColon;
+ rMeasure += OUString::number( TWIP_TO_MM100( rRec.lHeight ) ); rMeasure += sColon;
+ rMeasure += OUString::number( TWIP_TO_MM100( rRec.lLeft ) ); rMeasure += sColon;
+ rMeasure += OUString::number( TWIP_TO_MM100( rRec.lUpper ) ); rMeasure += sColon;
+ rMeasure += OUString::number( rRec.nCols ); rMeasure += sColon;
+ rMeasure += OUString::number( rRec.nRows ); rMeasure += sColon;
+ rMeasure += OUString::number( TWIP_TO_MM100( rRec.lPWidth ) ); rMeasure += sColon;
+ rMeasure += OUString::number( TWIP_TO_MM100( rRec.lPHeight ) );
+ pValues[nProp].Value <<= rMeasure;
+ }
+ break;
+ }
+ }
+ return aRet;
+}
+
+// function fills SwLabDlg with label definitions for manufacturer rManufacturer
+void SwLabelConfig::FillLabels(const OUString& rManufacturer, SwLabRecs& rLabArr)
+{
+ if (m_aLabels.find(rManufacturer) == m_aLabels.end())
+ return;
+ for (std::map<OUString, SwLabelMeasure>::iterator it = m_aLabels[rManufacturer].begin();
+ it != m_aLabels[rManufacturer].end(); ++it)
+ rLabArr.push_back( lcl_CreateSwLabRec(it->first, it->second.m_aMeasure, rManufacturer) );
+}
+
+sal_Bool SwLabelConfig::HasLabel(const OUString& rManufacturer, const OUString& rType)
+{
+ return ( ( m_aLabels.find(rManufacturer) != m_aLabels.end() ) &&
+ ( m_aLabels[rManufacturer].find(rType) != m_aLabels[rManufacturer].end() ) );
+}
+
+static bool lcl_Exists(const OUString& rNode, const Sequence<OUString>& rLabels)
+{
+ const OUString* pLabels = rLabels.getConstArray();
+ for(sal_Int32 i = 0; i < rLabels.getLength(); i++)
+ if(pLabels[i] == rNode)
+ return true;
+ return false;
+}
+
+// label is always saved as a custom label
+// predefined labels can NOT be overwritten by custom labels with same manufacturer/name
+void SwLabelConfig::SaveLabel( const OUString& rManufacturer,
+ const OUString& rType, const SwLabRec& rRec )
+{
+ OUString sFoundNode;
+ bool bManufacturerNodeFound;
+ if ( m_aLabels.find( rManufacturer ) == m_aLabels.end() ||
+ GetNodeNames( rManufacturer ).getLength() == 0 )
+ {
+ bManufacturerNodeFound = false;
+ // manufacturer node does not exist, add (and also to m_aManufacturers)
+ if ( !AddNode( OUString(), rManufacturer ) )
+ {
+ OSL_FAIL("New configuration node could not be created");
+ return ;
+ }
+ m_aManufacturers.push_back( rManufacturer );
+ }
+ else
+ bManufacturerNodeFound = true;
+
+ if ( !bManufacturerNodeFound ||
+ m_aLabels[rManufacturer].find( rType ) == m_aLabels[rManufacturer].end() )
+ {
+ // type does not yet exist, add to config
+ const Sequence<OUString> aLabels = GetNodeNames( rManufacturer );
+ sal_Int32 nIndex = aLabels.getLength();
+ OUString sPrefix( "Label" );
+ sFoundNode = sPrefix;
+ sFoundNode += OUString::number( nIndex );
+ while ( lcl_Exists( sFoundNode, aLabels ) )
+ {
+ sFoundNode = sPrefix;
+ sFoundNode += OUString::number(nIndex++);
+ }
+ }
+ else
+ {
+ // get the appropiate node
+ OUString sManufacturer( wrapConfigurationElementName( rManufacturer ) );
+ const Sequence<OUString> aLabels = GetNodeNames( sManufacturer );
+ const OUString* pLabels = aLabels.getConstArray();
+ for (sal_Int32 nLabel = 0; nLabel < aLabels.getLength(); nLabel++)
+ {
+ OUString sPrefix( sManufacturer );
+ sPrefix += "/";
+ sPrefix += pLabels[nLabel];
+ sPrefix += "/";
+ Sequence<OUString> aProperties(1);
+ aProperties.getArray()[0] = sPrefix;
+ aProperties.getArray()[0] += "Name";
+ Sequence<Any> aValues = GetProperties( aProperties );
+ const Any* pValues = aValues.getConstArray();
+ if ( pValues[0].hasValue() )
+ {
+ OUString sTmp;
+ pValues[0] >>= sTmp;
+ if ( rType == sTmp )
+ {
+ sFoundNode = pLabels[nLabel];
+ break;
+ }
+ }
+ }
+ }
+
+ OUString sPrefix( wrapConfigurationElementName( rManufacturer ) );
+ sPrefix += "/";
+ sPrefix += sFoundNode;
+ sPrefix += "/";
+ Sequence<OUString> aPropNames = lcl_CreatePropertyNames( sPrefix );
+ OUString sMeasure;
+ Sequence<PropertyValue> aPropValues = lcl_CreateProperties( aPropNames, sMeasure, rRec );
+ SetSetProperties( wrapConfigurationElementName( rManufacturer ), aPropValues );
+
+ //update m_aLabels
+ m_aLabels[rManufacturer][rType].m_aMeasure = sMeasure;
+ m_aLabels[rManufacturer][rType].m_bPredefined = false;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/envelp/labimg.cxx b/sw/source/core/uibase/envelp/labimg.cxx
new file mode 100644
index 000000000000..a2006b87dda9
--- /dev/null
+++ b/sw/source/core/uibase/envelp/labimg.cxx
@@ -0,0 +1,473 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <tools/stream.hxx>
+#include <tools/resid.hxx>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <unotools/useroptions.hxx>
+#include <tools/shl.hxx>
+#include <swmodule.hxx>
+#include "labimg.hxx"
+#include "cmdid.h"
+#include "swtypes.hxx"
+#include <unomid.h>
+
+using namespace utl;
+using namespace ::com::sun::star::uno;
+
+SwLabItem::SwLabItem() :
+
+ SfxPoolItem(FN_LABEL),
+ lLeft (0),
+ lUpper(0),
+ nCols (1),
+ nRows (1),
+ nCol (1),
+ nRow (1)
+{
+ bAddr =
+ bCont =
+ bSynchron = sal_False;
+ bPage = sal_True;
+ lHDist =
+ lVDist =
+ lWidth =
+ lHeight =
+ lPWidth =
+ lPHeight = 5669; // 10 cm
+}
+
+SwLabItem::SwLabItem(const SwLabItem& rItem) :
+ SfxPoolItem(FN_LABEL)
+{
+ *this = rItem;
+}
+
+SwLabItem& SwLabItem::operator =(const SwLabItem& rItem)
+{
+ bAddr = rItem.bAddr;
+ aWriting = rItem.aWriting;
+ bCont = rItem.bCont;
+ sDBName = rItem.sDBName;
+ aLstMake = rItem.aLstMake;
+ aLstType = rItem.aLstType;
+ aMake = rItem.aMake;
+ aType = rItem.aType;
+ bPage = rItem.bPage;
+ bSynchron = rItem.bSynchron;
+ aBin = rItem.aBin;
+ nCol = rItem.nCol;
+ nRow = rItem.nRow;
+ lHDist = rItem.lHDist;
+ lVDist = rItem.lVDist;
+ lWidth = rItem.lWidth;
+ lHeight = rItem.lHeight;
+ lLeft = rItem.lLeft;
+ lUpper = rItem.lUpper;
+ nCols = rItem.nCols;
+ nRows = rItem.nRows;
+ lPWidth = rItem.lPWidth;
+ lPHeight = rItem.lPHeight;
+ aPrivFirstName = rItem.aPrivFirstName;
+ aPrivName = rItem.aPrivName;
+ aPrivShortCut = rItem.aPrivShortCut;
+ aPrivFirstName2 = rItem.aPrivFirstName2;
+ aPrivName2 = rItem.aPrivName2;
+ aPrivShortCut2 = rItem.aPrivShortCut2;
+ aPrivStreet = rItem.aPrivStreet;
+ aPrivZip = rItem.aPrivZip;
+ aPrivCity = rItem.aPrivCity;
+ aPrivCountry = rItem.aPrivCountry;
+ aPrivState = rItem.aPrivState;
+ aPrivTitle = rItem.aPrivTitle;
+ aPrivProfession = rItem.aPrivProfession;
+ aPrivPhone = rItem.aPrivPhone;
+ aPrivMobile = rItem.aPrivMobile;
+ aPrivFax = rItem.aPrivFax;
+ aPrivWWW = rItem.aPrivWWW;
+ aPrivMail = rItem.aPrivMail;
+ aCompCompany = rItem.aCompCompany;
+ aCompCompanyExt = rItem.aCompCompanyExt;
+ aCompSlogan = rItem.aCompSlogan;
+ aCompStreet = rItem.aCompStreet;
+ aCompZip = rItem.aCompZip;
+ aCompCity = rItem.aCompCity;
+ aCompCountry = rItem.aCompCountry;
+ aCompState = rItem.aCompState;
+ aCompPosition = rItem.aCompPosition;
+ aCompPhone = rItem.aCompPhone;
+ aCompMobile = rItem.aCompMobile;
+ aCompFax = rItem.aCompFax;
+ aCompWWW = rItem.aCompWWW;
+ aCompMail = rItem.aCompMail;
+ sGlossaryGroup = rItem.sGlossaryGroup;
+ sGlossaryBlockName = rItem.sGlossaryBlockName;
+ return *this;
+}
+
+bool SwLabItem::operator ==(const SfxPoolItem& rItem) const
+{
+ const SwLabItem& rLab = (const SwLabItem&) rItem;
+
+ return bAddr == rLab.bAddr &&
+ bCont == rLab.bCont &&
+ bPage == rLab.bPage &&
+ bSynchron == rLab.bSynchron &&
+ aBin == rLab.aBin &&
+ nCol == rLab.nCol &&
+ nRow == rLab.nRow &&
+ lHDist == rLab.lHDist &&
+ lVDist == rLab.lVDist &&
+ lWidth == rLab.lWidth &&
+ lHeight == rLab.lHeight &&
+ lLeft == rLab.lLeft &&
+ lUpper == rLab.lUpper &&
+ nCols == rLab.nCols &&
+ nRows == rLab.nRows &&
+ lPWidth == rLab.lPWidth &&
+ lPHeight == rLab.lPHeight&&
+ aWriting == rLab.aWriting&&
+ aMake == rLab.aMake &&
+ aType == rLab.aType &&
+ aLstMake == rLab.aLstMake&&
+ aLstType == rLab.aLstType&&
+ sDBName == rLab.sDBName &&
+ aPrivFirstName == rLab.aPrivFirstName&&
+ aPrivName == rLab.aPrivName&&
+ aPrivShortCut == rLab.aPrivShortCut&&
+ aPrivFirstName2 == rLab.aPrivFirstName2&&
+ aPrivName2 == rLab.aPrivName2&&
+ aPrivShortCut2 == rLab.aPrivShortCut2&&
+ aPrivStreet == rLab.aPrivStreet&&
+ aPrivZip == rLab.aPrivZip&&
+ aPrivCity == rLab.aPrivCity&&
+ aPrivCountry == rLab.aPrivCountry&&
+ aPrivState == rLab.aPrivState&&
+ aPrivTitle == rLab.aPrivTitle&&
+ aPrivProfession == rLab.aPrivProfession&&
+ aPrivPhone == rLab.aPrivPhone&&
+ aPrivMobile == rLab.aPrivMobile&&
+ aPrivFax == rLab.aPrivFax&&
+ aPrivWWW == rLab.aPrivWWW&&
+ aPrivMail == rLab.aPrivMail&&
+ aCompCompany == rLab.aCompCompany&&
+ aCompCompanyExt == rLab.aCompCompanyExt&&
+ aCompSlogan == rLab.aCompSlogan&&
+ aCompStreet == rLab.aCompStreet&&
+ aCompZip == rLab.aCompZip&&
+ aCompCity == rLab.aCompCity&&
+ aCompCountry == rLab.aCompCountry&&
+ aCompState == rLab.aCompState&&
+ aCompPosition == rLab.aCompPosition&&
+ aCompPhone == rLab.aCompPhone&&
+ aCompMobile == rLab.aCompMobile&&
+ aCompFax == rLab.aCompFax&&
+ aCompWWW == rLab.aCompWWW&&
+ aCompMail == rLab.aCompMail &&
+ sGlossaryGroup == rLab.sGlossaryGroup &&
+ sGlossaryBlockName == rLab.sGlossaryBlockName;
+}
+
+SfxPoolItem* SwLabItem::Clone(SfxItemPool*) const
+{
+ return new SwLabItem(*this);
+}
+
+Sequence<OUString> SwLabCfgItem::GetPropertyNames()
+{
+ static const char* aLabelPropNames[] =
+ {
+ "Medium/Continuous", // 0
+ "Medium/Brand", // 1
+ "Medium/Type", // 2
+ "Format/Column", // 3
+ "Format/Row", // 4
+ "Format/HorizontalDistance",// 5
+ "Format/VerticalDistance", // 6
+ "Format/Width", // 7
+ "Format/Height", // 8
+ "Format/LeftMargin", // 9
+ "Format/TopMargin", //10
+ "Format/PageWidth", //11
+ "Format/PageHeight", //12
+ "Option/Synchronize", //13
+ "Option/Page", //14
+ "Option/Column", //15
+ "Option/Row", //16
+ "Inscription/UseAddress", //17
+ "Inscription/Address", //18
+ "Inscription/Database" //19
+ };
+ static const char* aBusinessPropNames[] =
+ {
+ "PrivateAddress/FirstName", // 0
+ "PrivateAddress/Name", // 1
+ "PrivateAddress/ShortCut", // 2
+ "PrivateAddress/SecondFirstName", // 3
+ "PrivateAddress/SecondName", // 4
+ "PrivateAddress/SecondShortCut", // 5
+ "PrivateAddress/Street", // 6
+ "PrivateAddress/Zip", // 7
+ "PrivateAddress/City", // 8
+ "PrivateAddress/Country", // 9
+ "PrivateAddress/State", // 10
+ "PrivateAddress/Title", // 11
+ "PrivateAddress/Profession", // 12
+ "PrivateAddress/Phone", // 13
+ "PrivateAddress/Mobile", // 14
+ "PrivateAddress/Fax", // 15
+ "PrivateAddress/WebAddress", // 16
+ "PrivateAddress/Email", // 17
+ "BusinessAddress/Company", // 18
+ "BusinessAddress/CompanyExt", // 19
+ "BusinessAddress/Slogan", // 20
+ "BusinessAddress/Street", // 21
+ "BusinessAddress/Zip", // 22
+ "BusinessAddress/City", // 23
+ "BusinessAddress/Country", // 24
+ "BusinessAddress/State", // 25
+ "BusinessAddress/Position", // 26
+ "BusinessAddress/Phone", // 27
+ "BusinessAddress/Mobile", // 28
+ "BusinessAddress/Fax", // 29
+ "BusinessAddress/WebAddress", // 30
+ "BusinessAddress/Email", // 31
+ "AutoText/Group", // 32
+ "AutoText/Block" // 33
+ };
+ const int nBusinessCount = bIsLabel ? 0 : 34;
+ const int nLabelCount = bIsLabel ? 20 : 17;
+ Sequence<OUString> aNames(nBusinessCount + nLabelCount);
+ OUString* pNames = aNames.getArray();
+ int nIndex = 0;
+ for(int nLabel = 0; nLabel < nLabelCount; nLabel++)
+ pNames[nIndex++] = OUString::createFromAscii(aLabelPropNames[nLabel]);
+ for(int nBusiness = 0; nBusiness < nBusinessCount; nBusiness++)
+ pNames[nIndex++] = OUString::createFromAscii(aBusinessPropNames[nBusiness]);
+ return aNames;
+}
+
+SwLabCfgItem::SwLabCfgItem(sal_Bool bLabel) :
+ ConfigItem(bLabel ? OUString("Office.Writer/Label") : OUString("Office.Writer/BusinessCard")),
+ bIsLabel(bLabel)
+{
+ Sequence<OUString> aNames = GetPropertyNames();
+ Sequence<Any> aValues = GetProperties(aNames);
+ EnableNotification(aNames);
+ const Any* pValues = aValues.getConstArray();
+ OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
+ bool bNoConfigValues = true;
+ if(aValues.getLength() == aNames.getLength())
+ {
+ for(int nProp = 0, nProperty = 0; nProp < aNames.getLength(); nProp++, nProperty++)
+ {
+
+ if(pValues[nProp].hasValue())
+ {
+ //to have a contiuous switch an offset is added
+ if(nProp == 17 && !bIsLabel)
+ nProperty += 3;
+ if(nProperty >= 20)
+ bNoConfigValues = false;
+ switch(nProperty)
+ {
+ case 0: aItem.bCont = *(sal_Bool*)pValues[nProp].getValue(); break;// "Medium/Continuous",
+ case 1: pValues[nProp] >>= aItem.aMake; break;// "Medium/Brand",
+ case 2: pValues[nProp] >>= aItem.aType; break;// "Medium/Type",
+ case 3: pValues[nProp] >>= aItem.nCols; break;// "Format/Column",
+ case 4: pValues[nProp] >>= aItem.nRows; break;// "Format/Row",
+ case 5:
+ pValues[nProp] >>= aItem.lHDist;
+ aItem.lHDist = MM100_TO_TWIP(aItem.lHDist);
+ break;// "Format/HorizontalDistance",
+ case 6:
+ pValues[nProp] >>= aItem.lVDist;
+ aItem.lVDist = MM100_TO_TWIP(aItem.lVDist);
+ break;// "Format/VerticalDistance",
+ case 7:
+ pValues[nProp] >>= aItem.lWidth;
+ aItem.lWidth = MM100_TO_TWIP(aItem.lWidth);
+ break;// "Format/Width",
+ case 8:
+ pValues[nProp] >>= aItem.lHeight;
+ aItem.lHeight = MM100_TO_TWIP(aItem.lHeight);
+ break;// "Format/Height",
+ case 9:
+ pValues[nProp] >>= aItem.lLeft;
+ aItem.lLeft = MM100_TO_TWIP(aItem.lLeft);
+ break;// "Format/LeftMargin",
+ case 10:
+ pValues[nProp] >>= aItem.lUpper;
+ aItem.lUpper = MM100_TO_TWIP(aItem.lUpper);
+ break;// "Format/TopMargin",
+ case 11:
+ pValues[nProp] >>= aItem.lPWidth;
+ aItem.lPWidth = MM100_TO_TWIP(aItem.lPWidth);
+ break;// "Format/PageWidth",
+ case 12:
+ pValues[nProp] >>= aItem.lPHeight;
+ aItem.lPHeight = MM100_TO_TWIP(aItem.lPHeight);
+ break;// "Format/PageHeight",
+ case 13: aItem.bSynchron = *(sal_Bool*)pValues[nProp].getValue(); break;// "Option/Synchronize",
+ case 14: aItem.bPage = *(sal_Bool*)pValues[nProp].getValue(); break;// "Option/Page",
+ case 15: pValues[nProp] >>= aItem.nCol; break;// "Option/Column",
+ case 16: pValues[nProp] >>= aItem.nRow; break;// "Option/Row"
+ case 17: aItem.bAddr = *(sal_Bool*)pValues[nProp].getValue(); break;// "Inscription/UseAddress",
+ case 18: pValues[nProp] >>= aItem.aWriting; break;// "Inscription/Address",
+ case 19: pValues[nProp] >>= aItem.sDBName; break;// "Inscription/Database"
+ case 20: pValues[nProp] >>= aItem.aPrivFirstName; break;// "PrivateAddress/FirstName",
+ case 21: pValues[nProp] >>= aItem.aPrivName; break;// "PrivateAddress/Name",
+ case 22: pValues[nProp] >>= aItem.aPrivShortCut; break;// "PrivateAddress/ShortCut",
+ case 23: pValues[nProp] >>= aItem.aPrivFirstName2; break;// "PrivateAddress/SecondFirstName",
+ case 24: pValues[nProp] >>= aItem.aPrivName2; break;// "PrivateAddress/SecondName",
+ case 25: pValues[nProp] >>= aItem.aPrivShortCut2; break;// "PrivateAddress/SecondShortCut",
+ case 26: pValues[nProp] >>= aItem.aPrivStreet; break;// "PrivateAddress/Street",
+ case 27: pValues[nProp] >>= aItem.aPrivZip; break;// "PrivateAddress/Zip",
+ case 28: pValues[nProp] >>= aItem.aPrivCity; break;// "PrivateAddress/City",
+ case 29: pValues[nProp] >>= aItem.aPrivCountry; break;// "PrivateAddress/Country",
+ case 30: pValues[nProp] >>= aItem.aPrivState; break;// "PrivateAddress/State",
+ case 31: pValues[nProp] >>= aItem.aPrivTitle; break;// "PrivateAddress/Title",
+ case 32: pValues[nProp] >>= aItem.aPrivProfession; break;// "PrivateAddress/Profession",
+ case 33: pValues[nProp] >>= aItem.aPrivPhone; break;// "PrivateAddress/Phone",
+ case 34: pValues[nProp] >>= aItem.aPrivMobile; break;// "PrivateAddress/Mobile",
+ case 35: pValues[nProp] >>= aItem.aPrivFax; break;// "PrivateAddress/Fax",
+ case 36: pValues[nProp] >>= aItem.aPrivWWW; break;// "PrivateAddress/WebAddress",
+ case 37: pValues[nProp] >>= aItem.aPrivMail; break;// "PrivateAddress/Email",
+ case 38: pValues[nProp] >>= aItem.aCompCompany; break;// "BusinessAddress/Company",
+ case 39: pValues[nProp] >>= aItem.aCompCompanyExt; break;// "BusinessAddress/CompanyExt",
+ case 40: pValues[nProp] >>= aItem.aCompSlogan; break;// "BusinessAddress/Slogan",
+ case 41: pValues[nProp] >>= aItem.aCompStreet; break;// "BusinessAddress/Street",
+ case 42: pValues[nProp] >>= aItem.aCompZip; break;// "BusinessAddress/Zip",
+ case 43: pValues[nProp] >>= aItem.aCompCity; break;// "BusinessAddress/City",
+ case 44: pValues[nProp] >>= aItem.aCompCountry; break;// "BusinessAddress/Country",
+ case 45: pValues[nProp] >>= aItem.aCompState; break;// "BusinessAddress/State",
+ case 46: pValues[nProp] >>= aItem.aCompPosition; break;// "BusinessAddress/Position",
+ case 47: pValues[nProp] >>= aItem.aCompPhone; break;// "BusinessAddress/Phone",
+ case 48: pValues[nProp] >>= aItem.aCompMobile; break;// "BusinessAddress/Mobile",
+ case 49: pValues[nProp] >>= aItem.aCompFax; break;// "BusinessAddress/Fax",
+ case 50: pValues[nProp] >>= aItem.aCompWWW; break;// "BusinessAddress/WebAddress",
+ case 51: pValues[nProp] >>= aItem.aCompMail; break;// "BusinessAddress/Email",
+ case 52: pValues[nProp] >>= aItem.sGlossaryGroup; break;// "AutoText/Group"
+ case 53: pValues[nProp] >>= aItem.sGlossaryBlockName; break;// "AutoText/Block"
+ }
+ }
+ }
+ }
+ if(!bIsLabel && bNoConfigValues)
+ {
+
+ SvtUserOptions& rUserOpt = SW_MOD()->GetUserOptions();
+ aItem.aPrivFirstName = rUserOpt.GetFirstName();
+ aItem.aPrivName = rUserOpt.GetLastName();
+ aItem.aPrivShortCut = rUserOpt.GetID();
+ aItem.aCompCompany = rUserOpt.GetCompany();
+ aItem.aCompStreet = aItem.aPrivStreet = rUserOpt.GetStreet();
+
+ aItem.aCompCountry = aItem.aPrivCountry = rUserOpt.GetCountry();
+ aItem.aCompZip = aItem.aPrivZip= rUserOpt.GetZip();
+ aItem.aCompCity = aItem.aPrivCity = rUserOpt.GetCity();
+ aItem.aPrivTitle = rUserOpt.GetTitle();
+ aItem.aCompPosition = rUserOpt.GetPosition();
+ aItem.aPrivPhone = rUserOpt.GetTelephoneHome();
+ aItem.aCompPhone = rUserOpt.GetTelephoneWork();
+ aItem.aCompFax = aItem.aPrivFax = rUserOpt.GetFax();
+ aItem.aCompMail = aItem.aPrivMail = rUserOpt.GetEmail();
+ aItem.aCompState = aItem.aPrivState = rUserOpt.GetState();
+ aItem.bSynchron = sal_True;
+ SetModified();
+ }
+}
+
+void SwLabCfgItem::Notify( const ::com::sun::star::uno::Sequence< OUString >& ) {}
+
+void SwLabCfgItem::Commit()
+{
+ Sequence<OUString> aNames = GetPropertyNames();
+ Sequence<Any> aValues(aNames.getLength());
+ Any* pValues = aValues.getArray();
+
+ const Type& rType = ::getBooleanCppuType();
+ for(int nProp = 0, nProperty = 0; nProp < aNames.getLength(); nProp++, nProperty++)
+ {
+ //to have a contiuous switch an offset is added
+ if(nProp == 17 && !bIsLabel)
+ nProperty += 3;
+ switch(nProperty)
+ {
+ case 0: pValues[nProp].setValue(&aItem.bCont, rType); break;// "Medium/Continuous",
+ case 1: pValues[nProp] <<= aItem.aMake; break;// "Medium/Brand",
+ case 2: pValues[nProp] <<= aItem.aType; break;// "Medium/Type",
+ case 3: pValues[nProp] <<= aItem.nCols; break;// "Format/Column",
+ case 4: pValues[nProp] <<= aItem.nRows; break;// "Format/Row",
+ case 5: pValues[nProp] <<= static_cast<sal_Int32>(TWIP_TO_MM100(aItem.lHDist));break;// "Format/HorizontalDistance",
+ case 6: pValues[nProp] <<= static_cast<sal_Int32>(TWIP_TO_MM100(aItem.lVDist));break;// "Format/VerticalDistance",
+ case 7: pValues[nProp] <<= static_cast<sal_Int32>(TWIP_TO_MM100(aItem.lWidth)); break;// "Format/Width",
+ case 8: pValues[nProp] <<= static_cast<sal_Int32>(TWIP_TO_MM100(aItem.lHeight)); break;// "Format/Height",
+ case 9: pValues[nProp] <<= static_cast<sal_Int32>(TWIP_TO_MM100(aItem.lLeft)); break;// "Format/LeftMargin",
+ case 10: pValues[nProp] <<= static_cast<sal_Int32>(TWIP_TO_MM100(aItem.lUpper)); break;// "Format/TopMargin",
+ case 11: pValues[nProp] <<= static_cast<sal_Int32>(TWIP_TO_MM100(aItem.lPWidth)); break;// "Format/Page Width",
+ case 12: pValues[nProp] <<= static_cast<sal_Int32>(TWIP_TO_MM100(aItem.lPHeight)); break;// "Format/PageHeight",
+ case 13: pValues[nProp].setValue(&aItem.bSynchron, rType); break;// "Option/Synchronize",
+ case 14: pValues[nProp].setValue(&aItem.bPage, rType); break;// "Option/Page",
+ case 15: pValues[nProp] <<= aItem.nCol; break;// "Option/Column",
+ case 16: pValues[nProp] <<= aItem.nRow; break;// "Option/Row"
+ case 17: pValues[nProp].setValue(&aItem.bAddr, rType); break;// "Inscription/UseAddress",
+ case 18: pValues[nProp] <<= aItem.aWriting; break;// "Inscription/Address",
+ case 19: pValues[nProp] <<= aItem.sDBName; break;// "Inscription/Database"
+ case 20: pValues[nProp] <<= aItem.aPrivFirstName; break;// "PrivateAddress/FirstName",
+ case 21: pValues[nProp] <<= aItem.aPrivName; break;// "PrivateAddress/Name",
+ case 22: pValues[nProp] <<= aItem.aPrivShortCut; break;// "PrivateAddress/ShortCut",
+ case 23: pValues[nProp] <<= aItem.aPrivFirstName2; break;// "PrivateAddress/SecondFirstName",
+ case 24: pValues[nProp] <<= aItem.aPrivName2; break;// "PrivateAddress/SecondName",
+ case 25: pValues[nProp] <<= aItem.aPrivShortCut2; break;// "PrivateAddress/SecondShortCut",
+ case 26: pValues[nProp] <<= aItem.aPrivStreet; break;// "PrivateAddress/Street",
+ case 27: pValues[nProp] <<= aItem.aPrivZip; break;// "PrivateAddress/Zip",
+ case 28: pValues[nProp] <<= aItem.aPrivCity; break;// "PrivateAddress/City",
+ case 29: pValues[nProp] <<= aItem.aPrivCountry; break;// "PrivateAddress/Country",
+ case 30: pValues[nProp] <<= aItem.aPrivState; break;// "PrivateAddress/State",
+ case 31: pValues[nProp] <<= aItem.aPrivTitle; break;// "PrivateAddress/Title",
+ case 32: pValues[nProp] <<= aItem.aPrivProfession; break;// "PrivateAddress/Profession",
+ case 33: pValues[nProp] <<= aItem.aPrivPhone; break;// "PrivateAddress/Phone",
+ case 34: pValues[nProp] <<= aItem.aPrivMobile; break;// "PrivateAddress/Mobile",
+ case 35: pValues[nProp] <<= aItem.aPrivFax; break;// "PrivateAddress/Fax",
+ case 36: pValues[nProp] <<= aItem.aPrivWWW; break;// "PrivateAddress/WebAddress",
+ case 37: pValues[nProp] <<= aItem.aPrivMail; break;// "PrivateAddress/Email",
+ case 38: pValues[nProp] <<= aItem.aCompCompany; break;// "BusinessAddress/Company",
+ case 39: pValues[nProp] <<= aItem.aCompCompanyExt; break;// "BusinessAddress/CompanyExt",
+ case 40: pValues[nProp] <<= aItem.aCompSlogan; break;// "BusinessAddress/Slogan",
+ case 41: pValues[nProp] <<= aItem.aCompStreet; break;// "BusinessAddress/Street",
+ case 42: pValues[nProp] <<= aItem.aCompZip; break;// "BusinessAddress/Zip",
+ case 43: pValues[nProp] <<= aItem.aCompCity; break;// "BusinessAddress/City",
+ case 44: pValues[nProp] <<= aItem.aCompCountry; break;// "BusinessAddress/Country",
+ case 45: pValues[nProp] <<= aItem.aCompState; break;// "BusinessAddress/State",
+ case 46: pValues[nProp] <<= aItem.aCompPosition; break;// "BusinessAddress/Position",
+ case 47: pValues[nProp] <<= aItem.aCompPhone; break;// "BusinessAddress/Phone",
+ case 48: pValues[nProp] <<= aItem.aCompMobile; break;// "BusinessAddress/Mobile",
+ case 49: pValues[nProp] <<= aItem.aCompFax; break;// "BusinessAddress/Fax",
+ case 50: pValues[nProp] <<= aItem.aCompWWW; break;// "BusinessAddress/WebAddress",
+ case 51: pValues[nProp] <<= aItem.aCompMail; break;// "BusinessAddress/Email",
+ case 52: pValues[nProp] <<= aItem.sGlossaryGroup; break;// "AutoText/Group"
+ case 53: pValues[nProp] <<= aItem.sGlossaryBlockName; break;// "AutoText/Block"
+ }
+ }
+ PutProperties(aNames, aValues);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/envelp/labimp.hxx b/sw/source/core/uibase/envelp/labimp.hxx
new file mode 100644
index 000000000000..5d4d17d7cfb3
--- /dev/null
+++ b/sw/source/core/uibase/envelp/labimp.hxx
@@ -0,0 +1,114 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_ENVELP_LABIMP_HXX
+#define INCLUDED_SW_SOURCE_UI_ENVELP_LABIMP_HXX
+
+#include <sfx2/tabdlg.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/fixed.hxx>
+#include <svtools/svmedit.hxx>
+#include <vcl/field.hxx>
+#include <svtools/stdctrl.hxx>
+#include <com/sun/star/frame/XController.hpp>
+#include <com/sun/star/text/XTextCursor.hpp>
+#include <com/sun/star/text/XWordCursor.hpp>
+#include <com/sun/star/text/XParagraphCursor.hpp>
+#include <com/sun/star/text/XPageCursor.hpp>
+#include <com/sun/star/text/XSentenceCursor.hpp>
+#include <com/sun/star/awt/XFileDialog.hpp>
+#include <com/sun/star/awt/XTextComponent.hpp>
+#include <com/sun/star/awt/XListBox.hpp>
+#include <com/sun/star/awt/XProgressMonitor.hpp>
+#include <com/sun/star/awt/TextAlign.hpp>
+#include <com/sun/star/awt/XScrollBar.hpp>
+#include <com/sun/star/awt/XVclContainerPeer.hpp>
+#include <com/sun/star/awt/XTabControllerModel.hpp>
+#include <com/sun/star/awt/XMessageBox.hpp>
+#include <com/sun/star/awt/XTextEditField.hpp>
+#include <com/sun/star/awt/Style.hpp>
+#include <com/sun/star/awt/XTimeField.hpp>
+#include <com/sun/star/awt/XVclWindowPeer.hpp>
+#include <com/sun/star/awt/XControlModel.hpp>
+#include <com/sun/star/awt/XSpinField.hpp>
+#include <com/sun/star/awt/XUnoControlContainer.hpp>
+#include <com/sun/star/awt/XTextLayoutConstrains.hpp>
+#include <com/sun/star/awt/XNumericField.hpp>
+#include <com/sun/star/awt/XButton.hpp>
+#include <com/sun/star/awt/XTextArea.hpp>
+#include <com/sun/star/awt/XImageButton.hpp>
+#include <com/sun/star/awt/XFixedText.hpp>
+#include <com/sun/star/awt/XControlContainer.hpp>
+#include <com/sun/star/awt/XDialog.hpp>
+#include <com/sun/star/awt/ScrollBarOrientation.hpp>
+#include <com/sun/star/awt/XRadioButton.hpp>
+#include <com/sun/star/awt/XCurrencyField.hpp>
+#include <com/sun/star/awt/XPatternField.hpp>
+#include <com/sun/star/awt/VclWindowPeerAttribute.hpp>
+#include <com/sun/star/awt/XTabController.hpp>
+#include <com/sun/star/awt/XVclContainer.hpp>
+#include <com/sun/star/awt/XDateField.hpp>
+#include <com/sun/star/awt/XComboBox.hpp>
+#include <com/sun/star/awt/XControl.hpp>
+#include <com/sun/star/awt/XCheckBox.hpp>
+#include <com/sun/star/awt/XLayoutConstrains.hpp>
+#include <com/sun/star/awt/XProgressBar.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <svtools/treelistbox.hxx>
+#include <label.hxx>
+#include <labimg.hxx>
+#include <vector>
+
+#define GETFLDVAL(rField) (rField).Denormalize((rField).GetValue(FUNIT_TWIP))
+#define SETFLDVAL(rField, lValue) (rField).SetValue((rField).Normalize(lValue), FUNIT_TWIP)
+
+class SwLabRec
+{
+public:
+ SwLabRec(): lHDist(0), lVDist(0), lWidth(0), lHeight(0), lLeft(0), lUpper(0), lPWidth(0), lPHeight(0), nCols(0), nRows(0), bCont(false) {}
+
+ void SetFromItem( const SwLabItem& rItem );
+ void FillItem( SwLabItem& rItem ) const;
+
+ OUString aMake;
+ OUString aType;
+ long lHDist;
+ long lVDist;
+ long lWidth;
+ long lHeight;
+ long lLeft;
+ long lUpper;
+ long lPWidth;
+ long lPHeight;
+ sal_Int32 nCols;
+ sal_Int32 nRows;
+ sal_Bool bCont;
+};
+
+class SwLabRecs : public std::vector<SwLabRec*> {
+public:
+ ~SwLabRecs()
+ {
+ for(const_iterator it = begin(); it != end(); ++it)
+ delete *it;
+ }
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/envelp/syncbtn.cxx b/sw/source/core/uibase/envelp/syncbtn.cxx
new file mode 100644
index 000000000000..b3882f011b8e
--- /dev/null
+++ b/sw/source/core/uibase/envelp/syncbtn.cxx
@@ -0,0 +1,82 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/dispatch.hxx>
+
+#include "cmdid.h"
+#include "swmodule.hxx"
+#include "view.hxx"
+#include "edtwin.hxx"
+#include "label.hrc"
+
+#define _SYNCDLG
+#include "syncbtn.hxx"
+#include "swtypes.hxx"
+
+SFX_IMPL_FLOATINGWINDOW( SwSyncChildWin, FN_SYNC_LABELS )
+
+SwSyncChildWin::SwSyncChildWin( Window* _pParent,
+ sal_uInt16 nId,
+ SfxBindings* pBindings,
+ SfxChildWinInfo* pInfo ) :
+ SfxChildWindow( _pParent, nId )
+{
+ pWindow = new SwSyncBtnDlg( pBindings, this, _pParent);
+
+ if (!pInfo->aSize.Width() || !pInfo->aSize.Height())
+ {
+ SwView* pActiveView = ::GetActiveView();
+ if(pActiveView)
+ {
+ const SwEditWin &rEditWin = pActiveView->GetEditWin();
+ pWindow->SetPosPixel(rEditWin.OutputToScreenPixel(Point(0, 0)));
+ }
+ else
+ pWindow->SetPosPixel(_pParent->OutputToScreenPixel(Point(0, 0)));
+ pInfo->aPos = pWindow->GetPosPixel();
+ pInfo->aSize = pWindow->GetSizePixel();
+ }
+
+ ((SwSyncBtnDlg *)pWindow)->Initialize(pInfo);
+
+ pWindow->Show();
+}
+
+SwSyncBtnDlg::SwSyncBtnDlg( SfxBindings* _pBindings,
+ SfxChildWindow* pChild,
+ Window *pParent) :
+ SfxFloatingWindow(_pBindings, pChild, pParent, SW_RES(DLG_SYNC_BTN)),
+ aSyncBtn (this, SW_RES(BTN_SYNC ))
+{
+ FreeResource();
+ aSyncBtn.SetClickHdl(LINK(this, SwSyncBtnDlg, BtnHdl));
+}
+
+SwSyncBtnDlg::~SwSyncBtnDlg()
+{
+}
+
+IMPL_LINK_NOARG(SwSyncBtnDlg, BtnHdl)
+{
+ SfxViewFrame::Current()->GetDispatcher()->Execute(FN_UPDATE_ALL_LINKS, SFX_CALLMODE_ASYNCHRON);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/fldui/fldmgr.cxx b/sw/source/core/uibase/fldui/fldmgr.cxx
new file mode 100644
index 000000000000..d4a0b5c4fb09
--- /dev/null
+++ b/sw/source/core/uibase/fldui/fldmgr.cxx
@@ -0,0 +1,1773 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <cmdid.h>
+#include <hintids.hxx>
+#include <svl/stritem.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/text/DefaultNumberingProvider.hpp>
+#include <com/sun/star/text/XDefaultNumberingProvider.hpp>
+#include <com/sun/star/text/XNumberingTypeInfo.hpp>
+#include <com/sun/star/style/NumberingType.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#include <com/sun/star/uri/UriReferenceFactory.hpp>
+#include <com/sun/star/uri/XVndSunStarScriptUrl.hpp>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/string.hxx>
+#include <editeng/unolingu.hxx>
+#include <unotools/localedatawrapper.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/linkmgr.hxx>
+#include <sfx2/app.hxx>
+#include <basic/basmgr.hxx>
+#include <editeng/langitem.hxx>
+#include <svl/macitem.hxx>
+#include <basic/sbmod.hxx>
+#include <fmtrfmrk.hxx>
+#include <basic/sbmeth.hxx>
+#include <basic/sbx.hxx>
+#include <svl/zforlist.hxx>
+#include <svl/zformat.hxx>
+#include <vcl/mnemonic.hxx>
+#include <view.hxx>
+#include <wrtsh.hxx>
+#include <doc.hxx>
+#include <docsh.hxx>
+#include <swmodule.hxx>
+#include <charatr.hxx>
+#include <fmtinfmt.hxx>
+#include <cellatr.hxx>
+#include <dbmgr.hxx>
+#include <shellres.hxx>
+#include <fldbas.hxx>
+#include <docufld.hxx>
+#include <chpfld.hxx>
+#include <ddefld.hxx>
+#include <expfld.hxx>
+#include <reffld.hxx>
+#include <usrfld.hxx>
+#include <dbfld.hxx>
+#include <authfld.hxx>
+#include <flddat.hxx>
+#include <fldmgr.hxx>
+#include <crsskip.hxx>
+#include <flddropdown.hxx>
+#include <fldui.hrc>
+#include <tox.hxx>
+#include <misc.hrc>
+#include <cnttab.hxx>
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::container;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::text;
+using namespace com::sun::star::style;
+using namespace com::sun::star::sdbc;
+using namespace ::com::sun::star;
+using namespace nsSwDocInfoSubType;
+
+/*--------------------------------------------------------------------
+ Description: groups of fields
+ --------------------------------------------------------------------*/
+enum
+{
+ GRP_DOC_BEGIN = 0,
+ GRP_DOC_END = GRP_DOC_BEGIN + 11,
+
+ GRP_FKT_BEGIN = GRP_DOC_END,
+ GRP_FKT_END = GRP_FKT_BEGIN + 8,
+
+ GRP_REF_BEGIN = GRP_FKT_END,
+ GRP_REF_END = GRP_REF_BEGIN + 2,
+
+ GRP_REG_BEGIN = GRP_REF_END,
+ GRP_REG_END = GRP_REG_BEGIN + 1,
+
+ GRP_DB_BEGIN = GRP_REG_END,
+ GRP_DB_END = GRP_DB_BEGIN + 5,
+
+ GRP_VAR_BEGIN = GRP_DB_END,
+ GRP_VAR_END = GRP_VAR_BEGIN + 9
+};
+
+enum
+{
+ GRP_WEB_DOC_BEGIN = 0,
+ GRP_WEB_DOC_END = GRP_WEB_DOC_BEGIN + 9,
+
+ GRP_WEB_FKT_BEGIN = GRP_WEB_DOC_END + 2,
+ GRP_WEB_FKT_END = GRP_WEB_FKT_BEGIN + 0, // the group is empty!
+
+ GRP_WEB_REF_BEGIN = GRP_WEB_FKT_END + 6, // the group is empty!
+ GRP_WEB_REF_END = GRP_WEB_REF_BEGIN + 0,
+
+ GRP_WEB_REG_BEGIN = GRP_WEB_REF_END + 2,
+ GRP_WEB_REG_END = GRP_WEB_REG_BEGIN + 1,
+
+ GRP_WEB_DB_BEGIN = GRP_WEB_REG_END, // the group is empty!
+ GRP_WEB_DB_END = GRP_WEB_DB_BEGIN + 0,
+
+ GRP_WEB_VAR_BEGIN = GRP_WEB_DB_END + 5,
+ GRP_WEB_VAR_END = GRP_WEB_VAR_BEGIN + 1
+};
+
+static const sal_uInt16 VF_COUNT = 1; // { 0 }
+static const sal_uInt16 VF_USR_COUNT = 2; // { 0, nsSwExtendedSubType::SUB_CMD }
+static const sal_uInt16 VF_DB_COUNT = 1; // { nsSwExtendedSubType::SUB_OWN_FMT }
+
+/*--------------------------------------------------------------------
+ Description: field types and subtypes
+ --------------------------------------------------------------------*/
+struct SwFldPack
+{
+ sal_uInt16 nTypeId;
+
+ sal_uInt16 nSubTypeStart;
+ sal_uInt16 nSubTypeEnd;
+
+ sal_uLong nFmtBegin;
+ sal_uLong nFmtEnd;
+};
+
+/*--------------------------------------------------------------------
+ Description: strings and formats
+ --------------------------------------------------------------------*/
+static const SwFldPack aSwFlds[] =
+{
+ // Document
+ { TYP_EXTUSERFLD, FLD_EU_BEGIN, FLD_EU_END, 0, 0 },
+ { TYP_AUTHORFLD, 0, 0, FMT_AUTHOR_BEGIN, FMT_AUTHOR_END },
+ { TYP_DATEFLD, FLD_DATE_BEGIN, FLD_DATE_END, 0, 0 },
+ { TYP_TIMEFLD, FLD_TIME_BEGIN, FLD_TIME_END, 0, 0 },
+ { TYP_PAGENUMBERFLD, 0, 0, FMT_NUM_BEGIN, FMT_NUM_END-1 },
+ { TYP_NEXTPAGEFLD, 0, 0, FMT_NUM_BEGIN, FMT_NUM_END },
+ { TYP_PREVPAGEFLD, 0, 0, FMT_NUM_BEGIN, FMT_NUM_END },
+ { TYP_FILENAMEFLD, 0, 0, FMT_FF_BEGIN, FMT_FF_END },
+ { TYP_DOCSTATFLD, FLD_STAT_BEGIN, FLD_STAT_END, FMT_NUM_BEGIN, FMT_NUM_END-1 },
+
+ { TYP_CHAPTERFLD, 0, 0, FMT_CHAPTER_BEGIN, FMT_CHAPTER_END },
+ { TYP_TEMPLNAMEFLD, 0, 0, FMT_FF_BEGIN, FMT_FF_END },
+
+ // Functions
+ { TYP_CONDTXTFLD, 0, 0, 0, 0 },
+ { TYP_DROPDOWN, 0, 0, 0, 0 },
+ { TYP_INPUTFLD, FLD_INPUT_BEGIN, FLD_INPUT_END, 0, 0 },
+ { TYP_MACROFLD, 0, 0, 0, 0 },
+ { TYP_JUMPEDITFLD, 0, 0, FMT_MARK_BEGIN, FMT_MARK_END },
+ { TYP_COMBINED_CHARS, 0, 0, 0, 0 },
+ { TYP_HIDDENTXTFLD, 0, 0, 0, 0 },
+ { TYP_HIDDENPARAFLD, 0, 0, 0, 0 },
+
+ // Cross-References
+ { TYP_SETREFFLD, 0, 0, 0, 0 },
+ { TYP_GETREFFLD, 0, 0, FMT_REF_BEGIN, FMT_REF_END },
+
+ // DocInformation
+ { TYP_DOCINFOFLD, 0, 0, FMT_REG_BEGIN, FMT_REG_END },
+
+ // Database
+ { TYP_DBFLD, 0, 0, FMT_DBFLD_BEGIN, FMT_DBFLD_END },
+ { TYP_DBNEXTSETFLD, 0, 0, 0, 0 },
+ { TYP_DBNUMSETFLD, 0, 0, 0, 0 },
+ { TYP_DBSETNUMBERFLD, 0, 0, FMT_NUM_BEGIN, FMT_NUM_END-2 },
+ { TYP_DBNAMEFLD, 0, 0, 0, 0 },
+
+ // Variables
+ { TYP_SETFLD, 0, 0, FMT_SETVAR_BEGIN, FMT_SETVAR_END },
+
+ { TYP_GETFLD, 0, 0, FMT_GETVAR_BEGIN, FMT_GETVAR_END },
+ { TYP_DDEFLD, 0, 0, FMT_DDE_BEGIN, FMT_DDE_END },
+ { TYP_FORMELFLD, 0, 0, FMT_GETVAR_BEGIN, FMT_GETVAR_END },
+ { TYP_INPUTFLD, FLD_INPUT_BEGIN, FLD_INPUT_END, 0, 0 },
+ { TYP_SEQFLD, 0, 0, FMT_NUM_BEGIN, FMT_NUM_END-2 },
+ { TYP_SETREFPAGEFLD, FLD_PAGEREF_BEGIN, FLD_PAGEREF_END,0, 0 },
+ { TYP_GETREFPAGEFLD, 0, 0, FMT_NUM_BEGIN, FMT_NUM_END-1 },
+ { TYP_USERFLD, 0, 0, FMT_USERVAR_BEGIN, FMT_USERVAR_END }
+};
+
+/*--------------------------------------------------------------------
+ Description: access to the shell
+ --------------------------------------------------------------------*/
+
+static SwWrtShell* lcl_GetShell()
+{
+ SwView* pView;
+ if ( 0 != (pView = ::GetActiveView()) )
+ return pView->GetWrtShellPtr();
+ OSL_FAIL("no current shell found!");
+ return 0;
+}
+
+inline sal_uInt16 GetPackCount() { return sizeof(aSwFlds) / sizeof(SwFldPack); }
+
+/*--------------------------------------------------------------------
+ Description: FieldManager controls inserting and updating of fields
+ --------------------------------------------------------------------*/
+
+SwFldMgr::SwFldMgr(SwWrtShell* pSh ) :
+ pModule(0),
+ pMacroItem(0),
+ pWrtShell(pSh),
+ bEvalExp(sal_True)
+{
+ // determine current field if existing
+ GetCurFld();
+}
+
+SwFldMgr::~SwFldMgr()
+{
+}
+
+/*--------------------------------------------------------------------
+ Description: organise RefMark by names
+ --------------------------------------------------------------------*/
+
+bool SwFldMgr::CanInsertRefMark( const OUString& rStr )
+{
+ bool bRet = false;
+ SwWrtShell *pSh = pWrtShell ? pWrtShell : lcl_GetShell();
+ OSL_ENSURE(pSh, "no SwWrtShell found");
+ if(pSh)
+ {
+ sal_uInt16 nCnt = pSh->GetCrsrCnt();
+
+ // the last Crsr doesn't have to be a spanned selection
+ if( 1 < nCnt && !pSh->SwCrsrShell::HasSelection() )
+ --nCnt;
+
+ bRet = 2 > nCnt && 0 == pSh->GetRefMark( rStr );
+ }
+ return bRet;
+}
+
+/*--------------------------------------------------------------------
+ Description: access over ResIds
+ --------------------------------------------------------------------*/
+
+void SwFldMgr::RemoveFldType(sal_uInt16 nResId, const OUString& rName )
+{
+ SwWrtShell * pSh = pWrtShell ? pWrtShell : lcl_GetShell();
+ OSL_ENSURE(pSh, "no SwWrtShell found");
+ if( pSh )
+ pSh->RemoveFldType(nResId, rName);
+}
+
+sal_uInt16 SwFldMgr::GetFldTypeCount(sal_uInt16 nResId) const
+{
+ SwWrtShell * pSh = pWrtShell ? pWrtShell : lcl_GetShell();
+ OSL_ENSURE(pSh, "no SwWrtShell found");
+ return pSh ? pSh->GetFldTypeCount(nResId) : 0;
+}
+
+SwFieldType* SwFldMgr::GetFldType(sal_uInt16 nResId, sal_uInt16 nId) const
+{
+ SwWrtShell * pSh = pWrtShell ? pWrtShell : lcl_GetShell();
+ OSL_ENSURE(pSh, "no SwWrtShell found");
+ return pSh ? pSh->GetFldType(nId, nResId) : 0;
+}
+
+SwFieldType* SwFldMgr::GetFldType(sal_uInt16 nResId, const OUString& rName) const
+{
+ SwWrtShell * pSh = pWrtShell ? pWrtShell : lcl_GetShell();
+ OSL_ENSURE(pSh, "no SwWrtShell found");
+ return pSh ? pSh->GetFldType(nResId, rName) : 0;
+}
+
+/*--------------------------------------------------------------------
+ Description: determine current field
+ --------------------------------------------------------------------*/
+SwField* SwFldMgr::GetCurFld()
+{
+ SwWrtShell *pSh = pWrtShell ? pWrtShell : ::lcl_GetShell();
+ if ( pSh )
+ pCurFld = pSh->GetCurFld( true );
+ else
+ pCurFld = NULL;
+
+ // initialise strings and format
+ aCurPar1 = "";
+ aCurPar2 = "";
+ sCurFrame = "";
+ nCurFmt = 0;
+
+ if(!pCurFld)
+ return 0;
+
+ // preprocess current values; determine parameter 1 and parameter 2
+ // as well as the format
+ const sal_uInt16 nTypeId = pCurFld->GetTypeId();
+
+ nCurFmt = pCurFld->GetFormat();
+ aCurPar1 = pCurFld->GetPar1();
+ aCurPar2 = pCurFld->GetPar2();
+
+ switch( nTypeId )
+ {
+ case TYP_PAGENUMBERFLD:
+ case TYP_NEXTPAGEFLD:
+ case TYP_PREVPAGEFLD:
+ case TYP_GETREFPAGEFLD:
+ if( nCurFmt == SVX_NUM_PAGEDESC )
+ nCurFmt -= 2;
+ break;
+ }
+ return pCurFld;
+}
+
+/*--------------------------------------------------------------------
+ Description: provide group range
+ --------------------------------------------------------------------*/
+
+const SwFldGroupRgn& SwFldMgr::GetGroupRange(sal_Bool bHtmlMode, sal_uInt16 nGrpId) const
+{
+static SwFldGroupRgn const aRanges[] =
+{
+ { /* Document */ GRP_DOC_BEGIN, GRP_DOC_END },
+ { /* Functions */ GRP_FKT_BEGIN, GRP_FKT_END },
+ { /* Cross-Refs */ GRP_REF_BEGIN, GRP_REF_END },
+ { /* DocInfos */ GRP_REG_BEGIN, GRP_REG_END },
+ { /* Database */ GRP_DB_BEGIN, GRP_DB_END },
+ { /* User */ GRP_VAR_BEGIN, GRP_VAR_END }
+};
+static SwFldGroupRgn const aWebRanges[] =
+{
+ { /* Document */ GRP_WEB_DOC_BEGIN, GRP_WEB_DOC_END },
+ { /* Functions */ GRP_WEB_FKT_BEGIN, GRP_WEB_FKT_END },
+ { /* Cross-Refs */ GRP_WEB_REF_BEGIN, GRP_WEB_REF_END },
+ { /* DocInfos */ GRP_WEB_REG_BEGIN, GRP_WEB_REG_END },
+ { /* Database */ GRP_WEB_DB_BEGIN, GRP_WEB_DB_END },
+ { /* User */ GRP_WEB_VAR_BEGIN, GRP_WEB_VAR_END }
+};
+
+ if (bHtmlMode)
+ return aWebRanges[(sal_uInt16)nGrpId];
+ else
+ return aRanges[(sal_uInt16)nGrpId];
+}
+
+/*--------------------------------------------------------------------
+ Description: determine GroupId
+ --------------------------------------------------------------------*/
+
+sal_uInt16 SwFldMgr::GetGroup(sal_Bool bHtmlMode, sal_uInt16 nTypeId, sal_uInt16 nSubType) const
+{
+ if (nTypeId == TYP_SETINPFLD)
+ nTypeId = TYP_SETFLD;
+
+ if (nTypeId == TYP_INPUTFLD && (nSubType & INP_USR))
+ nTypeId = TYP_USERFLD;
+
+ if (nTypeId == TYP_FIXDATEFLD)
+ nTypeId = TYP_DATEFLD;
+
+ if (nTypeId == TYP_FIXTIMEFLD)
+ nTypeId = TYP_TIMEFLD;
+
+ for (sal_uInt16 i = GRP_DOC; i <= GRP_VAR; i++)
+ {
+ const SwFldGroupRgn& rRange = GetGroupRange(bHtmlMode, i);
+ for (sal_uInt16 nPos = rRange.nStart; nPos < rRange.nEnd; nPos++)
+ {
+ if (aSwFlds[nPos].nTypeId == nTypeId)
+ return i;
+ }
+ }
+ return USHRT_MAX;
+}
+
+/*--------------------------------------------------------------------
+ Description: determine names to TypeId
+ ACCESS over TYP_....
+ --------------------------------------------------------------------*/
+
+sal_uInt16 SwFldMgr::GetTypeId(sal_uInt16 nPos)
+{
+ OSL_ENSURE(nPos < ::GetPackCount(), "forbidden Pos");
+ return aSwFlds[ nPos ].nTypeId;
+}
+
+OUString SwFldMgr::GetTypeStr(sal_uInt16 nPos)
+{
+ OSL_ENSURE(nPos < ::GetPackCount(), "forbidden TypeId");
+
+ sal_uInt16 nFldWh = aSwFlds[ nPos ].nTypeId;
+
+ // special treatment for date/time fields (without var/fix)
+ if( TYP_DATEFLD == nFldWh )
+ {
+ static OUString g_aDate( SW_RES( STR_DATEFLD ) );
+ return g_aDate;
+ }
+ if( TYP_TIMEFLD == nFldWh )
+ {
+ static OUString g_aTime( SW_RES( STR_TIMEFLD ) );
+ return g_aTime;
+ }
+
+ return SwFieldType::GetTypeStr( nFldWh );
+}
+
+/*--------------------------------------------------------------------
+ Description: determine Pos in the list
+ --------------------------------------------------------------------*/
+
+sal_uInt16 SwFldMgr::GetPos(sal_uInt16 nTypeId)
+{
+ switch( nTypeId )
+ {
+ case TYP_FIXDATEFLD: nTypeId = TYP_DATEFLD; break;
+ case TYP_FIXTIMEFLD: nTypeId = TYP_TIMEFLD; break;
+ case TYP_SETINPFLD: nTypeId = TYP_SETFLD; break;
+ case TYP_USRINPFLD: nTypeId = TYP_USERFLD; break;
+ }
+
+ for(sal_uInt16 i = 0; i < GetPackCount(); i++)
+ if(aSwFlds[i].nTypeId == nTypeId)
+ return i;
+
+ return USHRT_MAX;
+}
+
+/*--------------------------------------------------------------------
+ Description: localise subtypes of a field
+ --------------------------------------------------------------------*/
+
+bool SwFldMgr::GetSubTypes(sal_uInt16 nTypeId, std::vector<OUString>& rToFill)
+{
+ bool bRet = false;
+ SwWrtShell *pSh = pWrtShell ? pWrtShell : lcl_GetShell();
+ OSL_ENSURE(pSh, "no SwWrtShell found");
+ if(pSh)
+ {
+ const sal_uInt16 nPos = GetPos(nTypeId);
+
+ switch(nTypeId)
+ {
+ case TYP_SETREFFLD:
+ case TYP_GETREFFLD:
+ {
+ // references are no fields
+ pSh->GetRefMarks( &rToFill );
+ break;
+ }
+ case TYP_MACROFLD:
+ {
+ break;
+ }
+ case TYP_INPUTFLD:
+ {
+ rToFill.push_back(SW_RES(aSwFlds[nPos].nSubTypeStart));
+ // move on at generic types
+ }
+ case TYP_DDEFLD:
+ case TYP_SEQFLD:
+ case TYP_FORMELFLD:
+ case TYP_GETFLD:
+ case TYP_SETFLD:
+ case TYP_USERFLD:
+ {
+
+ const sal_uInt16 nCount = pSh->GetFldTypeCount();
+ for(sal_uInt16 i = 0; i < nCount; ++i)
+ {
+ SwFieldType* pFldType = pSh->GetFldType( i );
+ const sal_uInt16 nWhich = pFldType->Which();
+
+ if((nTypeId == TYP_DDEFLD && pFldType->Which() == RES_DDEFLD) ||
+
+ (nTypeId == TYP_USERFLD && nWhich == RES_USERFLD) ||
+
+ (nTypeId == TYP_GETFLD && nWhich == RES_SETEXPFLD &&
+ !(((SwSetExpFieldType*)pFldType)->GetType() & nsSwGetSetExpType::GSE_SEQ)) ||
+
+ (nTypeId == TYP_SETFLD && nWhich == RES_SETEXPFLD &&
+ !(((SwSetExpFieldType*)pFldType)->GetType() & nsSwGetSetExpType::GSE_SEQ)) ||
+
+ (nTypeId == TYP_SEQFLD && nWhich == RES_SETEXPFLD &&
+ (((SwSetExpFieldType*)pFldType)->GetType() & nsSwGetSetExpType::GSE_SEQ)) ||
+
+ ((nTypeId == TYP_INPUTFLD || nTypeId == TYP_FORMELFLD) &&
+ (nWhich == RES_USERFLD ||
+ (nWhich == RES_SETEXPFLD &&
+ !(((SwSetExpFieldType*)pFldType)->GetType() & nsSwGetSetExpType::GSE_SEQ))) ) )
+ {
+ rToFill.push_back(pFldType->GetName());
+ }
+ }
+ break;
+ }
+ case TYP_DBNEXTSETFLD:
+ case TYP_DBNUMSETFLD:
+ case TYP_DBNAMEFLD:
+ case TYP_DBSETNUMBERFLD:
+ break;
+
+ default:
+ {
+ // static SubTypes
+ if(nPos != USHRT_MAX)
+ {
+ sal_uInt16 nCount;
+ if (nTypeId == TYP_DOCINFOFLD)
+ nCount = DI_SUBTYPE_END - DI_SUBTYPE_BEGIN;
+ else
+ nCount = aSwFlds[nPos].nSubTypeEnd - aSwFlds[nPos].nSubTypeStart;
+
+ for(sal_uInt16 i = 0; i < nCount; ++i)
+ {
+ OUString sNew;
+ if (nTypeId == TYP_DOCINFOFLD)
+ {
+ if ( i == DI_CUSTOM )
+ sNew = SW_RES( STR_CUSTOM );
+ else
+ sNew = SwViewShell::GetShellRes()->aDocInfoLst[i];
+ }
+ else
+ sNew = SW_RES(aSwFlds[nPos].nSubTypeStart + i);
+
+ rToFill.push_back(sNew);
+ }
+ }
+ }
+ }
+ bRet = true;
+ }
+ return bRet;
+}
+
+/*--------------------------------------------------------------------
+ Description: determine format
+ ACCESS over TYP_....
+ --------------------------------------------------------------------*/
+
+sal_uInt16 SwFldMgr::GetFormatCount(sal_uInt16 nTypeId, bool bIsText, sal_Bool bHtmlMode) const
+{
+ OSL_ENSURE(nTypeId < TYP_END, "forbidden TypeId");
+
+ {
+ const sal_uInt16 nPos = GetPos(nTypeId);
+
+ if(nPos == USHRT_MAX || (bHtmlMode && nTypeId == TYP_SETFLD))
+ return 0;
+
+ sal_uLong nStart = aSwFlds[nPos].nFmtBegin;
+ sal_uLong nEnd = aSwFlds[nPos].nFmtEnd;
+
+ if (bIsText && nEnd - nStart >= 2)
+ return 2;
+
+ if (nTypeId == TYP_FILENAMEFLD)
+ nEnd -= 2; // no range or template
+
+ switch(nStart)
+ {
+ case FMT_GETVAR_BEGIN:
+ case FMT_SETVAR_BEGIN: return VF_COUNT;
+ case FMT_USERVAR_BEGIN: return VF_USR_COUNT;
+ case FMT_DBFLD_BEGIN: return VF_DB_COUNT;
+ case FMT_NUM_BEGIN:
+ {
+ sal_uInt16 nCount = (sal_uInt16)(nEnd - nStart);
+ GetNumberingInfo();
+ if(xNumberingInfo.is())
+ {
+ Sequence<sal_Int16> aTypes = xNumberingInfo->getSupportedNumberingTypes();
+ const sal_Int16* pTypes = aTypes.getConstArray();
+ for(sal_Int32 nType = 0; nType < aTypes.getLength(); nType++)
+ {
+ sal_Int16 nCurrent = pTypes[nType];
+ //skip all values below or equal to CHARS_LOWER_LETTER_N
+ if(nCurrent > NumberingType::CHARS_LOWER_LETTER_N)
+ {
+ // #i28073# it's not necessarily a sorted sequence
+ ++nCount;
+ }
+ }
+ }
+ return nCount;
+ }
+
+ }
+ return (sal_uInt16)(nEnd - nStart);
+ }
+}
+
+/*--------------------------------------------------------------------
+ Description: determine FormatString to a type
+ --------------------------------------------------------------------*/
+
+OUString SwFldMgr::GetFormatStr(sal_uInt16 nTypeId, sal_uLong nFormatId) const
+{
+ OSL_ENSURE(nTypeId < TYP_END, "forbidden TypeId");
+
+ const sal_uInt16 nPos = GetPos(nTypeId);
+
+ if(nPos == USHRT_MAX)
+ return OUString();
+
+ sal_uLong nStart;
+
+ nStart = aSwFlds[nPos].nFmtBegin;
+
+ if (TYP_AUTHORFLD == nTypeId|| TYP_FILENAMEFLD == nTypeId)
+ nFormatId &= ~FF_FIXED; // mask out Fixed-Flag
+
+ if((nStart + nFormatId) < aSwFlds[nPos].nFmtEnd)
+ return SW_RES((sal_uInt16)(nStart + nFormatId));
+
+ OUString aRet;
+ if( FMT_NUM_BEGIN == nStart)
+ {
+ if(xNumberingInfo.is())
+ {
+ SwOLENames aNames(SW_RES(STRRES_NUMTYPES));
+ ResStringArray& rNames = aNames.GetNames();
+
+ Sequence<sal_Int16> aTypes = xNumberingInfo->getSupportedNumberingTypes();
+ const sal_Int16* pTypes = aTypes.getConstArray();
+ sal_Int32 nOffset = aSwFlds[nPos].nFmtEnd - nStart;
+ sal_Int32 nValidEntry = 0;
+ for(sal_Int32 nType = 0; nType < aTypes.getLength(); nType++)
+ {
+ sal_Int16 nCurrent = pTypes[nType];
+ if(nCurrent > NumberingType::CHARS_LOWER_LETTER_N)
+ {
+ if(nValidEntry == ((sal_Int32)nFormatId) - nOffset)
+ {
+ sal_uInt32 n = rNames.FindIndex(pTypes[nType]);
+ if (n != RESARRAY_INDEX_NOTFOUND)
+ {
+ aRet = rNames.GetString(n);
+ }
+ else
+ {
+ aRet = xNumberingInfo->getNumberingIdentifier( pTypes[nType] );
+ }
+ break;
+ }
+ ++nValidEntry;
+ }
+ }
+ }
+ }
+
+ return aRet;
+}
+
+/*--------------------------------------------------------------------
+ Description: determine FormatId from Pseudo-ID
+ --------------------------------------------------------------------*/
+
+sal_uInt16 SwFldMgr::GetFormatId(sal_uInt16 nTypeId, sal_uLong nFormatId) const
+{
+ sal_uInt16 nId = (sal_uInt16)nFormatId;
+
+ switch( nTypeId )
+ {
+ case TYP_DOCINFOFLD:
+ switch( aSwFlds[ GetPos( nTypeId ) ].nFmtBegin + nFormatId )
+ {
+ case FMT_REG_AUTHOR: nId = DI_SUB_AUTHOR; break;
+ case FMT_REG_TIME: nId = DI_SUB_TIME; break;
+ case FMT_REG_DATE: nId = DI_SUB_DATE; break;
+ }
+ break;
+
+ case TYP_PAGENUMBERFLD:
+ case TYP_NEXTPAGEFLD:
+ case TYP_PREVPAGEFLD:
+ case TYP_DOCSTATFLD:
+ case TYP_DBSETNUMBERFLD:
+ case TYP_SEQFLD:
+ case TYP_GETREFPAGEFLD:
+ {
+ sal_uInt16 nPos = GetPos( nTypeId );
+ sal_uLong nBegin = aSwFlds[ nPos ].nFmtBegin;
+ sal_uLong nEnd = aSwFlds[nPos].nFmtEnd;
+ if((nBegin + nFormatId) < nEnd)
+ {
+ switch( nBegin + nFormatId )
+ {
+ case FMT_NUM_ABC: nId = SVX_NUM_CHARS_UPPER_LETTER; break;
+ case FMT_NUM_SABC: nId = SVX_NUM_CHARS_LOWER_LETTER; break;
+ case FMT_NUM_ROMAN: nId = SVX_NUM_ROMAN_UPPER; break;
+ case FMT_NUM_SROMAN: nId = SVX_NUM_ROMAN_LOWER; break;
+ case FMT_NUM_ARABIC: nId = SVX_NUM_ARABIC; break;
+ case FMT_NUM_PAGEDESC: nId = SVX_NUM_PAGEDESC; break;
+ case FMT_NUM_PAGESPECIAL: nId = SVX_NUM_CHAR_SPECIAL; break;
+ case FMT_NUM_ABC_N: nId = SVX_NUM_CHARS_UPPER_LETTER_N; break;
+ case FMT_NUM_SABC_N: nId = SVX_NUM_CHARS_LOWER_LETTER_N; break;
+ }
+ }
+ else if(xNumberingInfo.is())
+ {
+ Sequence<sal_Int16> aTypes = xNumberingInfo->getSupportedNumberingTypes();
+ const sal_Int16* pTypes = aTypes.getConstArray();
+ sal_Int32 nOffset = nEnd - nBegin;
+ sal_Int32 nValidEntry = 0;
+ for(sal_Int32 nType = 0; nType < aTypes.getLength(); nType++)
+ {
+ sal_Int16 nCurrent = pTypes[nType];
+ if(nCurrent > NumberingType::CHARS_LOWER_LETTER_N)
+ {
+ if(nValidEntry == ((sal_Int32)nFormatId) - nOffset)
+ {
+ nId = pTypes[nType];
+ break;
+ }
+ ++nValidEntry;
+ }
+ }
+ }
+ }
+ break;
+ case TYP_DDEFLD:
+ switch ( aSwFlds[ GetPos( nTypeId ) ].nFmtBegin + nFormatId )
+ {
+ case FMT_DDE_NORMAL: nId = sfx2::LINKUPDATE_ONCALL; break;
+ case FMT_DDE_HOT: nId = sfx2::LINKUPDATE_ALWAYS; break;
+ }
+ break;
+ }
+
+ return nId;
+
+}
+
+/*--------------------------------------------------------------------
+ Description: Traveling
+ --------------------------------------------------------------------*/
+
+sal_Bool SwFldMgr::GoNextPrev( sal_Bool bNext, SwFieldType* pTyp )
+{
+ SwWrtShell* pSh = pWrtShell ? pWrtShell : ::lcl_GetShell();
+ if(!pSh)
+ return sal_False;
+
+ if( !pTyp && pCurFld )
+ {
+ const sal_uInt16 nTypeId = pCurFld->GetTypeId();
+ if( TYP_SETINPFLD == nTypeId || TYP_USRINPFLD == nTypeId )
+ pTyp = pSh->GetFldType( 0, RES_INPUTFLD );
+ else
+ pTyp = pCurFld->GetTyp();
+ }
+
+ if (pTyp && pTyp->Which() == RES_DBFLD)
+ {
+ // for fieldcommand-edit (hop to all DB fields)
+ return pSh->MoveFldType( 0, (bNext ? true : false), RES_DBFLD );
+ }
+
+ return (pTyp && pSh)
+ ? pSh->MoveFldType( pTyp, (bNext ? true : false) )
+ : sal_False;
+}
+
+/*--------------------------------------------------------------------
+ Description: insert field types
+ --------------------------------------------------------------------*/
+
+void SwFldMgr::InsertFldType(SwFieldType& rType)
+{
+ SwWrtShell* pSh = pWrtShell ? pWrtShell : ::lcl_GetShell();
+ OSL_ENSURE(pSh, "no SwWrtShell found");
+ if(pSh)
+ pSh->InsertFldType(rType);
+}
+
+/*--------------------------------------------------------------------
+ Description: determine current TypeId
+ --------------------------------------------------------------------*/
+
+sal_uInt16 SwFldMgr::GetCurTypeId() const
+{
+ return pCurFld ? pCurFld->GetTypeId() : USHRT_MAX;
+}
+
+/*--------------------------------------------------------------------
+ Description: Over string insert field or update
+ --------------------------------------------------------------------*/
+
+sal_Bool SwFldMgr::InsertFld(
+ const SwInsertFld_Data& rData)
+{
+ SwField* pFld = 0;
+ bool bExp = false;
+ bool bTbl = false;
+ bool bPageVar = false;
+ sal_uLong nFormatId = rData.nFormatId;
+ sal_uInt16 nSubType = rData.nSubType;
+ sal_Unicode cSeparator = rData.cSeparator;
+ SwWrtShell* pCurShell = rData.pSh;
+ if(!pCurShell)
+ pCurShell = pWrtShell ? pWrtShell : ::lcl_GetShell();
+ OSL_ENSURE(pCurShell, "no SwWrtShell found");
+ if(!pCurShell)
+ return sal_False;
+
+ switch(rData.nTypeId)
+ { // ATTENTION this field is inserted by a separate dialog
+ case TYP_POSTITFLD:
+ {
+ SwPostItFieldType* pType = (SwPostItFieldType*)pCurShell->GetFldType(0, RES_POSTITFLD);
+ SwPostItField* pPostItField =
+ new SwPostItField(
+ pType,
+ rData.sPar1, // author
+ rData.sPar2, // content
+ OUString(), // author's initials
+ OUString(), // name
+ DateTime(DateTime::SYSTEM) );
+ pFld = pPostItField;
+ }
+ break;
+ case TYP_SCRIPTFLD:
+ {
+ SwScriptFieldType* pType =
+ (SwScriptFieldType*)pCurShell->GetFldType(0, RES_SCRIPTFLD);
+ pFld = new SwScriptField(pType, rData.sPar1, rData.sPar2, (sal_Bool)nFormatId);
+ break;
+ }
+
+ case TYP_COMBINED_CHARS:
+ {
+ SwCombinedCharFieldType* pType = (SwCombinedCharFieldType*)
+ pCurShell->GetFldType( 0, RES_COMBINED_CHARS );
+ pFld = new SwCombinedCharField( pType, rData.sPar1 );
+ }
+ break;
+
+ case TYP_AUTHORITY:
+ {
+ SwAuthorityFieldType* pType =
+ (SwAuthorityFieldType*)pCurShell->GetFldType(0, RES_AUTHORITY);
+ if (!pType)
+ {
+ SwAuthorityFieldType const type(pCurShell->GetDoc());
+ pType = static_cast<SwAuthorityFieldType*>(
+ pCurShell->InsertFldType(type));
+ }
+ pFld = new SwAuthorityField(pType, rData.sPar1);
+ }
+ break;
+
+ case TYP_DATEFLD:
+ case TYP_TIMEFLD:
+ {
+ sal_uInt16 nSub = static_cast< sal_uInt16 >(rData.nTypeId == TYP_DATEFLD ? DATEFLD : TIMEFLD);
+ nSub |= nSubType == DATE_VAR ? 0 : FIXEDFLD;
+
+ SwDateTimeFieldType* pTyp =
+ (SwDateTimeFieldType*)pCurShell->GetFldType(0, RES_DATETIMEFLD);
+ pFld = new SwDateTimeField(pTyp, nSub, nFormatId);
+ pFld->SetPar2(rData.sPar2);
+ break;
+ }
+
+ case TYP_FILENAMEFLD:
+ {
+ SwFileNameFieldType* pTyp =
+ (SwFileNameFieldType*)pCurShell->GetFldType(0, RES_FILENAMEFLD);
+ pFld = new SwFileNameField(pTyp, nFormatId);
+ break;
+ }
+
+ case TYP_TEMPLNAMEFLD:
+ {
+ SwTemplNameFieldType* pTyp =
+ (SwTemplNameFieldType*)pCurShell->GetFldType(0, RES_TEMPLNAMEFLD);
+ pFld = new SwTemplNameField(pTyp, nFormatId);
+ break;
+ }
+
+ case TYP_CHAPTERFLD:
+ {
+ sal_uInt16 nByte = (sal_uInt16)rData.sPar2.toInt32();
+ SwChapterFieldType* pTyp =
+ (SwChapterFieldType*)pCurShell->GetFldType(0, RES_CHAPTERFLD);
+ pFld = new SwChapterField(pTyp, nFormatId);
+ nByte = std::max(sal_uInt16(1), nByte);
+ nByte = std::min(nByte, sal_uInt16(MAXLEVEL));
+ nByte -= 1;
+ ((SwChapterField*)pFld)->SetLevel((sal_uInt8)nByte);
+ break;
+ }
+
+ case TYP_NEXTPAGEFLD:
+ case TYP_PREVPAGEFLD:
+ case TYP_PAGENUMBERFLD:
+ {
+ short nOff = (short)rData.sPar2.toInt32();
+
+ if(rData.nTypeId == TYP_NEXTPAGEFLD)
+ {
+ if( SVX_NUM_CHAR_SPECIAL == nFormatId )
+ nOff = 1;
+ else
+ nOff += 1;
+ nSubType = PG_NEXT;
+ }
+ else if(rData.nTypeId == TYP_PREVPAGEFLD)
+ {
+ if( SVX_NUM_CHAR_SPECIAL == nFormatId )
+ nOff = -1;
+ else
+ nOff -= 1;
+ nSubType = PG_PREV;
+ }
+ else
+ nSubType = PG_RANDOM;
+
+ SwPageNumberFieldType* pTyp =
+ (SwPageNumberFieldType*)pCurShell->GetFldType(0, RES_PAGENUMBERFLD);
+ pFld = new SwPageNumberField(pTyp, nSubType, nFormatId, nOff);
+
+ if( SVX_NUM_CHAR_SPECIAL == nFormatId &&
+ ( PG_PREV == nSubType || PG_NEXT == nSubType ) )
+ ((SwPageNumberField*)pFld)->SetUserString( rData.sPar2 );
+ break;
+ }
+
+ case TYP_DOCSTATFLD:
+ {
+ SwDocStatFieldType* pTyp =
+ (SwDocStatFieldType*)pCurShell->GetFldType(0, RES_DOCSTATFLD);
+ pFld = new SwDocStatField(pTyp, nSubType, nFormatId);
+ break;
+ }
+
+ case TYP_AUTHORFLD:
+ {
+ SwAuthorFieldType* pTyp =
+ (SwAuthorFieldType*)pCurShell->GetFldType(0, RES_AUTHORFLD);
+ pFld = new SwAuthorField(pTyp, nFormatId);
+ break;
+ }
+
+ case TYP_CONDTXTFLD:
+ case TYP_HIDDENTXTFLD:
+ {
+ SwHiddenTxtFieldType* pTyp =
+ (SwHiddenTxtFieldType*)pCurShell->GetFldType(0, RES_HIDDENTXTFLD);
+ pFld = new SwHiddenTxtField(pTyp, sal_True, rData.sPar1, rData.sPar2, sal_False, rData.nTypeId);
+ bExp = true;
+ break;
+ }
+
+ case TYP_HIDDENPARAFLD:
+ {
+ SwHiddenParaFieldType* pTyp =
+ (SwHiddenParaFieldType*)pCurShell->GetFldType(0, RES_HIDDENPARAFLD);
+ pFld = new SwHiddenParaField(pTyp, rData.sPar1);
+ bExp = true;
+ break;
+ }
+
+ case TYP_SETREFFLD:
+ {
+ if( !rData.sPar1.isEmpty() && CanInsertRefMark( rData.sPar1 ) )
+ {
+ pCurShell->SetAttrItem( SwFmtRefMark( rData.sPar1 ) );
+ return sal_True;
+ }
+ return sal_False;
+ }
+
+ case TYP_GETREFFLD:
+ {
+ SwGetRefFieldType* pTyp =
+ (SwGetRefFieldType*)pCurShell->GetFldType(0, RES_GETREFFLD);
+ sal_uInt16 nSeqNo = (sal_uInt16)rData.sPar2.toInt32();
+ pFld = new SwGetRefField(pTyp, rData.sPar1, nSubType, nSeqNo, nFormatId);
+ bExp = true;
+ break;
+ }
+
+ case TYP_DDEFLD:
+ {
+ //JP 28.08.95: DDE-Topics/-Items can have blanks in their names!
+ // That's not yet considered here.
+ sal_Int32 nIndex = 0;
+ OUString sCmd = rData.sPar2.replaceFirst(OUString(' '), OUString(sfx2::cTokenSeparator), &nIndex);
+ if (nIndex>=0 && ++nIndex<sCmd.getLength())
+ {
+ sCmd = sCmd.replaceFirst(OUString(' '), OUString(sfx2::cTokenSeparator), &nIndex);
+ }
+
+ SwDDEFieldType aType( rData.sPar1, sCmd, (sal_uInt16) nFormatId );
+ SwDDEFieldType* pTyp = (SwDDEFieldType*) pCurShell->InsertFldType( aType );
+ pFld = new SwDDEField( pTyp );
+ break;
+ }
+
+ case TYP_MACROFLD:
+ {
+ SwMacroFieldType* pTyp =
+ (SwMacroFieldType*)pCurShell->GetFldType(0, RES_MACROFLD);
+
+ pFld = new SwMacroField(pTyp, rData.sPar1, rData.sPar2);
+
+ break;
+ }
+
+ case TYP_INTERNETFLD:
+ {
+ SwFmtINetFmt aFmt( rData.sPar1, sCurFrame );
+ if( pMacroItem )
+ aFmt.SetMacroTbl( &pMacroItem->GetMacroTable() );
+ return pCurShell->InsertURL( aFmt, rData.sPar2 );
+ }
+
+ case TYP_JUMPEDITFLD:
+ {
+ SwJumpEditFieldType* pTyp =
+ (SwJumpEditFieldType*)pCurShell->GetFldType(0, RES_JUMPEDITFLD);
+
+ pFld = new SwJumpEditField(pTyp, nFormatId, rData.sPar1, rData.sPar2 );
+ break;
+ }
+
+ case TYP_DOCINFOFLD:
+ {
+ SwDocInfoFieldType* pTyp = (SwDocInfoFieldType*)pCurShell->GetFldType(
+ 0, RES_DOCINFOFLD );
+ pFld = new SwDocInfoField(pTyp, nSubType, rData.sPar1, nFormatId);
+ break;
+ }
+
+ case TYP_EXTUSERFLD:
+ {
+ SwExtUserFieldType* pTyp = (SwExtUserFieldType*)pCurShell->GetFldType(
+ 0, RES_EXTUSERFLD);
+ pFld = new SwExtUserField(pTyp, nSubType, nFormatId);
+ break;
+ }
+
+ case TYP_DBFLD:
+ {
+ SwDBData aDBData;
+ OUString sPar1;
+
+ if (rData.sPar1.indexOf(DB_DELIM)<0)
+ {
+ aDBData = pCurShell->GetDBData();
+ sPar1 = rData.sPar1;
+ }
+ else
+ {
+ aDBData.sDataSource = rData.sPar1.getToken(0, DB_DELIM);
+ aDBData.sCommand = rData.sPar1.getToken(1, DB_DELIM);
+ aDBData.nCommandType = rData.sPar1.getToken(2, DB_DELIM).toInt32();
+ sPar1 = rData.sPar1.getToken(3, DB_DELIM);
+ }
+
+ if(!aDBData.sDataSource.isEmpty() && pCurShell->GetDBData() != aDBData)
+ pCurShell->ChgDBData(aDBData);
+
+ SwDBFieldType* pTyp = (SwDBFieldType*)pCurShell->InsertFldType(
+ SwDBFieldType(pCurShell->GetDoc(), sPar1, aDBData) );
+ pFld = new SwDBField(pTyp);
+ pFld->SetSubType(nSubType);
+
+ if( !(nSubType & nsSwExtendedSubType::SUB_OWN_FMT) ) // determinee database format
+ {
+ Reference< XDataSource> xSource;
+ rData.aDBDataSource >>= xSource;
+ Reference<XConnection> xConnection;
+ rData.aDBConnection >>= xConnection;
+ Reference<XPropertySet> xColumn;
+ rData.aDBColumn >>= xColumn;
+ if(xColumn.is())
+ {
+ nFormatId = pCurShell->GetNewDBMgr()->GetColumnFmt(xSource, xConnection, xColumn,
+ pCurShell->GetNumberFormatter(), GetCurrLanguage() );
+ }
+ else
+ nFormatId = pCurShell->GetNewDBMgr()->GetColumnFmt(
+ aDBData.sDataSource, aDBData.sCommand, sPar1,
+ pCurShell->GetNumberFormatter(), GetCurrLanguage() );
+ }
+ pFld->ChangeFormat( nFormatId );
+
+ bExp = true;
+ break;
+ }
+
+ case TYP_DBSETNUMBERFLD:
+ case TYP_DBNUMSETFLD:
+ case TYP_DBNEXTSETFLD:
+ case TYP_DBNAMEFLD:
+ {
+ SwDBData aDBData;
+
+ // excract DBName from rData.sPar1. Format: DBName.TableName.CommandType.ExpStrg
+ sal_Int32 nTablePos = rData.sPar1.indexOf(DB_DELIM);
+ sal_Int32 nCmdTypePos = -1;
+ sal_Int32 nExpPos = -1;
+
+ if (nTablePos>=0)
+ {
+ aDBData.sDataSource = rData.sPar1.copy(0, nTablePos++);
+ nCmdTypePos = rData.sPar1.indexOf(DB_DELIM, nTablePos);
+ if (nCmdTypePos>=0)
+ {
+ aDBData.sCommand = rData.sPar1.copy(nTablePos, nCmdTypePos++ - nTablePos);
+ nExpPos = rData.sPar1.indexOf(DB_DELIM, nCmdTypePos);
+ if (nExpPos>=0)
+ {
+ aDBData.nCommandType = rData.sPar1.copy(nCmdTypePos, nExpPos++ - nCmdTypePos).toInt32();
+ }
+ }
+ }
+
+ sal_Int32 nPos = 0;
+ if (nExpPos>=0)
+ nPos = nExpPos;
+ else if (nTablePos>=0)
+ nPos = nTablePos;
+
+ OUString sPar1 = rData.sPar1.copy(nPos);
+
+ if (!aDBData.sDataSource.isEmpty() && pCurShell->GetDBData() != aDBData)
+ pCurShell->ChgDBData(aDBData);
+
+ switch(rData.nTypeId)
+ {
+ case TYP_DBNAMEFLD:
+ {
+ SwDBNameFieldType* pTyp =
+ (SwDBNameFieldType*)pCurShell->GetFldType(0, RES_DBNAMEFLD);
+ pFld = new SwDBNameField(pTyp, aDBData);
+
+ break;
+ }
+ case TYP_DBNEXTSETFLD:
+ {
+ SwDBNextSetFieldType* pTyp = (SwDBNextSetFieldType*)pCurShell->GetFldType(
+ 0, RES_DBNEXTSETFLD);
+ pFld = new SwDBNextSetField(pTyp, sPar1, rData.sPar2, aDBData);
+ bExp = true;
+ break;
+ }
+ case TYP_DBNUMSETFLD:
+ {
+ SwDBNumSetFieldType* pTyp = (SwDBNumSetFieldType*)pCurShell->GetFldType(
+ 0, RES_DBNUMSETFLD);
+ pFld = new SwDBNumSetField( pTyp, sPar1, rData.sPar2, aDBData);
+ bExp = true;
+ break;
+ }
+ case TYP_DBSETNUMBERFLD:
+ {
+ SwDBSetNumberFieldType* pTyp = (SwDBSetNumberFieldType*)
+ pCurShell->GetFldType(0, RES_DBSETNUMBERFLD);
+ pFld = new SwDBSetNumberField( pTyp, aDBData, nFormatId);
+ bExp = true;
+ break;
+ }
+ }
+ break;
+ }
+
+ case TYP_USERFLD:
+ {
+ SwUserFieldType* pTyp =
+ (SwUserFieldType*)pCurShell->GetFldType(RES_USERFLD, rData.sPar1);
+
+ // only if existing
+ if(!pTyp)
+ {
+ pTyp = (SwUserFieldType*)pCurShell->InsertFldType(
+ SwUserFieldType(pCurShell->GetDoc(), rData.sPar1));
+ }
+ if (pTyp->GetContent(nFormatId) != rData.sPar2)
+ pTyp->SetContent(rData.sPar2, nFormatId);
+ pFld = new SwUserField(pTyp, 0, nFormatId);
+ if (pFld->GetSubType() != nSubType)
+ pFld->SetSubType(nSubType);
+ bTbl = true;
+ break;
+ }
+
+ case TYP_INPUTFLD:
+ {
+ if ((nSubType & 0x00ff) == INP_VAR)
+ {
+ SwSetExpFieldType* pTyp = (SwSetExpFieldType*)
+ pCurShell->GetFldType(RES_SETEXPFLD, rData.sPar1);
+
+ // no Experssion Type with this name existing -> create
+ if(pTyp)
+ {
+ SwSetExpField* pExpFld =
+ new SwSetExpField(pTyp, OUString(), nFormatId);
+
+ // Don't change type of SwSetExpFieldType:
+ sal_uInt16 nOldSubType = pExpFld->GetSubType();
+ pExpFld->SetSubType(nOldSubType | (nSubType & 0xff00));
+
+ pExpFld->SetPromptText(rData.sPar2);
+ pExpFld->SetInputFlag(sal_True) ;
+ bExp = true;
+ pFld = pExpFld;
+ }
+ else
+ return sal_False;
+ }
+ else
+ {
+ SwInputFieldType* pTyp =
+ (SwInputFieldType*)pCurShell->GetFldType(0, RES_INPUTFLD);
+
+ SwInputField* pInpFld =
+ new SwInputField( pTyp, rData.sPar1, rData.sPar2, nSubType|nsSwExtendedSubType::SUB_INVISIBLE, nFormatId);
+ pFld = pInpFld;
+ }
+
+ // start dialog
+ pCurShell->StartInputFldDlg(pFld, sal_False, rData.pParent);
+ break;
+ }
+
+ case TYP_SETFLD:
+ {
+ if (rData.sPar2.isEmpty()) // empty variables are not allowed
+ return sal_False;
+
+ SwSetExpFieldType* pTyp = (SwSetExpFieldType*)pCurShell->InsertFldType(
+ SwSetExpFieldType(pCurShell->GetDoc(), rData.sPar1) );
+
+ SwSetExpField* pExpFld = new SwSetExpField( pTyp, rData.sPar2, nFormatId);
+ pExpFld->SetSubType(nSubType);
+ pExpFld->SetPar2(rData.sPar2);
+ bExp = true;
+ pFld = pExpFld;
+ break;
+ }
+
+ case TYP_SEQFLD:
+ {
+ SwSetExpFieldType* pTyp = (SwSetExpFieldType*)pCurShell->InsertFldType(
+ SwSetExpFieldType(pCurShell->GetDoc(), rData.sPar1, nsSwGetSetExpType::GSE_SEQ));
+
+ sal_uInt8 nLevel = static_cast< sal_uInt8 >(nSubType & 0xff);
+
+ pTyp->SetOutlineLvl(nLevel);
+ if (nLevel != 0x7f && cSeparator == 0)
+ cSeparator = '.';
+
+ pTyp->SetDelimiter(OUString(cSeparator));
+ SwSetExpField* pExpFld = new SwSetExpField(pTyp, rData.sPar2, nFormatId);
+ bExp = true;
+ pFld = pExpFld;
+ nSubType = nsSwGetSetExpType::GSE_SEQ;
+ break;
+ }
+
+ case TYP_GETFLD:
+ {
+ // is there a corresponding SetField
+ SwSetExpFieldType* pSetTyp = (SwSetExpFieldType*)
+ pCurShell->GetFldType(RES_SETEXPFLD, rData.sPar1);
+
+ if(pSetTyp)
+ {
+ SwGetExpFieldType* pTyp = (SwGetExpFieldType*)pCurShell->GetFldType(
+ 0, RES_GETEXPFLD);
+ pFld = new SwGetExpField(pTyp, rData.sPar1, pSetTyp->GetType(), nFormatId);
+ pFld->SetSubType(nSubType | pSetTyp->GetType());
+ bExp = true;
+ }
+ else
+ return sal_False;
+ break;
+ }
+
+ case TYP_FORMELFLD:
+ {
+ if(pCurShell->GetFrmType(0,sal_False) & FRMTYPE_TABLE)
+ {
+ pCurShell->StartAllAction();
+
+ SvNumberFormatter* pFormatter = pCurShell->GetDoc()->GetNumberFormatter();
+ const SvNumberformat* pEntry = pFormatter->GetEntry(nFormatId);
+
+ if (pEntry)
+ {
+ SfxStringItem aFormat(FN_NUMBER_FORMAT, pEntry->GetFormatstring());
+ pCurShell->GetView().GetViewFrame()->GetDispatcher()->
+ Execute(FN_NUMBER_FORMAT, SFX_CALLMODE_SYNCHRON, &aFormat, 0L);
+ }
+
+ SfxItemSet aBoxSet( pCurShell->GetAttrPool(),
+ RES_BOXATR_FORMULA, RES_BOXATR_FORMULA );
+
+ OUString sFml(comphelper::string::stripStart(rData.sPar2, ' '));
+ if ( sFml.startsWith("=") )
+ {
+ sFml = sFml.copy(1);
+ }
+
+ aBoxSet.Put( SwTblBoxFormula( sFml ));
+ pCurShell->SetTblBoxFormulaAttrs( aBoxSet );
+ pCurShell->UpdateTable();
+
+ pCurShell->EndAllAction();
+ return sal_True;
+
+ }
+ else
+ {
+ SwGetExpFieldType* pTyp = (SwGetExpFieldType*)
+ pCurShell->GetFldType(0, RES_GETEXPFLD);
+ pFld = new SwGetExpField(pTyp, rData.sPar2, nsSwGetSetExpType::GSE_FORMULA, nFormatId);
+ pFld->SetSubType(nSubType);
+ bExp = true;
+ }
+ break;
+ }
+ case TYP_SETREFPAGEFLD:
+ pFld = new SwRefPageSetField( (SwRefPageSetFieldType*)
+ pCurShell->GetFldType( 0, RES_REFPAGESETFLD ),
+ (short)rData.sPar2.toInt32(), 0 != nSubType );
+ bPageVar = true;
+ break;
+
+ case TYP_GETREFPAGEFLD:
+ pFld = new SwRefPageGetField( (SwRefPageGetFieldType*)
+ pCurShell->GetFldType( 0, RES_REFPAGEGETFLD ), nFormatId );
+ bPageVar = true;
+ break;
+ case TYP_DROPDOWN :
+ {
+ pFld = new SwDropDownField(pCurShell->GetFldType( 0, RES_DROPDOWN ));
+ const sal_Int32 nTokenCount = comphelper::string::getTokenCount(rData.sPar2, DB_DELIM);
+ Sequence<OUString> aEntries(nTokenCount);
+ OUString* pArray = aEntries.getArray();
+ for(sal_Int32 nToken = 0; nToken < nTokenCount; nToken++)
+ pArray[nToken] = rData.sPar2.getToken(nToken, DB_DELIM);
+ ((SwDropDownField*)pFld)->SetItems(aEntries);
+ ((SwDropDownField*)pFld)->SetName(rData.sPar1);
+ }
+ break;
+ default:
+ { OSL_ENSURE(!this, "wrong field type");
+ return sal_False;
+ }
+ }
+ OSL_ENSURE(pFld, "field not available");
+
+ //the auto language flag has to be set prior to the language!
+ pFld->SetAutomaticLanguage(rData.bIsAutomaticLanguage);
+ sal_uInt16 nLang = GetCurrLanguage();
+ pFld->SetLanguage(nLang);
+
+ // insert
+ pCurShell->StartAllAction();
+
+ pCurShell->Insert( *pFld );
+
+ if(bExp && bEvalExp)
+ pCurShell->UpdateExpFlds(sal_True);
+
+ if(bTbl)
+ {
+ pCurShell->Left(CRSR_SKIP_CHARS, sal_False, 1, sal_False );
+ pCurShell->UpdateFlds(*pFld);
+ pCurShell->Right(CRSR_SKIP_CHARS, sal_False, 1, sal_False );
+ }
+ else if( bPageVar )
+ ((SwRefPageGetFieldType*)pCurShell->GetFldType( 0, RES_REFPAGEGETFLD ))->UpdateFlds();
+ else if( TYP_GETREFFLD == rData.nTypeId )
+ pFld->GetTyp()->ModifyNotification( 0, 0 );
+
+ // delete temporary field
+ delete pFld;
+
+ pCurShell->EndAllAction();
+ return sal_True;
+}
+
+/*--------------------------------------------------------------------
+ Description: fields update
+ --------------------------------------------------------------------*/
+
+void SwFldMgr::UpdateCurFld(sal_uLong nFormat,
+ const OUString& rPar1,
+ const OUString& rPar2,
+ SwField * _pTmpFld) // #111840#
+{
+ // change format
+ OSL_ENSURE(pCurFld, "no field at CursorPos");
+
+ bool bDelete = false;
+ SwField *pTmpFld; // mb: fixed memory leak
+ if (NULL != _pTmpFld)
+ {
+ pTmpFld = _pTmpFld;
+ }
+ else
+ {
+ pTmpFld = pCurFld->CopyField();
+ bDelete = true;
+ }
+
+ SwFieldType* pType = pTmpFld->GetTyp();
+ const sal_uInt16 nTypeId = pTmpFld->GetTypeId();
+
+ SwWrtShell* pSh = pWrtShell ? pWrtShell : ::lcl_GetShell();
+ OSL_ENSURE(pSh, "no SwWrtShell found");
+ if(!pSh)
+ return;
+ pSh->StartAllAction();
+
+ bool bSetPar2 = true;
+ bool bSetPar1 = true;
+ OUString sPar1( rPar1 );
+ OUString sPar2( rPar2 );
+
+ // Order to Format
+ switch( nTypeId )
+ {
+ case TYP_DDEFLD:
+ {
+ // DDE-Topics/-Items can have blanks in their names!
+ // That's not yet considered here!
+ sal_Int32 nIndex = 0;
+ sPar2 = sPar2.replaceFirst(OUString(' '), OUString(sfx2::cTokenSeparator), &nIndex );
+ if (nIndex>=0 && ++nIndex<sPar2.getLength())
+ {
+ sPar2 = sPar2.replaceFirst(OUString(' '), OUString(sfx2::cTokenSeparator), &nIndex);
+ }
+ break;
+ }
+
+ case TYP_CHAPTERFLD:
+ {
+ sal_uInt16 nByte = (sal_uInt16)rPar2.toInt32();
+ nByte = std::max(sal_uInt16(1), nByte);
+ nByte = std::min(nByte, sal_uInt16(MAXLEVEL));
+ nByte -= 1;
+ ((SwChapterField*)pTmpFld)->SetLevel((sal_uInt8)nByte);
+ bSetPar2 = false;
+ break;
+ }
+
+ case TYP_SCRIPTFLD:
+ ((SwScriptField*)pTmpFld)->SetCodeURL((sal_Bool)nFormat);
+ break;
+
+ case TYP_NEXTPAGEFLD:
+ if( SVX_NUM_CHAR_SPECIAL == nFormat )
+ {
+ ((SwPageNumberField*)pCurFld)->SetUserString( sPar2 );
+ sPar2 = "1";
+ }
+ else
+ {
+ if( nFormat + 2 == SVX_NUM_PAGEDESC )
+ nFormat = SVX_NUM_PAGEDESC;
+ short nOff = (short)sPar2.toInt32();
+ nOff += 1;
+ sPar2 = OUString::number(nOff);
+ }
+ break;
+
+ case TYP_PREVPAGEFLD:
+ if( SVX_NUM_CHAR_SPECIAL == nFormat )
+ {
+ ((SwPageNumberField*)pCurFld)->SetUserString( sPar2 );
+ sPar2 = "-1";
+ }
+ else
+ {
+ if( nFormat + 2 == SVX_NUM_PAGEDESC )
+ nFormat = SVX_NUM_PAGEDESC;
+ short nOff = (short)sPar2.toInt32();
+ nOff -= 1;
+ sPar2 = OUString::number(nOff);
+ }
+ break;
+
+ case TYP_PAGENUMBERFLD:
+ case TYP_GETREFPAGEFLD:
+ if( nFormat + 2 == SVX_NUM_PAGEDESC )
+ nFormat = SVX_NUM_PAGEDESC;
+ break;
+
+ case TYP_GETREFFLD:
+ {
+ bSetPar2 = false;
+ ((SwGetRefField*)pTmpFld)->SetSubType( (sal_uInt16)rPar2.toInt32() );
+ const sal_Int32 nPos = rPar2.indexOf( '|' );
+ if( nPos>=0 )
+ ((SwGetRefField*)pTmpFld)->SetSeqNo( (sal_uInt16)rPar2.copy( nPos + 1 ).toInt32());
+ }
+ break;
+ case TYP_DROPDOWN:
+ {
+ sal_Int32 nTokenCount = comphelper::string::getTokenCount(sPar2, DB_DELIM);
+ Sequence<OUString> aEntries(nTokenCount);
+ OUString* pArray = aEntries.getArray();
+ for(sal_Int32 nToken = 0; nToken < nTokenCount; nToken++)
+ pArray[nToken] = sPar2.getToken(nToken, DB_DELIM);
+ ((SwDropDownField*)pTmpFld)->SetItems(aEntries);
+ ((SwDropDownField*)pTmpFld)->SetName(sPar1);
+ bSetPar1 = bSetPar2 = false;
+ }
+ break;
+ case TYP_AUTHORITY :
+ {
+ //#i99069# changes to a bibliography field should change the field type
+ SwAuthorityField* pAuthorityField = static_cast<SwAuthorityField*>(pTmpFld);
+ SwAuthorityFieldType* pAuthorityType = static_cast<SwAuthorityFieldType*>(pType);
+ SwAuthEntry aTempEntry;
+ for( sal_uInt16 i = 0; i < AUTH_FIELD_END; ++i )
+ aTempEntry.SetAuthorField( (ToxAuthorityField)i,
+ rPar1.getToken( i, TOX_STYLE_DELIMITER ));
+ if( pAuthorityType->ChangeEntryContent( &aTempEntry ) )
+ {
+ pType->UpdateFlds();
+ pSh->SetModified();
+ }
+
+ if( aTempEntry.GetAuthorField( AUTH_FIELD_IDENTIFIER ) ==
+ pAuthorityField->GetFieldText( AUTH_FIELD_IDENTIFIER ) )
+ bSetPar1 = false; //otherwise it's a new or changed entry, the field needs to be updated
+ bSetPar2 = false;
+ }
+ break;
+ }
+
+ // set format
+ // setup format before SetPar2 because of NumberFormatter!
+ pTmpFld->ChangeFormat(nFormat);
+
+ if(bSetPar1)
+ pTmpFld->SetPar1( sPar1 );
+ if( bSetPar2 )
+ pTmpFld->SetPar2( sPar2 );
+
+ // kick off update
+ if(nTypeId == TYP_DDEFLD ||
+ nTypeId == TYP_USERFLD ||
+ nTypeId == TYP_USRINPFLD)
+ {
+ pType->UpdateFlds();
+ pSh->SetModified();
+ }
+ else {
+ // mb: #32157
+ pSh->SwEditShell::UpdateFlds(*pTmpFld);
+ GetCurFld();
+ }
+
+ if (bDelete)
+ delete pTmpFld;
+
+ pSh->EndAllAction();
+}
+
+/*--------------------------------------------------------------------
+ Description: explicitly evaluate ExpressionFields
+ --------------------------------------------------------------------*/
+void SwFldMgr::EvalExpFlds(SwWrtShell* pSh)
+{
+ if (pSh == NULL)
+ pSh = pWrtShell ? pWrtShell : ::lcl_GetShell();
+
+ if(pSh)
+ {
+ pSh->StartAllAction();
+ pSh->UpdateExpFlds(sal_True);
+ pSh->EndAllAction();
+ }
+}
+sal_uInt16 SwFldMgr::GetCurrLanguage() const
+{
+ SwWrtShell* pSh = pWrtShell ? pWrtShell : ::lcl_GetShell();
+ if( pSh )
+ return pSh->GetCurLang();
+ return SvtSysLocale().GetLanguageTag().getLanguageType();
+}
+
+void SwFieldType::_GetFldName()
+{
+ static const sal_uInt16 coFldNms[] = {
+ FLD_DATE_STD,
+ FLD_TIME_STD,
+ STR_FILENAMEFLD,
+ STR_DBNAMEFLD,
+ STR_CHAPTERFLD,
+ STR_PAGENUMBERFLD,
+ STR_DOCSTATFLD,
+ STR_AUTHORFLD,
+ STR_SETFLD,
+ STR_GETFLD,
+ STR_FORMELFLD,
+ STR_HIDDENTXTFLD,
+ STR_SETREFFLD,
+ STR_GETREFFLD,
+ STR_DDEFLD,
+ STR_MACROFLD,
+ STR_INPUTFLD,
+ STR_HIDDENPARAFLD,
+ STR_DOCINFOFLD,
+ STR_DBFLD,
+ STR_USERFLD,
+ STR_POSTITFLD,
+ STR_TEMPLNAMEFLD,
+ STR_SEQFLD,
+ STR_DBNEXTSETFLD,
+ STR_DBNUMSETFLD,
+ STR_DBSETNUMBERFLD,
+ STR_CONDTXTFLD,
+ STR_NEXTPAGEFLD,
+ STR_PREVPAGEFLD,
+ STR_EXTUSERFLD,
+ FLD_DATE_FIX,
+ FLD_TIME_FIX,
+ STR_SETINPUTFLD,
+ STR_USRINPUTFLD,
+ STR_SETREFPAGEFLD,
+ STR_GETREFPAGEFLD,
+ STR_INTERNETFLD,
+ STR_JUMPEDITFLD,
+ STR_SCRIPTFLD,
+ STR_AUTHORITY,
+ STR_COMBINED_CHARS,
+ STR_DROPDOWN,
+ STR_CUSTOM
+ };
+
+ // insert infos for fields
+ SwFieldType::pFldNames = new std::vector<OUString>;
+ SwFieldType::pFldNames->reserve(SAL_N_ELEMENTS(coFldNms));
+ for( sal_uInt16 nIdx = 0; nIdx < SAL_N_ELEMENTS(coFldNms); ++nIdx )
+ {
+ const OUString aTmp(SW_RES( coFldNms[ nIdx ] ));
+ SwFieldType::pFldNames->push_back(MnemonicGenerator::EraseAllMnemonicChars( aTmp ));
+ }
+}
+
+sal_Bool SwFldMgr::ChooseMacro(const OUString&)
+{
+ sal_Bool bRet = sal_False;
+
+ // choose script dialog
+ OUString aScriptURL = SfxApplication::ChooseScript();
+
+ // the script selector dialog returns a valid script URL
+ if ( !aScriptURL.isEmpty() )
+ {
+ SetMacroPath( aScriptURL );
+ bRet = sal_True;
+ }
+
+ return bRet;
+}
+
+void SwFldMgr::SetMacroPath(const OUString& rPath)
+{
+ sMacroPath = rPath;
+ sMacroName = rPath;
+
+ // try to set sMacroName member variable by parsing the macro path
+ // using the new URI parsing services
+
+ Reference< XComponentContext > xContext =
+ ::comphelper::getProcessComponentContext();
+
+ Reference< uri::XUriReferenceFactory >
+ xFactory = uri::UriReferenceFactory::create( xContext );
+
+ Reference< uri::XVndSunStarScriptUrl >
+ xUrl( xFactory->parse( sMacroPath ), UNO_QUERY );
+
+ if ( xUrl.is() )
+ {
+ sMacroName = xUrl->getName();
+ }
+}
+
+sal_uLong SwFldMgr::GetDefaultFormat(sal_uInt16 nTypeId, bool bIsText, SvNumberFormatter* pFormatter, double* pVal)
+{
+ double fValue;
+ short nDefFormat;
+
+ switch (nTypeId)
+ {
+ case TYP_TIMEFLD:
+ case TYP_DATEFLD:
+ {
+ Date aDate( Date::SYSTEM );
+ Date* pNullDate = pFormatter->GetNullDate();
+
+ fValue = aDate - *pNullDate;
+
+ Time aTime( Time::SYSTEM );
+
+ sal_uLong nNumFmtTime = (sal_uLong)aTime.GetSec() + (sal_uLong)aTime.GetMin() * 60L +
+ (sal_uLong)aTime.GetHour() * 3600L;
+
+ fValue += (double)nNumFmtTime / 86400.0;
+
+ nDefFormat = (nTypeId == TYP_DATEFLD) ? NUMBERFORMAT_DATE : NUMBERFORMAT_TIME;
+ }
+ break;
+
+ default:
+ if (bIsText)
+ {
+ fValue = 0.0;
+ nDefFormat = NUMBERFORMAT_TEXT;
+ }
+ else
+ {
+ fValue = 0.0;
+ nDefFormat = NUMBERFORMAT_ALL;
+ }
+ break;
+ }
+
+ if (pVal)
+ *pVal = fValue;
+
+ return pFormatter->GetStandardFormat(nDefFormat, GetCurrLanguage());
+}
+
+Reference<XNumberingTypeInfo> SwFldMgr::GetNumberingInfo() const
+{
+ if(!xNumberingInfo.is())
+ {
+ Reference<XComponentContext> xContext( ::comphelper::getProcessComponentContext() );
+ Reference<XDefaultNumberingProvider> xDefNum = text::DefaultNumberingProvider::create(xContext);
+ ((SwFldMgr*)this)->xNumberingInfo = Reference<XNumberingTypeInfo>(xDefNum, UNO_QUERY);
+ }
+ return xNumberingInfo;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/fldui/fldwrap.cxx b/sw/source/core/uibase/fldui/fldwrap.cxx
new file mode 100644
index 000000000000..955978d7b8b8
--- /dev/null
+++ b/sw/source/core/uibase/fldui/fldwrap.cxx
@@ -0,0 +1,161 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <cmdid.h>
+#include <swtypes.hxx>
+#include <sfx2/basedlgs.hxx>
+#include <sfx2/dispatch.hxx>
+#include <vcl/msgbox.hxx>
+#include <sfx2/htmlmode.hxx>
+#include <viewopt.hxx>
+#include <docsh.hxx>
+#include <fldwrap.hxx>
+#include <wrtsh.hxx>
+#include <view.hxx>
+#include <swmodule.hxx>
+
+#include <helpid.h>
+#include <fldui.hrc>
+#include <globals.hrc>
+#include "swabstdlg.hxx"
+
+SFX_IMPL_CHILDWINDOW_WITHID(SwFldDlgWrapper, FN_INSERT_FIELD)
+
+SwChildWinWrapper::SwChildWinWrapper(Window *pParentWindow, sal_uInt16 nId) :
+ SfxChildWindow(pParentWindow, nId),
+ m_pDocSh(0)
+{
+ // avoid flickering of buttons:
+ m_aUpdateTimer.SetTimeout(200);
+ m_aUpdateTimer.SetTimeoutHdl(LINK(this, SwChildWinWrapper, UpdateHdl));
+}
+
+IMPL_LINK_NOARG(SwChildWinWrapper, UpdateHdl)
+{
+ GetWindow()->Activate(); // update dialog
+
+ return 0;
+}
+
+/*--------------------------------------------------------------------
+ Description: newly initialise dialog after Doc switch
+ --------------------------------------------------------------------*/
+sal_Bool SwChildWinWrapper::ReInitDlg(SwDocShell *)
+{
+ sal_Bool bRet = sal_False;
+
+ if (m_pDocSh != GetOldDocShell())
+ {
+ m_aUpdateTimer.Stop();
+ bRet = sal_True; // immediate Update
+ }
+ else
+ m_aUpdateTimer.Start();
+
+ return bRet;
+}
+
+SfxChildWinInfo SwFldDlgWrapper::GetInfo() const
+{
+ SfxChildWinInfo aInfo = SfxChildWindow::GetInfo();
+ aInfo.aPos = GetWindow()->OutputToAbsoluteScreenPixel(aInfo.aPos);
+ return aInfo;
+}
+
+SwFldDlgWrapper::SwFldDlgWrapper( Window* _pParent, sal_uInt16 nId,
+ SfxBindings* pB,
+ SfxChildWinInfo* )
+ : SwChildWinWrapper( _pParent, nId )
+{
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+
+ AbstractSwFldDlg* pDlg = pFact->CreateSwFldDlg(pB, this, _pParent);
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ pDlgInterface = pDlg;
+ pWindow = pDlg->GetWindow();
+ pDlg->Start();
+ eChildAlignment = SFX_ALIGN_NOALIGNMENT;
+}
+
+/*--------------------------------------------------------------------
+ Description: newly initialise dialog after Doc switch
+ --------------------------------------------------------------------*/
+sal_Bool SwFldDlgWrapper::ReInitDlg(SwDocShell *pDocSh)
+{
+ sal_Bool bRet;
+
+ if ((bRet = SwChildWinWrapper::ReInitDlg(pDocSh)) == sal_True) // update immediately, Doc switch
+ {
+ pDlgInterface->ReInitDlg();
+ }
+
+ return bRet;
+}
+
+void SwFldDlgWrapper::ShowReferencePage()
+{
+ pDlgInterface->ShowReferencePage();
+}
+
+SFX_IMPL_CHILDWINDOW(SwFldDataOnlyDlgWrapper, FN_INSERT_FIELD_DATA_ONLY)
+
+SfxChildWinInfo SwFldDataOnlyDlgWrapper::GetInfo() const
+{
+ SfxChildWinInfo aInfo = SfxChildWindow::GetInfo();
+// prevent instatiation of dialog other than by calling
+// the mail merge dialog
+ aInfo.bVisible = sal_False;
+ return aInfo;
+}
+
+SwFldDataOnlyDlgWrapper::SwFldDataOnlyDlgWrapper( Window* _pParent, sal_uInt16 nId,
+ SfxBindings* pB,
+ SfxChildWinInfo* pInfo )
+ : SwChildWinWrapper( _pParent, nId )
+{
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+
+ AbstractSwFldDlg* pDlg = pFact->CreateSwFldDlg(pB, this, _pParent);
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ pDlgInterface = pDlg;
+
+ pWindow = pDlg->GetWindow();
+ pDlg->ActivateDatabasePage();
+ pDlg->Start();
+ pDlg->Initialize( pInfo );
+ eChildAlignment = SFX_ALIGN_NOALIGNMENT;
+}
+
+/* --------------------------------------------------
+ * re-init after doc activation
+ * --------------------------------------------------*/
+sal_Bool SwFldDataOnlyDlgWrapper::ReInitDlg(SwDocShell *pDocSh)
+{
+ sal_Bool bRet;
+ if ((bRet = SwChildWinWrapper::ReInitDlg(pDocSh)) == sal_True) // update immediately, Doc switch
+ {
+ pDlgInterface->ReInitDlg();
+ }
+
+ return bRet;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/fldui/xfldui.cxx b/sw/source/core/uibase/fldui/xfldui.cxx
new file mode 100644
index 000000000000..000a5b75a54c
--- /dev/null
+++ b/sw/source/core/uibase/fldui/xfldui.cxx
@@ -0,0 +1,168 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <osl/diagnose.h>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdb/XQueriesSupplier.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <comphelper/processfactory.hxx>
+#include <fldmgr.hxx>
+#include <dbmgr.hxx>
+#include <wrtsh.hxx>
+#include <view.hxx>
+#include <swmodule.hxx>
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::beans;
+
+// This file contains all routines of the fldui directory, which must compile
+// with exceptions. So we can reduce the code of the other files, which don't
+// need any exception handling.
+
+/*--------------------------------------------------------------------
+ Description: Is the database field numeric?
+ remark: in case of error sal_True is returned
+ --------------------------------------------------------------------*/
+
+sal_Bool SwFldMgr::IsDBNumeric( const OUString& rDBName, const OUString& rTblQryName,
+ sal_Bool bIsTable, const OUString& rFldName)
+{
+ sal_Bool bNumeric = sal_True;
+
+ SwNewDBMgr* pDBMgr = pWrtShell ? pWrtShell->GetNewDBMgr() :
+ ::GetActiveView()->GetWrtShell().GetNewDBMgr();
+
+ OUString sSource(rDBName);
+ Reference< XConnection> xConnection =
+ pDBMgr->RegisterConnection(sSource);
+
+ if( !xConnection.is() )
+ return bNumeric;
+
+ Reference<XColumnsSupplier> xColsSupplier;
+ if(bIsTable)
+ {
+ Reference<XTablesSupplier> xTSupplier = Reference<XTablesSupplier>(xConnection, UNO_QUERY);
+ if(xTSupplier.is())
+ {
+ Reference<XNameAccess> xTbls = xTSupplier->getTables();
+ OSL_ENSURE(xTbls->hasByName(rTblQryName), "table not available anymore?");
+ try
+ {
+ Any aTable = xTbls->getByName(rTblQryName);
+ Reference<XPropertySet> xPropSet;
+ aTable >>= xPropSet;
+ xColsSupplier = Reference<XColumnsSupplier>(xPropSet, UNO_QUERY);
+ }
+ catch (const Exception&)
+ {
+ }
+ }
+ }
+ else
+ {
+ Reference<XQueriesSupplier> xQSupplier = Reference<XQueriesSupplier>(xConnection, UNO_QUERY);
+ if(xQSupplier.is())
+ {
+ Reference<XNameAccess> xQueries = xQSupplier->getQueries();
+ OSL_ENSURE(xQueries->hasByName(rTblQryName), "table not available anymore?");
+ try
+ {
+ Any aQuery = xQueries->getByName(rTblQryName);
+ Reference<XPropertySet> xPropSet;
+ aQuery >>= xPropSet;
+ xColsSupplier = Reference<XColumnsSupplier>(xPropSet, UNO_QUERY);
+ }
+ catch (const Exception&)
+ {
+ }
+ }
+ }
+
+ if(xColsSupplier.is())
+ {
+ Reference <XNameAccess> xCols;
+ try
+ {
+ xCols = xColsSupplier->getColumns();
+ }
+ catch (const Exception&)
+ {
+ OSL_FAIL("Exception in getColumns()");
+ }
+ if(xCols.is() && xCols->hasByName(rFldName))
+ {
+ Any aCol = xCols->getByName(rFldName);
+ Reference <XPropertySet> xCol;
+ aCol >>= xCol;
+ Any aType = xCol->getPropertyValue("Type");
+ sal_Int32 eDataType = 0;
+ aType >>= eDataType;
+ switch(eDataType)
+ {
+ case DataType::BIT:
+ case DataType::BOOLEAN:
+ case DataType::TINYINT:
+ case DataType::SMALLINT:
+ case DataType::INTEGER:
+ case DataType::BIGINT:
+ case DataType::FLOAT:
+ case DataType::REAL:
+ case DataType::DOUBLE:
+ case DataType::NUMERIC:
+ case DataType::DECIMAL:
+ case DataType::DATE:
+ case DataType::TIME:
+ case DataType::TIMESTAMP:
+ break;
+
+ case DataType::BINARY:
+ case DataType::VARBINARY:
+ case DataType::LONGVARBINARY:
+ case DataType::SQLNULL:
+ case DataType::OTHER:
+ case DataType::OBJECT:
+ case DataType::DISTINCT:
+ case DataType::STRUCT:
+ case DataType::ARRAY:
+ case DataType::BLOB:
+ case DataType::CLOB:
+ case DataType::REF:
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ case DataType::LONGVARCHAR:
+ default:
+ bNumeric = sal_False;
+ }
+ }
+ }
+ return bNumeric;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/frmdlg/colex.cxx b/sw/source/core/uibase/frmdlg/colex.cxx
new file mode 100644
index 000000000000..3137ec7565c5
--- /dev/null
+++ b/sw/source/core/uibase/frmdlg/colex.cxx
@@ -0,0 +1,589 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "cmdid.h"
+#include "hintids.hxx"
+#include <algorithm>
+
+#include <svl/eitem.hxx>
+#include <editeng/lrspitem.hxx>
+#include <editeng/ulspitem.hxx>
+#include <editeng/sizeitem.hxx>
+#include <svx/pageitem.hxx>
+#include <editeng/brushitem.hxx>
+#include <editeng/frmdiritem.hxx>
+#include <vcl/bitmap.hxx>
+#include <vcl/builder.hxx>
+#include <vcl/graph.hxx>
+#include <vcl/settings.hxx>
+#include <tgrditem.hxx>
+#include <viewopt.hxx>
+#include "colex.hxx"
+#include "colmgr.hxx"
+
+/*-----------------------------------------------------------------------
+ Description: Taking the updated values from the set
+ -----------------------------------------------------------------------*/
+void SwPageExample::UpdateExample( const SfxItemSet& rSet )
+{
+ SfxItemPool* pPool = rSet.GetPool();
+ sal_uInt16 nWhich = pPool->GetWhich( SID_ATTR_PAGE );
+
+ if ( rSet.GetItemState( nWhich, false ) == SFX_ITEM_SET )
+ {
+ // alignment
+ const SvxPageItem* pPage = (const SvxPageItem*)&rSet.Get( nWhich );
+
+ if ( pPage )
+ SetUsage( pPage->GetPageUsage() );
+ }
+
+ nWhich = pPool->GetWhich( SID_ATTR_PAGE_SIZE );
+
+ if ( rSet.GetItemState( nWhich, false ) == SFX_ITEM_SET )
+ {
+ // orientation and size from PageItem
+ const SvxSizeItem& rSize = (const SvxSizeItem&)rSet.Get( nWhich );
+ SetSize( rSize.GetSize() );
+ }
+ nWhich = RES_LR_SPACE;
+ if ( rSet.GetItemState( nWhich, false ) == SFX_ITEM_SET )
+ {
+ // set left and right border
+ const SvxLRSpaceItem& rLRSpace = (const SvxLRSpaceItem&)rSet.Get( nWhich );
+
+ SetLeft( rLRSpace.GetLeft() );
+ SetRight( rLRSpace.GetRight() );
+ }
+ else
+ {
+ SetLeft( 0 );
+ SetRight( 0 );
+ }
+
+ nWhich = RES_UL_SPACE;
+
+ if ( rSet.GetItemState( nWhich, false ) == SFX_ITEM_SET )
+ {
+ // set upper and lower border
+ const SvxULSpaceItem& rULSpace = (const SvxULSpaceItem&)rSet.Get( nWhich );
+
+ SetTop( rULSpace.GetUpper() );
+ SetBottom( rULSpace.GetLower() );
+ }
+ else
+ {
+ SetTop( 0 );
+ SetBottom( 0 );
+ }
+
+ // evaluate header-attributes
+ const SfxPoolItem* pItem;
+ if( SFX_ITEM_SET == rSet.GetItemState( pPool->GetWhich( SID_ATTR_PAGE_HEADERSET),
+ false, &pItem ) )
+ {
+ const SfxItemSet& rHeaderSet = ((SvxSetItem*)pItem)->GetItemSet();
+ const SfxBoolItem& rHeaderOn =
+ (const SfxBoolItem&)rHeaderSet.Get( pPool->GetWhich( SID_ATTR_PAGE_ON ) );
+
+ if ( rHeaderOn.GetValue() )
+ {
+ const SvxSizeItem& rSize =
+ (const SvxSizeItem&)rHeaderSet.Get(pPool->GetWhich(SID_ATTR_PAGE_SIZE));
+
+ const SvxULSpaceItem& rUL = (const SvxULSpaceItem&)rHeaderSet.Get(
+ pPool->GetWhich(SID_ATTR_ULSPACE));
+ const SvxLRSpaceItem& rLR = (const SvxLRSpaceItem&)rHeaderSet.Get(
+ pPool->GetWhich(SID_ATTR_LRSPACE));
+
+ SetHdHeight( rSize.GetSize().Height() - rUL.GetLower());
+ SetHdDist( rUL.GetLower() );
+ SetHdLeft( rLR.GetLeft() );
+ SetHdRight( rLR.GetRight() );
+ SetHeader( sal_True );
+ if ( rHeaderSet.GetItemState( RES_BACKGROUND ) == SFX_ITEM_SET )
+ {
+ const SvxBrushItem& rItem =
+ (const SvxBrushItem&)rHeaderSet.Get( RES_BACKGROUND );
+ SetHdColor( rItem.GetColor() );
+ }
+ if ( rHeaderSet.GetItemState( RES_BOX ) == SFX_ITEM_SET )
+ {
+ const SvxBoxItem& rItem =
+ (const SvxBoxItem&)rHeaderSet.Get( RES_BOX );
+ SetHdBorder( rItem );
+ }
+ }
+ else
+ SetHeader( sal_False );
+ }
+
+ if( SFX_ITEM_SET == rSet.GetItemState( pPool->GetWhich( SID_ATTR_PAGE_FOOTERSET),
+ false, &pItem ) )
+ {
+ const SfxItemSet& rFooterSet = ((SvxSetItem*)pItem)->GetItemSet();
+ const SfxBoolItem& rFooterOn =
+ (const SfxBoolItem&)rFooterSet.Get( SID_ATTR_PAGE_ON );
+
+ if ( rFooterOn.GetValue() )
+ {
+ const SvxSizeItem& rSize =
+ (const SvxSizeItem&)rFooterSet.Get( pPool->GetWhich( SID_ATTR_PAGE_SIZE ) );
+
+ const SvxULSpaceItem& rUL = (const SvxULSpaceItem&)rFooterSet.Get(
+ pPool->GetWhich( SID_ATTR_ULSPACE ) );
+ const SvxLRSpaceItem& rLR = (const SvxLRSpaceItem&)rFooterSet.Get(
+ pPool->GetWhich( SID_ATTR_LRSPACE ) );
+
+ SetFtHeight( rSize.GetSize().Height() - rUL.GetUpper());
+ SetFtDist( rUL.GetUpper() );
+ SetFtLeft( rLR.GetLeft() );
+ SetFtRight( rLR.GetRight() );
+ SetFooter( sal_True );
+ if( rFooterSet.GetItemState( RES_BACKGROUND ) == SFX_ITEM_SET )
+ {
+ const SvxBrushItem& rItem =
+ (const SvxBrushItem&)rFooterSet.Get( RES_BACKGROUND );
+ SetFtColor( rItem.GetColor() );
+ }
+ if( rFooterSet.GetItemState( RES_BOX ) == SFX_ITEM_SET )
+ {
+ const SvxBoxItem& rItem =
+ (const SvxBoxItem&)rFooterSet.Get( RES_BOX );
+ SetFtBorder( rItem );
+ }
+ }
+ else
+ SetFooter( sal_False );
+ }
+ if( SFX_ITEM_SET == rSet.GetItemState( RES_BACKGROUND,
+ false, &pItem ) )
+ {
+ SetColor( ( (const SvxBrushItem*)pItem )->GetColor() );
+ const Graphic* pGrf = ( (const SvxBrushItem*)pItem )->GetGraphic();
+
+ if ( pGrf )
+ {
+ Bitmap aBitmap = pGrf->GetBitmap();
+ SetBitmap( &aBitmap );
+ }
+ else
+ SetBitmap( NULL );
+ }
+
+ Invalidate();
+}
+
+void SwColExample::DrawPage( const Point& rOrg,
+ const sal_Bool bSecond,
+ const sal_Bool bEnabled )
+{
+ SwPageExample::DrawPage( rOrg, bSecond, bEnabled );
+ sal_uInt16 nColumnCount;
+ if( pColMgr && 0 != (nColumnCount = pColMgr->GetCount()))
+ {
+ long nL = GetLeft();
+ long nR = GetRight();
+
+ if ( GetUsage() == SVX_PAGE_MIRROR && !bSecond )
+ {
+ // rotate for mirrored
+ nL = GetRight();
+ nR = GetLeft();
+ }
+
+ SetFillColor( Color( COL_LIGHTGRAY ) );
+ Rectangle aRect;
+ aRect.Right() = rOrg.X() + GetSize().Width() - nR;
+ aRect.Left() = rOrg.X() + nL;
+ aRect.Top() = rOrg.Y() + GetTop()
+ + GetHdHeight() + GetHdDist();
+ aRect.Bottom()= rOrg.Y() + GetSize().Height() - GetBottom()
+ - GetFtHeight() - GetFtDist();
+ DrawRect(aRect);
+
+ if(GetColor() == Color(COL_TRANSPARENT))
+ {
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+ const Color& rFieldColor = rStyleSettings.GetFieldColor();
+ SetFillColor( rFieldColor );
+ }
+ else
+ SetFillColor( GetColor() );
+
+ // #97495# make sure that the automatic column width's are always equal
+ sal_Bool bAutoWidth = pColMgr->IsAutoWidth();
+ sal_Int32 nAutoColWidth = 0;
+ if(bAutoWidth)
+ {
+ sal_Int32 nColumnWidthSum = 0;
+ sal_uInt16 i;
+ for(i = 0; i < nColumnCount; ++i)
+ nColumnWidthSum += pColMgr->GetColWidth( i );
+ nAutoColWidth = nColumnWidthSum / nColumnCount;
+ }
+
+ sal_uInt16 i;
+ for( i = 0; i < nColumnCount; i++)
+ {
+ if(!bAutoWidth)
+ nAutoColWidth = pColMgr->GetColWidth( i );
+ aRect.Right() = aRect.Left() + nAutoColWidth;
+ DrawRect(aRect);
+ if(i < nColumnCount - 1)
+ aRect.Left() = aRect.Right() + pColMgr->GetGutterWidth(i);
+ }
+ if(pColMgr->HasLine())
+ {
+ Point aUp( rOrg.X() + nL, rOrg.Y() + GetTop() );
+ Point aDown( rOrg.X() + nL, rOrg.Y() + GetSize().Height()
+ - GetBottom() - GetFtHeight() - GetFtDist() );
+
+ if( pColMgr->GetLineHeightPercent() != 100 )
+ {
+ long nLength = aDown.Y() - aUp.Y();
+ nLength -= nLength * pColMgr->GetLineHeightPercent() / 100;
+ switch(pColMgr->GetAdjust())
+ {
+ case COLADJ_BOTTOM: aUp.Y() += nLength; break;
+ case COLADJ_TOP: aDown.Y() -= nLength; break;
+ case COLADJ_CENTER:
+ aUp.Y() += nLength / 2;
+ aDown.Y() -= nLength / 2;
+ break;
+ default:; // prevent warning
+ }
+ }
+
+ int nDist;
+ for( i = 0; i < nColumnCount - 1; i++)
+ {
+ int nGutter = pColMgr->GetGutterWidth(i);
+ nDist = pColMgr->GetColWidth( i ) + nGutter;
+ nDist -= (i == 0) ?
+ nGutter/2 :
+ 0;
+ aUp.X() += nDist;
+ aDown.X() += nDist;
+ DrawLine( aUp, aDown );
+
+ }
+ }
+ }
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSwColExample(Window *pParent, VclBuilder::stringmap &)
+{
+ return new SwColExample(pParent);
+}
+
+SwColumnOnlyExample::SwColumnOnlyExample(Window* pParent)
+ : Window(pParent)
+ , m_aFrmSize(1,1)
+{
+ SetMapMode( MapMode( MAP_TWIP ) );
+ m_aWinSize = GetOptimalSize();
+ m_aWinSize.Height() -= 4;
+ m_aWinSize.Width() -= 4;
+
+ m_aWinSize = PixelToLogic( m_aWinSize );
+
+ SetBorderStyle( WINDOW_BORDER_MONO );
+
+ m_aFrmSize = SvxPaperInfo::GetPaperSize(PAPER_A4);// DIN A4
+ ::FitToActualSize(m_aCols, (sal_uInt16)m_aFrmSize.Width());
+
+ long nHeight = m_aFrmSize.Height();
+ Fraction aScale( m_aWinSize.Height(), nHeight );
+ MapMode aMapMode( GetMapMode() );
+ aMapMode.SetScaleX( aScale );
+ aMapMode.SetScaleY( aScale );
+ SetMapMode( aMapMode );
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSwColumnOnlyExample(Window *pParent, VclBuilder::stringmap &)
+{
+ return new SwColumnOnlyExample(pParent);
+}
+
+void SwColumnOnlyExample::Paint( const Rectangle& /*rRect*/ )
+{
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+ const Color& rFieldColor = rStyleSettings.GetFieldColor();
+ const Color& rDlgColor = rStyleSettings.GetDialogColor();
+ const Color& rFieldTextColor = SwViewOption::GetFontColor();
+ Color aGrayColor(COL_LIGHTGRAY);
+ if(rFieldColor == aGrayColor)
+ aGrayColor.Invert();
+
+ Size aLogSize(PixelToLogic(GetOutputSizePixel()));
+ Rectangle aCompleteRect(Point(0,0), aLogSize);
+ SetLineColor(rDlgColor);
+ SetFillColor(rDlgColor);
+ DrawRect(aCompleteRect);
+
+ SetLineColor( rFieldTextColor );
+ Point aTL( (aLogSize.Width() - m_aFrmSize.Width()) / 2,
+ (aLogSize.Height() - m_aFrmSize.Height()) / 2);
+ Rectangle aRect(aTL, m_aFrmSize);
+
+ //draw a shadow rectangle
+ SetFillColor( Color(COL_GRAY) );
+ Rectangle aShadowRect(aRect);
+ aShadowRect.Move(aTL.Y(), aTL.Y());
+ DrawRect(aShadowRect);
+
+ SetFillColor( rFieldColor );
+ DrawRect(aRect);
+
+ SetFillColor( aGrayColor );
+
+ //column separator?
+ long nLength = aLogSize.Height() - 2 * aTL.Y();
+ Point aUp( aTL );
+ Point aDown( aTL.X(), nLength );
+ bool bLines = false;
+ if(m_aCols.GetLineAdj() != COLADJ_NONE)
+ {
+ bLines = true;
+
+ sal_uInt16 nPercent = m_aCols.GetLineHeight();
+ if( nPercent != 100 )
+ {
+ nLength -= nLength * nPercent / 100;
+ switch(m_aCols.GetLineAdj())
+ {
+ case COLADJ_BOTTOM: aUp.Y() += nLength; break;
+ case COLADJ_TOP: aDown.Y() -= nLength; break;
+ case COLADJ_CENTER:
+ aUp.Y() += nLength / 2;
+ aDown.Y() -= nLength / 2;
+ break;
+ default:; //prevent warning
+ }
+ }
+
+ }
+ const SwColumns& rCols = m_aCols.GetColumns();
+ sal_uInt16 nColCount = rCols.size();
+ if( nColCount )
+ {
+ DrawRect(aRect);
+ SetFillColor( rFieldColor );
+ Rectangle aFrmRect(aTL, m_aFrmSize);
+ long nSum = aTL.X();
+ for(sal_uInt16 i = 0; i < nColCount; i++)
+ {
+ const SwColumn* pCol = &rCols[i];
+ aFrmRect.Left() = nSum + pCol->GetLeft();//nSum + pCol->GetLeft() + aTL.X();
+ nSum += pCol->GetWishWidth();
+ aFrmRect.Right() = nSum - pCol->GetRight();
+ DrawRect(aFrmRect);
+ }
+ if(bLines )
+ {
+ nSum = aTL.X();
+ for(sal_uInt16 i = 0; i < nColCount - 1; i++)
+ {
+ nSum += rCols[i].GetWishWidth();
+ aUp.X() = nSum;
+ aDown.X() = nSum;
+ DrawLine(aUp, aDown);
+ }
+ }
+ }
+}
+
+void SwColumnOnlyExample::SetColumns(const SwFmtCol& rCol)
+{
+ m_aCols = rCol;
+ sal_uInt16 nWishSum = m_aCols.GetWishWidth();
+ long nFrmWidth = m_aFrmSize.Width();
+ SwColumns& rCols = m_aCols.GetColumns();
+ sal_uInt16 nColCount = rCols.size();
+
+ for(sal_uInt16 i = 0; i < nColCount; i++)
+ {
+ SwColumn* pCol = &rCols[i];
+ long nWish = pCol->GetWishWidth();
+ nWish *= nFrmWidth;
+ nWish /= nWishSum;
+ pCol->SetWishWidth((sal_uInt16)nWish);
+ long nLeft = pCol->GetLeft();
+ nLeft *= nFrmWidth;
+ nLeft /= nWishSum;
+ pCol->SetLeft((sal_uInt16)nLeft);
+ long nRight = pCol->GetRight();
+ nRight *= nFrmWidth;
+ nRight /= nWishSum;
+ pCol->SetRight((sal_uInt16)nRight);
+ }
+ // #97495# make sure that the automatic column width's are always equal
+ if(nColCount && m_aCols.IsOrtho())
+ {
+ sal_Int32 nColumnWidthSum = 0;
+ sal_uInt16 i;
+ for(i = 0; i < nColCount; ++i)
+ {
+ SwColumn* pCol = &rCols[i];
+ nColumnWidthSum += pCol->GetWishWidth();
+ nColumnWidthSum -= (pCol->GetRight() + pCol->GetLeft());
+ }
+ nColumnWidthSum /= nColCount;
+ for(i = 0; i < nColCount; ++i)
+ {
+ SwColumn* pCol = &rCols[i];
+ pCol->SetWishWidth( static_cast< sal_uInt16 >(nColumnWidthSum + pCol->GetRight() + pCol->GetLeft()));
+ }
+ }
+}
+
+Size SwColumnOnlyExample::GetOptimalSize() const
+{
+ return LogicToPixel(Size(75, 46), MapMode(MAP_APPFONT));
+}
+
+SwPageGridExample::~SwPageGridExample()
+{
+ delete pGridItem;
+}
+
+void SwPageGridExample::DrawPage( const Point& rOrg,
+ const sal_Bool bSecond,
+ const sal_Bool bEnabled )
+{
+ SwPageExample::DrawPage(rOrg, bSecond, bEnabled);
+ if(pGridItem && pGridItem->GetGridType())
+ {
+ //paint the grid now
+ Color aLineColor = pGridItem->GetColor();
+ if(aLineColor.GetColor() == COL_AUTO)
+ {
+ aLineColor = GetFillColor();
+ aLineColor.Invert();
+ }
+ SetLineColor(aLineColor);
+ long nL = GetLeft();
+ long nR = GetRight();
+
+ if ( GetUsage() == SVX_PAGE_MIRROR && !bSecond )
+ {
+ // rotate for mirrored
+ nL = GetRight();
+ nR = GetLeft();
+ }
+
+ Rectangle aRect;
+ aRect.Right() = rOrg.X() + GetSize().Width() - nR;
+ aRect.Left() = rOrg.X() + nL;
+ aRect.Top() = rOrg.Y() + GetTop()
+ + GetHdHeight() + GetHdDist();
+ aRect.Bottom()= rOrg.Y() + GetSize().Height() - GetBottom()
+ - GetFtHeight() - GetFtDist();
+
+ //increase the values to get a 'viewable' preview
+ sal_Int32 nBaseHeight = pGridItem->GetBaseHeight() * 3;
+ sal_Int32 nRubyHeight = pGridItem->GetRubyHeight() * 3;
+
+ //detect height of rectangles
+ Rectangle aRubyRect(aRect.TopLeft(),
+ m_bVertical ?
+ Size(nRubyHeight, aRect.GetHeight()) :
+ Size(aRect.GetWidth(), nRubyHeight));
+ Rectangle aCharRect(aRect.TopLeft(),
+ m_bVertical ?
+ Size(nBaseHeight, aRect.GetHeight()) :
+ Size(aRect.GetWidth(), nBaseHeight));
+
+ sal_Int32 nLineHeight = nBaseHeight + nRubyHeight;
+
+ //detect count of rectangles
+ sal_Int32 nLines = (m_bVertical ? aRect.GetWidth(): aRect.GetHeight()) / nLineHeight;
+ if(nLines > pGridItem->GetLines())
+ nLines = pGridItem->GetLines();
+
+ // determine start position
+ if(m_bVertical)
+ {
+ sal_Int16 nXStart = static_cast< sal_Int16 >(aRect.GetWidth() / 2 - nLineHeight * nLines /2);
+ aRubyRect.Move(nXStart, 0);
+ aCharRect.Move(nXStart, 0);
+ }
+ else
+ {
+ sal_Int16 nYStart = static_cast< sal_Int16 >(aRect.GetHeight() / 2 - nLineHeight * nLines /2);
+ aRubyRect.Move(0, nYStart);
+ aCharRect.Move(0, nYStart);
+ }
+
+ if(pGridItem->IsRubyTextBelow())
+ m_bVertical ? aRubyRect.Move(nBaseHeight, 0) : aRubyRect.Move(0, nBaseHeight);
+ else
+ m_bVertical ? aCharRect.Move(nRubyHeight, 0) : aCharRect.Move(0, nRubyHeight);
+
+ //vertical lines
+ bool bBothLines = pGridItem->GetGridType() == GRID_LINES_CHARS;
+ SetFillColor( Color( COL_TRANSPARENT ) );
+ sal_Int32 nXMove = m_bVertical ? nLineHeight : 0;
+ sal_Int32 nYMove = m_bVertical ? 0 : nLineHeight;
+ for(sal_Int32 nLine = 0; nLine < nLines; nLine++)
+ {
+ DrawRect(aRubyRect);
+ DrawRect(aCharRect);
+ if(bBothLines)
+ {
+ Point aStart = aCharRect.TopLeft();
+ Point aEnd = m_bVertical ? aCharRect.TopRight() : aCharRect.BottomLeft();
+ while(m_bVertical ? aStart.Y() < aRect.Bottom(): aStart.X() < aRect.Right())
+ {
+ DrawLine(aStart, aEnd);
+ if(m_bVertical)
+ aStart.Y() = aEnd.Y() += nBaseHeight;
+ else
+ aStart.X() = aEnd.X() += nBaseHeight;
+ }
+ }
+ aRubyRect.Move(nXMove, nYMove);
+ aCharRect.Move(nXMove, nYMove);
+ }
+ }
+}
+
+void SwPageGridExample::UpdateExample( const SfxItemSet& rSet )
+{
+ DELETEZ(pGridItem);
+ //get the grid information
+ if(SFX_ITEM_AVAILABLE <= rSet.GetItemState(RES_TEXTGRID, true))
+ pGridItem = (SwTextGridItem*)((const SwTextGridItem&)rSet.Get(RES_TEXTGRID)).Clone();
+ if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( RES_FRAMEDIR, true ))
+ {
+ const SvxFrameDirectionItem& rDirItem =
+ (const SvxFrameDirectionItem&)rSet.Get(RES_FRAMEDIR);
+ m_bVertical = rDirItem.GetValue() == FRMDIR_VERT_TOP_RIGHT||
+ rDirItem.GetValue() == FRMDIR_VERT_TOP_LEFT;
+ }
+ SwPageExample::UpdateExample(rSet);
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSwPageGridExample(Window *pParent, VclBuilder::stringmap &)
+{
+ return new SwPageGridExample(pParent);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/frmdlg/colmgr.cxx b/sw/source/core/uibase/frmdlg/colmgr.cxx
new file mode 100644
index 000000000000..8ea5563eb474
--- /dev/null
+++ b/sw/source/core/uibase/frmdlg/colmgr.cxx
@@ -0,0 +1,150 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "hintids.hxx"
+#include <editeng/lrspitem.hxx>
+
+#include "frmmgr.hxx"
+#include "frmfmt.hxx"
+#include "colmgr.hxx"
+
+// private methods
+/*------------------------------------------------------------------------
+ Description: set column width to current width
+------------------------------------------------------------------------*/
+void FitToActualSize(SwFmtCol& rCol, sal_uInt16 nWidth)
+{
+ const sal_uInt16 nCount = rCol.GetColumns().size();
+ for(sal_uInt16 i = 0; i < nCount; ++i)
+ {
+ const sal_uInt16 nTmp = rCol.CalcColWidth(i, nWidth);
+ rCol.GetColumns()[i].SetWishWidth(nTmp);
+ }
+ rCol.SetWishWidth(nWidth);
+}
+
+// public methods
+/*------------------------------------------------------------------------
+ Description: set column quantity and Gutterwidth
+------------------------------------------------------------------------*/
+void SwColMgr::SetCount(sal_uInt16 nCount, sal_uInt16 nGutterWidth)
+{
+ aFmtCol.Init(nCount, nGutterWidth, nWidth);
+ aFmtCol.SetWishWidth(nWidth);
+ aFmtCol.SetGutterWidth(nGutterWidth, nWidth);
+}
+
+sal_uInt16 SwColMgr::GetGutterWidth( sal_uInt16 nPos ) const
+{
+ sal_uInt16 nRet;
+ if(nPos == USHRT_MAX )
+ nRet = GetCount() > 1 ? aFmtCol.GetGutterWidth() : DEF_GUTTER_WIDTH;
+ else
+ {
+ OSL_ENSURE(nPos < GetCount() - 1, "Spalte ueberindiziert" );
+ const SwColumns& rCols = aFmtCol.GetColumns();
+ nRet = rCols[nPos].GetRight() + rCols[nPos + 1].GetLeft();
+ }
+ return nRet;
+}
+
+void SwColMgr::SetGutterWidth(sal_uInt16 nGutterWidth, sal_uInt16 nPos )
+{
+ if(nPos == USHRT_MAX)
+ aFmtCol.SetGutterWidth(nGutterWidth, nWidth);
+ else
+ {
+ OSL_ENSURE(nPos < GetCount() - 1, "Spalte ueberindiziert" );
+ SwColumns& rCols = aFmtCol.GetColumns();
+ sal_uInt16 nGutterWidth2 = nGutterWidth / 2;
+ rCols[nPos].SetRight(nGutterWidth2);
+ rCols[nPos + 1].SetLeft(nGutterWidth2);
+ }
+}
+
+/*------------------------------------------------------------------------
+ Description: height separation line
+------------------------------------------------------------------------*/
+short SwColMgr::GetLineHeightPercent() const
+{
+ return (short)aFmtCol.GetLineHeight();
+}
+
+void SwColMgr::SetLineHeightPercent(short nPercent)
+{
+ OSL_ENSURE(nPercent <= 100, "line height may be at most 100 %");
+ aFmtCol.SetLineHeight((sal_uInt8)nPercent);
+}
+
+/*------------------------------------------------------------------------
+ Description: column width
+------------------------------------------------------------------------*/
+sal_uInt16 SwColMgr::GetColWidth(sal_uInt16 nIdx) const
+{
+ OSL_ENSURE(nIdx < GetCount(), "Spaltenarray ueberindiziert.");
+ return aFmtCol.CalcPrtColWidth(nIdx, nWidth);
+}
+
+void SwColMgr::SetColWidth(sal_uInt16 nIdx, sal_uInt16 nWd)
+{
+ OSL_ENSURE(nIdx < GetCount(), "Spaltenarray ueberindiziert.");
+ aFmtCol.GetColumns()[nIdx].SetWishWidth(nWd);
+
+}
+
+/*--------------------------------------------------------------------
+ Description: newly set size
+ --------------------------------------------------------------------*/
+void SwColMgr::SetActualWidth(sal_uInt16 nW)
+{
+ nWidth = nW;
+ ::FitToActualSize(aFmtCol, nW);
+}
+
+/*--------------------------------------------------------------------
+ Description: ctor
+ --------------------------------------------------------------------*/
+SwColMgr::SwColMgr(const SfxItemSet& rSet, sal_uInt16 nActWidth) :
+ aFmtCol((const SwFmtCol&)rSet.Get(RES_COL)),
+ nWidth(nActWidth)
+{
+ if(nWidth == USHRT_MAX)
+ {
+ nWidth = (sal_uInt16)((const SwFmtFrmSize&)rSet.Get(RES_FRM_SIZE)).GetWidth();
+ if (nWidth < MINLAY)
+ nWidth = USHRT_MAX;
+ const SvxLRSpaceItem &rLR = (const SvxLRSpaceItem&)rSet.Get(RES_LR_SPACE);
+ nWidth = nWidth - (sal_uInt16)rLR.GetLeft();
+ nWidth = nWidth - (sal_uInt16)rLR.GetRight();
+ }
+ ::FitToActualSize(aFmtCol, nWidth);
+}
+
+SwColMgr::~SwColMgr()
+{
+}
+
+void SwColMgr::SetLineWidthAndColor(::editeng::SvxBorderStyle eStyle, sal_uLong nLWidth, const Color& rCol)
+{
+ aFmtCol.SetLineStyle(eStyle);
+ aFmtCol.SetLineWidth(nLWidth);
+ aFmtCol.SetLineColor(rCol);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/frmdlg/frmmgr.cxx b/sw/source/core/uibase/frmdlg/frmmgr.cxx
new file mode 100644
index 000000000000..07f6149e0011
--- /dev/null
+++ b/sw/source/core/uibase/frmdlg/frmmgr.cxx
@@ -0,0 +1,608 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "cmdid.h"
+#include "hintids.hxx"
+
+#include <svl/stritem.hxx>
+#include <editeng/protitem.hxx>
+#include <editeng/boxitem.hxx>
+#include <editeng/opaqitem.hxx>
+#include <editeng/lrspitem.hxx>
+#include <editeng/ulspitem.hxx>
+#include <editeng/shaditem.hxx>
+#include <svx/swframevalidation.hxx>
+#include <fmtclds.hxx>
+#include "wrtsh.hxx"
+#include "view.hxx"
+#include "viewopt.hxx"
+#include "uitool.hxx"
+#include "frmmgr.hxx"
+#include "format.hxx"
+#include "mdiexp.hxx"
+#include "poolfmt.hxx"
+#include <com/sun/star/text/TextContentAnchorType.hpp>
+#include <com/sun/star/text/HoriOrientation.hpp>
+#include <com/sun/star/text/VertOrientation.hpp>
+#include <com/sun/star/text/RelOrientation.hpp>
+
+using namespace ::com::sun::star;
+
+static sal_uInt16 aFrmMgrRange[] = {
+ RES_FRMATR_BEGIN, RES_FRMATR_END-1,
+ SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
+ FN_SET_FRM_NAME, FN_SET_FRM_NAME,
+ 0};
+
+/*--------------------------------------------------------------------
+ Description: determine frame attributes via Shell
+ --------------------------------------------------------------------*/
+SwFlyFrmAttrMgr::SwFlyFrmAttrMgr( sal_Bool bNew, SwWrtShell* pSh, sal_uInt8 nType ) :
+ m_aSet( (SwAttrPool&)pSh->GetAttrPool(), aFrmMgrRange ),
+ m_pOwnSh( pSh ),
+ m_bAbsPos( sal_False ),
+ m_bNewFrm( bNew ),
+ m_bIsInVertical( sal_False ),
+ m_bIsInVerticalL2R( sal_False )
+{
+ if ( m_bNewFrm )
+ {
+ // set defaults:
+ sal_uInt16 nId = 0;
+ switch ( nType )
+ {
+ case FRMMGR_TYPE_TEXT: nId = RES_POOLFRM_FRAME; break;
+ case FRMMGR_TYPE_OLE: nId = RES_POOLFRM_OLE; break;
+ case FRMMGR_TYPE_GRF: nId = RES_POOLFRM_GRAPHIC; break;
+ }
+ m_aSet.SetParent( &m_pOwnSh->GetFmtFromPool( nId )->GetAttrSet());
+ m_aSet.Put( SwFmtFrmSize( ATT_MIN_SIZE, DFLT_WIDTH, DFLT_HEIGHT ));
+ if ( 0 != ::GetHtmlMode(pSh->GetView().GetDocShell()) )
+ m_aSet.Put( SwFmtHoriOrient( 0, text::HoriOrientation::LEFT, text::RelOrientation::PRINT_AREA ) );
+ }
+ else if ( nType == FRMMGR_TYPE_NONE )
+ {
+ m_pOwnSh->GetFlyFrmAttr( m_aSet );
+ sal_Bool bRightToLeft;
+ m_bIsInVertical = m_pOwnSh->IsFrmVertical(sal_True, bRightToLeft, m_bIsInVerticalL2R);
+ }
+ ::PrepareBoxInfo( m_aSet, *m_pOwnSh );
+}
+
+SwFlyFrmAttrMgr::SwFlyFrmAttrMgr( sal_Bool bNew, SwWrtShell* pSh, const SfxItemSet &rSet ) :
+ m_aSet( rSet ),
+ m_pOwnSh( pSh ),
+ m_bAbsPos( sal_False ),
+ m_bNewFrm( bNew ),
+ m_bIsInVertical(sal_False),
+ m_bIsInVerticalL2R(sal_False)
+{
+ if(!bNew)
+ {
+ sal_Bool bRightToLeft;
+ m_bIsInVertical = pSh->IsFrmVertical(sal_True, bRightToLeft, m_bIsInVerticalL2R);
+ }
+}
+
+/*--------------------------------------------------------------------
+ Description: Initialise
+ --------------------------------------------------------------------*/
+void SwFlyFrmAttrMgr::UpdateAttrMgr()
+{
+ if ( !m_bNewFrm && m_pOwnSh->IsFrmSelected() )
+ m_pOwnSh->GetFlyFrmAttr( m_aSet );
+ ::PrepareBoxInfo( m_aSet, *m_pOwnSh );
+}
+
+void SwFlyFrmAttrMgr::_UpdateFlyFrm()
+{
+ const SfxPoolItem* pItem = 0;
+
+ if (m_aSet.GetItemState(FN_SET_FRM_NAME, false, &pItem) == SFX_ITEM_SET)
+ m_pOwnSh->SetFlyName(((SfxStringItem *)pItem)->GetValue());
+
+ m_pOwnSh->SetModified();
+
+ if ( m_bAbsPos )
+ {
+ m_pOwnSh->SetFlyPos( m_aAbsPos );
+ m_bAbsPos = sal_False;
+ }
+}
+
+/*--------------------------------------------------------------------
+ Description: change existing Fly-Frame
+ --------------------------------------------------------------------*/
+void SwFlyFrmAttrMgr::UpdateFlyFrm()
+{
+ OSL_ENSURE( m_pOwnSh->IsFrmSelected(),
+ "no frame selected or no shell, update not possible");
+
+ if( m_pOwnSh->IsFrmSelected() )
+ {
+ //JP 6.8.2001: set never an invalid anchor into the core.
+ const SfxPoolItem *pGItem, *pItem;
+ if( SFX_ITEM_SET == m_aSet.GetItemState( RES_ANCHOR, false, &pItem ))
+ {
+ SfxItemSet aGetSet( *m_aSet.GetPool(), RES_ANCHOR, RES_ANCHOR );
+ if( m_pOwnSh->GetFlyFrmAttr( aGetSet ) && 1 == aGetSet.Count() &&
+ SFX_ITEM_SET == aGetSet.GetItemState( RES_ANCHOR, false, &pGItem )
+ && ((SwFmtAnchor*)pGItem)->GetAnchorId() ==
+ ((SwFmtAnchor*)pItem)->GetAnchorId() )
+ m_aSet.ClearItem( RES_ANCHOR );
+ }
+
+ // return wg. BASIC
+ if( m_aSet.Count() )
+ {
+ m_pOwnSh->StartAllAction();
+ m_pOwnSh->SetFlyFrmAttr( m_aSet );
+ _UpdateFlyFrm();
+ m_pOwnSh->EndAllAction();
+ }
+ }
+}
+
+/*--------------------------------------------------------------------
+ Description: insert frame
+ --------------------------------------------------------------------*/
+sal_Bool SwFlyFrmAttrMgr::InsertFlyFrm()
+{
+ m_pOwnSh->StartAllAction();
+
+ sal_Bool bRet = 0 != m_pOwnSh->NewFlyFrm( m_aSet );
+
+ // turn on the right mode at the shell, frame got selected automatically.
+ if ( bRet )
+ {
+ _UpdateFlyFrm();
+ m_pOwnSh->EnterSelFrmMode();
+ FrameNotify(m_pOwnSh, FLY_DRAG_START);
+ }
+ m_pOwnSh->EndAllAction();
+ return bRet;
+}
+
+/*------------------------------------------------------------------------
+ Description: Insert frames of type eAnchorType. Position and size are
+ being set explicitly.
+ Not-allowed values of the enumeration type get corrected.
+------------------------------------------------------------------------*/
+void SwFlyFrmAttrMgr::InsertFlyFrm(RndStdIds eAnchorType,
+ const Point &rPos,
+ const Size &rSize,
+ sal_Bool bAbs )
+{
+ OSL_ENSURE( eAnchorType == FLY_AT_PAGE ||
+ eAnchorType == FLY_AT_PARA ||
+ eAnchorType == FLY_AT_CHAR ||
+ eAnchorType == FLY_AT_FLY ||
+ eAnchorType == FLY_AS_CHAR, "invalid frame type" );
+
+ if ( bAbs )
+ SetAbsPos( rPos );
+ else
+ SetPos( rPos );
+
+ SetSize( rSize );
+ SetAnchor( eAnchorType );
+ InsertFlyFrm();
+}
+
+/*--------------------------------------------------------------------
+ Description: set anchor
+ --------------------------------------------------------------------*/
+void SwFlyFrmAttrMgr::SetAnchor( RndStdIds eId )
+{
+ sal_uInt16 nPhyPageNum, nVirtPageNum;
+ m_pOwnSh->GetPageNum( nPhyPageNum, nVirtPageNum );
+
+ m_aSet.Put( SwFmtAnchor( eId, nPhyPageNum ) );
+ if ((FLY_AT_PAGE == eId) || (FLY_AT_PARA == eId) || (FLY_AT_CHAR == eId)
+ || (FLY_AT_FLY == eId))
+ {
+ SwFmtVertOrient aVertOrient( GetVertOrient() );
+ SwFmtHoriOrient aHoriOrient( GetHoriOrient() );
+ aHoriOrient.SetRelationOrient( text::RelOrientation::FRAME );
+ aVertOrient.SetRelationOrient( text::RelOrientation::FRAME );
+ m_aSet.Put( aVertOrient );
+ m_aSet.Put( aHoriOrient );
+ }
+}
+
+/*------------------------------------------------------------------------
+ Description: set the attribute for columns
+------------------------------------------------------------------------*/
+void SwFlyFrmAttrMgr::SetCol( const SwFmtCol &rCol )
+{
+ m_aSet.Put( rCol );
+}
+
+/*--------------------------------------------------------------------
+ Description: set absolute position
+ --------------------------------------------------------------------*/
+void SwFlyFrmAttrMgr::SetAbsPos( const Point& rPoint )
+{
+ m_bAbsPos = sal_True;
+ m_aAbsPos = rPoint;
+
+ SwFmtVertOrient aVertOrient( GetVertOrient() );
+ SwFmtHoriOrient aHoriOrient( GetHoriOrient() );
+ aHoriOrient.SetHoriOrient( text::HoriOrientation::NONE );
+ aVertOrient.SetVertOrient( text::VertOrientation::NONE );
+ m_aSet.Put( aVertOrient );
+ m_aSet.Put( aHoriOrient );
+}
+
+/*--------------------------------------------------------------------
+ Description: check metrics for correctness
+ --------------------------------------------------------------------*/
+void SwFlyFrmAttrMgr::ValidateMetrics( SvxSwFrameValidation& rVal,
+ const SwPosition* pToCharCntntPos,
+ bool bOnlyPercentRefValue )
+{
+ if (!bOnlyPercentRefValue)
+ {
+ rVal.nMinHeight = MINFLY + CalcTopSpace() + CalcBottomSpace();
+ rVal.nMinWidth = MINFLY + CalcLeftSpace()+ CalcRightSpace();
+ }
+
+ SwRect aBoundRect;
+
+ // OD 18.09.2003 #i18732# - adjustment for allowing vertical position
+ // aligned to page for fly frame anchored to paragraph or to character.
+ const RndStdIds eAnchorType = static_cast<RndStdIds >(rVal.nAnchorType);
+ const SwFmtFrmSize& rSize = (const SwFmtFrmSize&)m_aSet.Get(RES_FRM_SIZE);
+ m_pOwnSh->CalcBoundRect( aBoundRect, eAnchorType,
+ rVal.nHRelOrient,
+ rVal.nVRelOrient,
+ pToCharCntntPos,
+ rVal.bFollowTextFlow,
+ rVal.bMirror, NULL, &rVal.aPercentSize,
+ &rSize);
+
+ if (bOnlyPercentRefValue)
+ return;
+
+ // --> OD 2009-09-01 #mongolianlayout#
+ if ( m_bIsInVertical || m_bIsInVerticalL2R )
+ {
+ Point aPos(aBoundRect.Pos());
+ long nTmp = aPos.X();
+ aPos.X() = aPos.Y();
+ aPos.Y() = nTmp;
+ Size aSize(aBoundRect.SSize());
+ nTmp = aSize.Width();
+ aSize.Width() = aSize.Height();
+ aSize.Height() = nTmp;
+ aBoundRect.Chg( aPos, aSize );
+ //exchange width/height to enable correct values
+ nTmp = rVal.nWidth;
+ rVal.nWidth = rVal.nHeight;
+ rVal.nHeight = nTmp;
+ }
+ if ((eAnchorType == FLY_AT_PAGE) || (eAnchorType == FLY_AT_FLY))
+ {
+ // MinimalPosition
+ rVal.nMinHPos = aBoundRect.Left();
+ rVal.nMinVPos = aBoundRect.Top();
+ SwTwips nH = rVal.nHPos;
+ SwTwips nV = rVal.nVPos;
+
+ if (rVal.nHPos + rVal.nWidth > aBoundRect.Right())
+ {
+ if (rVal.nHoriOrient == text::HoriOrientation::NONE)
+ {
+ rVal.nHPos -= ((rVal.nHPos + rVal.nWidth) - aBoundRect.Right());
+ nH = rVal.nHPos;
+ }
+ else
+ rVal.nWidth = aBoundRect.Right() - rVal.nHPos;
+ }
+
+ if (rVal.nHPos + rVal.nWidth > aBoundRect.Right())
+ rVal.nWidth = aBoundRect.Right() - rVal.nHPos;
+
+ if (rVal.nVPos + rVal.nHeight > aBoundRect.Bottom())
+ {
+ if (rVal.nVertOrient == text::VertOrientation::NONE)
+ {
+ rVal.nVPos -= ((rVal.nVPos + rVal.nHeight) - aBoundRect.Bottom());
+ nV = rVal.nVPos;
+ }
+ else
+ rVal.nHeight = aBoundRect.Bottom() - rVal.nVPos;
+ }
+
+ if (rVal.nVPos + rVal.nHeight > aBoundRect.Bottom())
+ rVal.nHeight = aBoundRect.Bottom() - rVal.nVPos;
+
+ if ( rVal.nVertOrient != text::VertOrientation::NONE )
+ nV = aBoundRect.Top();
+
+ if ( rVal.nHoriOrient != text::HoriOrientation::NONE )
+ nH = aBoundRect.Left();
+
+ rVal.nMaxHPos = aBoundRect.Right() - rVal.nWidth;
+ rVal.nMaxHeight = aBoundRect.Bottom() - nV;
+
+ rVal.nMaxVPos = aBoundRect.Bottom() - rVal.nHeight;
+ rVal.nMaxWidth = aBoundRect.Right() - nH;
+ }
+ // OD 12.11.2003 #i22341# - handle to character anchored objects vertical
+ // aligned at character or top of line in a special case
+ else if ((eAnchorType == FLY_AT_PARA) ||
+ ((eAnchorType == FLY_AT_CHAR) &&
+ !(rVal.nVRelOrient == text::RelOrientation::CHAR) &&
+ !(rVal.nVRelOrient == text::RelOrientation::TEXT_LINE) ) )
+ {
+ if (rVal.nHPos + rVal.nWidth > aBoundRect.Right())
+ {
+ if (rVal.nHoriOrient == text::HoriOrientation::NONE)
+ {
+ rVal.nHPos -= ((rVal.nHPos + rVal.nWidth) - aBoundRect.Right());
+ }
+ else
+ rVal.nWidth = aBoundRect.Right() - rVal.nHPos;
+ }
+
+ // OD 29.09.2003 #i17567#, #i18732# - consider following the text flow
+ // and alignment at page areas.
+ const bool bMaxVPosAtBottom = !rVal.bFollowTextFlow ||
+ rVal.nVRelOrient == text::RelOrientation::PAGE_FRAME ||
+ rVal.nVRelOrient == text::RelOrientation::PAGE_PRINT_AREA;
+ {
+ SwTwips nTmpMaxVPos = ( bMaxVPosAtBottom
+ ? aBoundRect.Bottom()
+ : aBoundRect.Height() ) -
+ rVal.nHeight;
+ if ( rVal.nVPos > nTmpMaxVPos )
+ {
+ if (rVal.nVertOrient == text::VertOrientation::NONE)
+ {
+ rVal.nVPos = nTmpMaxVPos;
+ }
+ else
+ {
+ rVal.nHeight = ( bMaxVPosAtBottom
+ ? aBoundRect.Bottom()
+ : aBoundRect.Height() ) - rVal.nVPos;
+ }
+ }
+ }
+
+ rVal.nMinHPos = aBoundRect.Left();
+ rVal.nMaxHPos = aBoundRect.Right() - rVal.nWidth;
+
+ rVal.nMinVPos = aBoundRect.Top();
+ // OD 26.09.2003 #i17567#, #i18732# - determine maximum vertical position
+ if ( bMaxVPosAtBottom )
+ {
+ rVal.nMaxVPos = aBoundRect.Bottom() - rVal.nHeight;
+ }
+ else
+ {
+ rVal.nMaxVPos = aBoundRect.Height() - rVal.nHeight;
+ }
+
+ // maximum width height
+ const SwTwips nH = ( rVal.nHoriOrient != text::HoriOrientation::NONE )
+ ? aBoundRect.Left()
+ : rVal.nHPos;
+ const SwTwips nV = ( rVal.nVertOrient != text::VertOrientation::NONE )
+ ? aBoundRect.Top()
+ : rVal.nVPos;
+ rVal.nMaxHeight = rVal.nMaxVPos + rVal.nHeight - nV;
+ rVal.nMaxWidth = rVal.nMaxHPos + rVal.nWidth - nH;
+ }
+ // OD 12.11.2003 #i22341# - special case for to character anchored objects
+ // vertical aligned at character or top of line.
+ // Note: (1) positive vertical values are positions above the top of line
+ // (2) negative vertical values are positions below the top of line
+ else if ( (eAnchorType == FLY_AT_CHAR) &&
+ ( rVal.nVRelOrient == text::RelOrientation::CHAR ||
+ rVal.nVRelOrient == text::RelOrientation::TEXT_LINE ) )
+ {
+ // determine horizontal values
+ rVal.nMinHPos = aBoundRect.Left();
+
+ rVal.nMaxHPos = aBoundRect.Right() - rVal.nWidth;
+ if (rVal.nHPos + rVal.nWidth > aBoundRect.Right())
+ {
+ if (rVal.nHoriOrient == text::HoriOrientation::NONE)
+ {
+ rVal.nHPos -= ((rVal.nHPos + rVal.nWidth) - aBoundRect.Right());
+ }
+ else
+ rVal.nWidth = aBoundRect.Right() - rVal.nHPos;
+ }
+
+ const SwTwips nH = ( rVal.nHoriOrient != text::HoriOrientation::NONE )
+ ? aBoundRect.Left()
+ : rVal.nHPos;
+ rVal.nMaxWidth = rVal.nMaxHPos + rVal.nWidth - nH;
+
+ // determine vertical values
+ rVal.nMinVPos = -( aBoundRect.Bottom() - rVal.nHeight );
+ if ( rVal.nVPos < rVal.nMinVPos &&
+ rVal.nVertOrient == text::VertOrientation::NONE )
+ {
+ rVal.nVPos = rVal.nMinVPos;
+ }
+
+ rVal.nMaxVPos = -aBoundRect.Top();
+ if ( rVal.nVPos > rVal.nMaxVPos &&
+ rVal.nVertOrient == text::VertOrientation::NONE )
+ {
+ rVal.nVPos = rVal.nMaxVPos;
+ }
+
+ if ( rVal.nVertOrient == text::VertOrientation::NONE )
+ {
+ rVal.nMaxHeight = aBoundRect.Bottom() + rVal.nVPos;
+ }
+ else
+ {
+ rVal.nMaxHeight = aBoundRect.Height();
+ }
+ }
+ else if ( eAnchorType == FLY_AS_CHAR )
+ {
+ rVal.nMinHPos = 0;
+ rVal.nMaxHPos = 0;
+
+ rVal.nMaxHeight = aBoundRect.Height();
+ rVal.nMaxWidth = aBoundRect.Width();
+
+ rVal.nMaxVPos = aBoundRect.Height();
+ rVal.nMinVPos = -aBoundRect.Height() + rVal.nHeight;
+ if (rVal.nMaxVPos < rVal.nMinVPos)
+ {
+ rVal.nMinVPos = rVal.nMaxVPos;
+ rVal.nMaxVPos = -aBoundRect.Height();
+ }
+ }
+ // --> OD 2009-09-01 #mongolianlayout#
+ if ( m_bIsInVertical || m_bIsInVerticalL2R )
+ {
+ //restore width/height exchange
+ long nTmp = rVal.nWidth;
+ rVal.nWidth = rVal.nHeight;
+ rVal.nHeight = nTmp;
+ }
+
+ if (rVal.nMaxWidth < rVal.nWidth)
+ rVal.nWidth = rVal.nMaxWidth;
+ if (rVal.nMaxHeight < rVal.nHeight)
+ rVal.nHeight = rVal.nMaxHeight;
+}
+
+/*--------------------------------------------------------------------
+ Description: correction for border
+ --------------------------------------------------------------------*/
+SwTwips SwFlyFrmAttrMgr::CalcTopSpace()
+{
+ const SvxShadowItem& rShadow = GetShadow();
+ const SvxBoxItem& rBox = GetBox();
+ return rShadow.CalcShadowSpace(SHADOW_TOP ) + rBox.CalcLineSpace(BOX_LINE_TOP);
+}
+
+SwTwips SwFlyFrmAttrMgr::CalcBottomSpace()
+{
+ const SvxShadowItem& rShadow = GetShadow();
+ const SvxBoxItem& rBox = GetBox();
+ return rShadow.CalcShadowSpace(SHADOW_BOTTOM) + rBox.CalcLineSpace(BOX_LINE_BOTTOM);
+}
+
+SwTwips SwFlyFrmAttrMgr::CalcLeftSpace()
+{
+ const SvxShadowItem& rShadow = GetShadow();
+ const SvxBoxItem& rBox = GetBox();
+ return rShadow.CalcShadowSpace(SHADOW_LEFT) + rBox.CalcLineSpace(BOX_LINE_LEFT);
+}
+
+SwTwips SwFlyFrmAttrMgr::CalcRightSpace()
+{
+ const SvxShadowItem& rShadow = GetShadow();
+ const SvxBoxItem& rBox = GetBox();
+ return rShadow.CalcShadowSpace(SHADOW_RIGHT) + rBox.CalcLineSpace(BOX_LINE_RIGHT);
+}
+
+/*--------------------------------------------------------------------
+ Description: erase attribute from the set
+ --------------------------------------------------------------------*/
+void SwFlyFrmAttrMgr::DelAttr( sal_uInt16 nId )
+{
+ m_aSet.ClearItem( nId );
+}
+
+void SwFlyFrmAttrMgr::SetLRSpace( long nLeft, long nRight )
+{
+ OSL_ENSURE( LONG_MAX != nLeft && LONG_MAX != nRight, "Welchen Raend setzen?" );
+
+ SvxLRSpaceItem aTmp( (SvxLRSpaceItem&)m_aSet.Get( RES_LR_SPACE ) );
+ if( LONG_MAX != nLeft )
+ aTmp.SetLeft( sal_uInt16(nLeft) );
+ if( LONG_MAX != nRight )
+ aTmp.SetRight( sal_uInt16(nRight) );
+ m_aSet.Put( aTmp );
+}
+
+void SwFlyFrmAttrMgr::SetULSpace( long nTop, long nBottom )
+{
+ OSL_ENSURE(LONG_MAX != nTop && LONG_MAX != nBottom, "Welchen Raend setzen?" );
+
+ SvxULSpaceItem aTmp( (SvxULSpaceItem&)m_aSet.Get( RES_UL_SPACE ) );
+ if( LONG_MAX != nTop )
+ aTmp.SetUpper( sal_uInt16(nTop) );
+ if( LONG_MAX != nBottom )
+ aTmp.SetLower( sal_uInt16(nBottom) );
+ m_aSet.Put( aTmp );
+}
+
+void SwFlyFrmAttrMgr::SetPos( const Point& rPoint )
+{
+ SwFmtVertOrient aVertOrient( GetVertOrient() );
+ SwFmtHoriOrient aHoriOrient( GetHoriOrient() );
+
+ aHoriOrient.SetPos ( rPoint.X() );
+ aHoriOrient.SetHoriOrient( text::HoriOrientation::NONE );
+
+ aVertOrient.SetPos ( rPoint.Y() );
+ aVertOrient.SetVertOrient( text::VertOrientation::NONE );
+
+ m_aSet.Put( aVertOrient );
+ m_aSet.Put( aHoriOrient );
+}
+
+void SwFlyFrmAttrMgr::SetHorzOrientation( sal_Int16 eOrient )
+{
+ SwFmtHoriOrient aHoriOrient( GetHoriOrient() );
+ aHoriOrient.SetHoriOrient( eOrient );
+ m_aSet.Put( aHoriOrient );
+}
+
+void SwFlyFrmAttrMgr::SetVertOrientation( sal_Int16 eOrient )
+{
+ SwFmtVertOrient aVertOrient( GetVertOrient() );
+ aVertOrient.SetVertOrient( eOrient );
+ m_aSet.Put( aVertOrient );
+}
+
+void SwFlyFrmAttrMgr::SetHeightSizeType( SwFrmSize eType )
+{
+ SwFmtFrmSize aSize( GetFrmSize() );
+ aSize.SetHeightSizeType( eType );
+ m_aSet.Put( aSize );
+}
+
+void SwFlyFrmAttrMgr::SetSize( const Size& rSize )
+{
+ SwFmtFrmSize aSize( GetFrmSize() );
+ aSize.SetSize(Size(std::max(rSize.Width(), long(MINFLY)), std::max(rSize.Height(), long(MINFLY))));
+ m_aSet.Put( aSize );
+}
+
+void SwFlyFrmAttrMgr::SetAttrSet(const SfxItemSet& rSet)
+{
+ m_aSet.ClearItem();
+ m_aSet.Put( rSet );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/globdoc/globdoc.cxx b/sw/source/core/uibase/globdoc/globdoc.cxx
new file mode 100644
index 000000000000..1d72d5c16e0e
--- /dev/null
+++ b/sw/source/core/uibase/globdoc/globdoc.cxx
@@ -0,0 +1,73 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <comphelper/classids.hxx>
+#include <unotools/moduleoptions.hxx>
+
+#include <unomid.h>
+
+#include "swtypes.hxx"
+#include "shellio.hxx"
+#include "globdoc.hxx"
+#include "globdoc.hrc"
+#include "cfgid.h"
+
+// Description: Register all filters
+
+TYPEINIT1(SwGlobalDocShell, SwDocShell);
+
+SFX_IMPL_OBJECTFACTORY( SwGlobalDocShell, SvGlobalName(SO3_SWGLOB_CLASSID), SFXOBJECTSHELL_STD_NORMAL|SFXOBJECTSHELL_HASMENU, "swriter/GlobalDocument" )
+
+SwGlobalDocShell::SwGlobalDocShell(SfxObjectCreateMode eMode ) :
+ SwDocShell(eMode)
+{
+}
+
+SwGlobalDocShell::~SwGlobalDocShell()
+{
+}
+
+void SwGlobalDocShell::FillClass( SvGlobalName * pClassName,
+ sal_uInt32 * pClipFormat,
+ OUString * /*pAppName*/,
+ OUString * pLongUserName,
+ OUString * pUserName,
+ sal_Int32 nVersion,
+ sal_Bool bTemplate /* = sal_False */) const
+{
+ (void)bTemplate;
+ OSL_ENSURE( bTemplate == sal_False, "No template for Writer Global" );
+
+ if (nVersion == SOFFICE_FILEFORMAT_60)
+ {
+ *pClassName = SvGlobalName( SO3_SWGLOB_CLASSID_60 );
+ *pClipFormat = SOT_FORMATSTR_ID_STARWRITERGLOB_60;
+ *pLongUserName = SW_RESSTR(STR_WRITER_GLOBALDOC_FULLTYPE);
+ }
+ else if (nVersion == SOFFICE_FILEFORMAT_8)
+ {
+ *pClassName = SvGlobalName( SO3_SWGLOB_CLASSID_60 );
+ *pClipFormat = SOT_FORMATSTR_ID_STARWRITERGLOB_8;
+ *pLongUserName = SW_RESSTR(STR_WRITER_GLOBALDOC_FULLTYPE);
+ }
+
+ *pUserName = SW_RESSTR(STR_HUMAN_SWGLOBDOC_NAME);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/DashedLine.hxx b/sw/source/core/uibase/inc/DashedLine.hxx
new file mode 100644
index 000000000000..14ea2ef2507d
--- /dev/null
+++ b/sw/source/core/uibase/inc/DashedLine.hxx
@@ -0,0 +1,30 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_DASHEDLINE_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_DASHEDLINE_HXX
+
+#include <basegfx/color/bcolor.hxx>
+#include <vcl/fixed.hxx>
+
+/** Class for displaying a dashed line in the Writer GUI.
+ */
+class SwDashedLine : public FixedLine
+{
+ Color& (*m_pColorFn)();
+
+public:
+ SwDashedLine( Window* pParent, Color& ( *pColorFn )() );
+ ~SwDashedLine( );
+
+ virtual void Paint( const Rectangle& rRect );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/DropDownFieldDialog.hxx b/sw/source/core/uibase/inc/DropDownFieldDialog.hxx
new file mode 100644
index 000000000000..48ee686e8fe6
--- /dev/null
+++ b/sw/source/core/uibase/inc/DropDownFieldDialog.hxx
@@ -0,0 +1,58 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_DROPDOWNFIELDDIALOG_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_DROPDOWNFIELDDIALOG_HXX
+
+#include <svx/stddlg.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/button.hxx>
+
+class SwDropDownField;
+class SwField;
+class SwWrtShell;
+
+/*--------------------------------------------------------------------
+ Dialog to edit drop down field selection
+ --------------------------------------------------------------------*/
+namespace sw
+{
+class DropDownFieldDialog : public SvxStandardDialog
+{
+ ListBox* m_pListItemsLB;
+
+ OKButton* m_pOKPB;
+ PushButton* m_pNextPB;
+
+ PushButton* m_pEditPB;
+
+ SwWrtShell &rSh;
+ SwDropDownField* pDropField;
+
+ DECL_LINK(ButtonHdl, PushButton*);
+ virtual void Apply();
+public:
+ DropDownFieldDialog( Window *pParent, SwWrtShell &rSh,
+ SwField* pField, sal_Bool bNextButton = sal_False );
+};
+} //namespace sw
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/FrameControl.hxx b/sw/source/core/uibase/inc/FrameControl.hxx
new file mode 100644
index 000000000000..f976efbb31c5
--- /dev/null
+++ b/sw/source/core/uibase/inc/FrameControl.hxx
@@ -0,0 +1,53 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_FRAMECONTROL_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_FRAMECONTROL_HXX
+
+class SwEditWin;
+class SwFrm;
+class Point;
+
+/** Class representing a control linked to a SwFrm.
+ */
+class SwFrameControl
+{
+ SwEditWin* m_pEditWin;
+ const SwFrm* m_pFrm;
+
+public:
+ SwFrameControl( SwEditWin* pEditWin, const SwFrm* pFrm ) :
+ m_pEditWin( pEditWin ), m_pFrm( pFrm ) {};
+ virtual ~SwFrameControl( ) {};
+
+ SwFrameControl( const SwFrameControl& rCopy ) :
+ m_pEditWin( rCopy.m_pEditWin ),
+ m_pFrm( rCopy.m_pFrm )
+ {
+ }
+
+ const SwFrameControl& operator=( const SwFrameControl& rCopy )
+ {
+ m_pEditWin = rCopy.m_pEditWin;
+ m_pFrm = rCopy.m_pFrm;
+ return *this;
+ }
+
+ const SwFrm* GetFrame( ) { return m_pFrm; }
+ SwEditWin* GetEditWin( ) { return m_pEditWin; }
+
+ virtual void SetReadonly( bool bReadonly ) = 0;
+ virtual void ShowAll( bool bShow ) = 0;
+
+ /// Returns true if the point is inside the control.
+ virtual bool Contains( const Point &rDocPt ) const = 0;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/FrameControlsManager.hxx b/sw/source/core/uibase/inc/FrameControlsManager.hxx
new file mode 100644
index 000000000000..a9824c953b60
--- /dev/null
+++ b/sw/source/core/uibase/inc/FrameControlsManager.hxx
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_FRAMECONTROLSMANAGER_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_FRAMECONTROLSMANAGER_HXX
+
+#include <viewsh.hxx>
+#include <FrameControl.hxx>
+
+#include <boost/shared_ptr.hpp>
+#include <tools/gen.hxx>
+
+#include <map>
+#include <vector>
+
+class SwPageFrm;
+class SwEditWin;
+
+typedef boost::shared_ptr< SwFrameControl > SwFrameControlPtr;
+
+typedef std::map<const SwFrm*, SwFrameControlPtr> SwFrameControlPtrMap;
+
+/** A container for the Header/Footer, or PageBreak controls.
+*/
+class SwFrameControlsManager
+{
+ private:
+ SwEditWin* m_pEditWin;
+ std::map< FrameControlType, SwFrameControlPtrMap > m_aControls;
+
+ public:
+ SwFrameControlsManager( SwEditWin* pEditWin );
+ ~SwFrameControlsManager( );
+
+ SwFrameControlsManager( const SwFrameControlsManager& rCopy );
+ const SwFrameControlsManager& operator=( const SwFrameControlsManager& rCopy );
+
+ SwFrameControlPtr GetControl( FrameControlType eType, const SwFrm* pFrm );
+ void RemoveControls( const SwFrm* pFrm );
+ void RemoveControlsByType( FrameControlType eType, const SwFrm* pFrm );
+ void HideControls( FrameControlType eType );
+ void SetReadonlyControls( bool bReadonly );
+
+ // Helper methods
+ void SetHeaderFooterControl( const SwPageFrm* pPageFrm, FrameControlType eType, Point aOffset );
+ void SetPageBreakControl( const SwPageFrm* pPageFrm );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/HeaderFooterWin.hxx b/sw/source/core/uibase/inc/HeaderFooterWin.hxx
new file mode 100644
index 000000000000..945d02de07e6
--- /dev/null
+++ b/sw/source/core/uibase/inc/HeaderFooterWin.hxx
@@ -0,0 +1,58 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_HEADERFOOTERWIN_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_HEADERFOOTERWIN_HXX
+
+#include <FrameControl.hxx>
+
+#include <vcl/menubtn.hxx>
+
+/** Class for the header and footer separator control window.
+
+ This control is showing the header / footer style name and provides
+ a few useful actions to the user.
+ */
+class SwHeaderFooterWin : public MenuButton, public SwFrameControl
+{
+ OUString m_sLabel;
+ bool m_bIsHeader;
+ PopupMenu* m_pPopupMenu;
+ Window* m_pLine;
+ bool m_bIsAppearing;
+ int m_nFadeRate;
+ Timer m_aFadeTimer;
+
+public:
+ SwHeaderFooterWin( SwEditWin* pEditWin, const SwPageFrm* pPageFrm, bool bHeader );
+ ~SwHeaderFooterWin( );
+
+ void SetOffset( Point aOffset, long nXLineStart, long nXLineEnd );
+
+ virtual void Paint( const Rectangle& rRect );
+ virtual void MouseButtonDown( const MouseEvent& rMEvt );
+ virtual void Select( );
+
+ virtual void ShowAll( bool bShow );
+ virtual bool Contains( const Point &rDocPt ) const;
+
+ bool IsHeader() { return m_bIsHeader; };
+ bool IsEmptyHeaderFooter( );
+ const SwPageFrm* GetPageFrame( );
+
+ void ExecuteCommand(sal_uInt16 nSlot);
+
+ void SetReadonly( bool bReadonly );
+
+private:
+ DECL_LINK( FadeHandler, void * );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/PageBreakWin.hxx b/sw/source/core/uibase/inc/PageBreakWin.hxx
new file mode 100644
index 000000000000..9e9ed283b182
--- /dev/null
+++ b/sw/source/core/uibase/inc/PageBreakWin.hxx
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_PAGEBREAKWIN_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_PAGEBREAKWIN_HXX
+
+#include <FrameControl.hxx>
+
+#include <vcl/menubtn.hxx>
+
+class SwPageFrm;
+
+/** Class for the page break control window.
+
+ This control shows a line indicating a manual page break and a
+ button providing a few actions on that page break.
+ */
+class SwPageBreakWin : public MenuButton, public SwFrameControl
+{
+ PopupMenu* m_pPopupMenu;
+ Window* m_pLine;
+ bool m_bIsAppearing;
+ int m_nFadeRate;
+ int m_nDelayAppearing; ///< Before we show the control, let it transparent for a few timer ticks to avoid appearing with every mouse over.
+ Timer m_aFadeTimer;
+ bool m_bDestroyed;
+
+ const Point* m_pMousePt;
+
+public:
+ SwPageBreakWin( SwEditWin* pEditWin, const SwPageFrm* pPageFrm );
+ ~SwPageBreakWin( );
+
+ virtual void Paint( const Rectangle& rRect );
+ virtual void Select( );
+ virtual void MouseMove( const MouseEvent& rMEvt );
+ virtual void Activate( );
+
+ void UpdatePosition( const Point* pEvtPt = NULL );
+
+ virtual void ShowAll( bool bShow );
+ virtual bool Contains( const Point &rDocPt ) const;
+
+ const SwPageFrm* GetPageFrame( );
+
+ void SetReadonly( bool bReadonly );
+
+ void Fade( bool bFadeIn );
+
+private:
+ /// Hide the button (used when the popup menu is closed by clicking outside)
+ DECL_LINK( HideHandler, void * );
+ DECL_LINK( FadeHandler, void * );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/SidebarWindowsConsts.hxx b/sw/source/core/uibase/inc/SidebarWindowsConsts.hxx
new file mode 100644
index 000000000000..c2ed68276da5
--- /dev/null
+++ b/sw/source/core/uibase/inc/SidebarWindowsConsts.hxx
@@ -0,0 +1,31 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SW_SOURCE_UI_INC_SIDEBARWINDOWSCONSTS_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_SIDEBARWINDOWSCONSTS_HXX
+
+namespace sw { namespace sidebarwindows {
+
+const sal_Int8 ANCHORLINE_WIDTH = 1;
+
+} } // end of namespace sw::sidebarwindows
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/SwSpellDialogChildWindow.hxx b/sw/source/core/uibase/inc/SwSpellDialogChildWindow.hxx
new file mode 100644
index 000000000000..922841304721
--- /dev/null
+++ b/sw/source/core/uibase/inc/SwSpellDialogChildWindow.hxx
@@ -0,0 +1,67 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SW_SOURCE_UI_INC_SWSPELLDIALOGCHILDWINDOW_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_SWSPELLDIALOGCHILDWINDOW_HXX
+
+#include <svx/SpellDialogChildWindow.hxx>
+#include <view.hxx>
+
+class SwWrtShell;
+struct SpellState;
+class SwSpellDialogChildWindow
+ : public ::svx::SpellDialogChildWindow
+{
+ bool m_bIsGrammarCheckingOn;
+ SpellState* m_pSpellState;
+
+ SwWrtShell* GetWrtShell_Impl();
+ bool MakeTextSelection_Impl(SwWrtShell& rSh, ShellModes eSelMode);
+ bool FindNextDrawTextError_Impl(SwWrtShell& rSh);
+ bool SpellDrawText_Impl(SwWrtShell& rSh, ::svx::SpellPortions& rPortions);
+ void LockFocusNotification(bool bLock);
+
+protected:
+ virtual svx::SpellPortions GetNextWrongSentence(bool bRecheck);
+ virtual void ApplyChangedSentence(const svx::SpellPortions& rChanged, bool bRecheck);
+ virtual void AddAutoCorrection(const OUString& rOld, const OUString& rNew, LanguageType eLanguage);
+ virtual bool HasAutoCorrection();
+ virtual bool HasGrammarChecking();
+ virtual bool IsGrammarChecking();
+ virtual void SetGrammarChecking(bool bOn);
+ virtual void GetFocus();
+ virtual void LoseFocus();
+
+public:
+ SwSpellDialogChildWindow (
+ Window*pParent,
+ sal_uInt16 nId,
+ SfxBindings* pBindings,
+ SfxChildWinInfo* pInfo);
+ ~SwSpellDialogChildWindow();
+
+ SFX_DECL_CHILDWINDOW_WITHID(SwSpellDialogChildWindow);
+
+ void InvalidateSpellDialog();
+
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/SwXFilterOptions.hxx b/sw/source/core/uibase/inc/SwXFilterOptions.hxx
new file mode 100644
index 000000000000..8e39c494f529
--- /dev/null
+++ b/sw/source/core/uibase/inc/SwXFilterOptions.hxx
@@ -0,0 +1,101 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_SWXFILTEROPTIONS_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_SWXFILTEROPTIONS_HXX
+
+#include <com/sun/star/beans/XPropertyAccess.hpp>
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include <com/sun/star/document/XImporter.hpp>
+#include <com/sun/star/document/XExporter.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <cppuhelper/implbase5.hxx>
+
+namespace com { namespace sun { namespace star { namespace io {
+ class XInputStream;
+} } } }
+
+class SwXFilterOptions : public ::cppu::WeakImplHelper5<
+ ::com::sun::star::beans::XPropertyAccess,
+ ::com::sun::star::ui::dialogs::XExecutableDialog,
+ ::com::sun::star::document::XImporter,
+ ::com::sun::star::document::XExporter,
+ ::com::sun::star::lang::XServiceInfo >
+{
+ OUString sFilterName;
+ OUString sFilterOptions;
+
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::io::XInputStream > xInputStream;
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::lang::XComponent > xModel;
+ sal_Bool bExport;
+
+public:
+ SwXFilterOptions();
+ virtual ~SwXFilterOptions();
+
+ static OUString getImplementationName_Static();
+ static ::com::sun::star::uno::Sequence< OUString> getSupportedServiceNames_Static();
+
+ // XPropertyAccess
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >
+ SAL_CALL getPropertyValues() throw (::com::sun::star::uno::RuntimeException, std::exception);
+ virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence<
+ ::com::sun::star::beans::PropertyValue >& aProps )
+ throw (::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::beans::PropertyVetoException,
+ ::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException, std::exception);
+
+ // XExecutableDialog
+ virtual void SAL_CALL setTitle( const OUString& aTitle )
+ throw (::com::sun::star::uno::RuntimeException, std::exception);
+ virtual sal_Int16 SAL_CALL execute() throw (::com::sun::star::uno::RuntimeException, std::exception);
+
+ // XImporter
+ virtual void SAL_CALL setTargetDocument( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::lang::XComponent >& xDoc )
+ throw (::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::uno::RuntimeException, std::exception);
+
+ // XExporter
+ virtual void SAL_CALL setSourceDocument( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::lang::XComponent >& xDoc )
+ throw (::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::uno::RuntimeException, std::exception);
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName()
+ throw(::com::sun::star::uno::RuntimeException, std::exception);
+ virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
+ throw(::com::sun::star::uno::RuntimeException, std::exception);
+ virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
+ throw(::com::sun::star::uno::RuntimeException, std::exception);
+
+};
+
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
+ SwXFilterOptions_createInstance(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::lang::XMultiServiceFactory >& );
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/abstract.hxx b/sw/source/core/uibase/inc/abstract.hxx
new file mode 100644
index 000000000000..e6c80037e57b
--- /dev/null
+++ b/sw/source/core/uibase/inc/abstract.hxx
@@ -0,0 +1,42 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_ABSTRACT_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_ABSTRACT_HXX
+
+#include <sfx2/basedlgs.hxx>
+
+#include <vcl/field.hxx>
+
+class SwInsertAbstractDlg : public SfxModalDialog
+{
+ NumericField* m_pLevelNF;
+ NumericField* m_pParaNF;
+
+protected:
+
+public:
+ SwInsertAbstractDlg( Window* pParent );
+
+ sal_uInt8 GetLevel() const;
+ sal_uInt8 GetPara() const;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/actctrl.hxx b/sw/source/core/uibase/inc/actctrl.hxx
new file mode 100644
index 000000000000..0111eb1de37d
--- /dev/null
+++ b/sw/source/core/uibase/inc/actctrl.hxx
@@ -0,0 +1,92 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_ACTCTRL_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_ACTCTRL_HXX
+
+#include <vcl/field.hxx>
+#include "swdllapi.h"
+
+/*--------------------------------------------------------------------
+ Description: numerical input
+ --------------------------------------------------------------------*/
+class SW_DLLPUBLIC NumEditAction: public NumericField
+{
+ Link aActionLink;
+
+protected:
+ virtual void Action();
+ virtual bool Notify( NotifyEvent& rNEvt );
+public:
+ NumEditAction( Window* pParent, const ResId& rResId ) :
+ NumericField(pParent, rResId) {}
+
+ void SetActionHdl( const Link& rLink ) { aActionLink = rLink;}
+ const Link& GetActionHdl() const { return aActionLink; }
+};
+
+/* --------------------------------------------------
+ * Edit that doesn't accept spaces
+ * --------------------------------------------------*/
+class SW_DLLPUBLIC NoSpaceEdit : public Edit
+{
+ OUString sForbiddenChars;
+protected:
+ virtual void KeyInput( const KeyEvent& );
+ virtual void Modify();
+
+public:
+ NoSpaceEdit( Window* pParent );
+ virtual ~NoSpaceEdit();
+ void SetForbiddenChars(const OUString& rSet){sForbiddenChars = rSet;}
+ const OUString& GetForbiddenChars(){return sForbiddenChars;}
+};
+
+/* --------------------------------------------------
+ * No space and no full stop
+ * --------------------------------------------------*/
+class TableNameEdit : public NoSpaceEdit
+{
+public:
+ TableNameEdit(Window* pWin)
+ : NoSpaceEdit(pWin)
+ {
+ SetForbiddenChars(OUString(" .<>"));
+ }
+};
+
+/* --------------------------------------------------
+ call a link when KEY_RETURN is pressed
+ --------------------------------------------------*/
+class SW_DLLPUBLIC ReturnActionEdit : public Edit
+{
+ Link aReturnActionLink;
+public:
+ ReturnActionEdit(Window* pParent, const ResId& rResId);
+ ReturnActionEdit(Window* pParent, WinBits nStyle)
+ : Edit(pParent, nStyle){}
+ ~ReturnActionEdit();
+ virtual void KeyInput( const KeyEvent& );
+
+ void SetReturnActionLink(const Link& rLink)
+ { aReturnActionLink = rLink;}
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/addrdlg.hxx b/sw/source/core/uibase/inc/addrdlg.hxx
new file mode 100644
index 000000000000..14a1f0d9929f
--- /dev/null
+++ b/sw/source/core/uibase/inc/addrdlg.hxx
@@ -0,0 +1,32 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_ADDRDLG_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_ADDRDLG_HXX
+
+#include <sfx2/basedlgs.hxx>
+
+class SwAddrDlg : public SfxSingleTabDialog
+{
+public:
+ SwAddrDlg(Window* pParent, const SfxItemSet& rSet);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/annotsh.hxx b/sw/source/core/uibase/inc/annotsh.hxx
new file mode 100644
index 000000000000..7592d441b29a
--- /dev/null
+++ b/sw/source/core/uibase/inc/annotsh.hxx
@@ -0,0 +1,74 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_ANNOTSH_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_ANNOTSH_HXX
+
+#include <sfx2/shell.hxx>
+#include "shellid.hxx"
+#include "swmodule.hxx"
+#include <unotools/caserotate.hxx>
+
+class SwView;
+class SwAnnotationShell: public SfxShell
+{
+ SwView& rView;
+ RotateTransliteration m_aRotateCase;
+
+public:
+ SFX_DECL_INTERFACE(SW_ANNOTATIONSHELL)
+ TYPEINFO();
+
+ SwAnnotationShell(SwView&);
+ virtual ~SwAnnotationShell();
+
+ void StateDisableItems(SfxItemSet &);
+ void Exec(SfxRequest &);
+
+ void GetState(SfxItemSet &);
+ void StateInsert(SfxItemSet &rSet);
+
+ void NoteExec(SfxRequest &);
+ void GetNoteState(SfxItemSet &);
+
+ void ExecLingu(SfxRequest &rReq);
+ void GetLinguState(SfxItemSet &);
+
+ void ExecClpbrd(SfxRequest &rReq);
+ void StateClpbrd(SfxItemSet &rSet);
+
+ void ExecTransliteration(SfxRequest &);
+ void ExecRotateTransliteration(SfxRequest &);
+
+ void ExecUndo(SfxRequest &rReq);
+ void StateUndo(SfxItemSet &rSet);
+
+ void StateStatusLine(SfxItemSet &rSet);
+
+ void InsertSymbol(SfxRequest& rReq);
+
+ void ExecSearch(SfxRequest&, sal_Bool bNoMessage = sal_False);
+ void StateSearch(SfxItemSet &);
+
+ virtual ::svl::IUndoManager*
+ GetUndoManager();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/app.hrc b/sw/source/core/uibase/inc/app.hrc
new file mode 100644
index 000000000000..c5ac3f54edfe
--- /dev/null
+++ b/sw/source/core/uibase/inc/app.hrc
@@ -0,0 +1,118 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef _APP_HRC
+#define _APP_HRC
+
+#include "rcid.hrc"
+
+#define STR_CANTCREATE (RC_APP_BEGIN + 4)
+#define STR_CANTOPEN (RC_APP_BEGIN + 5)
+
+// For the interface because the RID_APP_BEGIN is now Desktop.
+#define RID_SW_NAME ( RC_APP_BEGIN + 8)
+
+
+#define STR_UNBENANNT (RC_APP_BEGIN + 13)
+#define STR_VERSION (RC_APP_BEGIN + 14)
+#define STR_PRINT_MERGE_MACRO (RC_APP_BEGIN + 15)
+#define STR_PAGE_COUNT_MACRO (RC_APP_BEGIN + 16)
+
+// Bitmap for the numbering style in organizer
+#define BMP_STYLES_FAMILY_NUM (RC_APP_BEGIN + 17)
+
+// Strings for regions in the configuration
+#define STR_PAGEOFFSET (RC_APP_BEGIN + 74)
+#define STR_PAGEBREAK (RC_APP_BEGIN + 75)
+#define STR_REDLINE_UNKNOWN_AUTHOR (RC_APP_BEGIN + 76)
+#define STR_WESTERN_FONT (RC_APP_BEGIN + 77)
+#define STR_CJK_FONT (RC_APP_BEGIN + 78)
+#define MSG_PRINT_AS_MERGE (RC_APP_BEGIN + 80)
+
+#define STR_ENV_TITLE (RC_APP_BEGIN + 91)
+#define STR_LAB_TITLE (RC_APP_BEGIN + 92)
+
+#define STR_HUMAN_SWDOC_NAME (RC_APP_BEGIN + 93)
+
+#define RID_SW_ERRHDL (RC_APP_BEGIN + 95)
+
+#define STR_FDLG_TEMPLATE_BUTTON (RC_APP_BEGIN + 1)
+#define STR_FDLG_TEMPLATE_NAME (RC_APP_BEGIN + 2)
+
+
+// Ids for all the PopUpMenues
+#define MN_FORMAT_STYLE (RC_APP_BEGIN + 17)
+#define MN_FORMAT_ALGN (RC_APP_BEGIN + 18)
+#define MN_FORMAT_LINESPACE (RC_APP_BEGIN + 19)
+#define MN_FORMAT_FRM_HORZ (RC_APP_BEGIN + 23)
+#define MN_CELL (RC_APP_BEGIN + 29)
+#define MN_WRAP (RC_APP_BEGIN + 38)
+#define MN_SUB_TBLROW (RC_APP_BEGIN + 39)
+#define MN_SUB_TBLCOL (RC_APP_BEGIN + 40)
+#define MN_SUB_ARRANGE (RC_APP_BEGIN + 46)
+
+#define MN_SUB_ALIGN (RC_APP_BEGIN + 50)
+
+#define STR_WRITER_DOCUMENT_FULLTYPE (RC_APP_BEGIN + 100)
+#define STR_CONVERT_TEXT_TABLE (RC_APP_BEGIN + 101)
+#define STR_ABSTRACT_TITLE (RC_APP_BEGIN + 102)
+#define STR_DONT_ASK_AGAIN (RC_APP_BEGIN + 103)
+#define STR_OUTLINE_NUMBERING (RC_APP_BEGIN + 104)
+#define STR_FDLG_OUTLINE_LEVEL (RC_APP_BEGIN + 105)
+#define STR_FDLG_STYLE (RC_APP_BEGIN + 106)
+
+// Status bar strings
+#define STR_STATUSBAR_WORDCOUNT_NO_SELECTION (RC_APP_BEGIN + 110)
+#define STR_STATUSBAR_WORDCOUNT (RC_APP_BEGIN + 111)
+
+#define STR_ADD_AUTOFORMAT_TITLE (RC_APP_BEGIN + 112)
+#define STR_ADD_AUTOFORMAT_LABEL (RC_APP_BEGIN + 113)
+#define STR_DEL_AUTOFORMAT_TITLE (RC_APP_BEGIN + 114)
+#define STR_DEL_AUTOFORMAT_MSG (RC_APP_BEGIN + 115)
+#define STR_RENAME_AUTOFORMAT_TITLE (RC_APP_BEGIN + 116)
+#define STR_BTN_AUTOFORMAT_CLOSE (RC_APP_BEGIN + 117)
+#define STR_INVALID_AUTOFORMAT_NAME (RC_APP_BEGIN + 118)
+#define STR_JAN (RC_APP_BEGIN + 119)
+#define STR_FEB (RC_APP_BEGIN + 120)
+#define STR_MAR (RC_APP_BEGIN + 121)
+#define STR_NORTH (RC_APP_BEGIN + 122)
+#define STR_MID (RC_APP_BEGIN + 123)
+#define STR_SOUTH (RC_APP_BEGIN + 124)
+#define STR_SUM (RC_APP_BEGIN + 125)
+#define STR_NUMERIC (RC_APP_BEGIN + 126)
+#define STR_COL (RC_APP_BEGIN + 127)
+#define STR_ROW (RC_APP_BEGIN + 128)
+#define STR_SIMPLE (RC_APP_BEGIN + 129)
+#define STR_AUTHMRK_EDIT (RC_APP_BEGIN + 130)
+#define STR_AUTHMRK_INSERT (RC_APP_BEGIN + 131)
+#define STR_CAPTION_TABLE (RC_APP_BEGIN + 133)
+#define STR_CAPTION_FRAME (RC_APP_BEGIN + 134)
+#define STR_CAPTION_GRAPHIC (RC_APP_BEGIN + 135)
+#define STR_CAPTION_OLE (RC_APP_BEGIN + 136)
+#define STR_CATEGORY_NONE (RC_APP_BEGIN + 137)
+
+#define APP_ACT_END STR_CATEGORY_NONE
+
+#if APP_ACT_END > RC_APP_END
+#error Resource-Id Ueberlauf in #file, #line
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/ascfldlg.hxx b/sw/source/core/uibase/inc/ascfldlg.hxx
new file mode 100644
index 000000000000..040485fedc08
--- /dev/null
+++ b/sw/source/core/uibase/inc/ascfldlg.hxx
@@ -0,0 +1,62 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_ASCFLDLG_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_ASCFLDLG_HXX
+#include <vcl/fixed.hxx>
+
+#include <vcl/button.hxx>
+#include <vcl/lstbox.hxx>
+#include <sfx2/basedlgs.hxx>
+#include <svx/txencbox.hxx>
+#include <svx/langbox.hxx>
+
+class SwAsciiOptions;
+class SvStream;
+class SwDocShell;
+
+class SwAsciiFilterDlg : public SfxModalDialog
+{
+ SvxTextEncodingBox* m_pCharSetLB;
+ FixedText* m_pFontFT;
+ ListBox* m_pFontLB;
+ FixedText* m_pLanguageFT;
+ SvxLanguageBox* m_pLanguageLB;
+ RadioButton* m_pCRLF_RB;
+ RadioButton* m_pCR_RB;
+ RadioButton* m_pLF_RB;
+ bool m_bSaveLineStatus;
+
+ DECL_LINK( CharSetSelHdl, SvxTextEncodingBox* );
+ DECL_LINK( LineEndHdl, RadioButton* );
+ void SetCRLF( LineEnd eEnd );
+ LineEnd GetCRLF() const;
+
+public:
+ // CTOR: for import - pStream is the inputstream
+ // for export - pStream must be 0
+ SwAsciiFilterDlg( Window* pParent, SwDocShell& rDocSh,
+ SvStream* pStream );
+ virtual ~SwAsciiFilterDlg();
+
+ void FillOptions( SwAsciiOptions& rOptions );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/autoedit.hxx b/sw/source/core/uibase/inc/autoedit.hxx
new file mode 100644
index 000000000000..94d81b771527
--- /dev/null
+++ b/sw/source/core/uibase/inc/autoedit.hxx
@@ -0,0 +1,37 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_AUTOEDIT_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_AUTOEDIT_HXX
+
+#include <vcl/edit.hxx>
+
+class AutoEdit : public Edit
+{
+public:
+ AutoEdit( Window* pParent, ResId aResId ) : Edit( pParent, aResId ){}
+
+protected:
+ virtual void KeyInput( const KeyEvent& rEvent );
+};
+
+// Implementation in autocorr.cxx
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/barcfg.hxx b/sw/source/core/uibase/inc/barcfg.hxx
new file mode 100644
index 000000000000..f0e05c11dde9
--- /dev/null
+++ b/sw/source/core/uibase/inc/barcfg.hxx
@@ -0,0 +1,41 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_BARCFG_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_BARCFG_HXX
+#include <unotools/configitem.hxx>
+
+class SwToolbarConfigItem : public utl::ConfigItem
+{
+ sal_Int32 aTbxIdArray[5];
+
+ com::sun::star::uno::Sequence<OUString> GetPropertyNames();
+
+public:
+ SwToolbarConfigItem( bool bWeb );
+ ~SwToolbarConfigItem();
+
+ virtual void Commit();
+ virtual void Notify( const ::com::sun::star::uno::Sequence< OUString >& aPropertyNames );
+
+ void SetTopToolbar( sal_Int32 nSelType, sal_Int32 nBarId );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/basesh.hxx b/sw/source/core/uibase/inc/basesh.hxx
new file mode 100644
index 000000000000..9875221d4c72
--- /dev/null
+++ b/sw/source/core/uibase/inc/basesh.hxx
@@ -0,0 +1,115 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_BASESH_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_BASESH_HXX
+
+#include <shellid.hxx>
+
+#include <tools/link.hxx>
+#include <vcl/timer.hxx>
+#include <sfx2/module.hxx>
+#include <sfx2/shell.hxx>
+#include <viewopt.hxx>
+
+#include <mdiexp.hxx>
+#include <set>
+
+class SwWrtShell;
+class SwView;
+class SfxItemSet;
+
+struct DBTextStruct_Impl;
+class SwBaseShell: public SfxShell
+{
+ SwView &rView;
+
+ // DragMode
+ static FlyMode eFrameMode;
+
+ // Bug 75078 - if in GetState the asynch call of GetGraphic returns
+ // synch, the set the state directly into the itemset
+ SfxItemSet* pGetStateSet;
+
+ // Update-Timer for graphic
+ std::set<sal_uInt16> aGrfUpdateSlots;
+
+ DECL_LINK( GraphicArrivedHdl, void* );
+
+protected:
+ SwWrtShell& GetShell();
+ SwWrtShell* GetShellPtr();
+
+ inline SwView& GetView() { return rView; }
+ inline void SetGetStateSet( SfxItemSet* p ) { pGetStateSet = p; }
+ inline bool AddGrfUpdateSlot( sal_uInt16 nSlot ){ return aGrfUpdateSlots.insert( nSlot ).second; }
+
+ DECL_STATIC_LINK( SwBaseShell, InsertDBTextHdl, DBTextStruct_Impl* );
+
+ void InsertURLButton( const OUString& rURL, const OUString& rTarget, const OUString& rTxt );
+ void InsertTable( SfxRequest& _rRequest );
+
+public:
+ SwBaseShell(SwView &rShell);
+ virtual ~SwBaseShell();
+
+ SFX_DECL_INTERFACE(SW_BASESHELL)
+ TYPEINFO();
+
+ void ExecDelete(SfxRequest &);
+
+ void ExecClpbrd(SfxRequest &);
+ void StateClpbrd(SfxItemSet &);
+
+ void ExecUndo(SfxRequest &);
+ void StateUndo(SfxItemSet &);
+
+ void Execute(SfxRequest &);
+ void GetState(SfxItemSet &);
+ void StateStyle(SfxItemSet &);
+
+ void ExecuteGallery(SfxRequest&);
+ void GetGalleryState(SfxItemSet&);
+
+ void ExecDlg(SfxRequest &);
+
+ void StateStatusLine(SfxItemSet &rSet);
+ void ExecTxtCtrl(SfxRequest& rReq);
+ void GetTxtFontCtrlState(SfxItemSet& rSet);
+ void GetTxtCtrlState(SfxItemSet& rSet);
+ void GetBorderState(SfxItemSet &rSet);
+ void GetBckColState(SfxItemSet &rSet);
+
+ void ExecBckCol(SfxRequest& rReq);
+ void SetWrapMode( sal_uInt16 nSlot );
+
+ void StateDisableItems(SfxItemSet &);
+
+ void EditRegionDialog(SfxRequest& rReq);
+ void InsertRegionDialog(SfxRequest& rReq);
+
+ void ExecField(SfxRequest& rReq);
+
+ static void SetFrmMode( FlyMode eMode, SwWrtShell *pShell ); // with update!
+ static void _SetFrmMode( FlyMode eMode ) { eFrameMode = eMode; }
+ static FlyMode GetFrmMode() { return eFrameMode; }
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/beziersh.hxx b/sw/source/core/uibase/inc/beziersh.hxx
new file mode 100644
index 000000000000..c957d083d1f8
--- /dev/null
+++ b/sw/source/core/uibase/inc/beziersh.hxx
@@ -0,0 +1,38 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_BEZIERSH_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_BEZIERSH_HXX
+
+#include "basesh.hxx"
+
+class SwBezierShell: public SwBaseShell
+{
+public:
+ SFX_DECL_INTERFACE(SW_BEZIERSHELL)
+ TYPEINFO();
+
+ SwBezierShell(SwView &rView);
+
+ void GetState(SfxItemSet &);
+ void Execute(SfxRequest &);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/bmpwin.hxx b/sw/source/core/uibase/inc/bmpwin.hxx
new file mode 100644
index 000000000000..dcf59bb97efb
--- /dev/null
+++ b/sw/source/core/uibase/inc/bmpwin.hxx
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SW_SOURCE_UI_INC_BMPWIN_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_BMPWIN_HXX
+
+#include <vcl/graph.hxx>
+#include <vcl/bitmapex.hxx>
+#include <vcl/window.hxx>
+
+/*--------------------------------------------------------------------
+ Description: extended page for graphics
+ --------------------------------------------------------------------*/
+class BmpWindow : public Window
+{
+private:
+ Graphic aGraphic;
+ BitmapEx aBmp;
+
+ sal_Bool bHorz : 1;
+ sal_Bool bVert : 1;
+ sal_Bool bGraphic : 1;
+ bool bLeftAlign : 1;
+
+ virtual void Paint(const Rectangle& rRect);
+
+ virtual Size GetOptimalSize() const;
+
+public:
+ BmpWindow(Window* pPar, WinBits nStyle);
+ ~BmpWindow();
+ void MirrorVert(sal_Bool bMirror) { bVert = bMirror; Invalidate(); }
+ void MirrorHorz(sal_Bool bMirror) { bHorz = bMirror; Invalidate(); }
+ void SetGraphic(const Graphic& rGrf);
+ void SetBitmapEx(const BitmapEx& rGrf);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/bookctrl.hxx b/sw/source/core/uibase/inc/bookctrl.hxx
new file mode 100644
index 000000000000..a8ce181fd7fc
--- /dev/null
+++ b/sw/source/core/uibase/inc/bookctrl.hxx
@@ -0,0 +1,47 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_BOOKCTRL_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_BOOKCTRL_HXX
+
+#include <rtl/ustring.hxx>
+#include <sfx2/stbitem.hxx>
+
+// class BookmarkToolBoxControl -------------------------------------------
+
+class SwBookmarkControl : public SfxStatusBarControl
+{
+ virtual void Command( const CommandEvent& rCEvt );
+
+public:
+ virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState,
+ const SfxPoolItem* pState );
+ virtual void Paint( const UserDrawEvent& rEvt );
+
+ SFX_DECL_STATUSBAR_CONTROL();
+
+ SwBookmarkControl( sal_uInt16 nSlotId, sal_uInt16 nId, StatusBar& rStb );
+ ~SwBookmarkControl();
+
+private:
+ OUString sPageNumber;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/bookmark.hxx b/sw/source/core/uibase/inc/bookmark.hxx
new file mode 100644
index 000000000000..2c896c17d3eb
--- /dev/null
+++ b/sw/source/core/uibase/inc/bookmark.hxx
@@ -0,0 +1,70 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_BOOKMARK_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_BOOKMARK_HXX
+
+#include <svx/stddlg.hxx>
+#include <vcl/fixed.hxx>
+
+#include <vcl/button.hxx>
+
+#include "swlbox.hxx"
+
+class SwWrtShell;
+class SfxRequest;
+
+class BookmarkCombo : public SwComboBox
+{
+ sal_Int32 GetFirstSelEntryPos() const;
+ sal_Int32 GetNextSelEntryPos(sal_Int32 nPos) const;
+ sal_Int32 GetSelEntryPos(sal_Int32 nPos) const;
+
+ virtual bool PreNotify(NotifyEvent& rNEvt);
+public:
+ BookmarkCombo(Window* pWin, WinBits nStyle);
+
+ sal_Int32 GetSelectEntryCount() const;
+ sal_Int32 GetSelectEntryPos( sal_Int32 nSelIndex = 0 ) const;
+
+ static const OUString aForbiddenChars;
+};
+
+class SwInsertBookmarkDlg: public SvxStandardDialog
+{
+ BookmarkCombo* m_pBookmarkBox;
+ OKButton* m_pOkBtn;
+ PushButton* m_pDeleteBtn;
+
+ OUString sRemoveWarning;
+ SwWrtShell &rSh;
+ SfxRequest& rReq;
+
+ DECL_LINK(ModifyHdl, BookmarkCombo *);
+ DECL_LINK(DeleteHdl, void *);
+
+ virtual void Apply();
+
+public:
+ SwInsertBookmarkDlg(Window *pParent, SwWrtShell &rSh, SfxRequest& rReq);
+ ~SwInsertBookmarkDlg();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/break.hxx b/sw/source/core/uibase/inc/break.hxx
new file mode 100644
index 000000000000..00933a759b4f
--- /dev/null
+++ b/sw/source/core/uibase/inc/break.hxx
@@ -0,0 +1,75 @@
+
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_BREAK_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_BREAK_HXX
+
+#include <svx/stddlg.hxx>
+
+#include <vcl/button.hxx>
+
+#include <vcl/fixed.hxx>
+
+#include <vcl/lstbox.hxx>
+
+#include <vcl/field.hxx>
+
+#include <boost/optional.hpp>
+
+class SwWrtShell;
+
+class SwBreakDlg: public SvxStandardDialog
+{
+ SwWrtShell &rSh;
+ RadioButton* m_pLineBtn;
+ RadioButton* m_pColumnBtn;
+ RadioButton* m_pPageBtn;
+ FixedText* m_pPageCollText;
+ ListBox* m_pPageCollBox;
+ CheckBox* m_pPageNumBox;
+ NumericField* m_pPageNumEdit;
+
+ OUString aTemplate;
+ sal_uInt16 nKind;
+ ::boost::optional<sal_uInt16> oPgNum;
+
+ sal_Bool bHtmlMode;
+
+ DECL_LINK( ClickHdl, void * );
+ DECL_LINK( PageNumHdl, CheckBox * );
+ DECL_LINK(PageNumModifyHdl, void *);
+ DECL_LINK(OkHdl, void *);
+
+ void CheckEnable();
+
+protected:
+ virtual void Apply();
+
+public:
+ SwBreakDlg( Window *pParent, SwWrtShell &rSh );
+ ~SwBreakDlg();
+
+ OUString GetTemplateName() { return aTemplate; }
+ sal_uInt16 GetKind() { return nKind; }
+ ::boost::optional<sal_uInt16> GetPageNumber() { return oPgNum; }
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/caption.hxx b/sw/source/core/uibase/inc/caption.hxx
new file mode 100644
index 000000000000..5f91f6f24fae
--- /dev/null
+++ b/sw/source/core/uibase/inc/caption.hxx
@@ -0,0 +1,98 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_CAPTION_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_CAPTION_HXX
+
+#include <rtl/ustring.hxx>
+#include <tools/globname.hxx>
+#include <SwCapObjType.hxx>
+#include "swdllapi.h"
+
+class SW_DLLPUBLIC InsCaptionOpt
+{
+private:
+ sal_Bool bUseCaption;
+ SwCapObjType eObjType;
+ SvGlobalName aOleId;
+ OUString sCategory;
+ sal_uInt16 nNumType;
+ OUString sNumberSeparator;
+ OUString sCaption;
+ sal_uInt16 nPos;
+ sal_uInt16 nLevel;
+ OUString sSeparator;
+ OUString sCharacterStyle;
+
+ bool bIgnoreSeqOpts; // is not being saved
+ sal_Bool bCopyAttributes; // -""-
+
+public:
+ InsCaptionOpt(const SwCapObjType eType = FRAME_CAP, const SvGlobalName* pOleId = 0);
+ InsCaptionOpt(const InsCaptionOpt&);
+ ~InsCaptionOpt();
+
+ inline sal_Bool& UseCaption() { return bUseCaption; }
+ inline sal_Bool UseCaption() const { return bUseCaption; }
+
+ inline SwCapObjType GetObjType() const { return eObjType; }
+ inline void SetObjType(const SwCapObjType eType) { eObjType = eType; }
+
+ inline const SvGlobalName& GetOleId() const { return aOleId; }
+ inline void SetOleId(const SvGlobalName &rId) { aOleId = rId; }
+
+ inline const OUString& GetCategory() const { return sCategory; }
+ inline void SetCategory(const OUString& rCat) { sCategory = rCat; }
+
+ inline sal_uInt16 GetNumType() const { return nNumType; }
+ inline void SetNumType(const sal_uInt16 nNT) { nNumType = nNT; }
+
+ const OUString& GetNumSeparator() const { return sNumberSeparator; }
+ void SetNumSeparator(const OUString& rSet) {sNumberSeparator = rSet;}
+
+ inline const OUString& GetCaption() const { return sCaption; }
+ inline void SetCaption(const OUString& rCap) { sCaption = rCap; }
+
+ inline sal_uInt16 GetPos() const { return nPos; }
+ inline void SetPos(const sal_uInt16 nP) { nPos = nP; }
+
+ inline sal_uInt16 GetLevel() const { return nLevel; }
+ inline void SetLevel(const sal_uInt16 nLvl) { nLevel = nLvl; }
+
+ inline const OUString& GetSeparator() const { return sSeparator; }
+ inline void SetSeparator(const OUString& rSep) { sSeparator = rSep; }
+
+ const OUString& GetCharacterStyle() const { return sCharacterStyle; }
+ void SetCharacterStyle(const OUString& rStyle)
+ { sCharacterStyle = rStyle; }
+
+ inline bool& IgnoreSeqOpts() { return bIgnoreSeqOpts; }
+ inline bool IgnoreSeqOpts() const { return bIgnoreSeqOpts; }
+
+ inline sal_Bool& CopyAttributes() { return bCopyAttributes; }
+ inline sal_Bool CopyAttributes() const { return bCopyAttributes; }
+
+ bool operator==( const InsCaptionOpt& rOpt ) const;
+ InsCaptionOpt& operator= ( const InsCaptionOpt& rOpt );
+ inline bool operator< ( const InsCaptionOpt & rObj ) const
+ { return aOleId < rObj.aOleId; }
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/cfgid.h b/sw/source/core/uibase/inc/cfgid.h
new file mode 100644
index 000000000000..20f652978fe1
--- /dev/null
+++ b/sw/source/core/uibase/inc/cfgid.h
@@ -0,0 +1,28 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_CFGID_H
+#define INCLUDED_SW_SOURCE_UI_INC_CFGID_H
+
+#include <sfx2/sfx.hrc>
+
+#define CFG_STATUSBAR (SFX_ITEMTYPE_SW_BEGIN +13)
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/cfgitems.hxx b/sw/source/core/uibase/inc/cfgitems.hxx
new file mode 100644
index 000000000000..fbcafa3c228c
--- /dev/null
+++ b/sw/source/core/uibase/inc/cfgitems.hxx
@@ -0,0 +1,221 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_CFGITEMS_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_CFGITEMS_HXX
+
+#include <tools/color.hxx>
+#include <svl/poolitem.hxx>
+#include "swdllapi.h"
+#include <printdata.hxx>
+
+#include <cmdid.h>
+
+class SwModule;
+#ifdef DBG_UTIL
+class SwTestTabPage;
+#endif
+class SwAddPrinterTabPage;
+class SfxPrinter;
+class SwViewShell;
+class SwViewOption;
+class SwContentOptPage;
+class SwShdwCrsrOptionsTabPage;
+
+SfxPrinter* GetPrt( SwViewShell* );
+void SetPrt( SfxPrinter* );
+
+/*--------OS 12.01.95 -----------------------------------
+Item for settings dialog - document view
+--------------------------------------------------------- */
+class SW_DLLPUBLIC SwDocDisplayItem : public SfxPoolItem
+{
+ friend class SwShdwCrsrOptionsTabPage;
+ friend class SwModule;
+
+ sal_Bool bParagraphEnd :1;
+ sal_Bool bTab :1;
+ sal_Bool bSpace :1;
+ sal_Bool bNonbreakingSpace :1;
+ sal_Bool bSoftHyphen :1;
+ sal_Bool bCharHiddenText :1;
+ sal_Bool bFldHiddenText :1;
+ sal_Bool bManualBreak :1;
+ sal_Bool bShowHiddenPara :1;
+
+ Color aIndexBackgrndCol;
+
+public:
+ TYPEINFO();
+ SwDocDisplayItem( sal_uInt16 nWhich = FN_PARAM_DOCDISP );
+ SwDocDisplayItem(
+ const SwDocDisplayItem& rSwDocDisplayItem );
+ SwDocDisplayItem( const SwViewOption& rVOpt,
+ sal_uInt16 nWhich );
+
+ virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
+ virtual bool operator==( const SfxPoolItem& ) const;
+ void operator=( const SwDocDisplayItem& );
+ void FillViewOptions( SwViewOption& rVOpt) const;
+};
+
+/*--------OS 12.01.95 -----------------------------------
+Item for settings dialog, element page
+--------------------------------------------------------- */
+class SW_DLLPUBLIC SwElemItem : public SfxPoolItem
+{
+ //view
+ bool bHorzScrollbar :1;
+ bool bVertScrollbar :1;
+ bool bAnyRuler : 1;
+ bool bHorzRuler :1;
+ bool bVertRuler :1;
+ bool bVertRulerRight:1;
+ bool bSmoothScroll :1;
+ //visual aids
+ bool bCrosshair :1;
+ //display
+ bool bTable :1;
+ bool bGraphic :1;
+ bool bDrawing :1;
+ bool bFieldName :1;
+ bool bNotes :1;
+
+ friend class SwContentOptPage;
+
+public:
+ TYPEINFO();
+ SwElemItem( sal_uInt16 nWhich = FN_PARAM_ELEM );
+ SwElemItem(const SwElemItem& rElemItem);
+ SwElemItem(const SwViewOption& rVOpt, sal_uInt16 nWhich);
+
+ virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
+ virtual bool operator==( const SfxPoolItem& ) const;
+ void operator=( const SwElemItem& );
+
+ void FillViewOptions( SwViewOption& rVOpt) const;
+
+};
+
+/*--------OS 12.01.95 -----------------------------------
+Item for settings dialog - printer/add ons
+--------------------------------------------------------- */
+class SW_DLLPUBLIC SwAddPrinterItem : public SfxPoolItem, public SwPrintData
+{
+ friend class SwAddPrinterTabPage;
+
+ using SwPrintData::operator ==;
+
+public:
+ TYPEINFO();
+ SwAddPrinterItem( sal_uInt16 nWhich = FN_PARAM_ADDPRINTER );
+ SwAddPrinterItem( sal_uInt16 nWhich, const SwPrintData& rPrtData );
+ SwAddPrinterItem( const SwAddPrinterItem& rAddPrinterItem);
+
+ virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
+
+ virtual bool operator==( const SfxPoolItem& ) const;
+
+ const OUString &GetFax() const { return sFaxName; }
+ void SetFax( const OUString& rFax) { sFaxName = rFax; }
+
+ sal_Bool IsPrintProspect() const { return bPrintProspect; }
+ sal_Bool IsPrintProspectRTL() const { return bPrintProspectRTL; }
+ void SetPrintProspect(sal_Bool bFlag ){ bPrintProspect = bFlag; }
+ void SetPrintProspectRTL(sal_Bool bFlag ){ bPrintProspectRTL = bFlag; }
+ sal_Bool IsPrintGraphic () const { return bPrintGraphic; }
+ sal_Bool IsPrintTable () const { return bPrintTable; }
+ sal_Bool IsPrintDraw () const { return bPrintDraw; }
+ sal_Bool IsPrintControl () const { return bPrintControl; }
+ sal_Bool IsPrintLeftPage () const { return bPrintLeftPages; }
+ sal_Bool IsPrintRightPage() const { return bPrintRightPages; }
+ sal_Bool IsPrintReverse () const { return bPrintReverse; }
+ sal_Bool IsPaperFromSetup() const { return bPaperFromSetup; }
+ sal_Bool IsPrintEmptyPages() const { return bPrintEmptyPages; }
+ sal_Bool IsPrintPageBackground() const { return bPrintPageBackground; }
+ sal_Bool IsPrintBlackFont() const { return bPrintBlackFont; }
+ //#i81434# - printing of hidden text
+ sal_Bool IsPrintHiddenText() const { return bPrintHiddenText; }
+ sal_Bool IsPrintTextPlaceholder() const { return bPrintTextPlaceholder; }
+
+ sal_Bool IsPrintSingleJobs() const { return bPrintSingleJobs; }
+ sal_uLong GetPrintPostIts () const { return nPrintPostIts; }
+
+};
+
+/*--------OS 12.01.95 -----------------------------------
+Item for settings dialog, ShadowCursorPage
+--------------------------------------------------------- */
+class SW_DLLPUBLIC SwShadowCursorItem : public SfxPoolItem
+{
+ sal_uInt8 eMode;
+ sal_Bool bOn;
+public:
+ TYPEINFO();
+ SwShadowCursorItem( sal_uInt16 nWhich = FN_PARAM_SHADOWCURSOR );
+ SwShadowCursorItem( const SwShadowCursorItem& rElemItem );
+ SwShadowCursorItem( const SwViewOption& rVOpt, sal_uInt16 nWhich );
+
+ virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
+ virtual bool operator==( const SfxPoolItem& ) const;
+ void operator=( const SwShadowCursorItem& );
+
+ void FillViewOptions( SwViewOption& rVOpt) const;
+
+ sal_uInt8 GetMode() const { return eMode; }
+ sal_Bool IsOn() const { return bOn; }
+
+ void SetMode( sal_uInt8 eM ) { eMode = eM; }
+ void SetOn( sal_Bool bFlag ) { bOn = bFlag; }
+};
+
+#ifdef DBG_UTIL
+
+/*--------OS 12.01.95 -----------------------------------
+Item for settings dialog - test settings
+--------------------------------------------------------- */
+class SW_DLLPUBLIC SwTestItem : public SfxPoolItem
+{
+ friend class SwModule;
+ friend class SwTestTabPage;
+
+ bool bTest1:1;
+ bool bTest2:1;
+ bool bTest3:1;
+ bool bTest4:1;
+ bool bTest5:1;
+ bool bTest6:1;
+ bool bTest7:1;
+ bool bTest8:1;
+ bool bTest9:1;
+ bool bTest10:1;
+
+public:
+ SwTestItem( sal_uInt16 _nWhich):
+ SfxPoolItem(_nWhich){};
+ SwTestItem( const SwTestItem& pTestItem);
+
+ virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
+ virtual bool operator==( const SfxPoolItem& ) const;
+
+};
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/changedb.hxx b/sw/source/core/uibase/inc/changedb.hxx
new file mode 100644
index 000000000000..4e8e31acce58
--- /dev/null
+++ b/sw/source/core/uibase/inc/changedb.hxx
@@ -0,0 +1,68 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_CHANGEDB_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_CHANGEDB_HXX
+
+#include <vcl/bitmap.hxx>
+#include <vcl/button.hxx>
+#include <vcl/fixed.hxx>
+#include <svtools/stdctrl.hxx>
+#include <svtools/treelistbox.hxx>
+#include <svx/stddlg.hxx>
+#include "dbtree.hxx"
+
+class SwFldMgr;
+class SwView;
+class SwWrtShell;
+struct SwDBData;
+
+/*--------------------------------------------------------------------
+ Description: exchange database at fields
+ --------------------------------------------------------------------*/
+class SwChangeDBDlg: public SvxStandardDialog
+{
+ SvTreeListBox* m_pUsedDBTLB;
+ SwDBTreeList* m_pAvailDBTLB;
+ PushButton* m_pAddDBPB;
+ FixedText* m_pDocDBNameFT;
+ PushButton* m_pDefineBT;
+
+ ImageList aImageList;
+
+ SwWrtShell *pSh;
+ SwFldMgr *pMgr;
+
+ DECL_LINK(TreeSelectHdl, void * = 0);
+ DECL_LINK(ButtonHdl, void *);
+ DECL_LINK(AddDBHdl, void *);
+
+ virtual void Apply();
+ void UpdateFlds();
+ void FillDBPopup();
+ SvTreeListEntry* Insert(const OUString& rDBName);
+ void ShowDBName(const SwDBData& rDBData);
+
+public:
+ SwChangeDBDlg(SwView& rVw);
+ ~SwChangeDBDlg();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/chartins.hxx b/sw/source/core/uibase/inc/chartins.hxx
new file mode 100644
index 000000000000..848653cf45f0
--- /dev/null
+++ b/sw/source/core/uibase/inc/chartins.hxx
@@ -0,0 +1,27 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_CHARTINS_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_CHARTINS_HXX
+
+Point SwGetChartDialogPos( const Window *pParentWin, const Size& rDialogSize, const Rectangle& rLogicChart );
+void SwInsertChart( Window *pParent, SfxBindings *pBindings );
+
+#endif // INCLUDED_SW_SOURCE_UI_INC_CHARTINS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/chldwrap.hxx b/sw/source/core/uibase/inc/chldwrap.hxx
new file mode 100644
index 000000000000..41f771acc2f9
--- /dev/null
+++ b/sw/source/core/uibase/inc/chldwrap.hxx
@@ -0,0 +1,47 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_CHLDWRAP_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_CHLDWRAP_HXX
+
+#include <sfx2/childwin.hxx>
+#include <vcl/timer.hxx>
+
+class SwDocShell;
+
+class SwChildWinWrapper : public SfxChildWindow
+{
+ Timer m_aUpdateTimer;
+ SwDocShell* m_pDocSh;
+
+ DECL_LINK( UpdateHdl, void* );
+
+ // Implementation in fldtdlg.cxx
+protected:
+ SwChildWinWrapper(Window *pParentWindow, sal_uInt16 nId);
+
+public:
+ virtual sal_Bool ReInitDlg(SwDocShell *pDocSh);
+
+ inline SwDocShell* GetOldDocShell() { return m_pDocSh; }
+ inline void SetOldDocShell(SwDocShell *pDcSh) { m_pDocSh = pDcSh; }
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/chrdlg.hxx b/sw/source/core/uibase/inc/chrdlg.hxx
new file mode 100644
index 000000000000..c01cc2d16357
--- /dev/null
+++ b/sw/source/core/uibase/inc/chrdlg.hxx
@@ -0,0 +1,94 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_CHRDLG_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_CHRDLG_HXX
+#include <sfx2/tabdlg.hxx>
+
+#include <vcl/group.hxx>
+
+#include <vcl/fixed.hxx>
+
+#include <vcl/edit.hxx>
+
+#include <vcl/combobox.hxx>
+
+#include <vcl/button.hxx>
+
+#include <vcl/lstbox.hxx>
+
+class SwView;
+class SvxMacroItem;
+
+class SwCharDlg: public SfxTabDialog
+{
+ SwView& m_rView;
+ sal_uInt8 m_nDialogMode;
+
+ sal_uInt16 m_nCharStdId;
+ sal_uInt16 m_nCharExtId;
+ sal_uInt16 m_nCharPosId;
+ sal_uInt16 m_nCharTwoId;
+ sal_uInt16 m_nCharUrlId;
+ sal_uInt16 m_nCharBgdId;
+ sal_uInt16 m_nCharBrdId;
+
+public:
+ SwCharDlg(Window* pParent, SwView& pVw, const SfxItemSet& rCoreSet,
+ sal_uInt8 nDialogMode, const OUString* pFmtStr = 0);
+
+ ~SwCharDlg();
+
+ virtual void PageCreated( sal_uInt16 nId, SfxTabPage &rPage );
+};
+
+class SwCharURLPage : public SfxTabPage
+{
+ Edit* m_pURLED;
+ FixedText* m_pTextFT;
+ Edit* m_pTextED;
+ Edit* m_pNameED;
+ ComboBox* m_pTargetFrmLB;
+ PushButton* m_pURLPB;
+ PushButton* m_pEventPB;
+ ListBox* m_pVisitedLB;
+ ListBox* m_pNotVisitedLB;
+
+ VclContainer* m_pCharStyleContainer;
+
+ SvxMacroItem* pINetItem;
+ bool bModified;
+
+ DECL_LINK(InsertFileHdl, void *);
+ DECL_LINK(EventHdl, void *);
+
+public:
+ SwCharURLPage( Window* pParent,
+ const SfxItemSet& rSet );
+
+ ~SwCharURLPage();
+ static SfxTabPage* Create( Window* pParent,
+ const SfxItemSet& rAttrSet);
+
+ virtual sal_Bool FillItemSet( SfxItemSet& rSet );
+ virtual void Reset( const SfxItemSet& rSet );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/chrdlgmodes.hxx b/sw/source/core/uibase/inc/chrdlgmodes.hxx
new file mode 100644
index 000000000000..bc7d6a2be8d0
--- /dev/null
+++ b/sw/source/core/uibase/inc/chrdlgmodes.hxx
@@ -0,0 +1,21 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_SW_SOURCE_UI_INC_CHRDLGMODES_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_CHRDLGMODES_HXX
+
+// DialogModes for SwCharDlg
+#define DLG_CHAR_STD 0
+#define DLG_CHAR_DRAW 1
+#define DLG_CHAR_ENV 2
+#define DLG_CHAR_ANN 3
+
+#endif // INCLUDED_SW_SOURCE_UI_INC_CHRDLGMODES_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/cnttab.hxx b/sw/source/core/uibase/inc/cnttab.hxx
new file mode 100644
index 000000000000..a1a6fae550a3
--- /dev/null
+++ b/sw/source/core/uibase/inc/cnttab.hxx
@@ -0,0 +1,88 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_CNTTAB_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_CNTTAB_HXX
+
+#include <svx/stddlg.hxx>
+
+#include <vcl/button.hxx>
+
+#include <vcl/edit.hxx>
+
+#include <vcl/fixed.hxx>
+
+#include <vcl/field.hxx>
+#include <vcl/lstbox.hxx>
+#include <sfx2/tabdlg.hxx>
+
+#include "tox.hxx"
+#include <toxmgr.hxx>
+#include <svx/checklbx.hxx>
+#include <tools/resary.hxx>
+#include <svtools/treelistbox.hxx>
+#include <vcl/menubtn.hxx>
+#include <svx/langbox.hxx>
+
+#define TOX_PAGE_SELECT 1
+#define TOX_PAGE_ENTRY 2
+#define TOX_PAGE_STYLES 3
+
+#define TO_CONTENT 1
+#define TO_INDEX 2
+#define TO_ILLUSTRATION 4
+#define TO_TABLE 8
+#define TO_USER 16
+#define TO_OBJECT 32
+#define TO_AUTHORITIES 64
+#define TO_BIBLIOGRAPHY 128
+
+struct CurTOXType
+{
+ TOXTypes eType;
+ sal_uInt16 nIndex; //for TOX_USER only
+
+ bool operator==(const CurTOXType aCmp)
+ {
+ return eType == aCmp.eType && nIndex == aCmp.nIndex;
+ }
+ sal_uInt16 GetFlatIndex() const;
+
+ CurTOXType () : eType (TOX_INDEX), nIndex (0) {};
+
+ CurTOXType (TOXTypes t, sal_uInt16 i) : eType (t), nIndex (i) {};
+};
+
+class SwOLENames : public Resource
+{
+ ResStringArray aNamesAry;
+public:
+ SwOLENames(const ResId& rResId) :
+ Resource(rResId),
+ aNamesAry(ResId(1,*rResId.GetResMgr()))
+ {
+ FreeResource();
+ }
+
+ ResStringArray& GetNames() { return aNamesAry;}
+
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/colex.hxx b/sw/source/core/uibase/inc/colex.hxx
new file mode 100644
index 000000000000..748cc8db0396
--- /dev/null
+++ b/sw/source/core/uibase/inc/colex.hxx
@@ -0,0 +1,109 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_COLEX_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_COLEX_HXX
+
+#include <svx/pagectrl.hxx>
+#include <editeng/paperinf.hxx>
+#include "swdllapi.h"
+#include <fmtclds.hxx>
+#include "frmatr.hxx"
+
+class SwColMgr;
+class SfxItemSet;
+
+class SW_DLLPUBLIC SwPageExample : public SvxPageWindow
+{
+public:
+ SwPageExample(Window* pPar)
+ : SvxPageWindow(pPar)
+ {
+ SetSize(SvxPaperInfo::GetPaperSize(PAPER_A4));
+ }
+
+ void UpdateExample( const SfxItemSet& rSet );
+};
+
+class SwTextGridItem;
+
+class SW_DLLPUBLIC SwPageGridExample : public SwPageExample
+{
+ SwTextGridItem* pGridItem;
+ bool m_bVertical;
+protected:
+ virtual void DrawPage( const Point& rPoint,
+ const sal_Bool bSecond,
+ const sal_Bool bEnabled );
+public:
+ SwPageGridExample(Window* pPar) :
+ SwPageExample(pPar),
+ pGridItem(0),
+ m_bVertical(false){}
+
+ ~SwPageGridExample();
+ void UpdateExample( const SfxItemSet& rSet );
+};
+
+class SW_DLLPUBLIC SwColExample : public SwPageExample
+{
+ SwColMgr* pColMgr;
+
+ using SwPageExample::UpdateExample;
+
+protected:
+ virtual void DrawPage( const Point& rPoint,
+ const sal_Bool bSecond,
+ const sal_Bool bEnabled );
+
+public:
+ SwColExample(Window* pPar)
+ : SwPageExample(pPar)
+ , pColMgr(0)
+ {
+ }
+
+ void UpdateExample( const SfxItemSet& rSet, SwColMgr* pMgr )
+ {
+ pColMgr = pMgr;
+ SwPageExample::UpdateExample(rSet);
+ }
+};
+
+class SW_DLLPUBLIC SwColumnOnlyExample : public Window
+{
+private:
+ Size m_aWinSize;
+
+ Size m_aFrmSize;
+ SwFmtCol m_aCols;
+
+protected:
+ virtual void Paint( const Rectangle& rRect );
+
+public:
+ SwColumnOnlyExample(Window*);
+
+ void SetColumns(const SwFmtCol& rCol);
+
+ virtual Size GetOptimalSize() const;
+};
+
+#endif // INCLUDED_SW_SOURCE_UI_INC_COLEX_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/colmgr.hxx b/sw/source/core/uibase/inc/colmgr.hxx
new file mode 100644
index 000000000000..b3f73001005a
--- /dev/null
+++ b/sw/source/core/uibase/inc/colmgr.hxx
@@ -0,0 +1,127 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_COLMGR_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_COLMGR_HXX
+
+#include "swdllapi.h"
+#include <fmtclds.hxx>
+
+SW_DLLPUBLIC void FitToActualSize(SwFmtCol& rCol, sal_uInt16 nWidth);
+
+class SW_DLLPUBLIC SwColMgr
+{
+public:
+ // lActWidth is passed directly from the page dialogs edits
+ SwColMgr(const SfxItemSet &rSet, sal_uInt16 nActWidth = USHRT_MAX);
+ ~SwColMgr();
+
+ inline sal_uInt16 GetCount() const;
+ void SetCount(sal_uInt16 nCount, sal_uInt16 nGutterWidth);
+ sal_uInt16 GetGutterWidth(sal_uInt16 nPos = USHRT_MAX) const;
+ void SetGutterWidth(sal_uInt16 nWidth, sal_uInt16 nPos = USHRT_MAX);
+
+ sal_uInt16 GetColWidth(sal_uInt16 nIdx) const;
+ void SetColWidth(sal_uInt16 nIdx, sal_uInt16 nWidth);
+
+ inline sal_Bool IsAutoWidth() const;
+ void SetAutoWidth(sal_Bool bOn = sal_True, sal_uInt16 lGutterWidth = 0);
+
+ inline bool HasLine() const;
+ inline void SetNoLine();
+
+ void SetLineWidthAndColor(::editeng::SvxBorderStyle eStyle, sal_uLong nWidth, const Color& rCol);
+ inline ::editeng::SvxBorderStyle GetLineStyle() const;
+ inline sal_uLong GetLineWidth() const;
+ inline const Color& GetLineColor() const;
+
+ inline SwColLineAdj GetAdjust() const;
+ inline void SetAdjust(SwColLineAdj);
+
+ short GetLineHeightPercent() const;
+ void SetLineHeightPercent(short nPercent);
+
+ inline void NoCols();
+ void Update();
+
+ const SwFmtCol& GetColumns() const { return aFmtCol; }
+
+ void SetActualWidth(sal_uInt16 nW);
+ sal_uInt16 GetActualSize() const { return nWidth; }
+
+private:
+
+ SwFmtCol aFmtCol;
+ sal_uInt16 nWidth;
+};
+
+// INLINE METHOD --------------------------------------------------------
+inline sal_uInt16 SwColMgr::GetCount() const
+{
+ return aFmtCol.GetNumCols();
+}
+
+inline ::editeng::SvxBorderStyle SwColMgr::GetLineStyle() const
+{
+ return aFmtCol.GetLineStyle();
+}
+inline sal_uLong SwColMgr::GetLineWidth() const
+{
+ return aFmtCol.GetLineWidth();
+}
+
+inline const Color& SwColMgr::GetLineColor() const
+{
+ return aFmtCol.GetLineColor();
+}
+
+inline SwColLineAdj SwColMgr::GetAdjust() const
+{
+ return aFmtCol.GetLineAdj();
+}
+
+inline void SwColMgr::SetAdjust(SwColLineAdj eAdj)
+{
+ aFmtCol.SetLineAdj(eAdj);
+}
+inline sal_Bool SwColMgr::IsAutoWidth() const
+{
+ return aFmtCol.IsOrtho();
+}
+inline void SwColMgr::SetAutoWidth(sal_Bool bOn, sal_uInt16 nGutterWidth)
+{
+ aFmtCol.SetOrtho(bOn, nGutterWidth, nWidth);
+}
+
+inline void SwColMgr::NoCols()
+{
+ aFmtCol.GetColumns().clear();
+}
+inline bool SwColMgr::HasLine() const
+{
+ return GetAdjust() != COLADJ_NONE;
+}
+
+inline void SwColMgr::SetNoLine()
+{
+ SetAdjust(COLADJ_NONE);
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/column.hxx b/sw/source/core/uibase/inc/column.hxx
new file mode 100644
index 000000000000..2593a35be19c
--- /dev/null
+++ b/sw/source/core/uibase/inc/column.hxx
@@ -0,0 +1,206 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SW_SOURCE_UI_INC_COLUMN_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_COLUMN_HXX
+
+#include <vcl/fixed.hxx>
+#include <vcl/field.hxx>
+#include <vcl/image.hxx>
+#include <vcl/group.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/button.hxx>
+#include <vcl/timer.hxx>
+#include <svtools/ctrlbox.hxx>
+#include <svtools/valueset.hxx>
+#include <sfx2/basedlgs.hxx>
+#include <sfx2/tabdlg.hxx>
+#include <fmtclbl.hxx>
+#include <colex.hxx>
+#include <prcntfld.hxx>
+
+const int nMaxCols = 99;
+class SwColMgr;
+class SwWrtShell;
+class SwColumnPage;
+
+class SwColumnDlg : public SfxModalDialog
+{
+ ListBox* m_pApplyToLB;
+
+ SwWrtShell& rWrtShell;
+ SwColumnPage* pTabPage;
+ SfxItemSet* pPageSet;
+ SfxItemSet* pSectionSet;
+ SfxItemSet* pSelectionSet;
+ SfxItemSet* pFrameSet;
+
+ long nOldSelection;
+ long nSelectionWidth;
+ long nPageWidth;
+
+ bool bPageChanged : 1;
+ bool bSectionChanged : 1;
+ bool bSelSectionChanged : 1;
+ bool bFrameChanged : 1;
+
+ DECL_LINK(ObjectHdl, ListBox*);
+ DECL_LINK(OkHdl, void *);
+
+public:
+ SwColumnDlg(Window* pParent, SwWrtShell& rSh);
+ virtual ~SwColumnDlg();
+
+ SwWrtShell& GetWrtShell() { return rWrtShell; }
+};
+
+class ColumnValueSet : public ValueSet
+{
+public:
+ ColumnValueSet(Window* pParent, const ResId& rResId)
+ : ValueSet(pParent, rResId)
+ {
+ }
+ ColumnValueSet(Window* pParent)
+ : ValueSet(pParent, WB_TABSTOP | WB_ITEMBORDER | WB_DOUBLEBORDER)
+ {
+ }
+ virtual void UserDraw( const UserDrawEvent& rUDEvt );
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+};
+
+/*--------------------------------------------------------------------
+ Description: column dialog now as TabPage
+ --------------------------------------------------------------------*/
+class SwColumnPage : public SfxTabPage
+{
+ NumericField* m_pCLNrEdt;
+ ColumnValueSet* m_pDefaultVS;
+ CheckBox* m_pBalanceColsCB;
+
+ PushButton* m_pBtnBack;
+ FixedText* m_pLbl1;
+ PercentField aEd1;
+ FixedText* m_pLbl2;
+ PercentField aEd2;
+ FixedText* m_pLbl3;
+ PercentField aEd3;
+ PushButton* m_pBtnNext;
+ PercentField aDistEd1;
+ PercentField aDistEd2;
+ CheckBox* m_pAutoWidthBox;
+
+ FixedText* m_pLineTypeLbl;
+ LineListBox* m_pLineTypeDLB;
+ FixedText* m_pLineWidthLbl;
+ MetricField* m_pLineWidthEdit;
+ FixedText* m_pLineColorLbl;
+ ColorListBox* m_pLineColorDLB;
+ FixedText* m_pLineHeightLbl;
+ MetricField* m_pLineHeightEdit;
+ FixedText* m_pLinePosLbl;
+ ListBox* m_pLinePosDLB;
+
+ FixedText* m_pTextDirectionFT;
+ ListBox* m_pTextDirectionLB;
+
+ // Example
+ SwColExample* m_pPgeExampleWN;
+ SwColumnOnlyExample* m_pFrmExampleWN;
+
+ SwColMgr* pColMgr;
+
+ sal_uInt16 nFirstVis;
+ sal_uInt16 nCols;
+ long nColWidth[nMaxCols];
+ long nColDist[nMaxCols];
+ sal_uInt16 nMinWidth;
+ PercentField* pModifiedField;
+
+ std::map<MetricField*, PercentField*> m_aPercentFieldsMap;
+
+ sal_Bool bFormat;
+ sal_Bool bFrm;
+ sal_Bool bHtmlMode;
+ bool bLockUpdate;
+
+ // Handler
+ DECL_LINK( ColModify, NumericField * );
+ DECL_LINK( GapModify, MetricField * );
+ DECL_LINK( EdModify, MetricField * );
+ DECL_LINK( AutoWidthHdl, CheckBox * );
+ DECL_LINK( SetDefaultsHdl, ValueSet * );
+
+ DECL_LINK(Up, void *);
+ DECL_LINK(Down, void *);
+ DECL_LINK( UpdateColMgr, void* );
+ void Apply(Button *);
+ void Timeout();
+
+ void Update();
+ void UpdateCols();
+ void Init();
+ void ResetColWidth();
+ void SetLabels( sal_uInt16 nVis );
+
+ using SfxTabPage::ActivatePage;
+ using SfxTabPage::DeactivatePage;
+
+ virtual void ActivatePage(const SfxItemSet& rSet);
+ virtual int DeactivatePage(SfxItemSet *pSet);
+
+ SwColumnPage(Window *pParent, const SfxItemSet &rSet);
+
+ void connectPercentField(PercentField &rWrap, const OString &rName);
+
+ bool isLineNotNone() const;
+
+public:
+ virtual ~SwColumnPage();
+
+ static SfxTabPage *Create(Window *pParent, const SfxItemSet &rSet);
+ static sal_uInt16* GetRanges();
+
+ virtual sal_Bool FillItemSet(SfxItemSet &rSet);
+ virtual void Reset(const SfxItemSet &rSet);
+
+ void SetFrmMode(sal_Bool bMod);
+ void SetPageWidth(long nPageWidth);
+
+ void SetFormatUsed(sal_Bool bFmt)
+ {
+ bFormat = bFmt;
+ }
+
+ void ShowBalance(sal_Bool bShow)
+ {
+ m_pBalanceColsCB->Show(bShow);
+ }
+
+ void SetInSection(sal_Bool bSet);
+
+ void ActivateColumnControl()
+ {
+ m_pCLNrEdt->GrabFocus();
+ }
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/conarc.hxx b/sw/source/core/uibase/inc/conarc.hxx
new file mode 100644
index 000000000000..354a625468f2
--- /dev/null
+++ b/sw/source/core/uibase/inc/conarc.hxx
@@ -0,0 +1,48 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_CONARC_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_CONARC_HXX
+
+#include "drawbase.hxx"
+
+/*************************************************************************
+|*
+|* draw rectangle
+|*
+\************************************************************************/
+
+class ConstArc : public SwDrawBase
+{
+ Point aStartPnt;
+ sal_uInt16 nAnzButUp;
+
+public:
+ ConstArc(SwWrtShell* pSh, SwEditWin* pWin, SwView* pView);
+
+ // Mouse- & Key-Events
+ virtual sal_Bool MouseButtonUp(const MouseEvent& rMEvt);
+ virtual sal_Bool MouseButtonDown(const MouseEvent& rMEvt);
+
+ virtual void Activate(const sal_uInt16 nSlotId); // activate function
+ virtual void Deactivate();
+};
+
+#endif // INCLUDED_SW_SOURCE_UI_INC_CONARC_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/concustomshape.hxx b/sw/source/core/uibase/inc/concustomshape.hxx
new file mode 100644
index 000000000000..96d6707b9a90
--- /dev/null
+++ b/sw/source/core/uibase/inc/concustomshape.hxx
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SW_SOURCE_UI_INC_CONCUSTOMSHAPE_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_CONCUSTOMSHAPE_HXX
+
+#include <rtl/ustring.hxx>
+#include "drawbase.hxx"
+
+class SdrObject;
+class SfxRequest;
+
+/*************************************************************************
+|*
+|* draw rectangle
+|*
+\************************************************************************/
+
+class ConstCustomShape : public SwDrawBase
+{
+
+ OUString aCustomShape;
+
+ void SetAttributes( SdrObject* pObj );
+
+ public:
+
+ ConstCustomShape( SwWrtShell* pSh, SwEditWin* pWin, SwView* pView, SfxRequest& rReq );
+
+ // Mouse- & Key-Events
+ virtual sal_Bool MouseButtonUp(const MouseEvent& rMEvt);
+ virtual sal_Bool MouseButtonDown(const MouseEvent& rMEvt);
+
+ virtual void Activate(const sal_uInt16 nSlotId); // activate function
+
+ OUString GetShapeType() const;
+ static OUString GetShapeTypeFromRequest( SfxRequest& rReq );
+
+ virtual void CreateDefaultObject();
+
+ // #i33136#
+ virtual bool doConstructOrthogonal() const;
+};
+
+#endif // INCLUDED_SW_SOURCE_UI_INC_CONCUSTOMSHAPE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/condedit.hxx b/sw/source/core/uibase/inc/condedit.hxx
new file mode 100644
index 000000000000..514a23e58c55
--- /dev/null
+++ b/sw/source/core/uibase/inc/condedit.hxx
@@ -0,0 +1,49 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_CONDEDIT_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_CONDEDIT_HXX
+
+#include <vcl/edit.hxx>
+#include <svtools/transfer.hxx>
+#include "swdllapi.h"
+
+class SW_DLLPUBLIC ConditionEdit : public Edit, public DropTargetHelper
+{
+ bool bBrackets, bEnableDrop;
+
+ SAL_DLLPRIVATE virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
+ SAL_DLLPRIVATE virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
+
+public:
+ ConditionEdit(Window* pParent, WinBits nStyle);
+
+ void ShowBrackets(bool bShow)
+ {
+ bBrackets = bShow;
+ }
+
+ void SetDropEnable(bool bFlag)
+ {
+ bEnableDrop = bFlag;
+ }
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/conform.hxx b/sw/source/core/uibase/inc/conform.hxx
new file mode 100644
index 000000000000..a1226a21f25e
--- /dev/null
+++ b/sw/source/core/uibase/inc/conform.hxx
@@ -0,0 +1,38 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_CONFORM_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_CONFORM_HXX
+
+#include "drawbase.hxx"
+
+class ConstFormControl : public SwDrawBase
+{
+public:
+ ConstFormControl(SwWrtShell* pSh, SwEditWin* pWin, SwView* pView);
+
+ // Mouse- & Key-Events
+ virtual sal_Bool MouseButtonDown(const MouseEvent& rMEvt);
+
+ virtual void Activate(const sal_uInt16 nSlotId); // activate function
+ virtual void CreateDefaultObject();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/conpoly.hxx b/sw/source/core/uibase/inc/conpoly.hxx
new file mode 100644
index 000000000000..d91c38e0dd6b
--- /dev/null
+++ b/sw/source/core/uibase/inc/conpoly.hxx
@@ -0,0 +1,47 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_CONPOLY_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_CONPOLY_HXX
+
+#include "drawbase.hxx"
+
+/*************************************************************************
+|*
+|* base class for all functions
+|*
+\************************************************************************/
+
+class ConstPolygon : public SwDrawBase
+{
+ Point aLastPos;
+
+public:
+ ConstPolygon(SwWrtShell* pSh, SwEditWin* pWin, SwView* pView);
+
+ // Mouse- & Key-Events
+ virtual sal_Bool MouseMove(const MouseEvent& rMEvt);
+ virtual sal_Bool MouseButtonUp(const MouseEvent& rMEvt);
+ virtual sal_Bool MouseButtonDown(const MouseEvent& rMEvt);
+
+ virtual void Activate(const sal_uInt16 nSlotId); // activate function
+};
+
+#endif // INCLUDED_SW_SOURCE_UI_INC_CONPOLY_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/conrect.hxx b/sw/source/core/uibase/inc/conrect.hxx
new file mode 100644
index 000000000000..4791935d37ce
--- /dev/null
+++ b/sw/source/core/uibase/inc/conrect.hxx
@@ -0,0 +1,51 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SW_SOURCE_UI_INC_CONRECT_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_CONRECT_HXX
+
+#include "drawbase.hxx"
+
+/*************************************************************************
+|*
+|* draw rectangle
+|*
+\************************************************************************/
+
+class ConstRectangle : public SwDrawBase
+{
+ bool bMarquee;
+ bool bCapVertical;
+
+ // #93382#
+ bool mbVertical;
+
+ public:
+ ConstRectangle(SwWrtShell* pSh, SwEditWin* pWin, SwView* pView);
+
+ // Mouse- & Key-Events
+ virtual sal_Bool MouseButtonUp(const MouseEvent& rMEvt);
+ virtual sal_Bool MouseButtonDown(const MouseEvent& rMEvt);
+
+ virtual void Activate(const sal_uInt16 nSlotId); // activate function
+};
+
+#endif // INCLUDED_SW_SOURCE_UI_INC_CONRECT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/content.hxx b/sw/source/core/uibase/inc/content.hxx
new file mode 100644
index 000000000000..2700bd261e83
--- /dev/null
+++ b/sw/source/core/uibase/inc/content.hxx
@@ -0,0 +1,208 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_CONTENT_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_CONTENT_HXX
+#include <limits.h>
+#include "swcont.hxx"
+
+#include <vcl/menu.hxx>
+
+class SwWrtShell;
+class SwContentArr;
+class SwContentType;
+class SwFmtFld;
+class SwTxtINetFmt;
+class SwTOXBase;
+class SwRangeRedline;
+
+// helper classes
+
+class SwPopup : public PopupMenu
+{
+ sal_uInt16 nCurId;
+ virtual void Select(){nCurId = GetCurItemId();}
+
+public:
+ SwPopup() :
+ PopupMenu(),
+ nCurId(USHRT_MAX){}
+
+ sal_uInt16 GetCurId() const { return nCurId; }
+
+};
+
+class SwOutlineContent : public SwContent
+{
+ sal_uInt16 nOutlinePos;
+ sal_uInt8 nOutlineLevel;
+ bool bIsMoveable;
+ public:
+ SwOutlineContent( const SwContentType* pCnt,
+ const OUString& rName,
+ sal_uInt16 nArrPos,
+ sal_uInt8 nLevel,
+ bool bMove,
+ long nYPos) :
+ SwContent(pCnt, rName, nYPos),
+ nOutlinePos(nArrPos), nOutlineLevel(nLevel), bIsMoveable(bMove) {}
+
+ sal_uInt16 GetPos(){return nOutlinePos;}
+ sal_uInt8 GetOutlineLevel(){return nOutlineLevel;}
+ bool IsMoveable(){return bIsMoveable;};
+};
+
+class SwRegionContent : public SwContent
+{
+
+ sal_uInt8 nRegionLevel;
+
+ public:
+ SwRegionContent( const SwContentType* pCnt,
+ const OUString& rName,
+ sal_uInt8 nLevel,
+ long nYPos) :
+ SwContent(pCnt, rName, nYPos),
+ nRegionLevel(nLevel){}
+ sal_uInt8 GetRegionLevel() const {return nRegionLevel;}
+};
+
+class SwURLFieldContent : public SwContent
+{
+ OUString sURL;
+ const SwTxtINetFmt* pINetAttr;
+
+public:
+ SwURLFieldContent( const SwContentType* pCnt,
+ const OUString& rName,
+ const OUString& rURL,
+ const SwTxtINetFmt* pAttr,
+ long nYPos )
+ : SwContent( pCnt, rName, nYPos ), sURL( rURL ), pINetAttr( pAttr )
+ {}
+
+ virtual sal_Bool IsProtect() const;
+ const OUString& GetURL() { return sURL; }
+ const SwTxtINetFmt* GetINetAttr() { return pINetAttr; }
+};
+
+class SwPostItContent : public SwContent
+{
+ const SwFmtFld* pFld;
+ SwRangeRedline* pRedline;
+ bool mbPostIt;
+public:
+ SwPostItContent( const SwContentType* pCnt,
+ const OUString& rName,
+ const SwFmtFld* pField,
+ long nYPos )
+ : SwContent(pCnt, rName, nYPos)
+ , pFld(pField)
+ , pRedline(NULL)
+ , mbPostIt(true)
+ {}
+ SwPostItContent( const SwContentType* pCnt,
+ const OUString& rName,
+ SwRangeRedline* pRed,
+ long nYPos )
+ : SwContent(pCnt, rName, nYPos)
+ , pFld(NULL)
+ , pRedline(pRed)
+ , mbPostIt(false)
+ {}
+
+ const SwFmtFld* GetPostIt() { return pFld; }
+ SwRangeRedline* GetRedline() { return pRedline; }
+ virtual sal_Bool IsProtect() const;
+ bool IsPostIt() {return mbPostIt; }
+};
+
+class SwGraphicContent : public SwContent
+{
+ OUString sLink;
+public:
+ SwGraphicContent(const SwContentType* pCnt, const OUString& rName, const OUString& rLink, long nYPos)
+ : SwContent( pCnt, rName, nYPos ), sLink( rLink )
+ {}
+ virtual ~SwGraphicContent();
+
+ const OUString& GetLink() const {return sLink;}
+};
+
+class SwTOXBaseContent : public SwContent
+{
+ const SwTOXBase* pBase;
+public:
+ SwTOXBaseContent(const SwContentType* pCnt, const OUString& rName, long nYPos, const SwTOXBase& rBase)
+ : SwContent( pCnt, rName, nYPos ), pBase(&rBase)
+ {}
+ virtual ~SwTOXBaseContent();
+
+ const SwTOXBase* GetTOXBase() const {return pBase;}
+};
+/*
+ class ContentType contains information to one type of content.
+ MemberArray is only populated if the content is requested by
+ GetMember. It is reloaded after Invalidate() only if the content
+ should be read again.
+*/
+
+class SwContentType : public SwTypeNumber
+{
+ SwWrtShell* pWrtShell;
+ SwContentArr* pMember; // array for content
+ OUString sContentTypeName; // name of content type
+ OUString sSingleContentTypeName; // name of content type, singular
+ OUString sTypeToken; // attachment for URL
+ sal_uInt16 nMemberCount; // content count
+ sal_uInt16 nContentType; // content type's Id
+ sal_uInt8 nOutlineLevel;
+ bool bDataValid : 1;
+ bool bEdit: 1; // can this type be edited?
+ bool bDelete: 1; // can this type be deleted?
+protected:
+ OUString RemoveNewline(const OUString&);
+public:
+ SwContentType(SwWrtShell* pParent, sal_uInt16 nType, sal_uInt8 nLevel );
+ ~SwContentType();
+
+ void Init(sal_Bool* pbInvalidateWindow = 0);
+ void FillMemberList(sal_Bool* pbLevelChanged = NULL);
+ sal_uInt16 GetMemberCount() const
+ {return nMemberCount;};
+ sal_uInt16 GetType() const {return nContentType;}
+ const SwContent* GetMember(sal_uInt16 nIndex);
+ const OUString& GetName() {return sContentTypeName;}
+ const OUString& GetSingleName() const {return sSingleContentTypeName;}
+ const OUString& GetTypeToken() const{return sTypeToken;}
+
+ void SetOutlineLevel(sal_uInt8 nNew)
+ {
+ nOutlineLevel = nNew;
+ Invalidate();
+ }
+
+ void Invalidate(); // only nMemberCount is read again
+
+ bool IsEditable() const {return bEdit;}
+ bool IsDeletable() const {return bDelete;}
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/conttree.hxx b/sw/source/core/uibase/inc/conttree.hxx
new file mode 100644
index 000000000000..d51152a344e7
--- /dev/null
+++ b/sw/source/core/uibase/inc/conttree.hxx
@@ -0,0 +1,329 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_CONTTREE_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_CONTTREE_HXX
+
+#include "svtools/treelistbox.hxx"
+#include "svtools/svlbitm.hxx"
+#include "swcont.hxx"
+
+#include <map>
+
+class SwWrtShell;
+class SwContentType;
+class SwNavigationPI;
+class SwNavigationConfig;
+class Menu;
+class ToolBox;
+class SwGlblDocContents;
+class SwGlblDocContent;
+class SfxObjectShell;
+class SdrObject;
+
+#define EDIT_MODE_EDIT 0
+#define EDIT_MODE_UPD_IDX 1
+#define EDIT_MODE_RMV_IDX 2
+#define EDIT_UNPROTECT_TABLE 3
+#define EDIT_MODE_DELETE 4
+#define EDIT_MODE_RENAME 5
+
+class SwContentTree : public SvTreeListBox
+{
+ ImageList aEntryImages;
+ OUString sSpace;
+ AutoTimer aUpdTimer;
+
+ SwContentType* aActiveContentArr[CONTENT_TYPE_MAX];
+ SwContentType* aHiddenContentArr[CONTENT_TYPE_MAX];
+ OUString aContextStrings[CONTEXT_COUNT + 1];
+ OUString sRemoveIdx;
+ OUString sUpdateIdx;
+ OUString sUnprotTbl;
+ OUString sRename;
+ OUString sReadonlyIdx;
+ OUString sInvisible;
+ OUString sPostItShow;
+ OUString sPostItHide;
+ OUString sPostItDelete;
+
+ SwWrtShell* pHiddenShell; // dropped Doc
+ SwWrtShell* pActiveShell; // the active or a const. open view
+ SwNavigationConfig* pConfig;
+
+ std::map< void*, bool > mOutLineNodeMap;
+
+ sal_Int32 nActiveBlock;
+ sal_uInt16 nHiddenBlock;
+ sal_uInt16 nRootType;
+ sal_uInt16 nLastSelType;
+ sal_uInt8 nOutlineLevel;
+
+ bool bIsActive :1;
+ bool bIsConstant :1;
+ bool bIsHidden :1;
+ bool bDocChgdInDragging :1;
+ bool bIsInternalDrag :1;
+ bool bIsRoot :1;
+ bool bIsIdleClear :1;
+ sal_Bool bIsLastReadOnly :1;
+ bool bIsOutlineMoveable :1;
+ bool bViewHasChanged :1;
+ bool bIsImageListInitialized : 1;
+
+ static bool bIsInDrag;
+
+ bool bIsKeySpace;
+ Rectangle oldRectangle;
+
+ void FindActiveTypeAndRemoveUserData();
+
+ using SvTreeListBox::ExecuteDrop;
+ using SvTreeListBox::EditEntry;
+
+protected:
+ virtual void RequestHelp( const HelpEvent& rHEvt );
+ virtual void InitEntry(SvTreeListEntry*, const OUString&, const Image&, const Image&, SvLBoxButtonKind);
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+
+ SwNavigationPI* GetParentWindow(){return
+ (SwNavigationPI*)Window::GetParent();}
+
+ virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel );
+ virtual void DragFinished( sal_Int8 );
+ virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
+
+ virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
+
+ bool FillTransferData( TransferDataContainer& rTransfer,
+ sal_Int8& rDragMode );
+ bool HasContentChanged();
+
+ virtual DragDropMode NotifyStartDrag( TransferDataContainer& rData,
+ SvTreeListEntry* );
+ virtual sal_Bool NotifyAcceptDrop( SvTreeListEntry* );
+
+ virtual sal_Bool NotifyMoving( SvTreeListEntry* pTarget,
+ SvTreeListEntry* pEntry,
+ SvTreeListEntry*& rpNewParent,
+ sal_uLong& rNewChildPos
+ );
+ virtual sal_Bool NotifyCopying( SvTreeListEntry* pTarget,
+ SvTreeListEntry* pEntry,
+ SvTreeListEntry*& rpNewParent,
+ sal_uLong& rNewChildPos
+ );
+ virtual void MouseButtonDown( const MouseEvent& rMEvt );
+
+ void EditEntry( SvTreeListEntry* pEntry, sal_uInt8 nMode );
+
+ void GotoContent(SwContent* pCnt);
+ static void SetInDrag(bool bSet) {bIsInDrag = bSet;}
+
+ virtual PopupMenu* CreateContextMenu( void );
+ virtual void ExcecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry );
+
+public:
+ SwContentTree(Window* pParent, const ResId& rResId);
+ ~SwContentTree();
+ OUString GetEntryAltText( SvTreeListEntry* pEntry ) const;
+ OUString GetEntryLongDescription( SvTreeListEntry* pEntry ) const;
+ SdrObject* GetDrawingObjectsByContent(const SwContent *pCnt);
+
+ bool ToggleToRoot();
+ bool IsRoot() const {return bIsRoot;}
+ sal_uInt16 GetRootType() const {return nRootType;}
+ void SetRootType(sal_uInt16 nType);
+ void Display( bool bActiveView );
+ void Clear();
+ void SetHiddenShell(SwWrtShell* pSh);
+ void ShowHiddenShell();
+ void ShowActualView();
+ void SetActiveShell(SwWrtShell* pSh);
+ void SetConstantShell(SwWrtShell* pSh);
+
+ SwWrtShell* GetWrtShell()
+ {return bIsActive||bIsConstant ?
+ pActiveShell :
+ pHiddenShell;}
+
+ static bool IsInDrag() {return bIsInDrag;}
+ bool IsInternalDrag() const {return bIsInternalDrag;}
+
+ sal_Int32 GetActiveBlock() const {return nActiveBlock;}
+
+ sal_uInt8 GetOutlineLevel()const {return nOutlineLevel;}
+ void SetOutlineLevel(sal_uInt8 nSet);
+
+ sal_Bool Expand( SvTreeListEntry* pParent );
+
+ sal_Bool Collapse( SvTreeListEntry* pParent );
+
+ void ExecCommand(sal_uInt16 nCmd, sal_Bool bModifier);
+
+ void ShowTree();
+ void HideTree();
+
+ bool IsConstantView() {return bIsConstant;}
+ bool IsActiveView() {return bIsActive;}
+ bool IsHiddenView() {return bIsHidden;}
+
+ const SwWrtShell* GetActiveWrtShell() {return pActiveShell;}
+ SwWrtShell* GetHiddenWrtShell() {return pHiddenShell;}
+
+ DECL_LINK( ContentDoubleClickHdl, void * );
+ DECL_LINK( TimerUpdate, void * );
+
+ virtual sal_IntPtr GetTabPos( SvTreeListEntry*, SvLBoxTab* );
+ virtual void RequestingChildren( SvTreeListEntry* pParent );
+ virtual void GetFocus();
+ virtual void KeyInput(const KeyEvent& rKEvt);
+
+ virtual sal_Bool Select( SvTreeListEntry* pEntry, sal_Bool bSelect=sal_True );
+ virtual sal_Int32 GetEntryRealChildrenNum( SvTreeListEntry* pEntry ) const;
+};
+
+// TreeListBox for global documents
+
+class SwLBoxString : public SvLBoxString
+{
+public:
+
+ SwLBoxString( SvTreeListEntry* pEntry, sal_uInt16 nFlags,
+ const OUString& rStr ) : SvLBoxString(pEntry,nFlags,rStr)
+ {
+ }
+
+ virtual void Paint(
+ const Point& rPos, SvTreeListBox& rDev, const SvViewDataEntry* pView,
+ const SvTreeListEntry* pEntry);
+};
+
+namespace sfx2 { class DocumentInserter; }
+namespace sfx2 { class FileDialogHelper; }
+
+class SwGlobalTree : public SvTreeListBox
+{
+private:
+ AutoTimer aUpdateTimer;
+ OUString aContextStrings[GLOBAL_CONTEXT_COUNT];
+
+ ImageList aEntryImages;
+
+ SwWrtShell* pActiveShell;
+ SvTreeListEntry* pEmphasisEntry; // Drag'n Drop emphasis
+ SvTreeListEntry* pDDSource; // source for Drag'n Drop
+ SwGlblDocContents* pSwGlblDocContents; // array with sorted content
+
+ Window* pDefParentWin;
+ SwGlblDocContent* pDocContent;
+ sfx2::DocumentInserter* pDocInserter;
+
+ bool bIsInternalDrag :1;
+ bool bLastEntryEmphasis :1; // Drag'n Drop
+ bool bIsImageListInitialized : 1;
+
+ static const SfxObjectShell* pShowShell;
+
+ void InsertRegion( const SwGlblDocContent* _pContent,
+ const com::sun::star::uno::Sequence< OUString >& _rFiles );
+
+ DECL_LINK( DialogClosedHdl, sfx2::FileDialogHelper* );
+
+ using SvTreeListBox::DoubleClickHdl;
+ using SvTreeListBox::ExecuteDrop;
+ using Window::Update;
+
+protected:
+
+ virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
+
+ virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
+
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+
+ virtual void RequestHelp( const HelpEvent& rHEvt );
+
+ virtual sal_IntPtr GetTabPos( SvTreeListEntry*, SvLBoxTab* );
+ virtual sal_Bool NotifyMoving( SvTreeListEntry* pTarget,
+ SvTreeListEntry* pEntry,
+ SvTreeListEntry*& rpNewParent,
+ sal_uLong& rNewChildPos
+ );
+ virtual sal_Bool NotifyCopying( SvTreeListEntry* pTarget,
+ SvTreeListEntry* pEntry,
+ SvTreeListEntry*& rpNewParent,
+ sal_uLong& rNewChildPos
+ );
+
+ virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel );
+ virtual void DragFinished( sal_Int8 );
+ virtual DragDropMode NotifyStartDrag( TransferDataContainer& rData,
+ SvTreeListEntry* );
+ virtual sal_Bool NotifyAcceptDrop( SvTreeListEntry* );
+
+ virtual void MouseButtonDown( const MouseEvent& rMEvt );
+ virtual void KeyInput(const KeyEvent& rKEvt);
+ virtual void GetFocus();
+ virtual void SelectHdl();
+ virtual void DeselectHdl();
+ virtual void InitEntry(SvTreeListEntry*, const OUString&, const Image&, const Image&, SvLBoxButtonKind);
+
+ void Clear();
+
+ DECL_LINK( PopupHdl, Menu* );
+ DECL_LINK( Timeout, void* );
+ DECL_LINK( DoubleClickHdl, void* );
+
+ bool IsInternalDrag() const {return bIsInternalDrag;}
+ SwNavigationPI* GetParentWindow()
+ { return (SwNavigationPI*)Window::GetParent(); }
+
+ void OpenDoc(const SwGlblDocContent*);
+ void GotoContent(const SwGlblDocContent*);
+ sal_uInt16 GetEnableFlags() const;
+
+ static const SfxObjectShell* GetShowShell() {return pShowShell;}
+ static void SetShowShell(const SfxObjectShell*pSet) {pShowShell = pSet;}
+ DECL_STATIC_LINK(SwGlobalTree, ShowFrameHdl, SwGlobalTree*);
+
+ virtual PopupMenu* CreateContextMenu( void );
+ virtual void ExcecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry );
+
+public:
+ SwGlobalTree(Window* pParent, const ResId& rResId);
+ virtual ~SwGlobalTree();
+
+ void TbxMenuHdl(sal_uInt16 nTbxId, ToolBox* pBox);
+ void InsertRegion( const SwGlblDocContent* pCont,
+ const OUString* pFileName = 0 );
+ void EditContent(const SwGlblDocContent* pCont );
+
+ void ShowTree();
+ void HideTree();
+
+ void ExecCommand(sal_uInt16 nCmd);
+
+ void Display(bool bOnlyUpdateUserData = false);
+
+ sal_Bool Update(sal_Bool bHard);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/convert.hxx b/sw/source/core/uibase/inc/convert.hxx
new file mode 100644
index 000000000000..e9f17a60e6e7
--- /dev/null
+++ b/sw/source/core/uibase/inc/convert.hxx
@@ -0,0 +1,74 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_CONVERT_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_CONVERT_HXX
+
+#include <vcl/fixed.hxx>
+#include <vcl/button.hxx>
+#include <vcl/edit.hxx>
+#include <sfx2/basedlgs.hxx>
+
+class SwTableAutoFmt;
+class SwView;
+class SwWrtShell;
+class NumericField;
+struct SwInsertTableOptions;
+
+class SwConvertTableDlg: public SfxModalDialog
+{
+ RadioButton* mpTabBtn;
+ RadioButton* mpSemiBtn;
+ RadioButton* mpParaBtn;
+ RadioButton* mpOtherBtn;
+ Edit* mpOtherEd;
+ CheckBox* mpKeepColumn;
+
+ VclContainer* mpOptions;
+
+ CheckBox* mpHeaderCB;
+ CheckBox* mpRepeatHeaderCB;
+
+ VclContainer* mpRepeatRows;
+ NumericField* mpRepeatHeaderNF;
+
+ CheckBox* mpDontSplitCB;
+ CheckBox* mpBorderCB;
+ PushButton* mpAutoFmtBtn;
+
+ OUString sConvertTextTable;
+ SwTableAutoFmt* pTAutoFmt;
+ SwWrtShell* pShell;
+
+ DECL_LINK( AutoFmtHdl, PushButton* );
+ DECL_LINK( BtnHdl, Button* );
+ DECL_LINK(CheckBoxHdl, void * = 0);
+ DECL_LINK( ReapeatHeaderCheckBoxHdl, void* p = 0 );
+
+public:
+ SwConvertTableDlg( SwView& rView, bool bToTable );
+ ~SwConvertTableDlg();
+
+ void GetValues( sal_Unicode& rDelim,
+ SwInsertTableOptions& rInsTblOpts,
+ SwTableAutoFmt const*& prTAFmt );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/cption.hxx b/sw/source/core/uibase/inc/cption.hxx
new file mode 100644
index 000000000000..578efcdb8e1c
--- /dev/null
+++ b/sw/source/core/uibase/inc/cption.hxx
@@ -0,0 +1,113 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_CPTION_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_CPTION_HXX
+
+#include <svx/stddlg.hxx>
+
+#include <vcl/fixed.hxx>
+
+#include <vcl/lstbox.hxx>
+
+#include <vcl/edit.hxx>
+
+#include <vcl/group.hxx>
+
+#include <vcl/button.hxx>
+#include <actctrl.hxx>
+
+#include <com/sun/star/container/XEnumerationAccess.hpp>
+#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/container/XContentEnumerationAccess.hpp>
+#include <com/sun/star/container/XEnumeration.hpp>
+#include <com/sun/star/container/XElementAccess.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+
+class SwFldMgr;
+class SwView;
+
+#include <wrtsh.hxx>
+#include "optload.hxx"
+#include "swlbox.hxx"
+
+class CategoryBox : public ComboBox
+{
+public:
+ CategoryBox( Window* pParent, WinBits nStyle = 0 )
+ : ComboBox( pParent, nStyle )
+ {}
+
+ virtual bool PreNotify( NotifyEvent& rNEvt );
+};
+
+class SwCaptionDialog : public SvxStandardDialog
+{
+ Edit* m_pTextEdit;
+ CategoryBox* m_pCategoryBox;
+ FixedText* m_pFormatText;
+ ListBox* m_pFormatBox;
+ //#i61007# order of captions
+ FixedText* m_pNumberingSeparatorFT;
+ Edit* m_pNumberingSeparatorED;
+ FixedText* m_pSepText;
+ Edit* m_pSepEdit;
+ FixedText* m_pPosText;
+ ListBox* m_pPosBox;
+ OKButton* m_pOKButton;
+ PushButton* m_pAutoCaptionButton;
+ PushButton* m_pOptionButton;
+
+ SwCaptionPreview* m_pPreview;
+
+ OUString m_sNone;
+
+ SwView &rView; // search per active, avoid ::com::sun::star::sdbcx::View
+ SwFldMgr *pMgr; // pointer to save the include
+ SelectionType eType;
+
+ OUString sCharacterStyle;
+ OUString sObjectName;
+ bool bCopyAttributes;
+ bool bOrderNumberingFirst; //#i61007# order of captions
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > xNameAccess;
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed > xNamed;
+
+ DECL_LINK(SelectHdl, void *);
+ DECL_LINK(ModifyHdl, void *);
+ DECL_LINK(OptionHdl, Button *);
+ DECL_LINK(CaptionHdl, void *);
+
+ virtual void Apply();
+
+ void DrawSample();
+ void CheckButtonWidth();
+ void ApplyCaptionOrder(); //#i61007# order of captions
+
+ static OUString our_aSepTextSave; // Save caption separator text
+public:
+ SwCaptionDialog( Window *pParent, SwView &rV );
+ ~SwCaptionDialog();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/dbconfig.hxx b/sw/source/core/uibase/inc/dbconfig.hxx
new file mode 100644
index 000000000000..042a719b7338
--- /dev/null
+++ b/sw/source/core/uibase/inc/dbconfig.hxx
@@ -0,0 +1,47 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_DBCONFIG_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_DBCONFIG_HXX
+
+#include <unotools/configitem.hxx>
+#include "swdllapi.h"
+
+struct SwDBData;
+
+class SW_DLLPUBLIC SwDBConfig : public utl::ConfigItem
+{
+ SAL_DLLPRIVATE const com::sun::star::uno::Sequence<OUString>& GetPropertyNames();
+
+ SwDBData* pAdrImpl;
+ SwDBData* pBibImpl;
+
+public:
+ SwDBConfig();
+ virtual ~SwDBConfig();
+
+ void Load();
+ const SwDBData& GetAddressSource();
+ const SwDBData& GetBibliographySource();
+ virtual void Commit();
+ virtual void Notify( const ::com::sun::star::uno::Sequence< OUString >& aPropertyNames );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/dbinsdlg.hxx b/sw/source/core/uibase/inc/dbinsdlg.hxx
new file mode 100644
index 000000000000..4d271dd41e2a
--- /dev/null
+++ b/sw/source/core/uibase/inc/dbinsdlg.hxx
@@ -0,0 +1,171 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SW_SOURCE_UI_INC_DBINSDLG_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_DBINSDLG_HXX
+
+#include <vcl/button.hxx>
+#include <vcl/group.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/edit.hxx>
+#include <vcl/layout.hxx>
+#include <vcl/lstbox.hxx>
+#include <svtools/svmedit.hxx>
+#include <sfx2/basedlgs.hxx>
+#include <unotools/configitem.hxx>
+#include <numfmtlb.hxx>
+#include <swdbdata.hxx>
+#include <com/sun/star/uno/Reference.h>
+#include <com/sun/star/uno/Sequence.h>
+#include <boost/ptr_container/ptr_vector.hpp>
+#include <o3tl/sorted_vector.hxx>
+
+namespace com{namespace sun{namespace star{
+ namespace sdbcx{
+ class XColumnsSupplier;
+ }
+ namespace sdbc{
+ class XDataSource;
+ class XConnection;
+ class XResultSet;
+ }
+}}}
+
+class SwTableAutoFmt;
+class SwView;
+class SfxItemSet;
+class SwTableRep;
+struct _DB_Column;
+typedef boost::ptr_vector<_DB_Column> _DB_Columns;
+
+struct SwInsDBColumn
+{
+ OUString sColumn, sUsrNumFmt;
+ sal_Int32 nDBNumFmt;
+ sal_uInt32 nUsrNumFmt;
+ LanguageType eUsrNumFmtLng;
+ sal_uInt16 nCol;
+ sal_Bool bHasFmt : 1;
+ sal_Bool bIsDBFmt : 1;
+
+ SwInsDBColumn( const OUString& rStr, sal_uInt16 nColumn )
+ : sColumn( rStr ),
+ nDBNumFmt( 0 ),
+ nUsrNumFmt( 0 ),
+ eUsrNumFmtLng( LANGUAGE_SYSTEM ),
+ nCol( nColumn ),
+ bHasFmt(sal_False),
+ bIsDBFmt(sal_True)
+ {}
+
+ bool operator==( const SwInsDBColumn& rCmp ) const
+ { return sColumn == rCmp.sColumn; }
+ bool operator<( const SwInsDBColumn& rCmp ) const;
+};
+
+class SwInsDBColumns : public o3tl::sorted_vector<SwInsDBColumn*, o3tl::less_ptr_to<SwInsDBColumn> >
+{
+public:
+ ~SwInsDBColumns() { DeleteAndDestroyAll(); }
+};
+
+class SwInsertDBColAutoPilot : public SfxModalDialog, public utl::ConfigItem
+{
+ RadioButton* m_pRbAsTable;
+ RadioButton* m_pRbAsField;
+ RadioButton* m_pRbAsText;
+
+ VclFrame* m_pHeadFrame;
+
+ ListBox* m_pLbTblDbColumn;
+ ListBox* m_pLbTxtDbColumn;
+
+ VclFrame* m_pFormatFrame;
+ RadioButton* m_pRbDbFmtFromDb;
+ RadioButton* m_pRbDbFmtFromUsr;
+ NumFormatListBox* m_pLbDbFmtFromUsr;
+
+ /* ----- Page Text/Field ------- */
+ PushButton* m_pIbDbcolToEdit;
+ VclMultiLineEdit* m_pEdDbText;
+ FixedText* m_pFtDbParaColl;
+ ListBox* m_pLbDbParaColl;
+
+ /* ----- Page Table ------------ */
+ PushButton* m_pIbDbcolAllTo;
+ PushButton* m_pIbDbcolOneTo;
+ PushButton* m_pIbDbcolOneFrom;
+ PushButton* m_pIbDbcolAllFrom;
+ FixedText* m_pFtTableCol;
+ ListBox* m_pLbTableCol;
+ CheckBox* m_pCbTableHeadon;
+ RadioButton* m_pRbHeadlColnms;
+ RadioButton* m_pRbHeadlEmpty;
+ PushButton* m_pPbTblFormat;
+ PushButton* m_pPbTblAutofmt;
+
+ SwInsDBColumns aDBColumns;
+ const SwDBData aDBData;
+
+ Link aOldNumFmtLnk;
+ OUString sNoTmpl;
+
+ SwView* pView;
+ SwTableAutoFmt* pTAutoFmt;
+
+ SfxItemSet* pTblSet;
+ SwTableRep* pRep;
+ sal_Int32 nGBFmtLen;
+
+ DECL_LINK( PageHdl, Button* );
+ DECL_LINK( AutoFmtHdl, PushButton* );
+ DECL_LINK( TblFmtHdl, PushButton* );
+ DECL_LINK( DBFormatHdl, Button* );
+ DECL_LINK( TblToFromHdl, Button* );
+ DECL_LINK( SelectHdl, ListBox* );
+ DECL_LINK( DblClickHdl, ListBox* );
+ DECL_LINK( HeaderHdl, Button* );
+
+ bool SplitTextToColArr( const OUString& rTxt, _DB_Columns& rColArr, sal_Bool bInsField );
+ using SfxModalDialog::Notify;
+ virtual void Notify( const ::com::sun::star::uno::Sequence< OUString >& aPropertyNames );
+ virtual void Commit();
+ void Load();
+
+ // set the tables - properties
+ void SetTabSet();
+
+public:
+ SwInsertDBColAutoPilot( SwView& rView,
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource> rxSource,
+ com::sun::star::uno::Reference<com::sun::star::sdbcx::XColumnsSupplier>,
+ const SwDBData& rData );
+
+ virtual ~SwInsertDBColAutoPilot();
+
+ void DataToDoc( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rSelection,
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource> rxSource,
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> xConnection,
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > xResultSet);
+
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/dbtree.hxx b/sw/source/core/uibase/inc/dbtree.hxx
new file mode 100644
index 000000000000..7120cbf25e17
--- /dev/null
+++ b/sw/source/core/uibase/inc/dbtree.hxx
@@ -0,0 +1,72 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_DBTREE_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_DBTREE_HXX
+
+#include <svtools/treelistbox.hxx>
+#include <com/sun/star/uno/Reference.h>
+
+#include "swdllapi.h"
+#include <swtypes.hxx>
+
+class SwDBTreeList_Impl;
+class SwWrtShell;
+
+class SW_DLLPUBLIC SwDBTreeList : public SvTreeListBox
+{
+ ImageList aImageList;
+ Image aDBBMP;
+ Image aTableBMP;
+ Image aQueryBMP;
+
+ OUString sDefDBName;
+ bool bInitialized;
+ sal_Bool bShowColumns;
+
+ SwDBTreeList_Impl* pImpl;
+
+ SAL_DLLPRIVATE DECL_LINK( DBCompare, SvSortData* );
+
+ SAL_DLLPRIVATE void InitTreeList();
+ SAL_DLLPRIVATE virtual void RequestingChildren( SvTreeListEntry* pParent );
+
+ SAL_DLLPRIVATE virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
+ SAL_DLLPRIVATE virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel );
+
+ using SvTreeListBox::Select;
+
+public:
+ SwDBTreeList(Window* pParent, WinBits nStyle);
+ virtual ~SwDBTreeList();
+ virtual Size GetOptimalSize() const;
+
+ OUString GetDBName( OUString& rTableName, OUString& rColumnName, sal_Bool* pbIsTable = 0);
+
+ void Select( const OUString& rDBName, const OUString& rTableName,
+ const OUString& rColumnName );
+
+ void ShowColumns(sal_Bool bShowCol);
+ void SetWrtShell(SwWrtShell& rSh);
+
+ void AddDataSource(const OUString& rSource);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/dbui.hxx b/sw/source/core/uibase/inc/dbui.hxx
new file mode 100644
index 000000000000..7105b2ec0199
--- /dev/null
+++ b/sw/source/core/uibase/inc/dbui.hxx
@@ -0,0 +1,70 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_DBUI_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_DBUI_HXX
+
+#include <svx/stddlg.hxx>
+
+#include <vcl/button.hxx>
+#include <vcl/fixed.hxx>
+
+class SW_DLLPUBLIC PrintMonitor: public ModelessDialog
+{
+public:
+ enum PrintMonitorType
+ {
+ MONITOR_TYPE_PRINT,
+ MONITOR_TYPE_SAVE
+ };
+ FixedText* m_pDocName;
+ FixedText* m_pPrinting;
+ FixedText* m_pPrinter;
+ FixedText* m_pPrintInfo;
+ CancelButton* m_pCancel;
+
+ PrintMonitor( Window *pParent, PrintMonitorType eType );
+};
+
+class CreateMonitor : public ModelessDialog
+{
+public:
+ CreateMonitor( Window *pParent );
+
+ void SetTotalCount( sal_Int32 nTotal );
+ void SetCurrentPosition( sal_Int32 nCurrent );
+
+ void SetCancelHdl( const Link& rLink );
+
+private:
+ void UpdateCountingText();
+
+private:
+ FixedText* m_pCounting;
+ CancelButton* m_pCancelButton;
+
+ OUString m_sCountingPattern;
+ OUString m_sVariable_Total;
+ OUString m_sVariable_Position;
+ sal_Int32 m_nTotalCount;
+ sal_Int32 m_nCurrentPosition;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/dialmgr.hxx b/sw/source/core/uibase/inc/dialmgr.hxx
new file mode 100644
index 000000000000..468b90402f9b
--- /dev/null
+++ b/sw/source/core/uibase/inc/dialmgr.hxx
@@ -0,0 +1,31 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_DIALMGR_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_DIALMGR_HXX
+
+#include <tools/resid.hxx>
+
+struct SwDialogsResMgr
+{
+ static ResMgr* GetResMgr();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/docfnote.hxx b/sw/source/core/uibase/inc/docfnote.hxx
new file mode 100644
index 000000000000..c5289213d2b2
--- /dev/null
+++ b/sw/source/core/uibase/inc/docfnote.hxx
@@ -0,0 +1,44 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_DOCFNOTE_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_DOCFNOTE_HXX
+
+#include <sfx2/tabdlg.hxx>
+
+class SwWrtShell;
+
+class SwFootNoteOptionDlg :public SfxTabDialog
+{
+ SwWrtShell &rSh;
+ Link aOldOkHdl;
+
+ sal_uInt16 m_nFootNoteId;
+ sal_uInt16 m_nEndNoteId;
+
+ virtual void PageCreated( sal_uInt16 nId, SfxTabPage &rPage );
+
+ DECL_LINK( OkHdl, Button * );
+
+public:
+ SwFootNoteOptionDlg(Window *pParent, SwWrtShell &rSh );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/docstdlg.hxx b/sw/source/core/uibase/inc/docstdlg.hxx
new file mode 100644
index 000000000000..60275da16acd
--- /dev/null
+++ b/sw/source/core/uibase/inc/docstdlg.hxx
@@ -0,0 +1,70 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_DOCSTDLG_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_DOCSTDLG_HXX
+
+#include <sfx2/tabdlg.hxx>
+
+#include <vcl/fixed.hxx>
+#include <svtools/stdctrl.hxx>
+
+#include "docstat.hxx"
+
+/*--------------------------------------------------------------------
+ Description: DocInfo now as page
+ --------------------------------------------------------------------*/
+class SwDocStatPage: public SfxTabPage
+{
+public:
+ SwDocStatPage(Window *pParent, const SfxItemSet &rSet);
+ ~SwDocStatPage();
+
+ static SfxTabPage *Create(Window *pParent, const SfxItemSet &rSet);
+
+protected:
+ virtual sal_Bool FillItemSet( SfxItemSet &rSet);
+ virtual void Reset (const SfxItemSet &rSet);
+
+ DECL_LINK(UpdateHdl, void *);
+
+private:
+ FixedText* m_pPageNo;
+ FixedText* m_pTableNo;
+ FixedText* m_pGrfNo;
+ FixedText* m_pOLENo;
+ FixedText* m_pParaNo;
+ FixedText* m_pWordNo;
+ FixedText* m_pCharNo;
+ FixedText* m_pCharExclSpacesNo;
+
+ FixedText* m_pLineLbl;
+ FixedText* m_pLineNo;
+ PushButton* m_pUpdatePB;
+
+ SwDocStat aDocStat;
+
+ void Update();
+
+ using Window::SetData;
+ void SetData(const SwDocStat &rStat);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/drawbase.hxx b/sw/source/core/uibase/inc/drawbase.hxx
new file mode 100644
index 000000000000..98c111dc2a6a
--- /dev/null
+++ b/sw/source/core/uibase/inc/drawbase.hxx
@@ -0,0 +1,79 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_DRAWBASE_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_DRAWBASE_HXX
+
+#include <tools/gen.hxx>
+
+class SwView;
+class SwWrtShell;
+class SwEditWin;
+class KeyEvent;
+class MouseEvent;
+
+/*************************************************************************
+|*
+|* base class for all functions
+|*
+\************************************************************************/
+
+class SwDrawBase
+{
+protected:
+ SwView* m_pView;
+ SwWrtShell* m_pSh;
+ SwEditWin* m_pWin;
+ Point m_aStartPos; // position of BeginCreate
+ Point m_aMDPos; // position of MouseButtonDown
+ sal_uInt16 m_nSlotId;
+ bool m_bCreateObj :1;
+ bool m_bInsForm :1;
+
+ Point GetDefaultCenterPos();
+public:
+ SwDrawBase(SwWrtShell *pSh, SwEditWin* pWin, SwView* pView);
+ virtual ~SwDrawBase();
+
+ void SetDrawPointer();
+ void EnterSelectMode(const MouseEvent& rMEvt);
+ inline bool IsInsertForm() const { return m_bInsForm; }
+ inline bool IsCreateObj() const { return m_bCreateObj; }
+
+ // mouse- & key events; return value=sal_True: event was edited
+ virtual sal_Bool KeyInput(const KeyEvent& rKEvt);
+ virtual sal_Bool MouseMove(const MouseEvent& rMEvt);
+ virtual sal_Bool MouseButtonUp(const MouseEvent& rMEvt);
+ virtual sal_Bool MouseButtonDown(const MouseEvent& rMEvt);
+
+ void BreakCreate();
+ void SetSlotId(sal_uInt16 nSlot) {m_nSlotId = nSlot;}
+ sal_uInt16 GetSlotId() { return m_nSlotId;}
+
+ virtual void Activate(const sal_uInt16 nSlotId); // activate function
+ virtual void Deactivate(); // deactivate function
+
+ virtual void CreateDefaultObject();
+
+ // #i33136#
+ virtual bool doConstructOrthogonal() const;
+};
+
+#endif // INCLUDED_SW_SOURCE_UI_INC_DRAWBASE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/drawsh.hxx b/sw/source/core/uibase/inc/drawsh.hxx
new file mode 100644
index 000000000000..545faf748d7d
--- /dev/null
+++ b/sw/source/core/uibase/inc/drawsh.hxx
@@ -0,0 +1,50 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_DRAWSH_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_DRAWSH_HXX
+
+#include "drwbassh.hxx"
+
+class SwDrawBaseShell;
+
+class SwDrawShell: public SwDrawBaseShell
+{
+public:
+ SFX_DECL_INTERFACE(SW_DRAWSHELL)
+ TYPEINFO();
+
+ SwDrawShell(SwView &rView);
+
+ void Execute(SfxRequest &);
+ void GetState(SfxItemSet &);
+ void ExecDrawDlg(SfxRequest& rReq);
+ void ExecDrawAttrArgs(SfxRequest& rReq);
+ void GetDrawAttrState(SfxItemSet &rSet);
+
+ void ExecFormText(SfxRequest& rReq);
+ void GetFormTextState(SfxItemSet& rSet);
+
+ // #i123922# added helper methods to handle applying graphic data to draw objects
+ SdrObject* IsSingleFillableNonOLESelected();
+ void InsertPictureFromFile(SdrObject& rObject);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/drformsh.hxx b/sw/source/core/uibase/inc/drformsh.hxx
new file mode 100644
index 000000000000..8f58bae51b96
--- /dev/null
+++ b/sw/source/core/uibase/inc/drformsh.hxx
@@ -0,0 +1,41 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_DRFORMSH_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_DRFORMSH_HXX
+
+#include "drwbassh.hxx"
+
+class SwDrawBaseShell;
+
+class SwDrawFormShell: public SwDrawBaseShell
+{
+public:
+ SFX_DECL_INTERFACE(SW_DRAWFORMSHELL)
+ TYPEINFO();
+
+ SwDrawFormShell(SwView &rView);
+ virtual ~SwDrawFormShell();
+
+ void Execute(SfxRequest &);
+ void GetState(SfxItemSet &);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/drpcps.hxx b/sw/source/core/uibase/inc/drpcps.hxx
new file mode 100644
index 000000000000..dd4a37377a4b
--- /dev/null
+++ b/sw/source/core/uibase/inc/drpcps.hxx
@@ -0,0 +1,103 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_DRPCPS_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_DRPCPS_HXX
+
+#include <sfx2/basedlgs.hxx>
+#include <sfx2/tabdlg.hxx>
+
+#include <vcl/button.hxx>
+
+#include <vcl/fixed.hxx>
+
+#include <vcl/field.hxx>
+
+#include <vcl/edit.hxx>
+
+#include <vcl/lstbox.hxx>
+
+class SwWrtShell;
+
+// class SwDropCapsDlg ******************************************************
+
+class SwDropCapsDlg : public SfxSingleTabDialog
+{
+public:
+ SwDropCapsDlg(Window *pParent, const SfxItemSet &rSet );
+};
+
+class SwDropCapsPict;
+
+// class SwDropCapsPage *****************************************************
+
+class SwDropCapsPage : public SfxTabPage
+{
+friend class SwDropCapsPict;
+ CheckBox* m_pDropCapsBox;
+ CheckBox* m_pWholeWordCB;
+ FixedText* m_pSwitchText;
+ NumericField* m_pDropCapsField;
+ FixedText* m_pLinesText;
+ NumericField* m_pLinesField;
+ FixedText* m_pDistanceText;
+ MetricField* m_pDistanceField;
+ FixedText* m_pTextText;
+ Edit* m_pTextEdit;
+ FixedText* m_pTemplateText;
+ ListBox* m_pTemplateBox;
+
+ SwDropCapsPict* m_pPict;
+
+ sal_Bool bModified;
+ sal_Bool bFormat;
+ sal_Bool bHtmlMode;
+
+ SwWrtShell &rSh;
+
+ SwDropCapsPage(Window *pParent, const SfxItemSet &rSet);
+ ~SwDropCapsPage();
+
+ virtual int DeactivatePage(SfxItemSet *pSet);
+ void FillSet( SfxItemSet &rSet );
+
+ DECL_LINK(ClickHdl, void *);
+ DECL_LINK( ModifyHdl, Edit * );
+ DECL_LINK(SelectHdl, void *);
+ DECL_LINK(WholeWordHdl, void *);
+
+ using SfxTabPage::ActivatePage;
+ using SfxTabPage::DeactivatePage;
+
+public:
+
+ static SfxTabPage *Create(Window *pParent, const SfxItemSet &rSet);
+ static sal_uInt16* GetRanges();
+
+ virtual sal_Bool FillItemSet( SfxItemSet &rSet);
+ virtual void Reset (const SfxItemSet &rSet);
+
+ void SetFormat(sal_Bool bSet){bFormat = bSet;}
+protected:
+ void aSwitchText(sal_Bool bChecked);
+ //void SW_RES(int arg1);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/drwbassh.hxx b/sw/source/core/uibase/inc/drwbassh.hxx
new file mode 100644
index 000000000000..7bb62ad9076c
--- /dev/null
+++ b/sw/source/core/uibase/inc/drwbassh.hxx
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_DRWBASSH_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_DRWBASSH_HXX
+#include "basesh.hxx"
+
+class SwView;
+class SfxItemSet;
+class SwDrawBase;
+class AbstractSvxNameDialog;
+struct SvxSwFrameValidation;
+
+class SwDrawBaseShell: public SwBaseShell
+{
+ SwDrawBase* pDrawActual;
+
+ sal_uInt16 eDrawMode;
+
+ DECL_LINK( CheckGroupShapeNameHdl, AbstractSvxNameDialog* );
+ DECL_LINK(ValidatePosition, SvxSwFrameValidation* );
+public:
+ SwDrawBaseShell(SwView &rShell);
+ virtual ~SwDrawBaseShell();
+
+ SFX_DECL_INTERFACE(SW_DRAWBASESHELL)
+ TYPEINFO();
+
+ void Execute(SfxRequest &);
+ void GetState(SfxItemSet &);
+ void GetDrawAttrStateForIFBX( SfxItemSet& rSet );
+ void DisableState(SfxItemSet &rSet) { Disable(rSet);}
+ sal_Bool Disable(SfxItemSet& rSet, sal_uInt16 nWhich = 0);
+
+ void StateStatusline(SfxItemSet &rSet);
+
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/drwtxtsh.hxx b/sw/source/core/uibase/inc/drwtxtsh.hxx
new file mode 100644
index 000000000000..9fbe1b20eee5
--- /dev/null
+++ b/sw/source/core/uibase/inc/drwtxtsh.hxx
@@ -0,0 +1,80 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_DRWTXTSH_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_DRWTXTSH_HXX
+
+#include <sfx2/shell.hxx>
+#include "shellid.hxx"
+#include <unotools/caserotate.hxx>
+
+class SdrView;
+class SwView;
+class SwWrtShell;
+
+class SwDrawTextShell: public SfxShell
+{
+ SwView &rView;
+ RotateTransliteration m_aRotateCase;
+
+ SdrView *pSdrView;
+
+ void SetAttrToMarked(const SfxItemSet& rAttr);
+ void InsertSymbol(SfxRequest& rReq);
+ sal_Bool IsTextEdit();
+public:
+ SFX_DECL_INTERFACE(SW_DRWTXTSHELL)
+ TYPEINFO();
+
+ SwView &GetView() { return rView; }
+ SwWrtShell &GetShell();
+
+ SwDrawTextShell(SwView &rView);
+ virtual ~SwDrawTextShell();
+
+ virtual ::svl::IUndoManager*
+ GetUndoManager();
+
+ void StateDisableItems(SfxItemSet &);
+
+ void Execute(SfxRequest &);
+ void ExecDraw(SfxRequest &);
+ void GetStatePropPanelAttr(SfxItemSet &);
+ void GetState(SfxItemSet &);
+ void GetDrawTxtCtrlState(SfxItemSet&);
+
+ void ExecFontWork(SfxRequest& rReq);
+ void StateFontWork(SfxItemSet& rSet);
+ void ExecFormText(SfxRequest& rReq);
+ void GetFormTextState(SfxItemSet& rSet);
+ void ExecDrawLingu(SfxRequest &rReq);
+ void ExecUndo(SfxRequest &rReq);
+ void StateUndo(SfxItemSet &rSet);
+ void ExecClpbrd(SfxRequest &rReq);
+ void StateClpbrd(SfxItemSet &rSet);
+ void StateInsert(SfxItemSet &rSet);
+ void ExecTransliteration(SfxRequest &);
+ void ExecRotateTransliteration(SfxRequest &);
+
+ void Init();
+ void StateStatusline(SfxItemSet &rSet);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/dselect.hxx b/sw/source/core/uibase/inc/dselect.hxx
new file mode 100644
index 000000000000..d3905bc27e57
--- /dev/null
+++ b/sw/source/core/uibase/inc/dselect.hxx
@@ -0,0 +1,43 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_DSELECT_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_DSELECT_HXX
+
+#include "drawbase.hxx"
+
+/*************************************************************************
+|*
+|* draw rectangle
+|*
+\************************************************************************/
+
+class DrawSelection : public SwDrawBase
+{
+ public:
+ DrawSelection(SwWrtShell* pSh, SwEditWin* pWin, SwView* pView);
+
+ // mouse- & key events
+ virtual sal_Bool KeyInput(const KeyEvent& rKEvt);
+
+ virtual void Activate(const sal_uInt16 nSlotId); // activate function
+};
+
+#endif // INCLUDED_SW_SOURCE_UI_INC_DSELECT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/edtwin.hxx b/sw/source/core/uibase/inc/edtwin.hxx
new file mode 100644
index 000000000000..7b6c807a6223
--- /dev/null
+++ b/sw/source/core/uibase/inc/edtwin.hxx
@@ -0,0 +1,302 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_EDTWIN_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_EDTWIN_HXX
+
+#include <FrameControlsManager.hxx>
+
+#include <svx/svdobj.hxx>
+#include <tools/link.hxx>
+#include <vcl/timer.hxx>
+#include <vcl/window.hxx>
+#include <svtools/transfer.hxx>
+#include <swevent.hxx>
+
+class SwWrtShell;
+class SwView;
+class SwRect;
+class SwViewShell;
+class SwAnchorMarker;
+class SdrObject;
+class SwShadowCursor;
+class DataChangedEvent;
+class SvxAutoCorrCfg;
+class SvxAutoCorrect;
+class SwPaM;
+struct SwApplyTemplate;
+struct QuickHelpData;
+class SdrDropMarkerOverlay;
+
+/*--------------------------------------------------------------------
+ Description: input window
+ --------------------------------------------------------------------*/
+
+/** Window class for the Writer edit area, this is the one handling mouse
+ and keyboard events and doing the final painting of the document from
+ the buffered layout.
+
+ To translate the pixel positions from the buffer OutputDevice to the real
+ pixel positions, use the PixelToLogic methods of this class.
+ */
+class SwEditWin: public Window,
+ public DropTargetHelper, public DragSourceHelper
+{
+friend void ScrollMDI(SwViewShell* pVwSh, const SwRect&,
+ sal_uInt16 nRangeX, sal_uInt16 nRangeY);
+friend sal_Bool IsScrollMDI(SwViewShell* pVwSh, const SwRect&);
+
+friend void SizeNotify(SwViewShell* pVwSh, const Size &);
+
+friend void PageNumNotify( SwViewShell* pVwSh,
+ sal_uInt16 nPhyNum,
+ sal_uInt16 nVirtNum,
+ const OUString& rPg );
+
+ static QuickHelpData* m_pQuickHlpData;
+
+ static long m_nDDStartPosX, m_nDDStartPosY;
+
+ static Color m_aTextColor; // text color; for the watering can
+ static bool m_bTransparentBackColor; // transparent background
+ static Color m_aTextBackColor; // text background; for the watering can
+
+ /*
+ * timer and handler for scrolling on when the mousepointer
+ * stopps outside of EditWin during a drag-operation.
+ * The selection is increased towards the mouse position
+ * regularly.
+ */
+ AutoTimer m_aTimer;
+ // timer for overlapping KeyInputs (e.g. for tables)
+ Timer m_aKeyInputTimer;
+ // timer for ANY-KeyInut question without a following KeyInputEvent
+ Timer m_aKeyInputFlushTimer;
+
+ OUString m_aInBuffer;
+ LanguageType m_eBufferLanguage;
+ Point m_aStartPos;
+ Point m_aMovePos;
+ Point m_aRszMvHdlPt;
+ Timer m_aTemplateTimer;
+
+ // type/object where the mouse pointer is
+ SwCallMouseEvent m_aSaveCallEvent;
+
+ SwApplyTemplate *m_pApplyTempl;
+ SwAnchorMarker *m_pAnchorMarker; // for relocating the anchor
+
+ SdrDropMarkerOverlay *m_pUserMarker;
+ SdrObject *m_pUserMarkerObj;
+ SwShadowCursor *m_pShadCrsr;
+ Point *m_pRowColumnSelectionStart; // save position where table row/column selection has been started
+
+ SwView &m_rView;
+
+ int m_aActHitType; // current mouse pointer
+
+ sal_uLong m_nDropFormat; // format from the last QueryDrop
+ sal_uInt16 m_nDropAction; // action from the last QueryDrop
+ sal_uInt16 m_nDropDestination; // destination from the last QueryDrop
+
+ sal_uInt16 m_eBezierMode;
+ sal_uInt16 m_nInsFrmColCount; // column number for interactive frame
+ SdrObjKind m_eDrawMode;
+ sal_Bool m_bMBPressed : 1,
+ m_bInsDraw : 1,
+ m_bInsFrm : 1,
+ m_bIsInMove : 1,
+ m_bIsInDrag : 1, // don't execute StartExecuteDrag twice
+ m_bOldIdle : 1, // to stop to idle
+ m_bOldIdleSet : 1, // during QeueryDrop
+ m_bTblInsDelMode : 1,
+ m_bTblIsInsMode : 1,
+ m_bChainMode : 1, // connect frames
+ m_bWasShdwCrsr : 1, // ShadowCrsr was on in MouseButtonDown
+ m_bLockInput : 1, // lock while calc panel is active
+ m_bIsRowDrag : 1, //selection of rows is used, in combination with m_pRowColumnSelectionStart
+ /** #i42732# display status of font size/name depending on either the input language or the
+ selection position depending on what has changed lately
+ */
+ m_bUseInputLanguage: 1,
+ m_bObjectSelect : 1;
+
+ sal_uInt16 m_nKS_NUMDOWN_Count; // #i23725#
+ sal_uInt16 m_nKS_NUMINDENTINC_Count;
+
+ SwFrameControlsManager m_aFrameControlsManager;
+
+ void LeaveArea(const Point &);
+ void JustifyAreaTimer();
+ inline void EnterArea();
+
+ void RstMBDownFlags();
+
+ void ChangeFly( sal_uInt8 nDir, sal_Bool bWeb = sal_False );
+ void ChangeDrawing( sal_uInt8 nDir );
+
+ sal_Bool EnterDrawMode(const MouseEvent& rMEvt, const Point& aDocPos);
+ sal_Bool RulerColumnDrag( const MouseEvent& rMEvt, sal_Bool bVerticalMode);
+
+ // helper function for D&D
+ void DropCleanup();
+ void CleanupDropUserMarker();
+ sal_uInt16 GetDropDestination( const Point& rPixPnt,
+ SdrObject ** ppObj = 0 );
+ //select the object/cursor at the mouse position of the context menu request
+ sal_Bool SelectMenuPosition(SwWrtShell& rSh, const Point& rMousePos );
+
+ /*
+ * handler for scrolling on when the mousepointer
+ * stopps outside of EditWin during a drag-operation.
+ * The selection is regularly increased towards the mouse
+ * position.
+ */
+ DECL_LINK( TimerHandler, void * );
+ void StartDDTimer();
+ void StopDDTimer(SwWrtShell *, const Point &);
+ DECL_LINK( DDHandler, void * );
+
+ // timer for ANY-KeyInut question without a following KeyInputEvent
+ DECL_LINK( KeyInputFlushHandler, void * );
+
+ // timer for overlapping KeyInputs (e.g. for tables)
+ DECL_LINK( KeyInputTimerHandler, void * );
+
+ // timer for ApplyTemplates via mouse (in disguise Drag&Drop)
+ DECL_LINK( TemplateTimerHdl, void * );
+
+ using OutputDevice::GetTextColor;
+
+protected:
+
+ virtual void DataChanged( const DataChangedEvent& );
+ virtual void PrePaint();
+ virtual void Paint( const Rectangle& rRect );
+ virtual void KeyInput(const KeyEvent &rKEvt);
+
+ virtual void GetFocus();
+ virtual void LoseFocus();
+
+ virtual void MouseMove(const MouseEvent& rMEvt);
+ virtual void MouseButtonDown(const MouseEvent& rMEvt);
+ virtual void MouseButtonUp(const MouseEvent& rMEvt);
+ virtual void RequestHelp(const HelpEvent& rEvt);
+
+ virtual void Command( const CommandEvent& rCEvt );
+
+ // Drag & Drop Interface
+ virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
+ virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
+ virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel );
+
+ virtual OUString GetSurroundingText() const;
+ virtual Selection GetSurroundingTextSelection() const;
+
+ void ShowAutoTextCorrectQuickHelp( const OUString& rWord, SvxAutoCorrCfg* pACfg,
+ SvxAutoCorrect* pACorr, bool bFromIME = false );
+
+ /// Returns true if in header/footer area, or in the header/footer control.
+ bool IsInHeaderFooter( const Point &rDocPt, FrameControlType &rControl ) const;
+
+ bool IsOverHeaderFooterFly( const Point& rDocPos, FrameControlType& rControl, bool& bOverFly, bool& bPageAnchored ) const;
+public:
+
+ void UpdatePointer(const Point &, sal_uInt16 nButtons = 0);
+
+ sal_Bool IsDrawSelMode();
+ sal_Bool IsDrawAction() { return (m_bInsDraw); }
+ void SetDrawAction(sal_Bool bFlag) { m_bInsDraw = bFlag; }
+
+ void SetObjectSelect( sal_Bool bVal ) { m_bObjectSelect = bVal; }
+ sal_Bool IsObjectSelect() const { return m_bObjectSelect; }
+
+ inline SdrObjKind GetSdrDrawMode(/*sal_Bool bBuf = sal_False*/) const { return m_eDrawMode; }
+ inline void SetSdrDrawMode( SdrObjKind eSdrObjectKind ) { m_eDrawMode = eSdrObjectKind; SetObjectSelect( sal_False ); }
+ void StdDrawMode( SdrObjKind eSdrObjectKind, sal_Bool bObjSelect );
+
+ bool IsFrmAction() const { return (m_bInsFrm); }
+ sal_uInt16 GetBezierMode() const { return m_eBezierMode; }
+ void SetBezierMode(sal_uInt16 eBezMode) { m_eBezierMode = eBezMode; }
+ void EnterDrawTextMode(const Point& aDocPos); // turn on DrawTextEditMode
+ void InsFrm(sal_uInt16 nCols);
+ void StopInsFrm();
+ sal_uInt16 GetFrmColCount() const {return m_nInsFrmColCount;} // column number for interactive frame
+
+ void SetChainMode( sal_Bool bOn );
+ sal_Bool IsChainMode() const { return m_bChainMode; }
+
+ void FlushInBuffer();
+ sal_Bool IsInputSequenceCheckingRequired( const OUString &rText, const SwPaM& rCrsr ) const;
+
+ void SetApplyTemplate(const SwApplyTemplate &);
+ SwApplyTemplate* GetApplyTemplate() const { return m_pApplyTempl; }
+
+ void StartExecuteDrag();
+ void DragFinished();
+ sal_uInt16 GetDropAction() const { return m_nDropAction; }
+ sal_uLong GetDropFormat() const { return m_nDropFormat; }
+
+ Color GetTextColor() { return m_aTextColor; }
+
+ void SetTextColor(const Color& rCol ) { m_aTextColor = rCol; }
+
+ Color GetTextBackColor()
+ { return m_aTextBackColor; }
+ void SetTextBackColor(const Color& rCol )
+ { m_aTextBackColor = rCol; }
+ void SetTextBackColorTransparent(bool bSet)
+ { m_bTransparentBackColor = bSet; }
+ bool IsTextBackColorTransparent()
+ { return m_bTransparentBackColor; }
+ void LockKeyInput(sal_Bool bSet){m_bLockInput = bSet;}
+
+ const SwView &GetView() const { return m_rView; }
+ SwView &GetView() { return m_rView; }
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
+
+ static inline long GetDDStartPosX() { return m_nDDStartPosX; }
+ static inline long GetDDStartPosY() { return m_nDDStartPosY; }
+
+ static void _InitStaticData();
+ static void _FinitStaticData();
+
+ //#i3370# remove quick help to prevent saving of autocorrection suggestions
+ void StopQuickHelp();
+
+ // #i42921# - add parameter <bVerticalMode>
+ sal_Bool RulerMarginDrag( const MouseEvent& rMEvt,
+ const bool bVerticalMode );
+
+ /** #i42732# display status of font size/name depending on either the input
+ language or the selection position depending on what has changed lately
+ */
+ void SetUseInputLanguage( sal_Bool bNew );
+ sal_Bool IsUseInputLanguage() const { return m_bUseInputLanguage; }
+
+ SwFrameControlsManager& GetFrameControlsManager() { return m_aFrameControlsManager; }
+
+ SwEditWin(Window *pParent, SwView &);
+ virtual ~SwEditWin();
+ virtual void SwitchView();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/envimg.hxx b/sw/source/core/uibase/inc/envimg.hxx
new file mode 100644
index 000000000000..9c766e11acea
--- /dev/null
+++ b/sw/source/core/uibase/inc/envimg.hxx
@@ -0,0 +1,91 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_ENVIMG_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_ENVIMG_HXX
+
+#include <svl/poolitem.hxx>
+#include <unotools/configitem.hxx>
+#include "swdllapi.h"
+
+// MakeSender -----------------------------------------------------------------
+SW_DLLPUBLIC OUString MakeSender();
+
+// enum -----------------------------------------------------------------------
+enum SwEnvAlign
+{
+ ENV_HOR_LEFT = 0,
+ ENV_HOR_CNTR,
+ ENV_HOR_RGHT,
+ ENV_VER_LEFT,
+ ENV_VER_CNTR,
+ ENV_VER_RGHT
+};
+
+// class SwEnvItem ------------------------------------------------------------
+class SW_DLLPUBLIC SwEnvItem : public SfxPoolItem
+{
+public:
+
+ OUString aAddrText; // text for receiver
+ sal_Bool bSend; // sender?
+ OUString aSendText; // text for sender
+ sal_Int32 lAddrFromLeft; // left gap for receiver (twips)
+ sal_Int32 lAddrFromTop; // upper gap for receiver (twips)
+ sal_Int32 lSendFromLeft; // left gap for sender (twips)
+ sal_Int32 lSendFromTop; // upper gap for sender (twips)
+ sal_Int32 lWidth; // envelope's width (twips)
+ sal_Int32 lHeight; // envelope's height (twips)
+ SwEnvAlign eAlign; // alignment at indent
+ sal_Bool bPrintFromAbove; // print from above?
+ sal_Int32 lShiftRight; // shift to right (twips)
+ sal_Int32 lShiftDown; // shift down (twips)
+
+ SwEnvItem();
+ SwEnvItem(const SwEnvItem& rItem);
+
+ TYPEINFO();
+
+ SwEnvItem& operator =(const SwEnvItem& rItem);
+
+ virtual bool operator ==(const SfxPoolItem& rItem) const;
+
+ virtual SfxPoolItem* Clone(SfxItemPool* = 0) const;
+ virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const;
+ virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 );
+};
+
+// class SwEnvCfgItem -------------------------------------------------------
+class SwEnvCfgItem : public utl::ConfigItem
+{
+ SwEnvItem aEnvItem;
+
+ com::sun::star::uno::Sequence<OUString> GetPropertyNames();
+public:
+ SwEnvCfgItem();
+ ~SwEnvCfgItem();
+
+ SwEnvItem& GetItem() {return aEnvItem;}
+
+ virtual void Commit();
+ virtual void Notify( const ::com::sun::star::uno::Sequence< OUString >& aPropertyNames );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/envlop.hxx b/sw/source/core/uibase/inc/envlop.hxx
new file mode 100644
index 000000000000..b7b7906ec79e
--- /dev/null
+++ b/sw/source/core/uibase/inc/envlop.hxx
@@ -0,0 +1,122 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_ENVLOP_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_ENVLOP_HXX
+
+#include <svtools/svmedit.hxx>
+#include <sfx2/tabdlg.hxx>
+
+#include <vcl/fixed.hxx>
+
+#include <vcl/edit.hxx>
+
+#include <vcl/lstbox.hxx>
+
+#include <vcl/button.hxx>
+
+#include "envimg.hxx"
+
+#define GetFldVal(rField) (rField).Denormalize((rField).GetValue(FUNIT_TWIP))
+#define SetFldVal(rField, lValue) (rField).SetValue((rField).Normalize(lValue), FUNIT_TWIP)
+
+class SwEnvPage;
+class SwEnvFmtPage;
+class SwWrtShell;
+class Printer;
+
+// class SwEnvPreview ---------------------------------------------------------
+class SwEnvPreview : public Window
+{
+ void Paint(const Rectangle&);
+
+public:
+
+ SwEnvPreview(Window * pParent, WinBits nStyle);
+
+protected:
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+ virtual Size GetOptimalSize() const;
+};
+
+// class SwEnvDlg -----------------------------------------------------------
+class SwEnvDlg : public SfxTabDialog
+{
+friend class SwEnvPage;
+friend class SwEnvFmtPage;
+friend class SwEnvPrtPage;
+friend class SwEnvPreview;
+
+ SwEnvItem aEnvItem;
+ SwWrtShell *pSh;
+ Printer *pPrinter;
+ SfxItemSet *pAddresseeSet;
+ SfxItemSet *pSenderSet;
+ sal_uInt16 m_nEnvPrintId;
+
+ virtual void PageCreated( sal_uInt16 nId, SfxTabPage &rPage );
+ virtual short Ok();
+
+public:
+ SwEnvDlg(Window* pParent, const SfxItemSet& rSet, SwWrtShell* pWrtSh, Printer* pPrt, sal_Bool bInsert);
+ ~SwEnvDlg();
+};
+
+// class SwEnvPage ----------------------------------------------------------
+class SwEnvPage : public SfxTabPage
+{
+ VclMultiLineEdit* m_pAddrEdit;
+ ListBox* m_pDatabaseLB;
+ ListBox* m_pTableLB;
+ ListBox* m_pDBFieldLB;
+ PushButton* m_pInsertBT;
+ CheckBox* m_pSenderBox;
+ VclMultiLineEdit* m_pSenderEdit;
+ SwEnvPreview* m_pPreview;
+
+ SwWrtShell* pSh;
+ OUString sActDBName;
+
+ SwEnvPage(Window* pParent, const SfxItemSet& rSet);
+ ~SwEnvPage();
+
+ DECL_LINK( DatabaseHdl, ListBox * );
+ DECL_LINK(FieldHdl, void *);
+ DECL_LINK(SenderHdl, void *);
+
+ void InitDatabaseBox();
+
+ SwEnvDlg* GetParentSwEnvDlg() {return (SwEnvDlg*)GetParentDialog();}
+
+ using SfxTabPage::ActivatePage;
+ using SfxTabPage::DeactivatePage;
+
+public:
+
+ static SfxTabPage* Create(Window* pParent, const SfxItemSet& rSet);
+
+ virtual void ActivatePage(const SfxItemSet& rSet);
+ virtual int DeactivatePage(SfxItemSet* pSet = 0);
+ void FillItem(SwEnvItem& rItem);
+ virtual sal_Bool FillItemSet(SfxItemSet& rSet);
+ virtual void Reset(const SfxItemSet& rSet);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/fldedt.hxx b/sw/source/core/uibase/inc/fldedt.hxx
new file mode 100644
index 000000000000..89312e6421ee
--- /dev/null
+++ b/sw/source/core/uibase/inc/fldedt.hxx
@@ -0,0 +1,55 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_FLDEDT_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_FLDEDT_HXX
+#include <sfx2/basedlgs.hxx>
+#include <vcl/button.hxx>
+
+class SwView;
+class SwWrtShell;
+
+class SwFldEditDlg : public SfxSingleTabDialog
+{
+ SwWrtShell* pSh;
+ PushButton* m_pPrevBT;
+ PushButton* m_pNextBT;
+ PushButton* m_pAddressBT;
+
+ DECL_LINK(AddressHdl, void *);
+ DECL_LINK(NextPrevHdl, Button *pBt = 0);
+
+ void Init();
+ SfxTabPage* CreatePage(sal_uInt16 nGroup);
+
+public:
+
+ SwFldEditDlg(SwView& rVw);
+ ~SwFldEditDlg();
+
+ DECL_LINK(OKHdl, void *);
+
+ virtual short Execute();
+
+ void EnableInsert(sal_Bool bEnable);
+ void InsertHdl();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/fldmgr.hxx b/sw/source/core/uibase/inc/fldmgr.hxx
new file mode 100644
index 000000000000..62c4210cae3a
--- /dev/null
+++ b/sw/source/core/uibase/inc/fldmgr.hxx
@@ -0,0 +1,217 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_FLDMGR_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_FLDMGR_HXX
+
+#include "swdllapi.h"
+#include "swtypes.hxx"
+#include <com/sun/star/uno/Reference.h>
+#include <com/sun/star/uno/Any.h>
+#include <vector>
+
+namespace com{namespace sun{namespace star{
+ namespace container{
+ class XNameAccess;
+ }
+ namespace text{
+ class XNumberingTypeInfo;
+ }
+}}}
+
+class SwWrtShell;
+class SwField;
+class SwFieldType;
+class SwPaM;
+class SbModule;
+class SvxMacroItem;
+class SvNumberFormatter;
+class Window;
+
+/*--------------------------------------------------------------------
+ Description: the groups of fields
+ --------------------------------------------------------------------*/
+enum SwFldGroups
+{
+ GRP_DOC,
+ GRP_FKT,
+ GRP_REF,
+ GRP_REG,
+ GRP_DB,
+ GRP_VAR
+};
+
+struct SwFldGroupRgn
+{
+ sal_uInt16 nStart;
+ sal_uInt16 nEnd;
+};
+
+/*--------------------------------------------------------------------
+ Description: the field manager handles the insertation of fields
+ with command strings
+ --------------------------------------------------------------------*/
+struct SwInsertFld_Data
+{
+ sal_uInt16 nTypeId;
+ sal_uInt16 nSubType;
+ const OUString sPar1;
+ const OUString sPar2;
+ sal_uLong nFormatId;
+ SwWrtShell* pSh;
+ sal_Unicode cSeparator;
+ sal_Bool bIsAutomaticLanguage;
+ ::com::sun::star::uno::Any aDBDataSource;
+ ::com::sun::star::uno::Any aDBConnection;
+ ::com::sun::star::uno::Any aDBColumn;
+ Window* pParent; // parent dialog used for SwWrtShell::StartInputFldDlg()
+
+ SwInsertFld_Data(sal_uInt16 nType, sal_uInt16 nSub, const OUString& rPar1, const OUString& rPar2,
+ sal_uLong nFmtId, SwWrtShell* pShell = NULL, sal_Unicode cSep = ' ', sal_Bool bIsAutoLanguage = sal_True) :
+ nTypeId(nType),
+ nSubType(nSub),
+ sPar1(rPar1),
+ sPar2(rPar2),
+ nFormatId(nFmtId),
+ pSh(pShell),
+ cSeparator(cSep),
+ bIsAutomaticLanguage(bIsAutoLanguage),
+ pParent(0) {}
+
+ SwInsertFld_Data() :
+ pSh(0),
+ cSeparator(' '),
+ bIsAutomaticLanguage(sal_True){}
+
+};
+
+class SW_DLLPUBLIC SwFldMgr
+{
+private:
+ SwField* pCurFld;
+ SbModule* pModule;
+ const SvxMacroItem* pMacroItem;
+ SwWrtShell* pWrtShell; // can be ZERO too!
+ OUString aCurPar1;
+ OUString aCurPar2;
+ OUString sCurFrame;
+
+ OUString sMacroPath;
+ OUString sMacroName;
+
+ sal_uLong nCurFmt;
+ sal_Bool bEvalExp;
+
+ SAL_DLLPRIVATE sal_uInt16 GetCurrLanguage() const;
+
+ com::sun::star::uno::Reference<com::sun::star::container::XNameAccess> xDBContext;
+ com::sun::star::uno::Reference<com::sun::star::text::XNumberingTypeInfo> xNumberingInfo;
+ SAL_DLLPRIVATE com::sun::star::uno::Reference<com::sun::star::text::XNumberingTypeInfo> GetNumberingInfo()const;
+
+public:
+ SwFldMgr(SwWrtShell* pSh = 0);
+ ~SwFldMgr();
+
+ void SetWrtShell( SwWrtShell* pShell )
+ { pWrtShell = pShell; }
+
+ // insert field using TypeID (TYP_ ...)
+ sal_Bool InsertFld( const SwInsertFld_Data& rData );
+
+ // change the current field directly
+ void UpdateCurFld(sal_uLong nFormat,
+ const OUString& rPar1,
+ const OUString& rPar2,
+ SwField * _pField = 0); // #111840#
+
+ OUString GetCurFldPar1() const { return aCurPar1; }
+ OUString GetCurFldPar2() const { return aCurPar2; }
+ inline sal_uLong GetCurFldFmt() const;
+
+ // determine a field
+ SwField* GetCurFld();
+
+ void InsertFldType(SwFieldType& rType);
+
+ sal_Bool ChooseMacro(const OUString &rSelMacro = OUString());
+ void SetMacroPath(const OUString& rPath);
+ inline OUString GetMacroPath() const { return sMacroPath; }
+ inline OUString GetMacroName() const { return sMacroName; }
+ inline void SetMacroModule(SbModule* pMod) { pModule = pMod; }
+
+ // previous and next of the same type
+ sal_Bool GoNextPrev( sal_Bool bNext = sal_True, SwFieldType* pTyp = 0 );
+ sal_Bool GoNext( SwFieldType* pTyp = 0 ) { return GoNextPrev( sal_True, pTyp ); }
+ sal_Bool GoPrev( SwFieldType* pTyp = 0 ) { return GoNextPrev( sal_False, pTyp ); }
+
+ // query values from database fields (BASIC )
+// String GetDataBaseFieldValue(const String &rDBName, const String &rFieldName, SwWrtShell* pSh);
+ sal_Bool IsDBNumeric(const OUString& rDBName, const OUString& rTblQryName,
+ sal_Bool bIsTable, const OUString& rFldName);
+
+ // organise RefMark with names
+ bool CanInsertRefMark( const OUString& rStr );
+
+ // access to field types via ResId
+ sal_uInt16 GetFldTypeCount(sal_uInt16 nResId = USHRT_MAX) const;
+ SwFieldType* GetFldType(sal_uInt16 nResId, sal_uInt16 nId = 0) const;
+ SwFieldType* GetFldType(sal_uInt16 nResId, const OUString& rName) const;
+
+ void RemoveFldType(sal_uInt16 nResId, const OUString& rName);
+
+ // access via TypeId from the dialog
+ // Ids for a range of fields
+ const SwFldGroupRgn& GetGroupRange(sal_Bool bHtmlMode, sal_uInt16 nGrpId) const;
+ sal_uInt16 GetGroup(sal_Bool bHtmlMode, sal_uInt16 nTypeId, sal_uInt16 nSubType = 0) const;
+
+ // the current field's TypeId
+ sal_uInt16 GetCurTypeId() const;
+
+ // TypeId for a concrete position in the list
+ static sal_uInt16 GetTypeId(sal_uInt16 nPos);
+ // name of the type in the list of fields
+ static OUString GetTypeStr(sal_uInt16 nPos);
+
+ // Pos in the list of fields
+ static sal_uInt16 GetPos(sal_uInt16 nTypeId);
+
+ // subtypes to a type
+ bool GetSubTypes(sal_uInt16 nId, std::vector<OUString>& rToFill);
+
+ // format to a type
+ sal_uInt16 GetFormatCount(sal_uInt16 nTypeId, bool bIsText, sal_Bool bHtmlMode = sal_False) const;
+ OUString GetFormatStr(sal_uInt16 nTypeId, sal_uLong nFormatId) const;
+ sal_uInt16 GetFormatId(sal_uInt16 nTypeId, sal_uLong nFormatId) const;
+ sal_uLong GetDefaultFormat(sal_uInt16 nTypeId, bool bIsText, SvNumberFormatter* pFormatter, double* pVal = 0L);
+
+ // turn off evaluation of expression fields for insertation
+ // of many expressino fields (see labels)
+
+ inline void SetEvalExpFlds(sal_Bool bEval);
+ void EvalExpFlds(SwWrtShell* pSh = NULL);
+};
+
+inline void SwFldMgr::SetEvalExpFlds(sal_Bool bEval)
+ { bEvalExp = bEval; }
+
+inline sal_uLong SwFldMgr::GetCurFldFmt() const
+ { return nCurFmt; }
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/fldtdlg.hxx b/sw/source/core/uibase/inc/fldtdlg.hxx
new file mode 100644
index 000000000000..4835a4afb054
--- /dev/null
+++ b/sw/source/core/uibase/inc/fldtdlg.hxx
@@ -0,0 +1,66 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_FLDTDLG_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_FLDTDLG_HXX
+#include <sfx2/tabdlg.hxx>
+
+class SfxBindings;
+class SfxTabPage;
+class SwChildWinWrapper;
+struct SfxChildWinInfo;
+
+class SwFldDlg: public SfxTabDialog
+{
+ SwChildWinWrapper* m_pChildWin;
+ SfxBindings* m_pBindings;
+ sal_Bool m_bHtmlMode;
+ sal_Bool m_bDataBaseMode;
+ sal_uInt16 m_nDokId;
+ sal_uInt16 m_nVarId;
+ sal_uInt16 m_nDokInf;
+ sal_uInt16 m_nRefId;
+ sal_uInt16 m_nFuncId;
+ sal_uInt16 m_nDbId;
+
+ virtual bool Close();
+ virtual SfxItemSet* CreateInputItemSet( sal_uInt16 nId );
+ virtual void Activate();
+ virtual void PageCreated(sal_uInt16 nId, SfxTabPage& rPage);
+
+ void ReInitTabPage( sal_uInt16 nPageId,
+ sal_Bool bOnlyActivate = sal_False );
+
+public:
+ SwFldDlg(SfxBindings* pB, SwChildWinWrapper* pCW, Window *pParent);
+ virtual ~SwFldDlg();
+
+ DECL_LINK(OKHdl, void *);
+ DECL_LINK(CancelHdl, void *);
+
+ void Initialize(SfxChildWinInfo *pInfo);
+ void ReInitDlg();
+ void EnableInsert(sal_Bool bEnable);
+ void InsertHdl();
+ void ActivateDatabasePage();
+ void ShowReferencePage();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/fldwrap.hxx b/sw/source/core/uibase/inc/fldwrap.hxx
new file mode 100644
index 000000000000..4a92fcf9c66d
--- /dev/null
+++ b/sw/source/core/uibase/inc/fldwrap.hxx
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_FLDWRAP_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_FLDWRAP_HXX
+
+#include "chldwrap.hxx"
+class AbstractSwFldDlg;
+
+class SwFldDlgWrapper : public SwChildWinWrapper
+{
+public:
+ AbstractSwFldDlg * pDlgInterface;
+ SwFldDlgWrapper( Window* pParent, sal_uInt16 nId,
+ SfxBindings* pBindings, SfxChildWinInfo* pInfo );
+
+ SFX_DECL_CHILDWINDOW_WITHID(SwFldDlgWrapper);
+
+ virtual sal_Bool ReInitDlg(SwDocShell *pDocSh);
+ void ShowReferencePage();
+};
+
+/* --------------------------------------------------
+ * field dialog only showing database page to support
+ * mail merge
+ * --------------------------------------------------*/
+class SwFldDataOnlyDlgWrapper : public SwChildWinWrapper
+{
+public:
+ AbstractSwFldDlg * pDlgInterface;
+ SwFldDataOnlyDlgWrapper( Window* pParent, sal_uInt16 nId,
+ SfxBindings* pBindings, SfxChildWinInfo* pInfo );
+
+ SFX_DECL_CHILDWINDOW(SwFldDataOnlyDlgWrapper);
+
+ virtual sal_Bool ReInitDlg(SwDocShell *pDocSh);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/fontcfg.hxx b/sw/source/core/uibase/inc/fontcfg.hxx
new file mode 100644
index 000000000000..49f536e8f48e
--- /dev/null
+++ b/sw/source/core/uibase/inc/fontcfg.hxx
@@ -0,0 +1,112 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_FONTCFG_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_FONTCFG_HXX
+
+#include <rtl/ustring.hxx>
+#include <unotools/configitem.hxx>
+#include <i18nlangtag/lang.h>
+#include <osl/diagnose.h>
+#include "swdllapi.h"
+
+#define FONT_STANDARD 0
+#define FONT_OUTLINE 1
+#define FONT_LIST 2
+#define FONT_CAPTION 3
+#define FONT_INDEX 4
+#define FONT_STANDARD_CJK 5
+#define FONT_OUTLINE_CJK 6
+#define FONT_LIST_CJK 7
+#define FONT_CAPTION_CJK 8
+#define FONT_INDEX_CJK 9
+#define FONT_STANDARD_CTL 10
+#define FONT_OUTLINE_CTL 11
+#define FONT_LIST_CTL 12
+#define FONT_CAPTION_CTL 13
+#define FONT_INDEX_CTL 14
+#define DEF_FONT_COUNT 15
+
+#define FONT_PER_GROUP 5
+
+#define FONT_GROUP_DEFAULT 0
+#define FONT_GROUP_CJK 1
+#define FONT_GROUP_CTL 2
+
+//pt-size of fonts
+#define FONTSIZE_DEFAULT 240
+#define FONTSIZE_CJK_DEFAULT 210
+#define FONTSIZE_OUTLINE 280
+
+class SW_DLLPUBLIC SwStdFontConfig : public utl::ConfigItem
+{
+ OUString sDefaultFonts[DEF_FONT_COUNT];
+ sal_Int32 nDefaultFontHeight[DEF_FONT_COUNT];
+
+ SAL_DLLPRIVATE com::sun::star::uno::Sequence<OUString> GetPropertyNames();
+
+ void ChangeString(sal_uInt16 nFontType, const OUString& rSet)
+ {
+ if(sDefaultFonts[nFontType] != rSet)
+ {
+ SetModified();
+ sDefaultFonts[nFontType] = rSet;
+ }
+ }
+
+ void ChangeInt( sal_uInt16 nFontType, sal_Int32 nHeight );
+
+public:
+ SwStdFontConfig();
+ ~SwStdFontConfig();
+
+ virtual void Commit();
+ virtual void Notify( const ::com::sun::star::uno::Sequence< OUString >& aPropertyNames );
+
+ const OUString& GetFontStandard(sal_uInt8 nFontGroup) const {return sDefaultFonts[FONT_STANDARD + FONT_PER_GROUP * nFontGroup];}
+ const OUString& GetFontOutline(sal_uInt8 nFontGroup) const {return sDefaultFonts[FONT_OUTLINE + FONT_PER_GROUP * nFontGroup];}
+ const OUString& GetFontList (sal_uInt8 nFontGroup) const {return sDefaultFonts[FONT_LIST + FONT_PER_GROUP * nFontGroup];}
+ const OUString& GetFontCaption(sal_uInt8 nFontGroup) const {return sDefaultFonts[FONT_CAPTION + FONT_PER_GROUP * nFontGroup];}
+ const OUString& GetFontIndex (sal_uInt8 nFontGroup) const {return sDefaultFonts[FONT_INDEX + FONT_PER_GROUP * nFontGroup];}
+
+ const OUString& GetFontFor(sal_uInt16 nFontType) const {return sDefaultFonts[nFontType];}
+ bool IsFontDefault(sal_uInt16 nFontType) const;
+
+ void SetFontStandard(const OUString& rSet, sal_uInt8 nFontGroup)
+ {ChangeString(FONT_STANDARD + FONT_PER_GROUP * nFontGroup, rSet);}
+
+ void SetFontOutline(const OUString& rSet, sal_uInt8 nFontGroup)
+ { ChangeString(FONT_OUTLINE + FONT_PER_GROUP * nFontGroup, rSet);}
+ void SetFontList (const OUString& rSet, sal_uInt8 nFontGroup)
+ { ChangeString(FONT_LIST + FONT_PER_GROUP * nFontGroup, rSet);}
+ void SetFontCaption(const OUString& rSet, sal_uInt8 nFontGroup)
+ { ChangeString(FONT_CAPTION + FONT_PER_GROUP * nFontGroup, rSet);}
+ void SetFontIndex (const OUString& rSet, sal_uInt8 nFontGroup)
+ { ChangeString(FONT_INDEX + FONT_PER_GROUP * nFontGroup, rSet);}
+
+ void SetFontHeight( sal_Int32 nHeight, sal_uInt8 nFont, sal_uInt8 nScriptType )
+ { ChangeInt(nFont + FONT_PER_GROUP * nScriptType, nHeight);}
+
+ sal_Int32 GetFontHeight( sal_uInt8 nFont, sal_uInt8 nScriptType, LanguageType eLang );
+
+ static OUString GetDefaultFor(sal_uInt16 nFontType, LanguageType eLang);
+ static sal_Int32 GetDefaultHeightFor(sal_uInt16 nFontType, LanguageType eLang);
+};
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/formatclipboard.hxx b/sw/source/core/uibase/inc/formatclipboard.hxx
new file mode 100644
index 000000000000..9d9335a32147
--- /dev/null
+++ b/sw/source/core/uibase/inc/formatclipboard.hxx
@@ -0,0 +1,95 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SW_SOURCE_UI_INC_FORMATCLIPBOARD_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_FORMATCLIPBOARD_HXX
+
+// header for class SwWrtShell
+#include <wrtsh.hxx>
+// header for class SfxItemSet
+#include <svl/itemset.hxx>
+// header for class SfxStyleSheetBasePool
+#include <svl/style.hxx>
+
+/** This class acts as data container and execution class for the format paintbrush feature in writer.
+*/
+
+class SwFormatClipboard
+{
+public:
+ SwFormatClipboard();
+ ~SwFormatClipboard();
+
+ /**
+ * Test if the object contains text or paragraph attribute
+ */
+ bool HasContent() const;
+ bool HasContentForThisType( int nSelectionType ) const;
+ bool CanCopyThisType( int nSelectionType ) const;
+
+ /**
+ * Store/Backup the text and paragraph attribute of the current selection.
+ *
+ * @param bPersistentCopy
+ * input parameter - specify if the Paste function will erase the current object.
+ */
+ void Copy( SwWrtShell& rWrtShell, SfxItemPool& rPool, bool bPersistentCopy=false );
+
+ /**
+ * Paste the stored text and paragraph attributes on the current selection and current paragraph.
+ *
+ * @param bNoCharacterFormats
+ * Do not paste the character formats.
+ *
+ * @param bNoParagraphFormats
+ * Do not paste the paragraph formats.
+ */
+ void Paste( SwWrtShell& rWrtShell, SfxStyleSheetBasePool* pPool
+ , bool bNoCharacterFormats=false, bool bNoParagraphFormats=false );
+
+ /**
+ * Clear the currently stored text and paragraph attributes.
+ */
+ void Erase();
+
+private:
+ int m_nSelectionType;
+
+ /** automatic/named character attribute set */
+ SfxItemSet* m_pItemSet_TxtAttr;
+ /** automatic/named paragraph attribute set
+ * (it can be caractere attribute applyied to the paragraph) */
+ SfxItemSet* m_pItemSet_ParAttr;
+
+ /** table attribute set */
+ SfxItemSet* m_pTableItemSet;
+
+ /** name of the character format (if it exist) */
+ OUString m_aCharStyle;
+ /** name of the paragraph format (if it exist) */
+ OUString m_aParaStyle;
+ //no frame style because it contains position information
+
+ /** specify if the Paste function have to clear the current object */
+ bool m_bPersistentCopy;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/formedt.hxx b/sw/source/core/uibase/inc/formedt.hxx
new file mode 100644
index 000000000000..eb0cdb05f323
--- /dev/null
+++ b/sw/source/core/uibase/inc/formedt.hxx
@@ -0,0 +1,92 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_FORMEDT_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_FORMEDT_HXX
+
+#include <svx/stddlg.hxx>
+
+#include <vcl/lstbox.hxx>
+
+#include <vcl/button.hxx>
+
+#include <vcl/fixed.hxx>
+
+#include <vcl/edit.hxx>
+
+#include "toxe.hxx"
+
+class SwWrtShell;
+class SwForm;
+
+/*--------------------------------------------------------------------
+ Description: insert marker for index entry
+ --------------------------------------------------------------------*/
+class SwIdxFormDlg : public SvxStandardDialog
+{
+ DECL_LINK( EntryHdl, Button * );
+ DECL_LINK( PageHdl, Button * );
+ DECL_LINK( TabHdl, Button * );
+ DECL_LINK( JumpHdl, Button * );
+ DECL_LINK( StdHdl, Button * );
+ DECL_LINK( SelectHdl, ListBox * );
+ DECL_LINK( EnableSelectHdl, ListBox * );
+ DECL_LINK( DoubleClickHdl, Button * );
+ DECL_LINK( ModifyHdl, Edit * );
+ DECL_LINK( AssignHdl, Button * );
+ void UpdatePattern();
+ void Apply();
+
+ ListBox aEntryLB;
+ OKButton aOKBtn;
+ CancelButton aCancelBT;
+ FixedText aLevelFT;
+ Edit aEntryED;
+ PushButton aEntryBT;
+ PushButton aTabBT;
+ PushButton aPageBT;
+ PushButton aJumpBT;
+ FixedLine aEntryFL;
+ FixedText aLevelFT2;
+ ListBox aLevelLB;
+ FixedText aTemplateFT;
+ ListBox aParaLayLB;
+ PushButton aStdBT;
+ PushButton aAssignBT;
+ FixedLine aFormatFL;
+
+ SwWrtShell &rSh;
+ SwForm *pForm;
+ sal_uInt16 nAktLevel;
+ sal_Bool bLastLinkIsEnd;
+
+public:
+ SwIdxFormDlg( Window* pParent, SwWrtShell &rShell, const SwForm& rForm );
+ ~SwIdxFormDlg();
+
+ const SwForm& GetTOXForm();
+};
+
+inline const SwForm& SwIdxFormDlg::GetTOXForm()
+{
+ return *pForm;
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/frmdlg.hxx b/sw/source/core/uibase/inc/frmdlg.hxx
new file mode 100644
index 000000000000..6a985691da16
--- /dev/null
+++ b/sw/source/core/uibase/inc/frmdlg.hxx
@@ -0,0 +1,68 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SW_SOURCE_UI_INC_FRMDLG_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_FRMDLG_HXX
+
+#include "globals.hrc"
+#include <sfx2/tabdlg.hxx>
+class SwWrtShell;
+
+/*--------------------------------------------------------------------
+ Description: frame dialog
+ --------------------------------------------------------------------*/
+class SwFrmDlg : public SfxTabDialog
+{
+ bool m_bFormat;
+ bool m_bNew;
+ bool m_bHTMLMode;
+ const SfxItemSet& m_rSet;
+ OString m_sDlgType;
+ SwWrtShell* m_pWrtShell;
+
+ sal_uInt16 m_nStdId;
+ sal_uInt16 m_nAddId;
+ sal_uInt16 m_nWrapId;
+ sal_uInt16 m_nUrlId;
+ sal_uInt16 m_nPictureId;
+ sal_uInt16 m_nCropId;
+ sal_uInt16 m_nColumnId;
+ sal_uInt16 m_nBackgroundId;
+ sal_uInt16 m_nMacroId;
+ sal_uInt16 m_nBorderId;
+
+ virtual void PageCreated( sal_uInt16 nId, SfxTabPage &rPage );
+
+public:
+ SwFrmDlg( SfxViewFrame *pFrame, Window *pParent,
+ const SfxItemSet& rCoreSet,
+ bool bNewFrm = false,
+ OString sResType = OString("FrameDialog"),
+ bool bFmt = false,
+ OString sDefPage = OString(),
+ const OUString* pFmtStr = 0);
+
+ ~SwFrmDlg();
+
+ SwWrtShell* GetWrtShell() { return m_pWrtShell; }
+};
+
+#endif // INCLUDED_SW_SOURCE_UI_INC_FRMDLG_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/frmmgr.hxx b/sw/source/core/uibase/inc/frmmgr.hxx
new file mode 100644
index 000000000000..8ff94053f2eb
--- /dev/null
+++ b/sw/source/core/uibase/inc/frmmgr.hxx
@@ -0,0 +1,188 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_FRMMGR_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_FRMMGR_HXX
+
+#include "swtypes.hxx"
+#include "frmatr.hxx"
+#include <editeng/svxenum.hxx>
+#include <tools/gen.hxx>
+#include <fmtfsize.hxx>
+#include <fmtsrnd.hxx>
+#include <fmtornt.hxx>
+#include <fmtanchr.hxx>
+#include "swdllapi.h"
+
+class SwWrtShell;
+struct SvxSwFrameValidation;
+struct SwPosition;
+
+class SwFmtCol;
+
+const SwTwips DFLT_WIDTH = MM50 * 4;
+const SwTwips DFLT_HEIGHT = MM50;
+
+#define FULL_ATTRSET 0xffff
+
+#define FRMMGR_TYPE_NONE 0x00
+#define FRMMGR_TYPE_TEXT 0x01
+#define FRMMGR_TYPE_GRF 0x02
+#define FRMMGR_TYPE_OLE 0x04
+#define FRMMGR_TYPE_LABEL 0x08
+#define FRMMGR_TYPE_ENVELP 0x10
+
+class SW_DLLPUBLIC SwFlyFrmAttrMgr
+{
+ SfxItemSet m_aSet;
+ Point m_aAbsPos;
+ SwWrtShell* m_pOwnSh;
+
+ sal_Bool m_bAbsPos,
+ m_bNewFrm;
+ sal_Bool m_bIsInVertical;
+ // --> OD 2009-09-01 #mongolianlayout#
+ sal_Bool m_bIsInVerticalL2R;
+
+ // internal calculation for borders
+ SAL_DLLPRIVATE SwTwips CalcTopSpace();
+ SAL_DLLPRIVATE SwTwips CalcBottomSpace();
+ SAL_DLLPRIVATE SwTwips CalcLeftSpace();
+ SAL_DLLPRIVATE SwTwips CalcRightSpace();
+
+ SAL_DLLPRIVATE void _UpdateFlyFrm(); // post-treatment after insert or update
+
+public:
+ SwFlyFrmAttrMgr( sal_Bool bNew, SwWrtShell* pSh, sal_uInt8 nType );
+
+ //CopyCtor for dialogs to check the metrics
+ SwFlyFrmAttrMgr( sal_Bool bNew, SwWrtShell *pSh, const SfxItemSet &rSet );
+
+ inline SwWrtShell* GetShell() { return m_pOwnSh; }
+
+ void SetAnchor(RndStdIds eId);
+ inline RndStdIds GetAnchor() const;
+
+ void SetHorzOrientation(sal_Int16 eOrient);
+ void SetVertOrientation(sal_Int16 eOrient);
+
+ // absolute position
+ void SetAbsPos(const Point& rLPoint);
+
+ // anchor's relative position
+ void SetPos(const Point& rLPoint);
+ inline Point GetPos() const;
+
+ // size
+ void SetSize(const Size& rLSize);
+ inline const Size& GetSize() const;
+
+ inline sal_uInt16 GetHeightPercent() const;
+
+ void SetHeightSizeType(SwFrmSize eType);
+
+ // space to content
+ void SetLRSpace( long nLeft = LONG_MAX,
+ long nRight = LONG_MAX );
+ void SetULSpace( long nTop = LONG_MAX,
+ long nBottom= LONG_MAX );
+
+ void SetCol( const SwFmtCol &rCol);
+
+ // change and query attributes
+ void UpdateAttrMgr();
+ void UpdateFlyFrm();
+
+ // create new frame
+ sal_Bool InsertFlyFrm();
+ void InsertFlyFrm(RndStdIds eAnchorType,
+ const Point &rPos,
+ const Size &rSize,
+ sal_Bool bAbsPos = sal_False);
+
+ // check and change metrics
+ void ValidateMetrics(SvxSwFrameValidation& rVal,
+ const SwPosition* pToCharCntntPos,
+ bool bOnlyPercentRefValue = false);
+
+ void DelAttr(sal_uInt16 nId);
+
+ // reach out the set
+ inline const SfxItemSet &GetAttrSet() const { return m_aSet; }
+ inline SfxItemSet &GetAttrSet() { return m_aSet; }
+ void SetAttrSet(const SfxItemSet& rSet);
+
+ inline const SwFmtVertOrient &GetVertOrient() const;
+ inline const SwFmtHoriOrient &GetHoriOrient() const;
+ inline const SvxShadowItem &GetShadow() const;
+ inline const SvxBoxItem &GetBox() const;
+ inline const SwFmtSurround &GetSurround() const;
+ inline const SwFmtFrmSize &GetFrmSize() const;
+
+ long CalcWidthBorder() { return CalcLeftSpace()+CalcRightSpace(); }
+ long CalcHeightBorder() { return CalcTopSpace()+CalcBottomSpace(); }
+};
+
+inline const Size& SwFlyFrmAttrMgr::GetSize() const
+{
+ return ((SwFmtFrmSize&)m_aSet.Get(RES_FRM_SIZE)).GetSize();
+}
+
+inline const SwFmtVertOrient &SwFlyFrmAttrMgr::GetVertOrient() const
+{
+ return ((SwFmtVertOrient&)m_aSet.Get(RES_VERT_ORIENT));
+}
+inline const SwFmtHoriOrient &SwFlyFrmAttrMgr::GetHoriOrient() const
+{
+ return ((SwFmtHoriOrient &)m_aSet.Get(RES_HORI_ORIENT));
+}
+inline const SwFmtFrmSize& SwFlyFrmAttrMgr::GetFrmSize() const
+{
+ return ((SwFmtFrmSize&)m_aSet.Get(RES_FRM_SIZE));
+}
+inline const SvxShadowItem &SwFlyFrmAttrMgr::GetShadow() const
+{
+ return ((SvxShadowItem&)m_aSet.Get(RES_SHADOW));
+}
+inline const SvxBoxItem &SwFlyFrmAttrMgr::GetBox() const
+{
+ return ((SvxBoxItem&)m_aSet.Get(RES_BOX));
+}
+inline const SwFmtSurround &SwFlyFrmAttrMgr::GetSurround() const
+{
+ return ((SwFmtSurround&)m_aSet.Get(RES_SURROUND));
+}
+
+inline Point SwFlyFrmAttrMgr::GetPos() const
+{
+ return Point( GetHoriOrient().GetPos(), GetVertOrient().GetPos() );
+}
+
+inline RndStdIds SwFlyFrmAttrMgr::GetAnchor() const
+{
+ return ((SwFmtAnchor&)m_aSet.Get(RES_ANCHOR)).GetAnchorId();
+}
+
+inline sal_uInt16 SwFlyFrmAttrMgr::GetHeightPercent() const
+{
+ return GetFrmSize().GetHeightPercent();
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/frmpage.hxx b/sw/source/core/uibase/inc/frmpage.hxx
new file mode 100644
index 000000000000..4f47b2c68067
--- /dev/null
+++ b/sw/source/core/uibase/inc/frmpage.hxx
@@ -0,0 +1,328 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SW_SOURCE_UI_INC_FRMPAGE_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_FRMPAGE_HXX
+
+#include <vcl/fixed.hxx>
+#include <vcl/button.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/field.hxx>
+#include <sfx2/tabdlg.hxx>
+#include <svx/swframeposstrings.hxx>
+#include <swtypes.hxx>
+#include <bmpwin.hxx>
+#include <svx/swframeexample.hxx>
+#include <prcntfld.hxx>
+#include <globals.hrc>
+
+namespace sfx2{class FileDialogHelper;}
+class SwWrtShell;
+struct FrmMap;
+// OD 12.11.2003 #i22341#
+struct SwPosition;
+
+/*--------------------------------------------------------------------
+ Description: frame dialog
+ --------------------------------------------------------------------*/
+class SwFrmPage: public SfxTabPage
+{
+ // size
+ FixedText* m_pWidthFT;
+ FixedText* m_pWidthAutoFT;
+ PercentField m_aWidthED;
+ CheckBox* m_pRelWidthCB;
+ ListBox* m_pRelWidthRelationLB;
+ CheckBox* m_pAutoWidthCB;
+
+ FixedText* m_pHeightFT;
+ FixedText* m_pHeightAutoFT;
+ PercentField m_aHeightED;
+ CheckBox* m_pRelHeightCB;
+ ListBox* m_pRelHeightRelationLB;
+ CheckBox* m_pAutoHeightCB;
+
+ CheckBox* m_pFixedRatioCB;
+ PushButton* m_pRealSizeBT;
+
+ // anchor
+ VclContainer* m_pAnchorFrame;
+ RadioButton* m_pAnchorAtPageRB;
+ RadioButton* m_pAnchorAtParaRB;
+ RadioButton* m_pAnchorAtCharRB;
+ RadioButton* m_pAnchorAsCharRB;
+ RadioButton* m_pAnchorAtFrameRB;
+
+ // position
+ FixedText* m_pHorizontalFT;
+ ListBox* m_pHorizontalDLB;
+ FixedText* m_pAtHorzPosFT;
+ MetricField* m_pAtHorzPosED;
+ FixedText* m_pHoriRelationFT;
+ ListBox* m_pHoriRelationLB;
+
+ CheckBox* m_pMirrorPagesCB;
+
+ FixedText* m_pVerticalFT;
+ ListBox* m_pVerticalDLB;
+ FixedText* m_pAtVertPosFT;
+ MetricField* m_pAtVertPosED;
+ FixedText* m_pVertRelationFT;
+ ListBox* m_pVertRelationLB;
+ // #i18732# - check box for new option 'FollowTextFlow'
+ CheckBox* m_pFollowTextFlowCB;
+
+ // example
+ SvxSwFrameExample* m_pExampleWN;
+
+ //'string provider'
+ SvxSwFramePosString aFramePosString;
+
+ sal_Bool bAtHorzPosModified;
+ sal_Bool bAtVertPosModified;
+
+ sal_Bool bFormat;
+ sal_Bool bNew;
+ sal_Bool bNoModifyHdl;
+ bool bIsVerticalFrame; //current frame is in vertical environment - strings are exchanged
+ // --> OD 2009-08-31 #mongolianlayou#
+ sal_Bool bIsVerticalL2R;
+ sal_Bool bIsInRightToLeft; // current frame is in right-to-left environment - strings are exchanged
+ sal_Bool bHtmlMode;
+ sal_uInt16 nHtmlMode;
+ OString sDlgType;
+ Size aGrfSize;
+ Size aWrap;
+ SwTwips nUpperBorder;
+ SwTwips nLowerBorder;
+ double fWidthHeightRatio; //width-to-height ratio to support the KeepRatio button
+
+ // OD 12.11.2003 #i22341# - keep content position of character for
+ // to character anchored objects.
+ const SwPosition* mpToCharCntntPos;
+
+ // old alignment
+ short nOldH;
+ short nOldHRel;
+ short nOldV;
+ short nOldVRel;
+
+ FrmMap* pVMap;
+ FrmMap* pHMap;
+
+ bool m_bAllowVertPositioning;
+ bool m_bIsMathOLE;
+ bool m_bIsMathBaselineAlignment;
+
+ virtual void ActivatePage(const SfxItemSet& rSet);
+ virtual int DeactivatePage(SfxItemSet *pSet);
+
+ DECL_LINK(RangeModifyHdl, void *);
+ DECL_LINK(AnchorTypeHdl, void *);
+ DECL_LINK( PosHdl, ListBox * );
+ DECL_LINK( RelHdl, ListBox * );
+ void InitPos(RndStdIds eId, sal_uInt16 nH, sal_uInt16 nHRel,
+ sal_uInt16 nV, sal_uInt16 nVRel,
+ long nX, long nY);
+
+ DECL_LINK(RealSizeHdl, void *);
+ DECL_LINK( RelSizeClickHdl, CheckBox * );
+ DECL_LINK(MirrorHdl, void *);
+
+ DECL_LINK( AutoWidthClickHdl, void* );
+ DECL_LINK( AutoHeightClickHdl, void* );
+
+ // update example
+ void UpdateExample();
+ DECL_LINK( ModifyHdl, Edit * );
+
+ void Init(const SfxItemSet& rSet, sal_Bool bReset = sal_False);
+ // OD 12.11.2003 #i22341# - adjustment to handle maps, that are ambigous
+ // in the alignment.
+ sal_Int32 FillPosLB( const FrmMap* _pMap,
+ const sal_uInt16 _nAlign,
+ const sal_uInt16 _nRel,
+ ListBox& _rLB );
+ // OD 14.11.2003 #i22341# - adjustment to handle maps, that are ambigous
+ // in their string entries.
+ sal_uLong FillRelLB( const FrmMap* _pMap,
+ const sal_uInt16 _nLBSelPos,
+ const sal_uInt16 _nAlign,
+ sal_uInt16 _nRel,
+ ListBox& _rLB,
+ FixedText& _rFT );
+ sal_Int32 GetMapPos( const FrmMap *pMap, ListBox &rAlignLB );
+ short GetAlignment(FrmMap *pMap, sal_Int32 nMapPos, ListBox &rAlignLB, ListBox &rRelationLB);
+ short GetRelation(FrmMap *pMap, ListBox &rRelationLB);
+ RndStdIds GetAnchor();
+
+ void setOptimalFrmWidth();
+ void setOptimalRelWidth();
+
+ void EnableGraficMode( void ); // hides auto check boxes and re-org controls for "Real Size" button
+
+ SwFrmPage(Window *pParent, const SfxItemSet &rSet);
+ ~SwFrmPage();
+
+ SwWrtShell *getFrmDlgParentShell();
+
+ using SfxTabPage::ActivatePage;
+ using SfxTabPage::DeactivatePage;
+
+public:
+
+ static SfxTabPage *Create(Window *pParent, const SfxItemSet &rSet);
+ static sal_uInt16* GetRanges();
+
+ virtual sal_Bool FillItemSet(SfxItemSet &rSet);
+ virtual void Reset(const SfxItemSet &rSet);
+
+ void SetNewFrame(sal_Bool bNewFrame) { bNew = bNewFrame; }
+ void SetFormatUsed(sal_Bool bFmt);
+ void SetFrmType(const OString &rType) { sDlgType = rType; }
+ inline sal_Bool IsInGraficMode( void ) { return sDlgType == "PictureDialog" || sDlgType == "ObjectDialog"; }
+ void EnableVerticalPositioning( bool bEnable );
+};
+
+class SwGrfExtPage: public SfxTabPage
+{
+ // mirror
+ VclContainer* m_pMirror;
+ CheckBox* m_pMirrorVertBox;
+ CheckBox* m_pMirrorHorzBox;
+ RadioButton* m_pAllPagesRB;
+ RadioButton* m_pLeftPagesRB;
+ RadioButton* m_pRightPagesRB;
+ BmpWindow* m_pBmpWin;
+
+ Edit* m_pConnectED;
+ PushButton* m_pBrowseBT;
+
+ OUString aFilterName;
+ OUString aGrfName, aNewGrfName;
+
+ ::sfx2::FileDialogHelper* pGrfDlg;
+
+ sal_Bool bHtmlMode;
+
+ // handler for mirroring
+ DECL_LINK(MirrorHdl, void *);
+ DECL_LINK(BrowseHdl, void *);
+
+ virtual void ActivatePage(const SfxItemSet& rSet);
+ SwGrfExtPage(Window *pParent, const SfxItemSet &rSet);
+ ~SwGrfExtPage();
+
+ using SfxTabPage::ActivatePage;
+ using SfxTabPage::DeactivatePage;
+
+public:
+
+ static SfxTabPage *Create(Window *pParent, const SfxItemSet &rSet);
+
+ virtual sal_Bool FillItemSet(SfxItemSet &rSet);
+ virtual void Reset(const SfxItemSet &rSet);
+ virtual int DeactivatePage(SfxItemSet *pSet);
+};
+
+class SwFrmURLPage : public SfxTabPage
+{
+ // hyperlink
+ Edit* pURLED;
+ PushButton* pSearchPB;
+ Edit* pNameED;
+ ComboBox* pFrameCB;
+
+ // image map
+ CheckBox* pServerCB;
+ CheckBox* pClientCB;
+
+ DECL_LINK(InsertFileHdl, void *);
+
+ SwFrmURLPage(Window *pParent, const SfxItemSet &rSet);
+ ~SwFrmURLPage();
+
+ using SfxTabPage::ActivatePage;
+ using SfxTabPage::DeactivatePage;
+
+public:
+
+ static SfxTabPage *Create(Window *pParent, const SfxItemSet &rSet);
+
+ virtual sal_Bool FillItemSet(SfxItemSet &rSet);
+ virtual void Reset(const SfxItemSet &rSet);
+};
+
+class SwFrmAddPage : public SfxTabPage
+{
+ VclContainer* pNameFrame;
+ FixedText* pNameFT;
+ Edit* pNameED;
+ FixedText* pAltNameFT;
+ Edit* pAltNameED;
+ FixedText* pPrevFT;
+ ListBox* pPrevLB;
+ FixedText* pNextFT;
+ ListBox* pNextLB;
+
+ VclContainer* pProtectFrame;
+ CheckBox* pProtectContentCB;
+ CheckBox* pProtectFrameCB;
+ CheckBox* pProtectSizeCB;
+
+ VclContainer* m_pContentAlignFrame;
+ ListBox* m_pVertAlignLB;
+
+ VclContainer* pPropertiesFrame;
+ CheckBox* pEditInReadonlyCB;
+ CheckBox* pPrintFrameCB;
+ FixedText* pTextFlowFT;
+ ListBox* pTextFlowLB;
+
+ SwWrtShell* pWrtSh;
+
+ OString sDlgType;
+ sal_Bool bHtmlMode;
+ sal_Bool bFormat;
+ sal_Bool bNew;
+
+ DECL_LINK(EditModifyHdl, void *);
+ DECL_LINK(ChainModifyHdl, ListBox*);
+
+ SwFrmAddPage(Window *pParent, const SfxItemSet &rSet);
+ ~SwFrmAddPage();
+
+public:
+
+ static SfxTabPage* Create(Window *pParent, const SfxItemSet &rSet);
+ static sal_uInt16* GetRanges();
+
+ virtual sal_Bool FillItemSet(SfxItemSet &rSet);
+ virtual void Reset(const SfxItemSet &rSet);
+
+ void SetFormatUsed(sal_Bool bFmt);
+ void SetFrmType(const OString &rType) { sDlgType = rType; }
+ void SetNewFrame(sal_Bool bNewFrame) { bNew = bNewFrame; }
+ void SetShell(SwWrtShell* pSh) { pWrtSh = pSh; }
+
+};
+
+#endif // INCLUDED_SW_SOURCE_UI_INC_FRMPAGE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/frmsh.hxx b/sw/source/core/uibase/inc/frmsh.hxx
new file mode 100644
index 000000000000..031025c9a2dd
--- /dev/null
+++ b/sw/source/core/uibase/inc/frmsh.hxx
@@ -0,0 +1,44 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_FRMSH_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_FRMSH_HXX
+
+#include "basesh.hxx"
+
+class SwFrameShell: public SwBaseShell
+{
+
+public:
+ SFX_DECL_INTERFACE(SW_FRAMESHELL)
+
+ SwFrameShell(SwView &rView);
+ virtual ~SwFrameShell();
+
+ void Execute(SfxRequest &);
+ void GetState(SfxItemSet &);
+ void ExecFrameStyle(SfxRequest& rReq);
+ void GetLineStyleState(SfxItemSet &rSet);
+ void StateInsert(SfxItemSet &rSet);
+
+ void StateStatusline(SfxItemSet &rSet);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/frmui.hrc b/sw/source/core/uibase/inc/frmui.hrc
new file mode 100644
index 000000000000..4e765f9c9456
--- /dev/null
+++ b/sw/source/core/uibase/inc/frmui.hrc
@@ -0,0 +1,71 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef _FRMUI_HRC
+#define _FRMUI_HRC
+
+#include "rcid.hrc"
+#include "globals.hrc"
+
+#define DLG_COLUMN (RC_FRMDLG_BEGIN + 4)
+
+#define DLG_CAPTION (RC_FRMDLG_BEGIN + 11)
+#define DLG_SEQUENCE_OPTION (RC_FRMDLG_BEGIN + 12)
+
+#define STR_FRMUI_BORDER (RC_FRMDLG_BEGIN + 16)
+#define STR_FRMUI_PATTERN (RC_FRMDLG_BEGIN + 17)
+
+#define BMP_BEGIN (RC_FRMDLG_BEGIN + 18)
+#define BMP_NOWRAP (BMP_BEGIN+5)
+
+#define BMP_END (BMP_NOWRAP)
+
+#define MN_BACKGROUND (BMP_END + 4)
+
+#define MN_FOOTNOTE (BMP_END + 7)
+
+#define STR_FRMDLG_BEGIN (MN_FOOTNOTE + 1)
+
+#define STR_TOPPRT (STR_FRMDLG_BEGIN + 1)
+
+#define STR_BORDER (STR_FRMDLG_BEGIN + 16)
+#define STR_COLUMN (STR_FRMDLG_BEGIN + 17)
+#define STR_CHAR (STR_FRMDLG_BEGIN + 19)
+
+#define STR_OLE_INSERT (STR_FRMDLG_BEGIN + 45)
+#define STR_OLE_EDIT (STR_FRMDLG_BEGIN + 46)
+#define STR_COLL_HEADER (STR_FRMDLG_BEGIN + 47)
+
+#define STR_LINE_TOP (STR_FRMDLG_BEGIN + 50)
+#define STR_LINE_BOTTOM (STR_FRMDLG_BEGIN + 51)
+#define STR_LINE_CENTER (STR_FRMDLG_BEGIN + 52)
+#define STR_CHAR_TOP (STR_FRMDLG_BEGIN + 53)
+#define STR_CHAR_BOTTOM (STR_FRMDLG_BEGIN + 54)
+#define STR_CHAR_CENTER (STR_FRMDLG_BEGIN + 55)
+
+#define FRMDLG_ACT_END STR_CHAR_CENTER
+
+#if FRMDLG_ACT_END > RC_FRMDLG_END
+#error Resource-Id Ueberlauf in #file, #line
+#endif
+
+
+#endif // FRMUI_HRC
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/globals.h b/sw/source/core/uibase/inc/globals.h
new file mode 100644
index 000000000000..4da432350b6f
--- /dev/null
+++ b/sw/source/core/uibase/inc/globals.h
@@ -0,0 +1,31 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_GLOBALS_H
+#define INCLUDED_SW_SOURCE_UI_INC_GLOBALS_H
+
+enum SwChangeState
+{
+ STATE_OFF = 0,
+ STATE_ON = 1,
+ STATE_TOGGLE = 2
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/globdoc.hrc b/sw/source/core/uibase/inc/globdoc.hrc
new file mode 100644
index 000000000000..8c954b379294
--- /dev/null
+++ b/sw/source/core/uibase/inc/globdoc.hrc
@@ -0,0 +1,44 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef _GLOBDOC_HRC
+#define _GLOBDOC_HRC
+
+#include "rcid.hrc"
+
+#define STR_HUMAN_SWGLOBDOC_NAME (RC_GLOBDOC_BEGIN + 2)
+#define STR_WRITER_GLOBALDOC_FULLTYPE_40 (RC_GLOBDOC_BEGIN + 3)
+#define STR_WRITER_GLOBALDOC_FULLTYPE_50 (RC_GLOBDOC_BEGIN + 4)
+#define STR_WRITER_GLOBALDOC_FULLTYPE (RC_GLOBDOC_BEGIN + 5)
+
+
+
+#define MN_GLOBAL_TEXT_POPUPMENU (RC_GLOBDOC_BEGIN + 63)
+
+
+#define GLOBDOC_ACT_END MN_GLOBAL_TEXT_POPUPMENU
+
+
+#if GLOBDOC_ACT_END > RC_GLOBDOC_END
+#error Resource-Id Ueberlauf in #file, #line
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/glosbib.hxx b/sw/source/core/uibase/inc/glosbib.hxx
new file mode 100644
index 000000000000..7620f419784a
--- /dev/null
+++ b/sw/source/core/uibase/inc/glosbib.hxx
@@ -0,0 +1,116 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SW_SOURCE_UI_INC_GLOSBIB_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_GLOSBIB_HXX
+
+#include <vcl/edit.hxx>
+#include <svx/stddlg.hxx>
+
+#include <vcl/lstbox.hxx>
+#include <svtools/svtabbx.hxx>
+
+#include <vcl/button.hxx>
+#include <vcl/fixed.hxx>
+#include "rtl/ustring.hxx"
+
+#include <vector>
+
+class SwGlossaryHdl;
+
+class FEdit : public Edit
+{
+public:
+ FEdit(Window* pParent, const ResId& rResId)
+ : Edit(pParent, rResId)
+ {
+ }
+
+ FEdit(Window* pParent)
+ : Edit(pParent, WB_LEFT|WB_VCENTER|WB_BORDER|WB_3DLOOK)
+ {
+ }
+
+ virtual void KeyInput( const KeyEvent& rKEvent );
+};
+
+struct GlosBibUserData
+{
+ OUString sPath;
+ OUString sGroupName;
+ OUString sGroupTitle;
+};
+
+class SwGlossaryGroupTLB : public SvTabListBox
+{
+public:
+ SwGlossaryGroupTLB(Window* pParent, const ResId& rResId)
+ : SvTabListBox(pParent, rResId)
+ {
+ }
+
+ SwGlossaryGroupTLB(Window* pParent)
+ : SvTabListBox(pParent, WB_BORDER|WB_HSCROLL|WB_CLIPCHILDREN|WB_SORT)
+ {
+ }
+
+ virtual void RequestHelp( const HelpEvent& rHEvt );
+};
+
+class SwGlossaryGroupDlg : public SvxStandardDialog
+{
+ FEdit* m_pNameED;
+ ListBox* m_pPathLB;
+ SwGlossaryGroupTLB* m_pGroupTLB;
+
+ PushButton* m_pNewPB;
+ PushButton* m_pDelPB;
+ PushButton* m_pRenamePB;
+
+ typedef std::vector< OUString> OUVector_t;
+ OUVector_t m_RemovedArr;
+ OUVector_t m_InsertedArr;
+ OUVector_t m_RenamedArr;
+
+ SwGlossaryHdl *pGlosHdl;
+
+ OUString sCreatedGroup;
+
+ sal_Bool IsDeleteAllowed(const OUString &rGroup);
+
+protected:
+ virtual void Apply();
+ DECL_LINK( SelectHdl, SvTabListBox* );
+ DECL_LINK(NewHdl, void *);
+ DECL_LINK( DeleteHdl, Button* );
+ DECL_LINK(ModifyHdl, void *);
+ DECL_LINK(RenameHdl, void *);
+
+public:
+ SwGlossaryGroupDlg(Window * pParent,
+ std::vector<OUString> const& rPathArr,
+ SwGlossaryHdl *pGlosHdl);
+ ~SwGlossaryGroupDlg();
+
+ const OUString& GetCreatedGroupName() const {return sCreatedGroup;}
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/glosdoc.hxx b/sw/source/core/uibase/inc/glosdoc.hxx
new file mode 100644
index 000000000000..a5213b1179a1
--- /dev/null
+++ b/sw/source/core/uibase/inc/glosdoc.hxx
@@ -0,0 +1,135 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_GLOSDOC_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_GLOSDOC_HXX
+
+#include "rtl/ustring.hxx"
+#include <com/sun/star/text/XAutoTextGroup.hpp>
+
+class SwTextBlocks;
+class SwDocShell;
+
+#ifndef SW_DECL_SWDOCSHELL_DEFINED
+#define SW_DECL_SWDOCSHELL_DEFINED
+#include <tools/ref.hxx>
+SV_DECL_REF( SwDocShell )
+#endif
+#include <cppuhelper/weakref.hxx>
+
+#include <vector>
+#include "swdllapi.h"
+
+typedef ::com::sun::star::uno::WeakReference< ::com::sun::star::text::XAutoTextGroup > AutoTextGroupRef;
+typedef ::std::vector< AutoTextGroupRef > UnoAutoTextGroups;
+
+typedef ::com::sun::star::uno::WeakReference< ::com::sun::star::text::XAutoTextEntry > AutoTextEntryRef;
+typedef ::std::vector< AutoTextEntryRef > UnoAutoTextEntries;
+
+#define GLOS_DELIM (sal_Unicode)'*'
+
+// CLASS -----------------------------------------------------------------
+class SW_DLLPUBLIC SwGlossaries
+{
+ UnoAutoTextGroups m_aGlossaryGroups;
+ UnoAutoTextEntries m_aGlossaryEntries;
+
+ OUString m_aPath;
+ std::vector<OUString> m_aInvalidPaths;
+ std::vector<OUString> m_PathArr;
+ std::vector<OUString> m_GlosArr;
+ sal_Bool m_bError;
+
+ SAL_DLLPRIVATE SwTextBlocks* GetGlosDoc(const OUString &rName, sal_Bool bCreate = sal_True) const;
+ SAL_DLLPRIVATE std::vector<OUString> & GetNameList();
+
+ // implementation in unoatxt.cxx
+ SAL_DLLPRIVATE void RemoveFileFromList( const OUString& rGroup );
+ SAL_DLLPRIVATE void InvalidateUNOOjects();
+
+public:
+ SwGlossaries();
+ ~SwGlossaries();
+
+ /** returns the cached AutoTextGroup (if any) for the given group name
+
+ @precond
+ If <arg>_bCreate</arg> is <TRUE/>, the SolarMutex must be locked when calling into this method.
+
+ @param _rGroupName
+ the name of the glossaries group
+ @param _bCreate
+ if <TRUE/>, the group is created if it does not yet exist
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::text::XAutoTextGroup >
+ GetAutoTextGroup(
+ const OUString& _rGroupName,
+ bool _bCreate = false
+ );
+
+ /** returns the cached AutoTextEntry (if any) for the given group/with the given name
+
+ @precond
+ If <arg>_bCreate</arg> is <TRUE/>, the SolarMutex must be locked when calling into this method.
+
+ @param _rGroupAccessName
+ the name to access the group
+ @param _rGroupName
+ the name of the glossaries group, as to be passed to the entry
+ @param _rEntryName
+ the name of the auto text entry
+ @param _bCreate
+ if <TRUE/>, the entry is created if it does not yet exist
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::text::XAutoTextEntry >
+ GetAutoTextEntry(
+ const OUString& _rCompleteGroupName,
+ const OUString& _rGroupName,
+ const OUString& _rEntryName,
+ bool _bCreate = false
+ );
+
+ sal_uInt16 GetGroupCnt();
+ OUString GetGroupName(sal_uInt16 );
+ OUString GetGroupTitle( const OUString& rGroupName );
+
+ sal_Bool FindGroupName(OUString& rGroup);
+
+ SwTextBlocks* GetGroupDoc(const OUString &rName,
+ sal_Bool bCreate = sal_False);
+ SwTextBlocks* GetDefGroupDoc() { return GetGroupDoc(GetDefName()); }
+ void PutGroupDoc(SwTextBlocks *pBlock);
+ static OUString GetDefName();
+ static OUString GetExtension();
+
+ OUString GetCompleteGroupName( const OUString& GroupName );
+
+ sal_Bool NewGroupDoc(OUString &rGroupName, const OUString& rTitle);
+ sal_Bool RenameGroupDoc(const OUString& sOldGroup, OUString& sNewGroup, const OUString& rNewTitle);
+ sal_Bool DelGroupDoc(const OUString &);
+ SwDocShellRef EditGroupDoc(const OUString &rGrpName, const OUString& rShortName, sal_Bool bShow = sal_True );
+ void SaveGroupDoc(const OUString &rGrpName, const OUString& rLongName );
+ void UpdateGlosPath(sal_Bool bFull);
+ void ShowError();
+ inline sal_uLong IsGlosPathErr() { return m_bError; }
+ std::vector<OUString> const& GetPathArray() const { return m_PathArr; }
+};
+
+#endif // INCLUDED_SW_SOURCE_UI_INC_GLOSDOC_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/gloshdl.hxx b/sw/source/core/uibase/inc/gloshdl.hxx
new file mode 100644
index 000000000000..2d341fd80ec0
--- /dev/null
+++ b/sw/source/core/uibase/inc/gloshdl.hxx
@@ -0,0 +1,104 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_GLOSHDL_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_GLOSHDL_HXX
+
+#include <rtl/ustring.hxx>
+#include "swdllapi.h"
+
+class SwWrtShell;
+class SwTextBlocks;
+class SvxMacro;
+class SwGlossaries;
+class SfxViewFrame;
+
+// CLASS -----------------------------------------------------------------
+class SW_DLLPUBLIC SwGlossaryHdl
+{
+
+ SwGlossaries& rStatGlossaries;
+ OUString aCurGrp;
+ SfxViewFrame* pViewFrame;
+ SwWrtShell* pWrtShell;
+ SwTextBlocks* pCurGrp;
+
+ SAL_DLLPRIVATE void _SetMacros(const OUString &rName,
+ const SvxMacro *pStart,
+ const SvxMacro *pEnd);
+
+ SAL_DLLPRIVATE sal_Bool Expand( const OUString& rShortName,
+ SwGlossaries* pGlossaries,
+ SwTextBlocks *pGlossary );
+
+public:
+ sal_Bool ConvertToNew(SwTextBlocks& rOld);
+ void GlossaryDlg();
+
+ sal_uInt16 GetGroupCnt() const;
+ OUString GetGroupName( sal_uInt16, OUString* pTitle = 0 );
+ sal_Bool NewGroup(OUString & rGroupName, const OUString& rTitle);
+ sal_Bool DelGroup(const OUString &);
+ sal_Bool RenameGroup(const OUString& rOld, OUString& rNew, const OUString& rNewTitle);
+ void SetCurGroup(const OUString &aGrp, sal_Bool bApi = sal_False, sal_Bool bAlwaysCreateNew = sal_False);
+
+ OUString GetCurGroup() const { return aCurGrp; }
+
+ sal_uInt16 GetGlossaryCnt();
+ OUString GetGlossaryName(sal_uInt16);
+ OUString GetGlossaryShortName(const OUString &rName);
+ OUString GetGlossaryShortName(sal_uInt16);
+
+ sal_Bool Rename( const OUString& rOldShortName, const OUString& rNewShortName,
+ const OUString& rNewName);
+ sal_Bool CopyOrMove( const OUString& rSourceGroupName, OUString& rSourceShortName,
+ const OUString& rDestGroupName, const OUString& rLongName, sal_Bool bMove );
+ sal_Bool HasShortName(const OUString &rShortName) const;
+ // when NewGlossary is called from Basic then the previously set group should
+ // be newly created if applicable.
+ sal_Bool NewGlossary(const OUString &rName, const OUString &rShortName,
+ sal_Bool bApiCall = sal_False, sal_Bool bNoAttr = sal_False );
+ sal_Bool DelGlossary(const OUString&);
+ sal_Bool CopyToClipboard(SwWrtShell& rSh, const OUString& rShortName);
+
+ sal_Bool ExpandGlossary();
+ bool InsertGlossary(const OUString &rName);
+
+ void SetMacros(const OUString& rName,
+ const SvxMacro* pStart,
+ const SvxMacro* pEnd,
+ SwTextBlocks *pGlossary = 0 );
+ void GetMacros(const OUString& rShortName,
+ SvxMacro& rStart,
+ SvxMacro& rEnd,
+ SwTextBlocks* pGlossary = 0 );
+
+ sal_Bool IsReadOnly( const OUString* = 0 ) const;
+ sal_Bool IsOld() const;
+
+ sal_Bool FindGroupName(OUString& rGroup); // find group without path index
+
+ sal_Bool ImportGlossaries( const OUString& rName );
+
+ SwGlossaryHdl(SfxViewFrame* pViewFrame, SwWrtShell *);
+ ~SwGlossaryHdl();
+};
+
+#endif // INCLUDED_SW_SOURCE_UI_INC_GLOSHDL_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/gloslst.hxx b/sw/source/core/uibase/inc/gloslst.hxx
new file mode 100644
index 000000000000..fb47656da3f2
--- /dev/null
+++ b/sw/source/core/uibase/inc/gloslst.hxx
@@ -0,0 +1,82 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SW_SOURCE_UI_INC_GLOSLST_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_GLOSLST_HXX
+
+#include <rtl/ustring.hxx>
+#include <tools/datetime.hxx>
+#include <vcl/timer.hxx>
+
+class SwGlossaries;
+class vector;
+
+struct AutoTextGroup
+{
+ sal_uInt16 nCount;
+ OUString sName;
+ OUString sTitle;
+ OUString sLongNames; // by 0x0A separated long names
+ OUString sShortNames; // by 0x0A separated short names
+ DateTime aDateModified;
+
+ AutoTextGroup()
+ : nCount(0)
+ , aDateModified(DateTime::EMPTY)
+ {
+ }
+};
+
+typedef std::vector<AutoTextGroup*> AutoTextGroups;
+
+class SwGlossaryList : public AutoTimer
+{
+ AutoTextGroups aGroupArr;
+ OUString sPath;
+ bool bFilled;
+
+ AutoTextGroup* FindGroup(const OUString& rGroupName);
+ void FillGroup(AutoTextGroup* pGroup, SwGlossaries* pGloss);
+
+public:
+ SwGlossaryList();
+ ~SwGlossaryList();
+
+ bool HasLongName(const OUString& rBegin, std::vector<OUString> *pLongNames);
+ sal_Bool GetShortName(const OUString& rLongName,
+ OUString& rShortName, OUString& rGroupName );
+
+ sal_uInt16 GetGroupCount();
+ OUString GetGroupName(sal_uInt16 nPos, bool bNoPath = true);
+ OUString GetGroupTitle(sal_uInt16 nPos);
+
+ sal_uInt16 GetBlockCount(sal_uInt16 nGroup);
+ OUString GetBlockLongName(sal_uInt16 nGroup, sal_uInt16 nBlock);
+ OUString GetBlockShortName(sal_uInt16 nGroup, sal_uInt16 nBlock);
+
+ void Update();
+
+ virtual void Timeout();
+
+ void ClearGroups();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/glossary.hxx b/sw/source/core/uibase/inc/glossary.hxx
new file mode 100644
index 000000000000..98f441620528
--- /dev/null
+++ b/sw/source/core/uibase/inc/glossary.hxx
@@ -0,0 +1,168 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_GLOSSARY_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_GLOSSARY_HXX
+
+#include <vcl/edit.hxx>
+#include <svtools/treelistbox.hxx>
+#include <svx/stddlg.hxx>
+
+#include <vcl/button.hxx>
+#include <vcl/fixed.hxx>
+
+#include <vcl/combobox.hxx>
+
+#include <vcl/menubtn.hxx>
+#include <com/sun/star/container/XEnumerationAccess.hpp>
+#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/container/XContentEnumerationAccess.hpp>
+#include <com/sun/star/container/XEnumeration.hpp>
+#include <com/sun/star/container/XElementAccess.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/text/XAutoTextContainer2.hpp>
+
+#include "rtl/ustring.hxx"
+
+#include <actctrl.hxx>
+
+class SwGlossaryHdl;
+class SwNewGlosNameDlg;
+class SwWrtShell;
+class SfxViewFrame;
+class PopupMenu;
+class Menu;
+
+const short RET_EDIT = 100;
+
+class SwGlTreeListBox : public SvTreeListBox
+{
+ const OUString sReadonly;
+
+ SvTreeListEntry* pDragEntry;
+
+ virtual DragDropMode NotifyStartDrag( TransferDataContainer& rContainer,
+ SvTreeListEntry* );
+ virtual sal_Bool NotifyAcceptDrop( SvTreeListEntry* );
+
+ virtual sal_Bool NotifyMoving( SvTreeListEntry* pTarget,
+ SvTreeListEntry* pEntry,
+ SvTreeListEntry*& rpNewParent,
+ sal_uLong& rNewChildPos
+ );
+ virtual sal_Bool NotifyCopying( SvTreeListEntry* pTarget,
+ SvTreeListEntry* pEntry,
+ SvTreeListEntry*& rpNewParent,
+ sal_uLong& rNewChildPos);
+
+ sal_Bool NotifyCopyingOrMoving( SvTreeListEntry* pTarget,
+ SvTreeListEntry* pEntry,
+ bool bIsMove);
+public:
+ SwGlTreeListBox(Window* pParent, WinBits nBits);
+
+ virtual void RequestHelp( const HelpEvent& rHEvt );
+ virtual Size GetOptimalSize() const;
+ void Clear();
+};
+
+class SwOneExampleFrame;
+class SwGlossaryDlg : public SvxStandardDialog
+{
+ friend class SwNewGlosNameDlg;
+ friend class SwGlTreeListBox;
+
+ CheckBox* m_pInsertTipCB;
+ Edit* m_pNameED;
+ FixedText* m_pShortNameLbl;
+ NoSpaceEdit* m_pShortNameEdit;
+ SwGlTreeListBox* m_pCategoryBox;
+ CheckBox* m_pFileRelCB;
+ CheckBox* m_pNetRelCB;
+ Window* m_pExampleWIN;
+ PushButton* m_pInsertBtn;
+ CloseButton* m_pCloseBtn;
+ MenuButton* m_pEditBtn;
+ PushButton* m_pBibBtn;
+ PushButton* m_pPathBtn;
+
+ OUString sReadonlyPath;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::text::XAutoTextContainer2 > m_xAutoText;
+ SwOneExampleFrame* pExampleFrame;
+
+ SwGlossaryHdl* pGlossaryHdl;
+
+ OUString sResumeGroup;
+ OUString sResumeShortName;
+ sal_Bool bResume;
+
+ const sal_Bool bSelection : 1;
+ sal_Bool bReadOnly : 1;
+ sal_Bool bIsOld : 1;
+ sal_Bool bIsDocReadOnly:1;
+
+ SwWrtShell* pSh;
+
+ void EnableShortName(sal_Bool bOn = sal_True);
+ void ShowPreview();
+
+ DECL_LINK( NameModify, Edit * );
+ DECL_LINK( NameDoubleClick, SvTreeListBox * );
+ DECL_LINK( GrpSelect, SvTreeListBox * );
+ DECL_LINK( MenuHdl, Menu * );
+ DECL_LINK( EnableHdl, Menu * );
+ DECL_LINK(BibHdl, void *);
+ DECL_LINK(EditHdl, void *);
+ DECL_LINK(InsertHdl, void *);
+ DECL_LINK( PathHdl, Button * );
+ DECL_LINK( CheckBoxHdl, CheckBox * );
+ DECL_LINK( PreviewLoadedHdl, void * );
+
+ virtual void Apply();
+ void Init();
+ SvTreeListEntry* DoesBlockExist(const OUString& sBlock, const OUString& rShort);
+ void ShowAutoText(const OUString& rGroup, const OUString& rShortName);
+ void ResumeShowAutoText();
+
+ sal_Bool GetResumeData(OUString& rGroup, OUString& rShortName)
+ {rGroup = sResumeGroup; rShortName = sResumeShortName; return bResume;}
+ void SetResumeData(const OUString& rGroup, const OUString& rShortName)
+ {sResumeGroup = rGroup; sResumeShortName = rShortName; bResume = sal_True;}
+ void ResetResumeData() {bResume = sal_False;}
+public:
+ SwGlossaryDlg(SfxViewFrame* pViewFrame, SwGlossaryHdl* pGlosHdl, SwWrtShell *pWrtShell);
+ ~SwGlossaryDlg();
+ OUString GetCurrGrpName() const;
+ OUString GetCurrLongName() const
+ {
+ return m_pNameED->GetText();
+ }
+ OUString GetCurrShortName() const
+ {
+ return m_pShortNameEdit->GetText();
+ }
+ static OUString GetCurrGroup();
+ static void SetActGroup(const OUString& rNewGroup);
+ static OUString GetExtension();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/glshell.hxx b/sw/source/core/uibase/inc/glshell.hxx
new file mode 100644
index 000000000000..9e9513d22b77
--- /dev/null
+++ b/sw/source/core/uibase/inc/glshell.hxx
@@ -0,0 +1,85 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_GLSHELL_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_GLSHELL_HXX
+#include "wdocsh.hxx"
+
+class SwGlosDocShell : public SwDocShell
+{
+ OUString aLongName;
+ OUString aShortName;
+ OUString aGroupName;
+
+ using SotObject::GetInterface;
+
+protected:
+ virtual sal_Bool Save();
+
+public:
+
+ TYPEINFO();
+ SFX_DECL_INTERFACE(SW_GLOSDOCSHELL)
+
+ SwGlosDocShell( sal_Bool bNewShow = sal_True);
+ virtual ~SwGlosDocShell();
+
+ void Execute( SfxRequest& );
+ void GetState( SfxItemSet& );
+ void SetLongName( const OUString& rLongName )
+ { aLongName = rLongName; }
+ void SetShortName( const OUString& rShortName )
+ { aShortName = rShortName; }
+ void SetGroupName( const OUString& rGroupName )
+ { aGroupName = rGroupName; }
+ const OUString& GetShortName(){return aShortName;}
+};
+
+class SwWebGlosDocShell : public SwWebDocShell
+{
+ OUString aLongName;
+ OUString aShortName;
+ OUString aGroupName;
+
+ using SotObject::GetInterface;
+
+protected:
+ virtual sal_Bool Save();
+
+public:
+
+ TYPEINFO();
+ SFX_DECL_INTERFACE(SW_WEBGLOSDOCSHELL)
+
+ SwWebGlosDocShell();
+ virtual ~SwWebGlosDocShell();
+
+ void Execute( SfxRequest& );
+ void GetState( SfxItemSet& );
+ void SetLongName( const OUString& rLongName )
+ { aLongName = rLongName; }
+ void SetShortName( const OUString& rShortName )
+ { aShortName = rShortName; }
+ void SetGroupName( const OUString& rGroupName )
+ { aGroupName = rGroupName; }
+ const OUString& GetShortName(){return aShortName;}
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/grfsh.hxx b/sw/source/core/uibase/inc/grfsh.hxx
new file mode 100644
index 000000000000..b05b5cb97d16
--- /dev/null
+++ b/sw/source/core/uibase/inc/grfsh.hxx
@@ -0,0 +1,41 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_GRFSH_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_GRFSH_HXX
+
+#include "frmsh.hxx"
+
+class SwGrfShell: public SwBaseShell
+{
+public:
+ SFX_DECL_INTERFACE(SW_GRFSHELL)
+
+ void Execute(SfxRequest& rRequest);
+ void ExecAttr(SfxRequest& rRequest);
+ void GetAttrState(SfxItemSet& rRequest);
+
+ void ExecuteRotation(SfxRequest &rRequest);
+ void GetAttrStateForRotation(SfxItemSet& rRequest);
+
+ SwGrfShell(SwView &rView);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/hyp.hxx b/sw/source/core/uibase/inc/hyp.hxx
new file mode 100644
index 000000000000..02edf350fe63
--- /dev/null
+++ b/sw/source/core/uibase/inc/hyp.hxx
@@ -0,0 +1,58 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SW_SOURCE_UI_INC_HYP_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_HYP_HXX
+
+#include <tools/link.hxx>
+#include <editeng/splwrap.hxx>
+#include <com/sun/star/linguistic2/XHyphenator.hpp>
+
+class SwView;
+
+class SwHyphWrapper : public SvxSpellWrapper {
+private:
+ SwView* pView;
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::linguistic2::XHyphenator > xHyph;
+ Link aOldLnk;
+ sal_uInt16 nPageCount; // page count for progress view
+ sal_uInt16 nPageStart; // 1st checked page
+ sal_Bool bInSelection : 1; // separating selected text
+ sal_Bool bAutomatic : 1; // insert separators without further inquiry
+ sal_Bool bInfoBox : 1; // display info-box when ending
+
+protected:
+ virtual void SpellStart( SvxSpellArea eSpell );
+ virtual bool SpellContinue();
+ virtual void SpellEnd( );
+ virtual bool SpellMore();
+ virtual void InsertHyphen( const sal_uInt16 nPos ); // insert hyphen
+
+public:
+ SwHyphWrapper( SwView* pVw,
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::linguistic2::XHyphenator > &rxHyph,
+ sal_Bool bStart, sal_Bool bOther, sal_Bool bSelect );
+ ~SwHyphWrapper();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/idxmrk.hxx b/sw/source/core/uibase/inc/idxmrk.hxx
new file mode 100644
index 000000000000..597dee285a91
--- /dev/null
+++ b/sw/source/core/uibase/inc/idxmrk.hxx
@@ -0,0 +1,60 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_IDXMRK_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_IDXMRK_HXX
+
+#include <sfx2/childwin.hxx>
+
+#include "swabstdlg.hxx"
+
+class SwWrtShell;
+
+class SwInsertIdxMarkWrapper : public SfxChildWindow
+{
+ AbstractMarkFloatDlg* pAbstDlg;
+protected:
+ SwInsertIdxMarkWrapper( Window *pParentWindow,
+ sal_uInt16 nId,
+ SfxBindings* pBindings,
+ SfxChildWinInfo* pInfo );
+
+ SFX_DECL_CHILDWINDOW_WITHID(SwInsertIdxMarkWrapper);
+
+public:
+ void ReInitDlg(SwWrtShell& rWrtShell);
+};
+
+class SwInsertAuthMarkWrapper : public SfxChildWindow
+{
+ AbstractMarkFloatDlg* pAbstDlg;
+protected:
+ SwInsertAuthMarkWrapper( Window *pParentWindow,
+ sal_uInt16 nId,
+ SfxBindings* pBindings,
+ SfxChildWinInfo* pInfo );
+
+ SFX_DECL_CHILDWINDOW_WITHID(SwInsertAuthMarkWrapper);
+
+public:
+ void ReInitDlg(SwWrtShell& rWrtShell);
+};
+
+#endif // INCLUDED_SW_SOURCE_UI_INC_IDXMRK_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/imaildsplistener.hxx b/sw/source/core/uibase/inc/imaildsplistener.hxx
new file mode 100644
index 000000000000..5b7e329df0d7
--- /dev/null
+++ b/sw/source/core/uibase/inc/imaildsplistener.hxx
@@ -0,0 +1,70 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SW_SOURCE_UI_INC_IMAILDSPLISTENER_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_IMAILDSPLISTENER_HXX
+
+#include "com/sun/star/mail/XMailMessage.hpp"
+#include <salhelper/refobj.hxx>
+
+class MailDispatcher;
+
+/**
+ MailDispatcher listener interface.
+ Clients may implement and register instances of the
+ mail dispatcher interface in order to get notifications
+ about the MailDispatcher status.
+
+ @see MailDispatcher
+*/
+class IMailDispatcherListener : public ::salhelper::ReferenceObject
+{
+public:
+ /**
+ Called when the MailDispatcher is started.
+ */
+ virtual void started(::rtl::Reference<MailDispatcher> xMailDispatcher) = 0;
+
+ /**
+ Called when the MailDispatcher is stopped.
+ */
+ virtual void stopped(::rtl::Reference<MailDispatcher> xMailDispatcher) = 0;
+
+ /**
+ Called when there are no more mail messages
+ to deliver.
+ */
+ virtual void idle(::rtl::Reference<MailDispatcher> xMailDispatcher) = 0;
+
+ /**
+ Called for every mail message that has been
+ successfully delivered.
+ */
+ virtual void mailDelivered(::rtl::Reference<MailDispatcher> xMailDispatcher, ::com::sun::star::uno::Reference< ::com::sun::star::mail::XMailMessage> xMailMessage) = 0;
+
+ /**
+ Called for every mail message whose delivery
+ failed.
+ */
+ virtual void mailDeliveryError(::rtl::Reference<MailDispatcher> xMailDispatcher, ::com::sun::star::uno::Reference< ::com::sun::star::mail::XMailMessage> xMailMessage, const OUString& sErrorMessage) = 0;
+};
+
+#endif // INCLUDED_IMAILDISPATCHERLISTENER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/initui.hxx b/sw/source/core/uibase/inc/initui.hxx
new file mode 100644
index 000000000000..9d95043d3a19
--- /dev/null
+++ b/sw/source/core/uibase/inc/initui.hxx
@@ -0,0 +1,66 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_INITUI_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_INITUI_HXX
+
+#include "tools/solar.h"
+#include "swdllapi.h"
+#include "rtl/ustring.hxx"
+
+#include <vector>
+
+/*
+ * Forward Declarations
+ */
+class SwThesaurus;
+
+/*
+ * Extern Definitions
+ */
+extern SwThesaurus* pThes;
+
+SW_DLLPUBLIC OUString GetOldGrfCat();
+SW_DLLPUBLIC void SetOldGrfCat(OUString sStr);
+SW_DLLPUBLIC OUString GetOldTabCat();
+SW_DLLPUBLIC void SetOldTabCat(OUString sStr);
+SW_DLLPUBLIC OUString GetOldFrmCat();
+SW_DLLPUBLIC void SetOldFrmCat(OUString sStr);
+SW_DLLPUBLIC OUString GetOldDrwCat();
+SW_DLLPUBLIC void SetOldDrwCat(OUString sStr);
+
+SW_DLLPUBLIC OUString GetCurrGlosGroup();
+SW_DLLPUBLIC void SetCurrGlosGroup(OUString sStr);
+
+// provides textblock management
+class SwGlossaries;
+SW_DLLPUBLIC SwGlossaries* GetGlossaries();
+
+class SwGlossaryList;
+
+bool HasGlossaryList();
+SwGlossaryList* GetGlossaryList();
+
+extern void _InitUI();
+extern void _FinitUI();
+extern void _InitSpell();
+extern void _FinitSpell();
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/inpdlg.hxx b/sw/source/core/uibase/inc/inpdlg.hxx
new file mode 100644
index 000000000000..d96c59f484ad
--- /dev/null
+++ b/sw/source/core/uibase/inc/inpdlg.hxx
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_INPDLG_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_INPDLG_HXX
+
+#include <svx/stddlg.hxx>
+
+#include <vcl/button.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/vclmedit.hxx>
+
+class SwInputField;
+class SwSetExpField;
+class SwUserFieldType;
+class SwField;
+class SwWrtShell;
+
+/*--------------------------------------------------------------------
+ Description: insert fields
+ --------------------------------------------------------------------*/
+
+class SwFldInputDlg: public SvxStandardDialog
+{
+ virtual void Apply();
+ virtual void StateChanged( StateChangedType );
+
+ SwWrtShell& rSh;
+ SwInputField* pInpFld;
+ SwSetExpField* pSetFld;
+ SwUserFieldType* pUsrType;
+
+ Edit* m_pLabelED;
+
+ VclMultiLineEdit* m_pEditED;
+
+ OKButton* m_pOKBT;
+ PushButton* m_pNextBT;
+
+ DECL_LINK(NextHdl, void *);
+public:
+ SwFldInputDlg( Window *pParent, SwWrtShell &rSh,
+ SwField* pField, sal_Bool bNextButton = sal_False );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/inputwin.hxx b/sw/source/core/uibase/inc/inputwin.hxx
new file mode 100644
index 000000000000..2278f51c23d4
--- /dev/null
+++ b/sw/source/core/uibase/inc/inputwin.hxx
@@ -0,0 +1,119 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_INPUTWIN_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_INPUTWIN_HXX
+
+#include <vcl/edit.hxx>
+#include <vcl/menu.hxx>
+#include <vcl/toolbox.hxx>
+
+#include <sfx2/childwin.hxx>
+
+class SwFldMgr;
+class SwWrtShell;
+class SwView;
+class SfxDispatcher;
+
+class InputEdit : public Edit
+{
+public:
+ InputEdit(Window* pParent, WinBits nStyle) :
+ Edit(pParent , nStyle){}
+
+ void UpdateRange(const OUString& aSel,
+ const OUString& aTblName );
+
+protected:
+ virtual void KeyInput( const KeyEvent& );
+};
+
+class SwInputWindow : public ToolBox
+{
+friend class InputEdit;
+
+ Edit aPos;
+ InputEdit aEdit;
+ PopupMenu aPopMenu;
+ SwFldMgr* pMgr;
+ SwWrtShell* pWrtShell;
+ SwView* pView;
+ SfxBindings* pBindings;
+ OUString aAktTableName, sOldFml;
+
+ sal_Bool bFirst : 1; // initialisations at first call
+ sal_Bool bActive : 1; // for hide/show when switching documents
+ sal_Bool bIsTable : 1;
+ sal_Bool bDelSel : 1;
+ bool m_bDoesUndo : 1;
+ bool m_bResetUndo : 1;
+ bool m_bCallUndo : 1;
+
+ void CleanupUglyHackWithUndo();
+
+ void DelBoxCntnt();
+ DECL_LINK( ModifyHdl, void* );
+
+ using Window::IsActive;
+
+protected:
+ virtual void Resize();
+ virtual void Click();
+ DECL_LINK( MenuHdl, Menu * );
+ DECL_LINK( DropdownClickHdl, void* );
+ void ApplyFormula();
+ void CancelFormula();
+
+public:
+ SwInputWindow( Window* pParent, SfxBindings* pBindings );
+ virtual ~SwInputWindow();
+
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+
+ void SelectHdl( ToolBox*);
+
+ void ShowWin();
+
+ sal_Bool IsActive(){ return bActive; };
+
+ DECL_LINK( SelTblCellsNotify, SwWrtShell * );
+
+ void SetFormula( const OUString& rFormula, sal_Bool bDelSel = sal_True );
+ const SwView* GetView() const{return pView;}
+};
+
+class SwInputChild : public SfxChildWindow
+{
+ SfxDispatcher* pDispatch;
+public:
+ SwInputChild( Window* ,
+ sal_uInt16 nId,
+ SfxBindings*,
+ SfxChildWinInfo* );
+ ~SwInputChild();
+ SFX_DECL_CHILDWINDOW_WITHID( SwInputChild );
+ void SetFormula( const OUString& rFormula, sal_Bool bDelSel = sal_True )
+ { ((SwInputWindow*)pWindow)->SetFormula(
+ rFormula, bDelSel ); }
+ const SwView* GetView() const{return ((SwInputWindow*)pWindow)->GetView();}
+
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/insfnote.hxx b/sw/source/core/uibase/inc/insfnote.hxx
new file mode 100644
index 000000000000..0c903a9a8341
--- /dev/null
+++ b/sw/source/core/uibase/inc/insfnote.hxx
@@ -0,0 +1,85 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_INSFNOTE_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_INSFNOTE_HXX
+
+#include <svx/stddlg.hxx>
+
+#include <vcl/button.hxx>
+
+#include <vcl/edit.hxx>
+#include <vcl/fixed.hxx>
+
+class SwWrtShell;
+
+class VclFrame;
+
+class SwInsFootNoteDlg: public SvxStandardDialog
+{
+ SwWrtShell &rSh;
+
+ // everything for the character(s)
+ OUString m_aFontName;
+ rtl_TextEncoding eCharSet;
+ sal_Bool bExtCharAvailable;
+ sal_Bool bEdit;
+
+ VclFrame* m_pNumberFrame;
+ RadioButton* m_pNumberAutoBtn;
+ RadioButton* m_pNumberCharBtn;
+ Edit* m_pNumberCharEdit;
+ PushButton* m_pNumberExtChar;
+
+ // everything for the selection footnote/endnote
+ RadioButton* m_pFtnBtn;
+ RadioButton* m_pEndNoteBtn;
+
+ PushButton* m_pOkBtn;
+ PushButton* m_pPrevBT;
+ PushButton* m_pNextBT;
+
+ DECL_LINK(NumberCharHdl, void *);
+ DECL_LINK(NumberEditHdl, void *);
+ DECL_LINK(NumberAutoBtnHdl, void *);
+ DECL_LINK(NumberExtCharHdl, void *);
+ DECL_LINK(NextPrevHdl, Button *);
+
+ virtual void Apply();
+
+ void Init();
+
+public:
+ SwInsFootNoteDlg(Window * pParent, SwWrtShell &rSh, sal_Bool bEd = sal_False);
+ ~SwInsFootNoteDlg();
+
+ rtl_TextEncoding GetCharSet() { return eCharSet; }
+ sal_Bool IsExtCharAvailable() { return bExtCharAvailable; }
+ OUString GetFontName() { return m_aFontName; }
+ sal_Bool IsEndNote() { return m_pEndNoteBtn->IsChecked(); }
+ OUString GetStr()
+ {
+ if ( m_pNumberCharBtn->IsChecked() )
+ return m_pNumberCharEdit->GetText();
+ return OUString();
+ }
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/instable.hxx b/sw/source/core/uibase/inc/instable.hxx
new file mode 100644
index 000000000000..e8046d6079a1
--- /dev/null
+++ b/sw/source/core/uibase/inc/instable.hxx
@@ -0,0 +1,76 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_INSTABLE_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_INSTABLE_HXX
+
+#include <rtl/ustring.hxx>
+#include <vcl/button.hxx>
+#include <vcl/field.hxx>
+#include <vcl/edit.hxx>
+#include <vcl/layout.hxx>
+#include <sfx2/basedlgs.hxx>
+#include <actctrl.hxx>
+
+class SwWrtShell;
+class SwTableAutoFmt;
+class SwView;
+struct SwInsertTableOptions;
+
+class SwInsTableDlg : public SfxModalDialog
+{
+ TableNameEdit* m_pNameEdit;
+
+ NumericField* m_pColNF;
+ NumericField* m_pRowNF;
+
+ CheckBox* m_pHeaderCB;
+ CheckBox* m_pRepeatHeaderCB;
+ NumericField* m_pRepeatHeaderNF;
+ VclContainer* m_pRepeatGroup;
+
+ CheckBox* m_pDontSplitCB;
+ CheckBox* m_pBorderCB;
+
+ PushButton* m_pInsertBtn;
+ PushButton* m_pAutoFmtBtn;
+
+ SwWrtShell* pShell;
+ SwTableAutoFmt* pTAutoFmt;
+ sal_Int64 nEnteredValRepeatHeaderNF;
+
+ DECL_LINK( ModifyName, Edit * );
+ DECL_LINK( ModifyRowCol, NumericField * );
+ DECL_LINK( AutoFmtHdl, PushButton* );
+ DECL_LINK(OKHdl, void*);
+ DECL_LINK(CheckBoxHdl, void * = 0);
+ DECL_LINK( ReapeatHeaderCheckBoxHdl, void* p = 0 );
+ DECL_LINK( ModifyRepeatHeaderNF_Hdl, void* p = 0 );
+
+public:
+ SwInsTableDlg( SwView& rView );
+ ~SwInsTableDlg();
+
+ void GetValues( OUString& rName, sal_uInt16& rRow, sal_uInt16& rCol,
+ SwInsertTableOptions& rInsTblOpts, OUString& rTableAutoFmtName,
+ SwTableAutoFmt *& prTAFmt );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/javaedit.hxx b/sw/source/core/uibase/inc/javaedit.hxx
new file mode 100644
index 000000000000..209c39a931fc
--- /dev/null
+++ b/sw/source/core/uibase/inc/javaedit.hxx
@@ -0,0 +1,88 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_JAVAEDIT_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_JAVAEDIT_HXX
+
+#include <svx/stddlg.hxx>
+#include <vcl/fixed.hxx>
+#include <svtools/svmedit.hxx>
+#include <vcl/button.hxx>
+
+class SwWrtShell;
+class SwFldMgr;
+class SwScriptField;
+
+namespace sfx2 { class FileDialogHelper; }
+
+// class SwJavaEditDialog -------------------------------------------------
+
+class SwJavaEditDialog : public SvxStandardDialog
+{
+private:
+ Edit* m_pTypeED;
+ RadioButton* m_pUrlRB;
+ RadioButton* m_pEditRB;
+ PushButton* m_pUrlPB;
+ Edit* m_pUrlED;
+ VclMultiLineEdit* m_pEditED;
+
+ OKButton* m_pOKBtn;
+ PushButton* m_pPrevBtn;
+ PushButton* m_pNextBtn;
+
+ OUString aText;
+ OUString aType;
+
+ sal_Bool bNew;
+ sal_Bool bIsUrl;
+
+ SwScriptField* pFld;
+ SwFldMgr* pMgr;
+ SwWrtShell* pSh;
+ sfx2::FileDialogHelper* pFileDlg;
+ Window* pOldDefDlgParent;
+
+ DECL_LINK(OKHdl, void *);
+ DECL_LINK(PrevHdl, void *);
+ DECL_LINK(NextHdl, void *);
+ DECL_LINK(RadioButtonHdl, void *);
+ DECL_LINK(InsertFileHdl, PushButton *);
+ DECL_LINK(DlgClosedHdl, void *);
+
+ virtual void Apply();
+
+ void CheckTravel();
+ void SetFld();
+
+public:
+ SwJavaEditDialog(Window* pParent, SwWrtShell* pWrtSh);
+ ~SwJavaEditDialog();
+
+ OUString GetScriptText() const { return aText; }
+
+ OUString GetScriptType() const { return aType; }
+
+ sal_Bool IsUrl() const { return bIsUrl; }
+ sal_Bool IsNew() const { return bNew; }
+ bool IsUpdate() const;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/label.hxx b/sw/source/core/uibase/inc/label.hxx
new file mode 100644
index 000000000000..43eb936734e5
--- /dev/null
+++ b/sw/source/core/uibase/inc/label.hxx
@@ -0,0 +1,93 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_LABEL_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_LABEL_HXX
+
+#include <sfx2/tabdlg.hxx>
+#include <com/sun/star/frame/XModel.hpp>
+#include <labelcfg.hxx>
+#include <vector>
+
+class SwLabRec;
+class SwLabRecs;
+class SwLabItem;
+class SwLabPrtPage;
+class SwNewDBMgr;
+class Printer;
+
+class SwLabDlg : public SfxTabDialog
+{
+ SwLabelConfig aLabelsCfg;
+ SwNewDBMgr* pNewDBMgr;
+ SwLabPrtPage* pPrtPage;
+
+ std::vector<sal_uInt16> aTypeIds;
+ std::vector<OUString> aMakes;
+
+ SwLabRecs* pRecs;
+ OUString aLstGroup;
+ OUString m_sBusinessCardDlg;
+ bool m_bLabel;
+ sal_uInt16 m_nFormatId;
+ sal_uInt16 m_nOptionsId;
+ sal_uInt16 m_nLabelId;
+ sal_uInt16 m_nCardsId;
+ sal_uInt16 m_nBusinessId;
+ sal_uInt16 m_nPrivateId;
+ void _ReplaceGroup( const OUString &rMake );
+
+ virtual void PageCreated( sal_uInt16 nId, SfxTabPage &rPage );
+public:
+
+ SwLabDlg( Window* pParent, const SfxItemSet& rSet,
+ SwNewDBMgr* pNewDBMgr, sal_Bool bLabel);
+ ~SwLabDlg();
+
+ SwLabRec* GetRecord(const OUString &rRecName, sal_Bool bCont);
+ void GetLabItem(SwLabItem &rItem);
+
+ SwLabRecs &Recs() { return *pRecs; }
+ const SwLabRecs &Recs() const { return *pRecs; }
+
+ std::vector<sal_uInt16> &TypeIds() { return aTypeIds; }
+ const std::vector<sal_uInt16> &TypeIds() const { return aTypeIds; }
+
+ std::vector<OUString> &Makes() { return aMakes; }
+ const std::vector<OUString> &Makes() const { return aMakes; }
+
+ Printer *GetPrt();
+ inline void ReplaceGroup( const OUString &rMake );
+ void UpdateGroup( const OUString &rMake ) {_ReplaceGroup( rMake );}
+ static void UpdateFieldInformation(::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel>& xModel,
+ const SwLabItem& rItem);
+ const OUString& GetBusinessCardStr() const {return m_sBusinessCardDlg;}
+
+ SwLabelConfig& GetLabelsConfig() {return aLabelsCfg;}
+
+};
+
+inline void SwLabDlg::ReplaceGroup( const OUString &rMake )
+{
+ if ( rMake != aLstGroup )
+ _ReplaceGroup( rMake );
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/labelcfg.hxx b/sw/source/core/uibase/inc/labelcfg.hxx
new file mode 100644
index 000000000000..a70260010d58
--- /dev/null
+++ b/sw/source/core/uibase/inc/labelcfg.hxx
@@ -0,0 +1,61 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_LABELCFG_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_LABELCFG_HXX
+
+#include <unotools/configitem.hxx>
+#include "swdllapi.h"
+
+#include <map>
+#include <vector>
+
+class SwLabRecs;
+class SwLabRec;
+
+struct SwLabelMeasure
+{
+ OUString m_aMeasure; // string contains the label dimensions
+ bool m_bPredefined; // used to distinguish predefined from user-defined labels
+};
+
+class SW_DLLPUBLIC SwLabelConfig : public utl::ConfigItem
+{
+ std::vector<OUString> m_aManufacturers;
+ std::map< OUString, std::map<OUString, SwLabelMeasure> > m_aLabels;
+
+public:
+ SwLabelConfig();
+ virtual ~SwLabelConfig();
+
+ virtual void Commit();
+ virtual void Notify( const ::com::sun::star::uno::Sequence< OUString >& aPropertyNames );
+
+ void FillLabels(const OUString& rManufacturer, SwLabRecs& rLabArr);
+ const std::vector<OUString>& GetManufacturers() const {return m_aManufacturers;}
+
+ sal_Bool HasLabel(const OUString& rManufacturer, const OUString& rType);
+ bool IsPredefinedLabel(const OUString& rManufacturer, const OUString& rType)
+ { return m_aLabels[rManufacturer][rType].m_bPredefined; };
+ void SaveLabel(const OUString& rManufacturer, const OUString& rType,
+ const SwLabRec& rRec);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/labimg.hxx b/sw/source/core/uibase/inc/labimg.hxx
new file mode 100644
index 000000000000..d668383efb68
--- /dev/null
+++ b/sw/source/core/uibase/inc/labimg.hxx
@@ -0,0 +1,125 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SW_SOURCE_UI_INC_LABIMG_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_LABIMG_HXX
+
+#include <svl/poolitem.hxx>
+#include <unotools/configitem.hxx>
+#include "swdllapi.h"
+
+// class SwLabItem ----------------------------------------------------------
+class SwLabCfgItem;
+
+class SW_DLLPUBLIC SwLabItem : public SfxPoolItem
+{
+
+public:
+
+ SwLabItem();
+ SwLabItem(const SwLabItem& rItem);
+
+ SwLabItem& operator =(const SwLabItem& rItem);
+
+ virtual bool operator ==(const SfxPoolItem& rItem) const;
+
+ virtual SfxPoolItem* Clone(SfxItemPool* = 0) const;
+
+ OUString aLstMake; // remember last selection
+ OUString aLstType;
+ OUString sDBName; // used database
+
+ OUString aWriting; // label
+ OUString aMake; // label mark
+ OUString aType; // label type
+ OUString aBin; // printer shaft
+ sal_Int32 lHDist; // horizontal distance (user)
+ sal_Int32 lVDist; // vertical distance (user)
+ sal_Int32 lWidth; // width (user)
+ sal_Int32 lHeight; // height (user)
+ sal_Int32 lLeft; // left border (user)
+ sal_Int32 lUpper; // upper border (user)
+ sal_Int32 nCols; // number of columns (user)
+ sal_Int32 nRows; // number of rows (user)
+ sal_Int32 nCol; // column for single print
+ sal_Int32 nRow; // row for single print
+ sal_Int32 lPHeight; // paper height
+ sal_Int32 lPWidth; // paper width
+ sal_Bool bAddr;// address as label?
+ sal_Bool bCont;// continuous paper?
+ sal_Bool bPage;// whole page or single labels?
+ sal_Bool bSynchron;// synchronise all labels
+
+ //parts of the business card
+ OUString aPrivFirstName;
+ OUString aPrivName;
+ OUString aPrivShortCut;
+ OUString aPrivFirstName2;
+ OUString aPrivName2;
+ OUString aPrivShortCut2;
+ OUString aPrivStreet;
+ OUString aPrivZip;
+ OUString aPrivCity;
+ OUString aPrivCountry;
+ OUString aPrivState;
+ OUString aPrivTitle;
+ OUString aPrivProfession;
+ OUString aPrivPhone;
+ OUString aPrivMobile;
+ OUString aPrivFax;
+ OUString aPrivWWW;
+ OUString aPrivMail;
+ OUString aCompCompany;
+ OUString aCompCompanyExt;
+ OUString aCompSlogan;
+ OUString aCompStreet;
+ OUString aCompZip;
+ OUString aCompCity;
+ OUString aCompCountry;
+ OUString aCompState;
+ OUString aCompPosition;
+ OUString aCompPhone;
+ OUString aCompMobile;
+ OUString aCompFax;
+ OUString aCompWWW;
+ OUString aCompMail;
+
+ OUString sGlossaryGroup;
+ OUString sGlossaryBlockName;
+};
+
+// class SwLabCfgItem -------------------------------------------------------
+class SwLabCfgItem : public utl::ConfigItem
+{
+ SwLabItem aItem;
+ sal_Bool bIsLabel;
+
+ com::sun::star::uno::Sequence<OUString> GetPropertyNames();
+public:
+ SwLabCfgItem(sal_Bool bLabel);
+
+ SwLabItem& GetItem() {return aItem;}
+
+ virtual void Commit();
+ virtual void Notify( const ::com::sun::star::uno::Sequence< OUString >& aPropertyNames );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/langhelper.hxx b/sw/source/core/uibase/inc/langhelper.hxx
new file mode 100644
index 000000000000..c771c0040c2f
--- /dev/null
+++ b/sw/source/core/uibase/inc/langhelper.hxx
@@ -0,0 +1,62 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_LANGHELPER_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_LANGHELPER_HXX
+
+class SwWrtShell;
+class SwView;
+class EditEngine;
+class EditView;
+class OutlinerView;
+class SfxItemSet;
+struct ESelection;
+
+namespace SwLangHelper
+{
+ extern sal_uInt16 GetLanguageStatus( OutlinerView* pOLV, SfxItemSet& rSet );
+ extern bool SetLanguageStatus( OutlinerView* pOLV, SfxRequest &rReq, SwView &rView, SwWrtShell &rSh );
+
+ extern void SetLanguage( SwWrtShell &rWrtSh, const OUString &rLangText, bool bIsForSelection, SfxItemSet &rCoreSet );
+// extern void SetLanguage( SwWrtShell &rWrtSh, EditEngine* pEditEngine, ESelection aSelection, const String &rLangText, bool bIsForSelection, SfxItemSet &rCoreSet );
+ extern void SetLanguage( SwWrtShell &rWrtSh, OutlinerView* pOLV, ESelection aSelection, const OUString &rLangText, bool bIsForSelection, SfxItemSet &rCoreSet );
+ extern void SetLanguage_None( SwWrtShell &rWrtSh, bool bIsForSelection, SfxItemSet &rCoreSet );
+// extern void SetLanguage_None( SwWrtShell &rWrtSh, EditEngine* pEditEngine, ESelection aSelection, bool bIsForSelection, SfxItemSet &rCoreSet );
+ extern void SetLanguage_None( SwWrtShell &rWrtSh, OutlinerView* pOLV, ESelection aSelection, bool bIsForSelection, SfxItemSet &rCoreSet );
+ extern void ResetLanguages( SwWrtShell &rWrtSh, bool bIsForSelection );
+// extern void ResetLanguages( SwWrtShell &rWrtSh, EditEngine* pEditEngine, ESelection aSelection, bool bIsForSelection );
+ extern void ResetLanguages( SwWrtShell &rWrtSh, OutlinerView* pOLV, ESelection aSelection, bool bIsForSelection );
+
+ // document
+ extern void SelectCurrentPara( SwWrtShell &rWrtSh );
+ // EditView
+ extern void SelectPara( EditView &rEditView, const ESelection &rCurSel );
+
+ extern OUString GetTextForLanguageGuessing( EditEngine* rEditEngine, ESelection aDocSelection );
+ extern OUString GetTextForLanguageGuessing( SwWrtShell &rSh );
+
+ extern LanguageType GetLanguage( SfxItemSet aSet, sal_uInt16 nLangWhichId );
+ extern LanguageType GetLanguage( SwWrtShell &rSh, sal_uInt16 nLangWhichId );
+
+ extern LanguageType GetCurrentLanguage( SfxItemSet aSet, sal_uInt16 nScriptType );
+ extern LanguageType GetCurrentLanguage( SwWrtShell &rSh );
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/linenum.hxx b/sw/source/core/uibase/inc/linenum.hxx
new file mode 100644
index 000000000000..94cc0fa02589
--- /dev/null
+++ b/sw/source/core/uibase/inc/linenum.hxx
@@ -0,0 +1,64 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_LINENUM_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_LINENUM_HXX
+
+#include <sfx2/basedlgs.hxx>
+#include <vcl/button.hxx>
+#include <vcl/layout.hxx>
+#include <vcl/lstbox.hxx>
+#include <numberingtypelistbox.hxx>
+
+class Window;
+class SwView;
+class SwWrtShell;
+
+class SwLineNumberingDlg : public SfxModalDialog
+{
+private:
+ SwWrtShell* pSh;
+ VclContainer* m_pBodyContent;
+ Window* m_pDivIntervalFT;
+ NumericField* m_pDivIntervalNF;
+ Window* m_pDivRowsFT;
+ NumericField* m_pNumIntervalNF;
+ ListBox* m_pCharStyleLB;
+ SwNumberingTypeListBox* m_pFormatLB;
+ ListBox* m_pPosLB;
+ MetricField* m_pOffsetMF;
+ Edit* m_pDivisorED;
+ CheckBox* m_pCountEmptyLinesCB;
+ CheckBox* m_pCountFrameLinesCB;
+ CheckBox* m_pRestartEachPageCB;
+ CheckBox* m_pNumberingOnCB;
+
+ DECL_LINK(OKHdl, void *);
+ DECL_LINK(LineOnOffHdl, void * = 0);
+ DECL_LINK(ModifyHdl, void * = 0);
+
+public:
+ SwWrtShell* GetWrtShell() const { return pSh; }
+
+ SwLineNumberingDlg(SwView *pVw);
+ ~SwLineNumberingDlg();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/listsh.hxx b/sw/source/core/uibase/inc/listsh.hxx
new file mode 100644
index 000000000000..d37d9ed62b6e
--- /dev/null
+++ b/sw/source/core/uibase/inc/listsh.hxx
@@ -0,0 +1,38 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_LISTSH_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_LISTSH_HXX
+
+#include "basesh.hxx"
+
+class SwListShell: public SwBaseShell
+{
+public:
+ SFX_DECL_INTERFACE(SW_LISTSHELL)
+ TYPEINFO();
+
+ SwListShell(SwView &rView);
+
+ void Execute(SfxRequest &);
+ void GetState(SfxItemSet &);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/macassgn.hxx b/sw/source/core/uibase/inc/macassgn.hxx
new file mode 100644
index 000000000000..cb4cda8e0391
--- /dev/null
+++ b/sw/source/core/uibase/inc/macassgn.hxx
@@ -0,0 +1,47 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_MACASSGN_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_MACASSGN_HXX
+
+#include <sfx2/evntconf.hxx>
+
+class SwWrtShell;
+class SvxMacroItem;
+
+enum DlgEventType
+{
+ MACASSGN_AUTOTEXT,
+ MACASSGN_GRAPHIC,
+ MACASSGN_OLE,
+ MACASSGN_FRMURL,
+ MACASSGN_INETFMT,
+ MACASSGN_ALLFRM
+};
+
+class SwMacroAssignDlg
+{
+public:
+ static SfxEventNamesItem AddEvents( DlgEventType eType );
+ static bool INetFmtDlg( Window* pParent, SwWrtShell& rSh,
+ SvxMacroItem*& rpINetItem );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/mailconfigpage.hxx b/sw/source/core/uibase/inc/mailconfigpage.hxx
new file mode 100644
index 000000000000..2de39fd89704
--- /dev/null
+++ b/sw/source/core/uibase/inc/mailconfigpage.hxx
@@ -0,0 +1,77 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_MAILCONFIGPAGE_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_MAILCONFIGPAGE_HXX
+
+#include <sfx2/tabdlg.hxx>
+#include <vcl/button.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/field.hxx>
+#include <vcl/fixed.hxx>
+#include <sfx2/basedlgs.hxx>
+
+class SwTestAccountSettingsDialog;
+class SwMailMergeConfigItem;
+
+class SwMailConfigPage : public SfxTabPage
+{
+ friend class SwTestAccountSettingsDialog;
+
+ Edit* m_pDisplayNameED;
+ Edit* m_pAddressED;
+
+ CheckBox* m_pReplyToCB;
+ FixedText* m_pReplyToFT;
+ Edit* m_pReplyToED;
+
+ Edit* m_pServerED;
+ NumericField* m_pPortNF;
+
+ CheckBox* m_pSecureCB;
+
+ PushButton* m_pServerAuthenticationPB;
+ PushButton* m_pTestPB;
+
+ SwMailMergeConfigItem* m_pConfigItem;
+
+ DECL_LINK(ReplyToHdl, CheckBox*);
+ DECL_LINK(AuthenticationHdl, void *);
+ DECL_LINK(TestHdl, void *);
+
+public:
+ SwMailConfigPage( Window* pParent, const SfxItemSet& rSet );
+ ~SwMailConfigPage();
+
+ static SfxTabPage* Create( Window* pParent,
+ const SfxItemSet& rAttrSet);
+
+ virtual sal_Bool FillItemSet( SfxItemSet& rSet );
+ virtual void Reset( const SfxItemSet& rSet );
+
+};
+
+class SwMailConfigDlg : public SfxSingleTabDialog
+{
+public:
+ SwMailConfigDlg(Window* pParent, SfxItemSet& rSet);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/maildispatcher.hxx b/sw/source/core/uibase/inc/maildispatcher.hxx
new file mode 100644
index 000000000000..512d6fde5b56
--- /dev/null
+++ b/sw/source/core/uibase/inc/maildispatcher.hxx
@@ -0,0 +1,154 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SW_SOURCE_UI_INC_MAILDISPATCHER_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_MAILDISPATCHER_HXX
+
+#include "com/sun/star/mail/XSmtpService.hpp"
+#include "com/sun/star/mail/XMailMessage.hpp"
+#include <osl/thread.hxx>
+#include <osl/conditn.hxx>
+#include <salhelper/refobj.hxx>
+
+#include <list>
+
+class IMailDispatcherListener;
+
+/**
+ A MailDispatcher should be used for sending a bunch a mail messages
+ asynchronously. Usually a client enqueues a number of mail messages
+ and then calls start to begin sending them. An instance of this class
+ must not be shared among different client threads. Instead each client
+ thread should create an own instance of this class.
+*/
+class MailDispatcher : public ::salhelper::ReferenceObject, private ::osl::Thread
+{
+public:
+ // bringing operator new/delete into scope
+ using osl::Thread::operator new;
+ using osl::Thread::operator delete;
+ using osl::Thread::join;
+
+public:
+
+ /**
+ @param xSmtpService
+ [in] a reference to a mail server. A user must be
+ connected to the mail server otherwise errors occur
+ during the delivery of mail messages.
+
+ @throws ::com::sun::star::uno::RuntimeException
+ on errors during construction of an instance of this class.
+ */
+ MailDispatcher(::com::sun::star::uno::Reference< ::com::sun::star::mail::XSmtpService> xMailService);
+
+ /**
+ Shutdown the mail dispatcher. Every mail messages
+ not yet sent will be discarded.
+ */
+ virtual ~MailDispatcher();
+
+ /**
+ Enqueue a mail message for delivery. A client must
+ start the mail dispatcher in order to send the
+ enqueued mail messages.
+
+ @param xMailMessage
+ [in] a mail message that should be send.
+ */
+ void enqueueMailMessage(::com::sun::star::uno::Reference< ::com::sun::star::mail::XMailMessage> xMailMessage);
+ /**
+ Dequeues a mail message.
+ This enables the caller to remove attachments when sending mails is to be cancelled.
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::mail::XMailMessage> dequeueMailMessage();
+
+ /**
+ Start sending mail messages asynchronously. A client may register
+ a listener for mail dispatcher events. For every mail message sent
+ the notification will be sent. While handling such notification a
+ client may enqueue new mail messages. If there are no more mail
+ messages to send an respective notification is sent and the mail
+ dispatcher waits for more mail messages.
+
+ @precond not isStarted()
+ */
+ void start();
+
+ /**
+ Stop sending mail messages.
+
+ @precond isStarted()
+ */
+ void stop();
+
+ /**
+ Request shutdown of the mail dispatcher thread.
+ NOTE: You must call this method before you release
+ your last reference to this class otherwise the
+ mail dispatcher thread will never end.
+ */
+ void shutdown();
+
+ /**
+ Check whether the mail dispatcher is started or not.
+
+ @return
+ <TRUE/> if the sending thread is running.
+ */
+ bool isStarted() const;
+
+ /** returns if the thread is still running
+ */
+ using osl::Thread::isRunning;
+
+ /** returns if shutdown has already been called
+ */
+ bool isShutdownRequested() const
+ { return shutdown_requested_; }
+ /**
+ Register a listener for mail dispatcher events.
+ */
+ void addListener(::rtl::Reference<IMailDispatcherListener> listener);
+
+protected:
+ virtual void SAL_CALL run();
+ virtual void SAL_CALL onTerminated();
+
+private:
+ std::list< ::rtl::Reference<IMailDispatcherListener> > cloneListener();
+ void sendMailMessageNotifyListener(::com::sun::star::uno::Reference< ::com::sun::star::mail::XMailMessage> message);
+
+private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::mail::XSmtpService> mailserver_;
+ ::std::list< ::com::sun::star::uno::Reference< ::com::sun::star::mail::XMailMessage > > messages_;
+ ::std::list< ::rtl::Reference<IMailDispatcherListener> > listeners_;
+ ::osl::Mutex message_container_mutex_;
+ ::osl::Mutex listener_container_mutex_;
+ ::osl::Mutex thread_status_mutex_;
+ ::osl::Condition mail_dispatcher_active_;
+ ::osl::Condition wakening_call_;
+ ::rtl::Reference<MailDispatcher> m_xSelfReference;
+ bool run_;
+ bool shutdown_requested_;
+};
+
+#endif // INCLUDED_SW_SOURCE_UI_INC_MAILDISPATCHER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/mailmergechildwindow.hxx b/sw/source/core/uibase/inc/mailmergechildwindow.hxx
new file mode 100644
index 000000000000..f1ecd5a87c2c
--- /dev/null
+++ b/sw/source/core/uibase/inc/mailmergechildwindow.hxx
@@ -0,0 +1,52 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_MAILMERGECHILDWINDOW_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_MAILMERGECHILDWINDOW_HXX
+#include <sfx2/childwin.hxx>
+#include <sfx2/basedlgs.hxx>
+#include <vcl/toolbox.hxx>
+#include "swdllapi.h"
+
+class SwMailMergeChildWin : public SfxFloatingWindow
+{
+ ToolBox m_aBackTB;
+
+ DECL_LINK( BackHdl, void* );
+
+public:
+ SwMailMergeChildWin(SfxBindings*, SfxChildWindow*, Window *pParent);
+ ~SwMailMergeChildWin();
+
+ virtual void FillInfo(SfxChildWinInfo&) const;
+};
+
+class SwMailMergeChildWindow : public SfxChildWindow
+{
+public:
+ SwMailMergeChildWindow( Window* ,
+ sal_uInt16 nId,
+ SfxBindings*,
+ SfxChildWinInfo* );
+
+ SFX_DECL_CHILDWINDOW( SwMailMergeChildWindow );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/mailmergehelper.hxx b/sw/source/core/uibase/inc/mailmergehelper.hxx
new file mode 100644
index 000000000000..fc87a3ec9949
--- /dev/null
+++ b/sw/source/core/uibase/inc/mailmergehelper.hxx
@@ -0,0 +1,310 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_MAILMERGEHELPER_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_MAILMERGEHELPER_HXX
+
+#include <svtools/stdctrl.hxx>
+#include <unotools/configitem.hxx>
+#include <com/sun/star/uno/Sequence.h>
+#include "com/sun/star/mail/XAuthenticator.hpp"
+#include "com/sun/star/mail/XConnectionListener.hpp"
+#include "com/sun/star/uno/XCurrentContext.hpp"
+#include "com/sun/star/mail/XMailMessage.hpp"
+#include "com/sun/star/datatransfer/XTransferable.hpp"
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/compbase1.hxx>
+#include <cppuhelper/compbase2.hxx>
+#include <vcl/scrbar.hxx>
+#include "rtl/ustring.hxx"
+#include "swdllapi.h"
+
+class SwMailMergeConfigItem;
+
+namespace com { namespace sun { namespace star { namespace mail {
+ class XMailService;
+ class XSmtpService;
+} } } }
+
+namespace SwMailMergeHelper
+{
+ SW_DLLPUBLIC OUString CallSaveAsDialog(OUString& rFilter);
+ SW_DLLPUBLIC bool CheckMailAddress( const OUString& rMailAddress );
+ SW_DLLPUBLIC com::sun::star::uno::Reference< com::sun::star::mail::XSmtpService >
+ ConnectToSmtpServer( SwMailMergeConfigItem& rConfigItem,
+ com::sun::star::uno::Reference< com::sun::star::mail::XMailService >& xInMailService,
+ const OUString& rInMailServerPassword,
+ const OUString& rOutMailServerPassword,
+ Window* pDialogParentWindow = 0 );
+}
+
+class SW_DLLPUBLIC SwBoldFixedInfo : public FixedInfo
+{
+public:
+ SwBoldFixedInfo(Window* pParent, const ResId& rResId);
+ ~SwBoldFixedInfo();
+};
+struct SwAddressPreview_Impl;
+
+/*-------------------------------------------------------------------------
+ Preview window used to show the possible selection of address blocks
+ and also the resulting address filled with database data
+ -----------------------------------------------------------------------*/
+class SW_DLLPUBLIC SwAddressPreview : public Window
+{
+ ScrollBar aVScrollBar;
+ SwAddressPreview_Impl* pImpl;
+ Link m_aSelectHdl;
+
+ void DrawText_Impl( const OUString& rAddress, const Point& rTopLeft, const Size& rSize, bool bIsSelected);
+
+ virtual void Paint(const Rectangle&);
+ virtual void Resize();
+ virtual void MouseButtonDown( const MouseEvent& rMEvt );
+ virtual void KeyInput( const KeyEvent& rKEvt );
+ virtual void StateChanged( StateChangedType nStateChange );
+ void UpdateScrollBar();
+
+ DECL_LINK(ScrollHdl, void*);
+
+public:
+ SwAddressPreview(Window* pParent, const ResId& rResId);
+
+ SwAddressPreview(Window* pParent, WinBits nStyle=WB_BORDER);
+
+ void positionScrollBar();
+
+ /** The address string is a list of address elements separated by spaces
+ and breaks. The addresses fit into the given layout. If more addresses then
+ rows/columns should be used a scrollbar will be added.
+
+ AddAddress appends the new address to the already added ones.
+ Initially the first added address will be selected
+ */
+ void AddAddress(const OUString& rAddress);
+ // for preview mode - replaces the currently used address by the given one
+ void SetAddress(const OUString& rAddress);
+ // removes all addresses
+ void Clear();
+
+ // returns the selected address
+ sal_uInt16 GetSelectedAddress() const;
+ void SelectAddress(sal_uInt16 nSelect);
+ void ReplaceSelectedAddress(const OUString&);
+ void RemoveSelectedAddress();
+
+ // set the number of rows and columns of addresses
+ void SetLayout(sal_uInt16 nRows, sal_uInt16 nColumns);
+ void EnableScrollBar(bool bEnable = true);
+
+ // fill the actual data into a string (address block or greeting)
+ static OUString FillData(
+ const OUString& rAddress,
+ SwMailMergeConfigItem& rConfigItem,
+ const ::com::sun::star::uno::Sequence< OUString>* pAssignments = 0);
+
+ void SetSelectHdl (const Link& rLink) {m_aSelectHdl = rLink;}
+};
+
+/*-------------------------------------------------------------------------
+ iterate over an address block or a greeting line
+ the iterator returns the parts either as pure string
+ or as column
+ -----------------------------------------------------------------------*/
+struct SwMergeAddressItem
+{
+ OUString sText;
+ bool bIsColumn;
+ bool bIsReturn;
+ SwMergeAddressItem() :
+ bIsColumn(false),
+ bIsReturn(false) {}
+};
+
+class SW_DLLPUBLIC SwAddressIterator
+{
+ OUString sAddress;
+public:
+ SwAddressIterator(const OUString& rAddress) :
+ sAddress(rAddress){}
+
+ SwMergeAddressItem Next();
+ bool HasMore() const{return !sAddress.isEmpty();}
+};
+
+class SW_DLLPUBLIC SwAuthenticator :
+ public cppu::WeakImplHelper1< ::com::sun::star::mail::XAuthenticator>
+{
+ OUString m_aUserName;
+ OUString m_aPassword;
+ Window* m_pParentWindow;
+public:
+ SwAuthenticator() : m_pParentWindow(0) {}
+ SwAuthenticator(const OUString& username, const OUString& password, Window* pParent) :
+ m_aUserName(username),
+ m_aPassword(password),
+ m_pParentWindow( pParent )
+ {}
+ ~SwAuthenticator();
+
+ virtual OUString SAL_CALL getUserName( ) throw (::com::sun::star::uno::RuntimeException, std::exception);
+ virtual OUString SAL_CALL getPassword( ) throw (::com::sun::star::uno::RuntimeException, std::exception);
+
+};
+
+class SW_DLLPUBLIC SwConnectionContext :
+ public cppu::WeakImplHelper1< ::com::sun::star::uno::XCurrentContext >
+{
+ OUString m_sMailServer;
+ sal_Int16 m_nPort;
+ OUString m_sConnectionType;
+
+public:
+ SwConnectionContext(const OUString& rMailServer, sal_Int16 nPort, const OUString& rConnectionType);
+ ~SwConnectionContext();
+
+ virtual ::com::sun::star::uno::Any SAL_CALL getValueByName( const OUString& Name )
+ throw (::com::sun::star::uno::RuntimeException, std::exception);
+};
+
+class SwMutexBase
+{
+public:
+ osl::Mutex m_aMutex;
+};
+
+class SW_DLLPUBLIC SwConnectionListener :
+ public SwMutexBase,
+ public cppu::WeakComponentImplHelper1< ::com::sun::star::mail::XConnectionListener >
+{
+ using cppu::WeakComponentImplHelperBase::disposing;
+
+public:
+ SwConnectionListener() :
+ cppu::WeakComponentImplHelper1< ::com::sun::star::mail::XConnectionListener>(m_aMutex)
+ {}
+ ~SwConnectionListener();
+
+ virtual void SAL_CALL connected(const ::com::sun::star::lang::EventObject& aEvent)
+ throw (::com::sun::star::uno::RuntimeException, std::exception);
+
+ virtual void SAL_CALL disconnected(const ::com::sun::star::lang::EventObject& aEvent)
+ throw (::com::sun::star::uno::RuntimeException, std::exception);
+
+ virtual void SAL_CALL disposing(const com::sun::star::lang::EventObject& aEvent)
+ throw(com::sun::star::uno::RuntimeException, std::exception);
+};
+
+class SwMailTransferable :
+ public SwMutexBase,
+ public cppu::WeakComponentImplHelper2
+ <
+ ::com::sun::star::datatransfer::XTransferable,
+ ::com::sun::star::beans::XPropertySet
+ >
+{
+ OUString m_aMimeType;
+ OUString m_sBody;
+ OUString m_aURL;
+ OUString m_aName;
+ bool m_bIsBody;
+
+ public:
+ SwMailTransferable(const OUString& rURL, const OUString& rName, const OUString& rMimeType);
+ SwMailTransferable(const OUString& rBody, const OUString& rMimeType);
+ ~SwMailTransferable();
+ virtual ::com::sun::star::uno::Any SAL_CALL
+ getTransferData( const ::com::sun::star::datatransfer::DataFlavor& aFlavor )
+ throw (::com::sun::star::datatransfer::UnsupportedFlavorException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, std::exception);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::datatransfer::DataFlavor > SAL_CALL
+ getTransferDataFlavors( )
+ throw (::com::sun::star::uno::RuntimeException, std::exception) ;
+ virtual ::sal_Bool SAL_CALL
+ isDataFlavorSupported( const ::com::sun::star::datatransfer::DataFlavor& aFlavor )
+ throw (::com::sun::star::uno::RuntimeException, std::exception);
+
+ //XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException, std::exception);
+ virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception);
+ virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception);
+ virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception);
+ virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception);
+ virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception);
+ virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception);
+
+};
+
+class SwMailMessage :
+ public SwMutexBase,
+ public cppu::WeakComponentImplHelper1< ::com::sun::star::mail::XMailMessage >
+{
+ OUString m_sSenderName;
+ OUString m_sSenderAddress;
+ OUString m_sReplyToAddress;
+ OUString m_sSubject;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable> m_xBody;
+// ::com::sun::star::mail::MailMessageBody m_aBody;
+
+ ::com::sun::star::uno::Sequence< OUString > m_aRecipients;
+ ::com::sun::star::uno::Sequence< OUString > m_aCcRecipients;
+ ::com::sun::star::uno::Sequence< OUString > m_aBccRecipients;
+// ::com::sun::star::uno::Sequence< ::com::sun::star::mail::MailAttachmentDescriptor > m_aAttachments;
+ ::com::sun::star::uno::Sequence< ::com::sun::star::mail::MailAttachment > m_aAttachments;
+public:
+ SwMailMessage();
+ ~SwMailMessage();
+
+ // attributes
+ virtual OUString SAL_CALL getSenderName() throw (::com::sun::star::uno::RuntimeException, std::exception);
+ virtual OUString SAL_CALL getSenderAddress() throw (::com::sun::star::uno::RuntimeException, std::exception);
+ virtual OUString SAL_CALL getReplyToAddress() throw (::com::sun::star::uno::RuntimeException, std::exception);
+ virtual void SAL_CALL setReplyToAddress( const OUString& _replytoaddress ) throw (::com::sun::star::uno::RuntimeException, std::exception);
+ virtual OUString SAL_CALL getSubject() throw (::com::sun::star::uno::RuntimeException, std::exception);
+ virtual void SAL_CALL setSubject( const OUString& _subject ) throw (::com::sun::star::uno::RuntimeException, std::exception);
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > SAL_CALL
+ getBody()
+ throw (::com::sun::star::uno::RuntimeException, std::exception);
+ virtual void SAL_CALL setBody( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& _body )
+ throw (::com::sun::star::uno::RuntimeException, std::exception);
+
+ // methods
+ virtual void SAL_CALL addRecipient( const OUString& sRecipientAddress ) throw (::com::sun::star::uno::RuntimeException, std::exception);
+ virtual void SAL_CALL addCcRecipient( const OUString& sRecipientAddress ) throw (::com::sun::star::uno::RuntimeException, std::exception);
+ virtual void SAL_CALL addBccRecipient( const OUString& sRecipientAddress ) throw (::com::sun::star::uno::RuntimeException, std::exception);
+ virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL
+ getRecipients( ) throw (::com::sun::star::uno::RuntimeException, std::exception);
+ virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL
+ getCcRecipients( ) throw (::com::sun::star::uno::RuntimeException, std::exception);
+ virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL
+ getBccRecipients( ) throw (::com::sun::star::uno::RuntimeException, std::exception);
+ virtual void SAL_CALL addAttachment( const ::com::sun::star::mail::MailAttachment& aMailAttachment )
+ throw (::com::sun::star::uno::RuntimeException, std::exception);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::mail::MailAttachment > SAL_CALL
+ getAttachments( ) throw (::com::sun::star::uno::RuntimeException, std::exception);
+ void SetSenderName(const OUString& rSenderName)
+ {m_sSenderName = rSenderName;}
+ void SetSenderAddress(const OUString& rSenderAddress)
+ {m_sSenderAddress = rSenderAddress;}
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/mailmergewizard.hxx b/sw/source/core/uibase/inc/mailmergewizard.hxx
new file mode 100644
index 000000000000..f7a3b2ce944f
--- /dev/null
+++ b/sw/source/core/uibase/inc/mailmergewizard.hxx
@@ -0,0 +1,97 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_MAILMERGEWIZARD_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_MAILMERGEWIZARD_HXX
+
+#include <svtools/roadmapwizard.hxx>
+#include "rtl/ustring.hxx"
+
+class SwView;
+class SwMailMergeConfigItem;
+
+#define MM_DOCUMENTSELECTPAGE 0
+#define MM_OUTPUTTYPETPAGE 1
+#define MM_ADDRESSBLOCKPAGE 2
+#define MM_GREETINGSPAGE 3
+#define MM_LAYOUTPAGE 4
+#define MM_PREPAREMERGEPAGE 5
+#define MM_MERGEPAGE 6
+#define MM_OUTPUTPAGE 7
+
+class SwMailMergeWizard : public ::svt::RoadmapWizard
+{
+ SwView* m_pSwView;
+ OUString sDocumentURL;
+ bool m_bDocumentLoad;
+
+ SwMailMergeConfigItem& m_rConfigItem;
+
+ OUString m_sStarting;
+ OUString m_sDocumentType;
+ OUString m_sAddressBlock;
+ OUString m_sAddressList;
+ OUString m_sGreetingsLine;
+ OUString m_sLayout;
+ OUString m_sPrepareMerge;
+ OUString m_sMerge;
+ OUString m_sOutput;
+ OUString m_sFinish;
+
+ sal_uInt16 m_nRestartPage;
+
+ using svt::OWizardMachine::skipUntil;
+
+protected:
+ virtual svt::OWizardPage* createPage(WizardState _nState);
+ virtual void enterState( WizardState _nState );
+
+// roadmap feature ??
+// virtual sal_Bool prepareLeaveCurrentState( CommitPageReason _eReason );
+ virtual OUString getStateDisplayName( WizardState _nState ) const;
+
+public:
+ SwMailMergeWizard(SwView& rView, SwMailMergeConfigItem& rConfigItem);
+ ~SwMailMergeWizard();
+
+ SwView* GetSwView() {return m_pSwView;}
+ SwMailMergeConfigItem& GetConfigItem() { return m_rConfigItem;}
+
+ void SetReloadDocument(const OUString& rURL) {sDocumentURL = rURL;}
+ OUString GetReloadDocument() const {return sDocumentURL;}
+
+ //next step requires loading of document
+ void SetDocumentLoad(bool bSet) {m_bDocumentLoad = bSet;}
+
+ void UpdateRoadmap();
+ void CreateTargetDocument();
+
+ sal_uInt16 GetRestartPage() const {return m_nRestartPage;}
+ void SetRestartPage(sal_uInt16 nPage) { m_nRestartPage = nPage;}
+
+ sal_Bool skipUntil( sal_uInt16 nPage)
+ {return ::svt::RoadmapWizard::skipUntil(WizardState(nPage));}
+
+ void updateRoadmapItemLabel( WizardState _nState );
+
+ virtual short Execute();
+ virtual void StartExecuteModal( const Link& rEndDialogHdl );
+};
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/mailmrge.hxx b/sw/source/core/uibase/inc/mailmrge.hxx
new file mode 100644
index 000000000000..c59bfda286f8
--- /dev/null
+++ b/sw/source/core/uibase/inc/mailmrge.hxx
@@ -0,0 +1,176 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_MAILMRGE_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_MAILMRGE_HXX
+
+#include <svx/stddlg.hxx>
+
+#include <vcl/button.hxx>
+
+#include <vcl/field.hxx>
+
+#include <vcl/fixed.hxx>
+#include <vcl/edit.hxx>
+#include <svtools/stdctrl.hxx>
+
+#include <vcl/lstbox.hxx>
+#include <com/sun/star/uno/Sequence.h>
+#include <com/sun/star/uno/Reference.h>
+
+class SwWrtShell;
+class SwModuleOptions;
+class SwXSelChgLstnr_Impl;
+struct SwMailMergeDlg_Impl;
+namespace com{namespace sun{namespace star{
+ namespace frame{
+ class XFrame2;
+ }
+ namespace sdbc{
+ class XResultSet;
+ class XConnection;
+ }
+}}}
+
+class SwMailMergeDlg : public SvxStandardDialog
+{
+ friend class SwXSelChgLstnr_Impl;
+
+ Window* pBeamerWin;
+
+ RadioButton aAllRB;
+ RadioButton aMarkedRB;
+ RadioButton aFromRB;
+ NumericField aFromNF;
+ FixedText aBisFT;
+ NumericField aToNF;
+ FixedLine aRecordFL;
+
+ FixedLine aSeparatorFL;
+
+ RadioButton aPrinterRB;
+ RadioButton aMailingRB;
+ RadioButton aFileRB;
+
+ CheckBox aSingleJobsCB;
+
+ FixedLine aSaveMergedDocumentFL;
+ RadioButton aSaveSingleDocRB;
+ RadioButton aSaveIndividualRB;
+
+ CheckBox aGenerateFromDataBaseCB;
+
+ FixedText aColumnFT;
+ ListBox aColumnLB;
+ FixedText aPathFT;
+ Edit aPathED;
+ PushButton aPathPB;
+ FixedText aFilterFT;
+ ListBox aFilterLB;
+
+ ListBox aAddressFldLB;
+ FixedText aSubjectFT;
+ Edit aSubjectED;
+ FixedText aFormatFT;
+ FixedText aAttachFT;
+ Edit aAttachED;
+ PushButton aAttachPB;
+ CheckBox aFormatHtmlCB;
+ CheckBox aFormatRtfCB;
+ CheckBox aFormatSwCB;
+ FixedLine aDestFL;
+
+ FixedLine aBottomSeparatorFL;
+
+ OKButton aOkBTN;
+ CancelButton aCancelBTN;
+ HelpButton aHelpBTN;
+
+ SwMailMergeDlg_Impl* pImpl;
+
+ SwWrtShell& rSh;
+ SwModuleOptions* pModOpt;
+ OUString rDBName;
+ OUString rTableName;
+
+ sal_uInt16 nMergeType;
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > m_aSelection;
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame2 > m_xFrame;
+
+ Size m_aDialogSize;
+ OUString m_sSaveFilter;
+
+ DECL_LINK( ButtonHdl, Button* pBtn );
+ DECL_LINK(InsertPathHdl, void *);
+ DECL_LINK(AttachFileHdl, void *);
+ DECL_LINK( OutputTypeHdl, RadioButton* pBtn );
+ DECL_LINK( FilenameHdl, CheckBox* pBtn );
+ DECL_LINK(ModifyHdl, void *);
+ DECL_LINK( SaveTypeHdl, RadioButton* pBtn );
+
+ virtual void Apply();
+ virtual void Resize();
+ bool ExecQryShell();
+
+public:
+ SwMailMergeDlg(Window* pParent, SwWrtShell& rSh,
+ const OUString& rSourceName,
+ const OUString& rTblName,
+ sal_Int32 nCommandType,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& xConnection,
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >* pSelection = 0);
+ ~SwMailMergeDlg();
+
+ inline sal_uInt16 GetMergeType() { return nMergeType; }
+
+ bool IsSaveIndividualDocs() const { return aSaveIndividualRB.IsChecked(); }
+ bool IsGenerateFromDataBase() const { return aGenerateFromDataBaseCB.IsChecked(); }
+ OUString GetColumnName() const { return aColumnLB.GetSelectEntry();}
+ OUString GetPath() const { return aPathED.GetText();}
+
+ const OUString& GetSaveFilter() const {return m_sSaveFilter;}
+ inline const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > GetSelection() const { return m_aSelection; }
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet> GetResultSet() const;
+
+};
+
+class SwMailMergeCreateFromDlg : public ModalDialog
+{
+ RadioButton* m_pThisDocRB;
+public:
+ SwMailMergeCreateFromDlg(Window* pParent);
+ bool IsThisDocument() const
+ {
+ return m_pThisDocRB->IsChecked();
+ }
+};
+
+class SwMailMergeFieldConnectionsDlg : public ModalDialog
+{
+ RadioButton* m_pUseExistingRB;
+public:
+ SwMailMergeFieldConnectionsDlg(Window* pParent);
+ bool IsUseExistingConnections() const
+ {
+ return m_pUseExistingRB->IsChecked();
+ }
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/mediash.hxx b/sw/source/core/uibase/inc/mediash.hxx
new file mode 100644
index 000000000000..8d8cfd7b23b4
--- /dev/null
+++ b/sw/source/core/uibase/inc/mediash.hxx
@@ -0,0 +1,37 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_MEDIASH_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_MEDIASH_HXX
+
+#include "frmsh.hxx"
+
+class SwMediaShell: public SwBaseShell
+{
+public:
+ SFX_DECL_INTERFACE(SW_MEDIASHELL)
+
+ void ExecMedia(SfxRequest &);
+ void GetMediaState(SfxItemSet &);
+
+ SwMediaShell(SwView &rView);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/mergetbl.hxx b/sw/source/core/uibase/inc/mergetbl.hxx
new file mode 100644
index 000000000000..3926c21b7376
--- /dev/null
+++ b/sw/source/core/uibase/inc/mergetbl.hxx
@@ -0,0 +1,41 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_MERGETBL_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_MERGETBL_HXX
+
+#include <vcl/button.hxx>
+
+#include <vcl/fixed.hxx>
+#include <svx/stddlg.hxx>
+
+class SwMergeTblDlg : public SvxStandardDialog
+{
+ RadioButton* m_pMergePrevRB;
+
+ sal_Bool& m_rMergePrev;
+protected:
+ virtual void Apply();
+
+public:
+ SwMergeTblDlg( Window *pParent, sal_Bool& rWithPrev );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/misc.hrc b/sw/source/core/uibase/inc/misc.hrc
new file mode 100644
index 000000000000..95113ff989f2
--- /dev/null
+++ b/sw/source/core/uibase/inc/misc.hrc
@@ -0,0 +1,60 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef _MISC_HRC
+#define _MISC_HRC
+
+#include "rcid.hrc"
+
+#define DLG_INSERT_BOOKMARK (RC_MISC_BEGIN + 17)
+#define DLG_NUM_NAMES (RC_MISC_BEGIN + 18)
+#define DLG_SORTING (RC_MISC_BEGIN + 19)
+
+#define DLG_TAB_OUTLINE (RC_MISC_BEGIN + 31)
+
+#define MSG_DOUBLE_SHORTNAME (RC_MISC_BEGIN + 30)
+#define MSG_QUERY_DELETE (RC_MISC_BEGIN + 31)
+#define STR_QUERY_DELETE_GROUP1 (RC_MISC_BEGIN + 32)
+#define STR_QUERY_DELETE_GROUP2 (RC_MISC_BEGIN + 33)
+#define MSG_NO_GLOSSARIES (RC_MISC_BEGIN + 34)
+
+#define MSG_SRTERR (RC_MISC_BEGIN + 42)
+
+#define STR_GLOSSARY (RC_MISC_BEGIN + 43)
+#define STR_CHANGE_START (RC_MISC_BEGIN + 44)
+#define STR_CHANGE_END (RC_MISC_BEGIN + 45)
+#define STR_SAVE_GLOSSARY (RC_MISC_BEGIN + 46)
+
+#define MN_REDLINE_POPUP (RC_MISC_BEGIN + 61)
+#define STRRES_NUMTYPES (RC_MISC_BEGIN + 63)
+#define STR_MY_AUTOTEXT (RC_MISC_BEGIN + 64)
+
+#define STR_COMMENTS_LABEL (RC_MISC_BEGIN + 65)
+#define STR_SHOW_COMMENTS (RC_MISC_BEGIN + 66)
+#define STR_HIDE_COMMENTS (RC_MISC_BEGIN + 67)
+
+#define MISC_ACT_END STR_HIDE_COMMENTS
+
+#if MISC_ACT_END > RC_MISC_END
+#error Resource-Id Ueberlauf in #file, #line
+#endif
+
+#endif // _MISC_HRC
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/mmconfigitem.hxx b/sw/source/core/uibase/inc/mmconfigitem.hxx
new file mode 100644
index 000000000000..8e53939f4bf8
--- /dev/null
+++ b/sw/source/core/uibase/inc/mmconfigitem.hxx
@@ -0,0 +1,270 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_MMCONFIGITEM_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_MMCONFIGITEM_HXX
+
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+#include <tools/resary.hxx>
+#include <swdbdata.hxx>
+#include "swdllapi.h"
+#include "sharedconnection.hxx"
+
+namespace com{namespace sun{namespace star{
+ namespace sdbc{
+ class XDataSource;
+ class XResultSet;
+ }
+ namespace sdbcx{
+ class XColumnsSupplier;
+ }
+}}}
+
+class SwMailMergeConfigItem_Impl;
+class SwView;
+
+struct SwDocMergeInfo
+{
+ long nStartPageInTarget;
+ long nEndPageInTarget;
+ long nDBRow;
+};
+
+class SW_DLLPUBLIC SwMailMergeConfigItem
+{
+// com::sun::star::uno::Sequence< OUString> m_aSavedDocuments;
+ SwMailMergeConfigItem_Impl* m_pImpl;
+ //session information - not stored in configuration
+ bool m_bAddressInserted;
+ bool m_bMergeDone;
+ bool m_bGreetingInserted;
+ sal_Int32 m_nGreetingMoves;
+ OUString m_rAddressBlockFrame;
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any> m_aSelection;
+
+ sal_uInt16 m_nStartPrint;
+ sal_uInt16 m_nEndPrint;
+
+ OUString m_sSelectedPrinter;
+
+ SwView* m_pSourceView;
+ SwView* m_pTargetView;
+public:
+ SwMailMergeConfigItem();
+ ~SwMailMergeConfigItem();
+
+ enum Gender
+ {
+ FEMALE,
+ MALE,
+ NEUTRAL
+ };
+
+ void Commit();
+
+ const ResStringArray& GetDefaultAddressHeaders() const;
+
+ void SetCurrentConnection(
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource> xSource,
+ SharedConnection xConnection,
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XColumnsSupplier> xColumnsSupplier,
+ const SwDBData& rDBData);
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource>
+ GetSource();
+
+ SharedConnection GetConnection();
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XColumnsSupplier>
+ GetColumnsSupplier();
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>
+ GetResultSet() const;
+
+ void DisposeResultSet();
+
+ OUString& GetFilter() const;
+ void SetFilter(OUString&);
+
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any>
+ GetSelection()const;
+ void SetSelection(::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > rSelection);
+
+ void SetCurrentDBData( const SwDBData& rDBData);
+ const SwDBData& GetCurrentDBData() const;
+
+ // move absolute, nTarget == -1 -> goto last record
+ sal_Int32 MoveResultSet(sal_Int32 nTarget);
+ sal_Int32 GetResultSetPosition()const;
+ bool IsResultSetFirstLast(bool& bIsFirst, bool& bIsLast);
+
+ bool IsRecordExcluded(sal_Int32 nRecord);
+ void ExcludeRecord(sal_Int32 nRecord, bool bExclude);
+
+ const com::sun::star::uno::Sequence< OUString>&
+ GetSavedDocuments() const;
+ void AddSavedDocument(OUString rName);
+
+ sal_Bool IsOutputToLetter()const;
+ void SetOutputToLetter(sal_Bool bSet);
+
+ bool IsAddressBlock()const;
+ void SetAddressBlock(sal_Bool bSet);
+
+ sal_Bool IsHideEmptyParagraphs() const;
+ void SetHideEmptyParagraphs(sal_Bool bSet);
+
+ const com::sun::star::uno::Sequence< OUString>
+ GetAddressBlocks() const;
+ void SetAddressBlocks(const com::sun::star::uno::Sequence< OUString>& rBlocks);
+
+ void SetCurrentAddressBlockIndex( sal_Int32 nSet );
+ sal_Int32 GetCurrentAddressBlockIndex() const;
+
+ sal_Bool IsIncludeCountry() const;
+ OUString& GetExcludeCountry() const;
+ void SetCountrySettings(sal_Bool bSet, const OUString& sCountry);
+
+ sal_Bool IsIndividualGreeting(sal_Bool bInEMail) const;
+ void SetIndividualGreeting(sal_Bool bSet, sal_Bool bInEMail);
+
+ sal_Bool IsGreetingLine(sal_Bool bInEMail) const;
+ void SetGreetingLine(sal_Bool bSet, sal_Bool bInEMail);
+
+ const com::sun::star::uno::Sequence< OUString>
+ GetGreetings(Gender eType) const;
+ void SetGreetings(Gender eType, const com::sun::star::uno::Sequence< OUString>& rBlocks);
+
+ sal_Int32 GetCurrentGreeting(Gender eType) const;
+ void SetCurrentGreeting(Gender eType, sal_Int32 nIndex);
+
+ //the content of the gender column that marks it as female
+ const OUString& GetFemaleGenderValue() const;
+ void SetFemaleGenderValue(const OUString rValue);
+
+ //returns the assignment in the order of the default headers (GetDefaultAddressHeaders())
+ com::sun::star::uno::Sequence< OUString >
+ GetColumnAssignment( const SwDBData& rDBData ) const;
+ void SetColumnAssignment(
+ const SwDBData& rDBData,
+ const com::sun::star::uno::Sequence< OUString>& );
+
+ bool IsAddressFieldsAssigned() const;
+ bool IsGreetingFieldsAssigned() const;
+
+ //e-Mail settings:
+ OUString GetMailDisplayName() const;
+ void SetMailDisplayName(const OUString& rName);
+
+ OUString GetMailAddress() const;
+ void SetMailAddress(const OUString& rAddress);
+
+ sal_Bool IsMailReplyTo() const;
+ void SetMailReplyTo(sal_Bool bSet);
+
+ OUString GetMailReplyTo() const;
+ void SetMailReplyTo(const OUString& rReplyTo);
+
+ OUString GetMailServer() const;
+ void SetMailServer(const OUString& rAddress);
+
+ sal_Int16 GetMailPort() const;
+ void SetMailPort(sal_Int16 nSet);
+
+ sal_Bool IsSecureConnection() const;
+ void SetSecureConnection(sal_Bool bSet);
+
+ sal_Bool IsAuthentication() const;
+ void SetAuthentication(sal_Bool bSet);
+
+ OUString GetMailUserName() const;
+ void SetMailUserName(const OUString& rName);
+
+ OUString GetMailPassword() const;
+ void SetMailPassword(const OUString& rPassword);
+
+ sal_Bool IsSMTPAfterPOP() const;
+ void SetSMTPAfterPOP(sal_Bool bSet);
+
+ OUString GetInServerName() const;
+ void SetInServerName(const OUString& rServer);
+
+ sal_Int16 GetInServerPort() const;
+ void SetInServerPort(sal_Int16 nSet);
+
+ sal_Bool IsInServerPOP() const;
+ void SetInServerPOP(sal_Bool bSet);
+
+ OUString GetInServerUserName() const;
+ void SetInServerUserName(const OUString& rName);
+
+ OUString GetInServerPassword() const;
+ void SetInServerPassword(const OUString& rPassword);
+
+ //session information
+ bool IsAddressInserted() const { return m_bAddressInserted; }
+ void SetAddressInserted(const OUString& rFrameName)
+ { m_bAddressInserted = true;
+ m_rAddressBlockFrame = rFrameName;
+ }
+
+ bool IsGreetingInserted() const { return m_bGreetingInserted; }
+ void SetGreetingInserted()
+ { m_bGreetingInserted = true; }
+
+ // counts the moves in the layout page
+ void MoveGreeting( sal_Int32 nMove) { m_nGreetingMoves += nMove;}
+ sal_Int32 GetGreetingMoves() const { return m_nGreetingMoves;}
+
+ bool IsMergeDone() const { return m_bMergeDone;}
+ void SetMergeDone( ) { m_bMergeDone = true; }
+
+ // new source document - reset some flags
+ void DocumentReloaded();
+
+ bool IsMailAvailable() const;
+
+ // notify a completed merge, provid the appropriate e-Mail address if available
+ void AddMergedDocument(SwDocMergeInfo& rInfo);
+ //returns the page and database cursor information of each merged document
+ SwDocMergeInfo& GetDocumentMergeInfo(sal_uInt32 nDocument);
+ sal_uInt32 GetMergedDocumentCount() const;
+
+ void SetPrintRange( sal_uInt16 nStartDocument, sal_uInt16 nEndDocument)
+ {m_nStartPrint = nStartDocument; m_nEndPrint = nEndDocument;}
+ sal_uInt16 GetPrintRangeStart() const {return m_nStartPrint;}
+ sal_uInt16 GetPrintRangeEnd() const {return m_nEndPrint;}
+
+ const OUString& GetSelectedPrinter() const {return m_sSelectedPrinter;}
+ void SetSelectedPrinter(const OUString& rSet )
+ {m_sSelectedPrinter = rSet;}
+
+ SwView* GetTargetView();
+ void SetTargetView(SwView* pView);
+
+ SwView* GetSourceView();
+ void SetSourceView(SwView* pView);
+
+ //helper methods
+ OUString GetAssignedColumn(sal_uInt32 nColumn)const;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/multmrk.hxx b/sw/source/core/uibase/inc/multmrk.hxx
new file mode 100644
index 000000000000..b98192765931
--- /dev/null
+++ b/sw/source/core/uibase/inc/multmrk.hxx
@@ -0,0 +1,53 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SW_SOURCE_UI_INC_MULTMRK_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_MULTMRK_HXX
+
+#include <svx/stddlg.hxx>
+#include <vcl/fixed.hxx>
+#include <svtools/stdctrl.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/button.hxx>
+
+class SwTOXMgr;
+
+/*--------------------------------------------------------------------
+ Description: insert mark for index entry
+ --------------------------------------------------------------------*/
+
+class SwMultiTOXMarkDlg : public SvxStandardDialog
+{
+ DECL_LINK( SelectHdl, ListBox * );
+
+ FixedText* m_pTextFT;
+ ListBox* m_pTOXLB;
+
+ SwTOXMgr& rMgr;
+ sal_uInt16 nPos;
+
+ void Apply();
+public:
+ SwMultiTOXMarkDlg( Window* pParent, SwTOXMgr &rTOXMgr );
+ ~SwMultiTOXMarkDlg();
+};
+
+#endif // INCLUDED_SW_SOURCE_UI_INC_MULTMRK_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/navicfg.hxx b/sw/source/core/uibase/inc/navicfg.hxx
new file mode 100644
index 000000000000..77a14d667166
--- /dev/null
+++ b/sw/source/core/uibase/inc/navicfg.hxx
@@ -0,0 +1,109 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_NAVICFG_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_NAVICFG_HXX
+
+#include <unotools/configitem.hxx>
+
+class SwNavigationConfig : public utl::ConfigItem
+{
+ sal_Int32 nRootType; //RootType
+ sal_Int32 nSelectedPos; //SelectedPosition
+ sal_Int32 nOutlineLevel; //OutlineLevel
+ sal_Int32 nRegionMode; //InsertMode
+ sal_Int32 nActiveBlock; //ActiveBlock//Expand/CollapsState
+ sal_Bool bIsSmall; //ShowListBox
+ sal_Bool bIsGlobalActive; //GlobalDocMode// global view for GlobalDoc valid?
+
+ com::sun::star::uno::Sequence<OUString> GetPropertyNames();
+
+public:
+ SwNavigationConfig();
+ ~SwNavigationConfig();
+
+ virtual void Commit();
+ virtual void Notify( const ::com::sun::star::uno::Sequence< OUString >& aPropertyNames );
+
+ sal_Int32 GetRootType()const {return nRootType;}
+ void SetRootType(sal_Int32 nSet){
+ if(nRootType != nSet)
+ {
+ SetModified();
+ nRootType = nSet;
+ }
+ }
+
+ sal_Int32 GetSelectedPos()const {return nSelectedPos;}
+ void SetSelectedPos(sal_Int32 nSet){
+ if(nSelectedPos != nSet)
+ {
+ SetModified();
+ nSelectedPos = nSet;
+ }
+ }
+
+ sal_Int32 GetOutlineLevel()const {return nOutlineLevel;}
+ void SetOutlineLevel(sal_Int32 nSet){
+ if(nOutlineLevel != nSet)
+ {
+ SetModified();
+ nOutlineLevel = nSet;
+ }
+ }
+
+ sal_Int32 GetRegionMode()const {return nRegionMode;}
+ void SetRegionMode(sal_Int32 nSet){
+ if(nRegionMode != nSet)
+ {
+ SetModified();
+ nRegionMode = nSet;
+ }
+ }
+
+ sal_Int32 GetActiveBlock()const {return nActiveBlock;}
+ void SetActiveBlock(sal_Int32 nSet){
+ if(nActiveBlock != nSet)
+ {
+ SetModified();
+ nActiveBlock = nSet;
+ }
+ }
+
+ sal_Bool IsSmall() const {return bIsSmall;}
+ void SetSmall(sal_Bool bSet){
+ if(bIsSmall != bSet)
+ {
+ SetModified();
+ bIsSmall = bSet;
+ }
+ }
+
+ sal_Bool IsGlobalActive() const {return bIsGlobalActive;}
+ void SetGlobalActive(sal_Bool bSet){
+ if(bIsGlobalActive != bSet)
+ {
+ SetModified();
+ bIsGlobalActive = bSet;
+ }
+ }
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/navicont.hxx b/sw/source/core/uibase/inc/navicont.hxx
new file mode 100644
index 000000000000..d04035ab1a72
--- /dev/null
+++ b/sw/source/core/uibase/inc/navicont.hxx
@@ -0,0 +1,54 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SW_SOURCE_UI_INC_NAVICONT_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_NAVICONT_HXX
+
+#include <rtl/ustring.hxx>
+
+class SwDocShell;
+class TransferDataContainer;
+class TransferableDataHelper;
+
+/*
+ navigator bookmark for distinct identification in Sw
+*/
+
+class NaviContentBookmark
+{
+ OUString aUrl; // URL including jump mark
+ OUString aDescr; // description
+ long nDocSh; // address of DocShell
+ sal_uInt16 nDefDrag; // description contains defaultDragType
+
+public:
+ NaviContentBookmark();
+ NaviContentBookmark( const OUString &rUrl, const OUString& rDesc,
+ sal_uInt16 nDragType, const SwDocShell* );
+
+ const OUString& GetURL() const { return aUrl; }
+ const OUString& GetDescription() const { return aDescr; }
+ sal_uInt16 GetDefaultDragType() const { return nDefDrag; }
+ void Copy( TransferDataContainer& rData ) const;
+ sal_Bool Paste( TransferableDataHelper& rData );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/navipi.hxx b/sw/source/core/uibase/inc/navipi.hxx
new file mode 100644
index 000000000000..04a6c269c706
--- /dev/null
+++ b/sw/source/core/uibase/inc/navipi.hxx
@@ -0,0 +1,186 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_NAVIPI_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_NAVIPI_HXX
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <vcl/lstbox.hxx>
+#include <svl/lstner.hxx>
+#include <svtools/transfer.hxx>
+#include <sfx2/childwin.hxx>
+#include <sfx2/ctrlitem.hxx>
+#include <sfx2/tbxctrl.hxx>
+#include <conttree.hxx>
+#include <popbox.hxx>
+
+class SwWrtShell;
+class SwNavigationPI;
+class SwNavigationChild;
+class SfxBindings;
+class NumEditAction;
+class SwView;
+class SwNavigationConfig;
+class SfxObjectShellLock;
+class SfxChildWindowContext;
+class SwNavigationPI;
+
+class SwNavHelpToolBox : public SwHelpToolBox
+{
+ virtual void MouseButtonDown(const MouseEvent &rEvt);
+ virtual void RequestHelp( const HelpEvent& rHEvt );
+ public:
+ SwNavHelpToolBox(SwNavigationPI* pParent, const ResId &rResId);
+};
+
+// CLASS -----------------------------------------------------------------
+class SwNavigationPI : public Window,
+ public SfxControllerItem, public SfxListener
+{
+ friend class SwNavigationChild;
+ friend class SwContentTree;
+ friend class SwGlobalTree;
+
+ // --------- members -----------------------------
+ SwNavHelpToolBox aContentToolBox;
+ SwHelpToolBox aGlobalToolBox;
+ ImageList aContentImageList;
+ SwContentTree aContentTree;
+ SwGlobalTree aGlobalTree;
+ ListBox aDocListBox;
+ Timer aPageChgTimer;
+ OUString sContentFileName;
+ OUString aContextArr[3];
+ OUString aStatusArr[4];
+ Point aBoxBottomLeft; // Pos when Box is at bottom
+
+ SfxObjectShellLock *pxObjectShell;
+ SwView *pContentView;
+ SwWrtShell *pContentWrtShell;
+ SwView *pActContView;
+ SwView *pCreateView;
+ SfxPopupWindow *pPopupWindow;
+ SfxPopupWindow *pFloatingWindow;
+
+ SfxChildWindowContext* pContextWin;
+
+ SwNavigationConfig *pConfig;
+ SfxBindings &rBindings;
+
+ long nDocLBIniHeight;
+ long nWishWidth;
+ sal_uInt16 nAutoMarkIdx;
+ sal_uInt16 nRegionMode; // 0 - URL, 1 - region with link 2 - region without link
+ short nZoomIn;
+ short nZoomOutInit;
+ short nZoomOut;
+
+ sal_Bool bSmallMode : 1;
+ sal_Bool bIsZoomedIn : 1;
+ sal_Bool bPageCtrlsVisible : 1;
+ sal_Bool bGlobalMode : 1;
+
+ // --------- methods -----------------------------
+ sal_Bool _IsZoomedIn() const {return bIsZoomedIn;}
+ void _ZoomOut();
+ void _ZoomIn();
+
+ void FillBox();
+ void MakeMark();
+
+ DECL_LINK( DocListBoxSelectHdl, ListBox * );
+ DECL_LINK( ToolBoxSelectHdl, ToolBox * );
+ DECL_LINK( ToolBoxClickHdl, ToolBox * );
+ DECL_LINK( ToolBoxDropdownClickHdl, ToolBox* );
+ DECL_LINK( EditAction, NumEditAction * );
+ DECL_LINK( EditGetFocus, NumEditAction * );
+ DECL_LINK( DoneLink, SfxPoolItem * );
+ DECL_LINK( MenuSelectHdl, Menu * );
+ DECL_LINK( ChangePageHdl, void* );
+ DECL_LINK( PageEditModifyHdl, void* );
+ DECL_LINK( PopupModeEndHdl, void * );
+ DECL_LINK( ClosePopupWindow, SfxPopupWindow * );
+ void UsePage(SwWrtShell *);
+
+ void MakeVisible();
+ void InitImageList();
+ virtual SfxChildAlignment
+ CheckAlignment(SfxChildAlignment,SfxChildAlignment);
+ void SetPopupWindow( SfxPopupWindow* );
+
+ using Window::Notify;
+ using Window::StateChanged;
+
+protected:
+
+ virtual sal_Bool Close();
+ virtual void Resize();
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+
+ // release ObjectShellLock early enough for app end
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+
+ NumEditAction& GetPageEdit();
+ sal_Bool ToggleTree();
+ void SetGlobalMode(sal_Bool bSet) {bGlobalMode = bSet;}
+
+public:
+
+ SwNavigationPI(SfxBindings*, SfxChildWindowContext*, Window*);
+ ~SwNavigationPI();
+
+ void GotoPage(); // jump to page; bindable function
+
+ void Update() { FillBox(); }
+ void UpdateListBox();
+ void MoveOutline(sal_uInt16 nSource, sal_uInt16 nTarget, bool bWithCilds);
+
+ virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState,
+ const SfxPoolItem* pState );
+
+ static OUString CreateDropFileName( TransferableDataHelper& rData );
+ static OUString CleanEntry(const OUString& rEntry);
+
+ sal_uInt16 GetRegionDropMode() const {return nRegionMode;}
+ void SetRegionDropMode(sal_uInt16 nNewMode);
+
+ sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
+ sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
+
+ sal_Bool IsGlobalDoc() const;
+ sal_Bool IsGlobalMode() const {return bGlobalMode;}
+
+ SwView* GetCreateView() const;
+ void CreateNavigationTool(const Rectangle& rRect, bool bSetFocus, Window *pParent);
+};
+
+class SwNavigationChild : public SfxChildWindowContext
+{
+public:
+ SwNavigationChild( Window* ,
+ sal_uInt16 nId,
+ SfxBindings*,
+ SfxChildWinInfo* );
+
+ SFX_DECL_CHILDWINDOW_CONTEXT( SwNavigationChild )
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/navmgr.hxx b/sw/source/core/uibase/inc/navmgr.hxx
new file mode 100644
index 000000000000..0ef4af93a1f6
--- /dev/null
+++ b/sw/source/core/uibase/inc/navmgr.hxx
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_NAVMGR_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_NAVMGR_HXX
+
+#include <vector>
+
+#include <boost/shared_ptr.hpp>
+
+#include "swtypes.hxx"
+
+class SwWrtShell;
+struct SwPosition;
+class SwUnoCrsr;
+
+class SwNavigationMgr
+{
+private:
+ /*
+ * List of entries in the navigation history
+ * Entries are SwUnoCrsr because thos gets corrected automatically
+ * when nodes are deleted.
+ *
+ * The navigation history behaves as a stack, to which items are added when we jump to a new position
+ * (e.g. click a link, or double click an entry from the navigator).
+ * Every use of the back/forward buttons results in moving the stack pointer within the navigation history
+ */
+ typedef ::std::vector< ::boost::shared_ptr<SwUnoCrsr> > Stack_t;
+ Stack_t m_entries;
+ Stack_t::size_type m_nCurrent; /* Current position within the navigation history */
+ SwWrtShell & m_rMyShell; /* The active shell within which the navigation occurs */
+
+ void GotoSwPosition(const SwPosition &rPos);
+
+public:
+ /* Constructor that initializes the shell to the current shell */
+ SwNavigationMgr( SwWrtShell & rShell );
+ /* Can we go back in the history ? */
+ bool backEnabled() ;
+ /* Can we go forward in the history ? */
+ bool forwardEnabled();
+ /* The method that is called when we click the back button */
+ void goBack() ;
+ /* The method that is called when we click the forward button */
+ void goForward() ;
+ /* The method that adds the position pPos to the navigation history */
+ bool addEntry(const SwPosition& rPos);
+};
+#endif
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/navsh.hxx b/sw/source/core/uibase/inc/navsh.hxx
new file mode 100644
index 000000000000..d05983a3948c
--- /dev/null
+++ b/sw/source/core/uibase/inc/navsh.hxx
@@ -0,0 +1,28 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_NAVSH_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_NAVSH_HXX
+
+#include "frmsh.hxx"
+
+class SfxItemSet;
+
+class SwNavigationShell: public SwBaseShell
+{
+public:
+ SFX_DECL_INTERFACE(SW_NAVIGATIONSHELL)
+
+ SwNavigationShell(SwView &rView);
+
+ void GetState(SfxItemSet &);
+ void Execute(SfxRequest &);
+};
+
+#endif
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/num.hxx b/sw/source/core/uibase/inc/num.hxx
new file mode 100644
index 000000000000..67d107588265
--- /dev/null
+++ b/sw/source/core/uibase/inc/num.hxx
@@ -0,0 +1,166 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_NUM_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_NUM_HXX
+
+#include <sfx2/tabdlg.hxx>
+#include <vcl/menubtn.hxx>
+#include <vcl/field.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/layout.hxx>
+#include <svtools/stdctrl.hxx>
+#include <vcl/button.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/edit.hxx>
+#include <svx/stddlg.hxx>
+#include <numprevw.hxx>
+#include "numrule.hxx"
+
+class SwWrtShell;
+class SvxBrushItem;
+class SwOutlineTabDialog;
+
+struct SwBmpItemInfo
+{
+ SvxBrushItem* pBrushItem;
+ sal_uInt16 nItemId;
+};
+
+#define NUM_PAGETYPE_BULLET 0
+#define NUM_PAGETYPE_SINGLENUM 1
+#define NUM_PAGETYPE_NUM 2
+#define NUM_PAGETYPE_BMP 3
+#define PAGETYPE_USER_START 10
+
+class SwNumPositionTabPage : public SfxTabPage
+{
+ ListBox* m_pLevelLB;
+ VclFrame* m_pPositionFrame;
+
+ // former set of controls shown for numbering rules containing list level
+ // attributes in SvxNumberFormat::SvxNumPositionAndSpaceMode == LABEL_WIDTH_AND_POSITION
+ FixedText* m_pDistBorderFT;
+ MetricField* m_pDistBorderMF;
+ CheckBox* m_pRelativeCB;
+ FixedText* m_pIndentFT;
+ MetricField* m_pIndentMF;
+ FixedText* m_pDistNumFT;
+ MetricField* m_pDistNumMF;
+ FixedText* m_pAlignFT;
+ ListBox* m_pAlignLB;
+
+ // new set of controls shown for numbering rules containing list level
+ // attributes in SvxNumberFormat::SvxNumPositionAndSpaceMode == LABEL_ALIGNMENT
+ FixedText* m_pLabelFollowedByFT;
+ ListBox* m_pLabelFollowedByLB;
+ FixedText* m_pListtabFT;
+ MetricField* m_pListtabMF;
+ FixedText* m_pAlign2FT;
+ ListBox* m_pAlign2LB;
+ FixedText* m_pAlignedAtFT;
+ MetricField* m_pAlignedAtMF;
+ FixedText* m_pIndentAtFT;
+ MetricField* m_pIndentAtMF;
+
+ PushButton* m_pStandardPB;
+
+ NumberingPreview* m_pPreviewWIN;
+
+ SwNumRule* pActNum;
+ SwNumRule* pSaveNum;
+ SwWrtShell* pWrtSh;
+
+ SwOutlineTabDialog* pOutlineDlg;
+ sal_uInt16 nActNumLvl;
+
+ sal_Bool bModified : 1;
+ sal_Bool bPreset : 1;
+ sal_Bool bInInintControl : 1; // work around modify-error; should be resolved from 391 on
+ bool bLabelAlignmentPosAndSpaceModeActive;
+
+ void InitControls();
+
+ DECL_LINK( LevelHdl, ListBox * );
+ DECL_LINK(EditModifyHdl, void *);
+ DECL_LINK( DistanceHdl, MetricField * );
+ DECL_LINK( RelativeHdl, CheckBox * );
+ DECL_LINK(StandardHdl, void *);
+
+ void InitPosAndSpaceMode();
+ void ShowControlsDependingOnPosAndSpaceMode();
+
+ DECL_LINK(LabelFollowedByHdl_Impl, void *);
+ DECL_LINK( ListtabPosHdl_Impl, MetricField* );
+ DECL_LINK( AlignAtHdl_Impl, MetricField* );
+ DECL_LINK( IndentAtHdl_Impl, MetricField* );
+
+ using SfxTabPage::ActivatePage;
+ using SfxTabPage::DeactivatePage;
+
+public:
+
+ SwNumPositionTabPage(Window* pParent,
+ const SfxItemSet& rSet);
+ ~SwNumPositionTabPage();
+
+ virtual void ActivatePage(const SfxItemSet& rSet);
+ virtual int DeactivatePage(SfxItemSet *pSet);
+ virtual sal_Bool FillItemSet( SfxItemSet& rSet );
+ virtual void Reset( const SfxItemSet& rSet );
+
+ static SfxTabPage* Create( Window* pParent,
+ const SfxItemSet& rAttrSet);
+
+ void SetOutlineTabDialog(SwOutlineTabDialog* pDlg){pOutlineDlg = pDlg;}
+ void SetWrtShell(SwWrtShell* pSh);
+#ifdef DBG_UTIL
+ void SetModified(sal_Bool bRepaint = sal_True);
+#else
+ void SetModified(sal_Bool bRepaint = sal_True)
+ { bModified = sal_True;
+ if(bRepaint)
+ {
+ m_pPreviewWIN->SetLevel(nActNumLvl);
+ m_pPreviewWIN->Invalidate();
+ }
+ }
+#endif
+};
+
+class SwSvxNumBulletTabDialog : public SfxTabDialog
+{
+ SwWrtShell& rWrtSh;
+ sal_uInt16 m_nSingleNumPageId;
+ sal_uInt16 m_nBulletPageId;
+ sal_uInt16 m_nOptionsPageId;
+ sal_uInt16 m_nPositionPageId;
+
+ protected:
+ virtual short Ok();
+ virtual void PageCreated(sal_uInt16 nPageId, SfxTabPage& rPage);
+ DECL_LINK(RemoveNumberingHdl, void *);
+ public:
+ SwSvxNumBulletTabDialog(Window* pParent,
+ const SfxItemSet* pSwItemSet,
+ SwWrtShell &);
+ ~SwSvxNumBulletTabDialog();
+};
+#endif // INCLUDED_SW_SOURCE_UI_INC_NUM_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/numberingtypelistbox.hxx b/sw/source/core/uibase/inc/numberingtypelistbox.hxx
new file mode 100644
index 000000000000..661252fb8e84
--- /dev/null
+++ b/sw/source/core/uibase/inc/numberingtypelistbox.hxx
@@ -0,0 +1,51 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_NUMBERINGTYPELISTBOX_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_NUMBERINGTYPELISTBOX_HXX
+
+#include <vcl/lstbox.hxx>
+#include "swdllapi.h"
+
+#define INSERT_NUM_TYPE_NO_NUMBERING 0x01
+#define INSERT_NUM_TYPE_PAGE_STYLE_NUMBERING 0x02
+#define INSERT_NUM_TYPE_BITMAP 0x04
+#define INSERT_NUM_TYPE_BULLET 0x08
+#define INSERT_NUM_EXTENDED_TYPES 0x10
+
+struct SwNumberingTypeListBox_Impl;
+
+class SW_DLLPUBLIC SwNumberingTypeListBox : public ListBox
+{
+ SwNumberingTypeListBox_Impl* pImpl;
+
+public:
+ SwNumberingTypeListBox( Window* pWin, WinBits nStyle = WB_BORDER );
+ ~SwNumberingTypeListBox();
+
+ virtual bool set_property(const OString &rKey, const OString &rValue);
+
+ void Reload(sal_uInt16 nTypeFlags);
+
+ sal_Int16 GetSelectedNumberingType();
+ sal_Bool SelectNumberingType(sal_Int16 nType);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/numfmtlb.hxx b/sw/source/core/uibase/inc/numfmtlb.hxx
new file mode 100644
index 000000000000..d6facd3da9b5
--- /dev/null
+++ b/sw/source/core/uibase/inc/numfmtlb.hxx
@@ -0,0 +1,73 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_NUMFMTLB_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_NUMFMTLB_HXX
+
+#include <vcl/lstbox.hxx>
+#include <svl/zforlist.hxx>
+#include "swdllapi.h"
+
+class SwView;
+
+class SW_DLLPUBLIC NumFormatListBox : public ListBox
+{
+ short nCurrFormatType;
+ sal_uInt16 nStdEntry;
+ sal_Bool bOneArea;
+ sal_uLong nDefFormat;
+ SwView* pVw;
+ SvNumberFormatter* pOwnFormatter;
+ LanguageType eCurLanguage;
+ sal_Bool bShowLanguageControl; //determine whether the language control has
+ //to be shown in the number format dialog
+ sal_Bool bUseAutomaticLanguage;//determine whether language is automatically assigned
+
+ SAL_DLLPRIVATE DECL_LINK( SelectHdl, ListBox * );
+
+ SAL_DLLPRIVATE double GetDefValue(const short nFormatType) const;
+ SAL_DLLPRIVATE void Init(short nFormatType, sal_Bool bUsrFmts);
+ SAL_DLLPRIVATE SwView* GetView();
+
+public:
+ NumFormatListBox(Window* pWin, WinBits nStyle);
+
+ ~NumFormatListBox();
+
+ void Clear();
+
+ inline void SetOneArea(sal_Bool bOnlyOne = sal_True) { bOneArea = bOnlyOne; }
+
+ void SetFormatType(const short nFormatType);
+ inline short GetFormatType() const { return nCurrFormatType; }
+ void SetDefFormat(const sal_uLong nDefFmt);
+ sal_uLong GetFormat() const;
+
+ inline LanguageType GetCurLanguage() const { return eCurLanguage;}
+ void SetLanguage(LanguageType eSet) { eCurLanguage = eSet;}
+
+ void SetAutomaticLanguage(sal_Bool bSet){bUseAutomaticLanguage = bSet;}
+ sal_Bool IsAutomaticLanguage()const {return bUseAutomaticLanguage;}
+
+ void SetShowLanguageControl(sal_Bool bSet){bShowLanguageControl = bSet;}
+
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/numpara.hxx b/sw/source/core/uibase/inc/numpara.hxx
new file mode 100644
index 000000000000..71602d8fc33c
--- /dev/null
+++ b/sw/source/core/uibase/inc/numpara.hxx
@@ -0,0 +1,86 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_NUMPARA_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_NUMPARA_HXX
+
+#include <sfx2/tabdlg.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/field.hxx>
+#include <vcl/button.hxx>
+
+/* --- class SwParagraphNumTabPage ----------------------------------------
+ with this TabPage numbering settings at the paragraph / paragraph style
+ are performed.
+
+ ---------------------------------------------------------------------------*/
+class SwParagraphNumTabPage : public SfxTabPage
+{
+ VclHBox* m_pOutlineStartBX;
+ ListBox* m_pOutlineLvLB;
+
+ VclHBox* m_pNumberStyleBX;
+ ListBox* m_pNumberStyleLB;
+
+ TriStateBox* m_pNewStartCB;
+ VclHBox* m_pNewStartBX;
+ TriStateBox* m_pNewStartNumberCB;
+ NumericField* m_pNewStartNF;
+
+ VclFrame* m_pCountParaFram;
+ TriStateBox* m_pCountParaCB;
+ TriStateBox* m_pRestartParaCountCB;
+
+ VclHBox* m_pRestartBX;
+ NumericField* m_pRestartNF;
+
+ // --> OD 2008-04-14 #outlinelevel#
+ const OUString msOutlineNumbering;
+
+ sal_Bool bModified : 1;
+ sal_Bool bCurNumrule : 1;
+
+ DECL_LINK(NewStartHdl_Impl, void *);
+ DECL_LINK( StyleHdl_Impl, ListBox* );
+ DECL_LINK(LineCountHdl_Impl, void *);
+
+protected:
+ SwParagraphNumTabPage(Window* pParent, const SfxItemSet& rSet );
+ void aCountParaFL();
+
+public:
+ ~SwParagraphNumTabPage();
+
+ static SfxTabPage* Create( Window* pParent,
+ const SfxItemSet& rSet );
+ static sal_uInt16* GetRanges();
+
+ virtual sal_Bool FillItemSet( SfxItemSet& rSet );
+ virtual void Reset( const SfxItemSet& rSet );
+
+ void EnableNewStart();
+ void DisableOutline();
+ void DisableNumbering();
+
+ ListBox& GetStyleBox() {return *m_pNumberStyleLB;};
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/numprevw.hxx b/sw/source/core/uibase/inc/numprevw.hxx
new file mode 100644
index 000000000000..71374d899261
--- /dev/null
+++ b/sw/source/core/uibase/inc/numprevw.hxx
@@ -0,0 +1,71 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SW_SOURCE_UI_INC_NUMPREVW_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_NUMPREVW_HXX
+
+#include <vcl/window.hxx>
+
+class SwNumRule;
+namespace rtl { class OUString; }
+
+class NumberingPreview : public Window
+{
+ const SwNumRule* pActNum;
+ Font aStdFont;
+ long nPageWidth;
+ const OUString* pOutlineNames;
+ sal_Bool bPosition;
+ sal_uInt16 nActLevel;
+
+ protected:
+ virtual void Paint( const Rectangle& rRect );
+
+ public:
+ NumberingPreview(Window* pParent, const ResId& rResId)
+ : Window(pParent, rResId),
+ pActNum(0),nPageWidth(0), pOutlineNames(0),
+ bPosition(sal_False), nActLevel(USHRT_MAX)
+ {
+ }
+
+ NumberingPreview(Window* pParent)
+ : Window(pParent)
+ , pActNum(0),nPageWidth(0), pOutlineNames(0),
+ bPosition(sal_False), nActLevel(USHRT_MAX)
+ {
+ }
+
+ ~NumberingPreview();
+
+ void SetNumRule(const SwNumRule* pNum)
+ {pActNum = pNum; Invalidate();};
+ void SetPageWidth(long nPgWidth)
+ {nPageWidth = nPgWidth;}
+ void SetOutlineNames(const OUString* pNames)
+ {pOutlineNames = pNames;}
+ void SetPositionMode()
+ { bPosition = sal_True;}
+ void SetLevel(sal_uInt16 nSet) {nActLevel = nSet;}
+
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/olesh.hxx b/sw/source/core/uibase/inc/olesh.hxx
new file mode 100644
index 000000000000..f9b6108a8edf
--- /dev/null
+++ b/sw/source/core/uibase/inc/olesh.hxx
@@ -0,0 +1,35 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_OLESH_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_OLESH_HXX
+
+#include "frmsh.hxx"
+
+class SwOleShell: public SwFrameShell
+{
+public:
+ SFX_DECL_INTERFACE(SW_OLESHELL)
+
+ SwOleShell(SwView &rView);
+
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/olmenu.hxx b/sw/source/core/uibase/inc/olmenu.hxx
new file mode 100644
index 000000000000..288413d5d746
--- /dev/null
+++ b/sw/source/core/uibase/inc/olmenu.hxx
@@ -0,0 +1,91 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_OLMENU_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_OLMENU_HXX
+
+#include <com/sun/star/linguistic2/XDictionary.hpp>
+#include <com/sun/star/linguistic2/XSpellAlternatives.hpp>
+#include <com/sun/star/linguistic2/ProofreadingResult.hpp>
+#include <com/sun/star/uno/Sequence.h>
+
+#include <rtl/ustring.hxx>
+#include <vcl/image.hxx>
+#include <vcl/menu.hxx>
+
+#include <map>
+#include <vector>
+
+class SwWrtShell;
+
+class SW_DLLPUBLIC SwSpellPopup : public PopupMenu
+{
+ SwWrtShell* m_pSh;
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference<
+ ::com::sun::star::linguistic2::XDictionary > > m_aDics;
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::linguistic2::XSpellAlternatives > m_xSpellAlt;
+
+ ::com::sun::star::linguistic2::ProofreadingResult m_xGrammarResult;
+ sal_Int32 m_nGrammarError;
+
+ ::com::sun::star::uno::Sequence< OUString > m_aSuggestions;
+ OUString m_sExplanationLink;
+
+ LanguageType m_nCheckedLanguage;
+ LanguageType m_nGuessLangWord;
+ LanguageType m_nGuessLangPara;
+
+ std::map< sal_Int16, OUString > m_aLangTable_Text;
+ std::map< sal_Int16, OUString > m_aLangTable_Paragraph;
+// std::map< sal_Int16, OUString > aLangTable_Document;
+
+ OUString m_aDicNameSingle;
+ bool m_bGrammarResults; // show grammar results? Or show spellcheck results?
+
+ Image m_aInfo16;
+
+ void fillLangPopupMenu( PopupMenu *pPopupMenu, sal_uInt16 nLangStart,
+ ::com::sun::star::uno::Sequence< OUString > aSeq, SwWrtShell* pWrtSh,
+ std::map< sal_Int16, OUString > &rLangTable );
+
+ using PopupMenu::Execute;
+
+ /// Checks if any of the redline menu items should be hidden.
+ void checkRedline();
+
+public:
+ SwSpellPopup( SwWrtShell *pWrtSh,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::linguistic2::XSpellAlternatives > &xAlt,
+ const OUString & rParaText );
+
+ SwSpellPopup( SwWrtShell *pWrtSh,
+ const ::com::sun::star::linguistic2::ProofreadingResult &rResult,
+ sal_Int32 nErrorInResult,
+ const ::com::sun::star::uno::Sequence< OUString > &rSuggestions,
+ const OUString & rParaText );
+
+ sal_uInt16 Execute( const Rectangle& rPopupPos, Window* pWin );
+ void Execute( sal_uInt16 nId );
+
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/optcomp.hxx b/sw/source/core/uibase/inc/optcomp.hxx
new file mode 100644
index 000000000000..afe29931d1d2
--- /dev/null
+++ b/sw/source/core/uibase/inc/optcomp.hxx
@@ -0,0 +1,75 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_OPTCOMP_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_OPTCOMP_HXX
+
+#include <sfx2/tabdlg.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/layout.hxx>
+#include <vcl/lstbox.hxx>
+#include <unotools/compatibility.hxx>
+#include <svx/checklbx.hxx>
+#include "rtl/ustring.hxx"
+
+// class SwCompatibilityOptPage ------------------------------------------
+class SwWrtShell;
+struct SwCompatibilityOptPage_Impl;
+
+class SwCompatibilityOptPage : public SfxTabPage
+{
+private:
+ // controls
+ VclFrame* m_pMain;
+ ListBox* m_pFormattingLB;
+ SvxCheckListBox* m_pOptionsLB;
+ PushButton* m_pDefaultPB;
+ // config item
+ SvtCompatibilityOptions m_aConfigItem;
+ // text of the user entry
+ OUString m_sUserEntry;
+ // shell of the current document
+ SwWrtShell* m_pWrtShell;
+ // impl object
+ SwCompatibilityOptPage_Impl* m_pImpl;
+ // saved options after "Reset"; used in "FillItemSet" for comparison
+ sal_uLong m_nSavedOptions;
+
+ // handler
+ DECL_LINK(SelectHdl, void *);
+ DECL_LINK(UseAsDefaultHdl, void *);
+
+ // private methods
+ void InitControls( const SfxItemSet& rSet );
+ void SetCurrentOptions( sal_uLong nOptions );
+ sal_uLong GetDocumentOptions() const;
+ void WriteOptions();
+
+public:
+ SwCompatibilityOptPage( Window* pParent, const SfxItemSet& rSet );
+ ~SwCompatibilityOptPage();
+
+ static SfxTabPage* Create( Window* pParent, const SfxItemSet& rAttrSet );
+
+ virtual sal_Bool FillItemSet( SfxItemSet& rSet );
+ virtual void Reset( const SfxItemSet& rSet );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/optload.hxx b/sw/source/core/uibase/inc/optload.hxx
new file mode 100644
index 000000000000..6013d8b8dfc3
--- /dev/null
+++ b/sw/source/core/uibase/inc/optload.hxx
@@ -0,0 +1,175 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_OPTLOAD_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_OPTLOAD_HXX
+
+#include <sfx2/tabdlg.hxx>
+
+#include <vcl/group.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/layout.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/field.hxx>
+#include <svx/strarray.hxx>
+#include <sfx2/basedlgs.hxx>
+#include <svx/checklbx.hxx>
+#include <swlbox.hxx>
+#include <caption.hxx>
+
+class SwFldMgr;
+class SvTreeListEntry;
+class SwWrtShell;
+
+class SwLoadOptPage : public SfxTabPage
+{
+private:
+ RadioButton* m_pAlwaysRB;
+ RadioButton* m_pRequestRB;
+ RadioButton* m_pNeverRB;
+
+ CheckBox* m_pAutoUpdateFields;
+ CheckBox* m_pAutoUpdateCharts;
+
+ ListBox* m_pMetricLB;
+ FixedText* m_pTabFT;
+ MetricField* m_pTabMF;
+ CheckBox* m_pUseSquaredPageMode;
+ CheckBox* m_pUseCharUnit;
+ Edit* m_pWordCountED;
+
+ SwWrtShell* m_pWrtShell;
+ sal_uInt16 m_nLastTab;
+ sal_Int32 m_nOldLinkMode;
+
+ DECL_LINK(MetricHdl, void *);
+
+public:
+ SwLoadOptPage(Window* pParent, const SfxItemSet& rSet);
+
+ static SfxTabPage* Create( Window* pParent,
+ const SfxItemSet& rAttrSet);
+
+ virtual sal_Bool FillItemSet( SfxItemSet& rSet );
+ virtual void Reset( const SfxItemSet& rSet );
+};
+
+class SwCaptionOptDlg : public SfxSingleTabDialog
+{
+public:
+ SwCaptionOptDlg(Window* pParent, const SfxItemSet& rSet);
+};
+
+class CaptionComboBox : public SwComboBox
+{
+protected:
+ virtual void KeyInput( const KeyEvent& );
+
+public:
+ CaptionComboBox(Window* pParent, WinBits nStyle)
+ : SwComboBox(pParent, nStyle)
+ {}
+};
+
+class SwCaptionPreview : public Window
+{
+private:
+ OUString maText;
+ Point maDrawPos;
+public:
+ SwCaptionPreview( Window* pParent, WinBits nStyle );
+ void Init();
+ void SetPreviewText( const OUString& rText );
+ virtual void Paint( const Rectangle& rRect );
+ virtual Size GetOptimalSize() const;
+};
+
+class SwCaptionOptPage : public SfxTabPage
+{
+private:
+ SvxCheckListBox* m_pCheckLB;
+ ListBox* m_pLbCaptionOrder;
+ SwCaptionPreview* m_pPreview;
+
+ VclContainer* m_pSettingsGroup;
+ CaptionComboBox* m_pCategoryBox;
+ FixedText* m_pFormatText;
+ ListBox* m_pFormatBox;
+ //#i61007# order of captions
+ FixedText* m_pNumberingSeparatorFT;
+ Edit* m_pNumberingSeparatorED;
+ FixedText* m_pTextText;
+ Edit* m_pTextEdit;
+ ListBox* m_pPosBox;
+
+ VclContainer* m_pNumCapt;
+ ListBox* m_pLbLevel;
+ Edit* m_pEdDelim;
+
+ VclContainer* m_pCategory;
+ ListBox* m_pCharStyleLB;
+ CheckBox* m_pApplyBorderCB;
+
+ OUString m_sSWTable;
+ OUString m_sSWFrame;
+ OUString m_sSWGraphic;
+ OUString m_sOLE;
+
+ OUString m_sIllustration;
+ OUString m_sTable;
+ OUString m_sText;
+ OUString m_sDrawing;
+
+ OUString m_sBegin;
+ OUString m_sEnd;
+ OUString m_sAbove;
+ OUString m_sBelow;
+
+ OUString m_sNone;
+
+ SwFldMgr *pMgr;
+ bool bHTMLMode;
+
+ DECL_LINK(SelectHdl, void *);
+ DECL_LINK(ModifyHdl, void * = 0);
+ DECL_LINK( OrderHdl, ListBox* );
+ DECL_LINK(ShowEntryHdl, void *);
+ DECL_LINK(SaveEntryHdl, void *);
+
+ void DelUserData();
+ void SetOptions( const sal_uLong nPos,
+ const SwCapObjType eType,
+ const SvGlobalName *pOleId = 0);
+ void SaveEntry( SvTreeListEntry* pEntry );
+ void DrawSample();
+
+public:
+ SwCaptionOptPage( Window* pParent,
+ const SfxItemSet& rSet );
+ ~SwCaptionOptPage();
+
+ static SfxTabPage* Create( Window* pParent,
+ const SfxItemSet& rAttrSet);
+
+ virtual sal_Bool FillItemSet( SfxItemSet& rSet );
+ virtual void Reset( const SfxItemSet& rSet );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/optpage.hxx b/sw/source/core/uibase/inc/optpage.hxx
new file mode 100644
index 000000000000..802b06092eed
--- /dev/null
+++ b/sw/source/core/uibase/inc/optpage.hxx
@@ -0,0 +1,439 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_OPTPAGE_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_OPTPAGE_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 <fontcfg.hxx>
+class SfxPrinter;
+class SwStdFontConfig;
+class SwWrtShell;
+class FontList;
+
+/*--------------------------------------------------------
+ Tools->Options->Writer->View
+ Tools->Options->Writer/Web->View
+--------------------------------------------------------- */
+class SwContentOptPage : public SfxTabPage
+{
+ CheckBox* m_pCrossCB;
+
+ CheckBox* m_pHScrollBox;
+ CheckBox* m_pVScrollBox;
+ CheckBox* m_pAnyRulerCB;
+ CheckBox* m_pHRulerCBox;
+ ListBox* m_pHMetric;
+ CheckBox* m_pVRulerCBox;
+ CheckBox* m_pVRulerRightCBox;
+ ListBox* m_pVMetric;
+ CheckBox* m_pSmoothCBox;
+
+ CheckBox* m_pGrfCB;
+ CheckBox* m_pTblCB;
+ CheckBox* m_pDrwCB;
+ CheckBox* m_pFldNameCB;
+ CheckBox* m_pPostItCB;
+
+ VclFrame* m_pSettingsFrame;
+ FixedText* m_pSettingsLabel;
+ FixedText* m_pMetricLabel;
+ ListBox* m_pMetricLB;
+
+ DECL_LINK(VertRulerHdl, CheckBox*);
+ DECL_LINK(AnyRulerHdl, CheckBox*);
+public:
+ SwContentOptPage( Window* pParent,
+ const SfxItemSet& rSet );
+ ~SwContentOptPage();
+
+ static SfxTabPage* Create( Window* pParent,
+ const SfxItemSet& rAttrSet);
+
+ virtual sal_Bool FillItemSet( SfxItemSet& rSet );
+ virtual void Reset( const SfxItemSet& rSet );
+
+};
+
+/*--------------------------------------------------------
+ TabPage printer settings additions
+--------------------------------------------------------- */
+class SwAddPrinterTabPage : public SfxTabPage
+{
+ CheckBox* m_pGrfCB;
+ CheckBox* m_pCtrlFldCB;
+ CheckBox* m_pBackgroundCB;
+ CheckBox* m_pBlackFontCB;
+ CheckBox* m_pPrintHiddenTextCB;
+ CheckBox* m_pPrintTextPlaceholderCB;
+
+ VclFrame* m_pPagesFrame;
+ CheckBox* m_pLeftPageCB;
+ CheckBox* m_pRightPageCB;
+ CheckBox* m_pProspectCB;
+ CheckBox* m_pProspectCB_RTL;
+
+ VclFrame* m_pCommentsFrame;
+ RadioButton* m_pNoRB;
+ RadioButton* m_pOnlyRB;
+ RadioButton* m_pEndRB;
+ RadioButton* m_pEndPageRB;
+
+ CheckBox* m_pPrintEmptyPagesCB;
+ CheckBox* m_pPaperFromSetupCB;
+ ListBox* m_pFaxLB;
+
+ OUString sNone;
+
+ sal_Bool bAttrModified;
+ sal_Bool bPreview;
+
+ void Init();
+ DECL_LINK(AutoClickHdl, void *);
+ DECL_LINK(SelectHdl, void *);
+
+ SwAddPrinterTabPage( Window* pParent,
+ const SfxItemSet& rSet );
+public:
+
+ static SfxTabPage* Create( Window* pParent,
+ const SfxItemSet& rAttrSet );
+
+ virtual sal_Bool FillItemSet( SfxItemSet& rSet );
+ virtual void Reset( const SfxItemSet& rSet );
+ void SetFax( const std::vector<OUString>& );
+ void SelectFax( const OUString& );
+ void SetPreview(sal_Bool bPrev);
+ virtual void PageCreated (SfxAllItemSet aSet);
+
+};
+
+class SwStdFontTabPage : public SfxTabPage
+{
+ FixedText* pLabelFT;
+
+ ComboBox* pStandardBox;
+ FontSizeBox* pStandardHeightLB;
+ ComboBox* pTitleBox ;
+ FontSizeBox* pTitleHeightLB;
+ ComboBox* pListBox ;
+ FontSizeBox* pListHeightLB;
+ ComboBox* pLabelBox ;
+ FontSizeBox* pLabelHeightLB;
+ ComboBox* pIdxBox ;
+ FontSizeBox* pIndexHeightLB;
+ CheckBox* pDocOnlyCB ;
+ PushButton* pStandardPB;
+
+ OUString sShellStd;
+ OUString sShellTitle;
+ OUString sShellList;
+ OUString sShellLabel;
+ OUString sShellIndex;
+
+ SfxPrinter* pPrt;
+ FontList* pFontList;
+ SwStdFontConfig* pFontConfig;
+ SwWrtShell* pWrtShell;
+ LanguageType eLanguage;
+ // only defaults were there? they were signed with the boxes
+ sal_Bool bListDefault :1;
+ sal_Bool bSetListDefault :1;
+ sal_Bool bLabelDefault :1;
+ sal_Bool bSetLabelDefault :1;
+ sal_Bool bIdxDefault :1;
+ sal_Bool bSetIdxDefault :1;
+ sal_Bool bDeletePrinter :1;
+
+ sal_Bool bListHeightDefault :1;
+ sal_Bool bSetListHeightDefault :1;
+ sal_Bool bLabelHeightDefault :1;
+ sal_Bool bSetLabelHeightDefault :1;
+ sal_Bool bIndexHeightDefault :1;
+ sal_Bool bSetIndexHeightDefault :1;
+
+ sal_uInt8 nFontGroup; //fontcfg.hxx: FONT_GROUP_[STANDARD|CJK|CTL]
+
+ OUString sScriptWestern;
+ OUString sScriptAsian;
+ OUString sScriptComplex;
+
+ DECL_LINK(StandardHdl, void *);
+ DECL_LINK( ModifyHdl, ComboBox * );
+ DECL_LINK( ModifyHeightHdl, FontSizeBox * );
+ DECL_LINK( LoseFocusHdl, ComboBox * );
+
+ SwStdFontTabPage( Window* pParent,
+ const SfxItemSet& rSet );
+ ~SwStdFontTabPage();
+
+public:
+ static SfxTabPage* Create( Window* pParent,
+ const SfxItemSet& rAttrSet );
+
+ virtual sal_Bool FillItemSet( SfxItemSet& rSet );
+ virtual void Reset( const SfxItemSet& rSet );
+
+ void SetFontMode(sal_uInt8 nGroup) {nFontGroup = nGroup;}
+ virtual void PageCreated (SfxAllItemSet aSet);
+};
+
+class SwTableOptionsTabPage : public SfxTabPage
+{
+ CheckBox* pHeaderCB;
+ CheckBox* pRepeatHeaderCB;
+ CheckBox* pDontSplitCB;
+ CheckBox* pBorderCB;
+
+ CheckBox* pNumFormattingCB;
+ CheckBox* pNumFmtFormattingCB;
+ CheckBox* pNumAlignmentCB;
+
+ MetricField* pRowMoveMF;
+ MetricField* pColMoveMF;
+
+ MetricField* pRowInsertMF;
+ MetricField* pColInsertMF;
+
+ RadioButton* pFixRB;
+ RadioButton* pFixPropRB;
+ RadioButton* pVarRB;
+
+ SwWrtShell* pWrtShell;
+ sal_Bool bHTMLMode;
+
+ DECL_LINK(CheckBoxHdl, void *);
+
+ SwTableOptionsTabPage( Window* pParent,
+ const SfxItemSet& rSet );
+ ~SwTableOptionsTabPage();
+
+public:
+
+ static SfxTabPage* Create( Window* pParent,
+ const SfxItemSet& rAttrSet );
+
+ virtual sal_Bool FillItemSet( SfxItemSet& rSet );
+ virtual void Reset( const SfxItemSet& rSet );
+
+ void SetWrtShell(SwWrtShell* pSh) {pWrtShell = pSh;}
+ virtual void PageCreated (SfxAllItemSet aSet);
+
+};
+
+/*--------------------------------------------------
+ TabPage for ShadowCrsr
+--------------------------------------------------*/
+class SwShdwCrsrOptionsTabPage : public SfxTabPage
+{
+ //nonprinting characters
+ CheckBox* m_pParaCB;
+ CheckBox* m_pSHyphCB;
+ CheckBox* m_pSpacesCB;
+ CheckBox* m_pHSpacesCB;
+ CheckBox* m_pTabCB;
+ CheckBox* m_pBreakCB;
+ CheckBox* m_pCharHiddenCB;
+ CheckBox* m_pFldHiddenCB;
+ CheckBox* m_pFldHiddenParaCB;
+
+ VclFrame* m_pDirectCursorFrame;
+ CheckBox* m_pOnOffCB;
+
+ RadioButton* m_pFillMarginRB;
+ RadioButton* m_pFillIndentRB;
+ RadioButton* m_pFillTabRB;
+ RadioButton* m_pFillSpaceRB;
+
+ VclFrame* m_pCursorProtFrame;
+ CheckBox* m_pCrsrInProtCB;
+
+ CheckBox* m_pMathBaselineAlignmentCB;
+
+ SwWrtShell * m_pWrtShell;
+
+ SwShdwCrsrOptionsTabPage( Window* pParent, const SfxItemSet& rSet );
+ ~SwShdwCrsrOptionsTabPage();
+
+public:
+
+ static SfxTabPage* Create( Window* pParent, const SfxItemSet& rAttrSet );
+
+ virtual sal_Bool FillItemSet( SfxItemSet& rSet );
+ virtual void Reset( const SfxItemSet& rSet );
+
+ void SetWrtShell( SwWrtShell * pSh ) { m_pWrtShell = pSh; }
+ virtual void PageCreated( SfxAllItemSet aSet );
+};
+
+/*-----------------------------------------------------------------------
+ Description: mark preview
+ -----------------------------------------------------------------------*/
+class SwMarkPreview : public Window
+{
+ Size m_aInitialSize;
+
+ Color m_aBgCol; // background
+ Color m_aTransCol; // transparency
+ Color m_aMarkCol; // marks
+ Color m_aLineCol; // general lines
+ Color m_aShadowCol; // shadow
+ Color m_aTxtCol; // text
+ Color m_aPrintAreaCol; // frame for print area
+
+ Rectangle aPage;
+ Rectangle aLeftPagePrtArea;
+ Rectangle aRightPagePrtArea;
+
+ sal_uInt16 nMarkPos;
+
+ using OutputDevice::DrawRect;
+ void DrawRect(const Rectangle &rRect, const Color &rFillColor, const Color &rLineColor);
+
+ void Paint(const Rectangle&);
+ void PaintPage(const Rectangle &rRect);
+ void InitColors( void );
+
+protected:
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+
+public:
+ SwMarkPreview(Window* pParent, WinBits nWinBits);
+ virtual ~SwMarkPreview();
+
+ inline void SetColor(const Color& rCol) { m_aMarkCol = rCol; }
+ inline void SetMarkPos(sal_uInt16 nPos) { nMarkPos = nPos; }
+ virtual Size GetOptimalSize() const;
+};
+
+/*-----------------------------------------------------------------------
+ Description: redlining options
+ -----------------------------------------------------------------------*/
+class SwRedlineOptionsTabPage : public SfxTabPage
+{
+ ListBox* pInsertLB;
+ ColorListBox* pInsertColorLB;
+ SvxFontPrevWindow* pInsertedPreviewWN;
+
+ ListBox* pDeletedLB;
+ ColorListBox* pDeletedColorLB;
+ SvxFontPrevWindow* pDeletedPreviewWN;
+
+ ListBox* pChangedLB;
+ ColorListBox* pChangedColorLB;
+ SvxFontPrevWindow* pChangedPreviewWN;
+
+ ListBox* pMarkPosLB;
+ ColorListBox* pMarkColorLB;
+ SwMarkPreview* pMarkPreviewWN;
+
+ OUString sAuthor;
+ OUString sNone;
+
+ SwRedlineOptionsTabPage( Window* pParent, const SfxItemSet& rSet );
+ ~SwRedlineOptionsTabPage();
+
+ DECL_LINK( AttribHdl, ListBox *pLB );
+ DECL_LINK(ChangedMaskPrevHdl, void * = 0);
+ DECL_LINK( ColorHdl, ColorListBox *pColorLB );
+
+ void InitFontStyle(SvxFontPrevWindow& rExampleWin);
+
+public:
+
+ static SfxTabPage* Create( Window* pParent, const SfxItemSet& rAttrSet );
+
+ virtual sal_Bool FillItemSet( SfxItemSet& rSet );
+ virtual void Reset( const SfxItemSet& rSet );
+};
+
+/*-------------------------------------------------------
+ TabPage test settings for SW
+--------------------------------------------------------- */
+
+#ifdef DBG_UTIL
+
+class SwTestTabPage : public SfxTabPage
+{
+public:
+ SwTestTabPage( Window* pParent,
+ const SfxItemSet& rSet );
+
+ static SfxTabPage* Create( Window* pParent,
+ const SfxItemSet& rAttrSet );
+
+ virtual sal_Bool FillItemSet( SfxItemSet& rSet );
+ virtual void Reset( const SfxItemSet& rSet );
+
+private:
+ CheckBox* m_pTest1CBox;
+ CheckBox* m_pTest2CBox;
+ CheckBox* m_pTest3CBox;
+ CheckBox* m_pTest4CBox;
+ CheckBox* m_pTest5CBox;
+ CheckBox* m_pTest6CBox;
+ CheckBox* m_pTest7CBox;
+ CheckBox* m_pTest8CBox;
+ CheckBox* m_pTest9CBox;
+ CheckBox* m_pTest10CBox;
+
+ sal_Bool bAttrModified;
+
+ void Init();
+ DECL_LINK(AutoClickHdl, void *);
+
+};
+#endif // DBG_UTIL
+
+class SwCompareOptionsTabPage : public SfxTabPage
+{
+ RadioButton* m_pAutoRB;
+ RadioButton* m_pWordRB;
+ RadioButton* m_pCharRB;
+
+ CheckBox* m_pRsidCB;
+ CheckBox* m_pIgnoreCB;
+ NumericField* m_pLenNF;
+
+ SwCompareOptionsTabPage( Window* pParent, const SfxItemSet& rSet );
+ ~SwCompareOptionsTabPage();
+
+ DECL_LINK(ComparisonHdl, void *);
+ DECL_LINK(IgnoreHdl, void *);
+
+public:
+
+ static SfxTabPage* Create( Window* pParent, const SfxItemSet& rAttrSet );
+
+ virtual sal_Bool FillItemSet( SfxItemSet& rSet );
+ virtual void Reset( const SfxItemSet& rSet );
+};
+
+#endif
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/outline.hxx b/sw/source/core/uibase/inc/outline.hxx
new file mode 100644
index 000000000000..6d54f977108d
--- /dev/null
+++ b/sw/source/core/uibase/inc/outline.hxx
@@ -0,0 +1,138 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_OUTLINE_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_OUTLINE_HXX
+
+#include <sfx2/tabdlg.hxx>
+
+#include <vcl/menu.hxx>
+
+#include <vcl/button.hxx>
+#include <svtools/stdctrl.hxx>
+
+#include <vcl/fixed.hxx>
+
+#include <vcl/lstbox.hxx>
+
+#include <vcl/edit.hxx>
+
+#include <vcl/field.hxx>
+
+#include "swtypes.hxx"
+#include <numprevw.hxx>
+#include <numberingtypelistbox.hxx>
+#include "rtl/ustring.hxx"
+
+class SwWrtShell;
+class SwNumRule;
+class SwChapterNumRules;
+
+class SwOutlineTabDialog : public SfxTabDialog
+{
+ static sal_uInt16 nNumLevel;
+
+ sal_uInt16 m_nNumPosId;
+ sal_uInt16 m_nOutlineId;
+
+ OUString aCollNames[MAXLEVEL];
+
+ SwWrtShell& rWrtSh;
+ SwNumRule* pNumRule;
+ SwChapterNumRules* pChapterNumRules;
+
+ sal_Bool bModified : 1;
+
+ protected:
+ DECL_LINK(CancelHdl, void *);
+ DECL_LINK( FormHdl, Button * );
+ DECL_LINK( MenuSelectHdl, Menu * );
+
+ virtual void PageCreated(sal_uInt16 nPageId, SfxTabPage& rPage);
+ virtual short Ok();
+
+ public:
+ SwOutlineTabDialog(Window* pParent,
+ const SfxItemSet* pSwItemSet,
+ SwWrtShell &);
+ ~SwOutlineTabDialog();
+
+ SwNumRule* GetNumRule() {return pNumRule;}
+ sal_uInt16 GetLevel(const OUString &rFmtName) const;
+ OUString* GetCollNames() {return aCollNames;}
+
+ static sal_uInt16 GetActNumLevel() {return nNumLevel;}
+ static void SetActNumLevel(sal_uInt16 nSet) {nNumLevel = nSet;}
+};
+
+class SwOutlineSettingsTabPage : public SfxTabPage
+{
+ ListBox* m_pLevelLB;
+
+ ListBox* m_pCollBox;
+ SwNumberingTypeListBox* m_pNumberBox;
+ ListBox* m_pCharFmtLB;
+ FixedText* m_pAllLevelFT;
+ NumericField* m_pAllLevelNF;
+ Edit* m_pPrefixED;
+ Edit* m_pSuffixED;
+ NumericField* m_pStartEdit;
+ NumberingPreview* m_pPreviewWIN;
+
+ OUString aNoFmtName;
+ OUString aSaveCollNames[MAXLEVEL];
+ SwWrtShell* pSh;
+ SwNumRule* pNumRule;
+ OUString* pCollNames;
+ sal_uInt16 nActLevel;
+
+ DECL_LINK( LevelHdl, ListBox * );
+ DECL_LINK( ToggleComplete, NumericField * );
+ DECL_LINK( CollSelect, ListBox * );
+ DECL_LINK(CollSelectGetFocus, void *);
+ DECL_LINK( NumberSelect, SwNumberingTypeListBox * );
+ DECL_LINK(DelimModify, void *);
+ DECL_LINK( StartModified, NumericField * );
+ DECL_LINK(CharFmtHdl, void *);
+
+ void Update();
+
+ void SetModified(){m_pPreviewWIN->Invalidate();}
+ void CheckForStartValue_Impl(sal_uInt16 nNumberingType);
+
+ using SfxTabPage::ActivatePage;
+ using SfxTabPage::DeactivatePage;
+
+public:
+ SwOutlineSettingsTabPage(Window* pParent, const SfxItemSet& rSet);
+ ~SwOutlineSettingsTabPage();
+
+ void SetWrtShell(SwWrtShell* pShell);
+
+ virtual void ActivatePage(const SfxItemSet& rSet);
+ virtual int DeactivatePage(SfxItemSet *pSet);
+
+ virtual sal_Bool FillItemSet( SfxItemSet& rSet );
+ virtual void Reset( const SfxItemSet& rSet );
+ static SfxTabPage* Create( Window* pParent,
+ const SfxItemSet& rAttrSet);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/pardlg.hxx b/sw/source/core/uibase/inc/pardlg.hxx
new file mode 100644
index 000000000000..d896350cbb85
--- /dev/null
+++ b/sw/source/core/uibase/inc/pardlg.hxx
@@ -0,0 +1,30 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_PARDLG_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_PARDLG_HXX
+
+#include <sfx2/tabdlg.hxx>
+
+//DialogModes:
+#define DLG_STD 0
+#define DLG_ENVELOP 2
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/pattern.hxx b/sw/source/core/uibase/inc/pattern.hxx
new file mode 100644
index 000000000000..386952247924
--- /dev/null
+++ b/sw/source/core/uibase/inc/pattern.hxx
@@ -0,0 +1,36 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SW_SOURCE_UI_INC_PATTERN_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_PATTERN_HXX
+
+#include <sfx2/basedlgs.hxx>
+
+class Window;
+class SfxItemSet;
+
+class SwBackgroundDlg : public SfxSingleTabDialog
+{
+public:
+ SwBackgroundDlg(Window* pParent, const SfxItemSet& rSet);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/pgfnote.hxx b/sw/source/core/uibase/inc/pgfnote.hxx
new file mode 100644
index 000000000000..156607ef105d
--- /dev/null
+++ b/sw/source/core/uibase/inc/pgfnote.hxx
@@ -0,0 +1,77 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_PGFNOTE_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_PGFNOTE_HXX
+
+#include <sfx2/tabdlg.hxx>
+
+#include <vcl/field.hxx>
+
+#include <vcl/fixed.hxx>
+
+#include <vcl/group.hxx>
+#include <svtools/ctrlbox.hxx>
+
+/*--------------------------------------------------------------------
+ Description: footnote settings TabPage
+ --------------------------------------------------------------------*/
+class SwFootNotePage: public SfxTabPage
+{
+public:
+ static SfxTabPage *Create(Window *pParent, const SfxItemSet &rSet);
+ static sal_uInt16* GetRanges();
+
+ virtual sal_Bool FillItemSet(SfxItemSet &rSet);
+ virtual void Reset(const SfxItemSet &rSet);
+
+private:
+ SwFootNotePage(Window *pParent, const SfxItemSet &rSet);
+ ~SwFootNotePage();
+
+ RadioButton* m_pMaxHeightPageBtn;
+ RadioButton* m_pMaxHeightBtn;
+ MetricField* m_pMaxHeightEdit;
+ MetricField* m_pDistEdit;
+
+ ListBox* m_pLinePosBox;
+ LineListBox* m_pLineTypeBox;
+ MetricField* m_pLineWidthEdit;
+ ColorListBox* m_pLineColorBox;
+ MetricField* m_pLineLengthEdit;
+ MetricField* m_pLineDistEdit;
+
+ DECL_LINK(HeightPage, void *);
+ DECL_LINK(HeightMetric, void *);
+ DECL_LINK(HeightModify, void *);
+ DECL_LINK( LineWidthChanged_Impl, void * );
+ DECL_LINK( LineColorSelected_Impl, void * );
+
+ long lMaxHeight;
+
+ using SfxTabPage::ActivatePage;
+ using SfxTabPage::DeactivatePage;
+
+ virtual void ActivatePage( const SfxItemSet& rSet );
+ virtual int DeactivatePage( SfxItemSet* pSet = 0 );
+
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/pggrid.hxx b/sw/source/core/uibase/inc/pggrid.hxx
new file mode 100644
index 000000000000..4dfc5d22748c
--- /dev/null
+++ b/sw/source/core/uibase/inc/pggrid.hxx
@@ -0,0 +1,101 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_PGGRID_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_PGGRID_HXX
+
+#include <sfx2/tabdlg.hxx>
+#include <colex.hxx>
+#include <vcl/field.hxx>
+#include <vcl/fixed.hxx>
+#include <svtools/ctrlbox.hxx>
+
+/*--------------------------------------------------------------------
+ Description: TabPage Format/(Styles/)Page/Text grid
+ --------------------------------------------------------------------*/
+class SwTextGridPage: public SfxTabPage
+{
+ RadioButton* m_pNoGridRB;
+ RadioButton* m_pLinesGridRB;
+ RadioButton* m_pCharsGridRB;
+ CheckBox* m_pSnapToCharsCB;
+
+ SwPageGridExample* m_pExampleWN;
+
+ VclFrame* m_pLayoutFL;
+ NumericField* m_pLinesPerPageNF;
+ FixedText* m_pLinesRangeFT;
+
+ MetricField* m_pTextSizeMF;
+
+ FixedText* m_pCharsPerLineFT;
+ NumericField* m_pCharsPerLineNF;
+ FixedText* m_pCharsRangeFT;
+
+ FixedText* m_pCharWidthFT;
+ MetricField* m_pCharWidthMF;
+
+ FixedText* m_pRubySizeFT;
+ MetricField* m_pRubySizeMF;
+
+ CheckBox* m_pRubyBelowCB;
+
+ VclFrame* m_pDisplayFL;
+
+ CheckBox* m_pDisplayCB;
+ CheckBox* m_pPrintCB;
+ ColorListBox* m_pColorLB;
+
+ sal_Int32 m_nRubyUserValue;
+ sal_Bool m_bRubyUserValue;
+ Size m_aPageSize;
+ bool m_bVertical;
+ sal_Bool m_bSquaredMode;
+ sal_Bool m_bHRulerChanged;
+ sal_Bool m_bVRulerChanged;
+
+ SwTextGridPage(Window *pParent, const SfxItemSet &rSet);
+ ~SwTextGridPage();
+
+ void UpdatePageSize(const SfxItemSet& rSet);
+ void PutGridItem(SfxItemSet& rSet);
+ void SetLinesOrCharsRanges(FixedText & rField, const sal_Int32 nValue );
+
+ DECL_LINK(GridTypeHdl, RadioButton*);
+ DECL_LINK(CharorLineChangedHdl, SpinField*);
+ DECL_LINK(TextSizeChangedHdl, SpinField*);
+ DECL_LINK(GridModifyHdl, void*);
+ DECL_LINK(DisplayGridHdl, void *);
+
+ using SfxTabPage::ActivatePage;
+ using SfxTabPage::DeactivatePage;
+
+public:
+ static SfxTabPage *Create(Window *pParent, const SfxItemSet &rSet);
+ static sal_uInt16* GetRanges();
+
+ virtual sal_Bool FillItemSet(SfxItemSet &rSet);
+ virtual void Reset(const SfxItemSet &rSet);
+
+ virtual void ActivatePage( const SfxItemSet& rSet );
+ virtual int DeactivatePage( SfxItemSet* pSet = 0 );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/popbox.hxx b/sw/source/core/uibase/inc/popbox.hxx
new file mode 100644
index 000000000000..e085886eaa81
--- /dev/null
+++ b/sw/source/core/uibase/inc/popbox.hxx
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_POPBOX_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_POPBOX_HXX
+
+#include <vcl/toolbox.hxx>
+#include <svtools/transfer.hxx>
+
+class SwNavigationPI;
+
+class SwHelpToolBox: public ToolBox, public DropTargetHelper
+{
+ Link aDoubleClickLink;
+ Link aRightClickLink; // link gets mouse event as parameter !!!
+
+ using ToolBox::DoubleClick;
+
+protected:
+ virtual void MouseButtonDown(const MouseEvent &rEvt);
+ virtual long DoubleClick(ToolBox *);
+ virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
+ virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
+
+public:
+ SwHelpToolBox(SwNavigationPI* pParent, const ResId &);
+ ~SwHelpToolBox();
+ void SetDoubleClickLink(const Link &); // inline
+ void SetRightClickLink(const Link &); // inline
+};
+
+inline void SwHelpToolBox::SetDoubleClickLink(const Link &rLink) {
+ aDoubleClickLink = rLink;
+}
+
+inline void SwHelpToolBox::SetRightClickLink(const Link &rLink) {
+ aRightClickLink = rLink;
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/popup.hrc b/sw/source/core/uibase/inc/popup.hrc
new file mode 100644
index 000000000000..88ed692f644a
--- /dev/null
+++ b/sw/source/core/uibase/inc/popup.hrc
@@ -0,0 +1,49 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef _POPUP_HRC
+#define _POPUP_HRC
+
+#include "rcid.hrc"
+
+#define MN_TEXT_POPUPMENU (RC_POPUPS_BEGIN + 0)
+#define MN_TAB_POPUPMENU (RC_POPUPS_BEGIN + 1)
+#define MN_FRM_POPUPMENU (RC_POPUPS_BEGIN + 2)
+#define MN_DRAW_POPUPMENU (RC_POPUPS_BEGIN + 3)
+#define MN_DRWTXT_POPUPMENU (RC_POPUPS_BEGIN + 4)
+#define MN_GRF_POPUPMENU (RC_POPUPS_BEGIN + 5)
+#define MN_OLE_POPUPMENU (RC_POPUPS_BEGIN + 6)
+#define MN_PPREVIEW_POPUPMENU (RC_POPUPS_BEGIN + 7)
+#define MN_SRCVIEW_POPUPMENU (RC_POPUPS_BEGIN + 8)
+#define MN_DRAWFORM_POPUPMENU (RC_POPUPS_BEGIN + 9)
+#define MN_MEDIA_POPUPMENU (RC_POPUPS_BEGIN + 10)
+#define MN_ANNOTATION_POPUPMENU (RC_POPUPS_BEGIN + 14)
+#define MN_ANNOTATION_BUTTON (RC_POPUPS_BEGIN + 15)
+#define MN_HEADERFOOTER_BUTTON (RC_POPUPS_BEGIN + 18)
+#define MN_PAGEBREAK_BUTTON (RC_POPUPS_BEGIN + 19)
+
+#if MN_PAGEBREAK_BUTTON > RC_POPUPS_END
+
+#error Resource-Id Ueberlauf in #file, #line
+#endif
+
+
+#endif // _POPUP_HRC
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/prcntfld.hxx b/sw/source/core/uibase/inc/prcntfld.hxx
new file mode 100644
index 000000000000..5e9422c03082
--- /dev/null
+++ b/sw/source/core/uibase/inc/prcntfld.hxx
@@ -0,0 +1,111 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_PRCNTFLD_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_PRCNTFLD_HXX
+
+#include <vcl/field.hxx>
+#include "swdllapi.h"
+#include "uitool.hxx"
+
+//Wraps a MetricField with extra features, preferred to PercentField
+class SW_DLLPUBLIC PercentField
+{
+ MetricField* m_pField;
+
+ sal_Int64 nRefValue; // 100% value for conversion (in Twips)
+ sal_Int64 nOldMax;
+ sal_Int64 nOldMin;
+ sal_Int64 nOldSpinSize;
+ sal_Int64 nOldBaseValue;
+ sal_Int64 nLastPercent;
+ sal_Int64 nLastValue;
+ sal_uInt16 nOldDigits;
+ FieldUnit eOldUnit;
+ bool bLockAutoCalculation; //prevent recalcution of percent values when the
+ //reference value is changed
+
+ SAL_DLLPRIVATE sal_Int64 ImpPower10(sal_uInt16 n);
+
+public:
+
+ PercentField();
+ void set(MetricField *pField);
+ const MetricField* get() const { return m_pField; }
+ MetricField* get() { return m_pField; }
+ void SetUpHdl(const Link& rLink) { m_pField->SetUpHdl(rLink); }
+ void SetDownHdl(const Link& rLink) { m_pField->SetDownHdl(rLink); }
+ void SetModifyHdl(const Link& rLink) { m_pField->SetModifyHdl(rLink); }
+ void SetLoseFocusHdl(const Link& rLink) { m_pField->SetLoseFocusHdl(rLink); }
+ void SetMetric(FieldUnit eUnit) { ::SetMetric(*m_pField, eUnit); }
+ void Enable(bool bEnable = true, bool bChild = true) { m_pField->Enable(bEnable, bChild); }
+ void Disable(bool bChild = true) { m_pField->Disable(bChild); }
+ bool HasFocus() const { return m_pField->HasFocus(); }
+ void SetAccessibleName(const OUString& rName) { m_pField->SetAccessibleName(rName); }
+ void SetText(const OUString& rStr) { m_pField->SetText(rStr); }
+ void SaveValue() { m_pField->SaveValue(); }
+ void ClearModifyFlag() { m_pField->ClearModifyFlag(); }
+ OUString GetSavedValue() const { return m_pField->GetSavedValue(); }
+ OUString GetText() const { return m_pField->GetText(); }
+ void SetMetricFieldMin(sal_Int64 nNewMin) { m_pField->SetMin(nNewMin); }
+ void SetMetricFieldMax(sal_Int64 nNewMax) { m_pField->SetMax(nNewMax); }
+
+ void SetValue(sal_Int64 nNewValue, FieldUnit eInUnit = FUNIT_NONE) { m_pField->SetValue(nNewValue, eInUnit); }
+
+ void SetLast(sal_Int64 nNewLast) { m_pField->SetLast(nNewLast); }
+
+ void SetPrcntValue(sal_Int64 nNewValue, FieldUnit eInUnit = FUNIT_NONE);
+
+ void SetUserValue(sal_Int64 nNewValue, FieldUnit eInUnit = FUNIT_NONE);
+
+ void SetBaseValue(sal_Int64 nNewValue, FieldUnit eInUnit = FUNIT_NONE);
+
+ sal_Int64 GetValue(FieldUnit eOutUnit = FUNIT_NONE);
+
+ bool IsValueModified();
+
+ void SetMax(sal_Int64 nNewMax, FieldUnit eInUnit = FUNIT_NONE);
+
+ void SetMin(sal_Int64 nNewMin, FieldUnit eInUnit = FUNIT_NONE);
+
+ sal_Int64 GetMin() const { return m_pField->GetMin(); }
+ sal_Int64 GetMax() const { return m_pField->GetMax(); }
+
+ sal_Int64 NormalizePercent(sal_Int64 nValue);
+ sal_Int64 DenormalizePercent(sal_Int64 nValue);
+
+ sal_Int64 Normalize( sal_Int64 nValue ) const { return m_pField->Normalize(nValue); }
+ sal_Int64 Denormalize( sal_Int64 nValue ) const { return m_pField->Denormalize(nValue); }
+
+ void SetRefValue(sal_Int64 nValue);
+ sal_Int64 GetRefValue() const { return nRefValue; }
+ sal_Int64 GetRealValue(FieldUnit eOutUnit = FUNIT_NONE);
+
+ sal_Int64 Convert(sal_Int64 nValue, FieldUnit eInUnit, FieldUnit eOutUnit);
+
+ void ShowPercent(bool bPercent);
+
+ sal_uInt16 GetOldDigits() const {return nOldDigits;}
+
+ void LockAutoCalculation(bool bLock) {bLockAutoCalculation = bLock;}
+ bool IsAutoCalculationLocked() const {return bLockAutoCalculation;}
+};
+
+#endif // INCLUDED_SW_SOURCE_UI_INC_PRCNTFLD_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/pview.hxx b/sw/source/core/uibase/inc/pview.hxx
new file mode 100644
index 000000000000..de42c7930541
--- /dev/null
+++ b/sw/source/core/uibase/inc/pview.hxx
@@ -0,0 +1,301 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_PVIEW_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_PVIEW_HXX
+
+#include <tools/link.hxx>
+#include <vcl/window.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/viewfac.hxx>
+#include <sfx2/viewsh.hxx>
+#include <sfx2/zoomitem.hxx>
+#include "swdllapi.h"
+#include "shellid.hxx"
+
+class SwViewOption;
+class SwDocShell;
+class SwScrollbar;
+class SwViewShell;
+class SwPagePreview;
+class ImageButton;
+class Button;
+class SwRect;
+class DataChangedEvent;
+class CommandEvent;
+class SvtAccessibilityOptions;
+class SwPagePreviewLayout;
+
+// Delete member <mnVirtPage> and its accessor
+class SwPagePreviewWin : public Window
+{
+ SwViewShell* mpViewShell;
+ sal_uInt16 mnSttPage;
+ sal_uInt8 mnRow, mnCol;
+ Size maPxWinSize;
+ Fraction maScale;
+ SwPagePreview& mrView;
+ bool mbCalcScaleForPreviewLayout;
+ Rectangle maPaintedPreviewDocRect;
+ SwPagePreviewLayout* mpPgPreviewLayout;
+
+ void SetPagePreview( sal_uInt8 nRow, sal_uInt8 nCol );
+
+ using Window::Scroll;
+
+public:
+ SwPagePreviewWin( Window* pParent, SwPagePreview& rView );
+ ~SwPagePreviewWin();
+
+ // calls SwViewShell::Paint
+ virtual void Paint( const Rectangle& rRect );
+ virtual void KeyInput( const KeyEvent & );
+ virtual void Command( const CommandEvent& rCEvt );
+ virtual void MouseButtonDown(const MouseEvent& rMEvt);
+ virtual void DataChanged( const DataChangedEvent& );
+
+ void SetViewShell( SwViewShell* pShell );
+
+ SwViewShell* GetViewShell() const { return mpViewShell; }
+
+ sal_uInt8 GetRow() const { return mnRow; }
+ void SetRow( sal_uInt8 n ) { if( n ) mnRow = n; }
+
+ sal_uInt8 GetCol() const { return mnCol; }
+ void SetCol( sal_uInt8 n ) { if( n ) mnCol = n; }
+
+ sal_uInt16 GetSttPage() const { return mnSttPage; }
+ void SetSttPage( sal_uInt16 n ) { mnSttPage = n; }
+
+ /** get selected page number of document preview
+
+ @return selected page number
+ */
+ sal_uInt16 SelectedPage() const;
+
+ /** set selected page number in document preview
+
+ @param _nSelectedPageNum
+ input parameter - physical page number of page that will be the selected one.
+ */
+ void SetSelectedPage( sal_uInt16 _nSelectedPageNum );
+
+ // If we only have one column we do not have a oth page
+ sal_uInt16 GetDefSttPage() const { return 1 == mnCol ? 1 : 0; }
+
+ void CalcWish( sal_uInt8 nNewRow, sal_uInt8 nNewCol );
+
+ const Size& GetWinSize() const { return maPxWinSize; }
+ void SetWinSize( const Size& rNewSize );
+
+ // Add <MV_SELPAGE>, <MV_SCROLL>
+ enum MoveMode{ MV_CALC, MV_PAGE_UP, MV_PAGE_DOWN, MV_DOC_STT, MV_DOC_END,
+ MV_SELPAGE, MV_SCROLL, MV_NEWWINSIZE };
+ int MovePage( int eMoveMode );
+
+ // Create the status bar's string
+ OUString GetStatusStr( sal_uInt16 nPageCount ) const;
+
+ void RepaintCoreRect( const SwRect& rRect );
+
+ /** Method to adjust preview to a new zoom factor
+ paint of preview is prepared for a new zoom factor
+ Zoom type has also been considered.
+ Thus, add new parameter <_eZoomType>
+ */
+ void AdjustPreviewToNewZoom( const sal_uInt16 _nZoomFactor,
+ const SvxZoomType _eZoomType );
+
+ const Rectangle& GetPaintedPreviewDocRect() const
+ {
+ return maPaintedPreviewDocRect;
+ }
+
+ void Scroll(long nXMove, long nYMove, sal_uInt16 nFlags = 0);
+
+ /** Method to enable/disable book preview
+ @param _bBookPreview
+ input parameter - boolean indicating, if book preview mode has to
+ switch on <sal_True> or of <sal_False>
+
+ @return boolean indicating, if book preview mode has changed.
+ */
+ bool SetBookPreviewMode( const bool _bBookPreview );
+
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible>
+ CreateAccessible();
+ virtual void SwitchView();
+};
+
+/**
+ * View of a document
+ */
+class SW_DLLPUBLIC SwPagePreview: public SfxViewShell
+{
+ // ViewWindow and handle to core
+ // current dispatcher shell
+ SwPagePreviewWin* pViewWin;
+ //viewdata of the previous SwView and the new crsrposition
+ OUString sSwViewData;
+ //and the new cursor position if the user double click in the PagePreview
+ OUString sNewCrsrPos;
+ // to support keyboard the number of the page to go to can be set too
+ sal_uInt16 nNewPage;
+ // visible range
+ OUString sPageStr;
+ Size aDocSz;
+ Rectangle aVisArea;
+
+ // MDI control elements
+ SwScrollbar *pHScrollbar;
+ SwScrollbar *pVScrollbar;
+ bool mbHScrollbarEnabled;
+ bool mbVScrollbarEnabled;
+ ImageButton *pPageUpBtn,
+ *pPageDownBtn;
+ // dummy window for filling the lower right edge when both scrollbars are active
+ Window *pScrollFill;
+
+ sal_uInt16 mnPageCount;
+ sal_Bool bNormalPrint;
+
+ // New members to reset design mode at draw view for form shell on switching
+ // back from writer page preview to normal view.
+ sal_Bool mbResetFormDesignMode:1;
+ sal_Bool mbFormDesignModeToReset:1;
+
+ SAL_DLLPRIVATE void Init(const SwViewOption* = 0);
+ SAL_DLLPRIVATE Point AlignToPixel(const Point& rPt) const;
+
+ SAL_DLLPRIVATE int _CreateScrollbar( sal_Bool bHori );
+ SAL_DLLPRIVATE DECL_LINK( ScrollHdl, SwScrollbar * );
+ SAL_DLLPRIVATE DECL_LINK( EndScrollHdl, SwScrollbar * );
+ SAL_DLLPRIVATE DECL_LINK( BtnPage, Button * );
+ SAL_DLLPRIVATE bool ChgPage( int eMvMode, int bUpdateScrollbar = sal_True );
+
+ SAL_DLLPRIVATE virtual SfxPrinter* GetPrinter( sal_Bool bCreate = sal_False );
+ SAL_DLLPRIVATE virtual sal_uInt16 SetPrinter( SfxPrinter *pNewPrinter, sal_uInt16 nDiffFlags = SFX_PRINTER_ALL, bool bIsAPI=false );
+ SAL_DLLPRIVATE virtual bool HasPrintOptionsPage() const;
+ SAL_DLLPRIVATE virtual SfxTabPage* CreatePrintOptionsPage( Window *pParent,
+ const SfxItemSet &rOptions );
+
+ SAL_DLLPRIVATE void CalcAndSetBorderPixel( SvBorder &rToFill, sal_Bool bInner );
+
+ /** Helper method to execute SfxRequest FN_PAGE_UP and FN_PAGE_DOWN
+
+ @param _bPgUp
+ input parameter - boolean that indicates, if FN_PAGE_UP or FN_PAGE_DOWN
+ has to be executed.
+
+ @param _pReq
+ optional input parameter - pointer to the <SfxRequest> instance, if existing.
+ */
+ SAL_DLLPRIVATE void _ExecPgUpAndPgDown( const bool _bPgUp,
+ SfxRequest* _pReq = 0 );
+
+protected:
+ virtual void InnerResizePixel( const Point &rOfs, const Size &rSize );
+ virtual void OuterResizePixel( const Point &rOfs, const Size &rSize );
+
+ void SetZoom(SvxZoomType eSet, sal_uInt16 nFactor);
+
+public:
+ SFX_DECL_VIEWFACTORY(SwPagePreview);
+ SFX_DECL_INTERFACE(SW_PAGEPREVIEW)
+ TYPEINFO();
+
+ inline Window* GetFrameWindow() const { return &(GetViewFrame())->GetWindow(); }
+ inline SwViewShell* GetViewShell() const { return pViewWin->GetViewShell(); }
+ inline const Rectangle& GetVisArea() const { return aVisArea; }
+ inline void GrabFocusViewWin() { pViewWin->GrabFocus(); }
+ inline void RepaintCoreRect( const SwRect& rRect )
+ { pViewWin->RepaintCoreRect( rRect ); }
+
+ void DocSzChgd(const Size& rNewSize);
+ const Size& GetDocSz() const { return aDocSz; }
+
+ virtual void SetVisArea( const Rectangle&, sal_Bool bUpdateScrollbar = sal_True);
+
+ inline void AdjustEditWin();
+
+ void ScrollViewSzChg();
+ void ScrollDocSzChg();
+ void ShowHScrollbar(sal_Bool bShow);
+ void ShowVScrollbar(sal_Bool bShow);
+ void EnableHScrollbar(bool bEnable);
+ void EnableVScrollbar(bool bEnable);
+
+ sal_uInt16 GetPageCount() const { return mnPageCount; }
+ sal_uInt16 GetSelectedPage() const {return pViewWin->SelectedPage();}
+
+ sal_Bool HandleWheelCommands( const CommandEvent& );
+
+ OUString GetPrevSwViewData() const { return sSwViewData; }
+ void SetNewCrsrPos( const OUString& rStr ) { sNewCrsrPos = rStr; }
+ const OUString& GetNewCrsrPos() const { return sNewCrsrPos; }
+
+ sal_uInt16 GetNewPage() const {return nNewPage;}
+ void SetNewPage(sal_uInt16 nSet) {nNewPage = nSet;}
+
+ // Handler
+ void Execute(SfxRequest&);
+ void GetState(SfxItemSet&);
+ void StateUndo(SfxItemSet&);
+
+ SwDocShell* GetDocShell();
+
+ // apply Accessiblity options
+ void ApplyAccessiblityOptions(SvtAccessibilityOptions& rAccessibilityOptions);
+
+ // Inline method to request values of new members
+ // <mbResetFormDesignMode> and <mbFormDesignModeToReset>
+ inline sal_Bool ResetFormDesignMode() const
+ {
+ return mbResetFormDesignMode;
+ }
+
+ inline sal_Bool FormDesignModeToReset() const
+ {
+ return mbFormDesignModeToReset;
+ }
+
+ /** Adjust position of vertical scrollbar
+
+ Currently used, if the complete preview layout rows fit into to the given
+ window, if a new page is selected and this page is visible.
+
+ @param _nNewThumbPos
+ input parameter - new position, which will be assigned to the vertical
+ scrollbar.
+ */
+ void SetVScrollbarThumbPos( const sal_uInt16 _nNewThumbPos );
+
+ SwPagePreview( SfxViewFrame* pFrame, SfxViewShell* );
+ ~SwPagePreview();
+};
+
+// ----------------- inline methods ----------------------
+inline void SwPagePreview::AdjustEditWin()
+{
+ OuterResizePixel( Point(), GetFrameWindow()->GetOutputSizePixel() );
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/redline_tmpl.hrc b/sw/source/core/uibase/inc/redline_tmpl.hrc
new file mode 100644
index 000000000000..42717089947b
--- /dev/null
+++ b/sw/source/core/uibase/inc/redline_tmpl.hrc
@@ -0,0 +1,39 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#include "cmdid.h"
+
+#define MN_EDIT_REDLINE \
+ MenuItem \
+ { \
+ Identifier = FN_REDLINE_ACCEPT_DIRECT; \
+ HelpId = CMD_FN_REDLINE_ACCEPT_DIRECT ; \
+ Text [ en-US ] = "Accept Change" ; \
+ }; \
+ MenuItem \
+ { \
+ Identifier = FN_REDLINE_REJECT_DIRECT ; \
+ HelpId = CMD_FN_REDLINE_REJECT_DIRECT ; \
+ Text [ en-US ] = "Reject Change" ; \
+ }; \
+ MenuItem \
+ { \
+ Identifier = FN_REDLINE_NEXT_CHANGE; \
+ HelpId = CMD_FN_REDLINE_NEXT_CHANGE ; \
+ Text [ en-US ] = "Next Change" ; \
+ }; \
+ MenuItem \
+ { \
+ Identifier = FN_REDLINE_PREV_CHANGE; \
+ HelpId = CMD_FN_REDLINE_PREV_CHANGE ; \
+ Text [ en-US ] = "Previous Change" ; \
+ };
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/redlndlg.hxx b/sw/source/core/uibase/inc/redlndlg.hxx
new file mode 100644
index 000000000000..2ee42bdef5c6
--- /dev/null
+++ b/sw/source/core/uibase/inc/redlndlg.hxx
@@ -0,0 +1,162 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_REDLNDLG_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_REDLNDLG_HXX
+#include "swdllapi.h"
+#include "chldwrap.hxx"
+#include <redline.hxx>
+#include <tools/datetime.hxx>
+#include <vcl/msgbox.hxx>
+#include <svl/eitem.hxx>
+#include <sfx2/basedlgs.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svx/ctredlin.hxx>
+#include <svx/postattr.hxx>
+#include <boost/ptr_container/ptr_vector.hpp>
+#include <o3tl/sorted_vector.hxx>
+
+class SwChildWinWrapper;
+
+struct SwRedlineDataChild
+{
+ const SwRedlineData* pChild; // link to original stacked data
+ const SwRedlineDataChild* pNext; // link to stacked data
+ SvTreeListEntry* pTLBChild; // corresponding TreeListBox entry
+};
+
+struct SwRedlineDataParent
+{
+ const SwRedlineData* pData; // RedlineDataPtr
+ const SwRedlineDataChild* pNext; // link to stacked data
+ SvTreeListEntry* pTLBParent; // corresponding TreeListBox entry
+ OUString sComment; // redline comment
+
+ inline sal_Bool operator==( const SwRedlineDataParent& rObj ) const
+ { return (pData && pData->GetSeqNo() == rObj.pData->GetSeqNo()); }
+ inline sal_Bool operator< ( const SwRedlineDataParent& rObj ) const
+ { return (pData && pData->GetSeqNo() < rObj.pData->GetSeqNo()); }
+};
+
+typedef boost::ptr_vector<SwRedlineDataParent> SwRedlineDataParentArr;
+
+class SwRedlineDataParentSortArr : public o3tl::sorted_vector<SwRedlineDataParent*, o3tl::less_ptr_to<SwRedlineDataParent> > {};
+
+typedef SwRedlineDataChild* SwRedlineDataChildPtr;
+typedef boost::ptr_vector<SwRedlineDataChild> SwRedlineDataChildArr;
+
+typedef SvTreeListEntry* SvLBoxEntryPtr;
+typedef std::vector<SvLBoxEntryPtr> SvLBoxEntryArr;
+
+class SW_DLLPUBLIC SwRedlineAcceptDlg
+{
+ Dialog* pParentDlg;
+ SwRedlineDataParentArr aRedlineParents;
+ SwRedlineDataChildArr aRedlineChildren;
+ SwRedlineDataParentSortArr aUsedSeqNo;
+ SvxAcceptChgCtr aTabPagesCTRL;
+ PopupMenu aPopup;
+ Timer aDeselectTimer;
+ Timer aSelectTimer;
+ OUString sInserted;
+ OUString sDeleted;
+ OUString sFormated;
+ OUString sTableChgd;
+ OUString sFmtCollSet;
+ OUString sFilterAction;
+ OUString sAutoFormat;
+ SvxTPView* pTPView;
+ SvxRedlinTable* pTable; // PB 2006/02/02 #i48648 now SvHeaderTabListBox
+ Link aOldSelectHdl;
+ Link aOldDeselectHdl;
+ sal_Bool bOnlyFormatedRedlines;
+ sal_Bool bHasReadonlySel;
+ sal_Bool bRedlnAutoFmt;
+
+ // prevent update dialog data during longer operations (cf #102657#)
+ bool bInhibitActivate;
+
+ SAL_DLLPRIVATE DECL_LINK( AcceptHdl, void* );
+ SAL_DLLPRIVATE DECL_LINK( AcceptAllHdl, void* );
+ SAL_DLLPRIVATE DECL_LINK( RejectHdl, void* );
+ SAL_DLLPRIVATE DECL_LINK( RejectAllHdl, void* );
+ SAL_DLLPRIVATE DECL_LINK( UndoHdl, void* );
+ SAL_DLLPRIVATE DECL_LINK( DeselectHdl, void* );
+ SAL_DLLPRIVATE DECL_LINK( SelectHdl, void* );
+ SAL_DLLPRIVATE DECL_LINK( GotoHdl, void* );
+ SAL_DLLPRIVATE DECL_LINK( CommandHdl, void* );
+
+ SAL_DLLPRIVATE sal_uInt16 CalcDiff(sal_uInt16 nStart, sal_Bool bChild);
+ SAL_DLLPRIVATE void InsertChildren(SwRedlineDataParent *pParent, const SwRangeRedline& rRedln, const sal_uInt16 nAutoFmt);
+ SAL_DLLPRIVATE void InsertParents(sal_uInt16 nStart, sal_uInt16 nEnd = USHRT_MAX);
+ SAL_DLLPRIVATE void RemoveParents(sal_uInt16 nStart, sal_uInt16 nEnd);
+ SAL_DLLPRIVATE void InitAuthors();
+
+ SAL_DLLPRIVATE OUString GetRedlineText(const SwRangeRedline& rRedln, DateTime &rDateTime, sal_uInt16 nStack = 0);
+ SAL_DLLPRIVATE OUString GetActionText(const SwRangeRedline& rRedln, sal_uInt16 nStack = 0);
+ SAL_DLLPRIVATE sal_uInt16 GetRedlinePos( const SvTreeListEntry& rEntry) const;
+
+public:
+ SwRedlineAcceptDlg(Dialog *pParent, sal_Bool bAutoFmt = sal_False);
+ virtual ~SwRedlineAcceptDlg();
+
+ DECL_LINK( FilterChangedHdl, void *pDummy = 0 );
+
+ inline SvxAcceptChgCtr* GetChgCtrl() { return &aTabPagesCTRL; }
+ inline sal_Bool HasRedlineAutoFmt() const { return bRedlnAutoFmt; }
+
+ void Init(sal_uInt16 nStart = 0);
+ void CallAcceptReject( sal_Bool bSelect, sal_Bool bAccept );
+
+ void Initialize(const OUString &rExtraData);
+ void FillInfo(OUString &rExtraData) const;
+
+ virtual void Activate();
+};
+
+class SwModelessRedlineAcceptDlg : public SfxModelessDialog
+{
+ SwRedlineAcceptDlg* pImplDlg;
+ SwChildWinWrapper* pChildWin;
+
+public:
+ SwModelessRedlineAcceptDlg(SfxBindings*, SwChildWinWrapper*, Window *pParent);
+ ~SwModelessRedlineAcceptDlg();
+
+ virtual void Activate();
+ virtual void FillInfo(SfxChildWinInfo&) const;
+ void Initialize (SfxChildWinInfo* pInfo);
+};
+
+class SwRedlineAcceptChild : public SwChildWinWrapper
+{
+public:
+ SwRedlineAcceptChild( Window* ,
+ sal_uInt16 nId,
+ SfxBindings*,
+ SfxChildWinInfo* );
+
+ SFX_DECL_CHILDWINDOW_WITHID( SwRedlineAcceptChild );
+
+ virtual sal_Bool ReInitDlg(SwDocShell *pDocSh);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/regionsw.hxx b/sw/source/core/uibase/inc/regionsw.hxx
new file mode 100644
index 000000000000..44a9fa642684
--- /dev/null
+++ b/sw/source/core/uibase/inc/regionsw.hxx
@@ -0,0 +1,303 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_REGIONSW_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_REGIONSW_HXX
+
+#include <hintids.hxx>
+#include <vcl/field.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/edit.hxx>
+#include <vcl/button.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/combobox.hxx>
+#include <vcl/group.hxx>
+#include <vcl/layout.hxx>
+#include <svtools/treelistbox.hxx>
+#include <sfx2/basedlgs.hxx>
+#include <sfx2/tabdlg.hxx>
+#include <editeng/brushitem.hxx>
+
+#include <condedit.hxx>
+#include <section.hxx>
+#include <fmtclds.hxx>
+#include <fmtftntx.hxx>
+#include <fmtclbl.hxx>
+#include <numberingtypelistbox.hxx>
+#include <editeng/frmdiritem.hxx>
+#include <vcl/image.hxx>
+#include <svx/paraprev.hxx>
+#include <editeng/lrspitem.hxx>
+
+#include <boost/ptr_container/ptr_set.hpp>
+
+class SwWrtShell;
+
+namespace sfx2
+{
+ class DocumentInserter;
+ class FileDialogHelper;
+}
+
+/*************************************************************************
+ dialog "edit regions"
+*************************************************************************/
+class SectRepr;
+typedef SectRepr* SectReprPtr;
+typedef boost::ptr_set<SectRepr> SectReprArr;
+
+class SwEditRegionDlg : public SfxModalDialog
+{
+ Edit* m_pCurName;
+ SvTreeListBox* m_pTree;
+
+ TriStateBox* m_pFileCB;
+ CheckBox* m_pDDECB;
+ VclContainer* m_pDDEFrame;
+ FixedText* m_pFileNameFT;
+ FixedText* m_pDDECommandFT;
+ Edit* m_pFileNameED;
+ PushButton* m_pFilePB;
+ FixedText* m_pSubRegionFT;
+ ComboBox* m_pSubRegionED;
+ bool m_bSubRegionsFilled;
+
+ TriStateBox* m_pProtectCB;
+ CheckBox* m_pPasswdCB;
+ PushButton* m_pPasswdPB;
+
+ TriStateBox* m_pHideCB;
+ FixedText* m_pConditionFT;
+ ConditionEdit* m_pConditionED;
+
+ // #114856# edit in readonly sections
+ TriStateBox* m_pEditInReadonlyCB;
+
+ OKButton* m_pOK;
+ PushButton* m_pOptionsPB;
+ PushButton* m_pDismiss;
+ ImageList aImageIL;
+
+ SwWrtShell& rSh;
+ SectReprArr aSectReprArr;
+ const SwSection* pCurrSect;
+ sfx2::DocumentInserter* m_pDocInserter;
+ Window* m_pOldDefDlgParent;
+
+ sal_Bool bDontCheckPasswd :1;
+ sal_Bool bWeb :1;
+
+ Image BuildBitmap(sal_Bool bProtect,sal_Bool bHidden);
+
+ void RecurseList( const SwSectionFmt* pFmt, SvTreeListEntry* pEntry);
+ sal_uInt16 FindArrPos(const SwSectionFmt* pFmt);
+
+ DECL_LINK( GetFirstEntryHdl, SvTreeListBox * );
+ DECL_LINK( DeselectHdl, SvTreeListBox * );
+
+ DECL_LINK(OkHdl, void *);
+ DECL_LINK(NameEditHdl, void *);
+ DECL_LINK( ConditionEditHdl, Edit * );
+
+ DECL_LINK( ChangePasswdHdl, Button * );
+ DECL_LINK( ChangeProtectHdl, TriStateBox * );
+ DECL_LINK( ChangeHideHdl, TriStateBox * );
+ // #114856# edit in readonly sections
+ DECL_LINK( ChangeEditInReadonlyHdl, TriStateBox * );
+ DECL_LINK(ChangeDismissHdl, void *);
+ DECL_LINK( UseFileHdl, CheckBox* );
+ DECL_LINK(FileSearchHdl, void *);
+ DECL_LINK(OptionsHdl, void *);
+ DECL_LINK( FileNameHdl, Edit* );
+ DECL_LINK( DDEHdl, CheckBox* );
+ DECL_LINK( DlgClosedHdl, sfx2::FileDialogHelper* );
+ DECL_LINK( SubRegionEventHdl, VclWindowEvent * );
+
+ sal_Bool CheckPasswd(CheckBox* pBox = 0);
+
+public:
+ SwEditRegionDlg( Window* pParent, SwWrtShell& rWrtSh );
+ virtual ~SwEditRegionDlg();
+
+ void SelectSection(const OUString& rSectionName);
+
+};
+
+/*************************************************************************
+ dialog "insert region"
+*************************************************************************/
+class SwInsertSectionTabPage : public SfxTabPage
+{
+ ComboBox* m_pCurName;
+
+ CheckBox* m_pFileCB;
+ CheckBox* m_pDDECB;
+ FixedText* m_pDDECommandFT;
+ FixedText* m_pFileNameFT;
+ Edit* m_pFileNameED;
+ PushButton* m_pFilePB;
+ FixedText* m_pSubRegionFT;
+ ComboBox* m_pSubRegionED;
+
+ CheckBox* m_pProtectCB;
+ CheckBox* m_pPasswdCB;
+ PushButton* m_pPasswdPB;
+
+ CheckBox* m_pHideCB;
+ FixedText* m_pConditionFT;
+ ConditionEdit* m_pConditionED;
+
+ // #114856# edit in readonly sections
+ CheckBox* m_pEditInReadonlyCB;
+
+ OUString m_sFileName;
+ OUString m_sFilterName;
+ OUString m_sFilePasswd;
+
+ ::com::sun::star::uno::Sequence <sal_Int8 > m_aNewPasswd;
+ SwWrtShell* m_pWrtSh;
+ sfx2::DocumentInserter* m_pDocInserter;
+ Window* m_pOldDefDlgParent;
+
+ DECL_LINK( ChangeHideHdl, CheckBox * );
+ // #114856# edit in readonly sections
+ DECL_LINK(ChangeEditInReadonlyHdl, void *);
+ DECL_LINK( ChangeProtectHdl, CheckBox * );
+ DECL_LINK( ChangePasswdHdl, Button * );
+ DECL_LINK(NameEditHdl, void *);
+ DECL_LINK( UseFileHdl, CheckBox* );
+ DECL_LINK(FileSearchHdl, void *);
+ DECL_LINK( DDEHdl, CheckBox* );
+ DECL_LINK( DlgClosedHdl, sfx2::FileDialogHelper* );
+
+public:
+ SwInsertSectionTabPage(Window *pParent, const SfxItemSet &rAttrSet);
+ virtual ~SwInsertSectionTabPage();
+
+ void SetWrtShell(SwWrtShell& rSh);
+
+ virtual sal_Bool FillItemSet( SfxItemSet& );
+ virtual void Reset( const SfxItemSet& );
+
+ static SfxTabPage* Create( Window* pParent,
+ const SfxItemSet& rAttrSet);
+};
+
+class SwSectionFtnEndTabPage : public SfxTabPage
+{
+ CheckBox* pFtnNtAtTextEndCB;
+
+ CheckBox* pFtnNtNumCB;
+ FixedText* pFtnOffsetLbl;
+ NumericField* pFtnOffsetFld;
+
+ CheckBox* pFtnNtNumFmtCB;
+ FixedText* pFtnPrefixFT;
+ Edit* pFtnPrefixED;
+ SwNumberingTypeListBox* pFtnNumViewBox;
+ FixedText* pFtnSuffixFT;
+ Edit* pFtnSuffixED;
+
+ CheckBox* pEndNtAtTextEndCB;
+
+ CheckBox* pEndNtNumCB;
+ FixedText* pEndOffsetLbl;
+ NumericField* pEndOffsetFld;
+
+ CheckBox* pEndNtNumFmtCB;
+ FixedText* pEndPrefixFT;
+ Edit* pEndPrefixED;
+ SwNumberingTypeListBox* pEndNumViewBox;
+ FixedText* pEndSuffixFT;
+ Edit* pEndSuffixED;
+
+ DECL_LINK( FootEndHdl, CheckBox * );
+ void ResetState( sal_Bool bFtn, const SwFmtFtnEndAtTxtEnd& );
+
+public:
+ SwSectionFtnEndTabPage( Window *pParent, const SfxItemSet &rAttrSet );
+ virtual ~SwSectionFtnEndTabPage();
+
+ virtual sal_Bool FillItemSet( SfxItemSet& );
+ virtual void Reset( const SfxItemSet& );
+
+ static SfxTabPage* Create( Window* pParent,
+ const SfxItemSet& rAttrSet);
+};
+
+class SwSectionIndentTabPage : public SfxTabPage
+{
+ MetricField* m_pBeforeMF;
+ MetricField* m_pAfterMF;
+ SvxParaPrevWindow* m_pPreviewWin;
+
+ DECL_LINK(IndentModifyHdl, void *);
+public:
+ SwSectionIndentTabPage( Window *pParent, const SfxItemSet &rAttrSet );
+ virtual ~SwSectionIndentTabPage();
+
+ virtual sal_Bool FillItemSet( SfxItemSet& );
+ virtual void Reset( const SfxItemSet& );
+
+ static SfxTabPage* Create( Window* pParent,
+ const SfxItemSet& rAttrSet);
+
+ void SetWrtShell(SwWrtShell& rSh);
+};
+
+class SwInsertSectionTabDialog : public SfxTabDialog
+{
+ SwWrtShell& rWrtSh;
+ ::std::auto_ptr<SwSectionData> m_pSectionData;
+
+ sal_uInt16 m_nSectionPageId;
+ sal_uInt16 m_nColumnPageId;
+ sal_uInt16 m_nBackPageId;
+ sal_uInt16 m_nNotePageId;
+ sal_uInt16 m_nIndentPage;
+
+protected:
+ virtual void PageCreated( sal_uInt16 nId, SfxTabPage &rPage );
+ virtual short Ok();
+public:
+ SwInsertSectionTabDialog(Window* pParent, const SfxItemSet& rSet, SwWrtShell& rSh);
+ virtual ~SwInsertSectionTabDialog();
+
+ void SetSectionData(SwSectionData const& rSect);
+ SwSectionData * GetSectionData() { return m_pSectionData.get(); }
+};
+
+class SwSectionPropertyTabDialog : public SfxTabDialog
+{
+ SwWrtShell& rWrtSh;
+
+ sal_uInt16 m_nColumnPageId;
+ sal_uInt16 m_nBackPageId;
+ sal_uInt16 m_nNotePageId;
+ sal_uInt16 m_nIndentPage;
+
+protected:
+ virtual void PageCreated( sal_uInt16 nId, SfxTabPage &rPage );
+public:
+ SwSectionPropertyTabDialog(Window* pParent, const SfxItemSet& rSet, SwWrtShell& rSh);
+ virtual ~SwSectionPropertyTabDialog();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/ribbar.hrc b/sw/source/core/uibase/inc/ribbar.hrc
new file mode 100644
index 000000000000..296b61d4b28c
--- /dev/null
+++ b/sw/source/core/uibase/inc/ribbar.hrc
@@ -0,0 +1,104 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef _RIBBAR_HRC
+#define _RIBBAR_HRC
+
+#include "rcid.hrc"
+
+#define MN_FORM1 1 // Defines fuer NumNames-Popup
+#define MN_FORMBASE MN_FORM1
+#define MN_FORM2 2
+#define MN_FORM3 3
+#define MN_FORM4 4
+#define MN_FORM5 5
+
+#define CB_FORMAT (RC_RIBBAR_BEGIN +1)
+#define CB_SIZE (RC_RIBBAR_BEGIN +3)
+#define RID_TBX_FORMULA (RC_RIBBAR_BEGIN +6)
+#define FT_POS (RC_RIBBAR_BEGIN +7)
+#define STR_TBL_FORMULA (RC_RIBBAR_BEGIN +9)
+
+#define RID_DRAW_WIN (RC_RIBBAR_BEGIN + 18)
+#define RID_CNTRLR_WIN (RC_RIBBAR_BEGIN + 19)
+#define RID_ALIGNMENT_WIN (RC_RIBBAR_BEGIN + 20)
+
+//Resourcen fuer Inputwin (Rechenleiste)
+#define MN_CALC_POPUP (RC_RIBBAR_BEGIN + 22)
+
+#define RID_INSERT_FIELD_CTRL (RC_RIBBAR_BEGIN + 26)
+#define RID_SCROLL_NAVIGATION_WIN (RC_RIBBAR_BEGIN + 30)
+#define RID_PVIEW_ZOOM_LB (RC_RIBBAR_BEGIN + 31)
+
+#define STR_IMGBTN_START (RC_RIBBAR_BEGIN + 31)
+
+#define STR_IMGBTN_NEXT_DOWN (STR_IMGBTN_START + 0)
+#define STR_IMGBTN_PREV_DOWN (STR_IMGBTN_START + 1)
+#define STR_IMGBTN_TBL_DOWN (STR_IMGBTN_START + 2)
+#define STR_IMGBTN_FRM_DOWN (STR_IMGBTN_START + 3)
+#define STR_IMGBTN_PGE_DOWN (STR_IMGBTN_START + 4)
+#define STR_IMGBTN_DRW_DOWN (STR_IMGBTN_START + 5)
+#define STR_IMGBTN_CTRL_DOWN (STR_IMGBTN_START + 6)
+#define STR_IMGBTN_REG_DOWN (STR_IMGBTN_START + 7)
+#define STR_IMGBTN_BKM_DOWN (STR_IMGBTN_START + 8)
+#define STR_IMGBTN_GRF_DOWN (STR_IMGBTN_START + 9)
+#define STR_IMGBTN_OLE_DOWN (STR_IMGBTN_START +10)
+#define STR_IMGBTN_OUTL_DOWN (STR_IMGBTN_START +11)
+#define STR_IMGBTN_SEL_DOWN (STR_IMGBTN_START +12)
+#define STR_IMGBTN_FTN_DOWN (STR_IMGBTN_START +13)
+#define STR_IMGBTN_MARK_DOWN (STR_IMGBTN_START +14)
+#define STR_IMGBTN_POSTIT_DOWN (STR_IMGBTN_START +15)
+#define STR_IMGBTN_SRCH_REP_DOWN (STR_IMGBTN_START +16)
+#define STR_IMGBTN_INDEX_ENTRY_DOWN (STR_IMGBTN_START +17)
+#define STR_IMGBTN_TBLFML_DOWN (STR_IMGBTN_START +18)
+#define STR_IMGBTN_TBLFML_ERR_DOWN (STR_IMGBTN_START +19)
+
+#define STR_IMGBTN_NEXT_UP (STR_IMGBTN_START +20)
+#define STR_IMGBTN_PREV_UP (STR_IMGBTN_START +21)
+#define STR_IMGBTN_TBL_UP (STR_IMGBTN_START +22)
+#define STR_IMGBTN_FRM_UP (STR_IMGBTN_START +23)
+#define STR_IMGBTN_PGE_UP (STR_IMGBTN_START +24)
+#define STR_IMGBTN_DRW_UP (STR_IMGBTN_START +25)
+#define STR_IMGBTN_CTRL_UP (STR_IMGBTN_START +26)
+#define STR_IMGBTN_REG_UP (STR_IMGBTN_START +27)
+#define STR_IMGBTN_BKM_UP (STR_IMGBTN_START +28)
+#define STR_IMGBTN_GRF_UP (STR_IMGBTN_START +29)
+#define STR_IMGBTN_OLE_UP (STR_IMGBTN_START +30)
+#define STR_IMGBTN_OUTL_UP (STR_IMGBTN_START +31)
+#define STR_IMGBTN_SEL_UP (STR_IMGBTN_START +32)
+#define STR_IMGBTN_FTN_UP (STR_IMGBTN_START +33)
+#define STR_IMGBTN_MARK_UP (STR_IMGBTN_START +34)
+#define STR_IMGBTN_POSTIT_UP (STR_IMGBTN_START +35)
+#define STR_IMGBTN_SRCH_REP_UP (STR_IMGBTN_START +36)
+#define STR_IMGBTN_INDEX_ENTRY_UP (STR_IMGBTN_START +37)
+#define STR_IMGBTN_TBLFML_UP (STR_IMGBTN_START +38)
+#define STR_IMGBTN_TBLFML_ERR_UP (STR_IMGBTN_START +39)
+
+#define BTN_NAVI (STR_IMGBTN_START +40)
+
+#define MN_ANCHOR_POPUP (STR_IMGBTN_START +41)
+
+#define RC_RIBBAR_ACT_END MN_ANCHOR_POPUP
+
+#if RC_RIBBAR_ACT_END > RC_RIBBAR_END
+#error Resource-Id Ueberlauf in #file, #line
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/rowht.hxx b/sw/source/core/uibase/inc/rowht.hxx
new file mode 100644
index 000000000000..022c1d2940f2
--- /dev/null
+++ b/sw/source/core/uibase/inc/rowht.hxx
@@ -0,0 +1,44 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_ROWHT_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_ROWHT_HXX
+
+#include <svx/stddlg.hxx>
+#include <vcl/field.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/button.hxx>
+
+class SwWrtShell;
+
+class SwTableHeightDlg : public SvxStandardDialog
+{
+ MetricField* m_pHeightEdit;
+ CheckBox* m_pAutoHeightCB;
+ SwWrtShell &rSh;
+
+protected:
+ virtual void Apply();
+
+public:
+ SwTableHeightDlg( Window *pParent, SwWrtShell &rS );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/scroll.hxx b/sw/source/core/uibase/inc/scroll.hxx
new file mode 100644
index 000000000000..ba0f66b33398
--- /dev/null
+++ b/sw/source/core/uibase/inc/scroll.hxx
@@ -0,0 +1,59 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_SCROLL_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_SCROLL_HXX
+#include <vcl/scrbar.hxx>
+
+class SwScrollbar: public ScrollBar
+{
+ Size aDocSz;
+ sal_Bool bHori :1; // horizontal = salTrue, otherwise vertical
+ sal_Bool bAuto :1; // for scrolling mode
+ sal_Bool bVisible :1; // show/hide should only set this flag
+ sal_Bool bSizeSet :1; // was the size already set?
+
+ void AutoShow();
+
+ using Window::Hide;
+ using Window::IsVisible;
+
+public:
+
+ void ExtendedShow( sal_Bool bVisible = sal_True );
+ void Hide() { Show( false ); }
+ void SetPosSizePixel( const Point& rNewPos, const Size& rNewSize );
+ sal_Bool IsVisible(sal_Bool bReal) const { return bReal ? ScrollBar::IsVisible() : bVisible; }
+
+ // changing of document size
+ void DocSzChgd(const Size &rNewSize);
+ // changing of visible region
+ void ViewPortChgd(const Rectangle &rRectangle);
+ // what is it??
+ sal_Bool IsHoriScroll() const { return bHori; }
+
+ void SetAuto(sal_Bool bSet);
+ sal_Bool IsAuto() { return bAuto;}
+
+ SwScrollbar(Window *pParent, sal_Bool bHori = sal_True );
+ ~SwScrollbar();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/selglos.hxx b/sw/source/core/uibase/inc/selglos.hxx
new file mode 100644
index 000000000000..734c098fea88
--- /dev/null
+++ b/sw/source/core/uibase/inc/selglos.hxx
@@ -0,0 +1,54 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_SELGLOS_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_SELGLOS_HXX
+
+#include <vcl/dialog.hxx>
+
+#include <vcl/lstbox.hxx>
+#include <vcl/fixed.hxx>
+
+#include <vcl/button.hxx>
+
+class SwSelGlossaryDlg : public ModalDialog
+{
+protected:
+ ListBox* m_pGlosBox;
+
+ DECL_LINK(DoubleClickHdl, ListBox*);
+public:
+ SwSelGlossaryDlg(Window * pParent, const OUString &rShortName);
+ void InsertGlos(const OUString &rRegion, const OUString &rGlosName)
+ {
+ const OUString aTmp = rRegion + ":" + rGlosName;
+ m_pGlosBox->InsertEntry(aTmp);
+ }
+ sal_uInt16 GetSelectedIdx() const
+ {
+ return m_pGlosBox->GetSelectEntryPos();
+ }
+ void SelectEntryPos(sal_uInt16 nIdx)
+ {
+ m_pGlosBox->SelectEntryPos(nIdx);
+ }
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/sharedconnection.hxx b/sw/source/core/uibase/inc/sharedconnection.hxx
new file mode 100644
index 000000000000..cf279b6e50b3
--- /dev/null
+++ b/sw/source/core/uibase/inc/sharedconnection.hxx
@@ -0,0 +1,30 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SW_SOURCE_UI_INC_SHAREDCONNECTION_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_SHAREDCONNECTION_HXX
+
+#include <unotools/sharedunocomponent.hxx>
+#include <com/sun/star/sdbc/XConnection.hpp>
+
+typedef ::utl::SharedUNOComponent< ::com::sun::star::sdbc::XConnection > SharedConnection;
+
+#endif // INCLUDED_SW_SOURCE_UI_INC_SHAREDCONNECTION_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/shdwcrsr.hxx b/sw/source/core/uibase/inc/shdwcrsr.hxx
new file mode 100644
index 000000000000..5fb1d9684162
--- /dev/null
+++ b/sw/source/core/uibase/inc/shdwcrsr.hxx
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_SHDWCRSR_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_SHDWCRSR_HXX
+
+#include <tools/gen.hxx>
+#include <tools/color.hxx>
+#include <limits.h>
+
+class Window;
+
+class SwShadowCursor
+{
+ Window* pWin;
+ Color aCol;
+ Point aOldPt;
+ long nOldHeight;
+ sal_uInt16 nOldMode;
+
+ void DrawTri( const Point& rPt, long nHeight, bool bLeft );
+ void DrawCrsr( const Point& rPt, long nHeight, sal_uInt16 nMode );
+
+public:
+ SwShadowCursor( Window& rWin, const Color& rCol )
+ : pWin( &rWin ), aCol( rCol ), nOldHeight(0), nOldMode( USHRT_MAX ) {}
+ ~SwShadowCursor();
+
+ void SetPos( const Point& rPt, long nHeight, sal_uInt16 nMode );
+
+ void Paint();
+
+ const Point& GetPoint() const { return aOldPt; }
+ long GetHeight() const { return nOldHeight; }
+ sal_uInt16 GetMode() const { return nOldMode; }
+
+ Rectangle GetRect() const;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/shells.hrc b/sw/source/core/uibase/inc/shells.hrc
new file mode 100644
index 000000000000..4070dd2c8764
--- /dev/null
+++ b/sw/source/core/uibase/inc/shells.hrc
@@ -0,0 +1,100 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef _SHELLS_HRC
+#define _SHELLS_HRC
+
+#include "rcid.hrc"
+
+#define STR_GRFILTER_OPENERROR (RC_SHELLS_BEGIN + 1)
+#define STR_GRFILTER_IOERROR (RC_SHELLS_BEGIN + 2)
+#define STR_GRFILTER_FORMATERROR (RC_SHELLS_BEGIN + 3)
+#define STR_GRFILTER_VERSIONERROR (RC_SHELLS_BEGIN + 4)
+#define STR_GRFILTER_FILTERERROR (RC_SHELLS_BEGIN + 5)
+#define STR_GRFILTER_TOOBIG (RC_SHELLS_BEGIN + 6)
+#define STR_INSERT_GRAPHIC (RC_SHELLS_BEGIN + 7)
+#define STR_NO_ADDRESSBOOK (RC_SHELLS_BEGIN + 10)
+#define STR_REDLINE_COMMENT (RC_SHELLS_BEGIN + 11)
+#define STR_REDLINE_INSERTED (RC_SHELLS_BEGIN + 12)
+#define STR_REDLINE_DELETED (RC_SHELLS_BEGIN + 13)
+#define STR_REDLINE_FMTCOLLSET (RC_SHELLS_BEGIN + 14)
+
+#define RID_TEXT_TOOLBOX (RC_SHELLS_BEGIN + 15)
+#define RID_TABLE_TOOLBOX (RC_SHELLS_BEGIN + 16)
+#define RID_FRAME_TOOLBOX (RC_SHELLS_BEGIN + 17)
+#define RID_GRAFIK_TOOLBOX (RC_SHELLS_BEGIN + 18)
+#define RID_DRAW_TOOLBOX (RC_SHELLS_BEGIN + 19)
+#define RID_DRAW_TEXT_TOOLBOX (RC_SHELLS_BEGIN + 20)
+#define RID_NUM_TOOLBOX (RC_SHELLS_BEGIN + 21)
+#define RID_OLE_TOOLBOX (RC_SHELLS_BEGIN + 22)
+#define RID_TOOLS_TOOLBOX (RC_SHELLS_BEGIN + 23)
+
+#define STR_SHELLNAME_TEXT (RC_SHELLS_BEGIN + 24)
+#define STR_SHELLNAME_TABLE (RC_SHELLS_BEGIN + 25)
+#define STR_SHELLNAME_FRAME (RC_SHELLS_BEGIN + 26)
+#define STR_SHELLNAME_GRAPHIC (RC_SHELLS_BEGIN + 27)
+#define STR_SHELLNAME_OBJECT (RC_SHELLS_BEGIN + 28)
+#define STR_SHELLNAME_LIST (RC_SHELLS_BEGIN + 29)
+#define STR_SHELLNAME_DRAW (RC_SHELLS_BEGIN + 30)
+#define STR_SHELLNAME_DRAW_TEXT (RC_SHELLS_BEGIN + 31)
+#define STR_SHELLNAME_MEDIA (RC_SHELLS_BEGIN + 32)
+
+
+#define RID_BEZIER_TOOLBOX (RC_SHELLS_BEGIN + 33)
+#define STR_SHELLNAME_BEZIER (RC_SHELLS_BEGIN + 34)
+
+#define STR_SWBG_PARAGRAPH (RC_SHELLS_BEGIN + 37)
+#define STR_SWBG_GRAPHIC (RC_SHELLS_BEGIN + 38)
+#define STR_SWBG_OLE (RC_SHELLS_BEGIN + 39)
+#define STR_SWBG_FRAME (RC_SHELLS_BEGIN + 40)
+#define STR_SWBG_TABLE (RC_SHELLS_BEGIN + 41)
+#define STR_SWBG_TABLE_ROW (RC_SHELLS_BEGIN + 42)
+#define STR_SWBG_TABLE_CELL (RC_SHELLS_BEGIN + 43)
+#define STR_SWBG_PAGE (RC_SHELLS_BEGIN + 44)
+#define STR_SWBG_HEADER (RC_SHELLS_BEGIN + 45)
+#define STR_SWBG_FOOTER (RC_SHELLS_BEGIN + 46)
+
+#define STR_SHELLNAME_DRAWFORM (RC_SHELLS_BEGIN + 48)
+ // FREE
+
+#define STR_REDLINE_FORMATED (RC_SHELLS_BEGIN + 50)
+#define STR_REDLINE_TABLECHG (RC_SHELLS_BEGIN + 51)
+
+#define STR_REDLINE_TITLE (RC_SHELLS_BEGIN + 52)
+#define STR_REDLINE_MSG (RC_SHELLS_BEGIN + 53)
+#define STR_REDLINE_ACCEPT_ALL (RC_SHELLS_BEGIN + 54)
+#define STR_REDLINE_REJECT_ALL (RC_SHELLS_BEGIN + 55)
+#define STR_REDLINE_EDIT (RC_SHELLS_BEGIN + 56)
+#define STR_REDLINE_AUTOFMT (RC_SHELLS_BEGIN + 57)
+
+#define RID_MODULE_TOOLBOX (RC_SHELLS_BEGIN + 60)
+
+#define RID_MEDIA_TOOLBOX (RC_SHELLS_BEGIN + 61)
+
+#define STR_SHELLNAME_NAVIGATION (RC_SHELLS_BEGIN + 62)
+
+#define SHELLS_ACT_END STR_SHELLNAME_NAVIGATION
+
+#if SHELLS_ACT_END > RC_SHELLS_END
+#error Resource-Id Ueberlauf in #file, #line
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/splittbl.hxx b/sw/source/core/uibase/inc/splittbl.hxx
new file mode 100644
index 000000000000..522f1d65cab4
--- /dev/null
+++ b/sw/source/core/uibase/inc/splittbl.hxx
@@ -0,0 +1,49 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_SPLITTBL_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_SPLITTBL_HXX
+
+#include <svx/stddlg.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/button.hxx>
+
+class SwWrtShell;
+
+class SwSplitTblDlg : public SvxStandardDialog
+{
+ RadioButton* mpCntntCopyRB;
+ RadioButton* mpBoxAttrCopyWithParaRB ;
+ RadioButton* mpBoxAttrCopyNoParaRB ;
+ RadioButton* mpBorderCopyRB;
+
+ SwWrtShell &rShell;
+ sal_uInt16 m_nSplit;
+
+protected:
+ virtual void Apply();
+
+public:
+ SwSplitTblDlg( Window *pParent, SwWrtShell &rSh );
+
+ sal_uInt16 GetSplitMode() const { return m_nSplit; }
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/srcedtw.hxx b/sw/source/core/uibase/inc/srcedtw.hxx
new file mode 100644
index 000000000000..c490dc4d6193
--- /dev/null
+++ b/sw/source/core/uibase/inc/srcedtw.hxx
@@ -0,0 +1,157 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_SRCEDTW_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_SRCEDTW_HXX
+
+#include <vcl/window.hxx>
+#include <svl/lstner.hxx>
+#include <vcl/timer.hxx>
+
+#include <vcl/xtextedt.hxx>
+#include <set>
+
+namespace com { namespace sun { namespace star { namespace beans {
+ class XMultiPropertySet;
+} } } }
+
+class ScrollBar;
+class SwSrcView;
+class SwSrcEditWindow;
+class TextEngine;
+class ExtTextView;
+class DataChangedEvent;
+
+class TextViewOutWin : public Window
+{
+ ExtTextView* pTextView;
+
+protected:
+ virtual void Paint( const Rectangle& );
+ virtual void KeyInput( const KeyEvent& rKeyEvt );
+ 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 DataChanged( const DataChangedEvent& );
+
+public:
+ TextViewOutWin(Window* pParent, WinBits nBits) :
+ Window(pParent, nBits), pTextView(0){}
+
+ void SetTextView( ExtTextView* pView ) {pTextView = pView;}
+
+};
+
+typedef std::set<sal_uInt16> SyntaxLineSet;
+
+class SwSrcEditWindow : public Window, public SfxListener
+{
+private:
+ class ChangesListener;
+ friend class ChangesListener;
+ ExtTextView* pTextView;
+ ExtTextEngine* pTextEngine;
+
+ TextViewOutWin* pOutWin;
+ ScrollBar *pHScrollbar,
+ *pVScrollbar;
+
+ SwSrcView* pSrcView;
+
+ rtl::Reference< ChangesListener > listener_;
+ osl::Mutex mutex_;
+ com::sun::star::uno::Reference< com::sun::star::beans::XMultiPropertySet >
+ notifier_;
+
+ long nCurTextWidth;
+ sal_uInt16 nStartLine;
+ rtl_TextEncoding eSourceEncoding;
+ sal_Bool bReadonly;
+ sal_Bool bDoSyntaxHighlight;
+ sal_Bool bHighlighting;
+
+ Timer aSyntaxIdleTimer;
+ SyntaxLineSet aSyntaxLineTable;
+
+ void ImpDoHighlight( const OUString& rSource, sal_uInt16 nLineOff );
+
+ using OutputDevice::SetFont;
+ void SetFont();
+
+ DECL_LINK( SyntaxTimerHdl, Timer * );
+ DECL_LINK( TimeoutHdl, Timer * );
+
+ using Window::Notify;
+ using Window::Invalidate;
+
+protected:
+
+ virtual void Resize();
+ virtual void DataChanged( const DataChangedEvent& );
+ virtual void GetFocus();
+// virtual void LoseFocus();
+
+ void CreateTextEngine();
+ void DoSyntaxHighlight( sal_uInt16 nPara );
+
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+
+ DECL_LINK(ScrollHdl, ScrollBar*);
+
+public:
+ SwSrcEditWindow( Window* pParent, SwSrcView* pParentView );
+ ~SwSrcEditWindow();
+
+ void SetScrollBarRanges();
+ void InitScrollBars();
+ void Read(SvStream& rInput) { pTextEngine->Read(rInput); }
+ void Write(SvStream& rOutput) { pTextEngine->Write(rOutput); }
+
+ ExtTextView* GetTextView()
+ {return pTextView;}
+ TextEngine* GetTextEngine()
+ {return pTextEngine;}
+ SwSrcView* GetSrcView() {return pSrcView;}
+
+ TextViewOutWin* GetOutWin() {return pOutWin;}
+
+ virtual void Invalidate( sal_uInt16 nFlags = 0 );
+
+ void ClearModifyFlag()
+ { pTextEngine->SetModified(false); }
+ sal_Bool IsModified() const
+ { return pTextEngine->IsModified();}
+ void CreateScrollbars();
+
+ void SetReadonly(sal_Bool bSet){bReadonly = bSet;}
+ sal_Bool IsReadonly(){return bReadonly;}
+
+ void DoDelayedSyntaxHighlight( sal_uInt16 nPara );
+
+ void SetStartLine(sal_uInt16 nLine){nStartLine = nLine;}
+
+ virtual void Command( const CommandEvent& rCEvt );
+ void HandleWheelCommand( const CommandEvent& rCEvt );
+
+ void SetTextEncoding(rtl_TextEncoding eEncoding);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/srcview.hxx b/sw/source/core/uibase/inc/srcview.hxx
new file mode 100644
index 000000000000..ba91f8732278
--- /dev/null
+++ b/sw/source/core/uibase/inc/srcview.hxx
@@ -0,0 +1,89 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_SRCVIEW_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_SRCVIEW_HXX
+
+#include <sfx2/viewfac.hxx>
+#include <sfx2/viewsh.hxx>
+#include <vcl/outdev.hxx>
+
+#include "srcedtw.hxx"
+#include "shellid.hxx"
+
+class SwDocShell;
+class SvxSearchItem;
+class SfxMedium;
+
+class SwSrcView: public SfxViewShell
+{
+ SwSrcEditWindow aEditWin;
+
+ SvxSearchItem* pSearchItem;
+
+ sal_Bool bSourceSaved :1;
+ rtl_TextEncoding eLoadEncoding;
+ void Init();
+
+ // for read-only switching
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+
+protected:
+ sal_uInt16 StartSearchAndReplace(const SvxSearchItem& rItem,
+ sal_Bool bFromStart,
+ sal_Bool bApi,
+ sal_Bool bRecursive = sal_False);
+
+public:
+
+ SFX_DECL_VIEWFACTORY(SwSrcView);
+ SFX_DECL_INTERFACE(SW_SRC_VIEWSHELL)
+ TYPEINFO();
+
+ SwSrcView(SfxViewFrame* pFrame, SfxViewShell*);
+
+ ~SwSrcView();
+
+ SwDocShell* GetDocShell();
+ SwSrcEditWindow& GetEditWin() {return aEditWin;}
+ void SaveContent(const OUString& rTmpFile);
+ void SaveContentTo(SfxMedium& rMed);
+
+ sal_Bool IsModified() {return aEditWin.IsModified();}
+
+ void Execute(SfxRequest&);
+ void GetState(SfxItemSet&);
+
+ SvxSearchItem* GetSearchItem();
+ void SetSearchItem( const SvxSearchItem& rItem );
+
+ void Load(SwDocShell* pDocShell);
+
+ virtual sal_uInt16 SetPrinter( SfxPrinter* pNew, sal_uInt16 nDiff = SFX_PRINTER_ALL, bool bIsAPI=false );
+ virtual SfxPrinter* GetPrinter( sal_Bool bCreate = sal_False );
+
+ sal_Int32 PrintSource( OutputDevice *pOutDev, sal_Int32 nPage, bool bCalcNumPagesOnly );
+
+ void SourceSaved() {bSourceSaved = sal_True;}
+ sal_Bool HasSourceSaved() const {return bSourceSaved;}
+
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/srtdlg.hxx b/sw/source/core/uibase/inc/srtdlg.hxx
new file mode 100644
index 000000000000..90fc60ab165a
--- /dev/null
+++ b/sw/source/core/uibase/inc/srtdlg.hxx
@@ -0,0 +1,92 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_SRTDLG_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_SRTDLG_HXX
+
+#include <vcl/fixed.hxx>
+#include <vcl/button.hxx>
+#include <vcl/field.hxx>
+#include <vcl/lstbox.hxx>
+#include <svx/stddlg.hxx>
+#include <svx/langbox.hxx>
+
+class SwWrtShell;
+class CollatorResource;
+
+class SwSortDlg : public SvxStandardDialog
+{
+ FixedText* m_pColLbl;
+ FixedText* m_pTypLbl;
+
+ CheckBox* m_pKeyCB1;
+ NumericField* m_pColEdt1;
+ ListBox* m_pTypDLB1;
+ RadioButton* m_pSortUp1RB;
+ RadioButton* m_pSortDn1RB;
+
+ CheckBox* m_pKeyCB2;
+ NumericField* m_pColEdt2;
+ ListBox* m_pTypDLB2;
+ RadioButton* m_pSortUp2RB;
+ RadioButton* m_pSortDn2RB;
+
+ CheckBox* m_pKeyCB3;
+ NumericField* m_pColEdt3;
+ ListBox* m_pTypDLB3;
+ RadioButton* m_pSortUp3RB;
+ RadioButton* m_pSortDn3RB;
+
+ RadioButton* m_pColumnRB;
+ RadioButton* m_pRowRB;
+
+ RadioButton* m_pDelimTabRB;
+ RadioButton* m_pDelimFreeRB;
+ Edit* m_pDelimEdt;
+ PushButton* m_pDelimPB;
+
+ SvxLanguageBox* m_pLangLB;
+
+ CheckBox* m_pCaseCB;
+
+ OUString aColTxt;
+ OUString aRowTxt;
+ OUString aNumericTxt;
+
+ SwWrtShell &rSh;
+ CollatorResource* pColRes;
+
+ sal_uInt16 nX;
+ sal_uInt16 nY;
+
+ virtual void Apply();
+ sal_Unicode GetDelimChar() const;
+
+ DECL_LINK( CheckHdl, CheckBox * );
+ DECL_LINK( DelimHdl, RadioButton* );
+ DECL_LINK( LanguageHdl, ListBox* );
+ DECL_LINK(DelimCharHdl, void *);
+
+public:
+ SwSortDlg(Window * pParent, SwWrtShell &rSh);
+ ~SwSortDlg();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/stmenu.hxx b/sw/source/core/uibase/inc/stmenu.hxx
new file mode 100644
index 000000000000..4d7737142370
--- /dev/null
+++ b/sw/source/core/uibase/inc/stmenu.hxx
@@ -0,0 +1,74 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+// SMARTTAGS
+
+#ifndef INCLUDED_SW_SOURCE_UI_INC_STMENU_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_STMENU_HXX
+
+#include <vcl/menu.hxx>
+
+#include <vector>
+#include <com/sun/star/smarttags/XSmartTagAction.hpp>
+
+#include <com/sun/star/container/XStringKeyMap.hpp>
+#include <com/sun/star/text/XTextRange.hpp>
+
+class SwView;
+
+/** Class: SwSmartTagPopup
+
+ This class contains the implementation of the smarttag popup
+ menu that is opened if a user clicks on an underlined word.
+
+ The menu is built in the constructor and the actions for each
+ menu entry are invoked in the excute-method.
+*/
+
+class SwSmartTagPopup : public PopupMenu
+{
+ SwView* mpSwView;
+ com::sun::star::uno::Reference< com::sun::star::text::XTextRange > mxTextRange;
+
+ struct InvokeAction
+ {
+ com::sun::star::uno::Reference< com::sun::star::smarttags::XSmartTagAction > mxAction;
+ com::sun::star::uno::Reference< com::sun::star::container::XStringKeyMap > mxSmartTagProperties;
+ sal_uInt32 mnActionID;
+ InvokeAction( com::sun::star::uno::Reference< com::sun::star::smarttags::XSmartTagAction > xAction,
+ com::sun::star::uno::Reference< com::sun::star::container::XStringKeyMap > xSmartTagProperties,
+ sal_uInt32 nActionID ) : mxAction( xAction ), mxSmartTagProperties( xSmartTagProperties ), mnActionID( nActionID ) {}
+ };
+
+ std::vector< InvokeAction > maInvokeActions;
+
+ using PopupMenu::Execute;
+
+public:
+ SwSmartTagPopup( SwView* _pSwView,
+ ::com::sun::star::uno::Sequence< OUString >& rSmartTagTypes,
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::container::XStringKeyMap > >& rStringKeyMaps,
+ ::com::sun::star::uno::Reference< com::sun::star::text::XTextRange > xTextRange );
+
+ sal_uInt16 Execute( const Rectangle& rPopupPos, Window* pWin );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/swcont.hxx b/sw/source/core/uibase/inc/swcont.hxx
new file mode 100644
index 000000000000..4c9294907b79
--- /dev/null
+++ b/sw/source/core/uibase/inc/swcont.hxx
@@ -0,0 +1,99 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SW_SOURCE_UI_INC_SWCONT_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_SWCONT_HXX
+
+#include <rtl/ustring.hxx>
+
+class SwContentType;
+
+// synchronize order and number with ResIds!!
+#define CONTENT_TYPE_OUTLINE 0
+#define CONTENT_TYPE_TABLE 1
+#define CONTENT_TYPE_FRAME 2
+#define CONTENT_TYPE_GRAPHIC 3
+#define CONTENT_TYPE_OLE 4
+#define CONTENT_TYPE_BOOKMARK 5
+#define CONTENT_TYPE_REGION 6
+#define CONTENT_TYPE_URLFIELD 7
+#define CONTENT_TYPE_REFERENCE 8
+#define CONTENT_TYPE_INDEX 9
+#define CONTENT_TYPE_POSTIT 10
+#define CONTENT_TYPE_DRAWOBJECT 11
+#define CONTENT_TYPE_MAX CONTENT_TYPE_DRAWOBJECT +1
+
+// types for global document
+#define GLOBAL_CONTENT_TEXT 102
+
+// strings for context menus
+#define CONTEXT_COUNT 12
+#define GLOBAL_CONTEXT_COUNT 14
+
+// modes for Drag 'n Drop
+#define REGION_MODE_NONE 0
+#define REGION_MODE_LINK 1
+#define REGION_MODE_EMBEDDED 2
+
+//mini rtti
+class SwTypeNumber
+{
+ sal_uInt8 nTypeId;
+
+ public:
+ SwTypeNumber(sal_uInt8 nId) :nTypeId(nId){}
+ virtual ~SwTypeNumber();
+
+ sal_uInt8 GetTypeId() const;
+};
+
+class SwContent : public SwTypeNumber
+{
+ const SwContentType* pParent;
+ OUString sContentName;
+ long nYPosition;
+ sal_Bool bInvisible;
+public:
+ SwContent(const SwContentType* pCnt, const OUString& rName, long nYPos );
+
+ virtual sal_Bool IsProtect() const;
+ const SwContentType* GetParent() const {return pParent;}
+ const OUString& GetName() const {return sContentName;}
+ int operator==(const SwContent& /*rCont*/) const
+ {
+ // they're never equal, otherwise they'd fall out of the array
+ return sal_False;
+ }
+ bool operator<(const SwContent& rCont) const
+ {
+ // at first sort by position and then by name
+ return nYPosition != rCont.nYPosition ?
+ nYPosition < rCont.nYPosition :
+ sContentName < rCont.sContentName;
+ }
+
+ long GetYPos() const {return nYPosition;}
+
+ sal_Bool IsInvisible() const {return bInvisible;}
+ void SetInvisible(){ bInvisible = sal_True;}
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/swdtflvr.hxx b/sw/source/core/uibase/inc/swdtflvr.hxx
new file mode 100644
index 000000000000..d68a9daac07a
--- /dev/null
+++ b/sw/source/core/uibase/inc/swdtflvr.hxx
@@ -0,0 +1,213 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_SWDTFLVR_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_SWDTFLVR_HXX
+
+#include <sfx2/objsh.hxx>
+
+#include <svtools/transfer.hxx>
+#include <vcl/graph.hxx>
+#include <sfx2/lnkbase.hxx>
+#include <com/sun/star/embed/XEmbeddedObject.hpp>
+
+class Graphic;
+class ImageMap;
+class INetBookmark;
+class INetImage;
+class SwDoc;
+class SwDocFac;
+class SwTextBlocks;
+class SwWrtShell;
+class SvxClipboardFmtItem;
+class SwViewShell;
+class SwView_Impl;
+
+typedef sal_uInt16 TransferBufferType;
+namespace nsTransferBufferType
+{
+ const sal_uInt16 TRNSFR_NONE = 0x0000;
+ const sal_uInt16 TRNSFR_DOCUMENT = 0x0001;
+ const sal_uInt16 TRNSFR_DOCUMENT_WORD = 0x0002;
+ const sal_uInt16 TRNSFR_GRAPHIC = 0x0004;
+ const sal_uInt16 TRNSFR_TABELLE = 0x0008;
+ const sal_uInt16 TRNSFR_DDELINK = 0x0010;
+ const sal_uInt16 TRNSFR_OLE = 0x0020;
+ const sal_uInt16 TRNSFR_INETFLD = 0x0040;
+ const sal_uInt16 TRNSFR_DRAWING = 0x0081; // drawing is internal too!
+}
+
+class SW_DLLPUBLIC SwTransferable : public TransferableHelper
+{
+ friend class SwView_Impl;
+ SfxObjectShellLock aDocShellRef;
+ TransferableDataHelper aOleData;
+ TransferableObjectDescriptor aObjDesc;
+ ::sfx2::SvBaseLinkRef refDdeLink;
+
+ SwWrtShell *pWrtShell;
+ /* #96392# Added pCreatorView to distinguish SwFrameShell from
+ SwWrtShell. */
+ const SwViewShell *pCreatorView;
+ SwDocFac *pClpDocFac;
+ Graphic *pClpGraphic, *pClpBitmap, *pOrigGrf;
+ INetBookmark *pBkmk; // URL and description!
+ ImageMap *pImageMap;
+ INetImage *pTargetURL;
+
+ TransferBufferType eBufferType;
+
+ sal_Bool bOldIdle :1; //D&D Idle flag from the viewsettings
+ sal_Bool bCleanUp :1; //D&D cleanup after Drop (not by internal Drop)
+
+ // helper methods for the copy
+ css::uno::Reference < css::embed::XEmbeddedObject > FindOLEObj( sal_Int64& nAspect ) const;
+ const Graphic* FindOLEReplacementGraphic() const;
+ void DeleteSelection();
+
+ // helper methods for the paste
+ static SwTransferable* GetSwTransferable( const TransferableDataHelper& rData );
+ static void SetSelInShell( SwWrtShell& , sal_Bool , const Point* );
+ static sal_Bool _CheckForURLOrLNKFile( TransferableDataHelper& rData,
+ OUString& rFileName, OUString* pTitle = 0 );
+ static bool _TestAllowedFormat( const TransferableDataHelper& rData,
+ sal_uLong nFormat, sal_uInt16 nDestination );
+
+ static bool _PasteFileContent( TransferableDataHelper&,
+ SwWrtShell& rSh, sal_uLong nFmt, sal_Bool bMsg );
+ static bool _PasteOLE( TransferableDataHelper& rData, SwWrtShell& rSh,
+ sal_uLong nFmt, sal_uInt8 nActionFlags, sal_Bool bMsg );
+ static bool _PasteTargetURL( TransferableDataHelper& rData, SwWrtShell& rSh,
+ sal_uInt16 nAction, const Point* pPt, sal_Bool bInsertGRF );
+
+ static bool _PasteDDE( TransferableDataHelper& rData, SwWrtShell& rWrtShell,
+ sal_Bool bReReadGrf, sal_Bool bMsg );
+
+ static bool _PasteSdrFormat( TransferableDataHelper& rData,
+ SwWrtShell& rSh, sal_uInt16 nAction,
+ const Point* pPt, sal_uInt8 nActionFlags, bool bNeedToSelectBeforePaste);
+
+ static bool _PasteGrf( TransferableDataHelper& rData, SwWrtShell& rSh,
+ sal_uLong nFmt, sal_uInt16 nAction, const Point* pPt,
+ sal_uInt8 nActionFlags, sal_Int8 nDropAction, bool bNeedToSelectBeforePaste);
+
+ static bool _PasteImageMap( TransferableDataHelper& rData,
+ SwWrtShell& rSh );
+
+ static bool _PasteAsHyperlink( TransferableDataHelper& rData,
+ SwWrtShell& rSh, sal_uLong nFmt );
+
+ static bool _PasteFileName( TransferableDataHelper& rData,
+ SwWrtShell& rSh, sal_uLong nFmt, sal_uInt16 nAction,
+ const Point* pPt, sal_uInt8 nActionFlags, sal_Bool bMsg, bool * graphicInserted );
+
+ static bool _PasteDBData( TransferableDataHelper& rData, SwWrtShell& rSh,
+ sal_uLong nFmt, sal_Bool bLink, const Point* pDragPt,
+ sal_Bool bMsg );
+
+ static bool _PasteFileList( TransferableDataHelper& rData,
+ SwWrtShell& rSh, sal_Bool bLink,
+ const Point* pPt, sal_Bool bMsg );
+
+ bool PrivateDrop( SwWrtShell& rSh, const Point& rDragPt, sal_Bool bMove,
+ sal_Bool bIsXSelection );
+ bool PrivatePaste( SwWrtShell& rShell );
+
+ void SetDataForDragAndDrop( const Point& rSttPos );
+
+ // not available
+ SwTransferable();
+ SwTransferable( const SwTransferable& );
+ SwTransferable& operator=( const SwTransferable& );
+
+protected:
+ virtual void AddSupportedFormats();
+ virtual sal_Bool GetData( const css::datatransfer::DataFlavor& rFlavor );
+ virtual sal_Bool WriteObject( SotStorageStreamRef& rxOStm,
+ void* pUserObject,
+ sal_uInt32 nUserObjectId,
+ const css::datatransfer::DataFlavor& rFlavor );
+ virtual void DragFinished( sal_Int8 nDropAction );
+ virtual void ObjectReleased();
+
+ using TransferableHelper::StartDrag;
+
+public:
+ SwTransferable( SwWrtShell& );
+ virtual ~SwTransferable();
+
+ static sal_uInt16 GetSotDestination( const SwWrtShell& rSh, const Point* = 0 );
+
+ // set properties on the document, like PageMargin, VisArea.
+ // And set real Size
+ static void InitOle( SfxObjectShell* pDoc, SwDoc& rDoc );
+
+ // copy - methods and helper methods for the copy
+ int Cut();
+ int Copy( sal_Bool bIsCut = sal_False );
+ int PrepareForCopy( sal_Bool bIsCut = sal_False );
+ int CalculateAndCopy(); // special for Calculator
+ int CopyGlossary( SwTextBlocks& rGlossary, const OUString& rStr );
+
+ // remove the DDE-Link format promise
+ void RemoveDDELinkFormat( const Window& rWin );
+
+ // paste - methods and helper methods for the paste
+ static sal_Bool IsPaste( const SwWrtShell&, const TransferableDataHelper& );
+ static bool Paste( SwWrtShell&, TransferableDataHelper& );
+ static bool PasteData( TransferableDataHelper& rData,
+ SwWrtShell& rSh, sal_uInt16 nAction, sal_uLong nFormat,
+ sal_uInt16 nDestination, sal_Bool bIsPasteFmt,
+ sal_Bool bIsDefault,
+ const Point* pDDPos = 0, sal_Int8 nDropAction = 0,
+ sal_Bool bPasteSelection = sal_False );
+
+ static sal_Bool IsPasteSpecial( const SwWrtShell& rWrtShell,
+ const TransferableDataHelper& );
+ static bool PasteUnformatted( SwWrtShell& rSh, TransferableDataHelper& );
+ static bool PasteSpecial( SwWrtShell& rSh, TransferableDataHelper&, sal_uLong& rFormatUsed );
+ static bool PasteFormat( SwWrtShell& rSh, TransferableDataHelper& rData,
+ sal_uLong nFormat );
+
+ static void FillClipFmtItem( const SwWrtShell& rSh,
+ const TransferableDataHelper& rData,
+ SvxClipboardFmtItem & rToFill );
+
+ // Interfaces for Drag & Drop
+ void StartDrag( Window* pWin, const Point& rPos );
+
+ SwWrtShell* GetShell() { return pWrtShell; }
+ void SetCleanUp( sal_Bool bFlag ) { bCleanUp = bFlag; }
+
+ // Interfaces for Selection
+ /* #96392# Added pCreator to distinguish SwFrameShell from SwWrtShell. */
+ static void CreateSelection( SwWrtShell & rSh,
+ const SwViewShell * pCreator = NULL );
+ static void ClearSelection( SwWrtShell& rSh,
+ const SwViewShell * pCreator = NULL );
+
+ // the related SwView is being closed and the SwTransferable is invalid now
+ void Invalidate() {pWrtShell = 0;}
+ static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId();
+
+ virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& rId ) throw( css::uno::RuntimeException, std::exception );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/swlbox.hxx b/sw/source/core/uibase/inc/swlbox.hxx
new file mode 100644
index 000000000000..49ac2b096892
--- /dev/null
+++ b/sw/source/core/uibase/inc/swlbox.hxx
@@ -0,0 +1,86 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_SWLBOX_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_SWLBOX_HXX
+
+#include <vcl/lstbox.hxx>
+#include <vcl/combobox.hxx>
+#include "swdllapi.h"
+#include <boost/ptr_container/ptr_vector.hpp>
+
+class SwBoxEntry;
+class Window;
+
+typedef boost::ptr_vector<SwBoxEntry> SwEntryLst;
+
+/*--------------------------------------------------------------------
+ Description: SwBoxEntry
+ --------------------------------------------------------------------*/
+class SW_DLLPUBLIC SwBoxEntry
+{
+ friend class SwComboBox;
+
+ sal_Bool bModified : 1;
+ sal_Bool bNew : 1;
+
+ OUString aName;
+ sal_Int32 nId;
+
+public:
+ SwBoxEntry(const OUString& aName, sal_Int32 nId=0);
+ SwBoxEntry(const SwBoxEntry& rOrg);
+ SwBoxEntry();
+
+ const OUString& GetName() const { return aName;}
+};
+
+/*--------------------------------------------------------------------
+ Description: for combo boxes
+ --------------------------------------------------------------------*/
+
+class SW_DLLPUBLIC SwComboBox : public ComboBox
+{
+ SwEntryLst aEntryLst;
+ SwEntryLst aDelEntryLst;
+ SwBoxEntry aDefault;
+
+ SAL_DLLPRIVATE void InitComboBox();
+ SAL_DLLPRIVATE void InsertSorted(SwBoxEntry* pEntry);
+ SAL_DLLPRIVATE void Init();
+
+public:
+
+ SwComboBox(Window* pParent, WinBits nStyle);
+ ~SwComboBox();
+
+ void InsertSwEntry(const SwBoxEntry&);
+ virtual sal_Int32 InsertEntry(const OUString& rStr, sal_Int32 = 0) SAL_OVERRIDE;
+
+ virtual void RemoveEntryAt(sal_Int32 nPos) SAL_OVERRIDE;
+
+ sal_Int32 GetSwEntryPos(const SwBoxEntry& rEntry) const;
+ const SwBoxEntry& GetSwEntry(sal_Int32) const;
+
+ sal_Int32 GetRemovedCount() const;
+ const SwBoxEntry& GetRemovedEntry(sal_Int32 nPos) const;
+};
+
+#endif // INCLUDED_SW_SOURCE_UI_INC_SWLBOX_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/swmessdialog.hxx b/sw/source/core/uibase/inc/swmessdialog.hxx
new file mode 100644
index 000000000000..1937e3723058
--- /dev/null
+++ b/sw/source/core/uibase/inc/swmessdialog.hxx
@@ -0,0 +1,30 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <vcl/dialog.hxx>
+
+class Edit;
+class FixedImage;
+class OKButton;
+class VclMultiLineEdit;
+
+class SwMessageAndEditDialog : public ModalDialog
+{
+protected:
+ OKButton* m_pOKPB;
+ FixedImage* m_pImageIM;
+ VclMultiLineEdit* m_pPrimaryMessage;
+ VclMultiLineEdit* m_pSecondaryMessage;
+ Edit* m_pEdit;
+public:
+ SwMessageAndEditDialog(Window* pParent, const OString& rID,
+ const OUString& rUIXMLDescription);
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/swmodalredlineacceptdlg.hxx b/sw/source/core/uibase/inc/swmodalredlineacceptdlg.hxx
new file mode 100644
index 000000000000..8c38330b83d8
--- /dev/null
+++ b/sw/source/core/uibase/inc/swmodalredlineacceptdlg.hxx
@@ -0,0 +1,40 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_SWMODALREDLINEACCEPTDLG_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_SWMODALREDLINEACCEPTDLG_HXX
+#include "chldwrap.hxx"
+#include <sfx2/basedlgs.hxx>
+
+class SwRedlineAcceptDlg;
+
+class SwModalRedlineAcceptDlg : public SfxModalDialog
+{
+ SwRedlineAcceptDlg* pImplDlg;
+
+public:
+ SwModalRedlineAcceptDlg(Window *pParent);
+ ~SwModalRedlineAcceptDlg();
+
+ void AcceptAll( sal_Bool bAccept );
+ virtual void Activate();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/swrenamexnameddlg.hxx b/sw/source/core/uibase/inc/swrenamexnameddlg.hxx
new file mode 100644
index 000000000000..1dfc4f2597a4
--- /dev/null
+++ b/sw/source/core/uibase/inc/swrenamexnameddlg.hxx
@@ -0,0 +1,69 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_SWRENAMEXNAMEDDLG_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_SWRENAMEXNAMEDDLG_HXX
+
+#include <vcl/dialog.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/edit.hxx>
+#include <vcl/button.hxx>
+#include <actctrl.hxx>
+#include <com/sun/star/frame/XController.hpp>
+#include <com/sun/star/text/XTextCursor.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/awt/XControl.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+
+class SwRenameXNamedDlg : public ModalDialog
+{
+ NoSpaceEdit* m_pNewNameED;
+ OKButton* m_pOk;
+
+ OUString m_sRemoveWarning;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed > & xNamed;
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > & xNameAccess;
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > xSecondAccess;
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > xThirdAccess;
+
+ DECL_LINK(OkHdl, void *);
+ DECL_LINK(ModifyHdl, NoSpaceEdit*);
+
+public:
+ SwRenameXNamedDlg( Window* pParent,
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed > & xNamed,
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > & xNameAccess );
+
+ void SetForbiddenChars(const OUString& rSet)
+ {
+ m_pNewNameED->SetForbiddenChars(rSet);
+ }
+
+ void SetAlternativeAccess(
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > & xSecond,
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > & xThird )
+ {
+ xSecondAccess = xSecond;
+ xThirdAccess = xThird;
+ }
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/swruler.hxx b/sw/source/core/uibase/inc/swruler.hxx
new file mode 100644
index 000000000000..aebf0b97396d
--- /dev/null
+++ b/sw/source/core/uibase/inc/swruler.hxx
@@ -0,0 +1,122 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_SW_SOURCE_UI_INC_SWRULER_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_SWRULER_HXX
+
+#include <svx/ruler.hxx>
+
+class SwViewShell;
+class View;
+class Window;
+class SwEditWin;
+
+/**
+ * An horizontal ruler with a control for comment panel visibility fo Writer.
+ *
+ * The comment control only appears when the document has comments already.
+ */
+class SwCommentRuler
+ : public SvxRuler
+{
+public:
+ SwCommentRuler (
+ SwViewShell* pViewSh,
+ Window* pParent,
+ SwEditWin* pWin,
+ sal_uInt16 nRulerFlags,
+ SfxBindings& rBindings,
+ WinBits nWinStyle);
+ virtual ~SwCommentRuler ();
+
+ /**
+ * Paint the ruler.
+ * \param rRect ignored
+ */
+ virtual void Paint( const Rectangle& rRect );
+
+protected:
+ SwViewShell * mpViewShell; //< Shell to check if there is any comments on doc and their visibility
+ SwEditWin * mpSwWin; //< Used to get SwView to change the SideBar visibility
+ bool mbIsHighlighted; //< If comment control is highlighted (mouse is over it)
+ Timer maFadeTimer; //< Timer for high/'low'light fading
+ int mnFadeRate; //< From 0 to 100. 0 means not highlighted.
+ VirtualDevice maVirDev; //< VirtualDevice of this window. Just for convenience.
+
+ /**
+ * Callback function to handle a mouse button down event.
+ *
+ * When on comment control, it toggles the comment panel visibility.
+ */
+ virtual void MouseButtonDown( const MouseEvent& rMEvt );
+ /**
+ * Callback function to handle a mouse move event.
+ *
+ * When on comment control, it let the control responsive by highlighting.
+ */
+ virtual void MouseMove(const MouseEvent& rMEvt);
+ /**
+ * Callback function to handle a context menu call (mouse right button click).
+ *
+ * When on comment control, it does not do anything.
+ */
+ virtual void Command( const CommandEvent& rCEvt );
+ /**
+ * Update the view.
+ *
+ * Update the ruler appearance according to the document view and
+ * current cursor position.
+ */
+ virtual void Update();
+
+ /**
+ * Get the rectangle area that should be used to draw the comment control.
+ *
+ * It is horizontally aligned to the SideBar panel.
+ * \return The area where the comment control is.
+ */
+ Rectangle GetCommentControlRegion();
+
+ /**
+ * Paint the comment control on VirtualDevice.
+ */
+ void DrawCommentControl();
+ /**
+ * Draw a little horizontal arrow tip on VirtualDevice.
+ * \param nX left coordinate of arrow
+ * \param nY top coordinate of arrow
+ * \param Color arrow color
+ * \param bPointRight if arrow should point to right. Otherwise, it will point left.
+ */
+ void ImplDrawArrow(long nX, long nY, const Color& rColor, bool bPointRight);
+
+ /**
+ * Update the tooltip text.
+ */
+ void UpdateCommentHelpText();
+
+ /**
+ * Get the proper color between two options, according to current status.
+ *
+ * The return color can be one of the given colors, or a merged one.
+ * It depends on highlight fadind status.
+ *
+ * \param rHighColor color used to highlight status
+ * \param rLowColor color used to normal status
+ * \return The proper color to used in moment
+ */
+ Color GetFadedColor(const Color &rHighColor, const Color &rLowColor);
+
+ /// Fade timer callback.
+ DECL_LINK(FadeHandler, void *);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/swtablerep.hxx b/sw/source/core/uibase/inc/swtablerep.hxx
new file mode 100644
index 000000000000..7f92bc0bc26b
--- /dev/null
+++ b/sw/source/core/uibase/inc/swtablerep.hxx
@@ -0,0 +1,84 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_SWTABLEREP_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_SWTABLEREP_HXX
+
+#include <sfx2/tabdlg.hxx>
+#include "swdllapi.h"
+#include "swtypes.hxx"
+
+class SwTabCols;
+struct TColumn;
+class SW_DLLPUBLIC SwTableRep
+{
+ TColumn* pTColumns;
+
+ SwTwips nTblWidth;
+ SwTwips nSpace;
+ SwTwips nLeftSpace;
+ SwTwips nRightSpace;
+ sal_uInt16 nAlign;
+ sal_uInt16 nColCount;
+ sal_uInt16 nAllCols;
+ sal_uInt16 nWidthPercent;
+ sal_Bool bLineSelected : 1;
+ sal_Bool bWidthChanged : 1;
+ sal_Bool bColsChanged : 1;
+
+public:
+ SwTableRep( const SwTabCols& rTabCol );
+ ~SwTableRep();
+
+ sal_Bool FillTabCols( SwTabCols& rTabCol ) const;
+
+ SwTwips GetLeftSpace() const {return nLeftSpace;}
+ void SetLeftSpace(SwTwips nSet) {nLeftSpace = nSet;}
+
+ SwTwips GetRightSpace() const {return nRightSpace;}
+ void SetRightSpace(SwTwips nSet) {nRightSpace = nSet;}
+
+ SwTwips GetWidth() const {return nTblWidth;}
+ void SetWidth(SwTwips nSet) {nTblWidth = nSet;}
+
+ sal_uInt16 GetWidthPercent() const {return nWidthPercent;}
+ void SetWidthPercent(sal_uInt16 nSet) {nWidthPercent = nSet;}
+
+ sal_uInt16 GetAlign() const {return nAlign;}
+ void SetAlign(sal_uInt16 nSet) {nAlign = nSet;}
+
+ sal_uInt16 GetColCount() const {return nColCount;}
+ sal_uInt16 GetAllColCount() const {return nAllCols;}
+
+ sal_Bool HasColsChanged() const {return bColsChanged;}
+ void SetColsChanged() {bColsChanged = sal_True;}
+
+ sal_Bool HasWidthChanged() const {return bWidthChanged;}
+ void SetWidthChanged() {bWidthChanged = sal_True;}
+
+ sal_Bool IsLineSelected() const {return bLineSelected;}
+ void SetLineSelected(sal_Bool bSet) {bLineSelected = bSet;}
+
+ SwTwips GetSpace() const { return nSpace;}
+ void SetSpace(SwTwips nSet) {nSpace = nSet;}
+
+ TColumn* GetColumns() const {return pTColumns;}
+};
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/swuiccoll.hxx b/sw/source/core/uibase/inc/swuiccoll.hxx
new file mode 100644
index 000000000000..d63d7ee99243
--- /dev/null
+++ b/sw/source/core/uibase/inc/swuiccoll.hxx
@@ -0,0 +1,75 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_SWUICCOLL_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_SWUICCOLL_HXX
+
+#include <tools/resary.hxx>
+
+class SwWrtShell;
+class SwFmt;
+
+class SwCondCollPage : public SfxTabPage
+{
+ CheckBox* m_pConditionCB;
+
+ FixedText* m_pContextFT;
+ FixedText* m_pUsedFT;
+ SvTabListBox* m_pTbLinks;
+
+ FixedText* m_pStyleFT;
+ ListBox* m_pStyleLB;
+ ListBox* m_pFilterLB;
+
+ PushButton* m_pRemovePB;
+ PushButton* m_pAssignPB;
+
+ std::vector<OUString> m_aStrArr;
+
+ SwWrtShell &rSh;
+ const CommandStruct*pCmds;
+ SwFmt* pFmt;
+
+ sal_Bool bNewTemplate;
+
+ SwCondCollPage(Window *pParent, const SfxItemSet &rSet);
+ virtual ~SwCondCollPage();
+
+ virtual int DeactivatePage(SfxItemSet *pSet);
+
+ DECL_LINK( OnOffHdl, CheckBox* );
+ DECL_LINK( AssignRemoveHdl, PushButton*);
+ DECL_LINK( SelectHdl, ListBox* );
+
+ using SfxTabPage::ActivatePage;
+ using SfxTabPage::DeactivatePage;
+
+public:
+
+ static SfxTabPage *Create(Window *pParent, const SfxItemSet &rSet);
+ static sal_uInt16* GetRanges();
+
+ virtual sal_Bool FillItemSet( SfxItemSet &rSet);
+ virtual void Reset (const SfxItemSet &rSet);
+
+ void SetCollection( SwFmt* pFormat, sal_Bool bNew );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/swuicnttab.hxx b/sw/source/core/uibase/inc/swuicnttab.hxx
new file mode 100644
index 000000000000..1986936f86f3
--- /dev/null
+++ b/sw/source/core/uibase/inc/swuicnttab.hxx
@@ -0,0 +1,497 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_SWUICNTTAB_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_SWUICNTTAB_HXX
+
+#include <svx/stddlg.hxx>
+
+#include <vcl/button.hxx>
+
+#include <vcl/edit.hxx>
+
+#include <vcl/fixed.hxx>
+
+#include <vcl/field.hxx>
+#include <vcl/lstbox.hxx>
+#include <sfx2/tabdlg.hxx>
+
+#include "tox.hxx"
+#include <toxmgr.hxx>
+#include <svx/checklbx.hxx>
+#include <svtools/treelistbox.hxx>
+#include <vcl/menubtn.hxx>
+#include <svx/langbox.hxx>
+#include <cnttab.hxx>
+#include <vector>
+
+class SwWrtShell;
+class SwTOXMgr;
+namespace com{namespace sun{namespace star{
+ namespace text{
+ class XTextSection;
+ class XDocumentIndex;
+ }
+}}}
+
+struct SwIndexSections_Impl
+{
+ com::sun::star::uno::Reference< com::sun::star::text::XTextSection > xContainerSection;
+ com::sun::star::uno::Reference< com::sun::star::text::XDocumentIndex > xDocumentIndex;
+};
+
+class SwOneExampleFrame;
+
+struct SwIndexSections_Impl;
+
+class SwMultiTOXTabDialog : public SfxTabDialog
+{
+ Window* m_pExampleContainerWIN;
+ CheckBox* m_pShowExampleCB;
+ SwTOXMgr* pMgr;
+ SwWrtShell& rSh;
+
+ sal_uInt16 m_nSelectId;
+ sal_uInt16 m_nStylesId;
+ sal_uInt16 m_nColumnId;
+ sal_uInt16 m_nBackGroundId;
+ sal_uInt16 m_nEntriesId;
+
+ SwOneExampleFrame* pExampleFrame;
+
+ SwTOXDescription** pDescArr;
+ SwForm** pFormArr;
+ SwIndexSections_Impl** pxIndexSectionsArr;
+
+ SwTOXBase* pParamTOXBase;
+
+ CurTOXType eCurrentTOXType;
+
+ OUString sUserDefinedIndex;
+ sal_uInt16 nTypeCount;
+ sal_uInt16 nInitialTOXType;
+
+ sal_Bool bEditTOX;
+ sal_Bool bExampleCreated;
+ sal_Bool bGlobalFlag;
+
+ virtual short Ok();
+ SwTOXDescription* CreateTOXDescFromTOXBase(const SwTOXBase*pCurTOX);
+
+ DECL_LINK(CreateExample_Hdl, void*);
+ DECL_LINK(ShowPreviewHdl, void*);
+
+public:
+ SwMultiTOXTabDialog(Window* pParent, const SfxItemSet& rSet,
+ SwWrtShell &rShell,
+ SwTOXBase* pCurTOX, sal_uInt16 nToxType = USHRT_MAX,
+ sal_Bool bGlobal = sal_False);
+ ~SwMultiTOXTabDialog();
+
+ virtual void PageCreated( sal_uInt16 nId, SfxTabPage &rPage );
+
+ SwForm* GetForm(CurTOXType eType);
+
+ CurTOXType GetCurrentTOXType() const { return eCurrentTOXType;}
+ void SetCurrentTOXType(CurTOXType eSet)
+ {
+ eCurrentTOXType = eSet;
+ }
+
+ void UpdateExample();
+ sal_Bool IsTOXEditMode() const { return bEditTOX;}
+
+ SwWrtShell& GetWrtShell() {return rSh;}
+
+ SwTOXDescription& GetTOXDescription(CurTOXType eTOXTypes);
+ void CreateOrUpdateExample(
+ TOXTypes nTOXIndex, sal_uInt16 nPage = 0, sal_uInt16 nCurLevel = USHRT_MAX);
+
+ static sal_Bool IsNoNum(SwWrtShell& rSh, const OUString& rName);
+};
+
+class IndexEntryResource;
+class IndexEntrySupplierWrapper;
+
+class SwTOXSelectTabPage : public SfxTabPage
+{
+ Edit* m_pTitleED;
+ FixedText* m_pTypeFT;
+ ListBox* m_pTypeLB;
+ CheckBox* m_pReadOnlyCB;
+
+ VclContainer* m_pAreaFrame;
+ ListBox* m_pAreaLB;
+ FixedText* m_pLevelFT; //content, user
+ NumericField* m_pLevelNF; //content, user
+
+ //content
+ VclContainer* m_pCreateFrame; // content, user, illustration
+ CheckBox* m_pFromHeadingsCB;
+ CheckBox* m_pAddStylesCB;
+ PushButton* m_pAddStylesPB;
+ //user
+ CheckBox* m_pFromTablesCB;
+ CheckBox* m_pFromFramesCB;
+ CheckBox* m_pFromGraphicsCB;
+ CheckBox* m_pFromOLECB;
+ CheckBox* m_pLevelFromChapterCB;
+
+ //illustration + table
+ RadioButton* m_pFromCaptionsRB;
+ RadioButton* m_pFromObjectNamesRB;
+
+ //illustration and tables
+ FixedText* m_pCaptionSequenceFT;
+ ListBox* m_pCaptionSequenceLB;
+ FixedText* m_pDisplayTypeFT;
+ ListBox* m_pDisplayTypeLB;
+
+ //all but illustration and table
+ CheckBox* m_pTOXMarksCB;
+
+ //index only
+ VclContainer* m_pIdxOptionsFrame;
+ CheckBox* m_pCollectSameCB;
+ CheckBox* m_pUseFFCB;
+ CheckBox* m_pUseDashCB;
+ CheckBox* m_pCaseSensitiveCB;
+ CheckBox* m_pInitialCapsCB;
+ CheckBox* m_pKeyAsEntryCB;
+ CheckBox* m_pFromFileCB;
+ MenuButton* m_pAutoMarkPB;
+
+ // object only
+ SwOLENames aFromNames;
+ SvxCheckListBox* m_pFromObjCLB;
+ VclContainer* m_pFromObjFrame;
+
+ CheckBox* m_pSequenceCB;
+ ListBox* m_pBracketLB;
+ VclContainer* m_pAuthorityFrame;
+
+ //all
+ VclContainer* m_pSortFrame;
+ SvxLanguageBox* m_pLanguageLB;
+ ListBox* m_pSortAlgorithmLB;
+
+ IndexEntryResource* pIndexRes;
+
+ OUString aStyleArr[MAXLEVEL];
+ OUString sAutoMarkURL;
+ OUString sAutoMarkType;
+ OUString sAddStyleUser;
+ OUString sAddStyleContent;
+
+ const IndexEntrySupplierWrapper* pIndexEntryWrapper;
+
+ bool m_bWaitingInitialSettings;
+
+ DECL_LINK(TOXTypeHdl, ListBox* );
+ DECL_LINK(AddStylesHdl, PushButton* );
+ DECL_LINK(MenuEnableHdl, Menu*);
+ DECL_LINK(MenuExecuteHdl, Menu*);
+ DECL_LINK(LanguageHdl, ListBox*);
+
+ DECL_LINK(CheckBoxHdl, CheckBox* );
+ DECL_LINK(RadioButtonHdl, void *);
+ DECL_LINK(ModifyHdl, void*);
+
+ void ApplyTOXDescription();
+ void FillTOXDescription();
+
+ using SfxTabPage::ActivatePage;
+ using SfxTabPage::DeactivatePage;
+
+public:
+ SwTOXSelectTabPage(Window* pParent, const SfxItemSet& rAttrSet);
+ ~SwTOXSelectTabPage();
+
+ virtual sal_Bool FillItemSet( SfxItemSet& );
+ virtual void Reset( const SfxItemSet& );
+
+ virtual void ActivatePage( const SfxItemSet& );
+ virtual int DeactivatePage( SfxItemSet* pSet = 0 );
+
+ static SfxTabPage* Create( Window* pParent,
+ const SfxItemSet& rAttrSet);
+
+ void SelectType(TOXTypes eSet); //preset TOXType, GlobalDoc
+ void SetWrtShell(SwWrtShell& rSh);
+};
+
+class SwTOXEdit;
+class SwTOXButton;
+class SwTOXEntryTabPage;
+
+class SwTokenWindow : public VclHBox, public VclBuilderContainer
+{
+ typedef std::vector<Control*>::iterator ctrl_iterator;
+ typedef std::vector<Control*>::const_iterator ctrl_const_iterator;
+ typedef std::vector<Control*>::reverse_iterator ctrl_reverse_iterator;
+ typedef std::vector<Control*>::const_reverse_iterator ctrl_const_reverse_iterator;
+
+ Button* m_pLeftScrollWin;
+ Window* m_pCtrlParentWin;
+ Button* m_pRightScrollWin;
+ std::vector<Control*> aControlList;
+ SwForm* pForm;
+ sal_uInt16 nLevel;
+ bool bValid;
+ OUString aButtonTexts[TOKEN_END]; // Text of the buttons
+ OUString aButtonHelpTexts[TOKEN_END]; // QuickHelpText of the buttons
+ OUString sCharStyle;
+ Link aButtonSelectedHdl;
+ Control* pActiveCtrl;
+ Link aModifyHdl;
+ OUString accessibleName;
+ OUString sAdditionalAccnameString1;
+ OUString sAdditionalAccnameString2;
+ OUString sAdditionalAccnameString3;
+
+ SwTOXEntryTabPage* m_pParent;
+
+ DECL_LINK(EditResize, Edit*);
+ DECL_LINK(NextItemHdl, SwTOXEdit* );
+ DECL_LINK(TbxFocusHdl, SwTOXEdit* );
+ DECL_LINK(NextItemBtnHdl, SwTOXButton* );
+ DECL_LINK(TbxFocusBtnHdl, SwTOXButton* );
+ DECL_LINK(ScrollHdl, ImageButton* );
+
+ void SetActiveControl(Control* pSet);
+
+ Control* InsertItem(const OUString& rText, const SwFormToken& aToken);
+ void AdjustPositions();
+ void AdjustScrolling();
+ void MoveControls(long nOffset);
+
+public:
+ SwTokenWindow(Window* pParent);
+ ~SwTokenWindow();
+
+ void SetTabPage(SwTOXEntryTabPage *pParent) { m_pParent = pParent; }
+
+ void SetForm(SwForm& rForm, sal_uInt16 nLevel);
+ sal_uInt16 GetLastLevel()const {return nLevel;};
+
+ sal_Bool IsValid() const {return bValid;}
+
+ void SetInvalid() {bValid = false;}
+
+ OUString GetPattern() const;
+
+ void SetButtonSelectedHdl(const Link& rLink)
+ { aButtonSelectedHdl = rLink;}
+
+ void SetModifyHdl(const Link& rLink){aModifyHdl = rLink;}
+
+ Control* GetActiveControl()
+ { return pActiveCtrl;}
+
+ void InsertAtSelection(const OUString& rText, const SwFormToken& aToken);
+ void RemoveControl(SwTOXButton* pDel, sal_Bool bInternalCall = sal_False);
+
+ sal_Bool Contains(FormTokenType) const;
+
+ sal_Bool DetermineLinkStart();
+
+ //helper for pattern buttons and edits
+ sal_Bool CreateQuickHelp(Control* pCtrl,
+ const SwFormToken& rToken, const HelpEvent& );
+
+ virtual void GetFocus();
+ virtual void setAllocation(const Size &rAllocation);
+ void SetFocus2theAllBtn();
+private:
+ sal_uInt32 GetControlIndex(FormTokenType eType) const;
+};
+
+class SwTOXEntryTabPage;
+
+class SwIdxTreeListBox : public SvTreeListBox
+{
+ SwTOXEntryTabPage* pParent;
+
+ virtual void RequestHelp( const HelpEvent& rHEvt );
+public:
+ SwIdxTreeListBox(Window* pPar, WinBits nStyle);
+ void SetTabPage(SwTOXEntryTabPage* pPar) { pParent = pPar; }
+};
+
+class SwTOXEntryTabPage : public SfxTabPage
+{
+ FixedText* m_pLevelFT;
+ SwIdxTreeListBox* m_pLevelLB;
+
+ SwTokenWindow* m_pTokenWIN;
+
+ PushButton* m_pAllLevelsPB;
+
+ PushButton* m_pEntryNoPB;
+ PushButton* m_pEntryPB;
+ PushButton* m_pTabPB;
+ PushButton* m_pChapterInfoPB;
+ PushButton* m_pPageNoPB;
+ PushButton* m_pHyperLinkPB;
+
+ ListBox* m_pAuthFieldsLB;
+ PushButton* m_pAuthInsertPB;
+ PushButton* m_pAuthRemovePB;
+
+ ListBox* m_pCharStyleLB; // character style of the current token
+ PushButton* m_pEditStylePB;
+
+ FixedText* m_pChapterEntryFT;
+ ListBox* m_pChapterEntryLB; // type of chapter info
+
+ FixedText* m_pNumberFormatFT;
+ ListBox* m_pNumberFormatLB; //!< format for numbering (E#)
+
+ FixedText* m_pEntryOutlineLevelFT; //!< Fixed text, for i53420
+ NumericField* m_pEntryOutlineLevelNF; //!< level to evaluate outline level to, for i53420
+
+ FixedText* m_pFillCharFT;
+ ComboBox* m_pFillCharCB; // fill char for tab stop
+
+ FixedText* m_pTabPosFT;
+ MetricField* m_pTabPosMF; // tab stop position
+ CheckBox* m_pAutoRightCB;
+
+ VclContainer* m_pFormatFrame;
+ FixedText* m_pMainEntryStyleFT;
+ ListBox* m_pMainEntryStyleLB; // character style of main entries in indexes
+ CheckBox* m_pAlphaDelimCB;
+ CheckBox* m_pCommaSeparatedCB;
+ CheckBox* m_pRelToStyleCB; // position relative to the right margin of the para style
+
+ VclContainer* m_pSortingFrame;
+ RadioButton* m_pSortDocPosRB;
+ RadioButton* m_pSortContentRB;
+
+ VclContainer* m_pSortKeyFrame;
+ ListBox* m_pFirstKeyLB;
+ RadioButton* m_pFirstSortUpRB;
+ RadioButton* m_pFirstSortDownRB;
+
+ ListBox* m_pSecondKeyLB;
+ RadioButton* m_pSecondSortUpRB;
+ RadioButton* m_pSecondSortDownRB;
+
+ ListBox* m_pThirdKeyLB;
+ RadioButton* m_pThirdSortUpRB;
+ RadioButton* m_pThirdSortDownRB;
+
+ OUString sDelimStr;
+ OUString sLevelStr;
+ OUString sAuthTypeStr;
+
+ OUString sNoCharStyle;
+ OUString sNoCharSortKey;
+ SwForm* m_pCurrentForm;
+
+ CurTOXType aLastTOXType;
+ bool bInLevelHdl;
+
+ DECL_LINK(StyleSelectHdl, ListBox*);
+ DECL_LINK(EditStyleHdl, PushButton*);
+ DECL_LINK(InsertTokenHdl, PushButton*);
+ DECL_LINK(LevelHdl, SvTreeListBox*);
+ DECL_LINK(AutoRightHdl, CheckBox*);
+ DECL_LINK(TokenSelectedHdl, SwFormToken*);
+ DECL_LINK(TabPosHdl, MetricField*);
+ DECL_LINK(FillCharHdl, ComboBox*);
+ DECL_LINK(RemoveInsertAuthHdl, PushButton*);
+ DECL_LINK(SortKeyHdl, RadioButton*);
+ DECL_LINK(ChapterInfoHdl, ListBox*);
+ DECL_LINK(ChapterInfoOutlineHdl, NumericField*);
+ DECL_LINK(NumberFormatHdl, ListBox*);
+
+ DECL_LINK(AllLevelsHdl, void *);
+
+ void EnableButtons();
+ void WriteBackLevel();
+ void UpdateDescriptor();
+ DECL_LINK(ModifyHdl, void*);
+
+ using SfxTabPage::ActivatePage;
+ using SfxTabPage::DeactivatePage;
+
+public:
+ SwTOXEntryTabPage(Window* pParent, const SfxItemSet& rAttrSet);
+ ~SwTOXEntryTabPage();
+
+ virtual sal_Bool FillItemSet( SfxItemSet& );
+ virtual void Reset( const SfxItemSet& );
+ virtual void ActivatePage( const SfxItemSet& );
+ virtual int DeactivatePage( SfxItemSet* pSet = 0 );
+
+ static SfxTabPage* Create( Window* pParent,
+ const SfxItemSet& rAttrSet);
+ void SetWrtShell(SwWrtShell& rSh);
+
+ OUString GetLevelHelp(sal_uInt16 nLevel) const;
+
+ void PreTokenButtonRemoved(const SwFormToken& rToken);
+ void SetFocus2theAllBtn();
+ virtual bool Notify( NotifyEvent& rNEvt );
+};
+
+class SwTOXStylesTabPage : public SfxTabPage
+{
+ ListBox* m_pLevelLB;
+ PushButton* m_pAssignBT;
+ ListBox* m_pParaLayLB;
+ PushButton* m_pStdBT;
+ PushButton* m_pEditStyleBT;
+
+ SwForm* m_pCurrentForm;
+
+ DECL_LINK( EditStyleHdl, Button *);
+ DECL_LINK(StdHdl, void *);
+ DECL_LINK(EnableSelectHdl, void *);
+ DECL_LINK(DoubleClickHdl, void *);
+ DECL_LINK(AssignHdl, void *);
+ void Modify();
+
+ SwForm& GetForm()
+ {
+ SwMultiTOXTabDialog* pDlg = (SwMultiTOXTabDialog*)GetTabDialog();
+ return *pDlg->GetForm(pDlg->GetCurrentTOXType());
+ }
+
+ using SfxTabPage::ActivatePage;
+ using SfxTabPage::DeactivatePage;
+
+public:
+ SwTOXStylesTabPage(Window* pParent, const SfxItemSet& rAttrSet);
+ ~SwTOXStylesTabPage();
+
+ virtual sal_Bool FillItemSet( SfxItemSet& );
+ virtual void Reset( const SfxItemSet& );
+
+ virtual void ActivatePage( const SfxItemSet& );
+ virtual int DeactivatePage( SfxItemSet* pSet = 0 );
+
+ static SfxTabPage* Create( Window* pParent,
+ const SfxItemSet& rAttrSet);
+
+};
+
+#endif // INCLUDED_SW_SOURCE_UI_INC_SWUICNTTAB_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/swuiidxmrk.hxx b/sw/source/core/uibase/inc/swuiidxmrk.hxx
new file mode 100644
index 000000000000..e552586e353b
--- /dev/null
+++ b/sw/source/core/uibase/inc/swuiidxmrk.hxx
@@ -0,0 +1,253 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_SWUIIDXMRK_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_SWUIIDXMRK_HXX
+
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <sfx2/basedlgs.hxx>
+
+#include <svx/stddlg.hxx>
+
+#include <vcl/button.hxx>
+#include <vcl/combobox.hxx>
+#include <vcl/field.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/group.hxx>
+#include <vcl/layout.hxx>
+#include <vcl/lstbox.hxx>
+
+#include <sfx2/childwin.hxx>
+#include "toxe.hxx"
+#include <svtools/stdctrl.hxx>
+#include <com/sun/star/i18n/XExtendedIndexEntrySupplier.hpp>
+
+class SwWrtShell;
+class SwTOXMgr;
+class SwTOXMark;
+/*--------------------------------------------------------------------
+ Description: insert mark for index entry
+ --------------------------------------------------------------------*/
+class SwIndexMarkFloatDlg;
+class SwIndexMarkModalDlg;
+
+class SwIndexMarkPane
+{
+ Dialog& m_rDialog;
+
+ friend class SwIndexMarkFloatDlg;
+ friend class SwIndexMarkModalDlg;
+ VclFrame* m_pFrame;
+ FixedText* m_pTypeFT;
+ ListBox* m_pTypeDCB;
+ PushButton* m_pNewBT;
+
+ Edit* m_pEntryED;
+ FixedText* m_pPhoneticFT0;
+ Edit* m_pPhoneticED0;
+
+ FixedText* m_pKey1FT;
+ ComboBox* m_pKey1DCB;
+ FixedText* m_pPhoneticFT1;
+ Edit* m_pPhoneticED1;
+
+ FixedText* m_pKey2FT;
+ ComboBox* m_pKey2DCB;
+ FixedText* m_pPhoneticFT2;
+ Edit* m_pPhoneticED2;
+
+ FixedText* m_pLevelFT;
+ NumericField* m_pLevelNF;
+ CheckBox* m_pMainEntryCB;
+ CheckBox* m_pApplyToAllCB;
+ CheckBox* m_pSearchCaseSensitiveCB;
+ CheckBox* m_pSearchCaseWordOnlyCB;
+
+ PushButton* m_pOKBT;
+ CloseButton* m_pCloseBT;
+ PushButton* m_pDelBT;
+
+ PushButton* m_pPrevSameBT;
+ PushButton* m_pNextSameBT;
+ PushButton* m_pPrevBT;
+ PushButton* m_pNextBT;
+
+ OUString aOrgStr;
+ sal_Bool bDel;
+ sal_Bool bNewMark;
+ sal_Bool bSelected;
+
+ sal_Bool bPhoneticED0_ChangedByUser;
+ sal_Bool bPhoneticED1_ChangedByUser;
+ sal_Bool bPhoneticED2_ChangedByUser;
+ LanguageType nLangForPhoneticReading; //Language of current text used for phonetic reading proposal
+ sal_Bool bIsPhoneticReadingEnabled; //this value states whether phonetic reading is enabled in principle dependent of global cjk settings and language of current entry
+ com::sun::star::uno::Reference< com::sun::star::i18n::XExtendedIndexEntrySupplier >
+ xExtendedIndexEntrySupplier;
+
+ SwTOXMgr* pTOXMgr;
+ SwWrtShell* pSh;
+
+ void Apply();
+ void InitControls();
+ void InsertMark();
+ void UpdateMark();
+
+ DECL_LINK( InsertHdl, Button * );
+ DECL_LINK(CloseHdl, void *);
+ DECL_LINK(DelHdl, void *);
+ DECL_LINK(NextHdl, void *);
+ DECL_LINK(NextSameHdl, void *);
+ DECL_LINK(PrevHdl, void *);
+ DECL_LINK(PrevSameHdl, void *);
+ DECL_LINK( ModifyHdl, ListBox* pBox = 0 );
+ DECL_LINK( KeyDCBModifyHdl, ComboBox * );
+ DECL_LINK(NewUserIdxHdl, void *);
+ DECL_LINK( SearchTypeHdl, CheckBox*);
+ DECL_LINK( PhoneticEDModifyHdl, Edit * );
+
+ //this method updates the values from 'nLangForPhoneticReading' and 'bIsPhoneticReadingEnabled'
+ //it needs to be called ones if this dialog is opened to create a new entry (in InitControls),
+ //or otherwise it has to be called for each changed TOXMark (in UpdateDialog)
+ void UpdateLanguageDependenciesForPhoneticReading();
+ OUString GetDefaultPhoneticReading( const OUString& rText );
+
+ void UpdateKeyBoxes();
+
+ void UpdateDialog();
+ void InsertUpdate();
+
+ void Activate();
+
+public:
+
+ SwIndexMarkPane(Dialog &rDialog,
+ sal_Bool bNewDlg,
+ SwWrtShell& rWrtShell);
+
+ Dialog &GetDialog() { return m_rDialog; }
+
+ ~SwIndexMarkPane();
+
+ void ReInitDlg(SwWrtShell& rWrtShell, SwTOXMark* pCurTOXMark = 0);
+ sal_Bool IsTOXType(const OUString& rName)
+ {return LISTBOX_ENTRY_NOTFOUND != m_pTypeDCB->GetEntryPos(rName);}
+};
+
+class SwIndexMarkFloatDlg : public SfxModelessDialog
+{
+ SwIndexMarkPane m_aContent;
+ virtual void Activate();
+ public:
+ SwIndexMarkFloatDlg( SfxBindings* pBindings,
+ SfxChildWindow* pChild,
+ Window *pParent,
+ SfxChildWinInfo* pInfo,
+ sal_Bool bNew=sal_True);
+ void ReInitDlg(SwWrtShell& rWrtShell);
+};
+
+class SwIndexMarkModalDlg : public SvxStandardDialog
+{
+ SwIndexMarkPane m_aContent;
+public:
+ SwIndexMarkModalDlg(Window *pParent, SwWrtShell& rSh, SwTOXMark* pCurTOXMark);
+
+ virtual void Apply();
+ void ReInitDlg(SwWrtShell& rWrtShell);
+};
+
+class SwAuthMarkModalDlg;
+
+class SwAuthorMarkPane
+{
+ Dialog& m_rDialog;
+
+ static sal_Bool bIsFromComponent;
+
+ friend class SwAuthMarkModalDlg;
+ friend class SwAuthMarkFloatDlg;
+
+ RadioButton* m_pFromComponentRB;
+ RadioButton* m_pFromDocContentRB;
+ FixedText* m_pAuthorFI;
+ FixedText* m_pTitleFI;
+ Edit* m_pEntryED;
+ ListBox* m_pEntryLB;
+
+ PushButton* m_pActionBT;
+ CloseButton* m_pCloseBT;
+ PushButton* m_pCreateEntryPB;
+ PushButton* m_pEditEntryPB;
+
+ sal_Bool bNewEntry;
+ sal_Bool bBibAccessInitialized;
+
+ SwWrtShell* pSh;
+
+ OUString m_sColumnTitles[AUTH_FIELD_END];
+ OUString m_sFields[AUTH_FIELD_END];
+
+ OUString m_sCreatedEntry[AUTH_FIELD_END];
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > xBibAccess;
+
+ DECL_LINK(InsertHdl, void *);
+ DECL_LINK(CloseHdl, void *);
+ DECL_LINK(CreateEntryHdl, PushButton*);
+ DECL_LINK(CompEntryHdl, ListBox*);
+ DECL_LINK(ChangeSourceHdl, RadioButton*);
+ DECL_LINK(IsEntryAllowedHdl, Edit*);
+ DECL_LINK(EditModifyHdl, Edit*);
+
+ void InitControls();
+ void Activate();
+public:
+
+ SwAuthorMarkPane( Dialog &rDialog,
+ sal_Bool bNew=sal_True);
+
+ void ReInitDlg(SwWrtShell& rWrtShell);
+};
+
+class SwAuthMarkFloatDlg : public SfxModelessDialog
+{
+ SwAuthorMarkPane m_aContent;
+ virtual void Activate();
+ public:
+ SwAuthMarkFloatDlg( SfxBindings* pBindings,
+ SfxChildWindow* pChild,
+ Window *pParent,
+ SfxChildWinInfo* pInfo,
+ sal_Bool bNew=sal_True);
+ void ReInitDlg(SwWrtShell& rWrtShell);
+};
+
+class SwAuthMarkModalDlg : public SvxStandardDialog
+{
+ SwAuthorMarkPane m_aContent;
+public:
+ SwAuthMarkModalDlg(Window *pParent, SwWrtShell& rSh);
+
+ virtual void Apply();
+ void ReInitDlg(SwWrtShell& rWrtShell);
+};
+
+#endif // INCLUDED_SW_SOURCE_UI_INC_SWUIIDXMRK_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/swuipardlg.hxx b/sw/source/core/uibase/inc/swuipardlg.hxx
new file mode 100644
index 000000000000..103cc99deb53
--- /dev/null
+++ b/sw/source/core/uibase/inc/swuipardlg.hxx
@@ -0,0 +1,53 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_SWUIPARDLG_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_SWUIPARDLG_HXX
+#include "pardlg.hxx"
+
+class SwParaDlg: public SfxTabDialog
+{
+ SwView& rView;
+ sal_uInt16 nHtmlMode;
+ sal_uInt8 nDlgMode;
+ sal_Bool bDrawParaDlg;
+
+ sal_uInt16 m_nParaStd;
+ sal_uInt16 m_nParaAlign;
+ sal_uInt16 m_nParaExt;
+ sal_uInt16 m_nParaNumPara;
+ sal_uInt16 m_nParaDrpCps;
+ sal_uInt16 m_nParaBckGrnd;
+ sal_uInt16 m_nParaBorder;
+
+ void PageCreated(sal_uInt16 nId, SfxTabPage& rPage);
+
+public:
+ SwParaDlg( Window *pParent,
+ SwView& rVw,
+ const SfxItemSet&,
+ sal_uInt8 nDialogMode,
+ const OUString *pCollName = 0,
+ sal_Bool bDraw = sal_False,
+ OString sDefPage = OString());
+ ~SwParaDlg();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/swvset.hxx b/sw/source/core/uibase/inc/swvset.hxx
new file mode 100644
index 000000000000..10b71577f1d2
--- /dev/null
+++ b/sw/source/core/uibase/inc/swvset.hxx
@@ -0,0 +1,32 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_SWVSET_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_SWVSET_HXX
+#include <svx/numvset.hxx>
+
+class SwRulerValueSet : public SvxBmpNumValueSet
+{
+public:
+ SwRulerValueSet(Window* pParent, WinBits nWinStyle);
+ ~SwRulerValueSet();
+ virtual void UserDraw( const UserDrawEvent& rUDEvt );
+};
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/swwrtshitem.hxx b/sw/source/core/uibase/inc/swwrtshitem.hxx
new file mode 100644
index 000000000000..ba498ea7c41f
--- /dev/null
+++ b/sw/source/core/uibase/inc/swwrtshitem.hxx
@@ -0,0 +1,45 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_SWWRTSHITEM_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_SWWRTSHITEM_HXX
+#include <svl/poolitem.hxx>
+#include "swdllapi.h"
+
+class SwWrtShell;
+
+class SW_DLLPUBLIC SwWrtShellItem: public SfxPoolItem
+{
+ SwWrtShell* pWrtSh;
+
+public:
+ TYPEINFO();
+ SwWrtShellItem();
+ SwWrtShellItem( sal_uInt16 nWhich , SwWrtShell* pWrtSh);
+ SwWrtShellItem( const SwWrtShellItem& );
+
+ virtual bool operator==( const SfxPoolItem& ) const;
+ virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
+
+ SwWrtShell* GetValue() const { return pWrtSh; }
+
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/syncbtn.hxx b/sw/source/core/uibase/inc/syncbtn.hxx
new file mode 100644
index 000000000000..468821ff2b58
--- /dev/null
+++ b/sw/source/core/uibase/inc/syncbtn.hxx
@@ -0,0 +1,53 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_SYNCBTN_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_SYNCBTN_HXX
+#include <sfx2/childwin.hxx>
+
+#ifdef _SYNCDLG
+#include <sfx2/basedlgs.hxx>
+
+#include <vcl/button.hxx>
+
+class SwSyncBtnDlg : public SfxFloatingWindow
+{
+ PushButton aSyncBtn;
+
+ DECL_LINK( BtnHdl, void* );
+
+public:
+ SwSyncBtnDlg(SfxBindings*, SfxChildWindow*, Window *pParent);
+ ~SwSyncBtnDlg();
+};
+#endif
+
+class SwSyncChildWin : public SfxChildWindow
+{
+public:
+ SwSyncChildWin( Window* ,
+ sal_uInt16 nId,
+ SfxBindings*,
+ SfxChildWinInfo* );
+
+ SFX_DECL_CHILDWINDOW( SwSyncChildWin );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/table.hrc b/sw/source/core/uibase/inc/table.hrc
new file mode 100644
index 000000000000..6f7635bd4d36
--- /dev/null
+++ b/sw/source/core/uibase/inc/table.hrc
@@ -0,0 +1,37 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "rcid.hrc"
+
+#define DLG_ROW_HEIGHT (RC_TABLE_BEGIN + 4)
+
+
+#define MSG_ERR_TABLE_MERGE (RC_TABLE_BEGIN + 7)
+
+
+
+#define MSG_WRONG_TABLENAME (RC_TABLE_BEGIN + 13)
+
+#define TABLE_ACT_END MSG_WRONG_TABLENAME
+
+#if TABLE_ACT_END > RC_TABLE_END
+#error Resource-Id Ueberlauf in #file, #line
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/tabledlg.hxx b/sw/source/core/uibase/inc/tabledlg.hxx
new file mode 100644
index 000000000000..d18be07670dc
--- /dev/null
+++ b/sw/source/core/uibase/inc/tabledlg.hxx
@@ -0,0 +1,49 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_TABLEDLG_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_TABLEDLG_HXX
+
+#include <sfx2/tabdlg.hxx>
+
+#include "swtypes.hxx"
+#include "swtablerep.hxx"
+
+class SwWrtShell;
+struct TColumn;
+
+/*-------------------------------------------------------
+ table dialog
+--------------------------------------------------------- */
+class SwTableTabDlg : public SfxTabDialog
+{
+ SwWrtShell* pShell;
+ sal_uInt16 m_nHtmlMode;
+ sal_uInt16 m_nTextFlowId;
+ sal_uInt16 m_nBackgroundId;
+ sal_uInt16 m_nBorderId;
+
+ virtual void PageCreated(sal_uInt16 nId, SfxTabPage& rPage);
+public:
+ SwTableTabDlg( Window* pParent, SfxItemPool& Pool,
+ const SfxItemSet* pItemSet, SwWrtShell* pSh );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/tablemgr.hxx b/sw/source/core/uibase/inc/tablemgr.hxx
new file mode 100644
index 000000000000..4144b9b9aa09
--- /dev/null
+++ b/sw/source/core/uibase/inc/tablemgr.hxx
@@ -0,0 +1,88 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_TABLEMGR_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_TABLEMGR_HXX
+
+#include "swdllapi.h"
+#include "swtypes.hxx"
+#include "tabcol.hxx"
+
+class SwFrmFmt;
+class SwWrtShell;
+class Window;
+class SwFlyFrmFmt;
+
+namespace com { namespace sun { namespace star {
+ namespace frame {
+ class XModel; }
+ namespace chart2 {
+ namespace data {
+ class XDataProvider; } }
+}}}
+
+const SwTwips lAutoWidth = INVALID_TWIPS;
+const char cParaDelim = 0x0a;
+
+class SW_DLLPUBLIC SwTableFUNC
+{
+ SwFrmFmt *pFmt;
+ SwWrtShell *pSh;
+ sal_Bool bCopy;
+ SwTabCols aCols;
+
+private:
+ SAL_DLLPRIVATE int GetRightSeparator(int nNum) const;
+
+public:
+ inline SwTableFUNC(SwFrmFmt &);
+ SwTableFUNC(SwWrtShell *pShell, sal_Bool bCopyFmt = sal_False);
+ ~SwTableFUNC();
+
+ void InitTabCols();
+ void ColWidthDlg(Window *pParent );
+ SwTwips GetColWidth(sal_uInt16 nNum) const;
+ SwTwips GetMaxColWidth(sal_uInt16 nNum) const;
+ void SetColWidth(sal_uInt16 nNum, SwTwips nWidth );
+ sal_uInt16 GetColCount() const;
+ sal_uInt16 GetCurColNum() const;
+
+ sal_Bool IsTableSelected() const { return pFmt != 0; }
+
+ const SwFrmFmt *GetTableFmt() const { return pFmt; }
+
+ SwWrtShell* GetShell() const { return pSh; }
+
+ // @deprecated
+ void UpdateChart();
+
+ /// @return the XModel of the newly inserted chart if successful
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >
+ InsertChart( ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataProvider > &rxDataProvider, sal_Bool bFillWithData, const OUString &rCellRange, SwFlyFrmFmt** ppFlyFrmFmt = 0 );
+};
+
+inline SwTableFUNC::SwTableFUNC(SwFrmFmt &rFmt) :
+ pFmt(&rFmt),
+ pSh(0),
+ bCopy(sal_False)
+{
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/tabsh.hxx b/sw/source/core/uibase/inc/tabsh.hxx
new file mode 100644
index 000000000000..8e37947b7cf5
--- /dev/null
+++ b/sw/source/core/uibase/inc/tabsh.hxx
@@ -0,0 +1,52 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_TABSH_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_TABSH_HXX
+
+#include "basesh.hxx"
+#include "swdllapi.h"
+
+class SfxItemSet;
+class SwWrtShell;
+
+SW_DLLPUBLIC void ItemSetToTableParam( const SfxItemSet& rSet, SwWrtShell &rSh );
+
+extern const sal_uInt16 aUITableAttrRange[];
+SW_DLLPUBLIC const sal_uInt16* SwuiGetUITableAttrRange();
+
+class SwTableShell: public SwBaseShell
+{
+public:
+ SFX_DECL_INTERFACE(SW_TABSHELL)
+ TYPEINFO();
+
+ void Execute(SfxRequest &);
+ void GetState(SfxItemSet &);
+ void GetFrmBorderState(SfxItemSet &rSet);
+ void GetLineStyleState(SfxItemSet &rSet);
+ void ExecTableStyle(SfxRequest& rReq);
+
+ void ExecNumberFormat(SfxRequest& rReq);
+
+ SwTableShell(SwView &rView);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/tautofmt.hxx b/sw/source/core/uibase/inc/tautofmt.hxx
new file mode 100644
index 000000000000..5aac7016a944
--- /dev/null
+++ b/sw/source/core/uibase/inc/tautofmt.hxx
@@ -0,0 +1,91 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_TAUTOFMT_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_TAUTOFMT_HXX
+#include <sfx2/basedlgs.hxx>
+
+#include <vcl/fixed.hxx>
+
+#include <vcl/lstbox.hxx>
+
+#include <vcl/button.hxx>
+
+#include <vcl/morebtn.hxx>
+
+#include <vcl/virdev.hxx>
+
+class SwTableAutoFmt;
+class AutoFmtPreview;
+class SwTableAutoFmtTbl;
+class SwWrtShell;
+
+enum AutoFmtLine { TOP_LINE, BOTTOM_LINE, LEFT_LINE, RIGHT_LINE };
+
+class SwAutoFormatDlg : public SfxModalDialog
+{
+ ListBox* m_pLbFormat;
+ VclContainer* m_pFormatting;
+ CheckBox* m_pBtnNumFormat;
+ CheckBox* m_pBtnBorder;
+ CheckBox* m_pBtnFont;
+ CheckBox* m_pBtnPattern;
+ CheckBox* m_pBtnAlignment;
+ OKButton* m_pBtnOk;
+ CancelButton* m_pBtnCancel;
+ PushButton* m_pBtnAdd;
+ PushButton* m_pBtnRemove;
+ PushButton* m_pBtnRename;
+ OUString aStrTitle;
+ OUString aStrLabel;
+ OUString aStrClose;
+ OUString aStrDelTitle;
+ OUString aStrDelMsg;
+ OUString aStrRenameTitle;
+ OUString aStrInvalidFmt;
+ AutoFmtPreview* m_pWndPreview;
+
+ SwWrtShell* pShell;
+ SwTableAutoFmtTbl* pTableTbl;
+ sal_uInt8 nIndex;
+ sal_uInt8 nDfltStylePos;
+ sal_Bool bCoreDataChanged : 1;
+ sal_Bool bSetAutoFmt : 1;
+
+ void Init( const SwTableAutoFmt* pSelFmt );
+ void UpdateChecks( const SwTableAutoFmt&, sal_Bool bEnableBtn );
+
+ DECL_LINK( CheckHdl, Button * );
+ DECL_LINK(OkHdl, void *);
+ DECL_LINK( AddHdl, void * );
+ DECL_LINK( RemoveHdl, void * );
+ DECL_LINK( RenameHdl, void * );
+ DECL_LINK( SelFmtHdl, void * );
+
+public:
+ SwAutoFormatDlg( Window* pParent, SwWrtShell* pShell,
+ sal_Bool bSetAutoFmt = sal_True,
+ const SwTableAutoFmt* pSelFmt = 0 );
+ virtual ~SwAutoFormatDlg();
+
+ void FillAutoFmtOfIndex( SwTableAutoFmt*& rToFill ) const;
+};
+
+#endif // SW_AUTOFMT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/tblctrl.hxx b/sw/source/core/uibase/inc/tblctrl.hxx
new file mode 100644
index 000000000000..fbf66057e2ae
--- /dev/null
+++ b/sw/source/core/uibase/inc/tblctrl.hxx
@@ -0,0 +1,40 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_TBLCTRL_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_TBLCTRL_HXX
+
+#include <sfx2/tbxctrl.hxx>
+
+class SwTableOptimizeCtrl : public SfxToolBoxControl
+{
+
+public:
+ SFX_DECL_TOOLBOX_CONTROL();
+
+ SwTableOptimizeCtrl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx );
+ ~SwTableOptimizeCtrl();
+
+ virtual SfxPopupWindowType GetPopupWindowType() const;
+ virtual SfxPopupWindow* CreatePopupWindow();
+
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/tblnumfm.hxx b/sw/source/core/uibase/inc/tblnumfm.hxx
new file mode 100644
index 000000000000..ad8b9999f56c
--- /dev/null
+++ b/sw/source/core/uibase/inc/tblnumfm.hxx
@@ -0,0 +1,35 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_TBLNUMFM_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_TBLNUMFM_HXX
+
+#include <sfx2/basedlgs.hxx>
+
+class Window;
+class SfxItemSet;
+
+class SwNumFmtDlg : public SfxSingleTabDialog
+{
+public:
+ SwNumFmtDlg(Window* pParent, const SfxItemSet& rSet);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/tbxanchr.hxx b/sw/source/core/uibase/inc/tbxanchr.hxx
new file mode 100644
index 000000000000..96eed47f58d5
--- /dev/null
+++ b/sw/source/core/uibase/inc/tbxanchr.hxx
@@ -0,0 +1,42 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_TBXANCHR_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_TBXANCHR_HXX
+
+#include <sfx2/tbxctrl.hxx>
+
+class SwTbxAnchor : public SfxToolBoxControl
+{
+ sal_uInt16 nActAnchorId;
+
+public:
+
+ virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
+ virtual void Click();
+ virtual SfxPopupWindow* CreatePopupWindow();
+
+ SFX_DECL_TOOLBOX_CONTROL();
+
+ SwTbxAnchor( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx );
+ ~SwTbxAnchor();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/textsh.hxx b/sw/source/core/uibase/inc/textsh.hxx
new file mode 100644
index 000000000000..e9e00baeb535
--- /dev/null
+++ b/sw/source/core/uibase/inc/textsh.hxx
@@ -0,0 +1,83 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SW_SOURCE_UI_INC_TEXTSH_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_TEXTSH_HXX
+
+#include <basesh.hxx>
+#include <unotools/caserotate.hxx>
+
+class AbstractSvxPostItDialog;
+class SwFldMgr;
+class SvxHyperlinkItem;
+
+class SwTextShell: public SwBaseShell
+{
+ SwFldMgr* pPostItFldMgr;
+ RotateTransliteration m_aRotateCase;
+
+ void InsertSymbol( SfxRequest& );
+ void InsertHyperlink(const SvxHyperlinkItem& rHlnkItem);
+ bool InsertMediaDlg( SfxRequest& );
+
+public:
+ SFX_DECL_INTERFACE(SW_TEXTSHELL)
+ TYPEINFO();
+
+ DECL_LINK( RedlineNextHdl, AbstractSvxPostItDialog * );
+ DECL_LINK( RedlinePrevHdl, AbstractSvxPostItDialog * );
+
+ void Execute(SfxRequest &);
+ void GetState(SfxItemSet &);
+
+ void ExecInsert(SfxRequest &);
+ void StateInsert(SfxItemSet&);
+ void ExecDelete(SfxRequest &);
+ void ExecEnterNum(SfxRequest &);
+ void ExecBasicMove(SfxRequest &);
+ void ExecMove(SfxRequest &);
+ void ExecMovePage(SfxRequest &);
+ void ExecMoveCol(SfxRequest &);
+ void ExecMoveLingu(SfxRequest &);
+ void ExecMoveMisc(SfxRequest &);
+ void ExecField(SfxRequest &rReq);
+ void ExecSetNumber(SfxRequest &);
+ void StateField(SfxItemSet &);
+ void ExecIdx(SfxRequest &);
+ void GetIdxState(SfxItemSet &);
+ void ExecGlossary(SfxRequest &);
+
+ void ExecCharAttr(SfxRequest &);
+ void ExecCharAttrArgs(SfxRequest &);
+ void ExecParaAttr(SfxRequest &);
+ void ExecParaAttrArgs(SfxRequest &);
+ void ExecAttr(SfxRequest &);
+ void ExecDB(SfxRequest &);
+ void ExecTransliteration(SfxRequest &);
+ void ExecRotateTransliteration(SfxRequest &);
+
+ void GetAttrState(SfxItemSet &);
+
+ SwTextShell(SwView &rView);
+ virtual ~SwTextShell();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/titlepage.hxx b/sw/source/core/uibase/inc/titlepage.hxx
new file mode 100644
index 000000000000..3031e3112ef9
--- /dev/null
+++ b/sw/source/core/uibase/inc/titlepage.hxx
@@ -0,0 +1,70 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_SW_SOURCE_UI_INC_TITLEPAGE_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_TITLEPAGE_HXX
+
+#include <sfx2/basedlgs.hxx>
+#include <vcl/button.hxx>
+#include <vcl/field.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/lstbox.hxx>
+#include <numberingtypelistbox.hxx>
+
+class Window;
+class SwWrtShell;
+class SwPageDesc;
+
+class SwTitlePageDlg : public SfxModalDialog
+{
+private:
+ RadioButton* m_pUseExistingPagesRB;
+ NumericField* m_pPageCountNF;
+
+ RadioButton* m_pDocumentStartRB;
+ RadioButton* m_pPageStartRB;
+ NumericField* m_pPageStartNF;
+
+ CheckBox* m_pRestartNumberingCB;
+ NumericField* m_pRestartNumberingNF;
+ CheckBox* m_pSetPageNumberCB;
+ NumericField* m_pSetPageNumberNF;
+
+ ListBox* m_pPagePropertiesLB;
+ PushButton* m_pPagePropertiesPB;
+
+ OKButton* m_pOkPB;
+
+ SwWrtShell *mpSh;
+
+ const SwFmtPageDesc *mpPageFmtDesc;
+
+ SwPageDesc *mpTitleDesc;
+ const SwPageDesc *mpIndexDesc;
+ const SwPageDesc *mpNormalDesc;
+
+ void FillList();
+
+ sal_uInt16 GetInsertPosition() const;
+
+ DECL_LINK(OKHdl, void *);
+ DECL_LINK(EditHdl, void *);
+ DECL_LINK(RestartNumberingHdl, void *);
+ DECL_LINK(SetPageNumberHdl, void *);
+ DECL_LINK(UpHdl, void *);
+ DECL_LINK(DownHdl, void *);
+ DECL_LINK(StartPageHdl, void *);
+public:
+ SwTitlePageDlg( Window *pParent );
+ ~SwTitlePageDlg();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/tmpdlg.hxx b/sw/source/core/uibase/inc/tmpdlg.hxx
new file mode 100644
index 000000000000..ac990146c80d
--- /dev/null
+++ b/sw/source/core/uibase/inc/tmpdlg.hxx
@@ -0,0 +1,89 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_TMPDLG_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_TMPDLG_HXX
+
+#include <sfx2/styledlg.hxx>
+
+class SfxItemSet;
+class SwWrtShell;
+
+/*--------------------------------------------------------------------
+ Description: the tab dialog carrier of TabPages
+ --------------------------------------------------------------------*/
+class SwTemplateDlg: public SfxStyleDialog
+{
+
+ sal_uInt16 nType;
+ sal_uInt16 nHtmlMode;
+ SwWrtShell* pWrtShell;
+ sal_Bool bNewStyle;
+
+ DECL_LINK( NumOptionsHdl, PushButton* );
+
+ sal_uInt16 m_nIndentsId;
+ sal_uInt16 m_nAlignId;
+ sal_uInt16 m_nTextFlowId;
+ sal_uInt16 m_nAsianTypo;
+ sal_uInt16 m_nFontId;
+ sal_uInt16 m_nFontEffectId;
+ sal_uInt16 m_nPositionId;
+ sal_uInt16 m_nAsianLayoutId;
+ sal_uInt16 m_nTabId;
+ sal_uInt16 m_nOutlineId;
+ sal_uInt16 m_nDropCapsId;
+ sal_uInt16 m_nBackgroundId;
+ sal_uInt16 m_nBorderId;
+ sal_uInt16 m_nConditionId;
+ sal_uInt16 m_nTypeId;
+ sal_uInt16 m_nOptionsId;
+ sal_uInt16 m_nWrapId;
+ sal_uInt16 m_nColumnId;
+ sal_uInt16 m_nMacroId;
+ sal_uInt16 m_nHeaderId;
+ sal_uInt16 m_nFooterId;
+ sal_uInt16 m_nPageId;
+ sal_uInt16 m_nFootNoteId;
+ sal_uInt16 m_nTextGridId;
+ sal_uInt16 m_nSingleId;
+ sal_uInt16 m_nBulletId;
+ sal_uInt16 m_nNumId;
+ sal_uInt16 m_nBmpId;
+ sal_uInt16 m_nNumOptId;
+ sal_uInt16 m_nNumPosId;
+
+public:
+ // @param sPage
+ // Identifies name of page to open at by default
+ SwTemplateDlg( Window* pParent,
+ SfxStyleSheetBase& rBase,
+ sal_uInt16 nRegion,
+ OString sPage = OString(),
+ SwWrtShell* pActShell = 0,
+ bool bNew = false );
+
+ const SfxItemSet* GetRefreshedSet();
+
+ virtual void PageCreated( sal_uInt16 nId, SfxTabPage &rPage );
+ virtual short Ok();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/tmplctrl.hxx b/sw/source/core/uibase/inc/tmplctrl.hxx
new file mode 100644
index 000000000000..9deea7c83496
--- /dev/null
+++ b/sw/source/core/uibase/inc/tmplctrl.hxx
@@ -0,0 +1,45 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_TMPLCTRL_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_TMPLCTRL_HXX
+
+#include <sfx2/stbitem.hxx>
+
+// class BookmarkToolBoxControl -------------------------------------------
+class SwTemplateControl : public SfxStatusBarControl
+{
+protected:
+ virtual void Command( const CommandEvent& rCEvt );
+public:
+ virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState,
+ const SfxPoolItem* pState );
+ virtual void Paint( const UserDrawEvent& rEvt );
+
+ SFX_DECL_STATUSBAR_CONTROL();
+
+ SwTemplateControl( sal_uInt16 nSlotId, sal_uInt16 nId, StatusBar& rStb );
+ ~SwTemplateControl();
+
+private:
+ OUString sTemplate;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/toolbox.hrc b/sw/source/core/uibase/inc/toolbox.hrc
new file mode 100644
index 000000000000..e65caf2bbcb3
--- /dev/null
+++ b/sw/source/core/uibase/inc/toolbox.hrc
@@ -0,0 +1,553 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef _TOOLBOX_HRC
+#define _TOOLBOX_HRC
+#include "shells.hrc"
+#include "globals.hrc"
+#include "cmdid.h"
+#define MN_FONT\
+ 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 ; };
+
+#define MN_TEXT1( HIDE )\
+ ToolBoxItem\
+ {\
+ Identifier = SID_ATTR_CHAR_WEIGHT ; \
+ HelpID = SID_ATTR_CHAR_WEIGHT ; \
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = SID_ATTR_CHAR_POSTURE ; \
+ HelpID = SID_ATTR_CHAR_POSTURE ; \
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = SID_ATTR_CHAR_UNDERLINE ; \
+ HelpID = SID_ATTR_CHAR_UNDERLINE ; \
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = SID_ATTR_CHAR_OVERLINE ; \
+ HelpID = SID_ATTR_CHAR_OVERLINE ; \
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = FN_SET_SUPER_SCRIPT;\
+ HelpID = FN_SET_SUPER_SCRIPT;\
+ Hide = HIDE;\
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = FN_SET_SUB_SCRIPT;\
+ HelpID = FN_SET_SUB_SCRIPT;\
+ Hide = HIDE;\
+ };\
+ ToolBoxItem\
+ {\
+ Type = TOOLBOXITEM_SEPARATOR ; \
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = SID_ATTR_PARA_ADJUST_LEFT ; \
+ HelpID = SID_ATTR_PARA_ADJUST_LEFT ; \
+ RadioCheck = TRUE ; \
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = SID_ATTR_PARA_ADJUST_CENTER ; \
+ HelpID = SID_ATTR_PARA_ADJUST_CENTER ; \
+ RadioCheck = TRUE ; \
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = SID_ATTR_PARA_ADJUST_RIGHT ; \
+ HelpID = SID_ATTR_PARA_ADJUST_RIGHT ; \
+ RadioCheck = TRUE ; \
+ };\
+
+#define MN_TEXT1_RTL( HIDE )\
+ ToolBoxItem\
+ {\
+ Identifier = SID_ATTR_CHAR_WEIGHT ; \
+ HelpID = SID_ATTR_CHAR_WEIGHT ; \
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = SID_ATTR_CHAR_POSTURE ; \
+ HelpID = SID_ATTR_CHAR_POSTURE ; \
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = SID_ATTR_CHAR_UNDERLINE ; \
+ HelpID = SID_ATTR_CHAR_UNDERLINE ; \
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = SID_ATTR_CHAR_OVERLINE ; \
+ HelpID = SID_ATTR_CHAR_OVERLINE ; \
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = FN_SET_SUPER_SCRIPT;\
+ HelpID = FN_SET_SUPER_SCRIPT;\
+ Hide = HIDE;\
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = FN_SET_SUB_SCRIPT;\
+ HelpID = FN_SET_SUB_SCRIPT;\
+ Hide = HIDE;\
+ };\
+ ToolBoxItem\
+ {\
+ Type = TOOLBOXITEM_SEPARATOR ; \
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = SID_ATTR_PARA_ADJUST_RIGHT ; \
+ HelpID = SID_ATTR_PARA_ADJUST_RIGHT ; \
+ RadioCheck = TRUE ; \
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = SID_ATTR_PARA_ADJUST_CENTER ; \
+ HelpID = SID_ATTR_PARA_ADJUST_CENTER ; \
+ RadioCheck = TRUE ; \
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = SID_ATTR_PARA_ADJUST_LEFT ; \
+ HelpID = SID_ATTR_PARA_ADJUST_LEFT ; \
+ RadioCheck = TRUE ; \
+ };\
+
+#define MN_TEXT1_BLOCK \
+ ToolBoxItem\
+ {\
+ Identifier = SID_ATTR_PARA_ADJUST_BLOCK ; \
+ HelpID = SID_ATTR_PARA_ADJUST_BLOCK ; \
+ RadioCheck = TRUE ; \
+ };\
+
+#define MN_TEXT_LINESPACE \
+ ToolBoxItem\
+ {\
+ Type = TOOLBOXITEM_SEPARATOR ; \
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = SID_ATTR_PARA_LINESPACE_10;\
+ HelpID = SID_ATTR_PARA_LINESPACE_10;\
+ RadioCheck = TRUE;\
+ Hide = TRUE;\
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = SID_ATTR_PARA_LINESPACE_15;\
+ HelpID = SID_ATTR_PARA_LINESPACE_15;\
+ RadioCheck = TRUE;\
+ Hide = TRUE;\
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = SID_ATTR_PARA_LINESPACE_20;\
+ HelpID = SID_ATTR_PARA_LINESPACE_20;\
+ RadioCheck = TRUE;\
+ Hide = TRUE;\
+ };\
+
+#define MN_TEXT_LTR_RTL \
+ 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;\
+ };\
+
+#define MN_TEXT_RTL_LTR \
+ 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;\
+ };\
+
+#define MN_TEXT2\
+ ToolBoxItem\
+ {\
+ Type = TOOLBOXITEM_SEPARATOR ; \
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = FN_NUM_NUMBERING_ON ; \
+ HelpID = FN_NUM_NUMBERING_ON ; \
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = FN_NUM_BULLET_ON ; \
+ HelpID = FN_NUM_BULLET_ON ; \
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = SID_DEC_INDENT ; \
+ HelpId = SID_DEC_INDENT ; \
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = SID_INC_INDENT ; \
+ HelpId = SID_INC_INDENT ; \
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = FN_GROW_FONT_SIZE;\
+ HelpID = FN_GROW_FONT_SIZE;\
+ Hide = TRUE;\
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = FN_SHRINK_FONT_SIZE;\
+ HelpID = FN_SHRINK_FONT_SIZE;\
+ Hide = TRUE;\
+ };\
+
+#define MN_BACKGROUND_COLOR\
+ ToolBoxItem\
+ {\
+ ITEM_TOOLBAR_BACKGROUND_COLOR\
+ };
+
+#define MN_TEXT_BACKGROUND \
+ ToolBoxItem\
+ {\
+ Type = TOOLBOXITEM_SEPARATOR ; \
+ };\
+ ToolBoxItem\
+ {\
+ ITEM_TOOLBAR_ATTR_CHAR_COLOR\
+ Identifier = SID_ATTR_CHAR_COLOR2 ; \
+ Command = ".uno:FontColor"; \
+ DropDown = TRUE ;\
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = SID_ATTR_CHAR_COLOR_BACKGROUND ; \
+ HelpID = SID_ATTR_CHAR_COLOR_BACKGROUND ; \
+ DropDown = TRUE ;\
+ };\
+ ToolBoxItem\
+ {\
+ ITEM_TOOLBAR_BACKGROUND_COLOR\
+ Text [ en-US ] = "Paragraph Background" ; \
+ };
+
+#define MN_TEXT_DIALOGS(HIDE)\
+ ToolBoxItem\
+ {\
+ Type = TOOLBOXITEM_SEPARATOR ; \
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = SID_SELECTALL;\
+ HelpId = SID_SELECTALL;\
+ Hide = HIDE;\
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = SID_CHAR_DLG;\
+ HelpId = SID_CHAR_DLG;\
+ Hide = HIDE;\
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = SID_PARA_DLG;\
+ HelpId = SID_PARA_DLG;\
+ Hide = HIDE;\
+ };
+
+
+#define MN_TEMPLATE\
+ ToolBoxItem\
+ {\
+ ITEM_TOOLBAR_TEMPLATE_APPLY\
+ };\
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+
+#define MN_FRAME_WRAP\
+ ToolBoxItem\
+ {\
+ Identifier = FN_FRAME_NOWRAP ; \
+ HelpID = FN_FRAME_NOWRAP ; \
+ RadioCheck = TRUE ; \
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = FN_FRAME_WRAP ; \
+ HelpID = FN_FRAME_WRAP ; \
+ RadioCheck = TRUE ; \
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = FN_FRAME_WRAP_IDEAL ; \
+ HelpID = FN_FRAME_WRAP_IDEAL ; \
+ RadioCheck = TRUE ; \
+ Hide = TRUE;\
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = FN_FRAME_WRAP_LEFT ; \
+ HelpID = FN_FRAME_WRAP_LEFT ; \
+ RadioCheck = TRUE ; \
+ Hide = TRUE;\
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = FN_FRAME_WRAP_RIGHT ; \
+ HelpID = FN_FRAME_WRAP_RIGHT ; \
+ RadioCheck = TRUE ; \
+ Hide = TRUE;\
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = FN_FRAME_WRAPTHRU ; \
+ HelpID = FN_FRAME_WRAPTHRU ; \
+ RadioCheck = TRUE ; \
+ };
+
+#define MN_FRAME_WRAP_WEB\
+ ToolBoxItem\
+ {\
+ Identifier = FN_FRAME_NOWRAP ; \
+ HelpID = FN_FRAME_NOWRAP ; \
+ RadioCheck = TRUE ; \
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = FN_FRAME_WRAP_LEFT ; \
+ HelpID = FN_FRAME_WRAP_LEFT ; \
+ RadioCheck = TRUE ; \
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = FN_FRAME_WRAP_RIGHT ; \
+ HelpID = FN_FRAME_WRAP_RIGHT ; \
+ RadioCheck = TRUE ; \
+ };\
+ ToolBoxItem\
+ {\
+ Type = TOOLBOXITEM_SEPARATOR ; \
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = SID_IMAP ; \
+ HelpID = SID_IMAP ; \
+ RadioCheck = TRUE ; \
+ };
+
+#define MN_CONTOUR\
+ ToolBoxItem\
+ {\
+ Type = TOOLBOXITEM_SEPARATOR ; \
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = FN_FRAME_WRAP_CONTOUR ; \
+ HelpID = FN_FRAME_WRAP_CONTOUR ; \
+ Hide = TRUE ; \
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = SID_CONTOUR_DLG ; \
+ HelpID = SID_CONTOUR_DLG ; \
+ Hide = TRUE ; \
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = SID_IMAP ; \
+ HelpID = SID_IMAP ; \
+ Hide = TRUE ; \
+ };
+
+
+#define MN_FRAME1\
+ ToolBoxItem\
+ {\
+ Type = TOOLBOXITEM_SEPARATOR ; \
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = FN_FRAME_ALIGN_HORZ_LEFT ; \
+ HelpID = FN_FRAME_ALIGN_HORZ_LEFT ; \
+ RadioCheck = TRUE ; \
+ };
+
+#define MN_FRAME2\
+ ToolBoxItem\
+ {\
+ Identifier = FN_FRAME_ALIGN_HORZ_CENTER ; \
+ HelpID = FN_FRAME_ALIGN_HORZ_CENTER ; \
+ RadioCheck = TRUE ; \
+ };
+
+#define MN_FRAME3\
+ ToolBoxItem\
+ {\
+ Identifier = FN_FRAME_ALIGN_HORZ_RIGHT ; \
+ HelpID = FN_FRAME_ALIGN_HORZ_RIGHT ; \
+ RadioCheck = TRUE ; \
+ };\
+ ToolBoxItem\
+ {\
+ Type = TOOLBOXITEM_SEPARATOR ; \
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = FN_FRAME_ALIGN_VERT_TOP ; \
+ HelpID = FN_FRAME_ALIGN_VERT_TOP ; \
+ RadioCheck = TRUE ; \
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = FN_FRAME_ALIGN_VERT_CENTER ; \
+ HelpID = FN_FRAME_ALIGN_VERT_CENTER ; \
+ RadioCheck = TRUE ; \
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = FN_FRAME_ALIGN_VERT_BOTTOM ; \
+ HelpID = FN_FRAME_ALIGN_VERT_BOTTOM ; \
+ RadioCheck = TRUE ; \
+ };\
+ ToolBoxItem\
+ {\
+ Type = TOOLBOXITEM_SEPARATOR ; \
+ };
+
+#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_LINESTYLE\
+ ToolBoxItem\
+ {\
+ ITEM_TOOLBAR_ATTR_BORDER\
+ };\
+ ToolBoxItem\
+ {\
+ ITEM_TOOLBAR_FRAME_LINESTYLE\
+ };\
+ ToolBoxItem\
+ {\
+ ITEM_TOOLBAR_FRAME_LINECOLOR\
+ };
+
+#define MN_ATTRIBUTES_FRAME\
+ ToolBoxItem\
+ {\
+ Identifier = FN_FORMAT_FRAME_DLG ; \
+ HelpID = FN_FORMAT_FRAME_DLG ; \
+ };
+
+#define MN_ATTRIBUTES_GRAFIK\
+ ToolBoxItem\
+ {\
+ Identifier = FN_FORMAT_FRAME_DLG;\
+ HelpID = FN_FORMAT_GRAFIC_DLG;\
+ Text [ en-US ] = "Image Properties";\
+ };
+
+
+#define MN_ATTRIBUTES_OLE\
+ ToolBoxItem\
+ {\
+ Identifier = FN_FORMAT_FRAME_DLG;\
+ HelpID = FN_FORMAT_FRAME_DLG;\
+ Text [ en-US ] = "Object Properties";\
+ };
+
+#define MN_GRID(hide)\
+ ToolBoxItem\
+ {\
+ Type = TOOLBOXITEM_SEPARATOR;\
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = SID_GRID_VISIBLE;\
+ HelpID = SID_GRID_VISIBLE;\
+ hide;\
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = SID_GRID_USE;\
+ HelpID = SID_GRID_USE;\
+ hide;\
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = SID_HELPLINES_MOVE;\
+ HelpID = SID_HELPLINES_MOVE;\
+ hide;\
+ };
+
+
+
+#endif // _TOOLBOX_HRC
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/toxmgr.hxx b/sw/source/core/uibase/inc/toxmgr.hxx
new file mode 100644
index 000000000000..86b2d7f5ecc5
--- /dev/null
+++ b/sw/source/core/uibase/inc/toxmgr.hxx
@@ -0,0 +1,310 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SW_SOURCE_UI_INC_TOXMGR_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_TOXMGR_HXX
+
+#include "swdllapi.h"
+#include "tox.hxx"
+#include <authfld.hxx>
+
+class SwWrtShell;
+class SwForm;
+
+/*--------------------------------------------------------------------
+ Description: manager for directory functionality
+ --------------------------------------------------------------------*/
+//one single method will be sufficient to insert AND upate indexes
+class SW_DLLPUBLIC SwTOXDescription
+{
+ TOXTypes eTOXType;
+ OUString aStyleNames[MAXLEVEL];
+ OUString sSequenceName;
+ OUString sMainEntryCharStyle;
+ OUString sAutoMarkURL;
+ OUString* pTitle;
+ OUString* pTOUName;
+ SwForm* pForm;
+ sal_uInt16 nContent;
+ sal_uInt16 nIndexOptions;
+ sal_uInt16 nOLEOptions;
+ LanguageType eLanguage;
+ OUString sSortAlgorithm;
+
+ OUString sAuthBrackets;
+ SwCaptionDisplay eCaptionDisplay;
+ SwTOXSortKey eSortKey1;
+ SwTOXSortKey eSortKey2;
+ SwTOXSortKey eSortKey3;
+ sal_uInt8 nLevel;
+ sal_Bool bFromObjectNames : 1;
+ sal_Bool bFromChapter : 1;
+ sal_Bool bReadonly: 1;
+ sal_Bool bLevelFromChapter : 1;
+ sal_Bool bIsAuthSequence :1;
+ sal_Bool bSortByDocument :1;
+
+ //TODO: TemplateNames
+ //const String* pTemplateName = 0, ???
+
+ // forbidden and not implemented.
+ SwTOXDescription();
+ SwTOXDescription(SwTOXDescription&);
+ SwTOXDescription & operator= (SwTOXDescription&);
+
+public:
+ // single argument ctors shall be explicit.
+ explicit SwTOXDescription(TOXTypes eType) :
+ eTOXType(eType),
+ pTitle(0),
+ pTOUName(0),
+ pForm(0),
+ nContent(nsSwTOXElement::TOX_MARK | nsSwTOXElement::TOX_OUTLINELEVEL),
+ nIndexOptions(nsSwTOIOptions::TOI_SAME_ENTRY|nsSwTOIOptions::TOI_FF|nsSwTOIOptions::TOI_CASE_SENSITIVE),
+ nOLEOptions(0),
+ eLanguage((LanguageType)::GetAppLanguage()),
+ eCaptionDisplay(CAPTION_COMPLETE),
+ nLevel(MAXLEVEL),
+ bFromObjectNames(sal_False),
+ bFromChapter(sal_False),
+ bReadonly(sal_True),
+ bLevelFromChapter(sal_False),
+ bIsAuthSequence(sal_False),
+ bSortByDocument(sal_True)
+ {}
+ ~SwTOXDescription()
+ {
+ delete pTitle;
+ delete pForm;
+ delete pTOUName;
+ }
+
+ void SetTOXType(TOXTypes eSet) { eTOXType = eSet;}
+ TOXTypes GetTOXType() const { return eTOXType;}
+
+ const OUString& GetStyleNames(sal_uInt16 nLvl) const
+ {return aStyleNames[nLvl];}
+ void SetStyleNames(const OUString& rSet, sal_uInt16 nLvl)
+ {aStyleNames[nLvl] = rSet; }
+
+ const OUString& GetAutoMarkURL() const { return sAutoMarkURL;}
+ void SetAutoMarkURL(const OUString& rSet) {sAutoMarkURL = rSet;}
+
+ void SetTitle(const OUString& pSet) {delete pTitle; pTitle = new OUString(pSet);}
+ const OUString* GetTitle() const {return pTitle; }
+
+ void SetTOUName(const OUString& pSet) {delete pTOUName; pTOUName = new OUString(pSet);}
+ const OUString* GetTOUName() const {return pTOUName; }
+
+ void SetForm(const SwForm& rSet) {delete pForm; pForm = new SwForm(rSet);}
+ const SwForm* GetForm() const {return pForm;}
+
+ void SetContentOptions(sal_uInt16 nSet) { nContent = nSet;}
+ sal_uInt16 GetContentOptions() const { return nContent;}
+
+ void SetIndexOptions(sal_uInt16 nSet) { nIndexOptions = nSet;}
+ sal_uInt16 GetIndexOptions() const { return nIndexOptions;}
+
+ const OUString& GetMainEntryCharStyle() const {return sMainEntryCharStyle;}
+ void SetMainEntryCharStyle(const OUString& rSet) {sMainEntryCharStyle = rSet;}
+
+ void SetLevel(sal_uInt8 nSet) {nLevel = nSet;}
+ sal_uInt8 GetLevel()const {return nLevel; }
+
+ void SetCreateFromObjectNames(sal_Bool bSet) { bFromObjectNames = bSet;}
+ sal_Bool IsCreateFromObjectNames() const {return bFromObjectNames;}
+
+ const OUString& GetSequenceName() const {return sSequenceName;}
+ void SetSequenceName(const OUString& rSet) {sSequenceName = rSet;}
+
+ SwCaptionDisplay GetCaptionDisplay() const { return eCaptionDisplay;}
+ void SetCaptionDisplay(SwCaptionDisplay eSet) {eCaptionDisplay = eSet;}
+
+ void SetFromChapter(sal_Bool bSet) { bFromChapter = bSet;}
+ sal_Bool IsFromChapter() const {return bFromChapter;}
+
+ void SetReadonly(sal_Bool bSet){bReadonly = bSet;}
+ sal_Bool IsReadonly() const {return bReadonly;}
+
+ sal_uInt16 GetOLEOptions() const {return nOLEOptions;}
+ void SetOLEOptions(sal_uInt16 nOpt) {nOLEOptions = nOpt;}
+
+ sal_Bool IsLevelFromChapter() const {return bLevelFromChapter;}
+ void SetLevelFromChapter(sal_Bool bSet) {bLevelFromChapter = bSet;}
+
+ OUString GetAuthBrackets() const {return sAuthBrackets;}
+ void SetAuthBrackets(const OUString& rSet) {sAuthBrackets = rSet;}
+
+ sal_Bool IsAuthSequence() const {return bIsAuthSequence;}
+ void SetAuthSequence(sal_Bool bSet){bIsAuthSequence = bSet;}
+
+ sal_Bool IsSortByDocument()const {return bSortByDocument ;}
+ void SetSortByDocument(sal_Bool bSet) {bSortByDocument = bSet;}
+
+ void SetSortKeys(SwTOXSortKey eKey1,
+ SwTOXSortKey eKey2,
+ SwTOXSortKey eKey3);
+
+ SwTOXSortKey GetSortKey1() const {return eSortKey1;}
+ SwTOXSortKey GetSortKey2() const {return eSortKey2;}
+ SwTOXSortKey GetSortKey3() const {return eSortKey3;}
+
+ LanguageType GetLanguage() const {return eLanguage;}
+ void SetLanguage(LanguageType nLang) {eLanguage = nLang;}
+
+ const OUString& GetSortAlgorithm()const {return sSortAlgorithm;}
+ void SetSortAlgorithm(const OUString& rSet) {sSortAlgorithm = rSet;}
+
+ void ApplyTo(SwTOXBase& rTOXBase);
+
+};
+
+class SwTOXMarkDescription
+{
+ TOXTypes eTOXType;
+ int nLevel;
+ sal_Bool bMainEntry;
+
+ OUString* pPrimKey;
+ OUString* pSecKey;
+ OUString* pAltStr;
+ OUString* pTOUName;
+
+ OUString* pPhoneticReadingOfAltStr;
+ OUString* pPhoneticReadingOfPrimKey;
+ OUString* pPhoneticReadingOfSecKey;
+
+ // forbidden and not implemented.
+ SwTOXMarkDescription();
+ SwTOXMarkDescription(SwTOXMarkDescription&);
+ SwTOXMarkDescription & operator= (SwTOXMarkDescription&);
+
+public:
+ // single argument ctors shall be explicit.
+ explicit SwTOXMarkDescription(TOXTypes eType) :
+ eTOXType(eType),
+ nLevel(0),
+ bMainEntry(sal_False),
+ pPrimKey(0),
+ pSecKey(0),
+ pAltStr(0),
+ pTOUName(0),
+ pPhoneticReadingOfAltStr(0),
+ pPhoneticReadingOfPrimKey(0),
+ pPhoneticReadingOfSecKey(0)
+ {
+ }
+ ~SwTOXMarkDescription()
+ {
+ delete pPrimKey;
+ delete pSecKey;
+ delete pAltStr;
+ delete pTOUName;
+ delete pPhoneticReadingOfAltStr;
+ delete pPhoneticReadingOfPrimKey;
+ delete pPhoneticReadingOfSecKey;
+ }
+
+ TOXTypes GetTOXType()const {return eTOXType;}
+
+ void SetLevel(int nSet) {nLevel = nSet;}
+ int GetLevel() const {return nLevel;}
+
+ void SetMainEntry(sal_Bool bSet) {bMainEntry = bSet;}
+ sal_Bool IsMainEntry() const {return bMainEntry;}
+
+ void SetPrimKey(const OUString& rSet)
+ {delete pPrimKey; pPrimKey = new OUString(rSet);}
+ const OUString* GetPrimKey() const {return pPrimKey;}
+
+ void SetSecKey(const OUString& rSet)
+ {delete pSecKey; pSecKey = new OUString(rSet);}
+ const OUString* GetSecKey() const { return pSecKey; }
+
+ void SetAltStr(const OUString& rSet)
+ {delete pAltStr; pAltStr = new OUString(rSet);}
+ const OUString* GetAltStr() const { return pAltStr; }
+
+ void SetTOUName(const OUString& rSet)
+ {delete pTOUName; pTOUName = new OUString(rSet);}
+ const OUString* GetTOUName() const {return pTOUName;}
+
+ void SetPhoneticReadingOfAltStr(const OUString& rSet)
+ {delete pPhoneticReadingOfAltStr; pPhoneticReadingOfAltStr = new OUString(rSet);}
+ const OUString* GetPhoneticReadingOfAltStr() const { return pPhoneticReadingOfAltStr; }
+
+ void SetPhoneticReadingOfPrimKey(const OUString& rSet)
+ {delete pPhoneticReadingOfPrimKey; pPhoneticReadingOfPrimKey = new OUString(rSet);}
+ const OUString* GetPhoneticReadingOfPrimKey() const { return pPhoneticReadingOfPrimKey; }
+
+ void SetPhoneticReadingOfSecKey(const OUString& rSet)
+ {delete pPhoneticReadingOfSecKey; pPhoneticReadingOfSecKey = new OUString(rSet);}
+ const OUString* GetPhoneticReadingOfSecKey() const { return pPhoneticReadingOfSecKey; }
+};
+
+class SW_DLLPUBLIC SwTOXMgr
+{
+ SwWrtShell* pSh;
+ SwTOXMark* pCurTOXMark;
+ SwTOXMarks aCurMarks;
+
+ SAL_DLLPRIVATE sal_uInt16 GetUserTypeID(const OUString& rStr);
+
+public:
+ // single argument ctors shall be explicit.
+ explicit SwTOXMgr(SwWrtShell* pShell);
+
+ // methods for directory marks
+
+ void InsertTOXMark(const SwTOXMarkDescription& rDesc);
+
+ void UpdateTOXMark(const SwTOXMarkDescription& rDesc);
+
+ void DeleteTOXMark();
+ void NextTOXMark(sal_Bool bSame=sal_False);
+ void PrevTOXMark(sal_Bool bSame=sal_False);
+
+ // get current TOXmarks
+ sal_uInt16 GetTOXMarks();
+ sal_uInt16 GetTOXMarkCount();
+ SwTOXMark* GetTOXMark(sal_uInt16 nId);
+ SwTOXMark* GetCurTOXMark();
+ void SetCurTOXMark(sal_uInt16 nId);
+
+ // methods for directories
+
+ sal_Bool UpdateOrInsertTOX(const SwTOXDescription& rDesc, SwTOXBase** ppBase = 0, const SfxItemSet* pSet = 0);
+
+ const SwTOXType* GetTOXType(TOXTypes eTyp, sal_uInt16 nId) const;
+ const SwTOXBase* GetCurTOX();
+
+};
+
+/*--------------------------------------------------------------------
+ Description: inlines
+ --------------------------------------------------------------------*/
+inline sal_uInt16 SwTOXMgr::GetTOXMarkCount()
+ { return aCurMarks.size(); }
+
+inline SwTOXMark* SwTOXMgr::GetCurTOXMark()
+ { return pCurTOXMark; }
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/uiborder.hxx b/sw/source/core/uibase/inc/uiborder.hxx
new file mode 100644
index 000000000000..78adaeb7846d
--- /dev/null
+++ b/sw/source/core/uibase/inc/uiborder.hxx
@@ -0,0 +1,41 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef _UIBORDER_HXX
+#define _UIBORDER_HXX
+
+#include <sfx2/basedlgs.hxx>
+class Window;
+class SfxItemSet;
+
+class SwBorderDlg : public SfxSingleTabDialog
+{
+public:
+
+ // nType may be:
+ // SW_BORDER_MODE_PARA
+ // SW_BORDER_MODE_TABLE
+ // SW_BORDER_MODE_FRAME
+
+ SwBorderDlg(Window* pParent, SfxItemSet& rSet, sal_uInt16 nType);
+ ~SwBorderDlg();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/uiitems.hxx b/sw/source/core/uibase/inc/uiitems.hxx
new file mode 100644
index 000000000000..033adf755882
--- /dev/null
+++ b/sw/source/core/uibase/inc/uiitems.hxx
@@ -0,0 +1,119 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_UIITEMS_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_UIITEMS_HXX
+
+#include <svl/intitem.hxx>
+#include "swdllapi.h"
+#include "cmdid.h"
+#include "pagedesc.hxx"
+
+class SwNumRule;
+class IntlWrapper;
+class SwPaM;
+
+/*--------------------------------------------------------------------
+ Description: container for FootNote
+ --------------------------------------------------------------------*/
+class SW_DLLPUBLIC SwPageFtnInfoItem : public SfxPoolItem
+{
+ SwPageFtnInfo aFtnInfo;
+
+public:
+
+ SwPageFtnInfoItem(const sal_uInt16 nId, SwPageFtnInfo& rInfo);
+ SwPageFtnInfoItem(const SwPageFtnInfoItem& rItem );
+ ~SwPageFtnInfoItem();
+
+ virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
+ virtual bool operator==( const SfxPoolItem& ) const;
+ virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
+ SfxMapUnit eCoreMetric,
+ SfxMapUnit ePresMetric,
+ OUString &rText,
+ const IntlWrapper* pIntl = 0 ) const;
+
+ virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const;
+ virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 );
+
+ SwPageFtnInfo& GetPageFtnInfo() { return aFtnInfo; }
+ const SwPageFtnInfo& GetPageFtnInfo() const { return aFtnInfo; }
+ void SetPageFtnInfo(SwPageFtnInfo& rInf) { aFtnInfo = rInf; }
+};
+
+class SW_DLLPUBLIC SwPtrItem : public SfxPoolItem
+{
+ void* pMisc;
+
+public:
+ SwPtrItem( const sal_uInt16 nId = FN_PARAM_GRF_DIALOG, void* pPtr = 0);
+ SwPtrItem( const SwPtrItem& rItem );
+
+ virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
+ virtual bool operator==( const SfxPoolItem& ) const;
+
+ void SetValue(void * pPtr) { pMisc= pPtr; }
+ void* GetValue() const { return pMisc; }
+};
+
+class SW_DLLPUBLIC SwUINumRuleItem : public SfxPoolItem
+{
+ SwNumRule* pRule;
+
+public:
+ SwUINumRuleItem( const SwNumRule& rRule, const sal_uInt16 = FN_PARAM_ACT_NUMBER);
+ SwUINumRuleItem( const SwUINumRuleItem& rItem );
+ virtual ~SwUINumRuleItem();
+
+ virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
+ virtual bool operator==( const SfxPoolItem& ) const;
+
+ virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const;
+ virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 );
+
+ const SwNumRule* GetNumRule() const { return pRule; }
+ SwNumRule* GetNumRule() { return pRule; }
+};
+
+class SwBackgroundDestinationItem : public SfxUInt16Item
+{
+public:
+ SwBackgroundDestinationItem(sal_uInt16 nWhich, sal_uInt16 nValue);
+
+ virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
+};
+
+class SW_DLLPUBLIC SwPaMItem : public SfxPoolItem
+{
+ SwPaM* m_pPaM;
+
+public:
+ SwPaMItem( const sal_uInt16 nId = FN_PARAM_PAM, SwPaM* pPaM = NULL);
+ SwPaMItem( const SwPaMItem& rItem );
+
+ virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
+ virtual bool operator==( const SfxPoolItem& ) const;
+
+ void SetValue(SwPaM * pPaM) { m_pPaM= pPaM; }
+ SwPaM* GetValue() const { return m_pPaM; }
+};
+
+#endif // INCLUDED_SW_SOURCE_UI_INC_UIITEMS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/uinums.hxx b/sw/source/core/uibase/inc/uinums.hxx
new file mode 100644
index 000000000000..a474dbd88bd1
--- /dev/null
+++ b/sw/source/core/uibase/inc/uinums.hxx
@@ -0,0 +1,123 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_UINUMS_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_UINUMS_HXX
+
+#include <numrule.hxx>
+#include "swdllapi.h"
+#include <boost/ptr_container/ptr_vector.hpp>
+
+class SfxPoolItem;
+class SwWrtShell;
+class SvStream;
+
+#define MAX_NUM_RULES 9
+
+typedef boost::ptr_vector<SfxPoolItem> _SwNumFmtsAttrs;
+
+class SW_DLLPUBLIC SwNumRulesWithName
+{
+ OUString maName;
+ // the NumRule's formats _have_ to be independent of a document
+ // (They should always be there!)
+ class SAL_DLLPRIVATE _SwNumFmtGlobal
+ {
+ SwNumFmt aFmt;
+ OUString sCharFmtName;
+ sal_uInt16 nCharPoolId;
+ _SwNumFmtsAttrs aItems;
+
+ _SwNumFmtGlobal& operator=( const _SwNumFmtGlobal& );
+
+ public:
+ _SwNumFmtGlobal( const SwNumFmt& rFmt );
+ _SwNumFmtGlobal( const _SwNumFmtGlobal& );
+ _SwNumFmtGlobal( SvStream&, sal_uInt16 nVersion );
+ ~_SwNumFmtGlobal();
+
+ void Store( SvStream& );
+ void ChgNumFmt( SwWrtShell& rSh, SwNumFmt& rChg ) const;
+ };
+
+ _SwNumFmtGlobal* aFmts[ MAXLEVEL ];
+
+protected:
+ void SetName(const OUString& rSet) {maName = rSet;}
+
+public:
+ SwNumRulesWithName(const SwNumRule &, const OUString &);
+ SwNumRulesWithName( const SwNumRulesWithName & );
+ SwNumRulesWithName(SvStream &, sal_uInt16 nVersion);
+ ~SwNumRulesWithName();
+
+ const SwNumRulesWithName &operator=(const SwNumRulesWithName &);
+
+ const OUString& GetName() const { return maName; }
+ void MakeNumRule( SwWrtShell& rSh, SwNumRule& rChg ) const;
+
+ void Store( SvStream& );
+};
+
+class SwBaseNumRules
+{
+public:
+ enum { nMaxRules = MAX_NUM_RULES }; // currently 9 defined forms
+protected:
+ SwNumRulesWithName *pNumRules[ MAX_NUM_RULES ];
+ OUString sFileName;
+ sal_uInt16 nVersion;
+ sal_Bool bModified;
+
+ virtual int Load(SvStream&);
+ virtual sal_Bool Store(SvStream&);
+
+ void Init();
+
+public:
+ SwBaseNumRules(const OUString& rFileName);
+ virtual ~SwBaseNumRules();
+
+ inline const SwNumRulesWithName* GetRules(sal_uInt16 nIdx) const;
+ virtual void ApplyNumRules(
+ const SwNumRulesWithName &rCopy,
+ sal_uInt16 nIdx);
+
+};
+
+class SwChapterNumRules : public SwBaseNumRules
+{
+
+public:
+ SwChapterNumRules();
+ virtual ~SwChapterNumRules();
+
+ virtual void ApplyNumRules( const SwNumRulesWithName &rCopy,
+ sal_uInt16 nIdx);
+};
+
+// INLINE METHODE --------------------------------------------------------
+inline const SwNumRulesWithName *SwBaseNumRules::GetRules(sal_uInt16 nIdx) const
+{
+ OSL_ENSURE(nIdx < nMaxRules, "Array der NumRules ueberindiziert.");
+ return pNumRules[nIdx];
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/uitool.hxx b/sw/source/core/uibase/inc/uitool.hxx
new file mode 100644
index 000000000000..211af6f33f11
--- /dev/null
+++ b/sw/source/core/uibase/inc/uitool.hxx
@@ -0,0 +1,109 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_UITOOL_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_UITOOL_HXX
+
+#include <tools/wintypes.hxx>
+#include <vcl/field.hxx>
+#include <swtypes.hxx>
+#include "swdllapi.h"
+
+class MetricFormatter;
+class SfxItemSet;
+class SwPageDesc;
+class SvxTabStopItem;
+class SwWrtShell;
+class ListBox;
+class SwDocShell;
+class SwFrmFmt;
+class SwTabCols;
+class DateTime;
+class SfxViewFrame;
+
+// switch a metric
+SW_DLLPUBLIC void SetMetric(MetricFormatter& rCtrl, FieldUnit eUnit);
+
+// fill BoxInfo attribute
+SW_DLLPUBLIC void PrepareBoxInfo(SfxItemSet& rSet, const SwWrtShell& rSh);
+
+// Modes for attribute conversion
+#define CONV_ATTR_STD 1 // Standard character dialog
+#define CONV_ATTR_ENV 2 // Character dialog opened from envelope dialog
+
+/**
+ * Convert character specific attributes to general ones used by tab pages.
+ *
+ * @param[in,out] rSet the set in which character attributes are stored
+ * @param[in] nMode specify the dialog which will be called after conversion
+**/
+SW_DLLPUBLIC void ConvertAttrCharToGen(SfxItemSet& rSet, const sal_uInt8 nMode);
+
+/**
+ * Convert general attributes to the corresponding character attributes.
+ * This method is used after executed a character dialog.
+ *
+ * @param[in,out] rSet the set in which character attributes are stored
+ * @param[in] nMode specify the dialog which was called before
+**/
+SW_DLLPUBLIC void ConvertAttrGenToChar(SfxItemSet& rSet, const sal_uInt8 nMode);
+
+// SfxItemSets <-> PageDesc
+void ItemSetToPageDesc( const SfxItemSet& rSet, SwPageDesc& rPageDesc );
+void PageDescToItemSet( const SwPageDesc& rPageDesc, SfxItemSet& rSet);
+
+// fill tabs with default tabs
+SW_DLLPUBLIC void MakeDefTabs(SwTwips nDefDist, SvxTabStopItem& rTabs);
+
+// erase DefaultTabs from TabStopArray
+//void EraseDefTabs(SvxTabStopItem& rTabs);
+
+// determine space between 1st and 2nd element
+SW_DLLPUBLIC sal_uInt16 GetTabDist(const SvxTabStopItem& rTabs);
+
+// determine whether a Sfx-PageDesc combination exists in the set
+// and set this in the set and delete the transport items
+// (PageBreak & PageModel) from the set
+void SwToSfxPageDescAttr( SfxItemSet& rSet );
+void SfxToSwPageDescAttr( const SwWrtShell& rShell, SfxItemSet& rSet );
+
+SW_DLLPUBLIC FieldUnit GetDfltMetric(sal_Bool bWeb);
+void SetDfltMetric(FieldUnit eMetric, sal_Bool bWeb);
+
+SW_DLLPUBLIC sal_Bool HasCharUnit( sal_Bool bWeb );
+void SetApplyCharUnit(sal_Bool bApplyChar, sal_Bool bWeb);
+
+// ListBox mit allen Zeichenvorlagen fuellen - ausser Standard!
+SW_DLLPUBLIC void FillCharStyleListBox(ListBox& rToFill, SwDocShell* pDocSh, bool bSorted = false, bool bWithDefault = false);
+
+//inserts a string sorted into a ListBox,
+SW_DLLPUBLIC sal_uInt16 InsertStringSorted(const OUString& rEntry, ListBox& rToFill, sal_uInt16 nOffset);
+
+// Get table width and alignement
+SwTwips GetTableWidth( SwFrmFmt* pFmt, SwTabCols& rCols, sal_uInt16 *pPercent,
+ SwWrtShell* pSh );
+
+OUString GetAppLangDateTimeString( const DateTime& );
+
+// search for a command string withing the menu structure and execute it
+// at the dispatcher if there is one, if executed return true
+bool ExecuteMenuCommand( PopupMenu& rMenu, SfxViewFrame& rViewFrame, sal_uInt16 nId );
+
+#endif // INCLUDED_SW_SOURCE_UI_INC_UITOOL_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/uivwimp.hxx b/sw/source/core/uibase/inc/uivwimp.hxx
new file mode 100644
index 000000000000..075dbf626708
--- /dev/null
+++ b/sw/source/core/uibase/inc/uivwimp.hxx
@@ -0,0 +1,173 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_UIVWIMP_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_UIVWIMP_HXX
+
+#include <com/sun/star/embed/XEmbeddedObject.hpp>
+#include <view.hxx>
+
+#include <sfx2/objsh.hxx>
+#include <com/sun/star/view/XSelectionSupplier.hpp>
+#include <com/sun/star/datatransfer/clipboard/XClipboardListener.hpp>
+#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/weakref.hxx>
+
+class SwXTextView;
+class SfxRequest;
+class SwTransferable;
+class SfxRequest;
+
+namespace sfx2 { class DocumentInserter; }
+namespace com{ namespace sun{ namespace star {
+ namespace frame {
+ class XDispatchProviderInterceptor;
+ }
+ namespace lang {
+ class XUnoTunnel;
+ }
+}}}
+
+class SwScannerEventListener : public ::cppu::WeakImplHelper1<
+ ::com::sun::star::lang::XEventListener >
+{
+ SwView* pView;
+
+public:
+
+ SwScannerEventListener( SwView& rView ) : pView( &rView ) {}
+ virtual ~SwScannerEventListener();
+
+ // XEventListener
+ virtual void SAL_CALL disposing(
+ const ::com::sun::star::lang::EventObject& rEventObject ) throw(::com::sun::star::uno::RuntimeException, std::exception);
+
+ void ViewDestroyed() { pView = 0; }
+};
+
+// --------------------------- Clipboard EventListener ------------------
+class SwClipboardChangeListener : public ::cppu::WeakImplHelper1<
+ ::com::sun::star::datatransfer::clipboard::XClipboardListener >
+{
+ SwView* pView;
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& rEventObject )
+ throw ( com::sun::star::uno::RuntimeException, std::exception );
+
+ // XClipboardListener
+ virtual void SAL_CALL changedContents( const ::com::sun::star::datatransfer::clipboard::ClipboardEvent& rEventObject )
+ throw (com::sun::star::uno::RuntimeException,
+ std::exception);
+
+public:
+ SwClipboardChangeListener( SwView& rView ) : pView( &rView ) {}
+ virtual ~SwClipboardChangeListener();
+
+ void ViewDestroyed() { pView = 0; }
+
+ void AddRemoveListener( sal_Bool bAdd );
+};
+
+class SwMailMergeConfigItem;
+
+class SwView_Impl
+{
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > xScanEvtLstnr;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > xClipEvtLstnr;
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor > xDisProvInterceptor;
+ ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionSupplier > *pxXTextView; // UNO object
+ com::sun::star::uno::WeakReference< com::sun::star::lang::XUnoTunnel > xTransferable;
+
+ // temporary document for printing text of selection / multi selection
+ // in PDF export.
+ SfxObjectShellLock xTmpSelDocSh;
+
+ SwView* pView;
+ SwScannerEventListener* pScanEvtLstnr;
+ SwClipboardChangeListener* pClipEvtLstnr;
+ ShellModes eShellMode;
+
+ SwMailMergeConfigItem* pConfigItem;
+ sal_uInt16 nMailMergeRestartPage;
+ sal_Bool bMailMergeSourceView;
+
+ sfx2::DocumentInserter* m_pDocInserter;
+ SfxRequest* m_pRequest;
+ sal_Int16 m_nParam;
+
+ Point m_aEditingPosition;
+ bool m_bSelectObject;
+ bool m_bEditingPositionSet;
+
+public:
+ SwView_Impl(SwView* pShell);
+ ~SwView_Impl();
+
+ void SetShellMode(ShellModes eSet);
+
+ ::com::sun::star::view::XSelectionSupplier* GetUNOObject();
+ SwXTextView* GetUNOObject_Impl();
+ void Invalidate();
+
+ ShellModes GetShellMode() {return eShellMode;}
+
+ void ExecuteScan(SfxRequest& rReq);
+ SwScannerEventListener& GetScannerEventListener();
+
+ void AddClipboardListener();
+
+ SfxObjectShellLock& GetTmpSelectionDoc() { return xTmpSelDocSh; }
+
+ void AddTransferable(SwTransferable& rTransferable);
+
+ void SetMailMergeConfigItem(SwMailMergeConfigItem* pItem,
+ sal_uInt16 nRestart, sal_Bool bIsSource)
+ { pConfigItem = pItem;
+ nMailMergeRestartPage = nRestart;
+ bMailMergeSourceView = bIsSource;
+ }
+ SwMailMergeConfigItem* GetMailMergeConfigItem() {return pConfigItem;}
+ sal_uInt16 GetMailMergeRestartPage() const {return nMailMergeRestartPage;}
+ sal_Bool IsMailMergeSourceView() const { return bMailMergeSourceView; }
+
+ //#i33307# restore editing position
+ void SetRestorePosition(const Point& rCrsrPos, bool bSelectObj)
+ {
+ m_aEditingPosition = rCrsrPos;
+ m_bSelectObject = bSelectObj;
+ m_bEditingPositionSet = true;
+ }
+ bool GetRestorePosition(Point& rCrsrPos, bool& rbSelectObj)
+ {
+ rCrsrPos = m_aEditingPosition;
+ rbSelectObj = m_bSelectObject;
+ return m_bEditingPositionSet;
+ }
+
+ void StartDocumentInserter( const OUString& rFactory, const Link& rEndDialogHdl );
+ SfxMedium* CreateMedium();
+ void InitRequest( const SfxRequest& rRequest );
+
+ inline SfxRequest* GetRequest() const { return m_pRequest; }
+ inline sal_Int16 GetParam() const { return m_nParam; }
+ inline void SetParam( sal_Int16 nParam ) { m_nParam = nParam; }
+};
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/unoatxt.hxx b/sw/source/core/uibase/inc/unoatxt.hxx
new file mode 100644
index 000000000000..3a27de5d55e7
--- /dev/null
+++ b/sw/source/core/uibase/inc/unoatxt.hxx
@@ -0,0 +1,283 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_UNOATXT_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_UNOATXT_HXX
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+#include <com/sun/star/document/XEventsSupplier.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/text/XAutoTextGroup.hpp>
+#include <com/sun/star/text/XAutoTextEntry.hpp>
+#include <com/sun/star/text/XAutoTextContainer2.hpp>
+#include <com/sun/star/text/XText.hpp>
+#include <svl/itemprop.hxx>
+#include <svl/lstner.hxx>
+#include <cppuhelper/implbase2.hxx>
+#include <cppuhelper/implbase5.hxx>
+#include <cppuhelper/implbase6.hxx>
+#include <svtools/unoevent.hxx>
+class SwTextBlocks;
+class SwGlossaries;
+class SwDoc;
+class SwDocShell;
+class SwXBodyText;
+
+#ifndef SW_DECL_SWDOCSHELL_DEFINED
+#define SW_DECL_SWDOCSHELL_DEFINED
+#include <tools/ref.hxx>
+SV_DECL_REF( SwDocShell )
+#endif
+
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ SAL_CALL SwXAutoTextContainer_createInstance(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & ) throw ( ::com::sun::star::uno::Exception );
+
+class SwXAutoTextContainer : public cppu::WeakImplHelper2
+<
+ ::com::sun::star::text::XAutoTextContainer2,
+ ::com::sun::star::lang::XServiceInfo
+>
+{
+ SwGlossaries *pGlossaries;
+
+protected:
+ virtual ~SwXAutoTextContainer(); // ref-counted objects are not to be deleted from outside -> protected dtor
+
+public:
+ SwXAutoTextContainer();
+
+ //XIndexAccess
+ virtual sal_Int32 SAL_CALL getCount( ) throw(::com::sun::star::uno::RuntimeException, std::exception);
+ 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, std::exception );
+
+ //XNameAccess
+ virtual ::com::sun::star::uno::Any SAL_CALL getByName(const OUString& Name) throw( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception );
+ virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getElementNames(void) throw( ::com::sun::star::uno::RuntimeException, std::exception );
+ virtual sal_Bool SAL_CALL hasByName(const OUString& Name) throw( ::com::sun::star::uno::RuntimeException, std::exception );
+
+ //XElementAccess
+ virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException, std::exception);
+ virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException, std::exception);
+
+ //XAutoTextContainer
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XAutoTextGroup > SAL_CALL insertNewByName(const OUString& aGroupName) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException, std::exception );
+ virtual void SAL_CALL removeByName(const OUString& aGroupName) throw( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException, std::exception );
+
+ //XServiceInfo
+ virtual OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException, std::exception );
+ virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException, std::exception );
+ virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException, std::exception );
+
+};
+
+class SwXAutoTextGroup : public cppu::WeakImplHelper6
+<
+ ::com::sun::star::text::XAutoTextGroup,
+ ::com::sun::star::beans::XPropertySet,
+ ::com::sun::star::lang::XServiceInfo,
+ ::com::sun::star::container::XIndexAccess,
+ ::com::sun::star::container::XNamed,
+ ::com::sun::star::lang::XUnoTunnel
+>
+{
+ const SfxItemPropertySet* pPropSet;
+ SwGlossaries* pGlossaries;
+ OUString sName;
+ OUString m_sGroupName; // prefix m_ to disambiguate from some local vars in the implementation
+
+protected:
+ virtual ~SwXAutoTextGroup(); // ref-counted objects are not to be deleted from outside -> protected dtor
+
+public:
+ SwXAutoTextGroup(const OUString& rName, SwGlossaries* pGloss);
+
+ static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId();
+
+ //XUnoTunnel
+ virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException, std::exception);
+
+ //XAutoTextGroup
+ virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getTitles(void) throw( ::com::sun::star::uno::RuntimeException, std::exception );
+ virtual void SAL_CALL renameByName(const OUString& aElementName, const OUString& aNewElementName, const OUString& aNewElementTitle) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::ElementExistException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, std::exception );
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XAutoTextEntry > SAL_CALL insertNewByName(const OUString& aName, const OUString& aTitle, const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange) throw( ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException, std::exception );
+ virtual void SAL_CALL removeByName(const OUString& aEntryName) throw( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException, std::exception );
+
+ //XNamed
+ virtual OUString SAL_CALL getName(void) throw( ::com::sun::star::uno::RuntimeException, std::exception );
+ virtual void SAL_CALL setName(const OUString& Name_) throw( ::com::sun::star::uno::RuntimeException, std::exception );
+
+ //XIndexAccess
+ virtual sal_Int32 SAL_CALL getCount( ) throw(::com::sun::star::uno::RuntimeException, std::exception);
+ 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, std::exception );
+
+ //XNameAccess
+ virtual ::com::sun::star::uno::Any SAL_CALL getByName(const OUString& Name) throw( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception );
+ virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getElementNames(void) throw( ::com::sun::star::uno::RuntimeException, std::exception );
+ virtual sal_Bool SAL_CALL hasByName(const OUString& Name) throw( ::com::sun::star::uno::RuntimeException, std::exception );
+
+ //XElementAccess
+ virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException, std::exception);
+ virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException, std::exception);
+
+ //XServiceInfo
+ virtual OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException, std::exception );
+ virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException, std::exception );
+ virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException, std::exception );
+
+ //XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException, std::exception);
+ virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception);
+ virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception);
+ virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception);
+ virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception);
+ virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception);
+ virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception);
+
+ void Invalidate();
+};
+
+class SwXAutoTextEntry
+ :public SfxListener
+ ,public cppu::WeakImplHelper5
+ <
+ ::com::sun::star::text::XAutoTextEntry,
+ ::com::sun::star::lang::XServiceInfo,
+ ::com::sun::star::lang::XUnoTunnel,
+ ::com::sun::star::text::XText,
+ ::com::sun::star::document::XEventsSupplier
+ >
+{
+ SwGlossaries* pGlossaries;
+ OUString sGroupName;
+ OUString sEntryName;
+ SwDocShellRef xDocSh;
+ SwXBodyText* pBodyText;
+ com::sun::star::uno::Reference < com::sun::star::lang::XServiceInfo> xBodyText;
+
+ void EnsureBodyText ()
+ {
+ if ( !pBodyText )
+ GetBodyText();
+ }
+ void GetBodyText ();
+
+protected:
+ /** ensure that the current content (which may only be in-memory so far) is flushed to the auto text group file
+
+ <p>If somebody modifies an auto text via this class, then this is not directly reflected to the respective
+ glossaries file (on disk), instead we hold a copy of this text (in [p|x]BodyText). On the other hand,
+ in applyTo, we do not work with this _copy_, but just tell the target for the application to insert
+ the content which we're responsible for - and this target doesn't know about our copy, but only
+ about the persistent version.</br>
+ So we need to ensure that before somebody else does something with our auto text, we flush our
+ (in-memory) copy to disk.</p>
+
+ */
+ void implFlushDocument( bool _bCloseDoc = false );
+
+ // SfxListener overridables
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+
+protected:
+ virtual ~SwXAutoTextEntry(); // ref-counted objects are not to be deleted from outside -> protected dtor
+
+public:
+ SwXAutoTextEntry(SwGlossaries* , const OUString& rGroupName, const OUString& rEntryName);
+
+ static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId();
+
+ //XUnoTunnel
+ virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException, std::exception);
+
+ //XText
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > SAL_CALL createTextCursor(void) throw( ::com::sun::star::uno::RuntimeException, std::exception );
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > SAL_CALL createTextCursorByRange(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & aTextPosition) throw( ::com::sun::star::uno::RuntimeException, std::exception );
+ virtual void SAL_CALL insertString(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xRange, const OUString& aString, sal_Bool bAbsorb) throw( ::com::sun::star::uno::RuntimeException, std::exception );
+ virtual void SAL_CALL insertControlCharacter(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xRange, sal_Int16 nControlCharacter, sal_Bool bAbsorb) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception );
+ virtual void SAL_CALL insertTextContent(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xRange, const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > & xContent, sal_Bool bAbsorb) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception );
+ virtual void SAL_CALL removeTextContent(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > & xContent) throw( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException, std::exception);
+
+ //XTextRange
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL getText(void) throw( ::com::sun::star::uno::RuntimeException, std::exception );
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getStart(void) throw( ::com::sun::star::uno::RuntimeException, std::exception );
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getEnd(void) throw( ::com::sun::star::uno::RuntimeException, std::exception );
+ virtual OUString SAL_CALL getString(void) throw( ::com::sun::star::uno::RuntimeException, std::exception );
+ virtual void SAL_CALL setString(const OUString& aString) throw( ::com::sun::star::uno::RuntimeException, std::exception );
+
+ //XAutoTextEntry
+ virtual void SAL_CALL applyTo(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xRange)throw( ::com::sun::star::uno::RuntimeException, std::exception );
+
+ //XServiceInfo
+ virtual OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException, std::exception );
+ virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException, std::exception );
+ virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException, std::exception );
+
+ // XEventsSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameReplace > SAL_CALL getEvents( ) throw( ::com::sun::star::uno::RuntimeException, std::exception );
+
+ void Invalidate() {pGlossaries = 0;}
+ const SwGlossaries* GetGlossaries() { return pGlossaries; }
+ const OUString& GetGroupName() {return sGroupName;}
+ const OUString& GetEntryName() {return sEntryName;}
+};
+
+/** Implement the XNameAccess for the AutoText events */
+class SwAutoTextEventDescriptor : public SvBaseEventDescriptor
+{
+ OUString sSwAutoTextEventDescriptor;
+
+ SwXAutoTextEntry& rAutoTextEntry;
+
+ using SvBaseEventDescriptor::replaceByName;
+ using SvBaseEventDescriptor::getByName;
+
+public:
+ SwAutoTextEventDescriptor( SwXAutoTextEntry& rAutoText );
+
+ ~SwAutoTextEventDescriptor();
+
+ virtual OUString SAL_CALL getImplementationName(void)
+ throw( ::com::sun::star::uno::RuntimeException, std::exception );
+
+protected:
+
+ virtual void replaceByName(
+ const sal_uInt16 nEvent, /// item ID of event
+ const SvxMacro& rMacro) /// event (will be copied)
+ throw(
+ ::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::container::NoSuchElementException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException);
+
+ virtual void getByName(
+ SvxMacro& rMacro, /// macro to be filled
+ const sal_uInt16 nEvent ) /// item ID of event
+ throw(
+ ::com::sun::star::container::NoSuchElementException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/unodispatch.hxx b/sw/source/core/uibase/inc/unodispatch.hxx
new file mode 100644
index 000000000000..f5992c1e0465
--- /dev/null
+++ b/sw/source/core/uibase/inc/unodispatch.hxx
@@ -0,0 +1,128 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_UNODISPATCH_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_UNODISPATCH_HXX
+
+#include <com/sun/star/frame/XDispatchProviderInterception.hpp>
+#include <com/sun/star/frame/XDispatchProviderInterceptor.hpp>
+#include <com/sun/star/view/XSelectionChangeListener.hpp>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <com/sun/star/frame/XDispatch.hpp>
+#include <cppuhelper/implbase2.hxx>
+#include <cppuhelper/implbase3.hxx>
+#include <list>
+#include <comphelper/solarmutex.hxx>
+#include <osl/mutex.hxx>
+
+class SwView;
+
+class SwXDispatchProviderInterceptor : public cppu::WeakImplHelper3
+<
+ ::com::sun::star::frame::XDispatchProviderInterceptor,
+ ::com::sun::star::lang::XEventListener,
+ ::com::sun::star::lang::XUnoTunnel
+>
+{
+ class DispatchMutexLock_Impl
+ {
+ //::osl::MutexGuard aGuard; #102295# solar mutex has to be used currently
+ osl::Guard< comphelper::SolarMutex > aGuard;
+ DispatchMutexLock_Impl();
+ public:
+ DispatchMutexLock_Impl(SwXDispatchProviderInterceptor&);
+ ~DispatchMutexLock_Impl();
+ };
+ friend class DispatchMutexLock_Impl;
+
+// ::osl::Mutex m_aMutex;#102295# solar mutex has to be used currently
+
+ // the component which's dispatches we're intercepting
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterception> m_xIntercepted;
+
+ // chaining
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider> m_xSlaveDispatcher;
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider> m_xMasterDispatcher;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch> m_xDispatch;
+
+ SwView* m_pView;
+
+public:
+ SwXDispatchProviderInterceptor(SwView& rView);
+ ~SwXDispatchProviderInterceptor();
+
+ //XDispatchProvider
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > SAL_CALL queryDispatch( const ::com::sun::star::util::URL& aURL, const OUString& aTargetFrameName, sal_Int32 nSearchFlags ) throw(::com::sun::star::uno::RuntimeException, std::exception);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > > SAL_CALL queryDispatches( const ::com::sun::star::uno::Sequence< ::com::sun::star::frame::DispatchDescriptor >& aDescripts ) throw(::com::sun::star::uno::RuntimeException, std::exception);
+
+ //XDispatchProviderInterceptor
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL getSlaveDispatchProvider( ) throw(::com::sun::star::uno::RuntimeException, std::exception);
+ virtual void SAL_CALL setSlaveDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewDispatchProvider ) throw(::com::sun::star::uno::RuntimeException, std::exception);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL getMasterDispatchProvider( ) throw(::com::sun::star::uno::RuntimeException, std::exception);
+ virtual void SAL_CALL setMasterDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewSupplier ) throw(::com::sun::star::uno::RuntimeException, std::exception);
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException, std::exception);
+
+ //XUnoTunnel
+ static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId();
+ virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException, std::exception);
+
+ // view destroyed
+ void Invalidate();
+};
+
+struct StatusStruct_Impl
+{
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener> xListener;
+ ::com::sun::star::util::URL aURL;
+};
+typedef std::list< StatusStruct_Impl > StatusListenerList;
+class SwXDispatch : public cppu::WeakImplHelper2
+<
+ ::com::sun::star::frame::XDispatch,
+ ::com::sun::star::view::XSelectionChangeListener
+>
+{
+ SwView* m_pView;
+ StatusListenerList m_aListenerList;
+ sal_Bool m_bOldEnable;
+ sal_Bool m_bListenerAdded;
+public:
+ SwXDispatch(SwView& rView);
+ ~SwXDispatch();
+
+ virtual void SAL_CALL dispatch( const ::com::sun::star::util::URL& aURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgs )
+ throw (::com::sun::star::uno::RuntimeException,
+ std::exception);
+ virtual void SAL_CALL addStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& xControl, const ::com::sun::star::util::URL& aURL ) throw(::com::sun::star::uno::RuntimeException, std::exception);
+ virtual void SAL_CALL removeStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& xControl, const ::com::sun::star::util::URL& aURL ) throw(::com::sun::star::uno::RuntimeException, std::exception);
+
+ //XSelectionChangeListener
+ virtual void SAL_CALL selectionChanged( const ::com::sun::star::lang::EventObject& aEvent ) throw(::com::sun::star::uno::RuntimeException, std::exception);
+
+ //XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException, std::exception);
+
+ static const sal_Char* GetDBChangeURL();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/unomailmerge.hxx b/sw/source/core/uibase/inc/unomailmerge.hxx
new file mode 100644
index 000000000000..211c2cbfe41b
--- /dev/null
+++ b/sw/source/core/uibase/inc/unomailmerge.hxx
@@ -0,0 +1,191 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SW_SOURCE_UI_INC_UNOMAILMERGE_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_UNOMAILMERGE_HXX
+
+#include <cppuhelper/implbase6.hxx>
+#include <cppuhelper/interfacecontainer.hxx>
+#include <unotools/configitem.hxx>
+
+#include <com/sun/star/task/XJob.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/beans/PropertyChangeEvent.hpp>
+#include <com/sun/star/text/XMailMergeBroadcaster.hpp>
+#include <com/sun/star/util/XCancellable.hpp>
+#include <svl/itemprop.hxx>
+#include <sfx2/objsh.hxx>
+
+namespace com { namespace sun { namespace star {
+
+ namespace sdbc {
+ class XResultSet;
+ class XConnection;
+ }
+ namespace frame {
+ class XModel;
+ }
+ namespace lang {
+ class XMultiServiceFactory;
+ }
+ namespace text {
+ class XMailMergeListener;
+ struct MailMergeEvent;
+ }
+ namespace beans{
+ struct PropertyValue;
+ }
+
+}}}
+
+// uses templates from <cppuhelper/interfacecontainer.h>
+// and <unotools/configitem.hxx>
+
+// helper function call class
+struct PropHashType_Impl
+{
+ size_t operator()(const sal_Int32 &s) const { return s; }
+};
+
+typedef cppu::OMultiTypeInterfaceContainerHelperVar
+ <
+ sal_Int32,
+ PropHashType_Impl
+ > OPropertyListenerContainerHelper;
+
+class SwNewDBMgr;
+class MailMergeExecuteFinalizer;
+
+class SwXMailMerge :
+ public cppu::WeakImplHelper6
+ <
+ com::sun::star::task::XJob,
+ com::sun::star::util::XCancellable,
+ com::sun::star::beans::XPropertySet,
+ com::sun::star::text::XMailMergeBroadcaster,
+ com::sun::star::lang::XComponent,
+ com::sun::star::lang::XServiceInfo
+ >
+{
+ friend class MailMergeExecuteFinalizer;
+
+ cppu::OInterfaceContainerHelper aEvtListeners;
+ cppu::OInterfaceContainerHelper aMergeListeners;
+ OPropertyListenerContainerHelper aPropListeners;
+
+ const SfxItemPropertySet* pPropSet;
+
+ SfxObjectShellRef xDocSh; // the document
+
+ OUString aTmpFileName;
+
+ // properties of mail merge service
+ com::sun::star::uno::Sequence< com::sun::star::uno::Any > aSelection;
+ com::sun::star::uno::Reference< com::sun::star::sdbc::XResultSet > xResultSet;
+ com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > xConnection;
+ com::sun::star::uno::Reference< com::sun::star::frame::XModel > xModel;
+ OUString aDataSourceName;
+ OUString aDataCommand;
+ OUString aFilter;
+ OUString aDocumentURL;
+ OUString aOutputURL;
+ OUString aFileNamePrefix;
+ sal_Int32 nDataCommandType;
+ sal_Int16 nOutputType;
+ sal_Bool bEscapeProcessing;
+ sal_Bool bSinglePrintJobs;
+ sal_Bool bFileNameFromColumn;
+
+ OUString sInServerPassword;
+ OUString sOutServerPassword;
+ OUString sSubject;
+ OUString sAddressFromColumn;
+ OUString sMailBody;
+ OUString sAttachmentName;
+ OUString sAttachmentFilter;
+ com::sun::star::uno::Sequence< OUString > aCopiesTo;
+ com::sun::star::uno::Sequence< OUString > aBlindCopiesTo;
+ sal_Bool bSendAsHTML;
+ sal_Bool bSendAsAttachment;
+
+ com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aPrintSettings;
+
+ sal_Bool bSaveAsSingleFile;
+ OUString sSaveFilter;
+ OUString sSaveFilterOptions;
+ com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aSaveFilterData;
+
+ sal_Bool bDisposing;
+ SwNewDBMgr *m_pMgr;
+
+ void launchEvent( const com::sun::star::beans::PropertyChangeEvent &rEvt ) const;
+
+ // disallow use of copy-constructor and assignment-operator for now
+ SwXMailMerge( const SwXMailMerge & );
+ SwXMailMerge & operator = ( const SwXMailMerge & );
+protected:
+ virtual ~SwXMailMerge();
+public:
+ SwXMailMerge();
+
+ void LaunchMailMergeEvent( const com::sun::star::text::MailMergeEvent &rData ) const;
+
+ // XJob
+ virtual ::com::sun::star::uno::Any SAL_CALL execute( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& Arguments )
+ throw (::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::uno::Exception,
+ ::com::sun::star::uno::RuntimeException,
+ std::exception);
+
+ // XCancellable
+ virtual void SAL_CALL cancel() throw (com::sun::star::uno::RuntimeException, std::exception);
+
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw (::com::sun::star::uno::RuntimeException, std::exception);
+ virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception);
+ virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception);
+ virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception);
+ virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception);
+ virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception);
+ virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception);
+
+ // XMailMergeBroadcaster
+ virtual void SAL_CALL addMailMergeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XMailMergeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException, std::exception);
+ virtual void SAL_CALL removeMailMergeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XMailMergeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException, std::exception);
+
+ // XComponent
+ virtual void SAL_CALL dispose( ) throw (::com::sun::star::uno::RuntimeException, std::exception);
+ virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException, std::exception);
+ virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException, std::exception);
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException, std::exception);
+ virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException, std::exception);
+ virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException, std::exception);
+};
+
+extern com::sun::star::uno::Sequence< OUString > SAL_CALL SwXMailMerge_getSupportedServiceNames() throw();
+extern OUString SAL_CALL SwXMailMerge_getImplementationName() throw();
+extern com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL SwXMailMerge_createInstance(const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > & rSMgr) throw( com::sun::star::uno::Exception );
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/unomod.hxx b/sw/source/core/uibase/inc/unomod.hxx
new file mode 100644
index 000000000000..1d1c8823eb7c
--- /dev/null
+++ b/sw/source/core/uibase/inc/unomod.hxx
@@ -0,0 +1,161 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_UNOMOD_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_UNOMOD_HXX
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/view/XPrintSettingsSupplier.hpp>
+#include <com/sun/star/view/XViewSettingsSupplier.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <cppuhelper/implbase2.hxx>
+#include <cppuhelper/implbase3.hxx>
+#include <comphelper/ChainablePropertySet.hxx>
+#include <comphelper/SettingsHelper.hxx>
+#include <usrpref.hxx>
+
+class SwView;
+class SwViewOption;
+class SwPrintData;
+class SwDoc;
+
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL SwXModule_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & );
+
+class SwXModule : public cppu::WeakImplHelper3
+<
+ ::com::sun::star::view::XViewSettingsSupplier,
+ ::com::sun::star::view::XPrintSettingsSupplier,
+ ::com::sun::star::lang::XServiceInfo
+>
+{
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > * pxViewSettings;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > * pxPrintSettings;
+
+protected:
+ virtual ~SwXModule();
+public:
+ SwXModule();
+
+ //XViewSettings
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL getViewSettings(void)
+ throw( ::com::sun::star::uno::RuntimeException, std::exception );
+
+ //XPrintSettings
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL getPrintSettings(void)
+ throw( ::com::sun::star::uno::RuntimeException, std::exception );
+
+ //XServiceInfo
+ virtual OUString SAL_CALL getImplementationName(void)
+ throw( ::com::sun::star::uno::RuntimeException, std::exception );
+ virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName)
+ throw( ::com::sun::star::uno::RuntimeException, std::exception );
+ virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames(void)
+ throw( ::com::sun::star::uno::RuntimeException, std::exception );
+};
+
+enum SwXPrintSettingsType
+{
+ PRINT_SETTINGS_MODULE,
+ PRINT_SETTINGS_WEB,
+ PRINT_SETTINGS_DOCUMENT
+};
+
+class SwXPrintSettings : public comphelper::ChainableHelperNoState
+{
+ friend class SwXDocumentSettings;
+protected:
+ SwXPrintSettingsType meType;
+ SwPrintData * mpPrtOpt;
+ SwDoc *mpDoc;
+
+ virtual void _preSetValues ()
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException );
+ virtual void _setSingleValue( const comphelper::PropertyInfo & rInfo, const ::com::sun::star::uno::Any &rValue )
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException );
+ virtual void _postSetValues ()
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException );
+
+ virtual void _preGetValues ()
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException );
+ virtual void _getSingleValue( const comphelper::PropertyInfo & rInfo, ::com::sun::star::uno::Any & rValue )
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException );
+ virtual void _postGetValues ()
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException );
+
+ virtual ~SwXPrintSettings()
+ throw();
+public:
+ SwXPrintSettings( SwXPrintSettingsType eType, SwDoc * pDoc = NULL );
+
+ //XServiceInfo
+ virtual OUString SAL_CALL getImplementationName(void)
+ throw( ::com::sun::star::uno::RuntimeException, std::exception );
+ virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName)
+ throw( ::com::sun::star::uno::RuntimeException, std::exception );
+ virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames(void)
+ throw( ::com::sun::star::uno::RuntimeException, std::exception );
+};
+
+class SwXViewSettings : public comphelper::ChainableHelperNoState
+{
+
+ friend class SwXDocumentSettings;
+protected:
+ SwView* pView;
+ SwViewOption* mpViewOption;
+ const SwViewOption* mpConstViewOption;
+ sal_Bool bObjectValid:1, bWeb:1, mbApplyZoom;
+
+ sal_Int32 eHRulerUnit;
+ sal_Bool mbApplyHRulerMetric;
+ sal_Int32 eVRulerUnit;
+ sal_Bool mbApplyVRulerMetric;
+
+ virtual void _preSetValues ()
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException );
+ virtual void _setSingleValue( const comphelper::PropertyInfo & rInfo, const ::com::sun::star::uno::Any &rValue )
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException );
+ virtual void _postSetValues ()
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException );
+
+ virtual void _preGetValues ()
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException );
+ virtual void _getSingleValue( const comphelper::PropertyInfo & rInfo, ::com::sun::star::uno::Any & rValue )
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException );
+ virtual void _postGetValues ()
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException );
+
+ virtual ~SwXViewSettings()
+ throw();
+public:
+ SwXViewSettings(sal_Bool bWeb, SwView* pView);
+
+ //XServiceInfo
+ virtual OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException, std::exception );
+ virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException, std::exception );
+ virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException, std::exception );
+
+ sal_Bool IsValid() const {return bObjectValid;}
+ void Invalidate() {bObjectValid = sal_False;}
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/unotools.hxx b/sw/source/core/uibase/inc/unotools.hxx
new file mode 100644
index 000000000000..0b85820a62bb
--- /dev/null
+++ b/sw/source/core/uibase/inc/unotools.hxx
@@ -0,0 +1,121 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_UNOTOOLS_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_UNOTOOLS_HXX
+
+#include <vcl/button.hxx>
+#include <vcl/edit.hxx>
+#include <vcl/dialog.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/layout.hxx>
+#include <actctrl.hxx>
+#include <com/sun/star/frame/XController.hpp>
+#include <com/sun/star/text/XTextCursor.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/awt/XControl.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+#include <tools/resary.hxx>
+#include "swdllapi.h"
+
+class SwOneExampleFrame;
+
+class SwFrmCtrlWindow : public VclEventBox
+{
+ SwOneExampleFrame* pExampleFrame;
+public:
+ SwFrmCtrlWindow(Window* pParent, SwOneExampleFrame* pFrame);
+
+ virtual void Command( const CommandEvent& rCEvt );
+ virtual Size GetOptimalSize() const;
+ virtual void Resize();
+};
+
+class MenuResource : public Resource
+{
+ ResStringArray aMenuArray;
+
+public:
+ MenuResource(const ResId& rResId);
+
+ ResStringArray& GetMenuArray() {return aMenuArray;}
+};
+
+#define EX_SHOW_ONLINE_LAYOUT 0x001
+
+// hard zoom value
+#define EX_SHOW_BUSINESS_CARDS 0x02
+//don't modify page size
+#define EX_SHOW_DEFAULT_PAGE 0x04
+
+class SwView;
+
+class SW_DLLPUBLIC SwOneExampleFrame
+{
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > _xControl;
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > _xModel;
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > _xController;
+ ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > _xCursor;
+
+ SwFrmCtrlWindow aTopWindow;
+ Timer aLoadedTimer;
+ Link aInitializedLink;
+
+ MenuResource aMenuRes;
+ OUString sArgumentURL;
+
+ SwView* pModuleView;
+
+ sal_uInt32 nStyleFlags;
+
+ sal_Bool bIsInitialized;
+ sal_Bool bServiceAvailable;
+
+ static bool bShowServiceNotAvailableMessage;
+
+ SAL_DLLPRIVATE DECL_LINK( TimeoutHdl, Timer* );
+ SAL_DLLPRIVATE DECL_LINK( PopupHdl, Menu* );
+
+ SAL_DLLPRIVATE void CreateControl();
+ SAL_DLLPRIVATE void DisposeControl();
+
+public:
+ SwOneExampleFrame(Window& rWin,
+ sal_uInt32 nStyleFlags = EX_SHOW_ONLINE_LAYOUT,
+ const Link* pInitalizedLink = 0,
+ OUString* pURL = 0);
+ ~SwOneExampleFrame();
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > & GetControl() {return _xControl; }
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & GetModel() {return _xModel;}
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > & GetController() {return _xController;}
+ ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > & GetTextCursor() {return _xCursor;}
+
+ void ClearDocument( sal_Bool bStartTimer = sal_False );
+
+ sal_Bool IsInitialized() const {return bIsInitialized;}
+ sal_Bool IsServiceAvailable() const {return bServiceAvailable;}
+
+ void CreatePopup(const Point& rPt);
+
+ static void CreateErrorMessage(Window* pParent);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/unotxvw.hxx b/sw/source/core/uibase/inc/unotxvw.hxx
new file mode 100644
index 000000000000..76f370ca1eba
--- /dev/null
+++ b/sw/source/core/uibase/inc/unotxvw.hxx
@@ -0,0 +1,338 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_UNOTXVW_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_UNOTXVW_HXX
+#include <sfx2/sfxbasecontroller.hxx>
+#include <cppuhelper/interfacecontainer.hxx>
+#include <com/sun/star/embed/XEmbeddedObject.hpp>
+#include <com/sun/star/text/XTextViewCursor.hpp>
+#include <com/sun/star/text/XTextViewCursorSupplier.hpp>
+#include <com/sun/star/text/XRubySelection.hpp>
+#include <com/sun/star/view/XFormLayerAccess.hpp>
+#include <com/sun/star/view/XScreenCursor.hpp>
+#include <com/sun/star/view/XViewSettingsSupplier.hpp>
+#include <com/sun/star/view/XSelectionSupplier.hpp>
+#include <com/sun/star/view/XLineCursor.hpp>
+#include <com/sun/star/view/XViewCursor.hpp>
+#include <com/sun/star/text/XPageCursor.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/XPropertySetInfo.hpp>
+#include <com/sun/star/beans/XPropertyState.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/datatransfer/XTransferableSupplier.hpp>
+#include <cppuhelper/implbase8.hxx>
+#include <svl/itemprop.hxx>
+#include "calbck.hxx"
+#include "TextCursorHelper.hxx"
+#include <comphelper/uno3.hxx>
+
+#include <sfx2/objsh.hxx>
+
+class SdrObject;
+class SwView;
+
+class SwXTextView :
+ public ::com::sun::star::view::XSelectionSupplier,
+ public ::com::sun::star::lang::XServiceInfo,
+ public ::com::sun::star::view::XFormLayerAccess,
+ public ::com::sun::star::text::XTextViewCursorSupplier,
+ public ::com::sun::star::text::XRubySelection,
+ public ::com::sun::star::view::XViewSettingsSupplier,
+ public ::com::sun::star::beans::XPropertySet,
+ public ::com::sun::star::datatransfer::XTransferableSupplier,
+ public SfxBaseController
+{
+ ::cppu::OInterfaceContainerHelper m_SelChangedListeners;
+
+ SwView* m_pView;
+ const SfxItemPropertySet* m_pPropSet; // property map for SwXTextView properties
+ // (not related to pxViewSettings!)
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > * pxViewSettings;
+ ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextViewCursor > * pxTextViewCursor;
+
+ SdrObject* GetControl(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > & Model,
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& xToFill );
+
+protected:
+ virtual ~SwXTextView();
+public:
+ SwXTextView(SwView* pSwView);
+
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw(::com::sun::star::uno::RuntimeException, std::exception);
+ virtual void SAL_CALL acquire( ) throw();
+ virtual void SAL_CALL release( ) throw();
+
+ //XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException, std::exception);
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException, std::exception);
+
+ //XSelectionSupplier
+ virtual ::com::sun::star::uno::Any SAL_CALL getSelection()
+ throw (::com::sun::star::uno::RuntimeException,
+ std::exception);
+ virtual sal_Bool SAL_CALL select(const ::com::sun::star::uno::Any& rInterface)
+ throw (::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::uno::RuntimeException,
+ std::exception);
+ virtual void SAL_CALL addSelectionChangeListener(const ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionChangeListener > & xListener) throw( ::com::sun::star::uno::RuntimeException, std::exception );
+ virtual void SAL_CALL removeSelectionChangeListener(const ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionChangeListener > & xListener) throw( ::com::sun::star::uno::RuntimeException, std::exception );
+
+ // XFormLayerAccess
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > SAL_CALL getFormController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& Form ) throw (::com::sun::star::uno::RuntimeException, std::exception);
+ virtual ::sal_Bool SAL_CALL isFormDesignMode( ) throw (::com::sun::star::uno::RuntimeException, std::exception);
+ virtual void SAL_CALL setFormDesignMode( ::sal_Bool DesignMode ) throw (::com::sun::star::uno::RuntimeException, std::exception);
+
+ // XControlAccess
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > SAL_CALL getControl(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > & Model) throw( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException, std::exception );
+
+ //XTextViewCursorSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextViewCursor > SAL_CALL getViewCursor(void) throw( ::com::sun::star::uno::RuntimeException, std::exception );
+
+ //XViewSettings
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL getViewSettings(void) throw( ::com::sun::star::uno::RuntimeException, std::exception );
+
+ //XRubySelection
+ virtual ::com::sun::star::uno::Sequence<
+ ::com::sun::star::uno::Sequence<
+ ::com::sun::star::beans::PropertyValue > > SAL_CALL getRubyList( sal_Bool bAutomatic )
+ throw (::com::sun::star::uno::RuntimeException,
+ std::exception);
+
+ virtual void SAL_CALL setRubyList(
+ const ::com::sun::star::uno::Sequence<
+ ::com::sun::star::uno::Sequence<
+ ::com::sun::star::beans::PropertyValue > >& RubyList, sal_Bool bAutomatic )
+ throw (::com::sun::star::uno::RuntimeException,
+ std::exception);
+
+ //XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw (::com::sun::star::uno::RuntimeException, std::exception);
+ virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception);
+ virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName )
+ throw (::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException,
+ std::exception);
+ virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception);
+ virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception);
+ virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception);
+ virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception);
+
+ //XServiceInfo
+ virtual OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException, std::exception );
+ virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException, std::exception );
+ virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException, std::exception );
+
+ //XTransferableSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > SAL_CALL getTransferable( )
+ throw (::com::sun::star::uno::RuntimeException,
+ std::exception);
+ virtual void SAL_CALL insertTransferable( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& xTrans ) throw (::com::sun::star::datatransfer::UnsupportedFlavorException, ::com::sun::star::uno::RuntimeException, std::exception);
+
+ void NotifySelChanged();
+ void NotifyDBChanged();
+
+ SwView* GetView() {return m_pView;}
+ void Invalidate();
+
+ // temporary document used for PDF export of selections/multi-selections
+ SfxObjectShellLock BuildTmpSelectionDoc();
+};
+
+typedef cppu::WeakImplHelper8<
+ ::com::sun::star::text::XTextViewCursor,
+ ::com::sun::star::lang::XServiceInfo,
+ ::com::sun::star::text::XPageCursor,
+ ::com::sun::star::view::XScreenCursor,
+ ::com::sun::star::view::XViewCursor,
+ ::com::sun::star::view::XLineCursor,
+ ::com::sun::star::beans::XPropertySet,
+ ::com::sun::star::beans::XPropertyState
+ > SwXTextViewCursor_Base;
+
+class SwXTextViewCursor : public SwXTextViewCursor_Base,
+public SwClient,
+public OTextCursorHelper
+{
+ SwView* m_pView;
+ const SfxItemPropertySet* m_pPropSet;
+protected:
+ sal_Bool IsTextSelection( sal_Bool bAllowTables = sal_True ) const;
+ virtual ~SwXTextViewCursor();
+public:
+ SwXTextViewCursor(SwView* pVw);
+
+ DECLARE_XINTERFACE()
+
+ //XTextViewCursor
+ virtual sal_Bool SAL_CALL isVisible(void) throw( ::com::sun::star::uno::RuntimeException, std::exception );
+ virtual void SAL_CALL setVisible(sal_Bool bVisible) throw( ::com::sun::star::uno::RuntimeException, std::exception );
+ virtual ::com::sun::star::awt::Point SAL_CALL getPosition(void) throw( ::com::sun::star::uno::RuntimeException, std::exception );
+
+ //XTextCursor - neu
+ virtual void SAL_CALL collapseToStart()
+ throw (::com::sun::star::uno::RuntimeException,
+ std::exception);
+ virtual void SAL_CALL collapseToEnd()
+ throw (::com::sun::star::uno::RuntimeException,
+ std::exception);
+ virtual sal_Bool SAL_CALL isCollapsed()
+ throw (::com::sun::star::uno::RuntimeException,
+ std::exception);
+ virtual sal_Bool SAL_CALL goLeft( sal_Int16 nCount, sal_Bool bExpand )
+ throw (::com::sun::star::uno::RuntimeException,
+ std::exception);
+ virtual sal_Bool SAL_CALL goRight( sal_Int16 nCount, sal_Bool bExpand )
+ throw (::com::sun::star::uno::RuntimeException,
+ std::exception);
+ virtual void SAL_CALL gotoStart( sal_Bool bExpand )
+ throw (::com::sun::star::uno::RuntimeException,
+ std::exception);
+ virtual void SAL_CALL gotoEnd( sal_Bool bExpand )
+ throw (::com::sun::star::uno::RuntimeException,
+ std::exception);
+ virtual void SAL_CALL gotoRange( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >& xRange, sal_Bool bExpand )
+ throw (::com::sun::star::uno::RuntimeException,
+ std::exception);
+
+ //XPageCursor
+ virtual sal_Bool SAL_CALL jumpToFirstPage()
+ throw (::com::sun::star::uno::RuntimeException,
+ std::exception);
+ virtual sal_Bool SAL_CALL jumpToLastPage()
+ throw (::com::sun::star::uno::RuntimeException,
+ std::exception);
+ virtual sal_Bool SAL_CALL jumpToPage(sal_Int16 nPage) throw( ::com::sun::star::uno::RuntimeException, std::exception );
+ virtual sal_Bool SAL_CALL jumpToNextPage(void) throw( ::com::sun::star::uno::RuntimeException, std::exception );
+ virtual sal_Bool SAL_CALL jumpToPreviousPage(void) throw( ::com::sun::star::uno::RuntimeException, std::exception );
+ virtual sal_Bool SAL_CALL jumpToEndOfPage(void) throw( ::com::sun::star::uno::RuntimeException, std::exception );
+ virtual sal_Bool SAL_CALL jumpToStartOfPage(void) throw( ::com::sun::star::uno::RuntimeException, std::exception );
+ virtual sal_Int16 SAL_CALL getPage()
+ throw (::com::sun::star::uno::RuntimeException,
+ std::exception);
+
+ //XTextRange
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL getText()
+ throw (::com::sun::star::uno::RuntimeException,
+ std::exception);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getStart()
+ throw (::com::sun::star::uno::RuntimeException,
+ std::exception);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getEnd()
+ throw (::com::sun::star::uno::RuntimeException,
+ std::exception);
+ virtual OUString SAL_CALL getString()
+ throw (::com::sun::star::uno::RuntimeException,
+ std::exception);
+ virtual void SAL_CALL setString(const OUString& aString)
+ throw (::com::sun::star::uno::RuntimeException,
+ std::exception);
+
+ //XScreenCursor
+ virtual sal_Bool SAL_CALL screenDown()
+ throw (::com::sun::star::uno::RuntimeException,
+ std::exception);
+ virtual sal_Bool SAL_CALL screenUp()
+ throw (::com::sun::star::uno::RuntimeException,
+ std::exception);
+
+ //XViewCursor
+ virtual sal_Bool SAL_CALL goDown(sal_Int16 nCount, sal_Bool bExpand)
+ throw (::com::sun::star::uno::RuntimeException,
+ std::exception);
+ virtual sal_Bool SAL_CALL goUp(sal_Int16 nCount, sal_Bool bExpand)
+ throw (::com::sun::star::uno::RuntimeException,
+ std::exception);
+
+ //XLineCursor
+ virtual sal_Bool SAL_CALL isAtStartOfLine()
+ throw (::com::sun::star::uno::RuntimeException,
+ std::exception);
+ virtual sal_Bool SAL_CALL isAtEndOfLine()
+ throw (::com::sun::star::uno::RuntimeException,
+ std::exception);
+ virtual void SAL_CALL gotoEndOfLine(sal_Bool bExpand)
+ throw (::com::sun::star::uno::RuntimeException,
+ std::exception);
+ virtual void SAL_CALL gotoStartOfLine(sal_Bool bExpand)
+ throw (::com::sun::star::uno::RuntimeException,
+ std::exception);
+
+ //XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException, std::exception);
+ virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue )
+ throw (::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::beans::PropertyVetoException,
+ ::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException,
+ std::exception);
+ virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName )
+ throw (::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException,
+ std::exception);
+ virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception);
+ virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception);
+ virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception);
+ virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception);
+
+ //XPropertyState
+ virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const OUString& PropertyName )
+ throw (::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::uno::RuntimeException,
+ std::exception);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL getPropertyStates( const ::com::sun::star::uno::Sequence< OUString >& aPropertyName )
+ throw (::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::uno::RuntimeException,
+ std::exception);
+ virtual void SAL_CALL setPropertyToDefault( const OUString& PropertyName )
+ throw (::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::uno::RuntimeException,
+ std::exception);
+ virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( const OUString& aPropertyName )
+ throw (::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException,
+ std::exception);
+
+ //XServiceInfo
+ virtual OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException, std::exception );
+ virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException, std::exception );
+ virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException, std::exception );
+
+ static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId();
+
+ //XUnoTunnel
+ virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException, std::exception);
+
+ void Invalidate(){m_pView = 0;}
+
+ // ITextCursorHelper
+ virtual const SwPaM* GetPaM() const;
+ virtual SwPaM* GetPaM();
+ virtual const SwDoc* GetDoc() const;
+ virtual SwDoc* GetDoc();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/usrpref.hxx b/sw/source/core/uibase/inc/usrpref.hxx
new file mode 100644
index 000000000000..9169166c5a6b
--- /dev/null
+++ b/sw/source/core/uibase/inc/usrpref.hxx
@@ -0,0 +1,276 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_USRPREF_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_USRPREF_HXX
+
+#include <unotools/configitem.hxx>
+#include <fldupde.hxx>
+#include "viewopt.hxx"
+#include <tools/fldunit.hxx>
+
+class SwMasterUsrPref;
+
+class SwContentViewConfig : public utl::ConfigItem
+{
+ SwMasterUsrPref& rParent;
+ sal_Bool bWeb;
+
+ com::sun::star::uno::Sequence<OUString> GetPropertyNames();
+ public:
+ SwContentViewConfig(sal_Bool bWeb, SwMasterUsrPref& rParent);
+ ~SwContentViewConfig();
+
+ // utl::ConfigItem
+ virtual void Notify( const com::sun::star::uno::Sequence< OUString > &rPropertyNames );
+ virtual void Commit();
+
+ void Load();
+ void SetModified(){ConfigItem::SetModified();}
+};
+
+class SwLayoutViewConfig : public utl::ConfigItem
+{
+ SwMasterUsrPref& rParent;
+ sal_Bool bWeb;
+
+ com::sun::star::uno::Sequence<OUString> GetPropertyNames();
+ public:
+ SwLayoutViewConfig(sal_Bool bWeb, SwMasterUsrPref& rParent);
+ ~SwLayoutViewConfig();
+
+ virtual void Notify( const ::com::sun::star::uno::Sequence< OUString >& aPropertyNames );
+ virtual void Commit();
+ void Load();
+ void SetModified(){ConfigItem::SetModified();}
+};
+
+class SwGridConfig : public utl::ConfigItem
+{
+ SwMasterUsrPref& rParent;
+
+ com::sun::star::uno::Sequence<OUString> GetPropertyNames();
+ public:
+ SwGridConfig(sal_Bool bWeb, SwMasterUsrPref& rParent);
+ ~SwGridConfig();
+
+ virtual void Commit();
+ virtual void Notify( const ::com::sun::star::uno::Sequence< OUString >& aPropertyNames );
+ void Load();
+ void SetModified(){ConfigItem::SetModified();}
+};
+
+class SwCursorConfig : public utl::ConfigItem
+{
+ SwMasterUsrPref& rParent;
+
+ com::sun::star::uno::Sequence<OUString> GetPropertyNames();
+ public:
+ SwCursorConfig(SwMasterUsrPref& rParent);
+ ~SwCursorConfig();
+
+ virtual void Commit();
+ virtual void Notify( const ::com::sun::star::uno::Sequence< OUString >& aPropertyNames );
+ void Load();
+ void SetModified(){ConfigItem::SetModified();}
+};
+
+class SwWebColorConfig : public utl::ConfigItem
+{
+ SwMasterUsrPref& rParent;
+ com::sun::star::uno::Sequence<OUString> aPropNames;
+
+ public:
+ SwWebColorConfig(SwMasterUsrPref& rParent);
+ ~SwWebColorConfig();
+
+ virtual void Commit();
+ virtual void Notify( const ::com::sun::star::uno::Sequence< OUString >& aPropertyNames );
+ void Load();
+ void SetModified(){ConfigItem::SetModified();}
+};
+
+class SwMasterUsrPref : public SwViewOption
+{
+ friend class SwContentViewConfig;
+ friend class SwLayoutViewConfig;
+ friend class SwGridConfig;
+ friend class SwCursorConfig;
+ friend class SwWebColorConfig;
+
+ SwFldUpdateFlags eFldUpdateFlags; //udpate of fields and charts
+ sal_Int32 nLinkUpdateMode;
+ FieldUnit eUserMetric;
+ FieldUnit eHScrollMetric;
+ sal_Bool bIsHScrollMetricSet;
+ FieldUnit eVScrollMetric;
+ sal_Bool bIsVScrollMetricSet;
+
+ sal_Int32 nDefTab; //default tab stop distance
+
+ sal_Bool bIsSquaredPageMode; //default page mode for text grid
+ sal_Bool bIsAlignMathObjectsToBaseline;
+
+ SwContentViewConfig aContentConfig;
+ SwLayoutViewConfig aLayoutConfig;
+ SwGridConfig aGridConfig;
+ SwCursorConfig aCursorConfig;
+ SwWebColorConfig* pWebColorConfig;
+
+ sal_Bool bApplyCharUnit; // apply_char_unit
+public:
+ SwMasterUsrPref(sal_Bool bWeb);
+ ~SwMasterUsrPref();
+
+ void SetUsrPref(const SwViewOption &rCopy);
+
+ void Commit()
+ {
+ aContentConfig.Commit();
+ aLayoutConfig.Commit();
+ aGridConfig.Commit();
+ aCursorConfig.Commit();
+ if(pWebColorConfig)
+ pWebColorConfig->Commit();
+ }
+ void SetModified()
+ {
+ aContentConfig.SetModified();
+ aLayoutConfig.SetModified();
+ aGridConfig.SetModified();
+ aCursorConfig.SetModified();
+ if(pWebColorConfig)
+ pWebColorConfig->SetModified();
+ }
+
+ void SetUpdateLinkMode(sal_Int32 nSet, sal_Bool bNoModify = sal_False)
+ {
+ nLinkUpdateMode = nSet;
+ if(!bNoModify)
+ aContentConfig.SetModified();
+ }
+ sal_Int32 GetUpdateLinkMode() const {return nLinkUpdateMode; }
+
+ void SetUpdateFields(sal_Bool bSet, sal_Bool bNoModify = sal_False)
+ {
+ if(bSet && eFldUpdateFlags == AUTOUPD_OFF)
+ {
+ eFldUpdateFlags = AUTOUPD_FIELD_ONLY;
+ if(!bNoModify)
+ aContentConfig.SetModified();
+ }
+ else if(!bSet)
+ {
+ eFldUpdateFlags = AUTOUPD_OFF;
+ if(!bNoModify)
+ aContentConfig.SetModified();
+ }
+ };
+ sal_Bool IsUpdateFields()const {return eFldUpdateFlags != AUTOUPD_OFF; }
+
+ SwFldUpdateFlags GetFldUpdateFlags()const {return eFldUpdateFlags;}
+ void SetFldUpdateFlags(SwFldUpdateFlags eSet, sal_Bool bNoModify = sal_False)
+ {
+ eFldUpdateFlags = eSet;
+ if(!bNoModify)
+ aContentConfig.SetModified();
+ }
+
+ void SetUpdateCharts(sal_Bool bSet, sal_Bool bNoModify = sal_False)
+ {
+ if(bSet)
+ {
+ eFldUpdateFlags = AUTOUPD_FIELD_AND_CHARTS;
+ if(!bNoModify)
+ aContentConfig.SetModified();
+ }
+ else if(eFldUpdateFlags == AUTOUPD_FIELD_AND_CHARTS)
+ {
+ eFldUpdateFlags = AUTOUPD_FIELD_ONLY;
+ if(!bNoModify)
+ aContentConfig.SetModified();
+ }
+ };
+ sal_Bool IsUpdateCharts()const {return eFldUpdateFlags == AUTOUPD_FIELD_AND_CHARTS; }
+
+ FieldUnit GetMetric() const { return eUserMetric;}
+ void SetMetric(FieldUnit eSet, sal_Bool bNoModify = sal_False)
+ {
+ eUserMetric = eSet;
+ if(!bNoModify)
+ aLayoutConfig.SetModified();
+ }
+
+ sal_Bool IsHScrollMetric()const {return bIsHScrollMetricSet;}
+ FieldUnit GetHScrollMetric() const { return bIsHScrollMetricSet ? eHScrollMetric : eUserMetric;}
+ void SetHScrollMetric(FieldUnit eSet, sal_Bool bNoModify = sal_False)
+ {
+ eHScrollMetric = eSet; bIsHScrollMetricSet = sal_True;
+ if(!bNoModify)
+ aLayoutConfig.SetModified();
+ }
+
+ sal_Bool IsVScrollMetric()const {return bIsVScrollMetricSet;}
+ FieldUnit GetVScrollMetric() const { return bIsVScrollMetricSet ? eVScrollMetric : eUserMetric;}
+ void SetVScrollMetric(FieldUnit eSet, sal_Bool bNoModify = sal_False)
+ {
+ eVScrollMetric = eSet; bIsVScrollMetricSet = sal_True;
+ if(!bNoModify)
+ aLayoutConfig.SetModified();
+ }
+
+ sal_Bool IsApplyCharUnit() const
+ {
+ return bApplyCharUnit;
+ }
+ void SetApplyCharUnit(sal_Bool bSet, sal_Bool bNoModify = sal_False)
+ {
+ bApplyCharUnit = bSet;
+ if(!bNoModify)
+ aLayoutConfig.SetModified();
+ }
+
+ sal_Int32 GetDefTab() const { return nDefTab;}
+ void SetDefTab( sal_Int32 nSet, sal_Bool bNoModify = sal_False )
+ {
+ nDefTab = nSet;
+ if(!bNoModify)
+ aLayoutConfig.SetModified();
+ }
+
+ //default page mode for text grid
+ sal_Bool IsSquaredPageMode() const {return bIsSquaredPageMode;}
+ void SetDefaultPageMode( sal_Bool bVal, sal_Bool bNoModify = sal_False )
+ {
+ bIsSquaredPageMode = bVal;
+ if(!bNoModify)
+ aLayoutConfig.SetModified();
+ }
+
+ sal_Bool IsAlignMathObjectsToBaseline() const { return bIsAlignMathObjectsToBaseline; }
+ void SetAlignMathObjectsToBaseline( sal_Bool bVal, sal_Bool bNoModify = sal_False )
+ {
+ bIsAlignMathObjectsToBaseline = bVal;
+ if(!bNoModify)
+ aLayoutConfig.SetModified();
+ }
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/utlui.hrc b/sw/source/core/uibase/inc/utlui.hrc
new file mode 100644
index 000000000000..774a0b868231
--- /dev/null
+++ b/sw/source/core/uibase/inc/utlui.hrc
@@ -0,0 +1,189 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef _UTLUI_HRC
+#define _UTLUI_HRC
+
+#include "rcid.hrc"
+
+
+#define RID_SW_SHELLRES (RC_UTLUI_BEGIN + 1)
+#define RID_STR_SYSTEM (RC_UTLUI_BEGIN + 2)
+
+
+
+// Strings in NumberFormatter-Listbox
+#define STR_DEFINE_NUMBERFORMAT (RC_UTLUI_BEGIN + 4)
+// hyperlink status bar control
+#define STR_HYPERCTRL_SEL (RC_UTLUI_BEGIN + 5)
+#define STR_HYPERCTRL_HYP (RC_UTLUI_BEGIN + 6)
+
+// names of content types (RC_UTLUI_BEGIN + 7)
+#define STR_CONTENT_TYPE_FIRST (RC_UTLUI_BEGIN + 8)
+#define STR_CONTENT_TYPE_OUTLINE STR_CONTENT_TYPE_FIRST
+#define STR_CONTENT_TYPE_TABLE (RC_UTLUI_BEGIN + 9)
+#define STR_CONTENT_TYPE_FRAME (RC_UTLUI_BEGIN + 10)
+#define STR_CONTENT_TYPE_GRAPHIC (RC_UTLUI_BEGIN + 11)
+#define STR_CONTENT_TYPE_OLE (RC_UTLUI_BEGIN + 12)
+#define STR_CONTENT_TYPE_BOOKMARK (RC_UTLUI_BEGIN + 13)
+#define STR_CONTENT_TYPE_REGION (RC_UTLUI_BEGIN + 14)
+#define STR_CONTENT_TYPE_URLFIELD (RC_UTLUI_BEGIN + 15)
+#define STR_CONTENT_TYPE_REFERENCE (RC_UTLUI_BEGIN + 16)
+#define STR_CONTENT_TYPE_INDEX (RC_UTLUI_BEGIN + 17)
+#define STR_CONTENT_TYPE_POSTIT (RC_UTLUI_BEGIN + 18)
+#define STR_CONTENT_TYPE_DRAWOBJECT (RC_UTLUI_BEGIN + 19)
+#define STR_CONTENT_END (RC_UTLUI_BEGIN + 19)
+
+#define STR_CONTENT_TYPE_SINGLE_FIRST (STR_CONTENT_END + 1)
+#define STR_CONTENT_TYPE_SINGLE_OUTLINE (STR_CONTENT_TYPE_SINGLE_FIRST + 0)
+#define STR_CONTENT_TYPE_SINGLE_TABLE (STR_CONTENT_TYPE_SINGLE_FIRST + 1)
+#define STR_CONTENT_TYPE_SINGLE_FRAME (STR_CONTENT_TYPE_SINGLE_FIRST + 2)
+#define STR_CONTENT_TYPE_SINGLE_GRAPHIC (STR_CONTENT_TYPE_SINGLE_FIRST + 3)
+#define STR_CONTENT_TYPE_SINGLE_OLE (STR_CONTENT_TYPE_SINGLE_FIRST + 4)
+#define STR_CONTENT_TYPE_SINGLE_BOOKMARK (STR_CONTENT_TYPE_SINGLE_FIRST + 5)
+#define STR_CONTENT_TYPE_SINGLE_REGION (STR_CONTENT_TYPE_SINGLE_FIRST + 6)
+#define STR_CONTENT_TYPE_SINGLE_URLFIELD (STR_CONTENT_TYPE_SINGLE_FIRST + 7)
+#define STR_CONTENT_TYPE_SINGLE_REFERENCE (STR_CONTENT_TYPE_SINGLE_FIRST + 8)
+#define STR_CONTENT_TYPE_SINGLE_INDEX (STR_CONTENT_TYPE_SINGLE_FIRST + 9)
+#define STR_CONTENT_TYPE_SINGLE_POSTIT (STR_CONTENT_TYPE_SINGLE_FIRST + 10)
+#define STR_CONTENT_TYPE_SINGLE_DRAWOBJECT (STR_CONTENT_TYPE_SINGLE_FIRST + 11)
+#define STR_CONTENT_SINGLE_END STR_CONTENT_TYPE_SINGLE_DRAWOBJECT
+
+#define FLD_DOCINFO_BEGIN STR_CONTENT_SINGLE_END
+#define FLD_DOCINFO_TITEL FLD_DOCINFO_BEGIN
+#define FLD_DOCINFO_THEMA (FLD_DOCINFO_BEGIN + 1)
+#define FLD_DOCINFO_KEYS (FLD_DOCINFO_BEGIN + 2)
+#define FLD_DOCINFO_COMMENT (FLD_DOCINFO_BEGIN + 3)
+#define FLD_DOCINFO_CREATE (FLD_DOCINFO_BEGIN + 4)
+#define FLD_DOCINFO_CHANGE (FLD_DOCINFO_BEGIN + 5)
+#define FLD_DOCINFO_PRINT (FLD_DOCINFO_BEGIN + 6)
+#define FLD_DOCINFO_DOCNO (FLD_DOCINFO_BEGIN + 7)
+#define FLD_DOCINFO_EDIT (FLD_DOCINFO_BEGIN + 8)
+#define FLD_DOCINFO_END (FLD_DOCINFO_BEGIN + 9)
+
+#define STR_SERVICE_UNAVAILABLE (FLD_DOCINFO_END + 1)
+
+#define STR_AUTH_TYPE_START (FLD_DOCINFO_END + 2)
+#define STR_AUTH_TYPE_ARTICLE (STR_AUTH_TYPE_START + 0)
+#define STR_AUTH_TYPE_BOOK (STR_AUTH_TYPE_START + 1)
+#define STR_AUTH_TYPE_BOOKLET (STR_AUTH_TYPE_START + 2)
+#define STR_AUTH_TYPE_CONFERENCE (STR_AUTH_TYPE_START + 3)
+#define STR_AUTH_TYPE_INBOOK (STR_AUTH_TYPE_START + 4)
+#define STR_AUTH_TYPE_INCOLLECTION (STR_AUTH_TYPE_START + 5)
+#define STR_AUTH_TYPE_INPROCEEDINGS (STR_AUTH_TYPE_START + 6)
+#define STR_AUTH_TYPE_JOURNAL (STR_AUTH_TYPE_START + 7)
+#define STR_AUTH_TYPE_MANUAL (STR_AUTH_TYPE_START + 8)
+#define STR_AUTH_TYPE_MASTERSTHESIS (STR_AUTH_TYPE_START + 9)
+#define STR_AUTH_TYPE_MISC (STR_AUTH_TYPE_START + 10)
+#define STR_AUTH_TYPE_PHDTHESIS (STR_AUTH_TYPE_START + 11)
+#define STR_AUTH_TYPE_PROCEEDINGS (STR_AUTH_TYPE_START + 12)
+#define STR_AUTH_TYPE_TECHREPORT (STR_AUTH_TYPE_START + 13)
+#define STR_AUTH_TYPE_UNPUBLISHED (STR_AUTH_TYPE_START + 14)
+#define STR_AUTH_TYPE_EMAIL (STR_AUTH_TYPE_START + 15)
+#define STR_AUTH_TYPE_WWW (STR_AUTH_TYPE_START + 16)
+#define STR_AUTH_TYPE_CUSTOM1 (STR_AUTH_TYPE_START + 17)
+#define STR_AUTH_TYPE_CUSTOM2 (STR_AUTH_TYPE_START + 18)
+#define STR_AUTH_TYPE_CUSTOM3 (STR_AUTH_TYPE_START + 19)
+#define STR_AUTH_TYPE_CUSTOM4 (STR_AUTH_TYPE_START + 20)
+#define STR_AUTH_TYPE_CUSTOM5 (STR_AUTH_TYPE_START + 21)
+#define STR_AUTH_TYPE_END (STR_AUTH_TYPE_CUSTOM5)
+
+#define STR_AUTH_FIELD_START (STR_AUTH_TYPE_END + 1)
+#define STR_AUTH_FIELD_IDENTIFIER (STR_AUTH_FIELD_START + 0)
+#define STR_AUTH_FIELD_AUTHORITY_TYPE (STR_AUTH_FIELD_START + 1)
+#define STR_AUTH_FIELD_ADDRESS (STR_AUTH_FIELD_START + 2)
+#define STR_AUTH_FIELD_ANNOTE (STR_AUTH_FIELD_START + 3)
+#define STR_AUTH_FIELD_AUTHOR (STR_AUTH_FIELD_START + 4)
+#define STR_AUTH_FIELD_BOOKTITLE (STR_AUTH_FIELD_START + 5)
+#define STR_AUTH_FIELD_CHAPTER (STR_AUTH_FIELD_START + 6)
+#define STR_AUTH_FIELD_EDITION (STR_AUTH_FIELD_START + 7)
+#define STR_AUTH_FIELD_EDITOR (STR_AUTH_FIELD_START + 8)
+#define STR_AUTH_FIELD_HOWPUBLISHED (STR_AUTH_FIELD_START + 9)
+#define STR_AUTH_FIELD_INSTITUTION (STR_AUTH_FIELD_START + 10)
+#define STR_AUTH_FIELD_JOURNAL (STR_AUTH_FIELD_START + 11)
+#define STR_AUTH_FIELD_MONTH (STR_AUTH_FIELD_START + 12)
+#define STR_AUTH_FIELD_NOTE (STR_AUTH_FIELD_START + 13)
+#define STR_AUTH_FIELD_NUMBER (STR_AUTH_FIELD_START + 14)
+#define STR_AUTH_FIELD_ORGANIZATIONS (STR_AUTH_FIELD_START + 15)
+#define STR_AUTH_FIELD_PAGES (STR_AUTH_FIELD_START + 16)
+#define STR_AUTH_FIELD_PUBLISHER (STR_AUTH_FIELD_START + 17)
+#define STR_AUTH_FIELD_SCHOOL (STR_AUTH_FIELD_START + 18)
+#define STR_AUTH_FIELD_SERIES (STR_AUTH_FIELD_START + 19)
+#define STR_AUTH_FIELD_TITLE (STR_AUTH_FIELD_START + 20)
+#define STR_AUTH_FIELD_TYPE (STR_AUTH_FIELD_START + 21)
+#define STR_AUTH_FIELD_VOLUME (STR_AUTH_FIELD_START + 22)
+#define STR_AUTH_FIELD_YEAR (STR_AUTH_FIELD_START + 23)
+#define STR_AUTH_FIELD_URL (STR_AUTH_FIELD_START + 24)
+#define STR_AUTH_FIELD_CUSTOM1 (STR_AUTH_FIELD_START + 25)
+#define STR_AUTH_FIELD_CUSTOM2 (STR_AUTH_FIELD_START + 26)
+#define STR_AUTH_FIELD_CUSTOM3 (STR_AUTH_FIELD_START + 27)
+#define STR_AUTH_FIELD_CUSTOM4 (STR_AUTH_FIELD_START + 28)
+#define STR_AUTH_FIELD_CUSTOM5 (STR_AUTH_FIELD_START + 29)
+#define STR_AUTH_FIELD_ISBN (STR_AUTH_FIELD_START + 30)
+#define STR_AUTH_FIELD_END (STR_AUTH_FIELD_ISBN)
+
+
+#define RES_FRMEX_MENU (STR_AUTH_FIELD_END + 1)
+
+#define DLG_NAVIGATION_PI (RC_UTLUI_BEGIN + 1)
+#define DLG_GLOSSARY_DECIDE_DLG (RC_UTLUI_BEGIN + 3)
+
+#define IMG_NAVI_ENTRYBMP (RC_UTLUI_BEGIN + 4)
+#define ILIST_DB_DLG (RC_UTLUI_BEGIN + 6)
+
+#define IMG_VIEWLAYOUT_AUTOMATIC (RC_UTLUI_BEGIN + 12)
+#define IMG_VIEWLAYOUT_AUTOMATIC_ACTIVE (RC_UTLUI_BEGIN + 13)
+#define IMG_VIEWLAYOUT_BOOKMODE (RC_UTLUI_BEGIN + 14)
+#define IMG_VIEWLAYOUT_BOOKMODE_ACTIVE (RC_UTLUI_BEGIN + 15)
+#define IMG_VIEWLAYOUT_SINGLECOLUMN (RC_UTLUI_BEGIN + 16)
+#define IMG_VIEWLAYOUT_SINGLECOLUMN_ACTIVE (RC_UTLUI_BEGIN + 17)
+#define IMG_PAGE_BREAK (RC_UTLUI_BEGIN + 18)
+
+
+//local ids of the Database ImageLists
+#define IMG_COLLAPSE 18002 /*RID_SVXIMG_COLLAPSEDNODE*/
+#define IMG_EXPAND 18003 /*RID_SVXIMG_EXPANDEDNODE*/
+#define IMG_DB 1
+#define IMG_DBTABLE 2
+#define IMG_DBQUERY 3
+
+#define UTLUI_ACT_END RES_FRMEX_MENU
+
+#if UTLUI_ACT_END > RC_UTLUI_END
+#error Resource-Id Ueberlauf in #file, #line
+#endif
+
+#define STR_IDXEXAMPLE_IDXTXT_BEGIN RC_IDXTXT_BEGIN
+#define STR_IDXEXAMPLE_IDXTXT_HEADING1 (STR_IDXEXAMPLE_IDXTXT_BEGIN + 1)
+#define STR_IDXEXAMPLE_IDXTXT_ENTRY1 (STR_IDXEXAMPLE_IDXTXT_BEGIN + 2)
+#define STR_IDXEXAMPLE_IDXTXT_HEADING11 (STR_IDXEXAMPLE_IDXTXT_BEGIN + 3)
+#define STR_IDXEXAMPLE_IDXTXT_ENTRY11 (STR_IDXEXAMPLE_IDXTXT_BEGIN + 4)
+#define STR_IDXEXAMPLE_IDXTXT_HEADING12 (STR_IDXEXAMPLE_IDXTXT_BEGIN + 5)
+#define STR_IDXEXAMPLE_IDXTXT_ENTRY12 (STR_IDXEXAMPLE_IDXTXT_BEGIN + 6)
+#define STR_IDXEXAMPLE_IDXTXT_TABLE1 (STR_IDXEXAMPLE_IDXTXT_BEGIN + 7)
+#define STR_IDXEXAMPLE_IDXTXT_IMAGE1 (STR_IDXEXAMPLE_IDXTXT_BEGIN + 8)
+#define STR_IDXEXAMPLE_IDXTXT_END STR_IDXEXAMPLE_IDXTXT_IMAGE1
+
+#if STR_IDXEXAMPLE_IDXTXT_END > RC_IDXTXT_END
+#error Resource-Id Ueberlauf in #file, #line
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/view.hxx b/sw/source/core/uibase/inc/view.hxx
new file mode 100644
index 000000000000..91733d3da373
--- /dev/null
+++ b/sw/source/core/uibase/inc/view.hxx
@@ -0,0 +1,689 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_VIEW_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_VIEW_HXX
+
+#include <vcl/timer.hxx>
+#include <vcl/field.hxx>
+#include <vcl/floatwin.hxx>
+#include <svtools/htmlcfg.hxx>
+#include <sfx2/viewfac.hxx>
+#include <sfx2/viewsh.hxx>
+#include <sfx2/objsh.hxx>
+#include <editeng/svxenum.hxx>
+#include <sfx2/zoomitem.hxx>
+#include <svx/svxids.hrc>
+#include <editeng/editstat.hxx>
+#include "swdllapi.h"
+#include <swtypes.hxx>
+#include <shellid.hxx>
+#include <IMark.hxx>
+
+class Button;
+class ImageButton;
+class SwTxtFmtColl;
+class SwPageDesc;
+class SwFrmFmt;
+class SwCharFmt;
+class SwNumRule;
+class SwGlossaryHdl;
+class SwDrawBase;
+class SvxRuler;
+class SvxLRSpaceItem;
+class SwDocShell;
+class SwScrollbar;
+class SvBorder;
+class Ruler;
+class SvxSearchItem;
+class SearchAttrItemList;
+class SvxSearchDialog;
+class SdrView;
+class Dialog;
+class SdrObject;
+class SdrPageView;
+class SwHlpImageButton;
+class SwView;
+class SwEditWin;
+class SwWrtShell;
+class SwView_Impl;
+struct SwSearchOptions;
+class FmFormShell;
+class CommandEvent;
+class InsCaptionOpt;
+class SvGlobalName;
+class SvtAccessibilityOptions;
+class SwTransferable;
+class SwMailMergeConfigItem;
+class SwTxtNode; // #i23726#
+class SwFormatClipboard;
+struct SwConversionArgs;
+class Graphic;
+class GraphicFilter;
+class SwPostItMgr;
+
+namespace com{ namespace sun { namespace star {
+ namespace view{ class XSelectionSupplier; }
+}}}
+namespace sfx2 { class FileDialogHelper; }
+
+const long nLeftOfst = -370;
+const long nScrollX = 30;
+const long nScrollY = 30;
+
+#define MINZOOM 20
+#define MAXZOOM 600
+
+#define MAX_MARKS 5
+
+#define CHILDWIN_LABEL 1
+#define CHILDWIN_MAILMERGE 2
+
+enum ShellModes
+{
+ SHELL_MODE_TEXT,
+ SHELL_MODE_FRAME,
+ SHELL_MODE_GRAPHIC,
+ SHELL_MODE_OBJECT,
+ SHELL_MODE_DRAW,
+ SHELL_MODE_DRAW_CTRL,
+ SHELL_MODE_DRAW_FORM,
+ SHELL_MODE_DRAWTEXT,
+ SHELL_MODE_BEZIER,
+ SHELL_MODE_LIST_TEXT,
+ SHELL_MODE_TABLE_TEXT,
+ SHELL_MODE_TABLE_LIST_TEXT,
+ SHELL_MODE_MEDIA,
+ SHELL_MODE_EXTRUDED_CUSTOMSHAPE,
+ SHELL_MODE_FONTWORK,
+ SHELL_MODE_POSTIT,
+ SHELL_MODE_NAVIGATION
+};
+
+/*--------------------------------------------------------------------
+ Description: apply a template
+ --------------------------------------------------------------------*/
+struct SwApplyTemplate
+{
+ union
+ {
+ SwTxtFmtColl* pTxtColl;
+ SwPageDesc* pPageDesc;
+ SwFrmFmt* pFrmFmt;
+ SwCharFmt* pCharFmt;
+ SwNumRule* pNumRule;
+ } aColl;
+
+ int eType;
+ sal_uInt16 nColor;
+ SwFormatClipboard* m_pFormatClipboard;
+ bool bUndo;
+
+ SwApplyTemplate() :
+ eType(0),
+ nColor(0),
+ m_pFormatClipboard(0),
+ bUndo(false)
+ {
+ aColl.pTxtColl = 0;
+ }
+};
+
+/*--------------------------------------------------------------------
+ Description: view of a document
+ --------------------------------------------------------------------*/
+class SW_DLLPUBLIC SwView: public SfxViewShell
+{
+ friend class SwHHCWrapper;
+ friend class SwHyphWrapper;
+ friend class SwView_Impl;
+ friend class SwClipboardChangeListener;
+
+ // search & replace
+ static SvxSearchDialog *m_pSrchDlg;
+ static SvxSearchItem *m_pSrchItem;
+
+ static sal_uInt16 m_nInsertCtrlState;
+ static sal_uInt16 m_nWebInsertCtrlState;
+ static sal_uInt16 m_nInsertObjectCtrlState;
+ static sal_uInt16 m_nInsertFieldCtrlState;
+ static sal_uInt16 m_nMoveType; // for buttons below the scrollbar (viewmdi)
+ static sal_Int32 m_nActMark; // current jump mark for unknown mark
+
+ static bool m_bExtra;
+ static sal_Bool m_bFound;
+ static bool m_bJustOpened;
+
+ static SearchAttrItemList* m_pSrchList;
+ static SearchAttrItemList* m_pReplList;
+
+ SvxHtmlOptions m_aHTMLOpt;
+ Timer m_aTimer; // for delayed ChgLnks during an action
+ OUString m_aPageStr; // status view, current page
+ OUString m_sSwViewData,
+ //and the new cursor position if the user double click in the PagePreview
+ m_sNewCrsrPos;
+ // to support keyboard the number of the page to go to can be set too
+ sal_uInt16 m_nNewPage;
+
+ sal_uInt16 m_nOldPageNum;
+ OUString m_sOldSectionName;
+
+ Point m_aTabColFromDocPos; // moving table colmns out of the document
+ SwTxtNode * m_pNumRuleNodeFromDoc; // Moving indent of numrule #i23726#
+
+ Size m_aDocSz; // current document size
+ Rectangle m_aVisArea; // visible region
+
+ SwEditWin *m_pEditWin;
+ SwWrtShell *m_pWrtShell;
+
+ SfxShell *m_pShell; // current SubShell at the dispatcher
+ FmFormShell *m_pFormShell; // DB-FormShell
+
+ SwView_Impl *m_pViewImpl; // Impl-data for UNO + Basic
+
+ SwScrollbar *m_pHScrollbar, // MDI control elements
+ *m_pVScrollbar;
+
+ bool m_bHScrollbarEnabled;
+ bool m_bVScrollbarEnabled;
+
+ Window *m_pScrollFill; // dummy window for filling the lower right edge
+ // when both scrollbars are active
+
+ SvxRuler *m_pHRuler,
+ *m_pVRuler;
+ ImageButton *m_pTogglePageBtn;
+
+ SwHlpImageButton *m_pPageUpBtn,
+ *m_pPageDownBtn;
+
+ SwGlossaryHdl *m_pGlosHdl; // handle text block
+ SwDrawBase *m_pDrawActual;
+
+ const SwFrmFmt *m_pLastTableFormat;
+
+ SwFormatClipboard *m_pFormatClipboard; //holds data for format paintbrush
+
+ SwPostItMgr *m_pPostItMgr;
+
+ int m_nSelectionType;
+ FloatingWindow *m_pFieldPopup;
+
+ static const int m_nMASTERENUMCOMMANDS = 6;
+
+ OUString m_aCurrShapeEnumCommand[ m_nMASTERENUMCOMMANDS ];
+
+ sal_uInt16 m_nPageCnt;
+
+ // current draw mode
+ sal_uInt16 m_nDrawSfxId;
+ OUString m_sDrawCustom; //some drawing types are marked with strings!
+ sal_uInt16 m_nFormSfxId;
+ sal_uInt16 m_nLastPasteDestination;
+
+ // save the border distance status from SwView::StateTabWin to re-use it in SwView::ExecTabWin()
+ sal_uInt16 m_nLeftBorderDistance;
+ sal_uInt16 m_nRightBorderDistance;
+
+ bool m_bWheelScrollInProgress;
+
+ sal_Bool m_bCenterCrsr : 1,
+ m_bTopCrsr : 1,
+ m_bAlwaysShowSel : 1,
+ m_bTabColFromDoc : 1,
+ m_bNumIndentFromDoc : 1, // #i23726#
+ m_bTabRowFromDoc : 1,
+ m_bSetTabColFromDoc : 1 ,
+ m_bSetTabRowFromDoc : 1,
+ m_bAttrChgNotified : 1,
+ m_bAttrChgNotifiedWithRegistrations : 1,
+ m_bVerbsActive : 1,
+ m_bDrawRotate : 1,
+ m_bDrawSelMode : 1,
+ m_bShowAtResize : 1,
+ m_bInOuterResizePixel : 1,
+ m_bInInnerResizePixel : 1,
+ m_bPasteState : 1,
+ m_bPasteSpecialState : 1,
+ m_bInMailMerge : 1,
+ m_bInDtor : 1, //detect destructor to prevent creating of sub shells while closing
+ m_bOldShellWasPagePreview : 1,
+ m_bIsPreviewDoubleClick : 1, // #i114045#
+ m_bMakeSelectionVisible : 1, // transport the bookmark selection
+ m_bAnnotationMode; ///< The real cursor position is inside an annotation.
+
+ // methods for searching
+ // set search context
+ SAL_DLLPRIVATE sal_Bool SearchAndWrap(sal_Bool bApi = sal_False);
+ SAL_DLLPRIVATE sal_Bool SearchAll(sal_uInt16* pFound = 0);
+ SAL_DLLPRIVATE sal_uLong FUNC_Search( const SwSearchOptions& rOptions );
+ SAL_DLLPRIVATE void Replace();
+
+ bool IsDocumentBorder();
+
+ SAL_DLLPRIVATE bool IsTextTool() const;
+
+ // create control elements
+ SAL_DLLPRIVATE void CreateBtns();
+ SAL_DLLPRIVATE DECL_LINK( BtnPage, Button * );
+
+ SAL_DLLPRIVATE DECL_LINK( TimeoutHdl, void* );
+ SAL_DLLPRIVATE DECL_LINK( UpdatePercentHdl, GraphicFilter* );
+
+ SAL_DLLPRIVATE DECL_LINK( FieldPopupModeEndHdl, void* );
+
+ inline long GetXScroll() const;
+ inline long GetYScroll() const;
+ SAL_DLLPRIVATE Point AlignToPixel(const Point& rPt) const;
+ SAL_DLLPRIVATE void CalcPt( Point* pPt,const Rectangle& rRect,
+ sal_uInt16 nRangeX = USHRT_MAX,
+ sal_uInt16 nRangeY = USHRT_MAX);
+
+ SAL_DLLPRIVATE sal_Bool GetPageScrollUpOffset(SwTwips& rOff) const;
+ SAL_DLLPRIVATE sal_Bool GetPageScrollDownOffset(SwTwips& rOff) const;
+
+ // scrollbar movements
+ SAL_DLLPRIVATE long PageUp();
+ SAL_DLLPRIVATE long PageDown();
+ SAL_DLLPRIVATE long PageUpCrsr(sal_Bool bSelect);
+ SAL_DLLPRIVATE long PageDownCrsr(sal_Bool bSelect);
+ SAL_DLLPRIVATE long PhyPageUp();
+ SAL_DLLPRIVATE long PhyPageDown();
+
+ SAL_DLLPRIVATE int _CreateScrollbar( sal_Bool bHori );
+ SAL_DLLPRIVATE DECL_LINK( ScrollHdl, SwScrollbar * );
+ SAL_DLLPRIVATE DECL_LINK( EndScrollHdl, SwScrollbar * );
+ SAL_DLLPRIVATE sal_Bool UpdateScrollbars();
+ SAL_DLLPRIVATE DECL_LINK( WindowChildEventListener, VclSimpleEvent* );
+ SAL_DLLPRIVATE void CalcVisArea( const Size &rPixelSz );
+
+ SAL_DLLPRIVATE void CreatePageButtons(sal_Bool bShow);
+
+ // linguistics functions
+ SAL_DLLPRIVATE void HyphenateDocument();
+ SAL_DLLPRIVATE sal_Bool IsDrawTextHyphenate();
+ SAL_DLLPRIVATE void HyphenateDrawText();
+ SAL_DLLPRIVATE void StartThesaurus();
+
+ // text conversion
+ SAL_DLLPRIVATE void StartTextConversion( LanguageType nSourceLang, LanguageType nTargetLang, const Font *pTargetFont, sal_Int32 nOptions, sal_Bool bIsInteractive );
+
+ // used for spell checking and text conversion
+ SAL_DLLPRIVATE void SpellStart( SvxSpellArea eSpell, bool bStartDone,
+ bool bEndDone, SwConversionArgs *pConvArgs = 0 );
+ SAL_DLLPRIVATE void SpellEnd( SwConversionArgs *pConvArgs = 0 );
+
+ SAL_DLLPRIVATE void HyphStart( SvxSpellArea eSpell );
+ SAL_DLLPRIVATE sal_Bool CheckSpecialCntnt();
+ SAL_DLLPRIVATE void SpellKontext(sal_Bool bOn = sal_True)
+ { m_bCenterCrsr = bOn; m_bAlwaysShowSel = bOn; }
+
+ // methods for printing
+ SAL_DLLPRIVATE virtual SfxPrinter* GetPrinter( sal_Bool bCreate = sal_False );
+ SAL_DLLPRIVATE virtual bool HasPrintOptionsPage() const;
+ SAL_DLLPRIVATE virtual SfxTabPage* CreatePrintOptionsPage( Window* pParent,
+ const SfxItemSet& rSet);
+ // for readonly switching
+ SAL_DLLPRIVATE virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+ SAL_DLLPRIVATE void _CheckReadonlyState();
+ SAL_DLLPRIVATE void _CheckReadonlySelection();
+
+ // method for rotating PageDesc
+ SAL_DLLPRIVATE void SwapPageMargin(const SwPageDesc&, SvxLRSpaceItem& rLR);
+
+ SAL_DLLPRIVATE void _SetZoom( const Size &rEditSz,
+ SvxZoomType eZoomType,
+ short nFactor = 100,
+ sal_Bool bViewOnly = sal_False);
+ SAL_DLLPRIVATE void CalcAndSetBorderPixel( SvBorder &rToFill, sal_Bool bInner );
+
+ SAL_DLLPRIVATE void ShowAtResize();
+
+ SAL_DLLPRIVATE virtual void Move();
+
+ SAL_DLLPRIVATE void DocumentStatsChanged();
+
+public: // #i123922# Needs to be called from a 2nd place now as a helper method
+ SAL_DLLPRIVATE sal_Bool InsertGraphicDlg( SfxRequest& );
+
+protected:
+
+ SwView_Impl* GetViewImpl() {return m_pViewImpl;}
+
+ void ImpSetVerb( int nSelType );
+
+ int GetSelectionType() const { return m_nSelectionType; }
+ void SetSelectionType(int nSet) { m_nSelectionType = nSet;}
+
+ // for SwWebView
+ void SetShell( SfxShell* pS ) { m_pShell = pS; }
+ void SetFormShell( FmFormShell* pSh ) { m_pFormShell = pSh; }
+
+ virtual void SelectShell();
+
+ virtual void Activate(sal_Bool);
+ virtual void Deactivate(sal_Bool);
+ virtual void InnerResizePixel( const Point &rOfs, const Size &rSize );
+ virtual void OuterResizePixel( const Point &rOfs, const Size &rSize );
+
+ void SetImageButtonColor(Color& rColor);
+
+ const SwFrmFmt* GetLastTblFrmFmt() const {return m_pLastTableFormat;}
+ void SetLastTblFrmFmt(const SwFrmFmt* pSet) {m_pLastTableFormat = pSet;}
+
+ // form letter execution
+ void GenerateFormLetter(sal_Bool bUseCurrentDocument);
+
+ using SfxShell::GetDispatcher;
+
+public:
+
+ SFX_DECL_VIEWFACTORY(SwView);
+ SFX_DECL_INTERFACE(SW_VIEWSHELL)
+ TYPEINFO();
+
+ SfxDispatcher &GetDispatcher();
+
+ void GotFocus() const;
+ virtual SdrView* GetDrawView() const;
+ virtual sal_Bool HasUIFeature( sal_uInt32 nFeature );
+ virtual void ShowCursor( bool bOn = true );
+ virtual ErrCode DoVerb( long nVerb );
+
+ virtual sal_uInt16 SetPrinter( SfxPrinter* pNew,
+ sal_uInt16 nDiff = SFX_PRINTER_ALL, bool bIsAPI=false);
+ ShellModes GetShellMode();
+
+ com::sun::star::view::XSelectionSupplier* GetUNOObject();
+
+ OUString GetSelectionTextParam( bool bCompleteWords,
+ bool bEraseTrail );
+ virtual sal_Bool HasSelection( sal_Bool bText ) const;
+ virtual OUString GetSelectionText( bool bCompleteWords = false );
+ virtual bool PrepareClose( sal_Bool bUI = sal_True ) SAL_OVERRIDE;
+ virtual void MarginChanged();
+
+ // replace word/selection with text from the thesaurus
+ // (this code has special handling for "in word" character)
+ void InsertThesaurusSynonym( const OUString &rSynonmText, const OUString &rLookUpText, bool bValidSelection );
+ bool IsValidSelectionForThesaurus() const;
+ OUString GetThesaurusLookUpText( bool bSelection ) const;
+
+ // immediately switch shell -> for GetSelectionObject
+ void StopShellTimer();
+
+ inline SwWrtShell& GetWrtShell () const { return *m_pWrtShell; }
+ inline SwWrtShell* GetWrtShellPtr() const { return m_pWrtShell; }
+
+ inline SwEditWin &GetEditWin() { return *m_pEditWin; }
+ inline const SwEditWin &GetEditWin () const { return *m_pEditWin; }
+
+#if defined WNT || defined UNX
+ void ScannerEventHdl( const ::com::sun::star::lang::EventObject& rEventObject );
+#endif
+
+ // hand the handler for text blocks to the shell; create if applicable
+ SwGlossaryHdl* GetGlosHdl();
+
+ inline const Rectangle& GetVisArea() const { return m_aVisArea; }
+
+ sal_Bool IsScroll(const Rectangle& rRect) const;
+ void Scroll( const Rectangle& rRect,
+ sal_uInt16 nRangeX = USHRT_MAX,
+ sal_uInt16 nRangeY = USHRT_MAX);
+
+ long SetVScrollMax(long lMax);
+ long SetHScrollMax(long lMax);
+
+ void SpellError(LanguageType eLang);
+ sal_Bool ExecSpellPopup( const Point& rPt );
+ void ExecFieldPopup( const Point& rPt, sw::mark::IFieldmark *fieldBM );
+
+ // SMARTTAGS
+ sal_Bool ExecSmartTagPopup( const Point& rPt );
+
+ DECL_LINK( OnlineSpellCallback, SpellCallbackInfo*);
+ sal_Bool ExecDrwTxtSpellPopup(const Point& rPt);
+
+ void SetTabColFromDocPos( const Point &rPt ) { m_aTabColFromDocPos = rPt; }
+ void SetTabColFromDoc( sal_Bool b ) { m_bTabColFromDoc = b; }
+ sal_Bool IsTabColFromDoc() const { return m_bTabColFromDoc; }
+ void SetTabRowFromDoc( sal_Bool b ) { m_bTabRowFromDoc = b; }
+ sal_Bool IsTabRowFromDoc() const { return m_bTabRowFromDoc; }
+
+ // -> #i23726#
+ void SetNumRuleNodeFromDoc( SwTxtNode * pNumRuleNode )
+ { m_pNumRuleNodeFromDoc = pNumRuleNode; }
+ void SetNumIndentFromDoc(sal_Bool b) { m_bNumIndentFromDoc = b; }
+ sal_Bool IsNumIndentFromDoc() const { return NULL != m_pNumRuleNodeFromDoc; }
+ // <- #i23726#
+
+ void DocSzChgd( const Size& rNewSize );
+ const Size& GetDocSz() const { return m_aDocSz; }
+ virtual void SetVisArea( const Rectangle&, sal_Bool bUpdateScrollbar = sal_True);
+ void SetVisArea( const Point&, sal_Bool bUpdateScrollbar = sal_True);
+ void CheckVisArea();
+
+ void RecheckBrowseMode();
+ static SvxSearchDialog* GetSearchDialog();
+
+ static sal_uInt16 GetMoveType();
+ static void SetMoveType(sal_uInt16 nSet);
+ DECL_STATIC_LINK( SwView, MoveNavigationHdl, bool* ); // #i75416#
+ static void SetActMark(sal_Int32 nSet);
+
+ sal_Bool HandleWheelCommands( const CommandEvent& );
+
+ // insert frames
+ void InsFrmMode(sal_uInt16 nCols);
+
+ void SetZoom( SvxZoomType eZoomType, short nFactor = 100, sal_Bool bViewOnly = sal_False);
+ virtual void SetZoomFactor( const Fraction &rX, const Fraction & );
+
+ void SetViewLayout( sal_uInt16 nColumns, bool bBookMode, sal_Bool bViewOnly = sal_False );
+
+ void ShowHScrollbar(sal_Bool bShow);
+ sal_Bool IsHScrollbarVisible()const;
+
+ void ShowVScrollbar(sal_Bool bShow);
+ sal_Bool IsVScrollbarVisible()const;
+
+ void EnableHScrollbar(bool bEnable);
+ void EnableVScrollbar(bool bEnable);
+
+ int CreateVRuler();
+ int KillVRuler();
+ int CreateTab();
+ int KillTab();
+
+ bool StatVRuler() const { return ((Window*)m_pVRuler)->IsVisible(); }
+ void ChangeVRulerMetric(FieldUnit eUnit);
+ void GetVRulerMetric(FieldUnit& rToFill) const;
+
+ bool StatTab() const { return ((Window*)m_pHRuler)->IsVisible(); }
+ SvxRuler& GetHRuler() { return *m_pHRuler; }
+ SvxRuler& GetVRuler() { return *m_pVRuler; }
+ void InvalidateRulerPos();
+ void ChangeTabMetric(FieldUnit eUnit);
+ void GetHRulerMetric(FieldUnit& rToFill) const;
+
+ // Handler
+ void Execute(SfxRequest&);
+ void ExecPageMove(SfxRequest&);
+ void ExecStyle(SfxRequest&);
+ void ExecLingu(SfxRequest&);
+ void ExecDataBase(SfxRequest&);
+ void ExecDlg(SfxRequest&);
+ void ExecDlgExt(SfxRequest&);
+ void ExecDBDlg(SfxRequest &);
+ void ExecColl(SfxRequest&);
+ void ExecutePrint(SfxRequest&);
+ void ExecDraw(SfxRequest&);
+ void ExecTabWin(SfxRequest&);
+ void ExecuteStatusLine(SfxRequest&);
+ DECL_LINK( ExecRulerClick, Ruler * );
+ void ExecSearch(SfxRequest&, sal_Bool bNoMessage = sal_False);
+ void ExecViewOptions(SfxRequest &);
+
+ void StateViewOptions(SfxItemSet &);
+ void StateSearch(SfxItemSet &);
+ void GetState(SfxItemSet&);
+ void StateStatusLine(SfxItemSet&);
+
+ // functions for drawing
+ void SetDrawFuncPtr(SwDrawBase* pFuncPtr);
+ inline SwDrawBase* GetDrawFuncPtr(/*sal_Bool bBuf = sal_False*/) const { return m_pDrawActual; }
+ void GetDrawState(SfxItemSet &rSet);
+ void ExitDraw();
+ inline sal_Bool IsDrawRotate() { return m_bDrawRotate; }
+ inline void FlipDrawRotate() { m_bDrawRotate = !m_bDrawRotate; }
+ inline sal_Bool IsDrawSelMode() { return m_bDrawSelMode; }
+ void SetSelDrawSlot();
+ inline void FlipDrawSelMode() { m_bDrawSelMode = !m_bDrawSelMode; }
+ void NoRotate(); // turn off rotate mode
+ sal_Bool EnterDrawTextMode(const Point& aDocPos);
+ void LeaveDrawCreate() { m_nDrawSfxId = m_nFormSfxId = USHRT_MAX; m_sDrawCustom = "";}
+ sal_Bool IsDrawMode() { return (m_nDrawSfxId != USHRT_MAX || m_nFormSfxId != USHRT_MAX); }
+ bool IsFormMode() const;
+ bool IsBezierEditMode();
+ bool AreOnlyFormsSelected() const;
+ sal_Bool HasDrwObj(SdrObject *pSdrObj) const;
+ sal_Bool HasOnlyObj(SdrObject *pSdrObj, sal_uInt32 eObjInventor) const;
+ sal_Bool BeginTextEdit( SdrObject* pObj, SdrPageView* pPV=NULL,
+ Window* pWin=NULL, bool bIsNewObj=false, bool bSetSelectionToStart=false );
+
+ void StateTabWin(SfxItemSet&);
+
+ // attributes have changed
+ DECL_LINK( AttrChangedNotify, void* );
+
+ // form control has been activated
+ DECL_LINK( FormControlActivated, void* );
+
+ // edit links
+ void EditLinkDlg();
+ void AutoCaption(const sal_uInt16 nType, const SvGlobalName *pOleId = 0);
+ void InsertCaption(const InsCaptionOpt *pOpt);
+
+ // Async call by Core
+ void UpdatePageNums(sal_uInt16 nPhyNum, sal_uInt16 nVirtNum, const OUString& rPgStr);
+
+ OUString GetPageStr(sal_uInt16 nPhyNum, sal_uInt16 nVirtNum, const OUString& rPgStr);
+
+ // hand over Shell
+ SfxShell *GetCurShell() { return m_pShell; }
+ SwDocShell *GetDocShell();
+ inline const SwDocShell *GetDocShell() const;
+ inline FmFormShell *GetFormShell() { return m_pFormShell; }
+ inline const FmFormShell *GetFormShell() const { return m_pFormShell; }
+
+ // so that in the SubShells' DTors m_pShell can be reset if applicable
+ void ResetSubShell() { m_pShell = 0; }
+
+ virtual void WriteUserData(OUString &, bool bBrowse = false);
+ virtual void ReadUserData(const OUString &, bool bBrowse = false);
+ virtual void ReadUserDataSequence ( const com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue >&, sal_Bool bBrowse );
+ virtual void WriteUserDataSequence ( com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue >&, sal_Bool bBrowse );
+
+ void SetCrsrAtTop( sal_Bool bFlag, sal_Bool bCenter = sal_False )
+ { m_bTopCrsr = bFlag, m_bCenterCrsr = bCenter; }
+ sal_Bool IsCrsrAtTop() const { return m_bTopCrsr; }
+ sal_Bool IsCrsrAtCenter() const { return m_bCenterCrsr; }
+
+ bool JumpToSwMark( const OUString& rMark );
+
+ long InsertDoc( sal_uInt16 nSlotId, const OUString& rFileName,
+ const OUString& rFilterName, sal_Int16 nVersion = 0 );
+
+ void ExecuteInsertDoc( SfxRequest& rRequest, const SfxPoolItem* pItem );
+ long InsertMedium( sal_uInt16 nSlotId, SfxMedium* pMedium, sal_Int16 nVersion );
+ DECL_LINK( DialogClosedHdl, sfx2::FileDialogHelper * );
+
+ // status methods for clipboard.
+ // Status changes now notified from the clipboard.
+ sal_Bool IsPasteAllowed();
+ sal_Bool IsPasteSpecialAllowed();
+
+ // Enable mail merge - mail merge field dialog enabled
+ void EnableMailMerge(sal_Bool bEnable = sal_True);
+ //apply Accessiblity options
+ void ApplyAccessiblityOptions(SvtAccessibilityOptions& rAccessibilityOptions);
+
+ SwView(SfxViewFrame* pFrame, SfxViewShell*);
+ ~SwView();
+
+ void NotifyDBChanged();
+
+ SfxObjectShellLock CreateTmpSelectionDoc();
+
+ void AddTransferable(SwTransferable& rTransferable);
+
+ // store MailMerge data while "Back to Mail Merge Wizard" FloatingWindow is active
+ // or to support printing
+ void SetMailMergeConfigItem(SwMailMergeConfigItem* pConfigItem, sal_uInt16 nRestart, sal_Bool bIsSource);
+ SwMailMergeConfigItem* GetMailMergeConfigItem();
+ sal_uInt16 GetMailMergeRestartPage() const;
+ sal_Bool IsMailMergeSourceView() const;
+
+ void ExecFormatPaintbrush(SfxRequest &);
+ void StateFormatPaintbrush(SfxItemSet &);
+
+ //public fuer D&D
+ int InsertGraphic( const OUString &rPath, const OUString &rFilter,
+ sal_Bool bLink = sal_True, GraphicFilter *pFlt = 0,
+ Graphic* pPreviewGrf = 0,
+ sal_Bool bRule = sal_False );
+
+ void ExecuteScan( SfxRequest& rReq );
+
+ SwPostItMgr* GetPostItMgr() { return m_pPostItMgr;}
+ const SwPostItMgr* GetPostItMgr() const { return m_pPostItMgr;}
+
+ // exhibition hack (MA,MBA)
+ void SelectShellForDrop();
+
+ void UpdateDocStats();
+ /// Where is the real cursor: in the annotation or in the main document?
+ void SetAnnotationMode(bool bMode);
+};
+
+// ----------------- inline Methoden ----------------------
+inline long SwView::GetXScroll() const
+{
+ return m_aVisArea.GetWidth() * nScrollX / 100L;
+}
+
+inline long SwView::GetYScroll() const
+{
+ return m_aVisArea.GetHeight() * nScrollY / 100L;
+}
+
+inline const SwDocShell *SwView::GetDocShell() const
+{
+ return ((SwView*)this)->GetDocShell();
+}
+
+SfxTabPage* CreatePrintOptionsPage( Window *pParent,
+ const SfxItemSet &rOptions,
+ sal_Bool bPreview);
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/viewlayoutctrl.hxx b/sw/source/core/uibase/inc/viewlayoutctrl.hxx
new file mode 100644
index 000000000000..10648cd36671
--- /dev/null
+++ b/sw/source/core/uibase/inc/viewlayoutctrl.hxx
@@ -0,0 +1,46 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_VIEWLAYOUTCTRL_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_VIEWLAYOUTCTRL_HXX
+
+#include <sfx2/stbitem.hxx>
+
+// class SwViewLayoutControl ----------------------------------------------
+class SwViewLayoutControl : public SfxStatusBarControl
+{
+private:
+
+ struct SwViewLayoutControl_Impl;
+ SwViewLayoutControl_Impl* mpImpl;
+
+public:
+
+ SFX_DECL_STATUSBAR_CONTROL();
+
+ SwViewLayoutControl( sal_uInt16 nSlotId, sal_uInt16 nId, StatusBar& rStb );
+ ~SwViewLayoutControl();
+
+ virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
+ virtual void Paint( const UserDrawEvent& rEvt );
+ virtual sal_Bool MouseButtonDown( const MouseEvent & );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/web.hrc b/sw/source/core/uibase/inc/web.hrc
new file mode 100644
index 000000000000..aef47e9d2bb1
--- /dev/null
+++ b/sw/source/core/uibase/inc/web.hrc
@@ -0,0 +1,47 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef _WEB_HRC
+#define _WEB_HRC
+
+#include "rcid.hrc"
+
+#define RID_WEBTOOLS_TOOLBOX (RC_WEB_BEGIN + 2)
+#define RID_WEBTEXT_TOOLBOX (RC_WEB_BEGIN + 3)
+#define STR_HUMAN_SWWEBDOC_NAME (RC_WEB_BEGIN + 4)
+#define STR_WRITER_WEBDOC_FULLTYPE_40 (RC_WEB_BEGIN + 5)
+#define STR_SHELLNAME_WEBTEXT (RC_WEB_BEGIN + 6)
+#define STR_SHELLNAME_WEBFRAME (RC_WEB_BEGIN + 7)
+#define RID_WEBFRAME_TOOLBOX (RC_WEB_BEGIN + 8)
+#define STR_WRITER_WEBDOC_FULLTYPE_50 (RC_WEB_BEGIN + 9)
+#define RID_WEBGRAPHIC_TOOLBOX (RC_WEB_BEGIN + 10)
+#define RID_WEBOLE_TOOLBOX (RC_WEB_BEGIN + 11)
+#define STR_WRITER_WEBDOC_FULLTYPE (RC_WEB_BEGIN + 12)
+
+
+
+#define WEB_ACT_END STR_WRITER_WEBDOC_FULLTYPE
+
+#if WEB_ACT_END > RC_WEB_END
+#error Resource-Id Ueberlauf in #file, #line
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/wformsh.hxx b/sw/source/core/uibase/inc/wformsh.hxx
new file mode 100644
index 000000000000..aac9f9f69c94
--- /dev/null
+++ b/sw/source/core/uibase/inc/wformsh.hxx
@@ -0,0 +1,36 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_WFORMSH_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_WFORMSH_HXX
+
+#include "drformsh.hxx"
+
+class SwWebDrawFormShell : public SwDrawFormShell
+{
+public:
+ SwWebDrawFormShell(SwView &rShell);
+ virtual ~SwWebDrawFormShell();
+
+ SFX_DECL_INTERFACE(SW_WEBDRAWFORMSHELL)
+ TYPEINFO();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/wfrmsh.hxx b/sw/source/core/uibase/inc/wfrmsh.hxx
new file mode 100644
index 000000000000..68f7edcab86b
--- /dev/null
+++ b/sw/source/core/uibase/inc/wfrmsh.hxx
@@ -0,0 +1,38 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SW_SOURCE_UI_INC_WFRMSH_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_WFRMSH_HXX
+
+#include "frmsh.hxx"
+
+class SwWebFrameShell: public SwFrameShell
+{
+
+public:
+ SFX_DECL_INTERFACE(SW_WEBFRAMESHELL)
+ TYPEINFO();
+
+ SwWebFrameShell(SwView &rView);
+ virtual ~SwWebFrameShell();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/wgrfsh.hxx b/sw/source/core/uibase/inc/wgrfsh.hxx
new file mode 100644
index 000000000000..45682ac74554
--- /dev/null
+++ b/sw/source/core/uibase/inc/wgrfsh.hxx
@@ -0,0 +1,36 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_WGRFSH_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_WGRFSH_HXX
+
+#include "grfsh.hxx"
+
+class SwWebGrfShell: public SwGrfShell
+{
+public:
+ SwWebGrfShell(SwView &rShell);
+ virtual ~SwWebGrfShell();
+
+ SFX_DECL_INTERFACE(SW_WEBGRFSHELL)
+ TYPEINFO();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/wlistsh.hxx b/sw/source/core/uibase/inc/wlistsh.hxx
new file mode 100644
index 000000000000..3df943966885
--- /dev/null
+++ b/sw/source/core/uibase/inc/wlistsh.hxx
@@ -0,0 +1,36 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_WLISTSH_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_WLISTSH_HXX
+
+#include "listsh.hxx"
+
+class SwWebListShell: public SwListShell
+{
+public:
+ SFX_DECL_INTERFACE(SW_WEBLISTSHELL)
+ TYPEINFO();
+
+ virtual ~SwWebListShell();
+ SwWebListShell(SwView &rView);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/wolesh.hxx b/sw/source/core/uibase/inc/wolesh.hxx
new file mode 100644
index 000000000000..bf9dcad60718
--- /dev/null
+++ b/sw/source/core/uibase/inc/wolesh.hxx
@@ -0,0 +1,35 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_WOLESH_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_WOLESH_HXX
+
+#include "olesh.hxx"
+
+class SwWebOleShell: public SwOleShell
+{
+public:
+ SFX_DECL_INTERFACE(SW_WEBOLESHELL)
+
+ virtual ~SwWebOleShell();
+ SwWebOleShell(SwView &rView);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/wordcountctrl.hxx b/sw/source/core/uibase/inc/wordcountctrl.hxx
new file mode 100644
index 000000000000..9026d2a676e9
--- /dev/null
+++ b/sw/source/core/uibase/inc/wordcountctrl.hxx
@@ -0,0 +1,33 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_SW_SOURCE_UI_INC_WORDCOUNTCTRL_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_WORDCOUNTCTRL_HXX
+
+#include <sfx2/stbitem.hxx>
+
+/**
+Word count status bar control for Writer.
+
+@remarks This is a simple status bar control of type SfxStringItem, and it has no custom
+logic whatsoever. The actual updating of the word count string happens in
+SwView::StateStatusLine (see sw/source/ui/uiview/view2.cxx).
+*/
+class SwWordCountStatusBarControl : public SfxStatusBarControl
+{
+public:
+ SFX_DECL_STATUSBAR_CONTROL();
+
+ SwWordCountStatusBarControl(sal_uInt16 nSlotId, sal_uInt16 nId, StatusBar& rStb);
+ ~SwWordCountStatusBarControl();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/wordcountdialog.hxx b/sw/source/core/uibase/inc/wordcountdialog.hxx
new file mode 100644
index 000000000000..3bebd69f4967
--- /dev/null
+++ b/sw/source/core/uibase/inc/wordcountdialog.hxx
@@ -0,0 +1,79 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_WORDCOUNTDIALOG_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_WORDCOUNTDIALOG_HXX
+#include <sfx2/basedlgs.hxx>
+#include <svtools/stdctrl.hxx>
+#include <vcl/layout.hxx>
+#include <vcl/button.hxx>
+struct SwDocStat;
+#include <sfx2/childwin.hxx>
+#include "swabstdlg.hxx"
+
+class SwWordCountFloatDlg : public SfxModelessDialog
+{
+ virtual void Activate();
+ void SetValues(const SwDocStat& rCurrent, const SwDocStat& rDoc);
+ void showCJK(bool bShowCJK);
+
+ FixedText* m_pCurrentWordFT;
+ FixedText* m_pCurrentCharacterFT;
+ FixedText* m_pCurrentCharacterExcludingSpacesFT;
+ FixedText* m_pCurrentCjkcharsFT;
+
+ FixedText* m_pDocWordFT;
+ FixedText* m_pDocCharacterFT;
+ FixedText* m_pDocCharacterExcludingSpacesFT;
+ FixedText* m_pDocCjkcharsFT;
+
+ FixedText* m_pCjkcharsLabelFT;
+
+ CloseButton* m_pClosePB;
+
+ DECL_LINK( CloseHdl, void* );
+public:
+ SwWordCountFloatDlg( SfxBindings* pBindings,
+ SfxChildWindow* pChild,
+ Window *pParent,
+ SfxChildWinInfo* pInfo);
+ ~SwWordCountFloatDlg();
+ void UpdateCounts();
+
+ void SetCounts(const SwDocStat &rCurrCnt, const SwDocStat &rDocStat);
+};
+
+class SwWordCountWrapper : public SfxChildWindow
+{
+ AbstractSwWordCountFloatDlg* pAbstDlg;
+protected:
+ SwWordCountWrapper( Window *pParentWindow,
+ sal_uInt16 nId,
+ SfxBindings* pBindings,
+ SfxChildWinInfo* pInfo );
+
+ SFX_DECL_CHILDWINDOW_WITHID(SwWordCountWrapper);
+
+public:
+ void UpdateCounts();
+ void SetCounts(const SwDocStat &rCurrCnt, const SwDocStat &rDocStat);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/workctrl.hxx b/sw/source/core/uibase/inc/workctrl.hxx
new file mode 100644
index 000000000000..eef6332e01db
--- /dev/null
+++ b/sw/source/core/uibase/inc/workctrl.hxx
@@ -0,0 +1,185 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_WORKCTRL_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_WORKCTRL_HXX
+
+#include <sfx2/tbxctrl.hxx>
+#include <vcl/toolbox.hxx>
+#include <svtools/stdctrl.hxx>
+#include <vcl/button.hxx>
+
+class PopupMenu;
+class SwView;
+
+// double entry! hrc and hxx
+// these Ids say what the buttons below the scrollbar are doing
+#define NID_START 20000
+#define NID_NEXT 20000
+#define NID_PREV 20001
+#define NID_TBL 20002
+#define NID_FRM 20003
+#define NID_PGE 20004
+#define NID_DRW 20005
+#define NID_CTRL 20006
+#define NID_REG 20007
+#define NID_BKM 20008
+#define NID_GRF 20009
+#define NID_OLE 20010
+#define NID_OUTL 20011
+#define NID_SEL 20012
+#define NID_FTN 20013
+#define NID_MARK 20014
+#define NID_POSTIT 20015
+#define NID_SRCH_REP 20016
+#define NID_INDEX_ENTRY 20017
+#define NID_TABLE_FORMULA 20018
+#define NID_TABLE_FORMULA_ERROR 20019
+#define NID_COUNT 20
+
+class SwTbxInsertCtrl : public SfxToolBoxControl
+{
+ sal_uInt16 nLastSlotId;
+
+ using SfxToolBoxControl::Select;
+ virtual void Select( sal_Bool bMod1 = sal_False );
+
+public:
+ SFX_DECL_TOOLBOX_CONTROL();
+
+ SwTbxInsertCtrl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx );
+ ~SwTbxInsertCtrl();
+
+ virtual SfxPopupWindowType GetPopupWindowType() const;
+ virtual SfxPopupWindow* CreatePopupWindow();
+ virtual void StateChanged( sal_uInt16 nSID,
+ SfxItemState eState,
+ const SfxPoolItem* pState );
+
+ virtual void SAL_CALL update() throw (::com::sun::star::uno::RuntimeException, std::exception);
+};
+
+class SwTbxAutoTextCtrl : public SfxToolBoxControl
+{
+ PopupMenu* pPopup;
+ SwView* pView;
+
+ void DelPopup();
+public:
+ SFX_DECL_TOOLBOX_CONTROL();
+
+ SwTbxAutoTextCtrl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx );
+ virtual ~SwTbxAutoTextCtrl();
+
+ virtual SfxPopupWindowType GetPopupWindowType() const;
+ virtual SfxPopupWindow* CreatePopupWindow();
+ virtual void StateChanged( sal_uInt16 nSID,
+ SfxItemState eState,
+ const SfxPoolItem* pState );
+
+ DECL_LINK(PopupHdl, PopupMenu*);
+};
+
+class SwTbxFieldCtrl : public SfxToolBoxControl
+{
+ PopupMenu* pPopup;
+ SwView* pView;
+
+ void DelPopup();
+public:
+ SFX_DECL_TOOLBOX_CONTROL();
+
+ SwTbxFieldCtrl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx );
+ virtual ~SwTbxFieldCtrl();
+
+ virtual SfxPopupWindowType GetPopupWindowType() const;
+ virtual SfxPopupWindow* CreatePopupWindow();
+ virtual void StateChanged( sal_uInt16 nSID,
+ SfxItemState eState,
+ const SfxPoolItem* pState );
+
+ DECL_LINK(PopupHdl, PopupMenu*);
+};
+
+class SwScrollNaviToolBox : public ToolBox
+{
+ virtual void MouseButtonUp( const MouseEvent& rMEvt );
+ virtual void RequestHelp( const HelpEvent& rHEvt );
+
+ public:
+ SwScrollNaviToolBox(Window* pParent, WinBits nWinStyle ) :
+ ToolBox(pParent, nWinStyle ) {}
+};
+
+class SwScrollNaviPopup : public SfxPopupWindow
+{
+ SwScrollNaviToolBox aToolBox;
+ FixedLine aSeparator;
+ FixedInfo aInfoField;
+ ImageList aIList;
+
+ OUString sQuickHelp[2 * NID_COUNT];
+
+ void ApplyImageList();
+
+ using Window::GetQuickHelpText;
+
+protected:
+ DECL_LINK(SelectHdl, ToolBox*);
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+
+public:
+ SwScrollNaviPopup( sal_uInt16 nId, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, Window *pParent );
+ ~SwScrollNaviPopup();
+
+ static OUString GetQuickHelpText(sal_Bool bNext);
+
+ virtual SfxPopupWindow* Clone() const;
+ void GrabFocus(){aToolBox.GrabFocus();}
+};
+
+// ImageButtons have to set the HelpText themselves if needed
+
+class SwHlpImageButton : public ImageButton
+{
+ sal_Bool bUp;
+ public:
+ SwHlpImageButton(Window* pParent, const ResId& rResId, sal_Bool bUpBtn) :
+ ImageButton(pParent, rResId), bUp(bUpBtn){}
+
+ virtual void RequestHelp( const HelpEvent& rHEvt );
+
+};
+
+class SwPreviewZoomControl : public SfxToolBoxControl
+{
+public:
+ SFX_DECL_TOOLBOX_CONTROL();
+
+ SwPreviewZoomControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx );
+ ~SwPreviewZoomControl();
+
+ virtual void StateChanged( sal_uInt16 nSID,
+ SfxItemState eState,
+ const SfxPoolItem* pState );
+
+ virtual Window* CreateItemWindow( Window *pParent );
+};
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/wrap.hxx b/sw/source/core/uibase/inc/wrap.hxx
new file mode 100644
index 000000000000..322b0530a749
--- /dev/null
+++ b/sw/source/core/uibase/inc/wrap.hxx
@@ -0,0 +1,117 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_WRAP_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_WRAP_HXX
+
+#include <sfx2/tabdlg.hxx>
+#include <sfx2/basedlgs.hxx>
+#include <vcl/button.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/field.hxx>
+
+class Window;
+class SfxItemSet;
+class SwWrtShell;
+
+class SwWrapDlg : public SfxSingleTabDialog
+{
+ SwWrtShell* pWrtShell;
+
+public:
+ SwWrapDlg(Window* pParent, SfxItemSet& rSet, SwWrtShell* pSh, bool bDrawMode);
+
+ SwWrtShell* GetWrtShell() { return pWrtShell; }
+};
+
+/*--------------------------------------------------------------------
+ Description: circulation TabPage
+ --------------------------------------------------------------------*/
+
+class SwWrapTabPage: public SfxTabPage
+{
+ // WRAPPING
+ RadioButton* m_pNoWrapRB;
+ RadioButton* m_pWrapLeftRB;
+ RadioButton* m_pWrapRightRB;
+ RadioButton* m_pWrapParallelRB;
+ RadioButton* m_pWrapThroughRB;
+ RadioButton* m_pIdealWrapRB;
+
+ // MARGIN
+ MetricField* m_pLeftMarginED;
+ MetricField* m_pRightMarginED;
+ MetricField* m_pTopMarginED;
+ MetricField* m_pBottomMarginED;
+
+ // OPTIONS
+ CheckBox* m_pWrapAnchorOnlyCB;
+ CheckBox* m_pWrapTransparentCB;
+ CheckBox* m_pWrapOutlineCB;
+ CheckBox* m_pWrapOutsideCB;
+
+ sal_uInt16 nOldLeftMargin;
+ sal_uInt16 nOldRightMargin;
+ sal_uInt16 nOldUpperMargin;
+ sal_uInt16 nOldLowerMargin;
+
+ RndStdIds nAnchorId;
+ sal_uInt16 nHtmlMode;
+
+ Size aFrmSize;
+ SwWrtShell* pWrtSh;
+
+ sal_Bool bFormat;
+ sal_Bool bNew;
+ sal_Bool bHtmlMode;
+ sal_Bool bDrawMode;
+ sal_Bool bContourImage;
+
+ SwWrapTabPage(Window *pParent, const SfxItemSet &rSet);
+ ~SwWrapTabPage();
+
+ void ApplyImageList();
+ void EnableModes(const SfxItemSet& rSet);
+ virtual void ActivatePage(const SfxItemSet& rSet);
+ virtual int DeactivatePage(SfxItemSet *pSet);
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+
+ DECL_LINK( RangeModifyHdl, MetricField * );
+ DECL_LINK( WrapTypeHdl, RadioButton * );
+ DECL_LINK(ContourHdl, void *);
+
+ using SfxTabPage::ActivatePage;
+ using SfxTabPage::DeactivatePage;
+
+public:
+
+ static SfxTabPage *Create(Window *pParent, const SfxItemSet &rSet);
+
+ virtual sal_Bool FillItemSet(SfxItemSet &rSet);
+ virtual void Reset(const SfxItemSet &rSet);
+
+ static sal_uInt16* GetRanges();
+ inline void SetNewFrame(sal_Bool bNewFrame) { bNew = bNewFrame; }
+ inline void SetFormatUsed(sal_Bool bFmt, sal_Bool bDrw) { bFormat = bFmt;
+ bDrawMode = bDrw; }
+ inline void SetShell(SwWrtShell* pSh) { pWrtSh = pSh; }
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/wrtsh.hxx b/sw/source/core/uibase/inc/wrtsh.hxx
new file mode 100644
index 000000000000..fbcdecaecf19
--- /dev/null
+++ b/sw/source/core/uibase/inc/wrtsh.hxx
@@ -0,0 +1,646 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_WRTSH_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_WRTSH_HXX
+
+#include <com/sun/star/embed/XEmbeddedObject.hpp>
+#include "swdllapi.h"
+#include <fesh.hxx>
+#include <sortopt.hxx>
+#include <swurl.hxx>
+#include <IMark.hxx>
+#include "navmgr.hxx"
+#include <boost/optional.hpp>
+
+class Window;
+class SbxArray;
+class SwDoc;
+class SwViewOption;
+class SwFlyFrmAttrMgr;
+class SwField;
+class SwTOXBase;
+class SwView;
+class SvGlobalName;
+class SwInputFieldList;
+class SwSectionData;
+class Timer;
+class SvxMacro;
+class SwFmtINetFmt;
+class SvxAutoCorrect;
+class NaviContentBookmark;
+struct SwCallMouseEvent;
+class SfxStringListItem;
+
+namespace com { namespace sun { namespace star { namespace util {
+ struct SearchOptions;
+} } } }
+
+typedef sal_Int32 SelectionType;
+namespace nsSelectionType
+{
+ const SelectionType SEL_TXT = CNT_TXT; // text, never frames too 0x0001
+ const SelectionType SEL_GRF = CNT_GRF; // graphic 0x0002
+ const SelectionType SEL_OLE = CNT_OLE; // OLE 0x0010
+ const SelectionType SEL_FRM = 0x000020; // frame, no content type
+ const SelectionType SEL_NUM = 0x000040; // NumList
+ const SelectionType SEL_TBL = 0x000080; // cursor is in table
+ const SelectionType SEL_TBL_CELLS = 0x000100; // table cells are selected
+ const SelectionType SEL_DRW = 0x000200; // drawing objects (rectangle, circle...)
+ const SelectionType SEL_DRW_TXT = 0x000400; // draw-textobjects in edit mode
+ const SelectionType SEL_BEZ = 0x000800; // edit ornament objects
+ const SelectionType SEL_DRW_FORM = 0x001000; // drawing objects: DB-Forms
+ const SelectionType SEL_FOC_FRM_CTRL = 0x002000; // a form control is focused. Neither set nor evaluated by the SwWrtShell itself, only by it's clients.
+ const SelectionType SEL_MEDIA = 0x004000; // Media object
+ const SelectionType SEL_EXTRUDED_CUSTOMSHAPE = 0x008000; // extruded custom shape
+ const SelectionType SEL_FONTWORK = 0x010000; // fontwork
+ const SelectionType SEL_POSTIT = 0x020000; //annotation
+}
+
+/** Used by the UI to modify the document model.
+
+Eg. the Insert() method will take the current cursor position, insert the
+string, and take care of undo etc.
+*/
+class SW_DLLPUBLIC SwWrtShell: public SwFEShell
+{
+private:
+ using SwCrsrShell::Left;
+ using SwCrsrShell::Right;
+ using SwCrsrShell::Up;
+ using SwCrsrShell::Down;
+ using SwCrsrShell::LeftMargin;
+ using SwCrsrShell::RightMargin;
+ using SwCrsrShell::SelectTxtAttr;
+ using SwCrsrShell::GotoPage;
+ using SwFEShell::InsertObject;
+ using SwEditShell::AutoCorrect;
+ using SwCrsrShell::GotoMark;
+
+ typedef long (SwWrtShell::*SELECTFUNC)(const Point *, sal_Bool bProp );
+
+ SELECTFUNC fnDrag;
+ SELECTFUNC fnSetCrsr;
+ SELECTFUNC fnEndDrag;
+ SELECTFUNC fnKillSel;
+
+public:
+
+ using SwEditShell::Insert;
+
+ long SetCursor (const Point* pPt, bool bProp) { return (this->*fnSetCrsr)(pPt, bProp); }
+ long Drag (const Point* pPt, bool bProp) { return (this->*fnDrag)(pPt, bProp); }
+ long EndDrag (const Point* pPt, bool bProp) { return (this->*fnEndDrag)(pPt, bProp); }
+ long KillSelection(const Point* pPt, bool bProp) { return (this->*fnKillSel)(pPt, bProp); }
+
+ // reset all selections
+ long ResetSelect( const Point *, sal_Bool );
+
+ // resets the cursorstack after movement with PageUp/-Down if a stack is built up
+ inline void ResetCursorStack();
+ SelectionType GetSelectionType() const;
+
+ bool IsModePushed() const { return 0 != pModeStack; }
+ void PushMode();
+ void PopMode();
+
+ void SttSelect();
+ void EndSelect();
+ sal_Bool IsInSelect() const { return bInSelect; }
+ void SetInSelect(sal_Bool bSel = sal_True) { bInSelect = bSel; }
+ // is there a text- or frameselection?
+ sal_Bool HasSelection() const { return SwCrsrShell::HasSelection() ||
+ IsMultiSelection() || IsSelFrmMode() || IsObjSelected(); }
+ sal_Bool Pop( sal_Bool bOldCrsr = sal_True );
+
+ void EnterStdMode();
+ bool IsStdMode() const { return !bExtMode && !bAddMode && !bBlockMode; }
+
+ void EnterExtMode();
+ void LeaveExtMode();
+ bool ToggleExtMode();
+ sal_Bool IsExtMode() const { return bExtMode; }
+
+ void EnterAddMode();
+ void LeaveAddMode();
+ bool ToggleAddMode();
+ sal_Bool IsAddMode() const { return bAddMode; }
+
+ void EnterBlockMode();
+ void LeaveBlockMode();
+ bool ToggleBlockMode();
+ bool IsBlockMode() const { return bBlockMode; }
+
+ void SetInsMode( sal_Bool bOn = sal_True );
+ void ToggleInsMode() { SetInsMode( !bIns ); }
+ sal_Bool IsInsMode() const { return bIns; }
+ void SetRedlineModeAndCheckInsMode( sal_uInt16 eMode );
+
+ void EnterSelFrmMode(const Point *pStartDrag = 0);
+ void LeaveSelFrmMode();
+ sal_Bool IsSelFrmMode() const { return bLayoutMode; }
+ // reset selection of frames
+ void UnSelectFrm();
+
+ void Invalidate();
+
+ // select table cells for editing of formulas in the ribbonbar
+ inline void SelTblCells( const Link &rLink, sal_Bool bMark = sal_True );
+ inline void EndSelTblCells();
+
+ // leave per word or per line selection mode. Is usually called in MB-Up.
+ bool IsExtSel() const { return bSelWrd || bSelLn; }
+
+ // query whether the active fnDrag pointer is set to BeginDrag
+ // is needed for MouseMove to work around bugs 55592/55931
+ inline bool Is_FnDragEQBeginDrag() const;
+
+ // base requests
+ sal_Bool IsInWrd() { return IsInWord(); }
+ sal_Bool IsSttWrd() { return IsStartWord(); }
+ sal_Bool IsEndWrd();
+ bool IsSttOfPara() const { return IsSttPara(); }
+ bool IsEndOfPara() const { return IsEndPara(); }
+
+ // select word / sentense
+ sal_Bool SelNearestWrd();
+ sal_Bool SelWrd (const Point * = 0, sal_Bool bProp=sal_False );
+ // #i32329# Enhanced selection
+ void SelSentence (const Point * = 0, sal_Bool bProp=sal_False );
+ void SelPara (const Point * = 0, sal_Bool bProp=sal_False );
+ long SelAll();
+
+ // basecursortravelling
+typedef sal_Bool (SwWrtShell:: *FNSimpleMove)();
+ sal_Bool SimpleMove( FNSimpleMove, sal_Bool bSelect );
+
+ sal_Bool Left ( sal_uInt16 nMode, sal_Bool bSelect,
+ sal_uInt16 nCount, sal_Bool bBasicCall, sal_Bool bVisual = sal_False );
+ sal_Bool Right ( sal_uInt16 nMode, sal_Bool bSelect,
+ sal_uInt16 nCount, sal_Bool bBasicCall, sal_Bool bVisual = sal_False );
+ sal_Bool Up ( sal_Bool bSelect = sal_False, sal_uInt16 nCount = 1,
+ sal_Bool bBasicCall = sal_False );
+ sal_Bool Down ( sal_Bool bSelect = sal_False, sal_uInt16 nCount = 1,
+ sal_Bool bBasicCall = sal_False );
+ sal_Bool NxtWrd ( sal_Bool bSelect = sal_False ) { return SimpleMove( &SwWrtShell::_NxtWrd, bSelect ); }
+ sal_Bool PrvWrd ( sal_Bool bSelect = sal_False ) { return SimpleMove( &SwWrtShell::_PrvWrd, bSelect ); }
+
+ sal_Bool LeftMargin ( sal_Bool bSelect, sal_Bool bBasicCall );
+ sal_Bool RightMargin( sal_Bool bSelect, sal_Bool bBasicCall );
+
+ sal_Bool SttDoc ( sal_Bool bSelect = sal_False );
+ sal_Bool EndDoc ( sal_Bool bSelect = sal_False );
+
+ sal_Bool SttNxtPg ( sal_Bool bSelect = sal_False );
+ sal_Bool SttPrvPg ( sal_Bool bSelect = sal_False );
+ sal_Bool EndNxtPg ( sal_Bool bSelect = sal_False );
+ sal_Bool EndPrvPg ( sal_Bool bSelect = sal_False );
+ sal_Bool SttPg ( sal_Bool bSelect = sal_False );
+ sal_Bool EndPg ( sal_Bool bSelect = sal_False );
+ sal_Bool SttPara ( sal_Bool bSelect = sal_False );
+ sal_Bool EndPara ( sal_Bool bSelect = sal_False );
+ sal_Bool FwdPara ( sal_Bool bSelect = sal_False )
+ { return SimpleMove( &SwWrtShell::_FwdPara, bSelect ); }
+ sal_Bool BwdPara ( sal_Bool bSelect = sal_False )
+ { return SimpleMove( &SwWrtShell::_BwdPara, bSelect ); }
+ sal_Bool FwdSentence( sal_Bool bSelect = sal_False )
+ { return SimpleMove( &SwWrtShell::_FwdSentence, bSelect ); }
+ sal_Bool BwdSentence( sal_Bool bSelect = sal_False )
+ { return SimpleMove( &SwWrtShell::_BwdSentence, bSelect ); }
+
+ // #i20126# Enhanced table selection
+ sal_Bool SelectTableRowCol( const Point& rPt, const Point* pEnd = 0, bool bRowDrag = false );
+ sal_Bool SelectTableRow();
+ sal_Bool SelectTableCol();
+ sal_Bool SelectTableCell();
+
+ sal_Bool SelectTxtAttr( sal_uInt16 nWhich, const SwTxtAttr* pAttr = 0 );
+
+ // per column jumps
+ sal_Bool StartOfColumn ( sal_Bool bSelect = sal_False );
+ sal_Bool EndOfColumn ( sal_Bool bSelect = sal_False );
+ sal_Bool StartOfNextColumn ( sal_Bool bSelect = sal_False );
+ sal_Bool EndOfNextColumn ( sal_Bool bSelect = sal_False );
+ sal_Bool StartOfPrevColumn ( sal_Bool bSelect = sal_False );
+ sal_Bool EndOfPrevColumn ( sal_Bool bSelect = sal_False );
+
+ // set the cursor to page "nPage" at the beginning
+ // additionally to a identically named implementation in crsrsh.hxx
+ // here all existing selections are being reset before setting the
+ // cursor
+ sal_Bool GotoPage( sal_uInt16 nPage, sal_Bool bRecord );
+
+ // setting the cursor; remember the old position for turning back
+ DECL_LINK( ExecFlyMac, void * );
+
+ sal_Bool PageCrsr(SwTwips lOffset, sal_Bool bSelect);
+
+ // update fields
+ void UpdateInputFlds( SwInputFieldList* pLst = 0 );
+
+ void NoEdit(bool bHideCrsr = true);
+ void Edit();
+
+ sal_Bool IsRetainSelection() const { return mbRetainSelection; }
+ void SetRetainSelection( sal_Bool bRet ) { mbRetainSelection = bRet; }
+
+ // change current data base and notify
+ void ChgDBData(const SwDBData& SwDBData);
+
+ // delete
+ long DelToEndOfLine();
+ long DelToStartOfLine();
+ long DelLine();
+ long DelLeft();
+
+ // also deletes the frame or sets the cursor in the frame when bDelFrm == sal_False
+ long DelRight();
+ long DelToEndOfPara();
+ long DelToStartOfPara();
+ long DelToEndOfSentence();
+ long DelToStartOfSentence();
+ long DelNxtWord();
+ long DelPrvWord();
+
+ // checks whether a word selection exists.
+ // According to the rules for intelligent Cut / Paste
+ // surrounding spaces are cut out.
+ // returns type of word selection (see enum)
+ enum word {
+ NO_WORD = 0,
+ WORD_SPACE_BEFORE = 1,
+ WORD_SPACE_AFTER = 2,
+ WORD_NO_SPACE = 3
+ };
+ int IntelligentCut(int nSelectionType, sal_Bool bCut = sal_True);
+
+ // edit
+ void Insert(SwField &);
+ void Insert(const OUString &);
+ // graphic
+ void Insert( const OUString &rPath, const OUString &rFilter,
+ const Graphic &, SwFlyFrmAttrMgr * = 0,
+ sal_Bool bRule = sal_False );
+
+ void InsertByWord( const OUString & );
+ void InsertPageBreak(const OUString *pPageDesc = 0, ::boost::optional<sal_uInt16> pPgNum = boost::none );
+ void InsertLineBreak();
+ void InsertColumnBreak();
+ void InsertFootnote(const OUString &, sal_Bool bEndNote = sal_False, sal_Bool bEdit = sal_True );
+ void SplitNode( sal_Bool bAutoFormat = sal_False, sal_Bool bCheckTableStart = sal_True );
+ bool CanInsert();
+
+ // indexes
+ void InsertTableOf(const SwTOXBase& rTOX, const SfxItemSet* pSet = 0);
+ sal_Bool UpdateTableOf(const SwTOXBase& rTOX, const SfxItemSet* pSet = 0);
+
+ // numbering and bullets
+ /**
+ Turns on numbering or bullets.
+
+ @param bNum sal_True: turn on numbering
+ sal_False: turn on bullets
+ */
+ void NumOrBulletOn(sal_Bool bNum); // #i29560#
+ void NumOrBulletOff(); // #i29560#
+ void NumOn();
+ void BulletOn();
+
+ //OLE
+ void InsertObject( /*SvInPlaceObjectRef *pObj, */ // != 0 for clipboard
+ const svt::EmbeddedObjectRef&,
+ SvGlobalName *pName = 0, // != 0 create object accordingly
+ sal_Bool bActivate = sal_True,
+ sal_uInt16 nSlotId = 0); // SlotId for dialog
+
+ sal_Bool InsertOleObject( const svt::EmbeddedObjectRef& xObj, SwFlyFrmFmt **pFlyFrmFmt = 0 );
+ void LaunchOLEObj( long nVerb = 0 ); // start server
+ virtual void MoveObjectIfActive( svt::EmbeddedObjectRef& xObj, const Point& rOffset );
+ virtual void CalcAndSetScale( svt::EmbeddedObjectRef& xObj,
+ const SwRect *pFlyPrtRect = 0,
+ const SwRect *pFlyFrmRect = 0,
+ const bool bNoTxtFrmPrtAreaChanged = false );
+ virtual void ConnectObj( svt::EmbeddedObjectRef& xIPObj, const SwRect &rPrt,
+ const SwRect &rFrm );
+
+ // styles and formats
+
+ // enum tells when should happen when the style was not found
+ enum GetStyle { GETSTYLE_NOCREATE, // create none
+ GETSTYLE_CREATESOME, // if on PoolId create mapt
+ GETSTYLE_CREATEANY }; // return standard if applicable
+
+ SwTxtFmtColl* GetParaStyle(const OUString &rCollName,
+ GetStyle eCreate = GETSTYLE_NOCREATE);
+ SwCharFmt* GetCharStyle(const OUString &rFmtName,
+ GetStyle eCreate = GETSTYLE_NOCREATE);
+ SwFrmFmt* GetTblStyle(const OUString &rFmtName);
+
+ void SetPageStyle(const OUString &rCollName);
+
+ OUString GetCurPageStyle( const sal_Bool bCalcFrm = sal_True ) const;
+
+ // change current style using the attributes in effect
+ void QuickUpdateStyle();
+
+ enum DoType { UNDO, REDO, REPEAT };
+
+ void Do( DoType eDoType, sal_uInt16 nCnt = 1 );
+ OUString GetDoString( DoType eDoType ) const;
+ OUString GetRepeatString() const;
+ sal_uInt16 GetDoStrings( DoType eDoType, SfxStringListItem& rStrLstItem ) const;
+
+ // search and replace
+ sal_uLong SearchPattern(const com::sun::star::util::SearchOptions& rSearchOpt,
+ sal_Bool bSearchInNotes,
+ SwDocPositions eStart, SwDocPositions eEnde,
+ FindRanges eFlags = FND_IN_BODY,
+ int bReplace = sal_False );
+
+ sal_uLong SearchTempl (const OUString &rTempl,
+ SwDocPositions eStart, SwDocPositions eEnde,
+ FindRanges eFlags = FND_IN_BODY,
+ const OUString* pReplTempl = 0 );
+
+ sal_uLong SearchAttr (const SfxItemSet& rFindSet,
+ sal_Bool bNoColls,
+ SwDocPositions eStart,SwDocPositions eEnde,
+ FindRanges eFlags = FND_IN_BODY,
+ const com::sun::star::util::SearchOptions* pSearchOpt = 0,
+ const SfxItemSet* pReplaceSet = 0);
+
+ void AutoCorrect( SvxAutoCorrect& rACorr, sal_Unicode cChar = ' ' );
+
+ // action ahead of cursor movement
+ // resets selection if applicable, triggers timer and GCAttr()
+ void MoveCrsr( sal_Bool bWithSelect = sal_False );
+
+ // update input fields
+ sal_Bool StartInputFldDlg(SwField*, sal_Bool bNextButton, Window* pParentWin = 0, OString* pWindowState = 0);
+ // update DropDown fields
+ sal_Bool StartDropDownFldDlg(SwField*, sal_Bool bNextButton, OString* pWindowState = 0);
+
+ //"Handler" for changes at DrawView - for controls.
+ virtual void DrawSelChanged( );
+
+ // jump to bookmark and set the "selctions-flags" correctly again
+ sal_Bool GotoMark( const ::sw::mark::IMark* const pMark );
+ sal_Bool GotoMark( const ::sw::mark::IMark* const pMark, sal_Bool bSelect, sal_Bool bStart );
+ sal_Bool GotoMark( const OUString& rName );
+ sal_Bool GoNextBookmark(); // sal_True when there still was one
+ sal_Bool GoPrevBookmark();
+
+ bool GotoFieldmark(::sw::mark::IFieldmark const * const pMark);
+
+ sal_Bool GotoField( const SwFmtFld& rFld );
+
+ // jump to the next / previous hyperlink - inside text and also
+ // on graphics
+ bool SelectNextPrevHyperlink( bool bNext = true );
+
+ // determine corresponding SwView
+ const SwView& GetView() const { return rView; }
+ SwView& GetView() { return rView; }
+
+ // Because nobody else is doing it, here is a ExecMacro()
+ void ExecMacro( const SvxMacro& rMacro, OUString* pRet = 0, SbxArray* pArgs = 0 );
+ // call into the dark Basic/JavaScript
+ sal_uInt16 CallEvent( sal_uInt16 nEvent, const SwCallMouseEvent& rCallEvent,
+ bool bCheckPtr = false, SbxArray* pArgs = 0,
+ const Link* pCallBack = 0 );
+
+ // a click at the given field. the cursor is on it.
+ // execute the predefined actions.
+ void ClickToField( const SwField& rFld );
+ void ClickToINetAttr( const SwFmtINetFmt& rItem, sal_uInt16 nFilter = URLLOAD_NOFILTER );
+ bool ClickToINetGrf( const Point& rDocPt, sal_uInt16 nFilter = URLLOAD_NOFILTER );
+ inline bool IsInClickToEdit() const ;
+
+ // if a URL-Button is selected, return its URL; otherwise an empty string
+ bool GetURLFromButton( OUString& rURL, OUString& rDescr ) const;
+
+ void NavigatorPaste( const NaviContentBookmark& rBkmk,
+ const sal_uInt16 nAction );
+
+ virtual void ApplyViewOptions( const SwViewOption &rOpt );
+ virtual void SetReadonlyOption( sal_Bool bSet );
+
+ // automatic update of styles
+ void AutoUpdateFrame(SwFrmFmt* pFmt, const SfxItemSet& rStyleSet);
+ void AutoUpdatePara(SwTxtFmtColl* pColl, const SfxItemSet& rStyleSet, SwPaM* pPaM = NULL );
+
+ // link for inserting ranges via Drag&Drop/Clipboard
+ DECL_STATIC_LINK( SwWrtShell, InsertRegionDialog, SwSectionData* );
+
+ // ctor, the first one is a kind of a controlled copy ctor for more views of a document
+ SwWrtShell( SwWrtShell&, Window *pWin, SwView &rShell);
+ SwWrtShell( SwDoc& rDoc, Window *pWin, SwView &rShell,
+ const SwViewOption *pViewOpt = 0);
+ virtual ~SwWrtShell();
+
+ bool TryRemoveIndent(); // #i23725#
+
+ OUString GetSelDescr() const;
+
+ SwNavigationMgr& GetNavigationMgr();
+ void addCurrentPosition();
+ sal_Bool GotoFly( const OUString& rName, FlyCntType eType = FLYCNTTYPE_ALL,
+ sal_Bool bSelFrame = sal_True );
+ bool GotoINetAttr( const SwTxtINetFmt& rAttr );
+ void GotoOutline( sal_uInt16 nIdx );
+ bool GotoOutline( const OUString& rName );
+ bool GotoRegion( const OUString& rName );
+ sal_Bool GotoRefMark( const OUString& rRefMark, sal_uInt16 nSubType = 0,
+ sal_uInt16 nSeqNo = 0 );
+ sal_Bool GotoNextTOXBase( const OUString* pName = 0);
+ bool GotoTable( const OUString& rName );
+ sal_Bool GotoFld( const SwFmtFld& rFld );
+ const SwRangeRedline* GotoRedline( sal_uInt16 nArrPos, sal_Bool bSelect = sal_False);
+
+ void ChangeHeaderOrFooter(const OUString& rStyleName, sal_Bool bHeader, sal_Bool bOn, sal_Bool bShowWarning);
+ virtual void SetShowHeaderFooterSeparator( FrameControlType eControl, bool bShow );
+
+private:
+
+ SAL_DLLPRIVATE void OpenMark();
+ SAL_DLLPRIVATE void CloseMark( bool bOkFlag );
+
+ struct ModeStack
+ {
+ ModeStack *pNext;
+ sal_Bool bAdd,
+ bBlock,
+ bExt,
+ bIns;
+ ModeStack(ModeStack *pNextMode, sal_Bool _bIns, sal_Bool _bExt, sal_Bool _bAdd, sal_Bool _bBlock):
+ pNext(pNextMode),
+ bAdd(_bAdd),
+ bBlock(_bBlock),
+ bExt(_bExt),
+ bIns(_bIns)
+ {}
+ } *pModeStack;
+
+ // carry cursor along when PageUp / -Down
+ enum PageMove
+ {
+ MV_NO,
+ MV_PAGE_UP,
+ MV_PAGE_DOWN
+ } ePageMove;
+
+ struct CrsrStack
+ {
+ Point aDocPos;
+ CrsrStack *pNext;
+ sal_Bool bValidCurPos : 1;
+ sal_Bool bIsFrmSel : 1;
+ SwTwips lOffset;
+
+ CrsrStack( sal_Bool bValid, sal_Bool bFrmSel, const Point &rDocPos,
+ SwTwips lOff, CrsrStack *pN )
+ : aDocPos(rDocPos),
+ pNext(pN),
+ bValidCurPos( bValid ),
+ bIsFrmSel( bFrmSel ),
+ lOffset(lOff)
+ {
+
+ }
+
+ } *pCrsrStack;
+
+ SwView &rView;
+ SwNavigationMgr aNavigationMgr;
+
+ Point aDest;
+ bool bDestOnStack;
+ bool HasCrsrStack() const { return 0 != pCrsrStack; }
+ SAL_DLLPRIVATE sal_Bool PushCrsr(SwTwips lOffset, sal_Bool bSelect);
+ SAL_DLLPRIVATE sal_Bool PopCrsr(sal_Bool bUpdate, sal_Bool bSelect = sal_False);
+
+ // take END cursor along when PageUp / -Down
+ SAL_DLLPRIVATE bool _SttWrd();
+ SAL_DLLPRIVATE bool _EndWrd();
+ SAL_DLLPRIVATE sal_Bool _NxtWrd();
+ SAL_DLLPRIVATE sal_Bool _PrvWrd();
+ // #i92468#
+ SAL_DLLPRIVATE sal_Bool _NxtWrdForDelete();
+ SAL_DLLPRIVATE sal_Bool _PrvWrdForDelete();
+ SAL_DLLPRIVATE sal_Bool _FwdSentence();
+ SAL_DLLPRIVATE sal_Bool _BwdSentence();
+ sal_Bool _FwdPara();
+ SAL_DLLPRIVATE sal_Bool _BwdPara();
+
+ // selections
+ sal_Bool bIns :1;
+ sal_Bool bInSelect :1;
+ sal_Bool bExtMode :1;
+ sal_Bool bAddMode :1;
+ sal_Bool bBlockMode :1;
+ sal_Bool bLayoutMode :1;
+ sal_Bool bCopy :1;
+ sal_Bool bSelWrd :1;
+ sal_Bool bSelLn :1;
+ bool bIsInClickToEdit:1;
+ sal_Bool bClearMark :1; // don't delete selection for ChartAutoPilot
+ sal_Bool mbRetainSelection :1; // Do not remove selections
+
+ Point aStart;
+ Link aSelTblLink;
+
+ // resets the cursor stack after movement by PageUp/-Down
+ SAL_DLLPRIVATE void _ResetCursorStack();
+
+ SAL_DLLPRIVATE void SttDragDrop(Timer *);
+
+ using SwCrsrShell::SetCrsr;
+ SAL_DLLPRIVATE long SetCrsr(const Point *, sal_Bool bProp=sal_False );
+
+ SAL_DLLPRIVATE long SetCrsrKillSel(const Point *, sal_Bool bProp=sal_False );
+
+ SAL_DLLPRIVATE long StdSelect(const Point *, sal_Bool bProp=sal_False );
+ SAL_DLLPRIVATE long BeginDrag(const Point *, sal_Bool bProp=sal_False );
+ SAL_DLLPRIVATE long Drag(const Point *, sal_Bool bProp=sal_False );
+ SAL_DLLPRIVATE long EndDrag(const Point *, sal_Bool bProp=sal_False );
+
+ SAL_DLLPRIVATE long ExtSelWrd(const Point *, sal_Bool bProp=sal_False );
+ SAL_DLLPRIVATE long ExtSelLn(const Point *, sal_Bool bProp=sal_False );
+
+ // move text from Drag and Drop; Point is destination for all selections.
+ SAL_DLLPRIVATE long MoveText(const Point *, sal_Bool bProp=sal_False );
+
+ SAL_DLLPRIVATE long BeginFrmDrag(const Point *, sal_Bool bProp=sal_False );
+
+ // after SSize/Move of a frame update; Point is destination.
+ SAL_DLLPRIVATE long UpdateLayoutFrm(const Point *, sal_Bool bProp=sal_False );
+
+ SAL_DLLPRIVATE long SttLeaveSelect(const Point *, sal_Bool bProp=sal_False );
+ SAL_DLLPRIVATE long AddLeaveSelect(const Point *, sal_Bool bProp=sal_False );
+ SAL_DLLPRIVATE long Ignore(const Point *, sal_Bool bProp=sal_False );
+
+ SAL_DLLPRIVATE void LeaveExtSel() { bSelWrd = bSelLn = sal_False;}
+
+ SAL_DLLPRIVATE sal_Bool GoStart(sal_Bool KeepArea = sal_False, sal_Bool * = 0,
+ sal_Bool bSelect = sal_False, sal_Bool bDontMoveRegion = sal_False);
+ SAL_DLLPRIVATE sal_Bool GoEnd(sal_Bool KeepArea = sal_False, sal_Bool * = 0);
+
+ enum BookMarkMove
+ {
+ BOOKMARK_INDEX,
+ BOOKMARK_NEXT,
+ BOOKMARK_PREV,
+ BOOKMARK_LAST_LAST_ENTRY
+ };
+
+ SAL_DLLPRIVATE sal_Bool MoveBookMark(BookMarkMove eFuncId, const ::sw::mark::IMark* const pMark=NULL);
+};
+
+inline void SwWrtShell::ResetCursorStack()
+{
+ if ( HasCrsrStack() )
+ _ResetCursorStack();
+}
+
+inline void SwWrtShell::SelTblCells(const Link &rLink, sal_Bool bMark )
+{
+ SetSelTblCells( sal_True );
+ bClearMark = bMark;
+ aSelTblLink = rLink;
+}
+inline void SwWrtShell::EndSelTblCells()
+{
+ SetSelTblCells( sal_False );
+ bClearMark = sal_True;
+}
+
+inline bool SwWrtShell::IsInClickToEdit() const { return bIsInClickToEdit; }
+
+inline bool SwWrtShell::Is_FnDragEQBeginDrag() const
+{
+#ifdef __GNUC__
+ SELECTFUNC fnTmp = &SwWrtShell::BeginDrag;
+ return fnDrag == fnTmp;
+#else
+ return fnDrag == &SwWrtShell::BeginDrag;
+#endif
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/wtabsh.hxx b/sw/source/core/uibase/inc/wtabsh.hxx
new file mode 100644
index 000000000000..64f25bcb4ed4
--- /dev/null
+++ b/sw/source/core/uibase/inc/wtabsh.hxx
@@ -0,0 +1,36 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_WTABSH_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_WTABSH_HXX
+
+#include "tabsh.hxx"
+
+class SwWebTableShell: public SwTableShell
+{
+public:
+ SFX_DECL_INTERFACE(SW_WEBTABSHELL)
+ TYPEINFO();
+
+ virtual ~SwWebTableShell();
+ SwWebTableShell(SwView &rView);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/wtextsh.hxx b/sw/source/core/uibase/inc/wtextsh.hxx
new file mode 100644
index 000000000000..3a236f7ce307
--- /dev/null
+++ b/sw/source/core/uibase/inc/wtextsh.hxx
@@ -0,0 +1,38 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SW_SOURCE_UI_INC_WTEXTSH_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_WTEXTSH_HXX
+
+#include "textsh.hxx"
+
+class SwWebTextShell: public SwTextShell
+{
+
+public:
+ SFX_DECL_INTERFACE(SW_WEBTEXTSHELL)
+ TYPEINFO();
+
+ SwWebTextShell(SwView &rView);
+ virtual ~SwWebTextShell();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/wview.hxx b/sw/source/core/uibase/inc/wview.hxx
new file mode 100644
index 000000000000..873f7a720648
--- /dev/null
+++ b/sw/source/core/uibase/inc/wview.hxx
@@ -0,0 +1,41 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_WVIEW_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_WVIEW_HXX
+
+#include "swdllapi.h"
+#include "view.hxx"
+
+class SW_DLLPUBLIC SwWebView: public SwView
+{
+protected:
+ virtual void SelectShell();
+public:
+
+ SFX_DECL_VIEWFACTORY(SwWebView);
+ SFX_DECL_INTERFACE(SW_WEBVIEWSHELL)
+ TYPEINFO();
+
+ SwWebView(SfxViewFrame* pFrame, SfxViewShell*);
+ ~SwWebView();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/inc/zoomctrl.hxx b/sw/source/core/uibase/inc/zoomctrl.hxx
new file mode 100644
index 000000000000..89818fdf4f72
--- /dev/null
+++ b/sw/source/core/uibase/inc/zoomctrl.hxx
@@ -0,0 +1,43 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_INC_ZOOMCTRL_HXX
+#define INCLUDED_SW_SOURCE_UI_INC_ZOOMCTRL_HXX
+
+#include <svx/zoomctrl.hxx>
+
+class SwZoomControl : public SvxZoomStatusBarControl
+{
+private:
+ OUString sPreviewZoom;
+public:
+ virtual void Command( const CommandEvent& rCEvt );
+ virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState,
+ const SfxPoolItem* pState );
+ virtual void Paint( const UserDrawEvent& rEvt );
+
+ SFX_DECL_STATUSBAR_CONTROL();
+
+ SwZoomControl( sal_uInt16 nSlotId, sal_uInt16 nId, StatusBar& rStb );
+ ~SwZoomControl();
+
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/index/idxmrk.cxx b/sw/source/core/uibase/index/idxmrk.cxx
new file mode 100644
index 000000000000..7a717fd42939
--- /dev/null
+++ b/sw/source/core/uibase/index/idxmrk.cxx
@@ -0,0 +1,114 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <hintids.hxx>
+#include <helpid.h>
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/util/SearchOptions.hpp>
+#include <com/sun/star/util/SearchFlags.hpp>
+#include <com/sun/star/i18n/TransliterationModules.hpp>
+#include <svl/stritem.hxx>
+#include <vcl/msgbox.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svl/eitem.hxx>
+#include <unotools/textsearch.hxx>
+#include <editeng/scripttypeitem.hxx>
+#include <svl/itemset.hxx>
+#include <editeng/langitem.hxx>
+#include <swtypes.hxx>
+#include <idxmrk.hxx>
+#include <txttxmrk.hxx>
+#include <wrtsh.hxx>
+#include <view.hxx>
+#include <multmrk.hxx>
+#include <swundo.hxx>
+#include <cmdid.h>
+#include <index.hrc>
+#include <idxmrk.hrc>
+#include <swmodule.hxx>
+#include <fldmgr.hxx>
+#include <fldbas.hxx>
+#include <utlui.hrc>
+#include <swcont.hxx>
+#include <svl/cjkoptions.hxx>
+#include <ndtxt.hxx>
+#include <breakit.hxx>
+
+SFX_IMPL_CHILDWINDOW_WITHID(SwInsertIdxMarkWrapper, FN_INSERT_IDX_ENTRY_DLG)
+
+SwInsertIdxMarkWrapper::SwInsertIdxMarkWrapper( Window *pParentWindow,
+ sal_uInt16 nId,
+ SfxBindings* pBindings,
+ SfxChildWinInfo* pInfo ) :
+ SfxChildWindow(pParentWindow, nId)
+{
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+ pAbstDlg = pFact->CreateIndexMarkFloatDlg(pBindings, this, pParentWindow, pInfo);
+ OSL_ENSURE(pAbstDlg, "Dialogdiet fail!");
+ pWindow = pAbstDlg->GetWindow();
+ pWindow->Show(); // at this point,because before pSh has to be initialized in ReInitDlg()
+ // -> Show() will invoke StateChanged() and save pos
+ eChildAlignment = SFX_ALIGN_NOALIGNMENT;
+}
+
+SfxChildWinInfo SwInsertIdxMarkWrapper::GetInfo() const
+{
+ SfxChildWinInfo aInfo = SfxChildWindow::GetInfo();
+
+ return aInfo;
+}
+
+void SwInsertIdxMarkWrapper::ReInitDlg(SwWrtShell& rWrtShell)
+{
+ pAbstDlg->ReInitDlg(rWrtShell);
+}
+
+SFX_IMPL_CHILDWINDOW_WITHID(SwInsertAuthMarkWrapper, FN_INSERT_AUTH_ENTRY_DLG)
+
+SwInsertAuthMarkWrapper::SwInsertAuthMarkWrapper( Window *pParentWindow,
+ sal_uInt16 nId,
+ SfxBindings* pBindings,
+ SfxChildWinInfo* pInfo ) :
+ SfxChildWindow(pParentWindow, nId)
+{
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+ pAbstDlg = pFact->CreateAuthMarkFloatDlg(pBindings, this, pParentWindow, pInfo);
+ OSL_ENSURE(pAbstDlg, "Dialogdiet fail!");
+ pWindow = pAbstDlg->GetWindow();
+
+ eChildAlignment = SFX_ALIGN_NOALIGNMENT;
+}
+
+SfxChildWinInfo SwInsertAuthMarkWrapper::GetInfo() const
+{
+ SfxChildWinInfo aInfo = SfxChildWindow::GetInfo();
+ return aInfo;
+}
+
+void SwInsertAuthMarkWrapper::ReInitDlg(SwWrtShell& rWrtShell)
+{
+ pAbstDlg->ReInitDlg(rWrtShell);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/index/idxmrk.hrc b/sw/source/core/uibase/index/idxmrk.hrc
new file mode 100644
index 000000000000..2a748b70bd63
--- /dev/null
+++ b/sw/source/core/uibase/index/idxmrk.hrc
@@ -0,0 +1,26 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#define PB_OK 22
+#define PB_CANCEL 23
+#define PB_HELP 24
+#define FL_NAME 37
+#define FT_NAME 38
+#define ED_NAME 39
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/index/toxmgr.cxx b/sw/source/core/uibase/index/toxmgr.cxx
new file mode 100644
index 000000000000..62875171feaf
--- /dev/null
+++ b/sw/source/core/uibase/index/toxmgr.cxx
@@ -0,0 +1,525 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <wrtsh.hxx>
+#include <shellres.hxx>
+#include <swwait.hxx>
+#include <view.hxx>
+#include <toxmgr.hxx>
+#include <crsskip.hxx>
+#include <doc.hxx>
+#include <IDocumentUndoRedo.hxx>
+#include <swundo.hxx>
+#include <globals.hrc>
+
+/*--------------------------------------------------------------------
+ Description: handle indexes with TOXMgr
+ --------------------------------------------------------------------*/
+
+SwTOXMgr::SwTOXMgr(SwWrtShell* pShell):
+ pSh(pShell)
+{
+ GetTOXMarks();
+ SetCurTOXMark(0);
+}
+
+/*--------------------------------------------------------------------
+ Description: handle current TOXMarks
+ --------------------------------------------------------------------*/
+
+sal_uInt16 SwTOXMgr::GetTOXMarks()
+{
+ return pSh->GetCurTOXMarks(aCurMarks);
+}
+
+SwTOXMark* SwTOXMgr::GetTOXMark(sal_uInt16 nId)
+{
+ if(!aCurMarks.empty())
+ return aCurMarks[nId];
+ return 0;
+}
+
+void SwTOXMgr::DeleteTOXMark()
+{
+ SwTOXMark* pNext = 0;
+ if( pCurTOXMark )
+ {
+ pNext = (SwTOXMark*)&pSh->GotoTOXMark( *pCurTOXMark, TOX_NXT );
+ if( pNext == pCurTOXMark )
+ pNext = 0;
+
+ pSh->DeleteTOXMark( pCurTOXMark );
+ pSh->SetModified();
+ }
+ // go to next one
+ pCurTOXMark = pNext;
+}
+
+void SwTOXMgr::InsertTOXMark(const SwTOXMarkDescription& rDesc)
+{
+ SwTOXMark* pMark = 0;
+ switch(rDesc.GetTOXType())
+ {
+ case TOX_CONTENT:
+ {
+ OSL_ENSURE(rDesc.GetLevel() > 0 && rDesc.GetLevel() <= MAXLEVEL,
+ "invalid InsertTOCMark level");
+ pMark = new SwTOXMark(pSh->GetTOXType(TOX_CONTENT, 0));
+ pMark->SetLevel( static_cast< sal_uInt16 >(rDesc.GetLevel()) );
+
+ if(rDesc.GetAltStr())
+ pMark->SetAlternativeText(*rDesc.GetAltStr());
+ }
+ break;
+ case TOX_INDEX:
+ {
+ pMark = new SwTOXMark(pSh->GetTOXType(TOX_INDEX, 0));
+
+ if( rDesc.GetPrimKey() && !rDesc.GetPrimKey()->isEmpty() )
+ {
+ pMark->SetPrimaryKey( *rDesc.GetPrimKey() );
+ if(rDesc.GetPhoneticReadingOfPrimKey())
+ pMark->SetPrimaryKeyReading( *rDesc.GetPhoneticReadingOfPrimKey() );
+
+ if( rDesc.GetSecKey() && !rDesc.GetSecKey()->isEmpty() )
+ {
+ pMark->SetSecondaryKey( *rDesc.GetSecKey() );
+ if(rDesc.GetPhoneticReadingOfSecKey())
+ pMark->SetSecondaryKeyReading( *rDesc.GetPhoneticReadingOfSecKey() );
+ }
+ }
+ if(rDesc.GetAltStr())
+ pMark->SetAlternativeText(*rDesc.GetAltStr());
+ if(rDesc.GetPhoneticReadingOfAltStr())
+ pMark->SetTextReading( *rDesc.GetPhoneticReadingOfAltStr() );
+ pMark->SetMainEntry(rDesc.IsMainEntry());
+ }
+ break;
+ case TOX_USER:
+ {
+ OSL_ENSURE(rDesc.GetLevel() > 0 && rDesc.GetLevel() <= MAXLEVEL,
+ "invalid InsertTOCMark level");
+ sal_uInt16 nId = rDesc.GetTOUName() ?
+ GetUserTypeID(*rDesc.GetTOUName()) : 0;
+ pMark = new SwTOXMark(pSh->GetTOXType(TOX_USER, nId));
+ pMark->SetLevel( static_cast< sal_uInt16 >(rDesc.GetLevel()) );
+
+ if(rDesc.GetAltStr())
+ pMark->SetAlternativeText(*rDesc.GetAltStr());
+ }
+ break;
+ case TOX_BIBLIOGRAPHY:
+ {
+ pMark = new SwTOXMark(pSh->GetTOXType(TOX_BIBLIOGRAPHY, 0));
+
+ if( rDesc.GetPrimKey() && !rDesc.GetPrimKey()->isEmpty() )
+ {
+ pMark->SetPrimaryKey( *rDesc.GetPrimKey() );
+ if(rDesc.GetPhoneticReadingOfPrimKey())
+ pMark->SetPrimaryKeyReading( *rDesc.GetPhoneticReadingOfPrimKey() );
+
+ if( rDesc.GetSecKey() && !rDesc.GetSecKey()->isEmpty() )
+ {
+ pMark->SetSecondaryKey( *rDesc.GetSecKey() );
+ if(rDesc.GetPhoneticReadingOfSecKey())
+ pMark->SetSecondaryKeyReading( *rDesc.GetPhoneticReadingOfSecKey() );
+ }
+ }
+ if(rDesc.GetAltStr())
+ pMark->SetAlternativeText(*rDesc.GetAltStr());
+ if(rDesc.GetPhoneticReadingOfAltStr())
+ pMark->SetTextReading( *rDesc.GetPhoneticReadingOfAltStr() );
+ pMark->SetMainEntry(rDesc.IsMainEntry());
+ }
+ break;
+ default:; //prevent warning
+ }
+ pSh->StartAllAction();
+ pSh->SwEditShell::Insert(*pMark);
+ pSh->EndAllAction();
+}
+/*--------------------------------------------------------------------
+ Description: Update of TOXMarks
+ --------------------------------------------------------------------*/
+
+void SwTOXMgr::UpdateTOXMark(const SwTOXMarkDescription& rDesc)
+{
+ OSL_ENSURE(pCurTOXMark, "no current TOXMark");
+
+ pSh->StartAllAction();
+ if(pCurTOXMark->GetTOXType()->GetType() == TOX_INDEX)
+ {
+ if(rDesc.GetPrimKey() && !rDesc.GetPrimKey()->isEmpty() )
+ {
+ pCurTOXMark->SetPrimaryKey( *rDesc.GetPrimKey() );
+ if(rDesc.GetPhoneticReadingOfPrimKey())
+ pCurTOXMark->SetPrimaryKeyReading( *rDesc.GetPhoneticReadingOfPrimKey() );
+ else
+ pCurTOXMark->SetPrimaryKeyReading( aEmptyOUStr );
+
+ if( rDesc.GetSecKey() && !rDesc.GetSecKey()->isEmpty() )
+ {
+ pCurTOXMark->SetSecondaryKey( *rDesc.GetSecKey() );
+ if(rDesc.GetPhoneticReadingOfSecKey())
+ pCurTOXMark->SetSecondaryKeyReading( *rDesc.GetPhoneticReadingOfSecKey() );
+ else
+ pCurTOXMark->SetSecondaryKeyReading( aEmptyOUStr );
+ }
+ else
+ {
+ pCurTOXMark->SetSecondaryKey( aEmptyOUStr );
+ pCurTOXMark->SetSecondaryKeyReading( aEmptyOUStr );
+ }
+ }
+ else
+ {
+ pCurTOXMark->SetPrimaryKey( aEmptyOUStr );
+ pCurTOXMark->SetPrimaryKeyReading( aEmptyOUStr );
+ pCurTOXMark->SetSecondaryKey( aEmptyOUStr );
+ pCurTOXMark->SetSecondaryKeyReading( aEmptyOUStr );
+ }
+ if(rDesc.GetPhoneticReadingOfAltStr())
+ pCurTOXMark->SetTextReading( *rDesc.GetPhoneticReadingOfAltStr() );
+ else
+ pCurTOXMark->SetTextReading( aEmptyOUStr );
+ pCurTOXMark->SetMainEntry(rDesc.IsMainEntry());
+ }
+ else
+ pCurTOXMark->SetLevel( static_cast< sal_uInt16 >(rDesc.GetLevel()) );
+
+ if(rDesc.GetAltStr())
+ {
+ // JP 26.08.96: Bug 30344 - either the text of a Doc or an alternative test,
+ // not both!
+ sal_Bool bReplace = pCurTOXMark->IsAlternativeText();
+ if( bReplace )
+ pCurTOXMark->SetAlternativeText( *rDesc.GetAltStr() );
+ else
+ {
+ SwTOXMark aCpy( *pCurTOXMark );
+ aCurMarks.clear();
+ pSh->DeleteTOXMark(pCurTOXMark);
+ aCpy.SetAlternativeText( *rDesc.GetAltStr() );
+ pSh->SwEditShell::Insert( aCpy );
+ pCurTOXMark = 0;
+ }
+ }
+ pSh->SetModified();
+ pSh->EndAllAction();
+ // Bug 36207 pCurTOXMark points nowhere here!
+ if(!pCurTOXMark)
+ {
+ pSh->Left(CRSR_SKIP_CHARS, sal_False, 1, sal_False );
+ pSh->GetCurTOXMarks(aCurMarks);
+ SetCurTOXMark(0);
+ }
+}
+
+/*--------------------------------------------------------------------
+ Description: determine UserTypeID
+ --------------------------------------------------------------------*/
+
+sal_uInt16 SwTOXMgr::GetUserTypeID(const OUString& rStr)
+{
+ sal_uInt16 nSize = pSh->GetTOXTypeCount(TOX_USER);
+ for(sal_uInt16 i=0; i < nSize; ++i)
+ {
+ const SwTOXType* pTmp = pSh->GetTOXType(TOX_USER, i);
+ if(pTmp && pTmp->GetTypeName() == rStr)
+ return i;
+ }
+ SwTOXType aUserType(TOX_USER, rStr);
+ pSh->InsertTOXType(aUserType);
+ return nSize;
+}
+
+/*--------------------------------------------------------------------
+ Description: traveling between TOXMarks
+ --------------------------------------------------------------------*/
+
+void SwTOXMgr::NextTOXMark(sal_Bool bSame)
+{
+ OSL_ENSURE(pCurTOXMark, "no current TOXMark");
+ if( pCurTOXMark )
+ {
+ SwTOXSearch eDir = bSame ? TOX_SAME_NXT : TOX_NXT;
+ pCurTOXMark = (SwTOXMark*)&pSh->GotoTOXMark( *pCurTOXMark, eDir );
+ }
+}
+
+void SwTOXMgr::PrevTOXMark(sal_Bool bSame)
+{
+ OSL_ENSURE(pCurTOXMark, "no current TOXMark");
+ if( pCurTOXMark )
+ {
+ SwTOXSearch eDir = bSame ? TOX_SAME_PRV : TOX_PRV;
+ pCurTOXMark = (SwTOXMark*)&pSh->GotoTOXMark(*pCurTOXMark, eDir );
+ }
+}
+
+/*--------------------------------------------------------------------
+ Description: insert keyword index
+ --------------------------------------------------------------------*/
+const SwTOXBase* SwTOXMgr::GetCurTOX()
+{
+ return pSh->GetCurTOX();
+}
+
+const SwTOXType* SwTOXMgr::GetTOXType(TOXTypes eTyp, sal_uInt16 nId) const
+{
+ return pSh->GetTOXType(eTyp, nId);
+}
+
+void SwTOXMgr::SetCurTOXMark(sal_uInt16 nId)
+{
+ pCurTOXMark = (nId < aCurMarks.size()) ? aCurMarks[nId] : 0;
+}
+
+sal_Bool SwTOXMgr::UpdateOrInsertTOX(const SwTOXDescription& rDesc,
+ SwTOXBase** ppBase,
+ const SfxItemSet* pSet)
+{
+ SwWait aWait( *pSh->GetView().GetDocShell(), true );
+ sal_Bool bRet = sal_True;
+ const SwTOXBase* pCurTOX = ppBase && *ppBase ? *ppBase : GetCurTOX();
+ SwTOXBase* pTOX = (SwTOXBase*)pCurTOX;
+
+ SwTOXBase * pNewTOX = NULL;
+
+ if (pTOX)
+ pNewTOX = new SwTOXBase(*pTOX);
+
+ TOXTypes eCurTOXType = rDesc.GetTOXType();
+ if(pCurTOX && !ppBase && pSh->HasSelection())
+ pSh->EnterStdMode();
+
+ switch(eCurTOXType)
+ {
+ case TOX_INDEX :
+ {
+ if(!pCurTOX || (ppBase && !(*ppBase)))
+ {
+ const SwTOXType* pType = pSh->GetTOXType(eCurTOXType, 0);
+ SwForm aForm(eCurTOXType);
+ pNewTOX = new SwTOXBase(pType, aForm, nsSwTOXElement::TOX_MARK, pType->GetTypeName());
+ }
+ pNewTOX->SetOptions(rDesc.GetIndexOptions());
+ pNewTOX->SetMainEntryCharStyle(rDesc.GetMainEntryCharStyle());
+ pSh->SetTOIAutoMarkURL(rDesc.GetAutoMarkURL());
+ pSh->ApplyAutoMark();
+ }
+ break;
+ case TOX_CONTENT :
+ {
+ if(!pCurTOX || (ppBase && !(*ppBase)))
+ {
+ const SwTOXType* pType = pSh->GetTOXType(eCurTOXType, 0);
+ SwForm aForm(eCurTOXType);
+ pNewTOX = new SwTOXBase(pType, aForm, rDesc.GetContentOptions(), pType->GetTypeName());
+ }
+ pNewTOX->SetCreate(rDesc.GetContentOptions());
+ pNewTOX->SetLevel(rDesc.GetLevel());
+ }
+ break;
+ case TOX_USER :
+ {
+ if(!pCurTOX || (ppBase && !(*ppBase)))
+ {
+ sal_uInt16 nPos = 0;
+ sal_uInt16 nSize = pSh->GetTOXTypeCount(eCurTOXType);
+ for(sal_uInt16 i=0; rDesc.GetTOUName() && i < nSize; ++i)
+ { const SwTOXType* pType = pSh->GetTOXType(TOX_USER, i);
+ if(pType->GetTypeName() == *rDesc.GetTOUName())
+ { nPos = i;
+ break;
+ }
+ }
+ const SwTOXType* pType = pSh->GetTOXType(eCurTOXType, nPos);
+
+ SwForm aForm(eCurTOXType);
+ pNewTOX = new SwTOXBase(pType, aForm, rDesc.GetContentOptions(), pType->GetTypeName());
+
+ }
+ else
+ {
+ const_cast<SwTOXBase*>( pCurTOX )->SetCreate(rDesc.GetContentOptions());
+ }
+ pNewTOX->SetLevelFromChapter(rDesc.IsLevelFromChapter());
+ }
+ break;
+ case TOX_OBJECTS:
+ case TOX_TABLES:
+ case TOX_AUTHORITIES:
+ case TOX_BIBLIOGRAPHY:
+ case TOX_ILLUSTRATIONS:
+ {
+ //Special handling for TOX_AUTHORITY
+ if(TOX_AUTHORITIES == eCurTOXType)
+ {
+ SwAuthorityFieldType* pFType = (SwAuthorityFieldType*)
+ pSh->GetFldType(RES_AUTHORITY, aEmptyOUStr);
+ if (!pFType)
+ {
+ SwAuthorityFieldType const type(pSh->GetDoc());
+ pFType = static_cast<SwAuthorityFieldType*>(
+ pSh->InsertFldType(type));
+ }
+ pFType->SetPreSuffix(rDesc.GetAuthBrackets()[0],
+ rDesc.GetAuthBrackets()[1]);
+ pFType->SetSequence(rDesc.IsAuthSequence());
+ SwTOXSortKey rArr[3];
+ rArr[0] = rDesc.GetSortKey1();
+ rArr[1] = rDesc.GetSortKey2();
+ rArr[2] = rDesc.GetSortKey3();
+ pFType->SetSortKeys(3, rArr);
+ pFType->SetSortByDocument(rDesc.IsSortByDocument());
+ pFType->SetLanguage(rDesc.GetLanguage());
+ pFType->SetSortAlgorithm(rDesc.GetSortAlgorithm());
+
+ pFType->UpdateFlds();
+ }
+ // TODO: consider properties of the current TOXType
+ if(!pCurTOX || (ppBase && !(*ppBase)))
+ {
+ const SwTOXType* pType = pSh->GetTOXType(eCurTOXType, 0);
+ SwForm aForm(eCurTOXType);
+ pNewTOX = new SwTOXBase(
+ pType, aForm,
+ TOX_AUTHORITIES == eCurTOXType ? nsSwTOXElement::TOX_MARK : 0, pType->GetTypeName());
+ }
+ else
+ {
+ if((!ppBase || !(*ppBase)) && pSh->HasSelection())
+ pSh->DelRight();
+ pNewTOX = (SwTOXBase*)pCurTOX;
+ }
+ pNewTOX->SetFromObjectNames(rDesc.IsCreateFromObjectNames());
+ pNewTOX->SetOLEOptions(rDesc.GetOLEOptions());
+ }
+ break;
+ }
+
+ OSL_ENSURE(pNewTOX, "no TOXBase created!" );
+ if(!pNewTOX)
+ return sal_False;
+
+ pNewTOX->SetFromChapter(rDesc.IsFromChapter());
+ pNewTOX->SetSequenceName(rDesc.GetSequenceName());
+ pNewTOX->SetCaptionDisplay(rDesc.GetCaptionDisplay());
+ pNewTOX->SetProtected(rDesc.IsReadonly());
+
+ for(sal_uInt16 nLevel = 0; nLevel < MAXLEVEL; nLevel++)
+ pNewTOX->SetStyleNames(rDesc.GetStyleNames(nLevel), nLevel);
+
+ if(rDesc.GetTitle())
+ pNewTOX->SetTitle(*rDesc.GetTitle());
+ if(rDesc.GetForm())
+ pNewTOX->SetTOXForm(*rDesc.GetForm());
+ pNewTOX->SetLanguage(rDesc.GetLanguage());
+ pNewTOX->SetSortAlgorithm(rDesc.GetSortAlgorithm());
+
+ if(!pCurTOX || (ppBase && !(*ppBase)) )
+ {
+ // when ppBase is passed over, TOXBase is only created here
+ // and then inserted in a global document by the dialog
+ if(ppBase)
+ (*ppBase) = pNewTOX;
+ else
+ {
+ pSh->InsertTableOf(*pNewTOX, pSet);
+ delete pNewTOX;
+ }
+ }
+ else
+ {
+ SwDoc * pDoc = pSh->GetDoc();
+
+ if (pDoc->GetIDocumentUndoRedo().DoesUndo())
+ {
+ if (pNewTOX != NULL)
+ {
+ pDoc->GetIDocumentUndoRedo().DelAllUndoObj();
+ }
+
+ pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_TOXCHANGE, NULL);
+ }
+
+ if (pNewTOX != NULL) // => pTOX != NULL
+ pDoc->ChgTOX(*pTOX, *pNewTOX);
+
+ pTOX->DisableKeepExpression();
+ bRet = pSh->UpdateTableOf(*pTOX, pSet);
+ pTOX->EnableKeepExpression();
+
+ if (pDoc->GetIDocumentUndoRedo().DoesUndo())
+ {
+ pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_TOXCHANGE, NULL);
+
+ if (pNewTOX == NULL)
+ {
+ pDoc->GetIDocumentUndoRedo().DelAllUndoObj();
+ }
+ }
+ }
+
+ return bRet;
+}
+
+void SwTOXDescription::SetSortKeys(SwTOXSortKey eKey1,
+ SwTOXSortKey eKey2,
+ SwTOXSortKey eKey3)
+{
+ SwTOXSortKey aArr[3];
+ sal_uInt16 nPos = 0;
+ if(AUTH_FIELD_END > eKey1.eField)
+ aArr[nPos++] = eKey1;
+ if(AUTH_FIELD_END > eKey2.eField)
+ aArr[nPos++] = eKey2;
+ if(AUTH_FIELD_END > eKey3.eField)
+ aArr[nPos++] = eKey3;
+
+ eSortKey1 = aArr[0];
+ eSortKey2 = aArr[1];
+ eSortKey3 = aArr[2];
+}
+
+void SwTOXDescription::ApplyTo(SwTOXBase& rTOXBase)
+{
+ for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
+ rTOXBase.SetStyleNames(GetStyleNames(i), i);
+ rTOXBase.SetTitle(GetTitle() ? *GetTitle() : OUString());
+ rTOXBase.SetCreate(GetContentOptions());
+
+ if(GetTOXType() == TOX_INDEX)
+ rTOXBase.SetOptions(GetIndexOptions());
+ if(GetTOXType() != TOX_INDEX)
+ rTOXBase.SetLevel(GetLevel());
+ rTOXBase.SetFromObjectNames(IsCreateFromObjectNames());
+ rTOXBase.SetSequenceName(GetSequenceName());
+ rTOXBase.SetCaptionDisplay(GetCaptionDisplay());
+ rTOXBase.SetFromChapter(IsFromChapter());
+ rTOXBase.SetProtected(IsReadonly());
+ rTOXBase.SetOLEOptions(GetOLEOptions());
+ rTOXBase.SetLevelFromChapter(IsLevelFromChapter());
+ rTOXBase.SetLanguage(eLanguage);
+ rTOXBase.SetSortAlgorithm(sSortAlgorithm);
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/lingu/hhcwrp.cxx b/sw/source/core/uibase/lingu/hhcwrp.cxx
new file mode 100644
index 000000000000..b5d1950f24f3
--- /dev/null
+++ b/sw/source/core/uibase/lingu/hhcwrp.cxx
@@ -0,0 +1,720 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <hintids.hxx>
+#include <view.hxx>
+#include <wrtsh.hxx>
+#include <swundo.hxx>
+#include <globals.hrc>
+#include <splargs.hxx>
+
+#include <vcl/msgbox.hxx>
+#include <editeng/unolingu.hxx>
+#include <editeng/langitem.hxx>
+#include <editeng/fontitem.hxx>
+#include <rtl/ustring.hxx>
+#include <com/sun/star/text/RubyAdjust.hpp>
+#include <hhcwrp.hxx>
+#include <sdrhhcwrap.hxx>
+#include <doc.hxx>
+#include <docsh.hxx>
+#include <mdiexp.hxx>
+#include <edtwin.hxx>
+#include <crsskip.hxx>
+#include <index.hxx>
+#include <pam.hxx>
+#include <swcrsr.hxx>
+#include <viscrs.hxx>
+#include <ndtxt.hxx>
+#include <fmtruby.hxx>
+#include <breakit.hxx>
+
+#include <olmenu.hrc>
+
+#include <unomid.h>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::text;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::linguistic2;
+using namespace ::com::sun::star::i18n;
+
+// Description: Turn off frame/object shell if applicable
+
+static void lcl_ActivateTextShell( SwWrtShell & rWrtSh )
+{
+ if( rWrtSh.IsSelFrmMode() || rWrtSh.IsObjSelected() )
+ rWrtSh.EnterStdMode();
+}
+
+class SwKeepConversionDirectionStateContext
+{
+public:
+ SwKeepConversionDirectionStateContext()
+ {
+ //!! hack to transport the current conversion direction state settings
+ //!! into the next incarnation that iterates over the drawing objets
+ //!! ( see SwHHCWrapper::~SwHHCWrapper() )
+ editeng::HangulHanjaConversion::SetUseSavedConversionDirectionState( true );
+ }
+
+ ~SwKeepConversionDirectionStateContext()
+ {
+ editeng::HangulHanjaConversion::SetUseSavedConversionDirectionState( false );
+ }
+};
+
+SwHHCWrapper::SwHHCWrapper(
+ SwView* pSwView,
+ const uno::Reference< uno::XComponentContext >& rxContext,
+ LanguageType nSourceLanguage,
+ LanguageType nTargetLanguage,
+ const Font *pTargetFont,
+ sal_Int32 nConvOptions,
+ bool bIsInteractive,
+ bool bStart, bool bOther, bool bSelection )
+ : editeng::HangulHanjaConversion( &pSwView->GetEditWin(), rxContext,
+ LanguageTag::convertToLocale( nSourceLanguage ),
+ LanguageTag::convertToLocale( nTargetLanguage ),
+ pTargetFont,
+ nConvOptions,
+ bIsInteractive )
+ , m_pView( pSwView )
+ , m_pWin( &pSwView->GetEditWin() )
+ , m_rWrtShell( pSwView->GetWrtShell() )
+ , m_pConvArgs( 0 )
+ , m_nLastPos( 0 )
+ , m_nUnitOffset( 0 )
+ , m_nPageCount( 0 )
+ , m_nPageStart( 0 )
+ , m_bIsDrawObj( false )
+ , m_bIsOtherCntnt( bOther )
+ , m_bStartChk( bOther )
+ , m_bIsSelection( bSelection )
+ , m_bStartDone( bOther || bStart )
+ , m_bEndDone( false )
+{
+}
+
+SwHHCWrapper::~SwHHCWrapper()
+{
+ delete m_pConvArgs;
+
+ m_rWrtShell.SetCareWin( NULL );
+
+ // check for existence of a draw view which means that there are
+ // (or previously were) draw objects present in the document.
+ // I.e. we like to check those too.
+ if ( IsDrawObj() /*&& bLastRet*/ && m_pView->GetWrtShell().HasDrawView() )
+ {
+ Cursor *pSave = m_pView->GetWindow()->GetCursor();
+ {
+ SwKeepConversionDirectionStateContext aContext;
+
+ SdrHHCWrapper aSdrConvWrap( m_pView, GetSourceLanguage(),
+ GetTargetLanguage(), GetTargetFont(),
+ GetConversionOptions(), IsInteractive() );
+ aSdrConvWrap.StartTextConversion();
+ }
+ m_pView->GetWindow()->SetCursor( pSave );
+ }
+
+ if( m_nPageCount )
+ ::EndProgress( m_pView->GetDocShell() );
+
+ // finally for chinese translation we need to change the documents
+ // default language and font to the new ones to be used.
+ LanguageType nTargetLang = GetTargetLanguage();
+ if (IsChinese( nTargetLang ))
+ {
+ SwDoc *pDoc = m_pView->GetDocShell()->GetDoc();
+
+ //!! Note: This also effects the default language of text boxes (EditEngine/EditView) !!
+ pDoc->SetDefault( SvxLanguageItem( nTargetLang, RES_CHRATR_CJK_LANGUAGE ) );
+
+ const Font *pFont = GetTargetFont();
+ if (pFont)
+ {
+ SvxFontItem aFontItem( pFont->GetFamily(), pFont->GetName(),
+ pFont->GetStyleName(), pFont->GetPitch(),
+ pFont->GetCharSet(), RES_CHRATR_CJK_FONT );
+ pDoc->SetDefault( aFontItem );
+ }
+
+ }
+}
+
+void SwHHCWrapper::GetNextPortion(
+ OUString& rNextPortion,
+ LanguageType& rLangOfPortion,
+ bool bAllowChanges )
+{
+ m_pConvArgs->bAllowImplicitChangesForNotConvertibleText = bAllowChanges;
+
+ FindConvText_impl();
+ rNextPortion = m_pConvArgs->aConvText;
+ rLangOfPortion = m_pConvArgs->nConvTextLang;
+
+ m_nUnitOffset = 0;
+
+ // build last pos from currently selected text
+ SwPaM* pCrsr = m_rWrtShell.GetCrsr();
+ m_nLastPos = pCrsr->Start()->nContent.GetIndex();
+}
+
+void SwHHCWrapper::SelectNewUnit_impl( sal_Int32 nUnitStart, sal_Int32 nUnitEnd )
+{
+ SwPaM *pCrsr = m_rWrtShell.GetCrsr();
+ pCrsr->GetPoint()->nContent = m_nLastPos;
+ pCrsr->DeleteMark();
+
+ m_rWrtShell.Right( CRSR_SKIP_CHARS, /*bExpand*/ sal_False,
+ (sal_uInt16) (m_nUnitOffset + nUnitStart), sal_True );
+ pCrsr->SetMark();
+ m_rWrtShell.Right( CRSR_SKIP_CHARS, /*bExpand*/ sal_True,
+ (sal_uInt16) (nUnitEnd - nUnitStart), sal_True );
+ // end selection now. Otherwise SHIFT+HOME (extending the selection)
+ // won't work when the dialog is closed without any replacement.
+ // (see #116346#)
+ m_rWrtShell.EndSelect();
+}
+
+void SwHHCWrapper::HandleNewUnit(
+ const sal_Int32 nUnitStart, const sal_Int32 nUnitEnd )
+{
+ OSL_ENSURE( nUnitStart >= 0 && nUnitEnd >= nUnitStart, "wrong arguments" );
+ if (!(0 <= nUnitStart && nUnitStart <= nUnitEnd))
+ return;
+
+ lcl_ActivateTextShell( m_rWrtShell );
+
+ m_rWrtShell.StartAllAction();
+
+ // select current unit
+ SelectNewUnit_impl( nUnitStart, nUnitEnd );
+
+ m_rWrtShell.EndAllAction();
+}
+
+void SwHHCWrapper::ChangeText( const OUString &rNewText,
+ const OUString& rOrigText,
+ const uno::Sequence< sal_Int32 > *pOffsets,
+ SwPaM *pCrsr )
+{
+ //!! please see also TextConvWrapper::ChangeText with is a modified
+ //!! copy of this code
+
+ OSL_ENSURE( !rNewText.isEmpty(), "unexpected empty string" );
+ if (rNewText.isEmpty())
+ return;
+
+ if (pOffsets && pCrsr) // try to keep as much attributation as possible ?
+ {
+ // remember cursor start position for later setting of the cursor
+ const SwPosition *pStart = pCrsr->Start();
+ const sal_Int32 nStartIndex = pStart->nContent.GetIndex();
+ const SwNodeIndex aStartNodeIndex = pStart->nNode;
+ SwTxtNode *pStartTxtNode = aStartNodeIndex.GetNode().GetTxtNode();
+
+ const sal_Int32 nIndices = pOffsets->getLength();
+ const sal_Int32 *pIndices = pOffsets->getConstArray();
+ sal_Int32 nConvTextLen = rNewText.getLength();
+ sal_Int32 nPos = 0;
+ sal_Int32 nChgPos = -1;
+ sal_Int32 nChgLen = 0;
+ sal_Int32 nConvChgPos = -1;
+ sal_Int32 nConvChgLen = 0;
+
+ // offset to calculate the position in the text taking into
+ // account that text may have been replaced with new text of
+ // different length. Negative values allowed!
+ long nCorrectionOffset = 0;
+
+ OSL_ENSURE(nIndices == 0 || nIndices == nConvTextLen,
+ "mismatch between string length and sequence length!" );
+
+ // find all substrings that need to be replaced (and only those)
+ while (true)
+ {
+ // get index in original text that matches nPos in new text
+ sal_Int32 nIndex;
+ if (nPos < nConvTextLen)
+ nIndex = nPos < nIndices ? pIndices[nPos] : nPos;
+ else
+ {
+ nPos = nConvTextLen;
+ nIndex = rOrigText.getLength();
+ }
+
+ if (rOrigText[nIndex] == rNewText[nPos] ||
+ nPos == nConvTextLen /* end of string also terminates non-matching char sequence */)
+ {
+ // substring that needs to be replaced found?
+ if (nChgPos != -1 && nConvChgPos != -1)
+ {
+ nChgLen = nIndex - nChgPos;
+ nConvChgLen = nPos - nConvChgPos;
+#if OSL_DEBUG_LEVEL > 1
+ OUString aInOrig( rOrigText.copy( nChgPos, nChgLen ) );
+#endif
+ OUString aInNew( rNewText.copy( nConvChgPos, nConvChgLen ) );
+
+ // set selection to sub string to be replaced in original text
+ sal_Int32 nChgInNodeStartIndex = nStartIndex + nCorrectionOffset + nChgPos;
+ OSL_ENSURE( m_rWrtShell.GetCrsr()->HasMark(), "cursor misplaced (nothing selected)" );
+ m_rWrtShell.GetCrsr()->GetMark()->nContent.Assign( pStartTxtNode, nChgInNodeStartIndex );
+ m_rWrtShell.GetCrsr()->GetPoint()->nContent.Assign( pStartTxtNode, nChgInNodeStartIndex + nChgLen );
+#if OSL_DEBUG_LEVEL > 1
+ OUString aSelTxt1( m_rWrtShell.GetSelTxt() );
+#endif
+
+ // replace selected sub string with the corresponding
+ // sub string from the new text while keeping as
+ // much from the attributes as possible
+ ChangeText_impl( aInNew, true );
+
+ nCorrectionOffset += nConvChgLen - nChgLen;
+
+ nChgPos = -1;
+ nConvChgPos = -1;
+ }
+ }
+ else
+ {
+ // begin of non-matching char sequence found ?
+ if (nChgPos == -1 && nConvChgPos == -1)
+ {
+ nChgPos = nIndex;
+ nConvChgPos = nPos;
+ }
+ }
+ if (nPos >= nConvTextLen)
+ break;
+ ++nPos;
+ }
+
+ // set cursor to the end of all the new text
+ // (as it would happen after ChangeText_impl (Delete and Insert)
+ // of the whole text in the 'else' branch below)
+ m_rWrtShell.ClearMark();
+ m_rWrtShell.GetCrsr()->Start()->nContent.Assign( pStartTxtNode, nStartIndex + nConvTextLen );
+ }
+ else
+ {
+ ChangeText_impl( rNewText, false );
+ }
+}
+
+void SwHHCWrapper::ChangeText_impl( const OUString &rNewText, bool bKeepAttributes )
+{
+ if (bKeepAttributes)
+ {
+ // get item set with all relevant attributes
+ sal_uInt16 aRanges[] = {
+ RES_CHRATR_BEGIN, RES_FRMATR_END,
+ 0, 0, 0 };
+ SfxItemSet aItemSet( m_rWrtShell.GetAttrPool(), aRanges );
+ // get all attributes spanning the whole selection in order to
+ // restore those for the new text
+ m_rWrtShell.GetCurAttr( aItemSet );
+
+#if OSL_DEBUG_LEVEL > 1
+ OUString aSelTxt1( m_rWrtShell.GetSelTxt() );
+#endif
+ m_rWrtShell.Delete();
+ m_rWrtShell.Insert( rNewText );
+
+ // select new inserted text (currently the Point is right after the new text)
+ if (!m_rWrtShell.GetCrsr()->HasMark())
+ m_rWrtShell.GetCrsr()->SetMark();
+ SwPosition *pMark = m_rWrtShell.GetCrsr()->GetMark();
+ pMark->nContent = pMark->nContent.GetIndex() - rNewText.getLength();
+#if OSL_DEBUG_LEVEL > 1
+ OUString aSelTxt2( m_rWrtShell.GetSelTxt() );
+#endif
+
+ // since 'SetAttr' below functions like merging with the attributes
+ // from the itemset with any existing ones we have to get rid of all
+ // all attributes now. (Those attributes that may take effect left
+ // to the position where the new text gets inserted after the old text
+ // was deleted)
+ m_rWrtShell.ResetAttr();
+ // apply previously saved attributes to new text
+ m_rWrtShell.SetAttrSet( aItemSet );
+ }
+ else
+ {
+ m_rWrtShell.Delete();
+ m_rWrtShell.Insert( rNewText );
+ }
+}
+
+void SwHHCWrapper::ReplaceUnit(
+ const sal_Int32 nUnitStart, const sal_Int32 nUnitEnd,
+ const OUString& rOrigText,
+ const OUString& rReplaceWith,
+ const uno::Sequence< sal_Int32 > &rOffsets,
+ ReplacementAction eAction,
+ LanguageType *pNewUnitLanguage )
+{
+ OSL_ENSURE( nUnitStart >= 0 && nUnitEnd >= nUnitStart, "wrong arguments" );
+ if (!(nUnitStart >= 0 && nUnitEnd >= nUnitStart))
+ return;
+
+ lcl_ActivateTextShell( m_rWrtShell );
+
+ // replace the current word
+ m_rWrtShell.StartAllAction();
+
+ // select current unit
+ SelectNewUnit_impl( nUnitStart, nUnitEnd );
+
+ OUString aOrigTxt( m_rWrtShell.GetSelTxt() );
+ OUString aNewTxt( rReplaceWith );
+ OSL_ENSURE( aOrigTxt == rOrigText, "!! text mismatch !!" );
+ SwFmtRuby *pRuby = 0;
+ bool bRubyBelow = false;
+ OUString aNewOrigText;
+ switch (eAction)
+ {
+ case eExchange :
+ break;
+ case eReplacementBracketed :
+ {
+ aNewTxt = aOrigTxt + "(" + rReplaceWith + ")";
+ }
+ break;
+ case eOriginalBracketed :
+ {
+ aNewTxt = rReplaceWith + "(" + aOrigTxt + ")";
+ }
+ break;
+ case eReplacementAbove :
+ {
+ pRuby = new SwFmtRuby( rReplaceWith );
+ }
+ break;
+ case eOriginalAbove :
+ {
+ pRuby = new SwFmtRuby( aOrigTxt );
+ aNewOrigText = rReplaceWith;
+ }
+ break;
+ case eReplacementBelow :
+ {
+ pRuby = new SwFmtRuby( rReplaceWith );
+ bRubyBelow = true;
+ }
+ break;
+ case eOriginalBelow :
+ {
+ pRuby = new SwFmtRuby( aOrigTxt );
+ aNewOrigText = rReplaceWith;
+ bRubyBelow = true;
+ }
+ break;
+ default:
+ OSL_FAIL("unexpected case" );
+ }
+ m_nUnitOffset += nUnitStart + aNewTxt.getLength();
+
+ if (pRuby)
+ {
+ m_rWrtShell.StartUndo( UNDO_SETRUBYATTR );
+ if (!aNewOrigText.isEmpty())
+ {
+ // according to FT we currently should not bother about keeping
+ // attributes in Hangul/Hanja conversion
+ ChangeText( aNewOrigText, rOrigText, NULL, NULL );
+
+ //!! since Delete, Insert in 'ChangeText' do not set the WrtShells
+ //!! bInSelect flag
+ //!! back to false we do it now manually in order for the selection
+ //!! to be done properly in the following call to Left.
+ // We didn't fix it in Delete and Insert since it is currently
+ // unclear if someone depends on this incorrect behvaiour
+ // of the flag.
+ m_rWrtShell.EndSelect();
+
+ m_rWrtShell.Left( 0, sal_True, aNewOrigText.getLength(), sal_True, sal_True );
+ }
+
+ pRuby->SetPosition( static_cast<sal_uInt16>(bRubyBelow) );
+ pRuby->SetAdjustment( RubyAdjust_CENTER );
+
+#if OSL_DEBUG_LEVEL > 1
+ SwPaM *pPaM = m_rWrtShell.GetCrsr();
+ (void)pPaM;
+#endif
+ m_rWrtShell.SetAttrItem(*pRuby);
+ delete pRuby;
+ m_rWrtShell.EndUndo( UNDO_SETRUBYATTR );
+ }
+ else
+ {
+ m_rWrtShell.StartUndo( UNDO_OVERWRITE );
+
+ // according to FT we should currently not bother about keeping
+ // attributes in Hangul/Hanja conversion and leave that untouched.
+ // Thus we do this only for Chinese translation...
+ const bool bIsChineseConversion = IsChinese( GetSourceLanguage() );
+ if (bIsChineseConversion)
+ ChangeText( aNewTxt, rOrigText, &rOffsets, m_rWrtShell.GetCrsr() );
+ else
+ ChangeText( aNewTxt, rOrigText, NULL, NULL );
+
+ // change language and font if necessary
+ if (bIsChineseConversion)
+ {
+ m_rWrtShell.SetMark();
+ m_rWrtShell.GetCrsr()->GetMark()->nContent -= aNewTxt.getLength();
+
+ OSL_ENSURE( GetTargetLanguage() == LANGUAGE_CHINESE_SIMPLIFIED || GetTargetLanguage() == LANGUAGE_CHINESE_TRADITIONAL,
+ "SwHHCWrapper::ReplaceUnit : unexpected target language" );
+
+ sal_uInt16 aRanges[] = {
+ RES_CHRATR_CJK_LANGUAGE, RES_CHRATR_CJK_LANGUAGE,
+ RES_CHRATR_CJK_FONT, RES_CHRATR_CJK_FONT,
+ 0, 0, 0 };
+
+ SfxItemSet aSet( m_rWrtShell.GetAttrPool(), aRanges );
+ if (pNewUnitLanguage)
+ {
+ aSet.Put( SvxLanguageItem( *pNewUnitLanguage, RES_CHRATR_CJK_LANGUAGE ) );
+ }
+
+ const Font *pTargetFont = GetTargetFont();
+ OSL_ENSURE( pTargetFont, "target font missing?" );
+ if (pTargetFont && pNewUnitLanguage)
+ {
+ SvxFontItem aFontItem = (SvxFontItem&) aSet.Get( RES_CHRATR_CJK_FONT );
+ aFontItem.SetFamilyName( pTargetFont->GetName());
+ aFontItem.SetFamily( pTargetFont->GetFamily());
+ aFontItem.SetStyleName( pTargetFont->GetStyleName());
+ aFontItem.SetPitch( pTargetFont->GetPitch());
+ aFontItem.SetCharSet( pTargetFont->GetCharSet() );
+ aSet.Put( aFontItem );
+ }
+
+ m_rWrtShell.SetAttrSet( aSet );
+
+ m_rWrtShell.ClearMark();
+ }
+
+ m_rWrtShell.EndUndo( UNDO_OVERWRITE );
+ }
+
+ m_rWrtShell.EndAllAction();
+}
+
+bool SwHHCWrapper::HasRubySupport() const
+{
+ return true;
+}
+
+void SwHHCWrapper::Convert()
+{
+ OSL_ENSURE( m_pConvArgs == 0, "NULL pointer expected" );
+ {
+ SwPaM *pCrsr = m_pView->GetWrtShell().GetCrsr();
+ SwPosition* pSttPos = pCrsr->Start();
+ SwPosition* pEndPos = pCrsr->End();
+
+ if (pSttPos->nNode.GetNode().IsTxtNode() &&
+ pEndPos->nNode.GetNode().IsTxtNode())
+ {
+ m_pConvArgs = new SwConversionArgs( GetSourceLanguage(),
+ pSttPos->nNode.GetNode().GetTxtNode(), pSttPos->nContent,
+ pEndPos->nNode.GetNode().GetTxtNode(), pEndPos->nContent );
+ }
+ else // we are not in the text (maybe a graphic or OLE object is selected) let's start from the top
+ {
+ // get PaM that points to the start of the document
+ SwNode& rNode = m_pView->GetDocShell()->GetDoc()->GetNodes().GetEndOfContent();
+ SwPaM aPam(rNode);
+ aPam.Move( fnMoveBackward, fnGoDoc ); // move to start of document
+
+ pSttPos = aPam.GetPoint(); //! using a PaM here makes sure we will get only text nodes
+ SwTxtNode *pTxtNode = pSttPos->nNode.GetNode().GetTxtNode();
+ // just in case we check anyway...
+ if (!pTxtNode || !pTxtNode->IsTxtNode())
+ return;
+ m_pConvArgs = new SwConversionArgs( GetSourceLanguage(),
+ pTxtNode, pSttPos->nContent,
+ pTxtNode, pSttPos->nContent );
+ }
+ OSL_ENSURE( m_pConvArgs->pStartNode && m_pConvArgs->pStartNode->IsTxtNode(),
+ "failed to get proper start text node" );
+ OSL_ENSURE( m_pConvArgs->pEndNode && m_pConvArgs->pEndNode->IsTxtNode(),
+ "failed to get proper end text node" );
+
+ // chinese conversion specific settings
+ OSL_ENSURE( IsChinese( GetSourceLanguage() ) == IsChinese( GetTargetLanguage() ),
+ "source and target language mismatch?" );
+ if (IsChinese( GetTargetLanguage() ))
+ {
+ m_pConvArgs->nConvTargetLang = GetTargetLanguage();
+ m_pConvArgs->pTargetFont = GetTargetFont();
+ m_pConvArgs->bAllowImplicitChangesForNotConvertibleText = true;
+ }
+
+ // if it is not just a selection and we are about to begin
+ // with the current conversion for the very first time
+ // we need to find the start of the current (initial)
+ // convertible unit in order for the text conversion to give
+ // the correct result for that. Since it is easier to obtain
+ // the start of the word we use that though.
+ if (!pCrsr->HasMark()) // is not a selection?
+ {
+ // since #118246 / #117803 still occurs if the cursor is placed
+ // between the two chinese characters to be converted (because both
+ // of them are words on their own!) using the word boundary here does
+ // not work. Thus since chinese conversion is not interactive we start
+ // at the begin of the paragraph to solve the problem, i.e. have the
+ // TextConversion service get those characters together in the same call.
+ sal_Int32 nStartIdx = -1;
+ if (editeng::HangulHanjaConversion::IsChinese( GetSourceLanguage() ) )
+ nStartIdx = 0;
+ else
+ {
+ OUString aText( m_pConvArgs->pStartNode->GetTxt() );
+ const sal_Int32 nPos = m_pConvArgs->pStartIdx->GetIndex();
+ Boundary aBoundary( g_pBreakIt->GetBreakIter()->
+ getWordBoundary( aText, nPos, g_pBreakIt->GetLocale( m_pConvArgs->nConvSrcLang ),
+ WordType::DICTIONARY_WORD, sal_True ) );
+
+ // valid result found?
+ if (aBoundary.startPos < aText.getLength() &&
+ aBoundary.startPos != aBoundary.endPos)
+ {
+ nStartIdx = aBoundary.startPos;
+ }
+ }
+
+ if (nStartIdx != -1)
+ *m_pConvArgs->pStartIdx = nStartIdx;
+ }
+ }
+
+ if ( m_bIsOtherCntnt )
+ ConvStart_impl( m_pConvArgs, SVX_SPELL_OTHER );
+ else
+ {
+ m_bStartChk = false;
+ ConvStart_impl( m_pConvArgs, SVX_SPELL_BODY_END );
+ }
+
+ ConvertDocument();
+
+ ConvEnd_impl( m_pConvArgs );
+}
+
+bool SwHHCWrapper::ConvNext_impl( )
+{
+ //! modified version of SvxSpellWrapper::SpellNext
+
+ // no change of direction so the desired region is fully processed
+ if( m_bStartChk )
+ m_bStartDone = true;
+ else
+ m_bEndDone = true;
+
+ if( m_bIsOtherCntnt && m_bStartDone && m_bEndDone ) // document completely checked?
+ {
+ return false;
+ }
+
+ bool bGoOn = false;
+
+ if ( m_bIsOtherCntnt )
+ {
+ m_bStartChk = false;
+ ConvStart_impl( m_pConvArgs, SVX_SPELL_BODY );
+ bGoOn = true;
+ }
+ else if ( m_bStartDone && m_bEndDone )
+ {
+ // body region done, ask about special region
+ if( HasOtherCnt_impl() )
+ {
+ ConvStart_impl( m_pConvArgs, SVX_SPELL_OTHER );
+ m_bIsOtherCntnt = bGoOn = true;
+ }
+ }
+ else
+ {
+ m_bStartChk = !m_bStartDone;
+ ConvStart_impl( m_pConvArgs, m_bStartChk ? SVX_SPELL_BODY_START : SVX_SPELL_BODY_END );
+ bGoOn = true;
+ }
+ return bGoOn;
+}
+
+bool SwHHCWrapper::FindConvText_impl()
+{
+ //! modified version of SvxSpellWrapper::FindSpellError
+
+ bool bFound = false;
+
+ m_pWin->EnterWait();
+ bool bConv = true;
+
+ while ( bConv )
+ {
+ bFound = ConvContinue_impl( m_pConvArgs );
+ if (bFound)
+ {
+ bConv = false;
+ }
+ else
+ {
+ ConvEnd_impl( m_pConvArgs );
+ bConv = ConvNext_impl();
+ }
+ }
+ m_pWin->LeaveWait();
+ return bFound;
+}
+
+bool SwHHCWrapper::HasOtherCnt_impl()
+{
+ return m_bIsSelection ? false : m_rWrtShell.HasOtherCnt();
+}
+
+void SwHHCWrapper::ConvStart_impl( SwConversionArgs /* [out] */ *pConversionArgs, SvxSpellArea eArea )
+{
+ SetDrawObj( SVX_SPELL_OTHER == eArea );
+ m_pView->SpellStart( eArea, m_bStartDone, m_bEndDone, /* [out] */ pConversionArgs );
+}
+
+void SwHHCWrapper::ConvEnd_impl( SwConversionArgs *pConversionArgs )
+{
+ m_pView->SpellEnd( pConversionArgs );
+}
+
+bool SwHHCWrapper::ConvContinue_impl( SwConversionArgs *pConversionArgs )
+{
+ bool bProgress = !m_bIsDrawObj && !m_bIsSelection;
+ pConversionArgs->aConvText = OUString();
+ pConversionArgs->nConvTextLang = LANGUAGE_NONE;
+ m_pView->GetWrtShell().SpellContinue( &m_nPageCount, bProgress ? &m_nPageStart : NULL, pConversionArgs );
+ return !pConversionArgs->aConvText.isEmpty();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/lingu/hyp.cxx b/sw/source/core/uibase/lingu/hyp.cxx
new file mode 100644
index 000000000000..73de46c7aeb8
--- /dev/null
+++ b/sw/source/core/uibase/lingu/hyp.cxx
@@ -0,0 +1,132 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "initui.hxx"
+#include "view.hxx"
+#include "edtwin.hxx"
+#include "wrtsh.hxx"
+#include "globals.hrc"
+#include <vcl/msgbox.hxx>
+#include <vcl/wrkwin.hxx>
+#include <linguistic/lngprops.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/linguistic2/XLinguProperties.hpp>
+#include <swwait.hxx>
+
+#include "hyp.hxx"
+#include "mdiexp.hxx"
+#include "olmenu.hrc"
+
+#include <unomid.h>
+
+#include <boost/scoped_ptr.hpp>
+
+#define PSH (&pView->GetWrtShell())
+
+using namespace ::com::sun::star;
+
+/*--------------------------------------------------------------------
+ Description: interactive separation
+ --------------------------------------------------------------------*/
+
+SwHyphWrapper::SwHyphWrapper( SwView* pVw,
+ uno::Reference< linguistic2::XHyphenator > &rxHyph,
+ sal_Bool bStart, sal_Bool bOther, sal_Bool bSelect ) :
+ SvxSpellWrapper( &pVw->GetEditWin(), rxHyph, bStart, bOther ),
+ pView( pVw ),
+ xHyph( rxHyph ),
+ nPageCount( 0 ),
+ nPageStart( 0 ),
+ bInSelection( bSelect ),
+ bInfoBox( sal_False )
+{
+ uno::Reference< linguistic2::XLinguProperties > xProp( GetLinguPropertySet() );
+ bAutomatic = xProp.is() ? xProp->getIsHyphAuto() : sal_False;
+ SetHyphen();
+}
+
+void SwHyphWrapper::SpellStart( SvxSpellArea eSpell )
+{
+ if( SVX_SPELL_OTHER == eSpell && nPageCount )
+ {
+ ::EndProgress( pView->GetDocShell() );
+ nPageCount = 0;
+ nPageStart = 0;
+ }
+ pView->HyphStart( eSpell );
+}
+
+bool SwHyphWrapper::SpellContinue()
+{
+ // for automatic separation, make actions visible only at the end
+ boost::scoped_ptr<SwWait> pWait;
+ if( bAutomatic )
+ {
+ PSH->StartAllAction();
+ pWait.reset(new SwWait( *pView->GetDocShell(), true ));
+ }
+
+ uno::Reference< uno::XInterface > xHyphWord = bInSelection ?
+ PSH->HyphContinue( NULL, NULL ) :
+ PSH->HyphContinue( &nPageCount, &nPageStart );
+ SetLast( xHyphWord );
+
+ // for automatic separation, make actions visible only at the end
+ if( bAutomatic )
+ {
+ PSH->EndAllAction();
+ pWait.reset();
+ }
+
+ return GetLast().is();
+}
+
+void SwHyphWrapper::SpellEnd()
+{
+ PSH->HyphEnd();
+ SvxSpellWrapper::SpellEnd();
+}
+
+bool SwHyphWrapper::SpellMore()
+{
+ PSH->Push();
+ bInfoBox = sal_True;
+ PSH->Combine();
+ return false;
+}
+
+void SwHyphWrapper::InsertHyphen( const sal_uInt16 nPos )
+{
+ if( nPos)
+ PSH->InsertSoftHyph( nPos + 1); // does nPos == 1 really mean
+ // insert hyphen after first char?
+ // (instead of nPos == 0)
+ else
+ PSH->HyphIgnore();
+}
+
+SwHyphWrapper::~SwHyphWrapper()
+{
+ if( nPageCount )
+ ::EndProgress( pView->GetDocShell() );
+ if( bInfoBox )
+ InfoBox( &pView->GetEditWin(), SW_RESSTR(STR_HYP_OK) ).Execute();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/lingu/olmenu.cxx b/sw/source/core/uibase/lingu/olmenu.cxx
new file mode 100644
index 000000000000..f5909da430d1
--- /dev/null
+++ b/sw/source/core/uibase/lingu/olmenu.cxx
@@ -0,0 +1,891 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "SwRewriter.hxx"
+#include "chrdlg.hrc"
+#include "cmdid.h"
+#include "comcore.hrc"
+#include "crsskip.hxx"
+#include "doc.hxx"
+#include "docsh.hxx"
+#include "edtwin.hxx"
+#include "helpid.h"
+#include "hintids.hxx"
+#include "langhelper.hxx"
+#include "ndtxt.hxx"
+#include "olmenu.hrc"
+#include "olmenu.hxx"
+#include "swabstdlg.hxx"
+#include "swmodule.hxx"
+#include "swtypes.hxx"
+#include "swundo.hxx"
+#include "uitool.hxx"
+#include "unomid.h"
+#include "view.hxx"
+#include "viewopt.hxx"
+#include "wrtsh.hxx"
+#include "wview.hxx"
+
+#include <comphelper/anytostring.hxx>
+#include <comphelper/processfactory.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+#include <editeng/acorrcfg.hxx>
+#include <editeng/svxacorr.hxx>
+#include <editeng/langitem.hxx>
+#include <editeng/splwrap.hxx>
+#include <editeng/brushitem.hxx>
+#include <editeng/unolingu.hxx>
+#include <editeng/editview.hxx>
+#include <i18nlangtag/mslangid.hxx>
+#include <i18nlangtag/languagetag.hxx>
+#include <linguistic/lngprops.hxx>
+#include <linguistic/misc.hxx>
+#include <osl/file.hxx>
+#include <rtl/string.hxx>
+#include <vcl/graphicfilter.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/imagemgr.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/sfxdlg.hxx>
+#include <svl/itemset.hxx>
+#include <svl/languageoptions.hxx>
+#include <svl/stritem.hxx>
+#include <svtools/langtab.hxx>
+#include <svx/dlgutil.hxx>
+#include <unotools/lingucfg.hxx>
+#include <unotools/linguprops.hxx>
+#include <vcl/layout.hxx>
+#include <vcl/settings.hxx>
+#include <vcl/svapp.hxx>
+#include <sal/macros.h>
+
+#include <map>
+
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/document/XDocumentLanguages.hpp>
+#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/frame/XStorable.hpp>
+#include <com/sun/star/i18n/ScriptType.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/linguistic2/SingleProofreadingError.hpp>
+#include <com/sun/star/linguistic2/XLanguageGuessing.hpp>
+#include <com/sun/star/linguistic2/XSpellChecker1.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/system/SystemShellExecuteFlags.hpp>
+#include <com/sun/star/system/SystemShellExecute.hpp>
+#include <com/sun/star/frame/theUICommandDescription.hpp>
+
+using namespace ::com::sun::star;
+
+extern void sw_CharDialog( SwWrtShell &rWrtSh, bool bUseDialog, sal_uInt16 nSlot,const SfxItemSet *pArgs, SfxRequest *pReq );
+
+/// @returns : the language for the selected text that is set for the
+/// specified attribute (script type).
+/// If there are more than one languages used LANGUAGE_DONTKNOW will be returned.
+/// @param nLangWhichId : one of
+/// RES_CHRATR_LANGUAGE, RES_CHRATR_CJK_LANGUAGE, RES_CHRATR_CTL_LANGUAGE,
+/// @returns: the language in use for the selected text.
+/// 'In use' means the language(s) matching the script type(s) of the
+/// selected text. Or in other words, the language a spell checker would use.
+/// If there is more than one language LANGUAGE_DONTKNOW will be returned.
+// check if nScriptType includes the script type associated to nLang
+static inline bool lcl_checkScriptType( sal_Int16 nScriptType, LanguageType nLang )
+{
+ return 0 != (nScriptType & SvtLanguageOptions::GetScriptTypeOfLanguage( nLang ));
+}
+
+void SwSpellPopup::fillLangPopupMenu(
+ PopupMenu *pPopupMenu,
+ sal_uInt16 nLangItemIdStart,
+ uno::Sequence< OUString > aSeq,
+ SwWrtShell* pWrtSh,
+ std::map< sal_Int16, OUString > &rLangTable )
+{
+ if (!pPopupMenu)
+ return;
+
+ SvtLanguageTable aLanguageTable;
+
+ // set of languages to be displayed in the sub menus
+ std::set< OUString > aLangItems;
+
+ OUString aCurLang( aSeq[0] );
+ sal_uInt16 nScriptType = static_cast< sal_Int16 >(aSeq[1].toInt32());
+ OUString aKeyboardLang( aSeq[2] );
+ OUString aGuessedTextLang( aSeq[3] );
+
+ if (!aCurLang.isEmpty() &&
+ LANGUAGE_DONTKNOW != aLanguageTable.GetType( aCurLang ))
+ aLangItems.insert( aCurLang );
+
+ //2--System
+ const AllSettings& rAllSettings = Application::GetSettings();
+ LanguageType rSystemLanguage = rAllSettings.GetLanguageTag().getLanguageType();
+ if (rSystemLanguage != LANGUAGE_DONTKNOW)
+ {
+ if (lcl_checkScriptType( nScriptType, rSystemLanguage ))
+ aLangItems.insert( aLanguageTable.GetString(rSystemLanguage) );
+ }
+
+ //3--UI
+ LanguageType rUILanguage = rAllSettings.GetUILanguageTag().getLanguageType();
+ if (rUILanguage != LANGUAGE_DONTKNOW)
+ {
+ if (lcl_checkScriptType(nScriptType, rUILanguage ))
+ aLangItems.insert( aLanguageTable.GetString(rUILanguage) );
+ }
+
+ //4--guessed language
+ if (!aGuessedTextLang.isEmpty())
+ {
+ if (lcl_checkScriptType(nScriptType, aLanguageTable.GetType(aGuessedTextLang)))
+ aLangItems.insert( aGuessedTextLang );
+ }
+
+ //5--keyboard language
+ if (!aKeyboardLang.isEmpty())
+ {
+ if (lcl_checkScriptType(nScriptType, aLanguageTable.GetType(aKeyboardLang)))
+ aLangItems.insert( aKeyboardLang );
+ }
+
+ //6--all languages used in current document
+ uno::Reference< com::sun::star::frame::XModel > xModel;
+ uno::Reference< com::sun::star::frame::XController > xController( pWrtSh->GetView().GetViewFrame()->GetFrame().GetFrameInterface()->getController(), uno::UNO_QUERY );
+ if ( xController.is() )
+ xModel = xController->getModel();
+ uno::Reference< document::XDocumentLanguages > xDocumentLanguages( xModel, uno::UNO_QUERY );
+ /*the description of nScriptType flags
+ LATIN : 0x0001
+ ASIAN : 0x0002
+ COMPLEX: 0x0004
+ */
+ const sal_Int16 nMaxCount = 7;
+ if (xDocumentLanguages.is())
+ {
+ uno::Sequence< lang::Locale > rLocales( xDocumentLanguages->getDocumentLanguages( nScriptType, nMaxCount ) );
+ if (rLocales.getLength() > 0)
+ {
+ for (sal_uInt16 i = 0; i < rLocales.getLength(); ++i)
+ {
+ if (aLangItems.size() == (size_t)nMaxCount)
+ break;
+ const lang::Locale& rLocale = rLocales[i];
+ if (lcl_checkScriptType( nScriptType, aLanguageTable.GetType( rLocale.Language )))
+ aLangItems.insert( rLocale.Language );
+ }
+ }
+ }
+
+ sal_uInt16 nItemId = nLangItemIdStart;
+ std::set< OUString >::const_iterator it;
+ for (it = aLangItems.begin(); it != aLangItems.end(); ++it)
+ {
+ OUString aEntryTxt( *it );
+ if (aEntryTxt != OUString( aLanguageTable.GetString( LANGUAGE_NONE ) )&&
+ aEntryTxt != "*" && // multiple languages in current selection
+ !aEntryTxt.isEmpty()) // 'no language found' from language guessing
+ {
+ OSL_ENSURE( nLangItemIdStart <= nItemId && nItemId <= nLangItemIdStart + MN_MAX_NUM_LANG,
+ "nItemId outside of expected range!" );
+ pPopupMenu->InsertItem( nItemId, aEntryTxt, MIB_RADIOCHECK );
+ if (aEntryTxt == aCurLang)
+ {
+ //make a check mark for the current language
+ pPopupMenu->CheckItem( nItemId, true );
+ }
+ rLangTable[ nItemId ] = aEntryTxt;
+ ++nItemId;
+ }
+ }
+
+ pPopupMenu->InsertItem( nLangItemIdStart + MN_NONE_OFFSET, OUString(SW_RES( STR_LANGSTATUS_NONE )), MIB_RADIOCHECK );
+ if ( aLanguageTable.GetString( LANGUAGE_NONE ) == aCurLang )
+ pPopupMenu->CheckItem( nLangItemIdStart + MN_NONE_OFFSET, true );
+
+ pPopupMenu->InsertItem( nLangItemIdStart + MN_RESET_OFFSET, OUString(SW_RES( STR_RESET_TO_DEFAULT_LANGUAGE )), 0 );
+ pPopupMenu->InsertItem( nLangItemIdStart + MN_MORE_OFFSET, OUString(SW_RES( STR_LANGSTATUS_MORE )), 0 );
+}
+
+OUString RetrieveLabelFromCommand( const OUString& aCmdURL )
+{
+ OUString aLabel;
+ if ( !aCmdURL.isEmpty() )
+ {
+ try
+ {
+ uno::Reference< container::XNameAccess > const xNameAccess(
+ frame::theUICommandDescription::get(
+ ::comphelper::getProcessComponentContext() ),
+ uno::UNO_QUERY_THROW );
+ uno::Reference< container::XNameAccess > xUICommandLabels;
+ uno::Any a = xNameAccess->getByName( "com.sun.star.text.TextDocument" );
+ uno::Reference< container::XNameAccess > xUICommands;
+ a >>= xUICommandLabels;
+ OUString aStr;
+ uno::Sequence< beans::PropertyValue > aPropSeq;
+ a = xUICommandLabels->getByName( aCmdURL );
+ if ( a >>= aPropSeq )
+ {
+ for ( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ )
+ {
+ if ( aPropSeq[i].Name == "Name" )
+ {
+ aPropSeq[i].Value >>= aStr;
+ break;
+ }
+ }
+ }
+ aLabel = aStr;
+ }
+ catch (const uno::Exception&)
+ {
+ }
+ }
+
+ return aLabel;
+}
+
+SwSpellPopup::SwSpellPopup(
+ SwWrtShell* pWrtSh,
+ const uno::Reference< linguistic2::XSpellAlternatives > &xAlt,
+ const OUString &rParaText
+) : PopupMenu( SW_RES(MN_SPELL_POPUP) )
+ , m_pSh( pWrtSh )
+ , m_xSpellAlt(xAlt)
+ , m_bGrammarResults(false)
+{
+ OSL_ENSURE(m_xSpellAlt.is(), "no spelling alternatives available");
+
+ SetMenuFlags(MENU_FLAG_NOAUTOMNEMONICS);
+ bool bUseImagesInMenus = Application::GetSettings().GetStyleSettings().GetUseImagesInMenus();
+
+ m_nCheckedLanguage = LANGUAGE_NONE;
+ if (m_xSpellAlt.is())
+ {
+ m_nCheckedLanguage = LanguageTag( m_xSpellAlt->getLocale() ).getLanguageType();
+ m_aSuggestions = m_xSpellAlt->getAlternatives();
+ }
+ sal_Int16 nStringCount = static_cast< sal_Int16 >( m_aSuggestions.getLength() );
+
+ SvtLinguConfig aCfg;
+
+ PopupMenu *pMenu = GetPopupMenu(MN_AUTOCORR);
+ pMenu->SetMenuFlags(MENU_FLAG_NOAUTOMNEMONICS);
+ sal_Bool bEnable = sal_False;
+ if( nStringCount )
+ {
+ Image aImage;
+ OUString aSuggestionImageUrl;
+
+ if (bUseImagesInMenus)
+ {
+ uno::Reference< container::XNamed > xNamed( m_xSpellAlt, uno::UNO_QUERY );
+ if (xNamed.is())
+ {
+ aSuggestionImageUrl = aCfg.GetSpellAndGrammarContextSuggestionImage( xNamed->getName() );
+ aImage = Image( aSuggestionImageUrl );
+ }
+ }
+
+ InsertSeparator(OString(), 0);
+ bEnable = sal_True;
+ sal_uInt16 nAutoCorrItemId = MN_AUTOCORR_START;
+ sal_uInt16 nItemId = MN_SUGGESTION_START;
+ for (sal_uInt16 i = 0; i < nStringCount; ++i)
+ {
+ const OUString aEntry = m_aSuggestions[ i ];
+ InsertItem(nItemId, aEntry, 0, OString(), i);
+ SetHelpId( nItemId, HID_LINGU_REPLACE);
+ if (!aSuggestionImageUrl.isEmpty())
+ SetItemImage( nItemId, aImage );
+
+ pMenu->InsertItem( nAutoCorrItemId, aEntry );
+ pMenu->SetHelpId( nAutoCorrItemId, HID_LINGU_AUTOCORR);
+
+ ++nAutoCorrItemId;
+ ++nItemId;
+ }
+ }
+
+ OUString aIgnoreSelection( SW_RES( STR_IGNORE_SELECTION ) );
+ OUString aSpellingAndGrammar = RetrieveLabelFromCommand( ".uno:SpellingAndGrammarDialog" );
+ SetItemText( MN_SPELLING_DLG, aSpellingAndGrammar );
+ sal_uInt16 nItemPos = GetItemPos( MN_IGNORE_WORD );
+ InsertItem(MN_IGNORE_SELECTION, aIgnoreSelection, 0, OString(), nItemPos);
+ SetHelpId( MN_IGNORE_SELECTION, HID_LINGU_IGNORE_SELECTION);
+
+ EnableItem( MN_AUTOCORR, bEnable );
+
+ uno::Reference< linguistic2::XLanguageGuessing > xLG = SW_MOD()->GetLanguageGuesser();
+ m_nGuessLangWord = LANGUAGE_NONE;
+ m_nGuessLangPara = LANGUAGE_NONE;
+ if (m_xSpellAlt.is() && xLG.is())
+ {
+ m_nGuessLangWord = EditView::CheckLanguage( m_xSpellAlt->getWord(), ::GetSpellChecker(), xLG, false );
+ m_nGuessLangPara = EditView::CheckLanguage( rParaText, ::GetSpellChecker(), xLG, true );
+ }
+ if (m_nGuessLangWord != LANGUAGE_NONE || m_nGuessLangPara != LANGUAGE_NONE)
+ {
+ // make sure LANGUAGE_NONE gets not used as menu entry
+ if (m_nGuessLangWord == LANGUAGE_NONE)
+ m_nGuessLangWord = m_nGuessLangPara;
+ if (m_nGuessLangPara == LANGUAGE_NONE)
+ m_nGuessLangPara = m_nGuessLangWord;
+ }
+
+ pMenu = GetPopupMenu(MN_ADD_TO_DIC);
+ pMenu->SetMenuFlags(MENU_FLAG_NOAUTOMNEMONICS); //! necessary to retrieve the correct dictionary name in 'Execute' below
+ uno::Reference< linguistic2::XSearchableDictionaryList > xDicList( SvxGetDictionaryList() );
+ sal_uInt16 nItemId = MN_DICTIONARIES_START;
+ if (xDicList.is())
+ {
+ // add the default positive dictionary to dic-list (if not already done).
+ // This is to ensure that there is at least one dictionary to which
+ // words could be added.
+ uno::Reference< linguistic2::XDictionary > xDic( SvxGetOrCreatePosDic( xDicList ) );
+ if (xDic.is())
+ xDic->setActive( sal_True );
+
+ m_aDics = xDicList->getDictionaries();
+ const uno::Reference< linguistic2::XDictionary > *pDic = m_aDics.getConstArray();
+ sal_uInt16 nDicCount = static_cast< sal_uInt16 >(m_aDics.getLength());
+
+ for( sal_uInt16 i = 0; i < nDicCount; i++ )
+ {
+ uno::Reference< linguistic2::XDictionary > xDicTmp( pDic[i], uno::UNO_QUERY );
+ if (!xDicTmp.is() || SvxGetIgnoreAllList() == xDicTmp)
+ continue;
+
+ uno::Reference< frame::XStorable > xStor( xDicTmp, uno::UNO_QUERY );
+ LanguageType nActLanguage = LanguageTag( xDicTmp->getLocale() ).getLanguageType();
+ if( xDicTmp->isActive()
+ && xDicTmp->getDictionaryType() != linguistic2::DictionaryType_NEGATIVE
+ && (m_nCheckedLanguage == nActLanguage || LANGUAGE_NONE == nActLanguage )
+ && (!xStor.is() || !xStor->isReadonly()) )
+ {
+ // the extra 1 is because of the (possible) external
+ // linguistic entry above
+ pMenu->InsertItem( nItemId, xDicTmp->getName() );
+ m_aDicNameSingle = xDicTmp->getName();
+
+ if (bUseImagesInMenus)
+ {
+ uno::Reference< lang::XServiceInfo > xSvcInfo( xDicTmp, uno::UNO_QUERY );
+ if (xSvcInfo.is())
+ {
+ OUString aDictionaryImageUrl( aCfg.GetSpellAndGrammarContextDictionaryImage(
+ xSvcInfo->getImplementationName() ) );
+ if (!aDictionaryImageUrl.isEmpty())
+ {
+ Image aImage( aDictionaryImageUrl );
+ pMenu->SetItemImage( nItemId, aImage );
+ }
+ }
+ }
+
+ ++nItemId;
+ }
+ }
+ }
+ EnableItem( MN_ADD_TO_DIC, ((nItemId - MN_DICTIONARIES_START) > 1)?sal_True:sal_False );
+ EnableItem( MN_ADD_TO_DIC_SINGLE, ((nItemId - MN_DICTIONARIES_START) == 1)?sal_True:sal_False );
+
+ //ADD NEW LANGUAGE MENU ITEM
+
+ OUString aScriptTypesInUse( OUString::number( pWrtSh->GetScriptType() ) );
+ SvtLanguageTable aLanguageTable;
+
+ // get keyboard language
+ OUString aKeyboardLang;
+ SwEditWin& rEditWin = pWrtSh->GetView().GetEditWin();
+ LanguageType nLang = rEditWin.GetInputLanguage();
+ if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
+ aKeyboardLang = aLanguageTable.GetString( nLang );
+
+ // get the language that is in use
+ OUString aCurrentLang("*");
+ nLang = SwLangHelper::GetCurrentLanguage( *pWrtSh );
+ if (nLang != LANGUAGE_DONTKNOW)
+ aCurrentLang = aLanguageTable.GetString( nLang );
+
+ // build sequence for status value
+ uno::Sequence< OUString > aSeq( 4 );
+ aSeq[0] = aCurrentLang;
+ aSeq[1] = aScriptTypesInUse;
+ aSeq[2] = aKeyboardLang;
+ aSeq[3] = aLanguageTable.GetString(m_nGuessLangWord);
+
+ pMenu = GetPopupMenu(MN_SET_LANGUAGE_SELECTION);
+ fillLangPopupMenu( pMenu, MN_SET_LANGUAGE_SELECTION_START, aSeq, pWrtSh, m_aLangTable_Text );
+ EnableItem( MN_SET_LANGUAGE_SELECTION, true );
+
+ pMenu = GetPopupMenu(MN_SET_LANGUAGE_PARAGRAPH);
+ fillLangPopupMenu( pMenu, MN_SET_LANGUAGE_PARAGRAPH_START, aSeq, pWrtSh, m_aLangTable_Paragraph );
+ EnableItem( MN_SET_LANGUAGE_PARAGRAPH, true );
+
+ if (bUseImagesInMenus)
+ {
+ uno::Reference< frame::XFrame > xFrame = pWrtSh->GetView().GetViewFrame()->GetFrame().GetFrameInterface();
+ Image rImg = ::GetImage( xFrame, ".uno:SpellingAndGrammarDialog", false );
+ SetItemImage( MN_SPELLING_DLG, rImg );
+ }
+
+ checkRedline();
+ RemoveDisabledEntries( true, true );
+}
+
+SwSpellPopup::SwSpellPopup(
+ SwWrtShell *pWrtSh,
+ const linguistic2::ProofreadingResult &rResult,
+ sal_Int32 nErrorInResult,
+ const uno::Sequence< OUString > &rSuggestions,
+ const OUString &rParaText ) :
+PopupMenu( SW_RES(MN_SPELL_POPUP) ),
+m_pSh( pWrtSh ),
+m_xGrammarResult( rResult ),
+m_aSuggestions( rSuggestions ),
+m_sExplanationLink( ),
+m_bGrammarResults( true ),
+m_aInfo16( SW_RES(IMG_INFO_16) )
+{
+ m_nCheckedLanguage = LanguageTag::convertToLanguageType( rResult.aLocale );
+ m_nGrammarError = nErrorInResult;
+ bool bUseImagesInMenus = Application::GetSettings().GetStyleSettings().GetUseImagesInMenus();
+
+ sal_uInt16 nPos = 0;
+ OUString aMessageText( rResult.aErrors[ nErrorInResult ].aShortComment );
+ InsertSeparator(OString(), nPos++);
+ InsertItem(MN_SHORT_COMMENT, aMessageText, MIB_NOSELECT, OString(), nPos++);
+ if (bUseImagesInMenus)
+ SetItemImage( MN_SHORT_COMMENT, m_aInfo16 );
+
+ // Add an item to show detailled infos if the FullCommentURL property is defined
+ beans::PropertyValues aProperties = rResult.aErrors[ nErrorInResult ].aProperties;
+ {
+ sal_Int32 i = 0;
+ while ( m_sExplanationLink.isEmpty() && i < aProperties.getLength() )
+ {
+ if ( aProperties[i].Name == "FullCommentURL" )
+ {
+ uno::Any aValue = aProperties[i].Value;
+ aValue >>= m_sExplanationLink;
+ }
+ ++i;
+ }
+ }
+
+ if ( !m_sExplanationLink.isEmpty( ) )
+ {
+ InsertItem(MN_EXPLANATION_LINK, SW_RESSTR(STR_EXPLANATION_LINK), MIB_TEXT | MIB_HELP, OString(), nPos++);
+ }
+
+ SetMenuFlags(MENU_FLAG_NOAUTOMNEMONICS);
+
+ InsertSeparator(OString(), nPos++);
+ sal_Int32 nStringCount = m_aSuggestions.getLength();
+ if ( nStringCount ) // suggestions available...
+ {
+ Image aImage;
+ OUString aSuggestionImageUrl;
+
+ if (bUseImagesInMenus)
+ {
+ uno::Reference< lang::XServiceInfo > xInfo( rResult.xProofreader, uno::UNO_QUERY );
+ if (xInfo.is())
+ {
+ aSuggestionImageUrl = SvtLinguConfig().GetSpellAndGrammarContextSuggestionImage( xInfo->getImplementationName() );
+ aImage = Image( aSuggestionImageUrl );
+ }
+ }
+
+ sal_uInt16 nItemId = MN_SUGGESTION_START;
+ for (sal_uInt16 i = 0; i < nStringCount; ++i)
+ {
+ const OUString aEntry = m_aSuggestions[ i ];
+ InsertItem(nItemId, aEntry, 0, OString(), nPos++);
+ SetHelpId( nItemId, HID_LINGU_REPLACE );
+ if (!aSuggestionImageUrl.isEmpty())
+ SetItemImage( nItemId, aImage );
+
+ ++nItemId;
+ }
+ InsertSeparator(OString(), nPos++);
+ }
+
+ OUString aIgnoreSelection( SW_RES( STR_IGNORE_SELECTION ) );
+ OUString aSpellingAndGrammar = RetrieveLabelFromCommand( ".uno:SpellingAndGrammarDialog" );
+ SetItemText( MN_SPELLING_DLG, aSpellingAndGrammar );
+ sal_uInt16 nItemPos = GetItemPos( MN_IGNORE_WORD );
+ InsertItem( MN_IGNORE_SELECTION, aIgnoreSelection, 0, OString(), nItemPos );
+ SetHelpId( MN_IGNORE_SELECTION, HID_LINGU_IGNORE_SELECTION);
+
+ EnableItem( MN_AUTOCORR, false );
+
+ uno::Reference< linguistic2::XLanguageGuessing > xLG = SW_MOD()->GetLanguageGuesser();
+ m_nGuessLangWord = LANGUAGE_NONE;
+ m_nGuessLangPara = LANGUAGE_NONE;
+ if (xLG.is())
+ {
+ m_nGuessLangPara = EditView::CheckLanguage( rParaText, ::GetSpellChecker(), xLG, true );
+ }
+ if (m_nGuessLangWord != LANGUAGE_NONE || m_nGuessLangPara != LANGUAGE_NONE)
+ {
+ // make sure LANGUAGE_NONE gets not used as menu entry
+ if (m_nGuessLangWord == LANGUAGE_NONE)
+ m_nGuessLangWord = m_nGuessLangPara;
+ if (m_nGuessLangPara == LANGUAGE_NONE)
+ m_nGuessLangPara = m_nGuessLangWord;
+ }
+
+ EnableItem( MN_ADD_TO_DIC, false );
+ EnableItem( MN_ADD_TO_DIC_SINGLE, false );
+
+ //ADD NEW LANGUAGE MENU ITEM
+
+ OUString aScriptTypesInUse( OUString::number( pWrtSh->GetScriptType() ) );
+ SvtLanguageTable aLanguageTable;
+
+ // get keyboard language
+ OUString aKeyboardLang;
+ SwEditWin& rEditWin = pWrtSh->GetView().GetEditWin();
+ LanguageType nLang = rEditWin.GetInputLanguage();
+ if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
+ aKeyboardLang = aLanguageTable.GetString( nLang );
+
+ // get the language that is in use
+ OUString aCurrentLang("*");
+ nLang = SwLangHelper::GetCurrentLanguage( *pWrtSh );
+ if (nLang != LANGUAGE_DONTKNOW)
+ aCurrentLang = aLanguageTable.GetString( nLang );
+
+ // build sequence for status value
+ uno::Sequence< OUString > aSeq( 4 );
+ aSeq[0] = aCurrentLang;
+ aSeq[1] = aScriptTypesInUse;
+ aSeq[2] = aKeyboardLang;
+ aSeq[3] = aLanguageTable.GetString(m_nGuessLangWord);
+
+ PopupMenu *pMenu = GetPopupMenu(MN_SET_LANGUAGE_SELECTION);
+ fillLangPopupMenu( pMenu, MN_SET_LANGUAGE_SELECTION_START, aSeq, pWrtSh, m_aLangTable_Text );
+ EnableItem( MN_SET_LANGUAGE_SELECTION, true );
+
+ pMenu = GetPopupMenu(MN_SET_LANGUAGE_PARAGRAPH);
+ fillLangPopupMenu( pMenu, MN_SET_LANGUAGE_PARAGRAPH_START, aSeq, pWrtSh, m_aLangTable_Paragraph );
+ EnableItem( MN_SET_LANGUAGE_PARAGRAPH, true );
+
+ if (bUseImagesInMenus)
+ {
+ uno::Reference< frame::XFrame > xFrame = pWrtSh->GetView().GetViewFrame()->GetFrame().GetFrameInterface();
+ Image rImg = ::GetImage( xFrame, ".uno:SpellingAndGrammarDialog", false );
+ SetItemImage( MN_SPELLING_DLG, rImg );
+ }
+
+ checkRedline();
+ RemoveDisabledEntries( true, true );
+}
+
+void SwSpellPopup::checkRedline()
+{
+ // Let SwView::GetState() already has the logic on when to disable the
+ // accept/reject and the next/prev change items, let it do the decision.
+
+ // Build an item set that contains a void item for each menu entry. The
+ // WhichId of each item is set, so SwView may clear it.
+ static const sal_uInt16 pRedlineIds[] = {
+ FN_REDLINE_ACCEPT_DIRECT,
+ FN_REDLINE_REJECT_DIRECT,
+ FN_REDLINE_NEXT_CHANGE,
+ FN_REDLINE_PREV_CHANGE
+ };
+ SwDoc *pDoc = m_pSh->GetDoc();
+ SfxItemSet aSet(pDoc->GetAttrPool(), FN_REDLINE_ACCEPT_DIRECT, FN_REDLINE_PREV_CHANGE);
+ for (size_t i = 0; i < SAL_N_ELEMENTS(pRedlineIds); ++i)
+ {
+ const sal_uInt16 nWhich = pRedlineIds[i];
+ aSet.Put(SfxVoidItem(nWhich), nWhich);
+ }
+ m_pSh->GetView().GetState(aSet);
+
+ // Enable/disable items based on if the which id of the void items are
+ // cleared or not.
+ for (size_t i = 0; i < SAL_N_ELEMENTS(pRedlineIds); ++i)
+ {
+ const sal_uInt16 nWhich = pRedlineIds[i];
+ EnableItem(nWhich, aSet.Get(nWhich).Which());
+ }
+}
+
+sal_uInt16 SwSpellPopup::Execute( const Rectangle& rWordPos, Window* pWin )
+{
+ sal_uInt16 nRet = PopupMenu::Execute(pWin, pWin->LogicToPixel(rWordPos));
+ Execute( nRet );
+ return nRet;
+}
+
+void SwSpellPopup::Execute( sal_uInt16 nId )
+{
+ if (nId == USHRT_MAX)
+ return;
+
+ if (/*m_bGrammarResults && */nId == MN_SHORT_COMMENT)
+ return; // nothing to do since it is the error message (short comment)
+
+ if ((MN_SUGGESTION_START <= nId && nId <= MN_SUGGESTION_END) ||
+ (MN_AUTOCORR_START <= nId && nId <= MN_AUTOCORR_END))
+ {
+ sal_Int32 nAltIdx = (MN_SUGGESTION_START <= nId && nId <= MN_SUGGESTION_END) ?
+ nId - MN_SUGGESTION_START : nId - MN_AUTOCORR_START;
+ OSL_ENSURE( 0 <= nAltIdx && nAltIdx < m_aSuggestions.getLength(), "index out of range" );
+ if (0 <= nAltIdx && nAltIdx < m_aSuggestions.getLength() && (m_bGrammarResults || m_xSpellAlt.is()))
+ {
+ sal_Bool bOldIns = m_pSh->IsInsMode();
+ m_pSh->SetInsMode( sal_True );
+
+ OUString aTmp( m_aSuggestions[ nAltIdx ] );
+ OUString aOrig( m_bGrammarResults ? OUString() : m_xSpellAlt->getWord() );
+
+ // if original word has a trailing . (likely the end of a sentence)
+ // and the replacement text hasn't, then add it to the replacement
+ if (!aTmp.isEmpty() && !aOrig.isEmpty() &&
+ aOrig.endsWith(".") && /* !IsAlphaNumeric ??*/
+ !aTmp.endsWith("."))
+ {
+ aTmp += ".";
+ }
+
+ // #111827#
+ SwRewriter aRewriter;
+
+ aRewriter.AddRule(UndoArg1, m_pSh->GetCrsrDescr());
+ aRewriter.AddRule(UndoArg2, OUString(SW_RES(STR_YIELDS)));
+
+ OUString aTmpStr( SW_RES(STR_START_QUOTE) );
+ aTmpStr += aTmp;
+ aTmpStr += OUString(SW_RES(STR_END_QUOTE));
+ aRewriter.AddRule(UndoArg3, aTmpStr);
+
+ m_pSh->StartUndo(UNDO_UI_REPLACE, &aRewriter);
+ m_pSh->StartAction();
+ m_pSh->DelLeft();
+
+ m_pSh->Insert( aTmp );
+
+ /* #102505# EndAction/EndUndo moved down since insertion
+ of temporary auto correction is now undoable two and
+ must reside in the same undo group.*/
+
+ // record only if it's NOT already present in autocorrection
+ SvxAutoCorrect* pACorr = SvxAutoCorrCfg::Get().GetAutoCorrect();
+
+ OUString aOrigWord( m_bGrammarResults ? OUString() : m_xSpellAlt->getWord() ) ;
+ OUString aNewWord( m_aSuggestions[ nAltIdx ] );
+ SvxPrepareAutoCorrect( aOrigWord, aNewWord );
+
+ if (MN_AUTOCORR_START <= nId && nId <= MN_AUTOCORR_END)
+ pACorr->PutText( aOrigWord, aNewWord, m_nCheckedLanguage );
+
+ /* #102505# EndAction/EndUndo moved down since insertion
+ of temporary auto correction is now undoable two and
+ must reside in the same undo group.*/
+ m_pSh->EndAction();
+ m_pSh->EndUndo();
+
+ m_pSh->SetInsMode( bOldIns );
+ }
+ }
+ else if (nId == MN_SPELLING_DLG)
+ {
+ if (m_bGrammarResults)
+ {
+ SvtLinguConfig().SetProperty( UPN_IS_GRAMMAR_INTERACTIVE, uno::makeAny( sal_True ));
+ }
+ m_pSh->Left(CRSR_SKIP_CHARS, sal_False, 1, sal_False );
+ {
+ uno::Reference<linguistic2::XSearchableDictionaryList> xDictionaryList( SvxGetDictionaryList() );
+ SvxDicListChgClamp aClamp( xDictionaryList );
+ m_pSh->GetView().GetViewFrame()->GetDispatcher()->
+ Execute( FN_SPELL_GRAMMAR_DIALOG, SFX_CALLMODE_ASYNCHRON );
+ }
+ }
+ else if (nId == MN_IGNORE_SELECTION)
+ {
+ SwPaM *pPaM = m_pSh->GetCrsr();
+ if (pPaM)
+ m_pSh->IgnoreGrammarErrorAt( *pPaM );
+ }
+ else if (nId == MN_IGNORE_WORD)
+ {
+ uno::Reference< linguistic2::XDictionary > xDictionary( SvxGetIgnoreAllList(), uno::UNO_QUERY );
+ if (m_bGrammarResults) {
+ try
+ {
+ m_xGrammarResult.xProofreader->ignoreRule(
+ m_xGrammarResult.aErrors[ m_nGrammarError ].aRuleIdentifier,
+ m_xGrammarResult.aLocale );
+ // refresh the layout of the actual paragraph (faster)
+ SwPaM *pPaM = m_pSh->GetCrsr();
+ if (pPaM)
+ m_pSh->IgnoreGrammarErrorAt( *pPaM );
+ // refresh the layout of all paragraphs (workaround to launch a dictionary event)
+ xDictionary->setActive(sal_False);
+ xDictionary->setActive(sal_True);
+ }
+ catch( const uno::Exception& )
+ {
+ }
+ } else {
+ linguistic::AddEntryToDic( xDictionary,
+ m_xSpellAlt->getWord(), sal_False, OUString(), LANGUAGE_NONE );
+ }
+ }
+ else if ((MN_DICTIONARIES_START <= nId && nId <= MN_DICTIONARIES_END) || nId == MN_ADD_TO_DIC_SINGLE)
+ {
+ OUString aWord( m_xSpellAlt->getWord() );
+ OUString aDicName;
+
+ if (MN_DICTIONARIES_START <= nId && nId <= MN_DICTIONARIES_END)
+ {
+ PopupMenu *pMenu = GetPopupMenu(MN_ADD_TO_DIC);
+ aDicName = pMenu->GetItemText(nId);
+ }
+ else
+ aDicName = m_aDicNameSingle;
+
+ uno::Reference< linguistic2::XDictionary > xDic;
+ uno::Reference< linguistic2::XSearchableDictionaryList > xDicList( SvxGetDictionaryList() );
+ if (xDicList.is())
+ xDic = xDicList->getDictionaryByName( aDicName );
+
+ if (xDic.is())
+ {
+ sal_Int16 nAddRes = linguistic::AddEntryToDic( xDic, aWord, sal_False, OUString(), LANGUAGE_NONE );
+ // save modified user-dictionary if it is persistent
+ uno::Reference< frame::XStorable > xSavDic( xDic, uno::UNO_QUERY );
+ if (xSavDic.is())
+ xSavDic->store();
+
+ if (DIC_ERR_NONE != nAddRes
+ && !xDic->getEntry( aWord ).is())
+ {
+ SvxDicError(
+ &m_pSh->GetView().GetViewFrame()->GetWindow(),
+ nAddRes );
+ }
+ }
+ }
+ else if ( nId == MN_EXPLANATION_LINK && !m_sExplanationLink.isEmpty() )
+ {
+ try
+ {
+ uno::Reference< com::sun::star::system::XSystemShellExecute > xSystemShellExecute(
+ com::sun::star::system::SystemShellExecute::create( ::comphelper::getProcessComponentContext() ) );
+ xSystemShellExecute->execute( m_sExplanationLink, OUString(),
+ com::sun::star::system::SystemShellExecuteFlags::URIS_ONLY );
+ }
+ catch (const uno::Exception&)
+ {
+ uno::Any exc( ::cppu::getCaughtException() );
+ OUString msg( ::comphelper::anyToString( exc ) );
+ const SolarMutexGuard guard;
+ MessageDialog aErrorBox(NULL, msg);
+ aErrorBox.SetText( "Explanations" );
+ aErrorBox.Execute();
+ }
+ }
+ else if (nId == FN_REDLINE_ACCEPT_DIRECT || nId == FN_REDLINE_REJECT_DIRECT
+ || nId == FN_REDLINE_NEXT_CHANGE || nId == FN_REDLINE_PREV_CHANGE)
+ {
+ // Let SwView::Execute() handle the redline actions.
+ SfxRequest aReq(m_pSh->GetView().GetViewFrame(), nId);
+ m_pSh->GetView().Execute(aReq);
+ }
+ else
+ {
+ // Set language for selection or for paragraph...
+
+ SfxItemSet aCoreSet( m_pSh->GetView().GetPool(),
+ RES_CHRATR_LANGUAGE, RES_CHRATR_LANGUAGE,
+ RES_CHRATR_CJK_LANGUAGE, RES_CHRATR_CJK_LANGUAGE,
+ RES_CHRATR_CTL_LANGUAGE, RES_CHRATR_CTL_LANGUAGE,
+ 0 );
+ OUString aNewLangTxt;
+
+ if (MN_SET_LANGUAGE_SELECTION_START <= nId && nId <= MN_SET_LANGUAGE_SELECTION_END)
+ {
+ //Set language for current selection
+ aNewLangTxt = m_aLangTable_Text[nId];
+ SwLangHelper::SetLanguage( *m_pSh, aNewLangTxt, true, aCoreSet );
+ }
+ else if (nId == MN_SET_SELECTION_NONE)
+ {
+ //Set Language_None for current selection
+ SwLangHelper::SetLanguage_None( *m_pSh, true, aCoreSet );
+ }
+ else if (nId == MN_SET_SELECTION_RESET)
+ {
+ //reset languages for current selection
+ SwLangHelper::ResetLanguages( *m_pSh, true );
+ }
+ else if (nId == MN_SET_SELECTION_MORE)
+ {
+ //Open Format/Character Dialog
+ sw_CharDialog( *m_pSh, true, nId, 0, 0 );
+ }
+ else if (MN_SET_LANGUAGE_PARAGRAPH_START <= nId && nId <= MN_SET_LANGUAGE_PARAGRAPH_END)
+ {
+ //Set language for current paragraph
+ aNewLangTxt = m_aLangTable_Paragraph[nId];
+ m_pSh->Push(); // save cursor
+ SwLangHelper::SelectCurrentPara( *m_pSh );
+ SwLangHelper::SetLanguage( *m_pSh, aNewLangTxt, true, aCoreSet );
+ m_pSh->Pop( sal_False ); // restore cursor
+ }
+ else if (nId == MN_SET_PARA_NONE)
+ {
+ //Set Language_None for current paragraph
+ m_pSh->Push(); // save cursor
+ SwLangHelper::SelectCurrentPara( *m_pSh );
+ SwLangHelper::SetLanguage_None( *m_pSh, true, aCoreSet );
+ m_pSh->Pop( sal_False ); // restore cursor
+ }
+ else if (nId == MN_SET_PARA_RESET)
+ {
+ //reset languages for current paragraph
+ m_pSh->Push(); // save cursor
+ SwLangHelper::SelectCurrentPara( *m_pSh );
+ SwLangHelper::ResetLanguages( *m_pSh, true );
+ m_pSh->Pop( sal_False ); // restore cursor
+ }
+ else if (nId == MN_SET_PARA_MORE)
+ {
+ m_pSh->Push(); // save cursor
+ SwLangHelper::SelectCurrentPara( *m_pSh );
+ //Open Format/Character Dialog
+ sw_CharDialog( *m_pSh, true, nId, 0, 0 );
+ m_pSh->Pop( sal_False ); // restore cursor
+ }
+ }
+
+ m_pSh->EnterStdMode();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/lingu/olmenu.hrc b/sw/source/core/uibase/lingu/olmenu.hrc
new file mode 100644
index 000000000000..0a8ae91cec6e
--- /dev/null
+++ b/sw/source/core/uibase/lingu/olmenu.hrc
@@ -0,0 +1,89 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef _OLMENU_HRC
+#define _OLMENU_HRC
+
+#include "rcid.hrc"
+
+#define MN_SPELL_POPUP (RC_LINGU_BEGIN + 1)
+#define STR_SPELL_OK (RC_LINGU_BEGIN + 2)
+#define STR_HYP_OK (RC_LINGU_BEGIN + 3)
+#define STR_WORD (RC_LINGU_BEGIN + 4)
+#define STR_PARAGRAPH (RC_LINGU_BEGIN + 5)
+#define STR_LANGSTATUS_NONE (RC_LINGU_BEGIN + 6)
+#define STR_LANGSTATUS_MORE (RC_LINGU_BEGIN + 7)
+#define STR_IGNORE_SELECTION (RC_LINGU_BEGIN + 8)
+#define STR_RESET_TO_DEFAULT_LANGUAGE (RC_LINGU_BEGIN + 9)
+#define STR_EXPLANATION_LINK (RC_LINGU_BEGIN + 10)
+
+#define IMG_INFO_16 (RC_LINGU_BEGIN + 100)
+
+//! Don't change these values. You may break context menu modifying extensions!
+#define MN_SPELLING_DLG 200
+#define MN_IGNORE_SELECTION 201
+#define MN_IGNORE_WORD 202
+#define MN_ADD_TO_DIC 203
+#define MN_AUTOCORR 204
+#define MN_SET_LANGUAGE_SELECTION 205
+#define MN_SET_LANGUAGE_PARAGRAPH 206
+#define MN_SET_LANGUAGE_ALL_TEXT 207
+#define MN_SHORT_COMMENT 208
+#define MN_EXPLANATION_LINK 209
+#define MN_ADD_TO_DIC_SINGLE 210
+
+// id range for dictionaries sub menu
+#define MN_DICTIONARIES_START 300
+#define MN_DICTIONARIES_END (MN_DICTIONARIES_START + 99)
+
+// id range for suggestions from spell and grammar checker
+#define MN_SUGGESTION_START 500
+#define MN_SUGGESTION_END (MN_SUGGESTION_START + MN_MAX_NUM_LANG)
+
+// id range for auto correction sub menu entries
+#define MN_AUTOCORR_START 700
+#define MN_AUTOCORR_END (MN_AUTOCORR_START + MN_MAX_NUM_LANG)
+
+// max number of language entries sub menus
+#define MN_MAX_NUM_LANG 99
+
+#define MN_NONE_OFFSET (MN_MAX_NUM_LANG + 1)
+#define MN_RESET_OFFSET (MN_MAX_NUM_LANG + 2)
+#define MN_MORE_OFFSET (MN_MAX_NUM_LANG + 3)
+
+// id range for 'set language for selection' sub menu entries
+#define MN_SET_LANGUAGE_SELECTION_START 900
+#define MN_SET_LANGUAGE_SELECTION_END (MN_SET_LANGUAGE_SELECTION_START + MN_MAX_NUM_LANG)
+#define MN_SET_SELECTION_NONE (MN_SET_LANGUAGE_SELECTION_START + MN_NONE_OFFSET)
+#define MN_SET_SELECTION_RESET (MN_SET_LANGUAGE_SELECTION_START + MN_RESET_OFFSET)
+#define MN_SET_SELECTION_MORE (MN_SET_LANGUAGE_SELECTION_START + MN_MORE_OFFSET)
+
+// id range for 'set language for paragraph' sub menu entries
+#define MN_SET_LANGUAGE_PARAGRAPH_START 1100
+#define MN_SET_LANGUAGE_PARAGRAPH_END (MN_SET_LANGUAGE_PARAGRAPH_START + MN_MAX_NUM_LANG)
+#define MN_SET_PARA_NONE (MN_SET_LANGUAGE_PARAGRAPH_START + MN_NONE_OFFSET)
+#define MN_SET_PARA_RESET (MN_SET_LANGUAGE_PARAGRAPH_START + MN_RESET_OFFSET)
+#define MN_SET_PARA_MORE (MN_SET_LANGUAGE_PARAGRAPH_START + MN_MORE_OFFSET)
+
+// id range for 'set language for all text' sub menu entries
+#define MN_SET_LANGUAGE_ALL_TEXT_START 1300
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/lingu/olmenu.src b/sw/source/core/uibase/lingu/olmenu.src
new file mode 100644
index 000000000000..293d8043c7db
--- /dev/null
+++ b/sw/source/core/uibase/lingu/olmenu.src
@@ -0,0 +1,131 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+/* StarView resource file */
+
+#include "olmenu.hrc"
+#include "helpid.h"
+#include "redline.hrc"
+
+#define MASKCOLOR MaskColor = Color { Red = 0xFFFF ; Green = 0x0000 ; Blue = 0xFFFF ; };
+#define SEPARATOR MenuItem { Separator = TRUE; };
+
+Menu MN_SPELL_POPUP
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = MN_IGNORE_WORD ;
+ HelpID = HID_LINGU_IGNORE_WORD ;
+ Text [ en-US ] = "Ignore All" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_ADD_TO_DIC ;
+ HelpID = HID_LINGU_ADD_WORD ;
+ SubMenu = Menu
+ {
+ };
+ Text [ en-US ] = "~Add to Dictionary" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_ADD_TO_DIC_SINGLE ;
+ HelpID = HID_LINGU_ADD_WORD ;
+ Text [ en-US ] = "~Add to Dictionary" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_AUTOCORR ;
+ HelpID = HID_LINGU_AUTOCORR ;
+ SubMenu = Menu
+ {
+ };
+ Text [ en-US ] = "Always correct to" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_SPELLING_DLG ;
+ HelpID = HID_LINGU_SPELLING_DLG ;
+ Text [ en-US ] = "~Spellcheck..." ;
+ };
+ SEPARATOR
+ MenuItem
+ {
+ Identifier = MN_SET_LANGUAGE_SELECTION ;
+ SubMenu = Menu
+ {
+ };
+ Text [ en-US ] = "Set Language for Selection" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_SET_LANGUAGE_PARAGRAPH ;
+ SubMenu = Menu
+ {
+ };
+ Text [ en-US ] = "Set Language for Paragraph" ;
+ };
+ SEPARATOR
+ MN_EDIT_REDLINE
+ };
+};
+String STR_WORD
+{
+ Text [ en-US ] = "Word is " ;
+};
+String STR_PARAGRAPH
+{
+ Text [ en-US ] = "Paragraph is " ;
+};
+String STR_SPELL_OK
+{
+ Text [ en-US ] = "The spellcheck is complete." ;
+};
+String STR_HYP_OK
+{
+ Text [ en-US ] = "Hyphenation completed" ;
+};
+String STR_LANGSTATUS_NONE
+{
+ Text [ en-US ] = "None (Do not check spelling)" ;
+};
+String STR_RESET_TO_DEFAULT_LANGUAGE
+{
+ Text [ en-US ] = "Reset to Default Language" ;
+};
+String STR_LANGSTATUS_MORE
+{
+ Text [ en-US ] = "More..." ;
+};
+String STR_IGNORE_SELECTION
+{
+ Text [ en-US ] = "Ignore" ;
+};
+String STR_EXPLANATION_LINK
+{
+ Text [ en-US ] = "Explanations..." ;
+};
+Image IMG_INFO_16
+{
+ ImageBitmap = Bitmap { File = "info_16.png" ; };
+ MASKCOLOR
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/lingu/sdrhhcwrap.cxx b/sw/source/core/uibase/lingu/sdrhhcwrap.cxx
new file mode 100644
index 000000000000..3a05a06b3328
--- /dev/null
+++ b/sw/source/core/uibase/lingu/sdrhhcwrap.cxx
@@ -0,0 +1,175 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <hintids.hxx>
+#include <svx/svditer.hxx>
+#include <svx/svdotext.hxx>
+#include <editeng/editdata.hxx>
+#include <svx/svdpagv.hxx>
+#include <svx/svdogrp.hxx>
+#include <sfx2/printer.hxx>
+#include <svx/svdmodel.hxx>
+#include <editeng/langitem.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <linguistic/lngprops.hxx>
+#include <sfx2/sfxuno.hxx>
+#include <svx/svdview.hxx>
+#include <editeng/unolingu.hxx>
+#include <unotools/localedatawrapper.hxx>
+#include <sdrhhcwrap.hxx>
+#include <frmfmt.hxx>
+#include <docsh.hxx>
+#include <wrtsh.hxx>
+#include <view.hxx>
+#include <dcontact.hxx>
+#include <doc.hxx>
+#include <docary.hxx>
+#include <edtwin.hxx>
+
+using namespace ::com::sun::star;
+
+SdrHHCWrapper::SdrHHCWrapper( SwView* pVw,
+ LanguageType nSourceLanguage, LanguageType nTargetLanguage,
+ const Font* pTargetFnt,
+ sal_Int32 nConvOptions,
+ bool bInteractive ) :
+ SdrOutliner(pVw->GetDocShell()->GetDoc()->GetDrawModel()->
+ GetDrawOutliner().GetEmptyItemSet().GetPool(),
+ OUTLINERMODE_TEXTOBJECT ),
+ pView( pVw ),
+ pTextObj( NULL ),
+ pOutlView( NULL ),
+ nOptions( nConvOptions ),
+ nDocIndex( 0 ),
+ nSourceLang( nSourceLanguage ),
+ nTargetLang( nTargetLanguage ),
+ pTargetFont( pTargetFnt ),
+ bIsInteractive( bInteractive )
+{
+ SetRefDevice( pView->GetDocShell()->GetDoc()->getPrinter( false ) );
+
+ MapMode aMapMode (MAP_TWIP);
+ SetRefMapMode(aMapMode);
+
+ Size aSize( 1, 1 );
+ SetPaperSize( aSize );
+
+ pOutlView = new OutlinerView( this, &(pView->GetEditWin()) );
+ pOutlView->GetOutliner()->SetRefDevice(pView->GetWrtShell().getIDocumentDeviceAccess()->getPrinter( false ));
+
+ // Hack: all SdrTextObj attributes should be transferred to EditEngine
+ pOutlView->SetBackgroundColor( Color( COL_WHITE ) );
+
+ InsertView( pOutlView );
+ Point aPoint( 0, 0 );
+ Rectangle aRect( aPoint, aSize );
+ pOutlView->SetOutputArea( aRect );
+// SetText( NULL );
+ ClearModifyFlag();
+}
+
+SdrHHCWrapper::~SdrHHCWrapper()
+{
+ if (pTextObj)
+ {
+ SdrView *pSdrView = pView->GetWrtShell().GetDrawView();
+ OSL_ENSURE( pSdrView, "SdrHHCWrapper without DrawView?" );
+ pSdrView->SdrEndTextEdit( sal_True );
+ SetUpdateMode(false);
+ pOutlView->SetOutputArea( Rectangle( Point(), Size(1, 1) ) );
+ }
+ RemoveView( pOutlView );
+ delete pOutlView;
+}
+
+void SdrHHCWrapper::StartTextConversion()
+{
+ pOutlView->StartTextConversion( nSourceLang, nTargetLang, pTargetFont, nOptions, bIsInteractive, true );
+}
+
+bool SdrHHCWrapper::ConvertNextDocument()
+{
+ bool bNextDoc = false;
+
+ if ( pTextObj )
+ {
+ SdrView *pSdrView = pView->GetWrtShell().GetDrawView();
+ OSL_ENSURE( pSdrView, "SdrHHCWrapper without DrawView?" );
+ pSdrView->SdrEndTextEdit( sal_True );
+ SetUpdateMode(false);
+ pOutlView->SetOutputArea( Rectangle( Point(), Size(1, 1) ) );
+ SetPaperSize( Size(1, 1) );
+ Clear();
+ pTextObj = NULL;
+ }
+
+ sal_uInt16 n = nDocIndex;
+
+ std::list<SdrTextObj*> aTextObjs;
+ SwDrawContact::GetTextObjectsFromFmt( aTextObjs, pView->GetDocShell()->GetDoc() );
+ for ( std::list<SdrTextObj*>::iterator aIt = aTextObjs.begin(); aIt != aTextObjs.end(); ++aIt )
+ {
+ pTextObj = (*aIt);
+ if ( pTextObj )
+ {
+ OutlinerParaObject* pParaObj = pTextObj->GetOutlinerParaObject();
+ if ( pParaObj )
+ {
+ SetPaperSize( pTextObj->GetLogicRect().GetSize() );
+ SetText( *pParaObj );
+
+ ClearModifyFlag();
+
+ //!! update mode needs to be set to true otherwise
+ //!! the call to 'HasConvertibleTextPortion' will not always
+ //!! work correctly because the document may not be properly
+ //!! formatted when some information is accessed, and thus
+ //!! incorrect results get returned.
+ SetUpdateMode(true);
+ if (HasConvertibleTextPortion( nSourceLang ))
+ {
+ SdrView *pSdrView = pView->GetWrtShell().GetDrawView();
+ OSL_ENSURE( pSdrView, "SdrHHCWrapper without DrawView?" );
+ SdrPageView* pPV = pSdrView->GetSdrPageView();
+ nDocIndex = n;
+ bNextDoc = true;
+ pOutlView->SetOutputArea( Rectangle( Point(), Size(1,1)));
+ SetPaperSize( pTextObj->GetLogicRect().GetSize() );
+ SetUpdateMode(true);
+ pView->GetWrtShell().MakeVisible(pTextObj->GetLogicRect());
+
+ pSdrView->SdrBeginTextEdit(pTextObj, pPV, &pView->GetEditWin(), sal_False, this, pOutlView, sal_True, sal_True);
+ }
+ else
+ SetUpdateMode(false);
+ }
+
+ if ( !bNextDoc )
+ pTextObj = NULL;
+ else
+ break;
+ }
+ }
+
+ ClearModifyFlag();
+
+ return bNextDoc;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/lingu/sdrhhcwrap.hxx b/sw/source/core/uibase/lingu/sdrhhcwrap.hxx
new file mode 100644
index 000000000000..d6befe334b44
--- /dev/null
+++ b/sw/source/core/uibase/lingu/sdrhhcwrap.hxx
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_LINGU_SDRHHCWRAP_HXX
+#define INCLUDED_SW_SOURCE_UI_LINGU_SDRHHCWRAP_HXX
+
+#include <svx/svdoutl.hxx>
+
+class SwView;
+class SdrTextObj;
+class OutlinerView;
+
+class SdrHHCWrapper : public SdrOutliner
+{
+ // modified version of SdrSpeller
+
+ SwView* pView;
+ SdrTextObj* pTextObj;
+ OutlinerView* pOutlView;
+ sal_Int32 nOptions;
+ sal_uInt16 nDocIndex;
+ LanguageType nSourceLang;
+ LanguageType nTargetLang;
+ const Font* pTargetFont;
+ bool bIsInteractive;
+
+public:
+ SdrHHCWrapper( SwView* pVw,
+ LanguageType nSourceLanguage, LanguageType nTargetLanguage,
+ const Font* pTargetFnt,
+ sal_Int32 nConvOptions, bool bInteractive );
+
+ virtual ~SdrHHCWrapper();
+
+ virtual bool ConvertNextDocument();
+ void StartTextConversion();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/misc/glosdoc.cxx b/sw/source/core/uibase/misc/glosdoc.cxx
new file mode 100644
index 000000000000..4236067c95a8
--- /dev/null
+++ b/sw/source/core/uibase/misc/glosdoc.cxx
@@ -0,0 +1,693 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <algorithm>
+
+#include <com/sun/star/container/XNamed.hpp>
+
+#include <unotools/transliterationwrapper.hxx>
+
+#ifndef __RSC //autogen
+#include <tools/errinf.hxx>
+#endif
+#include <osl/diagnose.h>
+#include <svl/urihelper.hxx>
+#include <svl/fstathelper.hxx>
+#include <unotools/pathoptions.hxx>
+#include <unotools/tempfile.hxx>
+#include <comphelper/string.hxx>
+#include <swtypes.hxx>
+#include <uitool.hxx>
+#include <glosdoc.hxx>
+#include <shellio.hxx>
+#include <swunohelper.hxx>
+
+#include <unoatxt.hxx>
+#include <swerror.h>
+#include <globals.hrc>
+
+#include <boost/scoped_ptr.hpp>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+namespace
+{
+
+inline OUString lcl_FullPathName(const OUString sPath, const OUString sName)
+{
+ return sPath + OUString(INET_PATH_TOKEN) + sName + SwGlossaries::GetExtension();
+}
+
+OUString lcl_CheckFileName( const OUString& rNewFilePath,
+ const OUString& rNewGroupName )
+{
+ const sal_Int32 nLen = rNewGroupName.getLength();
+ OUStringBuffer aBuf(nLen);
+ //group name should contain only A-Z and a-z and spaces
+ for( sal_Int32 i=0; i < nLen; ++i )
+ {
+ const sal_Unicode cChar = rNewGroupName[i];
+ if (comphelper::string::isalnumAscii(cChar) ||
+ cChar == '_' || cChar == 0x20)
+ {
+ aBuf.append(cChar);
+ }
+ }
+
+ const OUString sRet = aBuf.makeStringAndClear().trim();
+ if ( !sRet.isEmpty() )
+ {
+ if (!FStatHelper::IsDocument( lcl_FullPathName(rNewFilePath, sRet) ))
+ return sRet;
+ }
+
+ OUString rSG = SwGlossaries::GetExtension();
+ //generate generic name
+ utl::TempFile aTemp(OUString("group"), &rSG, &rNewFilePath );
+ aTemp.EnableKillingFile();
+
+ INetURLObject aTempURL( aTemp.GetURL() );
+ return aTempURL.GetBase();
+}
+
+}
+
+/*------------------------------------------------------------------------
+ Description: supplies the default group's name
+------------------------------------------------------------------------*/
+OUString SwGlossaries::GetDefName()
+{
+ return OUString("standard");
+
+}
+
+/*------------------------------------------------------------------------
+ Description: supplies the number of text block groups
+------------------------------------------------------------------------*/
+sal_uInt16 SwGlossaries::GetGroupCnt()
+{
+ return static_cast<sal_uInt16>(GetNameList().size());
+}
+
+/*------------------------------------------------------------------------
+ Description: supplies the group's name
+------------------------------------------------------------------------*/
+sal_Bool SwGlossaries::FindGroupName(OUString& rGroup)
+{
+ // if the group name doesn't contain a path, a suitable group entry
+ // can the searched for here;
+ sal_uInt16 nCount = GetGroupCnt();
+ sal_uInt16 i;
+ for(i= 0; i < nCount; i++)
+ {
+ const OUString sTemp(GetGroupName(i));
+ if (rGroup==sTemp.getToken(0, GLOS_DELIM))
+ {
+ rGroup = sTemp;
+ return sal_True;
+ }
+ }
+ // you can search two times because for more directories the case sensitive
+ // name could occur multiple times
+ const ::utl::TransliterationWrapper& rSCmp = GetAppCmpStrIgnore();
+ for(i = 0; i < nCount; i++)
+ {
+ const OUString sTemp( GetGroupName( i ));
+ sal_uInt16 nPath = (sal_uInt16)sTemp.getToken(1, GLOS_DELIM).toInt32();
+
+ if (!SWUnoHelper::UCB_IsCaseSensitiveFileName( m_PathArr[nPath] )
+ && rSCmp.isEqual( rGroup, sTemp.getToken( 0, GLOS_DELIM) ) )
+ {
+ rGroup = sTemp;
+ return sal_True;
+ }
+ }
+ return sal_False;
+}
+
+OUString SwGlossaries::GetGroupName(sal_uInt16 nGroupId)
+{
+ OSL_ENSURE(static_cast<size_t>(nGroupId) < m_GlosArr.size(),
+ "SwGlossaries::GetGroupName: index out of bounds");
+ return m_GlosArr[nGroupId];
+}
+
+OUString SwGlossaries::GetGroupTitle( const OUString& rGroupName )
+{
+ OUString sRet;
+ OUString sGroup(rGroupName);
+ if (sGroup.indexOf(GLOS_DELIM)<0)
+ FindGroupName(sGroup);
+ SwTextBlocks* pGroup = GetGroupDoc(sGroup, sal_False);
+ if(pGroup)
+ {
+ sRet = pGroup->GetName();
+ PutGroupDoc( pGroup );
+ }
+ return sRet;
+}
+
+/*------------------------------------------------------------------------
+ Description: supplies the group rName's text block document
+------------------------------------------------------------------------*/
+SwTextBlocks* SwGlossaries::GetGroupDoc(const OUString &rName,
+ sal_Bool bCreate)
+{
+ // insert to the list of text blocks if applicable
+ if(bCreate && !m_GlosArr.empty())
+ {
+ std::vector<OUString>::const_iterator it(m_GlosArr.begin());
+ for (; it != m_GlosArr.end(); ++it)
+ {
+ if (*it == rName)
+ break;
+ }
+ if (it == m_GlosArr.end())
+ { // block not in the list
+ m_GlosArr.push_back(rName);
+ }
+ }
+ return GetGlosDoc( rName, bCreate );
+}
+
+/*------------------------------------------------------------------------
+ Description: delete a text block
+------------------------------------------------------------------------*/
+void SwGlossaries::PutGroupDoc(SwTextBlocks *pBlock) {
+ delete pBlock;
+}
+
+/*------------------------------------------------------------------------
+ Description: Creates a new document with the group name. temporarly
+ also created as file so that groups remain there later
+ (without access).
+------------------------------------------------------------------------*/
+sal_Bool SwGlossaries::NewGroupDoc(OUString& rGroupName, const OUString& rTitle)
+{
+ const OUString sNewPath(rGroupName.getToken(1, GLOS_DELIM));
+ sal_uInt16 nNewPath = (sal_uInt16)sNewPath.toInt32();
+ if (static_cast<size_t>(nNewPath) >= m_PathArr.size())
+ return sal_False;
+ const OUString sNewFilePath(m_PathArr[nNewPath]);
+ const OUString sNewGroup = lcl_CheckFileName(sNewFilePath, rGroupName.getToken(0, GLOS_DELIM))
+ + OUString(GLOS_DELIM) + sNewPath;
+ SwTextBlocks *pBlock = GetGlosDoc( sNewGroup );
+ if(pBlock)
+ {
+ GetNameList().push_back(sNewGroup);
+ pBlock->SetName(rTitle);
+ PutGroupDoc(pBlock);
+ rGroupName = sNewGroup;
+ return sal_True;
+ }
+ return sal_False;
+}
+
+sal_Bool SwGlossaries::RenameGroupDoc(
+ const OUString& rOldGroup, OUString& rNewGroup, const OUString& rNewTitle )
+{
+ sal_uInt16 nOldPath = (sal_uInt16)rOldGroup.getToken(1, GLOS_DELIM).toInt32();
+ if (static_cast<size_t>(nOldPath) >= m_PathArr.size())
+ return sal_False;
+
+ const OUString sOldFileURL =
+ lcl_FullPathName(m_PathArr[nOldPath], rOldGroup.getToken(0, GLOS_DELIM));
+
+ if (!FStatHelper::IsDocument( sOldFileURL ))
+ {
+ OSL_FAIL("group doesn't exist!");
+ return sal_False;
+ }
+
+ sal_uInt16 nNewPath = (sal_uInt16)rNewGroup.getToken(1, GLOS_DELIM).toInt32();
+ if (static_cast<size_t>(nNewPath) >= m_PathArr.size())
+ return sal_False;
+
+ const OUString sNewFileName = lcl_CheckFileName(m_PathArr[nNewPath],
+ rNewGroup.getToken(0, GLOS_DELIM));
+ const OUString sNewFileURL = lcl_FullPathName(m_PathArr[nNewPath], sNewFileName);
+
+ if (FStatHelper::IsDocument( sNewFileURL ))
+ {
+ OSL_FAIL("group already exists!");
+ return sal_False;
+ }
+
+ if (!SWUnoHelper::UCB_CopyFile(sOldFileURL, sNewFileURL, sal_True ))
+ return sal_False;
+
+ RemoveFileFromList( rOldGroup );
+
+ rNewGroup = sNewFileName + OUString(GLOS_DELIM) + OUString::number(nNewPath);
+ if (m_GlosArr.empty())
+ {
+ GetNameList();
+ }
+ else
+ {
+ m_GlosArr.push_back(rNewGroup);
+ }
+
+ SwTextBlocks* pNewBlock = new SwTextBlocks( sNewFileURL );
+ pNewBlock->SetName(rNewTitle);
+ delete pNewBlock;
+
+ return sal_True;
+}
+
+/*------------------------------------------------------------------------
+ Description: Deletes a text block group
+------------------------------------------------------------------------*/
+sal_Bool SwGlossaries::DelGroupDoc(const OUString &rName)
+{
+ sal_uInt16 nPath = (sal_uInt16)rName.getToken(1, GLOS_DELIM).toInt32();
+ if (static_cast<size_t>(nPath) >= m_PathArr.size())
+ return sal_False;
+ const OUString sBaseName(rName.getToken(0, GLOS_DELIM));
+ const OUString sFileURL = lcl_FullPathName(m_PathArr[nPath], sBaseName);
+ const OUString aName = sBaseName + OUString(GLOS_DELIM) + OUString::number(nPath);
+ // Even if the file doesn't exist it has to be deleted from
+ // the list of text block regions
+ // no && because of CFfront
+ sal_Bool bRemoved = SWUnoHelper::UCB_DeleteFile( sFileURL );
+ OSL_ENSURE(bRemoved, "file has not been removed");
+ RemoveFileFromList( aName );
+ return bRemoved;
+}
+
+SwGlossaries::~SwGlossaries()
+{
+ InvalidateUNOOjects();
+}
+
+/*------------------------------------------------------------------------
+ Description: read a block document
+------------------------------------------------------------------------*/
+SwTextBlocks* SwGlossaries::GetGlosDoc( const OUString &rName, sal_Bool bCreate ) const
+{
+ sal_uInt16 nPath = (sal_uInt16)rName.getToken(1, GLOS_DELIM).toInt32();
+ SwTextBlocks *pTmp = 0;
+ if (static_cast<size_t>(nPath) < m_PathArr.size())
+ {
+ const OUString sFileURL =
+ lcl_FullPathName(m_PathArr[nPath], rName.getToken(0, GLOS_DELIM));
+
+ sal_Bool bExist = sal_False;
+ if(!bCreate)
+ bExist = FStatHelper::IsDocument( sFileURL );
+
+ if (bCreate || bExist)
+ {
+ pTmp = new SwTextBlocks( sFileURL );
+ bool bOk = true;
+ if( pTmp->GetError() )
+ {
+ ErrorHandler::HandleError( pTmp->GetError() );
+ bOk = !IsError( pTmp->GetError() );
+ }
+
+ if( bOk && pTmp->GetName().isEmpty() )
+ pTmp->SetName( rName );
+ }
+ }
+
+ return pTmp;
+}
+
+/*------------------------------------------------------------------------
+ Description: access to the list of names; read in if applicable
+------------------------------------------------------------------------*/
+std::vector<OUString> & SwGlossaries::GetNameList()
+{
+ if (m_GlosArr.empty())
+ {
+ const OUString sExt( SwGlossaries::GetExtension() );
+ for (size_t i = 0; i < m_PathArr.size(); ++i)
+ {
+ std::vector<OUString> aFiles;
+
+ SWUnoHelper::UCB_GetFileListOfFolder(m_PathArr[i], aFiles, &sExt);
+ for( std::vector<OUString>::const_iterator filesIt(aFiles.begin());
+ filesIt != aFiles.end(); ++filesIt)
+ {
+ const OUString aTitle = *filesIt;
+ const OUString sName( aTitle.copy( 0, aTitle.getLength() - sExt.getLength() )
+ + OUString(GLOS_DELIM) + OUString::number( static_cast<sal_Int16>(i) ));
+ m_GlosArr.push_back(sName);
+ }
+ }
+ if (m_GlosArr.empty())
+ {
+ // the standard block is inside of the path's first part
+ m_GlosArr.push_back( SwGlossaries::GetDefName() + OUString(GLOS_DELIM) + "0" );
+ }
+ }
+ return m_GlosArr;
+}
+
+SwGlossaries::SwGlossaries()
+{
+ UpdateGlosPath(sal_True);
+}
+
+/*------------------------------------------------------------------------
+ Description: set new path and recreate internal array
+------------------------------------------------------------------------*/
+
+rtl::OUString lcl_makePath(const std::vector<rtl::OUString>& rPaths)
+{
+ std::vector<rtl::OUString>::const_iterator aIt(rPaths.begin());
+ const std::vector<rtl::OUString>::const_iterator aEnd(rPaths.end());
+ rtl::OUStringBuffer aPath(*aIt);
+ for (++aIt; aIt != aEnd; ++aIt)
+ {
+ aPath.append(SVT_SEARCHPATH_DELIMITER);
+ const INetURLObject aTemp(*aIt);
+ aPath.append(aTemp.GetFull());
+ }
+ return aPath.getStr();
+}
+
+void SwGlossaries::UpdateGlosPath(sal_Bool bFull)
+{
+ SvtPathOptions aPathOpt;
+ OUString aNewPath( aPathOpt.GetAutoTextPath() );
+ bool bPathChanged = m_aPath != aNewPath;
+ if (bFull || bPathChanged)
+ {
+ m_aPath = aNewPath;
+
+ m_PathArr.clear();
+
+ std::vector<OUString> aDirArr;
+ std::vector<rtl::OUString> aInvalidPaths;
+ if (!m_aPath.isEmpty())
+ {
+ sal_Int32 nIndex = 0;
+ do
+ {
+ const OUString sPth = URIHelper::SmartRel2Abs(
+ INetURLObject(),
+ m_aPath.getToken(0, SVT_SEARCHPATH_DELIMITER, nIndex),
+ URIHelper::GetMaybeFileHdl());
+ if (aDirArr.size() &&
+ std::find(aDirArr.begin(), aDirArr.end(), sPth) != aDirArr.end())
+ {
+ continue;
+ }
+ aDirArr.push_back(sPth);
+ if( !FStatHelper::IsFolder( sPth ) )
+ aInvalidPaths.push_back(sPth);
+ else
+ m_PathArr.push_back(sPth);
+ }
+ while (nIndex>=0);
+ }
+
+ if (m_aPath.isEmpty() || !aInvalidPaths.empty())
+ {
+ std::sort(aInvalidPaths.begin(), aInvalidPaths.end());
+ aInvalidPaths.erase(std::unique(aInvalidPaths.begin(), aInvalidPaths.end()), aInvalidPaths.end());
+ if (bPathChanged || (m_aInvalidPaths != aInvalidPaths))
+ {
+ m_aInvalidPaths = aInvalidPaths;
+ // wrong path, that means AutoText directory doesn't exist
+
+ ErrorHandler::HandleError( *new StringErrorInfo(
+ ERR_AUTOPATH_ERROR, lcl_makePath(m_aInvalidPaths),
+ ERRCODE_BUTTON_OK | ERRCODE_MSG_ERROR ));
+ m_bError = sal_True;
+ }
+ else
+ m_bError = sal_False;
+ }
+ else
+ m_bError = sal_False;
+
+ if (!m_GlosArr.empty())
+ {
+ m_GlosArr.clear();
+ GetNameList();
+ }
+ }
+}
+
+void SwGlossaries::ShowError()
+{
+ sal_uInt32 nPathError = *new StringErrorInfo(ERR_AUTOPATH_ERROR,
+ lcl_makePath(m_aInvalidPaths), ERRCODE_BUTTON_OK );
+ ErrorHandler::HandleError( nPathError );
+}
+
+OUString SwGlossaries::GetExtension()
+{
+ return OUString(".bau");
+}
+
+void SwGlossaries::RemoveFileFromList( const OUString& rGroup )
+{
+ if (!m_GlosArr.empty())
+ {
+ for (std::vector<OUString>::iterator it(m_GlosArr.begin());
+ it != m_GlosArr.end(); ++it)
+ {
+ if (*it == rGroup)
+ {
+ OUString aUName = rGroup;
+ {
+ // tell the UNO AutoTextGroup object that it's not valid anymore
+ for ( UnoAutoTextGroups::iterator aLoop = m_aGlossaryGroups.begin();
+ aLoop != m_aGlossaryGroups.end();
+ ++aLoop
+ )
+ {
+ Reference< container::XNamed > xNamed( aLoop->get(), UNO_QUERY );
+ if ( xNamed.is() && ( xNamed->getName() == aUName ) )
+ {
+ static_cast< SwXAutoTextGroup* >( xNamed.get() )->Invalidate();
+ // note that this static_cast works because we know that the array only
+ // contains SwXAutoTextGroup implementation
+ m_aGlossaryGroups.erase( aLoop );
+ break;
+ }
+ }
+ }
+
+ {
+ // tell all our UNO AutoTextEntry objects that they're not valid anymore
+ for ( UnoAutoTextEntries::iterator aLoop = m_aGlossaryEntries.begin();
+ aLoop != m_aGlossaryEntries.end();
+ )
+ {
+ Reference< lang::XUnoTunnel > xEntryTunnel( aLoop->get(), UNO_QUERY );
+
+ SwXAutoTextEntry* pEntry = NULL;
+ if ( xEntryTunnel.is() )
+ pEntry = reinterpret_cast< SwXAutoTextEntry* >(
+ xEntryTunnel->getSomething( SwXAutoTextEntry::getUnoTunnelId() ) );
+
+ if ( pEntry && ( pEntry->GetGroupName() == rGroup ) )
+ {
+ pEntry->Invalidate();
+ aLoop = m_aGlossaryEntries.erase( aLoop );
+ }
+ else
+ ++aLoop;
+ }
+ }
+
+ m_GlosArr.erase(it);
+ break;
+ }
+ }
+ }
+}
+
+OUString SwGlossaries::GetCompleteGroupName( const OUString& rGroupName )
+{
+ const sal_uInt16 nCount = GetGroupCnt();
+ // when the group name was created internally the path is here as well
+ sal_Int32 nIndex = 0;
+ const OUString sGroupName(rGroupName.getToken(0, GLOS_DELIM, nIndex));
+ const bool bPathLen = !rGroupName.getToken(0, GLOS_DELIM, nIndex).isEmpty();
+ for ( sal_uInt16 i = 0; i < nCount; i++ )
+ {
+ const OUString sGrpName = GetGroupName(i);
+ if (bPathLen)
+ {
+ if (rGroupName == sGrpName)
+ return sGrpName;
+ }
+ else
+ {
+ if (sGroupName == sGrpName.getToken(0, GLOS_DELIM))
+ return sGrpName;
+ }
+ }
+ return OUString();
+}
+
+void SwGlossaries::InvalidateUNOOjects()
+{
+ // invalidate all the AutoTextGroup-objects
+ for ( UnoAutoTextGroups::iterator aGroupLoop = m_aGlossaryGroups.begin();
+ aGroupLoop != m_aGlossaryGroups.end();
+ ++aGroupLoop
+ )
+ {
+ Reference< text::XAutoTextGroup > xGroup( aGroupLoop->get(), UNO_QUERY );
+ if ( xGroup.is() )
+ static_cast< SwXAutoTextGroup* >( xGroup.get() )->Invalidate();
+ }
+ UnoAutoTextGroups aTmpg = UnoAutoTextGroups();
+ m_aGlossaryGroups.swap( aTmpg );
+
+ // invalidate all the AutoTextEntry-objects
+ for ( UnoAutoTextEntries::const_iterator aEntryLoop = m_aGlossaryEntries.begin();
+ aEntryLoop != m_aGlossaryEntries.end();
+ ++aEntryLoop
+ )
+ {
+ Reference< lang::XUnoTunnel > xEntryTunnel( aEntryLoop->get(), UNO_QUERY );
+ SwXAutoTextEntry* pEntry = NULL;
+ if ( xEntryTunnel.is() )
+ pEntry = reinterpret_cast< SwXAutoTextEntry* >(
+ xEntryTunnel->getSomething( SwXAutoTextEntry::getUnoTunnelId() ) );
+
+ if ( pEntry )
+ pEntry->Invalidate();
+ }
+ UnoAutoTextEntries aTmpe = UnoAutoTextEntries();
+ m_aGlossaryEntries.swap( aTmpe );
+}
+
+Reference< text::XAutoTextGroup > SwGlossaries::GetAutoTextGroup( const OUString& _rGroupName, bool _bCreate )
+{
+ // first, find the name with path-extension
+ const OUString sCompleteGroupName = GetCompleteGroupName( _rGroupName );
+
+ Reference< text::XAutoTextGroup > xGroup;
+
+ // look up the group in the cache
+ UnoAutoTextGroups::iterator aSearch = m_aGlossaryGroups.begin();
+ for ( ; aSearch != m_aGlossaryGroups.end(); )
+ {
+ Reference< lang::XUnoTunnel > xGroupTunnel( aSearch->get(), UNO_QUERY );
+
+ SwXAutoTextGroup* pSwGroup = 0;
+ if ( xGroupTunnel.is() )
+ pSwGroup = reinterpret_cast< SwXAutoTextGroup* >( xGroupTunnel->getSomething( SwXAutoTextGroup::getUnoTunnelId() ) );
+
+ if ( !pSwGroup )
+ {
+ // the object is dead in the meantime -> remove from cache
+ aSearch = m_aGlossaryGroups.erase( aSearch );
+ continue;
+ }
+
+ if ( _rGroupName == pSwGroup->getName() )
+ { // the group is already cached
+ if ( !sCompleteGroupName.isEmpty() )
+ { // the group still exists -> return it
+ xGroup = pSwGroup;
+ break;
+ }
+ else
+ {
+ // this group does not exist (anymore) -> release the cached UNO object for it
+ aSearch = m_aGlossaryGroups.erase( aSearch );
+ // so it won't be created below
+ _bCreate = false;
+ break;
+ }
+ }
+
+ ++aSearch;
+ }
+
+ if ( !xGroup.is() && _bCreate )
+ {
+ xGroup = new SwXAutoTextGroup( sCompleteGroupName, this );
+ // cache it
+ m_aGlossaryGroups.push_back( AutoTextGroupRef( xGroup ) );
+ }
+
+ return xGroup;
+}
+
+Reference< text::XAutoTextEntry > SwGlossaries::GetAutoTextEntry(
+ const OUString& rCompleteGroupName,
+ const OUString& rGroupName,
+ const OUString& rEntryName,
+ bool _bCreate )
+{
+ //standard must be created
+ sal_Bool bCreate = ( rCompleteGroupName == GetDefName() );
+ boost::scoped_ptr< SwTextBlocks > pGlosGroup( GetGroupDoc( rCompleteGroupName, bCreate ) );
+
+ if ( pGlosGroup.get() && !pGlosGroup->GetError() )
+ {
+ sal_uInt16 nIdx = pGlosGroup->GetIndex( rEntryName );
+ if ( USHRT_MAX == nIdx )
+ throw container::NoSuchElementException();
+ }
+ else
+ throw lang::WrappedTargetException();
+
+ Reference< text::XAutoTextEntry > xReturn;
+
+ UnoAutoTextEntries::iterator aSearch( m_aGlossaryEntries.begin() );
+ for ( ; aSearch != m_aGlossaryEntries.end(); )
+ {
+ Reference< lang::XUnoTunnel > xEntryTunnel( aSearch->get(), UNO_QUERY );
+
+ SwXAutoTextEntry* pEntry = NULL;
+ if ( xEntryTunnel.is() )
+ pEntry = reinterpret_cast< SwXAutoTextEntry* >( xEntryTunnel->getSomething( SwXAutoTextEntry::getUnoTunnelId() ) );
+ else
+ {
+ // the object is dead in the meantime -> remove from cache
+ aSearch = m_aGlossaryEntries.erase( aSearch );
+ continue;
+ }
+
+ if ( pEntry
+ && pEntry->GetGroupName() == rGroupName
+ && pEntry->GetEntryName() == rEntryName
+ )
+ {
+ xReturn = pEntry;
+ break;
+ }
+
+ ++aSearch;
+ }
+
+ if ( !xReturn.is() && _bCreate )
+ {
+ xReturn = new SwXAutoTextEntry( this, rGroupName, rEntryName );
+ // cache it
+ m_aGlossaryEntries.push_back( AutoTextEntryRef( xReturn ) );
+ }
+
+ return xReturn;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/misc/glshell.cxx b/sw/source/core/uibase/misc/glshell.cxx
new file mode 100644
index 000000000000..c3776ceb852a
--- /dev/null
+++ b/sw/source/core/uibase/misc/glshell.cxx
@@ -0,0 +1,274 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <com/sun/star/frame/XTitle.hpp>
+
+#include <svl/eitem.hxx>
+#include <svl/stritem.hxx>
+#include <sfx2/printer.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/sfxsids.hrc>
+#include <svl/srchitem.hxx>
+#include <svl/macitem.hxx>
+#include <gloshdl.hxx>
+
+#include <editeng/acorrcfg.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/objface.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <uitool.hxx>
+#include <wrtsh.hxx>
+#include <view.hxx>
+#include <glshell.hxx>
+#include <doc.hxx>
+#include <IDocumentUndoRedo.hxx>
+#include <glosdoc.hxx>
+#include <shellio.hxx>
+#include <initui.hxx>
+#include <cmdid.h>
+#include <swerror.h>
+#include <misc.hrc>
+
+#define SwWebGlosDocShell
+#define SwGlosDocShell
+
+#include <sfx2/msg.hxx>
+#include <swslots.hxx>
+
+using namespace ::com::sun::star;
+
+SFX_IMPL_INTERFACE( SwGlosDocShell, SwDocShell, SW_RES(0) )
+{
+}
+
+SFX_IMPL_INTERFACE( SwWebGlosDocShell, SwWebDocShell, SW_RES(0) )
+{
+}
+
+TYPEINIT1( SwGlosDocShell, SwDocShell );
+TYPEINIT1( SwWebGlosDocShell, SwWebDocShell );
+
+static void lcl_Execute( SwDocShell& rSh, SfxRequest& rReq )
+{
+ if ( rReq.GetSlot() == SID_SAVEDOC )
+ {
+ if( !rSh.HasName() )
+ {
+ rReq.SetReturnValue( SfxBoolItem( 0, rSh.Save() ) );
+ }
+ else
+ {
+ const SfxBoolItem* pRes = ( const SfxBoolItem* )
+ rSh.ExecuteSlot( rReq,
+ rSh.SfxObjectShell::GetInterface() );
+ if( pRes->GetValue() )
+ rSh.GetDoc()->ResetModified();
+ }
+ }
+}
+
+static void lcl_GetState( SwDocShell& rSh, SfxItemSet& rSet )
+{
+ if( SFX_ITEM_AVAILABLE >= rSet.GetItemState( SID_SAVEDOC, false ))
+ {
+ if( !rSh.GetDoc()->IsModified() )
+ rSet.DisableItem( SID_SAVEDOC );
+ else
+ rSet.Put( SfxStringItem( SID_SAVEDOC, SW_RESSTR(STR_SAVE_GLOSSARY)));
+ }
+}
+
+static sal_Bool lcl_Save( SwWrtShell& rSh, const OUString& rGroupName,
+ const OUString& rShortNm, const OUString& rLongNm )
+{
+ const SvxAutoCorrCfg& rCfg = SvxAutoCorrCfg::Get();
+ SwTextBlocks * pBlock = ::GetGlossaries()->GetGroupDoc( rGroupName );
+
+ SvxMacro aStart(aEmptyOUStr, aEmptyOUStr);
+ SvxMacro aEnd(aEmptyOUStr, aEmptyOUStr);
+ SwGlossaryHdl* pGlosHdl;
+
+ pGlosHdl = rSh.GetView().GetGlosHdl();
+ pGlosHdl->GetMacros( rShortNm, aStart, aEnd, pBlock );
+
+ sal_uInt16 nRet = rSh.SaveGlossaryDoc( *pBlock, rLongNm, rShortNm,
+ rCfg.IsSaveRelFile(),
+ pBlock->IsOnlyTextBlock( rShortNm ) );
+
+ if(aStart.HasMacro() || aEnd.HasMacro() )
+ {
+ SvxMacro* pStart = aStart.HasMacro() ? &aStart : 0;
+ SvxMacro* pEnd = aEnd.HasMacro() ? &aEnd : 0;
+ pGlosHdl->SetMacros( rShortNm, pStart, pEnd, pBlock );
+ }
+
+ rSh.EnterStdMode();
+ if( USHRT_MAX != nRet )
+ rSh.ResetModified();
+ delete pBlock;
+ return nRet != USHRT_MAX;
+}
+
+SwGlosDocShell::SwGlosDocShell(sal_Bool bNewShow)
+ : SwDocShell( (bNewShow)
+ ? SFX_CREATE_MODE_STANDARD : SFX_CREATE_MODE_INTERNAL )
+{
+ SetHelpId(SW_GLOSDOCSHELL);
+}
+
+SwGlosDocShell::~SwGlosDocShell( )
+{
+}
+
+void SwGlosDocShell::Execute( SfxRequest& rReq )
+{
+ ::lcl_Execute( *this, rReq );
+}
+
+void SwGlosDocShell::GetState( SfxItemSet& rSet )
+{
+ ::lcl_GetState( *this, rSet );
+}
+
+sal_Bool SwGlosDocShell::Save()
+{
+ // In case of an API object which holds this document, it is possible that the WrtShell is already
+ // dead. For instance, if the doc is modified via this API object, and then, upon office shutdown,
+ // the document's view is closed (by the SFX framework) _before_ the API object is release and
+ // tries to save the doc, again.
+ // 96380 - 2002-03-03 - fs@openoffice.org
+ if ( GetWrtShell() )
+ return ::lcl_Save( *GetWrtShell(), aGroupName, aShortName, aLongName );
+ else
+ {
+ SetModified( sal_False );
+ return sal_False;
+ }
+}
+
+SwWebGlosDocShell::SwWebGlosDocShell()
+ : SwWebDocShell( SFX_CREATE_MODE_STANDARD )
+{
+ SetHelpId(SW_WEBGLOSDOCSHELL);
+}
+
+SwWebGlosDocShell::~SwWebGlosDocShell( )
+{
+}
+
+void SwWebGlosDocShell::Execute( SfxRequest& rReq )
+{
+ ::lcl_Execute( *this, rReq );
+}
+
+void SwWebGlosDocShell::GetState( SfxItemSet& rSet )
+{
+ ::lcl_GetState( *this, rSet );
+}
+
+sal_Bool SwWebGlosDocShell::Save()
+{
+ // same comment as in SwGlosDocShell::Save - see there
+ if ( GetWrtShell() )
+ return ::lcl_Save( *GetWrtShell(), aGroupName, aShortName, aLongName );
+ else
+ {
+ SetModified( sal_False );
+ return sal_False;
+ }
+}
+
+SV_IMPL_REF ( SwDocShell )
+
+SwDocShellRef SwGlossaries::EditGroupDoc( const OUString& rGroup, const OUString& rShortName, sal_Bool bShow )
+{
+ SwDocShellRef xDocSh;
+
+ SwTextBlocks* pGroup = GetGroupDoc( rGroup );
+ if( pGroup && pGroup->GetCount() )
+ {
+ // query which view is registered. In WebWriter there is no normal view
+ sal_uInt16 nViewId = 0 != &SwView::Factory() ? 2 : 6;
+ const OUString sLongName = pGroup->GetLongName(pGroup->GetIndex( rShortName ));
+
+ if( 6 == nViewId )
+ {
+ SwWebGlosDocShell* pDocSh = new SwWebGlosDocShell();
+ xDocSh = pDocSh;
+ pDocSh->DoInitNew( 0 );
+ pDocSh->SetLongName( sLongName );
+ pDocSh->SetShortName( rShortName);
+ pDocSh->SetGroupName( rGroup );
+ }
+ else
+ {
+ SwGlosDocShell* pDocSh = new SwGlosDocShell(bShow);
+ xDocSh = pDocSh;
+ pDocSh->DoInitNew( 0 );
+ pDocSh->SetLongName( sLongName );
+ pDocSh->SetShortName( rShortName );
+ pDocSh->SetGroupName( rGroup );
+ }
+
+ // set document title
+ SfxViewFrame* pFrame = bShow ? SfxViewFrame::LoadDocument( *xDocSh, nViewId ) : SfxViewFrame::LoadHiddenDocument( *xDocSh, nViewId );
+ const OUString aDocTitle(SW_RESSTR( STR_GLOSSARY ) + " " + sLongName);
+
+ bool const bDoesUndo =
+ xDocSh->GetDoc()->GetIDocumentUndoRedo().DoesUndo();
+ xDocSh->GetDoc()->GetIDocumentUndoRedo().DoUndo( false );
+
+ xDocSh->GetWrtShell()->InsertGlossary( *pGroup, rShortName );
+ if( !xDocSh->GetDoc()->getPrinter( false ) )
+ {
+ // we create a default SfxPrinter.
+ // ItemSet is deleted by Sfx!
+ SfxItemSet *pSet = new SfxItemSet( xDocSh->GetDoc()->GetAttrPool(),
+ FN_PARAM_ADDPRINTER, FN_PARAM_ADDPRINTER,
+ SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN,
+ SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC,
+ 0 );
+ SfxPrinter* pPrinter = new SfxPrinter( pSet );
+
+ // and append it to the document.
+ xDocSh->GetDoc()->setPrinter( pPrinter, true, true );
+ }
+
+ xDocSh->SetTitle( aDocTitle );
+ try
+ {
+ // set the UI-title
+ uno::Reference< frame::XTitle > xTitle( xDocSh->GetModel(), uno::UNO_QUERY_THROW );
+ xTitle->setTitle( aDocTitle );
+ }
+ catch (const uno::Exception&)
+ {
+ }
+
+ xDocSh->GetDoc()->GetIDocumentUndoRedo().DoUndo( bDoesUndo );
+ xDocSh->GetDoc()->ResetModified();
+ if ( bShow )
+ pFrame->GetFrame().Appear();
+
+ delete pGroup;
+ }
+ return xDocSh;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/misc/numberingtypelistbox.cxx b/sw/source/core/uibase/misc/numberingtypelistbox.cxx
new file mode 100644
index 000000000000..d319a131e3df
--- /dev/null
+++ b/sw/source/core/uibase/misc/numberingtypelistbox.cxx
@@ -0,0 +1,164 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <numberingtypelistbox.hxx>
+#include <misc.hrc>
+#include <cnttab.hxx>
+#include <com/sun/star/style/NumberingType.hpp>
+#include <com/sun/star/text/DefaultNumberingProvider.hpp>
+#include <com/sun/star/text/XDefaultNumberingProvider.hpp>
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/text/XNumberingTypeInfo.hpp>
+
+#include <unomid.h>
+
+using namespace com::sun::star;
+
+struct SwNumberingTypeListBox_Impl
+{
+ uno::Reference<text::XNumberingTypeInfo> xInfo;
+};
+
+SwNumberingTypeListBox::SwNumberingTypeListBox( Window* pWin, WinBits nStyle ) :
+ ListBox(pWin, nStyle),
+ pImpl(new SwNumberingTypeListBox_Impl)
+{
+ uno::Reference<uno::XComponentContext> xContext( ::comphelper::getProcessComponentContext() );
+ uno::Reference<text::XDefaultNumberingProvider> xDefNum = text::DefaultNumberingProvider::create(xContext);
+
+ pImpl->xInfo = uno::Reference<text::XNumberingTypeInfo>(xDefNum, uno::UNO_QUERY);
+}
+
+bool SwNumberingTypeListBox::set_property(const OString &rKey, const OString &rValue)
+{
+ if (rKey == "type")
+ Reload(rValue.toInt32());
+ else
+ return ListBox::set_property(rKey, rValue);
+ return true;
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSwNumberingTypeListBox(Window *pParent, VclBuilder::stringmap &)
+{
+ SwNumberingTypeListBox *pListBox = new SwNumberingTypeListBox(pParent, WB_LEFT|WB_DROPDOWN|WB_VCENTER|WB_3DLOOK|WB_TABSTOP);
+ pListBox->EnableAutoSize(true);
+ return pListBox;
+}
+
+SwNumberingTypeListBox::~SwNumberingTypeListBox()
+{
+ delete pImpl;
+}
+
+void SwNumberingTypeListBox::Reload(sal_uInt16 nTypeFlags)
+{
+ Clear();
+ uno::Sequence<sal_Int16> aTypes;
+ const sal_Int16* pTypes = NULL;
+ if(0 != (nTypeFlags&INSERT_NUM_EXTENDED_TYPES) )
+ {
+ if(pImpl->xInfo.is())
+ {
+ aTypes = pImpl->xInfo->getSupportedNumberingTypes();
+ pTypes = aTypes.getConstArray();
+ }
+ }
+ SwOLENames aNames(SW_RES(STRRES_NUMTYPES));
+ ResStringArray& rNames = aNames.GetNames();
+ for(sal_uInt16 i = 0; i < rNames.Count(); i++)
+ {
+ sal_IntPtr nValue = rNames.GetValue(i);
+ bool bInsert = true;
+ sal_Int32 nPos = LISTBOX_APPEND;
+ switch(nValue)
+ {
+ case style::NumberingType::NUMBER_NONE:
+ bInsert = 0 != (nTypeFlags&INSERT_NUM_TYPE_NO_NUMBERING);
+ nPos = 0;
+ break;
+ case style::NumberingType::CHAR_SPECIAL: bInsert = 0 != (nTypeFlags&INSERT_NUM_TYPE_BULLET); break;
+ case style::NumberingType::PAGE_DESCRIPTOR:bInsert = 0 != (nTypeFlags&INSERT_NUM_TYPE_PAGE_STYLE_NUMBERING); break;
+ case style::NumberingType::BITMAP:bInsert = 0 != (nTypeFlags&INSERT_NUM_TYPE_BITMAP ); break;
+ default:
+ if (nValue > style::NumberingType::CHARS_LOWER_LETTER_N)
+ {
+ // Insert only if offered by i18n framework per configuration.
+ bInsert = false;
+ if (pTypes)
+ {
+ for(sal_Int32 nType = 0; nType < aTypes.getLength(); nType++)
+ {
+ if (pTypes[nType] == nValue)
+ {
+ bInsert = true;
+ break; // for
+ }
+ }
+ }
+ }
+ }
+ if(bInsert)
+ {
+ sal_Int32 nEntry = InsertEntry(rNames.GetString(i), nPos);
+ SetEntryData( nEntry, (void*)nValue );
+ }
+ }
+ if(0 != (nTypeFlags&INSERT_NUM_EXTENDED_TYPES) )
+ {
+ if(pTypes)
+ {
+ for(sal_Int32 nType = 0; nType < aTypes.getLength(); nType++)
+ {
+ sal_Int16 nCurrent = pTypes[nType];
+ if(nCurrent > style::NumberingType::CHARS_LOWER_LETTER_N)
+ {
+ if(LISTBOX_ENTRY_NOTFOUND == GetEntryPos((void*)(sal_uLong)nCurrent))
+ {
+ OUString aIdent = pImpl->xInfo->getNumberingIdentifier( nCurrent );
+ sal_Int32 nPos = InsertEntry(aIdent);
+ SetEntryData(nPos,(void*)(sal_uLong)nCurrent);
+ }
+ }
+ }
+ }
+ SelectEntryPos(0);
+ }
+}
+
+sal_Int16 SwNumberingTypeListBox::GetSelectedNumberingType()
+{
+ sal_Int16 nRet = 0;
+ sal_Int32 nSelPos = GetSelectEntryPos();
+ if(LISTBOX_ENTRY_NOTFOUND != nSelPos)
+ nRet = (sal_Int16)(sal_uLong)GetEntryData(nSelPos);
+#if OSL_DEBUG_LEVEL > 0
+ else
+ OSL_FAIL("SwNumberingTypeListBox not selected");
+#endif
+ return nRet;
+}
+
+sal_Bool SwNumberingTypeListBox::SelectNumberingType(sal_Int16 nType)
+{
+ sal_Int32 nPos = GetEntryPos((void*)(sal_uLong)nType);
+ SelectEntryPos( nPos );
+ return LISTBOX_ENTRY_NOTFOUND != nPos;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/misc/redlndlg.cxx b/sw/source/core/uibase/misc/redlndlg.cxx
new file mode 100644
index 000000000000..f6ceee69026d
--- /dev/null
+++ b/sw/source/core/uibase/misc/redlndlg.cxx
@@ -0,0 +1,1210 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <redline.hxx>
+#include <tools/datetime.hxx>
+#include <vcl/msgbox.hxx>
+#include <svl/eitem.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svx/ctredlin.hxx>
+#include <svx/postattr.hxx>
+#include <swtypes.hxx>
+#include <wrtsh.hxx>
+#include <view.hxx>
+#include <swmodule.hxx>
+#include <redlndlg.hxx>
+#include <swwait.hxx>
+#include <uitool.hxx>
+
+#include <helpid.h>
+#include <cmdid.h>
+#include <misc.hrc>
+#include <redlndlg.hrc>
+#include <shells.hrc>
+
+// -> #111827#
+#include <comcore.hrc>
+#include <swundo.hxx>
+#include <SwRewriter.hxx>
+// <- #111827#
+
+#include <vector>
+#include <svx/svxdlg.hxx>
+#include <svx/dialogs.hrc>
+
+#include <unomid.h>
+
+#include <docsh.hxx>
+
+#include <IDocumentRedlineAccess.hxx>
+
+SFX_IMPL_MODELESSDIALOG_WITHID( SwRedlineAcceptChild, FN_REDLINE_ACCEPT )
+
+static sal_uInt16 nSortMode = 0xffff;
+static sal_Bool bSortDir = sal_True;
+
+SwRedlineAcceptChild::SwRedlineAcceptChild( Window* _pParent,
+ sal_uInt16 nId,
+ SfxBindings* pBindings,
+ SfxChildWinInfo* pInfo ) :
+ SwChildWinWrapper( _pParent, nId )
+{
+ pWindow = new SwModelessRedlineAcceptDlg( pBindings, this, _pParent);
+
+ ((SwModelessRedlineAcceptDlg *)pWindow)->Initialize(pInfo);
+}
+
+/*--------------------------------------------------------------------
+ Description: newly initialise dialog after document switch
+ --------------------------------------------------------------------*/
+sal_Bool SwRedlineAcceptChild::ReInitDlg(SwDocShell *pDocSh)
+{
+ sal_Bool bRet;
+
+ if ((bRet = SwChildWinWrapper::ReInitDlg(pDocSh)) == sal_True) // update immediately, doc switch!
+ ((SwModelessRedlineAcceptDlg*)GetWindow())->Activate();
+
+ return bRet;
+}
+
+SwModelessRedlineAcceptDlg::SwModelessRedlineAcceptDlg(
+ SfxBindings* _pBindings, SwChildWinWrapper* pChild, Window *_pParent)
+ : SfxModelessDialog(_pBindings, pChild, _pParent,
+ "AcceptRejectChangesDialog", "svx/ui/acceptrejectchangesdialog.ui")
+ , pChildWin (pChild)
+{
+ pImplDlg = new SwRedlineAcceptDlg(this);
+}
+
+void SwModelessRedlineAcceptDlg::Activate()
+{
+ SwView *pView = ::GetActiveView();
+
+ if (!pView) // can happen when switching to another app, when a Listbox in dialog
+ return; // had the focus previously (actually THs Bug)
+
+ SwDocShell *pDocSh = pView->GetDocShell();
+
+ if (pChildWin->GetOldDocShell() != pDocSh)
+ { // doc-switch
+ SwWait aWait( *pDocSh, false );
+ SwWrtShell* pSh = pView->GetWrtShellPtr();
+
+ pChildWin->SetOldDocShell(pDocSh); // avoid recursion (using modified-Hdl)
+
+ sal_Bool bMod = pSh->IsModified();
+ SfxBoolItem aShow(FN_REDLINE_SHOW, true);
+ pSh->GetView().GetViewFrame()->GetDispatcher()->Execute(
+ FN_REDLINE_SHOW, SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD, &aShow, 0L);
+ if (!bMod)
+ pSh->ResetModified();
+ pImplDlg->Init();
+
+ return;
+ }
+
+ pImplDlg->Activate();
+}
+
+void SwModelessRedlineAcceptDlg::Initialize(SfxChildWinInfo *pInfo)
+{
+ if (pInfo != NULL)
+ pImplDlg->Initialize(pInfo->aExtraString);
+
+ SfxModelessDialog::Initialize(pInfo);
+}
+
+void SwModelessRedlineAcceptDlg::FillInfo(SfxChildWinInfo& rInfo) const
+{
+ SfxModelessDialog::FillInfo(rInfo);
+ pImplDlg->FillInfo(rInfo.aExtraString);
+}
+
+SwModelessRedlineAcceptDlg::~SwModelessRedlineAcceptDlg()
+{
+ delete pImplDlg;
+}
+
+SwRedlineAcceptDlg::SwRedlineAcceptDlg(Dialog *pParent, sal_Bool bAutoFmt) :
+ pParentDlg (pParent),
+ aTabPagesCTRL (pParent->get_content_area()),
+ aPopup (SW_RES(MN_REDLINE_POPUP)),
+ sInserted (SW_RES(STR_REDLINE_INSERTED)),
+ sDeleted (SW_RES(STR_REDLINE_DELETED)),
+ sFormated (SW_RES(STR_REDLINE_FORMATED)),
+ sTableChgd (SW_RES(STR_REDLINE_TABLECHG)),
+ sFmtCollSet (SW_RES(STR_REDLINE_FMTCOLLSET)),
+ sAutoFormat (SW_RES(STR_REDLINE_AUTOFMT)),
+ bOnlyFormatedRedlines( sal_False ),
+ bHasReadonlySel ( sal_False ),
+ bRedlnAutoFmt (bAutoFmt),
+ bInhibitActivate( false )
+{
+ aTabPagesCTRL.SetHelpId(HID_REDLINE_CTRL);
+ pTPView = aTabPagesCTRL.GetViewPage();
+ pTable = pTPView->GetTableControl();
+
+ pTPView->InsertWriterHeader();
+ pTPView->SetAcceptClickHdl(LINK(this, SwRedlineAcceptDlg, AcceptHdl));
+ pTPView->SetAcceptAllClickHdl(LINK(this, SwRedlineAcceptDlg, AcceptAllHdl));
+ pTPView->SetRejectClickHdl(LINK(this, SwRedlineAcceptDlg, RejectHdl));
+ pTPView->SetRejectAllClickHdl(LINK(this, SwRedlineAcceptDlg, RejectAllHdl));
+ pTPView->SetUndoClickHdl(LINK(this, SwRedlineAcceptDlg, UndoHdl));
+
+ aTabPagesCTRL.GetFilterPage()->SetReadyHdl(LINK(this, SwRedlineAcceptDlg, FilterChangedHdl));
+
+ ListBox *pActLB = aTabPagesCTRL.GetFilterPage()->GetLbAction();
+ pActLB->InsertEntry(sInserted);
+ pActLB->InsertEntry(sDeleted);
+ pActLB->InsertEntry(sFormated);
+ pActLB->InsertEntry(sTableChgd);
+
+ if (HasRedlineAutoFmt())
+ {
+ pActLB->InsertEntry(sFmtCollSet);
+ pActLB->InsertEntry(sAutoFormat);
+ pTPView->ShowUndo(sal_True);
+ pTPView->DisableUndo(); // no UNDO events yet
+ }
+
+ pActLB->SelectEntryPos(0);
+
+ pTable->SetStyle(pTable->GetStyle()|WB_HASLINES|WB_CLIPCHILDREN|WB_HASBUTTONS|WB_HASBUTTONSATROOT|WB_HSCROLL);
+ pTable->SetNodeDefaultImages();
+ pTable->SetSelectionMode(MULTIPLE_SELECTION);
+ pTable->SetHighlightRange(1);
+
+ static long aStaticTabs[]=
+ {
+ 4,10,70,120,170
+ };
+
+ pTable->SetTabs(aStaticTabs);
+
+ pTable->SortByCol(nSortMode, bSortDir);
+
+ aOldSelectHdl = pTable->GetSelectHdl();
+ aOldDeselectHdl = pTable->GetDeselectHdl();
+ pTable->SetSelectHdl(LINK(this, SwRedlineAcceptDlg, SelectHdl));
+ pTable->SetDeselectHdl(LINK(this, SwRedlineAcceptDlg, DeselectHdl));
+ pTable->SetCommandHdl(LINK(this, SwRedlineAcceptDlg, CommandHdl));
+
+ // avoid flickering of buttons:
+ aDeselectTimer.SetTimeout(100);
+ aDeselectTimer.SetTimeoutHdl(LINK(this, SwRedlineAcceptDlg, SelectHdl));
+
+ // avoid multiple selection of the same texts:
+ aSelectTimer.SetTimeout(100);
+ aSelectTimer.SetTimeoutHdl(LINK(this, SwRedlineAcceptDlg, GotoHdl));
+}
+
+SwRedlineAcceptDlg::~SwRedlineAcceptDlg()
+{
+}
+
+void SwRedlineAcceptDlg::Init(sal_uInt16 nStart)
+{
+ SwWait aWait( *::GetActiveView()->GetDocShell(), false );
+ pTable->SetUpdateMode(sal_False);
+ aUsedSeqNo.clear();
+
+ if (nStart)
+ RemoveParents(nStart, aRedlineParents.size() - 1);
+ else
+ {
+ pTable->Clear();
+ aRedlineChildren.clear();
+ aRedlineParents.erase(aRedlineParents.begin() + nStart, aRedlineParents.end());
+ }
+
+ // insert parents
+ InsertParents(nStart);
+ InitAuthors();
+
+ pTable->SetUpdateMode(sal_True);
+ // #i69618# this moves the list box to the right position, visually
+ SvTreeListEntry* pSelEntry = pTable->FirstSelected();
+ if( pSelEntry )
+ pTable->MakeVisible( pSelEntry, sal_True ); //#i70937#, force the scroll
+}
+
+void SwRedlineAcceptDlg::InitAuthors()
+{
+ SwWrtShell* pSh = ::GetActiveView()->GetWrtShellPtr();
+
+ SvxTPFilter *pFilterPage = aTabPagesCTRL.GetFilterPage();
+
+ std::vector<OUString> aStrings;
+ OUString sOldAuthor(pFilterPage->GetSelectedAuthor());
+ pFilterPage->ClearAuthors();
+
+ sal_uInt16 nCount = pSh->GetRedlineCount();
+
+ bOnlyFormatedRedlines = sal_True;
+ bHasReadonlySel = sal_False;
+ bool bIsNotFormated = false;
+ sal_uInt16 i;
+
+ // determine authors
+ for ( i = 0; i < nCount; i++)
+ {
+ const SwRangeRedline& rRedln = pSh->GetRedline(i);
+
+ if( bOnlyFormatedRedlines && nsRedlineType_t::REDLINE_FORMAT != rRedln.GetType() )
+ bOnlyFormatedRedlines = sal_False;
+
+ aStrings.push_back(rRedln.GetAuthorString());
+
+ for (sal_uInt16 nStack = 1; nStack < rRedln.GetStackCount(); nStack++)
+ {
+ aStrings.push_back(rRedln.GetAuthorString(nStack));
+ }
+ }
+
+ std::sort(aStrings.begin(), aStrings.end());
+ aStrings.erase(std::unique(aStrings.begin(), aStrings.end()), aStrings.end());
+
+ for (i = 0; i < aStrings.size(); i++)
+ pFilterPage->InsertAuthor(aStrings[i]);
+
+ if (pFilterPage->SelectAuthor(sOldAuthor) == LISTBOX_ENTRY_NOTFOUND && !aStrings.empty())
+ pFilterPage->SelectAuthor(aStrings[0]);
+
+ bool bEnable = pTable->GetEntryCount() != 0 && !pSh->getIDocumentRedlineAccess()->GetRedlinePassword().getLength();
+ bool bSel = pTable->FirstSelected() != 0;
+
+ SvTreeListEntry* pSelEntry = pTable->FirstSelected();
+ while (pSelEntry)
+ {
+ // find the selected redline
+ // (fdo#57874: ignore, if the redline is already gone)
+ sal_uInt16 nPos = GetRedlinePos(*pSelEntry);
+ if( nPos != USHRT_MAX )
+ {
+ const SwRangeRedline& rRedln = pSh->GetRedline( nPos );
+
+ bIsNotFormated |= nsRedlineType_t::REDLINE_FORMAT != rRedln.GetType();
+ }
+ pSelEntry = pTable->NextSelected(pSelEntry);
+ }
+
+ pTPView->EnableAccept( bEnable && bSel );
+ pTPView->EnableReject( bEnable && bIsNotFormated && bSel );
+ pTPView->EnableAcceptAll( bEnable && !bHasReadonlySel );
+ pTPView->EnableRejectAll( bEnable && !bHasReadonlySel &&
+ !bOnlyFormatedRedlines );
+}
+
+OUString SwRedlineAcceptDlg::GetRedlineText( const SwRangeRedline& rRedln,
+ DateTime &rDateTime, sal_uInt16 nStack)
+{
+ OUString sEntry(GetActionText(rRedln, nStack));
+ sEntry += "\t";
+ sEntry += rRedln.GetAuthorString(nStack);
+ sEntry += "\t";
+
+ const DateTime &rDT = rRedln.GetTimeStamp(nStack);
+ rDateTime = rDT;
+
+ sEntry += GetAppLangDateTimeString( rDT );
+ sEntry += "\t";
+
+ sEntry += rRedln.GetComment(nStack);
+
+ return sEntry;
+}
+
+OUString SwRedlineAcceptDlg::GetActionText(const SwRangeRedline& rRedln, sal_uInt16 nStack)
+{
+ switch( rRedln.GetType(nStack) )
+ {
+ case nsRedlineType_t::REDLINE_INSERT: return sInserted;
+ case nsRedlineType_t::REDLINE_DELETE: return sDeleted;
+ case nsRedlineType_t::REDLINE_FORMAT: return sFormated;
+ case nsRedlineType_t::REDLINE_TABLE: return sTableChgd;
+ case nsRedlineType_t::REDLINE_FMTCOLL: return sFmtCollSet;
+ default:;//prevent warning
+ }
+
+ return OUString();
+}
+
+/*--------------------------------------------------------------------
+ Description: newly initialise after activation
+ --------------------------------------------------------------------*/
+void SwRedlineAcceptDlg::Activate()
+{
+ // prevent update if flag is set (#102547#)
+ if( bInhibitActivate )
+ return;
+
+ SwView *pView = ::GetActiveView();
+
+ if (!pView) // can happen when switching to another app, when a Listbox in the dialog
+ return; // had the focus previously (actually THs Bug)
+
+ SwWait aWait( *pView->GetDocShell(), false );
+
+ aUsedSeqNo.clear();
+
+ // did something change?
+ SwWrtShell* pSh = pView->GetWrtShellPtr();
+ sal_uInt16 nCount = pSh->GetRedlineCount();
+
+ // check the number of pointers
+ SwRedlineDataParent *pParent = 0;
+ sal_uInt16 i;
+
+ for ( i = 0; i < nCount; i++)
+ {
+ const SwRangeRedline& rRedln = pSh->GetRedline(i);
+
+ if (i >= aRedlineParents.size())
+ {
+ // new entries have been appended
+ Init(i);
+ return;
+ }
+
+ pParent = &aRedlineParents[i];
+ if (&rRedln.GetRedlineData() != pParent->pData)
+ {
+ // Redline-Parents were inserted, changed or deleted
+ if ((i = CalcDiff(i, sal_False)) == USHRT_MAX)
+ return;
+ continue;
+ }
+
+ const SwRedlineData *pRedlineData = rRedln.GetRedlineData().Next();
+ const SwRedlineDataChild *pBackupData = pParent->pNext;
+
+ if (!pRedlineData && pBackupData)
+ {
+ // Redline-Children were deleted
+ if ((i = CalcDiff(i, sal_True)) == USHRT_MAX)
+ return;
+ continue;
+ }
+ else
+ {
+ while (pRedlineData)
+ {
+ if (pRedlineData != pBackupData->pChild)
+ {
+ // Redline-Children were inserted, changed or deleted
+ if ((i = CalcDiff(i, sal_True)) == USHRT_MAX)
+ return;
+ continue;
+ }
+ pBackupData = pBackupData->pNext;
+ pRedlineData = pRedlineData->Next();
+ }
+ }
+ }
+
+ if (nCount != aRedlineParents.size())
+ {
+ // Redlines were deleted at the end
+ Init(nCount);
+ return;
+ }
+
+ // check comment
+ for (i = 0; i < nCount; i++)
+ {
+ const SwRangeRedline& rRedln = pSh->GetRedline(i);
+ pParent = &aRedlineParents[i];
+
+ if(rRedln.GetComment() != pParent->sComment)
+ {
+ if (pParent->pTLBParent)
+ {
+ // update only comment
+ OUString sComment(rRedln.GetComment());
+ pTable->SetEntryText(sComment.replace('\n', ' '), pParent->pTLBParent, 3);
+ }
+ pParent->sComment = rRedln.GetComment();
+ }
+ }
+
+ InitAuthors();
+}
+
+sal_uInt16 SwRedlineAcceptDlg::CalcDiff(sal_uInt16 nStart, sal_Bool bChild)
+{
+ if (!nStart)
+ {
+ Init();
+ return USHRT_MAX;
+ }
+
+ pTable->SetUpdateMode(sal_False);
+ SwView *pView = ::GetActiveView();
+ SwWrtShell* pSh = pView->GetWrtShellPtr();
+ sal_uInt16 nAutoFmt = HasRedlineAutoFmt() ? nsRedlineType_t::REDLINE_FORM_AUTOFMT : 0;
+ SwRedlineDataParent *pParent = &aRedlineParents[nStart];
+ const SwRangeRedline& rRedln = pSh->GetRedline(nStart);
+
+ if (bChild) // should actually never happen, but just in case...
+ {
+ // throw away all entry's children and initialise newly
+ SwRedlineDataChild* pBackupData = (SwRedlineDataChild*)pParent->pNext;
+ SwRedlineDataChild* pNext;
+
+ while (pBackupData)
+ {
+ pNext = (SwRedlineDataChild*)pBackupData->pNext;
+ if (pBackupData->pTLBChild)
+ pTable->RemoveEntry(pBackupData->pTLBChild);
+
+ for( SwRedlineDataChildArr::iterator it = aRedlineChildren.begin();
+ it != aRedlineChildren.end(); ++it)
+ if (&*it == pBackupData)
+ {
+ aRedlineChildren.erase(it);
+ break;
+ }
+ pBackupData = pNext;
+ }
+ pParent->pNext = 0;
+
+ // insert new children
+ InsertChildren(pParent, rRedln, nAutoFmt);
+
+ pTable->SetUpdateMode(sal_True);
+ return nStart;
+ }
+
+ // have entries been deleted?
+ const SwRedlineData *pRedlineData = &rRedln.GetRedlineData();
+ sal_uInt16 i;
+ for ( i = nStart + 1; i < aRedlineParents.size(); i++)
+ {
+ if (aRedlineParents[i].pData == pRedlineData)
+ {
+ // remove entries from nStart to i-1
+ RemoveParents(nStart, i - 1);
+ pTable->SetUpdateMode(sal_True);
+ return nStart - 1;
+ }
+ }
+
+ // entries been inserted?
+ sal_uInt16 nCount = pSh->GetRedlineCount();
+ pRedlineData = aRedlineParents[nStart].pData;
+
+ for (i = nStart + 1; i < nCount; i++)
+ {
+ if (&pSh->GetRedline(i).GetRedlineData() == pRedlineData)
+ {
+ // insert entries from nStart to i-1
+ InsertParents(nStart, i - 1);
+ pTable->SetUpdateMode(sal_True);
+ return nStart - 1;
+ }
+ }
+
+ pTable->SetUpdateMode(sal_True);
+ Init(nStart); // adjust all entries until the end
+ return USHRT_MAX;
+}
+
+void SwRedlineAcceptDlg::InsertChildren(SwRedlineDataParent *pParent, const SwRangeRedline& rRedln, const sal_uInt16 nAutoFmt)
+{
+ OUString sChild;
+ SwRedlineDataChild *pLastRedlineChild = 0;
+ const SwRedlineData *pRedlineData = &rRedln.GetRedlineData();
+ bool bAutoFmt = (rRedln.GetRealType() & nAutoFmt) != 0;
+
+ OUString sAction = GetActionText(rRedln);
+ sal_Bool bValidParent = sFilterAction.isEmpty() || sFilterAction == sAction;
+ bValidParent = bValidParent && pTable->IsValidEntry(rRedln.GetAuthorString(), rRedln.GetTimeStamp(), rRedln.GetComment());
+ if (nAutoFmt)
+ {
+
+ if (pParent->pData->GetSeqNo())
+ {
+ std::pair<SwRedlineDataParentSortArr::const_iterator,bool> const ret
+ = aUsedSeqNo.insert(pParent);
+ if (ret.second) // already there
+ {
+ if (pParent->pTLBParent)
+ {
+ pTable->SetEntryText(
+ sAutoFormat, (*ret.first)->pTLBParent, 0);
+ pTable->RemoveEntry(pParent->pTLBParent);
+ pParent->pTLBParent = 0;
+ }
+ return;
+ }
+ }
+ bValidParent = bValidParent && bAutoFmt;
+ }
+ sal_Bool bValidTree = bValidParent;
+
+ for (sal_uInt16 nStack = 1; nStack < rRedln.GetStackCount(); nStack++)
+ {
+ pRedlineData = pRedlineData->Next();
+
+ SwRedlineDataChildPtr pRedlineChild = new SwRedlineDataChild;
+ pRedlineChild->pChild = pRedlineData;
+ aRedlineChildren.push_back(pRedlineChild);
+
+ if ( pLastRedlineChild )
+ pLastRedlineChild->pNext = pRedlineChild;
+ else
+ pParent->pNext = pRedlineChild;
+
+ sAction = GetActionText(rRedln, nStack);
+ sal_Bool bValidChild = sFilterAction.isEmpty() || sFilterAction == sAction;
+ bValidChild = bValidChild && pTable->IsValidEntry(rRedln.GetAuthorString(nStack), rRedln.GetTimeStamp(nStack), rRedln.GetComment());
+ if (nAutoFmt)
+ bValidChild = bValidChild && bAutoFmt;
+ bValidTree |= bValidChild;
+
+ if (bValidChild)
+ {
+ RedlinData *pData = new RedlinData;
+ pData->pData = pRedlineChild;
+ pData->bDisabled = sal_True;
+ sChild = GetRedlineText(rRedln, pData->aDateTime, nStack);
+
+ SvTreeListEntry* pChild = pTable->InsertEntry(sChild, pData, pParent->pTLBParent);
+
+ pRedlineChild->pTLBChild = pChild;
+ if (!bValidParent)
+ pTable->Expand(pParent->pTLBParent);
+ }
+ else
+ pRedlineChild->pTLBChild = 0;
+
+ pLastRedlineChild = pRedlineChild;
+ }
+
+ if (pLastRedlineChild)
+ pLastRedlineChild->pNext = 0;
+
+ if (!bValidTree && pParent->pTLBParent)
+ {
+ pTable->RemoveEntry(pParent->pTLBParent);
+ pParent->pTLBParent = 0;
+ if (nAutoFmt)
+ aUsedSeqNo.erase(pParent);
+ }
+}
+
+void SwRedlineAcceptDlg::RemoveParents(sal_uInt16 nStart, sal_uInt16 nEnd)
+{
+ SwWrtShell* pSh = ::GetActiveView()->GetWrtShellPtr();
+ sal_uInt16 nCount = pSh->GetRedlineCount();
+
+ SvLBoxEntryArr aLBoxArr;
+
+ // because of Bug of TLB that ALWAYS calls the SelectHandler at Remove:
+ pTable->SetSelectHdl(aOldSelectHdl);
+ pTable->SetDeselectHdl(aOldDeselectHdl);
+ bool bChildrenRemoved = false;
+ pTable->SelectAll(sal_False);
+
+ // set the cursor after the last entry because otherwise performance problem in TLB.
+ // TLB would otherwise reset the cursor at every Remove (expensive)
+ sal_uInt16 nPos = std::min((sal_uInt16)nCount, (sal_uInt16)aRedlineParents.size());
+ SvTreeListEntry *pCurEntry = NULL;
+ while( ( pCurEntry == NULL ) && ( nPos > 0 ) )
+ {
+ --nPos;
+ pCurEntry = aRedlineParents[nPos].pTLBParent;
+ }
+
+ if (pCurEntry)
+ pTable->SetCurEntry(pCurEntry);
+
+ SvTreeList* pModel = pTable->GetModel();
+
+ for (sal_uInt16 i = nStart; i <= nEnd; i++)
+ {
+ if (!bChildrenRemoved && aRedlineParents[i].pNext)
+ {
+ SwRedlineDataChildPtr pChildPtr = (SwRedlineDataChildPtr)aRedlineParents[i].pNext;
+ for( SwRedlineDataChildArr::iterator it = aRedlineChildren.begin();
+ it != aRedlineChildren.end(); ++it)
+ if (&*it == pChildPtr)
+ {
+ sal_uInt16 nChildren = 0;
+ while (pChildPtr)
+ {
+ pChildPtr = (SwRedlineDataChildPtr)pChildPtr->pNext;
+ nChildren++;
+ }
+
+ aRedlineChildren.erase(it, it + nChildren);
+ bChildrenRemoved = true;
+ break;
+ }
+ }
+ SvTreeListEntry *pEntry = aRedlineParents[i].pTLBParent;
+ if (pEntry)
+ {
+ long nIdx = aLBoxArr.size() - 1L;
+ sal_uLong nAbsPos = pModel->GetAbsPos(pEntry);
+ while (nIdx >= 0 &&
+ pModel->GetAbsPos(aLBoxArr[ static_cast< sal_uInt16 >(nIdx) ]) > nAbsPos)
+ nIdx--;
+ aLBoxArr.insert( aLBoxArr.begin() + static_cast< sal_uInt16 >(++nIdx) , pEntry);
+ }
+ }
+
+ // clear TLB from behind
+ long nIdx = (long)aLBoxArr.size() - 1L;
+ while (nIdx >= 0)
+ pTable->RemoveEntry(aLBoxArr[ static_cast< sal_uInt16 >(nIdx--) ]);
+
+ pTable->SetSelectHdl(LINK(this, SwRedlineAcceptDlg, SelectHdl));
+ pTable->SetDeselectHdl(LINK(this, SwRedlineAcceptDlg, DeselectHdl));
+ // unfortunately by Remove it was selected from the TLB always again ...
+ pTable->SelectAll(sal_False);
+
+ aRedlineParents.erase( aRedlineParents.begin() + nStart, aRedlineParents.begin() + nEnd + 1);
+}
+
+void SwRedlineAcceptDlg::InsertParents(sal_uInt16 nStart, sal_uInt16 nEnd)
+{
+ SwView *pView = ::GetActiveView();
+ SwWrtShell* pSh = pView->GetWrtShellPtr();
+ sal_uInt16 nAutoFmt = HasRedlineAutoFmt() ? nsRedlineType_t::REDLINE_FORM_AUTOFMT : 0;
+
+ OUString sParent;
+ sal_uInt16 nCount = pSh->GetRedlineCount();
+ nEnd = std::min((sal_uInt16)nEnd, (sal_uInt16)(nCount - 1)); // also treats nEnd=USHRT_MAX (until the end)
+
+ if (nEnd == USHRT_MAX)
+ return; // no redlines in the document
+
+ RedlinData *pData;
+ SvTreeListEntry *pParent;
+ SwRedlineDataParent* pRedlineParent;
+ const SwRangeRedline* pCurrRedline;
+ if( !nStart && !pTable->FirstSelected() )
+ {
+ pCurrRedline = pSh->GetCurrRedline();
+ if( !pCurrRedline )
+ {
+ pSh->SwCrsrShell::Push();
+ if( 0 == (pCurrRedline = pSh->SelNextRedline()))
+ pCurrRedline = pSh->SelPrevRedline();
+ pSh->SwCrsrShell::Pop( sal_False );
+ }
+ }
+ else
+ pCurrRedline = 0;
+
+ for (sal_uInt16 i = nStart; i <= nEnd; i++)
+ {
+ const SwRangeRedline& rRedln = pSh->GetRedline(i);
+ const SwRedlineData *pRedlineData = &rRedln.GetRedlineData();
+
+ pRedlineParent = new SwRedlineDataParent;
+ pRedlineParent->pData = pRedlineData;
+ pRedlineParent->pNext = 0;
+ OUString sComment(rRedln.GetComment());
+ pRedlineParent->sComment = sComment.replace('\n', ' ');
+ aRedlineParents.insert(aRedlineParents.begin() + i, pRedlineParent);
+
+ pData = new RedlinData;
+ pData->pData = pRedlineParent;
+ pData->bDisabled = sal_False;
+
+ sParent = GetRedlineText(rRedln, pData->aDateTime);
+ pParent = pTable->InsertEntry(sParent, pData, 0, i);
+ if( pCurrRedline == &rRedln )
+ {
+ pTable->SetCurEntry( pParent );
+ pTable->Select( pParent );
+ pTable->MakeVisible( pParent );
+ }
+
+ pRedlineParent->pTLBParent = pParent;
+
+ InsertChildren(pRedlineParent, rRedln, nAutoFmt);
+ }
+}
+
+void SwRedlineAcceptDlg::CallAcceptReject( sal_Bool bSelect, sal_Bool bAccept )
+{
+ SwWrtShell* pSh = ::GetActiveView()->GetWrtShellPtr();
+ SvTreeListEntry* pEntry = bSelect ? pTable->FirstSelected() : pTable->First();
+ sal_uLong nPos = LONG_MAX;
+
+ typedef std::vector<SvTreeListEntry*> ListBoxEntries_t;
+ ListBoxEntries_t aRedlines;
+
+ // don't activate
+ OSL_ENSURE( bInhibitActivate == false,
+ "recursive call of CallAcceptReject?");
+ bInhibitActivate = true;
+
+ // collect redlines-to-be-accepted/rejected in aRedlines vector
+ while( pEntry )
+ {
+ if( !pTable->GetParent( pEntry ) )
+ {
+ if( bSelect && LONG_MAX == nPos )
+ nPos = pTable->GetModel()->GetAbsPos( pEntry );
+
+ RedlinData *pData = (RedlinData *)pEntry->GetUserData();
+
+ if( !pData->bDisabled )
+ aRedlines.push_back( pEntry );
+ }
+
+ pEntry = bSelect ? pTable->NextSelected(pEntry) : pTable->Next(pEntry);
+ }
+
+ sal_Bool (SwEditShell:: *FnAccRej)( sal_uInt16 ) = &SwEditShell::AcceptRedline;
+ if( !bAccept )
+ FnAccRej = &SwEditShell::RejectRedline;
+
+ SwWait aWait( *pSh->GetView().GetDocShell(), true );
+ pSh->StartAction();
+
+ // #111827#
+ if (aRedlines.size() > 1)
+ {
+ OUString aTmpStr;
+ {
+ SwRewriter aRewriter;
+ aRewriter.AddRule(UndoArg1,
+ OUString::number(aRedlines.size()));
+ aTmpStr = aRewriter.Apply(OUString(SW_RES(STR_N_REDLINES)));
+ }
+
+ SwRewriter aRewriter;
+ aRewriter.AddRule(UndoArg1, aTmpStr);
+
+ pSh->StartUndo(bAccept? UNDO_ACCEPT_REDLINE : UNDO_REJECT_REDLINE,
+ &aRewriter);
+ }
+
+ // accept/reject the redlines in aRedlines. The absolute
+ // position may change during the process (e.g. when two redlines
+ // are merged in result of another one being deleted), so the
+ // position must be resolved late and checked before using it.
+ // (cf #102547#)
+ ListBoxEntries_t::iterator aEnd = aRedlines.end();
+ for( ListBoxEntries_t::iterator aIter = aRedlines.begin();
+ aIter != aEnd;
+ ++aIter )
+ {
+ sal_uInt16 nPosition = GetRedlinePos( **aIter );
+ if( nPosition != USHRT_MAX )
+ (pSh->*FnAccRej)( nPosition );
+ }
+
+ // #111827#
+ if (aRedlines.size() > 1)
+ {
+ pSh->EndUndo();
+ }
+
+ pSh->EndAction();
+
+ bInhibitActivate = false;
+ Activate();
+
+ if( ULONG_MAX != nPos && pTable->GetEntryCount() )
+ {
+ if( nPos >= pTable->GetEntryCount() )
+ nPos = pTable->GetEntryCount() - 1;
+ pEntry = pTable->GetEntryAtAbsPos( nPos );
+ if( !pEntry && nPos-- )
+ pEntry = pTable->GetEntryAtAbsPos( nPos );
+ if( pEntry )
+ {
+ pTable->Select( pEntry );
+ pTable->MakeVisible( pEntry );
+ pTable->SetCurEntry(pEntry);
+ }
+ }
+ pTPView->EnableUndo();
+}
+
+sal_uInt16 SwRedlineAcceptDlg::GetRedlinePos( const SvTreeListEntry& rEntry ) const
+{
+ SwWrtShell* pSh = ::GetActiveView()->GetWrtShellPtr();
+ return pSh->FindRedlineOfData( *((SwRedlineDataParent*)((RedlinData *)
+ rEntry.GetUserData())->pData)->pData );
+}
+
+IMPL_LINK_NOARG(SwRedlineAcceptDlg, AcceptHdl)
+{
+ CallAcceptReject( sal_True, sal_True );
+ return 0;
+}
+
+IMPL_LINK_NOARG(SwRedlineAcceptDlg, AcceptAllHdl)
+{
+ CallAcceptReject( sal_False, sal_True );
+ return 0;
+}
+
+IMPL_LINK_NOARG(SwRedlineAcceptDlg, RejectHdl)
+{
+ CallAcceptReject( sal_True, sal_False );
+ return 0;
+}
+
+IMPL_LINK_NOARG(SwRedlineAcceptDlg, RejectAllHdl)
+{
+ CallAcceptReject( sal_False, sal_False );
+ return 0;
+}
+
+IMPL_LINK_NOARG(SwRedlineAcceptDlg, UndoHdl)
+{
+ SwView * pView = ::GetActiveView();
+ pView->GetViewFrame()->GetDispatcher()->
+ Execute(SID_UNDO, SFX_CALLMODE_SYNCHRON);
+ pTPView->EnableUndo(pView->GetSlotState(SID_UNDO) != 0);
+
+ Activate();
+
+ return 0;
+}
+
+IMPL_LINK_NOARG(SwRedlineAcceptDlg, FilterChangedHdl)
+{
+ SvxTPFilter *pFilterTP = aTabPagesCTRL.GetFilterPage();
+
+ if (pFilterTP->IsAction())
+ sFilterAction = pFilterTP->GetLbAction()->GetSelectEntry();
+ else
+ sFilterAction = aEmptyOUStr;
+
+ Init();
+
+ return 0;
+}
+
+IMPL_LINK_NOARG(SwRedlineAcceptDlg, DeselectHdl)
+{
+ // avoid flickering of buttons:
+ aDeselectTimer.Start();
+
+ return 0;
+}
+
+IMPL_LINK_NOARG(SwRedlineAcceptDlg, SelectHdl)
+{
+ aDeselectTimer.Stop();
+ aSelectTimer.Start();
+
+ return 0;
+}
+
+IMPL_LINK_NOARG(SwRedlineAcceptDlg, GotoHdl)
+{
+ SwWrtShell* pSh = ::GetActiveView()->GetWrtShellPtr();
+ aSelectTimer.Stop();
+
+ bool bIsNotFormated = false;
+ bool bSel = false;
+
+ //#98883# don't select redlines while the dialog is not focussed
+ //#107938# But not only ask pTable if it has the focus. To move
+ // the selection to the selected redline any child of pParentDlg
+ // may the focus.
+ SvTreeListEntry* pSelEntry = 0;
+
+ if (pParentDlg->HasChildPathFocus())
+ pSelEntry = pTable->FirstSelected();
+
+ if( pSelEntry )
+ {
+ SvTreeListEntry* pActEntry = pSelEntry;
+ pSh->StartAction();
+ pSh->EnterStdMode();
+ pSh->SetCareWin(pParentDlg);
+
+ while (pSelEntry)
+ {
+ if (pTable->GetParent(pSelEntry))
+ {
+ pActEntry = pTable->GetParent(pSelEntry);
+
+ if (pTable->IsSelected(pActEntry))
+ {
+ pSelEntry = pActEntry = pTable->NextSelected(pSelEntry);
+ continue; // don't select twice
+ }
+ }
+ else
+ bSel = true;
+
+ // #98864# find the selected redline (ignore, if the redline is already gone)
+ sal_uInt16 nPos = GetRedlinePos(*pActEntry);
+ if( nPos != USHRT_MAX )
+ {
+
+ const SwRangeRedline& rRedln = pSh->GetRedline( nPos );
+ bIsNotFormated |= nsRedlineType_t::REDLINE_FORMAT != rRedln.GetType();
+
+ if (pSh->GotoRedline(nPos, sal_True))
+ {
+ pSh->SetInSelect();
+ pSh->EnterAddMode();
+ }
+ }
+
+ pSelEntry = pActEntry = pTable->NextSelected(pSelEntry);
+ }
+
+ pSh->LeaveAddMode();
+ pSh->EndAction();
+ pSh->SetCareWin(NULL);
+ }
+ bool bEnable = !pSh->getIDocumentRedlineAccess()->GetRedlinePassword().getLength();
+ pTPView->EnableAccept( bEnable && bSel /*&& !bReadonlySel*/ );
+ pTPView->EnableReject( bEnable && bSel && bIsNotFormated /*&& !bReadonlySel*/ );
+ pTPView->EnableRejectAll( bEnable && !bOnlyFormatedRedlines && !bHasReadonlySel );
+
+ return 0;
+}
+
+IMPL_LINK_NOARG(SwRedlineAcceptDlg, CommandHdl)
+{
+ const CommandEvent aCEvt(pTable->GetCommandEvent());
+
+ switch ( aCEvt.GetCommand() )
+ {
+ case COMMAND_CONTEXTMENU:
+ {
+ SwWrtShell* pSh = ::GetActiveView()->GetWrtShellPtr();
+ SvTreeListEntry* pEntry = pTable->FirstSelected();
+ const SwRangeRedline *pRed = 0;
+
+ if (pEntry)
+ {
+ SvTreeListEntry* pTopEntry = pEntry;
+
+ if (pTable->GetParent(pEntry))
+ pTopEntry = pTable->GetParent(pEntry);
+
+ sal_uInt16 nPos = GetRedlinePos(*pTopEntry);
+
+ // disable commenting for protected areas
+ if (nPos != USHRT_MAX && (pRed = pSh->GotoRedline(nPos, sal_True)) != 0)
+ {
+ if( pSh->IsCrsrPtAtEnd() )
+ pSh->SwapPam();
+ pSh->SetInSelect();
+ }
+ }
+
+ aPopup.EnableItem( MN_EDIT_COMMENT, pEntry && pRed &&
+ !pTable->GetParent(pEntry) &&
+ !pTable->NextSelected(pEntry)
+//JP 27.9.2001: make no sense if we handle readonly sections
+// && pRed->HasReadonlySel()
+ );
+
+ aPopup.EnableItem( MN_SUB_SORT, pTable->First() != 0 );
+ sal_uInt16 nColumn = pTable->GetSortedCol();
+ if (nColumn == 0xffff)
+ nColumn = 4;
+
+ PopupMenu *pSubMenu = aPopup.GetPopupMenu(MN_SUB_SORT);
+ if (pSubMenu)
+ {
+ for (sal_uInt16 i = MN_SORT_ACTION; i < MN_SORT_ACTION + 5; i++)
+ pSubMenu->CheckItem(i, false);
+
+ pSubMenu->CheckItem(nColumn + MN_SORT_ACTION);
+ }
+
+ sal_uInt16 nRet = aPopup.Execute(pTable, aCEvt.GetMousePosPixel());
+
+ switch( nRet )
+ {
+ case MN_EDIT_COMMENT:
+ {
+ if (pEntry)
+ {
+ if (pTable->GetParent(pEntry))
+ pEntry = pTable->GetParent(pEntry);
+
+ sal_uInt16 nPos = GetRedlinePos(*pEntry);
+
+ if (nPos == USHRT_MAX)
+ break;
+
+ const SwRangeRedline &rRedline = pSh->GetRedline(nPos);
+
+ /* enable again once we have redline comments in the margin
+ sComment = rRedline.GetComment();
+ if ( !sComment.Len() )
+ GetActiveView()->GetDocShell()->Broadcast(SwRedlineHint(&rRedline,SWREDLINE_INSERTED));
+ const_cast<SwRangeRedline&>(rRedline).Broadcast(SwRedlineHint(&rRedline,SWREDLINE_FOCUS));
+ */
+
+ OUString sComment = convertLineEnd(rRedline.GetComment(), GetSystemLineEnd());
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "Dialogdiet fail!");
+ ::DialogGetRanges fnGetRange = pFact->GetDialogGetRangesFunc();
+ OSL_ENSURE(fnGetRange, "Dialogdiet fail! GetRanges()");
+ SfxItemSet aSet( pSh->GetAttrPool(), fnGetRange() );
+
+ aSet.Put(SvxPostItTextItem(sComment, SID_ATTR_POSTIT_TEXT));
+ aSet.Put(SvxPostItAuthorItem(rRedline.GetAuthorString(), SID_ATTR_POSTIT_AUTHOR));
+
+ aSet.Put(SvxPostItDateItem( GetAppLangDateTimeString(
+ rRedline.GetRedlineData().GetTimeStamp() ),
+ SID_ATTR_POSTIT_DATE ));
+
+ AbstractSvxPostItDialog* pDlg = pFact->CreateSvxPostItDialog( pParentDlg, aSet, sal_False );
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+
+ pDlg->HideAuthor();
+
+ sal_uInt16 nResId = 0;
+ switch( rRedline.GetType() )
+ {
+ case nsRedlineType_t::REDLINE_INSERT:
+ nResId = STR_REDLINE_INSERTED;
+ break;
+ case nsRedlineType_t::REDLINE_DELETE:
+ nResId = STR_REDLINE_DELETED;
+ break;
+ case nsRedlineType_t::REDLINE_FORMAT:
+ nResId = STR_REDLINE_FORMATED;
+ break;
+ case nsRedlineType_t::REDLINE_TABLE:
+ nResId = STR_REDLINE_TABLECHG;
+ break;
+ default:;//prevent warning
+ }
+ OUString sTitle(SW_RES(STR_REDLINE_COMMENT));
+ if( nResId )
+ sTitle += SW_RESSTR( nResId );
+ pDlg->SetText(sTitle);
+
+ pSh->SetCareWin(pDlg->GetWindow());
+
+ if ( pDlg->Execute() == RET_OK )
+ {
+ const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
+ OUString sMsg(((const SvxPostItTextItem&)pOutSet->Get(SID_ATTR_POSTIT_TEXT)).GetValue());
+
+ // insert / change comment
+ pSh->SetRedlineComment(sMsg);
+ pTable->SetEntryText(sMsg.replace('\n', ' '), pEntry, 3);
+ }
+
+ delete pDlg;
+ pSh->SetCareWin(NULL);
+ }
+
+ }
+ break;
+
+ case MN_SORT_ACTION:
+ case MN_SORT_AUTHOR:
+ case MN_SORT_DATE:
+ case MN_SORT_COMMENT:
+ case MN_SORT_POSITION:
+ {
+ bSortDir = sal_True;
+ if (nRet - MN_SORT_ACTION == 4 && pTable->GetSortedCol() == 0xffff)
+ break; // we already have it
+
+ nSortMode = nRet - MN_SORT_ACTION;
+ if (nSortMode == 4)
+ nSortMode = 0xffff; // unsorted / sorted by position
+
+ if (pTable->GetSortedCol() == nSortMode)
+ bSortDir = !pTable->GetSortDirection();
+
+ SwWait aWait( *::GetActiveView()->GetDocShell(), false );
+ pTable->SortByCol(nSortMode, bSortDir);
+ if (nSortMode == 0xffff)
+ Init(); // newly fill everything
+ }
+ break;
+ }
+ }
+ break;
+ }
+
+ return 0;
+}
+
+void SwRedlineAcceptDlg::Initialize(const OUString& rExtraData)
+{
+ if (!rExtraData.isEmpty())
+ {
+ sal_Int32 nPos = rExtraData.indexOf("AcceptChgDat:");
+
+ // try to read the alignment string "ALIGN:(...)"; if none existing,
+ // it's an old version
+ if (nPos != -1)
+ {
+ sal_Int32 n1 = rExtraData.indexOf('(', nPos);
+ if (n1 != -1)
+ {
+ sal_Int32 n2 = rExtraData.indexOf(')', n1);
+ if (n2 != -1)
+ {
+ // cut out the alignment string
+ OUString aStr = rExtraData.copy(nPos, n2 - nPos + 1);
+ aStr = aStr.copy(n1 - nPos + 1);
+
+ if (!aStr.isEmpty())
+ {
+ sal_uInt16 nCount = static_cast< sal_uInt16 >(aStr.toInt32());
+
+ for (sal_uInt16 i = 0; i < nCount; i++)
+ {
+ sal_Int32 n3 = aStr.indexOf(';');
+ aStr = aStr.copy(n3 + 1);
+ pTable->SetTab(i, aStr.toInt32(), MAP_PIXEL);
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+void SwRedlineAcceptDlg::FillInfo(OUString &rExtraData) const
+{
+ rExtraData += "AcceptChgDat:(";
+
+ sal_uInt16 nCount = pTable->TabCount();
+
+ rExtraData += OUString::number(nCount);
+ rExtraData += ";";
+ for(sal_uInt16 i = 0; i < nCount; i++)
+ {
+ rExtraData += OUString::number( pTable->GetTab(i) );
+ rExtraData += ";";
+ }
+ rExtraData += ")";
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/misc/redlndlg.hrc b/sw/source/core/uibase/misc/redlndlg.hrc
new file mode 100644
index 000000000000..e3d0464faca6
--- /dev/null
+++ b/sw/source/core/uibase/misc/redlndlg.hrc
@@ -0,0 +1,28 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#define MN_EDIT_COMMENT 1
+#define MN_SUB_SORT 2
+#define MN_SORT_ACTION 3
+#define MN_SORT_AUTHOR 4
+#define MN_SORT_DATE 5
+#define MN_SORT_COMMENT 6
+#define MN_SORT_POSITION 7
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/misc/redlndlg.src b/sw/source/core/uibase/misc/redlndlg.src
new file mode 100644
index 000000000000..e3b9aadb3a0f
--- /dev/null
+++ b/sw/source/core/uibase/misc/redlndlg.src
@@ -0,0 +1,85 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+/* StarView resource file */
+
+#include "redlndlg.hrc"
+#include "misc.hrc"
+#include "helpid.h"
+
+Menu MN_REDLINE_POPUP
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = MN_EDIT_COMMENT ;
+ HelpID = HID_EDIT_COMMENT ;
+ Text [ en-US ] = "Edit Comment..." ;
+ };
+ MenuItem
+ {
+ Identifier = MN_SUB_SORT ;
+ RadioCheck = TRUE ;
+ SubMenu = Menu
+ {
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = MN_SORT_ACTION ;
+ HelpID = HID_SORT_ACTION ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Action" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_SORT_AUTHOR ;
+ HelpID = HID_SORT_AUTHOR ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Author" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_SORT_DATE ;
+ HelpID = HID_SORT_DATE ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Date" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_SORT_COMMENT ;
+ HelpID = HID_SORT_COMMENT ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Comment" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_SORT_POSITION ;
+ HelpID = HID_SW_SORT_POSITION ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Document position" ;
+ };
+ };
+ };
+ Text [ en-US ] = "Sort By" ;
+ };
+ };
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/misc/swruler.cxx b/sw/source/core/uibase/misc/swruler.cxx
new file mode 100644
index 000000000000..1ba770fd6a42
--- /dev/null
+++ b/sw/source/core/uibase/misc/swruler.cxx
@@ -0,0 +1,302 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+// FIX fdo#38246 https://bugs.libreoffice.org/show_bug.cgi?id=38246
+// Design proposal: https://wiki.documentfoundation.org/Design/Whiteboards/Comments_Ruler_Control
+// TODO Alpha blend border when it doesn't fit in window
+
+#include "swruler.hxx"
+
+#include "viewsh.hxx"
+#include "edtwin.hxx"
+#include "PostItMgr.hxx"
+#include "viewopt.hxx"
+#include <view.hxx>
+#include "cmdid.h"
+#include <sfx2/request.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/window.hxx>
+#include <vcl/settings.hxx>
+#include "misc.hrc"
+
+#define CONTROL_BORDER_WIDTH 1
+
+#define CONTROL_LEFT_OFFSET 6
+#define CONTROL_RIGHT_OFFSET 3
+#define CONTROL_TOP_OFFSET 4
+
+#define CONTROL_TRIANGLE_WIDTH 4
+#define CONTROL_TRIANGLE_PAD 3
+
+// Constructor
+SwCommentRuler::SwCommentRuler( SwViewShell* pViewSh, Window* pParent, SwEditWin* pWin, sal_uInt16 nRulerFlags, SfxBindings& rBindings, WinBits nWinStyle)
+: SvxRuler(pParent, pWin, nRulerFlags, rBindings, nWinStyle | WB_HSCROLL)
+, mpViewShell(pViewSh)
+, mpSwWin(pWin)
+, mbIsHighlighted(false)
+, mnFadeRate(0)
+, maVirDev( *this )
+{
+ // Set fading timeout: 5 x 40ms = 200ms
+ maFadeTimer.SetTimeout(40);
+ maFadeTimer.SetTimeoutHdl( LINK( this, SwCommentRuler, FadeHandler ) );
+}
+
+// Destructor
+SwCommentRuler::~SwCommentRuler()
+{
+}
+
+void SwCommentRuler::Paint( const Rectangle& rRect )
+{
+ SvxRuler::Paint( rRect );
+ // Don't draw if there is not any note
+ if ( mpViewShell->GetPostItMgr()
+ && mpViewShell->GetPostItMgr()->HasNotes() )
+ DrawCommentControl();
+}
+
+void SwCommentRuler::DrawCommentControl()
+{
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+ bool bIsCollapsed = ! mpViewShell->GetPostItMgr()->ShowNotes();
+
+ Rectangle aControlRect = GetCommentControlRegion();
+ maVirDev.SetOutputSizePixel( aControlRect.GetSize() );
+
+ // Paint comment control background
+ // TODO Check if these are best colors to be used
+ Color aBgColor = GetFadedColor( rStyleSettings.GetDarkShadowColor(), rStyleSettings.GetWorkspaceColor() );
+ maVirDev.SetFillColor( aBgColor );
+
+ if ( mbIsHighlighted || !bIsCollapsed )
+ {
+ // Draw borders
+ maVirDev.SetLineColor( rStyleSettings.GetShadowColor() );
+ }
+ else
+ {
+ // No borders
+ maVirDev.SetLineColor();
+ }
+
+ maVirDev.DrawRect( Rectangle( Point(), aControlRect.GetSize() ) );
+
+ // Label and arrow tip
+ OUString aLabel( SW_RESSTR ( STR_COMMENTS_LABEL ) );
+ // Get label and arrow coordinates
+ Point aLabelPos;
+ Point aArrowPos;
+ bool bArrowToRight;
+ // TODO Discover why it should be 0 instead of CONTROL_BORDER_WIDTH + CONTROL_TOP_OFFSET
+ aLabelPos.Y() = 0;
+ aArrowPos.Y() = CONTROL_BORDER_WIDTH + CONTROL_TOP_OFFSET;
+ if ( !Application::GetSettings().GetLayoutRTL() )
+ {
+ // LTR
+ if ( bIsCollapsed )
+ {
+ // It should draw something like | > Comments |
+ aLabelPos.X() = CONTROL_LEFT_OFFSET + CONTROL_TRIANGLE_WIDTH + CONTROL_TRIANGLE_PAD;
+ aArrowPos.X() = CONTROL_LEFT_OFFSET;
+ }
+ else
+ {
+ // It should draw something like | Comments < |
+ aLabelPos.X() = CONTROL_LEFT_OFFSET;
+ aArrowPos.X() = aControlRect.GetSize().Width() - 1 - CONTROL_RIGHT_OFFSET - CONTROL_BORDER_WIDTH - CONTROL_TRIANGLE_WIDTH;
+ }
+ bArrowToRight = bIsCollapsed;
+ }
+ else
+ {
+ // RTL
+ long nLabelWidth = GetTextWidth( aLabel );
+ if ( bIsCollapsed )
+ {
+ // It should draw something like | Comments < |
+ aArrowPos.X() = aControlRect.GetSize().Width() - 1 - CONTROL_RIGHT_OFFSET - CONTROL_BORDER_WIDTH - CONTROL_TRIANGLE_WIDTH;
+ aLabelPos.X() = aArrowPos.X() - CONTROL_TRIANGLE_PAD - nLabelWidth;
+ }
+ else
+ {
+ // It should draw something like | > Comments |
+ aLabelPos.X() = aControlRect.GetSize().Width() - 1 - CONTROL_RIGHT_OFFSET - CONTROL_BORDER_WIDTH - nLabelWidth;
+ aArrowPos.X() = CONTROL_LEFT_OFFSET;
+ }
+ bArrowToRight = !bIsCollapsed;
+ }
+
+ // Draw label
+ Color aTextColor = GetFadedColor( rStyleSettings.GetButtonTextColor(), rStyleSettings.GetDarkShadowColor() );
+ maVirDev.SetTextColor( aTextColor );
+ // FIXME Expected font size?
+ maVirDev.DrawText( aLabelPos, aLabel );
+
+ // Draw arrow
+ // FIXME consistence of button colors. http://opengrok.libreoffice.org/xref/core/vcl/source/control/button.cxx#785
+ Color aArrowColor = GetFadedColor( Color( COL_BLACK ), rStyleSettings.GetShadowColor() );
+ ImplDrawArrow ( aArrowPos.X(), aArrowPos.Y(), aArrowColor, bArrowToRight );
+
+ // Blit comment control
+ DrawOutDev( aControlRect.TopLeft(), aControlRect.GetSize(), Point(), aControlRect.GetSize(), maVirDev );
+}
+
+void SwCommentRuler::ImplDrawArrow(long nX, long nY, const Color& rColor, bool bPointRight)
+{
+ maVirDev.SetLineColor();
+ maVirDev.SetFillColor( rColor );
+ if ( bPointRight )
+ {
+ maVirDev.DrawRect( Rectangle( nX+0, nY+0, nX+0, nY+6 ) );
+ maVirDev.DrawRect( Rectangle( nX+1, nY+1, nX+1, nY+5 ) );
+ maVirDev.DrawRect( Rectangle( nX+2, nY+2, nX+2, nY+4 ) );
+ maVirDev.DrawRect( Rectangle( nX+3, nY+3, nX+3, nY+3 ) );
+ }
+ else
+ {
+ maVirDev.DrawRect( Rectangle( nX+0, nY+3, nX+0, nY+3 ) );
+ maVirDev.DrawRect( Rectangle( nX+1, nY+2, nX+1, nY+4 ) );
+ maVirDev.DrawRect( Rectangle( nX+2, nY+1, nX+2, nY+5 ) );
+ maVirDev.DrawRect( Rectangle( nX+3, nY+0, nX+3, nY+6 ) );
+ }
+}
+
+// Just accept double-click outside comment control
+void SwCommentRuler::Command( const CommandEvent& rCEvt )
+{
+ Point aMousePos = rCEvt.GetMousePosPixel();
+ // Ignore command request if it is inside Comment Control
+ if ( !mpViewShell->GetPostItMgr()
+ || !mpViewShell->GetPostItMgr()->HasNotes()
+ || !GetCommentControlRegion().IsInside( aMousePos ) )
+ SvxRuler::Command( rCEvt );
+}
+
+void SwCommentRuler::MouseMove(const MouseEvent& rMEvt)
+{
+ SvxRuler::MouseMove(rMEvt);
+ if ( ! mpViewShell->GetPostItMgr() || ! mpViewShell->GetPostItMgr()->HasNotes() )
+ return;
+
+ Point aMousePos = rMEvt.GetPosPixel();
+ bool bWasHighlighted = mbIsHighlighted;
+ mbIsHighlighted = GetCommentControlRegion().IsInside( aMousePos );
+ if ( mbIsHighlighted != bWasHighlighted )
+ {
+ // Set proper help text
+ if ( mbIsHighlighted )
+ {
+ // Mouse over comment control
+ UpdateCommentHelpText();
+ }
+ else
+ {
+ // Mouse out of comment control
+ // FIXME Should remember previous tooltip text?
+ SetQuickHelpText( OUString() );
+ }
+ // Do start fading
+ maFadeTimer.Start();
+ }
+}
+
+void SwCommentRuler::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ Point aMousePos = rMEvt.GetPosPixel();
+ if ( !rMEvt.IsLeft() || IsTracking() || !GetCommentControlRegion().IsInside( aMousePos ) )
+ {
+ SvxRuler::MouseButtonDown(rMEvt);
+ return;
+ }
+
+ // Toggle notes visibility
+ SwView &rView = mpSwWin->GetView();
+ SfxRequest aRequest( rView.GetViewFrame(), FN_VIEW_NOTES );
+ rView.ExecViewOptions( aRequest );
+
+ // It is inside comment control, so update help text
+ UpdateCommentHelpText();
+
+ Invalidate();
+}
+
+void SwCommentRuler::Update()
+{
+ Rectangle aPreviousControlRect = GetCommentControlRegion();
+ SvxRuler::Update();
+ if (aPreviousControlRect != GetCommentControlRegion())
+ Invalidate();
+}
+
+void SwCommentRuler::UpdateCommentHelpText()
+{
+ int nTooltipResId;
+ if ( mpViewShell->GetPostItMgr()->ShowNotes() )
+ nTooltipResId = STR_HIDE_COMMENTS;
+ else
+ nTooltipResId = STR_SHOW_COMMENTS;
+ SetQuickHelpText( OUString( SW_RESSTR( nTooltipResId ) ) );
+}
+
+// TODO Make Ruler return its central rectangle instead of margins.
+Rectangle SwCommentRuler::GetCommentControlRegion()
+{
+ long nLeft = 0;
+ SwPostItMgr *pPostItMgr = mpViewShell->GetPostItMgr();
+
+ //rhbz#1006850 When the SwPostItMgr ctor is called from SwView::SwView it
+ //triggers an update of the uiview, but the result of the ctor hasn't been
+ //set into the mpViewShell yet, so GetPostItMgr is temporarily still NULL
+ if (!pPostItMgr)
+ return Rectangle();
+
+ unsigned long nSidebarWidth = pPostItMgr->GetSidebarWidth(true);
+ //FIXME When the page width is larger then screen, the ruler is misplaced by one pixel
+ if (GetTextRTL())
+ nLeft = GetPageOffset() - nSidebarWidth + GetBorderOffset();
+ else
+ nLeft = GetWinOffset() + GetPageOffset() + mpSwWin->LogicToPixel(Size(GetPageWidth(), 0)).Width();
+ long nTop = 0 + 4; // Ruler::ImplDraw uses RULER_OFF (value: 3px) as offset, and Ruler::ImplFormat adds one extra pixel
+ // Somehow pPostItMgr->GetSidebarBorderWidth() returns border width already doubled
+ long nRight = nLeft + nSidebarWidth + pPostItMgr->GetSidebarBorderWidth(true);
+ long nBottom = nTop + GetRulerVirHeight() - 3;
+
+ Rectangle aRect(nLeft, nTop, nRight, nBottom);
+ return aRect;
+}
+
+Color SwCommentRuler::GetFadedColor(const Color &rHighColor, const Color &rLowColor)
+{
+ if ( ! maFadeTimer.IsActive() )
+ return mbIsHighlighted ? rHighColor : rLowColor;
+
+ Color aColor = rHighColor;
+ aColor.Merge( rLowColor, mnFadeRate * 255/100.f );
+ return aColor;
+}
+
+IMPL_LINK_NOARG(SwCommentRuler, FadeHandler)
+{
+ const int nStep = 25;
+ if ( mbIsHighlighted && mnFadeRate < 100 )
+ mnFadeRate += nStep;
+ else if ( !mbIsHighlighted && mnFadeRate > 0 )
+ mnFadeRate -= nStep;
+ else
+ return 0;
+
+ Invalidate();
+
+ if ( mnFadeRate != 0 && mnFadeRate != 100)
+ maFadeTimer.Start();
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/ribbar/conarc.cxx b/sw/source/core/uibase/ribbar/conarc.cxx
new file mode 100644
index 000000000000..d3cf4d146d16
--- /dev/null
+++ b/sw/source/core/uibase/ribbar/conarc.cxx
@@ -0,0 +1,102 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <svx/svdobj.hxx>
+
+#include "view.hxx"
+#include "edtwin.hxx"
+#include "wrtsh.hxx"
+#include "drawbase.hxx"
+#include "conarc.hxx"
+
+ConstArc::ConstArc(SwWrtShell* pWrtShell, SwEditWin* pEditWin, SwView* pSwView)
+ : SwDrawBase(pWrtShell, pEditWin, pSwView), nAnzButUp(0)
+{
+}
+
+sal_Bool ConstArc::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ sal_Bool bReturn;
+
+ if ((bReturn = SwDrawBase::MouseButtonDown(rMEvt)) == sal_True)
+ {
+ if (!nAnzButUp)
+ aStartPnt = m_pWin->PixelToLogic(rMEvt.GetPosPixel());
+ }
+ return (bReturn);
+}
+
+sal_Bool ConstArc::MouseButtonUp( const MouseEvent& rMEvt )
+{
+ sal_Bool bReturn = sal_False;
+
+ if ((m_pSh->IsDrawCreate() || m_pWin->IsDrawAction()) && rMEvt.IsLeft())
+ {
+ Point aPnt(m_pWin->PixelToLogic(rMEvt.GetPosPixel()));
+ if (!nAnzButUp && aPnt == aStartPnt)
+ {
+ SwDrawBase::MouseButtonUp(rMEvt);
+ bReturn = sal_True;
+ }
+ else
+ { nAnzButUp++;
+
+ if (nAnzButUp == 3) // Generating of circular arc finished
+ {
+ SwDrawBase::MouseButtonUp(rMEvt);
+ nAnzButUp = 0;
+ bReturn = sal_True;
+ }
+ else
+ m_pSh->EndCreate(SDRCREATE_NEXTPOINT);
+ }
+ }
+
+ return (bReturn);
+}
+
+void ConstArc::Activate(const sal_uInt16 nSlotId)
+{
+ switch (nSlotId)
+ {
+ case SID_DRAW_ARC:
+ m_pWin->SetSdrDrawMode(OBJ_CARC);
+ break;
+ case SID_DRAW_PIE:
+ m_pWin->SetSdrDrawMode(OBJ_SECT);
+ break;
+ case SID_DRAW_CIRCLECUT:
+ m_pWin->SetSdrDrawMode(OBJ_CCUT);
+ break;
+ default:
+ m_pWin->SetSdrDrawMode(OBJ_NONE);
+ break;
+ }
+
+ SwDrawBase::Activate(nSlotId);
+}
+
+void ConstArc::Deactivate()
+{
+ nAnzButUp = 0;
+
+ SwDrawBase::Deactivate();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/ribbar/concustomshape.cxx b/sw/source/core/uibase/ribbar/concustomshape.cxx
new file mode 100644
index 000000000000..58e3747e5237
--- /dev/null
+++ b/sw/source/core/uibase/ribbar/concustomshape.cxx
@@ -0,0 +1,196 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <sfx2/bindings.hxx>
+#include <sfx2/htmlmode.hxx>
+#include <svx/sdtacitm.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/sdtagitm.hxx>
+#include <svx/sdtakitm.hxx>
+#include <svx/sdtaditm.hxx>
+#include <svx/sdtaaitm.hxx>
+#include <svx/svdview.hxx>
+#include <svx/svdocapt.hxx>
+#include <editeng/outlobj.hxx>
+#include <cmdid.h>
+#include <view.hxx>
+#include <edtwin.hxx>
+#include <wrtsh.hxx>
+#include <viewopt.hxx>
+#include <drawbase.hxx>
+#include <concustomshape.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/adjustitem.hxx>
+
+#include <math.h>
+
+ConstCustomShape::ConstCustomShape( SwWrtShell* pWrtShell, SwEditWin* pEditWin, SwView* pSwView, SfxRequest& rReq )
+ : SwDrawBase( pWrtShell, pEditWin, pSwView )
+{
+ aCustomShape = ConstCustomShape::GetShapeTypeFromRequest( rReq );
+}
+
+OUString ConstCustomShape::GetShapeType() const
+{
+ return aCustomShape;
+}
+
+OUString ConstCustomShape::GetShapeTypeFromRequest( SfxRequest& rReq )
+{
+ OUString aRet;
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ if ( pArgs )
+ {
+ const SfxStringItem& rItm = (const SfxStringItem&)pArgs->Get( rReq.GetSlot() );
+ aRet = rItm.GetValue();
+ }
+ return aRet;
+}
+
+sal_Bool ConstCustomShape::MouseButtonDown(const MouseEvent& rMEvt)
+{
+ sal_Bool bReturn = SwDrawBase::MouseButtonDown(rMEvt);
+ if ( bReturn )
+ {
+ SdrView *pSdrView = m_pSh->GetDrawView();
+ if ( pSdrView )
+ {
+ SdrObject* pObj = pSdrView->GetCreateObj();
+ if ( pObj )
+ {
+ SetAttributes( pObj );
+ bool bForceNoFillStyle = false;
+ if ( ((SdrObjCustomShape*)pObj)->UseNoFillStyle() )
+ bForceNoFillStyle = true;
+
+ SfxItemSet aAttr( m_pView->GetPool() );
+ if ( bForceNoFillStyle )
+ aAttr.Put( XFillStyleItem( XFILL_NONE ) );
+ pObj->SetMergedItemSet(aAttr);
+ }
+ }
+ }
+ return bReturn;
+}
+
+sal_Bool ConstCustomShape::MouseButtonUp(const MouseEvent& rMEvt)
+{
+ return SwDrawBase::MouseButtonUp(rMEvt);
+}
+
+void ConstCustomShape::Activate(const sal_uInt16 nSlotId)
+{
+ m_pWin->SetSdrDrawMode( OBJ_CUSTOMSHAPE );
+
+ SwDrawBase::Activate(nSlotId);
+}
+
+// applying attributes
+
+void ConstCustomShape::SetAttributes( SdrObject* pObj )
+{
+ bool bAttributesAppliedFromGallery = false;
+
+ if ( GalleryExplorer::GetSdrObjCount( GALLERY_THEME_POWERPOINT ) )
+ {
+ std::vector< 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 = true;
+ }
+ }
+ break;
+ }
+ }
+ }
+ }
+ if ( !bAttributesAppliedFromGallery )
+ {
+ pObj->SetMergedItem( SvxAdjustItem( SVX_ADJUST_CENTER, RES_PARATR_ADJUST ) );
+ pObj->SetMergedItem( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER ) );
+ pObj->SetMergedItem( SdrTextHorzAdjustItem( SDRTEXTHORZADJUST_BLOCK ) );
+ pObj->SetMergedItem( SdrTextAutoGrowHeightItem( sal_False ) );
+ ((SdrObjCustomShape*)pObj)->MergeDefaultAttributes( &aCustomShape );
+ }
+}
+
+void ConstCustomShape::CreateDefaultObject()
+{
+ SwDrawBase::CreateDefaultObject();
+ SdrView *pSdrView = m_pSh->GetDrawView();
+ if ( pSdrView )
+ {
+ const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
+ if ( rMarkList.GetMarkCount() == 1 )
+ {
+ SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+ if ( pObj && pObj->ISA( SdrObjCustomShape ) )
+ SetAttributes( pObj );
+ }
+ }
+}
+
+// #i33136#
+bool ConstCustomShape::doConstructOrthogonal() const
+{
+ return SdrObjCustomShape::doConstructOrthogonal(aCustomShape);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/ribbar/conform.cxx b/sw/source/core/uibase/ribbar/conform.cxx
new file mode 100644
index 000000000000..2b15f5f8e9e4
--- /dev/null
+++ b/sw/source/core/uibase/ribbar/conform.cxx
@@ -0,0 +1,110 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <svx/fmglob.hxx>
+#include <svx/svdview.hxx>
+#include <svx/fmshell.hxx>
+
+#include "view.hxx"
+#include "edtwin.hxx"
+#include "wrtsh.hxx"
+#include "drawbase.hxx"
+#include "conform.hxx"
+
+extern bool bNoInterrupt; // in mainwn.cxx
+
+ConstFormControl::ConstFormControl(SwWrtShell* pWrtShell, SwEditWin* pEditWin, SwView* pSwView) :
+ SwDrawBase(pWrtShell, pEditWin, pSwView)
+{
+ m_bInsForm = true;
+}
+
+sal_Bool ConstFormControl::MouseButtonDown(const MouseEvent& rMEvt)
+{
+ sal_Bool bReturn = sal_False;
+
+ SdrView *pSdrView = m_pSh->GetDrawView();
+
+ pSdrView->SetOrtho(rMEvt.IsShift());
+ pSdrView->SetAngleSnapEnabled(rMEvt.IsShift());
+
+ if (rMEvt.IsMod2())
+ {
+ pSdrView->SetCreate1stPointAsCenter(sal_True);
+ pSdrView->SetResizeAtCenter(sal_True);
+ }
+ else
+ {
+ pSdrView->SetCreate1stPointAsCenter(sal_False);
+ pSdrView->SetResizeAtCenter(sal_False);
+ }
+
+ SdrViewEvent aVEvt;
+ SdrHitKind eHit = pSdrView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
+
+ // Only new object; if not in base mode (or pure selection mode)
+ if (rMEvt.IsLeft() && !m_pWin->IsDrawAction() &&
+ (eHit == SDRHIT_UNMARKEDOBJECT || eHit == SDRHIT_NONE || m_pSh->IsDrawCreate()))
+ {
+ bNoInterrupt = true;
+ m_pWin->CaptureMouse();
+
+ m_pWin->SetPointer(Pointer(POINTER_DRAW_RECT));
+
+ m_aStartPos = m_pWin->PixelToLogic(rMEvt.GetPosPixel());
+ bReturn = m_pSh->BeginCreate( static_cast< sal_uInt16 >(m_pWin->GetSdrDrawMode()), FmFormInventor, m_aStartPos);
+
+ if (bReturn)
+ m_pWin->SetDrawAction(sal_True);
+ }
+ else
+ bReturn = SwDrawBase::MouseButtonDown(rMEvt);
+
+ return (bReturn);
+}
+
+void ConstFormControl::Activate(const sal_uInt16 nSlotId)
+{
+ m_pWin->SetSdrDrawMode( static_cast<SdrObjKind>(nSlotId) );
+ SwDrawBase::Activate(nSlotId);
+ m_pSh->GetDrawView()->SetCurrentObj(nSlotId);
+
+ m_pWin->SetPointer(Pointer(POINTER_DRAW_RECT));
+}
+
+void ConstFormControl::CreateDefaultObject()
+{
+ Point aStartPos(GetDefaultCenterPos());
+ Point aEndPos(aStartPos);
+ aStartPos.X() -= 2 * MM50;
+ aStartPos.Y() -= MM50;
+ aEndPos.X() += 2 * MM50;
+ aEndPos.Y() += MM50;
+
+ if(!m_pSh->HasDrawView())
+ m_pSh->MakeDrawView();
+
+ SdrView *pSdrView = m_pSh->GetDrawView();
+ pSdrView->SetDesignMode(true);
+ m_pSh->BeginCreate( static_cast< sal_uInt16 >(m_pWin->GetSdrDrawMode()), FmFormInventor, aStartPos);
+ m_pSh->MoveCreate(aEndPos);
+ m_pSh->EndCreate(SDRCREATE_FORCEEND);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/ribbar/conpoly.cxx b/sw/source/core/uibase/ribbar/conpoly.cxx
new file mode 100644
index 000000000000..5edde1056ac2
--- /dev/null
+++ b/sw/source/core/uibase/ribbar/conpoly.cxx
@@ -0,0 +1,107 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <svx/svdmark.hxx>
+#include <svx/svdview.hxx>
+#include <svx/svdopath.hxx>
+
+#include "view.hxx"
+#include "edtwin.hxx"
+#include "wrtsh.hxx"
+#include "drawbase.hxx"
+#include "conpoly.hxx"
+#include <basegfx/polygon/b2dpolygon.hxx>
+
+ConstPolygon::ConstPolygon(SwWrtShell* pWrtShell, SwEditWin* pEditWin, SwView* pSwView) :
+ SwDrawBase(pWrtShell, pEditWin, pSwView)
+{
+}
+
+sal_Bool ConstPolygon::MouseButtonDown(const MouseEvent& rMEvt)
+{
+ sal_Bool bReturn;
+
+ if ((bReturn = SwDrawBase::MouseButtonDown(rMEvt)) == sal_True)
+ aLastPos = rMEvt.GetPosPixel();
+
+ return (bReturn);
+}
+
+sal_Bool ConstPolygon::MouseMove(const MouseEvent& rMEvt)
+{
+ sal_Bool bReturn = SwDrawBase::MouseMove(rMEvt);
+
+ return bReturn;
+}
+
+sal_Bool ConstPolygon::MouseButtonUp(const MouseEvent& rMEvt)
+{
+ sal_Bool bReturn = sal_False;
+
+ if (m_pSh->IsDrawCreate())
+ {
+ if (rMEvt.IsLeft() && rMEvt.GetClicks() == 1 &&
+ m_pWin->GetSdrDrawMode() != OBJ_FREELINE)
+ {
+ if (!m_pSh->EndCreate(SDRCREATE_NEXTPOINT))
+ {
+ m_pSh->BreakCreate();
+ EnterSelectMode(rMEvt);
+ return sal_True;
+ }
+ }
+ else
+ {
+ bReturn = SwDrawBase::MouseButtonUp(rMEvt);
+
+ // #i85045# removed double mechanism to check for AutoClose polygon
+ // after construction; the method here did not check for already closed and
+ // also worked only for a single polygon. Removing.
+ }
+ }
+ else
+ bReturn = SwDrawBase::MouseButtonUp(rMEvt);
+
+ return (bReturn);
+}
+
+void ConstPolygon::Activate(const sal_uInt16 nSlotId)
+{
+ switch (nSlotId)
+ {
+ case SID_DRAW_POLYGON_NOFILL:
+ m_pWin->SetSdrDrawMode(OBJ_PLIN);
+ break;
+
+ case SID_DRAW_BEZIER_NOFILL:
+ m_pWin->SetSdrDrawMode(OBJ_PATHLINE);
+ break;
+
+ case SID_DRAW_FREELINE_NOFILL:
+ m_pWin->SetSdrDrawMode(OBJ_FREELINE);
+ break;
+
+ default:
+ break;
+ }
+
+ SwDrawBase::Activate(nSlotId);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/ribbar/conrect.cxx b/sw/source/core/uibase/ribbar/conrect.cxx
new file mode 100644
index 000000000000..383ff7e8310d
--- /dev/null
+++ b/sw/source/core/uibase/ribbar/conrect.cxx
@@ -0,0 +1,187 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <sfx2/bindings.hxx>
+#include <sfx2/htmlmode.hxx>
+#include <svx/sdtacitm.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/sdtagitm.hxx>
+#include <svx/sdtakitm.hxx>
+#include <svx/sdtaditm.hxx>
+#include <svx/sdtaaitm.hxx>
+#include <svx/svdview.hxx>
+#include <svx/svdocapt.hxx>
+#include <editeng/outlobj.hxx>
+#include <cmdid.h>
+#include <view.hxx>
+#include <edtwin.hxx>
+#include <wrtsh.hxx>
+#include <viewopt.hxx>
+#include <drawbase.hxx>
+#include <conrect.hxx>
+
+ConstRectangle::ConstRectangle( SwWrtShell* pWrtShell, SwEditWin* pEditWin,
+ SwView* pSwView )
+ : SwDrawBase( pWrtShell, pEditWin, pSwView ),
+ bMarquee(false),
+ // #93382#
+ mbVertical(false)
+{
+}
+
+sal_Bool ConstRectangle::MouseButtonDown(const MouseEvent& rMEvt)
+{
+ sal_Bool bReturn;
+
+ if ((bReturn = SwDrawBase::MouseButtonDown(rMEvt)) == sal_True
+ && m_pWin->GetSdrDrawMode() == OBJ_CAPTION)
+ {
+ m_pView->NoRotate();
+ if (m_pView->IsDrawSelMode())
+ {
+ m_pView->FlipDrawSelMode();
+ m_pSh->GetDrawView()->SetFrameDragSingles(m_pView->IsDrawSelMode());
+ }
+ }
+ return (bReturn);
+}
+
+sal_Bool ConstRectangle::MouseButtonUp(const MouseEvent& rMEvt)
+{
+ sal_Bool bRet = SwDrawBase::MouseButtonUp(rMEvt);
+ if( bRet )
+ {
+ SdrView *pSdrView = m_pSh->GetDrawView();
+ const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
+ SdrObject* pObj = rMarkList.GetMark(0) ? rMarkList.GetMark(0)->GetMarkedSdrObj()
+ : 0;
+ switch( m_pWin->GetSdrDrawMode() )
+ {
+ case OBJ_TEXT:
+ if( bMarquee )
+ {
+ m_pSh->ChgAnchor(FLY_AS_CHAR);
+
+ if( pObj )
+ {
+ // Set the attributes needed for scrolling
+ SfxItemSet aItemSet( pSdrView->GetModel()->GetItemPool(),
+ SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST);
+
+ aItemSet.Put( SdrTextAutoGrowWidthItem( sal_False ) );
+ aItemSet.Put( SdrTextAutoGrowHeightItem( sal_False ) );
+ aItemSet.Put( SdrTextAniKindItem( SDRTEXTANI_SCROLL ) );
+ aItemSet.Put( SdrTextAniDirectionItem( SDRTEXTANI_LEFT ) );
+ aItemSet.Put( SdrTextAniCountItem( 0 ) );
+ aItemSet.Put( SdrTextAniAmountItem(
+ (sal_Int16)m_pWin->PixelToLogic(Size(2,1)).Width()) );
+
+ pObj->SetMergedItemSetAndBroadcast(aItemSet);
+ }
+ }
+ else if(mbVertical && pObj && pObj->ISA(SdrTextObj))
+ {
+ SdrTextObj* pText = (SdrTextObj*)pObj;
+ SfxItemSet aSet(pSdrView->GetModel()->GetItemPool());
+
+ pText->SetVerticalWriting(sal_True);
+
+ aSet.Put(SdrTextAutoGrowWidthItem(sal_True));
+ aSet.Put(SdrTextAutoGrowHeightItem(sal_False));
+ aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP));
+ aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
+
+ pText->SetMergedItemSet(aSet);
+ }
+ if( pObj )
+ {
+ SdrPageView* pPV = pSdrView->GetSdrPageView();
+ m_pView->BeginTextEdit( pObj, pPV, m_pWin, true );
+ }
+ m_pView->LeaveDrawCreate(); // Switch to selection mode
+ m_pSh->GetView().GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW);
+ break;
+
+ case OBJ_CAPTION:
+ {
+ SdrCaptionObj* pCaptObj = dynamic_cast<SdrCaptionObj*>(pObj);
+ if( bCapVertical && pCaptObj )
+ {
+ pCaptObj->ForceOutlinerParaObject();
+ OutlinerParaObject* pOPO = pCaptObj->GetOutlinerParaObject();
+ if( pOPO && !pOPO->IsVertical() )
+ pOPO->SetVertical( true );
+ }
+ }
+ break;
+ default:; //prevent warning
+ }
+ }
+ return bRet;
+}
+
+void ConstRectangle::Activate(const sal_uInt16 nSlotId)
+{
+ bMarquee = bCapVertical = false;
+ mbVertical = false;
+
+ switch (nSlotId)
+ {
+ case SID_DRAW_LINE:
+ m_pWin->SetSdrDrawMode(OBJ_LINE);
+ break;
+
+ case SID_DRAW_RECT:
+ m_pWin->SetSdrDrawMode(OBJ_RECT);
+ break;
+
+ case SID_DRAW_ELLIPSE:
+ m_pWin->SetSdrDrawMode(OBJ_CIRC);
+ break;
+
+ case SID_DRAW_TEXT_MARQUEE:
+ bMarquee = true;
+ m_pWin->SetSdrDrawMode(OBJ_TEXT);
+ break;
+
+ case SID_DRAW_TEXT_VERTICAL:
+ mbVertical = true;
+ m_pWin->SetSdrDrawMode(OBJ_TEXT);
+ break;
+
+ case SID_DRAW_TEXT:
+ m_pWin->SetSdrDrawMode(OBJ_TEXT);
+ break;
+
+ case SID_DRAW_CAPTION_VERTICAL:
+ bCapVertical = true;
+ // no break
+ case SID_DRAW_CAPTION:
+ m_pWin->SetSdrDrawMode(OBJ_CAPTION);
+ break;
+
+ default:
+ m_pWin->SetSdrDrawMode(OBJ_NONE);
+ break;
+ }
+
+ SwDrawBase::Activate(nSlotId);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/ribbar/drawbase.cxx b/sw/source/core/uibase/ribbar/drawbase.cxx
new file mode 100644
index 000000000000..de3eddb8fe3d
--- /dev/null
+++ b/sw/source/core/uibase/ribbar/drawbase.cxx
@@ -0,0 +1,623 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <hintids.hxx>
+#include <svx/svdview.hxx>
+#include <svx/svdobj.hxx>
+#include <svl/ptitem.hxx>
+#include <editeng/sizeitem.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/bindings.hxx>
+#include <fmtclds.hxx>
+#include <frmfmt.hxx>
+#include "cmdid.h"
+#include "basesh.hxx"
+#include "view.hxx"
+#include "wrtsh.hxx"
+#include "drawbase.hxx"
+#include "edtwin.hxx"
+#include "caption.hxx"
+#include "swundo.hxx"
+#include <SwRewriter.hxx>
+#include "comcore.hrc"
+
+using namespace ::com::sun::star;
+
+extern bool bNoInterrupt; // in mainwn.cxx
+
+SwDrawBase::SwDrawBase(SwWrtShell* pSwWrtShell, SwEditWin* pWindow, SwView* pSwView) :
+ m_pView(pSwView),
+ m_pSh(pSwWrtShell),
+ m_pWin(pWindow),
+ m_nSlotId(USHRT_MAX),
+ m_bCreateObj(true),
+ m_bInsForm(false)
+{
+ if ( !m_pSh->HasDrawView() )
+ m_pSh->MakeDrawView();
+}
+
+SwDrawBase::~SwDrawBase()
+{
+ if (m_pView->GetWrtShellPtr()) // In the view-dtor could the wrtsh already been deleted...
+ m_pSh->GetDrawView()->SetEditMode(sal_True);
+}
+
+sal_Bool SwDrawBase::MouseButtonDown(const MouseEvent& rMEvt)
+{
+ sal_Bool bReturn = sal_False;
+
+ SdrView *pSdrView = m_pSh->GetDrawView();
+
+ // #i33136#
+ pSdrView->SetOrtho(doConstructOrthogonal() ? !rMEvt.IsShift() : rMEvt.IsShift());
+ pSdrView->SetAngleSnapEnabled(rMEvt.IsShift());
+
+ if (rMEvt.IsMod2())
+ {
+ pSdrView->SetCreate1stPointAsCenter(sal_True);
+ pSdrView->SetResizeAtCenter(sal_True);
+ }
+ else
+ {
+ pSdrView->SetCreate1stPointAsCenter(sal_False);
+ pSdrView->SetResizeAtCenter(sal_False);
+ }
+
+ SdrViewEvent aVEvt;
+ SdrHitKind eHit = pSdrView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
+
+ // Only new object, if not in the basic mode (or pure selection mode).
+ if (rMEvt.IsLeft() && !m_pWin->IsDrawAction())
+ {
+ if (IsCreateObj() && (eHit == SDRHIT_UNMARKEDOBJECT || eHit == SDRHIT_NONE || m_pSh->IsDrawCreate()))
+ {
+ bNoInterrupt = true;
+ m_pWin->CaptureMouse();
+
+ m_aStartPos = m_pWin->PixelToLogic(rMEvt.GetPosPixel());
+
+ bReturn = m_pSh->BeginCreate( static_cast< sal_uInt16 >(m_pWin->GetSdrDrawMode()), m_aStartPos);
+
+ SetDrawPointer();
+
+ if ( bReturn )
+ m_pWin->SetDrawAction(sal_True);
+ }
+ else if (!pSdrView->IsAction())
+ {
+ // BEZIER-EDITOR
+ m_pWin->CaptureMouse();
+ m_aStartPos = m_pWin->PixelToLogic(rMEvt.GetPosPixel());
+ sal_uInt16 nEditMode = m_pWin->GetBezierMode();
+
+ if (eHit == SDRHIT_HANDLE && aVEvt.pHdl->GetKind() == HDL_BWGT)
+ {
+ // Drag handle
+ bNoInterrupt = true;
+ bReturn = pSdrView->BegDragObj(m_aStartPos, (OutputDevice*) NULL, aVEvt.pHdl);
+ m_pWin->SetDrawAction(sal_True);
+ }
+ else if (eHit == SDRHIT_MARKEDOBJECT && nEditMode == SID_BEZIER_INSERT)
+ {
+ // Insert gluepoint
+ bNoInterrupt = true;
+ bReturn = pSdrView->BegInsObjPoint(m_aStartPos, rMEvt.IsMod1());
+ m_pWin->SetDrawAction(sal_True);
+ }
+ else if (eHit == SDRHIT_MARKEDOBJECT && rMEvt.IsMod1())
+ {
+ // Select gluepoint
+ if (!rMEvt.IsShift())
+ pSdrView->UnmarkAllPoints();
+
+ bReturn = pSdrView->BegMarkPoints(m_aStartPos);
+ m_pWin->SetDrawAction(sal_True);
+ }
+ else if (eHit == SDRHIT_MARKEDOBJECT && !rMEvt.IsShift() && !rMEvt.IsMod2())
+ {
+ // Move objekt
+ return sal_False;
+ }
+ else if (eHit == SDRHIT_HANDLE)
+ {
+ // Select gluepoint
+ if (pSdrView->HasMarkablePoints() && (!pSdrView->IsPointMarked(*aVEvt.pHdl) || rMEvt.IsShift()))
+ {
+ SdrHdl* pHdl = NULL;
+
+ if (!rMEvt.IsShift())
+ {
+ pSdrView->UnmarkAllPoints();
+ pHdl = pSdrView->PickHandle(m_aStartPos);
+ }
+ else
+ {
+ if (pSdrView->IsPointMarked(*aVEvt.pHdl))
+ {
+ bReturn = pSdrView->UnmarkPoint(*aVEvt.pHdl);
+ pHdl = NULL;
+ }
+ else
+ {
+ pHdl = pSdrView->PickHandle(m_aStartPos);
+ }
+ }
+
+ if (pHdl)
+ {
+ bNoInterrupt = true;
+ pSdrView->MarkPoint(*pHdl);
+ }
+ }
+ }
+ else
+ {
+ // Select or drag object
+ if (m_pSh->IsObjSelectable(m_aStartPos) && eHit == SDRHIT_UNMARKEDOBJECT)
+ {
+ if (pSdrView->HasMarkablePoints())
+ pSdrView->UnmarkAllPoints();
+
+ bNoInterrupt = false;
+ // Use drag in edtwin
+ return sal_False;
+ }
+
+ bNoInterrupt = true;
+
+ if (m_pSh->IsObjSelected())
+ {
+ if (!rMEvt.IsShift())
+ {
+ if (!pSdrView->HasMarkablePoints())
+ {
+ bool bUnlockView = !m_pSh->IsViewLocked();
+ m_pSh->LockView( sal_True ); //lock visible section
+ m_pSh->SelectObj(Point(LONG_MAX, LONG_MAX)); // deselect all
+ if( bUnlockView )
+ m_pSh->LockView( sal_False );
+ }
+ else
+ pSdrView->UnmarkAllPoints();
+ }
+ }
+ if (!m_pSh->IsSelFrmMode())
+ m_pSh->EnterSelFrmMode(NULL);
+
+ if( 0 != (bReturn = m_pSh->BeginMark(m_aStartPos)) )
+ m_pWin->SetDrawAction(sal_True);
+
+ SetDrawPointer();
+ }
+ }
+ }
+ return bReturn;
+}
+
+sal_Bool SwDrawBase::MouseMove(const MouseEvent& rMEvt)
+{
+ SdrView *pSdrView = m_pSh->GetDrawView();
+ Point aPnt(m_pWin->PixelToLogic(rMEvt.GetPosPixel()));
+ sal_Bool bRet = sal_False;
+
+ if (IsCreateObj() && !m_pWin->IsDrawSelMode() && pSdrView->IsCreateObj())
+ {
+ // #i33136#
+ pSdrView->SetOrtho(doConstructOrthogonal() ? !rMEvt.IsShift() : rMEvt.IsShift());
+ pSdrView->SetAngleSnapEnabled(rMEvt.IsShift());
+
+ m_pSh->MoveCreate(aPnt);
+ bRet = sal_True;
+ }
+ else if (pSdrView->IsAction() || pSdrView->IsInsObjPoint() || pSdrView->IsMarkPoints())
+ {
+ m_pSh->MoveMark(aPnt);
+ bRet = sal_True;
+ }
+
+ return (bRet);
+}
+
+sal_Bool SwDrawBase::MouseButtonUp(const MouseEvent& rMEvt)
+{
+ sal_Bool bReturn = sal_False;
+ bool bCheckShell = false;
+ bool bAutoCap = false;
+
+ Point aPnt(m_pWin->PixelToLogic(rMEvt.GetPosPixel()));
+
+ if (IsCreateObj() && m_pSh->IsDrawCreate() && !m_pWin->IsDrawSelMode())
+ {
+ const SdrObjKind nDrawMode = m_pWin->GetSdrDrawMode();
+ //objects with multiple point may end at the start position
+ bool bMultiPoint = OBJ_PLIN == nDrawMode ||
+ OBJ_PATHLINE == nDrawMode ||
+ OBJ_FREELINE == nDrawMode;
+ if(rMEvt.IsRight() || (aPnt == m_aStartPos && !bMultiPoint))
+ {
+ m_pSh->BreakCreate();
+ m_pView->LeaveDrawCreate();
+ }
+ else
+ {
+ if (OBJ_NONE == nDrawMode)
+ {
+ SwRewriter aRewriter;
+
+ aRewriter.AddRule(UndoArg1, SW_RES(STR_FRAME));
+ m_pSh->StartUndo(UNDO_INSERT, &aRewriter);
+ }
+
+ m_pSh->EndCreate(SDRCREATE_FORCEEND);
+ if (OBJ_NONE == nDrawMode) // Text border inserted
+ {
+ uno::Reference< frame::XDispatchRecorder > xRecorder =
+ m_pSh->GetView().GetViewFrame()->GetBindings().GetRecorder();
+ if ( xRecorder.is() )
+ {
+ SfxRequest aReq(m_pSh->GetView().GetViewFrame(),FN_INSERT_FRAME);
+ aReq.AppendItem(SfxUInt16Item( FN_INSERT_FRAME,
+ static_cast<sal_uInt16>(FLY_AT_PARA) ));
+ aReq.AppendItem(SfxPointItem( FN_PARAM_1, m_pSh->GetAnchorObjDiff()));
+ aReq.AppendItem(SvxSizeItem( FN_PARAM_2, m_pSh->GetObjSize()));
+ aReq.Done();
+ }
+ bAutoCap = true;
+ if(m_pWin->GetFrmColCount() > 1)
+ {
+ SfxItemSet aSet(m_pView->GetPool(),RES_COL,RES_COL);
+ SwFmtCol aCol((const SwFmtCol&)aSet.Get(RES_COL));
+ aCol.Init(m_pWin->GetFrmColCount(), aCol.GetGutterWidth(), aCol.GetWishWidth());
+ aSet.Put(aCol);
+ // Template AutoUpdate
+ SwFrmFmt* pFmt = m_pSh->GetCurFrmFmt();
+ if(pFmt && pFmt->IsAutoUpdateFmt())
+ m_pSh->AutoUpdateFrame(pFmt, aSet);
+ else
+ m_pSh->SetFlyFrmAttr( aSet );
+ }
+ }
+ if (m_pWin->GetSdrDrawMode() == OBJ_NONE)
+ {
+ m_pSh->EndUndo();
+ }
+ }
+
+ bReturn = sal_True;
+
+ EnterSelectMode(rMEvt);
+ }
+ else
+ {
+ SdrView *pSdrView = m_pSh->GetDrawView();
+
+ if (!pSdrView->HasMarkablePoints())
+ {
+ // NO BEZIER_EDITOR
+ if ((m_pSh->GetDrawView()->IsMarkObj() || m_pSh->GetDrawView()->IsMarkPoints())
+ && rMEvt.IsLeft())
+ {
+ bReturn = m_pSh->EndMark();
+
+ m_pWin->SetDrawAction(sal_False);
+
+ if (aPnt == m_aStartPos && m_pSh->IsObjSelectable(aPnt))
+ {
+ m_pSh->SelectObj(aPnt, ( rMEvt.IsShift() &&
+ m_pSh->IsSelFrmMode()) ? SW_ADD_SELECT : 0);
+
+ if (!m_pSh->IsObjSelected())
+ {
+ m_pView->LeaveDrawCreate(); // Switch to selection mode
+
+ m_pSh->GetView().GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW);
+
+ if (m_pSh->IsSelFrmMode())
+ m_pSh->LeaveSelFrmMode();
+ }
+ m_pView->NoRotate();
+
+ bCheckShell = true; // if necessary turn on BezierShell
+ }
+ else if (!m_pSh->IsObjSelected() && !m_pWin->IsDrawAction())
+ {
+ if (m_pSh->IsObjSelectable(aPnt))
+ m_pSh->SelectObj(aPnt, ( rMEvt.IsShift() &&
+ m_pSh->IsSelFrmMode() ) ? SW_ADD_SELECT : 0 );
+ else
+ {
+ m_pView->LeaveDrawCreate();
+ if (m_pSh->IsSelFrmMode())
+ m_pSh->LeaveSelFrmMode();
+ }
+ m_pView->NoRotate();
+
+ bReturn = sal_True;
+ }
+ }
+ }
+ else
+ {
+ // BEZIER_EDITOR
+ if ( pSdrView->IsAction() )
+ {
+ if ( pSdrView->IsInsObjPoint() )
+ bReturn = pSdrView->EndInsObjPoint(SDRCREATE_FORCEEND);
+ else if (pSdrView->IsMarkPoints() )
+ bReturn = pSdrView->EndMarkPoints();
+ else
+ {
+ pSdrView->EndAction();
+ bReturn = sal_True;
+ }
+ m_pWin->SetDrawAction(sal_False);
+
+ if (aPnt == m_aStartPos)
+ {
+ if (!m_pSh->IsObjSelectable(aPnt))
+ m_pSh->SelectObj(Point(LONG_MAX, LONG_MAX));
+ else if (!bReturn)
+ {
+ if (!rMEvt.IsShift())
+ pSdrView->UnmarkAllPoints();
+ m_pSh->SelectObj(aPnt, (rMEvt.IsShift() &&
+ m_pSh->IsSelFrmMode()) ? SW_ADD_SELECT :0);
+ }
+
+ if (!m_pSh->IsObjSelected())
+ {
+ m_pView->LeaveDrawCreate(); // Switch to selection mode
+
+ m_pSh->GetView().GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW);
+
+ if (m_pSh->IsSelFrmMode())
+ m_pSh->LeaveSelFrmMode();
+ }
+ m_pView->NoRotate();
+
+ bCheckShell = true; // if necessary turn on BezierShell
+ }
+ }
+
+ SetDrawPointer();
+
+ if (!m_pSh->IsObjSelected() && !m_pWin->IsDrawAction())
+ {
+ m_pView->LeaveDrawCreate();
+ if (m_pSh->IsSelFrmMode())
+ m_pSh->LeaveSelFrmMode();
+
+ m_pView->NoRotate();
+ bReturn = sal_True;
+ }
+ }
+ }
+
+ if (bCheckShell)
+ m_pView->AttrChangedNotify( m_pSh ); // if necessary turn on BezierShell
+
+ //!!!!!!!!!! Attention suicide !!!!!!!!!!! Everything should be renewed once
+ if ( bAutoCap )
+ m_pView->AutoCaption(FRAME_CAP); //Can currently only be FRAME, otherwise convert
+ // to enums
+ return (bReturn);
+}
+
+void SwDrawBase::Activate(const sal_uInt16 nSlot)
+{
+ SetSlotId(nSlot);
+ SdrView *pSdrView = m_pSh->GetDrawView();
+
+ pSdrView->SetCurrentObj( static_cast< sal_uInt16 >(m_pWin->GetSdrDrawMode()) );
+ pSdrView->SetEditMode(sal_False);
+
+ SetDrawPointer();
+ m_pSh->NoEdit();
+}
+
+void SwDrawBase::Deactivate()
+{
+ SdrView *pSdrView = m_pSh->GetDrawView();
+ pSdrView->SetOrtho(false);
+ pSdrView->SetAngleSnapEnabled(sal_False);
+
+ if (m_pWin->IsDrawAction() && m_pSh->IsDrawCreate())
+ m_pSh->BreakCreate();
+
+ m_pWin->SetDrawAction(sal_False);
+
+ m_pWin->ReleaseMouse();
+ bNoInterrupt = false;
+
+ if(m_pWin->GetApplyTemplate())
+ m_pWin->SetApplyTemplate(SwApplyTemplate());
+ m_pSh->GetView().GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW);
+}
+
+// Process keyboard events
+
+// If a KeyEvent is processed then the return value is sal_True, otherwise
+// Sal_False.
+
+sal_Bool SwDrawBase::KeyInput(const KeyEvent& rKEvt)
+{
+ sal_Bool bReturn = sal_False;
+ sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
+
+ switch (nCode)
+ {
+ case KEY_ESCAPE:
+ {
+ if (m_pWin->IsDrawAction())
+ {
+ BreakCreate();
+ m_pView->LeaveDrawCreate();
+ }
+
+ bReturn = sal_True;
+ }
+ break;
+
+ case KEY_DELETE:
+ {
+ m_pSh->DelSelectedObj();
+ bReturn = sal_True;
+ }
+ break;
+
+ case KEY_UP:
+ case KEY_DOWN:
+ case KEY_LEFT:
+ case KEY_RIGHT:
+ {
+ SdrView *pSdrView = m_pSh->GetDrawView();
+
+ if (!pSdrView->IsTextEdit())
+ {
+ long nX = 0;
+ long nY = 0;
+
+ if (nCode == KEY_UP)
+ {
+ // Scroll to top
+ nX = 0;
+ nY =-1;
+ }
+ else if (nCode == KEY_DOWN)
+ {
+ // Scroll down
+ nX = 0;
+ nY = 1;
+ }
+ else if (nCode == KEY_LEFT)
+ {
+ // Scroll left
+ nX =-1;
+ nY = 0;
+ }
+ else if (nCode == KEY_RIGHT)
+ {
+ // Scroll right
+ nX = 1;
+ nY = 0;
+ }
+
+ if (pSdrView->AreObjectsMarked() && rKEvt.GetKeyCode().IsMod2())
+ {
+ // Move objects
+ nX *= 100;
+ nY *= 100;
+ pSdrView->MoveAllMarked(Size(nX, nY));
+ }
+
+ bReturn = sal_True;
+ }
+ }
+ break;
+ }
+
+ return (bReturn);
+}
+
+// Process keyboard events
+
+// If a KeyEvent is processed then the return value is sal_True, otherwise
+// Sal_False.
+
+void SwDrawBase::BreakCreate()
+{
+ m_pSh->BreakCreate();
+ m_pWin->SetDrawAction(sal_False);
+ m_pWin->ReleaseMouse();
+
+ Deactivate();
+}
+
+void SwDrawBase::SetDrawPointer()
+{
+ SdrView *pSdrView = m_pSh->GetDrawView();
+ Point aPnt(m_pWin->OutputToScreenPixel(m_pWin->GetPointerPosPixel()));
+ aPnt = m_pWin->PixelToLogic(m_pWin->ScreenToOutputPixel(aPnt));
+ const Pointer aPointTyp = pSdrView->GetPreferredPointer(aPnt, m_pSh->GetOut());
+ const Pointer aDrawPt(aPointTyp);
+ m_pWin->SetPointer(aDrawPt);
+}
+
+// If necessary switch into selection mode
+
+void SwDrawBase::EnterSelectMode(const MouseEvent& rMEvt)
+{
+ m_pWin->SetDrawAction(sal_False);
+
+ if (!m_pSh->IsObjSelected() && !m_pWin->IsDrawAction())
+ {
+ Point aPnt(m_pWin->PixelToLogic(rMEvt.GetPosPixel()));
+
+ if (m_pSh->IsObjSelectable(aPnt))
+ {
+ m_pSh->SelectObj(aPnt);
+ if (rMEvt.GetModifier() == KEY_SHIFT || !m_pSh->IsObjSelected())
+ {
+ m_pView->LeaveDrawCreate(); // Switch to selection mode
+
+ m_pSh->GetView().GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW);
+ }
+ }
+ else
+ {
+ m_pView->LeaveDrawCreate();
+ if (m_pSh->IsSelFrmMode())
+ m_pSh->LeaveSelFrmMode();
+ }
+ m_pView->NoRotate();
+ }
+}
+
+void SwDrawBase::CreateDefaultObject()
+{
+ Point aStartPos = GetDefaultCenterPos();
+ Point aEndPos(aStartPos);
+ aStartPos.X() -= 8 * MM50;
+ aStartPos.Y() -= 4 * MM50;
+ aEndPos.X() += 8 * MM50;
+ aEndPos.Y() += 4 * MM50;
+ Rectangle aRect(aStartPos, aEndPos);
+ m_pSh->CreateDefaultShape( static_cast< sal_uInt16 >(m_pWin->GetSdrDrawMode()), aRect, m_nSlotId);
+}
+
+Point SwDrawBase::GetDefaultCenterPos()
+{
+ Size aDocSz(m_pSh->GetDocSize());
+ const SwRect& rVisArea = m_pSh->VisArea();
+ Point aStartPos = rVisArea.Center();
+ if(rVisArea.Width() > aDocSz.Width())
+ aStartPos.X() = aDocSz.Width() / 2 + rVisArea.Left();
+ if(rVisArea.Height() > aDocSz.Height())
+ aStartPos.Y() = aDocSz.Height() / 2 + rVisArea.Top();
+ return aStartPos;
+}
+
+// #i33136#
+bool SwDrawBase::doConstructOrthogonal() const
+{
+ return false;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/ribbar/dselect.cxx b/sw/source/core/uibase/ribbar/dselect.cxx
new file mode 100644
index 000000000000..91ad444ccf0b
--- /dev/null
+++ b/sw/source/core/uibase/ribbar/dselect.cxx
@@ -0,0 +1,72 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <sfx2/bindings.hxx>
+#include "view.hxx"
+#include "edtwin.hxx"
+#include "wrtsh.hxx"
+#include "cmdid.h"
+#include "drawbase.hxx"
+#include "dselect.hxx"
+
+DrawSelection::DrawSelection(SwWrtShell* pWrtShell, SwEditWin* pEditWin, SwView* pSwView) :
+ SwDrawBase(pWrtShell, pEditWin, pSwView)
+{
+ m_bCreateObj = false;
+}
+
+// Process keyboard events
+
+// If a KeyEvent is processed then the return value is sal_True, otherwise
+// Sal_False.
+
+sal_Bool DrawSelection::KeyInput(const KeyEvent& rKEvt)
+{
+ sal_Bool bReturn = sal_False;
+
+ switch (rKEvt.GetKeyCode().GetCode())
+ {
+ case KEY_ESCAPE:
+ {
+ if (m_pWin->IsDrawAction())
+ {
+ m_pSh->BreakMark();
+ m_pWin->ReleaseMouse();
+ }
+ bReturn = sal_True;
+ }
+ break;
+ }
+
+ if (!bReturn)
+ bReturn = SwDrawBase::KeyInput(rKEvt);
+
+ return (bReturn);
+}
+
+void DrawSelection::Activate(const sal_uInt16 nSlotId)
+{
+ m_pWin->SetSdrDrawMode(OBJ_NONE);
+ m_pWin->SetObjectSelect( sal_True );
+ SwDrawBase::Activate(nSlotId);
+
+ m_pSh->GetView().GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/ribbar/inputwin.cxx b/sw/source/core/uibase/ribbar/inputwin.cxx
new file mode 100644
index 000000000000..aa1f46ab5598
--- /dev/null
+++ b/sw/source/core/uibase/ribbar/inputwin.cxx
@@ -0,0 +1,636 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "sal/config.h"
+
+#include <comphelper/string.hxx>
+#include <officecfg/Office/Common.hxx>
+#include <tools/gen.hxx>
+#include <sfx2/imgmgr.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svx/ruler.hxx>
+#include <svl/zforlist.hxx>
+#include <svl/stritem.hxx>
+#include <vcl/settings.hxx>
+
+#include "swtypes.hxx"
+#include "cmdid.h"
+#include "swmodule.hxx"
+#include "wrtsh.hxx"
+#include "view.hxx"
+#include "calc.hxx"
+#include "inputwin.hxx"
+#include "fldbas.hxx"
+#include "fldmgr.hxx"
+#include "frmfmt.hxx"
+#include "cellatr.hxx"
+#include "edtwin.hxx"
+#include "helpid.h"
+#include "access.hrc"
+
+// Only for the UpdateRange: Delete the box in which the stacked cursor is positioned.
+#include "pam.hxx"
+
+#include "swundo.hxx"
+#include "ribbar.hrc"
+#include "inputwin.hrc"
+
+#include <IDocumentContentOperations.hxx>
+
+SFX_IMPL_POS_CHILDWINDOW_WITHID( SwInputChild, FN_EDIT_FORMULA, SFX_OBJECTBAR_OBJECT )
+
+SwInputWindow::SwInputWindow( Window* pParent, SfxBindings* pBind )
+ : ToolBox( pParent , SW_RES( RID_TBX_FORMULA )),
+ aPos( this, SW_RES(ED_POS)),
+ aEdit( this, WB_3DLOOK|WB_TABSTOP|WB_BORDER|WB_NOHIDESELECTION),
+ aPopMenu( SW_RES(MN_CALC_POPUP)),
+ pMgr(0),
+ pWrtShell(0),
+ pView(0),
+ pBindings(pBind),
+ aAktTableName(aEmptyOUStr)
+ , m_bDoesUndo(true)
+ , m_bResetUndo(false)
+ , m_bCallUndo(false)
+{
+ bFirst = sal_True;
+ bActive = bIsTable = bDelSel = sal_False;
+
+ FreeResource();
+
+ aEdit.SetSizePixel( aEdit.CalcMinimumSize() );
+
+ SfxImageManager* pManager = SfxImageManager::GetImageManager( SW_MOD() );
+ pManager->RegisterToolBox(this);
+
+ pView = ::GetActiveView();
+ pWrtShell = pView ? pView->GetWrtShellPtr() : 0;
+
+ InsertWindow( ED_POS, &aPos, 0, 0);
+ SetItemText(ED_POS, SW_RESSTR(STR_ACCESS_FORMULA_TYPE));
+ aPos.SetAccessibleName(SW_RESSTR(STR_ACCESS_FORMULA_TYPE));
+ SetAccessibleName(SW_RESSTR(STR_ACCESS_FORMULA_TOOLBAR));
+ InsertSeparator ( 1 );
+ InsertSeparator ();
+ InsertWindow( ED_FORMULA, &aEdit);
+ SetItemText(ED_FORMULA, SW_RESSTR(STR_ACCESS_FORMULA_TEXT));
+ aEdit.SetAccessibleName(SW_RESSTR(STR_ACCESS_FORMULA_TEXT));
+ SetHelpId(ED_FORMULA, HID_EDIT_FORMULA);
+
+ SetItemImage( FN_FORMULA_CALC, pManager->GetImage(FN_FORMULA_CALC ));
+ SetItemImage( FN_FORMULA_CANCEL, pManager->GetImage(FN_FORMULA_CANCEL ));
+ SetItemImage( FN_FORMULA_APPLY, pManager->GetImage(FN_FORMULA_APPLY ));
+
+ SetItemBits( FN_FORMULA_CALC, GetItemBits( FN_FORMULA_CALC ) | TIB_DROPDOWNONLY );
+ SetDropdownClickHdl( LINK( this, SwInputWindow, DropdownClickHdl ));
+
+ Size aSizeTbx = CalcWindowSizePixel();
+ Size aEditSize = aEdit.GetSizePixel();
+ Rectangle aItemRect( GetItemRect(FN_FORMULA_CALC) );
+ long nMaxHeight = (aEditSize.Height() > aItemRect.GetHeight()) ? aEditSize.Height() : aItemRect.GetHeight();
+ if( nMaxHeight+2 > aSizeTbx.Height() )
+ aSizeTbx.Height() = nMaxHeight+2;
+ Size aSize = GetSizePixel();
+ aSize.Height() = aSizeTbx.Height();
+ SetSizePixel( aSize );
+
+ // align edit and item vcentered
+ Size aPosSize = aPos.GetSizePixel();
+ aPosSize.Height() = nMaxHeight;
+ aEditSize.Height() = nMaxHeight;
+ Point aPosPos = aPos.GetPosPixel();
+ Point aEditPos = aEdit.GetPosPixel();
+ aPosPos.Y() = (aSize.Height() - nMaxHeight)/2 + 1;
+ aEditPos.Y() = (aSize.Height() - nMaxHeight)/2 + 1;
+ aPos.SetPosSizePixel( aPosPos, aPosSize );
+ aEdit.SetPosSizePixel( aEditPos, aEditSize );
+
+ aPopMenu.SetSelectHdl(LINK( this, SwInputWindow, MenuHdl ));
+}
+
+SwInputWindow::~SwInputWindow()
+{
+ SfxImageManager::GetImageManager( SW_MOD() )->ReleaseToolBox(this);
+
+ // wake rulers
+ if(pView)
+ {
+ pView->GetHRuler().SetActive( sal_True );
+ pView->GetVRuler().SetActive( sal_True );
+ }
+ delete pMgr;
+ if(pWrtShell)
+ pWrtShell->EndSelTblCells();
+
+ CleanupUglyHackWithUndo();
+}
+
+void SwInputWindow::CleanupUglyHackWithUndo()
+{
+ if (m_bResetUndo)
+ {
+ if (pWrtShell)
+ {
+ DelBoxCntnt();
+ pWrtShell->DoUndo(m_bDoesUndo);
+ if (m_bCallUndo)
+ {
+ pWrtShell->Undo();
+ }
+ }
+ m_bResetUndo = false; // #i117122# once is enough :)
+ }
+}
+
+void SwInputWindow::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ if ( rDCEvt.GetType() == DATACHANGED_SETTINGS && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ {
+ // update item images
+ SwModule *pMod = SW_MOD();
+ SfxImageManager *pImgMgr = SfxImageManager::GetImageManager( pMod );
+ SetItemImage( FN_FORMULA_CALC, pImgMgr->GetImage(FN_FORMULA_CALC ));
+ SetItemImage( FN_FORMULA_CANCEL, pImgMgr->GetImage(FN_FORMULA_CANCEL ));
+ SetItemImage( FN_FORMULA_APPLY, pImgMgr->GetImage(FN_FORMULA_APPLY ));
+ }
+
+ ToolBox::DataChanged( rDCEvt );
+}
+
+void SwInputWindow::Resize()
+{
+ ToolBox::Resize();
+
+ long nWidth = GetSizePixel().Width();
+ long nLeft = aEdit.GetPosPixel().X();
+ Size aEditSize = aEdit.GetSizePixel();
+
+ aEditSize.Width() = std::max( ((long)(nWidth - nLeft - 5)), (long)0 );
+ aEdit.SetSizePixel( aEditSize );
+ aEdit.Invalidate();
+}
+
+void SwInputWindow::ShowWin()
+{
+ bIsTable = sal_False;
+ // stop rulers
+ if(pView)
+ {
+ pView->GetHRuler().SetActive( sal_False );
+ pView->GetVRuler().SetActive( sal_False );
+
+ OSL_ENSURE(pWrtShell, "no WrtShell!");
+ // Cursor in table
+ bIsTable = pWrtShell->IsCrsrInTbl() ? sal_True : sal_False;
+
+ if( bFirst )
+ pWrtShell->SelTblCells( LINK( this, SwInputWindow,
+ SelTblCellsNotify) );
+ if( bIsTable )
+ {
+ const OUString& rPos = pWrtShell->GetBoxNms();
+ sal_Int32 nPos = 0;
+ short nSrch = -1;
+ while( (nPos = rPos.indexOf( ':',nPos + 1 ) ) != -1 )
+ nSrch = (short) nPos;
+ aPos.SetText( rPos.copy( ++nSrch ) );
+ aAktTableName = pWrtShell->GetTableFmt()->GetName();
+ }
+ else
+ aPos.SetText(SW_RESSTR(STR_TBL_FORMULA));
+
+ // Edit current field
+ OSL_ENSURE(pMgr == 0, "FieldManager not deleted");
+ pMgr = new SwFldMgr;
+
+ // Formular should always begin with "=" , so set here
+ OUString sEdit('=');
+ if( pMgr->GetCurFld() && TYP_FORMELFLD == pMgr->GetCurTypeId() )
+ {
+ sEdit += pMgr->GetCurFldPar2();
+ }
+ else if( bFirst )
+ {
+ if( bIsTable )
+ {
+ m_bResetUndo = true;
+ SAL_WARN_IF(
+ officecfg::Office::Common::Undo::Steps::get() <= 0,
+ "sw", "/org.openoffice.Office.Common/Undo/Steps <= 0");
+
+ m_bDoesUndo = pWrtShell->DoesUndo();
+ if( !m_bDoesUndo )
+ {
+ pWrtShell->DoUndo( sal_True );
+ }
+
+ if( !pWrtShell->SwCrsrShell::HasSelection() )
+ {
+ pWrtShell->MoveSection( fnSectionCurr, fnSectionStart );
+ pWrtShell->SetMark();
+ pWrtShell->MoveSection( fnSectionCurr, fnSectionEnd );
+ }
+ if( pWrtShell->SwCrsrShell::HasSelection() )
+ {
+ pWrtShell->StartUndo( UNDO_DELETE );
+ pWrtShell->Delete();
+ if( 0 != pWrtShell->EndUndo( UNDO_DELETE ))
+ {
+ m_bCallUndo = true;
+ }
+ }
+ pWrtShell->DoUndo(false);
+
+ SfxItemSet aSet( pWrtShell->GetAttrPool(), RES_BOXATR_FORMULA, RES_BOXATR_FORMULA );
+ if( pWrtShell->GetTblBoxFormulaAttrs( aSet ))
+ sEdit += ((SwTblBoxFormula&)aSet.Get( RES_BOXATR_FORMULA )).GetFormula();
+ }
+ }
+
+ if( bFirst )
+ {
+ // Set WrtShell flags correctly
+ pWrtShell->SttSelect();
+ pWrtShell->EndSelect();
+ }
+
+ bFirst = sal_False;
+
+ aEdit.SetModifyHdl( LINK( this, SwInputWindow, ModifyHdl ));
+
+ aEdit.SetText( sEdit );
+ aEdit.SetSelection( Selection( sEdit.getLength(), sEdit.getLength() ) );
+ sOldFml = sEdit;
+
+ aEdit.Invalidate();
+ aEdit.Update();
+ aEdit.GrabFocus();
+ // For input cut the UserInterface
+
+ pView->GetEditWin().LockKeyInput(sal_True);
+ pView->GetViewFrame()->GetDispatcher()->Lock(sal_True);
+ pWrtShell->Push();
+ }
+ ToolBox::Show();
+}
+
+IMPL_LINK( SwInputWindow, MenuHdl, Menu *, pMenu )
+{
+static const char * const aStrArr[] = {
+ sCalc_Phd,
+ sCalc_Sqrt,
+ sCalc_Or,
+ sCalc_Xor,
+ sCalc_And,
+ sCalc_Not,
+ sCalc_Eq,
+ sCalc_Neq,
+ sCalc_Leq,
+ sCalc_Geq,
+ sCalc_L,
+ sCalc_G,
+ sCalc_Sum,
+ sCalc_Mean,
+ sCalc_Min,
+ sCalc_Max,
+ sCalc_Sin,
+ sCalc_Cos,
+ sCalc_Tan,
+ sCalc_Asin,
+ sCalc_Acos,
+ sCalc_Atan,
+ sCalc_Pow,
+ "|",
+ sCalc_Round
+};
+
+ sal_uInt16 nId = pMenu->GetCurItemId();
+ if ( nId <= MN_CALC_ROUND )
+ {
+ OUString aTmp( OUString::createFromAscii(aStrArr[nId - 1]) );
+ aTmp += " ";
+ aEdit.ReplaceSelected( aTmp );
+ }
+ return 0;
+}
+
+IMPL_LINK_NOARG(SwInputWindow, DropdownClickHdl)
+{
+ sal_uInt16 nCurID = GetCurItemId();
+ EndSelection(); // reset back CurItemId !
+ switch ( nCurID )
+ {
+ case FN_FORMULA_CALC :
+ {
+ aPopMenu.Execute( this, GetItemRect( FN_FORMULA_CALC ), POPUPMENU_NOMOUSEUPCLOSE );
+ break;
+ default:
+ break;
+ }
+ }
+
+ return sal_True;
+}
+
+void SwInputWindow::Click( )
+{
+ sal_uInt16 nCurID = GetCurItemId();
+ EndSelection(); // reset back CurItemId !
+ switch ( nCurID )
+ {
+ case FN_FORMULA_CANCEL:
+ {
+ CancelFormula();
+ }
+ break;
+ case FN_FORMULA_APPLY:
+ {
+ ApplyFormula();
+ }
+ break;
+ }
+}
+
+void SwInputWindow::ApplyFormula()
+{
+ pView->GetViewFrame()->GetDispatcher()->Lock(sal_False);
+ pView->GetEditWin().LockKeyInput(sal_False);
+ CleanupUglyHackWithUndo();
+ pWrtShell->Pop( sal_False );
+
+ // Formular should always begin with "=", so remove it here again
+ OUString sEdit(comphelper::string::strip(aEdit.GetText(), ' '));
+ if( !sEdit.isEmpty() && '=' == sEdit[0] )
+ sEdit = sEdit.copy( 1 );
+ SfxStringItem aParam(FN_EDIT_FORMULA, sEdit);
+
+ pWrtShell->EndSelTblCells();
+ pView->GetEditWin().GrabFocus();
+ const SfxPoolItem* aArgs[2];
+ aArgs[0] = &aParam;
+ aArgs[1] = 0;
+ pView->GetViewFrame()->GetBindings().Execute( FN_EDIT_FORMULA, aArgs, 0, SFX_CALLMODE_ASYNCHRON );
+}
+
+void SwInputWindow::CancelFormula()
+{
+ if(pView)
+ {
+ pView->GetViewFrame()->GetDispatcher()->Lock( sal_False );
+ pView->GetEditWin().LockKeyInput(sal_False);
+ CleanupUglyHackWithUndo();
+ pWrtShell->Pop( sal_False );
+
+ if( bDelSel )
+ pWrtShell->EnterStdMode();
+
+ pWrtShell->EndSelTblCells();
+
+ pView->GetEditWin().GrabFocus();
+
+ pView->GetViewFrame()->GetDispatcher()->Execute( FN_EDIT_FORMULA, SFX_CALLMODE_ASYNCHRON);
+ }
+}
+
+const sal_Unicode CH_LRE = 0x202a;
+const sal_Unicode CH_PDF = 0x202c;
+
+IMPL_LINK( SwInputWindow, SelTblCellsNotify, SwWrtShell *, pCaller )
+{
+ if(bIsTable)
+ {
+ SwFrmFmt* pTblFmt = pCaller->GetTableFmt();
+ OUString sBoxNms( pCaller->GetBoxNms() );
+ OUString sTblNm;
+ if( pTblFmt && aAktTableName != pTblFmt->GetName() )
+ sTblNm = pTblFmt->GetName();
+
+ aEdit.UpdateRange( sBoxNms, sTblNm );
+
+ OUString sNew;
+ sNew += OUString(CH_LRE);
+ sNew += aEdit.GetText();
+ sNew += OUString(CH_PDF);
+
+ if( sNew != sOldFml )
+ {
+ // The WrtShell is in the table selection,
+ // then cancel the table selection otherwise, the cursor is
+ // positioned "in the forest" and the live update does not work!
+ pWrtShell->StartAllAction();
+
+ SwPaM aPam( *pWrtShell->GetStkCrsr()->GetPoint() );
+ aPam.Move( fnMoveBackward, fnGoSection );
+ aPam.SetMark();
+ aPam.Move( fnMoveForward, fnGoSection );
+
+ IDocumentContentOperations* pIDCO = pWrtShell->getIDocumentContentOperations();
+ pIDCO->DeleteRange( aPam );
+ pIDCO->InsertString( aPam, sNew );
+ pWrtShell->EndAllAction();
+ sOldFml = sNew;
+ }
+ }
+ else
+ aEdit.GrabFocus();
+ return 0;
+}
+
+void SwInputWindow::SetFormula( const OUString& rFormula, sal_Bool bDelFlag )
+{
+ OUString sEdit('=');
+ if( !rFormula.isEmpty() )
+ {
+ if( '=' == rFormula[0] )
+ sEdit = rFormula;
+ else
+ sEdit += rFormula;
+ }
+ aEdit.SetText( sEdit );
+ aEdit.SetSelection( Selection( sEdit.getLength(), sEdit.getLength() ) );
+ aEdit.Invalidate();
+ bDelSel = bDelFlag;
+}
+
+IMPL_LINK_NOARG(SwInputWindow, ModifyHdl)
+{
+ if (bIsTable && m_bResetUndo)
+ {
+ pWrtShell->StartAllAction();
+ DelBoxCntnt();
+ OUString sNew;
+ sNew += OUString(CH_LRE);
+ sNew += aEdit.GetText();
+ sNew += OUString(CH_PDF);
+ pWrtShell->SwEditShell::Insert2( sNew );
+ pWrtShell->EndAllAction();
+ sOldFml = sNew;
+ }
+ return 0;
+}
+
+void SwInputWindow::DelBoxCntnt()
+{
+ if( bIsTable )
+ {
+ pWrtShell->StartAllAction();
+ pWrtShell->ClearMark();
+ pWrtShell->Pop( sal_False );
+ pWrtShell->Push();
+ pWrtShell->MoveSection( fnSectionCurr, fnSectionStart );
+ pWrtShell->SetMark();
+ pWrtShell->MoveSection( fnSectionCurr, fnSectionEnd );
+ pWrtShell->SwEditShell::Delete();
+ pWrtShell->EndAllAction();
+ }
+}
+
+void InputEdit::KeyInput(const KeyEvent& rEvent)
+{
+ const KeyCode aCode = rEvent.GetKeyCode();
+ if(aCode == KEY_RETURN || aCode == KEY_F2 )
+ ((SwInputWindow*)GetParent())->ApplyFormula();
+ else if(aCode == KEY_ESCAPE )
+ ((SwInputWindow*)GetParent())->CancelFormula();
+ else
+ Edit::KeyInput(rEvent);
+}
+
+void InputEdit::UpdateRange(const OUString& rBoxes,
+ const OUString& rName )
+{
+ if( rBoxes.isEmpty() )
+ {
+ GrabFocus();
+ return;
+ }
+ const sal_Unicode cOpen = '<', cClose = '>',
+ cOpenBracket = '(';
+ OUString aPrefix = rName;
+ if(!rName.isEmpty())
+ aPrefix += ".";
+ OUString aBoxes = aPrefix;
+ aBoxes += rBoxes;
+ Selection aSelection(GetSelection());
+ sal_uInt16 nSel = (sal_uInt16) aSelection.Len();
+ // OS: The following expression ensures that in the overwrite mode,
+ // the selected closing parenthesis will be not deleted.
+ if( nSel && ( nSel > 1 ||
+ GetText()[ (sal_uInt16)aSelection.Min() ] != cClose ))
+ Cut();
+ else
+ aSelection.Max() = aSelection.Min();
+ OUString aActText(GetText());
+ const sal_uInt16 nLen = aActText.getLength();
+ if( !nLen )
+ {
+ OUString aStr = OUStringBuffer().
+ append(cOpen).append(aBoxes).append(cClose).
+ makeStringAndClear();
+ SetText(aStr);
+ sal_Int32 nPos = aStr.indexOf( cClose );
+ OSL_ENSURE(nPos != -1, "delimiter not found");
+ ++nPos;
+ SetSelection( Selection( nPos, nPos ));
+ }
+ else
+ {
+ bool bFound = false;
+ sal_Unicode cCh;
+ sal_uInt16 nPos, nEndPos = 0, nStartPos = (sal_uInt16) aSelection.Min();
+ if( nStartPos-- )
+ {
+ do {
+ if( cOpen == (cCh = aActText[ nStartPos ] ) ||
+ cOpenBracket == cCh )
+ {
+ bFound = cCh == cOpen;
+ break;
+ }
+ } while( nStartPos-- > 0 );
+ }
+ if( bFound )
+ {
+ bFound = false;
+ nEndPos = nStartPos;
+ while( nEndPos < nLen )
+ {
+ if( cClose == (cCh = aActText[ nEndPos ]))
+ {
+ bFound = true;
+ break;
+ }
+ ++nEndPos;
+ }
+ // Only if the current position lies in the range or right behind.
+ if( bFound && !( nStartPos < (sal_uInt16)aSelection.Max() &&
+ (sal_uInt16)aSelection.Max() <= nEndPos + 1 ))
+ bFound = false;
+ }
+ if( bFound )
+ {
+ nPos = ++nStartPos + 1; // We want behind
+ aActText = aActText.replaceAt( nStartPos, nEndPos - nStartPos, aBoxes );
+ nPos = nPos + aBoxes.getLength();
+ }
+ else
+ {
+ OUString aTmp = OUStringBuffer().
+ append(cOpen).append(aBoxes).append(cClose).
+ makeStringAndClear();
+ nPos = (sal_uInt16)aSelection.Min();
+ aActText = aActText.replaceAt( nPos, 0, aTmp );
+ nPos = nPos + aTmp.getLength();
+ }
+ if( GetText() != OUString(aActText) )
+ {
+ SetText( aActText );
+ SetSelection( Selection( nPos, nPos ) );
+ }
+ }
+ GrabFocus();
+
+}
+
+SwInputChild::SwInputChild(Window* _pParent,
+ sal_uInt16 nId,
+ SfxBindings* pBindings,
+ SfxChildWinInfo* ) :
+ SfxChildWindow( _pParent, nId )
+{
+ pDispatch = pBindings->GetDispatcher();
+ pWindow = new SwInputWindow( _pParent, pBindings );
+ ((SwInputWindow*)pWindow)->ShowWin();
+ eChildAlignment = SFX_ALIGN_LOWESTTOP;
+}
+
+SwInputChild::~SwInputChild()
+{
+ if(pDispatch)
+ pDispatch->Lock(sal_False);
+}
+
+SfxChildWinInfo SwInputChild::GetInfo() const
+{
+ SfxChildWinInfo aInfo = SfxChildWindow::GetInfo(); \
+ return aInfo;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/ribbar/inputwin.hrc b/sw/source/core/uibase/ribbar/inputwin.hrc
new file mode 100644
index 000000000000..5e168a0d0552
--- /dev/null
+++ b/sw/source/core/uibase/ribbar/inputwin.hrc
@@ -0,0 +1,62 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef _INPUTWIN_HRC
+#define _INPUTWIN_HRC
+
+
+//PopupMenu Id's
+#define MN_CALC_PHD 1
+#define MN_CALC_SQRT 2
+#define MN_CALC_OR 3
+#define MN_CALC_XOR 4
+#define MN_CALC_AND 5
+#define MN_CALC_NOT 6
+#define MN_CALC_EQ 7
+#define MN_CALC_NEQ 8
+#define MN_CALC_LEQ 9
+#define MN_CALC_GEQ 10
+#define MN_CALC_LES 11
+#define MN_CALC_GRE 12
+#define MN_CALC_SUM 13
+#define MN_CALC_MEAN 14
+#define MN_CALC_MIN 15
+#define MN_CALC_MAX 16
+#define MN_CALC_SIN 17
+#define MN_CALC_COS 18
+#define MN_CALC_TAN 19
+#define MN_CALC_ASIN 20
+#define MN_CALC_ACOS 21
+#define MN_CALC_ATAN 22
+#define MN_CALC_POW 23
+#define MN_CALC_LISTSEP 24
+#define MN_CALC_ROUND 25
+
+#define MN_POP_OPS 29
+#define MN_POP_STATISTICS 30
+#define MN_POP_FUNC 31
+
+#define ED_POS 2
+#define ED_FORMULA 3
+
+#define STR_ED_POS 1
+#define STR_ED_FORMULA 2
+#define STR_TOOLBAR_FORMULA 35
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/ribbar/inputwin.src b/sw/source/core/uibase/ribbar/inputwin.src
new file mode 100644
index 000000000000..d228bbeed267
--- /dev/null
+++ b/sw/source/core/uibase/ribbar/inputwin.src
@@ -0,0 +1,290 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+/* HelpID resource file */
+/* HelpID resource file */
+
+#include "cmdid.h"
+#include "helpid.h"
+#include "globals.hrc"
+#include "ribbar.hrc"
+#include "inputwin.hrc"
+#include "access.hrc"
+
+ToolBox RID_TBX_FORMULA
+{
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( 600 , 14 ) ;
+ HelpID = HID_CALC_TOOLBOX ;
+ SVLook = TRUE ;
+ Border = TRUE ;
+ ItemList =
+ {
+ ToolBoxItem
+ {
+ Identifier = FN_FORMULA_CALC ;
+ HelpId = HID_TBX_FORMULA_CALC ;
+ DropDown = TRUE ;
+ Text [ en-US ] = "Formula" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = FN_FORMULA_CANCEL ;
+ HelpId = HID_TBX_FORMULA_CANCEL ;
+ Text [ en-US ] = "Cancel" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = FN_FORMULA_APPLY ;
+ HelpId = HID_TBX_FORMULA_APPLY ;
+ Text [ en-US ] = "Apply" ;
+ };
+ };
+ Edit ED_POS
+ {
+ Border = TRUE ;
+ Size = MAP_APPFONT ( 45 , 11 ) ;
+ ReadOnly = TRUE ;
+ SVLook = TRUE ;
+ Center = TRUE ;
+ };
+ Edit ED_FORMULA
+ {
+ Border = TRUE ;
+ TabStop = TRUE ;
+ Size = MAP_APPFONT ( 500 , 11 ) ;
+ SVLook = TRUE ;
+ };
+};
+Menu MN_CALC_POPUP
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = MN_CALC_SUM ;
+ HelpID = HID_MN_CALC_SUM ;
+ Text [ en-US ] = "Sum" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_CALC_ROUND ;
+ HelpID = HID_MN_CALC_ROUND ;
+ Text [ en-US ] = "Round" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_CALC_PHD ;
+ HelpID = HID_MN_CALC_PHD ;
+ Text [ en-US ] = "Percent" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_CALC_SQRT ;
+ HelpID = HID_MN_CALC_SQRT ;
+ Text [ en-US ] = "Square Root" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_CALC_POW ;
+ HelpID = HID_MN_CALC_POW ;
+ Text [ en-US ] = "Power" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_POP_OPS ;
+ HelpID = HID_MN_POP_OPS ;
+ Text [ en-US ] = "Operators" ;
+ SubMenu = Menu
+ {
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = MN_CALC_LISTSEP ;
+ HelpID = HID_MN_CALC_LISTSEP ;
+ Text [ en-US ] = "List Separator" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_CALC_EQ ;
+ HelpID = HID_MN_CALC_EQ ;
+ Text [ en-US ] = "Equal" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_CALC_NEQ ;
+ HelpID = HID_MN_CALC_NEQ ;
+ Text [ en-US ] = "Not Equal" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_CALC_LEQ ;
+ HelpID = HID_MN_CALC_LEQ ;
+ Text [ en-US ] = "Less Than or Equal" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_CALC_GEQ ;
+ HelpID = HID_MN_CALC_GEQ ;
+ Text [ en-US ] = "Greater Than or Equal" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_CALC_LES ;
+ HelpID = HID_MN_CALC_LES ;
+ Text [ en-US ] = "Less" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_CALC_GRE ;
+ HelpID = HID_MN_CALC_GRE ;
+ Text [ en-US ] = "Greater" ;
+ };
+ MenuItem
+ {
+ Separator = TRUE ;
+ };
+ MenuItem
+ {
+ Identifier = MN_CALC_OR ;
+ HelpID = HID_MN_CALC_OR ;
+ Text [ en-US ] = "Boolean Or" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_CALC_XOR ;
+ HelpID = HID_MN_CALC_XOR ;
+ Text [ en-US ] = "Boolean Xor" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_CALC_AND ;
+ HelpID = HID_MN_CALC_AND ;
+ Text [ en-US ] = "Boolean And" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_CALC_NOT ;
+ HelpID = HID_MN_CALC_NOT ;
+ Text [ en-US ] = "Boolean Not" ;
+ };
+ };
+ };
+ };
+ MenuItem
+ {
+ Identifier = MN_POP_STATISTICS ;
+ HelpID = HID_MN_POP_STATISTICS ;
+ Text [ en-US ] = "Statistical Functions" ;
+ SubMenu = Menu
+ {
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = MN_CALC_MEAN ;
+ HelpID = HID_MN_CALC_MEAN ;
+ Text [ en-US ] = "Mean" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_CALC_MIN ;
+ HelpID = HID_MN_CALC_MIN ;
+ Text [ en-US ] = "Minimum" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_CALC_MAX ;
+ HelpID = HID_MN_CALC_MAX ;
+ Text [ en-US ] = "Maximum" ;
+ };
+ };
+ };
+ };
+ MenuItem
+ {
+ Identifier = MN_POP_FUNC ;
+ HelpID = HID_MN_POP_FUNC ;
+ Text [ en-US ] = "Functions" ;
+ SubMenu = Menu
+ {
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = MN_CALC_SIN ;
+ HelpID = HID_MN_CALC_SIN ;
+ Text [ en-US ] = "Sine" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_CALC_COS ;
+ HelpID = HID_MN_CALC_COS ;
+ Text [ en-US ] = "Cosine" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_CALC_TAN ;
+ HelpID = HID_MN_CALC_TAN ;
+ Text [ en-US ] = "Tangent" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_CALC_ASIN ;
+ HelpID = HID_MN_CALC_ASIN ;
+ Text [ en-US ] = "Arcsine" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_CALC_ACOS ;
+ HelpID = HID_MN_CALC_ACOS ;
+ Text [ en-US ] = "Arccosine" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_CALC_ATAN ;
+ HelpID = HID_MN_CALC_ATAN ;
+ Text [ en-US ] = "Arctangent" ;
+ };
+ };
+ };
+ };
+ };
+};
+String STR_TBL_FORMULA
+{
+ Text [ en-US ] = "Text formula" ;
+};
+
+String STR_ACCESS_FORMULA_TOOLBAR
+{
+ Text [ en-US ] = "Formula Tool Bar" ;
+};
+
+String STR_ACCESS_FORMULA_TYPE
+{
+ Text [ en-US ] = "Formula Type" ;
+};
+
+String STR_ACCESS_FORMULA_TEXT
+{
+ Text [ en-US ] = "Formula Text" ;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/ribbar/tblctrl.cxx b/sw/source/core/uibase/ribbar/tblctrl.cxx
new file mode 100644
index 000000000000..2649d74e6951
--- /dev/null
+++ b/sw/source/core/uibase/ribbar/tblctrl.cxx
@@ -0,0 +1,55 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <svl/intitem.hxx>
+
+#include <vcl/toolbox.hxx>
+#include <sfx2/app.hxx>
+
+#include "cmdid.h"
+#include "swtypes.hxx"
+#include "tblctrl.hxx"
+
+SFX_IMPL_TOOLBOX_CONTROL( SwTableOptimizeCtrl, SfxUInt16Item );
+
+SwTableOptimizeCtrl::SwTableOptimizeCtrl(
+ sal_uInt16 nSlotId,
+ sal_uInt16 nId,
+ ToolBox& rTbx ) :
+ SfxToolBoxControl( nSlotId, nId, rTbx )
+{
+ rTbx.SetItemBits( nId, TIB_DROPDOWNONLY | rTbx.GetItemBits( nId ) );
+}
+
+SwTableOptimizeCtrl::~SwTableOptimizeCtrl()
+{
+}
+
+SfxPopupWindow* SwTableOptimizeCtrl::CreatePopupWindow()
+{
+ createAndPositionSubToolBar("private:resource/toolbar/optimizetablebar");
+ return NULL;
+}
+
+SfxPopupWindowType SwTableOptimizeCtrl::GetPopupWindowType() const
+{
+ return SFX_POPUPWINDOW_ONCLICK;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/ribbar/tbxanchr.cxx b/sw/source/core/uibase/ribbar/tbxanchr.cxx
new file mode 100644
index 000000000000..e90b3ab9905e
--- /dev/null
+++ b/sw/source/core/uibase/ribbar/tbxanchr.cxx
@@ -0,0 +1,124 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <string>
+#include <vcl/timer.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/htmlmode.hxx>
+#include <svl/intitem.hxx>
+#include <sfx2/dispatch.hxx>
+#include <vcl/toolbox.hxx>
+#include <sfx2/mnumgr.hxx>
+
+#include "cmdid.h"
+#include "docsh.hxx"
+#include "swtypes.hxx"
+#include "swmodule.hxx"
+#include "wrtsh.hxx"
+#include "view.hxx"
+#include "viewopt.hxx"
+#include "ribbar.hrc"
+#include "tbxanchr.hxx"
+
+SFX_IMPL_TOOLBOX_CONTROL(SwTbxAnchor, SfxUInt16Item);
+
+SwTbxAnchor::SwTbxAnchor( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
+ SfxToolBoxControl( nSlotId, nId, rTbx ),
+ nActAnchorId(0)
+{
+ rTbx.SetItemBits( nId, TIB_DROPDOWNONLY | rTbx.GetItemBits( nId ) );
+}
+
+ SwTbxAnchor::~SwTbxAnchor()
+{
+}
+
+void SwTbxAnchor::StateChanged( sal_uInt16 /*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)
+ nActAnchorId = pItem->GetValue();
+ }
+
+}
+
+SfxPopupWindow* SwTbxAnchor::CreatePopupWindow()
+{
+ SwTbxAnchor::Click();
+ return 0;
+}
+
+void SwTbxAnchor::Click()
+{
+ PopupMenu aPopMenu(SW_RES(MN_ANCHOR_POPUP));
+
+ SfxViewFrame* pViewFrame( 0 );
+ SfxDispatcher* pDispatch( 0 );
+ SfxViewShell* pCurSh( SfxViewShell::Current() );
+
+ if ( pCurSh )
+ {
+ pViewFrame = pCurSh->GetViewFrame();
+ if ( pViewFrame )
+ pDispatch = pViewFrame->GetDispatcher();
+ }
+
+ SwView* pActiveView = 0;
+ if(pViewFrame)
+ {
+ const TypeId aTypeId = TYPE(SwView);
+ SwView* pView = (SwView*)SfxViewShell::GetFirst(&aTypeId);
+ while( pView )
+ {
+ if(pView->GetViewFrame() == pViewFrame)
+ {
+ pActiveView = pView;
+ break;
+ }
+ pView = (SwView*)SfxViewShell::GetNext(*pView, &aTypeId);
+ }
+ }
+ if(!pActiveView)
+ {
+ OSL_FAIL("No active view found");
+ return;
+ }
+ SwWrtShell* pWrtShell = pActiveView->GetWrtShellPtr();
+ aPopMenu.EnableItem( FN_TOOL_ANCHOR_FRAME, 0 != pWrtShell->IsFlyInFly() );
+
+ Rectangle aRect(GetToolBox().GetItemRect(GetId()));
+
+ if (pWrtShell->IsInHeaderFooter())
+ aPopMenu.RemoveItem(aPopMenu.GetItemPos(FN_TOOL_ANCHOR_PAGE));
+
+ if (nActAnchorId)
+ aPopMenu.CheckItem(nActAnchorId);
+
+ sal_uInt16 nSlotId = aPopMenu.Execute(&GetToolBox(), aRect);
+ GetToolBox().EndSelection();
+
+ if (nSlotId)
+ pDispatch->Execute(nSlotId, SFX_CALLMODE_ASYNCHRON|SFX_CALLMODE_RECORD);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/ribbar/workctrl.cxx b/sw/source/core/uibase/ribbar/workctrl.cxx
new file mode 100644
index 000000000000..e1d58875f9ba
--- /dev/null
+++ b/sw/source/core/uibase/ribbar/workctrl.cxx
@@ -0,0 +1,775 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <string>
+#include <comphelper/string.hxx>
+#include <i18nutil/unicode.hxx>
+#include <svl/eitem.hxx>
+#include <sfx2/htmlmode.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/imagemgr.hxx>
+#include <swmodule.hxx>
+#include <view.hxx>
+#include <initui.hxx>
+#include <viewopt.hxx>
+#include <docsh.hxx>
+#include <gloshdl.hxx>
+#include <glosdoc.hxx>
+#include <gloslst.hxx>
+#include <workctrl.hxx>
+#include <workctrl.hrc>
+#include <cmdid.h>
+#include <helpid.h>
+#include <wrtsh.hxx>
+#include <svl/imageitm.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/settings.hxx>
+#include <rtl/ustring.hxx>
+#include "swabstdlg.hxx"
+#include <misc.hrc>
+
+#include <vcl/svapp.hxx>
+
+// Size check
+#define NAVI_ENTRIES 20
+#if NAVI_ENTRIES != NID_COUNT
+#error SwScrollNaviPopup-CTOR static array wrong size. Are new IDs added?
+#endif
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::frame;
+
+SFX_IMPL_TOOLBOX_CONTROL( SwTbxInsertCtrl, SfxImageItem);
+SFX_IMPL_TOOLBOX_CONTROL( SwTbxAutoTextCtrl, SfxVoidItem );
+SFX_IMPL_TOOLBOX_CONTROL( SwTbxFieldCtrl, SfxBoolItem );
+
+SwTbxInsertCtrl::SwTbxInsertCtrl(
+ sal_uInt16 nSlotId,
+ sal_uInt16 nId,
+ ToolBox& rTbx ) :
+ SfxToolBoxControl( nSlotId, nId, rTbx ),
+ nLastSlotId(FN_INSERT_CTRL == nSlotId ? FN_INSERT_TABLE : SID_INSERT_DIAGRAM)
+{
+ rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
+}
+
+SwTbxInsertCtrl::~SwTbxInsertCtrl()
+{
+}
+
+void SAL_CALL SwTbxInsertCtrl::update() throw (uno::RuntimeException, std::exception)
+{
+ ToolBox& rTbx = GetToolBox();
+ OUString aSlotURL = "slot:" + OUString::number( nLastSlotId);
+ Image aImage = GetImage( m_xFrame, aSlotURL, hasBigImages() );
+
+ rTbx.SetItemImage(GetId(), aImage);
+ rTbx.Invalidate();
+
+ SfxToolBoxControl::update();
+}
+
+void SwTbxInsertCtrl::StateChanged( sal_uInt16 /*nSID*/,
+ SfxItemState eState,
+ const SfxPoolItem* pState )
+{
+ sal_uInt16 nId = GetId();
+ GetToolBox().EnableItem( nId, (GetItemState(pState) != SFX_ITEM_DISABLED) );
+
+ if( eState == SFX_ITEM_AVAILABLE )
+ {
+ const SfxImageItem* pItem = PTR_CAST( SfxImageItem, pState );
+ if(pItem)
+ {
+ nLastSlotId = pItem->GetValue();
+ if( nLastSlotId )
+ nId = nLastSlotId;
+
+ OUString aSlotURL = "slot:" + OUString::number( nId);
+ ToolBox& rBox = GetToolBox();
+ Image aImage = GetImage( m_xFrame, aSlotURL, hasBigImages() );
+ rBox.SetItemImage(GetId(), aImage);
+ rBox.SetItemImageMirrorMode( GetId(), false );
+ rBox.SetItemImageAngle( GetId(), pItem->GetRotation() );
+ rBox.SetItemImageMirrorMode( GetId(), pItem->IsMirrored() );
+ }
+ }
+
+}
+
+SfxPopupWindow* SwTbxInsertCtrl::CreatePopupWindow()
+{
+ if(GetSlotId() == FN_INSERT_CTRL)
+ {
+ OUString aToolBarResStr( "private:resource/toolbar/insertbar" );
+ createAndPositionSubToolBar( aToolBarResStr );
+ }
+ else /* FN_INSERT_OBJ_CTRL */
+ {
+ OUString aToolBarResStr( "private:resource/toolbar/insertobjectbar" );
+ createAndPositionSubToolBar( aToolBarResStr );
+ }
+ return NULL;
+}
+
+SfxPopupWindowType SwTbxInsertCtrl::GetPopupWindowType() const
+{
+ return nLastSlotId ? SFX_POPUPWINDOW_ONTIMEOUT : SFX_POPUPWINDOW_ONCLICK;
+}
+
+void SwTbxInsertCtrl::Select( sal_Bool /*bMod1*/ )
+{
+ if( nLastSlotId )
+ {
+ SfxViewShell* pCurSh( SfxViewShell::Current() );
+ SfxDispatcher* pDispatch( 0 );
+
+ if ( pCurSh )
+ {
+ SfxViewFrame* pViewFrame = pCurSh->GetViewFrame();
+ if ( pViewFrame )
+ pDispatch = pViewFrame->GetDispatcher();
+ }
+
+ if ( pDispatch )
+ pDispatch->Execute(nLastSlotId);
+ }
+}
+
+SwTbxAutoTextCtrl::SwTbxAutoTextCtrl(
+ sal_uInt16 nSlotId,
+ sal_uInt16 nId,
+ ToolBox& rTbx ) :
+ SfxToolBoxControl( nSlotId, nId, rTbx ),
+ pPopup(0),
+ pView(0)
+{
+ rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
+}
+
+SwTbxAutoTextCtrl::~SwTbxAutoTextCtrl()
+{
+ DelPopup();
+}
+
+SfxPopupWindow* SwTbxAutoTextCtrl::CreatePopupWindow()
+{
+ pView = ::GetActiveView();
+ if(pView && !pView->GetDocShell()->IsReadOnly() &&
+ !pView->GetWrtShell().HasReadonlySel() )
+ {
+ ToolBox& rBox = GetToolBox();
+
+ Rectangle aItemRect( rBox.GetItemRect( GetId() ) );
+ Point aPt(rBox.OutputToScreenPixel(aItemRect.TopLeft()));
+ aPt.X() += aItemRect.GetWidth()/2;
+ aPt.Y() += aItemRect.GetHeight()/2;
+ if(pView)
+ {
+ Link aLnk = LINK(this, SwTbxAutoTextCtrl, PopupHdl);
+
+ pPopup = new PopupMenu;
+ SwGlossaryList* pGlossaryList = ::GetGlossaryList();
+ sal_uInt16 nGroupCount = pGlossaryList->GetGroupCount();
+ for(sal_uInt16 i = 1; i <= nGroupCount; i++)
+ {
+ OUString sTitle = pGlossaryList->GetGroupTitle(i - 1);
+ sal_uInt16 nBlockCount = pGlossaryList->GetBlockCount(i -1);
+ if(nBlockCount)
+ {
+ sal_uInt16 nIndex = 100 * (i);
+ // but insert without extension
+ pPopup->InsertItem( i, sTitle);
+ PopupMenu* pSub = new PopupMenu;
+ pSub->SetSelectHdl(aLnk);
+ pPopup->SetPopupMenu(i, pSub);
+ for(sal_uInt16 j = 0; j < nBlockCount; j++)
+ {
+ OUString sLongName(pGlossaryList->GetBlockLongName(i - 1, j));
+ OUString sShortName(pGlossaryList->GetBlockShortName(i - 1, j));
+
+ OUString sEntry = sShortName + " - " + sLongName;
+ pSub->InsertItem(++nIndex, sEntry);
+ }
+ }
+ }
+ }
+ ToolBox* pToolBox = &GetToolBox();
+ sal_uInt16 nId = GetId();
+ pToolBox->SetItemDown( nId, true );
+
+ pPopup->Execute( pToolBox, pToolBox->GetItemRect( nId ),
+ (pToolBox->GetAlign() == WINDOWALIGN_TOP || pToolBox->GetAlign() == WINDOWALIGN_BOTTOM) ?
+ POPUPMENU_EXECUTE_DOWN : POPUPMENU_EXECUTE_RIGHT );
+
+ pToolBox->SetItemDown( nId, false );
+ }
+ GetToolBox().EndSelection();
+ DelPopup();
+ return 0;
+
+}
+
+SfxPopupWindowType SwTbxAutoTextCtrl::GetPopupWindowType() const
+{
+ return SFX_POPUPWINDOW_ONTIMEOUT;
+}
+
+void SwTbxAutoTextCtrl::StateChanged( sal_uInt16,
+ SfxItemState,
+ const SfxPoolItem* pState )
+{
+ GetToolBox().EnableItem( GetId(), (GetItemState(pState) != SFX_ITEM_DISABLED) );
+}
+
+IMPL_LINK(SwTbxAutoTextCtrl, PopupHdl, PopupMenu*, pMenu)
+{
+ sal_uInt16 nId = pMenu->GetCurItemId();
+
+ sal_uInt16 nBlock = nId / 100;
+
+ SwGlossaryList* pGlossaryList = ::GetGlossaryList();
+ OUString sGroup = pGlossaryList->GetGroupName(nBlock - 1, false);
+ OUString sShortName =
+ pGlossaryList->GetBlockShortName(nBlock - 1, nId - (100 * nBlock) - 1);
+
+ SwGlossaryHdl* pGlosHdl = pView->GetGlosHdl();
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "Dialogdiet fail!");
+ ::GlossarySetActGroup fnSetActGroup = pFact->SetGlossaryActGroupFunc();
+ if ( fnSetActGroup )
+ (*fnSetActGroup)( sGroup );
+ pGlosHdl->SetCurGroup(sGroup, sal_True);
+ pGlosHdl->InsertGlossary(sShortName);
+
+ return 0;
+}
+
+void SwTbxAutoTextCtrl::DelPopup()
+{
+ if(pPopup)
+ {
+ for( sal_uInt16 i = 0; i < pPopup->GetItemCount(); i ++ )
+ {
+ PopupMenu* pSubPopup = pPopup->GetPopupMenu(pPopup->GetItemId(i));
+ delete pSubPopup;
+ }
+ delete pPopup;
+ pPopup = 0;
+ }
+}
+
+SwTbxFieldCtrl::SwTbxFieldCtrl(
+ sal_uInt16 nSlotId,
+ sal_uInt16 nId,
+ ToolBox& rTbx ) :
+ SfxToolBoxControl( nSlotId, nId, rTbx ),
+ pPopup(0),
+ pView(0)
+{
+ rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
+}
+
+SwTbxFieldCtrl::~SwTbxFieldCtrl()
+{
+ DelPopup();
+}
+
+SfxPopupWindow* SwTbxFieldCtrl::CreatePopupWindow()
+{
+ pView = ::GetActiveView();
+ if(pView && !pView->GetDocShell()->IsReadOnly() &&
+ !pView->GetWrtShell().HasReadonlySel() )
+ {
+ ToolBox& rBox = GetToolBox();
+
+ Rectangle aItemRect( rBox.GetItemRect( GetId() ) );
+ Point aPt(rBox.OutputToScreenPixel(aItemRect.TopLeft()));
+ aPt.X() += aItemRect.GetWidth()/2;
+ aPt.Y() += aItemRect.GetHeight()/2;
+ if(pView)
+ {
+ Link aLnk = LINK(this, SwTbxFieldCtrl, PopupHdl);
+
+ pPopup = new PopupMenu(SW_RES(RID_INSERT_FIELD_CTRL));
+ pPopup->SetSelectHdl(aLnk);
+
+ if (::GetHtmlMode(pView->GetDocShell()) & HTMLMODE_ON)
+ {
+ pPopup->RemoveItem(pPopup->GetItemPos(FN_INSERT_FLD_PGCOUNT));
+ pPopup->RemoveItem(pPopup->GetItemPos(FN_INSERT_FLD_TOPIC));
+ }
+ }
+ ToolBox* pToolBox = &GetToolBox();
+ sal_uInt16 nId = GetId();
+ pToolBox->SetItemDown( nId, true );
+
+ pPopup->Execute( pToolBox, pToolBox->GetItemRect( nId ),
+ (pToolBox->GetAlign() == WINDOWALIGN_TOP || pToolBox->GetAlign() == WINDOWALIGN_BOTTOM) ?
+ POPUPMENU_EXECUTE_DOWN : POPUPMENU_EXECUTE_RIGHT );
+
+ pToolBox->SetItemDown( nId, false );
+ }
+ GetToolBox().EndSelection();
+ DelPopup();
+ return 0;
+
+}
+
+SfxPopupWindowType SwTbxFieldCtrl::GetPopupWindowType() const
+{
+ return SFX_POPUPWINDOW_ONTIMEOUT;
+}
+
+void SwTbxFieldCtrl::StateChanged( sal_uInt16,
+ SfxItemState eState,
+ const SfxPoolItem* pState )
+{
+ GetToolBox().EnableItem( GetId(), (GetItemState(pState) != SFX_ITEM_DISABLED) );
+ if (eState >= SFX_ITEM_DEFAULT)
+ {
+ GetToolBox().CheckItem( GetId(), ((SfxBoolItem*)pState)->GetValue() );
+ }
+}
+
+IMPL_LINK(SwTbxFieldCtrl, PopupHdl, PopupMenu*, pMenu)
+{
+ sal_uInt16 nId = pMenu->GetCurItemId();
+
+ Sequence< PropertyValue > aArgs;
+ const char* pChar = 0;
+ switch(nId)
+ {
+ case FN_INSERT_FLD_DATE:
+ pChar = ".uno:InsertDateField";
+ break;
+ case FN_INSERT_FLD_TIME:
+ pChar = ".uno:InsertTimeField";
+ break;
+ case FN_INSERT_FLD_PGNUMBER:
+ pChar = ".uno:InsertPageNumberField";
+ break;
+ case FN_INSERT_FLD_PGCOUNT:
+ pChar = ".uno:InsertPageCountField";
+ break;
+ case FN_INSERT_FLD_TOPIC:
+ pChar = ".uno:InsertTopicField";
+ break;
+ case FN_INSERT_FLD_TITLE:
+ pChar = ".uno:InsertTitleField";
+ break;
+ case FN_INSERT_FLD_AUTHOR:
+ pChar = ".uno:InsertAuthorField";
+ break;
+ default:
+ pChar = ".uno:InsertFieldCtrl";
+ }
+ Dispatch( OUString::createFromAscii( pChar ),aArgs );
+
+ return 0;
+}
+
+void SwTbxFieldCtrl::DelPopup()
+{
+ if(pPopup)
+ {
+ delete pPopup;
+ pPopup = 0;
+ }
+}
+
+// Navigation-Popup
+// determine the order of the toolbox items
+static sal_uInt16 aNavigationInsertIds[ NAVI_ENTRIES ] =
+{
+ // -- first line
+ NID_TBL,
+ NID_FRM,
+ NID_GRF,
+ NID_OLE,
+ NID_PGE,
+ NID_OUTL,
+ NID_MARK,
+ NID_DRW,
+ NID_CTRL,
+ NID_PREV,
+ // -- second line
+ NID_REG,
+ NID_BKM,
+ NID_SEL,
+ NID_FTN,
+ NID_POSTIT,
+ NID_SRCH_REP,
+ NID_INDEX_ENTRY,
+ NID_TABLE_FORMULA,
+ NID_TABLE_FORMULA_ERROR,
+ NID_NEXT
+};
+static const char* aNavigationHelpIds[ NAVI_ENTRIES ] =
+{
+ // -- first line
+ HID_NID_TBL,
+ HID_NID_FRM,
+ HID_NID_GRF,
+ HID_NID_OLE,
+ HID_NID_PGE,
+ HID_NID_OUTL,
+ HID_NID_MARK,
+ HID_NID_DRW,
+ HID_NID_CTRL,
+ HID_NID_PREV,
+ // -- second line
+ HID_NID_REG,
+ HID_NID_BKM,
+ HID_NID_SEL,
+ HID_NID_FTN,
+ HID_NID_POSTIT,
+ HID_NID_SRCH_REP,
+ HID_NID_INDEX_ENTRY,
+ HID_NID_TABLE_FORMULA,
+ HID_NID_TABLE_FORMULA_ERROR,
+ HID_NID_NEXT
+};
+
+SwScrollNaviPopup::SwScrollNaviPopup(sal_uInt16 nId, const Reference< XFrame >& rFrame, Window *pParent)
+ : SfxPopupWindow(nId, rFrame, pParent, SW_RES(RID_SCROLL_NAVIGATION_WIN)),
+ aToolBox(this, 0),
+ aSeparator(this, SW_RES(FL_SEP)),
+ aInfoField(this, SW_RES(FI_INFO)),
+ aIList(SW_RES(IL_VALUES))
+{
+ sal_uInt16 i;
+
+ aToolBox.SetHelpId(HID_NAVI_VS);
+ aToolBox.SetLineCount( 2 );
+ aToolBox.SetOutStyle(TOOLBOX_STYLE_FLAT);
+ for( i = 0; i < NID_COUNT; i++)
+ {
+ sal_uInt16 nNaviId = aNavigationInsertIds[i];
+ OUString sText;
+ ToolBoxItemBits nTbxBits = 0;
+ if((NID_PREV != nNaviId) && (NID_NEXT != nNaviId))
+ {
+ // -2, there's no string for Next/Prev
+ sal_uInt16 nResStr = ST_TBL - 2 + nNaviId - NID_START;
+ sText = SW_RESSTR(nResStr);
+ nTbxBits = TIB_CHECKABLE;
+ }
+ else
+ {
+ if (nNaviId == NID_PREV)
+ sText = SW_RESSTR(STR_IMGBTN_PGE_UP);
+ else if (nNaviId == NID_NEXT)
+ sText = SW_RESSTR(STR_IMGBTN_PGE_DOWN);
+ }
+ aToolBox.InsertItem(nNaviId, sText, nTbxBits);
+ aToolBox.SetHelpId( nNaviId, aNavigationHelpIds[i] );
+ }
+ ApplyImageList();
+ aToolBox.InsertBreak(NID_COUNT/2);
+ // don't call it before!
+ FreeResource();
+
+ // these are global strings
+ for( i = 0; i < 2 * NID_COUNT; i++)
+ {
+ sQuickHelp[i] = SW_RESSTR(STR_IMGBTN_START + i);
+ }
+
+ Size aImgSize = aIList.GetImageSize();
+ aImgSize.Width() += 5;
+ aImgSize.Height() += 5;
+ Size aSz = aToolBox.CalcWindowSizePixel(2);
+ aToolBox.SetPosSizePixel( Point(), aSz );
+ sal_uInt16 nItemId = SwView::GetMoveType();
+ aInfoField.SetText(aToolBox.GetItemText(nItemId));
+ aToolBox.CheckItem( nItemId, true );
+ Size aFTSize(aInfoField.GetSizePixel());
+ Size aSepSize(aSeparator.GetSizePixel());
+ aSepSize.Width() = aSz.Width();
+
+ aSz.Height() += aFTSize.Height() + aSepSize.Height();
+ aInfoField.SetPosSizePixel(
+ Point(0, aSz.Height() - aFTSize.Height()), Size(aSz.Width(), aFTSize.Height()));
+
+ aSeparator.SetSizePixel(aSepSize);
+ aSeparator.SetPosPixel(Point(0, aSz.Height() - aFTSize.Height() - aSepSize.Height()));
+
+ SetOutputSizePixel(aSz);
+ aToolBox.SetSelectHdl(LINK(this, SwScrollNaviPopup, SelectHdl));
+ aToolBox.StartSelection();
+ aToolBox.Show();
+}
+
+SwScrollNaviPopup::~SwScrollNaviPopup()
+{
+}
+
+void SwScrollNaviPopup::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
+ (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ ApplyImageList();
+
+ Window::DataChanged( rDCEvt );
+}
+
+void SwScrollNaviPopup::ApplyImageList()
+{
+ ImageList& rImgLst = aIList;
+ for(sal_uInt16 i = 0; i < NID_COUNT; i++)
+ {
+ sal_uInt16 nNaviId = aNavigationInsertIds[i];
+ aToolBox.SetItemImage(nNaviId, rImgLst.GetImage(nNaviId));
+ }
+}
+
+SfxPopupWindow* SwScrollNaviPopup::Clone() const
+{
+ return new SwScrollNaviPopup( GetId(), GetFrame(), GetParent() );
+}
+
+IMPL_LINK(SwScrollNaviPopup, SelectHdl, ToolBox*, pSet)
+{
+ sal_uInt16 nSet = pSet->GetCurItemId();
+ if( nSet != NID_PREV && nSet != NID_NEXT )
+ {
+ SwView::SetMoveType(nSet);
+ aToolBox.SetItemText(NID_NEXT, sQuickHelp[nSet - NID_START]);
+ aToolBox.SetItemText(NID_PREV, sQuickHelp[nSet - NID_START + NID_COUNT]);
+ aInfoField.SetText(aToolBox.GetItemText(nSet));
+ // check the current button only
+ for(sal_uInt16 i = 0; i < NID_COUNT; i++)
+ {
+ sal_uInt16 nItemId = aToolBox.GetItemId( i );
+ aToolBox.CheckItem( nItemId, nItemId == nSet );
+ }
+ }
+ else
+ {
+ Sequence< PropertyValue > aArgs;
+ OUString cmd(".uno:ScrollToPrevious");
+ if (NID_NEXT == nSet)
+ cmd = OUString(".uno:ScrollToNext");
+ SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( GetFrame()->getController(), UNO_QUERY ),
+ cmd, aArgs );
+ }
+ return 0;
+}
+
+void SwScrollNaviToolBox::MouseButtonUp( const MouseEvent& rMEvt )
+{
+ ToolBox::MouseButtonUp(rMEvt);
+ if ( ((SwScrollNaviPopup*)GetParent())->IsInPopupMode() )
+ ((SwScrollNaviPopup*)GetParent())->EndPopupMode( FLOATWIN_POPUPMODEEND_CLOSEALL );
+}
+
+void SwScrollNaviToolBox::RequestHelp( const HelpEvent& rHEvt )
+{
+ SetItemText(NID_NEXT, SwScrollNaviPopup::GetQuickHelpText(sal_True));
+ SetItemText(NID_PREV, SwScrollNaviPopup::GetQuickHelpText(sal_False));
+ ToolBox::RequestHelp( rHEvt );
+
+}
+
+OUString SwScrollNaviPopup::GetQuickHelpText(sal_Bool bNext)
+{
+ sal_uInt16 nResId = STR_IMGBTN_START;
+ nResId += SwView::GetMoveType() - NID_START;
+ if(!bNext)
+ nResId += NID_COUNT;
+ return SW_RESSTR(nResId);
+}
+
+void SwHlpImageButton::RequestHelp( const HelpEvent& rHEvt )
+{
+
+ SetQuickHelpText(SwScrollNaviPopup::GetQuickHelpText(!bUp));
+
+ ImageButton::RequestHelp(rHEvt);
+}
+
+class SwZoomBox_Impl : public ComboBox
+{
+ sal_uInt16 nSlotId;
+ bool bRelease;
+ uno::Reference< frame::XDispatchProvider > m_xDispatchProvider;
+
+public:
+ SwZoomBox_Impl(
+ Window* pParent,
+ sal_uInt16 nSlot,
+ const Reference< XDispatchProvider >& rDispatchProvider );
+ ~SwZoomBox_Impl();
+
+protected:
+ virtual void Select();
+ virtual bool Notify( NotifyEvent& rNEvt );
+
+ void ReleaseFocus();
+
+};
+
+SwZoomBox_Impl::SwZoomBox_Impl(
+ Window* pParent,
+ sal_uInt16 nSlot,
+ const Reference< XDispatchProvider >& rDispatchProvider ):
+ ComboBox( pParent, SW_RES(RID_PVIEW_ZOOM_LB)),
+ nSlotId(nSlot),
+ bRelease(true),
+ m_xDispatchProvider( rDispatchProvider )
+{
+ EnableAutocomplete( false );
+ sal_uInt16 aZoomValues[] =
+ { 25, 50, 75, 100, 150, 200 };
+ for(sal_uInt16 i = 0; i < sizeof(aZoomValues)/sizeof(sal_uInt16); i++)
+ {
+ OUString sEntry = unicode::formatPercent(aZoomValues[i],
+ Application::GetSettings().GetUILanguageTag());
+ InsertEntry(sEntry);
+ }
+}
+
+SwZoomBox_Impl::~SwZoomBox_Impl()
+{}
+
+void SwZoomBox_Impl::Select()
+{
+ if ( !IsTravelSelect() )
+ {
+ OUString sEntry(comphelper::string::remove(GetText(), '%'));
+ sal_uInt16 nZoom = (sal_uInt16)sEntry.toInt32();
+ if(nZoom < MINZOOM)
+ nZoom = MINZOOM;
+ if(nZoom > MAXZOOM)
+ nZoom = MAXZOOM;
+
+ SfxUInt16Item aItem( nSlotId, nZoom );
+ if ( FN_PREVIEW_ZOOM == nSlotId )
+ {
+ Any a;
+ Sequence< PropertyValue > aArgs( 1 );
+ aArgs[0].Name = "PreviewZoom";
+ aItem.QueryValue( a );
+ aArgs[0].Value = a;
+ SfxToolBoxControl::Dispatch(
+ m_xDispatchProvider,
+ OUString( ".uno:PreviewZoom" ),
+ aArgs );
+ }
+
+ ReleaseFocus();
+ }
+}
+
+bool SwZoomBox_Impl::Notify( NotifyEvent& rNEvt )
+{
+ bool bHandled = false;
+
+ if ( rNEvt.GetType() == EVENT_KEYINPUT )
+ {
+ sal_uInt16 nCode = rNEvt.GetKeyEvent()->GetKeyCode().GetCode();
+
+ switch ( nCode )
+ {
+ case KEY_RETURN:
+ case KEY_TAB:
+ {
+ if ( KEY_TAB == nCode )
+ bRelease = false;
+ else
+ bHandled = true;
+ Select();
+ break;
+ }
+
+ case KEY_ESCAPE:
+ SetText( GetSavedValue() );
+ ReleaseFocus();
+ break;
+ }
+ }
+ else if ( EVENT_LOSEFOCUS == rNEvt.GetType() )
+ {
+ Window* pFocusWin = Application::GetFocusWindow();
+ if ( !HasFocus() && GetSubEdit() != pFocusWin )
+ SetText( GetSavedValue() );
+ }
+
+ return bHandled || ComboBox::Notify( rNEvt );
+}
+
+void SwZoomBox_Impl::ReleaseFocus()
+{
+ if ( !bRelease )
+ {
+ bRelease = true;
+ return;
+ }
+ SfxViewShell* pCurSh = SfxViewShell::Current();
+
+ if ( pCurSh )
+ {
+ Window* pShellWnd = pCurSh->GetWindow();
+
+ if ( pShellWnd )
+ pShellWnd->GrabFocus();
+ }
+}
+
+SFX_IMPL_TOOLBOX_CONTROL( SwPreviewZoomControl, SfxUInt16Item);
+
+SwPreviewZoomControl::SwPreviewZoomControl(
+ sal_uInt16 nSlotId,
+ sal_uInt16 nId,
+ ToolBox& rTbx) :
+ SfxToolBoxControl( nSlotId, nId, rTbx )
+{
+}
+
+SwPreviewZoomControl::~SwPreviewZoomControl()
+{
+}
+
+void SwPreviewZoomControl::StateChanged( sal_uInt16 /*nSID*/,
+ SfxItemState eState,
+ const SfxPoolItem* pState )
+{
+ sal_uInt16 nId = GetId();
+ GetToolBox().EnableItem( nId, (GetItemState(pState) != SFX_ITEM_DISABLED) );
+ SwZoomBox_Impl* pBox = (SwZoomBox_Impl*)GetToolBox().GetItemWindow( GetId() );
+ if(SFX_ITEM_AVAILABLE <= eState)
+ {
+ OUString sZoom(unicode::formatPercent(((const SfxUInt16Item*)pState)->GetValue(),
+ Application::GetSettings().GetUILanguageTag()));
+ pBox->SetText(sZoom);
+ pBox->SaveValue();
+ }
+}
+
+Window* SwPreviewZoomControl::CreateItemWindow( Window *pParent )
+{
+ SwZoomBox_Impl* pRet = new SwZoomBox_Impl( pParent, GetSlotId(), Reference< XDispatchProvider >( m_xFrame->getController(), UNO_QUERY ));
+ return pRet;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/ribbar/workctrl.hrc b/sw/source/core/uibase/ribbar/workctrl.hrc
new file mode 100644
index 000000000000..cee389be0671
--- /dev/null
+++ b/sw/source/core/uibase/ribbar/workctrl.hrc
@@ -0,0 +1,75 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef _WORKCTRL_HRC
+#define _WORKCTRL_HRC
+#include "ribbar.hrc"
+
+#define IL_VALUES 5
+#define IMG_BTN 6
+#define ST_QUICK 7
+#define FI_INFO 8
+#define FL_SEP 9
+
+#define ST_TBL 12
+#define ST_FRM 13
+#define ST_PGE 14
+#define ST_DRW 15
+#define ST_CTRL 16
+#define ST_REG 17
+#define ST_BKM 18
+#define ST_GRF 19
+#define ST_OLE 20
+#define ST_OUTL 21
+#define ST_SEL 22
+#define ST_FTN 23
+#define ST_MARK 24
+#define ST_POSTIT 25
+#define ST_SRCH_REP 26
+#define ST_INDEX_ENTRY 27
+#define ST_TABLE_FORMULA 28
+#define ST_TABLE_FORMULA_ERROR 29
+
+// duplicate entry! hrc and hxx
+// these Ids specifiy the action of the buttons below the scroll bar
+#define NID_START 20000
+#define NID_NEXT 20000
+#define NID_PREV 20001
+#define NID_TBL 20002
+#define NID_FRM 20003
+#define NID_PGE 20004
+#define NID_DRW 20005
+#define NID_CTRL 20006
+#define NID_REG 20007
+#define NID_BKM 20008
+#define NID_GRF 20009
+#define NID_OLE 20010
+#define NID_OUTL 20011
+#define NID_SEL 20012
+#define NID_FTN 20013
+#define NID_MARK 20014
+#define NID_POSTIT 20015
+#define NID_SRCH_REP 20016
+#define NID_INDEX_ENTRY 20017
+#define NID_TABLE_FORMULA 20018
+#define NID_TABLE_FORMULA_ERROR 20019
+#define NID_COUNT 20
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/ribbar/workctrl.src b/sw/source/core/uibase/ribbar/workctrl.src
new file mode 100644
index 000000000000..f3592d0a7a8e
--- /dev/null
+++ b/sw/source/core/uibase/ribbar/workctrl.src
@@ -0,0 +1,382 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <svx/svxids.hrc>
+#include <svx/globlmn.hrc>
+#include "workctrl.hrc"
+#include "helpid.h"
+#include "cmdid.h"
+
+Menu RID_INSERT_FIELD_CTRL
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = FN_INSERT_FLD_DATE ;
+ HelpId = CMD_FN_INSERT_FLD_DATE ;
+ Text [ en-US ] = "Date" ;
+ };
+ MenuItem
+ {
+ Identifier = FN_INSERT_FLD_TIME ;
+ HelpId = CMD_FN_INSERT_FLD_TIME ;
+ Text [ en-US ] = "Time" ;
+ };
+ MenuItem
+ {
+ Identifier = FN_INSERT_FLD_PGNUMBER ;
+ HelpId = CMD_FN_INSERT_FLD_PGNUMBER ;
+ Text [ en-US ] = "Page Number" ;
+ };
+ MenuItem
+ {
+ Identifier = FN_INSERT_FLD_PGCOUNT ;
+ HelpId = CMD_FN_INSERT_FLD_PGCOUNT ;
+ Text [ en-US ] = "Page Count" ;
+ };
+ MenuItem
+ {
+ Identifier = FN_INSERT_FLD_TOPIC ;
+ HelpId = CMD_FN_INSERT_FLD_TOPIC ;
+ Text [ en-US ] = "Subject" ;
+ };
+ MenuItem
+ {
+ Identifier = FN_INSERT_FLD_TITLE ;
+ HelpId = CMD_FN_INSERT_FLD_TITLE ;
+ Text [ en-US ] = "Title" ;
+ };
+ MenuItem
+ {
+ Identifier = FN_INSERT_FLD_AUTHOR ;
+ HelpId = CMD_FN_INSERT_FLD_AUTHOR ;
+ Text [ en-US ] = "Author" ;
+ };
+ MenuItem
+ {
+ Separator = TRUE ;
+ };
+ MenuItem
+ {
+ Identifier = FN_INSERT_FIELD ;
+ HelpId = CMD_FN_INSERT_FIELD ;
+ Text [ en-US ] = "Other..." ;
+ };
+ };
+};
+#define SCROLL_IMAGE_IDLIST \
+ IdList = \
+ { \
+ NID_NEXT ; \
+ NID_PREV ; \
+ NID_TBL ; \
+ NID_FRM ; \
+ NID_PGE ; \
+ NID_DRW ; \
+ NID_CTRL ; \
+ NID_REG ; \
+ NID_BKM ; \
+ NID_GRF ; \
+ NID_OLE ; \
+ NID_OUTL ; \
+ NID_SEL ; \
+ NID_FTN ; \
+ NID_MARK ; \
+ NID_POSTIT ; \
+ NID_SRCH_REP ; \
+ NID_INDEX_ENTRY; \
+ NID_TABLE_FORMULA; \
+ NID_TABLE_FORMULA_ERROR; \
+ }; \
+ IdCount = { 20 ; };
+
+FloatingWindow RID_SCROLL_NAVIGATION_WIN
+{
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ HelpID = HID_INSERT_CTRL ;
+ ImageList IL_VALUES
+ {
+ Prefix = "sr";
+ MaskColor = IMAGE_MASK_COLOR ;
+ SCROLL_IMAGE_IDLIST
+ };
+ FixedLine FL_SEP
+ {
+ //no position, no text
+ Size = MAP_APPFONT ( 20 , 4 ) ;
+ };
+ FixedText FI_INFO
+ {
+ //no position, no text
+ Size = MAP_APPFONT ( 20 , 8 ) ;
+ Center = TRUE;
+ };
+ String ST_TBL
+ {
+ Text [ en-US ] = "Table" ;
+ };
+ String ST_FRM
+ {
+ Text [ en-US ] = "Text Frame" ;
+ };
+ String ST_PGE
+ {
+ Text [ en-US ] = "Page" ;
+ };
+ String ST_DRW
+ {
+ Text [ en-US ] = "Drawing" ;
+ };
+ String ST_CTRL
+ {
+ Text [ en-US ] = "Control" ;
+ };
+ String ST_REG
+ {
+ Text [ en-US ] = "Section" ;
+ };
+ String ST_BKM
+ {
+ Text [ en-US ] = "Bookmark" ;
+ };
+ String ST_GRF
+ {
+ Text [ en-US ] = "Graphics" ;
+ };
+ String ST_OLE
+ {
+ Text [ en-US ] = "OLE object" ;
+ };
+ String ST_OUTL
+ {
+ Text [ en-US ] = "Headings" ;
+ };
+ String ST_SEL
+ {
+ Text [ en-US ] = "Selection" ;
+ };
+ String ST_FTN
+ {
+ Text [ en-US ] = "Footnote" ;
+ };
+ String ST_MARK
+ {
+ Text [ en-US ] = "Reminder" ;
+ };
+ String ST_POSTIT
+ {
+ Text [ en-US ] = "Comment" ;
+ };
+ String ST_SRCH_REP
+ {
+ Text [ en-US ] = "Repeat search" ;
+ };
+ String ST_INDEX_ENTRY
+ {
+ Text [ en-US ] = "Index entry";
+ };
+ String ST_TABLE_FORMULA
+ {
+ Text [ en-US ] = "Table formula";
+ };
+ String ST_TABLE_FORMULA_ERROR
+ {
+ Text [ en-US ] = "Wrong table formula";
+ };
+ Text [ en-US ] = "Navigation" ;
+};
+
+// Strings for the quickhelp of the View-PgUp/Down-Buttons
+
+String STR_IMGBTN_NEXT_DOWN
+{
+ Text = "" ;
+};
+String STR_IMGBTN_PREV_DOWN
+{
+ Text = "" ;
+};
+String STR_IMGBTN_TBL_DOWN
+{
+ Text [ en-US ] = "Next table" ;
+};
+String STR_IMGBTN_FRM_DOWN
+{
+ Text [ en-US ] = "Next text frame" ;
+};
+String STR_IMGBTN_PGE_DOWN
+{
+ Text [ en-US ] = "Next page" ;
+};
+String STR_IMGBTN_DRW_DOWN
+{
+ Text [ en-US ] = "Next drawing" ;
+};
+String STR_IMGBTN_CTRL_DOWN
+{
+ Text [ en-US ] = "Next control" ;
+};
+String STR_IMGBTN_REG_DOWN
+{
+ Text [ en-US ] = "Next section" ;
+};
+String STR_IMGBTN_BKM_DOWN
+{
+ Text [ en-US ] = "Next bookmark" ;
+};
+String STR_IMGBTN_GRF_DOWN
+{
+ Text [ en-US ] = "Next graphic" ;
+};
+String STR_IMGBTN_OLE_DOWN
+{
+ Text [ en-US ] = "Next OLE object" ;
+};
+String STR_IMGBTN_OUTL_DOWN
+{
+ Text [ en-US ] = "Next heading" ;
+};
+String STR_IMGBTN_SEL_DOWN
+{
+ Text [ en-US ] = "Next selection" ;
+};
+String STR_IMGBTN_FTN_DOWN
+{
+ Text [ en-US ] = "Next footnote" ;
+};
+String STR_IMGBTN_MARK_DOWN
+{
+ Text [ en-US ] = "Next Reminder" ;
+};
+String STR_IMGBTN_POSTIT_DOWN
+{
+ Text [ en-US ] = "Next Comment" ;
+};
+String STR_IMGBTN_SRCH_REP_DOWN
+{
+ Text [ en-US ] = "Continue search forward" ;
+};
+String STR_IMGBTN_INDEX_ENTRY_DOWN
+{
+ Text [ en-US ] = "Next index entry";
+};
+String STR_IMGBTN_NEXT_UP
+{
+ Text = "" ;
+};
+String STR_IMGBTN_PREV_UP
+{
+ Text = "" ;
+};
+String STR_IMGBTN_TBL_UP
+{
+ Text [ en-US ] = "Previous table" ;
+};
+String STR_IMGBTN_FRM_UP
+{
+ Text [ en-US ] = "Previous text frame" ;
+};
+String STR_IMGBTN_PGE_UP
+{
+ Text [ en-US ] = "Previous page" ;
+};
+String STR_IMGBTN_DRW_UP
+{
+ Text [ en-US ] = "Previous drawing" ;
+};
+String STR_IMGBTN_CTRL_UP
+{
+ Text [ en-US ] = "Previous control" ;
+};
+String STR_IMGBTN_REG_UP
+{
+ Text [ en-US ] = "Previous section" ;
+};
+String STR_IMGBTN_BKM_UP
+{
+ Text [ en-US ] = "Previous bookmark" ;
+};
+String STR_IMGBTN_GRF_UP
+{
+ Text [ en-US ] = "Previous graphic" ;
+};
+String STR_IMGBTN_OLE_UP
+{
+ Text [ en-US ] = "Previous OLE object" ;
+};
+String STR_IMGBTN_OUTL_UP
+{
+ Text [ en-US ] = "Previous heading" ;
+};
+String STR_IMGBTN_SEL_UP
+{
+ Text [ en-US ] = "Previous selection" ;
+};
+String STR_IMGBTN_FTN_UP
+{
+ Text [ en-US ] = "Previous footnote" ;
+};
+String STR_IMGBTN_MARK_UP
+{
+ Text [ en-US ] = "Previous Reminder" ;
+};
+String STR_IMGBTN_POSTIT_UP
+{
+ Text [ en-US ] = "Previous Comment" ;
+};
+String STR_IMGBTN_SRCH_REP_UP
+{
+ Text [ en-US ] = "Continue search backwards" ;
+};
+String STR_IMGBTN_INDEX_ENTRY_UP
+{
+ Text [ en-US ] = "Previous index entry";
+};
+String STR_IMGBTN_TBLFML_UP
+{
+ Text [ en-US ] = "Previous table formula";
+};
+String STR_IMGBTN_TBLFML_DOWN
+{
+ Text [ en-US ] = "Next table formula";
+};
+String STR_IMGBTN_TBLFML_ERR_UP
+{
+ Text [ en-US ] = "Previous faulty table formula";
+};
+String STR_IMGBTN_TBLFML_ERR_DOWN
+{
+ Text [ en-US ] = "Next faulty table formula";
+};
+ComboBox RID_PVIEW_ZOOM_LB
+{
+ HelpId = HID_PVIEW_ZOOM_LB;
+ Size = MAP_APPFONT ( 30 , 86 ) ;
+ DropDown = TRUE ;
+ AutoHScroll = TRUE ;
+ DDExtraWidth = TRUE ;
+ Border = TRUE ;
+ Hide = TRUE ;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/shells/annotsh.cxx b/sw/source/core/uibase/shells/annotsh.cxx
new file mode 100644
index 000000000000..d1e69591744f
--- /dev/null
+++ b/sw/source/core/uibase/shells/annotsh.cxx
@@ -0,0 +1,1760 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <hintids.hxx>
+
+#include <com/sun/star/i18n/TransliterationModules.hpp>
+#include <com/sun/star/i18n/TransliterationModulesExtra.hpp>
+#include <com/sun/star/i18n/TextConversionOption.hpp>
+#include <com/sun/star/ui/dialogs/XSLTFilterDialog.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+
+#include <tools/shl.hxx>
+#include <i18nlangtag/mslangid.hxx>
+#include <sfx2/objface.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/request.hxx>
+#include <editeng/spltitem.hxx>
+#include <editeng/lrspitem.hxx>
+#include <editeng/ulspitem.hxx>
+#include <editeng/orphitem.hxx>
+#include <editeng/formatbreakitem.hxx>
+#include <editeng/widwitem.hxx>
+#include <editeng/kernitem.hxx>
+#include <editeng/escapementitem.hxx>
+#include <editeng/lspcitem.hxx>
+#include <editeng/adjustitem.hxx>
+#include <editeng/crossedoutitem.hxx>
+#include <editeng/shdditem.hxx>
+#include <editeng/hyphenzoneitem.hxx>
+#include <editeng/udlnitem.hxx>
+#include <editeng/fontitem.hxx>
+#include <editeng/fhgtitem.hxx>
+#include <svx/clipfmtitem.hxx>
+#include <svl/stritem.hxx>
+#include <svl/slstitm.hxx>
+#include <editeng/colritem.hxx>
+#include <editeng/wghtitem.hxx>
+#include <editeng/contouritem.hxx>
+#include <editeng/postitem.hxx>
+#include <editeng/frmdiritem.hxx>
+#include <svx/svdoutl.hxx>
+#include <svl/whiter.hxx>
+#include <svl/cjkoptions.hxx>
+#include <svl/ctloptions.hxx>
+#include <unotools/useroptions.hxx>
+#include <vcl/msgbox.hxx>
+#include <editeng/flditem.hxx>
+#include <editeng/editstat.hxx>
+#include <svx/hlnkitem.hxx>
+#include <sfx2/htmlmode.hxx>
+#include <editeng/langitem.hxx>
+#include <editeng/unolingu.hxx>
+#include <editeng/scripttypeitem.hxx>
+#include <editeng/writingmodeitem.hxx>
+#include <swundo.hxx>
+#include <doc.hxx>
+#include <viewopt.hxx>
+#include <wrtsh.hxx>
+#include <uitool.hxx>
+#include <popup.hrc>
+#include <chrdlgmodes.hxx>
+#include <pardlg.hxx>
+#include <swdtflvr.hxx>
+#include <drwtxtsh.hxx>
+#include <swmodule.hxx>
+#include <initui.hxx>
+#include <edtwin.hxx>
+#include <swwait.hxx>
+#include <docstat.hxx>
+
+#include <cmdid.h>
+#include <globals.hrc>
+#include <shells.hrc>
+#include <breakit.hxx>
+#include "annotsh.hxx"
+#include "view.hxx"
+#include <PostItMgr.hxx>
+#include <SidebarWin.hxx>
+
+#include "swtypes.hxx"
+
+#include <svx/svxdlg.hxx>
+#include <svx/dialogs.hrc>
+
+#include <svx/svxids.hrc>
+#include <sfx2/sidebar/EnumContext.hxx>
+#include <svl/itempool.hxx>
+#include <editeng/outliner.hxx>
+#include <editeng/editeng.hxx>
+#include <editeng/editview.hxx>
+
+#include <svl/languageoptions.hxx>
+#include <svtools/langtab.hxx>
+
+#include <docsh.hxx>
+#include <svl/undo.hxx>
+#include "swabstdlg.hxx"
+#include "chrdlg.hrc"
+#include "misc.hrc"
+#include <app.hrc>
+
+#include <comphelper/processfactory.hxx>
+#include <comphelper/string.hxx>
+#include <cppuhelper/bootstrap.hxx>
+
+#include <langhelper.hxx>
+
+#include <wordcountdialog.hxx>
+#include <tools/diagnose_ex.h>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::i18n;
+
+#define SwAnnotationShell
+
+#include <sfx2/msg.hxx>
+#include <swslots.hxx>
+
+SFX_IMPL_INTERFACE(SwAnnotationShell, SfxShell, SW_RES(STR_SHELLNAME_DRAW_TEXT))
+{
+ SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_TEXT_TOOLBOX));
+ SFX_POPUPMENU_REGISTRATION(SW_RES(MN_ANNOTATION_POPUPMENU));
+}
+
+TYPEINIT1(SwAnnotationShell,SfxShell)
+
+SwAnnotationShell::SwAnnotationShell( SwView& r )
+: rView(r)
+{
+ SwWrtShell &rSh = rView.GetWrtShell();
+ SetPool(rSh.GetAttrPool().GetSecondaryPool());
+ SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_Annotation));
+}
+
+SwAnnotationShell::~SwAnnotationShell()
+{
+}
+
+::svl::IUndoManager* SwAnnotationShell::GetUndoManager()
+{
+ SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
+ if ( !pPostItMgr ||
+ !pPostItMgr->HasActiveSidebarWin() )
+ {
+ OSL_ENSURE(pPostItMgr,"PostItMgr::Layout(): We are looping forever");
+ return 0;
+ }
+ return &pPostItMgr->GetActiveSidebarWin()->GetOutlinerView()->GetOutliner()->GetUndoManager();
+}
+
+void SwAnnotationShell::Exec( SfxRequest &rReq )
+{
+ //TODO: clean this up!!!!
+ SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
+ if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() )
+ return;
+
+ OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView();
+ SfxItemSet aEditAttr(pOLV->GetAttribs());
+ SfxItemSet aNewAttr(*aEditAttr.GetPool(), aEditAttr.GetRanges());
+
+ sal_uInt16 nSlot = rReq.GetSlot();
+ sal_uInt16 nWhich = GetPool().GetWhich(nSlot);
+ const SfxItemSet *pNewAttrs = rReq.GetArgs();
+ sal_uInt16 nEEWhich = 0;
+ switch (nSlot)
+ {
+ case SID_ATTR_PARA_LRSPACE:
+ {
+ SvxLRSpaceItem aParaMargin((const SvxLRSpaceItem&)rReq.
+ GetArgs()->Get(nSlot));
+ aParaMargin.SetWhich( EE_PARA_LRSPACE );
+
+ aNewAttr.Put(aParaMargin);
+ rReq.Done();
+ break;
+ }
+ case SID_ATTR_PARA_LINESPACE:
+ {
+ SvxLineSpacingItem aParaMargin = (const SvxLineSpacingItem&)pNewAttrs->Get(
+ GetPool().GetWhich(nSlot));
+ aParaMargin.SetWhich( EE_PARA_SBL );
+
+ aNewAttr.Put(aParaMargin);
+ rReq.Done();
+ break;
+ }
+ case SID_ATTR_PARA_ULSPACE:
+ {
+ SvxULSpaceItem aULSpace = (const SvxULSpaceItem&)pNewAttrs->Get(
+ GetPool().GetWhich(nSlot));
+ aULSpace.SetWhich( EE_PARA_ULSPACE );
+ aNewAttr.Put( aULSpace );
+ rReq.Done();
+ }
+ break;
+ case SID_ATTR_CHAR_FONT:
+ case SID_ATTR_CHAR_FONTHEIGHT:
+ case SID_ATTR_CHAR_WEIGHT:
+ case SID_ATTR_CHAR_POSTURE:
+ {
+ SfxItemPool* pSecondPool = aEditAttr.GetPool()->GetSecondaryPool();
+ if( !pSecondPool )
+ pSecondPool = aEditAttr.GetPool();
+ SvxScriptSetItem aSetItem( nSlot, *pSecondPool );
+ aSetItem.PutItemForScriptType( pOLV->GetSelectedScriptType(), pNewAttrs->Get( nWhich ));
+ aNewAttr.Put( aSetItem.GetItemSet() );
+ rReq.Done();
+ break;
+ }
+ case SID_ATTR_CHAR_COLOR: nEEWhich = EE_CHAR_COLOR; break;
+ case SID_ATTR_CHAR_UNDERLINE:
+ {
+ if( rReq.GetArgs() )
+ {
+ SFX_REQUEST_ARG( rReq, pItem, SvxUnderlineItem, SID_ATTR_CHAR_UNDERLINE , false );
+ if (pItem)
+ {
+ aNewAttr.Put(*pItem);
+ }
+ else
+ {
+ FontUnderline eFU = ( (const SvxUnderlineItem&) aEditAttr.Get( EE_CHAR_UNDERLINE ) ).GetLineStyle();
+ aNewAttr.Put( SvxUnderlineItem( eFU != UNDERLINE_NONE ?UNDERLINE_NONE : UNDERLINE_SINGLE, EE_CHAR_UNDERLINE ) );
+ }
+ }
+ break;
+ }
+ case SID_ATTR_CHAR_OVERLINE:
+ {
+ FontUnderline eFO = ((const SvxOverlineItem&)aEditAttr.Get(EE_CHAR_OVERLINE)).GetLineStyle();
+ aNewAttr.Put(SvxOverlineItem(eFO == UNDERLINE_SINGLE ? UNDERLINE_NONE : UNDERLINE_SINGLE, EE_CHAR_OVERLINE));
+ break;
+ }
+ case SID_ATTR_CHAR_CONTOUR: nEEWhich = EE_CHAR_OUTLINE; break;
+ case SID_ATTR_CHAR_SHADOWED: nEEWhich = EE_CHAR_SHADOW; break;
+ case SID_ATTR_CHAR_STRIKEOUT: nEEWhich = EE_CHAR_STRIKEOUT; break;
+ case SID_ATTR_CHAR_WORDLINEMODE: nEEWhich = EE_CHAR_WLM; break;
+ case SID_ATTR_CHAR_RELIEF : nEEWhich = EE_CHAR_RELIEF; break;
+ case SID_ATTR_CHAR_LANGUAGE : nEEWhich = EE_CHAR_LANGUAGE;break;
+ case SID_ATTR_CHAR_KERNING : nEEWhich = EE_CHAR_KERNING; break;
+ case SID_ATTR_CHAR_SCALEWIDTH: nEEWhich = EE_CHAR_FONTWIDTH; break;
+ case SID_ATTR_CHAR_AUTOKERN : nEEWhich = EE_CHAR_PAIRKERNING; break;
+ case SID_ATTR_CHAR_ESCAPEMENT: nEEWhich = EE_CHAR_ESCAPEMENT; break;
+ case SID_ATTR_PARA_ADJUST_LEFT:
+ aNewAttr.Put(SvxAdjustItem(SVX_ADJUST_LEFT, EE_PARA_JUST));
+ break;
+ case SID_ATTR_PARA_ADJUST_CENTER:
+ aNewAttr.Put(SvxAdjustItem(SVX_ADJUST_CENTER, EE_PARA_JUST));
+ break;
+ case SID_ATTR_PARA_ADJUST_RIGHT:
+ aNewAttr.Put(SvxAdjustItem(SVX_ADJUST_RIGHT, EE_PARA_JUST));
+ break;
+ case SID_ATTR_PARA_ADJUST_BLOCK:
+ 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_SELECTALL:
+ {
+ Outliner * pOutliner = pOLV->GetOutliner();
+ if(pOutliner)
+ {
+ sal_Int32 nParaCount = pOutliner->GetParagraphCount();
+ if (nParaCount > 0)
+ pOLV->SelectRange(0L, nParaCount );
+ }
+ break;
+ }
+ case FN_FORMAT_RESET:
+ {
+ pPostItMgr->GetActiveSidebarWin()->ResetAttributes();
+ rReq.Done();
+ break;
+ }
+ case FN_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, EE_CHAR_ESCAPEMENT );
+ }
+ break;
+ case FN_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, EE_CHAR_ESCAPEMENT );
+ }
+ break;
+ case SID_HYPERLINK_SETLINK:
+ {
+ const SfxPoolItem* pItem = 0;
+ if(pNewAttrs)
+ pNewAttrs->GetItemState(nSlot, false, &pItem);
+
+ if(pItem)
+ {
+ const SvxHyperlinkItem& rHLinkItem = *(const SvxHyperlinkItem *)pItem;
+ SvxURLField aFld(rHLinkItem.GetURL(), rHLinkItem.GetName(), SVXURLFORMAT_APPDEFAULT);
+ aFld.SetTargetFrame(rHLinkItem.GetTargetFrame());
+
+ const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection();
+
+ if (pFieldItem && pFieldItem->GetField()->ISA(SvxURLField))
+ {
+ // Select the field so that it will be deleted during insert
+ ESelection aSel = pOLV->GetSelection();
+ aSel.nEndPos++;
+ pOLV->SetSelection(aSel);
+ }
+ if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED)
+ pOLV->InsertField(SvxFieldItem(aFld, EE_FEATURE_FIELD));
+ }
+ break;
+ }
+ case FN_INSERT_SOFT_HYPHEN:
+ case FN_INSERT_HARDHYPHEN:
+ case FN_INSERT_HARD_SPACE:
+ case SID_INSERT_RLM :
+ case SID_INSERT_LRM :
+ case SID_INSERT_ZWNBSP :
+ case SID_INSERT_ZWSP:
+ {
+ sal_Unicode cIns = 0;
+ switch(rReq.GetSlot())
+ {
+ case FN_INSERT_SOFT_HYPHEN: cIns = CHAR_SOFTHYPHEN; break;
+ case FN_INSERT_HARDHYPHEN: cIns = CHAR_HARDHYPHEN; break;
+ case FN_INSERT_HARD_SPACE: cIns = CHAR_HARDBLANK; break;
+ case SID_INSERT_RLM : cIns = CHAR_RLM ; break;
+ case SID_INSERT_LRM : cIns = CHAR_LRM ; break;
+ case SID_INSERT_ZWSP : cIns = CHAR_ZWSP ; break;
+ case SID_INSERT_ZWNBSP: cIns = CHAR_ZWNBSP; break;
+ }
+ pOLV->InsertText( OUString(cIns));
+ rReq.Done();
+ break;
+ }
+ case SID_CHARMAP:
+ {
+ if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED)
+ InsertSymbol(rReq);
+ break;
+ }
+ case FN_INSERT_STRING:
+ {
+ const SfxPoolItem* pItem = 0;
+ if(pNewAttrs)
+ pNewAttrs->GetItemState(nSlot, false, &pItem );
+ if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED)
+ pOLV->InsertText(((const SfxStringItem *)pItem)->GetValue());
+ break;
+ }
+
+ case FN_FORMAT_FOOTNOTE_DLG:
+ {
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+
+ VclAbstractDialog* pDlg = pFact->CreateSwFootNoteOptionDlg(rView.GetWindow(), rView.GetWrtShell());
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ pDlg->Execute();
+ delete pDlg;
+ break;
+ }
+ case FN_NUMBERING_OUTLINE_DLG:
+ {
+ SfxItemSet aTmp(GetPool(), FN_PARAM_1, FN_PARAM_1);
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "Dialogdiet fail!");
+ SfxAbstractTabDialog* pDlg = pFact->CreateSwTabDialog( DLG_TAB_OUTLINE,
+ rView.GetWindow(), &aTmp, rView.GetWrtShell());
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ pDlg->Execute();
+ delete pDlg;
+ rReq.Done();
+ }
+ break;
+ case SID_OPEN_XML_FILTERSETTINGS:
+ {
+ try
+ {
+ uno::Reference < ui::dialogs::XExecutableDialog > xDialog = ui::dialogs::XSLTFilterDialog::create( ::comphelper::getProcessComponentContext() );
+ xDialog->execute();
+ }
+ catch (const uno::Exception&)
+ {
+ }
+ rReq.Ignore ();
+ }
+ break;
+ case FN_WORDCOUNT_DIALOG:
+ {
+ SfxViewFrame* pVFrame = rView.GetViewFrame();
+ if (pVFrame != NULL)
+ {
+ pVFrame->ToggleChildWindow(FN_WORDCOUNT_DIALOG);
+ Invalidate(rReq.GetSlot());
+
+ SwWordCountWrapper *pWrdCnt = (SwWordCountWrapper*)pVFrame->GetChildWindow(SwWordCountWrapper::GetChildWindowId());
+ if (pWrdCnt)
+ pWrdCnt->UpdateCounts();
+ }
+ }
+ break;
+ case SID_CHAR_DLG_EFFECT:
+ case SID_CHAR_DLG:
+ {
+ const SfxItemSet* pArgs = rReq.GetArgs();
+
+ if( !pArgs )
+ {
+ /* mod
+ SwView* pView = &GetView();
+ FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, pView));
+ SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, eMetric));
+ */
+ SfxItemSet aDlgAttr(GetPool(), EE_ITEMS_START, EE_ITEMS_END);
+
+ // util::Language does not exist in the EditEngine! Therefore not included in the set.
+
+ aDlgAttr.Put( aEditAttr );
+ aDlgAttr.Put( SvxKerningItem(0, RES_CHRATR_KERNING) );
+
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+
+ SfxAbstractTabDialog* pDlg = pFact->CreateSwCharDlg( rView.GetWindow(), rView, aDlgAttr, DLG_CHAR_ANN);
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ if (nSlot == SID_CHAR_DLG_EFFECT)
+ {
+ pDlg->SetCurPageId("fonteffect");
+ }
+ sal_uInt16 nRet = pDlg->Execute();
+ if(RET_OK == nRet )
+ {
+ rReq.Done( *( pDlg->GetOutputItemSet() ) );
+ aNewAttr.Put(*pDlg->GetOutputItemSet());
+ }
+ delete( pDlg );
+ if(RET_OK != nRet)
+ return ;
+ }
+ else
+ aNewAttr.Put(*pArgs);
+ break;
+ }
+ case SID_PARA_DLG:
+ {
+ const SfxItemSet* pArgs = rReq.GetArgs();
+
+ if (!pArgs)
+ {
+ /* mod todo ???
+ SwView* pView = &GetView();
+ FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, pView));
+ SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, eMetric));
+ */
+ SfxItemSet aDlgAttr(GetPool(),
+ EE_ITEMS_START, EE_ITEMS_END,
+ SID_ATTR_PARA_HYPHENZONE, SID_ATTR_PARA_HYPHENZONE,
+ 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);
+
+ aDlgAttr.Put(aEditAttr);
+
+ aDlgAttr.Put( SvxHyphenZoneItem( false, RES_PARATR_HYPHENZONE) );
+ aDlgAttr.Put( SvxFmtBreakItem( SVX_BREAK_NONE, RES_BREAK ) );
+ aDlgAttr.Put( SvxFmtSplitItem( true, RES_PARATR_SPLIT ) );
+ aDlgAttr.Put( SvxWidowsItem( 0, RES_PARATR_WIDOWS ) );
+ aDlgAttr.Put( SvxOrphansItem( 0, RES_PARATR_ORPHANS ) );
+
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+
+ SfxAbstractTabDialog* pDlg = pFact->CreateSwParaDlg( rView.GetWindow(), rView, aDlgAttr,DLG_STD, 0, sal_True );
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ sal_uInt16 nRet = pDlg->Execute();
+ if(RET_OK == nRet)
+ {
+ rReq.Done( *( pDlg->GetOutputItemSet() ) );
+ aNewAttr.Put(*pDlg->GetOutputItemSet());
+ }
+ delete( pDlg );
+ if(RET_OK != nRet)
+ return;
+ }
+ else
+ aNewAttr.Put(*pArgs);
+ break;
+ }
+
+ case SID_AUTOSPELL_CHECK:
+ {
+ rView.ExecuteSlot(rReq);
+ break;
+ }
+ case SID_ATTR_PARA_LEFT_TO_RIGHT:
+ case SID_ATTR_PARA_RIGHT_TO_LEFT:
+ {
+ bool bLeftToRight = nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT;
+
+ const SfxPoolItem* pPoolItem;
+ if( pNewAttrs && SFX_ITEM_SET == pNewAttrs->GetItemState( nSlot, true, &pPoolItem ) )
+ {
+ if( !( (SfxBoolItem*)pPoolItem)->GetValue() )
+ bLeftToRight = !bLeftToRight;
+ }
+ SfxItemSet aAttr( *aNewAttr.GetPool(),
+ EE_PARA_JUST, EE_PARA_JUST,
+ EE_PARA_WRITINGDIR, EE_PARA_WRITINGDIR,
+ 0 );
+
+ sal_uInt16 nAdjust = SVX_ADJUST_LEFT;
+ if( SFX_ITEM_ON == aEditAttr.GetItemState(EE_PARA_JUST, true, &pPoolItem ) )
+ nAdjust = ( (SvxAdjustItem*)pPoolItem)->GetEnumValue();
+
+ if( bLeftToRight )
+ {
+ aAttr.Put( SvxFrameDirectionItem( FRMDIR_HORI_LEFT_TOP, EE_PARA_WRITINGDIR ) );
+ if( nAdjust == SVX_ADJUST_RIGHT )
+ aAttr.Put( SvxAdjustItem( SVX_ADJUST_LEFT, EE_PARA_JUST ) );
+ }
+ else
+ {
+ aAttr.Put( SvxFrameDirectionItem( FRMDIR_HORI_RIGHT_TOP, EE_PARA_WRITINGDIR ) );
+ if( nAdjust == SVX_ADJUST_LEFT )
+ aAttr.Put( SvxAdjustItem( SVX_ADJUST_RIGHT, EE_PARA_JUST ) );
+ }
+ pOLV->SetAttribs(aAttr);
+ break;
+ }
+ }
+
+ if(nEEWhich && pNewAttrs)
+ aNewAttr.Put(pNewAttrs->Get(nWhich), nEEWhich);
+
+ Rectangle aNullRect;
+ Rectangle aOutRect = pOLV->GetOutputArea();
+ if (aNullRect != aOutRect)
+ pOLV->SetAttribs(aNewAttr);
+
+ rView.GetViewFrame()->GetBindings().InvalidateAll(sal_False);
+ if ( pOLV->GetOutliner()->IsModified() )
+ rView.GetWrtShell().SetModified();
+
+}
+
+void SwAnnotationShell::GetState(SfxItemSet& rSet)
+{
+ //TODO: clean this up!!!
+ // FN_SET_SUPER_SCRIPT
+ //SID_ATTR_PARA_ADJUST
+ //SID_ATTR_PARA_ADJUST_BLOCK
+
+ SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
+ if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() )
+ return;
+
+ OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView();
+ SfxItemSet aEditAttr(pOLV->GetAttribs());
+
+ SfxWhichIter aIter(rSet);
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ while(nWhich)
+ {
+ sal_uInt16 nEEWhich = 0;
+ sal_uInt16 nSlotId = GetPool().GetSlotId( nWhich );
+ switch( nSlotId )
+ {
+ case SID_ATTR_PARA_LRSPACE:
+ {
+ SfxItemState eState = aEditAttr.GetItemState( EE_PARA_LRSPACE );
+ if( eState >= SFX_ITEM_DEFAULT )
+ {
+ SvxLRSpaceItem aLR = ( (const SvxLRSpaceItem&) aEditAttr.Get( EE_PARA_LRSPACE ) );
+ aLR.SetWhich(SID_ATTR_PARA_LRSPACE);
+ rSet.Put(aLR);
+ }
+ else
+ rSet.InvalidateItem(nSlotId);
+ }
+ break;
+ case SID_ATTR_PARA_LINESPACE:
+ {
+ SfxItemState eState = aEditAttr.GetItemState( EE_PARA_SBL );
+ if( eState >= SFX_ITEM_DEFAULT )
+ {
+ SvxLineSpacingItem aLR = ( (const SvxLineSpacingItem&) aEditAttr.Get( EE_PARA_SBL ) );
+ rSet.Put(aLR);
+ }
+ else
+ rSet.InvalidateItem(nSlotId);
+ }
+ break;
+ case SID_ATTR_PARA_ULSPACE:
+ {
+ SfxItemState eState = aEditAttr.GetItemState( EE_PARA_ULSPACE );
+ if( eState >= SFX_ITEM_DEFAULT )
+ {
+ SvxULSpaceItem aULSpace = (const SvxULSpaceItem&) aEditAttr.Get( EE_PARA_ULSPACE );
+ aULSpace.SetWhich(SID_ATTR_PARA_ULSPACE);
+ rSet.Put(aULSpace);
+ }
+ else
+ rSet.InvalidateItem(nSlotId);
+ }
+ break;
+ case SID_ATTR_CHAR_FONT:
+ case SID_ATTR_CHAR_FONTHEIGHT:
+ case SID_ATTR_CHAR_WEIGHT:
+ case SID_ATTR_CHAR_POSTURE:
+ {
+ if ( pOLV )
+ {
+ sal_uInt16 nScriptType = pOLV->GetSelectedScriptType();
+ SfxItemPool* pSecondPool = aEditAttr.GetPool()->GetSecondaryPool();
+ if( !pSecondPool )
+ pSecondPool = aEditAttr.GetPool();
+ SvxScriptSetItem aSetItem( nSlotId, *pSecondPool );
+ aSetItem.GetItemSet().Put( aEditAttr, false );
+ const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScriptType );
+ if( pI )
+ rSet.Put( *pI, nWhich );
+ else
+ rSet.InvalidateItem( nWhich );
+ }
+ else
+ rSet.InvalidateItem( nWhich );
+ }
+ break;
+ case SID_ATTR_CHAR_COLOR: nEEWhich = EE_CHAR_COLOR; break;
+ case SID_ATTR_CHAR_UNDERLINE: nEEWhich = EE_CHAR_UNDERLINE;break;
+ case SID_ATTR_CHAR_OVERLINE: nEEWhich = EE_CHAR_OVERLINE;break;
+ case SID_ATTR_CHAR_CONTOUR: nEEWhich = EE_CHAR_OUTLINE; break;
+ case SID_ATTR_CHAR_SHADOWED: nEEWhich = EE_CHAR_SHADOW;break;
+ case SID_ATTR_CHAR_STRIKEOUT: nEEWhich = EE_CHAR_STRIKEOUT;break;
+ case SID_ATTR_CHAR_LANGUAGE : nEEWhich = EE_CHAR_LANGUAGE;break;
+ case SID_ATTR_CHAR_ESCAPEMENT: nEEWhich = EE_CHAR_ESCAPEMENT;break;
+ case SID_ATTR_CHAR_KERNING: nEEWhich = EE_CHAR_KERNING;break;
+ case FN_SET_SUPER_SCRIPT:
+ case FN_SET_SUB_SCRIPT:
+ {
+ sal_uInt16 nEsc = 0;
+ const SfxPoolItem *pEscItem = 0;
+ if (nWhich==FN_SET_SUPER_SCRIPT)
+ nEsc = SVX_ESCAPEMENT_SUPERSCRIPT;
+ else
+ nEsc = SVX_ESCAPEMENT_SUBSCRIPT;
+
+ if( !pEscItem )
+ pEscItem = &aEditAttr.Get( EE_CHAR_ESCAPEMENT );
+
+ if( nEsc == ((const SvxEscapementItem*)pEscItem)->GetEnumValue() )
+ rSet.Put( SfxBoolItem( nWhich, true ));
+ else
+ rSet.InvalidateItem( nWhich );
+ break;
+ }
+ case SID_ATTR_PARA_ADJUST_LEFT:
+ case SID_ATTR_PARA_ADJUST_RIGHT:
+ case SID_ATTR_PARA_ADJUST_CENTER:
+ case SID_ATTR_PARA_ADJUST_BLOCK:
+ {
+ const SfxPoolItem *pAdjust = 0;
+ int eAdjust = 0;
+
+ if (nWhich==SID_ATTR_PARA_ADJUST_LEFT)
+ eAdjust = SVX_ADJUST_LEFT;
+ else if (nWhich==SID_ATTR_PARA_ADJUST_RIGHT)
+ eAdjust = SVX_ADJUST_RIGHT;
+ else if (nWhich==SID_ATTR_PARA_ADJUST_CENTER)
+ eAdjust = SVX_ADJUST_CENTER;
+ else if (nWhich==SID_ATTR_PARA_ADJUST_BLOCK)
+ eAdjust = SVX_ADJUST_BLOCK;
+
+ if( !pAdjust )
+ aEditAttr.GetItemState( EE_PARA_JUST, false, &pAdjust);
+
+ if( !pAdjust || IsInvalidItem( pAdjust ))
+ rSet.InvalidateItem( nSlotId ), nSlotId = 0;
+ else
+ {
+ if ( eAdjust == ((const SvxAdjustItem*)pAdjust)->GetAdjust())
+ rSet.Put( SfxBoolItem( nWhich, true ));
+ else
+ rSet.InvalidateItem( nWhich );
+ }
+ break;
+ }
+ case SID_ATTR_PARA_LINESPACE_10:
+ case SID_ATTR_PARA_LINESPACE_15:
+ case SID_ATTR_PARA_LINESPACE_20:
+ {
+ const SfxPoolItem *pLSpace = 0;
+ int nLSpace = 0;
+
+ if (nWhich==SID_ATTR_PARA_LINESPACE_10)
+ nLSpace = 100;
+ else if (nWhich==SID_ATTR_PARA_LINESPACE_15)
+ nLSpace = 150;
+ else if (nWhich==SID_ATTR_PARA_LINESPACE_20)
+ nLSpace = 200;
+
+ if( !pLSpace )
+ aEditAttr.GetItemState( EE_PARA_SBL, false, &pLSpace );
+
+ if( !pLSpace || IsInvalidItem( pLSpace ))
+ rSet.InvalidateItem( nSlotId ), nSlotId = 0;
+ else
+ {
+ if( nLSpace == ((const SvxLineSpacingItem*)pLSpace)->GetPropLineSpace() )
+ rSet.Put( SfxBoolItem( nWhich, true ));
+ else
+ rSet.InvalidateItem( nWhich );
+ }
+ break;
+ }
+ case SID_AUTOSPELL_CHECK:
+ {
+ const SfxPoolItem* pState = rView.GetSlotState(nWhich);
+ if (pState)
+ rSet.Put(SfxBoolItem(nWhich, ((const SfxBoolItem*)pState)->GetValue()));
+ else
+ rSet.DisableItem( nWhich );
+ break;
+ }
+ case SID_ATTR_PARA_LEFT_TO_RIGHT:
+ case SID_ATTR_PARA_RIGHT_TO_LEFT:
+ {
+ if ( !SvtLanguageOptions().IsCTLFontEnabled() )
+ rSet.DisableItem( nWhich );
+ else
+ {
+ if(pOLV->GetOutliner() && pOLV->GetOutliner()->IsVertical())
+ rSet.DisableItem( nWhich );
+ else
+ {
+ sal_Bool bFlag = sal_False;
+ switch( ( ( (SvxFrameDirectionItem&) aEditAttr.Get( EE_PARA_WRITINGDIR ) ) ).GetValue() )
+ {
+ case FRMDIR_HORI_LEFT_TOP:
+ {
+ bFlag = nWhich == SID_ATTR_PARA_LEFT_TO_RIGHT;
+ rSet.Put( SfxBoolItem( nWhich, bFlag ));
+ break;
+ }
+ case FRMDIR_HORI_RIGHT_TOP:
+ {
+ bFlag = nWhich != SID_ATTR_PARA_LEFT_TO_RIGHT;
+ rSet.Put( SfxBoolItem( nWhich, bFlag ));
+ break;
+ }
+ }
+ }
+ }
+ }
+ break;
+ case SID_INSERT_RLM :
+ case SID_INSERT_LRM :
+ case SID_INSERT_ZWNBSP :
+ case SID_INSERT_ZWSP:
+ {
+ SvtCTLOptions aCTLOptions;
+ sal_Bool bEnabled = aCTLOptions.IsCTLFontEnabled();
+ rView.GetViewFrame()->GetBindings().SetVisibleState( nWhich, bEnabled );
+ if(!bEnabled)
+ rSet.DisableItem(nWhich);
+ }
+ break;
+ default:
+ rSet.InvalidateItem( nWhich );
+ break;
+ }
+
+ if(nEEWhich)
+ {
+ rSet.Put(aEditAttr.Get(nEEWhich, sal_True), nWhich);
+ if(nEEWhich == EE_CHAR_KERNING)
+ {
+ SfxItemState eState = aEditAttr.GetItemState( EE_CHAR_KERNING, true );
+ if ( eState == SFX_ITEM_DONTCARE )
+ {
+ rSet.InvalidateItem(EE_CHAR_KERNING);
+ }
+ }
+ }
+
+ if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()==SwPostItHelper::DELETED)
+ rSet.DisableItem( nWhich );
+
+ nWhich = aIter.NextWhich();
+ }
+}
+
+void SwAnnotationShell::ExecSearch(SfxRequest& rReq, sal_Bool bNoMessage)
+{
+ rView.ExecSearch(rReq,bNoMessage);
+}
+
+void SwAnnotationShell::StateSearch(SfxItemSet &rSet)
+{
+ rView.StateSearch(rSet);
+}
+
+void SwAnnotationShell::ExecClpbrd(SfxRequest &rReq)
+{
+ SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
+ if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() )
+ return;
+
+ OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView();
+ SfxItemSet aEditAttr(pOLV->GetAttribs());
+ SfxItemSet aNewAttr(*aEditAttr.GetPool(), aEditAttr.GetRanges());
+
+ long aOldHeight = pPostItMgr->GetActiveSidebarWin()->GetPostItTextHeight();
+ sal_uInt16 nSlot = rReq.GetSlot();
+ switch (nSlot)
+ {
+ case SID_CUT:
+ if ( (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED) && pOLV->HasSelection() )
+ pOLV->Cut();
+ break;
+ case SID_COPY:
+ if( pOLV->HasSelection() )
+ pOLV->Copy();
+ break;
+ case SID_PASTE:
+ if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED)
+ pOLV->Paste();
+ break;
+ case SID_PASTE_SPECIAL:
+ {
+ if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED)
+ {
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ SfxAbstractPasteDialog* pDlg = pFact->CreatePasteDialog( &rView.GetEditWin() );
+
+ pDlg->Insert( SOT_FORMAT_STRING, OUString() );
+ pDlg->Insert( SOT_FORMAT_RTF, OUString() );
+
+ TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( &rView.GetEditWin() ) );
+
+ sal_uLong nFormat = pDlg->GetFormat( aDataHelper.GetTransferable() );
+
+ if (nFormat > 0)
+ {
+ if (nFormat == SOT_FORMAT_STRING)
+ pOLV->Paste();
+ else
+ pOLV->PasteSpecial();
+ }
+ delete pDlg;
+ }
+ break;
+ }
+ case SID_CLIPBOARD_FORMAT_ITEMS:
+ {
+ sal_uLong nFormat = 0;
+ const SfxPoolItem* pItem;
+ if ( rReq.GetArgs() && rReq.GetArgs()->GetItemState(nSlot, true, &pItem) == SFX_ITEM_SET &&
+ pItem->ISA(SfxUInt32Item) )
+ {
+ nFormat = ((const SfxUInt32Item*)pItem)->GetValue();
+ }
+
+ if ( nFormat )
+ {
+ if (SOT_FORMAT_STRING == nFormat)
+ pOLV->Paste();
+ else
+ pOLV->PasteSpecial();
+ }
+ break;
+ }
+ }
+ pPostItMgr->GetActiveSidebarWin()->ResizeIfNecessary(aOldHeight,pPostItMgr->GetActiveSidebarWin()->GetPostItTextHeight());
+}
+
+void SwAnnotationShell::StateClpbrd(SfxItemSet &rSet)
+{
+ SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
+ if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() )
+ return;
+ OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView();
+
+ TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( &rView.GetEditWin() ) );
+ bool bPastePossible = ( aDataHelper.HasFormat( SOT_FORMAT_STRING ) || aDataHelper.HasFormat( SOT_FORMAT_RTF ) );
+ bPastePossible = bPastePossible && (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED);
+
+ SfxWhichIter aIter(rSet);
+ sal_uInt16 nWhich = aIter.FirstWhich();
+
+ while(nWhich)
+ {
+ switch(nWhich)
+ {
+ case SID_CUT:
+ {
+ if ( (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()==SwPostItHelper::DELETED) || !pOLV->HasSelection() )
+ rSet.DisableItem( nWhich );
+ }
+ case SID_COPY:
+ {
+ if( !pOLV->HasSelection() )
+ rSet.DisableItem( nWhich );
+ break;
+ }
+ 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 );
+ if ( aDataHelper.HasFormat( SOT_FORMAT_RTF ) )
+ aFormats.AddClipbrdFormat( SOT_FORMAT_RTF );
+ aFormats.AddClipbrdFormat( SOT_FORMAT_STRING );
+ rSet.Put( aFormats );
+ }
+ else
+ rSet.DisableItem( nWhich );
+ break;
+ }
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+void SwAnnotationShell::StateStatusLine(SfxItemSet &rSet)
+{
+ SfxWhichIter aIter( rSet );
+ sal_uInt16 nWhich = aIter.FirstWhich();
+
+ while( nWhich )
+ {
+ switch( nWhich )
+ {
+ case FN_STAT_SELMODE:
+ {
+ rSet.Put(SfxUInt16Item(FN_STAT_SELMODE, 0));
+ rSet.DisableItem( nWhich );
+ break;
+ }
+ case FN_STAT_TEMPLATE:
+ {
+ rSet.DisableItem( nWhich );
+ break;
+ }
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+void SwAnnotationShell::StateInsert(SfxItemSet &rSet)
+{
+ SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
+ if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() )
+ return;
+
+ OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView();
+ SfxWhichIter aIter(rSet);
+ sal_uInt16 nWhich = aIter.FirstWhich();
+
+ while(nWhich)
+ {
+ switch(nWhich)
+ {
+ case SID_HYPERLINK_GETLINK:
+ {
+ SvxHyperlinkItem aHLinkItem;
+ aHLinkItem.SetInsertMode(HLINK_FIELD);
+
+ const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection();
+
+ if (pFieldItem)
+ {
+ const SvxFieldData* pField = pFieldItem->GetField();
+
+ if (pField->ISA(SvxURLField))
+ {
+ aHLinkItem.SetName(((const SvxURLField*) pField)->GetRepresentation());
+ aHLinkItem.SetURL(((const SvxURLField*) pField)->GetURL());
+ aHLinkItem.SetTargetFrame(((const SvxURLField*) pField)->GetTargetFrame());
+ }
+ }
+ else
+ {
+ OUString sSel(pOLV->GetSelected());
+ sSel = sSel.copy(0, std::min<sal_Int32>(255, sSel.getLength()));
+ aHLinkItem.SetName(comphelper::string::stripEnd(sSel, ' '));
+ }
+
+ sal_uInt16 nHtmlMode = ::GetHtmlMode(rView.GetDocShell());
+ aHLinkItem.SetInsertMode((SvxLinkInsertMode)(aHLinkItem.GetInsertMode() |
+ ((nHtmlMode & HTMLMODE_ON) != 0 ? HLINK_HTMLMODE : 0)));
+
+ rSet.Put(aHLinkItem);
+ }
+ break;
+ }
+
+ if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()==SwPostItHelper::DELETED)
+ rSet.DisableItem( nWhich );
+
+ nWhich = aIter.NextWhich();
+ }
+}
+
+void SwAnnotationShell::NoteExec(SfxRequest &rReq)
+{
+ SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
+ if ( !pPostItMgr )
+ return;
+
+ sal_uInt16 nSlot = rReq.GetSlot();
+ switch (nSlot)
+ {
+ case FN_REPLY:
+ case FN_POSTIT:
+ case FN_DELETE_COMMENT:
+ if ( pPostItMgr->HasActiveSidebarWin() )
+ pPostItMgr->GetActiveSidebarWin()->ExecuteCommand(nSlot);
+ break;
+
+ case FN_DELETE_ALL_NOTES:
+ pPostItMgr->Delete();
+ break;
+ case FN_DELETE_NOTE_AUTHOR:
+ {
+ SFX_REQUEST_ARG( rReq, pItem, SfxStringItem, nSlot, false);
+ if ( pItem )
+ pPostItMgr->Delete( pItem->GetValue() );
+ break;
+ }
+ case FN_HIDE_NOTE:
+ break;
+ case FN_HIDE_ALL_NOTES:
+ pPostItMgr->Hide();
+ break;
+ case FN_HIDE_NOTE_AUTHOR:
+ {
+ SFX_REQUEST_ARG( rReq, pItem, SfxStringItem, nSlot, false);
+ if ( pItem )
+ pPostItMgr->Hide( pItem->GetValue() );
+ }
+ }
+}
+
+void SwAnnotationShell::GetNoteState(SfxItemSet &rSet)
+{
+ SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
+ SfxWhichIter aIter(rSet);
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ while(nWhich)
+ {
+ sal_uInt16 nSlotId = GetPool().GetSlotId( nWhich );
+ switch( nSlotId )
+ {
+ case FN_POSTIT:
+ case FN_DELETE_NOTE_AUTHOR:
+ case FN_DELETE_ALL_NOTES:
+ case FN_HIDE_NOTE:
+ case FN_HIDE_NOTE_AUTHOR:
+ case FN_HIDE_ALL_NOTES:
+ case FN_DELETE_COMMENT:
+ {
+ if( !pPostItMgr
+ || !pPostItMgr->HasActiveAnnotationWin() )
+ {
+ rSet.DisableItem(nWhich);
+ }
+ break;
+ }
+
+ case FN_REPLY:
+ {
+ if ( !pPostItMgr ||
+ !pPostItMgr->HasActiveAnnotationWin() )
+ {
+ rSet.DisableItem(nWhich);
+ }
+ else
+ {
+ SvtUserOptions aUserOpt;
+ OUString sAuthor;
+ if( (sAuthor = aUserOpt.GetFullName()).isEmpty() &&
+ (sAuthor = aUserOpt.GetID()).isEmpty() )
+ sAuthor = SW_RES( STR_REDLINE_UNKNOWN_AUTHOR );
+ if (sAuthor == pPostItMgr->GetActiveSidebarWin()->GetAuthor())
+ rSet.DisableItem(nWhich);
+ }
+ break;
+ }
+ default:
+ rSet.InvalidateItem( nWhich );
+ break;
+ }
+
+ if (pPostItMgr->HasActiveSidebarWin())
+ {
+ if ( (pPostItMgr->GetActiveSidebarWin()->IsProtected()) &&
+ ( (nSlotId==FN_DELETE_COMMENT) || (nSlotId==FN_REPLY) ) )
+ rSet.DisableItem( nWhich );
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+void SwAnnotationShell::ExecLingu(SfxRequest &rReq)
+{
+ SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
+ if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() )
+ return;
+
+ OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView();
+ SfxItemSet aEditAttr(pOLV->GetAttribs());
+ sal_uInt16 nSlot = rReq.GetSlot();
+ SwWrtShell &rSh = rView.GetWrtShell();
+ bool bRestoreSelection = false;
+ ESelection aOldSelection;
+
+ switch (nSlot)
+ {
+ case SID_LANGUAGE_STATUS:
+ {
+ aOldSelection = pOLV->GetSelection();
+ if (!pOLV->GetEditView().HasSelection())
+ {
+ bRestoreSelection = true;
+ pOLV->GetEditView().SelectCurrentWord();
+ }
+
+ bRestoreSelection = SwLangHelper::SetLanguageStatus(pOLV,rReq,rView,rSh);
+ break;
+ }
+ case SID_THES:
+ {
+ OUString aReplaceText;
+ SFX_REQUEST_ARG( rReq, pItem2, SfxStringItem, SID_THES, false );
+ if (pItem2)
+ aReplaceText = pItem2->GetValue();
+ if (!aReplaceText.isEmpty())
+ ReplaceTextWithSynonym( pOLV->GetEditView(), aReplaceText );
+ break;
+ }
+ case SID_THESAURUS:
+ {
+ pOLV->StartThesaurus();
+ break;
+ }
+ case SID_HANGUL_HANJA_CONVERSION:
+ pOLV->StartTextConversion( LANGUAGE_KOREAN, LANGUAGE_KOREAN, NULL,
+ i18n::TextConversionOption::CHARACTER_BY_CHARACTER, true, false );
+ 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(
+ OUString("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 = "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( "IsDirectionToSimplified" ) >>= bToSimplified;
+ xProp->getPropertyValue( "IsUseCharacterVariants" ) >>= bUseVariants;
+ xProp->getPropertyValue( "IsTranslateCommonTerms" ) >>= bCommonTerms;
+ }
+ catch (const Exception&)
+ {
+ }
+ }
+
+ //execute translation
+ sal_Int16 nSourceLang = bToSimplified ? LANGUAGE_CHINESE_TRADITIONAL : LANGUAGE_CHINESE_SIMPLIFIED;
+ sal_Int16 nTargetLang = bToSimplified ? LANGUAGE_CHINESE_SIMPLIFIED : LANGUAGE_CHINESE_TRADITIONAL;
+ sal_Int32 nOptions = bUseVariants ? i18n::TextConversionOption::USE_CHARACTER_VARIANTS : 0;
+ if( !bCommonTerms )
+ nOptions = nOptions | i18n::TextConversionOption::CHARACTER_BY_CHARACTER;
+
+ Font aTargetFont = pOLV->GetWindow()->GetDefaultFont( DEFAULTFONT_CJK_TEXT,
+ nTargetLang, DEFAULTFONT_FLAGS_ONLYONE );
+
+ pOLV->StartTextConversion( nSourceLang, nTargetLang, &aTargetFont, nOptions, false, false );
+ }
+ }
+ Reference< lang::XComponent > xComponent( xDialog, UNO_QUERY );
+ if( xComponent.is() )
+ xComponent->dispose();
+ }
+ }
+ }
+ break;
+ }
+
+ if (bRestoreSelection)
+ {
+ // restore selection
+ pOLV->GetEditView().SetSelection( aOldSelection );
+ }
+}
+
+void SwAnnotationShell::GetLinguState(SfxItemSet &rSet)
+{
+ SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
+ if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() )
+ return;
+
+ OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView();
+ SfxItemSet aEditAttr(pOLV->GetAttribs());
+
+ SfxWhichIter aIter(rSet);
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ while(nWhich)
+ {
+ switch (nWhich)
+ {
+ case SID_LANGUAGE_STATUS:
+ {
+ SwLangHelper::GetLanguageStatus(pOLV,rSet);
+ break;
+ }
+
+ case SID_THES:
+ {
+ OUString aStatusVal;
+ LanguageType nLang = LANGUAGE_NONE;
+ bool bIsLookUpWord = GetStatusValueForThesaurusFromContext( aStatusVal, nLang, pOLV->GetEditView() );
+ rSet.Put( SfxStringItem( SID_THES, aStatusVal ) );
+
+ // disable "Thesaurus" context menu entry if there is nothing to look up
+ uno::Reference< linguistic2::XThesaurus > xThes( ::GetThesaurus() );
+ if (!bIsLookUpWord ||
+ !xThes.is() || nLang == LANGUAGE_NONE || !xThes->hasLocale( LanguageTag::convertToLocale( nLang ) ))
+ rSet.DisableItem( SID_THES );
+ break;
+ }
+
+ // disable "Thesaurus" if the language is not supported
+ case SID_THESAURUS:
+ {
+ const SfxPoolItem &rItem = rView.GetWrtShell().GetDoc()->GetDefault(
+ GetWhichOfScript( RES_CHRATR_LANGUAGE,
+ GetI18NScriptTypeOfLanguage( (sal_uInt16)GetAppLanguage())) );
+ LanguageType nLang = ((const SvxLanguageItem &)
+ rItem).GetLanguage();
+ uno::Reference< linguistic2::XThesaurus > xThes( ::GetThesaurus() );
+ if (!xThes.is() || nLang == LANGUAGE_NONE ||
+ !xThes->hasLocale( LanguageTag::convertToLocale( nLang ) ))
+ rSet.DisableItem( SID_THESAURUS );
+ }
+ break;
+ case SID_HANGUL_HANJA_CONVERSION:
+ case SID_CHINESE_CONVERSION:
+ {
+ if (!SvtCJKOptions().IsAnyEnabled())
+ {
+ rView.GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_False );
+ rSet.DisableItem(nWhich);
+ }
+ else
+ rView.GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_True );
+ }
+ break;
+ }
+
+ if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()==SwPostItHelper::DELETED)
+ rSet.DisableItem( nWhich );
+
+ nWhich = aIter.NextWhich();
+ }
+}
+
+void SwAnnotationShell::ExecTransliteration(SfxRequest &rReq)
+{
+ SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
+ if (!pPostItMgr || !pPostItMgr->HasActiveSidebarWin())
+ return;
+
+ OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView();
+
+ if (!pOLV)
+ return;
+
+ using namespace ::com::sun::star::i18n;
+
+ sal_uInt32 nMode = 0;
+
+ switch( rReq.GetSlot() )
+ {
+ case SID_TRANSLITERATE_SENTENCE_CASE:
+ nMode = TransliterationModulesExtra::SENTENCE_CASE;
+ break;
+ case SID_TRANSLITERATE_TITLE_CASE:
+ nMode = TransliterationModulesExtra::TITLE_CASE;
+ break;
+ case SID_TRANSLITERATE_TOGGLE_CASE:
+ nMode = TransliterationModulesExtra::TOGGLE_CASE;
+ break;
+ case SID_TRANSLITERATE_UPPER:
+ nMode = TransliterationModules_LOWERCASE_UPPERCASE;
+ break;
+ case SID_TRANSLITERATE_LOWER:
+ nMode = TransliterationModules_UPPERCASE_LOWERCASE;
+ break;
+ case SID_TRANSLITERATE_HALFWIDTH:
+ nMode = TransliterationModules_FULLWIDTH_HALFWIDTH;
+ break;
+ case SID_TRANSLITERATE_FULLWIDTH:
+ nMode = TransliterationModules_HALFWIDTH_FULLWIDTH;
+ break;
+ case SID_TRANSLITERATE_HIRAGANA:
+ nMode = TransliterationModules_KATAKANA_HIRAGANA;
+ break;
+ case SID_TRANSLITERATE_KATAGANA:
+ nMode = TransliterationModules_HIRAGANA_KATAKANA;
+ break;
+
+ default:
+ OSL_ENSURE(!this, "wrong dispatcher");
+ }
+
+ if( nMode )
+ pOLV->TransliterateText( nMode );
+}
+
+void SwAnnotationShell::ExecRotateTransliteration( SfxRequest & rReq )
+{
+ if( rReq.GetSlot() == SID_TRANSLITERATE_ROTATE_CASE )
+ {
+ SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
+ if (!pPostItMgr || !pPostItMgr->HasActiveSidebarWin())
+ return;
+
+ OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView();
+
+ if (!pOLV)
+ return;
+
+ pOLV->TransliterateText(m_aRotateCase.getNextMode());
+ }
+}
+
+void SwAnnotationShell::ExecUndo(SfxRequest &rReq)
+{
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ ::svl::IUndoManager* pUndoManager = GetUndoManager();
+ SwWrtShell &rSh = rView.GetWrtShell();
+
+ long aOldHeight = rView.GetPostItMgr()->HasActiveSidebarWin()
+ ? rView.GetPostItMgr()->GetActiveSidebarWin()->GetPostItTextHeight()
+ : 0;
+
+ sal_uInt16 nId = rReq.GetSlot();
+ sal_uInt16 nCnt = 1;
+ const SfxPoolItem* pItem=0;
+ if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( nId, false, &pItem ) )
+ nCnt = ((SfxUInt16Item*)pItem)->GetValue();
+ switch( nId )
+ {
+ case SID_UNDO:
+ {
+ if ( pUndoManager )
+ {
+ sal_uInt16 nCount = pUndoManager->GetUndoActionCount();
+ sal_uInt16 nSteps = nCnt;
+ if ( nCount < nCnt )
+ {
+ nCnt = nCnt - nCount;
+ nSteps = nCount;
+ }
+ else
+ nCnt = 0;
+
+ while( nSteps-- )
+ pUndoManager->Undo();
+ }
+
+ if ( nCnt )
+ rSh.Do( SwWrtShell::UNDO, nCnt );
+
+ break;
+ }
+
+ case SID_REDO:
+ {
+ if ( pUndoManager )
+ {
+ sal_uInt16 nCount = pUndoManager->GetRedoActionCount();
+ sal_uInt16 nSteps = nCnt;
+ if ( nCount < nCnt )
+ {
+ nCnt = nCnt - nCount;
+ nSteps = nCount;
+ }
+ else
+ nCnt = 0;
+
+ while( nSteps-- )
+ pUndoManager->Redo();
+ }
+
+ if ( nCnt )
+ rSh.Do( SwWrtShell::REDO, nCnt );
+
+ break;
+ }
+ }
+
+ rView.GetViewFrame()->GetBindings().InvalidateAll(sal_False);
+
+ if (rView.GetPostItMgr()->HasActiveSidebarWin())
+ rView.GetPostItMgr()->GetActiveSidebarWin()->ResizeIfNecessary(aOldHeight,rView.GetPostItMgr()->GetActiveSidebarWin()->GetPostItTextHeight());
+}
+
+void SwAnnotationShell::StateUndo(SfxItemSet &rSet)
+{
+ SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
+ if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() )
+ return;
+
+ SfxWhichIter aIter(rSet);
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ ::svl::IUndoManager* pUndoManager = GetUndoManager();
+ SfxViewFrame *pSfxViewFrame = rView.GetViewFrame();
+ SwWrtShell &rSh = rView.GetWrtShell();
+
+ while( nWhich )
+ {
+ switch ( nWhich )
+ {
+ case SID_UNDO:
+ {
+ sal_uInt16 nCount = pUndoManager->GetUndoActionCount();
+ if ( nCount )
+ pSfxViewFrame->GetSlotState( nWhich, pSfxViewFrame->GetInterface(), &rSet );
+ else if (rSh.GetLastUndoInfo(0, 0))
+ {
+ rSet.Put( SfxStringItem( nWhich, rSh.GetDoString(SwWrtShell::UNDO)) );
+ }
+ else
+ rSet.DisableItem(nWhich);
+ break;
+ }
+ case SID_REDO:
+ {
+ sal_uInt16 nCount = pUndoManager->GetRedoActionCount();
+ if ( nCount )
+ pSfxViewFrame->GetSlotState( nWhich, pSfxViewFrame->GetInterface(), &rSet );
+ else if (rSh.GetFirstRedoInfo(0))
+ {
+ rSet.Put(SfxStringItem( nWhich, rSh.GetDoString(SwWrtShell::REDO)) );
+ }
+ else
+ rSet.DisableItem(nWhich);
+ break;
+ }
+ case SID_GETUNDOSTRINGS:
+ case SID_GETREDOSTRINGS:
+ {
+ if( pUndoManager )
+ {
+ OUString (::svl::IUndoManager:: *fnGetComment)( size_t, bool const ) const;
+
+ sal_uInt16 nCount;
+ if( SID_GETUNDOSTRINGS == nWhich )
+ {
+ nCount = pUndoManager->GetUndoActionCount();
+ fnGetComment = &::svl::IUndoManager::GetUndoActionComment;
+ }
+ else
+ {
+ nCount = pUndoManager->GetRedoActionCount();
+ fnGetComment = &::svl::IUndoManager::GetRedoActionComment;
+ }
+
+ OUString sList;
+ if( nCount )
+ {
+ for( sal_uInt16 n = 0; n < nCount; ++n )
+ sList += (pUndoManager->*fnGetComment)( n, ::svl::IUndoManager::TopLevel ) + "\n";
+ }
+
+ SfxStringListItem aItem( nWhich );
+ if ((nWhich == SID_GETUNDOSTRINGS) &&
+ rSh.GetLastUndoInfo(0, 0))
+ {
+ rSh.GetDoStrings( SwWrtShell::UNDO, aItem );
+ }
+ else if ((nWhich == SID_GETREDOSTRINGS) &&
+ (rSh.GetFirstRedoInfo(0)))
+ {
+ rSh.GetDoStrings( SwWrtShell::UNDO, aItem );
+ }
+
+ sList += aItem.GetString();
+ aItem.SetString( sList );
+ rSet.Put( aItem );
+ }
+ else
+ rSet.DisableItem( nWhich );
+ }
+ break;
+
+ default:
+ {
+ pSfxViewFrame->GetSlotState( nWhich, pSfxViewFrame->GetInterface(), &rSet );
+ break;
+ }
+
+ }
+
+ if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()==SwPostItHelper::DELETED)
+ rSet.DisableItem( nWhich );
+
+ nWhich = aIter.NextWhich();
+ }
+}
+
+void SwAnnotationShell::StateDisableItems( SfxItemSet &rSet )
+{
+ SfxWhichIter aIter(rSet);
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ while (nWhich)
+ {
+ rSet.DisableItem( nWhich );
+ nWhich = aIter.NextWhich();
+ }
+}
+
+void SwAnnotationShell::InsertSymbol(SfxRequest& rReq)
+{
+ SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
+ if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() )
+ return;
+
+ OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView();
+
+ const SfxItemSet *pArgs = rReq.GetArgs();
+ const SfxPoolItem* pItem = 0;
+ if( pArgs )
+ pArgs->GetItemState(GetPool().GetWhich(SID_CHARMAP), false, &pItem);
+
+ OUString sSym;
+ OUString sFontName;
+ if ( pItem )
+ {
+ sSym = ((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 )
+ sFontName = pFontItem->GetValue();
+ }
+
+ SfxItemSet aSet(pOLV->GetAttribs());
+ sal_uInt16 nScript = pOLV->GetSelectedScriptType();
+ SvxFontItem aSetDlgFont( RES_CHRATR_FONT );
+ {
+ SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONT, *aSet.GetPool() );
+ aSetItem.GetItemSet().Put( aSet, false );
+ const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScript );
+ if( pI )
+ aSetDlgFont = *(SvxFontItem*)pI;
+ else
+ aSetDlgFont = (SvxFontItem&)aSet.Get( GetWhichOfScript(
+ SID_ATTR_CHAR_FONT,
+ GetI18NScriptTypeOfLanguage( (sal_uInt16)GetAppLanguage() ) ));
+ if (sFontName.isEmpty())
+ sFontName = aSetDlgFont.GetFamilyName();
+ }
+
+ Font aFont(sFontName, Size(1,1));
+ if( sSym.isEmpty() )
+ {
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+
+ SfxAllItemSet aAllSet( GetPool() );
+ aAllSet.Put( SfxBoolItem( FN_PARAM_1, false ) );
+
+ SwViewOption aOpt(*rView.GetWrtShell().GetViewOptions());
+ OUString sSymbolFont = aOpt.GetSymbolFont();
+ if( !sSymbolFont.isEmpty() )
+ aAllSet.Put( SfxStringItem( SID_FONT_NAME, sSymbolFont ) );
+ else
+ aAllSet.Put( SfxStringItem( SID_FONT_NAME, aSetDlgFont.GetFamilyName() ) );
+
+ // If character is selected then it can be shown.
+ SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( rView.GetWindow(), aAllSet,
+ rView.GetViewFrame()->GetFrame().GetFrameInterface(), RID_SVXDLG_CHARMAP );
+
+ sal_uInt16 nResult = pDlg->Execute();
+ if( nResult == RET_OK )
+ {
+ SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pCItem, SfxStringItem, SID_CHARMAP, false );
+ SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pFontItem, SvxFontItem, SID_ATTR_CHAR_FONT, false );
+ if ( pFontItem )
+ {
+ aFont.SetName( pFontItem->GetFamilyName() );
+ aFont.SetStyleName( pFontItem->GetStyleName() );
+ aFont.SetCharSet( pFontItem->GetCharSet() );
+ aFont.SetPitch( pFontItem->GetPitch() );
+ }
+
+ if ( pCItem )
+ {
+ sSym = pCItem->GetValue();
+ aOpt.SetSymbolFont(aFont.GetName());
+ SW_MOD()->ApplyUsrPref(aOpt, &rView);
+ }
+ }
+
+ delete( pDlg );
+ }
+
+ if( !sSym.isEmpty() )
+ {
+ // do not flicker
+ pOLV->HideCursor();
+ Outliner * pOutliner = pOLV->GetOutliner();
+ pOutliner->SetUpdateMode(false);
+
+ SfxItemSet aOldSet( pOLV->GetAttribs() );
+ SfxItemSet aFontSet( *aOldSet.GetPool(),
+ EE_CHAR_FONTINFO, EE_CHAR_FONTINFO,
+ EE_CHAR_FONTINFO_CJK, EE_CHAR_FONTINFO_CJK,
+ EE_CHAR_FONTINFO_CTL, EE_CHAR_FONTINFO_CTL,
+ 0 );
+ aFontSet.Set( aOldSet );
+
+ // Insert string
+ pOLV->InsertText( sSym);
+
+ // Attributing (set font)
+ SfxItemSet aSetFont( *aFontSet.GetPool(), aFontSet.GetRanges() );
+ SvxFontItem aFontItem (aFont.GetFamily(), aFont.GetName(),
+ aFont.GetStyleName(), aFont.GetPitch(),
+ aFont.GetCharSet(),
+ EE_CHAR_FONTINFO );
+ sal_uInt16 nScriptBreak = g_pBreakIt->GetAllScriptsOfText( sSym );
+ if( SCRIPTTYPE_LATIN & nScriptBreak )
+ aSetFont.Put( aFontItem, EE_CHAR_FONTINFO );
+ if( SCRIPTTYPE_ASIAN & nScriptBreak )
+ aSetFont.Put( aFontItem, EE_CHAR_FONTINFO_CJK );
+ if( SCRIPTTYPE_COMPLEX & nScriptBreak )
+ aSetFont.Put( aFontItem, EE_CHAR_FONTINFO_CTL );
+ pOLV->SetAttribs(aSetFont);
+
+ // Erase selection
+ ESelection aSel(pOLV->GetSelection());
+ aSel.nStartPara = aSel.nEndPara;
+ aSel.nStartPos = aSel.nEndPos;
+ pOLV->SetSelection(aSel);
+
+ // Restore old font
+ pOLV->SetAttribs( aFontSet );
+
+ // From now on show it again
+ pOutliner->SetUpdateMode(true);
+ pOLV->ShowCursor();
+
+ rReq.AppendItem( SfxStringItem( GetPool().GetWhich(SID_CHARMAP), sSym ) );
+ if(!aFont.GetName().isEmpty())
+ rReq.AppendItem( SfxStringItem( SID_ATTR_SPECIALCHAR, aFont.GetName() ) );
+ rReq.Done();
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/shells/basesh.cxx b/sw/source/core/uibase/shells/basesh.cxx
new file mode 100644
index 000000000000..797f9dee8749
--- /dev/null
+++ b/sw/source/core/uibase/shells/basesh.cxx
@@ -0,0 +1,2832 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <sot/factory.hxx>
+#include <hintids.hxx>
+#include <svl/urihelper.hxx>
+#include <svl/languageoptions.hxx>
+
+#include <svx/svxids.hrc>
+#include <sfx2/linkmgr.hxx>
+#include <sfx2/htmlmode.hxx>
+#include <svx/imapdlg.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/request.hxx>
+#include <svl/whiter.hxx>
+#include <svl/visitem.hxx>
+#include <sfx2/objitem.hxx>
+#include <vcl/graphicfilter.hxx>
+#include <svx/gallery.hxx>
+#include <editeng/langitem.hxx>
+#include <svx/clipfmtitem.hxx>
+#include <svx/contdlg.hxx>
+#include <vcl/graph.hxx>
+#include <svl/slstitm.hxx>
+#include <vcl/msgbox.hxx>
+#include <svl/ptitem.hxx>
+#include <svl/itemiter.hxx>
+#include <svl/stritem.hxx>
+#include <editeng/colritem.hxx>
+#include <editeng/shaditem.hxx>
+#include <editeng/boxitem.hxx>
+#include <svl/srchitem.hxx>
+#include <editeng/ulspitem.hxx>
+#include <editeng/lrspitem.hxx>
+#include <editeng/brushitem.hxx>
+#include <editeng/opaqitem.hxx>
+#include <editeng/sizeitem.hxx>
+#include <svx/flagsdef.hxx>
+#include <editeng/scripttypeitem.hxx>
+#include <sfx2/objface.hxx>
+#include <fmturl.hxx>
+#include <fmthdft.hxx>
+#include <fmtclds.hxx>
+#include <docsh.hxx>
+#include <wrtsh.hxx>
+#include <view.hxx>
+#include <swmodule.hxx>
+#include <swundo.hxx>
+#include <fldbas.hxx>
+#include <uitool.hxx>
+#include <basesh.hxx>
+#include <viewopt.hxx>
+#include <fontcfg.hxx>
+#include <docstat.hxx>
+#include <usrfld.hxx>
+#include <expfld.hxx>
+#include <fldmgr.hxx>
+#include <frmmgr.hxx>
+#include <tablemgr.hxx>
+#include <mdiexp.hxx>
+#include <swdtflvr.hxx>
+#include <pagedesc.hxx>
+#include <convert.hxx>
+#include <fmtcol.hxx>
+#include <edtwin.hxx>
+#include <tblafmt.hxx>
+#include <caption.hxx>
+#include <swwait.hxx>
+#include <cmdid.h>
+#include <globals.hrc>
+#include <shells.hrc>
+#include <statstr.hrc>
+#include <globals.h>
+#include <unotxdoc.hxx>
+#include <crsskip.hxx>
+#include <fmtinfmt.hxx>
+#include <doc.hxx>
+
+#include "swabstdlg.hxx"
+#include "dialog.hrc"
+#include "fldui.hrc"
+#include "table.hrc"
+#include <modcfg.hxx>
+#include <instable.hxx>
+#include <svx/fmshell.hxx>
+#include <SwRewriter.hxx>
+#include <comcore.hrc>
+
+#include <unomid.h>
+#include <svx/galleryitem.hxx>
+#include <com/sun/star/gallery/GalleryItemType.hpp>
+
+FlyMode SwBaseShell::eFrameMode = FLY_DRAG_END;
+
+// These variables keep the state of Gallery (slot SID_GALLERY_BG_BRUSH)
+// detected by GetGalleryState() for the subsequent ExecuteGallery() call.
+
+static sal_uInt8 nParagraphPos;
+static sal_uInt8 nGraphicPos;
+static sal_uInt8 nOlePos;
+static sal_uInt8 nFramePos;
+static sal_uInt8 nTablePos;
+static sal_uInt8 nTableRowPos;
+static sal_uInt8 nTableCellPos;
+static sal_uInt8 nPagePos;
+static sal_uInt8 nHeaderPos;
+static sal_uInt8 nFooterPos;
+
+#define SwBaseShell
+#include <sfx2/msg.hxx>
+#include "swslots.hxx"
+
+#define SWCONTOURDLG(rView) ( (SvxContourDlg*) ( rView.GetViewFrame()->GetChildWindow( \
+ SvxContourDlgChildWindow::GetChildWindowId() )-> \
+ GetWindow() ) )
+
+#define SWIMAPDLG(rView) ( (SvxIMapDlg*) ( rView.GetViewFrame()->GetChildWindow( \
+ SvxIMapDlgChildWindow::GetChildWindowId() )-> \
+ GetWindow() ) )
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::lang;
+
+SFX_IMPL_INTERFACE(SwBaseShell, SfxShell, SW_RES(0))
+{
+ SFX_CHILDWINDOW_REGISTRATION(SvxIMapDlgChildWindow::GetChildWindowId());
+ SFX_CHILDWINDOW_REGISTRATION(SvxContourDlgChildWindow::GetChildWindowId());
+}
+
+TYPEINIT1(SwBaseShell,SfxShell)
+
+static void lcl_UpdateIMapDlg( SwWrtShell& rSh )
+{
+ Graphic aGrf( rSh.GetIMapGraphic() );
+ GraphicType nGrfType = aGrf.GetType();
+ void* pEditObj = GRAPHIC_NONE != nGrfType && GRAPHIC_DEFAULT != nGrfType
+ ? rSh.GetIMapInventor() : 0;
+ TargetList* pList = new TargetList;
+ rSh.GetView().GetViewFrame()->GetTopFrame().GetTargetList(*pList);
+
+ SfxItemSet aSet( rSh.GetAttrPool(), RES_URL, RES_URL );
+ rSh.GetFlyFrmAttr( aSet );
+ const SwFmtURL &rURL = (SwFmtURL&)aSet.Get( RES_URL );
+ SvxIMapDlgChildWindow::UpdateIMapDlg(
+ aGrf, rURL.GetMap(), pList, pEditObj );
+
+ delete pList;
+}
+
+static bool lcl_UpdateContourDlg( SwWrtShell &rSh, int nSel )
+{
+ Graphic aGraf( rSh.GetIMapGraphic() );
+ GraphicType nGrfType = aGraf.GetType();
+ bool bRet = GRAPHIC_NONE != nGrfType && GRAPHIC_DEFAULT != nGrfType;
+ if( bRet )
+ {
+ OUString aGrfName;
+ if ( nSel & nsSelectionType::SEL_GRF )
+ rSh.GetGrfNms( &aGrfName, 0 );
+
+ SvxContourDlg *pDlg = SWCONTOURDLG(rSh.GetView());
+ pDlg->Update( aGraf, !aGrfName.isEmpty(),
+ rSh.GetGraphicPolygon(), rSh.GetIMapInventor() );
+ }
+ return bRet;
+}
+
+void SwBaseShell::ExecDelete(SfxRequest &rReq)
+{
+ SwWrtShell &rSh = GetShell();
+ SwEditWin& rTmpEditWin = GetView().GetEditWin();
+ switch(rReq.GetSlot())
+ {
+ case SID_DELETE:
+ rSh.DelRight();
+ break;
+
+ case FN_BACKSPACE:
+
+ if( rSh.IsNoNum() )
+ {
+ rSh.SttCrsrMove();
+ sal_Bool bLeft = rSh.Left( CRSR_SKIP_CHARS, sal_True, 1, sal_False );
+ if( bLeft )
+ {
+ rSh.DelLeft();
+ }
+ else
+ // JP 15.07.96: If it no longer goes forward, cancel
+ // the numbering. For example at the beginning
+ // of a doc, frame, table or an area.
+ rSh.DelNumRules();
+
+ rSh.EndCrsrMove();
+ break;
+ }
+
+ // otherwise call DelLeft
+ case FN_SHIFT_BACKSPACE:
+ rSh.DelLeft();
+ break;
+ default:
+ OSL_FAIL("wrong Dispatcher");
+ return;
+ }
+ rReq.Done();
+
+ //#i42732# - notify the edit window that from now on we do not use the input language
+ rTmpEditWin.SetUseInputLanguage( sal_False );
+}
+
+void SwBaseShell::ExecClpbrd(SfxRequest &rReq)
+{
+ // Attention: At risk of suicide!
+ // After paste, paste special the shell can be destroy.
+
+ SwWrtShell &rSh = GetShell();
+ sal_uInt16 nId = rReq.GetSlot();
+ bool bIgnore = false;
+ switch( nId )
+ {
+ case SID_CUT:
+ case SID_COPY:
+ rView.GetEditWin().FlushInBuffer();
+ if ( rSh.HasSelection() )
+ {
+ SwTransferable* pTransfer = new SwTransferable( rSh );
+/*??*/ uno::Reference< datatransfer::XTransferable > xRef( pTransfer );
+
+ if ( nId == SID_CUT && !rSh.IsSelObjProtected(FLYPROTECT_CONTENT|FLYPROTECT_PARENT) )
+ pTransfer->Cut();
+ else
+ {
+ const sal_Bool bLockedView = rSh.IsViewLocked();
+ rSh.LockView( sal_True ); //lock visible section
+ pTransfer->Copy();
+ rSh.LockView( bLockedView );
+ }
+ break;
+ }
+ return;
+
+ case SID_PASTE:
+ {
+ TransferableDataHelper aDataHelper(
+ TransferableDataHelper::CreateFromSystemClipboard( &rSh.GetView().GetEditWin() ) );
+ if( aDataHelper.GetXTransferable().is()
+ && SwTransferable::IsPaste( rSh, aDataHelper )
+ && !rSh.CrsrInsideInputFld() )
+ {
+ // Temporary variables, because the shell could already be
+ // destroyed after the paste.
+ SwView* pView = &rView;
+ SwTransferable::Paste( rSh, aDataHelper );
+ if( rSh.IsFrmSelected() || rSh.IsObjSelected() )
+ rSh.EnterSelFrmMode();
+ pView->AttrChangedNotify( &rSh );
+ }
+ else
+ return;
+ }
+ break;
+
+ case SID_CLIPBOARD_FORMAT_ITEMS:
+ {
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ const SfxPoolItem* pFmt;
+ if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( nId, false, &pFmt ) )
+ {
+ TransferableDataHelper aDataHelper(
+ TransferableDataHelper::CreateFromSystemClipboard(
+ &rSh.GetView().GetEditWin()) );
+ if( aDataHelper.GetXTransferable().is()
+ /*&& SwTransferable::IsPaste( rSh, aDataHelper )*/ )
+ {
+ // Temporary variables, because the shell could already be
+ // destroyed after the paste.
+ SwView* pView = &rView;
+
+ SwTransferable::PasteFormat( rSh, aDataHelper,
+ ((SfxUInt32Item*)pFmt)->GetValue() );
+
+ //Done() has to be called before the shell has been removed
+ rReq.Done();
+ bIgnore = true;
+ if( rSh.IsFrmSelected() || rSh.IsObjSelected())
+ rSh.EnterSelFrmMode();
+ pView->AttrChangedNotify( &rSh );
+ }
+ }
+ }
+ break;
+
+ case SID_PASTE_UNFORMATTED:
+ {
+ TransferableDataHelper aDataHelper(
+ TransferableDataHelper::CreateFromSystemClipboard( &rSh.GetView().GetEditWin()) );
+ if( aDataHelper.GetXTransferable().is()
+ && SwTransferable::IsPaste( rSh, aDataHelper ) )
+ {
+ // Temporary variables, because the shell could already be
+ // destroyed after the paste.
+ SwView* pView = &rView;
+ rReq.Ignore();
+ bIgnore = true;
+ if(SwTransferable::PasteUnformatted( rSh, aDataHelper ))
+ {
+ SfxViewFrame* pViewFrame = pView->GetViewFrame();
+ uno::Reference< frame::XDispatchRecorder > xRecorder =
+ pViewFrame->GetBindings().GetRecorder();
+ if(xRecorder.is()) {
+ SfxRequest aReq( pViewFrame, SID_CLIPBOARD_FORMAT_ITEMS );
+ aReq.AppendItem( SfxUInt32Item( SID_CLIPBOARD_FORMAT_ITEMS, SOT_FORMAT_STRING ) );
+ aReq.Done();
+ }
+ }
+
+ if (rSh.IsFrmSelected() || rSh.IsObjSelected())
+ rSh.EnterSelFrmMode();
+ pView->AttrChangedNotify( &rSh );
+ }
+ else
+ return;
+ }
+ break;
+
+ case SID_PASTE_SPECIAL:
+ {
+ TransferableDataHelper aDataHelper(
+ TransferableDataHelper::CreateFromSystemClipboard( &rSh.GetView().GetEditWin()) );
+ if( aDataHelper.GetXTransferable().is()
+ && SwTransferable::IsPaste( rSh, aDataHelper )
+ && !rSh.CrsrInsideInputFld() )
+ {
+ // Temporary variables, because the shell could already be
+ // destroyed after the paste.
+ SwView* pView = &rView;
+ sal_uLong nFormatId = 0;
+ rReq.Ignore();
+ bIgnore = true;
+ if(SwTransferable::PasteSpecial( rSh, aDataHelper, nFormatId ))
+ {
+ SfxViewFrame* pViewFrame = pView->GetViewFrame();
+ uno::Reference< frame::XDispatchRecorder > xRecorder =
+ pViewFrame->GetBindings().GetRecorder();
+ if(xRecorder.is()) {
+ SfxRequest aReq( pViewFrame, SID_CLIPBOARD_FORMAT_ITEMS );
+ aReq.AppendItem( SfxUInt32Item( SID_CLIPBOARD_FORMAT_ITEMS, nFormatId ) );
+ aReq.Done();
+ }
+ }
+
+ if (rSh.IsFrmSelected() || rSh.IsObjSelected())
+ rSh.EnterSelFrmMode();
+ pView->AttrChangedNotify( &rSh );
+ }
+ else
+ return;
+ }
+ break;
+
+ default:
+ OSL_FAIL("wrong Dispatcher");
+ return;
+ }
+ if(!bIgnore)
+ rReq.Done();
+}
+
+// ClipBoard state
+
+void SwBaseShell::StateClpbrd(SfxItemSet &rSet)
+{
+ SwWrtShell &rSh = GetShell();
+ SfxWhichIter aIter(rSet);
+
+ const sal_Bool bCopy = rSh.HasSelection();
+
+ sal_uInt16 nWhich = aIter.FirstWhich();
+
+ while(nWhich)
+ {
+ switch(nWhich)
+ {
+ case SID_CUT:
+ if( 0 != rSh.IsSelObjProtected(FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) )
+ {
+ rSet.DisableItem( nWhich );
+ break;
+ }
+ case SID_COPY:
+ if( !bCopy )
+ rSet.DisableItem( nWhich );
+ break;
+
+ case SID_PASTE:
+ if( !GetView().IsPasteAllowed()
+ || rSh.CrsrInsideInputFld() )
+ {
+ rSet.DisableItem( nWhich );
+ }
+ break;
+
+ case SID_PASTE_SPECIAL:
+ if( !GetView().IsPasteSpecialAllowed()
+ || rSh.CrsrInsideInputFld() )
+ {
+ rSet.DisableItem( nWhich );
+ }
+ break;
+
+ case SID_PASTE_UNFORMATTED:
+ if( !GetView().IsPasteSpecialAllowed() )
+ {
+ rSet.DisableItem( nWhich );
+ }
+ break;
+
+ case SID_CLIPBOARD_FORMAT_ITEMS:
+ {
+ TransferableDataHelper aDataHelper(
+ TransferableDataHelper::CreateFromSystemClipboard(
+ &rSh.GetView().GetEditWin()) );
+
+ SvxClipboardFmtItem aFmtItem( nWhich );
+ SwTransferable::FillClipFmtItem( rSh, aDataHelper, aFmtItem );
+ rSet.Put( aFmtItem );
+ }
+ break;
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+// Perform undo
+
+void SwBaseShell::ExecUndo(SfxRequest &rReq)
+{
+ SwWrtShell &rSh = GetShell();
+
+ sal_uInt16 nId = rReq.GetSlot(), nCnt = 1;
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ const SfxPoolItem* pItem;
+ if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( nId, false, &pItem ))
+ nCnt = ((SfxUInt16Item*)pItem)->GetValue();
+
+ // #i106349#: save pointer: undo/redo may delete the shell, i.e., this!
+ SfxViewFrame *const pViewFrame( GetView().GetViewFrame() );
+
+ switch( nId )
+ {
+ case SID_UNDO:
+ rSh.LockPaint();
+ rSh.Do( SwWrtShell::UNDO, nCnt );
+ rSh.UnlockPaint();
+ break;
+
+ case SID_REDO:
+ rSh.LockPaint();
+ rSh.Do( SwWrtShell::REDO, nCnt );
+ rSh.UnlockPaint();
+ break;
+
+ case SID_REPEAT:
+ rSh.Do( SwWrtShell::REPEAT );
+ break;
+ default:
+ OSL_FAIL("wrong Dispatcher");
+ }
+
+ if (pViewFrame) { pViewFrame->GetBindings().InvalidateAll(sal_False); }
+}
+
+// State of undo
+
+void SwBaseShell::StateUndo(SfxItemSet &rSet)
+{
+ SwWrtShell &rSh = GetShell();
+ SfxWhichIter aIter(rSet);
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ while(nWhich)
+ {
+ switch(nWhich)
+ {
+ case SID_UNDO:
+ {
+ if (rSh.GetLastUndoInfo(0, 0))
+ {
+ rSet.Put( SfxStringItem(nWhich,
+ rSh.GetDoString(SwWrtShell::UNDO)));
+ }
+ else
+ rSet.DisableItem(nWhich);
+ break;
+ }
+ case SID_REDO:
+ {
+ if (rSh.GetFirstRedoInfo(0))
+ {
+ rSet.Put(SfxStringItem(nWhich,
+ rSh.GetDoString(SwWrtShell::REDO)));
+ }
+ else
+ rSet.DisableItem(nWhich);
+ break;
+ }
+ case SID_REPEAT:
+ { // Repeat is only possible if no REDO is possible - UI-Restriction
+ if ((!rSh.GetFirstRedoInfo(0)) &&
+ !rSh.IsSelFrmMode() &&
+ (UNDO_EMPTY != rSh.GetRepeatInfo(0)))
+ {
+ rSet.Put(SfxStringItem(nWhich, rSh.GetRepeatString()));
+ }
+ else
+ rSet.DisableItem(nWhich);
+ break;
+ }
+
+ case SID_GETUNDOSTRINGS:
+ if (rSh.GetLastUndoInfo(0, 0))
+ {
+ SfxStringListItem aStrLst( nWhich );
+ rSh.GetDoStrings( SwWrtShell::UNDO, aStrLst );
+ rSet.Put( aStrLst );
+ }
+ else
+ rSet.DisableItem( nWhich );
+ break;
+
+ case SID_GETREDOSTRINGS:
+ if (rSh.GetFirstRedoInfo(0))
+ {
+ SfxStringListItem aStrLst( nWhich );
+ rSh.GetDoStrings( SwWrtShell::REDO, aStrLst );
+ rSet.Put( aStrLst );
+ }
+ else
+ rSet.DisableItem( nWhich );
+ break;
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+// Evaluate respectively dispatching the slot Id
+
+void SwBaseShell::Execute(SfxRequest &rReq)
+{
+ const SfxPoolItem *pItem;
+ SwWrtShell &rSh = GetShell();
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ bool bMore = false;
+
+ sal_uInt16 nSlot = rReq.GetSlot();
+ switch(nSlot)
+ {
+ case FN_REPAGINATE:
+ {
+ Reference < XModel > xModel = GetView().GetDocShell()->GetModel();
+ Reference < XUnoTunnel > xDocTunnel ( xModel, UNO_QUERY );
+ SwXTextDocument *pDoc = reinterpret_cast < SwXTextDocument * > ( xDocTunnel->getSomething ( SwXTextDocument::getUnoTunnelId() ) );
+ pDoc->NotifyRefreshListeners();
+ rSh.CalcLayout();
+ }
+ break;
+ case FN_UPDATE_FIELDS:
+ {
+ rSh.UpdateDocStat();
+ rSh.EndAllTblBoxEdit();
+ rSh.SwViewShell::UpdateFlds(sal_True);
+
+ if( rSh.IsCrsrInTbl() )
+ {
+ if( !rSh.IsTblComplexForChart() )
+ SwTableFUNC( &rSh, sal_False).UpdateChart();
+ rSh.ClearTblBoxCntnt();
+ rSh.SaveTblBoxCntnt();
+ }
+ }
+ break;
+ case FN_UPDATE_CHARTS:
+ {
+ SwWait aWait( *rView.GetDocShell(), true );
+ rSh.UpdateAllCharts();
+ }
+ break;
+
+ case FN_UPDATE_ALL:
+ {
+ SwView& rTempView = GetView();
+ rSh.EnterStdMode();
+ if( !rSh.GetLinkManager().GetLinks().empty() )
+ {
+ rSh.StartAllAction();
+ rSh.GetLinkManager().UpdateAllLinks( false, true, true );
+ rSh.EndAllAction();
+ }
+ SfxDispatcher &rDis = *rTempView.GetViewFrame()->GetDispatcher();
+ rDis.Execute( FN_UPDATE_FIELDS );
+ rDis.Execute( FN_UPDATE_TOX );
+ rDis.Execute( FN_UPDATE_CHARTS );
+ rSh.CalcLayout();
+ }
+ break;
+
+ case FN_UPDATE_INPUTFIELDS:
+ rSh.UpdateInputFlds();
+ break;
+
+ case FN_PREV_BOOKMARK:
+ rReq.SetReturnValue(SfxBoolItem( nSlot, rSh.GoPrevBookmark()));
+ break;
+ case FN_NEXT_BOOKMARK:
+ rReq.SetReturnValue(SfxBoolItem( nSlot, rSh.GoNextBookmark()));
+ break;
+
+ case FN_GOTO_NEXT_MARK:
+ case FN_GOTO_PREV_MARK:
+ {
+ SwFldMgr aFldMgr;
+ SwFieldType* pFldType = aFldMgr.GetFldType(RES_JUMPEDITFLD);
+
+ if (pFldType)
+ {
+ if (rSh.IsSelFrmMode())
+ {
+ rSh.UnSelectFrm();
+ rSh.LeaveSelFrmMode();
+ }
+
+ if (rSh.HasMark())
+ {
+ SwMvContext aMvContext(&rSh);
+ if (rSh.IsCrsrPtAtEnd())
+ rSh.SwapPam();
+ rSh.ClearMark();
+ rSh.EndSelect();
+ }
+ sal_Bool bRet = rSh.MoveFldType( pFldType, nSlot == FN_GOTO_NEXT_MARK );
+ SwField* pCurField = bRet ? rSh.GetCurFld() : 0;
+ if (pCurField)
+ rSh.ClickToField(*pCurField);
+ rReq.SetReturnValue(SfxBoolItem( nSlot, bRet));
+ }
+ }
+ break;
+
+ case FN_START_DOC_DIRECT:
+ case FN_END_DOC_DIRECT:
+ {
+ if (rSh.IsSelFrmMode())
+ {
+ rSh.UnSelectFrm();
+ rSh.LeaveSelFrmMode();
+ }
+ rSh.EnterStdMode();
+ nSlot == FN_START_DOC_DIRECT ?
+ rSh.SttEndDoc(sal_True) :
+ rSh.SttEndDoc(sal_False);
+ }
+ break;
+ case FN_GOTO_PREV_OBJ:
+ case FN_GOTO_NEXT_OBJ:
+ {
+ sal_Bool bSuccess = rSh.GotoObj(
+ nSlot == FN_GOTO_NEXT_OBJ ? sal_True : sal_False);
+ rReq.SetReturnValue(SfxBoolItem(nSlot, bSuccess));
+ if (bSuccess && !rSh.IsSelFrmMode())
+ {
+ rSh.HideCrsr();
+ rSh.EnterSelFrmMode();
+ GetView().AttrChangedNotify( &rSh );
+ }
+ }
+ break;
+ case SID_GALLERY_FORMATS:
+ {
+ SFX_ITEMSET_ARG( pArgs, pGalleryItem, SvxGalleryItem, SID_GALLERY_FORMATS, false );
+ if ( !pGalleryItem )
+ break;
+
+ const int nSelType = rSh.GetSelectionType();
+ sal_Int8 nGalleryItemType( pGalleryItem->GetType() );
+
+ if ( (!rSh.IsSelFrmMode() || nSelType & nsSelectionType::SEL_GRF) &&
+ nGalleryItemType == com::sun::star::gallery::GalleryItemType::GRAPHIC )
+ {
+ SwWait aWait( *rView.GetDocShell(), true );
+
+ OUString aGrfName, aFltName;
+ const Graphic aGrf( pGalleryItem->GetGraphic() );
+
+ if ( nSelType & nsSelectionType::SEL_GRF )
+ rSh.ReRead( aGrfName, aFltName, &aGrf );
+ else
+ rSh.Insert( aGrfName, aFltName, aGrf );
+
+ GetView().GetEditWin().GrabFocus();
+ }
+ else if(!rSh.IsSelFrmMode() &&
+ nGalleryItemType == com::sun::star::gallery::GalleryItemType::MEDIA )
+ {
+ const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA, pGalleryItem->GetURL() );
+ GetView().GetViewFrame()->GetDispatcher()->Execute( SID_INSERT_AVMEDIA, SFX_CALLMODE_SYNCHRON, &aMediaURLItem, 0L );
+ }
+ }
+ break;
+ case FN_PAGE_STYLE_SET_COLS:
+ {
+ if (pArgs)
+ {
+ // Determine the current PageDescriptor and fill the set with that.
+ const sal_uInt16 nCurIdx = rSh.GetCurPageDesc();
+ SwPageDesc aPageDesc(rSh.GetPageDesc(nCurIdx));
+
+ SwFrmFmt &rFmt = aPageDesc.GetMaster();
+
+ SwFmtCol aFmtCol = rFmt.GetCol();
+
+ sal_uInt16 nCount;
+ if(SFX_ITEM_SET == pArgs->GetItemState(nSlot))
+ nCount = ((SfxUInt16Item &)pArgs->Get(nSlot)).GetValue();
+ else
+ nCount = ((SfxUInt16Item &)pArgs->Get(SID_ATTR_COLUMNS)).GetValue();
+ sal_uInt16 nGutterWidth = DEF_GUTTER_WIDTH;
+
+ aFmtCol.Init(nCount ? nCount : 1, nGutterWidth, USHRT_MAX);
+ aFmtCol.SetWishWidth(USHRT_MAX);
+ aFmtCol.SetGutterWidth(nGutterWidth, USHRT_MAX);
+
+ rFmt.SetFmtAttr(aFmtCol);
+
+ rSh.ChgPageDesc(nCurIdx, aPageDesc);
+ }
+ else
+ GetView().GetViewFrame()->GetDispatcher()->Execute(FN_FORMAT_PAGE_COLUMN_DLG, sal_False);
+ }
+ break;
+ case FN_CONVERT_TABLE_TO_TEXT:
+ case FN_CONVERT_TEXT_TO_TABLE:
+ case FN_CONVERT_TEXT_TABLE:
+ {
+ sal_Unicode cDelim = 0;
+ bool bToTable = false;
+ if( nSlot == FN_CONVERT_TEXT_TO_TABLE ||
+ ( nSlot == FN_CONVERT_TEXT_TABLE && 0 == rSh.GetTableFmt() ))
+ bToTable = true;
+ SwInsertTableOptions aInsTblOpts( tabopts::ALL_TBL_INS_ATTR, 1 );
+ SwTableAutoFmt const* pTAFmt = 0;
+ SwTableAutoFmtTbl* pAutoFmtTbl = 0;
+ bool bDeleteFormat = true;
+ if(pArgs && SFX_ITEM_SET == pArgs->GetItemState( FN_PARAM_1, true, &pItem))
+ {
+ aInsTblOpts.mnInsMode = 0;
+ // Delimiter
+ OUString sDelim = static_cast< const SfxStringItem* >(pItem)->GetValue();
+ if(!sDelim.isEmpty())
+ cDelim = sDelim[0];
+ // AutoFormat
+ if(SFX_ITEM_SET == pArgs->GetItemState( FN_PARAM_2, true, &pItem))
+ {
+ OUString sAutoFmt = static_cast< const SfxStringItem* >(pItem)->GetValue();
+
+ pAutoFmtTbl = new SwTableAutoFmtTbl;
+ pAutoFmtTbl->Load();
+
+ for( sal_uInt16 i = 0, nCount = pAutoFmtTbl->size(); i < nCount; i++ )
+ {
+ SwTableAutoFmt const*const pFmt = &(*pAutoFmtTbl)[ i ];
+ if( pFmt->GetName() == sAutoFmt )
+ {
+ pTAFmt = pFmt;
+ bDeleteFormat = false;
+ break;
+ }
+ }
+ }
+ //WithHeader
+ if(SFX_ITEM_SET == pArgs->GetItemState( FN_PARAM_3, true, &pItem) &&
+ static_cast< const SfxBoolItem* >(pItem)->GetValue())
+ aInsTblOpts.mnInsMode |= tabopts::HEADLINE;
+ // RepeatHeaderLines
+ if(SFX_ITEM_SET == pArgs->GetItemState( FN_PARAM_4, true, &pItem))
+ aInsTblOpts.mnRowsToRepeat =
+ (sal_uInt16)static_cast< const SfxInt16Item* >(pItem)->GetValue();
+ //WithBorder
+ if(SFX_ITEM_SET == pArgs->GetItemState( FN_PARAM_5, true, &pItem) &&
+ static_cast< const SfxBoolItem* >(pItem)->GetValue())
+ aInsTblOpts.mnInsMode |= tabopts::DEFAULT_BORDER;
+ //DontSplitTable
+ if(SFX_ITEM_SET == pArgs->GetItemState( FN_PARAM_6, true, &pItem) &&
+ !static_cast< const SfxBoolItem* >(pItem)->GetValue() )
+ aInsTblOpts.mnInsMode |= tabopts::SPLIT_LAYOUT;
+ }
+ else
+ {
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+
+ AbstractSwConvertTableDlg* pDlg = pFact->CreateSwConvertTableDlg(GetView(), bToTable);
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ if( RET_OK == pDlg->Execute() )
+ {
+ pDlg->GetValues( cDelim, aInsTblOpts, pTAFmt );
+
+ }
+ delete pDlg;
+ }
+
+ if( cDelim )
+ {
+ //Shell change!
+ SwView& rSaveView = rView;
+ sal_Bool bInserted = sal_False;
+ //recording:
+ SfxViewFrame* pViewFrame = GetView().GetViewFrame();
+ if( SfxRequest::HasMacroRecorder(pViewFrame) )
+ {
+ SfxRequest aReq( pViewFrame, nSlot);
+ aReq.AppendItem( SfxStringItem( FN_PARAM_1, OUString(cDelim) ));
+ if(bToTable)
+ {
+ if(pTAFmt)
+ aReq.AppendItem( SfxStringItem( FN_PARAM_2, pTAFmt->GetName()));
+ aReq.AppendItem( SfxBoolItem ( FN_PARAM_3, 0 != (aInsTblOpts.mnInsMode & tabopts::HEADLINE)));
+ aReq.AppendItem( SfxInt16Item( FN_PARAM_4, (short)aInsTblOpts.mnRowsToRepeat ));
+ aReq.AppendItem( SfxBoolItem ( FN_PARAM_5, 0 != (aInsTblOpts.mnInsMode & tabopts::DEFAULT_BORDER) ));
+ aReq.AppendItem( SfxBoolItem ( FN_PARAM_6, !(aInsTblOpts.mnInsMode & tabopts::SPLIT_LAYOUT)));
+ }
+ aReq.Done();
+ }
+
+ if( !bToTable )
+ rSh.TableToText( cDelim );
+ else
+ {
+ bInserted = rSh.TextToTable( aInsTblOpts, cDelim, text::HoriOrientation::FULL, pTAFmt );
+ }
+ rSh.EnterStdMode();
+
+ if( bInserted )
+ rSaveView.AutoCaption( TABLE_CAP );
+ }
+ if(bDeleteFormat)
+ delete pTAFmt;
+ delete pAutoFmtTbl;
+ }
+ break;
+ case SID_STYLE_WATERCAN:
+ case SID_STYLE_UPDATE_BY_EXAMPLE:
+ case SID_STYLE_NEW_BY_EXAMPLE:
+ case SID_STYLE_APPLY:
+ {
+ ShellModes eMode = GetView().GetShellMode();
+ if ( SHELL_MODE_DRAW != eMode &&
+ SHELL_MODE_DRAW_CTRL != eMode &&
+ SHELL_MODE_DRAW_FORM != eMode &&
+ SHELL_MODE_DRAWTEXT != eMode &&
+ SHELL_MODE_BEZIER != eMode )
+ {
+ // oj #107754#
+ if ( SID_STYLE_WATERCAN == nSlot )
+ {
+ const sal_Bool bLockedView = rSh.IsViewLocked();
+ rSh.LockView( sal_True ); //lock visible section
+
+ GetView().GetDocShell()->ExecStyleSheet(rReq);
+
+ rSh.LockView( bLockedView );
+ }
+ else
+ // Will be recorded from the DocShell
+ GetView().GetDocShell()->ExecStyleSheet(rReq);
+ }
+ }
+ break;
+ case FN_ESCAPE:
+ GetView().ExecuteSlot(rReq);
+ break;
+ case SID_IMAP:
+ {
+ sal_uInt16 nId = SvxIMapDlgChildWindow::GetChildWindowId();
+
+ SfxViewFrame* pVFrame = GetView().GetViewFrame();
+ pVFrame->ToggleChildWindow( nId );
+ pVFrame->GetBindings().Invalidate( SID_IMAP );
+
+ if ( pVFrame->HasChildWindow( nId ) && rSh.IsFrmSelected() )
+ lcl_UpdateIMapDlg( rSh );
+ }
+ break;
+ case SID_IMAP_EXEC:
+ {
+ SvxIMapDlg* pDlg = SWIMAPDLG(GetView());
+
+ // Check, if the allocation is useful or allowed at all.
+ if ( rSh.IsFrmSelected() &&
+ pDlg->GetEditingObject() == rSh.GetIMapInventor() )
+ {
+ SfxItemSet aSet( rSh.GetAttrPool(), RES_URL, RES_URL );
+ rSh.GetFlyFrmAttr( aSet );
+ SwFmtURL aURL( (SwFmtURL&)aSet.Get( RES_URL ) );
+ aURL.SetMap( &pDlg->GetImageMap() );
+ aSet.Put( aURL );
+ rSh.SetFlyFrmAttr( aSet );
+ }
+ }
+ break;
+ case SID_CONTOUR_DLG:
+ {
+ sal_uInt16 nId = SvxContourDlgChildWindow::GetChildWindowId();
+
+ SfxViewFrame* pVFrame = GetView().GetViewFrame();
+ pVFrame->ToggleChildWindow( nId );
+ pVFrame->GetBindings().Invalidate( SID_CONTOUR_DLG );
+
+ int nSel = rSh.GetSelectionType();
+ if ( pVFrame->HasChildWindow( nId ) &&
+ (nSel & (nsSelectionType::SEL_GRF|nsSelectionType::SEL_OLE)) )
+ {
+ lcl_UpdateContourDlg( rSh, nSel );
+ }
+ }
+ break;
+ case SID_CONTOUR_EXEC:
+ {
+ SvxContourDlg *pDlg = SWCONTOURDLG(GetView());
+ // Check, if the allocation is useful or allowed at all.
+ int nSel = rSh.GetSelectionType();
+ if ( nSel & (nsSelectionType::SEL_GRF|nsSelectionType::SEL_OLE) )
+ {
+ if ( pDlg->GetEditingObject() == rSh.GetIMapInventor() )
+ {
+ rSh.StartAction();
+ SfxItemSet aSet( rSh.GetAttrPool(), RES_SURROUND, RES_SURROUND);
+ rSh.GetFlyFrmAttr( aSet );
+ SwFmtSurround aSur( (SwFmtSurround&)aSet.Get( RES_SURROUND ) );
+ if ( !aSur.IsContour() )
+ {
+ aSur.SetContour( sal_True );
+ if ( aSur.GetSurround() == SURROUND_NONE )
+ aSur.SetSurround( SURROUND_PARALLEL );
+ aSet.Put( aSur );
+ rSh.SetFlyFrmAttr( aSet );
+ }
+ const PolyPolygon aPoly( pDlg->GetPolyPolygon() );
+ rSh.SetGraphicPolygon( &aPoly );
+ if ( pDlg->IsGraphicChanged() )
+ rSh.ReRead( OUString(), OUString(), &pDlg->GetGraphic());
+ rSh.EndAction();
+ }
+ }
+ }
+ break;
+ case FN_FRAME_TO_ANCHOR:
+ {
+ rSh.GotoFlyAnchor();
+ rSh.EnterStdMode();
+ rSh.CallChgLnk();
+ }
+ break;
+ case FN_TOOL_ANCHOR:
+ break;
+ case FN_TOOL_ANCHOR_PAGE:
+ case FN_TOOL_ANCHOR_PARAGRAPH:
+ case FN_TOOL_ANCHOR_CHAR:
+ case FN_TOOL_ANCHOR_AT_CHAR:
+ case FN_TOOL_ANCHOR_FRAME:
+ {
+ RndStdIds eSet = nSlot == FN_TOOL_ANCHOR_PAGE
+ ? FLY_AT_PAGE
+ : nSlot == FN_TOOL_ANCHOR_PARAGRAPH
+ ? FLY_AT_PARA
+ : nSlot == FN_TOOL_ANCHOR_FRAME
+ ? FLY_AT_FLY
+ : nSlot == FN_TOOL_ANCHOR_CHAR
+ ? FLY_AS_CHAR
+ : FLY_AT_CHAR;
+ rSh.StartUndo();
+ if( rSh.IsObjSelected() )
+ rSh.ChgAnchor( eSet );
+ else if( rSh.IsFrmSelected() )
+ {
+ // The set also includes VERT/HORI_ORIENT, because the align
+ // shall be changed in FEShell::SetFlyFrmAttr/SetFlyFrmAnchor,
+ // possibly as a result of the anchor change.
+ SfxItemSet aSet( GetPool(), RES_VERT_ORIENT, RES_ANCHOR );
+ SwFmtAnchor aAnc( eSet, rSh.GetPhyPageNum() );
+ aSet.Put( aAnc );
+ rSh.SetFlyFrmAttr(aSet);
+ }
+ // if new anchor is 'as char' and it is a Math object and the usual
+ // pre-conditions are met then align the formula to the baseline of the text
+ const uno::Reference < embed::XEmbeddedObject > xObj( rSh.GetOleRef() );
+ const bool bDoMathBaselineAlignment = xObj.is() && SotExchange::IsMath( xObj->getClassID() )
+ && FLY_AS_CHAR == eSet && rSh.GetDoc()->get( IDocumentSettingAccess::MATH_BASELINE_ALIGNMENT );
+ if (bDoMathBaselineAlignment)
+ rSh.AlignFormulaToBaseline( xObj );
+
+ sal_uInt16 nHtmlMode = ::GetHtmlMode(GetView().GetDocShell());
+ if( nHtmlMode )
+ {
+ SfxItemSet aSet(GetPool(), RES_SURROUND, RES_HORI_ORIENT);
+ rSh.GetFlyFrmAttr(aSet);
+
+ const SwFmtSurround& rSurround = (const SwFmtSurround&)aSet.Get(RES_SURROUND);
+ const SwFmtVertOrient& rVert = (const SwFmtVertOrient&)aSet.Get(RES_VERT_ORIENT);
+ const SwFmtHoriOrient& rHori = (const SwFmtHoriOrient&)aSet.Get(RES_HORI_ORIENT);
+ sal_Int16 eVOrient = rVert.GetVertOrient();
+ sal_Int16 eHOrient = rHori.GetHoriOrient();
+ SwSurround eSurround = rSurround.GetSurround();
+
+ switch( eSet )
+ {
+ case FLY_AT_FLY:
+ case FLY_AT_PAGE:
+ //Wrap through, left or from left, top, from top
+ if(eSurround != SURROUND_THROUGHT)
+ aSet.Put(SwFmtSurround(SURROUND_THROUGHT));
+
+ if( eVOrient != text::VertOrientation::TOP && eVOrient != text::VertOrientation::NONE)
+ aSet.Put(SwFmtVertOrient(0, text::VertOrientation::TOP));
+
+ if(eHOrient != text::HoriOrientation::NONE || eHOrient != text::HoriOrientation::LEFT)
+ aSet.Put(SwFmtHoriOrient(0, text::HoriOrientation::LEFT));
+ break;
+
+ case FLY_AT_PARA:
+ // left, from left, right, top, no wrap, wrap left and right
+ if(eSurround != SURROUND_LEFT || eSurround != SURROUND_RIGHT)
+ aSet.Put(SwFmtSurround(SURROUND_LEFT));
+
+ if( eVOrient != text::VertOrientation::TOP)
+ aSet.Put(SwFmtVertOrient(0, text::VertOrientation::TOP));
+
+ if(eHOrient != text::HoriOrientation::NONE || eHOrient != text::HoriOrientation::LEFT || eHOrient != text::HoriOrientation::RIGHT)
+ aSet.Put(SwFmtHoriOrient(0, text::HoriOrientation::LEFT));
+ break;
+
+ case FLY_AT_CHAR:
+ // left, from left, right, top, wrap through
+ if(eSurround != SURROUND_THROUGHT)
+ aSet.Put(SwFmtSurround(SURROUND_THROUGHT));
+
+ if( eVOrient != text::VertOrientation::TOP)
+ aSet.Put(SwFmtVertOrient(0, text::VertOrientation::TOP));
+
+ if(eHOrient != text::HoriOrientation::NONE || eHOrient != text::HoriOrientation::LEFT || eHOrient != text::HoriOrientation::RIGHT)
+ aSet.Put(SwFmtHoriOrient(0, text::HoriOrientation::LEFT));
+ break;
+
+ default:
+ ;
+ }
+
+ if( aSet.Count() )
+ rSh.SetFlyFrmAttr( aSet );
+ }
+ rSh.EndUndo();
+
+ GetView().GetViewFrame()->GetBindings().Invalidate( FN_TOOL_ANCHOR );
+ }
+ break;
+
+ case FN_FRAME_NOWRAP:
+ case FN_FRAME_WRAP:
+ case FN_FRAME_WRAP_IDEAL:
+ case FN_FRAME_WRAPTHRU:
+ case FN_FRAME_WRAPTHRU_TRANSP:
+ case FN_FRAME_WRAP_CONTOUR:
+ case FN_WRAP_ANCHOR_ONLY:
+ case FN_FRAME_WRAP_LEFT:
+ case FN_FRAME_WRAP_RIGHT:
+ SetWrapMode( nSlot );
+ break;
+
+ case FN_UPDATE_ALL_LINKS:
+ {
+ if( !rSh.GetLinkManager().GetLinks().empty() )
+ {
+ rSh.EnterStdMode();
+ rSh.StartAllAction();
+ rSh.GetLinkManager().UpdateAllLinks( false, false, false );
+ rSh.EndAllAction();
+ }
+ }
+ break;
+
+ case FN_XFORMS_DESIGN_MODE:
+ if( pArgs != NULL
+ && pArgs->GetItemState( nSlot, true, &pItem ) == SFX_ITEM_SET
+ && pItem != NULL
+ && pItem->ISA( SfxBoolItem ) )
+ {
+ sal_Bool bDesignMode =
+ static_cast<const SfxBoolItem*>( pItem )->GetValue();
+
+ // set form design mode
+ OSL_ENSURE( GetView().GetFormShell() != NULL, "form shell?" );
+ SfxRequest aReq( GetView().GetViewFrame(), SID_FM_DESIGN_MODE );
+ aReq.AppendItem( SfxBoolItem( SID_FM_DESIGN_MODE, bDesignMode ) );
+ GetView().GetFormShell()->Execute( aReq );
+ aReq.Done();
+
+ // also set suitable view options
+ SwViewOption aViewOption = *rSh.GetViewOptions();
+ aViewOption.SetFormView( ! bDesignMode );
+ rSh.ApplyViewOptions( aViewOption );
+ }
+ break;
+
+ default:
+ bMore = true;
+ }
+ if(bMore && pArgs)
+ {
+ pItem = 0;
+ pArgs->GetItemState(GetPool().GetWhich(nSlot), false, &pItem);
+ if(pItem)
+ switch(nSlot)
+ {
+ case SID_ATTR_BRUSH:
+ case SID_ATTR_BORDER_SHADOW:
+ case RES_SHADOW:
+ {
+ rSh.StartAllAction();
+ SfxItemSet aSet( rSh.GetAttrPool(),
+ RES_SHADOW, RES_SHADOW,
+ RES_BACKGROUND, RES_BACKGROUND, 0 );
+
+ aSet.Put(*pItem);
+ // Tabele cell(s) selected?
+ if ( rSh.IsTableMode() )
+ {
+ SwFrmFmt *pFmt = rSh.GetTableFmt();
+ pFmt->SetFmtAttr( *pItem );
+ }
+ else if ( rSh.IsFrmSelected() )
+ {
+ // Set border attributes via Frame-Manager.
+ SwFlyFrmAttrMgr aMgr( sal_False, &rSh, FRMMGR_TYPE_NONE );
+ aMgr.SetAttrSet( *pArgs );
+ aMgr.UpdateFlyFrm();
+ }
+ else
+ {
+ rSh.SetAttrSet( *pArgs );
+ }
+ rSh.EndAllAction();
+ }
+ break;
+ case FN_PAGE_STYLE_SET_LR_MARGIN:
+ case FN_PAGE_STYLE_SET_UL_MARGIN:
+ case FN_PAGE_STYLE_SET_NUMBER_FORMAT:
+ case FN_PAGE_STYLE_SET_PAPER_SIZE:
+ case FN_PAGE_STYLE_SET_PAPER_BIN:
+ {
+ OSL_FAIL("not implemented");
+ }
+ break;
+
+ case SID_ATTR_BORDER_OUTER:
+ {
+ // Tabele cell(s) selected?
+ if ( rSh.IsTableMode() )
+ {
+ // Set border attributes Get/SetTabBorders()
+ rSh.SetTabBorders(*pArgs);
+ }
+ else if ( rSh.IsFrmSelected() )
+ {
+ // Set border attributes via Frame-Manager.
+ SwFlyFrmAttrMgr aMgr( sal_False, &rSh, FRMMGR_TYPE_NONE );
+ aMgr.SetAttrSet(*pArgs);
+ aMgr.UpdateFlyFrm();
+ }
+ else
+ {
+ // Set border attributes via shell quite normally.
+ rSh.SetAttrItem( *pItem );
+ }
+ }
+ break;
+ default:
+ OSL_FAIL("wrong Dispatcher");
+ }
+
+ }
+}
+
+// Here the state fpr SID_IMAP / SID_CONTOUR will be handled
+// until the swapping of the graphic is finished.
+
+IMPL_LINK_NOARG(SwBaseShell, GraphicArrivedHdl)
+{
+ sal_uInt16 nGrfType;
+ SwWrtShell &rSh = GetShell();
+ if( CNT_GRF == rSh.SwEditShell::GetCntType() &&
+ GRAPHIC_NONE != ( nGrfType = rSh.GetGraphicType() ) &&
+ !aGrfUpdateSlots.empty() )
+ {
+ bool bProtect = 0 != rSh.IsSelObjProtected(FLYPROTECT_CONTENT|FLYPROTECT_PARENT);
+ SfxViewFrame* pVFrame = GetView().GetViewFrame();
+ sal_uInt16 nSlot;
+ std::set<sal_uInt16>::iterator it;
+ for( it = aGrfUpdateSlots.begin(); it != aGrfUpdateSlots.end(); ++it )
+ {
+ sal_Bool bSetState = sal_False;
+ sal_Bool bState = sal_False;
+ switch( nSlot = *it )
+ {
+ case SID_IMAP:
+ case SID_IMAP_EXEC:
+ {
+ sal_uInt16 nId = SvxIMapDlgChildWindow::GetChildWindowId();
+ SvxIMapDlg *pDlg = pVFrame->HasChildWindow( nId ) ?
+ (SvxIMapDlg*) ( pVFrame->GetChildWindow( nId )
+ ->GetWindow()) : 0;
+
+ if( pDlg && ( SID_IMAP_EXEC == nSlot ||
+ ( SID_IMAP == nSlot && !bProtect)) &&
+ pDlg->GetEditingObject() != rSh.GetIMapInventor())
+ lcl_UpdateIMapDlg( rSh );
+
+ if( !bProtect && SID_IMAP == nSlot )
+ bSetState = sal_True, bState = 0 != pDlg;
+ }
+ break;
+
+ case SID_CONTOUR_DLG:
+ if( !bProtect )
+ {
+ sal_uInt16 nId = SvxContourDlgChildWindow::GetChildWindowId();
+ SvxIMapDlg *pDlg = pVFrame->HasChildWindow( nId ) ?
+ (SvxIMapDlg*) ( pVFrame->GetChildWindow( nId )
+ ->GetWindow()) : 0;
+ if( pDlg && pDlg->GetEditingObject() !=
+ rSh.GetIMapInventor() )
+ lcl_UpdateContourDlg( rSh, nsSelectionType::SEL_GRF );
+
+ bSetState = sal_True;
+ bState = 0 != pDlg;
+ }
+ break;
+
+ case FN_FRAME_WRAP_CONTOUR:
+ if( !bProtect )
+ {
+ SfxItemSet aSet(GetPool(), RES_SURROUND, RES_SURROUND);
+ rSh.GetFlyFrmAttr(aSet);
+ const SwFmtSurround& rWrap = (const SwFmtSurround&)aSet.Get(RES_SURROUND);
+ bSetState = sal_True;
+ bState = rWrap.IsContour();
+ }
+ break;
+
+ case SID_GRFFILTER:
+ case SID_GRFFILTER_INVERT:
+ case SID_GRFFILTER_SMOOTH:
+ case SID_GRFFILTER_SHARPEN:
+ case SID_GRFFILTER_REMOVENOISE:
+ case SID_GRFFILTER_SOBEL:
+ case SID_GRFFILTER_MOSAIC:
+ case SID_GRFFILTER_EMBOSS:
+ case SID_GRFFILTER_POSTER:
+ case SID_GRFFILTER_POPART:
+ case SID_GRFFILTER_SEPIA:
+ case SID_GRFFILTER_SOLARIZE:
+ bSetState = bState = GRAPHIC_BITMAP == nGrfType;
+ break;
+ }
+
+ if( bSetState )
+ {
+ SfxBoolItem aBool( nSlot, bState );
+ if( pGetStateSet )
+ pGetStateSet->Put( aBool );
+ else
+ pVFrame->GetBindings().SetState( aBool );
+ }
+ }
+ aGrfUpdateSlots.clear();
+ }
+ return 0;
+}
+
+void SwBaseShell::GetState( SfxItemSet &rSet )
+{
+ SwWrtShell &rSh = GetShell();
+ SfxViewFrame* pVFrame = GetView().GetViewFrame();
+ SfxWhichIter aIter( rSet );
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ pGetStateSet = &rSet;
+ while ( nWhich )
+ {
+ switch ( nWhich )
+ {
+ case SID_GALLERY_FORMATS:
+ if ( rSh.IsObjSelected() ||
+ (rSh.IsSelFrmMode() &&
+ !(rSh.GetSelectionType() & nsSelectionType::SEL_GRF)) )
+ rSet.DisableItem( nWhich );
+ break;
+ case SID_GALLERY_ENABLE_ADDCOPY:
+ // #108230# allow copy from gallery in Writer AND Writer/Web!
+ rSet.Put( SfxBoolItem( SID_GALLERY_ENABLE_ADDCOPY, true ) );
+ break;
+ case FN_EDIT_REGION:
+ if( !rSh.IsAnySectionInDoc() )
+ rSet.DisableItem(nWhich);
+ break;
+
+ case FN_INSERT_REGION:
+ if( rSh.CrsrInsideInputFld()
+ || rSh.IsSelFrmMode()
+ || !rSh.IsInsRegionAvailable() )
+ {
+ rSet.DisableItem( nWhich );
+ }
+ break;
+
+ case FN_CONVERT_TABLE_TO_TEXT:
+ {
+ sal_uInt16 eFrmType = rSh.GetFrmType(0,sal_True);
+ if( (eFrmType & FRMTYPE_FOOTNOTE) ||
+ !rSh.GetTableFmt() )
+ rSet.DisableItem( nWhich );
+ }
+ break;
+ case FN_CONVERT_TEXT_TO_TABLE:
+ {
+ sal_uInt16 eFrmType = rSh.GetFrmType(0,sal_True);
+ if( (eFrmType & FRMTYPE_FOOTNOTE) ||
+ !rSh.IsTextToTableAvailable() )
+ rSet.DisableItem( nWhich );
+ }
+ break;
+ case FN_CONVERT_TEXT_TABLE:
+ {
+ sal_uInt16 eFrmType = rSh.GetFrmType(0,sal_True);
+ if( (eFrmType & FRMTYPE_FOOTNOTE) ||
+ (!rSh.GetTableFmt() && !rSh.IsTextToTableAvailable() ) )
+ rSet.DisableItem( nWhich );
+ }
+ break;
+ case RES_SHADOW:
+ {
+ SfxItemSet aSet( rSh.GetAttrPool(),
+ RES_SHADOW, RES_SHADOW );
+
+ // Table cell(s) selected?
+ if ( rSh.IsTableMode() )
+ {
+ SwFrmFmt *pFmt = rSh.GetTableFmt();
+ aSet.Put(pFmt->GetFmtAttr( nWhich, sal_True ));
+ }
+ else if( rSh.IsFrmSelected() )
+ {
+ SwFlyFrmAttrMgr aMgr( sal_False, &rSh, FRMMGR_TYPE_NONE );
+ aSet.Put( aMgr.GetAttrSet() );
+ }
+ else
+ rSh.GetCurAttr( aSet );
+
+ const SvxShadowItem& rShItem = (const SvxShadowItem&)aSet.Get(nWhich);
+ rSet.Put(rShItem);
+ }
+ break;
+ case SID_IMAP:
+ {
+ // #i59688#
+ // Improve efficiency:
+ // If selected object is protected, item has to disabled.
+ const bool bProtect = 0 != rSh.IsSelObjProtected(FLYPROTECT_CONTENT|FLYPROTECT_PARENT);
+ if ( bProtect )
+ {
+ rSet.DisableItem( nWhich );
+ }
+ else
+ {
+ const sal_uInt16 nId = SvxIMapDlgChildWindow::GetChildWindowId();
+ const sal_Bool bHas = pVFrame->HasChildWindow( nId );
+ const sal_Bool bFrmSel = rSh.IsFrmSelected();
+ const bool bIsGraphicSelection =
+ rSh.GetSelectionType() == nsSelectionType::SEL_GRF;
+
+ // #i59688#
+ // Avoid unnecessary loading of selected graphic.
+ // The graphic is only needed, if the dialog is open.
+ // If the swapping of the graphic is finished, the status
+ // must be determined asynchronously, until this the slot
+ // will be disabled.
+ if ( bHas && bIsGraphicSelection && rSh.IsGrfSwapOut( sal_True ) )
+ {
+ if( AddGrfUpdateSlot( nWhich ))
+ rSh.GetGraphic(sal_False); // start the loading
+ }
+ else
+ {
+ if ( !bHas &&
+ ( !bFrmSel ||
+ ( bIsGraphicSelection &&
+ rSh.GetGraphicType() == GRAPHIC_NONE ) ) )
+ {
+ rSet.DisableItem( nWhich );
+ }
+ else
+ {
+ SfxBoolItem aBool(nWhich, bHas);
+ if ( bHas && bFrmSel )
+ lcl_UpdateIMapDlg( rSh );
+ rSet.Put(aBool);
+ }
+ }
+ }
+ }
+ break;
+ case SID_IMAP_EXEC:
+ {
+ sal_Bool bDisable = sal_False;
+ if( !rSh.IsFrmSelected())
+ bDisable = sal_True;
+ sal_uInt16 nId = SvxIMapDlgChildWindow::GetChildWindowId();
+ if(!bDisable && pVFrame->HasChildWindow( nId ))
+ {
+ if(rSh.GetSelectionType() == nsSelectionType::SEL_GRF
+ && rSh.IsGrfSwapOut(sal_True))
+ {
+ if( AddGrfUpdateSlot( nWhich ))
+ rSh.GetGraphic(sal_False); // start the loading
+ }
+ else
+ {
+ SvxIMapDlg *pDlg = SWIMAPDLG(GetView());
+ if( pDlg->GetEditingObject() != rSh.GetIMapInventor() )
+ lcl_UpdateIMapDlg( rSh );
+ }
+ }
+ rSet.Put(SfxBoolItem(nWhich, bDisable));
+ }
+ break;
+
+ case FN_BACKSPACE:
+ case SID_DELETE:
+ if ( ( rSh.HasReadonlySel() && !rSh.CrsrInsideInputFld() )
+ || rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) != 0 )
+ {
+ rSet.DisableItem( nWhich );
+ }
+ break;
+
+ case SID_CONTOUR_DLG:
+ {
+ sal_Bool bParentCntProt = 0 != rSh.IsSelObjProtected(FLYPROTECT_CONTENT|FLYPROTECT_PARENT );
+
+ if( bParentCntProt || 0 != (HTMLMODE_ON & ::GetHtmlMode(
+ GetView().GetDocShell() )) )
+ rSet.DisableItem( nWhich );
+ else
+ {
+ sal_uInt16 nId = SvxContourDlgChildWindow::GetChildWindowId();
+ sal_Bool bHas = GetView().GetViewFrame()->HasChildWindow( nId );
+ int nSel = rSh.GetSelectionType();
+ sal_Bool bOk = 0 != (nSel & (nsSelectionType::SEL_GRF|nsSelectionType::SEL_OLE));
+
+ bool bDisable = false;
+ if( !bHas && !bOk )
+ bDisable = true;
+ // #i59688#
+ // Avoid unnecessary loading of selected graphic.
+ // The graphic is only needed, if the dialog is open.
+ // If the swapping of the graphic is finished, the status
+ // must be determined asynchronously, until this the slot
+ // will be disabled.
+ else if ( bHas && (nSel & nsSelectionType::SEL_GRF) &&
+ rSh.IsGrfSwapOut(sal_True) )
+ {
+ if( AddGrfUpdateSlot( nWhich ))
+ rSh.GetGraphic(sal_False); // start the loading
+ // #i75481#
+ bDisable = true;
+ }
+ else if( bHas && bOk )
+ bDisable = !lcl_UpdateContourDlg( rSh, nSel );
+ else if( bOk )
+ {
+ // #i75481#
+ // apply fix #i59688# only for selected graphics
+ if ( nSel & nsSelectionType::SEL_GRF )
+ bDisable = GRAPHIC_NONE == rSh.GetGraphicType();
+ else
+ bDisable = GRAPHIC_NONE == rSh.GetIMapGraphic().GetType();
+ }
+
+ if( bDisable )
+ rSet.DisableItem( nWhich );
+ else
+ rSet.Put( SfxBoolItem(nWhich, bHas) );
+ }
+ }
+ break;
+ case SID_CONTOUR_EXEC:
+ {
+ sal_Bool bDisable = sal_False;
+ int nSel = rSh.GetSelectionType();
+ if( !(nSel & (nsSelectionType::SEL_GRF|nsSelectionType::SEL_OLE)) )
+ bDisable = sal_True;
+ sal_uInt16 nId = SvxContourDlgChildWindow::GetChildWindowId();
+ if( !bDisable && GetView().GetViewFrame()->HasChildWindow( nId ))
+ {
+ SvxContourDlg *pDlg = SWCONTOURDLG(GetView());
+ if( pDlg->GetEditingObject() != rSh.GetIMapInventor() )
+ bDisable = sal_True;
+ }
+ rSet.Put(SfxBoolItem(nWhich, bDisable));
+ }
+ break;
+
+ case FN_TOOL_ANCHOR:
+ case FN_TOOL_ANCHOR_PAGE:
+ case FN_TOOL_ANCHOR_PARAGRAPH:
+ case FN_TOOL_ANCHOR_CHAR:
+ case FN_TOOL_ANCHOR_AT_CHAR:
+ case FN_TOOL_ANCHOR_FRAME:
+ {
+ sal_Bool bObj = 0 != rSh.IsObjSelected();
+ sal_Bool bParentCntProt = rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) != 0;
+
+ if( !bParentCntProt && (bObj || rSh.IsFrmSelected()))
+ {
+ SfxItemSet aSet(GetPool(), RES_ANCHOR, RES_ANCHOR);
+ if(bObj)
+ rSh.GetObjAttr(aSet);
+ else
+ rSh.GetFlyFrmAttr(aSet);
+ RndStdIds eSet = ((SwFmtAnchor&)aSet.Get(RES_ANCHOR)).GetAnchorId();
+ const sal_Bool bSet =
+ ((nWhich == FN_TOOL_ANCHOR_PAGE) &&
+ (eSet == FLY_AT_PAGE))
+ || ((nWhich == FN_TOOL_ANCHOR_PARAGRAPH) &&
+ (eSet == FLY_AT_PARA))
+ || ((nWhich == FN_TOOL_ANCHOR_FRAME) &&
+ (eSet == FLY_AT_FLY))
+ || ((nWhich == FN_TOOL_ANCHOR_AT_CHAR) &&
+ (eSet == FLY_AT_CHAR))
+ || ((nWhich == FN_TOOL_ANCHOR_CHAR) &&
+ (eSet == FLY_AS_CHAR));
+ if(nWhich != FN_TOOL_ANCHOR)
+ {
+ if( nWhich == FN_TOOL_ANCHOR_FRAME && !rSh.IsFlyInFly() )
+ rSet.DisableItem(nWhich);
+ else
+ rSet.Put(SfxBoolItem(nWhich, bSet));
+ }
+ else
+ {
+ sal_uInt16 nSlotId = 0;
+
+ switch (eSet)
+ {
+ case FLY_AT_PAGE:
+ nSlotId = FN_TOOL_ANCHOR_PAGE;
+ break;
+ case FLY_AT_PARA:
+ nSlotId = FN_TOOL_ANCHOR_PARAGRAPH;
+ break;
+ case FLY_AS_CHAR:
+ nSlotId = FN_TOOL_ANCHOR_CHAR;
+ break;
+ case FLY_AT_CHAR:
+ nSlotId = FN_TOOL_ANCHOR_AT_CHAR;
+ break;
+ case FLY_AT_FLY:
+ nSlotId = FN_TOOL_ANCHOR_FRAME;
+ break;
+ default:
+ ;
+ }
+ rSet.Put(SfxUInt16Item(nWhich, nSlotId));
+ }
+ }
+ else
+ rSet.DisableItem( nWhich );
+ }
+ break;
+ case FN_FRAME_NOWRAP:
+ case FN_FRAME_WRAP:
+ case FN_FRAME_WRAP_IDEAL:
+ case FN_FRAME_WRAPTHRU:
+ case FN_FRAME_WRAPTHRU_TRANSP:
+ case FN_FRAME_WRAP_CONTOUR:
+ case FN_WRAP_ANCHOR_ONLY:
+ case FN_FRAME_WRAP_LEFT:
+ case FN_FRAME_WRAP_RIGHT:
+ {
+ sal_Bool bObj = 0 != rSh.IsObjSelected();
+ sal_Bool bParentCntProt = rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) != 0;
+
+ if( !bParentCntProt && (bObj || rSh.IsFrmSelected()))
+ {
+ SfxItemSet aSet(GetPool(), RES_OPAQUE, RES_ANCHOR);
+ int nAnchorType;
+ if(bObj)
+ {
+ rSh.GetObjAttr(aSet);
+ nAnchorType = rSh.GetAnchorId();
+ }
+ else
+ {
+ rSh.GetFlyFrmAttr(aSet);
+ nAnchorType = ((SwFmtAnchor&)aSet.Get(RES_ANCHOR)).GetAnchorId();
+ }
+ const SwFmtSurround& rWrap = (const SwFmtSurround&)aSet.Get(RES_SURROUND);
+
+ const SvxOpaqueItem& rOpaque = (const SvxOpaqueItem&)aSet.Get(RES_OPAQUE);
+ sal_Bool bOpaque = rOpaque.GetValue();
+ SwSurround nSurround = rWrap.GetSurround();
+ sal_Bool bSet = sal_False;
+
+ bool bDisable =
+ (nAnchorType == - 1) || (nAnchorType == FLY_AS_CHAR);
+ const bool bHtmlMode =
+ 0 != ::GetHtmlMode(GetView().GetDocShell());
+
+ switch( nWhich )
+ {
+ case FN_FRAME_NOWRAP:
+ bDisable |=
+ ( (nAnchorType != FLY_AT_PARA)
+ && (nAnchorType != FLY_AT_CHAR)
+ && (nAnchorType != FLY_AT_PAGE));
+ bSet = nSurround == SURROUND_NONE;
+ break;
+ case FN_FRAME_WRAP:
+ bDisable |= bHtmlMode;
+ bSet = nSurround == SURROUND_PARALLEL;
+ break;
+ case FN_FRAME_WRAP_IDEAL:
+ bDisable |= bHtmlMode;
+ bSet = nSurround == SURROUND_IDEAL;
+ break;
+ case FN_FRAME_WRAPTHRU:
+ bDisable |= (bHtmlMode ||
+ ( (nAnchorType != FLY_AT_PARA)
+ && (nAnchorType != FLY_AT_CHAR)
+ && (nAnchorType != FLY_AT_PAGE)));
+ if(bObj)
+ bSet = nSurround == SURROUND_THROUGHT && rSh.GetLayerId();
+ else
+ bSet = nSurround == SURROUND_THROUGHT && bOpaque;
+ break;
+ case FN_FRAME_WRAPTHRU_TRANSP:
+ bDisable |= bHtmlMode;
+ if(bObj)
+ bSet = nSurround == SURROUND_THROUGHT && !rSh.GetLayerId();
+ else
+ bSet = nSurround == SURROUND_THROUGHT && !bOpaque;
+ break;
+ case FN_FRAME_WRAP_CONTOUR:
+ bDisable |= bHtmlMode;
+ //no contour available whenn no wrap or wrap through is set
+ bDisable |= (nSurround == SURROUND_NONE || nSurround == SURROUND_THROUGHT);
+ bSet = rWrap.IsContour();
+ if( !bDisable )
+ {
+ int nSel = rSh.GetSelectionType();
+ if( (nSel & nsSelectionType::SEL_GRF) &&
+ rSh.IsGrfSwapOut(sal_True))
+ {
+ if( AddGrfUpdateSlot( nWhich ))
+ rSh.GetGraphic(sal_False); // start the loading
+ }
+ else if( rSh.IsFrmSelected() )
+ {
+ // #i102253# applied patch from OD (see task)
+ bDisable =
+ nSel & nsSelectionType::SEL_FRM ||
+ GRAPHIC_NONE == rSh.GetIMapGraphic().GetType();
+ }
+ }
+ bSet = bDisable ? sal_False : rWrap.IsContour();
+
+ break;
+ case FN_WRAP_ANCHOR_ONLY:
+ bDisable |= (bHtmlMode ||
+ (nAnchorType != FLY_AT_PARA));
+ bSet = rWrap.IsAnchorOnly();
+ break;
+ case FN_FRAME_WRAP_LEFT:
+ bSet = nSurround == SURROUND_LEFT;
+ break;
+ case FN_FRAME_WRAP_RIGHT:
+ bSet = nSurround == SURROUND_RIGHT;
+ break;
+ }
+
+ if(bDisable)
+ rSet.DisableItem(nWhich);
+ else
+ rSet.Put(SfxBoolItem(nWhich, bSet));
+ }
+ else
+ rSet.DisableItem(nWhich);
+ }
+ break;
+ case FN_UPDATE_CHARTS:
+ if( !rSh.HasCharts() )
+ rSet.DisableItem( nWhich );
+ break;
+ case FN_UPDATE_ALL_LINKS:
+ if ( rSh.GetLinkManager().GetLinks().empty() )
+ rSet.DisableItem(nWhich);
+ break;
+ case FN_XFORMS_DESIGN_MODE:
+ // enable if in XForms document
+ if( rSh.GetDoc()->isXForms() )
+ {
+ // determine current state from view options
+ sal_Bool bValue = ! rSh.GetViewOptions()->IsFormView();
+ rSet.Put( SfxBoolItem( nWhich, bValue ) );
+ }
+ else
+ rSet.Put( SfxVisibilityItem( nWhich, false ) );
+ break;
+ }
+ nWhich = aIter.NextWhich();
+ }
+ pGetStateSet = 0;
+}
+
+// Disable the slots with this status methode
+
+void SwBaseShell::StateDisableItems( SfxItemSet &rSet )
+{
+ SfxWhichIter aIter(rSet);
+ sal_uInt16 nWhich = aIter.FirstWhich();
+
+ while (nWhich)
+ {
+ rSet.DisableItem( nWhich );
+ nWhich = aIter.NextWhich();
+ }
+}
+
+// Disable the slots with this status methode
+
+void SwBaseShell::StateStyle( SfxItemSet &rSet )
+{
+ bool bParentCntProt = GetShell().IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) != 0;
+ ShellModes eMode = GetView().GetShellMode();
+
+ if ( bParentCntProt ||
+ SHELL_MODE_DRAW == eMode ||
+ SHELL_MODE_DRAW_CTRL == eMode ||
+ SHELL_MODE_DRAW_FORM == eMode ||
+ SHELL_MODE_DRAWTEXT == eMode ||
+ SHELL_MODE_BEZIER == eMode )
+ {
+ SfxWhichIter aIter( rSet );
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ while ( nWhich )
+ {
+ rSet.DisableItem( nWhich );
+ nWhich = aIter.NextWhich();
+ }
+ }
+ else
+ GetView().GetDocShell()->StateStyleSheet(rSet, &GetShell());
+}
+
+void SwBaseShell::SetWrapMode( sal_uInt16 nSlot )
+{
+ SwWrtShell &rSh = GetShell();
+ bool bObj = 0 != rSh.IsObjSelected();
+ if( bObj || rSh.IsFrmSelected())
+ {
+ SfxItemSet aSet(GetPool(), RES_OPAQUE, RES_SURROUND);
+ if(bObj)
+ rSh.GetObjAttr(aSet);
+ else
+ rSh.GetFlyFrmAttr(aSet);
+ SwFmtSurround aWrap( (SwFmtSurround&)aSet.Get(RES_SURROUND) );
+ SwSurround nOldSurround(aWrap.GetSurround());
+ SwSurround nSurround = SURROUND_PARALLEL;
+
+ switch (nSlot)
+ {
+ case FN_FRAME_NOWRAP:
+ nSurround = SURROUND_NONE;
+ if (aWrap.IsContour())
+ aWrap.SetContour(sal_False);
+ break;
+ case FN_FRAME_WRAP_IDEAL:
+ nSurround = SURROUND_IDEAL;
+ break;
+ case FN_WRAP_ANCHOR_ONLY:
+ aWrap.SetAnchorOnly(!aWrap.IsAnchorOnly());
+
+ // keep previous wrapping
+
+ // switch to wrap SURROUND_PARALLEL, if previous wrap is SURROUND_NONE
+ if ( nOldSurround != SURROUND_NONE )
+ {
+ nSurround = nOldSurround;
+ }
+ break;
+ case FN_FRAME_WRAP_CONTOUR:
+ aWrap.SetContour(!aWrap.IsContour());
+ if (nSurround == SURROUND_THROUGHT)
+ nSurround = SURROUND_PARALLEL;
+ break;
+ case FN_FRAME_WRAPTHRU_TRANSP:
+ if (aWrap.IsContour())
+ aWrap.SetContour(sal_False);
+ // No break!!!
+ case FN_FRAME_WRAPTHRU:
+ nSurround = SURROUND_THROUGHT;
+ break;
+
+ case FN_FRAME_WRAP_LEFT:
+ nSurround = SURROUND_LEFT;
+ break;
+
+ case FN_FRAME_WRAP_RIGHT:
+ nSurround = SURROUND_RIGHT;
+ break;
+
+ default:
+ break;
+ }
+ aWrap.SetSurround(nSurround);
+
+ if (nSlot != FN_FRAME_WRAP_CONTOUR)
+ {
+ // Defaulting the contour wrap on draw objects.
+ if (bObj && nOldSurround != nSurround &&
+ (nOldSurround == SURROUND_NONE || nOldSurround == SURROUND_THROUGHT))
+ {
+ aWrap.SetContour(sal_True);
+ }
+ }
+
+ aSet.Put( aWrap );
+ aSet.Put(SvxOpaqueItem(RES_OPAQUE, nSlot != FN_FRAME_WRAPTHRU_TRANSP));
+ if(bObj)
+ {
+ rSh.SetObjAttr(aSet);
+ if (nSlot != FN_FRAME_WRAPTHRU_TRANSP)
+ rSh.SelectionToHeaven();
+ else
+ rSh.SelectionToHell();
+ }
+ else
+ rSh.SetFlyFrmAttr(aSet);
+ }
+}
+
+//Force update of the status line
+
+void SwBaseShell::SetFrmMode(FlyMode eMode, SwWrtShell *pSh )
+{
+ eFrameMode = eMode;
+ SfxBindings &rBnd = pSh->GetView().GetViewFrame()->GetBindings();
+
+ if( eMode == FLY_DRAG || pSh->IsFrmSelected() || pSh->IsObjSelected() )
+ {
+ const SfxPointItem aTmp1( SID_ATTR_POSITION, pSh->GetAnchorObjDiff());
+ const SvxSizeItem aTmp2( SID_ATTR_SIZE, pSh->GetObjSize());
+ rBnd.SetState( aTmp1 );
+ rBnd.SetState( aTmp2 );
+ }
+ else if( eMode == FLY_DRAG_END )
+ {
+ static sal_uInt16 aInval[] =
+ {
+ SID_ATTR_POSITION, SID_ATTR_SIZE, 0
+ };
+ rBnd.Invalidate(aInval);
+ }
+}
+
+SwBaseShell::SwBaseShell(SwView& rVw) :
+ SfxShell( &rVw ),
+ rView(rVw),
+ pGetStateSet(0)
+{
+ SwWrtShell& rWrtSh = rView.GetWrtShell();
+
+ SetPool(&rWrtSh.GetAttrPool());
+ SetName(OUString("Base"));
+ rWrtSh.SetGrfArrivedLnk( LINK( this, SwBaseShell, GraphicArrivedHdl));
+}
+
+SwBaseShell::~SwBaseShell()
+{
+ if( rView.GetCurShell() == this )
+ rView.ResetSubShell();
+
+ Link aTmp( LINK( this, SwBaseShell, GraphicArrivedHdl));
+ if( aTmp == rView.GetWrtShell().GetGrfArrivedLnk() )
+ rView.GetWrtShell().SetGrfArrivedLnk( Link() );
+}
+
+void SwBaseShell::ExecTxtCtrl( SfxRequest& rReq )
+{
+ const SfxItemSet *pArgs = rReq.GetArgs();
+
+ if( pArgs)
+ {
+ SwWrtShell &rSh = GetShell();
+ SvxScriptSetItem* pSSetItem = 0;
+ sal_uInt16 nSlot = rReq.GetSlot();
+ SfxItemPool& rPool = rSh.GetAttrPool();
+ sal_uInt16 nWhich = rPool.GetWhich( nSlot );
+ sal_uInt16 nScripts = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX;
+ SfxItemSet aHeightSet( GetPool(), RES_CHRATR_FONTSIZE, RES_CHRATR_FONTSIZE,
+ RES_CHRATR_CJK_FONTSIZE, RES_CHRATR_CJK_FONTSIZE,
+ RES_CHRATR_CTL_FONTSIZE, RES_CHRATR_CTL_FONTSIZE,
+ 0L);
+
+ switch( nSlot )
+ {
+ case SID_ATTR_CHAR_FONT:
+ {
+ nScripts = rSh.GetScriptType();
+ // #i42732# input language should be preferred over
+ // current cursor position to detect script type
+ if(!rSh.HasSelection())
+ {
+ LanguageType nInputLang = GetView().GetEditWin().GetInputLanguage();
+ if(nInputLang != LANGUAGE_DONTKNOW && nInputLang != LANGUAGE_SYSTEM)
+ nScripts = SvtLanguageOptions::GetScriptTypeOfLanguage( nInputLang );
+ }
+ }
+ case SID_ATTR_CHAR_POSTURE:
+ case SID_ATTR_CHAR_WEIGHT:
+ {
+ pSSetItem = new SvxScriptSetItem( nSlot, rPool );
+ pSSetItem->PutItemForScriptType( nScripts, pArgs->Get( nWhich ));
+ pArgs = &pSSetItem->GetItemSet();
+ }
+ break;
+ case SID_ATTR_CHAR_FONTHEIGHT:
+ {
+ if(rSh.HasSelection())
+ {
+ pSSetItem = new SvxScriptSetItem( nSlot, rPool );
+ pSSetItem->PutItemForScriptType( nScripts, pArgs->Get( nWhich ));
+ pArgs = &pSSetItem->GetItemSet();
+ }
+ else
+ {
+ nScripts = rSh.GetScriptType();
+ LanguageType nInputLang = GetView().GetEditWin().GetInputLanguage();
+ if(nInputLang != LANGUAGE_DONTKNOW && nInputLang != LANGUAGE_SYSTEM)
+ nScripts = SvtLanguageOptions::GetScriptTypeOfLanguage( nInputLang );
+ sal_uInt32 nHeight = static_cast< const SvxFontHeightItem& >(pArgs->Get( nWhich )).GetHeight();
+ SwStdFontConfig* pStdFont = SW_MOD()->GetStdFontConfig();
+
+ SfxItemSet aLangSet( GetPool(), RES_CHRATR_LANGUAGE, RES_CHRATR_LANGUAGE,
+ RES_CHRATR_CJK_LANGUAGE, RES_CHRATR_CJK_LANGUAGE,
+ RES_CHRATR_CTL_LANGUAGE, RES_CHRATR_CTL_LANGUAGE,
+ 0L);
+ rSh.GetCurAttr( aLangSet );
+
+ sal_Int32 nWesternSize =
+ pStdFont->GetFontHeight(FONT_STANDARD, FONT_GROUP_DEFAULT,
+ static_cast<const SvxLanguageItem&>(aLangSet.Get( RES_CHRATR_LANGUAGE)).GetLanguage());
+ sal_Int32 nCJKSize =
+ pStdFont->GetFontHeight(FONT_STANDARD, FONT_GROUP_CJK,
+ static_cast<const SvxLanguageItem&>(aLangSet.Get( RES_CHRATR_CJK_LANGUAGE)).GetLanguage());
+ sal_Int32 nCTLSize =
+ pStdFont->GetFontHeight(FONT_STANDARD, FONT_GROUP_CTL,
+ static_cast<const SvxLanguageItem&>(aLangSet.Get( RES_CHRATR_CTL_LANGUAGE)).GetLanguage());
+
+ switch(nScripts)
+ {
+ case SCRIPTTYPE_LATIN:
+ nCJKSize = nHeight * nCJKSize / nWesternSize;
+ nCTLSize = nHeight * nCTLSize / nWesternSize;
+ nWesternSize = (sal_Int32) nHeight;
+ break;
+ case SCRIPTTYPE_ASIAN:
+ nCTLSize = nHeight* nCTLSize / nCJKSize;
+ nWesternSize = nHeight * nWesternSize / nCJKSize;
+ nCJKSize = (sal_Int32) nHeight;
+ break;
+ case SCRIPTTYPE_COMPLEX:
+ nCJKSize = nHeight * nCJKSize / nCTLSize;
+ nWesternSize = nHeight * nWesternSize / nCTLSize;
+ nCTLSize = (sal_Int32) nHeight;
+ break;
+ }
+ aHeightSet.Put( SvxFontHeightItem( (sal_uInt32)nWesternSize, 100, RES_CHRATR_FONTSIZE ));
+ aHeightSet.Put( SvxFontHeightItem( (sal_uInt32)nCJKSize, 100, RES_CHRATR_CJK_FONTSIZE ));
+ aHeightSet.Put( SvxFontHeightItem( (sal_uInt32)nCTLSize, 100, RES_CHRATR_CTL_FONTSIZE ));
+ pArgs = &aHeightSet;
+ }
+ }
+ break;
+ }
+
+ if( pArgs )
+ {
+ bool bAuto = false;
+ if ( !isCHRATR(nWhich) ||
+ ( rSh.HasSelection() && rSh.IsSelFullPara() ) )
+ {
+ SwTxtFmtColl * pColl = rSh.GetCurTxtFmtColl();
+ if ( pColl && pColl->IsAutoUpdateFmt() )
+ {
+ rSh.AutoUpdatePara( pColl, *pArgs );
+ bAuto = true;
+ }
+ }
+
+ if (!bAuto)
+ {
+ rSh.SetAttrSet( *pArgs );
+ }
+ }
+ delete pSSetItem;
+ }
+ else
+ GetView().GetViewFrame()->GetDispatcher()->Execute( SID_CHAR_DLG, sal_False);
+ rReq.Done();
+}
+
+void SwBaseShell::GetTxtCtrlState( SfxItemSet& rSet )
+{
+ SwWrtShell &rSh = GetShell();
+ rSh.GetCurAttr( rSet );
+}
+
+void SwBaseShell::GetTxtFontCtrlState( SfxItemSet& rSet )
+{
+ SwWrtShell &rSh = GetShell();
+ bool bFirst = true;
+ SfxItemSet* pFntCoreSet = 0;
+ sal_uInt16 nScriptType = SCRIPTTYPE_LATIN;
+ SfxWhichIter aIter( rSet );
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ while( nWhich )
+ {
+ switch( nWhich )
+ {
+ case RES_CHRATR_FONT:
+ case RES_CHRATR_FONTSIZE:
+ case RES_CHRATR_WEIGHT:
+ case RES_CHRATR_POSTURE:
+ {
+ if( !pFntCoreSet )
+ {
+ pFntCoreSet = new SfxItemSet( *rSet.GetPool(),
+ RES_CHRATR_BEGIN, RES_CHRATR_END-1 );
+ rSh.GetCurAttr( *pFntCoreSet );
+ nScriptType = rSh.GetScriptType();
+ // #i42732# input language should be preferred over
+ // current cursor position to detect script type
+ SwEditWin& rEditWin = GetView().GetEditWin();
+ if( rEditWin.IsUseInputLanguage() )
+ {
+ if(!rSh.HasSelection() && (
+ nWhich == RES_CHRATR_FONT ||
+ nWhich == RES_CHRATR_FONTSIZE ))
+ {
+ LanguageType nInputLang = rEditWin.GetInputLanguage();
+ if(nInputLang != LANGUAGE_DONTKNOW && nInputLang != LANGUAGE_SYSTEM)
+ nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( nInputLang );
+ }
+ }
+ }
+ SfxItemPool& rPool = *rSet.GetPool();
+ SvxScriptSetItem aSetItem( rPool.GetSlotId( nWhich ), rPool );
+ aSetItem.GetItemSet().Put( *pFntCoreSet, false );
+ const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScriptType );
+ if( pI )
+ rSet.Put( *pI, nWhich );
+ else
+ rSet.InvalidateItem( nWhich );
+ // Set input context of the SwEditWin according to the selected font and script type
+ if(RES_CHRATR_FONT == nWhich)
+ {
+ Font aFont;
+ if(pI && pI->ISA(SvxFontItem))
+ {
+ aFont.SetName( ((const SvxFontItem*)pI)->GetFamilyName());
+ aFont.SetStyleName(((const SvxFontItem*)pI)->GetStyleName());
+ aFont.SetFamily(((const SvxFontItem*)pI)->GetFamily());
+ aFont.SetPitch(((const SvxFontItem*)pI)->GetPitch());
+ aFont.SetCharSet(((const SvxFontItem*)pI)->GetCharSet());
+ }
+
+ bool bVertical = rSh.IsInVerticalText();
+ aFont.SetOrientation(bVertical ? 2700 : 0);
+ aFont.SetVertical(bVertical ? sal_True : sal_False);
+ GetView().GetEditWin().SetInputContext( InputContext( aFont, INPUTCONTEXT_TEXT |
+ INPUTCONTEXT_EXTTEXTINPUT ) );
+ }
+ }
+ break;
+
+ default:
+ if( bFirst )
+ {
+ rSh.GetCurAttr( rSet );
+ bFirst = false;
+ }
+ }
+ nWhich = aIter.NextWhich();
+ }
+ delete pFntCoreSet;
+}
+
+void SwBaseShell::GetBckColState(SfxItemSet &rSet)
+{
+ SwWrtShell &rSh = GetShell();
+ SfxWhichIter aIter( rSet );
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ int nSelType = rSh.GetSelectionType();
+
+ if( nSelType & nsSelectionType::SEL_OLE )
+ {
+ rSet.DisableItem( SID_BACKGROUND_COLOR );
+ return;
+ }
+
+ if ( nSelType & nsSelectionType::SEL_FRM )
+ {
+ bool bParentCntProt = rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) != 0;
+ if (bParentCntProt)
+ {
+ rSet.DisableItem( SID_BACKGROUND_COLOR );
+ return;
+ }
+ }
+
+ SvxBrushItem aBrushItem( RES_BACKGROUND );
+
+ if( nsSelectionType::SEL_TBL_CELLS & nSelType )
+ rSh.GetBoxBackground( aBrushItem );
+ else
+ {
+ SfxItemSet aCoreSet(GetPool(), RES_BACKGROUND, RES_BACKGROUND);
+ if( nSelType & nsSelectionType::SEL_GRF || nsSelectionType::SEL_FRM & nSelType )
+ rSh.GetFlyFrmAttr( aCoreSet );
+ else
+ rSh.GetCurAttr( aCoreSet );
+ aBrushItem = (const SvxBrushItem&)aCoreSet.Get(RES_BACKGROUND);
+ }
+
+ while ( nWhich )
+ {
+ switch(nWhich)
+ {
+ case SID_BACKGROUND_COLOR :
+ {
+ SvxColorItem aColorItem(aBrushItem.GetColor(), SID_BACKGROUND_COLOR);
+ rSet.Put( aColorItem, SID_BACKGROUND_COLOR );
+ }
+ break;
+ case SID_ATTR_BRUSH:
+ case RES_BACKGROUND:
+ rSet.Put( aBrushItem, GetPool().GetWhich(nWhich) );
+ break;
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+void SwBaseShell::ExecBckCol(SfxRequest& rReq)
+{
+ SwWrtShell &rSh = GetShell();
+ int nSelType = rSh.GetSelectionType();
+ if ( nSelType & nsSelectionType::SEL_OLE )
+ {
+ return;
+ }
+
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ sal_uInt16 nSlot = rReq.GetSlot();
+ if( !pArgs && nSlot != SID_BACKGROUND_COLOR)
+ return ;
+
+ SvxBrushItem aBrushItem( RES_BACKGROUND );
+
+ if( nsSelectionType::SEL_TBL_CELLS & nSelType )
+ {
+ rSh.GetBoxBackground( aBrushItem );
+ }
+ else
+ {
+ SfxItemSet aCoreSet(GetPool(), RES_BACKGROUND, RES_BACKGROUND);
+ if( (nsSelectionType::SEL_FRM & nSelType) || (nsSelectionType::SEL_GRF & nSelType) )
+ rSh.GetFlyFrmAttr( aCoreSet );
+ else
+ rSh.GetCurAttr( aCoreSet );
+ aBrushItem = (const SvxBrushItem&)aCoreSet.Get(RES_BACKGROUND);
+ }
+
+ switch (nSlot)
+ {
+ // RES_BACKGROUND (=SID_ATTR_BRUSH) must be set with two IDs:
+ case SID_BACKGROUND_COLOR:
+ {
+ aBrushItem.SetGraphicPos(GPOS_NONE);
+
+ if(pArgs)
+ {
+ const SvxColorItem& rNewColorItem = (const SvxColorItem&)
+ pArgs->Get(SID_BACKGROUND_COLOR);
+ const Color& rNewColor = rNewColorItem.GetValue();
+ aBrushItem.SetColor( rNewColor );
+ GetView().GetViewFrame()->GetBindings().SetState(rNewColorItem);
+ }
+ else
+ {
+ aBrushItem.SetColor( COL_TRANSPARENT );
+ rReq.AppendItem( SvxColorItem( Color( COL_TRANSPARENT ), nSlot ) );
+ }
+ }
+ break;
+
+ case SID_ATTR_BRUSH:
+ case RES_BACKGROUND:
+ {
+ const SvxBrushItem& rNewBrushItem = (const SvxBrushItem&)
+ pArgs->Get( GetPool().GetWhich(nSlot) );
+ aBrushItem = rNewBrushItem;
+ }
+ break;
+ default:
+ rReq.Ignore();
+ OSL_FAIL("unknown message in ExecuteAttr!" );
+ return;
+ }
+
+ if( nsSelectionType::SEL_TBL_CELLS & nSelType )
+ {
+ rSh.SetBoxBackground( aBrushItem );
+ }
+ else if( (nsSelectionType::SEL_FRM & nSelType) ||
+ (nsSelectionType::SEL_GRF & nSelType) )
+ {
+ SfxItemSet aCoreSet(GetPool(), RES_BACKGROUND, RES_BACKGROUND);
+ aCoreSet.Put( aBrushItem );
+ // Template autoupdate
+ SwFrmFmt* pFmt = rSh.GetCurFrmFmt();
+ if(pFmt && pFmt->IsAutoUpdateFmt())
+ rSh.AutoUpdateFrame( pFmt, aCoreSet);
+ else
+ rSh.SetFlyFrmAttr( aCoreSet );
+ }
+ else
+ {
+ SwTxtFmtColl* pColl = rSh.GetCurTxtFmtColl();
+ if( pColl && pColl->IsAutoUpdateFmt())
+ {
+ SfxItemSet aSet(GetPool(), RES_BACKGROUND, RES_BACKGROUND );
+ aSet.Put(aBrushItem);
+ rSh.AutoUpdatePara( pColl, aSet);
+ }
+ else
+ rSh.SetAttrItem( aBrushItem );
+ }
+
+ rReq.Done();
+}
+
+void SwBaseShell::GetBorderState(SfxItemSet &rSet)
+{
+ SwWrtShell &rSh = GetShell();
+ // Tabele cell(s) selected?
+ bool bPrepare = true;
+ sal_Bool bTableMode = rSh.IsTableMode();
+ if ( bTableMode )
+ {
+ SfxItemSet aCoreSet( GetPool(),
+ RES_BOX, RES_BOX,
+ SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 0 );
+ SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
+ aCoreSet.Put( aBoxInfo );
+ rSh.GetTabBorders( aCoreSet );
+ rSet.Put( aCoreSet );
+ }
+ else if ( rSh.IsFrmSelected() )
+ {
+ SwFlyFrmAttrMgr aMgr( sal_False, &rSh, FRMMGR_TYPE_NONE );
+ rSet.Put( aMgr.GetAttrSet() );
+ bPrepare = false;
+ }
+ else
+ // Get border attributes via shell quite normal
+ rSh.GetCurAttr( rSet );
+ if ( bPrepare )
+ ::PrepareBoxInfo( rSet, rSh );
+ // Switch the border toolbox controller mode
+ rSet.Put( SfxBoolItem( SID_BORDER_REDUCED_MODE, !bTableMode ));
+}
+
+void SwBaseShell::ExecDlg(SfxRequest &rReq)
+{
+ SwWrtShell &rSh = GetShell();
+ Window *pMDI = &GetView().GetViewFrame()->GetWindow();
+ // So that from the basic no dialogues for the background views are called:
+ bool bBackground = (&GetView() != GetActiveView());
+ const SfxPoolItem* pItem = 0;
+ const SfxItemSet* pArgs = rReq.GetArgs();
+
+ sal_uInt16 nSlot = rReq.GetSlot();
+ const SfxItemSet* pOutSet = 0;
+ bool bDone = false;
+ if(pArgs)
+ pArgs->GetItemState( GetPool().GetWhich(nSlot), false, &pItem );
+
+ switch ( nSlot )
+ {
+ case FN_FORMAT_TITLEPAGE_DLG:
+ {
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ VclAbstractDialog* pDlg = pFact->CreateTitlePageDlg( pMDI );
+ pDlg->Execute();
+ delete pDlg;
+ }
+ break;
+ case FN_FORMAT_PAGE_DLG:
+ case FN_FORMAT_PAGE_COLUMN_DLG:
+ case FN_FORMAT_PAGE_SETTING_DLG:
+ {
+ if( !bBackground )
+ {
+ const sal_uInt16 nCurIdx = rSh.GetCurPageDesc();
+ const SwPageDesc& rPageDesc = rSh.GetPageDesc( nCurIdx );
+ // Temporary view, because the shell does not need to be valid after the dialogue
+ // for example disable header
+ SwView& rTempView = GetView();
+
+ OString sPageId;
+ switch (nSlot)
+ {
+ case FN_FORMAT_PAGE_COLUMN_DLG:
+ sPageId = "columns";
+ break;
+ case FN_FORMAT_PAGE_SETTING_DLG:
+ sPageId = "page";
+ break;
+ }
+
+ rTempView.GetDocShell()->FormatPage(
+ rPageDesc.GetName(), sPageId, rSh);
+ rTempView.InvalidateRulerPos();
+ }
+ }
+ break;
+ case FN_FORMAT_BORDER_DLG:
+ {
+ SfxItemSet aSet( rSh.GetAttrPool(),
+ RES_BOX , RES_SHADOW,
+ SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
+ 0 );
+ SfxAbstractDialog * pDlg = 0;
+ // Table cell(s) selected?
+ if ( rSh.IsTableMode() )
+ {
+ // Set border attributes Get/SetTabBorders()
+ ::PrepareBoxInfo( aSet, rSh );
+ rSh.GetTabBorders( aSet );
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+
+ pDlg = pFact->CreateSwBorderDlg( pMDI, aSet, SW_BORDER_MODE_TABLE, RC_DLG_SWBORDERDLG );
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ if ( pDlg->Execute() == RET_OK )
+ {
+ rSh.SetTabBorders( *pDlg->GetOutputItemSet() );
+ pOutSet = pDlg->GetOutputItemSet();
+ }
+ }
+ else if ( rSh.IsFrmSelected() )
+ {
+ // Set border attributes via Frame-Manager
+ SwFlyFrmAttrMgr aMgr( sal_False, &rSh, FRMMGR_TYPE_NONE );
+ aSet.Put( aMgr.GetAttrSet() );
+
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+
+ pDlg = pFact->CreateSwBorderDlg( pMDI, aSet, SW_BORDER_MODE_FRAME, RC_DLG_SWBORDERDLG );
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ if ( pDlg->Execute() == RET_OK )
+ {
+ aMgr.SetAttrSet( *pDlg->GetOutputItemSet() );
+ aMgr.UpdateFlyFrm();
+ pOutSet = pDlg->GetOutputItemSet();
+ }
+ }
+ else
+ {
+ // Set border attributes via Shell quite normal
+ rSh.GetCurAttr( aSet );
+ ::PrepareBoxInfo( aSet, rSh );
+
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+
+ pDlg = pFact->CreateSwBorderDlg( pMDI, aSet, SW_BORDER_MODE_PARA, RC_DLG_SWBORDERDLG );
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ if ( pDlg->Execute() == RET_OK )
+ {
+ rSh.SetAttrSet( *pDlg->GetOutputItemSet() );
+ pOutSet = pDlg->GetOutputItemSet();
+ }
+ }
+ if(pOutSet)
+ {
+ rReq.Done(*pOutSet);
+ bDone = true;
+ }
+ delete pDlg;
+ }
+ break;
+ case FN_FORMAT_BACKGROUND_DLG:
+ {
+ SfxItemSet aSet( rSh.GetAttrPool(),
+ RES_BACKGROUND, RES_BACKGROUND );
+
+ SfxAbstractDialog * pDlg = 0;
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+
+ // Table cell(s) selected?
+ if ( rSh.IsTableMode() )
+ {
+ // Get background attributes of the table and put it in the set
+ SvxBrushItem aBrush(RES_BACKGROUND);
+ rSh.GetBoxBackground( aBrush );
+ pDlg = pFact->CreateSfxDialog( pMDI, aSet,
+ rView.GetViewFrame()->GetFrame().GetFrameInterface(),
+ RC_SWDLG_BACKGROUND );
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ aSet.Put( aBrush );
+ if ( pDlg->Execute() == RET_OK )
+ {
+
+ rSh.SetBoxBackground( (SvxBrushItem&)
+ pDlg->GetOutputItemSet()->Get( RES_BACKGROUND ));
+ pOutSet = pDlg->GetOutputItemSet();
+ }
+ }
+ else if ( rSh.IsFrmSelected() )
+ {
+
+ rSh.GetFlyFrmAttr( aSet );
+
+ pDlg = pFact->CreateSfxDialog( pMDI, aSet,
+ rView.GetViewFrame()->GetFrame().GetFrameInterface(),
+ RC_SWDLG_BACKGROUND );
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ if ( pDlg->Execute() == RET_OK )
+ {
+ rSh.SetFlyFrmAttr((SfxItemSet &) *pDlg->GetOutputItemSet() );
+ pOutSet = pDlg->GetOutputItemSet();
+ }
+ }
+ else
+ {
+ // Set border attributes Umrandungsattribute with the shell quite normal.
+ rSh.GetCurAttr( aSet );
+
+ pDlg = pFact->CreateSfxDialog( pMDI, aSet,
+ rView.GetViewFrame()->GetFrame().GetFrameInterface(),
+ RC_SWDLG_BACKGROUND );
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ if ( pDlg->Execute() == RET_OK )
+ {
+ rSh.SetAttrSet( *pDlg->GetOutputItemSet() );
+ pOutSet = pDlg->GetOutputItemSet();
+ }
+ }
+ if(pOutSet)
+ {
+ rReq.Done(*pOutSet);
+ bDone = true;
+ }
+ delete pDlg;
+
+ }
+ break;
+ default:OSL_FAIL("wrong Dispatcher (basesh.cxx)");
+ }
+ if(!bDone)
+ rReq.Done();
+}
+
+SwWrtShell& SwBaseShell::GetShell()
+{
+ return rView.GetWrtShell();
+}
+
+SwWrtShell* SwBaseShell::GetShellPtr()
+{
+ return rView.GetWrtShellPtr();
+}
+
+void SwBaseShell::InsertTable( SfxRequest& _rRequest )
+{
+ const SfxItemSet* pArgs = _rRequest.GetArgs();
+ SwWrtShell& rSh = GetShell();
+
+ if ( !( rSh.GetFrmType( 0, sal_True ) & FRMTYPE_FOOTNOTE ) )
+ {
+ SwView &rTempView = GetView(); // Because GetView() does not work after the shell exchange
+ sal_Bool bHTMLMode = 0 != (::GetHtmlMode(rTempView.GetDocShell())&HTMLMODE_ON);
+ bool bCallEndUndo = false;
+
+ if( !pArgs && rSh.IsSelection() && !rSh.IsInClickToEdit() &&
+ !rSh.IsTableMode() )
+ {
+ const SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
+ SwInsertTableOptions aInsTblOpts = pModOpt->GetInsTblFlags(bHTMLMode);
+
+ rSh.StartUndo(UNDO_INSTABLE);
+ bCallEndUndo = true;
+
+ sal_Bool bInserted = rSh.TextToTable( aInsTblOpts, '\t', text::HoriOrientation::FULL );
+ rSh.EnterStdMode();
+ if (bInserted)
+ rTempView.AutoCaption(TABLE_CAP);
+ _rRequest.Done();
+ }
+ else
+ {
+ sal_uInt16 nCols = 0;
+ sal_uInt16 nRows = 0;
+ SwInsertTableOptions aInsTblOpts( tabopts::ALL_TBL_INS_ATTR, 1 );
+ OUString aTableName;
+ OUString aAutoName;
+ SwTableAutoFmt* pTAFmt = 0;
+
+ if( pArgs && pArgs->Count() >= 2 )
+ {
+ SFX_REQUEST_ARG( _rRequest, pName, SfxStringItem, FN_INSERT_TABLE, false );
+ SFX_REQUEST_ARG( _rRequest, pCols, SfxUInt16Item, SID_ATTR_TABLE_COLUMN, false );
+ SFX_REQUEST_ARG( _rRequest, pRows, SfxUInt16Item, SID_ATTR_TABLE_ROW, false );
+ SFX_REQUEST_ARG( _rRequest, pFlags, SfxInt32Item, FN_PARAM_1, false );
+ SFX_REQUEST_ARG( _rRequest, pAuto, SfxStringItem, FN_PARAM_2, false );
+
+ if ( pName )
+ aTableName = pName->GetValue();
+ if ( pCols )
+ nCols = pCols->GetValue();
+ if ( pRows )
+ nRows = pRows->GetValue();
+ if ( pAuto )
+ {
+ aAutoName = pAuto->GetValue();
+ if ( !aAutoName.isEmpty() )
+ {
+ SwTableAutoFmtTbl aTableTbl;
+ aTableTbl.Load();
+ for ( sal_uInt16 n=0; n<aTableTbl.size(); n++ )
+ {
+ if ( aTableTbl[n].GetName() == aAutoName )
+ {
+ pTAFmt = new SwTableAutoFmt( aTableTbl[n] );
+ break;
+ }
+ }
+ }
+ }
+
+ if ( pFlags )
+ aInsTblOpts.mnInsMode = (sal_uInt16) pFlags->GetValue();
+ else
+ {
+ const SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
+ aInsTblOpts = pModOpt->GetInsTblFlags(bHTMLMode);
+ }
+ }
+
+ if( !nCols || !nRows )
+ {
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "Dialogdiet fail!");
+ AbstractInsTableDlg* pDlg = pFact->CreateInsTableDlg(rTempView);
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ if( RET_OK == pDlg->Execute() )
+ {
+ pDlg->GetValues( aTableName, nRows, nCols, aInsTblOpts, aAutoName, pTAFmt );
+ }
+ else
+ _rRequest.Ignore();
+ delete pDlg;
+ }
+
+ if( nCols && nRows )
+ {
+ // record before shell change
+ _rRequest.AppendItem( SfxStringItem( FN_INSERT_TABLE, aTableName ) );
+ if ( !aAutoName.isEmpty() )
+ _rRequest.AppendItem( SfxStringItem( FN_PARAM_2, aAutoName ) );
+ _rRequest.AppendItem( SfxUInt16Item( SID_ATTR_TABLE_COLUMN, nCols ) );
+ _rRequest.AppendItem( SfxUInt16Item( SID_ATTR_TABLE_ROW, nRows ) );
+ _rRequest.AppendItem( SfxInt32Item( FN_PARAM_1, (sal_Int32) aInsTblOpts.mnInsMode ) );
+ _rRequest.Done();
+
+ rSh.StartUndo(UNDO_INSTABLE);
+ bCallEndUndo = true;
+
+ rSh.StartAllAction();
+ if( rSh.HasSelection() )
+ rSh.DelRight();
+
+ rSh.InsertTable( aInsTblOpts, nRows, nCols, text::HoriOrientation::FULL, pTAFmt );
+ rSh.MoveTable( fnTablePrev, fnTableStart );
+
+ if( !aTableName.isEmpty() && !rSh.GetTblStyle( aTableName ) )
+ rSh.GetTableFmt()->SetName( aTableName );
+
+ rSh.EndAllAction();
+ rTempView.AutoCaption(TABLE_CAP);
+ }
+ delete pTAFmt;
+ }
+
+ if( bCallEndUndo )
+ {
+ SwRewriter aRewriter;
+
+ if (rSh.GetTableFmt())
+ {
+ aRewriter.AddRule(UndoArg1, SW_RESSTR(STR_START_QUOTE));
+ aRewriter.AddRule(UndoArg2, rSh.GetTableFmt()->GetName());
+ aRewriter.AddRule(UndoArg3, SW_RESSTR(STR_END_QUOTE));
+
+ }
+ rSh.EndUndo(UNDO_INSTABLE, &aRewriter); // If possible change the Shell
+ }
+ }
+}
+
+void SwBaseShell::GetGalleryState( SfxItemSet &rSet )
+{
+ SwWrtShell &rSh = GetShell();
+ SfxWhichIter aIter( rSet );
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ switch ( nWhich )
+ {
+ case SID_GALLERY_BG_BRUSH:
+ {
+ int nSel = rSh.GetSelectionType();
+ SfxStringListItem aLst( nWhich );
+ std::vector<OUString> &rLst = aLst.GetList();
+ nParagraphPos = nGraphicPos = nOlePos = nFramePos = nTablePos =
+ nTableRowPos = nTableCellPos = nPagePos =
+ nHeaderPos = nFooterPos = 0;
+ sal_uInt8 nPos = 1;
+ rLst.push_back( SW_RESSTR( STR_SWBG_PAGE ) );
+ nPagePos = nPos++;
+ sal_uInt16 nHtmlMode = ::GetHtmlMode(GetView().GetDocShell());
+ bool bHtmlMode = 0 != (nHtmlMode & HTMLMODE_ON);
+
+ if ( (!bHtmlMode || (nHtmlMode & HTMLMODE_FULL_STYLES)) &&
+ (nSel & nsSelectionType::SEL_TXT) )
+ {
+ rLst.push_back( SW_RESSTR( STR_SWBG_PARAGRAPH ) );
+ nParagraphPos = nPos++;
+ }
+ if ( (!bHtmlMode || (nHtmlMode & HTMLMODE_SOME_STYLES)) &&
+ nSel & (nsSelectionType::SEL_TBL|nsSelectionType::SEL_TBL_CELLS) )
+ {
+ rLst.push_back( SW_RESSTR( STR_SWBG_TABLE ) );
+ nTablePos = nPos++;
+
+ if(!bHtmlMode)
+ {
+ rLst.push_back( SW_RESSTR( STR_SWBG_TABLE_ROW ) );
+ nTableRowPos = nPos++;
+ }
+
+ rLst.push_back( SW_RESSTR( STR_SWBG_TABLE_CELL) );
+ nTableCellPos = nPos++;
+ }
+ if(!bHtmlMode)
+ {
+ if ( nSel & nsSelectionType::SEL_FRM )
+ {
+ rLst.push_back( SW_RESSTR( STR_SWBG_FRAME ) );
+ nFramePos = nPos++;
+ }
+ if ( nSel & nsSelectionType::SEL_GRF )
+ {
+ rLst.push_back( SW_RESSTR( STR_SWBG_GRAPHIC ) );
+ nGraphicPos = nPos++;
+ }
+ if ( nSel & nsSelectionType::SEL_OLE )
+ {
+ rLst.push_back( SW_RESSTR( STR_SWBG_OLE ) );
+ nOlePos = nPos++;
+ }
+ const sal_uInt16 nType = rSh.GetFrmType(0,sal_True);
+ if ( nType & FRMTYPE_HEADER )
+ {
+ rLst.push_back( SW_RESSTR( STR_SWBG_HEADER ) );
+ nHeaderPos = nPos++;
+ }
+ if ( nType & FRMTYPE_FOOTER )
+ {
+ rLst.push_back( SW_RESSTR( STR_SWBG_FOOTER ) );
+ nFooterPos = nPos;
+ }
+ }
+ if ( rLst.empty() )
+ rSet.DisableItem( nWhich );
+ else
+ rSet.Put( aLst );
+ break;
+ }
+ }
+}
+
+void SwBaseShell::ExecuteGallery(SfxRequest &rReq)
+{
+ SwWrtShell &rSh = GetShell();
+ rSh.StartAction();
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ sal_uInt16 nSlot = rReq.GetSlot();
+ switch(nSlot)
+ {
+ case SID_GALLERY_BG_BRUSH:
+ {
+ if ( !pArgs )
+ break;
+
+ int nSel = rSh.GetSelectionType();
+ if ( nSel & nsSelectionType::SEL_DRW_TXT )
+ break;
+
+ SFX_REQUEST_ARG( rReq, pPos, SfxUInt16Item, SID_GALLERY_BG_POS, false );
+ SFX_REQUEST_ARG( rReq, pBrush, SvxBrushItem, SID_GALLERY_BG_BRUSH, false );
+ if ( !pPos || !pBrush )
+ break;
+
+ sal_uInt8 nPos = pPos->GetValue();
+ ++nPos;
+
+ SvxBrushItem aBrush( *pBrush );
+ aBrush.SetWhich( RES_BACKGROUND );
+ if ( nPos == nParagraphPos )
+ rSh.SetAttrItem( aBrush );
+ else if ( nPos == nTablePos )
+ rSh.SetTabBackground( aBrush );
+ else if ( nPos == nTableRowPos )
+ rSh.SetRowBackground( aBrush );
+ else if ( nPos == nTableCellPos )
+ rSh.SetBoxBackground( aBrush );
+ else if ( nPos == nFramePos || nPos == nGraphicPos || nPos == nOlePos )
+ {
+ SfxItemSet aCoreSet(GetPool(), RES_BACKGROUND, RES_BACKGROUND);
+ aCoreSet.Put( aBrush );
+ rSh.SetFlyFrmAttr( aCoreSet );
+ }
+ else if ( nPos == nPagePos || nPos == nHeaderPos || nPos == nFooterPos )
+ {
+ sal_uInt16 nDesc = rSh.GetCurPageDesc();
+ SwPageDesc aDesc( rSh.GetPageDesc( nDesc ) );
+ if ( nPos == nPagePos )
+ aDesc.GetMaster().SetFmtAttr( aBrush );
+ else if ( nPos == nHeaderPos )
+ {
+ SwFmtHeader aHead( aDesc.GetMaster().GetHeader() );
+ aHead.GetHeaderFmt()->SetFmtAttr( aBrush );
+ aDesc.GetMaster().SetFmtAttr( aHead );
+ }
+ else if ( nPos == nFooterPos )
+ {
+ SwFmtFooter aFoot( aDesc.GetMaster().GetFooter() );
+ aFoot.GetFooterFmt()->SetFmtAttr( aBrush );
+ aDesc.GetMaster().SetFmtAttr( aFoot );
+ }
+ rSh.ChgPageDesc( nDesc, aDesc );
+ }
+ break;
+ }
+ }
+ rSh.EndAction();
+ rReq.Done();
+}
+
+void SwBaseShell::ExecField( SfxRequest& rReq )
+{
+ sal_uInt16 nSlot = rReq.GetSlot();
+ switch( nSlot )
+ {
+ case FN_CHANGE_DBFIELD:
+ {
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+
+ VclAbstractDialog* pDlg = pFact->CreateSwChangeDBDlg(GetView());
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ pDlg->Execute();
+ delete pDlg;
+ }
+ break;
+ default:
+ OSL_FAIL("wrong dispatcher");
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/shells/beziersh.cxx b/sw/source/core/uibase/shells/beziersh.cxx
new file mode 100644
index 000000000000..8ba2d2a184df
--- /dev/null
+++ b/sw/source/core/uibase/shells/beziersh.cxx
@@ -0,0 +1,330 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "cmdid.h"
+#include <svx/svdview.hxx>
+#include <svl/srchitem.hxx>
+#include <svl/eitem.hxx>
+#include <svl/whiter.hxx>
+#include <svx/svdopath.hxx>
+#include <sfx2/sidebar/EnumContext.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/objface.hxx>
+
+#include "wrtsh.hxx"
+#include "view.hxx"
+#include "edtwin.hxx"
+#include "helpid.h"
+#include "globals.hrc"
+#include "drawbase.hxx"
+#include "beziersh.hxx"
+#include "popup.hrc"
+#include "shells.hrc"
+#define SwBezierShell
+#include <sfx2/msg.hxx>
+#include "swslots.hxx"
+
+#include <unomid.h>
+
+SFX_IMPL_INTERFACE(SwBezierShell, SwBaseShell, SW_RES(STR_SHELLNAME_BEZIER))
+{
+ SFX_POPUPMENU_REGISTRATION(SW_RES(MN_DRAW_POPUPMENU));
+ SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_BEZIER_TOOLBOX));
+}
+
+TYPEINIT1(SwBezierShell,SwBaseShell)
+
+SwBezierShell::SwBezierShell(SwView &_rView):
+ SwBaseShell( _rView )
+{
+ SetName(OUString("Bezier"));
+ SetHelpId(SW_BEZIERSHELL);
+
+ SwWrtShell *pSh = &GetShell();
+ SdrView* pSdrView = pSh->GetDrawView();
+ pSdrView->SetEliminatePolyPointLimitAngle(1500L);
+
+ SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_Draw));
+}
+
+void SwBezierShell::Execute(SfxRequest &rReq)
+{
+ SwWrtShell *pSh = &GetShell();
+ SdrView* pSdrView = pSh->GetDrawView();
+ const SfxItemSet *pArgs = rReq.GetArgs();
+ sal_uInt16 nSlotId = rReq.GetSlot();
+ sal_Bool bChanged = pSdrView->GetModel()->IsChanged();
+ pSdrView->GetModel()->SetChanged(false);
+ const SfxPoolItem* pItem;
+ if(pArgs)
+ pArgs->GetItemState(nSlotId, false, &pItem);
+
+ switch (nSlotId)
+ {
+ case SID_DELETE:
+ case FN_BACKSPACE:
+ if (pSh->IsObjSelected())
+ {
+ if (pSdrView->HasMarkedPoints())
+ pSh->GetView().GetViewFrame()->GetDispatcher()->Execute(SID_BEZIER_DELETE, sal_False);
+ else
+ {
+ pSh->DelSelectedObj();
+ if (pSh->IsSelFrmMode())
+ {
+ pSh->LeaveSelFrmMode();
+ pSh->NoEdit();
+ }
+ GetView().AttrChangedNotify(pSh); // Shell change if applicable...
+ }
+ }
+ break;
+
+ case FN_ESCAPE:
+ if (pSdrView->HasMarkedPoints())
+ pSdrView->UnmarkAllPoints();
+ else
+ {
+ if ( pSh->IsDrawCreate() )
+ {
+ GetView().GetDrawFuncPtr()->BreakCreate();
+ GetView().AttrChangedNotify(pSh); // Shell change if applicable...
+ }
+ else if ( pSh->HasSelection() || GetView().IsDrawMode() )
+ {
+ GetView().LeaveDrawCreate();
+ pSh->EnterStdMode();
+ GetView().AttrChangedNotify(pSh); // Shell change if applicable...
+ }
+ }
+ break;
+
+ case SID_BEZIER_MOVE:
+ case SID_BEZIER_INSERT:
+ {
+ GetView().GetEditWin().SetBezierMode(nSlotId);
+ static sal_uInt16 aInva[] =
+ {
+ SID_BEZIER_INSERT,
+ SID_BEZIER_MOVE,
+ 0
+ };
+ GetView().GetViewFrame()->GetBindings().Invalidate(aInva);
+ }
+ break;
+
+ case SID_BEZIER_DELETE:
+ case SID_BEZIER_CUTLINE:
+ case SID_BEZIER_CONVERT:
+ case SID_BEZIER_EDGE:
+ case SID_BEZIER_SMOOTH:
+ case SID_BEZIER_SYMMTR:
+ case SID_BEZIER_CLOSE:
+ case SID_BEZIER_ELIMINATE_POINTS:
+ {
+ const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
+
+ if (rMarkList.GetMark(0) && !pSdrView->IsAction())
+ {
+ switch (nSlotId)
+ {
+ case SID_BEZIER_DELETE:
+ pSdrView->DeleteMarkedPoints();
+ break;
+
+ case SID_BEZIER_CUTLINE:
+ {
+ pSdrView->RipUpAtMarkedPoints();
+ pSh->CheckUnboundObjects();
+ }
+ break;
+
+ case SID_BEZIER_CONVERT:
+ {
+ pSdrView->SetMarkedSegmentsKind(SDRPATHSEGMENT_TOGGLE);
+ break;
+ }
+
+ case SID_BEZIER_EDGE:
+ case SID_BEZIER_SMOOTH:
+ case SID_BEZIER_SYMMTR:
+ {
+ SdrPathSmoothKind eKind = SDRPATHSMOOTH_ASYMMETRIC;
+
+ switch (nSlotId)
+ {
+ case SID_BEZIER_EDGE: eKind = SDRPATHSMOOTH_ANGULAR; break;
+ case SID_BEZIER_SMOOTH: eKind = SDRPATHSMOOTH_ASYMMETRIC; break;
+ case SID_BEZIER_SYMMTR: eKind = SDRPATHSMOOTH_SYMMETRIC; break;
+ }
+
+ SdrPathSmoothKind eSmooth = pSdrView->GetMarkedPointsSmooth();
+ if (eKind != eSmooth)
+ {
+ pSdrView->SetMarkedPointsSmooth(eKind);
+
+ static sal_uInt16 aInva[] =
+ {
+ SID_BEZIER_SMOOTH,
+ SID_BEZIER_EDGE,
+ SID_BEZIER_SYMMTR,
+ 0
+ };
+ GetView().GetViewFrame()->GetBindings().Invalidate(aInva);
+ }
+ break;
+ }
+
+ case SID_BEZIER_CLOSE:
+ {
+ SdrPathObj* pPathObj = (SdrPathObj*) rMarkList.GetMark(0)->GetMarkedSdrObj();
+ pSdrView->UnmarkAllPoints();
+ // Size aDist(GetView().GetEditWin().PixelToLogic(Size(8,8)));
+ pPathObj->ToggleClosed(); // aDist.Width());
+ break;
+ }
+
+ case SID_BEZIER_ELIMINATE_POINTS:
+ pSdrView->SetEliminatePolyPoints(!pSdrView->IsEliminatePolyPoints());
+ break;
+ }
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ if (pSdrView->GetModel()->IsChanged())
+ GetShell().SetModified();
+ else if (bChanged)
+ pSdrView->GetModel()->SetChanged(true);
+}
+
+void SwBezierShell::GetState(SfxItemSet &rSet)
+{
+ SdrView* pSdrView = GetShell().GetDrawView();
+
+ SfxWhichIter aIter( rSet );
+ sal_uInt16 nWhich = aIter.FirstWhich();
+
+ while( nWhich )
+ {
+ switch( nWhich )
+ {
+ case SID_BEZIER_MOVE:
+ case SID_BEZIER_INSERT:
+ {
+ sal_uInt16 nEditMode = GetView().GetEditWin().GetBezierMode();
+
+ rSet.Put(SfxBoolItem(nWhich, nEditMode == nWhich));
+ }
+ break;
+
+ case SID_BEZIER_CUTLINE:
+ if (!pSdrView->IsRipUpAtMarkedPointsPossible())
+ {
+ rSet.DisableItem(SID_BEZIER_CUTLINE);
+ }
+ break;
+
+ case SID_BEZIER_DELETE:
+ if (!pSdrView->IsDeleteMarkedPointsPossible())
+ {
+ rSet.DisableItem(SID_BEZIER_DELETE);
+ }
+ break;
+
+ case SID_BEZIER_CONVERT:
+ if (!pSdrView->IsSetMarkedSegmentsKindPossible())
+ {
+ rSet.DisableItem(SID_BEZIER_CONVERT);
+ }
+ else
+ {
+ SdrPathSegmentKind eSegm = pSdrView->GetMarkedSegmentsKind();
+ switch (eSegm)
+ {
+ case SDRPATHSEGMENT_DONTCARE: rSet.InvalidateItem(SID_BEZIER_CONVERT); break;
+ case SDRPATHSEGMENT_LINE : rSet.Put(SfxBoolItem(SID_BEZIER_CONVERT,false)); break; // Button pressed = curve
+ case SDRPATHSEGMENT_CURVE : rSet.Put(SfxBoolItem(SID_BEZIER_CONVERT,true)); break;
+ default:; //prevent warning
+ }
+ }
+ break;
+
+ case SID_BEZIER_EDGE:
+ case SID_BEZIER_SMOOTH:
+ case SID_BEZIER_SYMMTR:
+ if (!pSdrView->IsSetMarkedPointsSmoothPossible())
+ rSet.DisableItem(nWhich);
+ else
+ {
+ SdrPathSmoothKind eSmooth = pSdrView->GetMarkedPointsSmooth();
+ sal_Bool bEnable = sal_False;
+ switch (eSmooth)
+ {
+ case SDRPATHSMOOTH_DONTCARE :
+ break;
+ case SDRPATHSMOOTH_ANGULAR :
+ bEnable = nWhich == SID_BEZIER_EDGE;
+ break;
+ case SDRPATHSMOOTH_ASYMMETRIC:
+ bEnable = nWhich == SID_BEZIER_SMOOTH;
+ break;
+ case SDRPATHSMOOTH_SYMMETRIC :
+ bEnable = nWhich == SID_BEZIER_SYMMTR;
+ break;
+ }
+ rSet.Put(SfxBoolItem(nWhich, bEnable));
+ }
+ break;
+
+ case SID_BEZIER_CLOSE:
+ if (!pSdrView->IsOpenCloseMarkedObjectsPossible())
+ {
+ rSet.DisableItem(SID_BEZIER_CLOSE);
+ }
+ else
+ {
+ SdrObjClosedKind eClose = pSdrView->GetMarkedObjectsClosedState();
+ switch (eClose)
+ {
+ case SDROBJCLOSED_DONTCARE: rSet.InvalidateItem(SID_BEZIER_CLOSE); break;
+ case SDROBJCLOSED_OPEN : rSet.Put(SfxBoolItem(SID_BEZIER_CLOSE,false)); break;
+ case SDROBJCLOSED_CLOSED : rSet.Put(SfxBoolItem(SID_BEZIER_CLOSE,true)); break;
+ default:; //prevent warning
+ }
+ }
+ break;
+
+ case SID_BEZIER_ELIMINATE_POINTS:
+ rSet.Put(SfxBoolItem(SID_BEZIER_ELIMINATE_POINTS, pSdrView->IsEliminatePolyPoints()));
+ break;
+
+ default:
+ break;
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/shells/drawdlg.cxx b/sw/source/core/uibase/shells/drawdlg.cxx
new file mode 100644
index 000000000000..9ba12d925938
--- /dev/null
+++ b/sw/source/core/uibase/shells/drawdlg.cxx
@@ -0,0 +1,234 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <svx/svxids.hrc>
+#include <vcl/msgbox.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svx/svdview.hxx>
+#include <svx/drawitem.hxx>
+
+#include <svx/xtable.hxx>
+#include "view.hxx"
+#include "wrtsh.hxx"
+#include "docsh.hxx"
+#include "cmdid.h"
+
+#include "drawsh.hxx"
+#include <svx/svxdlg.hxx>
+#include <svx/dialogs.hrc>
+
+void SwDrawShell::ExecDrawDlg(SfxRequest& rReq)
+{
+ SwWrtShell* pSh = &GetShell();
+ SdrView* pView = pSh->GetDrawView();
+ SdrModel* pDoc = pView->GetModel();
+ sal_Bool bChanged = pDoc->IsChanged();
+ pDoc->SetChanged(false);
+
+ SfxItemSet aNewAttr( pDoc->GetItemPool() );
+ pView->GetAttributes( aNewAttr );
+
+ GetView().NoRotate();
+
+ switch (rReq.GetSlot())
+ {
+ case FN_DRAWTEXT_ATTR_DLG:
+ {
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ if ( pFact )
+ {
+ SfxAbstractTabDialog *pDlg = pFact->CreateTextTabDialog( NULL, &aNewAttr, pView );
+ sal_uInt16 nResult = pDlg->Execute();
+
+ if (nResult == RET_OK)
+ {
+ if (pView->AreObjectsMarked())
+ {
+ pSh->StartAction();
+ pView->SetAttributes(*pDlg->GetOutputItemSet());
+ rReq.Done(*(pDlg->GetOutputItemSet()));
+ pSh->EndAction();
+ }
+ }
+
+ delete( pDlg );
+ }
+ }
+ break;
+
+ case SID_ATTRIBUTES_AREA:
+ {
+ sal_Bool bHasMarked = pView->AreObjectsMarked();
+
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ AbstractSvxAreaTabDialog * pDlg = pFact->CreateSvxAreaTabDialog( NULL,
+ &aNewAttr,
+ pDoc,
+ pView);
+ if (pDlg->Execute() == RET_OK)
+ {
+ pSh->StartAction();
+ if (bHasMarked)
+ pView->SetAttributes(*pDlg->GetOutputItemSet());
+ else
+ pView->SetDefaultAttr(*pDlg->GetOutputItemSet(), sal_False);
+ pSh->EndAction();
+
+ static sal_uInt16 aInval[] =
+ {
+ SID_ATTR_FILL_STYLE,
+ SID_ATTR_FILL_COLOR,
+ SID_ATTR_FILL_TRANSPARENCE,
+ SID_ATTR_FILL_FLOATTRANSPARENCE,
+ 0
+ };
+ SfxBindings &rBnd = GetView().GetViewFrame()->GetBindings();
+ rBnd.Invalidate(aInval);
+ rBnd.Update(SID_ATTR_FILL_STYLE);
+ rBnd.Update(SID_ATTR_FILL_COLOR);
+ rBnd.Update(SID_ATTR_FILL_TRANSPARENCE);
+ rBnd.Update(SID_ATTR_FILL_FLOATTRANSPARENCE);
+ }
+ delete pDlg;
+ }
+ break;
+
+ case SID_ATTRIBUTES_LINE:
+ {
+ sal_Bool bHasMarked = pView->AreObjectsMarked();
+
+ const SdrObject* pObj = NULL;
+ const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
+ if( rMarkList.GetMarkCount() == 1 )
+ pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "Dialogdiet Factory fail!");
+ SfxAbstractTabDialog * pDlg = pFact->CreateSvxLineTabDialog( NULL,
+ &aNewAttr,
+ pDoc,
+ pObj,
+ bHasMarked);
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ if (pDlg->Execute() == RET_OK)
+ {
+ pSh->StartAction();
+ if(bHasMarked)
+ pView->SetAttrToMarked(*pDlg->GetOutputItemSet(), sal_False);
+ else
+ pView->SetDefaultAttr(*pDlg->GetOutputItemSet(), sal_False);
+ pSh->EndAction();
+
+ static sal_uInt16 aInval[] =
+ {
+ SID_ATTR_LINE_STYLE, // ( SID_SVX_START + 169 )
+ SID_ATTR_LINE_DASH, // ( SID_SVX_START + 170 )
+ SID_ATTR_LINE_WIDTH, // ( SID_SVX_START + 171 )
+ SID_ATTR_LINE_COLOR, // ( SID_SVX_START + 172 )
+ SID_ATTR_LINE_START, // ( SID_SVX_START + 173 )
+ SID_ATTR_LINE_END, // ( SID_SVX_START + 174 )
+ SID_ATTR_LINE_TRANSPARENCE, // (SID_SVX_START+1107)
+ SID_ATTR_LINE_JOINT, // (SID_SVX_START+1110)
+ SID_ATTR_LINE_CAP, // (SID_SVX_START+1111)
+ 0
+ };
+
+ GetView().GetViewFrame()->GetBindings().Invalidate(aInval);
+ }
+ delete pDlg;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ if (pDoc->IsChanged())
+ GetShell().SetModified();
+ else
+ if (bChanged)
+ pDoc->SetChanged(true);
+}
+
+void SwDrawShell::ExecDrawAttrArgs(SfxRequest& rReq)
+{
+ SwWrtShell* pSh = &GetShell();
+ SdrView* pView = pSh->GetDrawView();
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ sal_Bool bChanged = pView->GetModel()->IsChanged();
+ pView->GetModel()->SetChanged(false);
+
+ GetView().NoRotate();
+
+ if (pArgs)
+ {
+ if(pView->AreObjectsMarked())
+ pView->SetAttrToMarked(*rReq.GetArgs(), sal_False);
+ else
+ pView->SetDefaultAttr(*rReq.GetArgs(), sal_False);
+ }
+ else
+ {
+ SfxDispatcher* pDis = pSh->GetView().GetViewFrame()->GetDispatcher();
+ switch (rReq.GetSlot())
+ {
+ 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:
+ case SID_ATTR_FILL_TRANSPARENCE:
+ case SID_ATTR_FILL_FLOATTRANSPARENCE:
+ pDis->Execute(SID_ATTRIBUTES_AREA, sal_False);
+ break;
+ case SID_ATTR_LINE_STYLE:
+ case SID_ATTR_LINE_DASH:
+ case SID_ATTR_LINE_WIDTH:
+ case SID_ATTR_LINE_COLOR:
+ case SID_ATTR_LINE_TRANSPARENCE:
+ case SID_ATTR_LINE_JOINT:
+ case SID_ATTR_LINE_CAP:
+ pDis->Execute(SID_ATTRIBUTES_LINE, sal_False);
+ break;
+ }
+ }
+ if (pView->GetModel()->IsChanged())
+ GetShell().SetModified();
+ else
+ if (bChanged)
+ pView->GetModel()->SetChanged(true);
+}
+
+void SwDrawShell::GetDrawAttrState(SfxItemSet& rSet)
+{
+ SdrView* pSdrView = GetShell().GetDrawView();
+
+ if (pSdrView->AreObjectsMarked())
+ {
+ sal_Bool bDisable = Disable( rSet );
+
+ if( !bDisable )
+ pSdrView->GetAttributes( rSet );
+ }
+ else
+ rSet.Put(pSdrView->GetDefaultAttr());
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/shells/drawsh.cxx b/sw/source/core/uibase/shells/drawsh.cxx
new file mode 100644
index 000000000000..5932d12c999b
--- /dev/null
+++ b/sw/source/core/uibase/shells/drawsh.cxx
@@ -0,0 +1,597 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <tools/shl.hxx>
+#include <svx/svdview.hxx>
+#include <svx/svdotext.hxx>
+#include <svl/whiter.hxx>
+#include <svx/fontwork.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/objface.hxx>
+#include <svl/itemiter.hxx>
+#include <svl/srchitem.hxx>
+#include <svx/extrusionbar.hxx>
+#include <svx/fontworkbar.hxx>
+#include <svx/tbxcustomshapes.hxx>
+#include <uitool.hxx>
+#include <wview.hxx>
+#include <swmodule.hxx>
+#include <swwait.hxx>
+#include <doc.hxx>
+#include <docsh.hxx>
+#include <docstat.hxx>
+#include <IDocumentStatistics.hxx>
+#include <tools/diagnose_ex.h>
+
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/ui/dialogs/XSLTFilterDialog.hpp>
+
+#include <svx/svdoashp.hxx>
+#include <svx/xtable.hxx>
+#include <sfx2/sidebar/EnumContext.hxx>
+#include <svx/svdoashp.hxx>
+#include <svx/svdoole2.hxx>
+#include <sfx2/opengrf.hxx>
+#include <svx/svdograf.hxx>
+#include <svx/svdundo.hxx>
+#include <svx/xbtmpit.hxx>
+
+#include "swundo.hxx"
+#include "wrtsh.hxx"
+#include "cmdid.h"
+#include "globals.hrc"
+#include "helpid.h"
+#include "popup.hrc"
+#include "shells.hrc"
+#include "drwbassh.hxx"
+#include "drawsh.hxx"
+
+#define SwDrawShell
+#include <sfx2/msg.hxx>
+#include "swslots.hxx"
+#include "swabstdlg.hxx"
+#include <wordcountdialog.hxx>
+#include "misc.hrc"
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+SFX_IMPL_INTERFACE(SwDrawShell, SwDrawBaseShell, SW_RES(STR_SHELLNAME_DRAW))
+{
+ SFX_POPUPMENU_REGISTRATION(SW_RES(MN_DRAW_POPUPMENU));
+ SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_DRAW_TOOLBOX));
+ SFX_CHILDWINDOW_REGISTRATION(SvxFontWorkChildWindow::GetChildWindowId());
+}
+
+TYPEINIT1(SwDrawShell,SwDrawBaseShell)
+
+// #i123922# check as the name implies
+SdrObject* SwDrawShell::IsSingleFillableNonOLESelected()
+{
+ SwWrtShell &rSh = GetShell();
+ SdrView* pSdrView = rSh.GetDrawView();
+
+ if(!pSdrView)
+ {
+ return 0;
+ }
+
+ if(1 != pSdrView->GetMarkedObjectCount())
+ {
+ return 0;
+ }
+
+ SdrObject* pPickObj = pSdrView->GetMarkedObjectByIndex(0);
+
+ if(!pPickObj)
+ {
+ return 0;
+ }
+
+ if(!pPickObj->IsClosedObj())
+ {
+ return 0;
+ }
+
+ if(dynamic_cast< SdrOle2Obj* >(pPickObj))
+ {
+ return 0;
+ }
+
+ return pPickObj;
+}
+
+// #i123922# insert given graphic data dependent of the object type in focus
+void SwDrawShell::InsertPictureFromFile(SdrObject& rObject)
+{
+ SwWrtShell &rSh = GetShell();
+ SdrView* pSdrView = rSh.GetDrawView();
+
+ if(pSdrView)
+ {
+ SvxOpenGraphicDialog aDlg(SW_RESSTR(STR_INSERT_GRAPHIC));
+
+ if(GRFILTER_OK == aDlg.Execute())
+ {
+ Graphic aGraphic;
+ int nError(aDlg.GetGraphic(aGraphic));
+
+ if(GRFILTER_OK == nError)
+ {
+ const bool bAsLink(aDlg.IsAsLink());
+ SdrObject* pResult = &rObject;
+
+ rSh.StartUndo(UNDO_PASTE_CLIPBOARD);
+
+ if(dynamic_cast< SdrGrafObj* >(&rObject))
+ {
+ SdrGrafObj* pNewGrafObj = (SdrGrafObj*)rObject.Clone();
+
+ pNewGrafObj->SetGraphic(aGraphic);
+
+ // #i123922# for handling MasterObject and virtual ones correctly, SW
+ // wants us to call ReplaceObject at the page, but that also
+ // triggers the same assertion (I tried it), so stay at the view method
+ pSdrView->ReplaceObjectAtView(&rObject, *pSdrView->GetSdrPageView(), pNewGrafObj);
+
+ OUString aReferer;
+ SwDocShell *pDocShell = rSh.GetDoc()->GetDocShell();
+ if (pDocShell->HasName()) {
+ aReferer = pDocShell->GetMedium()->GetName();
+ }
+
+ // set in all cases - the Clone() will have copied an existing link (!)
+ pNewGrafObj->SetGraphicLink(
+ bAsLink ? aDlg.GetPath() : OUString(),
+ aReferer,
+ bAsLink ? aDlg.GetCurrentFilter() : OUString());
+
+ pResult = pNewGrafObj;
+ }
+ else // if(rObject.IsClosedObj() && !dynamic_cast< SdrOle2Obj* >(&rObject))
+ {
+ pSdrView->AddUndo(new SdrUndoAttrObj(rObject));
+
+ SfxItemSet aSet(pSdrView->GetModel()->GetItemPool(), XATTR_FILLSTYLE, XATTR_FILLBITMAP);
+
+ aSet.Put(XFillStyleItem(XFILL_BITMAP));
+ aSet.Put(XFillBitmapItem(OUString(), aGraphic));
+ rObject.SetMergedItemSetAndBroadcast(aSet);
+ }
+
+ rSh.EndUndo( UNDO_END );
+
+ if(pResult)
+ {
+ // we are done; mark the modified/new object
+ pSdrView->MarkObj(pResult, pSdrView->GetSdrPageView());
+ }
+ }
+ }
+ }
+}
+
+void SwDrawShell::Execute(SfxRequest &rReq)
+{
+ SwWrtShell &rSh = GetShell();
+ SdrView *pSdrView = rSh.GetDrawView();
+ const SfxItemSet *pArgs = rReq.GetArgs();
+ SfxBindings &rBnd = GetView().GetViewFrame()->GetBindings();
+ sal_uInt16 nSlotId = rReq.GetSlot();
+ sal_Bool bChanged = pSdrView->GetModel()->IsChanged();
+
+ pSdrView->GetModel()->SetChanged(false);
+
+ const SfxPoolItem* pItem;
+ if(pArgs)
+ pArgs->GetItemState(nSlotId, false, &pItem);
+
+ bool bMirror = true;
+
+ switch (nSlotId)
+ {
+ case SID_OBJECT_ROTATE:
+ if (rSh.IsObjSelected() && pSdrView->IsRotateAllowed())
+ {
+ if (GetView().IsDrawRotate())
+ rSh.SetDragMode(SDRDRAG_MOVE);
+ else
+ rSh.SetDragMode(SDRDRAG_ROTATE);
+
+ GetView().FlipDrawRotate();
+ }
+ break;
+
+ case SID_BEZIER_EDIT:
+ if (GetView().IsDrawRotate())
+ {
+ rSh.SetDragMode(SDRDRAG_MOVE);
+ GetView().FlipDrawRotate();
+ }
+ GetView().FlipDrawSelMode();
+ pSdrView->SetFrameDragSingles(GetView().IsDrawSelMode());
+ GetView().AttrChangedNotify(&rSh); // Shell switch
+ break;
+
+ case SID_OBJECT_HELL:
+ if (rSh.IsObjSelected())
+ {
+ rSh.StartUndo( UNDO_START );
+ SetWrapMode(FN_FRAME_WRAPTHRU_TRANSP);
+ rSh.SelectionToHell();
+ rSh.EndUndo( UNDO_END );
+ rBnd.Invalidate(SID_OBJECT_HEAVEN);
+ }
+ break;
+
+ case SID_OBJECT_HEAVEN:
+ if (rSh.IsObjSelected())
+ {
+ rSh.StartUndo( UNDO_START );
+ SetWrapMode(FN_FRAME_WRAPTHRU);
+ rSh.SelectionToHeaven();
+ rSh.EndUndo( UNDO_END );
+ rBnd.Invalidate(SID_OBJECT_HELL);
+ }
+ break;
+
+ case FN_TOOL_HIERARCHIE:
+ if (rSh.IsObjSelected())
+ {
+ rSh.StartUndo( UNDO_START );
+ if (rSh.GetLayerId() == 0)
+ {
+ SetWrapMode(FN_FRAME_WRAPTHRU);
+ rSh.SelectionToHeaven();
+ }
+ else
+ {
+ SetWrapMode(FN_FRAME_WRAPTHRU_TRANSP);
+ rSh.SelectionToHell();
+ }
+ rSh.EndUndo( UNDO_END );
+ rBnd.Invalidate( SID_OBJECT_HELL );
+ rBnd.Invalidate( SID_OBJECT_HEAVEN );
+ }
+ break;
+
+ case SID_FLIP_VERTICAL:
+ bMirror = false;
+ /* no break */
+ case SID_FLIP_HORIZONTAL:
+ rSh.MirrorSelection( bMirror );
+ break;
+
+ case SID_FONTWORK:
+ {
+ FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, &rSh.GetView()));
+ SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)) );
+ SfxViewFrame* pVFrame = GetView().GetViewFrame();
+ if (pArgs)
+ {
+ pVFrame->SetChildWindow(SvxFontWorkChildWindow::GetChildWindowId(),
+ ((const SfxBoolItem&)(pArgs->Get(SID_FONTWORK))).GetValue());
+ }
+ else
+ pVFrame->ToggleChildWindow( SvxFontWorkChildWindow::GetChildWindowId() );
+ pVFrame->GetBindings().Invalidate(SID_FONTWORK);
+ }
+ break;
+ case FN_FORMAT_FOOTNOTE_DLG:
+ {
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+
+ VclAbstractDialog* pDlg = pFact->CreateSwFootNoteOptionDlg(GetView().GetWindow(), GetView().GetWrtShell());
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ pDlg->Execute();
+ delete pDlg;
+ break;
+ }
+ case FN_NUMBERING_OUTLINE_DLG:
+ {
+ SfxItemSet aTmp(GetPool(), FN_PARAM_1, FN_PARAM_1);
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "Dialogdiet fail!");
+ SfxAbstractTabDialog* pDlg = pFact->CreateSwTabDialog( DLG_TAB_OUTLINE,
+ GetView().GetWindow(), &aTmp, GetView().GetWrtShell());
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ pDlg->Execute();
+ delete pDlg;
+ rReq.Done();
+ }
+ break;
+ case SID_OPEN_XML_FILTERSETTINGS:
+ {
+ try
+ {
+ uno::Reference < ui::dialogs::XExecutableDialog > xDialog = ui::dialogs::XSLTFilterDialog::create( ::comphelper::getProcessComponentContext() );
+ xDialog->execute();
+ }
+ catch (const uno::Exception&)
+ {
+ }
+ rReq.Ignore ();
+ }
+ break;
+ case FN_WORDCOUNT_DIALOG:
+ {
+ SfxViewFrame* pVFrame = GetView().GetViewFrame();
+ if (pVFrame != NULL)
+ {
+ pVFrame->ToggleChildWindow(FN_WORDCOUNT_DIALOG);
+ Invalidate(rReq.GetSlot());
+
+ SwWordCountWrapper *pWrdCnt = (SwWordCountWrapper*)pVFrame->GetChildWindow(SwWordCountWrapper::GetChildWindowId());
+ if (pWrdCnt)
+ pWrdCnt->UpdateCounts();
+ }
+ }
+ 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( pSdrView, rReq, rBnd );
+ 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( pSdrView, rReq, rBnd );
+ rReq.Ignore ();
+ break;
+
+ case SID_INSERT_GRAPHIC:
+ {
+ // #i123922# check if we can do something
+ SdrObject* pObj = IsSingleFillableNonOLESelected();
+
+ if(pObj)
+ {
+ // ...and if yes, do something
+ InsertPictureFromFile(*pObj);
+ }
+
+ break;
+ }
+
+ default:
+ OSL_ENSURE(!this, "wrong dispatcher");
+ return;
+ }
+ if (pSdrView->GetModel()->IsChanged())
+ rSh.SetModified();
+ else if (bChanged)
+ pSdrView->GetModel()->SetChanged(true);
+}
+
+void SwDrawShell::GetState(SfxItemSet& rSet)
+{
+ SwWrtShell &rSh = GetShell();
+ SdrView* pSdrView = rSh.GetDrawViewWithValidMarkList();
+ SfxWhichIter aIter( rSet );
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ bool bProtected = rSh.IsSelObjProtected(FLYPROTECT_CONTENT);
+
+ if (!bProtected) // Check the parent
+ bProtected |= rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) != 0;
+
+ while( nWhich )
+ {
+ switch( nWhich )
+ {
+ case SID_OBJECT_HELL:
+ if ( !rSh.IsObjSelected() || rSh.GetLayerId() == 0 || bProtected )
+ rSet.DisableItem( nWhich );
+ break;
+
+ case SID_OBJECT_HEAVEN:
+ if ( !rSh.IsObjSelected() || rSh.GetLayerId() == 1 || bProtected )
+ rSet.DisableItem( nWhich );
+ break;
+
+ case FN_TOOL_HIERARCHIE:
+ if ( !rSh.IsObjSelected() || bProtected )
+ rSet.DisableItem( nWhich );
+ break;
+
+ case SID_OBJECT_ROTATE:
+ {
+ const sal_Bool bIsRotate = GetView().IsDrawRotate();
+ if ( (!bIsRotate && !pSdrView->IsRotateAllowed()) || bProtected )
+ rSet.DisableItem( nWhich );
+ else
+ rSet.Put( SfxBoolItem( nWhich, bIsRotate ) );
+ }
+ break;
+
+ case SID_BEZIER_EDIT:
+ if (!Disable(rSet, nWhich))
+ rSet.Put( SfxBoolItem( nWhich, !GetView().IsDrawSelMode()));
+ break;
+
+ case SID_FLIP_VERTICAL:
+ if ( !pSdrView->IsMirrorAllowed() || bProtected )
+ {
+ rSet.DisableItem( nWhich );
+ }
+ else
+ {
+ // TTTT - needs to be adapted in aw080:
+ // state is not kept for drawing objects --> provide not flipped state
+ rSet.Put( SfxBoolItem( nWhich, false ) );
+ }
+ break;
+
+ case SID_FLIP_HORIZONTAL:
+ if ( !pSdrView->IsMirrorAllowed() || bProtected )
+ {
+ rSet.DisableItem( nWhich );
+ }
+ else
+ {
+ // TTTT - needs to be adapted in aw080:
+ // state is not kept for drawing objects --> provide not flipped state
+ rSet.Put( SfxBoolItem( nWhich, false ) );
+ }
+ break;
+
+ case SID_FONTWORK:
+ {
+ if (bProtected)
+ rSet.DisableItem( nWhich );
+ else
+ {
+ const sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId();
+ rSet.Put(SfxBoolItem( nWhich , GetView().GetViewFrame()->HasChildWindow(nId)));
+ }
+ }
+ break;
+
+ case SID_INSERT_GRAPHIC:
+ {
+ // #i123922# check if we can do something
+ SdrObject* pObj = IsSingleFillableNonOLESelected();
+
+ if(!pObj)
+ {
+ rSet.DisableItem(nWhich);
+ }
+
+ break;
+ }
+ }
+ nWhich = aIter.NextWhich();
+ }
+ svx::ExtrusionBar::getState( pSdrView, rSet );
+ svx::FontworkBar::getState( pSdrView, rSet );
+}
+
+SwDrawShell::SwDrawShell(SwView &_rView) :
+ SwDrawBaseShell(_rView)
+{
+ SetHelpId(SW_DRAWSHELL);
+ SetName(OUString("Draw"));
+
+ SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_Draw));
+}
+
+// Edit SfxRequests for FontWork
+
+void SwDrawShell::ExecFormText(SfxRequest& rReq)
+{
+ SwWrtShell &rSh = GetShell();
+ SdrView* pDrView = rSh.GetDrawView();
+ sal_Bool bChanged = pDrView->GetModel()->IsChanged();
+ pDrView->GetModel()->SetChanged(false);
+
+ const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
+
+ if ( rMarkList.GetMarkCount() == 1 && rReq.GetArgs() )
+ {
+ const SfxItemSet& rSet = *rReq.GetArgs();
+
+ if ( pDrView->IsTextEdit() )
+ {
+ pDrView->SdrEndTextEdit( sal_True );
+ GetView().AttrChangedNotify(&rSh);
+ }
+
+ pDrView->SetAttributes(rSet);
+ }
+ if (pDrView->GetModel()->IsChanged())
+ rSh.SetModified();
+ else
+ if (bChanged)
+ pDrView->GetModel()->SetChanged(true);
+}
+
+//Return status values for FontWork
+
+void SwDrawShell::GetFormTextState(SfxItemSet& rSet)
+{
+ SwWrtShell &rSh = GetShell();
+ SdrView* pDrView = rSh.GetDrawView();
+ const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
+ const SdrObject* pObj = NULL;
+ SvxFontWorkDialog* pDlg = NULL;
+
+ const sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId();
+
+ SfxViewFrame* pVFrame = GetView().GetViewFrame();
+ if ( pVFrame->HasChildWindow(nId) )
+ pDlg = (SvxFontWorkDialog*)(pVFrame->GetChildWindow(nId)->GetWindow());
+
+ if ( rMarkList.GetMarkCount() == 1 )
+ pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+
+ const SdrTextObj* pTextObj = dynamic_cast< const SdrTextObj* >(pObj);
+ const bool bDeactivate(
+ !pObj ||
+ !pTextObj ||
+ !pTextObj->HasText() ||
+ dynamic_cast< const SdrObjCustomShape* >(pObj)); // #121538# no FontWork for CustomShapes
+
+ if(bDeactivate)
+ {
+ rSet.DisableItem(XATTR_FORMTXTSTYLE);
+ rSet.DisableItem(XATTR_FORMTXTADJUST);
+ rSet.DisableItem(XATTR_FORMTXTDISTANCE);
+ rSet.DisableItem(XATTR_FORMTXTSTART);
+ rSet.DisableItem(XATTR_FORMTXTMIRROR);
+ 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 )
+ pDlg->SetColorList(XColorList::GetStdColorList());
+
+ pDrView->GetAttributes( rSet );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/shells/drformsh.cxx b/sw/source/core/uibase/shells/drformsh.cxx
new file mode 100644
index 000000000000..117db5a8c69e
--- /dev/null
+++ b/sw/source/core/uibase/shells/drformsh.cxx
@@ -0,0 +1,258 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <hintids.hxx>
+#include <svx/hlnkitem.hxx>
+#include <svx/svdview.hxx>
+#include <svl/whiter.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/objface.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/sidebar/EnumContext.hxx>
+#include <svl/srchitem.hxx>
+#include <svx/fmglob.hxx>
+#include <svx/svdouno.hxx>
+#include <com/sun/star/form/FormButtonType.hpp>
+#include <sfx2/htmlmode.hxx>
+#include <tools/urlobj.hxx>
+
+#include "viewopt.hxx"
+#include "swmodule.hxx"
+#include "wrtsh.hxx"
+#include "cmdid.h"
+#include "globals.hrc"
+#include "helpid.h"
+#include "popup.hrc"
+#include "shells.hrc"
+#include "drwbassh.hxx"
+#include "drformsh.hxx"
+#include <svl/urihelper.hxx>
+#include <view.hxx>
+#include <sfx2/docfile.hxx>
+#include <docsh.hxx>
+
+#define SwDrawFormShell
+#include <sfx2/msg.hxx>
+#include "swslots.hxx"
+
+#include <unomid.h>
+
+using namespace ::com::sun::star;
+
+SFX_IMPL_INTERFACE(SwDrawFormShell, SwDrawBaseShell, SW_RES(STR_SHELLNAME_DRAWFORM))
+{
+ SFX_POPUPMENU_REGISTRATION(SW_RES(MN_DRAWFORM_POPUPMENU));
+ SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_TEXT_TOOLBOX));
+}
+
+TYPEINIT1(SwDrawFormShell, SwDrawBaseShell)
+
+void SwDrawFormShell::Execute(SfxRequest &rReq)
+{
+ SwWrtShell &rSh = GetShell();
+ const SfxPoolItem* pItem = 0;
+ const SfxItemSet *pArgs = rReq.GetArgs();
+
+ switch ( rReq.GetSlot() )
+ {
+ case SID_HYPERLINK_SETLINK:
+ {
+ if(pArgs)
+ pArgs->GetItemState(SID_HYPERLINK_SETLINK, false, &pItem);
+ if(pItem)
+ {
+ SdrView *pSdrView = rSh.GetDrawView();
+ const SvxHyperlinkItem& rHLinkItem = *(const SvxHyperlinkItem *)pItem;
+ bool bConvertToText = rHLinkItem.GetInsertMode() == HLINK_DEFAULT ||
+ rHLinkItem.GetInsertMode() == HLINK_FIELD;
+ const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
+ if (rMarkList.GetMark(0))
+ {
+ SdrUnoObj* pUnoCtrl = PTR_CAST(SdrUnoObj, rMarkList.GetMark(0)->GetMarkedSdrObj());
+ if (pUnoCtrl && FmFormInventor == pUnoCtrl->GetObjInventor())
+ {
+ if(bConvertToText)
+ {
+ //remove object -> results in destruction of this!
+ SwView& rTempView = GetView();
+ rTempView.GetViewFrame()->GetDispatcher()->Execute(SID_DELETE, SFX_CALLMODE_SYNCHRON );
+ rTempView.StopShellTimer();
+ //issue a new command to insert the link
+ rTempView.GetViewFrame()->GetDispatcher()->Execute(
+ SID_HYPERLINK_SETLINK, SFX_CALLMODE_ASYNCHRON, &rHLinkItem, 0);
+ }
+ else
+ {
+ uno::Reference< awt::XControlModel > xControlModel = pUnoCtrl->GetUnoControlModel();
+
+ OSL_ENSURE( xControlModel.is(), "UNO-Control without Model" );
+ if( !xControlModel.is() )
+ return;
+
+ uno::Reference< beans::XPropertySet > xPropSet(xControlModel, uno::UNO_QUERY);
+
+ // Can we set an URL to the object?
+ OUString sTargetURL( "TargetURL" );
+ uno::Reference< beans::XPropertySetInfo > xPropInfoSet = xPropSet->getPropertySetInfo();
+ if( xPropInfoSet->hasPropertyByName( sTargetURL ))
+ {
+ beans::Property aProp = xPropInfoSet->getPropertyByName( sTargetURL );
+ if( !aProp.Name.isEmpty() )
+ {
+ uno::Any aTmp;
+ // Yes!
+ OUString sLabel("Label");
+ if( xPropInfoSet->hasPropertyByName(sLabel) )
+ {
+ aTmp <<= OUString(rHLinkItem.GetName());
+ xPropSet->setPropertyValue(sLabel, aTmp );
+ }
+
+ SfxMedium* pMedium = GetView().GetDocShell()->GetMedium();
+ INetURLObject aAbs;
+ if( pMedium )
+ aAbs = pMedium->GetURLObject();
+ aTmp <<= OUString(URIHelper::SmartRel2Abs(aAbs, rHLinkItem.GetURL()));
+ xPropSet->setPropertyValue( sTargetURL, aTmp );
+
+ if( !rHLinkItem.GetTargetFrame().isEmpty() )
+ {
+ aTmp <<= rHLinkItem.GetTargetFrame();
+ xPropSet->setPropertyValue( "TargetFrame", aTmp );
+ }
+
+ form::FormButtonType eButtonType = form::FormButtonType_URL;
+ aTmp.setValue( &eButtonType, ::getCppuType((const form::FormButtonType*)0));
+ xPropSet->setPropertyValue( "ButtonType", aTmp );
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ break;
+
+ default:
+ OSL_ENSURE(!this, "wrong dispatcher");
+ return;
+ }
+}
+
+void SwDrawFormShell::GetState(SfxItemSet& rSet)
+{
+ SwWrtShell &rSh = GetShell();
+ SfxWhichIter aIter( rSet );
+ sal_uInt16 nWhich = aIter.FirstWhich();
+
+ while( nWhich )
+ {
+ switch( nWhich )
+ {
+ case SID_HYPERLINK_GETLINK:
+ {
+ SdrView* pSdrView = rSh.GetDrawViewWithValidMarkList();
+ const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
+ SvxHyperlinkItem aHLinkItem;
+ if (rMarkList.GetMark(0))
+ {
+ SdrUnoObj* pUnoCtrl = PTR_CAST(SdrUnoObj, rMarkList.GetMark(0)->GetMarkedSdrObj());
+ if (pUnoCtrl && FmFormInventor == pUnoCtrl->GetObjInventor())
+ {
+ uno::Reference< awt::XControlModel > xControlModel = pUnoCtrl->GetUnoControlModel();
+
+ OSL_ENSURE( xControlModel.is(), "UNO-Control without Model" );
+ if( !xControlModel.is() )
+ return;
+
+ uno::Reference< beans::XPropertySet > xPropSet(xControlModel, uno::UNO_QUERY);
+
+ uno::Any aTmp;
+ uno::Reference< beans::XPropertySetInfo > xInfo = xPropSet->getPropertySetInfo();
+ if(xInfo->hasPropertyByName( "ButtonType" ))
+ {
+ form::FormButtonType eButtonType = form::FormButtonType_URL;
+ aTmp = xPropSet->getPropertyValue( "ButtonType" );
+ if( aTmp >>= eButtonType )
+ {
+ // Label
+ if(xInfo->hasPropertyByName( "Label" ))
+ {
+ aTmp = xPropSet->getPropertyValue( "Label" );
+ OUString sTmp;
+ if( (aTmp >>= sTmp) && !sTmp.isEmpty())
+ {
+ aHLinkItem.SetName(sTmp);
+ }
+ }
+
+ // URL
+ if(xInfo->hasPropertyByName( "TargetURL" ))
+ {
+ aTmp = xPropSet->getPropertyValue( "TargetURL" );
+ OUString sTmp;
+ if( (aTmp >>= sTmp) && !sTmp.isEmpty())
+ {
+ aHLinkItem.SetURL(sTmp);
+ }
+ }
+
+ // Target
+ if(xInfo->hasPropertyByName( "TargetFrame" ))
+ {
+ aTmp = xPropSet->getPropertyValue( "TargetFrame" );
+ OUString sTmp;
+ if( (aTmp >>= sTmp) && !sTmp.isEmpty())
+ {
+ aHLinkItem.SetTargetFrame(sTmp);
+ }
+ }
+ aHLinkItem.SetInsertMode(HLINK_BUTTON);
+ }
+ }
+ }
+ }
+ sal_uInt16 nHtmlMode = ::GetHtmlMode(GetView().GetDocShell());
+ aHLinkItem.SetInsertMode((SvxLinkInsertMode)(aHLinkItem.GetInsertMode() |
+ ((nHtmlMode & HTMLMODE_ON) != 0 ? HLINK_HTMLMODE : 0)));
+
+ rSet.Put(aHLinkItem);
+ }
+ break;
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+SwDrawFormShell::SwDrawFormShell(SwView &_rView) :
+ SwDrawBaseShell(_rView)
+{
+ SetHelpId(SW_DRAWFORMSHELL);
+ GetShell().NoEdit(true);
+ SetName(OUString("DrawForm"));
+ SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_Form));
+}
+
+SwDrawFormShell::~SwDrawFormShell()
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/shells/drwbassh.cxx b/sw/source/core/uibase/shells/drwbassh.cxx
new file mode 100644
index 000000000000..c19d90caa019
--- /dev/null
+++ b/sw/source/core/uibase/shells/drwbassh.cxx
@@ -0,0 +1,961 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <tools/shl.hxx>
+#include <hintids.hxx>
+#include <helpid.h>
+#include <swtypes.hxx>
+#include <sfx2/objface.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/bindings.hxx>
+#include <svl/aeitem.hxx>
+#include <svx/svdview.hxx>
+#include <vcl/msgbox.hxx>
+#include <svl/srchitem.hxx>
+#include <svl/whiter.hxx>
+#include <svx/swframevalidation.hxx>
+#include <svx/anchorid.hxx>
+#include <sfx2/htmlmode.hxx>
+#include <uitool.hxx>
+#include <fmtornt.hxx>
+#include <cmdid.h>
+#include <swmodule.hxx>
+#include <wrtsh.hxx>
+#include <wview.hxx>
+#include <edtwin.hxx>
+#include <viewopt.hxx>
+#include <dcontact.hxx>
+#include <frmfmt.hxx>
+#include <wrap.hxx>
+#include <drawbase.hxx>
+#include <drwbassh.hxx>
+#include <swdtflvr.hxx>
+#include <svx/svdogrp.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svditer.hxx>
+
+#include <shells.hrc>
+#define SwDrawBaseShell
+#include <sfx2/msg.hxx>
+#include <swslots.hxx>
+#include <svx/svxdlg.hxx>
+#include <svx/dialogs.hrc>
+#include "swabstdlg.hxx"
+#include "dialog.hrc"
+#include <swundo.hxx>
+#include <com/sun/star/text/HoriOrientation.hpp>
+#include <com/sun/star/text/VertOrientation.hpp>
+#include <com/sun/star/text/RelOrientation.hpp>
+
+#include <IDocumentDrawModelAccess.hxx>
+
+using namespace ::com::sun::star;
+
+SFX_IMPL_INTERFACE(SwDrawBaseShell, SwBaseShell, SW_RES(0))
+{
+}
+
+TYPEINIT1(SwDrawBaseShell,SwBaseShell)
+
+SwDrawBaseShell::SwDrawBaseShell(SwView &_rView):
+ SwBaseShell( _rView )
+{
+ GetShell().NoEdit(true);
+
+ SwEditWin& rWin = GetView().GetEditWin();
+
+ rWin.SetBezierMode(SID_BEZIER_MOVE);
+
+ if ( !_rView.GetDrawFuncPtr() )
+ _rView.GetEditWin().StdDrawMode( OBJ_NONE, sal_True );
+
+ SwTransferable::CreateSelection( GetShell() );
+}
+
+SwDrawBaseShell::~SwDrawBaseShell()
+{
+ GetView().ExitDraw();
+ GetShell().Edit();
+ SwTransferable::ClearSelection( GetShell() );
+}
+
+void SwDrawBaseShell::Execute(SfxRequest &rReq)
+{
+ SwWrtShell *pSh = &GetShell();
+ SdrView* pSdrView = pSh->GetDrawView();
+ const SfxItemSet *pArgs = rReq.GetArgs();
+ sal_uInt16 nSlotId = rReq.GetSlot();
+ sal_Bool bChanged = pSdrView->GetModel()->IsChanged();
+ pSdrView->GetModel()->SetChanged(false);
+ const SfxPoolItem* pItem = 0;
+ if(pArgs)
+ pArgs->GetItemState(nSlotId, false, &pItem);
+
+ //Special case align by menu
+ if(pItem && nSlotId == SID_OBJECT_ALIGN)
+ {
+ OSL_ENSURE(PTR_CAST(SfxEnumItem, pItem),"SfxEnumItem expected");
+ nSlotId = nSlotId + ((const SfxEnumItem*)pItem)->GetValue();
+ nSlotId++;
+ }
+
+ sal_Bool bAlignPossible = pSh->IsAlignPossible();
+
+ sal_Bool bTopParam = sal_True, bBottomParam = sal_True;
+ bool bNotify = false;
+ bool bDone = false;
+ SfxBindings& rBind = GetView().GetViewFrame()->GetBindings();
+
+ switch (nSlotId)
+ {
+ case FN_DRAW_WRAP_DLG:
+ {
+ if(pSdrView->AreObjectsMarked())
+ {
+ if(!pArgs)
+ {
+ const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
+ if( rMarkList.GetMark(0) != 0 )
+ {
+ SfxItemSet aSet(GetPool(), RES_SURROUND, RES_SURROUND,
+ RES_ANCHOR, RES_ANCHOR,
+ RES_LR_SPACE, RES_UL_SPACE,
+ SID_HTML_MODE, SID_HTML_MODE,
+ FN_DRAW_WRAP_DLG, FN_DRAW_WRAP_DLG,
+ 0);
+
+ aSet.Put(SfxBoolItem(SID_HTML_MODE,
+ 0 != ::GetHtmlMode(pSh->GetView().GetDocShell())));
+
+ aSet.Put(SfxInt16Item(FN_DRAW_WRAP_DLG, pSh->GetLayerId()));
+
+ pSh->GetObjAttr(aSet);
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+
+ SfxAbstractDialog* pDlg = pFact->CreateSwWrapDlg( GetView().GetWindow(), aSet, pSh, sal_True, RC_DLG_SWWRAPDLG );
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+
+ if (pDlg->Execute() == RET_OK)
+ {
+ const SfxPoolItem* pWrapItem;
+ const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
+ if(SFX_ITEM_SET == pOutSet->GetItemState(FN_DRAW_WRAP_DLG, false, &pWrapItem))
+ {
+ short nLayer = ((const SfxInt16Item*)pWrapItem)->GetValue();
+ if (nLayer == 1)
+ pSh->SelectionToHeaven();
+ else
+ pSh->SelectionToHell();
+ }
+
+ pSh->SetObjAttr(*pOutSet);
+ }
+ delete pDlg;
+ }
+ }
+ }
+ }
+ break;
+
+ case SID_ATTR_TRANSFORM:
+ {
+ if(pSdrView->AreObjectsMarked())
+ {
+ if(!pArgs)
+ {
+ const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
+ if( rMarkList.GetMark(0) != 0 )
+ {
+ SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+ SfxAbstractTabDialog *pDlg=NULL;
+ bool bCaption = false;
+
+ // Allowed anchorages:
+ short nAnchor = pSh->GetAnchorId();
+ sal_uInt16 nAllowedAnchors = SVX_OBJ_AT_CNTNT | SVX_OBJ_IN_CNTNT | SVX_OBJ_PAGE;
+ sal_uInt16 nHtmlMode = ::GetHtmlMode(pSh->GetView().GetDocShell());
+
+ if ( pSh->IsFlyInFly() )
+ nAllowedAnchors |= SVX_OBJ_AT_FLY;
+
+ if (pObj->GetObjIdentifier() == OBJ_CAPTION )
+ bCaption = true;
+
+ if (bCaption)
+ {
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ if ( pFact )
+ {
+ AbstractSvxCaptionDialog* pCaptionDlg =
+ pFact->CreateCaptionDialog( NULL, pSdrView, nAllowedAnchors );
+ pCaptionDlg->SetValidateFramePosLink( LINK(this, SwDrawBaseShell, ValidatePosition) );
+ pDlg = pCaptionDlg;
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ }
+ }
+ else
+ {
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ if ( pFact )
+ {
+
+ AbstractSvxTransformTabDialog* pTransform =
+ pFact->CreateSvxTransformTabDialog( NULL, NULL, pSdrView, nAllowedAnchors );
+ pTransform->SetValidateFramePosLink( LINK(this, SwDrawBaseShell, ValidatePosition) );
+ pDlg = pTransform;
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ }
+ }
+ SfxItemSet aNewAttr(pSdrView->GetGeoAttrFromMarked());
+
+ const sal_uInt16* pRange = pDlg->GetInputRanges( *aNewAttr.GetPool() );
+ SfxItemSet aSet( *aNewAttr.GetPool(), pRange );
+ FieldUnit eMetric = ::GetDfltMetric(0 != dynamic_cast<SwWebView*>(&GetView()));
+ SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)) );
+
+ aSet.Put( aNewAttr, false );
+
+ if (bCaption)
+ pSdrView->GetAttributes( aSet );
+
+ aSet.Put(SfxInt16Item(SID_ATTR_TRANSFORM_ANCHOR, nAnchor));
+ sal_Bool bRTL;
+ sal_Bool bVertL2R;
+ aSet.Put(SfxBoolItem(SID_ATTR_TRANSFORM_IN_VERTICAL_TEXT, pSh->IsFrmVertical(sal_True, bRTL, bVertL2R)));
+ aSet.Put(SfxBoolItem(SID_ATTR_TRANSFORM_IN_RTL_TEXT, bRTL));
+
+ SwFrmFmt* pFrmFmt = FindFrmFmt( pObj );
+
+ aSet.Put( pFrmFmt->GetFmtAttr(RES_FOLLOW_TEXT_FLOW) );
+
+ SwFmtVertOrient aVOrient((const SwFmtVertOrient&)pFrmFmt->GetFmtAttr(RES_VERT_ORIENT));
+ aSet.Put(SfxInt16Item(SID_ATTR_TRANSFORM_VERT_ORIENT, aVOrient.GetVertOrient()));
+ aSet.Put(SfxInt16Item(SID_ATTR_TRANSFORM_VERT_RELATION, aVOrient.GetRelationOrient() ));
+ aSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_VERT_POSITION, aVOrient.GetPos()));
+
+ SwFmtHoriOrient aHOrient((const SwFmtHoriOrient&)pFrmFmt->GetFmtAttr(RES_HORI_ORIENT));
+ aSet.Put(SfxInt16Item(SID_ATTR_TRANSFORM_HORI_ORIENT, aHOrient.GetHoriOrient()));
+ aSet.Put(SfxInt16Item(SID_ATTR_TRANSFORM_HORI_RELATION, aHOrient.GetRelationOrient() ));
+ aSet.Put(SfxBoolItem(SID_ATTR_TRANSFORM_HORI_MIRROR, aHOrient.IsPosToggle()));
+ aSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_HORI_POSITION, aHOrient.GetPos()));
+
+ aSet.Put(SfxUInt16Item(SID_HTML_MODE, nHtmlMode));
+
+ pDlg->SetInputSet( &aSet );
+
+ if (pDlg->Execute() == RET_OK)
+ {
+ const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
+ pSh->StartAllAction();
+
+ // #i30451#
+ pSh->StartUndo(UNDO_INSFMTATTR);
+
+ pSdrView->SetGeoAttrToMarked(*pOutSet);
+
+ if (bCaption)
+ pSdrView->SetAttributes(*pOutSet);
+
+ bool bPosCorr =
+ SFX_ITEM_SET != pOutSet->GetItemState(
+ SID_ATTR_TRANSFORM_POS_X, false ) &&
+ SFX_ITEM_SET != pOutSet->GetItemState(
+ SID_ATTR_TRANSFORM_POS_Y, false );
+
+ SfxItemSet aFrmAttrSet(GetPool(), RES_FRMATR_BEGIN, RES_FRMATR_END - 1);
+
+ bool bSingleSelection = rMarkList.GetMarkCount() == 1;
+
+ const SfxPoolItem* pAnchorItem;
+ if(SFX_ITEM_SET == pOutSet->GetItemState(
+ SID_ATTR_TRANSFORM_ANCHOR, false, &pAnchorItem))
+ {
+ if(!bSingleSelection)
+ pSh->ChgAnchor(((const SfxInt16Item*)pAnchorItem)
+ ->GetValue(), false, bPosCorr );
+ else
+ {
+ SwFmtAnchor aAnchor(pFrmFmt->GetAnchor());
+ aAnchor.SetType((RndStdIds)((const SfxInt16Item*)pAnchorItem)->GetValue());
+ aFrmAttrSet.Put( aAnchor );
+ }
+ }
+ const SfxPoolItem* pHoriOrient = 0;
+ const SfxPoolItem* pHoriRelation = 0;
+ const SfxPoolItem* pHoriPosition = 0;
+ const SfxPoolItem* pHoriMirror = 0;
+ pOutSet->GetItemState(SID_ATTR_TRANSFORM_HORI_ORIENT, false, &pHoriOrient);
+ pOutSet->GetItemState(SID_ATTR_TRANSFORM_HORI_RELATION, false, &pHoriRelation);
+ pOutSet->GetItemState(SID_ATTR_TRANSFORM_HORI_POSITION, false, &pHoriPosition);
+ pOutSet->GetItemState(SID_ATTR_TRANSFORM_HORI_MIRROR, false, &pHoriMirror);
+ if(pHoriOrient || pHoriRelation || pHoriPosition || pHoriMirror)
+ {
+ if(pHoriOrient)
+ aHOrient.SetHoriOrient(
+ static_cast<const SfxInt16Item*>(pHoriOrient)->GetValue());
+ if(pHoriRelation)
+ aHOrient.SetRelationOrient(
+ static_cast<const SfxInt16Item*>(pHoriRelation)->GetValue());
+ if(pHoriPosition)
+ aHOrient.SetPos( static_cast<const SfxInt32Item*>(pHoriPosition)->GetValue());
+ if(pHoriMirror)
+ aHOrient.SetPosToggle( static_cast<const SfxBoolItem*>(pHoriMirror)->GetValue());
+ aFrmAttrSet.Put(aHOrient);
+ }
+
+ const SfxPoolItem* pVertOrient = 0;
+ const SfxPoolItem* pVertRelation = 0;
+ const SfxPoolItem* pVertPosition = 0;
+ pOutSet->GetItemState(SID_ATTR_TRANSFORM_VERT_ORIENT, false, &pVertOrient);
+ pOutSet->GetItemState(SID_ATTR_TRANSFORM_VERT_RELATION, false, &pVertRelation);
+ pOutSet->GetItemState(SID_ATTR_TRANSFORM_VERT_POSITION, false, &pVertPosition);
+ if(pVertOrient || pVertRelation || pVertPosition )
+ {
+ if(pVertOrient)
+ aVOrient.SetVertOrient(
+ static_cast<const SfxInt16Item*>(pVertOrient)->GetValue());
+ if(pVertRelation)
+ aVOrient.SetRelationOrient(
+ static_cast<const SfxInt16Item*>(pVertRelation)->GetValue());
+ if(pVertPosition)
+ aVOrient.SetPos( static_cast<const SfxInt32Item*>(pVertPosition)->GetValue());
+ aFrmAttrSet.Put( aVOrient );
+ }
+ const SfxPoolItem* pFollowItem = 0;
+ pOutSet->GetItemState(RES_FOLLOW_TEXT_FLOW, false, &pFollowItem);
+ if(pFollowItem)
+ aFrmAttrSet.Put(*pFollowItem);
+
+ if(aFrmAttrSet.Count())
+ pSh->SetDrawingAttr(aFrmAttrSet);
+
+ rBind.InvalidateAll(sal_False);
+
+ // #i30451#
+ pSh->EndUndo( UNDO_INSFMTATTR );
+
+ pSh->EndAllAction();
+ }
+ delete pDlg;
+
+ }
+ }
+ else
+ {
+ pSdrView->SetGeoAttrToMarked( *pArgs );
+ }
+ }
+ }
+ break;
+
+ case SID_DELETE:
+ case FN_BACKSPACE:
+ if (pSh->IsObjSelected() && !pSdrView->IsTextEdit())
+ {
+ bDone = true;
+
+ if( GetView().IsDrawRotate() )
+ {
+ pSh->SetDragMode( SDRDRAG_MOVE );
+ GetView().FlipDrawRotate();
+ }
+
+ pSh->SetModified();
+ pSh->DelSelectedObj();
+
+ if (rReq.IsAPI() ||
+ GetView().GetEditWin().IsObjectSelect() )
+ {
+ // If basic call, then back to the text shell, because the
+ // Basic otherwise has no possibility to return.
+ if (GetView().GetDrawFuncPtr())
+ {
+ GetView().GetDrawFuncPtr()->Deactivate();
+ GetView().SetDrawFuncPtr(NULL);
+ }
+ GetView().LeaveDrawCreate(); // Switch to selection mode
+ }
+
+ if (pSh->IsSelFrmMode())
+ {
+ pSh->LeaveSelFrmMode();
+ // #105852# FME
+ }
+ bNotify = true;
+ }
+ break;
+
+ case SID_GROUP:
+ if (pSh->IsObjSelected() > 1 && pSh->IsGroupAllowed())
+ {
+ pSh->GroupSelection();
+ rBind.Invalidate(SID_UNGROUP);
+ }
+ break;
+
+ case SID_UNGROUP:
+ if (pSh->IsGroupSelected())
+ {
+ pSh->UnGroupSelection();
+ rBind.Invalidate(SID_GROUP);
+ }
+ break;
+
+ case SID_ENTER_GROUP:
+ if (pSh->IsGroupSelected())
+ {
+ pSdrView->EnterMarkedGroup();
+ rBind.InvalidateAll(sal_False);
+ }
+ break;
+
+ case SID_LEAVE_GROUP:
+ if (pSdrView->IsGroupEntered())
+ {
+ pSdrView->LeaveOneGroup();
+ rBind.Invalidate(SID_ENTER_GROUP);
+ rBind.Invalidate(SID_UNGROUP);
+ }
+ break;
+
+ case SID_OBJECT_ALIGN_LEFT:
+ case SID_OBJECT_ALIGN_CENTER:
+ case SID_OBJECT_ALIGN_RIGHT:
+ case SID_OBJECT_ALIGN_UP:
+ case SID_OBJECT_ALIGN_MIDDLE:
+ case SID_OBJECT_ALIGN_DOWN:
+ {
+ if ( bAlignPossible )
+ {
+ const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
+ if( rMarkList.GetMarkCount() == 1 && bAlignPossible )
+ { // Do not align objects to each other
+ sal_uInt16 nAnchor = pSh->GetAnchorId();
+ if (nAnchor == FLY_AS_CHAR)
+ {
+ sal_Int16 nVertOrient = -1;
+
+ switch (nSlotId)
+ {
+ case SID_OBJECT_ALIGN_UP:
+ nVertOrient = text::VertOrientation::TOP;
+ break;
+ case SID_OBJECT_ALIGN_MIDDLE:
+ nVertOrient = text::VertOrientation::CENTER;
+ break;
+ case SID_OBJECT_ALIGN_DOWN:
+ nVertOrient = text::VertOrientation::BOTTOM;
+ break;
+ default:
+ break;
+ }
+ if (nVertOrient != -1)
+ {
+ pSh->StartAction();
+ SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+ SwFrmFmt* pFrmFmt = FindFrmFmt( pObj );
+ SwFmtVertOrient aVOrient((SwFmtVertOrient&)pFrmFmt->GetFmtAttr(RES_VERT_ORIENT));
+ aVOrient.SetVertOrient( nVertOrient );
+ pFrmFmt->SetFmtAttr(aVOrient);
+ pSh->EndAction();
+ }
+ break;
+ }
+ if (nAnchor == FLY_AT_PARA)
+ break; // Do not align frames of an anchored paragraph
+ }
+
+ pSh->StartAction();
+ switch (nSlotId)
+ {
+ case SID_OBJECT_ALIGN_LEFT:
+ pSdrView->AlignMarkedObjects(SDRHALIGN_LEFT, SDRVALIGN_NONE);
+ break;
+ case SID_OBJECT_ALIGN_CENTER:
+ pSdrView->AlignMarkedObjects(SDRHALIGN_CENTER, SDRVALIGN_NONE);
+ break;
+ case SID_OBJECT_ALIGN_RIGHT:
+ pSdrView->AlignMarkedObjects(SDRHALIGN_RIGHT, SDRVALIGN_NONE);
+ break;
+ case SID_OBJECT_ALIGN_UP:
+ pSdrView->AlignMarkedObjects(SDRHALIGN_NONE, SDRVALIGN_TOP);
+ break;
+ case SID_OBJECT_ALIGN_MIDDLE:
+ pSdrView->AlignMarkedObjects(SDRHALIGN_NONE, SDRVALIGN_CENTER);
+ break;
+ case SID_OBJECT_ALIGN_DOWN:
+ pSdrView->AlignMarkedObjects(SDRHALIGN_NONE, SDRVALIGN_BOTTOM);
+ break;
+ }
+ pSh->EndAction();
+ }
+ }
+ break;
+
+ case FN_FRAME_UP:
+ bTopParam = sal_False;
+ /* no break */
+ case SID_FRAME_TO_TOP:
+ pSh->SelectionToTop( bTopParam );
+ break;
+
+ case FN_FRAME_DOWN:
+ bBottomParam = sal_False;
+ /* no break */
+ case SID_FRAME_TO_BOTTOM:
+ pSh->SelectionToBottom( bBottomParam );
+ break;
+
+ case FN_NAME_SHAPE:
+ {
+ bDone = true;
+
+ if(1L == pSdrView->GetMarkedObjectCount())
+ {
+ // #i68101#
+ SdrObject* pSelected = pSdrView->GetMarkedObjectByIndex(0L);
+ OSL_ENSURE(pSelected, "DrawViewShell::FuTemp03: nMarkCount, but no object (!)");
+ OUString 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, SwDrawBaseShell, CheckGroupShapeNameHdl));
+
+ if(RET_OK == pDlg->Execute())
+ {
+ pDlg->GetName(aName);
+ pSelected->SetName(aName);
+ pSh->SetModified();
+ }
+
+ delete pDlg;
+ }
+
+ break;
+ }
+
+ // #i68101#
+ case FN_TITLE_DESCRIPTION_SHAPE:
+ {
+ bDone = true;
+
+ if(1L == pSdrView->GetMarkedObjectCount())
+ {
+ SdrObject* pSelected = pSdrView->GetMarkedObjectByIndex(0L);
+ OSL_ENSURE(pSelected, "DrawViewShell::FuTemp03: nMarkCount, but no object (!)");
+ OUString aTitle(pSelected->GetTitle());
+ OUString 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())
+ {
+ pDlg->GetTitle(aTitle);
+ pDlg->GetDescription(aDescription);
+
+ pSelected->SetTitle(aTitle);
+ pSelected->SetDescription(aDescription);
+
+ pSh->SetModified();
+ }
+
+ delete pDlg;
+ }
+
+ break;
+ }
+
+ default:
+ OSL_ENSURE(!this, "wrong Dispatcher");
+ return;
+ }
+ if(!bDone)
+ {
+ if(nSlotId >= SID_OBJECT_ALIGN_LEFT && nSlotId <= SID_OBJECT_ALIGN_DOWN)
+ rBind.Invalidate(SID_ATTR_LONG_LRSPACE);
+ if (pSdrView->GetModel()->IsChanged())
+ pSh->SetModified();
+ else if (bChanged)
+ pSdrView->GetModel()->SetChanged(true);
+ // 40220: After Delete from DrawObjecs over the API GPF through self-destruction
+ if(bNotify)
+ GetView().AttrChangedNotify(pSh); // Shell switch if applicable...
+ }
+}
+
+// Checks whether a given name is allowed for a group shape
+
+IMPL_LINK( SwDrawBaseShell, CheckGroupShapeNameHdl, AbstractSvxNameDialog*, pNameDialog )
+{
+ SwWrtShell &rSh = GetShell();
+ SdrView *pSdrView = rSh.GetDrawView();
+ const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
+ OSL_ENSURE(rMarkList.GetMarkCount() == 1, "wrong draw selection");
+ SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+ const OUString sCurrentName = pObj->GetName();
+ OUString sNewName;
+ pNameDialog->GetName(sNewName);
+ long nRet = 0;
+ if (sNewName.isEmpty() || sCurrentName == sNewName)
+ nRet = 1;
+ else
+ {
+ nRet = 1;
+ SdrModel* pModel = rSh.getIDocumentDrawModelAccess()->GetDrawModel();
+ SdrObjListIter aIter( *(pModel->GetPage(0)), IM_DEEPWITHGROUPS );
+ while( aIter.IsMore() )
+ {
+ SdrObject* pTempObj = aIter.Next();
+ if ( pObj != pTempObj && pTempObj->GetName().equals(sNewName) )
+ {
+ nRet = 0;
+ break;
+ }
+ }
+ }
+ return nRet;
+}
+
+void SwDrawBaseShell::GetState(SfxItemSet& rSet)
+{
+ SwWrtShell &rSh = GetShell();
+ SdrView* pSdrView = rSh.GetDrawViewWithValidMarkList();
+ SfxWhichIter aIter( rSet );
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ bool bProtected = rSh.IsSelObjProtected(FLYPROTECT_CONTENT);
+
+ if (!bProtected) // Look in the parent
+ bProtected |= rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) != 0;
+
+ while( nWhich )
+ {
+ switch( nWhich )
+ {
+ case FN_DRAW_WRAP_DLG:
+ case SID_ATTR_TRANSFORM:
+ case SID_FRAME_TO_TOP:
+ case SID_FRAME_TO_BOTTOM:
+ case FN_FRAME_UP:
+ case FN_FRAME_DOWN:
+ case SID_DELETE:
+ case FN_BACKSPACE:
+ if( bProtected || !rSh.IsObjSelected() )
+ rSet.DisableItem( nWhich );
+ break;
+ case SID_GROUP:
+ if ( rSh.IsObjSelected() < 2 || bProtected || !rSh.IsGroupAllowed() )
+ rSet.DisableItem( nWhich );
+ break;
+ case SID_UNGROUP:
+ if ( !rSh.IsGroupSelected() || bProtected )
+ rSet.DisableItem( nWhich );
+ break;
+ case SID_ENTER_GROUP:
+ if ( !rSh.IsGroupSelected() )
+ rSet.DisableItem( nWhich );
+ break;
+ case SID_LEAVE_GROUP:
+ if ( !pSdrView->IsGroupEntered() )
+ rSet.DisableItem( nWhich );
+ break;
+ case SID_OBJECT_ALIGN_LEFT:
+ case SID_OBJECT_ALIGN_CENTER:
+ case SID_OBJECT_ALIGN_RIGHT:
+ case SID_OBJECT_ALIGN_UP:
+ case SID_OBJECT_ALIGN_MIDDLE:
+ case SID_OBJECT_ALIGN_DOWN:
+ case SID_OBJECT_ALIGN:
+ if ( !rSh.IsAlignPossible() || bProtected )
+ rSet.DisableItem( nWhich );
+ else
+ {
+ SfxAllEnumItem aEnumItem(nWhich, USHRT_MAX);
+ const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
+ //if only one object is selected it can only be vertically
+ // aligned because it is character bound
+ if( rMarkList.GetMarkCount() == 1 )
+ {
+ aEnumItem.DisableValue(SID_OBJECT_ALIGN_LEFT);
+ aEnumItem.DisableValue(SID_OBJECT_ALIGN_CENTER);
+ aEnumItem.DisableValue(SID_OBJECT_ALIGN_RIGHT);
+ }
+ rSet.Put(aEnumItem);
+ }
+ break;
+
+ case FN_NAME_SHAPE :
+ {
+ if(1L != pSdrView->GetMarkedObjectCount())
+ {
+ rSet.DisableItem( nWhich );
+ }
+ }
+ break;
+
+ // #i68101#
+ case FN_TITLE_DESCRIPTION_SHAPE:
+ {
+ const bool bIsWebView(NULL != dynamic_cast<SwWebView*>(&GetView()));
+
+ if(!bIsWebView && 1L != pSdrView->GetMarkedObjectCount())
+ {
+ rSet.DisableItem( nWhich );
+ }
+ }
+ break;
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+void SwDrawBaseShell::GetDrawAttrStateForIFBX( SfxItemSet& rSet )
+{
+ SwWrtShell *pSh = &GetShell();
+ SdrView* pSdrView = pSh->GetDrawView();
+ const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
+ if( rMarkList.GetMark(0) != 0 )
+ {
+ SfxItemSet aNewAttr(pSdrView->GetGeoAttrFromMarked());
+ rSet.Put(aNewAttr,false);
+ }
+}
+
+sal_Bool SwDrawBaseShell::Disable(SfxItemSet& rSet, sal_uInt16 nWhich)
+{
+ sal_Bool bDisable = GetShell().IsSelObjProtected(FLYPROTECT_CONTENT);
+
+ if (bDisable)
+ {
+ if (nWhich)
+ rSet.DisableItem( nWhich );
+ else
+ {
+ SfxWhichIter aIter( rSet );
+ nWhich = aIter.FirstWhich();
+ while (nWhich)
+ {
+ rSet.DisableItem( nWhich );
+ nWhich = aIter.NextWhich();
+ }
+ }
+ }
+
+ return bDisable;
+}
+
+// Validate of drawing positions
+
+IMPL_LINK(SwDrawBaseShell, ValidatePosition, SvxSwFrameValidation*, pValidation )
+{
+ SwWrtShell *pSh = &GetShell();
+ pValidation->nMinHeight = MINFLY;
+ pValidation->nMinWidth = MINFLY;
+
+ SwRect aBoundRect;
+
+ // OD 18.09.2003 #i18732# - adjustment for allowing vertical position
+ // aligned to page for fly frame anchored to paragraph or to character.
+ const RndStdIds eAnchorType = static_cast<RndStdIds >(pValidation->nAnchorType);
+ const SwPosition* pCntntPos = 0;
+ SdrView* pSdrView = pSh->GetDrawView();
+ const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
+ if( rMarkList.GetMarkCount() == 1 )
+ {
+ SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+ SwFrmFmt* pFrmFmt = FindFrmFmt( pObj );
+ pCntntPos = pFrmFmt->GetAnchor().GetCntntAnchor();
+ }
+
+ pSh->CalcBoundRect( aBoundRect, eAnchorType,
+ pValidation->nHRelOrient,
+ pValidation->nVRelOrient,
+ pCntntPos,
+ pValidation->bFollowTextFlow,
+ pValidation->bMirror, NULL, &pValidation->aPercentSize);
+
+ sal_Bool bIsInVertical( sal_False );
+ {
+ sal_Bool bRTL;
+ sal_Bool bVertL2R;
+ bIsInVertical = pSh->IsFrmVertical(sal_True, bRTL, bVertL2R);
+ }
+ if(bIsInVertical)
+ {
+ Point aPos(aBoundRect.Pos());
+ long nTmp = aPos.X();
+ aPos.X() = aPos.Y();
+ aPos.Y() = nTmp;
+ Size aSize(aBoundRect.SSize());
+ nTmp = aSize.Width();
+ aSize.Width() = aSize.Height();
+ aSize.Height() = nTmp;
+ aBoundRect.Chg( aPos, aSize );
+ //exchange width/height to enable correct values
+ nTmp = pValidation->nWidth;
+ pValidation->nWidth = pValidation->nHeight;
+ pValidation->nHeight = nTmp;
+ }
+ if ((eAnchorType == FLY_AT_PAGE) || (eAnchorType == FLY_AT_FLY))
+ {
+ // MinimalPosition
+ pValidation->nMinHPos = aBoundRect.Left();
+ pValidation->nMinVPos = aBoundRect.Top();
+ SwTwips nH = pValidation->nHPos;
+ SwTwips nV = pValidation->nVPos;
+
+ if (pValidation->nHPos + pValidation->nWidth > aBoundRect.Right())
+ {
+ if (pValidation->nHoriOrient == text::HoriOrientation::NONE)
+ {
+ pValidation->nHPos -= ((pValidation->nHPos + pValidation->nWidth) - aBoundRect.Right());
+ nH = pValidation->nHPos;
+ }
+ else
+ pValidation->nWidth = aBoundRect.Right() - pValidation->nHPos;
+ }
+
+ if (pValidation->nHPos + pValidation->nWidth > aBoundRect.Right())
+ pValidation->nWidth = aBoundRect.Right() - pValidation->nHPos;
+
+ if (pValidation->nVPos + pValidation->nHeight > aBoundRect.Bottom())
+ {
+ if (pValidation->nVertOrient == text::VertOrientation::NONE)
+ {
+ pValidation->nVPos -= ((pValidation->nVPos + pValidation->nHeight) - aBoundRect.Bottom());
+ nV = pValidation->nVPos;
+ }
+ else
+ pValidation->nHeight = aBoundRect.Bottom() - pValidation->nVPos;
+ }
+
+ if (pValidation->nVPos + pValidation->nHeight > aBoundRect.Bottom())
+ pValidation->nHeight = aBoundRect.Bottom() - pValidation->nVPos;
+
+ if ( pValidation->nVertOrient != text::VertOrientation::NONE )
+ nV = aBoundRect.Top();
+
+ if ( pValidation->nHoriOrient != text::HoriOrientation::NONE )
+ nH = aBoundRect.Left();
+
+ pValidation->nMaxHPos = aBoundRect.Right() - pValidation->nWidth;
+ pValidation->nMaxHeight = aBoundRect.Bottom() - nV;
+
+ pValidation->nMaxVPos = aBoundRect.Bottom() - pValidation->nHeight;
+ pValidation->nMaxWidth = aBoundRect.Right() - nH;
+ }
+ else if ((eAnchorType == FLY_AT_PARA) || (eAnchorType == FLY_AT_CHAR))
+ {
+ if (pValidation->nHPos + pValidation->nWidth > aBoundRect.Right())
+ {
+ if (pValidation->nHoriOrient == text::HoriOrientation::NONE)
+ {
+ pValidation->nHPos -= ((pValidation->nHPos + pValidation->nWidth) - aBoundRect.Right());
+ }
+ else
+ pValidation->nWidth = aBoundRect.Right() - pValidation->nHPos;
+ }
+
+ // OD 29.09.2003 #i17567#, #i18732# - consider following the text flow
+ // and alignment at page areas.
+ const bool bMaxVPosAtBottom = !pValidation->bFollowTextFlow ||
+ pValidation->nVRelOrient == text::RelOrientation::PAGE_FRAME ||
+ pValidation->nVRelOrient == text::RelOrientation::PAGE_PRINT_AREA;
+ {
+ SwTwips nTmpMaxVPos = ( bMaxVPosAtBottom
+ ? aBoundRect.Bottom()
+ : aBoundRect.Height() ) -
+ pValidation->nHeight;
+ if ( pValidation->nVPos > nTmpMaxVPos )
+ {
+ if (pValidation->nVertOrient == text::VertOrientation::NONE)
+ {
+ pValidation->nVPos = nTmpMaxVPos;
+ }
+ else
+ {
+ pValidation->nHeight = ( bMaxVPosAtBottom
+ ? aBoundRect.Bottom()
+ : aBoundRect.Height() ) - pValidation->nVPos;
+ }
+ }
+ }
+
+ pValidation->nMinHPos = aBoundRect.Left();
+ pValidation->nMaxHPos = aBoundRect.Right() - pValidation->nWidth;
+
+ pValidation->nMinVPos = aBoundRect.Top();
+ // OD 26.09.2003 #i17567#, #i18732# - determine maximum vertical position
+ if ( bMaxVPosAtBottom )
+ {
+ pValidation->nMaxVPos = aBoundRect.Bottom() - pValidation->nHeight;
+ }
+ else
+ {
+ pValidation->nMaxVPos = aBoundRect.Height() - pValidation->nHeight;
+ }
+
+ // Maximum width height
+ const SwTwips nH = ( pValidation->nHoriOrient != text::HoriOrientation::NONE )
+ ? aBoundRect.Left()
+ : pValidation->nHPos;
+ const SwTwips nV = ( pValidation->nVertOrient != text::VertOrientation::NONE )
+ ? aBoundRect.Top()
+ : pValidation->nVPos;
+ pValidation->nMaxHeight = pValidation->nMaxVPos + pValidation->nHeight - nV;
+ pValidation->nMaxWidth = pValidation->nMaxHPos + pValidation->nWidth - nH;
+ }
+ else if (eAnchorType == FLY_AS_CHAR)
+ {
+ pValidation->nMinHPos = 0;
+ pValidation->nMaxHPos = 0;
+
+ pValidation->nMaxHeight = aBoundRect.Height();
+ pValidation->nMaxWidth = aBoundRect.Width();
+
+ pValidation->nMaxVPos = aBoundRect.Height();
+ pValidation->nMinVPos = -aBoundRect.Height() + pValidation->nHeight;
+ if (pValidation->nMaxVPos < pValidation->nMinVPos)
+ {
+ pValidation->nMinVPos = pValidation->nMaxVPos;
+ pValidation->nMaxVPos = -aBoundRect.Height();
+ }
+ }
+ if(bIsInVertical)
+ {
+ //restore width/height exchange
+ long nTmp = pValidation->nWidth;
+ pValidation->nWidth = pValidation->nHeight;
+ pValidation->nHeight = nTmp;
+ }
+
+ if (pValidation->nMaxWidth < pValidation->nWidth)
+ pValidation->nWidth = pValidation->nMaxWidth;
+ if (pValidation->nMaxHeight < pValidation->nHeight)
+ pValidation->nHeight = pValidation->nMaxHeight;
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/shells/drwtxtex.cxx b/sw/source/core/uibase/shells/drwtxtex.cxx
new file mode 100644
index 000000000000..24abc785cf6e
--- /dev/null
+++ b/sw/source/core/uibase/shells/drwtxtex.cxx
@@ -0,0 +1,1084 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <com/sun/star/ui/dialogs/XSLTFilterDialog.hpp>
+
+#include <comphelper/processfactory.hxx>
+#include <comphelper/string.hxx>
+#include <i18nlangtag/mslangid.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/request.hxx>
+#include <tools/shl.hxx>
+#include <svx/svdview.hxx>
+#include <editeng/spltitem.hxx>
+#include <editeng/lrspitem.hxx>
+#include <editeng/ulspitem.hxx>
+#include <editeng/orphitem.hxx>
+#include <editeng/formatbreakitem.hxx>
+#include <editeng/widwitem.hxx>
+#include <editeng/kernitem.hxx>
+#include <editeng/escapementitem.hxx>
+#include <editeng/lspcitem.hxx>
+#include <editeng/adjustitem.hxx>
+#include <editeng/crossedoutitem.hxx>
+#include <editeng/shdditem.hxx>
+#include <editeng/udlnitem.hxx>
+#include <editeng/fontitem.hxx>
+#include <editeng/fhgtitem.hxx>
+#include <editeng/colritem.hxx>
+#include <editeng/wghtitem.hxx>
+#include <editeng/contouritem.hxx>
+#include <editeng/postitem.hxx>
+#include <editeng/frmdiritem.hxx>
+#include <svx/svdoutl.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <svl/whiter.hxx>
+#include <svl/cjkoptions.hxx>
+#include <svl/ctloptions.hxx>
+#include <svtools/langtab.hxx>
+#include <svl/languageoptions.hxx>
+#include <vcl/msgbox.hxx>
+#include <editeng/flditem.hxx>
+#include <editeng/editstat.hxx>
+#include <svx/hlnkitem.hxx>
+#include <sfx2/htmlmode.hxx>
+#include <svl/slstitm.hxx>
+#include <editeng/langitem.hxx>
+#include <editeng/unolingu.hxx>
+#include <editeng/scripttypeitem.hxx>
+#include <editeng/writingmodeitem.hxx>
+#include <editeng/eeitem.hxx>
+#include <editeng/editeng.hxx>
+#include <editeng/editdata.hxx>
+#include <editeng/outliner.hxx>
+#include <vcl/window.hxx>
+#include <editeng/editview.hxx>
+#include <vcl/outdev.hxx>
+#include <editeng/hyphenzoneitem.hxx>
+#include <tools/diagnose_ex.h>
+
+#include <cmdid.h>
+#include <doc.hxx>
+#include <docstat.hxx>
+#include <drwtxtsh.hxx>
+#include <edtwin.hxx>
+#include <globals.hrc>
+#include <hintids.hxx>
+#include <initui.hxx>
+#include <langhelper.hxx>
+#include <chrdlgmodes.hxx>
+#include <pardlg.hxx>
+#include <shells.hrc>
+#include <string.h>
+#include <swdtflvr.hxx>
+#include <swmodule.hxx>
+#include <swwait.hxx>
+#include <uitool.hxx>
+#include <viewopt.hxx>
+#include <wrtsh.hxx>
+#include <wview.hxx>
+#include <wordcountdialog.hxx>
+
+#include "swabstdlg.hxx"
+#include "chrdlg.hrc"
+#include "misc.hrc"
+
+const sal_uInt32 nFontInc = 40; // 2pt
+const sal_uInt32 nFontMaxSz = 19998; // 999.9pt
+
+using namespace ::com::sun::star;
+
+void SwDrawTextShell::Execute( SfxRequest &rReq )
+{
+ SwWrtShell &rSh = GetShell();
+ OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
+ SfxItemSet aEditAttr(pOLV->GetAttribs());
+ SfxItemSet aNewAttr(*aEditAttr.GetPool(), aEditAttr.GetRanges());
+
+ const sal_uInt16 nSlot = rReq.GetSlot();
+
+ const sal_uInt16 nWhich = GetPool().GetWhich(nSlot);
+ const SfxItemSet *pNewAttrs = rReq.GetArgs();
+
+ bool bRestoreSelection = false;
+ ESelection aOldSelection;
+
+ sal_uInt16 nEEWhich = 0;
+ switch (nSlot)
+ {
+ case SID_LANGUAGE_STATUS:
+ {
+ aOldSelection = pOLV->GetSelection();
+ if (!pOLV->GetEditView().HasSelection())
+ {
+ bRestoreSelection = true;
+ pOLV->GetEditView().SelectCurrentWord();
+ }
+
+ bRestoreSelection = SwLangHelper::SetLanguageStatus(pOLV,rReq,GetView(),rSh);
+ break;
+ }
+
+ case SID_THES:
+ {
+ OUString aReplaceText;
+ SFX_REQUEST_ARG( rReq, pItem2, SfxStringItem, SID_THES, false );
+ if (pItem2)
+ aReplaceText = pItem2->GetValue();
+ if (!aReplaceText.isEmpty())
+ ReplaceTextWithSynonym( pOLV->GetEditView(), aReplaceText );
+ break;
+ }
+
+ case SID_ATTR_CHAR_FONT:
+ case SID_ATTR_CHAR_FONTHEIGHT:
+ case SID_ATTR_CHAR_WEIGHT:
+ case SID_ATTR_CHAR_POSTURE:
+ {
+ SfxItemPool* pPool2 = aEditAttr.GetPool()->GetSecondaryPool();
+ if( !pPool2 )
+ pPool2 = aEditAttr.GetPool();
+ SvxScriptSetItem aSetItem( nSlot, *pPool2 );
+
+ // #i78017 establish the same behaviour as in Writer
+ sal_uInt16 nScriptTypes = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX;
+ if (nSlot == SID_ATTR_CHAR_FONT)
+ nScriptTypes = pOLV->GetSelectedScriptType();
+
+ if (pNewAttrs)
+ {
+ aSetItem.PutItemForScriptType( nScriptTypes, pNewAttrs->Get( nWhich ) );
+ aNewAttr.Put( aSetItem.GetItemSet() );
+ }
+ }
+ break;
+
+ case SID_ATTR_CHAR_COLOR: nEEWhich = EE_CHAR_COLOR; break;
+
+ case SID_ATTR_CHAR_UNDERLINE:
+ {
+ if ( pNewAttrs )
+ {
+ const SvxTextLineItem& rTextLineItem = static_cast< const SvxTextLineItem& >( pNewAttrs->Get( pNewAttrs->GetPool()->GetWhich(nSlot) ) );
+ aNewAttr.Put( SvxUnderlineItem( rTextLineItem.GetLineStyle(), EE_CHAR_UNDERLINE ) );
+ }
+ else
+ {
+ FontUnderline eFU = ((const SvxUnderlineItem&)aEditAttr.Get(EE_CHAR_UNDERLINE)).GetLineStyle();
+ aNewAttr.Put( SvxUnderlineItem(eFU == UNDERLINE_SINGLE ? UNDERLINE_NONE : UNDERLINE_SINGLE, EE_CHAR_UNDERLINE) );
+ }
+ }
+ break;
+
+ case SID_ATTR_CHAR_OVERLINE:
+ {
+ FontUnderline eFO = ((const SvxOverlineItem&)aEditAttr.Get(EE_CHAR_OVERLINE)).GetLineStyle();
+ aNewAttr.Put(SvxOverlineItem(eFO == UNDERLINE_SINGLE ? UNDERLINE_NONE : UNDERLINE_SINGLE, EE_CHAR_OVERLINE));
+ }
+ break;
+
+ case SID_ATTR_CHAR_CONTOUR: nEEWhich = EE_CHAR_OUTLINE; break;
+ case SID_ATTR_CHAR_SHADOWED: nEEWhich = EE_CHAR_SHADOW; break;
+ case SID_ATTR_CHAR_STRIKEOUT: nEEWhich = EE_CHAR_STRIKEOUT; break;
+ case SID_ATTR_CHAR_WORDLINEMODE: nEEWhich = EE_CHAR_WLM; break;
+ case SID_ATTR_CHAR_RELIEF : nEEWhich = EE_CHAR_RELIEF; break;
+ case SID_ATTR_CHAR_LANGUAGE : nEEWhich = EE_CHAR_LANGUAGE;break;
+ case SID_ATTR_CHAR_KERNING : nEEWhich = EE_CHAR_KERNING; break;
+ case SID_ATTR_CHAR_SCALEWIDTH: nEEWhich = EE_CHAR_FONTWIDTH; break;
+ case SID_ATTR_CHAR_AUTOKERN : nEEWhich = EE_CHAR_PAIRKERNING; break;
+ case SID_ATTR_CHAR_ESCAPEMENT: nEEWhich = EE_CHAR_ESCAPEMENT; break;
+ case SID_ATTR_PARA_ADJUST_LEFT:
+ aNewAttr.Put(SvxAdjustItem(SVX_ADJUST_LEFT, EE_PARA_JUST));
+ break;
+ case SID_ATTR_PARA_ADJUST_CENTER:
+ aNewAttr.Put(SvxAdjustItem(SVX_ADJUST_CENTER, EE_PARA_JUST));
+ break;
+ case SID_ATTR_PARA_ADJUST_RIGHT:
+ aNewAttr.Put(SvxAdjustItem(SVX_ADJUST_RIGHT, EE_PARA_JUST));
+ break;
+ case SID_ATTR_PARA_ADJUST_BLOCK:
+ aNewAttr.Put(SvxAdjustItem(SVX_ADJUST_BLOCK, EE_PARA_JUST));
+ break;
+ case SID_ATTR_PARA_LRSPACE:
+ {
+ SvxLRSpaceItem aParaMargin((const SvxLRSpaceItem&)rReq.
+ GetArgs()->Get(nSlot));
+ aParaMargin.SetWhich( EE_PARA_LRSPACE );
+ aNewAttr.Put(aParaMargin);
+ rReq.Done();
+ }
+ break;
+ case SID_ATTR_PARA_LINESPACE:
+ {
+ SvxLineSpacingItem aLineSpace = (const SvxLineSpacingItem&)pNewAttrs->Get(
+ GetPool().GetWhich(nSlot));
+ aLineSpace.SetWhich( EE_PARA_SBL );
+ aNewAttr.Put( aLineSpace );
+ rReq.Done();
+ }
+ break;
+ case SID_ATTR_PARA_ULSPACE:
+ {
+ SvxULSpaceItem aULSpace = (const SvxULSpaceItem&)pNewAttrs->Get(
+ GetPool().GetWhich(nSlot));
+ aULSpace.SetWhich( EE_PARA_ULSPACE );
+ aNewAttr.Put( aULSpace );
+ rReq.Done();
+ }
+ 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 FN_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, EE_CHAR_ESCAPEMENT );
+ }
+ break;
+ case FN_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, EE_CHAR_ESCAPEMENT );
+ }
+ break;
+
+ case SID_CHAR_DLG_EFFECT:
+ case SID_CHAR_DLG:
+ case SID_CHAR_DLG_FOR_PARAGRAPH:
+ {
+ const SfxItemSet* pArgs = rReq.GetArgs();
+
+ if( !pArgs )
+ {
+ aOldSelection = pOLV->GetSelection();
+ if (nSlot == SID_CHAR_DLG_FOR_PARAGRAPH)
+ {
+ // select current paragraph (and restore selection later on...)
+ EditView & rEditView = pOLV->GetEditView();
+ SwLangHelper::SelectPara( rEditView, rEditView.GetSelection() );
+ bRestoreSelection = true;
+ }
+
+ SwView* pView = &GetView();
+ FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, pView));
+ SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)) );
+ SfxItemSet aDlgAttr(GetPool(), EE_ITEMS_START, EE_ITEMS_END);
+
+ // util::Language does not exists in the EditEngine! That is why not in set.
+
+ aDlgAttr.Put( aEditAttr );
+ aDlgAttr.Put( SvxKerningItem(0, RES_CHRATR_KERNING) );
+
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+
+ SfxAbstractTabDialog* pDlg = pFact->CreateSwCharDlg(pView->GetWindow(), *pView, aDlgAttr, DLG_CHAR_DRAW);
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ if (nSlot == SID_CHAR_DLG_EFFECT)
+ {
+ pDlg->SetCurPageId("fonteffect");
+ }
+ sal_uInt16 nRet = pDlg->Execute();
+ if(RET_OK == nRet )
+ {
+ rReq.Done( *( pDlg->GetOutputItemSet() ) );
+ aNewAttr.Put(*pDlg->GetOutputItemSet());
+ }
+ delete( pDlg );
+ if(RET_OK != nRet)
+ return ;
+ }
+ else
+ aNewAttr.Put(*pArgs);
+ }
+ break;
+ case FN_FORMAT_FOOTNOTE_DLG:
+ {
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+
+ VclAbstractDialog* pDlg = pFact->CreateSwFootNoteOptionDlg(GetView().GetWindow(), rView.GetWrtShell());
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ pDlg->Execute();
+ delete pDlg;
+ break;
+ }
+ case FN_NUMBERING_OUTLINE_DLG:
+ {
+ SfxItemSet aTmp(GetPool(), FN_PARAM_1, FN_PARAM_1);
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "Dialogdiet fail!");
+ SfxAbstractTabDialog* pDlg = pFact->CreateSwTabDialog( DLG_TAB_OUTLINE,
+ GetView().GetWindow(), &aTmp, GetView().GetWrtShell());
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ pDlg->Execute();
+ delete pDlg;
+ rReq.Done();
+ }
+ break;
+ case SID_OPEN_XML_FILTERSETTINGS:
+ {
+ try
+ {
+ uno::Reference < ui::dialogs::XExecutableDialog > xDialog = ui::dialogs::XSLTFilterDialog::create( ::comphelper::getProcessComponentContext() );
+ xDialog->execute();
+ }
+ catch (const uno::Exception&)
+ {
+ }
+ rReq.Ignore ();
+ }
+ break;
+ case FN_WORDCOUNT_DIALOG:
+ {
+ SfxViewFrame* pVFrame = GetView().GetViewFrame();
+ if (pVFrame != NULL)
+ {
+ pVFrame->ToggleChildWindow(FN_WORDCOUNT_DIALOG);
+ Invalidate(rReq.GetSlot());
+
+ SwWordCountWrapper *pWrdCnt = (SwWordCountWrapper*)pVFrame->GetChildWindow(SwWordCountWrapper::GetChildWindowId());
+ if (pWrdCnt)
+ pWrdCnt->UpdateCounts();
+ }
+ }
+ break;
+ case SID_PARA_DLG:
+ {
+ const SfxItemSet* pArgs = rReq.GetArgs();
+
+ if (!pArgs)
+ {
+ SwView* pView = &GetView();
+ FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, pView));
+ SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)) );
+ SfxItemSet aDlgAttr(GetPool(),
+ EE_ITEMS_START, EE_ITEMS_END,
+ SID_ATTR_PARA_HYPHENZONE, SID_ATTR_PARA_HYPHENZONE,
+ 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);
+
+ aDlgAttr.Put(aEditAttr);
+
+ aDlgAttr.Put( SvxHyphenZoneItem( false, RES_PARATR_HYPHENZONE) );
+ aDlgAttr.Put( SvxFmtBreakItem( SVX_BREAK_NONE, RES_BREAK ) );
+ aDlgAttr.Put( SvxFmtSplitItem( true, RES_PARATR_SPLIT ) );
+ aDlgAttr.Put( SvxWidowsItem( 0, RES_PARATR_WIDOWS ) );
+ aDlgAttr.Put( SvxOrphansItem( 0, RES_PARATR_ORPHANS ) );
+
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+
+ SfxAbstractTabDialog* pDlg = pFact->CreateSwParaDlg( GetView().GetWindow(), GetView(), aDlgAttr,DLG_STD, 0, sal_True );
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ sal_uInt16 nRet = pDlg->Execute();
+ if(RET_OK == nRet)
+ {
+ rReq.Done( *( pDlg->GetOutputItemSet() ) );
+ aNewAttr.Put(*pDlg->GetOutputItemSet());
+ }
+ delete( pDlg );
+ if(RET_OK != nRet)
+ return;
+ }
+ else
+ aNewAttr.Put(*pArgs);
+ }
+ break;
+ case SID_AUTOSPELL_CHECK:
+ {
+//!! JP 16.03.2001: why?? pSdrView = rSh.GetDrawView();
+//!! JP 16.03.2001: why?? pOutliner = pSdrView->GetTextEditOutliner();
+ SdrOutliner * pOutliner = pSdrView->GetTextEditOutliner();
+ sal_uInt32 nCtrl = pOutliner->GetControlWord();
+
+ sal_Bool bSet = ((const SfxBoolItem&)rReq.GetArgs()->Get(
+ nSlot)).GetValue();
+ if(bSet)
+ nCtrl |= EE_CNTRL_ONLINESPELLING|EE_CNTRL_ALLOWBIGOBJS;
+ else
+ nCtrl &= ~EE_CNTRL_ONLINESPELLING;
+ pOutliner->SetControlWord(nCtrl);
+
+ rView.ExecuteSlot(rReq);
+ }
+ break;
+ case SID_HYPERLINK_SETLINK:
+ {
+ const SfxPoolItem* pItem = 0;
+ if(pNewAttrs)
+ pNewAttrs->GetItemState(nSlot, false, &pItem);
+
+ if(pItem)
+ {
+ const SvxHyperlinkItem& rHLinkItem = *(const SvxHyperlinkItem *)pItem;
+ SvxURLField aFld(rHLinkItem.GetURL(), rHLinkItem.GetName(), SVXURLFORMAT_APPDEFAULT);
+ aFld.SetTargetFrame(rHLinkItem.GetTargetFrame());
+
+ const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection();
+
+ if (pFieldItem && pFieldItem->GetField()->ISA(SvxURLField))
+ {
+ // Select field so that it will be deleted during insert
+ ESelection aSel = pOLV->GetSelection();
+ aSel.nEndPos++;
+ pOLV->SetSelection(aSel);
+ }
+ pOLV->InsertField(SvxFieldItem(aFld, EE_FEATURE_FIELD));
+ }
+ }
+ break;
+
+ case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
+ case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
+ // Shell switch!
+ {
+ SdrObject* pTmpObj = pSdrView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
+ SdrPageView* pTmpPV = pSdrView->GetSdrPageView();
+ SdrView* pTmpView = pSdrView;
+
+ pSdrView->SdrEndTextEdit(sal_True);
+
+ SfxItemSet aAttr( *aNewAttr.GetPool(),
+ SDRATTR_TEXTDIRECTION,
+ SDRATTR_TEXTDIRECTION );
+
+ aAttr.Put( SvxWritingModeItem(
+ nSlot == SID_TEXTDIRECTION_LEFT_TO_RIGHT ?
+ text::WritingMode_LR_TB
+ : text::WritingMode_TB_RL, SDRATTR_TEXTDIRECTION ) );
+ pTmpView->SetAttributes( aAttr );
+
+ rSh.GetView().BeginTextEdit( pTmpObj, pTmpPV, &rSh.GetView().GetEditWin(), false);
+ rSh.GetView().AttrChangedNotify( &rSh );
+ }
+ return;
+
+ case SID_ATTR_PARA_LEFT_TO_RIGHT:
+ case SID_ATTR_PARA_RIGHT_TO_LEFT:
+ {
+ SdrObject* pTmpObj = pSdrView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
+ SdrPageView* pTmpPV = pSdrView->GetSdrPageView();
+ SdrView* pTmpView = pSdrView;
+
+ pSdrView->SdrEndTextEdit(sal_True);
+ bool bLeftToRight = nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT;
+
+ const SfxPoolItem* pPoolItem;
+ if( pNewAttrs && SFX_ITEM_SET == pNewAttrs->GetItemState( nSlot, true, &pPoolItem ) )
+ {
+ if( !( (SfxBoolItem*)pPoolItem)->GetValue() )
+ bLeftToRight = !bLeftToRight;
+ }
+ SfxItemSet aAttr( *aNewAttr.GetPool(),
+ EE_PARA_JUST, EE_PARA_JUST,
+ EE_PARA_WRITINGDIR, EE_PARA_WRITINGDIR,
+ 0 );
+
+ sal_uInt16 nAdjust = SVX_ADJUST_LEFT;
+ if( SFX_ITEM_ON == aEditAttr.GetItemState(EE_PARA_JUST, true, &pPoolItem ) )
+ nAdjust = ( (SvxAdjustItem*)pPoolItem)->GetEnumValue();
+
+ if( bLeftToRight )
+ {
+ aAttr.Put( SvxFrameDirectionItem( FRMDIR_HORI_LEFT_TOP, EE_PARA_WRITINGDIR ) );
+ if( nAdjust == SVX_ADJUST_RIGHT )
+ aAttr.Put( SvxAdjustItem( SVX_ADJUST_LEFT, EE_PARA_JUST ) );
+ }
+ else
+ {
+ aAttr.Put( SvxFrameDirectionItem( FRMDIR_HORI_RIGHT_TOP, EE_PARA_WRITINGDIR ) );
+ if( nAdjust == SVX_ADJUST_LEFT )
+ aAttr.Put( SvxAdjustItem( SVX_ADJUST_RIGHT, EE_PARA_JUST ) );
+ }
+ pTmpView->SetAttributes( aAttr );
+ rSh.GetView().BeginTextEdit( pTmpObj, pTmpPV, &rSh.GetView().GetEditWin(), false );
+ rSh.GetView().AttrChangedNotify( &rSh );
+ }
+ return;
+
+ case FN_GROW_FONT_SIZE:
+ case FN_SHRINK_FONT_SIZE:
+ {
+ SfxItemPool* pPool2 = aEditAttr.GetPool()->GetSecondaryPool();
+ if( !pPool2 )
+ pPool2 = aEditAttr.GetPool();
+
+ SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONTHEIGHT, *pPool2 );
+ aSetItem.GetItemSet().Put( aEditAttr, false );
+
+ sal_uInt16 nScriptTypes = pOLV->GetSelectedScriptType();
+ const SvxFontHeightItem* pSize( static_cast<const SvxFontHeightItem*>( aSetItem.GetItemOfScript( nScriptTypes ) ) );
+
+ if (pSize)
+ {
+ SvxFontHeightItem aSize(*pSize);
+
+ sal_uInt32 nSize = aSize.GetHeight();
+
+ if( nSlot == FN_GROW_FONT_SIZE && ( nSize += nFontInc ) > nFontMaxSz )
+ nSize = nFontMaxSz;
+ else if( nSlot == FN_SHRINK_FONT_SIZE && ( nSize -= nFontInc ) < nFontInc )
+ nSize = nFontInc;
+
+ aSize.SetHeight( nSize );
+ aSetItem.PutItemForScriptType( nScriptTypes, aSize );
+ aNewAttr.Put( aSetItem.GetItemSet() );
+ }
+ }
+ break;
+
+ default:
+ OSL_ENSURE(!this, "wrong dispatcher");
+ return;
+ }
+ if(nEEWhich && pNewAttrs)
+ aNewAttr.Put(pNewAttrs->Get(nWhich), nEEWhich);
+
+ SetAttrToMarked(aNewAttr);
+
+ GetView().GetViewFrame()->GetBindings().InvalidateAll(sal_False);
+
+ if (IsTextEdit() && pOLV->GetOutliner()->IsModified())
+ rSh.SetModified();
+
+ if (bRestoreSelection)
+ {
+ // restore selection
+ pOLV->GetEditView().SetSelection( aOldSelection );
+ }
+}
+
+void SwDrawTextShell::GetState(SfxItemSet& rSet)
+{
+ if (!IsTextEdit()) // Otherwise sometimes crash!
+ return;
+
+ OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
+ SfxWhichIter aIter(rSet);
+ sal_uInt16 nWhich = aIter.FirstWhich();
+
+ SfxItemSet aEditAttr( pOLV->GetAttribs() );
+ const SfxPoolItem *pAdjust = 0, *pLSpace = 0, *pEscItem = 0;
+ int eAdjust, nLSpace, nEsc;
+
+ while(nWhich)
+ {
+ sal_uInt16 nSlotId = GetPool().GetSlotId( nWhich );
+ sal_Bool bFlag = sal_False;
+ switch( nSlotId )
+ {
+ case SID_LANGUAGE_STATUS://20412:
+ {
+ nSlotId = SwLangHelper::GetLanguageStatus(pOLV,rSet);
+ break;
+ }
+
+ case SID_THES:
+ {
+ OUString aStatusVal;
+ LanguageType nLang = LANGUAGE_NONE;
+ bool bIsLookUpWord = GetStatusValueForThesaurusFromContext( aStatusVal, nLang, pOLV->GetEditView() );
+ rSet.Put( SfxStringItem( SID_THES, aStatusVal ) );
+
+ // disable "Thesaurus" context menu entry if there is nothing to look up
+ uno::Reference< linguistic2::XThesaurus > xThes( ::GetThesaurus() );
+ if (!bIsLookUpWord ||
+ !xThes.is() || nLang == LANGUAGE_NONE || !xThes->hasLocale( LanguageTag::convertToLocale( nLang ) ))
+ rSet.DisableItem( SID_THES );
+
+ //! avoid putting the same item as SfxBoolItem at the end of this function
+ nSlotId = 0;
+ break;
+ }
+
+ case SID_ATTR_PARA_ADJUST_LEFT: eAdjust = SVX_ADJUST_LEFT; goto ASK_ADJUST;
+ case SID_ATTR_PARA_ADJUST_RIGHT: eAdjust = SVX_ADJUST_RIGHT; goto ASK_ADJUST;
+ case SID_ATTR_PARA_ADJUST_CENTER: eAdjust = SVX_ADJUST_CENTER; goto ASK_ADJUST;
+ case SID_ATTR_PARA_ADJUST_BLOCK: eAdjust = SVX_ADJUST_BLOCK; goto ASK_ADJUST;
+ASK_ADJUST:
+ {
+ if( !pAdjust )
+ aEditAttr.GetItemState( EE_PARA_JUST, false, &pAdjust);
+
+ if( !pAdjust || IsInvalidItem( pAdjust ))
+ rSet.InvalidateItem( nSlotId ), nSlotId = 0;
+ else
+ bFlag = eAdjust == ((SvxAdjustItem*)pAdjust)->GetAdjust();
+ }
+ break;
+
+ case SID_ATTR_PARA_LRSPACE:
+ {
+ SfxItemState eState = aEditAttr.GetItemState(EE_PARA_LRSPACE);
+ if( eState >= SFX_ITEM_DEFAULT )
+ {
+ SvxLRSpaceItem aLR = (const SvxLRSpaceItem&) aEditAttr.Get( EE_PARA_LRSPACE );
+ aLR.SetWhich(SID_ATTR_PARA_LRSPACE);
+ rSet.Put(aLR);
+ }
+ else
+ rSet.InvalidateItem(nSlotId);
+ nSlotId = 0;
+ }
+ break;
+ case SID_ATTR_PARA_LINESPACE:
+ {
+ SfxItemState eState = aEditAttr.GetItemState(EE_PARA_SBL);
+ if( eState >= SFX_ITEM_DEFAULT )
+ {
+ SvxLineSpacingItem aLR = (const SvxLineSpacingItem&) aEditAttr.Get( EE_PARA_SBL );
+ rSet.Put(aLR);
+ }
+ else
+ rSet.InvalidateItem(nSlotId);
+ nSlotId = 0;
+ }
+ break;
+ case SID_ATTR_PARA_ULSPACE:
+ {
+ SfxItemState eState = aEditAttr.GetItemState(EE_PARA_ULSPACE);
+ if( eState >= SFX_ITEM_DEFAULT )
+ {
+ SvxULSpaceItem aULSpace = (const SvxULSpaceItem&) aEditAttr.Get( EE_PARA_ULSPACE );
+ aULSpace.SetWhich(SID_ATTR_PARA_ULSPACE);
+ rSet.Put(aULSpace);
+ }
+ else
+ rSet.InvalidateItem(nSlotId);
+ nSlotId = 0;
+ }
+ break;
+
+ case SID_ATTR_PARA_LINESPACE_10: nLSpace = 100; goto ASK_LINESPACE;
+ case SID_ATTR_PARA_LINESPACE_15: nLSpace = 150; goto ASK_LINESPACE;
+ case SID_ATTR_PARA_LINESPACE_20: nLSpace = 200; goto ASK_LINESPACE;
+ASK_LINESPACE:
+ {
+ if( !pLSpace )
+ aEditAttr.GetItemState( EE_PARA_SBL, false, &pLSpace );
+
+ if( !pLSpace || IsInvalidItem( pLSpace ))
+ rSet.InvalidateItem( nSlotId ), nSlotId = 0;
+ else if( nLSpace == ((const SvxLineSpacingItem*)pLSpace)->
+ GetPropLineSpace() )
+ bFlag = sal_True;
+ else
+ nSlotId = 0;
+ }
+ break;
+
+ case FN_SET_SUPER_SCRIPT: nEsc = SVX_ESCAPEMENT_SUPERSCRIPT;
+ goto ASK_ESCAPE;
+ case FN_SET_SUB_SCRIPT: nEsc = SVX_ESCAPEMENT_SUBSCRIPT;
+ goto ASK_ESCAPE;
+ASK_ESCAPE:
+ {
+ if( !pEscItem )
+ pEscItem = &aEditAttr.Get( EE_CHAR_ESCAPEMENT );
+
+ if( nEsc == ((const SvxEscapementItem*)
+ pEscItem)->GetEnumValue() )
+ bFlag = sal_True;
+ else
+ nSlotId = 0;
+ }
+ break;
+
+ case SID_THESAURUS:
+ {
+ // disable "Thesaurus" if the language is not supported
+ const SfxPoolItem &rItem = GetShell().GetDoc()->GetDefault(
+ GetWhichOfScript( RES_CHRATR_LANGUAGE,
+ GetI18NScriptTypeOfLanguage( (sal_uInt16)GetAppLanguage())) );
+ LanguageType nLang = ((const SvxLanguageItem &) rItem).GetLanguage();
+
+ uno::Reference< linguistic2::XThesaurus > xThes( ::GetThesaurus() );
+ if (!xThes.is() || nLang == LANGUAGE_NONE || !xThes->hasLocale( LanguageTag::convertToLocale( nLang ) ))
+ rSet.DisableItem( SID_THESAURUS );
+ nSlotId = 0;
+ }
+ break;
+ case SID_HANGUL_HANJA_CONVERSION:
+ case SID_CHINESE_CONVERSION:
+ {
+ if (!SvtCJKOptions().IsAnyEnabled())
+ {
+ GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_False );
+ rSet.DisableItem(nWhich);
+ }
+ else
+ GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_True );
+ }
+ break;
+
+ case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
+ case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
+ if ( !SvtLanguageOptions().IsVerticalTextEnabled() )
+ {
+ rSet.DisableItem( nSlotId );
+ nSlotId = 0;
+ }
+ else
+ {
+ SdrOutliner * pOutliner = pSdrView->GetTextEditOutliner();
+ if( pOutliner )
+ bFlag = pOutliner->IsVertical() ==
+ (SID_TEXTDIRECTION_TOP_TO_BOTTOM == nSlotId);
+ else
+ {
+ text::WritingMode eMode = (text::WritingMode)
+ ( (const SvxWritingModeItem&) aEditAttr.Get( SDRATTR_TEXTDIRECTION ) ).GetValue();
+
+ if( nSlotId == SID_TEXTDIRECTION_LEFT_TO_RIGHT )
+ {
+ bFlag = eMode == text::WritingMode_LR_TB;
+ }
+ else
+ {
+ bFlag = eMode != text::WritingMode_TB_RL;
+ }
+ }
+ }
+ break;
+ case SID_ATTR_PARA_LEFT_TO_RIGHT:
+ case SID_ATTR_PARA_RIGHT_TO_LEFT:
+ {
+ if ( !SvtLanguageOptions().IsCTLFontEnabled() )
+ {
+ rSet.DisableItem( nWhich );
+ nSlotId = 0;
+ }
+ else
+ {
+ SdrOutliner * pOutliner = pSdrView->GetTextEditOutliner();
+ if(pOutliner && pOutliner->IsVertical())
+ {
+ rSet.DisableItem( nWhich );
+ nSlotId = 0;
+ }
+ else
+ {
+ switch( ( ( (SvxFrameDirectionItem&) aEditAttr.Get( EE_PARA_WRITINGDIR ) ) ).GetValue() )
+ {
+ case FRMDIR_HORI_LEFT_TOP:
+ bFlag = nWhich == SID_ATTR_PARA_LEFT_TO_RIGHT;
+ break;
+
+ case FRMDIR_HORI_RIGHT_TOP:
+ bFlag = nWhich != SID_ATTR_PARA_LEFT_TO_RIGHT;
+ break;
+ }
+ }
+ }
+ }
+ break;
+ case SID_TRANSLITERATE_HALFWIDTH:
+ case SID_TRANSLITERATE_FULLWIDTH:
+ case SID_TRANSLITERATE_HIRAGANA:
+ case SID_TRANSLITERATE_KATAGANA:
+ {
+ SvtCJKOptions aCJKOptions;
+ if(!aCJKOptions.IsChangeCaseMapEnabled())
+ {
+ rSet.DisableItem(nWhich);
+ GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_False );
+ }
+ else
+ GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_True );
+ }
+ break;
+ case SID_INSERT_RLM :
+ case SID_INSERT_LRM :
+ case SID_INSERT_ZWNBSP :
+ case SID_INSERT_ZWSP:
+ {
+ SvtCTLOptions aCTLOptions;
+ sal_Bool bEnabled = aCTLOptions.IsCTLFontEnabled();
+ GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, bEnabled );
+ if(!bEnabled)
+ rSet.DisableItem(nWhich);
+ }
+ break;
+ default:
+ nSlotId = 0; // don't know this slot
+ break;
+ }
+
+ if( nSlotId )
+ rSet.Put( SfxBoolItem( nWhich, bFlag ));
+
+ nWhich = aIter.NextWhich();
+ }
+}
+
+void SwDrawTextShell::GetDrawTxtCtrlState(SfxItemSet& rSet)
+{
+ if (!IsTextEdit()) // Otherwise crash!
+ return;
+
+ OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
+ SfxItemSet aEditAttr(pOLV->GetAttribs());
+
+ SfxWhichIter aIter(rSet);
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ sal_uInt16 nScriptType = pOLV->GetSelectedScriptType();
+ while(nWhich)
+ {
+ sal_uInt16 nEEWhich = 0;
+ sal_uInt16 nSlotId = GetPool().GetSlotId( nWhich );
+ switch( nSlotId )
+ {
+ case SID_ATTR_CHAR_FONT:
+ case SID_ATTR_CHAR_FONTHEIGHT:
+ case SID_ATTR_CHAR_WEIGHT:
+ case SID_ATTR_CHAR_POSTURE:
+ {
+ SfxItemPool* pEditPool = aEditAttr.GetPool()->GetSecondaryPool();
+ if( !pEditPool )
+ pEditPool = aEditAttr.GetPool();
+ SvxScriptSetItem aSetItem( nSlotId, *pEditPool );
+ aSetItem.GetItemSet().Put( aEditAttr, false );
+ const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScriptType );
+ if( pI )
+ rSet.Put( *pI, nWhich );
+ else
+ rSet.InvalidateItem( nWhich );
+ }
+ break;
+ case SID_ATTR_CHAR_COLOR: nEEWhich = EE_CHAR_COLOR; break;
+ case SID_ATTR_CHAR_UNDERLINE: nEEWhich = EE_CHAR_UNDERLINE;break;
+ case SID_ATTR_CHAR_OVERLINE: nEEWhich = EE_CHAR_OVERLINE;break;
+ case SID_ATTR_CHAR_CONTOUR: nEEWhich = EE_CHAR_OUTLINE; break;
+ case SID_ATTR_CHAR_SHADOWED: nEEWhich = EE_CHAR_SHADOW;break;
+ case SID_ATTR_CHAR_STRIKEOUT: nEEWhich = EE_CHAR_STRIKEOUT;break;
+ case SID_AUTOSPELL_CHECK:
+ {
+ const SfxPoolItem* pState = rView.GetSlotState(nWhich);
+ if (pState)
+ rSet.Put(SfxBoolItem(nWhich, ((const SfxBoolItem*)pState)->GetValue()));
+ else
+ rSet.DisableItem( nWhich );
+ break;
+ }
+ case SID_ATTR_CHAR_WORDLINEMODE: nEEWhich = EE_CHAR_WLM; break;
+ case SID_ATTR_CHAR_RELIEF : nEEWhich = EE_CHAR_RELIEF; break;
+ case SID_ATTR_CHAR_LANGUAGE : nEEWhich = EE_CHAR_LANGUAGE;break;
+ case SID_ATTR_CHAR_KERNING : nEEWhich = EE_CHAR_KERNING; break;
+ case SID_ATTR_CHAR_SCALEWIDTH: nEEWhich = EE_CHAR_FONTWIDTH;break;
+ case SID_ATTR_CHAR_AUTOKERN : nEEWhich = EE_CHAR_PAIRKERNING; break;
+ case SID_ATTR_CHAR_ESCAPEMENT: nEEWhich = EE_CHAR_ESCAPEMENT; break;
+ case FN_GROW_FONT_SIZE:
+ case FN_SHRINK_FONT_SIZE:
+ {
+ SfxItemPool* pEditPool = aEditAttr.GetPool()->GetSecondaryPool();
+ if( !pEditPool )
+ pEditPool = aEditAttr.GetPool();
+
+ SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONTHEIGHT, *pEditPool );
+ aSetItem.GetItemSet().Put( aEditAttr, false );
+ const SvxFontHeightItem* pSize( static_cast<const SvxFontHeightItem*>( aSetItem.GetItemOfScript( nScriptType ) ) );
+
+ if( !pSize )
+ rSet.DisableItem( nSlotId );
+ else
+ {
+ sal_uInt32 nSize = pSize->GetHeight();
+ if( nSize == nFontMaxSz )
+ rSet.DisableItem( FN_GROW_FONT_SIZE );
+ else if( nSize == nFontInc )
+ rSet.DisableItem( FN_SHRINK_FONT_SIZE );
+ }
+ }
+ }
+ if(nEEWhich)
+ rSet.Put(aEditAttr.Get(nEEWhich, sal_True), nWhich);
+
+ nWhich = aIter.NextWhich();
+ }
+}
+
+void SwDrawTextShell::ExecClpbrd(SfxRequest &rReq)
+{
+ if (!IsTextEdit()) // Otherwise crash!
+ return;
+
+ OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
+
+ ESelection aSel(pOLV->GetSelection());
+ const bool bCopy = (aSel.nStartPara != aSel.nEndPara) || (aSel.nStartPos != aSel.nEndPos);
+ sal_uInt16 nId = rReq.GetSlot();
+ switch( nId )
+ {
+ case SID_CUT:
+ if (bCopy)
+ pOLV->Cut();
+ return;
+
+ case SID_COPY:
+ if (bCopy)
+ pOLV->Copy();
+ return;
+
+ case SID_PASTE:
+ pOLV->PasteSpecial();
+ break;
+
+ default:
+ OSL_FAIL("wrong dispatcher");
+ return;
+ }
+}
+
+void SwDrawTextShell::StateClpbrd(SfxItemSet &rSet)
+{
+ if (!IsTextEdit()) // Otherwise crash!
+ return;
+
+ OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
+ ESelection aSel(pOLV->GetSelection());
+ const bool bCopy = (aSel.nStartPara != aSel.nEndPara) ||
+ (aSel.nStartPos != aSel.nEndPos);
+
+ SfxWhichIter aIter(rSet);
+ sal_uInt16 nWhich = aIter.FirstWhich();
+
+ while(nWhich)
+ {
+ switch(nWhich)
+ {
+ case SID_CUT:
+ case SID_COPY:
+ if( !bCopy )
+ rSet.DisableItem( nWhich );
+ break;
+
+ case SID_PASTE:
+ {
+ TransferableDataHelper aDataHelper(
+ TransferableDataHelper::CreateFromSystemClipboard( &GetView().GetEditWin() ) );
+
+ if( !aDataHelper.GetXTransferable().is()
+ || !SwTransferable::IsPaste( GetShell(), aDataHelper ) )
+ {
+ rSet.DisableItem( nWhich );
+ }
+ }
+ break;
+
+ case SID_PASTE_SPECIAL:
+ case SID_CLIPBOARD_FORMAT_ITEMS:
+ rSet.DisableItem( nWhich );
+ break;
+ }
+
+ nWhich = aIter.NextWhich();
+ }
+}
+
+// Hyperlink status
+
+void SwDrawTextShell::StateInsert(SfxItemSet &rSet)
+{
+ if (!IsTextEdit()) // Otherwise crash!
+ return;
+
+ OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
+ SfxWhichIter aIter(rSet);
+ sal_uInt16 nWhich = aIter.FirstWhich();
+
+ while(nWhich)
+ {
+ switch(nWhich)
+ {
+ case SID_HYPERLINK_GETLINK:
+ {
+ SvxHyperlinkItem aHLinkItem;
+ aHLinkItem.SetInsertMode(HLINK_FIELD);
+
+ const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection();
+
+ if (pFieldItem)
+ {
+ const SvxFieldData* pField = pFieldItem->GetField();
+
+ if (pField->ISA(SvxURLField))
+ {
+ aHLinkItem.SetName(((const SvxURLField*) pField)->GetRepresentation());
+ aHLinkItem.SetURL(((const SvxURLField*) pField)->GetURL());
+ aHLinkItem.SetTargetFrame(((const SvxURLField*) pField)->GetTargetFrame());
+ }
+ }
+ else
+ {
+ OUString sSel(pOLV->GetSelected());
+ sSel = sSel.copy(0, std::min<sal_Int32>(255, sSel.getLength()));
+ aHLinkItem.SetName(comphelper::string::stripEnd(sSel, ' '));
+ }
+
+ sal_uInt16 nHtmlMode = ::GetHtmlMode(GetView().GetDocShell());
+ aHLinkItem.SetInsertMode((SvxLinkInsertMode)(aHLinkItem.GetInsertMode() |
+ ((nHtmlMode & HTMLMODE_ON) != 0 ? HLINK_HTMLMODE : 0)));
+
+ rSet.Put(aHLinkItem);
+ }
+ break;
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/shells/drwtxtsh.cxx b/sw/source/core/uibase/shells/drwtxtsh.cxx
new file mode 100644
index 000000000000..350c4f62c06a
--- /dev/null
+++ b/sw/source/core/uibase/shells/drwtxtsh.cxx
@@ -0,0 +1,878 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <hintids.hxx>
+#include <i18nlangtag/lang.h>
+#include <svl/slstitm.hxx>
+#include <svl/cjkoptions.hxx>
+#include <editeng/fontitem.hxx>
+#include <editeng/langitem.hxx>
+#include <svx/svdview.hxx>
+#include <vcl/msgbox.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/objface.hxx>
+#include <svx/svdotext.hxx>
+#include <editeng/editeng.hxx>
+#include <editeng/editview.hxx>
+#include <editeng/eeitem.hxx>
+#include <editeng/scripttypeitem.hxx>
+#include <sfx2/bindings.hxx>
+#include <svx/fontwork.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/sidebar/EnumContext.hxx>
+#include <svl/whiter.hxx>
+#include <editeng/outliner.hxx>
+#include <editeng/editstat.hxx>
+#include <svx/svdoutl.hxx>
+#include <com/sun/star/i18n/TransliterationModules.hpp>
+#include <com/sun/star/i18n/TransliterationModulesExtra.hpp>
+#include <com/sun/star/i18n/TextConversionOption.hpp>
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <swtypes.hxx>
+#include <view.hxx>
+#include <wrtsh.hxx>
+#include <viewopt.hxx>
+#include <initui.hxx>
+#include <drwtxtsh.hxx>
+#include <swundo.hxx>
+#include <breakit.hxx>
+
+#include <cmdid.h>
+#include <helpid.h>
+#include <globals.hrc>
+#include <shells.hrc>
+
+#define SwDrawTextShell
+#include <sfx2/msg.hxx>
+#include <swslots.hxx>
+#include <popup.hrc>
+#include <uitool.hxx>
+#include <wview.hxx>
+#include <swmodule.hxx>
+#include <svx/dialogs.hrc>
+#include <svx/svdoashp.hxx>
+#include <svx/svxdlg.hxx>
+#include <svx/xtable.hxx>
+#include <cppuhelper/bootstrap.hxx>
+#include "swabstdlg.hxx"
+#include "misc.hrc"
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::i18n;
+
+SFX_IMPL_INTERFACE(SwDrawTextShell, SfxShell, SW_RES(STR_SHELLNAME_DRAW_TEXT))
+{
+ SFX_POPUPMENU_REGISTRATION(SW_RES(MN_DRWTXT_POPUPMENU));
+ SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_DRAW_TEXT_TOOLBOX));
+ SFX_CHILDWINDOW_REGISTRATION(SvxFontWorkChildWindow::GetChildWindowId());
+}
+
+TYPEINIT1(SwDrawTextShell,SfxShell)
+
+void SwDrawTextShell::Init()
+{
+ SwWrtShell &rSh = GetShell();
+ pSdrView = rSh.GetDrawView();
+ SdrOutliner * pOutliner = pSdrView->GetTextEditOutliner();
+ //#97471# mouse click _and_ key input at the same time
+ if( !pOutliner )
+ return ;
+ OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
+ sal_uLong nCtrl = pOutliner->GetControlWord();
+ nCtrl |= EE_CNTRL_AUTOCORRECT;
+
+ SetUndoManager(&pOutliner->GetUndoManager());
+
+ // Now let's try an AutoSpell.
+
+ const SwViewOption* pVOpt = rSh.GetViewOptions();
+ if(pVOpt->IsOnlineSpell())
+ {
+ nCtrl |= EE_CNTRL_ONLINESPELLING|EE_CNTRL_ALLOWBIGOBJS;
+ }
+ else
+ nCtrl &= ~(EE_CNTRL_ONLINESPELLING);
+
+ pOutliner->SetControlWord(nCtrl);
+ pOLV->ShowCursor();
+}
+
+SwDrawTextShell::SwDrawTextShell(SwView &rV) :
+ SfxShell(&rV),
+ rView(rV)
+{
+ SwWrtShell &rSh = GetShell();
+ SetPool(rSh.GetAttrPool().GetSecondaryPool());
+
+ Init();
+
+ rSh.NoEdit(true);
+ SetName(OUString("ObjectText"));
+ SetHelpId(SW_DRWTXTSHELL);
+ SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_DrawText));
+}
+
+SwDrawTextShell::~SwDrawTextShell()
+{
+ if ( GetView().GetCurShell() == this )
+ rView.ResetSubShell();
+}
+
+SwWrtShell& SwDrawTextShell::GetShell()
+{
+ return rView.GetWrtShell();
+}
+
+// Disable slots with this status method
+
+void SwDrawTextShell::StateDisableItems( SfxItemSet &rSet )
+{
+ SfxWhichIter aIter(rSet);
+ sal_uInt16 nWhich = aIter.FirstWhich();
+
+ while (nWhich)
+ {
+ rSet.DisableItem( nWhich );
+ nWhich = aIter.NextWhich();
+ }
+}
+
+void SwDrawTextShell::SetAttrToMarked(const SfxItemSet& rAttr)
+{
+ Rectangle aNullRect;
+ OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
+ Rectangle aOutRect = pOLV->GetOutputArea();
+
+ if (aNullRect != aOutRect)
+ {
+ GetShell().GetDrawView()->SetAttributes(rAttr);
+// Init();
+ }
+}
+
+sal_Bool SwDrawTextShell::IsTextEdit()
+{
+ return pSdrView->IsTextEdit();
+}
+
+void SwDrawTextShell::ExecFontWork(SfxRequest& rReq)
+{
+ SwWrtShell &rSh = GetShell();
+ FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, &rSh.GetView()));
+ SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)) );
+ SfxViewFrame* pVFrame = GetView().GetViewFrame();
+ if ( rReq.GetArgs() )
+ {
+ pVFrame->SetChildWindow(SvxFontWorkChildWindow::GetChildWindowId(),
+ ((const SfxBoolItem&) (rReq.GetArgs()->
+ Get(SID_FONTWORK))).GetValue());
+ }
+ else
+ pVFrame->ToggleChildWindow(SvxFontWorkChildWindow::GetChildWindowId());
+
+ pVFrame->GetBindings().Invalidate(SID_FONTWORK);
+}
+
+void SwDrawTextShell::StateFontWork(SfxItemSet& rSet)
+{
+ const sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId();
+ rSet.Put(SfxBoolItem(SID_FONTWORK, GetView().GetViewFrame()->HasChildWindow(nId)));
+}
+
+// Edit SfxRequests for FontWork
+
+void SwDrawTextShell::ExecFormText(SfxRequest& rReq)
+{
+ SwWrtShell &rSh = GetShell();
+ SdrView* pDrView = rSh.GetDrawView();
+
+ const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
+
+ if ( rMarkList.GetMarkCount() == 1 && rReq.GetArgs() )
+ {
+ const SfxItemSet& rSet = *rReq.GetArgs();
+
+ if ( pDrView->IsTextEdit() )
+ {
+ //#111733# Sometimes SdrEndTextEdit() initiates the change in selection and
+ // 'this' is not valid anymore
+ SwView& rTempView = GetView();
+ pDrView->SdrEndTextEdit(sal_True);
+ //this removes the current shell from the dispatcher stack!!
+ rTempView.AttrChangedNotify(&rSh);
+ }
+
+ pDrView->SetAttributes(rSet);
+ }
+
+}
+
+// Return Status values back to FontWork
+
+void SwDrawTextShell::GetFormTextState(SfxItemSet& rSet)
+{
+ SwWrtShell &rSh = GetShell();
+ SdrView* pDrView = rSh.GetDrawView();
+ const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
+ const SdrObject* pObj = NULL;
+ SvxFontWorkDialog* pDlg = NULL;
+
+ const sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId();
+
+ SfxViewFrame* pVFrame = GetView().GetViewFrame();
+ if ( pVFrame->HasChildWindow(nId) )
+ pDlg = (SvxFontWorkDialog*)(pVFrame->GetChildWindow(nId)->GetWindow());
+
+ if ( rMarkList.GetMarkCount() == 1 )
+ pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+
+ const SdrTextObj* pTextObj = dynamic_cast< const SdrTextObj* >(pObj);
+ const bool bDeactivate(
+ !pObj ||
+ !pTextObj ||
+ !pTextObj->HasText() ||
+ dynamic_cast< const SdrObjCustomShape* >(pObj)); // #121538# no FontWork for CustomShapes
+
+ if (bDeactivate)
+ {
+ rSet.DisableItem(XATTR_FORMTXTSTYLE);
+ rSet.DisableItem(XATTR_FORMTXTADJUST);
+ rSet.DisableItem(XATTR_FORMTXTDISTANCE);
+ rSet.DisableItem(XATTR_FORMTXTSTART);
+ rSet.DisableItem(XATTR_FORMTXTMIRROR);
+ 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 )
+ pDlg->SetColorList(XColorList::GetStdColorList());
+
+ pDrView->GetAttributes( rSet );
+ }
+}
+
+void SwDrawTextShell::ExecDrawLingu(SfxRequest &rReq)
+{
+ SwWrtShell &rSh = GetShell();
+ OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
+ if( rSh.GetDrawView()->GetMarkedObjectList().GetMarkCount() )
+ {
+ switch(rReq.GetSlot())
+ {
+ case SID_THESAURUS:
+ pOLV->StartThesaurus();
+ break;
+
+ case SID_HANGUL_HANJA_CONVERSION:
+ pOLV->StartTextConversion( LANGUAGE_KOREAN, LANGUAGE_KOREAN, NULL,
+ i18n::TextConversionOption::CHARACTER_BY_CHARACTER, true, false );
+ 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(
+ OUString("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 = "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( "IsDirectionToSimplified" ) >>= bToSimplified;
+ xProp->getPropertyValue( "IsUseCharacterVariants" ) >>= bUseVariants;
+ xProp->getPropertyValue( "IsTranslateCommonTerms" ) >>= bCommonTerms;
+ }
+ catch (const Exception&)
+ {
+ }
+ }
+
+ //execute translation
+ sal_Int16 nSourceLang = bToSimplified ? LANGUAGE_CHINESE_TRADITIONAL : LANGUAGE_CHINESE_SIMPLIFIED;
+ sal_Int16 nTargetLang = bToSimplified ? LANGUAGE_CHINESE_SIMPLIFIED : LANGUAGE_CHINESE_TRADITIONAL;
+ sal_Int32 nOptions = bUseVariants ? i18n::TextConversionOption::USE_CHARACTER_VARIANTS : 0;
+ if( !bCommonTerms )
+ nOptions = nOptions | i18n::TextConversionOption::CHARACTER_BY_CHARACTER;
+
+ Font aTargetFont = pOLV->GetWindow()->GetDefaultFont( DEFAULTFONT_CJK_TEXT,
+ nTargetLang, DEFAULTFONT_FLAGS_ONLYONE );
+
+ pOLV->StartTextConversion( nSourceLang, nTargetLang, &aTargetFont, nOptions, false, false );
+ }
+ }
+ Reference< lang::XComponent > xComponent( xDialog, UNO_QUERY );
+ if( xComponent.is() )
+ xComponent->dispose();
+ }
+ }
+ }
+ break;
+
+ default:
+ OSL_ENSURE(!this, "unexpected slot-id");
+ }
+ }
+}
+
+void SwDrawTextShell::ExecDraw(SfxRequest &rReq)
+{
+ SwWrtShell &rSh = GetShell();
+ pSdrView = rSh.GetDrawView();
+ OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
+
+ switch (rReq.GetSlot())
+ {
+ case FN_INSERT_SOFT_HYPHEN:
+ case FN_INSERT_HARDHYPHEN:
+ case FN_INSERT_HARD_SPACE:
+ case SID_INSERT_RLM :
+ case SID_INSERT_LRM :
+ case SID_INSERT_ZWNBSP :
+ case SID_INSERT_ZWSP:
+ {
+ sal_Unicode cIns = 0;
+ switch(rReq.GetSlot())
+ {
+ case FN_INSERT_SOFT_HYPHEN: cIns = CHAR_SOFTHYPHEN; break;
+ case FN_INSERT_HARDHYPHEN: cIns = CHAR_HARDHYPHEN; break;
+ case FN_INSERT_HARD_SPACE: cIns = CHAR_HARDBLANK; break;
+ case SID_INSERT_RLM : cIns = CHAR_RLM ; break;
+ case SID_INSERT_LRM : cIns = CHAR_LRM ; break;
+ case SID_INSERT_ZWSP : cIns = CHAR_ZWSP ; break;
+ case SID_INSERT_ZWNBSP: cIns = CHAR_ZWNBSP; break;
+ }
+ pOLV->InsertText( OUString(cIns));
+ rReq.Done();
+ }
+ break;
+ case SID_CHARMAP:
+ { // Insert special character
+ InsertSymbol(rReq);
+ break;
+ }
+ case FN_INSERT_STRING:
+ {
+ const SfxItemSet *pNewAttrs = rReq.GetArgs();
+ sal_uInt16 nSlot = rReq.GetSlot();
+ const SfxPoolItem* pItem = 0;
+ if(pNewAttrs)
+ {
+ pNewAttrs->GetItemState(nSlot, false, &pItem );
+ pOLV->InsertText(((const SfxStringItem *)pItem)->GetValue());
+ }
+ break;
+ }
+
+ case SID_SELECTALL:
+ {
+ SdrOutliner * pOutliner = pSdrView->GetTextEditOutliner();
+ if(pOutliner)
+ {
+ sal_Int32 nParaCount = pOutliner->GetParagraphCount();
+ if (nParaCount > 0)
+ pOLV->SelectRange(0L, nParaCount );
+ }
+ }
+ break;
+
+ case FN_FORMAT_RESET: // delete hard text attributes
+ {
+ pOLV->RemoveAttribsKeepLanguages( true );
+ pOLV->GetEditView().GetEditEngine()->RemoveFields(true);
+ rReq.Done();
+ }
+ break;
+
+ case FN_ESCAPE:
+ if (pSdrView->IsTextEdit())
+ {
+ // Shell switch!
+ rSh.EndTextEdit();
+ SwView& rTempView = rSh.GetView();
+ rTempView.ExitDraw();
+ rSh.Edit();
+ return;
+ }
+ break;
+ case FN_DRAWTEXT_ATTR_DLG:
+ {
+ SfxItemSet aNewAttr( pSdrView->GetModel()->GetItemPool() );
+ pSdrView->GetAttributes( aNewAttr );
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ if ( pFact )
+ {
+ SfxAbstractTabDialog *pDlg = pFact->CreateTextTabDialog(
+ &(GetView().GetViewFrame()->GetWindow()),
+ &aNewAttr, pSdrView );
+ sal_uInt16 nResult = pDlg->Execute();
+
+ if (nResult == RET_OK)
+ {
+ if (pSdrView->AreObjectsMarked())
+ {
+ pSdrView->SetAttributes(*pDlg->GetOutputItemSet());
+ rReq.Done(*(pDlg->GetOutputItemSet()));
+ }
+ }
+
+ delete( pDlg );
+ }
+ }
+ break;
+ case SID_TABLE_VERT_NONE:
+ case SID_TABLE_VERT_CENTER:
+ case SID_TABLE_VERT_BOTTOM:
+ {
+ sal_uInt16 nSId = rReq.GetSlot();
+ if (pSdrView->AreObjectsMarked())
+ {
+ SdrTextVertAdjust eTVA = SDRTEXTVERTADJUST_TOP;
+ if (nSId == SID_TABLE_VERT_CENTER)
+ eTVA = SDRTEXTVERTADJUST_CENTER;
+ else if (nSId == SID_TABLE_VERT_BOTTOM)
+ eTVA = SDRTEXTVERTADJUST_BOTTOM;
+
+ SfxItemSet aNewAttr( pSdrView->GetModel()->GetItemPool() );
+ pSdrView->GetAttributes( aNewAttr );
+ aNewAttr.Put(SdrTextVertAdjustItem(eTVA));
+ pSdrView->SetAttributes(aNewAttr);
+ rReq.Done();
+ }
+
+ }
+ break;
+
+ default:
+ OSL_ENSURE(!this, "unexpected slot-id");
+ return;
+ }
+
+ GetView().GetViewFrame()->GetBindings().InvalidateAll(sal_False);
+
+ if (IsTextEdit() && pOLV->GetOutliner()->IsModified())
+ rSh.SetModified();
+}
+
+// Execute undo
+
+void SwDrawTextShell::ExecUndo(SfxRequest &rReq)
+{
+ if( IsTextEdit() )
+ {
+ bool bCallBase = true;
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ if( pArgs )
+ {
+ sal_uInt16 nId = rReq.GetSlot(), nCnt = 1;
+ const SfxPoolItem* pItem;
+ switch( nId )
+ {
+ case SID_UNDO:
+ case SID_REDO:
+ if( SFX_ITEM_SET == pArgs->GetItemState( nId, false, &pItem ) &&
+ 1 < (nCnt = ((SfxUInt16Item*)pItem)->GetValue()) )
+ {
+ // then we make by ourself.
+ ::svl::IUndoManager* pUndoManager = GetUndoManager();
+ if( pUndoManager )
+ {
+ if( SID_UNDO == nId )
+ while( nCnt-- )
+ pUndoManager->Undo();
+ else
+ while( nCnt-- )
+ pUndoManager->Redo();
+ }
+ bCallBase = false;
+ GetView().GetViewFrame()->GetBindings().InvalidateAll(sal_False);
+ }
+ break;
+ }
+ }
+ if( bCallBase )
+ {
+ SfxViewFrame *pSfxViewFrame = GetView().GetViewFrame();
+ pSfxViewFrame->ExecuteSlot(rReq, pSfxViewFrame->GetInterface());
+ }
+ }
+}
+
+// State of undo
+
+void SwDrawTextShell::StateUndo(SfxItemSet &rSet)
+{
+ if ( !IsTextEdit() )
+ return;
+
+ SfxViewFrame *pSfxViewFrame = GetView().GetViewFrame();
+ SfxWhichIter aIter(rSet);
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ while( nWhich )
+ {
+ switch ( nWhich )
+ {
+ case SID_GETUNDOSTRINGS:
+ case SID_GETREDOSTRINGS:
+ {
+ ::svl::IUndoManager* pUndoManager = GetUndoManager();
+ if( pUndoManager )
+ {
+ OUString (::svl::IUndoManager:: *fnGetComment)( size_t, bool const ) const;
+
+ sal_uInt16 nCount;
+ if( SID_GETUNDOSTRINGS == nWhich )
+ {
+ nCount = pUndoManager->GetUndoActionCount();
+ fnGetComment = &::svl::IUndoManager::GetUndoActionComment;
+ }
+ else
+ {
+ nCount = pUndoManager->GetRedoActionCount();
+ fnGetComment = &::svl::IUndoManager::GetRedoActionComment;
+ }
+ if( nCount )
+ {
+ OUString sList;
+ for( sal_uInt16 n = 0; n < nCount; ++n )
+ sList += (pUndoManager->*fnGetComment)( n, ::svl::IUndoManager::TopLevel ) + "\n";
+
+ SfxStringListItem aItem( nWhich );
+ aItem.SetString( sList );
+ rSet.Put( aItem );
+ }
+ }
+ else
+ rSet.DisableItem( nWhich );
+ }
+ break;
+
+ default:
+ pSfxViewFrame->GetSlotState( nWhich,
+ pSfxViewFrame->GetInterface(), &rSet );
+ }
+
+ nWhich = aIter.NextWhich();
+ }
+}
+
+void SwDrawTextShell::ExecTransliteration( SfxRequest & rReq )
+{
+ if (!pSdrView)
+ return;
+
+ using namespace i18n;
+
+ sal_uInt32 nMode = 0;
+
+ switch( rReq.GetSlot() )
+ {
+ case SID_TRANSLITERATE_SENTENCE_CASE:
+ nMode = TransliterationModulesExtra::SENTENCE_CASE;
+ break;
+ case SID_TRANSLITERATE_TITLE_CASE:
+ nMode = TransliterationModulesExtra::TITLE_CASE;
+ break;
+ case SID_TRANSLITERATE_TOGGLE_CASE:
+ nMode = TransliterationModulesExtra::TOGGLE_CASE;
+ break;
+ case SID_TRANSLITERATE_UPPER:
+ nMode = TransliterationModules_LOWERCASE_UPPERCASE;
+ break;
+ case SID_TRANSLITERATE_LOWER:
+ nMode = TransliterationModules_UPPERCASE_LOWERCASE;
+ break;
+
+ case SID_TRANSLITERATE_HALFWIDTH:
+ nMode = TransliterationModules_FULLWIDTH_HALFWIDTH;
+ break;
+ case SID_TRANSLITERATE_FULLWIDTH:
+ nMode = TransliterationModules_HALFWIDTH_FULLWIDTH;
+ break;
+
+ case SID_TRANSLITERATE_HIRAGANA:
+ nMode = TransliterationModules_KATAKANA_HIRAGANA;
+ break;
+ case SID_TRANSLITERATE_KATAGANA:
+ nMode = TransliterationModules_HIRAGANA_KATAKANA;
+ break;
+
+ default:
+ OSL_ENSURE(!this, "wrong dispatcher");
+ }
+
+ if( nMode )
+ {
+ OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
+
+ if (!pOLV)
+ return;
+
+ pOLV->TransliterateText( nMode );
+ }
+}
+
+void SwDrawTextShell::ExecRotateTransliteration( SfxRequest & rReq )
+{
+ if( rReq.GetSlot() == SID_TRANSLITERATE_ROTATE_CASE )
+ {
+ if (!pSdrView)
+ return;
+
+ OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
+
+ if (!pOLV)
+ return;
+
+ pOLV->TransliterateText( m_aRotateCase.getNextMode() );
+ }
+}
+
+// Insert special character (see SDraw: FUBULLET.CXX)
+
+void SwDrawTextShell::InsertSymbol(SfxRequest& rReq)
+{
+ OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
+ if(!pOLV)
+ return;
+ const SfxItemSet *pArgs = rReq.GetArgs();
+ const SfxPoolItem* pItem = 0;
+ if( pArgs )
+ pArgs->GetItemState(GetPool().GetWhich(SID_CHARMAP), false, &pItem);
+
+ OUString sSym;
+ OUString sFontName;
+ if ( pItem )
+ {
+ sSym = ((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 )
+ sFontName = pFontItem->GetValue();
+ }
+
+ SfxItemSet aSet(pOLV->GetAttribs());
+ sal_uInt16 nScript = pOLV->GetSelectedScriptType();
+ SvxFontItem aSetDlgFont( RES_CHRATR_FONT );
+ {
+ SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONT, *aSet.GetPool() );
+ aSetItem.GetItemSet().Put( aSet, false );
+ const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScript );
+ if( pI )
+ aSetDlgFont = *(SvxFontItem*)pI;
+ else
+ aSetDlgFont = (SvxFontItem&)aSet.Get( GetWhichOfScript(
+ SID_ATTR_CHAR_FONT,
+ GetI18NScriptTypeOfLanguage( (sal_uInt16)GetAppLanguage() ) ));
+ if (sFontName.isEmpty())
+ sFontName = aSetDlgFont.GetFamilyName();
+ }
+
+ Font aFont(sFontName, Size(1,1));
+ if(sSym.isEmpty())
+ {
+ SfxAllItemSet aAllSet( GetPool() );
+ aAllSet.Put( SfxBoolItem( FN_PARAM_1, false ) );
+
+ SwViewOption aOpt(*rView.GetWrtShell().GetViewOptions());
+ OUString sSymbolFont = aOpt.GetSymbolFont();
+ if( !sSymbolFont.isEmpty() )
+ aAllSet.Put( SfxStringItem( SID_FONT_NAME, sSymbolFont ) );
+ else
+ aAllSet.Put( SfxStringItem( SID_FONT_NAME, aSetDlgFont.GetFamilyName() ) );
+
+ // If character is selected, it can be shown
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( rView.GetWindow(), aAllSet,
+ rView.GetViewFrame()->GetFrame().GetFrameInterface(), RID_SVXDLG_CHARMAP );
+ sal_uInt16 nResult = pDlg->Execute();
+ if( nResult == RET_OK )
+ {
+ SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pCItem, SfxStringItem, SID_CHARMAP, false );
+ SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pFontItem, SvxFontItem, SID_ATTR_CHAR_FONT, false );
+ if ( pFontItem )
+ {
+ aFont.SetName( pFontItem->GetFamilyName() );
+ aFont.SetStyleName( pFontItem->GetStyleName() );
+ aFont.SetCharSet( pFontItem->GetCharSet() );
+ aFont.SetPitch( pFontItem->GetPitch() );
+ }
+
+ if ( pCItem )
+ {
+ sSym = pCItem->GetValue();
+ aOpt.SetSymbolFont(aFont.GetName());
+ SW_MOD()->ApplyUsrPref(aOpt, &rView);
+ }
+ }
+
+ delete( pDlg );
+ }
+
+ if( !sSym.isEmpty() )
+ {
+ // do not flicker
+ pOLV->HideCursor();
+ SdrOutliner * pOutliner = pSdrView->GetTextEditOutliner();
+ pOutliner->SetUpdateMode(false);
+
+ SfxItemSet aOldSet( pOLV->GetAttribs() );
+ SfxItemSet aFontSet( *aOldSet.GetPool(),
+ EE_CHAR_FONTINFO, EE_CHAR_FONTINFO,
+ EE_CHAR_FONTINFO_CJK, EE_CHAR_FONTINFO_CJK,
+ EE_CHAR_FONTINFO_CTL, EE_CHAR_FONTINFO_CTL,
+ 0 );
+ aFontSet.Set( aOldSet );
+
+ // Insert string
+ pOLV->InsertText( sSym );
+
+ // assign attributes (Set font)
+ SfxItemSet aFontAttribSet( *aFontSet.GetPool(), aFontSet.GetRanges() );
+ SvxFontItem aFontItem (aFont.GetFamily(), aFont.GetName(),
+ aFont.GetStyleName(), aFont.GetPitch(),
+ aFont.GetCharSet(),
+ EE_CHAR_FONTINFO );
+ nScript = g_pBreakIt->GetAllScriptsOfText( sSym );
+ if( SCRIPTTYPE_LATIN & nScript )
+ aFontAttribSet.Put( aFontItem, EE_CHAR_FONTINFO );
+ if( SCRIPTTYPE_ASIAN & nScript )
+ aFontAttribSet.Put( aFontItem, EE_CHAR_FONTINFO_CJK );
+ if( SCRIPTTYPE_COMPLEX & nScript )
+ aFontAttribSet.Put( aFontItem, EE_CHAR_FONTINFO_CTL );
+ pOLV->SetAttribs(aFontAttribSet);
+
+ // Remove selection
+ ESelection aSel(pOLV->GetSelection());
+ aSel.nStartPara = aSel.nEndPara;
+ aSel.nStartPos = aSel.nEndPos;
+ pOLV->SetSelection(aSel);
+
+ // Restore old font
+ pOLV->SetAttribs( aFontSet );
+
+ // From now on show again
+ pOutliner->SetUpdateMode(true);
+ pOLV->ShowCursor();
+
+ rReq.AppendItem( SfxStringItem( GetPool().GetWhich(SID_CHARMAP), sSym ) );
+ if(!aFont.GetName().isEmpty())
+ rReq.AppendItem( SfxStringItem( SID_ATTR_SPECIALCHAR, aFont.GetName() ) );
+ rReq.Done();
+ }
+}
+
+::svl::IUndoManager* SwDrawTextShell::GetUndoManager()
+{
+ SwWrtShell &rSh = GetShell();
+ pSdrView = rSh.GetDrawView();
+ SdrOutliner * pOutliner = pSdrView->GetTextEditOutliner();
+ return &pOutliner->GetUndoManager();
+}
+
+void SwDrawTextShell::GetStatePropPanelAttr(SfxItemSet &rSet)
+{
+ SfxWhichIter aIter( rSet );
+ sal_uInt16 nWhich = aIter.FirstWhich();
+
+ SwWrtShell &rSh = GetShell();
+ pSdrView = rSh.GetDrawView();
+
+ SfxItemSet aAttrs( pSdrView->GetModel()->GetItemPool() );
+ pSdrView->GetAttributes( aAttrs );
+
+ while ( nWhich )
+ {
+ sal_uInt16 nSlotId = SfxItemPool::IsWhich(nWhich)
+ ? GetPool().GetSlotId(nWhich)
+ : nWhich;
+ switch ( nSlotId )
+ {
+ case SID_TABLE_VERT_NONE:
+ case SID_TABLE_VERT_CENTER:
+ case SID_TABLE_VERT_BOTTOM:
+ sal_Bool bContour = sal_False;
+ SfxItemState eConState = aAttrs.GetItemState( SDRATTR_TEXT_CONTOURFRAME );
+ if( eConState != SFX_ITEM_DONTCARE )
+ {
+ bContour = ( ( const SdrTextContourFrameItem& )aAttrs.Get( SDRATTR_TEXT_CONTOURFRAME ) ).GetValue();
+ }
+ if (bContour) break;
+
+ SfxItemState eVState = aAttrs.GetItemState( SDRATTR_TEXT_VERTADJUST );
+ //SfxItemState eHState = aAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST );
+
+ //if(SFX_ITEM_DONTCARE != eVState && SFX_ITEM_DONTCARE != eHState)
+ if(SFX_ITEM_DONTCARE != eVState)
+ {
+ SdrTextVertAdjust eTVA = (SdrTextVertAdjust)((const SdrTextVertAdjustItem&)aAttrs.Get(SDRATTR_TEXT_VERTADJUST)).GetValue();
+ sal_Bool bSet = (nSlotId == SID_TABLE_VERT_NONE && eTVA == SDRTEXTVERTADJUST_TOP) ||
+ (nSlotId == SID_TABLE_VERT_CENTER && eTVA == SDRTEXTVERTADJUST_CENTER) ||
+ (nSlotId == SID_TABLE_VERT_BOTTOM && eTVA == SDRTEXTVERTADJUST_BOTTOM);
+ rSet.Put(SfxBoolItem(nSlotId, bSet));
+ }
+ else
+ {
+ rSet.Put(SfxBoolItem(nSlotId, false));
+ }
+ break;
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/shells/frmsh.cxx b/sw/source/core/uibase/shells/frmsh.cxx
new file mode 100644
index 000000000000..f9ed0949a836
--- /dev/null
+++ b/sw/source/core/uibase/shells/frmsh.cxx
@@ -0,0 +1,1185 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <hintids.hxx>
+#include <svl/whiter.hxx>
+#include <svtools/imapobj.hxx>
+#include <svtools/miscopt.hxx>
+#include <svl/srchitem.hxx>
+#include <svtools/imap.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <basic/sbstar.hxx>
+#include <svl/rectitem.hxx>
+#include <svl/ptitem.hxx>
+#include <svl/stritem.hxx>
+#include <svl/intitem.hxx>
+#include <svl/eitem.hxx>
+#include <editeng/colritem.hxx>
+#include <editeng/lineitem.hxx>
+#include <editeng/boxitem.hxx>
+#include <editeng/protitem.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/objface.hxx>
+#include <sfx2/sidebar/EnumContext.hxx>
+#include <svx/hlnkitem.hxx>
+// #i73249#
+#include <svx/svdview.hxx>
+#include <vcl/msgbox.hxx>
+#include <tools/diagnose_ex.h>
+
+#include <doc.hxx>
+#include <fmturl.hxx>
+#include <fmtclds.hxx>
+#include <fmtcnct.hxx>
+#include <swmodule.hxx>
+#include <wrtsh.hxx>
+#include <wview.hxx>
+#include <frmatr.hxx>
+#include <uitool.hxx>
+#include <frmfmt.hxx>
+#include <frmsh.hxx>
+#include <frmmgr.hxx>
+#include <frmdlg.hxx>
+#include <swevent.hxx>
+#include <usrpref.hxx>
+#include <edtwin.hxx>
+#include <swdtflvr.hxx>
+#include <swwait.hxx>
+#include <docstat.hxx>
+#include <IDocumentStatistics.hxx>
+
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/ui/dialogs/XSLTFilterDialog.hpp>
+
+#include <helpid.h>
+#include <cmdid.h>
+#include <cfgitems.hxx>
+#include <globals.hrc>
+#include <popup.hrc>
+#include <shells.hrc>
+#include "swabstdlg.hxx"
+#include "misc.hrc"
+// #i73249#
+#include <svx/dialogs.hrc>
+#include <wordcountdialog.hxx>
+
+using ::editeng::SvxBorderLine;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+// Prototypes
+static void lcl_FrmGetMaxLineWidth(const SvxBorderLine* pBorderLine, SvxBorderLine& rBorderLine);
+static const SwFrmFmt* lcl_GetFrmFmtByName(SwWrtShell& rSh, const OUString& rName)
+{
+ sal_uInt16 nCount = rSh.GetFlyCount(FLYCNTTYPE_FRM);
+ for( sal_uInt16 i = 0; i < nCount; i++)
+ {
+ const SwFrmFmt* pFmt = rSh.GetFlyNum(i, FLYCNTTYPE_FRM);
+ if(pFmt->GetName() == rName)
+ return pFmt;
+ }
+ return 0;
+}
+
+#define SwFrameShell
+#include <sfx2/msg.hxx>
+#include "swslots.hxx"
+
+SFX_IMPL_INTERFACE(SwFrameShell, SwBaseShell, SW_RES(STR_SHELLNAME_FRAME))
+{
+ SFX_POPUPMENU_REGISTRATION(SW_RES(MN_FRM_POPUPMENU));
+ SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_FRAME_TOOLBOX));
+}
+
+void SwFrameShell::Execute(SfxRequest &rReq)
+{
+ //First those who do not need FrmMgr.
+ SwWrtShell &rSh = GetShell();
+ bool bMore = false;
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ const SfxPoolItem* pItem;
+ sal_uInt16 nSlot = rReq.GetSlot();
+
+ switch ( nSlot )
+ {
+ case FN_FRAME_TO_ANCHOR:
+ if ( rSh.IsFrmSelected() )
+ {
+ rSh.GotoFlyAnchor();
+ rSh.EnterStdMode();
+ rSh.CallChgLnk();
+ }
+ break;
+ case SID_FRAME_TO_TOP:
+ rSh.SelectionToTop();
+ break;
+
+ case SID_FRAME_TO_BOTTOM:
+ rSh.SelectionToBottom();
+ break;
+
+ case FN_FRAME_UP:
+ rSh.SelectionToTop( sal_False );
+ break;
+
+ case FN_FRAME_DOWN:
+ rSh.SelectionToBottom( sal_False );
+ break;
+ case FN_INSERT_FRAME:
+ if (!pArgs)
+ {
+ // Frame already exists, open frame dialog for editing.
+ SfxStringItem aDefPage(FN_FORMAT_FRAME_DLG, "columns");
+ rSh.GetView().GetViewFrame()->GetDispatcher()->Execute( FN_FORMAT_FRAME_DLG,
+ SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD,
+ &aDefPage, 0L );
+
+ }
+ else
+ {
+ // Frame already exists, only the number of columns will be changed.
+ sal_uInt16 nCols = 1;
+ if(pArgs->GetItemState(SID_ATTR_COLUMNS, false, &pItem) == SFX_ITEM_SET)
+ nCols = ((SfxUInt16Item *)pItem)->GetValue();
+
+ SfxItemSet aSet(GetPool(),RES_COL,RES_COL);
+ rSh.GetFlyFrmAttr( aSet );
+ SwFmtCol aCol((const SwFmtCol&)aSet.Get(RES_COL));
+ // GutterWidth will not always passed, hence get firstly
+ // (see view2: Execute on this slot)
+ sal_uInt16 nGutterWidth = aCol.GetGutterWidth();
+ if(!nCols )
+ nCols++;
+ aCol.Init(nCols, nGutterWidth, aCol.GetWishWidth());
+ aSet.Put(aCol);
+ // Template AutoUpdate
+ SwFrmFmt* pFmt = rSh.GetCurFrmFmt();
+ if(pFmt && pFmt->IsAutoUpdateFmt())
+ {
+ rSh.AutoUpdateFrame(pFmt, aSet);
+ }
+ else
+ {
+ rSh.StartAllAction();
+ rSh.SetFlyFrmAttr( aSet );
+ rSh.SetModified();
+ rSh.EndAllAction();
+ }
+
+ }
+ return;
+
+ case SID_HYPERLINK_SETLINK:
+ {
+ if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(SID_HYPERLINK_SETLINK, false, &pItem))
+ {
+ const SvxHyperlinkItem& rHLinkItem = *(const SvxHyperlinkItem *)pItem;
+ const OUString& rURL = rHLinkItem.GetURL();
+ const OUString& rTarget = rHLinkItem.GetTargetFrame();
+
+ SfxItemSet aSet( rSh.GetAttrPool(), RES_URL, RES_URL );
+ rSh.GetFlyFrmAttr( aSet );
+ SwFmtURL aURL( (SwFmtURL&)aSet.Get( RES_URL ) );
+
+ OUString sOldName(rHLinkItem.GetName().toAsciiUpperCase());
+ OUString sFlyName(rSh.GetFlyName().toAsciiUpperCase());
+ if (sOldName != sFlyName)
+ {
+ OUString sName(sOldName);
+ sal_uInt16 i = 1;
+ while (rSh.FindFlyByName(sName))
+ {
+ sName = sOldName;
+ sName += "_";
+ sName += OUString::number(i++);
+ }
+ rSh.SetFlyName(sName);
+ }
+ aURL.SetURL( rURL, false );
+ aURL.SetTargetFrameName(rTarget);
+
+ aSet.Put( aURL );
+ rSh.SetFlyFrmAttr( aSet );
+ }
+ }
+ break;
+
+ case FN_FRAME_CHAIN:
+ rSh.GetView().GetEditWin().SetChainMode( !rSh.GetView().GetEditWin().IsChainMode() );
+ break;
+
+ case FN_FRAME_UNCHAIN:
+ rSh.Unchain( (SwFrmFmt&)*rSh.GetFlyFrmFmt() );
+ GetView().GetViewFrame()->GetBindings().Invalidate(FN_FRAME_CHAIN);
+ break;
+ case FN_FORMAT_FOOTNOTE_DLG:
+ {
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+
+ VclAbstractDialog* pDlg = pFact->CreateSwFootNoteOptionDlg(GetView().GetWindow(), GetView().GetWrtShell());
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ pDlg->Execute();
+ delete pDlg;
+ break;
+ }
+ case FN_NUMBERING_OUTLINE_DLG:
+ {
+ SfxItemSet aTmp(GetPool(), FN_PARAM_1, FN_PARAM_1);
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "Dialogdiet fail!");
+ SfxAbstractTabDialog* pDlg = pFact->CreateSwTabDialog( DLG_TAB_OUTLINE,
+ GetView().GetWindow(), &aTmp, GetView().GetWrtShell());
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ pDlg->Execute();
+ delete pDlg;
+ rReq.Done();
+ break;
+ }
+ case SID_OPEN_XML_FILTERSETTINGS:
+ {
+ try
+ {
+ uno::Reference < ui::dialogs::XExecutableDialog > xDialog = ui::dialogs::XSLTFilterDialog::create(::comphelper::getProcessComponentContext());
+ xDialog->execute();
+ }
+ catch (const uno::Exception&)
+ {
+ }
+ rReq.Ignore ();
+ }
+ break;
+ case FN_WORDCOUNT_DIALOG:
+ {
+ SfxViewFrame* pVFrame = GetView().GetViewFrame();
+ if (pVFrame != NULL)
+ {
+ pVFrame->ToggleChildWindow(FN_WORDCOUNT_DIALOG);
+ Invalidate(rReq.GetSlot());
+
+ SwWordCountWrapper *pWrdCnt = (SwWordCountWrapper*)pVFrame->GetChildWindow(SwWordCountWrapper::GetChildWindowId());
+ if (pWrdCnt)
+ pWrdCnt->UpdateCounts();
+ }
+ }
+ break;
+ default: bMore = true;
+ }
+
+ if ( !bMore )
+ {
+ return;
+ }
+
+ SwFlyFrmAttrMgr aMgr( sal_False, &rSh, FRMMGR_TYPE_NONE );
+ bool bUpdateMgr = true;
+ bool bCopyToFmt = false;
+ switch ( nSlot )
+ {
+ case SID_OBJECT_ALIGN_MIDDLE:
+ case FN_FRAME_ALIGN_VERT_CENTER:
+ aMgr.SetVertOrientation( text::VertOrientation::CENTER );
+ break;
+ case SID_OBJECT_ALIGN_DOWN :
+ case FN_FRAME_ALIGN_VERT_BOTTOM:
+ aMgr.SetVertOrientation( text::VertOrientation::BOTTOM );
+ break;
+ case SID_OBJECT_ALIGN_UP :
+ case FN_FRAME_ALIGN_VERT_TOP:
+ aMgr.SetVertOrientation( text::VertOrientation::TOP );
+ break;
+
+ case FN_FRAME_ALIGN_VERT_CHAR_CENTER:
+ aMgr.SetVertOrientation( text::VertOrientation::CHAR_CENTER );
+ break;
+
+ case FN_FRAME_ALIGN_VERT_CHAR_BOTTOM:
+ aMgr.SetVertOrientation( text::VertOrientation::CHAR_BOTTOM );
+ break;
+
+ case FN_FRAME_ALIGN_VERT_CHAR_TOP:
+ aMgr.SetVertOrientation( text::VertOrientation::CHAR_TOP );
+ break;
+
+ case FN_FRAME_ALIGN_VERT_ROW_CENTER:
+ aMgr.SetVertOrientation( text::VertOrientation::LINE_CENTER );
+ break;
+
+ case FN_FRAME_ALIGN_VERT_ROW_BOTTOM:
+ aMgr.SetVertOrientation( text::VertOrientation::LINE_BOTTOM );
+ break;
+
+ case FN_FRAME_ALIGN_VERT_ROW_TOP:
+ aMgr.SetVertOrientation( text::VertOrientation::LINE_TOP );
+ break;
+ case SID_OBJECT_ALIGN_CENTER :
+ case FN_FRAME_ALIGN_HORZ_CENTER:
+ aMgr.SetHorzOrientation( text::HoriOrientation::CENTER );
+ break;
+ case SID_OBJECT_ALIGN_RIGHT:
+ case FN_FRAME_ALIGN_HORZ_RIGHT:
+ aMgr.SetHorzOrientation( text::HoriOrientation::RIGHT );
+ break;
+ case SID_OBJECT_ALIGN_LEFT:
+ case FN_FRAME_ALIGN_HORZ_LEFT:
+ aMgr.SetHorzOrientation( text::HoriOrientation::LEFT );
+ break;
+
+ case FN_SET_FRM_POSITION:
+ {
+ aMgr.SetAbsPos(((SfxPointItem &)pArgs->Get
+ (FN_SET_FRM_POSITION)).GetValue());
+ }
+ break;
+ case SID_ATTR_BRUSH:
+ {
+ if(pArgs)
+ {
+ aMgr.SetAttrSet( *pArgs );
+ bCopyToFmt = true;
+ }
+ }
+ break;
+ case SID_ATTR_ULSPACE:
+ case SID_ATTR_LRSPACE:
+ {
+ if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(GetPool().GetWhich(nSlot), false, &pItem))
+ {
+ aMgr.SetAttrSet( *pArgs );
+ bCopyToFmt = true;
+ }
+ }
+ break;
+
+ case SID_ATTR_TRANSFORM:
+ {
+ bool bApplyNewSize = false;
+
+ Size aNewSize = aMgr.GetSize();
+ if ( SFX_ITEM_SET == pArgs->GetItemState( SID_ATTR_TRANSFORM_WIDTH, false, &pItem ) )
+ {
+ aNewSize.setWidth( static_cast< const SfxUInt32Item* >(pItem)->GetValue() );
+ bApplyNewSize = true;
+ }
+
+ if ( SFX_ITEM_SET == pArgs->GetItemState( SID_ATTR_TRANSFORM_HEIGHT, false, &pItem ) )
+ {
+ aNewSize.setHeight( static_cast< const SfxUInt32Item* >(pItem)->GetValue() );
+ bApplyNewSize = true;
+ }
+
+ if ( bApplyNewSize )
+ {
+ aMgr.SetSize( aNewSize );
+ }
+ else
+ {
+ bUpdateMgr = false;
+ }
+
+ }
+ break;
+
+ case FN_FORMAT_FRAME_DLG:
+ case FN_DRAW_WRAP_DLG:
+ {
+ const int nSel = rSh.GetSelectionType();
+ if (nSel & nsSelectionType::SEL_GRF)
+ {
+ rSh.GetView().GetViewFrame()->GetDispatcher()->Execute(FN_FORMAT_GRAFIC_DLG);
+ bUpdateMgr = false;
+ }
+ else
+ {
+ SfxItemSet aSet(GetPool(), RES_FRMATR_BEGIN, RES_FRMATR_END-1,
+ SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
+ FN_GET_PRINT_AREA, FN_GET_PRINT_AREA,
+ SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE,
+ SID_ATTR_BRUSH, SID_ATTR_BRUSH,
+ SID_ATTR_LRSPACE, SID_ATTR_ULSPACE,
+ FN_SURROUND, FN_HORI_ORIENT,
+ FN_SET_FRM_NAME, FN_SET_FRM_NAME,
+ FN_KEEP_ASPECT_RATIO, FN_KEEP_ASPECT_RATIO,
+ SID_DOCFRAME, SID_DOCFRAME,
+ SID_HTML_MODE, SID_HTML_MODE,
+ FN_SET_FRM_ALT_NAME, FN_SET_FRM_ALT_NAME,
+ FN_PARAM_CHAIN_PREVIOUS, FN_PARAM_CHAIN_NEXT,
+ FN_OLE_IS_MATH, FN_OLE_IS_MATH,
+ FN_MATH_BASELINE_ALIGNMENT, FN_MATH_BASELINE_ALIGNMENT,
+ 0);
+
+ const SwViewOption* pVOpt = rSh.GetViewOptions();
+ if(nSel & nsSelectionType::SEL_OLE)
+ aSet.Put( SfxBoolItem(FN_KEEP_ASPECT_RATIO, pVOpt->IsKeepRatio()) );
+ aSet.Put(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(GetView().GetDocShell())));
+ aSet.Put(SfxStringItem(FN_SET_FRM_NAME, rSh.GetFlyName()));
+ if( nSel & nsSelectionType::SEL_OLE )
+ {
+ // #i73249#
+ aSet.Put( SfxStringItem( FN_SET_FRM_ALT_NAME, rSh.GetObjTitle() ) );
+ }
+
+ const SwRect &rPg = rSh.GetAnyCurRect(RECT_PAGE);
+ SwFmtFrmSize aFrmSize(ATT_VAR_SIZE, rPg.Width(), rPg.Height());
+ aFrmSize.SetWhich(GetPool().GetWhich(SID_ATTR_PAGE_SIZE));
+ aSet.Put(aFrmSize);
+
+ const SwRect &rPr = rSh.GetAnyCurRect(RECT_PAGE_PRT);
+ SwFmtFrmSize aPrtSize(ATT_VAR_SIZE, rPr.Width(), rPr.Height());
+ aPrtSize.SetWhich(GetPool().GetWhich(FN_GET_PRINT_AREA));
+ aSet.Put(aPrtSize);
+
+ aSet.Put(aMgr.GetAttrSet());
+ aSet.SetParent( aMgr.GetAttrSet().GetParent() );
+
+ // On % values initialize size
+ SwFmtFrmSize& rSize = (SwFmtFrmSize&)aSet.Get(RES_FRM_SIZE);
+ if (rSize.GetWidthPercent() && rSize.GetWidthPercent() != 0xff)
+ rSize.SetWidth(rSh.GetAnyCurRect(RECT_FLY_EMBEDDED).Width());
+ if (rSize.GetHeightPercent() && rSize.GetHeightPercent() != 0xff)
+ rSize.SetHeight(rSh.GetAnyCurRect(RECT_FLY_EMBEDDED).Height());
+
+ // disable vertical positioning for Math Objects anchored 'as char' if baseline alignment is activated
+ aSet.Put( SfxBoolItem( FN_MATH_BASELINE_ALIGNMENT,
+ rSh.GetDoc()->get( IDocumentSettingAccess::MATH_BASELINE_ALIGNMENT ) ) );
+ const uno::Reference < embed::XEmbeddedObject > xObj( rSh.GetOleRef() );
+ aSet.Put( SfxBoolItem( FN_OLE_IS_MATH, xObj.is() && SotExchange::IsMath( xObj->getClassID() ) ) );
+
+ OString sDefPage;
+ if(pArgs && pArgs->GetItemState(FN_FORMAT_FRAME_DLG, false, &pItem) == SFX_ITEM_SET)
+ sDefPage = OUStringToOString(((SfxStringItem *)pItem)->GetValue(), RTL_TEXTENCODING_UTF8);
+
+ aSet.Put(SfxFrameItem( SID_DOCFRAME, &GetView().GetViewFrame()->GetTopFrame()));
+ FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, &GetView()));
+ SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric) ));
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "Dialogdiet fail!");
+ SfxAbstractTabDialog* pDlg = pFact->CreateFrmTabDialog(
+ nSel & nsSelectionType::SEL_GRF ? "PictureDialog" :
+ nSel & nsSelectionType::SEL_OLE ? "ObjectDialog":
+ "FrameDialog",
+ GetView().GetViewFrame(),
+ GetView().GetWindow(),
+ aSet, false,
+ false,
+ sDefPage);
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+
+ if ( nSlot == FN_DRAW_WRAP_DLG )
+ {
+ pDlg->SetCurPageId("wrap");
+ }
+
+ if ( pDlg->Execute() )
+ {
+ const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
+ if(pOutSet)
+ {
+ rReq.Done(*pOutSet);
+ if(nSel & nsSelectionType::SEL_OLE &&
+ SFX_ITEM_SET == pOutSet->GetItemState(FN_KEEP_ASPECT_RATIO, true, &pItem))
+ {
+ SwViewOption aUsrPref( *pVOpt );
+ aUsrPref.SetKeepRatio(((const SfxBoolItem*)pItem)->GetValue());
+ SW_MOD()->ApplyUsrPref(aUsrPref, &GetView());
+ }
+ if (SFX_ITEM_SET == pOutSet->GetItemState(FN_SET_FRM_ALT_NAME, true, &pItem))
+ {
+ // #i73249#
+ rSh.SetObjTitle(((const SfxStringItem*)pItem)->GetValue());
+ }
+ // Template AutoUpdate
+ SwFrmFmt* pFmt = rSh.GetCurFrmFmt();
+ if(pFmt && pFmt->IsAutoUpdateFmt())
+ {
+ rSh.AutoUpdateFrame(pFmt, *pOutSet);
+ // Anything which is not supported by the format must be set hard.
+ if(SFX_ITEM_SET == pOutSet->GetItemState(FN_SET_FRM_NAME, false, &pItem))
+ rSh.SetFlyName(((SfxStringItem*)pItem)->GetValue());
+ SfxItemSet aShellSet(GetPool(), RES_FRM_SIZE, RES_FRM_SIZE,
+ RES_SURROUND, RES_SURROUND,
+ RES_ANCHOR, RES_ANCHOR,
+ RES_VERT_ORIENT,RES_HORI_ORIENT,
+ 0);
+ aShellSet.Put(*pOutSet);
+ aMgr.SetAttrSet(aShellSet);
+ if(SFX_ITEM_SET == pOutSet->GetItemState(FN_SET_FRM_NAME, false, &pItem))
+ rSh.SetFlyName(((SfxStringItem*)pItem)->GetValue());
+ }
+ else
+ aMgr.SetAttrSet( *pOutSet );
+
+ const SwFrmFmt* pCurrFlyFmt = rSh.GetFlyFrmFmt();
+ if(SFX_ITEM_SET ==
+ pOutSet->GetItemState(FN_PARAM_CHAIN_PREVIOUS,
+ false, &pItem))
+ {
+ rSh.HideChainMarker();
+
+ OUString sPrevName =
+ ((const SfxStringItem*)pItem)->GetValue();
+ const SwFmtChain &rChain = pCurrFlyFmt->GetChain();
+ //needs cast - no non-const method available
+ SwFlyFrmFmt* pFlyFmt =
+ (SwFlyFrmFmt*)rChain.GetPrev();
+ if(pFlyFmt)
+ {
+ if (pFlyFmt->GetName() != sPrevName)
+ {
+ rSh.Unchain(*pFlyFmt);
+ }
+ else
+ sPrevName = OUString();
+ }
+
+ if (!sPrevName.isEmpty())
+ {
+ //needs cast - no non-const method available
+ SwFrmFmt* pPrevFmt = (SwFrmFmt*)
+ lcl_GetFrmFmtByName(rSh, sPrevName);
+ OSL_ENSURE(pPrevFmt, "No frame found!");
+ if(pPrevFmt)
+ {
+ rSh.Chain(*pPrevFmt, *pCurrFlyFmt);
+ }
+ }
+ rSh.SetChainMarker();
+ }
+ if(SFX_ITEM_SET ==
+ pOutSet->GetItemState(FN_PARAM_CHAIN_NEXT, false,
+ &pItem))
+ {
+ rSh.HideChainMarker();
+ OUString sNextName =
+ ((const SfxStringItem*)pItem)->GetValue();
+ const SwFmtChain &rChain = pCurrFlyFmt->GetChain();
+ //needs cast - no non-const method available
+ SwFlyFrmFmt* pFlyFmt =
+ (SwFlyFrmFmt*)rChain.GetNext();
+ if(pFlyFmt)
+ {
+ if (pFlyFmt->GetName() != sNextName)
+ {
+ rSh.Unchain(*((SwFlyFrmFmt*) pCurrFlyFmt));
+ }
+ else
+ sNextName = OUString();
+ }
+
+ if (!sNextName.isEmpty())
+ {
+ //needs cast - no non-const method available
+ SwFrmFmt* pNextFmt = (SwFrmFmt*)
+ lcl_GetFrmFmtByName(rSh, sNextName);
+ OSL_ENSURE(pNextFmt, "No frame found!");
+ if(pNextFmt)
+ {
+ rSh.Chain(*(SwFrmFmt*)
+ pCurrFlyFmt, *pNextFmt);
+ }
+ }
+ rSh.SetChainMarker();
+ }
+ }
+ }
+ else
+ bUpdateMgr = false;
+ delete pDlg;
+ }
+ }
+ break;
+ case FN_FRAME_MIRROR_ON_EVEN_PAGES:
+ {
+ SwFmtHoriOrient aHori(aMgr.GetHoriOrient());
+ sal_Bool bMirror = !aHori.IsPosToggle();
+ aHori.SetPosToggle(bMirror);
+ SfxItemSet aSet(GetPool(), RES_HORI_ORIENT, RES_HORI_ORIENT);
+ aSet.Put(aHori);
+ aMgr.SetAttrSet(aSet);
+ bCopyToFmt = true;
+ rReq.SetReturnValue(SfxBoolItem(nSlot, bMirror));
+ }
+ break;
+ // #i73249#
+ case FN_TITLE_DESCRIPTION_SHAPE:
+ {
+ bUpdateMgr = false;
+ SdrView* pSdrView = rSh.GetDrawViewWithValidMarkList();
+ if ( pSdrView &&
+ pSdrView->GetMarkedObjectCount() == 1 )
+ {
+ OUString aDescription(rSh.GetObjDescription());
+ OUString aTitle(rSh.GetObjTitle());
+
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "Dialogdiet fail!");
+ AbstractSvxObjectTitleDescDialog* pDlg =
+ pFact->CreateSvxObjectTitleDescDialog( NULL,
+ aTitle,
+ aDescription );
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+
+ if ( pDlg->Execute() == RET_OK )
+ {
+ pDlg->GetDescription(aDescription);
+ pDlg->GetTitle(aTitle);
+
+ rSh.SetObjDescription(aDescription);
+ rSh.SetObjTitle(aTitle);
+ }
+
+ delete pDlg;
+ }
+ }
+ break;
+ default:
+ OSL_ENSURE( !this, "wrong dispatcher" );
+ return;
+ }
+ if ( bUpdateMgr )
+ {
+ SwFrmFmt* pFmt = rSh.GetCurFrmFmt();
+ if ( bCopyToFmt && pFmt && pFmt->IsAutoUpdateFmt() )
+ {
+ rSh.AutoUpdateFrame(pFmt, aMgr.GetAttrSet());
+ }
+ else
+ {
+ aMgr.UpdateFlyFrm();
+ }
+ }
+
+}
+
+void SwFrameShell::GetState(SfxItemSet& rSet)
+{
+ SwWrtShell &rSh = GetShell();
+ bool bHtmlMode = 0 != ::GetHtmlMode(rSh.GetView().GetDocShell());
+ if (rSh.IsFrmSelected())
+ {
+ SfxItemSet aSet( rSh.GetAttrPool(),
+ RES_LR_SPACE, RES_UL_SPACE,
+ RES_PROTECT, RES_HORI_ORIENT,
+ RES_OPAQUE, RES_OPAQUE,
+ RES_PRINT, RES_OPAQUE,
+ 0 );
+ rSh.GetFlyFrmAttr( aSet );
+
+ sal_Bool bProtect = rSh.IsSelObjProtected(FLYPROTECT_POS);
+ sal_Bool bParentCntProt = rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) != 0;
+
+ bProtect |= bParentCntProt;
+
+ const sal_uInt16 eFrmType = rSh.GetFrmType(0,sal_True);
+ SwFlyFrmAttrMgr aMgr( sal_False, &rSh, FRMMGR_TYPE_NONE );
+
+ SfxWhichIter aIter( rSet );
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ while ( nWhich )
+ {
+ switch ( nWhich )
+ {
+ case RES_FRM_SIZE:
+ {
+ SwFmtFrmSize aSz(aMgr.GetFrmSize());
+ rSet.Put(aSz);
+ }
+ break;
+ case RES_VERT_ORIENT:
+ case RES_HORI_ORIENT:
+ case SID_ATTR_ULSPACE:
+ case SID_ATTR_LRSPACE:
+ case RES_LR_SPACE:
+ case RES_UL_SPACE:
+ case RES_PROTECT:
+ case RES_OPAQUE:
+ case RES_PRINT:
+ case RES_SURROUND:
+ {
+ rSet.Put(aSet.Get(GetPool().GetWhich(nWhich), sal_True ));
+ }
+ break;
+ case SID_OBJECT_ALIGN_LEFT :
+ case SID_OBJECT_ALIGN_CENTER :
+ case SID_OBJECT_ALIGN_RIGHT :
+ case FN_FRAME_ALIGN_HORZ_CENTER:
+ case FN_FRAME_ALIGN_HORZ_RIGHT:
+ case FN_FRAME_ALIGN_HORZ_LEFT:
+ if ( (eFrmType & FRMTYPE_FLY_INCNT) ||
+ bProtect ||
+ ((nWhich == FN_FRAME_ALIGN_HORZ_CENTER || nWhich == SID_OBJECT_ALIGN_CENTER) &&
+ bHtmlMode ))
+ rSet.DisableItem( nWhich );
+ break;
+ case FN_FRAME_ALIGN_VERT_ROW_TOP:
+ case FN_FRAME_ALIGN_VERT_ROW_CENTER:
+ case FN_FRAME_ALIGN_VERT_ROW_BOTTOM:
+ case FN_FRAME_ALIGN_VERT_CHAR_TOP:
+ case FN_FRAME_ALIGN_VERT_CHAR_CENTER:
+ case FN_FRAME_ALIGN_VERT_CHAR_BOTTOM:
+ if ( !(eFrmType & FRMTYPE_FLY_INCNT) || bProtect
+ || (bHtmlMode && FN_FRAME_ALIGN_VERT_CHAR_BOTTOM == nWhich) )
+ rSet.DisableItem( nWhich );
+ break;
+
+ case SID_OBJECT_ALIGN_UP :
+ case SID_OBJECT_ALIGN_MIDDLE :
+ case SID_OBJECT_ALIGN_DOWN :
+
+ case FN_FRAME_ALIGN_VERT_TOP:
+ case FN_FRAME_ALIGN_VERT_CENTER:
+ case FN_FRAME_ALIGN_VERT_BOTTOM:
+ if ( bProtect || (bHtmlMode && eFrmType & FRMTYPE_FLY_ATCNT))
+ rSet.DisableItem( nWhich );
+ else
+ {
+ sal_uInt16 nId = 0;
+ if (eFrmType & FRMTYPE_FLY_INCNT)
+ {
+ switch (nWhich)
+ {
+ case SID_OBJECT_ALIGN_UP :
+ case FN_FRAME_ALIGN_VERT_TOP:
+ nId = STR_TOP_BASE; break;
+ case SID_OBJECT_ALIGN_MIDDLE :
+ case FN_FRAME_ALIGN_VERT_CENTER:
+ nId = STR_CENTER_BASE; break;
+ case SID_OBJECT_ALIGN_DOWN :
+ case FN_FRAME_ALIGN_VERT_BOTTOM:
+ if(!bHtmlMode)
+ nId = STR_BOTTOM_BASE;
+ else
+ rSet.DisableItem( nWhich );
+ break;
+ }
+ }
+ else
+ {
+ if (nWhich != FN_FRAME_ALIGN_VERT_TOP &&
+ nWhich != SID_OBJECT_ALIGN_UP )
+ {
+ if (aMgr.GetAnchor() == FLY_AT_FLY)
+ {
+ const SwFrmFmt* pFmt = rSh.IsFlyInFly();
+ if (pFmt)
+ {
+ const SwFmtFrmSize& rFrmSz = pFmt->GetFrmSize();
+ if (rFrmSz.GetHeightSizeType() != ATT_FIX_SIZE)
+ {
+ rSet.DisableItem( nWhich );
+ break;
+ }
+ }
+ }
+ }
+ switch (nWhich)
+ {
+ case SID_OBJECT_ALIGN_UP :
+ case FN_FRAME_ALIGN_VERT_TOP:
+ nId = STR_TOP; break;
+ case SID_OBJECT_ALIGN_MIDDLE:
+ case FN_FRAME_ALIGN_VERT_CENTER:
+ nId = STR_CENTER_VERT; break;
+ case SID_OBJECT_ALIGN_DOWN:
+ case FN_FRAME_ALIGN_VERT_BOTTOM:
+ nId = STR_BOTTOM; break;
+ }
+ }
+ if ( nId )
+ rSet.Put( SfxStringItem( nWhich, SW_RES(nId) ));
+ }
+ break;
+ case SID_HYPERLINK_GETLINK:
+ {
+ SvxHyperlinkItem aHLinkItem;
+ const SfxPoolItem* pItem;
+
+ SfxItemSet aURLSet(GetPool(), RES_URL, RES_URL);
+ rSh.GetFlyFrmAttr( aURLSet );
+
+ if(SFX_ITEM_SET == aURLSet.GetItemState(RES_URL, true, &pItem))
+ {
+ const SwFmtURL* pFmtURL = (const SwFmtURL*)pItem;
+ aHLinkItem.SetURL(pFmtURL->GetURL());
+ aHLinkItem.SetTargetFrame(pFmtURL->GetTargetFrameName());
+ aHLinkItem.SetName(rSh.GetFlyName());
+ }
+
+ aHLinkItem.SetInsertMode((SvxLinkInsertMode)(aHLinkItem.GetInsertMode() |
+ (bHtmlMode ? HLINK_HTMLMODE : 0)));
+
+ rSet.Put(aHLinkItem);
+ }
+ break;
+
+ case FN_FRAME_CHAIN:
+ {
+ const int nSel = rSh.GetSelectionType();
+ if (nSel & nsSelectionType::SEL_GRF || nSel & nsSelectionType::SEL_OLE)
+ rSet.DisableItem( FN_FRAME_CHAIN );
+ else
+ {
+ const SwFrmFmt *pFmt = rSh.GetFlyFrmFmt();
+ if ( bParentCntProt || rSh.GetView().GetEditWin().GetApplyTemplate() ||
+ !pFmt || pFmt->GetChain().GetNext() )
+ {
+ rSet.DisableItem( FN_FRAME_CHAIN );
+ }
+ else
+ {
+ sal_Bool bChainMode = rSh.GetView().GetEditWin().IsChainMode();
+ rSet.Put( SfxBoolItem( FN_FRAME_CHAIN, bChainMode ) );
+ }
+ }
+ }
+ break;
+ case FN_FRAME_UNCHAIN:
+ {
+ const int nSel = rSh.GetSelectionType();
+ if (nSel & nsSelectionType::SEL_GRF || nSel & nsSelectionType::SEL_OLE)
+ rSet.DisableItem( FN_FRAME_UNCHAIN );
+ else
+ {
+ const SwFrmFmt *pFmt = rSh.GetFlyFrmFmt();
+ if ( bParentCntProt || rSh.GetView().GetEditWin().GetApplyTemplate() ||
+ !pFmt || !pFmt->GetChain().GetNext() )
+ {
+ rSet.DisableItem( FN_FRAME_UNCHAIN );
+ }
+ }
+ }
+ break;
+ case SID_FRAME_TO_TOP:
+ case SID_FRAME_TO_BOTTOM:
+ case FN_FRAME_UP:
+ case FN_FRAME_DOWN:
+ if ( bParentCntProt )
+ rSet.DisableItem( nWhich );
+ break;
+
+ case SID_ATTR_TRANSFORM:
+ {
+ rSet.DisableItem( nWhich );
+ }
+ break;
+
+ case SID_ATTR_TRANSFORM_PROTECT_SIZE:
+ {
+ const sal_uInt8 eProtection = rSh.IsSelObjProtected( FLYPROTECT_SIZE );
+ if ( ( eProtection & FLYPROTECT_CONTENT ) ||
+ ( eProtection & FLYPROTECT_SIZE ) )
+ {
+ rSet.Put( SfxBoolItem( SID_ATTR_TRANSFORM_PROTECT_SIZE, true ) );
+ }
+ else
+ {
+ rSet.Put( SfxBoolItem( SID_ATTR_TRANSFORM_PROTECT_SIZE, false ) );
+ }
+ }
+ break;
+
+ case SID_ATTR_TRANSFORM_WIDTH:
+ {
+ rSet.Put( SfxUInt32Item( SID_ATTR_TRANSFORM_WIDTH, aMgr.GetSize().getWidth() ) );
+ }
+ break;
+
+ case SID_ATTR_TRANSFORM_HEIGHT:
+ {
+ rSet.Put( SfxUInt32Item( SID_ATTR_TRANSFORM_HEIGHT, aMgr.GetSize().getHeight() ) );
+ }
+ break;
+
+ case FN_FORMAT_FRAME_DLG:
+ {
+ const int nSel = rSh.GetSelectionType();
+ if ( bParentCntProt || nSel & nsSelectionType::SEL_GRF)
+ rSet.DisableItem( nWhich );
+ }
+ break;
+ // #i73249#
+ case FN_TITLE_DESCRIPTION_SHAPE:
+ {
+ SwWrtShell &rWrtSh = GetShell();
+ SdrView* pSdrView = rWrtSh.GetDrawViewWithValidMarkList();
+ if ( !pSdrView ||
+ pSdrView->GetMarkedObjectCount() != 1 )
+ {
+ rSet.DisableItem( nWhich );
+ }
+
+ }
+ break;
+
+ default:
+ /* do nothing */;
+ break;
+ }
+ nWhich = aIter.NextWhich();
+ }
+ }
+}
+
+SwFrameShell::SwFrameShell(SwView &_rView) :
+ SwBaseShell( _rView )
+{
+ SetName(OUString("Frame"));
+ SetHelpId(SW_FRAMESHELL);
+
+ // #96392# Use this to announce it is the frame shell who creates the selection.
+ SwTransferable::CreateSelection( _rView.GetWrtShell(), (SwViewShell *) this );
+
+ SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_Frame));
+}
+
+SwFrameShell::~SwFrameShell()
+{
+ // #96392# Only clear the selection if it was this frame shell who created it.
+ SwTransferable::ClearSelection( GetShell(), (SwViewShell *) this );
+}
+
+void SwFrameShell::ExecFrameStyle(SfxRequest& rReq)
+{
+ SwWrtShell &rSh = GetShell();
+ bool bDefault = false;
+ if (!rSh.IsFrmSelected())
+ return;
+ // At first pick the default BoxItem out of the pool.
+ // If unequal to regular box item, then it has already
+ // been changed (New one is no default).
+ const SvxBoxItem* pPoolBoxItem = (const SvxBoxItem*)::GetDfltAttr(RES_BOX);
+
+ const SfxItemSet *pArgs = rReq.GetArgs();
+ SfxItemSet aFrameSet(rSh.GetAttrPool(), RES_BOX, RES_BOX);
+
+ rSh.GetFlyFrmAttr( aFrameSet );
+ const SvxBoxItem& rBoxItem = (const SvxBoxItem&)aFrameSet.Get(RES_BOX);
+
+ if (pPoolBoxItem == &rBoxItem)
+ bDefault = true;
+
+ SvxBoxItem aBoxItem(rBoxItem);
+
+ SvxBorderLine aBorderLine;
+ const SfxPoolItem *pItem = 0;
+
+ if(pArgs) // Any controller can sometimes deliver nothing #48169#
+ {
+ switch (rReq.GetSlot())
+ {
+ case SID_ATTR_BORDER:
+ {
+ if (pArgs->GetItemState(RES_BOX, true, &pItem) == SFX_ITEM_SET)
+ {
+ SvxBoxItem aNewBox(*((SvxBoxItem *)pItem));
+ const SvxBorderLine* pBorderLine;
+
+ if ((pBorderLine = aBoxItem.GetTop()) != NULL)
+ lcl_FrmGetMaxLineWidth(pBorderLine, aBorderLine);
+ if ((pBorderLine = aBoxItem.GetBottom()) != NULL)
+ lcl_FrmGetMaxLineWidth(pBorderLine, aBorderLine);
+ if ((pBorderLine = aBoxItem.GetLeft()) != NULL)
+ lcl_FrmGetMaxLineWidth(pBorderLine, aBorderLine);
+ if ((pBorderLine = aBoxItem.GetRight()) != NULL)
+ lcl_FrmGetMaxLineWidth(pBorderLine, aBorderLine);
+
+ if(aBorderLine.GetOutWidth() == 0)
+ {
+ aBorderLine.SetBorderLineStyle(
+ table::BorderLineStyle::SOLID);
+ aBorderLine.SetWidth( DEF_LINE_WIDTH_0 );
+ }
+ //Set distance only if the request is received from the controller.
+
+#ifndef DISABLE_SCRIPTING
+ if(!StarBASIC::IsRunning())
+#endif
+ {
+ aNewBox.SetDistance( rBoxItem.GetDistance() );
+ }
+
+ aBoxItem = aNewBox;
+ SvxBorderLine aDestBorderLine;
+
+ if( aBoxItem.GetTop() != NULL )
+ aBoxItem.SetLine(&aBorderLine, BOX_LINE_TOP);
+ if( aBoxItem.GetBottom() != NULL )
+ aBoxItem.SetLine(&aBorderLine, BOX_LINE_BOTTOM);
+ if( aBoxItem.GetLeft() != NULL )
+ aBoxItem.SetLine(&aBorderLine, BOX_LINE_LEFT);
+ if( aBoxItem.GetRight() != NULL )
+ aBoxItem.SetLine(&aBorderLine, BOX_LINE_RIGHT);
+ }
+ }
+ break;
+
+ case SID_FRAME_LINESTYLE:
+ {
+ if (pArgs->GetItemState(SID_FRAME_LINESTYLE, false, &pItem) == SFX_ITEM_SET)
+ {
+ const SvxLineItem* pLineItem =
+ (const SvxLineItem*)pItem;
+
+ if ( pLineItem->GetLine() )
+ {
+ aBorderLine = *(pLineItem->GetLine());
+
+ if (!aBoxItem.GetTop() && !aBoxItem.GetBottom() &&
+ !aBoxItem.GetLeft() && !aBoxItem.GetRight())
+ {
+ aBoxItem.SetLine(&aBorderLine, BOX_LINE_TOP);
+ aBoxItem.SetLine(&aBorderLine, BOX_LINE_BOTTOM);
+ aBoxItem.SetLine(&aBorderLine, BOX_LINE_LEFT);
+ aBoxItem.SetLine(&aBorderLine, BOX_LINE_RIGHT);
+ }
+ else
+ {
+ if( aBoxItem.GetTop() )
+ {
+ aBorderLine.SetColor( aBoxItem.GetTop()->GetColor() );
+ aBoxItem.SetLine(&aBorderLine, BOX_LINE_TOP);
+ }
+ if( aBoxItem.GetBottom() )
+ {
+ aBorderLine.SetColor( aBoxItem.GetBottom()->GetColor());
+ aBoxItem.SetLine(&aBorderLine, BOX_LINE_BOTTOM);
+ }
+ if( aBoxItem.GetLeft() )
+ {
+ aBorderLine.SetColor( aBoxItem.GetLeft()->GetColor());
+ aBoxItem.SetLine(&aBorderLine, BOX_LINE_LEFT);
+ }
+ if( aBoxItem.GetRight() )
+ {
+ aBorderLine.SetColor(aBoxItem.GetRight()->GetColor());
+ aBoxItem.SetLine(&aBorderLine, BOX_LINE_RIGHT);
+ }
+ }
+ }
+ else
+ {
+ aBoxItem.SetLine(0, BOX_LINE_TOP);
+ aBoxItem.SetLine(0, BOX_LINE_BOTTOM);
+ aBoxItem.SetLine(0, BOX_LINE_LEFT);
+ aBoxItem.SetLine(0, BOX_LINE_RIGHT);
+ }
+ }
+ }
+ break;
+
+ case SID_FRAME_LINECOLOR:
+ {
+ if (pArgs->GetItemState(SID_FRAME_LINECOLOR, false, &pItem) == SFX_ITEM_SET)
+ {
+ const Color& rNewColor = ((const SvxColorItem*)pItem)->GetValue();
+
+ if (!aBoxItem.GetTop() && !aBoxItem.GetBottom() &&
+ !aBoxItem.GetLeft() && !aBoxItem.GetRight())
+ {
+ aBorderLine.SetColor( rNewColor );
+ aBoxItem.SetLine(&aBorderLine, BOX_LINE_TOP);
+ aBoxItem.SetLine(&aBorderLine, BOX_LINE_BOTTOM);
+ aBoxItem.SetLine(&aBorderLine, BOX_LINE_LEFT);
+ aBoxItem.SetLine(&aBorderLine, BOX_LINE_RIGHT);
+ }
+ else
+ {
+ if ( aBoxItem.GetTop() )
+ ((SvxBorderLine*)aBoxItem.GetTop())->SetColor( rNewColor );
+ if ( aBoxItem.GetBottom() )
+ ((SvxBorderLine*)aBoxItem.GetBottom())->SetColor( rNewColor );
+ if ( aBoxItem.GetLeft() )
+ ((SvxBorderLine*)aBoxItem.GetLeft())->SetColor( rNewColor );
+ if ( aBoxItem.GetRight() )
+ ((SvxBorderLine*)aBoxItem.GetRight())->SetColor( rNewColor );
+ }
+ }
+ }
+ break;
+ }
+ }
+ if (bDefault && (aBoxItem.GetTop() || aBoxItem.GetBottom() ||
+ aBoxItem.GetLeft() || aBoxItem.GetRight()))
+ {
+ aBoxItem.SetDistance(MIN_BORDER_DIST);
+ }
+ aFrameSet.Put( aBoxItem );
+ // Template AutoUpdate
+ SwFrmFmt* pFmt = rSh.GetCurFrmFmt();
+ if(pFmt && pFmt->IsAutoUpdateFmt())
+ {
+ rSh.AutoUpdateFrame(pFmt, aFrameSet);
+ }
+ else
+ rSh.SetFlyFrmAttr( aFrameSet );
+
+}
+
+static void lcl_FrmGetMaxLineWidth(const SvxBorderLine* pBorderLine, SvxBorderLine& rBorderLine)
+{
+ if(pBorderLine->GetWidth() > rBorderLine.GetWidth())
+ rBorderLine.SetWidth(pBorderLine->GetWidth());
+
+ rBorderLine.SetBorderLineStyle(pBorderLine->GetBorderLineStyle());
+ rBorderLine.SetColor(pBorderLine->GetColor());
+}
+
+void SwFrameShell::GetLineStyleState(SfxItemSet &rSet)
+{
+ SwWrtShell &rSh = GetShell();
+ bool bParentCntProt = rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) != 0;
+
+ if (bParentCntProt)
+ {
+ if (rSh.IsFrmSelected())
+ rSet.DisableItem( SID_FRAME_LINECOLOR );
+
+ rSet.DisableItem( SID_ATTR_BORDER );
+ rSet.DisableItem( SID_FRAME_LINESTYLE );
+ }
+ else
+ {
+ if (rSh.IsFrmSelected())
+ {
+ SfxItemSet aFrameSet( rSh.GetAttrPool(), RES_BOX, RES_BOX );
+
+ rSh.GetFlyFrmAttr(aFrameSet);
+
+ const SvxBorderLine* pLine = ((const SvxBoxItem&)aFrameSet.Get(RES_BOX)).GetTop();
+ rSet.Put(SvxColorItem(pLine ? pLine->GetColor() : Color(), SID_FRAME_LINECOLOR));
+ }
+ }
+}
+
+void SwFrameShell::StateInsert(SfxItemSet &rSet)
+{
+ const int nSel = GetShell().GetSelectionType();
+ if ( (nSel & nsSelectionType::SEL_GRF)
+ || (nSel & nsSelectionType::SEL_OLE) )
+ {
+ rSet.DisableItem(FN_INSERT_FRAME);
+ }
+ else if ( GetShell().CrsrInsideInputFld() )
+ {
+ rSet.DisableItem(FN_INSERT_FRAME);
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/shells/grfsh.cxx b/sw/source/core/uibase/shells/grfsh.cxx
new file mode 100644
index 000000000000..b8c9b422396a
--- /dev/null
+++ b/sw/source/core/uibase/shells/grfsh.cxx
@@ -0,0 +1,892 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <cmdid.h>
+#include <hintids.hxx>
+#include <tools/urlobj.hxx>
+#include <vcl/msgbox.hxx>
+#include <svl/stritem.hxx>
+#include <svl/whiter.hxx>
+#include <svl/urihelper.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/dispatch.hxx>
+
+#include <sfx2/objface.hxx>
+#include <editeng/sizeitem.hxx>
+#include <editeng/protitem.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/sidebar/EnumContext.hxx>
+#include <svl/srchitem.hxx>
+#include <sfx2/htmlmode.hxx>
+#include <svx/sdgluitm.hxx>
+#include <svx/sdgcoitm.hxx>
+#include <svx/sdggaitm.hxx>
+#include <svx/sdgtritm.hxx>
+#include <svx/sdginitm.hxx>
+#include <svx/sdgmoitm.hxx>
+#include <editeng/brushitem.hxx>
+#include <svx/grfflt.hxx>
+#include <svx/compressgraphicdialog.hxx>
+#include <vcl/GraphicNativeTransform.hxx>
+#include <svx/tbxcolor.hxx>
+#include <fmturl.hxx>
+#include <view.hxx>
+#include <wrtsh.hxx>
+#include <viewopt.hxx>
+#include <swmodule.hxx>
+#include <frmatr.hxx>
+#include <swundo.hxx>
+#include <uitool.hxx>
+#include <docsh.hxx>
+#include <grfsh.hxx>
+#include <frmmgr.hxx>
+#include <frmdlg.hxx>
+#include <frmfmt.hxx>
+#include <grfatr.hxx>
+#include <usrpref.hxx>
+#include <edtwin.hxx>
+#include <swwait.hxx>
+#include <shells.hrc>
+#include <popup.hrc>
+#include <svx/extedit.hxx>
+#include <svx/graphichelper.hxx>
+#include <doc.hxx>
+
+#define SwGrfShell
+
+#include <sfx2/msg.hxx>
+#include "swslots.hxx"
+
+#include "swabstdlg.hxx"
+
+#define TOOLBOX_NAME "colorbar"
+
+namespace
+{
+ class SwExternalToolEdit : public ExternalToolEdit
+ {
+ SwWrtShell* m_pShell;
+
+ public:
+ SwExternalToolEdit ( SwWrtShell* pShell ) :
+ m_pShell (pShell)
+ {}
+
+ virtual void Update( Graphic& aGraphic )
+ {
+ m_pShell->ReRead(OUString(), OUString(), (const Graphic*) &aGraphic);
+ }
+ };
+}
+
+SFX_IMPL_INTERFACE(SwGrfShell, SwBaseShell, SW_RES(STR_SHELLNAME_GRAPHIC))
+{
+ SFX_POPUPMENU_REGISTRATION(SW_RES(MN_GRF_POPUPMENU));
+ SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_GRAFIK_TOOLBOX));
+}
+
+void SwGrfShell::Execute(SfxRequest &rReq)
+{
+ SwWrtShell &rSh = GetShell();
+
+ sal_uInt16 nSlot = rReq.GetSlot();
+ switch(nSlot)
+ {
+ case SID_TWAIN_TRANSFER:
+ {
+ GetView().ExecuteScan( rReq );
+ break;
+ }
+
+ case SID_SAVE_GRAPHIC:
+ {
+ const Graphic *pGraphic;
+ if(0 != (pGraphic = rSh.GetGraphic()))
+ {
+ OUString sGrfNm;
+ OUString sFilterNm;
+ rSh.GetGrfNms( &sGrfNm, &sFilterNm );
+ GraphicHelper::ExportGraphic( *pGraphic, sGrfNm );
+ }
+ }
+ break;
+
+ case SID_COMPRESS_GRAPHIC:
+ {
+ const Graphic* pGraphic = rSh.GetGraphic();
+ if( pGraphic )
+ {
+ Size aSize (
+ TWIP_TO_MM100(rSh.GetAnyCurRect(RECT_FLY_EMBEDDED).Width()),
+ TWIP_TO_MM100(rSh.GetAnyCurRect(RECT_FLY_EMBEDDED).Height()));
+
+ SfxItemSet aSet( rSh.GetAttrPool(), RES_GRFATR_CROPGRF, RES_GRFATR_CROPGRF );
+ rSh.GetCurAttr( aSet );
+ SwCropGrf aCrop( (const SwCropGrf&) aSet.Get(RES_GRFATR_CROPGRF) );
+
+ Rectangle aCropRectangle(
+ TWIP_TO_MM100(aCrop.GetLeft()),
+ TWIP_TO_MM100(aCrop.GetTop()),
+ TWIP_TO_MM100(aCrop.GetRight()),
+ TWIP_TO_MM100(aCrop.GetBottom()) );
+
+ Graphic aGraphic = Graphic( *pGraphic );
+
+ CompressGraphicsDialog aDialog( GetView().GetWindow(), aGraphic, aSize, aCropRectangle, GetView().GetViewFrame()->GetBindings() );
+ if( aDialog.Execute() == RET_OK )
+ {
+ rSh.StartAllAction();
+ rSh.StartUndo(UNDO_START);
+ Rectangle aScaledCropedRectangle = aDialog.GetScaledCropRectangle();
+
+ aCrop.SetLeft( MM100_TO_TWIP( aScaledCropedRectangle.Left() ));
+ aCrop.SetTop( MM100_TO_TWIP( aScaledCropedRectangle.Top() ));
+ aCrop.SetRight( MM100_TO_TWIP( aScaledCropedRectangle.Right() ));
+ aCrop.SetBottom( MM100_TO_TWIP( aScaledCropedRectangle.Bottom() ));
+
+ Graphic aCompressedGraphic( aDialog.GetCompressedGraphic() );
+ rSh.ReRead(OUString(), OUString(), (const Graphic*) &aCompressedGraphic);
+
+ rSh.SetAttrItem(aCrop);
+
+ rSh.EndUndo(UNDO_END);
+ rSh.EndAllAction();
+ }
+ }
+ }
+ break;
+
+ case SID_EXTERNAL_EDIT:
+ {
+ // When the graphic is selected to be opened via some external tool
+ // for advanced editing
+ GraphicObject *pGraphicObject = (GraphicObject *) rSh.GetGraphicObj();
+ if(0 != pGraphicObject)
+ {
+ SwExternalToolEdit* externalToolEdit = new SwExternalToolEdit( &rSh );
+ externalToolEdit->Edit ( pGraphicObject );
+ }
+ }
+ break;
+
+ case SID_INSERT_GRAPHIC:
+ {
+ // #i123922# implement slot independent from the two below to
+ // bring up the insert graphic dialog and associated actions
+ SwView& rLclView = GetView();
+ rReq.SetReturnValue(SfxBoolItem(nSlot, rLclView.InsertGraphicDlg( rReq )));
+ break;
+ }
+ case FN_FORMAT_GRAFIC_DLG:
+ case FN_DRAW_WRAP_DLG:
+ {
+ SwFlyFrmAttrMgr aMgr( sal_False, &rSh, rSh.IsFrmSelected() ?
+ FRMMGR_TYPE_NONE : FRMMGR_TYPE_GRF);
+ const SwViewOption* pVOpt = rSh.GetViewOptions();
+ SwViewOption aUsrPref( *pVOpt );
+
+ SfxItemSet aSet(GetPool(), RES_FRMATR_BEGIN, RES_FRMATR_END-1,
+ RES_GRFATR_MIRRORGRF, RES_GRFATR_CROPGRF,
+ SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
+ SID_ATTR_GRAF_KEEP_ZOOM, SID_ATTR_GRAF_KEEP_ZOOM,
+ SID_ATTR_GRAF_FRMSIZE, SID_ATTR_GRAF_FRMSIZE,
+ SID_ATTR_GRAF_FRMSIZE_PERCENT, SID_ATTR_GRAF_FRMSIZE_PERCENT,
+ SID_ATTR_GRAF_GRAPHIC, SID_ATTR_GRAF_GRAPHIC,
+ FN_PARAM_GRF_CONNECT, FN_PARAM_GRF_CONNECT,
+ SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE,
+ FN_GET_PRINT_AREA, FN_GET_PRINT_AREA,
+ FN_SET_FRM_NAME, FN_KEEP_ASPECT_RATIO,
+ FN_PARAM_GRF_DIALOG, FN_PARAM_GRF_DIALOG,
+ SID_DOCFRAME, SID_DOCFRAME,
+ SID_HTML_MODE, SID_HTML_MODE,
+ FN_SET_FRM_ALT_NAME, FN_SET_FRM_ALT_NAME,
+ SID_REFERER, SID_REFERER,
+ 0);
+
+ sal_uInt16 nHtmlMode = ::GetHtmlMode(GetView().GetDocShell());
+ aSet.Put(SfxUInt16Item(SID_HTML_MODE, nHtmlMode));
+ FieldUnit eMetric = ::GetDfltMetric((0 != (nHtmlMode&HTMLMODE_ON)));
+ SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)) );
+
+ const SwRect* pRect = &rSh.GetAnyCurRect(RECT_PAGE);
+ SwFmtFrmSize aFrmSize( ATT_VAR_SIZE, pRect->Width(), pRect->Height());
+ aFrmSize.SetWhich( GetPool().GetWhich( SID_ATTR_PAGE_SIZE ) );
+ aSet.Put( aFrmSize );
+
+ aSet.Put(SfxStringItem(FN_SET_FRM_NAME, rSh.GetFlyName()));
+ if ( nSlot == FN_FORMAT_GRAFIC_DLG )
+ {
+ // #i73249#
+ aSet.Put( SfxStringItem( FN_SET_FRM_ALT_NAME, rSh.GetObjTitle() ) );
+ }
+
+ pRect = &rSh.GetAnyCurRect(RECT_PAGE_PRT);
+ aFrmSize.SetWidth( pRect->Width() );
+ aFrmSize.SetHeight( pRect->Height() );
+ aFrmSize.SetWhich( GetPool().GetWhich(FN_GET_PRINT_AREA) );
+ aSet.Put( aFrmSize );
+
+ aSet.Put( aMgr.GetAttrSet() );
+ aSet.SetParent( aMgr.GetAttrSet().GetParent() );
+
+ // At percentage values initialize size
+ SwFmtFrmSize aSizeCopy = (const SwFmtFrmSize&)aSet.Get(RES_FRM_SIZE);
+ if (aSizeCopy.GetWidthPercent() && aSizeCopy.GetWidthPercent() != 0xff)
+ aSizeCopy.SetWidth(rSh.GetAnyCurRect(RECT_FLY_EMBEDDED).Width());
+ if (aSizeCopy.GetHeightPercent() && aSizeCopy.GetHeightPercent() != 0xff)
+ aSizeCopy.SetHeight(rSh.GetAnyCurRect(RECT_FLY_EMBEDDED).Height());
+ // and now set the size for "external" tabpages
+ {
+ SvxSizeItem aSzItm( SID_ATTR_GRAF_FRMSIZE, aSizeCopy.GetSize() );
+ aSet.Put( aSzItm );
+
+ Size aSz( aSizeCopy.GetWidthPercent(), aSizeCopy.GetHeightPercent() );
+ if( 0xff == aSz.Width() ) aSz.Width() = 0;
+ if( 0xff == aSz.Height() ) aSz.Height() = 0;
+
+ aSzItm.SetSize( aSz );
+ aSzItm.SetWhich( SID_ATTR_GRAF_FRMSIZE_PERCENT );
+ aSet.Put( aSzItm );
+ }
+
+ OUString sGrfNm;
+ OUString sFilterNm;
+ rSh.GetGrfNms( &sGrfNm, &sFilterNm );
+ if( !sGrfNm.isEmpty() )
+ {
+ aSet.Put( SvxBrushItem( INetURLObject::decode( sGrfNm,
+ INET_HEX_ESCAPE,
+ INetURLObject::DECODE_UNAMBIGUOUS,
+ RTL_TEXTENCODING_UTF8 ),
+ sFilterNm, GPOS_LT,
+ SID_ATTR_GRAF_GRAPHIC ));
+ }
+ else
+ {
+ // #119353# - robust
+ const GraphicObject* pGrfObj = rSh.GetGraphicObj();
+ if ( pGrfObj )
+ {
+ aSet.Put( SvxBrushItem( *pGrfObj, GPOS_LT,
+ SID_ATTR_GRAF_GRAPHIC ) );
+ }
+ }
+ aSet.Put( SfxBoolItem( FN_PARAM_GRF_CONNECT, !sGrfNm.isEmpty() ) );
+
+ // get Mirror and Crop
+ {
+ SfxItemSet aTmpSet( rSh.GetAttrPool(),
+ RES_GRFATR_MIRRORGRF, RES_GRFATR_CROPGRF );
+
+ rSh.GetCurAttr( aTmpSet );
+ aSet.Put( aTmpSet );
+ }
+
+ aSet.Put(SfxBoolItem(FN_KEEP_ASPECT_RATIO, aUsrPref.IsKeepRatio()));
+ aSet.Put(SfxBoolItem( SID_ATTR_GRAF_KEEP_ZOOM, aUsrPref.IsGrfKeepZoom()));
+
+ aSet.Put(SfxFrameItem( SID_DOCFRAME, &GetView().GetViewFrame()->GetTopFrame()));
+
+ SfxObjectShell * sh = rSh.GetDoc()->GetPersist();
+ if (sh != 0 && sh->HasName())
+ {
+ aSet.Put(
+ SfxStringItem(SID_REFERER, sh->GetMedium()->GetName()));
+ }
+
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "no dialog factory!");
+ SfxAbstractTabDialog* pDlg = pFact->CreateFrmTabDialog("PictureDialog",
+ GetView().GetViewFrame(),
+ GetView().GetWindow(),
+ aSet, false);
+ OSL_ENSURE(pDlg, "no tab dialog!");
+
+ if (nSlot == FN_DRAW_WRAP_DLG)
+ pDlg->SetCurPageId("wrap");
+
+ if( pDlg->Execute() )
+ {
+ rSh.StartAllAction();
+ rSh.StartUndo(UNDO_START);
+ const SfxPoolItem* pItem;
+ SfxItemSet* pSet = (SfxItemSet*)pDlg->GetOutputItemSet();
+ rReq.Done(*pSet);
+ // change the 2 frmsize SizeItems to the correct SwFrmSizeItem
+ if( SFX_ITEM_SET == pSet->GetItemState(
+ SID_ATTR_GRAF_FRMSIZE, false, &pItem ))
+ {
+ SwFmtFrmSize aSize;
+ const Size& rSz = ((SvxSizeItem*)pItem)->GetSize();
+ aSize.SetWidth( rSz.Width() );
+ aSize.SetHeight( rSz.Height() );
+
+ if( SFX_ITEM_SET == pSet->GetItemState(
+ SID_ATTR_GRAF_FRMSIZE_PERCENT, false, &pItem ))
+ {
+ const Size& rRelativeSize = ((SvxSizeItem*)pItem)->GetSize();
+ aSize.SetWidthPercent( static_cast< sal_uInt8 >( rRelativeSize.Width() ) );
+ aSize.SetHeightPercent( static_cast< sal_uInt8 >( rRelativeSize.Height() ) );
+ }
+ pSet->Put( aSize );
+ }
+
+ // Templates AutoUpdate
+ SwFrmFmt* pFmt = rSh.GetCurFrmFmt();
+ if(pFmt && pFmt->IsAutoUpdateFmt())
+ {
+ pFmt->SetFmtAttr(*pSet);
+ SfxItemSet aShellSet(GetPool(), RES_FRM_SIZE, RES_FRM_SIZE,
+ RES_SURROUND, RES_SURROUND,
+ RES_ANCHOR, RES_ANCHOR,
+ RES_VERT_ORIENT,RES_HORI_ORIENT,
+ 0);
+ aShellSet.Put(*pSet);
+ aMgr.SetAttrSet(aShellSet);
+ }
+ else
+ {
+ aMgr.SetAttrSet(*pSet);
+ }
+ aMgr.UpdateFlyFrm();
+
+ bool bApplyUsrPref = false;
+ if (SFX_ITEM_SET == pSet->GetItemState(
+ FN_KEEP_ASPECT_RATIO, true, &pItem ))
+ {
+ aUsrPref.SetKeepRatio(
+ ((const SfxBoolItem*)pItem)->GetValue() );
+ bApplyUsrPref = true;
+ }
+ if( SFX_ITEM_SET == pSet->GetItemState(
+ SID_ATTR_GRAF_KEEP_ZOOM, true, &pItem ))
+ {
+ aUsrPref.SetGrfKeepZoom(
+ ((const SfxBoolItem*)pItem)->GetValue() );
+ bApplyUsrPref = true;
+ }
+
+ if( bApplyUsrPref )
+ SW_MOD()->ApplyUsrPref(aUsrPref, &GetView());
+
+ // and now set all the graphic attributes and other stuff
+ if( SFX_ITEM_SET == pSet->GetItemState(
+ SID_ATTR_GRAF_GRAPHIC, true, &pItem ))
+ {
+ if( !((SvxBrushItem*)pItem)->GetGraphicLink().isEmpty() )
+ sGrfNm = ((SvxBrushItem*)pItem)->GetGraphicLink();
+ else
+ sGrfNm = "";
+
+ if( !((SvxBrushItem*)pItem)->GetGraphicFilter().isEmpty() )
+ sFilterNm = ((SvxBrushItem*)pItem)->GetGraphicFilter();
+ else
+ sFilterNm = "";
+
+ if( !sGrfNm.isEmpty() )
+ {
+ SwDocShell* pDocSh = GetView().GetDocShell();
+ SwWait aWait( *pDocSh, true );
+ SfxMedium* pMedium = pDocSh->GetMedium();
+ INetURLObject aAbs;
+ if( pMedium )
+ aAbs = pMedium->GetURLObject();
+ rSh.ReRead( URIHelper::SmartRel2Abs(
+ aAbs, sGrfNm,
+ URIHelper::GetMaybeFileHdl() ),
+ sFilterNm, 0 );
+ }
+ }
+ if ( SFX_ITEM_SET == pSet->GetItemState(
+ FN_SET_FRM_ALT_NAME, true, &pItem ))
+ {
+ // #i73249#
+ rSh.SetObjTitle( ((const SfxStringItem*)pItem)->GetValue() );
+ }
+
+ SfxItemSet aGrfSet( rSh.GetAttrPool(), RES_GRFATR_BEGIN,
+ RES_GRFATR_END-1 );
+ aGrfSet.Put( *pSet );
+ if( aGrfSet.Count() )
+ rSh.SetAttrSet( aGrfSet );
+
+ rSh.EndUndo(UNDO_END);
+ rSh.EndAllAction();
+ }
+ delete pDlg;
+ }
+ break;
+
+ case FN_GRAPHIC_MIRROR_ON_EVEN_PAGES:
+ {
+ SfxItemSet aSet(rSh.GetAttrPool(), RES_GRFATR_MIRRORGRF, RES_GRFATR_MIRRORGRF);
+ rSh.GetCurAttr( aSet );
+ SwMirrorGrf aGrf((const SwMirrorGrf &)aSet.Get(RES_GRFATR_MIRRORGRF));
+ aGrf.SetGrfToggle(!aGrf.IsGrfToggle());
+ rSh.SetAttrItem(aGrf);
+ }
+ break;
+
+ default:
+ OSL_ENSURE(!this, "wrong dispatcher");
+ return;
+ }
+}
+
+void SwGrfShell::ExecAttr( SfxRequest &rReq )
+{
+ sal_uInt16 nGrfType;
+ if( CNT_GRF == GetShell().GetCntType() &&
+ ( GRAPHIC_BITMAP == ( nGrfType = GetShell().GetGraphicType()) ||
+ GRAPHIC_GDIMETAFILE == nGrfType ))
+ {
+ SfxItemSet aGrfSet( GetShell().GetAttrPool(), RES_GRFATR_BEGIN,
+ RES_GRFATR_END -1 );
+ const SfxItemSet *pArgs = rReq.GetArgs();
+ const SfxPoolItem* pItem;
+ sal_uInt16 nSlot = rReq.GetSlot();
+ if( !pArgs || SFX_ITEM_SET != pArgs->GetItemState( nSlot, false, &pItem ))
+ pItem = 0;
+
+ switch( nSlot )
+ {
+ case SID_FLIP_VERTICAL:
+ case SID_FLIP_HORIZONTAL:
+ {
+ GetShell().GetCurAttr( aGrfSet );
+ SwMirrorGrf aMirror( (SwMirrorGrf&)aGrfSet.Get( RES_GRFATR_MIRRORGRF ) );
+ sal_uInt16 nMirror = aMirror.GetValue();
+ if ( nSlot==SID_FLIP_HORIZONTAL )
+ switch( nMirror )
+ {
+ case RES_MIRROR_GRAPH_DONT: nMirror = RES_MIRROR_GRAPH_VERT;
+ break;
+ case RES_MIRROR_GRAPH_HOR: nMirror = RES_MIRROR_GRAPH_BOTH;
+ break;
+ case RES_MIRROR_GRAPH_VERT: nMirror = RES_MIRROR_GRAPH_DONT;
+ break;
+ case RES_MIRROR_GRAPH_BOTH: nMirror = RES_MIRROR_GRAPH_HOR;
+ break;
+ }
+ else
+ switch( nMirror )
+ {
+ case RES_MIRROR_GRAPH_DONT: nMirror = RES_MIRROR_GRAPH_HOR;
+ break;
+ case RES_MIRROR_GRAPH_VERT: nMirror = RES_MIRROR_GRAPH_BOTH;
+ break;
+ case RES_MIRROR_GRAPH_HOR: nMirror = RES_MIRROR_GRAPH_DONT;
+ break;
+ case RES_MIRROR_GRAPH_BOTH: nMirror = RES_MIRROR_GRAPH_VERT;
+ break;
+ }
+ aMirror.SetValue( nMirror );
+ aGrfSet.ClearItem();
+ aGrfSet.Put( aMirror );
+ }
+ break;
+
+ case SID_ATTR_GRAF_LUMINANCE:
+ if( pItem )
+ aGrfSet.Put( SwLuminanceGrf(
+ ((SfxInt16Item*)pItem)->GetValue() ));
+ break;
+
+ case SID_ATTR_GRAF_CONTRAST:
+ if( pItem )
+ aGrfSet.Put( SwContrastGrf(
+ ((SfxInt16Item*)pItem)->GetValue() ));
+ break;
+
+ case SID_ATTR_GRAF_RED:
+ if( pItem )
+ aGrfSet.Put( SwChannelRGrf(
+ ((SfxInt16Item*)pItem)->GetValue() ));
+ break;
+
+ case SID_ATTR_GRAF_GREEN:
+ if( pItem )
+ aGrfSet.Put( SwChannelGGrf(
+ ((SfxInt16Item*)pItem)->GetValue() ));
+ break;
+
+ case SID_ATTR_GRAF_BLUE:
+ if( pItem )
+ aGrfSet.Put( SwChannelBGrf(
+ ((SfxInt16Item*)pItem)->GetValue() ));
+ break;
+
+ case SID_ATTR_GRAF_GAMMA:
+ if( pItem )
+ {
+ double fVal = ((SfxUInt32Item*)pItem)->GetValue();
+ aGrfSet.Put( SwGammaGrf(fVal/100. ));
+ }
+ break;
+
+ case SID_ATTR_GRAF_TRANSPARENCE:
+ if( pItem )
+ aGrfSet.Put( SwTransparencyGrf(
+ static_cast< sal_Int8 >( ( (SfxUInt16Item*)pItem )->GetValue() ) ) );
+ break;
+
+ case SID_ATTR_GRAF_INVERT:
+ if( pItem )
+ aGrfSet.Put( SwInvertGrf(
+ ((SfxBoolItem*)pItem)->GetValue() ));
+ break;
+
+ case SID_ATTR_GRAF_MODE:
+ if( pItem )
+ aGrfSet.Put( SwDrawModeGrf(
+ ((SfxUInt16Item*)pItem)->GetValue() ));
+ break;
+
+ case SID_COLOR_SETTINGS:
+ {
+ svx::ToolboxAccess aToolboxAccess( TOOLBOX_NAME );
+ aToolboxAccess.toggleToolbox();
+ break;
+ }
+
+ case SID_GRFFILTER:
+ case SID_GRFFILTER_INVERT:
+ case SID_GRFFILTER_SMOOTH:
+ case SID_GRFFILTER_SHARPEN:
+ case SID_GRFFILTER_REMOVENOISE:
+ case SID_GRFFILTER_SOBEL:
+ case SID_GRFFILTER_MOSAIC:
+ case SID_GRFFILTER_EMBOSS:
+ case SID_GRFFILTER_POSTER:
+ case SID_GRFFILTER_POPART:
+ case SID_GRFFILTER_SEPIA:
+ case SID_GRFFILTER_SOLARIZE:
+ if( GRAPHIC_BITMAP == nGrfType )
+ {
+ // #119353# - robust
+ const GraphicObject* pFilterObj( GetShell().GetGraphicObj() );
+ if ( pFilterObj )
+ {
+ GraphicObject aFilterObj( *pFilterObj );
+ if( SVX_GRAPHICFILTER_ERRCODE_NONE ==
+ SvxGraphicFilter::ExecuteGrfFilterSlot( rReq, aFilterObj ))
+ GetShell().ReRead( OUString(), OUString(),
+ &aFilterObj.GetGraphic() );
+ }
+ }
+ break;
+
+ default:
+ OSL_ENSURE(!this, "wrong dispatcher");
+ }
+
+ if( aGrfSet.Count() )
+ GetShell().SetAttrSet( aGrfSet );
+ }
+ GetView().GetViewFrame()->GetBindings().Invalidate(rReq.GetSlot());
+}
+
+void SwGrfShell::GetAttrState(SfxItemSet &rSet)
+{
+ SwWrtShell &rSh = GetShell();
+ SfxItemSet aCoreSet( GetPool(), aNoTxtNodeSetRange );
+ rSh.GetCurAttr( aCoreSet );
+ bool bParentCntProt = 0 != rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT );
+ bool bIsGrfCntnt = CNT_GRF == GetShell().GetCntType();
+
+ SetGetStateSet( &rSet );
+
+ SfxWhichIter aIter( rSet );
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ while( nWhich )
+ {
+ bool bDisable = bParentCntProt;
+ switch( nWhich )
+ {
+ case SID_INSERT_GRAPHIC:
+ case FN_FORMAT_GRAFIC_DLG:
+ case SID_TWAIN_TRANSFER:
+ if( bParentCntProt || !bIsGrfCntnt )
+ bDisable = true;
+ else if ( nWhich == SID_INSERT_GRAPHIC
+ && rSh.CrsrInsideInputFld() )
+ {
+ bDisable = true;
+ }
+ break;
+
+ case SID_SAVE_GRAPHIC:
+ case SID_EXTERNAL_EDIT:
+ if( rSh.GetGraphicType() == GRAPHIC_NONE )
+ bDisable = true;
+ break;
+
+ case SID_COLOR_SETTINGS:
+ {
+ if ( bParentCntProt || !bIsGrfCntnt )
+ bDisable = true;
+ else
+ {
+ svx::ToolboxAccess aToolboxAccess( TOOLBOX_NAME );
+ rSet.Put( SfxBoolItem( nWhich, aToolboxAccess.isToolboxVisible() ) );
+ }
+ break;
+ }
+
+ case SID_FLIP_HORIZONTAL:
+ if( !bParentCntProt )
+ {
+ MirrorGraph nState = static_cast< MirrorGraph >(((const SwMirrorGrf &) aCoreSet.Get(
+ RES_GRFATR_MIRRORGRF )).GetValue());
+
+ rSet.Put(SfxBoolItem( nWhich, nState == RES_MIRROR_GRAPH_VERT ||
+ nState == RES_MIRROR_GRAPH_BOTH));
+ }
+ break;
+
+ case SID_FLIP_VERTICAL:
+ if( !bParentCntProt )
+ {
+ MirrorGraph nState = static_cast< MirrorGraph >(((const SwMirrorGrf &) aCoreSet.Get(
+ RES_GRFATR_MIRRORGRF )).GetValue());
+
+ rSet.Put(SfxBoolItem( nWhich, nState == RES_MIRROR_GRAPH_HOR ||
+ nState == RES_MIRROR_GRAPH_BOTH));
+ }
+ break;
+
+ case SID_ATTR_GRAF_LUMINANCE:
+ if( !bParentCntProt )
+ rSet.Put( SfxInt16Item( nWhich, ((SwLuminanceGrf&)
+ aCoreSet.Get(RES_GRFATR_LUMINANCE)).GetValue() ));
+ break;
+
+ case SID_ATTR_GRAF_CONTRAST:
+ if( !bParentCntProt )
+ rSet.Put( SfxInt16Item( nWhich, ((SwContrastGrf&)
+ aCoreSet.Get(RES_GRFATR_CONTRAST)).GetValue() ));
+ break;
+
+ case SID_ATTR_GRAF_RED:
+ if( !bParentCntProt )
+ rSet.Put( SfxInt16Item( nWhich, ((SwChannelRGrf&)
+ aCoreSet.Get(RES_GRFATR_CHANNELR)).GetValue() ));
+ break;
+
+ case SID_ATTR_GRAF_GREEN:
+ if( !bParentCntProt )
+ rSet.Put( SfxInt16Item( nWhich, ((SwChannelGGrf&)
+ aCoreSet.Get(RES_GRFATR_CHANNELG)).GetValue() ));
+ break;
+
+ case SID_ATTR_GRAF_BLUE:
+ if( !bParentCntProt )
+ rSet.Put( SfxInt16Item( nWhich, ((SwChannelBGrf&)
+ aCoreSet.Get(RES_GRFATR_CHANNELB)).GetValue() ));
+ break;
+
+ case SID_ATTR_GRAF_GAMMA:
+ if( !bParentCntProt )
+ rSet.Put( SfxUInt32Item( nWhich, static_cast< sal_uInt32 >(
+ ( (SwGammaGrf&)aCoreSet.Get( RES_GRFATR_GAMMA ) ).GetValue() * 100 ) ) );
+ break;
+
+ case SID_ATTR_GRAF_TRANSPARENCE:
+ if( !bParentCntProt )
+ {
+ // #119353# - robust
+ const GraphicObject* pGrafObj = rSh.GetGraphicObj();
+ if ( pGrafObj )
+ {
+ if( pGrafObj->IsAnimated() ||
+ GRAPHIC_GDIMETAFILE == pGrafObj->GetType() )
+ bDisable = true;
+ else
+ rSet.Put( SfxUInt16Item( nWhich, ((SwTransparencyGrf&)
+ aCoreSet.Get(RES_GRFATR_TRANSPARENCY)).GetValue() ));
+ }
+ }
+ break;
+
+ case SID_ATTR_GRAF_INVERT:
+ if( !bParentCntProt )
+ rSet.Put( SfxBoolItem( nWhich, ((SwInvertGrf&)
+ aCoreSet.Get(RES_GRFATR_INVERT)).GetValue() ));
+ break;
+
+ case SID_ATTR_GRAF_MODE:
+ if( !bParentCntProt )
+ rSet.Put( SfxUInt16Item( nWhich, ((SwDrawModeGrf&)
+ aCoreSet.Get(RES_GRFATR_DRAWMODE)).GetValue() ));
+ break;
+
+ case SID_GRFFILTER:
+ case SID_GRFFILTER_INVERT:
+ case SID_GRFFILTER_SMOOTH:
+ case SID_GRFFILTER_SHARPEN:
+ case SID_GRFFILTER_REMOVENOISE:
+ case SID_GRFFILTER_SOBEL:
+ case SID_GRFFILTER_MOSAIC:
+ case SID_GRFFILTER_EMBOSS:
+ case SID_GRFFILTER_POSTER:
+ case SID_GRFFILTER_POPART:
+ case SID_GRFFILTER_SEPIA:
+ case SID_GRFFILTER_SOLARIZE:
+ {
+ if( bParentCntProt || !bIsGrfCntnt )
+ bDisable = true;
+ // #i59688# load graphic only if type is unknown
+ else
+ {
+ const sal_uInt16 eGraphicType( rSh.GetGraphicType() );
+ if ( ( eGraphicType == GRAPHIC_NONE ||
+ eGraphicType == GRAPHIC_DEFAULT ) &&
+ rSh.IsGrfSwapOut( sal_True ) )
+ {
+ rSet.DisableItem( nWhich );
+ if( AddGrfUpdateSlot( nWhich ))
+ rSh.GetGraphic(sal_False); // start the loading
+ }
+ else
+ {
+ bDisable = eGraphicType != GRAPHIC_BITMAP;
+ }
+ }
+ }
+ break;
+
+ default:
+ bDisable = false;
+ }
+
+ if( bDisable )
+ rSet.DisableItem( nWhich );
+ nWhich = aIter.NextWhich();
+ }
+ SetGetStateSet( 0 );
+}
+
+void SwGrfShell::ExecuteRotation(SfxRequest &rReq)
+{
+ sal_uInt16 aRotation;
+
+ SwWrtShell& rShell = GetShell();
+
+ if (rReq.GetSlot() == SID_ROTATE_GRAPHIC_LEFT)
+ {
+ aRotation = 900;
+ }
+ else if (rReq.GetSlot() == SID_ROTATE_GRAPHIC_RIGHT)
+ {
+ aRotation = 2700;
+ }
+ else
+ {
+ return;
+ }
+
+ rShell.StartAllAction();
+ rShell.StartUndo(UNDO_START);
+
+ Graphic aGraphic = *rShell.GetGraphic();
+ GraphicNativeTransform aTransform(aGraphic);
+ aTransform.rotate(aRotation);
+ rShell.ReRead(OUString(), OUString(), (const Graphic*) &aGraphic);
+
+ SwFlyFrmAttrMgr aManager(false, &rShell, rShell.IsFrmSelected() ? FRMMGR_TYPE_NONE : FRMMGR_TYPE_GRF);
+ Size aSize(aManager.GetSize().Height(), aManager.GetSize().Width());
+ aManager.SetSize(aSize);
+ aManager.UpdateFlyFrm();
+
+ SfxItemSet aSet( rShell.GetAttrPool(), RES_GRFATR_CROPGRF, RES_GRFATR_CROPGRF );
+ rShell.GetCurAttr( aSet );
+ SwCropGrf aCrop( (const SwCropGrf&) aSet.Get(RES_GRFATR_CROPGRF) );
+ Rectangle aCropRectangle(aCrop.GetLeft(), aCrop.GetTop(), aCrop.GetRight(), aCrop.GetBottom());
+
+ if (rReq.GetSlot() == SID_ROTATE_GRAPHIC_LEFT)
+ {
+ aCrop.SetLeft( aCropRectangle.Top() );
+ aCrop.SetTop( aCropRectangle.Right() );
+ aCrop.SetRight( aCropRectangle.Bottom() );
+ aCrop.SetBottom( aCropRectangle.Left() );
+ }
+ else if (rReq.GetSlot() == SID_ROTATE_GRAPHIC_RIGHT)
+ {
+ aCrop.SetLeft( aCropRectangle.Bottom() );
+ aCrop.SetTop( aCropRectangle.Left() );
+ aCrop.SetRight( aCropRectangle.Top() );
+ aCrop.SetBottom( aCropRectangle.Right() );
+ }
+
+ rShell.SetAttrItem(aCrop);
+
+ rShell.EndUndo(UNDO_END);
+ rShell.EndAllAction();
+}
+
+void SwGrfShell::GetAttrStateForRotation(SfxItemSet &rSet)
+{
+ SwWrtShell& rShell = GetShell();
+ bool bIsParentContentProtected = 0 != rShell.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT );
+
+ SetGetStateSet( &rSet );
+
+ SfxWhichIter aIterator( rSet );
+ sal_uInt16 nWhich = aIterator.FirstWhich();
+ while( nWhich )
+ {
+ bool bDisable = bIsParentContentProtected;
+ switch( nWhich )
+ {
+ case SID_ROTATE_GRAPHIC_LEFT:
+ case SID_ROTATE_GRAPHIC_RIGHT:
+ if( rShell.GetGraphicType() == GRAPHIC_NONE )
+ {
+ bDisable = true;
+ }
+ else
+ {
+ Graphic aGraphic = *rShell.GetGraphic();
+ GraphicNativeTransform aTransform(aGraphic);
+ if (!aTransform.canBeRotated())
+ {
+ bDisable = true;
+ }
+ }
+ break;
+ default:
+ bDisable = false;
+ }
+
+ if( bDisable )
+ rSet.DisableItem( nWhich );
+ nWhich = aIterator.NextWhich();
+ }
+ SetGetStateSet( 0 );
+}
+
+SwGrfShell::SwGrfShell(SwView &_rView) :
+ SwBaseShell(_rView)
+{
+ SetName(OUString("Graphic"));
+ SetHelpId(SW_GRFSHELL);
+ SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_Graphic));
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/shells/grfshex.cxx b/sw/source/core/uibase/shells/grfshex.cxx
new file mode 100644
index 000000000000..60988bac1736
--- /dev/null
+++ b/sw/source/core/uibase/shells/grfshex.cxx
@@ -0,0 +1,154 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <docary.hxx>
+#include <grfsh.hxx>
+#include <wrtsh.hxx>
+#include <view.hxx>
+#include <textsh.hxx>
+#include <viewopt.hxx>
+#include <swundo.hxx>
+#include <shells.hrc>
+#include <caption.hxx>
+#include <vcl/graphicfilter.hxx>
+#include <sfx2/htmlmode.hxx>
+#include <doc.hxx>
+#include <docsh.hxx>
+#include <frmfmt.hxx>
+#include <frmmgr.hxx>
+#include <vcl/msgbox.hxx>
+#include <svx/svdomedia.hxx>
+#include <svx/svdview.hxx>
+#include <svx/svdpagv.hxx>
+#include <SwStyleNameMapper.hxx>
+#include <sfx2/filedlghelper.hxx>
+#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
+#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
+#include <com/sun/star/ui/dialogs/ListboxControlActions.hpp>
+#include <poolfmt.hrc>
+
+#include <sfx2/request.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <svl/stritem.hxx>
+#include <avmedia/mediawindow.hxx>
+#include <vcl/svapp.hxx>
+
+// -> #111827#
+#include <SwRewriter.hxx>
+#include <comcore.hrc>
+// <- #111827#
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::ui::dialogs;
+using namespace ::sfx2;
+
+bool SwTextShell::InsertMediaDlg( SfxRequest& rReq )
+{
+ OUString aURL;
+ const SfxItemSet* pReqArgs = rReq.GetArgs();
+ Window* pWindow = &GetView().GetViewFrame()->GetWindow();
+ bool bAPI = false, bRet = false;
+
+ if( pReqArgs )
+ {
+ const SfxStringItem* pStringItem = PTR_CAST( SfxStringItem, &pReqArgs->Get( rReq.GetSlot() ) );
+
+ if( pStringItem )
+ {
+ aURL = pStringItem->GetValue();
+ bAPI = !aURL.isEmpty();
+ }
+ }
+
+ bool bLink(true);
+ if (bAPI ||
+ ::avmedia::MediaWindow::executeMediaURLDialog(pWindow, aURL, & bLink))
+ {
+ Size aPrefSize;
+
+ if( pWindow )
+ pWindow->EnterWait();
+
+ if( !::avmedia::MediaWindow::isMediaURL( aURL, "", true, &aPrefSize ) )
+ {
+ if( pWindow )
+ pWindow->LeaveWait();
+
+ if( !bAPI )
+ ::avmedia::MediaWindow::executeFormatErrorBox( pWindow );
+ }
+ else
+ {
+ SwWrtShell& rSh = GetShell();
+
+ if( !rSh.HasDrawView() )
+ rSh.MakeDrawView();
+
+ Size aDocSz( rSh.GetDocSize() );
+ const SwRect& rVisArea = rSh.VisArea();
+ Point aPos( rVisArea.Center() );
+ Size aSize;
+
+ if( rVisArea.Width() > aDocSz.Width())
+ aPos.X() = aDocSz.Width() / 2 + rVisArea.Left();
+
+ if(rVisArea.Height() > aDocSz.Height())
+ aPos.Y() = aDocSz.Height() / 2 + rVisArea.Top();
+
+ if( aPrefSize.Width() && aPrefSize.Height() )
+ {
+ if( pWindow )
+ aSize = pWindow->PixelToLogic( aPrefSize, MAP_TWIP );
+ else
+ aSize = Application::GetDefaultDevice()->PixelToLogic( aPrefSize, MAP_TWIP );
+ }
+ else
+ aSize = Size( 2835, 2835 );
+
+ OUString realURL;
+ if (bLink)
+ {
+ realURL = aURL;
+ }
+ else
+ {
+ uno::Reference<frame::XModel> const xModel(
+ rSh.GetDoc()->GetDocShell()->GetModel());
+ bRet = ::avmedia::EmbedMedia(xModel, aURL, realURL);
+ if (!bRet) { return bRet; }
+ }
+
+ SdrMediaObj* pObj = new SdrMediaObj( Rectangle( aPos, aSize ) );
+
+ pObj->SetModel(rSh.GetDoc()->GetDrawModel()); // set before setURL
+ pObj->setURL( realURL, "" );
+ rSh.EnterStdMode();
+ rSh.SwFEShell::InsertDrawObj( *pObj, aPos );
+ bRet = true;
+
+ if( pWindow )
+ pWindow->LeaveWait();
+ }
+ }
+
+ return bRet;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/shells/langhelper.cxx b/sw/source/core/uibase/shells/langhelper.cxx
new file mode 100644
index 000000000000..8342502e12ae
--- /dev/null
+++ b/sw/source/core/uibase/shells/langhelper.cxx
@@ -0,0 +1,612 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <string.h>
+
+#include <vcl/window.hxx>
+
+#include <wrtsh.hxx>
+#include <doc.hxx>
+#include <docary.hxx>
+#include <charfmt.hxx>
+
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/request.hxx>
+#include <editeng/eeitem.hxx>
+#include <editeng/editeng.hxx>
+#include <editeng/editdata.hxx>
+#include <editeng/outliner.hxx>
+#include <editeng/editview.hxx>
+#include <editeng/scripttypeitem.hxx>
+#include <editeng/langitem.hxx>
+
+#include <svl/languageoptions.hxx>
+#include <svtools/langtab.hxx>
+#include <svl/slstitm.hxx>
+#include <svl/stritem.hxx>
+
+#include <ndtxt.hxx>
+#include <pam.hxx>
+#include <view.hxx>
+#include <viewopt.hxx>
+
+#include "swabstdlg.hxx"
+
+#include <vcl/msgbox.hxx>
+
+#include <langhelper.hxx>
+
+using namespace ::com::sun::star;
+
+namespace SwLangHelper
+{
+
+ sal_uInt16 GetLanguageStatus( OutlinerView* pOLV, SfxItemSet& rSet )
+ {
+ ESelection aSelection = pOLV->GetSelection();
+ EditView& rEditView=pOLV->GetEditView();
+ EditEngine* pEditEngine=rEditView.GetEditEngine();
+
+ // the value of used script types
+ const sal_uInt16 nScriptType =pOLV->GetSelectedScriptType();
+ OUString aScriptTypesInUse( OUString::number( nScriptType ) );//pEditEngine->GetScriptType(aSelection)
+
+ SvtLanguageTable aLangTable;
+
+ // get keyboard language
+ OUString aKeyboardLang;
+ LanguageType nLang = LANGUAGE_DONTKNOW;
+
+ Window* pWin = rEditView.GetWindow();
+ if(pWin)
+ nLang = pWin->GetInputLanguage();
+ if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
+ aKeyboardLang = aLangTable.GetString( nLang );
+
+ // get the language that is in use
+ OUString aCurrentLang("*");
+ SfxItemSet aSet(pOLV->GetAttribs());
+ nLang = SwLangHelper::GetCurrentLanguage( aSet,nScriptType );
+ if (nLang != LANGUAGE_DONTKNOW)
+ aCurrentLang = aLangTable.GetString( nLang );
+
+ // build sequence for status value
+ uno::Sequence< OUString > aSeq( 4 );
+ aSeq[0] = aCurrentLang;
+ aSeq[1] = aScriptTypesInUse;
+ aSeq[2] = aKeyboardLang;
+ aSeq[3] = SwLangHelper::GetTextForLanguageGuessing( pEditEngine, aSelection );
+
+ // set sequence as status value
+ SfxStringListItem aItem( SID_LANGUAGE_STATUS );
+ aItem.SetStringList( aSeq );
+ rSet.Put( aItem, SID_LANGUAGE_STATUS );
+ return 0;
+ }
+
+ bool SetLanguageStatus( OutlinerView* pOLV, SfxRequest &rReq, SwView &rView, SwWrtShell &rSh )
+ {
+ bool bRestoreSelection = false;
+ SfxItemSet aEditAttr(pOLV->GetAttribs());
+ ESelection aSelection = pOLV->GetSelection();
+ EditView & rEditView = pOLV->GetEditView();
+ EditEngine * pEditEngine = rEditView.GetEditEngine();
+
+ // get the language
+ OUString aNewLangTxt;
+
+ SFX_REQUEST_ARG( rReq, pItem, SfxStringItem, SID_LANGUAGE_STATUS , false );
+ if (pItem)
+ aNewLangTxt = pItem->GetValue();
+
+ //!! Remember the view frame right now...
+ //!! (call to GetView().GetViewFrame() will break if the
+ //!! SwTextShell got destroyed meanwhile.)
+ SfxViewFrame *pViewFrame = rView.GetViewFrame();
+
+ if (aNewLangTxt == "*" )
+ {
+ // open the dialog "Tools/Options/Language Settings - Language"
+ SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
+ if (pFact)
+ {
+ VclAbstractDialog* pDlg = pFact->CreateVclDialog( rView.GetWindow(), SID_LANGUAGE_OPTIONS );
+ pDlg->Execute();
+ delete pDlg;
+ }
+ }
+ else
+ {
+ // setting the new language...
+ if (!aNewLangTxt.isEmpty())
+ {
+ const OUString aSelectionLangPrefix("Current_");
+ const OUString aParagraphLangPrefix("Paragraph_");
+ const OUString aDocumentLangPrefix("Default_");
+ const OUString aStrNone("LANGUAGE_NONE");
+ const OUString aStrResetLangs("RESET_LANGUAGES");
+
+ sal_Int32 nPos = 0;
+ bool bForSelection = true;
+ bool bForParagraph = false;
+ if (-1 != (nPos = aNewLangTxt.indexOf( aSelectionLangPrefix, 0 )))
+ {
+ // ... for the current selection
+ aNewLangTxt = aNewLangTxt.replaceAt(nPos, aSelectionLangPrefix.getLength(), "");
+ bForSelection = true;
+ }
+ else if (-1 != (nPos = aNewLangTxt.indexOf( aParagraphLangPrefix , 0 )))
+ {
+ // ... for the current paragraph language
+ aNewLangTxt = aNewLangTxt.replaceAt(nPos, aParagraphLangPrefix.getLength(), "");
+ bForSelection = true;
+ bForParagraph = true;
+ }
+ else if (-1 != (nPos = aNewLangTxt.indexOf( aDocumentLangPrefix , 0 )))
+ {
+ // ... as default document language
+ aNewLangTxt = aNewLangTxt.replaceAt(nPos, aDocumentLangPrefix.getLength(), "");
+ bForSelection = false;
+ }
+
+ if (bForParagraph)
+ {
+ bRestoreSelection = true;
+ SwLangHelper::SelectPara( rEditView, aSelection );
+ aSelection = pOLV->GetSelection();
+ }
+ if (!bForSelection) // document language to be changed...
+ {
+ rSh.StartAction();
+ rSh.LockView( sal_True );
+ rSh.Push();
+
+ // prepare to apply new language to all text in document
+ rSh.SelAll();
+ rSh.ExtendedSelectAll();
+ }
+
+ if (aNewLangTxt == aStrNone)
+ SwLangHelper::SetLanguage_None( rSh, pOLV, aSelection, bForSelection, aEditAttr );
+ else if (aNewLangTxt == aStrResetLangs)
+ SwLangHelper::ResetLanguages( rSh, pOLV, aSelection, bForSelection );
+ else
+ SwLangHelper::SetLanguage( rSh, pOLV, aSelection, aNewLangTxt, bForSelection, aEditAttr );
+
+ // ugly hack, as it seems that EditView/EditEngine does not update their spellchecking marks
+ // when setting a new language attribute
+ if (bForSelection)
+ {
+ const SwViewOption* pVOpt = rView.GetWrtShellPtr()->GetViewOptions();
+ sal_uLong nCntrl = pEditEngine->GetControlWord();
+ // turn off
+ nCntrl &= ~EE_CNTRL_ONLINESPELLING;
+ pEditEngine->SetControlWord(nCntrl);
+
+ //turn back on
+ if (pVOpt->IsOnlineSpell())
+ nCntrl |= EE_CNTRL_ONLINESPELLING;
+ else
+ nCntrl &= ~EE_CNTRL_ONLINESPELLING;
+ pEditEngine->SetControlWord(nCntrl);
+
+ pEditEngine->CompleteOnlineSpelling();
+ rEditView.Invalidate();
+ }
+
+ if (!bForSelection)
+ {
+ // need to release view and restore selection...
+ rSh.Pop( sal_False );
+ rSh.LockView( sal_False );
+ rSh.EndAction();
+ }
+ }
+ }
+
+ // invalidate slot to get the new language displayed
+ pViewFrame->GetBindings().Invalidate( rReq.GetSlot() );
+
+ rReq.Done();
+ return bRestoreSelection;
+ }
+
+ void SetLanguage( SwWrtShell &rWrtSh, const OUString &rLangText, bool bIsForSelection, SfxItemSet &rCoreSet )
+ {
+ SetLanguage( rWrtSh, 0 , ESelection(), rLangText, bIsForSelection, rCoreSet );
+ }
+
+ void SetLanguage( SwWrtShell &rWrtSh, OutlinerView* pOLV, ESelection aSelection, const OUString &rLangText, bool bIsForSelection, SfxItemSet &rCoreSet )
+ {
+ const LanguageType nLang = SvtLanguageTable().GetType( rLangText );
+ if (nLang != LANGUAGE_DONTKNOW)
+ {
+ sal_uInt16 nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( nLang );
+
+ EditEngine* pEditEngine = pOLV ? pOLV->GetEditView().GetEditEngine() : NULL;
+ OSL_ENSURE( !pOLV || pEditEngine, "OutlinerView without EditEngine???" );
+
+ //get ScriptType
+ sal_uInt16 nLangWhichId = 0;
+ bool bIsSingleScriptType = true;
+ switch (nScriptType)
+ {
+ case SCRIPTTYPE_LATIN : nLangWhichId = pEditEngine ? EE_CHAR_LANGUAGE : RES_CHRATR_LANGUAGE; break;
+ case SCRIPTTYPE_ASIAN : nLangWhichId = pEditEngine ? EE_CHAR_LANGUAGE_CJK : RES_CHRATR_CJK_LANGUAGE; break;
+ case SCRIPTTYPE_COMPLEX : nLangWhichId = pEditEngine ? EE_CHAR_LANGUAGE_CTL : RES_CHRATR_CTL_LANGUAGE; break;
+ default:
+ bIsSingleScriptType = false;
+ OSL_FAIL("unexpected case" );
+ }
+ if (bIsSingleScriptType)
+ {
+ // change language for selection or paragraph
+ // (for paragraph is handled by previosuly having set the selection to the
+ // whole paragraph)
+ if (bIsForSelection)
+ {
+ // apply language to current selection
+ if (pEditEngine)
+ {
+ rCoreSet.Put( SvxLanguageItem( nLang, nLangWhichId ));
+ pEditEngine->QuickSetAttribs( rCoreSet, aSelection);
+ }
+ else
+ {
+ rWrtSh.GetCurAttr( rCoreSet );
+ rCoreSet.Put( SvxLanguageItem( nLang, nLangWhichId ));
+ rWrtSh.SetAttrSet( rCoreSet );
+ }
+ }
+ else // change language for all text
+ {
+ // set document default language
+ switch (nLangWhichId)
+ {
+ case EE_CHAR_LANGUAGE : nLangWhichId = RES_CHRATR_LANGUAGE; break;
+ case EE_CHAR_LANGUAGE_CJK : nLangWhichId = RES_CHRATR_CJK_LANGUAGE; break;
+ case EE_CHAR_LANGUAGE_CTL : nLangWhichId = RES_CHRATR_CTL_LANGUAGE; break;
+ }
+ //Set the default document language
+ rWrtSh.SetDefault( SvxLanguageItem( nLang, nLangWhichId ) );
+
+ //Resolves: fdo#35282 Clear the language from all Text Styles, and
+ //fallback to default document language
+ const SwTxtFmtColls *pColls = rWrtSh.GetDoc()->GetTxtFmtColls();
+ for(sal_uInt16 i = 0, nCount = pColls->size(); i < nCount; ++i)
+ {
+ SwTxtFmtColl &rTxtColl = *(*pColls)[ i ];
+ rTxtColl.ResetFmtAttr(nLangWhichId);
+ }
+ //Resolves: fdo#35282 Clear the language from all Character Styles,
+ //and fallback to default document language
+ const SwCharFmts *pCharFmts = rWrtSh.GetDoc()->GetCharFmts();
+ for(sal_uInt16 i = 0, nCount = pCharFmts->size(); i < nCount; ++i)
+ {
+ SwCharFmt &rCharFmt = *(*pCharFmts)[ i ];
+ rCharFmt.ResetFmtAttr(nLangWhichId);
+ }
+
+ // #i102191: hard set respective language attribute in text document
+ // (for all text in the document - which should be selected by now...)
+ rWrtSh.SetAttrItem( SvxLanguageItem( nLang, nLangWhichId ) );
+ }
+ }
+ }
+ }
+
+ void SetLanguage_None( SwWrtShell &rWrtSh, bool bIsForSelection, SfxItemSet &rCoreSet )
+ {
+ SetLanguage_None( rWrtSh,0,ESelection(),bIsForSelection,rCoreSet );
+ }
+
+ void SetLanguage_None( SwWrtShell &rWrtSh, OutlinerView* pOLV, ESelection aSelection, bool bIsForSelection, SfxItemSet &rCoreSet )
+ {
+ // EditEngine IDs
+ const sal_uInt16 aLangWhichId_EE[3] =
+ {
+ EE_CHAR_LANGUAGE,
+ EE_CHAR_LANGUAGE_CJK,
+ EE_CHAR_LANGUAGE_CTL
+ };
+
+ // Writewr IDs
+ const sal_uInt16 aLangWhichId_Writer[3] =
+ {
+ RES_CHRATR_LANGUAGE,
+ RES_CHRATR_CJK_LANGUAGE,
+ RES_CHRATR_CTL_LANGUAGE
+ };
+
+ if (bIsForSelection)
+ {
+ // change language for selection or paragraph
+ // (for paragraph is handled by previosuly having set the selection to the
+ // whole paragraph)
+
+ EditEngine* pEditEngine = pOLV ? pOLV->GetEditView().GetEditEngine() : NULL;
+ OSL_ENSURE( !pOLV || pEditEngine, "OutlinerView without EditEngine???" );
+ if (pEditEngine)
+ {
+ for (sal_uInt16 i = 0; i < 3; ++i)
+ rCoreSet.Put( SvxLanguageItem( LANGUAGE_NONE, aLangWhichId_EE[i] ));
+ pEditEngine->QuickSetAttribs( rCoreSet, aSelection);
+ }
+ else
+ {
+ rWrtSh.GetCurAttr( rCoreSet );
+ for (sal_uInt16 i = 0; i < 3; ++i)
+ rCoreSet.Put( SvxLanguageItem( LANGUAGE_NONE, aLangWhichId_Writer[i] ));
+ rWrtSh.SetAttrSet( rCoreSet );
+ }
+ }
+ else // change language for all text
+ {
+ std::set<sal_uInt16> aAttribs;
+ for (sal_uInt16 i = 0; i < 3; ++i)
+ {
+ rWrtSh.SetDefault( SvxLanguageItem( LANGUAGE_NONE, aLangWhichId_Writer[i] ) );
+ aAttribs.insert( aLangWhichId_Writer[i] );
+ }
+
+ // set all language attributes to default
+ // (for all text in the document - which should be selected by now...)
+ rWrtSh.ResetAttr( aAttribs );
+ }
+ }
+
+ void ResetLanguages( SwWrtShell &rWrtSh, bool bIsForSelection )
+ {
+ ResetLanguages( rWrtSh, 0 , ESelection(), bIsForSelection );
+ }
+
+ void ResetLanguages( SwWrtShell &rWrtSh, OutlinerView* pOLV, ESelection aSelection, bool bIsForSelection )
+ {
+ (void) bIsForSelection;
+ (void) aSelection;
+
+ // reset language for current selection.
+ // The selection should already have been expanded to the whole paragraph or
+ // to all text in the document if those are the ranges where to reset
+ // the language attributes
+
+ if (pOLV)
+ {
+ EditView &rEditView = pOLV->GetEditView();
+ rEditView.RemoveAttribs( true, EE_CHAR_LANGUAGE );
+ rEditView.RemoveAttribs( true, EE_CHAR_LANGUAGE_CJK );
+ rEditView.RemoveAttribs( true, EE_CHAR_LANGUAGE_CTL );
+ }
+ else
+ {
+ std::set<sal_uInt16> aAttribs;
+ aAttribs.insert( RES_CHRATR_LANGUAGE );
+ aAttribs.insert( RES_CHRATR_CJK_LANGUAGE );
+ aAttribs.insert( RES_CHRATR_CTL_LANGUAGE );
+ rWrtSh.ResetAttr( aAttribs );
+ }
+ }
+
+ /// @returns : the language for the selected text that is set for the
+ /// specified attribute (script type).
+ /// If there are more than one languages used LANGUAGE_DONTKNOW will be returned.
+ /// @param nLangWhichId : one of
+ /// RES_CHRATR_LANGUAGE, RES_CHRATR_CJK_LANGUAGE, RES_CHRATR_CTL_LANGUAGE,
+ LanguageType GetLanguage( SwWrtShell &rSh, sal_uInt16 nLangWhichId )
+ {
+ SfxItemSet aSet( rSh.GetAttrPool(), nLangWhichId, nLangWhichId );
+ rSh.GetCurAttr( aSet );
+
+ return GetLanguage(aSet,nLangWhichId);
+ }
+
+ LanguageType GetLanguage( SfxItemSet aSet, sal_uInt16 nLangWhichId )
+ {
+
+ LanguageType nLang = LANGUAGE_SYSTEM;
+
+ const SfxPoolItem *pItem = 0;
+ SfxItemState nState = aSet.GetItemState( nLangWhichId, true, &pItem );
+ if (nState > SFX_ITEM_DEFAULT && pItem)
+ {
+ // the item is set and can be used
+ nLang = (dynamic_cast< const SvxLanguageItem* >(pItem))->GetLanguage();
+ }
+ else if (nState == SFX_ITEM_DEFAULT)
+ {
+ // since the attribute is not set: retrieve the default value
+ nLang = (dynamic_cast< const SvxLanguageItem& >(aSet.GetPool()->GetDefaultItem( nLangWhichId ))).GetLanguage();
+ }
+ else if (nState == SFX_ITEM_DONTCARE)
+ {
+ // there is more than one language...
+ nLang = LANGUAGE_DONTKNOW;
+ }
+ OSL_ENSURE( nLang != LANGUAGE_SYSTEM, "failed to get the language?" );
+
+ return nLang;
+ }
+
+ /// @returns: the language in use for the selected text.
+ /// 'In use' means the language(s) matching the script type(s) of the
+ /// selected text. Or in other words, the language a spell checker would use.
+ /// If there is more than one language LANGUAGE_DONTKNOW will be returned.
+ LanguageType GetCurrentLanguage( SwWrtShell &rSh )
+ {
+ // get all script types used in current selection
+ const sal_uInt16 nScriptType = rSh.GetScriptType();
+
+ //set language attribute to use according to the script type
+ sal_uInt16 nLangWhichId = 0;
+ bool bIsSingleScriptType = true;
+ switch (nScriptType)
+ {
+ case SCRIPTTYPE_LATIN : nLangWhichId = RES_CHRATR_LANGUAGE; break;
+ case SCRIPTTYPE_ASIAN : nLangWhichId = RES_CHRATR_CJK_LANGUAGE; break;
+ case SCRIPTTYPE_COMPLEX : nLangWhichId = RES_CHRATR_CTL_LANGUAGE; break;
+ default: bIsSingleScriptType = false; break;
+ }
+
+ // get language according to the script type(s) in use
+ LanguageType nCurrentLang = LANGUAGE_SYSTEM;
+ if (bIsSingleScriptType)
+ nCurrentLang = GetLanguage( rSh, nLangWhichId );
+ else
+ {
+ // check if all script types are set to LANGUAGE_NONE and return
+ // that if this is the case. Otherwise, having multiple script types
+ // in use always means there are several languages in use...
+ const sal_uInt16 aScriptTypes[3] =
+ {
+ RES_CHRATR_LANGUAGE,
+ RES_CHRATR_CJK_LANGUAGE,
+ RES_CHRATR_CTL_LANGUAGE
+ };
+ nCurrentLang = LANGUAGE_NONE;
+ for (sal_uInt16 i = 0; i < 3; ++i)
+ {
+ LanguageType nTmpLang = GetLanguage( rSh, aScriptTypes[i] );
+ if (nTmpLang != LANGUAGE_NONE)
+ {
+ nCurrentLang = LANGUAGE_DONTKNOW;
+ break;
+ }
+ }
+ }
+ OSL_ENSURE( nCurrentLang != LANGUAGE_SYSTEM, "failed to get the language?" );
+
+ return nCurrentLang;
+ }
+
+ /// @returns: the language in use for the selected text.
+ /// 'In use' means the language(s) matching the script type(s) of the
+ /// selected text. Or in other words, the language a spell checker would use.
+ /// If there is more than one language LANGUAGE_DONTKNOW will be returned.
+ LanguageType GetCurrentLanguage( SfxItemSet aSet, sal_uInt16 nScriptType )
+ {
+ //set language attribute to use according to the script type
+ sal_uInt16 nLangWhichId = 0;
+ bool bIsSingleScriptType = true;
+ switch (nScriptType)
+ {
+ case SCRIPTTYPE_LATIN : nLangWhichId = EE_CHAR_LANGUAGE; break;
+ case SCRIPTTYPE_ASIAN : nLangWhichId = EE_CHAR_LANGUAGE_CJK; break;
+ case SCRIPTTYPE_COMPLEX : nLangWhichId = EE_CHAR_LANGUAGE_CTL; break;
+ default: bIsSingleScriptType = false;
+ }
+
+ // get language according to the script type(s) in use
+ LanguageType nCurrentLang = LANGUAGE_SYSTEM;
+ if (bIsSingleScriptType)
+ nCurrentLang = GetLanguage( aSet, nLangWhichId );
+ else
+ {
+ // check if all script types are set to LANGUAGE_NONE and return
+ // that if this is the case. Otherwise, having multiple script types
+ // in use always means there are several languages in use...
+ const sal_uInt16 aScriptTypes[3] =
+ {
+ EE_CHAR_LANGUAGE,
+ EE_CHAR_LANGUAGE_CJK,
+ EE_CHAR_LANGUAGE_CTL
+ };
+ nCurrentLang = LANGUAGE_NONE;
+ for (sal_uInt16 i = 0; i < 3; ++i)
+ {
+ LanguageType nTmpLang = GetLanguage( aSet, aScriptTypes[i] );
+ if (nTmpLang != LANGUAGE_NONE)
+ {
+ nCurrentLang = LANGUAGE_DONTKNOW;
+ break;
+ }
+ }
+ }
+ OSL_ENSURE( nCurrentLang != LANGUAGE_SYSTEM, "failed to get the language?" );
+
+ return nCurrentLang;
+ }
+
+ OUString GetTextForLanguageGuessing( SwWrtShell &rSh )
+ {
+ // string for guessing language
+ OUString aText;
+ SwPaM *pCrsr = rSh.GetCrsr();
+ SwTxtNode *pNode = pCrsr->GetNode()->GetTxtNode();
+ if (pNode)
+ {
+ aText = pNode->GetTxt();
+ if (!aText.isEmpty())
+ {
+ sal_Int32 nEnd = pCrsr->GetPoint()->nContent.GetIndex();
+ // at most 100 chars to the left...
+ const sal_Int32 nStt = nEnd > 100 ? nEnd - 100 : 0;
+ // ... and 100 to the right of the cursor position
+ nEnd = aText.getLength() - nEnd > 100 ? nEnd + 100 : aText.getLength();
+ aText = aText.copy( nStt, nEnd - nStt );
+ }
+ }
+ return aText;
+ }
+
+ OUString GetTextForLanguageGuessing( EditEngine* rEditEngine, ESelection aDocSelection )
+ {
+ // string for guessing language
+ OUString aText;
+
+ aText = rEditEngine->GetText(aDocSelection);
+ if (!aText.isEmpty())
+ {
+ sal_Int32 nStt = 0;
+ sal_Int32 nEnd = aDocSelection.nEndPos;
+ // at most 100 chars to the left...
+ nStt = nEnd > 100 ? nEnd - 100 : 0;
+ // ... and 100 to the right of the cursor position
+ nEnd = aText.getLength() - nEnd > 100 ? nEnd + 100 : aText.getLength();
+ aText = aText.copy( nStt, nEnd - nStt );
+ }
+
+ return aText;
+ }
+
+ void SelectPara( EditView &rEditView, const ESelection &rCurSel )
+ {
+ ESelection aParaSel( rCurSel.nStartPara, 0, rCurSel.nStartPara, EE_TEXTPOS_ALL );
+ rEditView.SetSelection( aParaSel );
+ }
+
+ void SelectCurrentPara( SwWrtShell &rWrtSh )
+ {
+ // select current para
+ if (!rWrtSh.IsSttPara())
+ rWrtSh.MovePara( fnParaCurr, fnParaStart );
+ if (!rWrtSh.HasMark())
+ rWrtSh.SetMark();
+ rWrtSh.SwapPam();
+ if (!rWrtSh.IsEndPara())
+ rWrtSh.MovePara( fnParaCurr, fnParaEnd );
+ #if OSL_DEBUG_LEVEL > 1
+ OUString aSelTxt;
+ rWrtSh.GetSelectedText( aSelTxt );
+ (void) aSelTxt;
+ #endif
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/shells/listsh.cxx b/sw/source/core/uibase/shells/listsh.cxx
new file mode 100644
index 000000000000..ae32351c3db8
--- /dev/null
+++ b/sw/source/core/uibase/shells/listsh.cxx
@@ -0,0 +1,280 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "cmdid.h"
+#include "hintids.hxx"
+#include <editeng/sizeitem.hxx>
+#include <editeng/brushitem.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/objface.hxx>
+#include <sfx2/bindings.hxx>
+#include <svl/stritem.hxx>
+#include <svl/eitem.hxx>
+#include <svl/whiter.hxx>
+#include <svl/intitem.hxx>
+#include <tools/shl.hxx>
+#include <svl/srchitem.hxx>
+
+#include <numrule.hxx>
+#include <fmtornt.hxx>
+#include "wrtsh.hxx"
+#include "swmodule.hxx"
+#include "frmatr.hxx"
+#include "helpid.h"
+#include "globals.hrc"
+#include "shells.hrc"
+#include "uinums.hxx"
+#include "listsh.hxx"
+#include "poolfmt.hxx"
+#include "view.hxx"
+#include "edtwin.hxx"
+
+#define SwListShell
+#include <sfx2/msg.hxx>
+#include "swslots.hxx"
+
+#include <IDocumentOutlineNodes.hxx>
+
+SFX_IMPL_INTERFACE(SwListShell, SwBaseShell, SW_RES(STR_SHELLNAME_LIST))
+{
+ SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_NUM_TOOLBOX));
+}
+
+TYPEINIT1(SwListShell,SwBaseShell)
+
+// #i35572# Functionality of Numbering/Bullet toolbar
+// for outline numbered paragraphs should match the functions for outlines
+// available in the navigator. Therefore the code in the following
+// function is quite similar the code in SwContentTree::ExecCommand.
+static void lcl_OutlineUpDownWithSubPoints( SwWrtShell& rSh, bool bMove, bool bUp )
+{
+ const sal_uInt16 nActPos = rSh.GetOutlinePos();
+ if ( nActPos < USHRT_MAX && rSh.IsOutlineMovable( nActPos ) )
+ {
+ rSh.Push();
+ rSh.MakeOutlineSel( nActPos, nActPos, sal_True );
+
+ if ( bMove )
+ {
+ const IDocumentOutlineNodes* pIDoc( rSh.getIDocumentOutlineNodesAccess() );
+ const sal_uInt16 nActLevel = static_cast<sal_uInt16>(pIDoc->getOutlineLevel( nActPos ));
+ sal_uInt16 nActEndPos = nActPos + 1;
+ sal_Int16 nDir = 0;
+
+ if ( !bUp )
+ {
+ // Move down with subpoints:
+ while ( nActEndPos < pIDoc->getOutlineNodesCount() &&
+ pIDoc->getOutlineLevel( nActEndPos ) > nActLevel )
+ ++nActEndPos;
+
+ if ( nActEndPos < pIDoc->getOutlineNodesCount() )
+ {
+ // The current subpoint which should be moved
+ // starts at nActPos and ends at nActEndPos - 1
+ --nActEndPos;
+ sal_uInt16 nDest = nActEndPos + 2;
+ while ( nDest < pIDoc->getOutlineNodesCount() &&
+ pIDoc->getOutlineLevel( nDest ) > nActLevel )
+ ++nDest;
+
+ nDir = nDest - 1 - nActEndPos;
+ }
+ }
+ else
+ {
+ // Move up with subpoints:
+ if ( nActPos > 0 )
+ {
+ --nActEndPos;
+ sal_uInt16 nDest = nActPos - 1;
+ while ( nDest > 0 && pIDoc->getOutlineLevel( nDest ) > nActLevel )
+ --nDest;
+
+ nDir = nDest - nActPos;
+ }
+ }
+
+ if ( nDir )
+ {
+ rSh.MoveOutlinePara( nDir );
+ rSh.GotoOutline( nActPos + nDir );
+ }
+ }
+ else
+ {
+ // Up/down with subpoints:
+ rSh.OutlineUpDown( bUp ? -1 : 1 );
+ }
+
+ rSh.ClearMark();
+ rSh.Pop( sal_False );
+ }
+}
+
+void SwListShell::Execute(SfxRequest &rReq)
+{
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ sal_uInt16 nSlot = rReq.GetSlot();
+ SwWrtShell& rSh = GetShell();
+
+ // #i35572#
+ const SwNumRule* pCurRule = rSh.GetCurNumRule();
+ OSL_ENSURE( pCurRule, "SwListShell::Execute without NumRule" );
+ bool bOutline = pCurRule && pCurRule->IsOutlineRule();
+
+ switch (nSlot)
+ {
+ case FN_NUM_BULLET_DOWN:
+ case FN_NUM_BULLET_UP:
+ {
+ SfxViewFrame * pFrame = GetView().GetViewFrame();
+
+ rReq.Done();
+ rSh.NumUpDown( nSlot == FN_NUM_BULLET_DOWN );
+ pFrame->GetBindings().Invalidate( SID_TABLE_CELL ); // Update status line!
+ }
+ break;
+
+ case FN_NUM_BULLET_NEXT:
+ rSh.GotoNextNum();
+ rReq.Done();
+ break;
+
+ case FN_NUM_BULLET_NONUM:
+ rSh.NoNum();
+ rReq.Done();
+ break;
+
+ case FN_NUM_BULLET_OFF:
+ {
+ rReq.Ignore();
+ SfxRequest aReq( GetView().GetViewFrame(), FN_NUM_BULLET_ON );
+ aReq.AppendItem( SfxBoolItem( FN_PARAM_1, false ) );
+ aReq.Done();
+ rSh.DelNumRules();
+ break;
+ }
+
+ case FN_NUM_BULLET_OUTLINE_DOWN:
+ if ( bOutline )
+ lcl_OutlineUpDownWithSubPoints( rSh, false, false );
+ else
+ rSh.MoveNumParas(false, false);
+ rReq.Done();
+ break;
+
+ case FN_NUM_BULLET_OUTLINE_MOVEDOWN:
+ if ( bOutline )
+ lcl_OutlineUpDownWithSubPoints( rSh, true, false );
+ else
+ rSh.MoveNumParas(true, false);
+ rReq.Done();
+ break;
+
+ case FN_NUM_BULLET_OUTLINE_MOVEUP:
+ if ( bOutline )
+ lcl_OutlineUpDownWithSubPoints( rSh, true, true );
+ else
+ rSh.MoveNumParas(true, true);
+ rReq.Done();
+ break;
+
+ case FN_NUM_BULLET_OUTLINE_UP:
+ if ( bOutline )
+ lcl_OutlineUpDownWithSubPoints( rSh, false, true );
+ else
+ rSh.MoveNumParas(false, true);
+ rReq.Done();
+ break;
+
+ case FN_NUM_BULLET_PREV:
+ rSh.GotoPrevNum();
+ rReq.Done();
+ break;
+
+ case FN_NUM_OR_NONUM:
+ {
+ sal_Bool bApi = rReq.IsAPI();
+ sal_Bool bDelete = !rSh.IsNoNum(!bApi);
+ if(pArgs )
+ bDelete = ((SfxBoolItem &)pArgs->Get(rReq.GetSlot())).GetValue();
+ rSh.NumOrNoNum( bDelete, !bApi );
+ rReq.AppendItem( SfxBoolItem( nSlot, bDelete ) );
+ rReq.Done();
+ }
+ break;
+ default:
+ OSL_ENSURE(!this, "wrong dispatcher");
+ return;
+ }
+}
+
+void SwListShell::GetState(SfxItemSet &rSet)
+{
+ SfxWhichIter aIter( rSet );
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ SwWrtShell& rSh = GetShell();
+ sal_uInt8 nCurrentNumLevel = rSh.GetNumLevel();
+ while ( nWhich )
+ {
+ switch( nWhich )
+ {
+ case FN_NUM_OR_NONUM:
+ rSet.Put(SfxBoolItem(nWhich, GetShell().IsNoNum(sal_False)));
+ break;
+ case FN_NUM_BULLET_OUTLINE_UP:
+ case FN_NUM_BULLET_UP:
+ if(!nCurrentNumLevel)
+ rSet.DisableItem(nWhich);
+ break;
+ case FN_NUM_BULLET_OUTLINE_DOWN :
+ {
+ sal_uInt8 nUpper = 0;
+ sal_uInt8 nLower = 0;
+ rSh.GetCurrentOutlineLevels( nUpper, nLower );
+ if(nLower == (MAXLEVEL - 1))
+ rSet.DisableItem(nWhich);
+ }
+ break;
+ case FN_NUM_BULLET_DOWN:
+ if(nCurrentNumLevel == (MAXLEVEL - 1))
+ rSet.DisableItem(nWhich);
+ break;
+
+ case FN_NUM_BULLET_NONUM:
+ if ( rSh.CrsrInsideInputFld() )
+ {
+ rSet.DisableItem(nWhich);
+ }
+ break;
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+SwListShell::SwListShell(SwView &_rView) :
+ SwBaseShell(_rView)
+{
+ SetName(OUString("List"));
+ SetHelpId(SW_LISTSHELL);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/shells/mediash.cxx b/sw/source/core/uibase/shells/mediash.cxx
new file mode 100644
index 000000000000..6f9671c42322
--- /dev/null
+++ b/sw/source/core/uibase/shells/mediash.cxx
@@ -0,0 +1,199 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <cmdid.h>
+#include <hintids.hxx>
+#include <vcl/msgbox.hxx>
+#include <svl/stritem.hxx>
+#include <svl/whiter.hxx>
+#include <svl/urihelper.hxx>
+#include <sfx2/dispatch.hxx>
+#include <editeng/sizeitem.hxx>
+#include <editeng/protitem.hxx>
+#include <sfx2/request.hxx>
+#include <svl/srchitem.hxx>
+#include <sfx2/htmlmode.hxx>
+#include <svx/sdgluitm.hxx>
+#include <svx/sdgcoitm.hxx>
+#include <svx/sdggaitm.hxx>
+#include <svx/sdgtritm.hxx>
+#include <svx/sdginitm.hxx>
+#include <svx/sdgmoitm.hxx>
+#include <editeng/brushitem.hxx>
+#include <svx/grfflt.hxx>
+#include <fmturl.hxx>
+#include <view.hxx>
+#include <wrtsh.hxx>
+#include <viewopt.hxx>
+#include <swmodule.hxx>
+#include <frmatr.hxx>
+#include <swundo.hxx>
+#include <uitool.hxx>
+#include <docsh.hxx>
+#include <mediash.hxx>
+#include <frmmgr.hxx>
+#include <frmdlg.hxx>
+#include <frmfmt.hxx>
+#include <grfatr.hxx>
+#include <usrpref.hxx>
+#include <edtwin.hxx>
+#include <swwait.hxx>
+#include <shells.hrc>
+#include <popup.hrc>
+
+#include <sfx2/objface.hxx>
+#include <sfx2/sidebar/EnumContext.hxx>
+#include <svx/svdomedia.hxx>
+#include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx>
+#include <avmedia/mediaitem.hxx>
+
+#define SwMediaShell
+#include <sfx2/msg.hxx>
+#include "swslots.hxx"
+#include "swabstdlg.hxx"
+
+SFX_IMPL_INTERFACE(SwMediaShell, SwBaseShell, SW_RES(STR_SHELLNAME_MEDIA))
+{
+ SFX_POPUPMENU_REGISTRATION(SW_RES(MN_MEDIA_POPUPMENU));
+ SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_MEDIA_TOOLBOX));
+}
+
+void SwMediaShell::ExecMedia(SfxRequest &rReq)
+{
+ SwWrtShell* pSh = &GetShell();
+ SdrView* pSdrView = pSh->GetDrawView();
+
+ if( pSdrView )
+ {
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ sal_uInt16 nSlotId = rReq.GetSlot();
+ sal_Bool bChanged = pSdrView->GetModel()->IsChanged();
+
+ pSdrView->GetModel()->SetChanged( false );
+
+ switch( nSlotId )
+ {
+ case SID_DELETE:
+ {
+ if( pSh->IsObjSelected() )
+ {
+ pSh->SetModified();
+ pSh->DelSelectedObj();
+
+ if( pSh->IsSelFrmMode() )
+ pSh->LeaveSelFrmMode();
+
+ GetView().AttrChangedNotify( pSh );
+ }
+ }
+ break;
+
+ case( SID_AVMEDIA_TOOLBOX ):
+ {
+ if( pSh->IsObjSelected() )
+ {
+ const SfxPoolItem* pItem;
+
+ if( !pArgs || ( SFX_ITEM_SET != pArgs->GetItemState( SID_AVMEDIA_TOOLBOX, false, &pItem ) ) )
+ pItem = NULL;
+
+ if( pItem )
+ {
+ SdrMarkList* pMarkList = new SdrMarkList( pSdrView->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;
+ }
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ if( pSdrView->GetModel()->IsChanged() )
+ GetShell().SetModified();
+ else if( bChanged )
+ pSdrView->GetModel()->SetChanged(true);
+ }
+}
+
+void SwMediaShell::GetMediaState(SfxItemSet &rSet)
+{
+ SfxWhichIter aIter( rSet );
+ sal_uInt16 nWhich = aIter.FirstWhich();
+
+ while( nWhich )
+ {
+ if( SID_AVMEDIA_TOOLBOX == nWhich )
+ {
+ SwWrtShell& rSh = GetShell();
+ SdrView* pView = rSh.GetDrawView();
+
+ if( pView )
+ {
+ bool bDisable = true;
+ SdrMarkList* pMarkList = new SdrMarkList( pView->GetMarkedObjectList() );
+
+ 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();
+ }
+}
+
+SwMediaShell::SwMediaShell(SwView &_rView) :
+ SwBaseShell(_rView)
+
+{
+ SetName(OUString("Media Playback"));
+ SetHelpId(SW_MEDIASHELL);
+ SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_Media));
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/shells/navsh.cxx b/sw/source/core/uibase/shells/navsh.cxx
new file mode 100644
index 000000000000..c5a9199daa32
--- /dev/null
+++ b/sw/source/core/uibase/shells/navsh.cxx
@@ -0,0 +1,106 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "cmdid.h"
+#include <svx/svdview.hxx>
+#include <svl/srchitem.hxx>
+#include <svl/eitem.hxx>
+#include <svl/whiter.hxx>
+#include <svx/svdopath.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/objface.hxx>
+#include "wrtsh.hxx"
+#include "view.hxx"
+#include "edtwin.hxx"
+#include "helpid.h"
+#include "globals.hrc"
+#include "navsh.hxx"
+#include "popup.hrc"
+#include "shells.hrc"
+#define SwNavigationShell
+#include "swslots.hxx"
+#include <unomid.h>
+#include "navmgr.hxx"
+
+SFX_IMPL_INTERFACE(SwNavigationShell, SwBaseShell, SW_RES(STR_SHELLNAME_NAVIGATION))
+{
+}
+
+SwNavigationShell::SwNavigationShell(SwView &_rView):
+ SwBaseShell( _rView )
+
+{
+ SetName(OUString("Navigation"));
+ SetHelpId(SW_NAVIGATIONSHELL);
+}
+
+void SwNavigationShell::Execute(SfxRequest &rReq)
+{
+ SwWrtShell *pSh = &GetShell();
+ SdrView* pSdrView = pSh->GetDrawView();
+ const SfxItemSet *pArgs = rReq.GetArgs();
+ sal_uInt16 nSlotId = rReq.GetSlot();
+ sal_Bool bChanged = pSdrView->GetModel()->IsChanged();
+ pSdrView->GetModel()->SetChanged(false);
+ SwNavigationMgr& aSwNavigationMgr = pSh->GetNavigationMgr();
+ const SfxPoolItem* pItem;
+ if(pArgs)
+ pArgs->GetItemState(nSlotId, false, &pItem);
+ switch (nSlotId)
+ {
+ case FN_NAVIGATION_BACK:
+ aSwNavigationMgr.goBack();
+ break;
+
+ case FN_NAVIGATION_FORWARD:
+ aSwNavigationMgr.goForward();
+ break;
+ default:
+ break;
+ }
+ if (pSdrView->GetModel()->IsChanged())
+ GetShell().SetModified();
+ else if (bChanged)
+ pSdrView->GetModel()->SetChanged(true);
+}
+
+// determine if the buttons should be enabled/disabled
+
+void SwNavigationShell::GetState(SfxItemSet &rSet)
+{
+ SwWrtShell *pSh = &GetShell();
+ SfxWhichIter aIter( rSet );
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ SwNavigationMgr& aNavigationMgr = pSh->GetNavigationMgr();
+ while( nWhich )
+ {
+ switch( nWhich )
+ {
+ case FN_NAVIGATION_BACK:
+ {
+ if (!aNavigationMgr.backEnabled()) {
+ rSet.DisableItem(FN_NAVIGATION_BACK);
+ }
+ }
+ break;
+ case FN_NAVIGATION_FORWARD:
+ {
+ if (!aNavigationMgr.forwardEnabled())
+ rSet.DisableItem(FN_NAVIGATION_FORWARD);
+ }
+ break;
+ default:
+ break;
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/shells/olesh.cxx b/sw/source/core/uibase/shells/olesh.cxx
new file mode 100644
index 000000000000..6014c2fd725a
--- /dev/null
+++ b/sw/source/core/uibase/shells/olesh.cxx
@@ -0,0 +1,55 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <sfx2/app.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/objface.hxx>
+#include <sfx2/objitem.hxx>
+#include <sfx2/sidebar/EnumContext.hxx>
+#include <wrtsh.hxx>
+#include <view.hxx>
+#include <helpid.h>
+#include <globals.hrc>
+#include <frmsh.hxx>
+#include <olesh.hxx>
+
+#include <cmdid.h>
+#include <popup.hrc>
+#include <shells.hrc>
+
+#define SwOleShell
+#include <sfx2/msg.hxx>
+#include <swslots.hxx>
+
+SFX_IMPL_INTERFACE(SwOleShell, SwFrameShell, SW_RES(STR_SHELLNAME_OBJECT))
+{
+ SFX_POPUPMENU_REGISTRATION(SW_RES(MN_OLE_POPUPMENU));
+ SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_OLE_TOOLBOX));
+}
+
+SwOleShell::SwOleShell(SwView &_rView) :
+ SwFrameShell(_rView)
+
+{
+ SetName(OUString("Object"));
+ SetHelpId(SW_OLESHELL);
+ SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_OLE));
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/shells/slotadd.cxx b/sw/source/core/uibase/shells/slotadd.cxx
new file mode 100644
index 000000000000..ed66709a37e5
--- /dev/null
+++ b/sw/source/core/uibase/shells/slotadd.cxx
@@ -0,0 +1,139 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <config_options.h>
+
+#include "hintids.hxx"
+#include "uiitems.hxx"
+#include "cmdid.h"
+
+#include <svl/globalnameitem.hxx>
+#include <editeng/memberids.hrc>
+#include <svl/imageitm.hxx>
+#include <svl/aeitem.hxx>
+#include <svl/rectitem.hxx>
+#include <sfx2/objitem.hxx>
+#include <sfx2/objsh.hxx>
+#include <svx/rulritem.hxx>
+#include <sfx2/zoomitem.hxx>
+#include <svx/viewlayoutitem.hxx>
+#include <svx/zoomslideritem.hxx>
+#include <svx/hlnkitem.hxx>
+#include <svx/SmartTagItem.hxx>
+#include <svl/ptitem.hxx>
+#include <svx/pageitem.hxx>
+#include <svl/srchitem.hxx>
+#include <sfx2/tplpitem.hxx>
+#include <editeng/wrlmitem.hxx>
+#include <editeng/protitem.hxx>
+#include <editeng/opaqitem.hxx>
+#include <editeng/tstpitem.hxx>
+#include <editeng/autokernitem.hxx>
+#include <editeng/keepitem.hxx>
+#include <editeng/kernitem.hxx>
+#include <editeng/spltitem.hxx>
+#include <editeng/brushitem.hxx>
+#include <editeng/wghtitem.hxx>
+#include <editeng/shaditem.hxx>
+#include <editeng/pbinitem.hxx>
+#include <editeng/ulspitem.hxx>
+#include <editeng/prntitem.hxx>
+#include <editeng/orphitem.hxx>
+#include <editeng/widwitem.hxx>
+#include <editeng/lineitem.hxx>
+#include <editeng/pmdlitem.hxx>
+#include <editeng/cmapitem.hxx>
+#include <editeng/langitem.hxx>
+#include <editeng/formatbreakitem.hxx>
+#include <editeng/hyphenzoneitem.hxx>
+#include <editeng/escapementitem.hxx>
+#include <editeng/lspcitem.hxx>
+#include <editeng/adjustitem.hxx>
+#include <editeng/crossedoutitem.hxx>
+#include <editeng/fontitem.hxx>
+#include <editeng/shdditem.hxx>
+#include <editeng/udlnitem.hxx>
+#include <editeng/postitem.hxx>
+#include <editeng/fhgtitem.hxx>
+#include <editeng/contouritem.hxx>
+#include <editeng/colritem.hxx>
+#include <editeng/boxitem.hxx>
+#include <editeng/sizeitem.hxx>
+#include <editeng/lrspitem.hxx>
+#include <svx/xgrad.hxx>
+#include <svx/xlnstit.hxx>
+#include <svx/xlnedit.hxx>
+#include <svx/xfillit0.hxx>
+#include <svx/xflclit.hxx>
+#include <svx/xflgrit.hxx>
+#include <svx/xflhtit.hxx>
+#include <svx/xbtmpit.hxx>
+#include <svx/xlineit0.hxx>
+#include <svx/xlnwtit.hxx>
+#include <svx/xlndsit.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/grafctrl.hxx>
+
+#include <fmtornt.hxx>
+#include <paratr.hxx>
+#include <fmtinfmt.hxx>
+#include <fmtfsize.hxx>
+#include <fmtsrnd.hxx>
+#include "envimg.hxx"
+#include "frmatr.hxx"
+#include "cfgitems.hxx"
+#include "grfatr.hxx"
+#include "fmtline.hxx"
+#include <svx/clipfmtitem.hxx>
+#include <editeng/blinkitem.hxx>
+#include <svl/slstitm.hxx>
+#include <editeng/paravertalignitem.hxx>
+#include <editeng/charreliefitem.hxx>
+#include <editeng/charrotateitem.hxx>
+#include <editeng/charscaleitem.hxx>
+#include <svx/postattr.hxx>
+#include <sfx2/frame.hxx>
+#include <svx/chrtitem.hxx>
+#include <svx/drawitem.hxx>
+#include <avmedia/mediaitem.hxx>
+
+#define SvxDrawToolItem SfxAllEnumItem
+#define SvxDrawAlignItem SfxAllEnumItem
+#define avmedia_MediaItem ::avmedia::MediaItem
+
+#include <svx/xflftrit.hxx>
+#include <svx/xlncapit.hxx>
+#include <svx/xlinjoit.hxx>
+#include <svx/AffineMatrixItem.hxx>
+#include <svx/galleryitem.hxx>
+
+#define SFX_TYPEMAP
+#include <sfx2/msg.hxx>
+#include "swslots.hxx"
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/shells/tabsh.cxx b/sw/source/core/uibase/shells/tabsh.cxx
new file mode 100644
index 000000000000..5b60dafb9d50
--- /dev/null
+++ b/sw/source/core/uibase/shells/tabsh.cxx
@@ -0,0 +1,1476 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <hintids.hxx>
+#include <svl/zforlist.hxx>
+#include <svl/stritem.hxx>
+#include <svl/whiter.hxx>
+#include <unotools/moduleoptions.hxx>
+#include <svx/rulritem.hxx>
+#include <svl/srchitem.hxx>
+#include <editeng/lrspitem.hxx>
+#include <editeng/ulspitem.hxx>
+#include <editeng/brushitem.hxx>
+#include <editeng/boxitem.hxx>
+#include <editeng/shaditem.hxx>
+#include <editeng/spltitem.hxx>
+#include <editeng/langitem.hxx>
+#include <editeng/keepitem.hxx>
+#include <editeng/lineitem.hxx>
+#include <editeng/colritem.hxx>
+#include <editeng/frmdiritem.hxx>
+#include <svx/numinf.hxx>
+#include <svx/svddef.hxx>
+#include <svx/svxdlg.hxx>
+#include <svl/zformat.hxx>
+#include <sfx2/bindings.hxx>
+#include <vcl/msgbox.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/objface.hxx>
+#include <sfx2/sidebar/EnumContext.hxx>
+
+#include <fmtornt.hxx>
+#include <fmtclds.hxx>
+#include <fmtlsplt.hxx>
+#include <fmtrowsplt.hxx>
+#include <fmtfsize.hxx>
+#include <swmodule.hxx>
+#include <wrtsh.hxx>
+#include <wview.hxx>
+#include <frmatr.hxx>
+#include <uitool.hxx>
+#include <inputwin.hxx>
+#include <uiitems.hxx>
+#include <usrpref.hxx>
+#include <tabsh.hxx>
+#include "swtablerep.hxx"
+#include <tablemgr.hxx>
+#include <cellatr.hxx>
+#include <frmfmt.hxx>
+#include <swundo.hxx>
+#include <swtable.hxx>
+#include <docsh.hxx>
+#include <tblsel.hxx>
+
+#include <dialog.hrc>
+#include <popup.hrc>
+#include <shells.hrc>
+#include <cmdid.h>
+#include <globals.hrc>
+#include <helpid.h>
+#include <unobaseclass.hxx>
+
+#define SwTableShell
+#include <sfx2/msg.hxx>
+#include <swslots.hxx>
+
+#include "swabstdlg.hxx"
+#include <table.hrc>
+
+#include <boost/scoped_ptr.hpp>
+
+using ::editeng::SvxBorderLine;
+using namespace ::com::sun::star;
+
+SFX_IMPL_INTERFACE(SwTableShell, SwBaseShell, SW_RES(STR_SHELLNAME_TABLE))
+{
+ SFX_POPUPMENU_REGISTRATION(SW_RES(MN_TAB_POPUPMENU));
+ SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_TABLE_TOOLBOX));
+}
+
+TYPEINIT1(SwTableShell,SwBaseShell)
+
+const sal_uInt16 aUITableAttrRange[] =
+{
+ FN_PARAM_TABLE_NAME, FN_PARAM_TABLE_NAME,
+ FN_PARAM_TABLE_HEADLINE, FN_PARAM_TABLE_HEADLINE,
+ FN_PARAM_TABLE_SPACE, FN_PARAM_TABLE_SPACE,
+ FN_TABLE_REP, FN_TABLE_REP,
+ SID_RULER_BORDERS, SID_RULER_BORDERS,
+ RES_LR_SPACE, RES_UL_SPACE,
+ SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_SHADOW,
+ RES_BOX, RES_SHADOW,
+ RES_BACKGROUND, RES_BACKGROUND,
+ SID_BACKGRND_DESTINATION, SID_BACKGRND_DESTINATION,
+ SID_HTML_MODE, SID_HTML_MODE,
+ SID_ATTR_BRUSH_ROW, SID_ATTR_BRUSH_TABLE,
+ RES_PAGEDESC, RES_BREAK,
+ RES_KEEP, RES_KEEP,
+ RES_LAYOUT_SPLIT, RES_LAYOUT_SPLIT,
+ FN_TABLE_SET_VERT_ALIGN, FN_TABLE_SET_VERT_ALIGN,
+ RES_FRAMEDIR, RES_FRAMEDIR,
+ RES_ROW_SPLIT, RES_ROW_SPLIT,
+ FN_TABLE_BOX_TEXTORIENTATION, FN_TABLE_BOX_TEXTORIENTATION,
+// #i29550#
+ RES_COLLAPSING_BORDERS, RES_COLLAPSING_BORDERS,
+// <-- collapsing borders
+ 0
+};
+
+const sal_uInt16* SwuiGetUITableAttrRange()
+{
+ return aUITableAttrRange;
+}
+
+static void lcl_SetAttr( SwWrtShell &rSh, const SfxPoolItem &rItem )
+{
+ SfxItemSet aSet( rSh.GetView().GetPool(), rItem.Which(), rItem.Which(), 0);
+ aSet.Put( rItem );
+ rSh.SetTblAttr( aSet );
+}
+
+static SwTableRep* lcl_TableParamToItemSet( SfxItemSet& rSet, SwWrtShell &rSh )
+{
+ SwFrmFmt *pFmt = rSh.GetTableFmt();
+ SwTabCols aCols;
+ rSh.GetTabCols( aCols );
+
+ //At first get the simple attributes.
+ rSet.Put( SfxStringItem( FN_PARAM_TABLE_NAME, pFmt->GetName()));
+ rSet.Put( SfxUInt16Item( FN_PARAM_TABLE_HEADLINE, rSh.GetRowsToRepeat() ) );
+ rSet.Put( pFmt->GetShadow() );
+ rSet.Put(SfxUInt16Item(FN_TABLE_SET_VERT_ALIGN, rSh.GetBoxAlign()));
+ rSet.Put( pFmt->GetFrmDir() );
+
+ SvxULSpaceItem aULSpace( pFmt->GetULSpace() );
+ rSet.Put( aULSpace );
+
+ sal_uInt16 nBackgroundDestination = rSh.GetViewOptions()->GetTblDest();
+ rSet.Put(SwBackgroundDestinationItem(SID_BACKGRND_DESTINATION, nBackgroundDestination ));
+ SvxBrushItem aBrush( RES_BACKGROUND );
+ if(rSh.GetRowBackground(aBrush))
+ rSet.Put( aBrush, SID_ATTR_BRUSH_ROW );
+ else
+ rSet.InvalidateItem(SID_ATTR_BRUSH_ROW);
+ rSh.GetTabBackground(aBrush);
+ rSet.Put( aBrush, SID_ATTR_BRUSH_TABLE );
+
+ // text direction in boxes
+ SvxFrameDirectionItem aBoxDirection( FRMDIR_ENVIRONMENT, RES_FRAMEDIR );
+ if(rSh.GetBoxDirection( aBoxDirection ))
+ rSet.Put(aBoxDirection, FN_TABLE_BOX_TEXTORIENTATION);
+
+ sal_Bool bTableSel = rSh.IsTableMode();
+ if(!bTableSel)
+ {
+ rSh.StartAllAction();
+ rSh.Push();
+ rSh.GetView().GetViewFrame()->GetDispatcher()->Execute( FN_TABLE_SELECT_ALL, sal_False );
+ }
+ SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
+
+ // Table variant: If multiple table cells are selected.
+ rSh.GetCrsr(); //Thus GetCrsrCnt() returns the right thing
+ aBoxInfo.SetTable ((rSh.IsTableMode() && rSh.GetCrsrCnt() > 1) ||
+ !bTableSel);
+ // Always show distance field.
+ aBoxInfo.SetDist (true);
+ // Set minimum size in tables and paragraphs.
+ aBoxInfo.SetMinDist( !bTableSel || rSh.IsTableMode() ||
+ rSh.GetSelectionType() &
+ (nsSelectionType::SEL_TXT | nsSelectionType::SEL_TBL));
+ // Always set the default spacing.
+ aBoxInfo.SetDefDist (MIN_BORDER_DIST);
+ // Individual lines can have DontCare status only in tables.
+ aBoxInfo.SetValid( VALID_DISABLE, !bTableSel || !rSh.IsTableMode() );
+
+ rSet.Put(aBoxInfo);
+ rSh.GetTabBorders( rSet );
+
+ //row split
+ SwFmtRowSplit* pSplit = 0;
+ rSh.GetRowSplit(pSplit);
+ if(pSplit)
+ {
+ rSet.Put(*pSplit);
+ delete pSplit;
+ }
+
+ if(!bTableSel)
+ {
+ rSh.ClearMark();
+ rSh.Pop(sal_False);
+ rSh.EndAllAction();
+ }
+
+ SwTabCols aTabCols;
+ rSh.GetTabCols( aTabCols );
+ SvxColumnItem aColItem;
+
+ // Pointer will be deleted after the dialogue execution.
+ SwTableRep* pRep = new SwTableRep( aTabCols );
+ pRep->SetSpace(aCols.GetRightMax());
+
+ sal_uInt16 nPercent = 0;
+ long nWidth = ::GetTableWidth(pFmt, aCols, &nPercent, &rSh );
+ // The table width is wrong for relative values.
+ if(nPercent)
+ nWidth = pRep->GetSpace() * nPercent / 100;
+ sal_uInt16 nAlign = pFmt->GetHoriOrient().GetHoriOrient();
+ pRep->SetAlign(nAlign);
+ SvxLRSpaceItem aLRSpace( pFmt->GetLRSpace() );
+ SwTwips nLeft = aLRSpace.GetLeft();
+ SwTwips nRight = aLRSpace.GetRight();
+ SwTwips nDiff = pRep->GetSpace() - nRight - nLeft - nWidth;
+ if(nAlign != text::HoriOrientation::FULL && std::abs(nDiff) > 2)
+ {
+ SwTwips nLR = pRep->GetSpace() - nWidth;
+ switch ( nAlign )
+ {
+ case text::HoriOrientation::CENTER: nLeft = nRight = nLR / 2;
+ break;
+ case text::HoriOrientation::LEFT: nRight = nLR; nLeft = 0;
+ break;
+ case text::HoriOrientation::RIGHT: nLeft = nLR, nRight = 0;
+ break;
+ case text::HoriOrientation::LEFT_AND_WIDTH:
+ nRight = nLR - nLeft;
+ break;
+ case text::HoriOrientation::NONE:
+ if(!nPercent)
+ nWidth = pRep->GetSpace() - nLeft - nRight;
+ break;
+ }
+ }
+ pRep->SetLeftSpace(nLeft);
+ pRep->SetRightSpace(nRight);
+
+ pRep->SetWidth(nWidth);
+ pRep->SetWidthPercent(nPercent);
+ // Are individual rows / cells are selected, the column processing will be changed.
+ pRep->SetLineSelected(bTableSel && ! rSh.HasWholeTabSelection());
+ rSet.Put(SwPtrItem(FN_TABLE_REP, pRep));
+ return pRep;
+}
+
+void ItemSetToTableParam( const SfxItemSet& rSet,
+ SwWrtShell &rSh )
+{
+ rSh.StartAllAction();
+ rSh.StartUndo( UNDO_TABLE_ATTR );
+ const SfxPoolItem* pItem = 0;
+
+ SwViewOption aUsrPref( *rSh.GetViewOptions() );
+ sal_uInt16 nBackgroundDestination = aUsrPref.GetTblDest();
+ if(SFX_ITEM_SET == rSet.GetItemState(SID_BACKGRND_DESTINATION, false, &pItem))
+ {
+ nBackgroundDestination = ((SfxUInt16Item*)pItem)->GetValue();
+ aUsrPref.SetTblDest((sal_uInt8)nBackgroundDestination);
+ SW_MOD()->ApplyUsrPref(aUsrPref, &rSh.GetView());
+ }
+ bool bBorder = ( SFX_ITEM_SET == rSet.GetItemState( RES_BOX ) ||
+ SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_BORDER_INNER ) );
+ pItem = 0;
+ bool bBackground = SFX_ITEM_SET == rSet.GetItemState( RES_BACKGROUND, false, &pItem );
+ const SfxPoolItem* pRowItem = 0, *pTableItem = 0;
+ bBackground |= SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_BRUSH_ROW, false, &pRowItem );
+ bBackground |= SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_BRUSH_TABLE, false, &pTableItem );
+ const SfxPoolItem* pSplit = 0;
+ bool bRowSplit = SFX_ITEM_SET == rSet.GetItemState( RES_ROW_SPLIT, false, &pSplit );
+ const SfxPoolItem* pBoxDirection = 0;
+ bool bBoxDirection = SFX_ITEM_SET == rSet.GetItemState( FN_TABLE_BOX_TEXTORIENTATION, false, &pBoxDirection );
+ if( bBackground || bBorder || bRowSplit || bBoxDirection)
+ {
+ // The border will be applied to the present selection.
+ // If there is no selection, the table will be completely selected.
+ // The background will always be applied to the current state.
+ sal_Bool bTableSel = rSh.IsTableMode();
+ rSh.StartAllAction();
+
+ if(bBackground)
+ {
+ if(pItem)
+ rSh.SetBoxBackground( *(const SvxBrushItem*)pItem );
+ if(pRowItem)
+ {
+ SvxBrushItem aBrush(*(const SvxBrushItem*)pRowItem);
+ aBrush.SetWhich(RES_BACKGROUND);
+ rSh.SetRowBackground(aBrush);
+ }
+ if(pTableItem)
+ {
+ SvxBrushItem aBrush(*(const SvxBrushItem*)pTableItem);
+ aBrush.SetWhich(RES_BACKGROUND);
+ rSh.SetTabBackground( aBrush );
+ }
+ }
+
+ if(bBoxDirection)
+ {
+ SvxFrameDirectionItem aDirection( FRMDIR_ENVIRONMENT, RES_FRAMEDIR );
+ aDirection.SetValue(static_cast< const SvxFrameDirectionItem* >(pBoxDirection)->GetValue());
+ rSh.SetBoxDirection(aDirection);
+ }
+
+ if(bBorder || bRowSplit)
+ {
+ rSh.Push();
+ if(!bTableSel)
+ {
+ rSh.GetView().GetViewFrame()->GetDispatcher()->Execute( FN_TABLE_SELECT_ALL );
+ }
+ if(bBorder)
+ rSh.SetTabBorders( rSet );
+
+ if(bRowSplit)
+ {
+ rSh.SetRowSplit(*static_cast<const SwFmtRowSplit*>(pSplit));
+ }
+
+ if(!bTableSel)
+ {
+ rSh.ClearMark();
+ }
+ rSh.Pop(sal_False);
+ }
+
+ rSh.EndAllAction();
+ }
+
+ SwTabCols aTabCols;
+ bool bTabCols = false;
+ sal_Bool bSingleLine = sal_False;
+ SwTableRep* pRep = 0;
+ SwFrmFmt *pFmt = rSh.GetTableFmt();
+ SfxItemSet aSet( rSh.GetAttrPool(), RES_FRMATR_BEGIN, RES_FRMATR_END-1 );
+ if(SFX_ITEM_SET == rSet.GetItemState( FN_TABLE_REP, false, &pItem ))
+ {
+ pRep = (SwTableRep*)((const SwPtrItem*)pItem)->GetValue();
+
+ const SwTwips nWidth = pRep->GetWidth();
+ if ( text::HoriOrientation::FULL == pRep->GetAlign() )
+ {
+ SwFmtHoriOrient aAttr( pFmt->GetHoriOrient() );
+ aAttr.SetHoriOrient( text::HoriOrientation::FULL );
+ aSet.Put( aAttr );
+ }
+ else
+ {
+ SwFmtFrmSize aSz( ATT_VAR_SIZE, nWidth );
+ if(pRep->GetWidthPercent())
+ {
+ aSz.SetWidthPercent( (sal_uInt8)pRep->GetWidthPercent() );
+ }
+ aSet.Put(aSz);
+ }
+
+ SvxLRSpaceItem aLRSpace( RES_LR_SPACE );
+ aLRSpace.SetLeft(pRep->GetLeftSpace());
+ aLRSpace.SetRight(pRep->GetRightSpace());
+ aSet.Put( aLRSpace );
+
+ sal_Int16 eOrient = pRep->GetAlign();
+ SwFmtHoriOrient aAttr( 0, eOrient );
+ aSet.Put( aAttr );
+ // The item must only be recorded while manual alignment, so that the
+ // alignment is not overwritten by the distances while recording.
+ if(eOrient != text::HoriOrientation::NONE)
+ ((SfxItemSet&)rSet).ClearItem( SID_ATTR_LRSPACE );
+
+ if(pRep->HasColsChanged())
+ {
+ bTabCols = true;
+ }
+ }
+
+ if( SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_TABLE_HEADLINE, false, &pItem))
+ rSh.SetRowsToRepeat( ((SfxUInt16Item*)pItem)->GetValue() );
+
+ if( SFX_ITEM_SET == rSet.GetItemState( FN_TABLE_SET_VERT_ALIGN, false, &pItem))
+ rSh.SetBoxAlign(((SfxUInt16Item*)(pItem))->GetValue());
+
+ if( SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_TABLE_NAME, false, &pItem ))
+ rSh.SetTableName( *pFmt, ((const SfxStringItem*)pItem)->GetValue() );
+
+ // Copy the chosen attributes in the ItemSet.
+ static const sal_uInt16 aIds[] =
+ {
+ RES_PAGEDESC,
+ RES_BREAK,
+ RES_KEEP,
+ RES_LAYOUT_SPLIT,
+ RES_UL_SPACE,
+ RES_SHADOW,
+ RES_FRAMEDIR,
+ // #i29550#
+ RES_COLLAPSING_BORDERS,
+ // <-- collapsing borders
+ 0
+ };
+ for( const sal_uInt16* pIds = aIds; *pIds; ++pIds )
+ if( SFX_ITEM_SET == rSet.GetItemState( *pIds, false, &pItem))
+ aSet.Put( *pItem );
+
+ if( aSet.Count() )
+ rSh.SetTblAttr( aSet );
+
+ if(bTabCols)
+ {
+ rSh.GetTabCols( aTabCols );
+ bSingleLine = pRep->FillTabCols( aTabCols );
+ rSh.SetTabCols( aTabCols, bSingleLine );
+ }
+
+ rSh.EndUndo( UNDO_TABLE_ATTR );
+ rSh.EndAllAction();
+}
+
+static void lcl_TabGetMaxLineWidth(const SvxBorderLine* pBorderLine, SvxBorderLine& rBorderLine)
+{
+ if(pBorderLine->GetWidth() > rBorderLine.GetWidth())
+ rBorderLine.SetWidth(pBorderLine->GetWidth());
+
+ rBorderLine.SetBorderLineStyle(pBorderLine->GetBorderLineStyle());
+ rBorderLine.SetColor(pBorderLine->GetColor());
+}
+
+void SwTableShell::Execute(SfxRequest &rReq)
+{
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ SwWrtShell &rSh = GetShell();
+
+ // At first the slots which doesn't need a FrmMgr.
+ bool bMore = false;
+ const SfxPoolItem* pItem = 0;
+ sal_uInt16 nSlot = rReq.GetSlot();
+ if(pArgs)
+ pArgs->GetItemState(GetPool().GetWhich(nSlot), false, &pItem);
+ bool bCallDone = false;
+ switch ( nSlot )
+ {
+ case SID_ATTR_BORDER:
+ {
+ if(!pArgs)
+ break;
+ // Create items, because we have to rework anyway.
+ SvxBoxItem aBox( RES_BOX );
+ SfxItemSet aCoreSet( GetPool(),
+ RES_BOX, RES_BOX,
+ SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
+ 0);
+ SvxBoxInfoItem aCoreInfo( SID_ATTR_BORDER_INNER );
+ aCoreSet.Put(aCoreInfo);
+ rSh.GetTabBorders( aCoreSet );
+ const SvxBoxItem& rCoreBox = (const SvxBoxItem&)
+ aCoreSet.Get(RES_BOX);
+ const SfxPoolItem *pBoxItem = 0;
+ if ( pArgs->GetItemState(RES_BOX, true, &pBoxItem) == SFX_ITEM_SET )
+ {
+ aBox = *(SvxBoxItem*)pBoxItem;
+ if ( !rReq.IsAPI() )
+ aBox.SetDistance( std::max(rCoreBox.GetDistance(),sal_uInt16(55)) );
+ else if ( aBox.GetDistance() < MIN_BORDER_DIST )
+ aBox.SetDistance( std::max(rCoreBox.GetDistance(),(sal_uInt16)MIN_BORDER_DIST) );
+ }
+ else
+ OSL_ENSURE( !this, "where is BoxItem?" );
+
+ //since the drawing layer also supports borders the which id might be a different one
+ SvxBoxInfoItem aInfo( SID_ATTR_BORDER_INNER );
+ if (pArgs->GetItemState(SID_ATTR_BORDER_INNER, true, &pBoxItem) == SFX_ITEM_SET)
+ aInfo = *(SvxBoxInfoItem*)pBoxItem;
+ else if( pArgs->GetItemState(SDRATTR_TABLE_BORDER_INNER, true, &pBoxItem) == SFX_ITEM_SET )
+ {
+ aInfo = *(SvxBoxInfoItem*)pBoxItem;
+ aInfo.SetWhich(SID_ATTR_BORDER_INNER);
+ }
+
+ aInfo.SetTable( true );
+ aInfo.SetValid( VALID_DISABLE, false );
+
+// The attributes of all lines will be read and the strongest wins.
+ const SvxBorderLine* pBorderLine;
+ SvxBorderLine aBorderLine;
+ if ((pBorderLine = rCoreBox.GetTop()) != NULL)
+ lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
+ if ((pBorderLine = rCoreBox.GetBottom()) != NULL)
+ lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
+ if ((pBorderLine = rCoreBox.GetLeft()) != NULL)
+ lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
+ if ((pBorderLine = rCoreBox.GetRight()) != NULL)
+ lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
+ if ((pBorderLine = aCoreInfo.GetHori()) != NULL)
+ lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
+ if ((pBorderLine = aCoreInfo.GetVert()) != NULL)
+ lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
+
+ if(aBorderLine.GetOutWidth() == 0)
+ {
+ aBorderLine.SetBorderLineStyle(table::BorderLineStyle::SOLID);
+ aBorderLine.SetWidth( DEF_LINE_WIDTH_0 );
+ }
+
+ sal_Bool bLine = sal_False;
+ if( aBox.GetTop() != NULL )
+ aBox.SetLine(&aBorderLine, BOX_LINE_TOP), bLine |= sal_True;
+ if( aBox.GetBottom() != NULL )
+ aBox.SetLine(&aBorderLine, BOX_LINE_BOTTOM), bLine |= sal_True;
+ if( aBox.GetLeft() != NULL )
+ aBox.SetLine(&aBorderLine, BOX_LINE_LEFT), bLine |= sal_True;
+ if( aBox.GetRight() != NULL )
+ aBox.SetLine(&aBorderLine, BOX_LINE_RIGHT), bLine |= sal_True;
+ if( aInfo.GetHori() != NULL )
+ aInfo.SetLine(&aBorderLine, BOXINFO_LINE_HORI), bLine |= sal_True;
+ if( aInfo.GetVert() != NULL )
+ aInfo.SetLine(&aBorderLine, BOXINFO_LINE_VERT), bLine |= sal_True;
+
+ aCoreSet.Put( aBox );
+ aCoreSet.Put( aInfo );
+ rSh.SetTabBorders( aCoreSet );
+
+ // we must record the "real" values because otherwise the lines can't be reconstructed on playtime
+ // the coding style of the controller (setting lines with width 0) is not transportable via Query/PutValue in
+ // the SvxBoxItem
+ rReq.AppendItem( aBox );
+ rReq.AppendItem( aInfo );
+ bCallDone = true;
+
+ }
+ break;
+ case FN_INSERT_TABLE:
+ InsertTable( rReq );
+ break;
+ case FN_FORMAT_TABLE_DLG:
+ {
+ //#127012# get the bindings before the dialog is called
+ // it might happen that this shell is removed after closing the dialog
+ SfxBindings& rBindings = GetView().GetViewFrame()->GetBindings();
+ SfxItemSet aCoreSet( GetPool(), aUITableAttrRange);
+
+ FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, &rSh.GetView()));
+ SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)));
+ SwTableRep* pTblRep = ::lcl_TableParamToItemSet( aCoreSet, rSh );
+ SfxAbstractTabDialog * pDlg = NULL;
+ {
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+
+ pDlg = pFact->CreateSwTableTabDlg(GetView().GetWindow(), GetPool(), &aCoreSet, &rSh);
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+
+ if (pItem)
+ pDlg->SetCurPageId(OUStringToOString(((SfxStringItem *)pItem)->GetValue(), RTL_TEXTENCODING_UTF8));
+ }
+ aCoreSet.Put(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(GetView().GetDocShell())));
+ rSh.GetTblAttr(aCoreSet);
+ // GetTblAttr overwrites the background!
+ SvxBrushItem aBrush( RES_BACKGROUND );
+ if(rSh.GetBoxBackground(aBrush))
+ aCoreSet.Put( aBrush );
+ else
+ aCoreSet.InvalidateItem( RES_BACKGROUND );
+
+ if ( (!pDlg && rReq.GetArgs()) || pDlg->Execute() == RET_OK )
+ {
+ const SfxItemSet* pOutSet = pDlg ? pDlg->GetOutputItemSet() : rReq.GetArgs();
+ if ( pDlg )
+ {
+ //to record FN_INSERT_TABLE correctly
+ rReq.SetSlot(FN_FORMAT_TABLE_DLG);
+ rReq.Done( *pOutSet );
+ }
+ ItemSetToTableParam( *pOutSet, rSh );
+ }
+
+ delete pDlg;
+ delete pTblRep;
+ rBindings.Update(SID_RULER_BORDERS);
+ rBindings.Update(SID_ATTR_TABSTOP);
+ rBindings.Update(SID_RULER_BORDERS_VERTICAL);
+ rBindings.Update(SID_ATTR_TABSTOP_VERTICAL);
+ }
+ break;
+ case SID_ATTR_BRUSH:
+ case SID_ATTR_BRUSH_ROW :
+ case SID_ATTR_BRUSH_TABLE :
+ if(rReq.GetArgs())
+ ItemSetToTableParam(*rReq.GetArgs(), rSh);
+ break;
+ case FN_NUM_FORMAT_TABLE_DLG:
+ {
+ SwView* pView = GetActiveView();
+ if(pView)
+ {
+ FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, pView));
+ SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)));
+ SvNumberFormatter* pFormatter = rSh.GetNumberFormatter();
+ SfxItemSet aCoreSet( GetPool(),
+ SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_VALUE,
+ SID_ATTR_NUMBERFORMAT_INFO, SID_ATTR_NUMBERFORMAT_INFO,
+ 0 );
+
+ SfxItemSet aBoxSet( *aCoreSet.GetPool(),
+ RES_BOXATR_FORMAT, RES_BOXATR_FORMAT,
+ RES_BOXATR_VALUE, RES_BOXATR_VALUE,
+ 0 );
+ rSh.GetTblBoxFormulaAttrs( aBoxSet );
+
+ SfxItemState eState = aBoxSet.GetItemState(RES_BOXATR_FORMAT);
+ if(eState == SFX_ITEM_DEFAULT)
+ {
+ aCoreSet.Put( SfxUInt32Item( SID_ATTR_NUMBERFORMAT_VALUE,
+ pFormatter->GetFormatIndex(NF_TEXT, LANGUAGE_SYSTEM)));
+ }
+ else
+ aCoreSet.Put( SfxUInt32Item( SID_ATTR_NUMBERFORMAT_VALUE,
+ ((SwTblBoxNumFormat&)aBoxSet.Get(
+ RES_BOXATR_FORMAT )).GetValue() ));
+
+ OUString sCurText( rSh.GetTableBoxText() );
+ aCoreSet.Put( SvxNumberInfoItem( pFormatter,
+ ((SwTblBoxValue&)aBoxSet.Get(
+ RES_BOXATR_VALUE)).GetValue(),
+ sCurText, SID_ATTR_NUMBERFORMAT_INFO ));
+
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+
+ SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( GetView().GetWindow(),aCoreSet,
+ pView->GetViewFrame()->GetFrame().GetFrameInterface(),
+ RC_DLG_SWNUMFMTDLG );
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+
+ if (RET_OK == pDlg->Execute())
+ {
+ const SfxPoolItem* pNumberFormatItem = GetView().GetDocShell()->
+ GetItem( SID_ATTR_NUMBERFORMAT_INFO );
+
+ if( pNumberFormatItem && 0 != ((SvxNumberInfoItem*)pNumberFormatItem)->GetDelCount() )
+ {
+ const sal_uInt32* pDelArr = ((SvxNumberInfoItem*)
+ pNumberFormatItem)->GetDelArray();
+
+ for ( sal_uInt16 i = 0; i < ((SvxNumberInfoItem*)pNumberFormatItem)->GetDelCount(); i++ )
+ ((SvxNumberInfoItem*)pNumberFormatItem)->
+ GetNumberFormatter()->DeleteEntry( pDelArr[i] );
+ }
+
+ if( SFX_ITEM_SET == pDlg->GetOutputItemSet()->GetItemState(
+ SID_ATTR_NUMBERFORMAT_VALUE, false, &pNumberFormatItem ))
+ {
+ SfxItemSet aBoxFormatSet( *aCoreSet.GetPool(),
+ RES_BOXATR_FORMAT, RES_BOXATR_FORMAT );
+ aBoxFormatSet.Put( SwTblBoxNumFormat(
+ ((SfxUInt32Item*)pNumberFormatItem)->GetValue() ));
+ rSh.SetTblBoxFormulaAttrs( aBoxFormatSet );
+
+ }
+ }
+ delete pDlg;
+ }
+ }
+ break;
+ case FN_CALC_TABLE:
+ rSh.UpdateTable();
+ bCallDone = true;
+ break;
+ case FN_TABLE_OPTIMAL_HEIGHT:
+ {
+ const SwFmtFrmSize aSz;
+ rSh.SetRowHeight( aSz );
+ bCallDone = true;
+ }
+ break;
+ case FN_TABLE_DELETE_COL:
+ if ( rSh.DeleteCol() && rSh.HasSelection() )
+ rSh.EnterStdMode();
+ bCallDone = true;
+ break;
+ case FN_END_TABLE:
+ rSh.MoveTable( fnTableCurr, fnTableEnd );
+ bCallDone = true;
+ break;
+ case FN_START_TABLE:
+ rSh.MoveTable( fnTableCurr, fnTableStart );
+ bCallDone = true;
+ break;
+ case FN_GOTO_NEXT_CELL:
+ {
+ sal_Bool bAppendLine = sal_True;
+ if( pItem )
+ bAppendLine = ((SfxBoolItem*)pItem)->GetValue();
+ rReq.SetReturnValue( SfxBoolItem( nSlot,
+ rSh.GoNextCell( bAppendLine ) ) );
+ bCallDone = true;
+ }
+ break;
+ case FN_GOTO_PREV_CELL:
+ rReq.SetReturnValue( SfxBoolItem( nSlot, rSh.GoPrevCell() ) );
+ bCallDone = true;
+ break;
+ case FN_TABLE_DELETE_ROW:
+ if ( rSh.DeleteRow() && rSh.HasSelection() )
+ rSh.EnterStdMode();
+ bCallDone = true;
+ break;
+ case FN_TABLE_MERGE_CELLS:
+ if ( rSh.IsTableMode() )
+ switch ( rSh.MergeTab() )
+ {
+ case TBLMERGE_OK:
+ bCallDone = true;
+ //no break;
+ case TBLMERGE_NOSELECTION: break;
+ case TBLMERGE_TOOCOMPLEX:
+ {
+ InfoBox aInfoBox( GetView().GetWindow(),
+ SW_RES( MSG_ERR_TABLE_MERGE ) );
+ aInfoBox.Execute();
+ break;
+ }
+ default: OSL_ENSURE( !this, "unknown return value MergeTab.");
+ }
+ break;
+ case FN_TABLE_ADJUST_CELLS:
+ case FN_TABLE_BALANCE_CELLS:
+ {
+ sal_Bool bBalance = (FN_TABLE_BALANCE_CELLS == nSlot);
+ if ( rSh.IsAdjustCellWidthAllowed(bBalance) )
+ {
+ {
+ // remove actions to make a valid table selection
+ UnoActionRemoveContext aRemoveContext(rSh.GetDoc());
+ }
+ rSh.AdjustCellWidth(bBalance);
+ }
+ bCallDone = true;
+ }
+ break;
+ case FN_TABLE_BALANCE_ROWS:
+ if ( rSh.BalanceRowHeight(sal_True) )
+ rSh.BalanceRowHeight(sal_False);
+ bCallDone = true;
+ break;
+ case FN_TABLE_SELECT_ALL:
+ rSh.EnterStdMode();
+ rSh.MoveTable( fnTableCurr, fnTableStart );
+ rSh.SttSelect();
+ rSh.MoveTable( fnTableCurr, fnTableEnd );
+ rSh.EndSelect();
+ bCallDone = true;
+ break;
+ case FN_TABLE_SELECT_COL:
+ rSh.EnterStdMode();
+ rSh.SelectTableCol();
+ bCallDone = true;
+ break;
+ case FN_TABLE_SELECT_ROW:
+ rSh.EnterStdMode();
+ rSh.SelectTableRow();
+ bCallDone = true;
+ break;
+ case FN_TABLE_SET_READ_ONLY_CELLS:
+ rSh.ProtectCells();
+ rSh.ResetSelect( 0, sal_False );
+ bCallDone = true;
+ break;
+ case FN_TABLE_UNSET_READ_ONLY_CELLS:
+ rSh.UnProtectCells();
+ bCallDone = true;
+ break;
+ case SID_AUTOFORMAT:
+ {
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+
+ AbstractSwAutoFormatDlg* pDlg = pFact->CreateSwAutoFormatDlg(&GetView().GetViewFrame()->GetWindow(), &rSh);
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ pDlg->Execute();
+ delete pDlg;
+ }
+ break;
+ case FN_TABLE_SET_ROW_HEIGHT:
+ {
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+
+ VclAbstractDialog* pDlg = pFact->CreateVclAbstractDialog( GetView().GetWindow(), rSh, DLG_ROW_HEIGHT );
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ pDlg->Execute();
+ delete pDlg;
+ }
+ break;
+ case FN_NUMBER_BULLETS:
+ case FN_NUM_BULLET_ON:
+ OSL_ENSURE( !this, "function may not be called now." );
+ break;
+
+ case FN_TABLE_INSERT_COL:
+ case FN_TABLE_INSERT_ROW:
+ {
+ bool bColumn = rReq.GetSlot() == FN_TABLE_INSERT_COL;
+ sal_uInt16 nCount = 0;
+ sal_Bool bAfter = sal_True;
+ if (pItem)
+ {
+ nCount = ((const SfxInt16Item* )pItem)->GetValue();
+ if(SFX_ITEM_SET == pArgs->GetItemState(FN_PARAM_INSERT_AFTER, true, &pItem))
+ bAfter = ((const SfxBoolItem* )pItem)->GetValue();
+ }
+ else if( !rReq.IsAPI() )
+ ++nCount;
+
+ if( nCount )
+ {
+ // i74180: Table border patch submitted by chensuchun:
+ // -->get the SvxBoxInfoItem of the table before insert
+ SfxItemSet aCoreSet( GetPool(), aUITableAttrRange);
+ ::lcl_TableParamToItemSet( aCoreSet, rSh );
+ bool bSetInnerBorders = false;
+ SwUndoId nUndoId = UNDO_EMPTY;
+ // <--End
+
+ if( bColumn )
+ {
+ rSh.StartUndo( UNDO_TABLE_INSCOL );
+ rSh.InsertCol( nCount, bAfter );
+ bSetInnerBorders = true;
+ nUndoId = UNDO_TABLE_INSCOL;
+ }
+ else if ( !rSh.IsInRepeatedHeadline() )
+ {
+ rSh.StartUndo( UNDO_TABLE_INSROW );
+ rSh.InsertRow( nCount, bAfter );
+ bSetInnerBorders = true;
+ nUndoId = UNDO_TABLE_INSROW;
+ }
+
+ // -->after inserting,reset the inner table borders
+ if ( bSetInnerBorders )
+ {
+ const SvxBoxInfoItem aBoxInfo((const SvxBoxInfoItem&)
+ aCoreSet.Get(SID_ATTR_BORDER_INNER));
+ SfxItemSet aSet( GetPool(), SID_ATTR_BORDER_INNER,
+ SID_ATTR_BORDER_INNER, 0);
+ aSet.Put( aBoxInfo );
+ ItemSetToTableParam( aSet, rSh );
+ rSh.EndUndo( nUndoId );
+ }
+
+ bCallDone = true;
+ break;
+ }
+
+ nSlot = bColumn ? FN_TABLE_INSERT_COL_DLG : FN_TABLE_INSERT_ROW_DLG;
+ }
+ // No break; on Count = 0 appears the dialog
+ case FN_TABLE_INSERT_COL_DLG:
+ case FN_TABLE_INSERT_ROW_DLG:
+ {
+ const SfxSlot* pSlot = GetStaticInterface()->GetSlot(nSlot);
+ if ( FN_TABLE_INSERT_ROW_DLG != nSlot || !rSh.IsInRepeatedHeadline())
+ {
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ boost::scoped_ptr<SvxAbstractInsRowColDlg> pDlg( pFact ? pFact->CreateSvxInsRowColDlg( GetView().GetWindow(), nSlot == FN_TABLE_INSERT_COL_DLG, pSlot->GetCommand() ) : 0);
+
+ if( pDlg.get() && (pDlg->Execute() == 1) )
+ {
+ sal_uInt16 nDispatchSlot = (nSlot == FN_TABLE_INSERT_COL_DLG) ? FN_TABLE_INSERT_COL : FN_TABLE_INSERT_ROW;
+ SfxUInt16Item aCountItem( nDispatchSlot, static_cast< sal_uInt16 >(pDlg->getInsertCount()) );
+ SfxBoolItem aAfter( FN_PARAM_INSERT_AFTER, !pDlg->isInsertBefore() );
+ SfxViewFrame* pVFrame = GetView().GetViewFrame();
+ if( pVFrame )
+ pVFrame->GetDispatcher()->Execute( nDispatchSlot, SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD, &aCountItem, &aAfter, 0L);
+ }
+ }
+ }
+ break;
+ case FN_TABLE_SPLIT_CELLS:
+ {
+ long nCount=0;
+ sal_Bool bHorizontal=sal_True;
+ sal_Bool bProportional = sal_False;
+ SFX_REQUEST_ARG( rReq, pSplit, SfxInt32Item, FN_TABLE_SPLIT_CELLS, false );
+ SFX_REQUEST_ARG( rReq, pHor, SfxBoolItem, FN_PARAM_1, false );
+ SFX_REQUEST_ARG( rReq, pProp, SfxBoolItem, FN_PARAM_2, false );
+ if ( pSplit )
+ {
+ nCount = pSplit->GetValue();
+ if ( pHor )
+ bHorizontal = pHor->GetValue();
+ if ( pProp )
+ bProportional = pProp->GetValue();
+ }
+ else
+ {
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ if( pFact )
+ {
+ const long nMaxVert = rSh.GetAnyCurRect( RECT_FRM ).Width() / MINLAY;
+ SvxAbstractSplittTableDialog* pDlg = pFact->CreateSvxSplittTableDialog( GetView().GetWindow(), rSh.IsTableVertical(), nMaxVert, 99 );
+ if( pDlg && (pDlg->Execute() == RET_OK) )
+ {
+ nCount = pDlg->GetCount();
+ bHorizontal = pDlg->IsHorizontal();
+ bProportional = pDlg->IsProportional();
+ rReq.AppendItem( SfxInt32Item( FN_TABLE_SPLIT_CELLS, nCount ) );
+ rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bHorizontal ) );
+ rReq.AppendItem( SfxBoolItem( FN_PARAM_2, bProportional ) );
+ }
+ delete pDlg;
+ }
+ }
+
+ if ( nCount>1 )
+ {
+ rSh.SplitTab(!bHorizontal, static_cast< sal_uInt16 >( nCount-1 ), bProportional );
+ bCallDone = true;
+ }
+ else
+ rReq.Ignore();
+ }
+ break;
+
+ case FN_TABLE_SPLIT_TABLE:
+ {
+ SFX_REQUEST_ARG( rReq, pType, SfxUInt16Item, FN_PARAM_1, false );
+ if( pType )
+ {
+ switch( pType->GetValue() )
+ {
+ case HEADLINE_NONE :
+ case HEADLINE_BORDERCOPY:
+ case HEADLINE_CNTNTCOPY:
+ case HEADLINE_BOXATTRCOPY:
+ case HEADLINE_BOXATRCOLLCOPY:
+ rSh.SplitTable(pType->GetValue()) ;
+ default: ;//wrong parameter, do nothing
+ }
+ }
+ else
+ {
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+
+ AbstractSplitTableDialog* pDlg = pFact->CreateSplitTblDialog( GetView().GetWindow(), rSh );
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ pDlg->Execute();
+ rReq.AppendItem( SfxUInt16Item( FN_PARAM_1, pDlg->GetSplitMode() ) );
+ delete pDlg;
+ bCallDone = true;
+ }
+ }
+ break;
+
+ case FN_TABLE_MERGE_TABLE:
+ {
+ sal_Bool bPrev = rSh.CanMergeTable( sal_True );
+ sal_Bool bNext = rSh.CanMergeTable( sal_False );
+
+ if( bPrev && bNext )
+ {
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+ VclAbstractDialog* pDlg = pFact->CreateTblMergeDialog(GetView().GetWindow(), bPrev);
+ OSL_ENSURE(pDlg, "dialogdiet pDlg fail!");
+ if( RET_OK != pDlg->Execute())
+ bPrev = bNext = sal_False;
+ delete pDlg;
+ }
+
+ if( bPrev || bNext )
+ rSh.MergeTable( bPrev );
+ }
+ break;
+
+ case FN_TABLE_MODE_FIX :
+ case FN_TABLE_MODE_FIX_PROP :
+ case FN_TABLE_MODE_VARIABLE :
+ {
+ rSh.SetTblChgMode( ( FN_TABLE_MODE_FIX == nSlot ? TBLFIX_CHGABS
+ : FN_TABLE_MODE_FIX_PROP == nSlot
+ ? TBLFIX_CHGPROP
+ : TBLVAR_CHGABS ) );
+
+ SfxBindings& rBind = GetView().GetViewFrame()->GetBindings();
+ static sal_uInt16 aInva[] =
+ { FN_TABLE_MODE_FIX,
+ FN_TABLE_MODE_FIX_PROP,
+ FN_TABLE_MODE_VARIABLE,
+ 0
+ };
+ rBind.Invalidate( aInva );
+ bCallDone = true;
+ }
+ break;
+ case FN_TABLE_AUTOSUM:
+ {
+ SfxViewFrame* pVFrame = GetView().GetViewFrame();
+ pVFrame->GetDispatcher()->Execute(FN_EDIT_FORMULA, SFX_CALLMODE_SYNCHRON);
+ const sal_uInt16 nId = SwInputChild::GetChildWindowId();
+ SwInputChild* pChildWin = (SwInputChild*)pVFrame->
+ GetChildWindow( nId );
+ OUString sSum;
+ GetShell().GetAutoSum(sSum);
+ if( pChildWin )
+ pChildWin->SetFormula( sSum );
+
+ }
+ break;
+ case FN_TABLE_HEADLINE_REPEAT:
+ if(0 != rSh.GetRowsToRepeat())
+ rSh.SetRowsToRepeat( 0 );
+ else
+ rSh.SetRowsToRepeat(rSh.GetRowSelectionFromTop());
+ break;
+ case FN_TABLE_SELECT_CELL :
+ rSh.SelectTableCell();
+ break;
+ case FN_TABLE_DELETE_TABLE :
+ {
+ rSh.StartAction();
+ rSh.StartUndo();
+ rSh.GetView().GetViewFrame()->GetDispatcher()->Execute(FN_TABLE_SELECT_ALL);
+ rSh.DeleteRow();
+ rSh.EndUndo();
+ rSh.EndAction();
+ }
+ //'this' is already destroyed
+ return;
+ //break;
+ default:
+ bMore = true;
+ }
+
+ if ( !bMore )
+ {
+ if(bCallDone)
+ rReq.Done();
+ return;
+ }
+ else
+ bMore = false;
+ // Now the slots which are working directly on the TableFmt.
+ SwFrmFmt *pFmt = rSh.GetTableFmt();
+ switch ( nSlot )
+ {
+ case SID_ATTR_ULSPACE:
+ {
+ if(pItem)
+ {
+ SvxULSpaceItem aULSpace( *(const SvxULSpaceItem*)pItem );
+ aULSpace.SetWhich( RES_UL_SPACE );
+ ::lcl_SetAttr( rSh, aULSpace );
+ }
+ }
+ break;
+
+ case SID_ATTR_LRSPACE:
+ {
+ if(pItem)
+ {
+ SfxItemSet aSet( GetPool(), RES_LR_SPACE, RES_LR_SPACE,
+ RES_HORI_ORIENT, RES_HORI_ORIENT, 0 );
+ SvxLRSpaceItem aLRSpace( *(const SvxLRSpaceItem*)pItem );
+ aLRSpace.SetWhich( RES_LR_SPACE );
+ aSet.Put( aLRSpace );
+ SwFmtHoriOrient aHori( pFmt->GetHoriOrient() );
+ aHori.SetHoriOrient( text::HoriOrientation::NONE );
+ aSet.Put( aLRSpace );
+ rSh.SetTblAttr( aSet );
+ }
+ }
+ break;
+// The last case branch which needs a table manager!!
+ case FN_TABLE_SET_COL_WIDTH:
+ {
+ SwTableFUNC aMgr( &rSh, sal_False);
+ aMgr.ColWidthDlg(GetView().GetWindow());
+ }
+ break;
+ case SID_TABLE_VERT_NONE:
+ case SID_TABLE_VERT_CENTER:
+ case SID_TABLE_VERT_BOTTOM:
+ {
+ sal_uInt16 nAlign = nSlot == SID_TABLE_VERT_NONE ?
+ text::VertOrientation::NONE :
+ nSlot == SID_TABLE_VERT_CENTER ?
+ text::VertOrientation::CENTER : text::VertOrientation::BOTTOM;
+ rSh.SetBoxAlign(nAlign);
+ bCallDone = true;
+ }
+ break;
+
+ case SID_ATTR_PARA_SPLIT:
+ if ( pItem )
+ {
+ SwFmtLayoutSplit aSplit( ((const SvxFmtSplitItem*)pItem)->GetValue());
+ SfxItemSet aSet(GetPool(), RES_LAYOUT_SPLIT, RES_LAYOUT_SPLIT, 0 );
+ aSet.Put(aSplit);
+ rSh.SetTblAttr(aSet);
+ }
+ break;
+
+ case SID_ATTR_PARA_KEEP:
+ if ( pItem )
+ {
+ SvxFmtKeepItem aKeep( *(const SvxFmtKeepItem*)pItem );
+ aKeep.SetWhich( RES_KEEP );
+ SfxItemSet aSet(GetPool(), RES_KEEP, RES_KEEP, 0 );
+ aSet.Put(aKeep);
+ rSh.SetTblAttr(aSet);
+ }
+ break;
+ case FN_TABLE_ROW_SPLIT :
+ {
+ const SfxBoolItem* pBool = static_cast<const SfxBoolItem*>(pItem);
+ SwFmtRowSplit* pSplit = 0;
+ if(!pBool)
+ {
+ rSh.GetRowSplit(pSplit);
+ if(pSplit)
+ pSplit->SetValue(!pSplit->GetValue());
+ else
+ pSplit = new SwFmtRowSplit(sal_True);
+ }
+ else
+ {
+ pSplit = new SwFmtRowSplit(pBool->GetValue());
+ }
+ rSh.SetRowSplit( *pSplit );
+ delete pSplit;
+ }
+ break;
+
+ default:
+ OSL_ENSURE( !this, "wrong Dispatcher" );
+ return;
+ }
+ if(bCallDone)
+ rReq.Done();
+}
+
+void SwTableShell::GetState(SfxItemSet &rSet)
+{
+ SfxWhichIter aIter( rSet );
+ SwWrtShell &rSh = GetShell();
+ SwFrmFmt *pFmt = rSh.GetTableFmt();
+ // os #124829# crash report: in case of an invalid shell selection return immediately
+ if(!pFmt)
+ return;
+ sal_uInt16 nSlot = aIter.FirstWhich();
+ while ( nSlot )
+ {
+ switch ( nSlot )
+ {
+ case FN_TABLE_MERGE_CELLS:
+ if ( !rSh.IsTableMode() )
+ rSet.DisableItem(FN_TABLE_MERGE_CELLS);
+ break;
+ case FN_TABLE_ADJUST_CELLS:
+ if ( !rSh.IsAdjustCellWidthAllowed() )
+ rSet.DisableItem(FN_TABLE_ADJUST_CELLS);
+ break;
+
+ case FN_TABLE_BALANCE_CELLS:
+ if ( !rSh.IsAdjustCellWidthAllowed(sal_True) )
+ rSet.DisableItem(FN_TABLE_BALANCE_CELLS);
+ break;
+
+ case FN_TABLE_BALANCE_ROWS:
+ if ( !rSh.BalanceRowHeight(sal_True) )
+ rSet.DisableItem(FN_TABLE_BALANCE_ROWS);
+ break;
+ case FN_OPTIMIZE_TABLE:
+ if ( !rSh.IsTableMode() &&
+ !rSh.IsAdjustCellWidthAllowed() &&
+ !rSh.IsAdjustCellWidthAllowed(sal_True) &&
+ !rSh.BalanceRowHeight(sal_True) )
+ rSet.DisableItem(FN_OPTIMIZE_TABLE);
+ break;
+ case SID_INSERT_DIAGRAM:
+ {
+ SvtModuleOptions aMOpt;
+ if ( !aMOpt.IsMath() || rSh.IsTblComplexForChart() )
+ rSet.DisableItem(nSlot);
+ }
+ break;
+
+ case FN_INSERT_TABLE:
+ if ( rSh.CrsrInsideInputFld() )
+ {
+ rSet.DisableItem( nSlot );
+ }
+ break;
+
+ case FN_TABLE_OPTIMAL_HEIGHT:
+ {
+ // Disable if auto height already is enabled.
+ SwFmtFrmSize *pSz;
+ rSh.GetRowHeight( pSz );
+ if ( pSz )
+ {
+ if ( ATT_VAR_SIZE == pSz->GetHeightSizeType() )
+ rSet.DisableItem( nSlot );
+ delete pSz;
+ }
+ }
+ break;
+ case FN_TABLE_INSERT_ROW:
+ case FN_TABLE_INSERT_ROW_DLG:
+ {
+ if ( rSh.IsInRepeatedHeadline() )
+ rSet.DisableItem( nSlot );
+ }
+ break;
+ case RES_LR_SPACE:
+ rSet.Put(pFmt->GetLRSpace());
+ break;
+ case RES_UL_SPACE:
+ rSet.Put(pFmt->GetULSpace());
+ break;
+
+ case SID_TABLE_VERT_NONE:
+ case SID_TABLE_VERT_CENTER:
+ case SID_TABLE_VERT_BOTTOM:
+ {
+ sal_uInt16 nAlign = rSh.GetBoxAlign();
+ sal_Bool bSet = (nSlot == SID_TABLE_VERT_NONE && nAlign == text::VertOrientation::NONE) ||
+ (nSlot == SID_TABLE_VERT_CENTER && nAlign == text::VertOrientation::CENTER) ||
+ (nSlot == SID_TABLE_VERT_BOTTOM && nAlign == text::VertOrientation::BOTTOM);
+ rSet.Put(SfxBoolItem(nSlot, bSet));
+ }
+ break;
+
+ case FN_TABLE_MODE_FIX :
+ case FN_TABLE_MODE_FIX_PROP :
+ case FN_TABLE_MODE_VARIABLE :
+ {
+ TblChgMode nMode = rSh.GetTblChgMode();
+ sal_Bool bSet = (nSlot == FN_TABLE_MODE_FIX && nMode == TBLFIX_CHGABS) ||
+ (nSlot == FN_TABLE_MODE_FIX_PROP && nMode == TBLFIX_CHGPROP) ||
+ (nSlot == FN_TABLE_MODE_VARIABLE && nMode == TBLVAR_CHGABS);
+ rSet.Put(SfxBoolItem(nSlot, bSet));
+ }
+ break;
+
+ case SID_ATTR_PARA_SPLIT:
+ rSet.Put( pFmt->GetKeep() );
+ break;
+
+ case SID_ATTR_PARA_KEEP:
+ rSet.Put( pFmt->GetLayoutSplit() );
+ break;
+ case FN_TABLE_SPLIT_TABLE:
+ {
+ if ( rSh.IsInHeadline() )
+ rSet.DisableItem( nSlot );
+ }
+ break;
+ case FN_TABLE_MERGE_TABLE:
+ {
+ sal_Bool bAsk;
+ if( !rSh.CanMergeTable( sal_True, &bAsk ))
+ rSet.DisableItem( nSlot );
+ }
+ break;
+
+ case FN_TABLE_DELETE_ROW:
+ {
+ SwSelBoxes aBoxes;
+ ::GetTblSel( rSh, aBoxes, nsSwTblSearchType::TBLSEARCH_ROW );
+ if( ::HasProtectedCells( aBoxes ))
+ rSet.DisableItem( nSlot );
+ }
+ break;
+ case FN_TABLE_DELETE_COL:
+ {
+ SwSelBoxes aBoxes;
+ ::GetTblSel( rSh, aBoxes, nsSwTblSearchType::TBLSEARCH_COL );
+ if( ::HasProtectedCells( aBoxes ))
+ rSet.DisableItem( nSlot );
+ }
+ break;
+
+ case FN_TABLE_UNSET_READ_ONLY_CELLS:
+ // disable in readonly sections, but enable in protected cells
+ if( !rSh.CanUnProtectCells() )
+ rSet.DisableItem( nSlot );
+ break;
+ case RES_ROW_SPLIT:
+ {
+ const SwFmtLayoutSplit& rTabSplit = pFmt->GetLayoutSplit();
+ if ( !rTabSplit.GetValue() )
+ {
+ rSet.DisableItem( nSlot );
+ }
+ else
+ {
+ SwFmtRowSplit* pSplit = 0;
+ rSh.GetRowSplit(pSplit);
+ if(pSplit)
+ rSet.Put(*pSplit);
+ else
+ rSet.InvalidateItem( nSlot );
+ delete pSplit;
+ }
+ }
+ break;
+ case FN_TABLE_HEADLINE_REPEAT:
+ if(0 != rSh.GetRowsToRepeat())
+ rSet.Put(SfxBoolItem(nSlot, true));
+ else if(!rSh.GetRowSelectionFromTop())
+ rSet.DisableItem( nSlot );
+ else
+ rSet.Put(SfxBoolItem(nSlot, false));
+ break;
+ case FN_TABLE_SELECT_CELL :
+ if(rSh.HasBoxSelection())
+ rSet.DisableItem( nSlot );
+ break;
+ }
+ nSlot = aIter.NextWhich();
+ }
+}
+
+SwTableShell::SwTableShell(SwView &_rView) :
+ SwBaseShell(_rView)
+{
+ SetName(OUString("Table"));
+ SetHelpId(SW_TABSHELL);
+ SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_Table));
+}
+
+void SwTableShell::GetFrmBorderState(SfxItemSet &rSet)
+{
+ SfxItemSet aCoreSet( GetPool(),
+ RES_BOX, RES_BOX,
+ SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 0 );
+ SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
+ aCoreSet.Put( aBoxInfo );
+ GetShell().GetTabBorders( aCoreSet );
+ rSet.Put( aCoreSet );
+}
+
+void SwTableShell::ExecTableStyle(SfxRequest& rReq)
+{
+ SwWrtShell &rSh = GetShell();
+ const SfxItemSet *pArgs = rReq.GetArgs();
+ if(pArgs)
+ switch ( rReq.GetSlot() )
+ {
+ case SID_FRAME_LINESTYLE:
+ case SID_FRAME_LINECOLOR:
+ {
+ if ( rReq.GetSlot() == SID_FRAME_LINESTYLE )
+ {
+ const SvxLineItem &rLineItem = (const SvxLineItem&)pArgs->
+ Get( SID_FRAME_LINESTYLE );
+ const SvxBorderLine* pBorderLine = rLineItem.GetLine();
+ rSh.SetTabLineStyle( 0, sal_True, pBorderLine);
+ }
+ else
+ {
+ const SvxColorItem &rNewColorItem = (const SvxColorItem&)pArgs->
+ Get( SID_FRAME_LINECOLOR );
+ rSh.SetTabLineStyle( &rNewColorItem.GetValue() );
+ }
+
+ rReq.Done();
+
+ break;
+ }
+ }
+}
+
+void SwTableShell::GetLineStyleState(SfxItemSet &rSet)
+{
+ SfxItemSet aCoreSet( GetPool(),
+ RES_BOX, RES_BOX,
+ SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 0);
+ SvxBoxInfoItem aCoreInfo( SID_ATTR_BORDER_INNER );
+ aCoreSet.Put(aCoreInfo);
+ GetShell().GetTabBorders( aCoreSet );
+
+ const SvxBoxItem& rBoxItem = (const SvxBoxItem&)aCoreSet.Get( RES_BOX );
+ const SvxBorderLine* pLine = rBoxItem.GetTop();
+
+ rSet.Put( SvxColorItem( pLine ? pLine->GetColor() : Color(), SID_FRAME_LINECOLOR ) );
+ SvxLineItem aLine( SID_FRAME_LINESTYLE );
+ aLine.SetLine(pLine);
+ rSet.Put( aLine );
+}
+
+void SwTableShell::ExecNumberFormat(SfxRequest& rReq)
+{
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ SwWrtShell &rSh = GetShell();
+
+ // At first the slots, which doesn't need a FrmMgr.
+ const SfxPoolItem* pItem = 0;
+ sal_uInt16 nSlot = rReq.GetSlot();
+ if(pArgs)
+ pArgs->GetItemState(GetPool().GetWhich(nSlot), false, &pItem);
+
+ // Always aquire the language from the current cursor position.
+ LanguageType eLang = rSh.GetCurLang();
+ SvNumberFormatter* pFormatter = rSh.GetNumberFormatter();
+ sal_uInt32 nNumberFormat = NUMBERFORMAT_ENTRY_NOT_FOUND;
+ sal_uInt16 nFmtType = 0, nOffset = 0;
+
+ switch ( nSlot )
+ {
+ case FN_NUMBER_FORMAT:
+ if( pItem )
+ {
+ // Determine index for string.
+ OUString aCode( ((const SfxStringItem*)pItem)->GetValue() );
+ nNumberFormat = pFormatter->GetEntryKey( aCode, eLang );
+ if( NUMBERFORMAT_ENTRY_NOT_FOUND == nNumberFormat )
+ {
+ // Re-enter
+ sal_Int32 nErrPos;
+ short nType;
+ if( !pFormatter->PutEntry( aCode, nErrPos, nType,
+ nNumberFormat, eLang ))
+ nNumberFormat = NUMBERFORMAT_ENTRY_NOT_FOUND;
+ }
+ }
+ break;
+ case FN_NUMBER_STANDARD: nFmtType = NUMBERFORMAT_NUMBER; break;
+ case FN_NUMBER_SCIENTIFIC: nFmtType = NUMBERFORMAT_SCIENTIFIC; break;
+ case FN_NUMBER_DATE: nFmtType = NUMBERFORMAT_DATE; break;
+ case FN_NUMBER_TIME: nFmtType = NUMBERFORMAT_TIME; break;
+ case FN_NUMBER_CURRENCY: nFmtType = NUMBERFORMAT_CURRENCY; break;
+ case FN_NUMBER_PERCENT: nFmtType = NUMBERFORMAT_PERCENT; break;
+
+ case FN_NUMBER_TWODEC: // #.##0,00
+ nFmtType = NUMBERFORMAT_NUMBER;
+ nOffset = NF_NUMBER_1000DEC2;
+ break;
+
+ default:
+ OSL_FAIL("wrong dispatcher");
+ return;
+ }
+
+ if( nFmtType )
+ nNumberFormat = pFormatter->GetStandardFormat( nFmtType, eLang ) + nOffset;
+
+ if( NUMBERFORMAT_ENTRY_NOT_FOUND != nNumberFormat )
+ {
+ SfxItemSet aBoxSet( GetPool(), RES_BOXATR_FORMAT, RES_BOXATR_FORMAT );
+ aBoxSet.Put( SwTblBoxNumFormat( nNumberFormat ));
+ rSh.SetTblBoxFormulaAttrs( aBoxSet );
+ }
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/shells/textdrw.cxx b/sw/source/core/uibase/shells/textdrw.cxx
new file mode 100644
index 000000000000..fcc12affcb9c
--- /dev/null
+++ b/sw/source/core/uibase/shells/textdrw.cxx
@@ -0,0 +1,122 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <svx/svdview.hxx>
+#include <tools/urlobj.hxx>
+#include <svx/fmglob.hxx>
+#include <svx/svdouno.hxx>
+#include <com/sun/star/form/FormButtonType.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+#include <view.hxx>
+#include <wrtsh.hxx>
+#include <edtwin.hxx>
+#include <swundo.hxx>
+#include <basesh.hxx>
+
+#include <poolfmt.hrc>
+
+#include <docsh.hxx>
+#include <sfx2/docfile.hxx>
+#include <svl/urihelper.hxx>
+#include <avmedia/mediawindow.hxx>
+
+#include <unomid.h>
+
+using namespace ::com::sun::star;
+
+void SwBaseShell::InsertURLButton(const OUString& rURL, const OUString& rTarget, const OUString& rTxt)
+{
+ SwWrtShell& rSh = GetShell();
+
+ if (!rSh.HasDrawView())
+ rSh.MakeDrawView();
+ SdrView *pSdrView = rSh.GetDrawView();
+
+ // OBJ_FM_BUTTON
+ pSdrView->SetDesignMode(true);
+ pSdrView->SetCurrentObj(OBJ_FM_BUTTON);
+ pSdrView->SetEditMode(sal_False);
+
+ Point aStartPos(rSh.GetCharRect().Pos() + Point(0, 1));
+
+ rSh.StartAction();
+ rSh.StartUndo( UNDO_UI_INSERT_URLBTN );
+ if (rSh.BeginCreate(OBJ_FM_BUTTON, FmFormInventor, aStartPos))
+ {
+ pSdrView->SetOrtho(false);
+ Size aSz(GetView().GetEditWin().PixelToLogic(Size(140, 20)));
+ Point aEndPos(aSz.Width(), aSz.Height());
+
+ rSh.MoveCreate(aStartPos + aEndPos);
+ rSh.EndCreate(SDRCREATE_FORCEEND);
+
+ const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
+ if (rMarkList.GetMark(0))
+ {
+ SdrUnoObj* pUnoCtrl = PTR_CAST(SdrUnoObj, rMarkList.GetMark(0)->GetMarkedSdrObj());
+ uno::Reference< awt::XControlModel > xControlModel = pUnoCtrl->GetUnoControlModel();
+
+ OSL_ENSURE( xControlModel.is(), "UNO-Control without Model" );
+ if( !xControlModel.is() )
+ return;
+
+ uno::Reference< beans::XPropertySet > xPropSet(xControlModel, uno::UNO_QUERY);
+
+ uno::Any aTmp;
+
+ aTmp <<= OUString(rTxt);
+ xPropSet->setPropertyValue( "Label", aTmp );
+
+ SfxMedium* pMedium = rSh.GetView().GetDocShell()->GetMedium();
+ INetURLObject aAbs;
+ if( pMedium )
+ aAbs = pMedium->GetURLObject();
+
+ aTmp <<= OUString(URIHelper::SmartRel2Abs(aAbs, rURL));
+ xPropSet->setPropertyValue( "TargetURL", aTmp );
+
+ if( !rTarget.isEmpty() )
+ {
+ aTmp <<= rTarget;
+ xPropSet->setPropertyValue( "TargetFrame", aTmp );
+ }
+
+ form::FormButtonType eButtonType = form::FormButtonType_URL;
+ aTmp.setValue( &eButtonType, ::getCppuType((const form::FormButtonType*)0));
+ xPropSet->setPropertyValue( "ButtonType", aTmp );
+
+ if ( ::avmedia::MediaWindow::isMediaURL( rURL, ""/*TODO?*/ ) )
+ {
+ // #105638# OJ
+ aTmp <<= sal_True;
+ xPropSet->setPropertyValue("DispatchURLInternal", aTmp );
+ }
+ }
+
+ if (rSh.IsObjSelected())
+ {
+ rSh.UnSelectFrm();
+ }
+ }
+ rSh.EndUndo( UNDO_UI_INSERT_URLBTN );
+ rSh.EndAction();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/shells/textfld.cxx b/sw/source/core/uibase/shells/textfld.cxx
new file mode 100644
index 000000000000..5b336ff25aee
--- /dev/null
+++ b/sw/source/core/uibase/shells/textfld.cxx
@@ -0,0 +1,923 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <crsskip.hxx>
+#include <hintids.hxx>
+
+#include <sfx2/lnkbase.hxx>
+#include <fmtfld.hxx>
+#include <vcl/msgbox.hxx>
+#include <svl/itempool.hxx>
+#include <unotools/useroptions.hxx>
+#include <svl/whiter.hxx>
+#include <svl/eitem.hxx>
+#include <svl/macitem.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/request.hxx>
+#include <svx/postattr.hxx>
+#include <svx/hlnkitem.hxx>
+#include <svx/svxdlg.hxx>
+#include <sfx2/linkmgr.hxx>
+#include <unotools/localedatawrapper.hxx>
+#include <sfx2/dispatch.hxx>
+#include <fmtinfmt.hxx>
+#include <fldwrap.hxx>
+#include <redline.hxx>
+#include <view.hxx>
+#include <viewopt.hxx>
+#include <wrtsh.hxx>
+#include <basesh.hxx>
+#include <flddat.hxx>
+#include <numrule.hxx>
+#include <textsh.hxx>
+#include <docsh.hxx>
+#include <docufld.hxx>
+#include <usrfld.hxx>
+#include <ddefld.hxx>
+#include <expfld.hxx>
+#include <fldmgr.hxx>
+#include <uitool.hxx>
+#include <cmdid.h>
+#include <shells.hrc>
+#include <sfx2/app.hxx>
+#include <svx/dialogs.hrc>
+#include "swabstdlg.hxx"
+#include "dialog.hrc"
+#include <fldui.hrc>
+#include <doc.hxx>
+#include <app.hrc>
+#include <edtwin.hxx>
+#include <PostItMgr.hxx>
+#include <switerator.hxx>
+
+using namespace nsSwDocInfoSubType;
+
+extern bool bNoInterrupt; // in mainwn.cxx
+
+static OUString& lcl_AppendRedlineStr( OUString& rStr, sal_uInt16 nRedlId )
+{
+ sal_uInt16 nResId = 0;
+ switch( nRedlId )
+ {
+ case nsRedlineType_t::REDLINE_INSERT: nResId = STR_REDLINE_INSERTED; break;
+ case nsRedlineType_t::REDLINE_DELETE: nResId = STR_REDLINE_DELETED; break;
+ case nsRedlineType_t::REDLINE_FORMAT: nResId = STR_REDLINE_FORMATED; break;
+ case nsRedlineType_t::REDLINE_TABLE: nResId = STR_REDLINE_TABLECHG; break;
+ case nsRedlineType_t::REDLINE_FMTCOLL: nResId = STR_REDLINE_FMTCOLLSET; break;
+ }
+ if( nResId )
+ rStr += SW_RESSTR( nResId );
+ return rStr;
+}
+
+void SwTextShell::ExecField(SfxRequest &rReq)
+{
+ SwWrtShell& rSh = GetShell();
+ const SfxPoolItem* pItem = 0;
+
+ sal_uInt16 nSlot = rReq.GetSlot();
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ if(pArgs)
+ pArgs->GetItemState(GetPool().GetWhich(nSlot), false, &pItem);
+
+ Window *pMDI = &GetView().GetViewFrame()->GetWindow();
+ bool bMore = false;
+ bool bIsText = true;
+ sal_uInt16 nInsertType = 0;
+ sal_uInt16 nInsertSubType = 0;
+ sal_uLong nInsertFormat = 0;
+
+ switch(nSlot)
+ {
+ case FN_EDIT_FIELD:
+ {
+ SwField* pFld = rSh.GetCurFld();
+ if( pFld )
+ {
+ switch ( pFld->GetTypeId() )
+ {
+ case TYP_DDEFLD:
+ {
+ ::sfx2::SvBaseLink& rLink = ((SwDDEFieldType*)pFld->GetTyp())->
+ GetBaseLink();
+ if(rLink.IsVisible())
+ {
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ SfxAbstractLinksDialog* pDlg = pFact->CreateLinksDialog( pMDI, &rSh.GetLinkManager(), sal_False, &rLink );
+ if ( pDlg )
+ {
+ pDlg->Execute();
+ delete pDlg;
+ }
+ }
+ break;
+ }
+ default:
+ {
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+
+ SfxAbstractDialog* pDlg = pFact->CreateSwFldEditDlg( GetView(),RC_DLG_SWFLDEDITDLG );
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ pDlg->Execute();
+ delete pDlg;
+ }
+ }
+ }
+ break;
+ }
+ case FN_EXECUTE_MACROFIELD:
+ {
+ SwField* pFld = rSh.GetCurFld();
+ if(pFld && pFld->GetTyp()->Which() == RES_MACROFLD)
+ {
+
+ const OUString& rMacro = ((SwMacroField*)pFld)->GetMacro();
+ sal_Int32 nPos = rMacro.indexOf('.');
+ if(nPos != -1)
+ {
+ SvxMacro aMacro( rMacro.copy(nPos + 1), rMacro.copy(0,nPos), STARBASIC );
+ rSh.ExecMacro(aMacro);
+ }
+ }
+ }
+ break;
+
+ case FN_GOTO_NEXT_INPUTFLD:
+ case FN_GOTO_PREV_INPUTFLD:
+ {
+ sal_Bool bRet = sal_False;
+ SwFieldType* pFld = rSh.GetFldType( 0, RES_INPUTFLD );
+ const bool bAddSetExpressionFlds = !( rSh.GetViewOptions()->IsReadonly() );
+ if ( pFld != NULL
+ && rSh.MoveFldType(
+ pFld,
+ FN_GOTO_NEXT_INPUTFLD == nSlot,
+ USHRT_MAX,
+ bAddSetExpressionFlds ) )
+ {
+ rSh.ClearMark();
+ if ( dynamic_cast<SwInputField*>(rSh.GetCurFld( true )) != NULL )
+ {
+ rSh.SttSelect();
+ rSh.SelectTxt(
+ rSh.StartOfInputFldAtPos( *(rSh.GetCrsr()->Start()) ) + 1,
+ rSh.EndOfInputFldAtPos( *(rSh.GetCrsr()->Start()) ) - 1 );
+ }
+ else
+ {
+ rSh.StartInputFldDlg( rSh.GetCurFld( true ), sal_False );
+ }
+ bRet = sal_True;
+ }
+
+ rReq.SetReturnValue( SfxBoolItem( nSlot, bRet ));
+ }
+ break;
+
+ default:
+ bMore = true;
+ }
+ if(bMore)
+ {
+ // Here come the slots with FldMgr.
+ SwFldMgr aFldMgr(GetShellPtr());
+ switch(nSlot)
+ {
+ case FN_INSERT_DBFIELD:
+ {
+ sal_Bool bRes = sal_False;
+ if( pItem )
+ {
+ sal_uLong nFormat = 0;
+ sal_uInt16 nType = 0;
+ OUString aPar1 = ((SfxStringItem *)pItem)->GetValue();
+ OUString aPar2;
+ sal_Int32 nCommand = 0;
+
+ if( SFX_ITEM_SET == pArgs->GetItemState( FN_PARAM_FIELD_TYPE,
+ false, &pItem ))
+ nType = ((SfxUInt16Item *)pItem)->GetValue();
+ aPar1 += OUString(DB_DELIM);
+ if( SFX_ITEM_SET == pArgs->GetItemState(
+ FN_PARAM_1, false, &pItem ))
+ {
+ aPar1 += ((SfxStringItem *)pItem)->GetValue();
+ }
+ if( SFX_ITEM_SET == pArgs->GetItemState(
+ FN_PARAM_3, false, &pItem ))
+ nCommand = ((SfxInt32Item*)pItem)->GetValue();
+ aPar1 += OUString(DB_DELIM);
+ aPar1 += OUString::number(nCommand);
+ aPar1 += OUString(DB_DELIM);
+ if( SFX_ITEM_SET == pArgs->GetItemState(
+ FN_PARAM_2, false, &pItem ))
+ {
+ aPar1 += ((SfxStringItem *)pItem)->GetValue();
+ }
+ if( SFX_ITEM_SET == pArgs->GetItemState(
+ FN_PARAM_FIELD_CONTENT, false, &pItem ))
+ aPar2 = ((SfxStringItem *)pItem)->GetValue();
+ if( SFX_ITEM_SET == pArgs->GetItemState(
+ FN_PARAM_FIELD_FORMAT, false, &pItem ))
+ nFormat = ((SfxUInt32Item *)pItem)->GetValue();
+ OSL_FAIL("Command is not yet used");
+ sal_Unicode cSeparator = ' ';
+ SwInsertFld_Data aData(nType, 0, aPar1, aPar2, nFormat, GetShellPtr(), cSeparator );
+ bRes = aFldMgr.InsertFld(aData);
+ }
+ rReq.SetReturnValue(SfxBoolItem( nSlot, bRes ));
+ }
+ break;
+ case FN_INSERT_FIELD_CTRL:
+ case FN_INSERT_FIELD:
+ {
+ sal_Bool bRes = sal_False;
+ if( pItem && nSlot != FN_INSERT_FIELD_CTRL)
+ {
+ sal_uLong nFormat = 0;
+ sal_uInt16 nType = 0;
+ sal_uInt16 nSubType = 0;
+ OUString aPar1 = ((SfxStringItem *)pItem)->GetValue();
+ OUString aPar2;
+ sal_Unicode cSeparator = ' ';
+
+ if( SFX_ITEM_SET == pArgs->GetItemState( FN_PARAM_FIELD_TYPE,
+ false, &pItem ))
+ nType = ((SfxUInt16Item *)pItem)->GetValue();
+ if( SFX_ITEM_SET == pArgs->GetItemState( FN_PARAM_FIELD_SUBTYPE,
+ false, &pItem ))
+ nSubType = ((SfxUInt16Item *)pItem)->GetValue();
+ if( SFX_ITEM_SET == pArgs->GetItemState(
+ FN_PARAM_FIELD_CONTENT, false, &pItem ))
+ aPar2 = ((SfxStringItem *)pItem)->GetValue();
+ if( SFX_ITEM_SET == pArgs->GetItemState(
+ FN_PARAM_FIELD_FORMAT, false, &pItem ))
+ nFormat = ((SfxUInt32Item *)pItem)->GetValue();
+ if( SFX_ITEM_SET == pArgs->GetItemState(
+ FN_PARAM_3, false, &pItem ))
+ {
+ OUString sTmp = ((SfxStringItem *)pItem)->GetValue();
+ if(!sTmp.isEmpty())
+ cSeparator = sTmp[0];
+ }
+ SwInsertFld_Data aData(nType, nSubType, aPar1, aPar2, nFormat, GetShellPtr(), cSeparator );
+ bRes = aFldMgr.InsertFld( aData );
+ }
+ else
+ //#i5788# prevent closing of the field dialog while a modal dialog ( Input field dialog ) is active
+ if(!GetView().GetViewFrame()->IsInModalMode())
+ {
+ SfxViewFrame* pVFrame = GetView().GetViewFrame();
+ pVFrame->ToggleChildWindow(FN_INSERT_FIELD);
+ bRes = pVFrame->GetChildWindow( nSlot ) != 0;
+ Invalidate(rReq.GetSlot());
+ Invalidate(FN_INSERT_FIELD_CTRL);
+ rReq.Ignore();
+ }
+ rReq.SetReturnValue(SfxBoolItem( nSlot, bRes ));
+ }
+ break;
+
+ case FN_INSERT_REF_FIELD:
+ {
+ SfxViewFrame* pVFrame = GetView().GetViewFrame();
+ if (!pVFrame->HasChildWindow(FN_INSERT_FIELD))
+ pVFrame->ToggleChildWindow(FN_INSERT_FIELD); // Show dialog
+
+ // Switch Flddlg at a new TabPage
+ sal_uInt16 nId = SwFldDlgWrapper::GetChildWindowId();
+ SwFldDlgWrapper *pWrp = (SwFldDlgWrapper*)pVFrame->GetChildWindow(nId);
+ if (pWrp)
+ pWrp->ShowReferencePage();
+ rReq.Ignore();
+ }
+ break;
+ case FN_DELETE_COMMENT:
+ if ( GetView().GetPostItMgr() &&
+ GetView().GetPostItMgr()->HasActiveSidebarWin() )
+ {
+ GetView().GetPostItMgr()->DeleteActiveSidebarWin();
+ }
+ break;
+ case FN_DELETE_ALL_NOTES:
+ if ( GetView().GetPostItMgr() )
+ GetView().GetPostItMgr()->Delete();
+ break;
+ case FN_DELETE_NOTE_AUTHOR:
+ {
+ SFX_REQUEST_ARG( rReq, pNoteItem, SfxStringItem, nSlot, false);
+ if ( pNoteItem && GetView().GetPostItMgr() )
+ GetView().GetPostItMgr()->Delete( pNoteItem->GetValue() );
+ }
+ break;
+ case FN_HIDE_NOTE:
+ if ( GetView().GetPostItMgr() &&
+ GetView().GetPostItMgr()->HasActiveSidebarWin() )
+ {
+ GetView().GetPostItMgr()->HideActiveSidebarWin();
+ }
+ break;
+ case FN_HIDE_ALL_NOTES:
+ if ( GetView().GetPostItMgr() )
+ GetView().GetPostItMgr()->Hide();
+ break;
+ case FN_HIDE_NOTE_AUTHOR:
+ {
+ SFX_REQUEST_ARG( rReq, pNoteItem, SfxStringItem, nSlot, false);
+ if ( pNoteItem && GetView().GetPostItMgr() )
+ GetView().GetPostItMgr()->Hide( pNoteItem->GetValue() );
+ }
+ break;
+ case FN_POSTIT:
+ {
+ SwPostItField* pPostIt = dynamic_cast<SwPostItField*>(aFldMgr.GetCurFld());
+ bool bNew = !(pPostIt && pPostIt->GetTyp()->Which() == RES_POSTITFLD);
+ if (bNew || GetView().GetPostItMgr()->IsAnswer())
+ {
+ SvtUserOptions aUserOpt;
+ OUString sAuthor;
+ if( (sAuthor = aUserOpt.GetFullName()).isEmpty())
+ if( (sAuthor = aUserOpt.GetID()).isEmpty() )
+ sAuthor = SW_RES( STR_REDLINE_UNKNOWN_AUTHOR );
+
+ if ( rSh.HasSelection() && !rSh.IsTableMode() )
+ {
+ rSh.KillPams();
+ }
+
+ // #i120513# Inserting a comment into an autocompletion crashes
+ // --> suggestion has to be removed before
+ GetView().GetEditWin().StopQuickHelp();
+
+ SwInsertFld_Data aData(TYP_POSTITFLD, 0, sAuthor, OUString(), 0);
+ aFldMgr.InsertFld( aData );
+
+ rSh.Push();
+ rSh.SwCrsrShell::Left(1, CRSR_SKIP_CHARS, sal_False);
+ pPostIt = (SwPostItField*)aFldMgr.GetCurFld();
+ rSh.Pop(sal_False); // Restore cursor position
+ }
+
+ if (pPostIt)
+ {
+ SwFieldType* pType = rSh.GetDoc()->GetFldType(RES_POSTITFLD, OUString(), false);
+ SwIterator<SwFmtFld,SwFieldType> aIter( *pType );
+ SwFmtFld* pSwFmtFld = aIter.First();
+ while( pSwFmtFld )
+ {
+ if ( pSwFmtFld->GetField() == pPostIt )
+ {
+ pSwFmtFld->Broadcast( SwFmtFldHint( 0, SWFMTFLD_FOCUS, &GetView() ) );
+ break;
+ }
+ pSwFmtFld = aIter.Next();
+ }
+ }
+ }
+ break;
+ case FN_REDLINE_COMMENT:
+ {
+ /* this code can be used once we want redline comments in the margin, all other stuff can
+ then be deleted
+ String sComment;
+ const SwRangeRedline *pRedline = rSh.GetCurrRedline();
+
+ if (pRedline)
+ {
+ sComment = pRedline->GetComment();
+ if ( !sComment.Len() )
+ GetView().GetDocShell()->Broadcast(SwRedlineHint(pRedline,SWREDLINE_INSERTED));
+ const_cast<SwRangeRedline*>(pRedline)->Broadcast(SwRedlineHint(pRedline,SWREDLINE_FOCUS,&GetView()));
+ }
+ */
+
+ const SwRangeRedline *pRedline = rSh.GetCurrRedline();
+
+ if (pRedline)
+ {
+ OUString sComment = convertLineEnd(pRedline->GetComment(), GetSystemLineEnd());
+
+ sal_Bool bTravel = sal_False;
+
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "Dialogdiet fail!");
+ ::DialogGetRanges fnGetRange = pFact->GetDialogGetRangesFunc();
+ OSL_ENSURE(fnGetRange, "Dialogdiet fail! GetRanges()");
+ SfxItemSet aSet(GetPool(), fnGetRange());
+ aSet.Put(SvxPostItTextItem(sComment, SID_ATTR_POSTIT_TEXT));
+ aSet.Put(SvxPostItAuthorItem(pRedline->GetAuthorString(), SID_ATTR_POSTIT_AUTHOR));
+
+ aSet.Put( SvxPostItDateItem( GetAppLangDateTimeString(
+ pRedline->GetRedlineData().GetTimeStamp() ),
+ SID_ATTR_POSTIT_DATE ));
+
+ // Traveling only if more than one field.
+ rSh.StartAction();
+
+ rSh.Push();
+ const SwRangeRedline *pActRed = rSh.SelPrevRedline();
+
+ if (pActRed == pRedline)
+ { // New cursor is at the beginning of the current redlines.
+ rSh.Pop(); // Throw old cursor away
+ rSh.Push();
+ pActRed = rSh.SelPrevRedline();
+ }
+
+ sal_Bool bPrev = pActRed != 0;
+ rSh.Pop(sal_False);
+ rSh.EndAction();
+
+ rSh.ClearMark();
+ rSh.SelNextRedline(); // Select current redline.
+
+ rSh.StartAction();
+ rSh.Push();
+ pActRed = rSh.SelNextRedline();
+ sal_Bool bNext = pActRed != 0;
+ rSh.Pop(sal_False); // Restore cursor position
+
+ if( rSh.IsCrsrPtAtEnd() )
+ rSh.SwapPam();
+
+ rSh.EndAction();
+
+ bTravel |= bNext|bPrev;
+
+ SvxAbstractDialogFactory* pFact2 = SvxAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact2, "Dialogdiet fail!");
+ AbstractSvxPostItDialog* pDlg = pFact2->CreateSvxPostItDialog( pMDI, aSet, bTravel );
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ pDlg->HideAuthor();
+
+ OUString sTitle(SW_RES(STR_REDLINE_COMMENT));
+ ::lcl_AppendRedlineStr( sTitle, pRedline->GetType() );
+
+ pDlg->SetText(sTitle);
+
+ if (bTravel)
+ {
+ pDlg->EnableTravel(bNext, bPrev);
+ pDlg->SetPrevHdl(LINK(this, SwTextShell, RedlinePrevHdl));
+ pDlg->SetNextHdl(LINK(this, SwTextShell, RedlineNextHdl));
+ }
+
+ rSh.SetCareWin(pDlg->GetWindow());
+ bNoInterrupt = true;
+
+ if ( pDlg->Execute() == RET_OK )
+ {
+ const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
+ OUString sMsg(((const SvxPostItTextItem&)pOutSet->Get(SID_ATTR_POSTIT_TEXT)).GetValue());
+
+ // Insert or change a comment
+ rSh.SetRedlineComment(sMsg);
+ }
+
+ delete pDlg;
+ rSh.SetCareWin(NULL);
+ bNoInterrupt = false;
+ rSh.ClearMark();
+ GetView().AttrChangedNotify(GetShellPtr());
+ }
+ }
+ break;
+
+ case FN_JAVAEDIT:
+ {
+ OUString aType, aText;
+ sal_Bool bIsUrl=sal_False;
+ sal_Bool bNew=sal_False;
+ bool bUpdate = false;
+ SwFldMgr aMgr;
+ if ( pItem )
+ {
+ aText = ((SfxStringItem*)pItem)->GetValue();
+ SFX_REQUEST_ARG( rReq, pType, SfxStringItem, FN_PARAM_2 , false );
+ SFX_REQUEST_ARG( rReq, pIsUrl, SfxBoolItem, FN_PARAM_1 , false );
+ if ( pType )
+ aType = pType->GetValue();
+ if ( pIsUrl )
+ bIsUrl = pIsUrl->GetValue();
+
+ SwScriptField* pFld = (SwScriptField*)aMgr.GetCurFld();
+ bNew = !pFld || !(pFld->GetTyp()->Which() == RES_SCRIPTFLD);
+ bUpdate = pFld && ( bIsUrl != pFld->GetFormat() || pFld->GetPar2() != aType || pFld->GetPar1() != aText );
+ }
+ else
+ {
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "Dialogdiet fail!");
+ AbstractJavaEditDialog* pDlg = pFact->CreateJavaEditDialog(pMDI, &rSh);
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ if ( pDlg->Execute() )
+ {
+ aType = pDlg->GetScriptType();
+ aText = pDlg->GetScriptText();
+ bIsUrl = pDlg->IsUrl();
+ bNew = pDlg->IsNew();
+ bUpdate = pDlg->IsUpdate();
+ rReq.AppendItem( SfxStringItem( FN_JAVAEDIT, aText ) );
+ rReq.AppendItem( SfxStringItem( FN_PARAM_2, aType ) );
+ rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bIsUrl ) );
+ }
+
+ delete pDlg;
+ }
+
+ if( bNew )
+ {
+ SwInsertFld_Data aData(TYP_SCRIPTFLD, 0, aType, aText, bIsUrl);
+ aMgr.InsertFld(aData);
+ rReq.Done();
+ }
+ else if( bUpdate )
+ {
+ aMgr.UpdateCurFld( bIsUrl, aType, aText );
+ rSh.SetUndoNoResetModified();
+ rReq.Done();
+ }
+ else
+ rReq.Ignore();
+ }
+ break;
+
+ case FN_INSERT_FLD_DATE :
+ nInsertType = TYP_DATEFLD;
+ bIsText = false;
+ goto FIELD_INSERT;
+ case FN_INSERT_FLD_TIME :
+ nInsertType = TYP_TIMEFLD;
+ bIsText = false;
+ goto FIELD_INSERT;
+ case FN_INSERT_FLD_PGNUMBER:
+ nInsertType = TYP_PAGENUMBERFLD;
+ nInsertFormat = SVX_NUM_PAGEDESC; // Like page template
+ bIsText = false;
+ goto FIELD_INSERT;
+ case FN_INSERT_FLD_PGCOUNT :
+ nInsertType = TYP_DOCSTATFLD;
+ nInsertSubType = 0;
+ bIsText = false;
+ nInsertFormat = SVX_NUM_PAGEDESC;
+ goto FIELD_INSERT;
+ case FN_INSERT_FLD_TOPIC :
+ nInsertType = TYP_DOCINFOFLD;
+ nInsertSubType = DI_THEMA;
+ goto FIELD_INSERT;
+ case FN_INSERT_FLD_TITLE :
+ nInsertType = TYP_DOCINFOFLD;
+ nInsertSubType = DI_TITEL;
+ goto FIELD_INSERT;
+ case FN_INSERT_FLD_AUTHOR :
+ nInsertType = TYP_DOCINFOFLD;
+ nInsertSubType = DI_CREATE|DI_SUB_AUTHOR;
+
+FIELD_INSERT:
+ {
+ //format conversion should only be done for number formatter formats
+ if(!nInsertFormat)
+ nInsertFormat = aFldMgr.GetDefaultFormat(nInsertType, bIsText, rSh.GetNumberFormatter());
+ SwInsertFld_Data aData(nInsertType, nInsertSubType,
+ OUString(), OUString(), nInsertFormat);
+ aFldMgr.InsertFld(aData);
+ rReq.Done();
+ }
+ break;
+ default:
+ OSL_FAIL("wrong dispatcher");
+ return;
+ }
+ }
+}
+
+void SwTextShell::StateField( SfxItemSet &rSet )
+{
+ SwWrtShell& rSh = GetShell();
+ SfxWhichIter aIter( rSet );
+ const SwField* pField = 0;
+ int bGetField = sal_False;
+ sal_uInt16 nWhich = aIter.FirstWhich();
+
+ while (nWhich)
+ {
+ switch (nWhich)
+ {
+ case FN_DELETE_COMMENT:
+ case FN_DELETE_NOTE_AUTHOR:
+ case FN_DELETE_ALL_NOTES:
+ case FN_HIDE_NOTE:
+ case FN_HIDE_NOTE_AUTHOR:
+ case FN_HIDE_ALL_NOTES:
+ {
+ SwPostItMgr* pPostItMgr = GetView().GetPostItMgr();
+ if ( !pPostItMgr )
+ rSet.InvalidateItem( nWhich );
+ else if ( !pPostItMgr->HasActiveSidebarWin() )
+ {
+ rSet.InvalidateItem( FN_DELETE_COMMENT );
+ rSet.InvalidateItem( FN_HIDE_NOTE );
+ }
+ }
+ break;
+
+ case FN_EDIT_FIELD:
+ {
+ if( !bGetField )
+ {
+ pField = rSh.GetCurFld();
+ bGetField = sal_True;
+ }
+
+ sal_uInt16 nTempWhich = pField ? pField->GetTyp()->Which() : USHRT_MAX;
+ if( USHRT_MAX == nTempWhich ||
+ RES_POSTITFLD == nTempWhich ||
+ RES_SCRIPTFLD == nTempWhich ||
+ RES_AUTHORITY == nTempWhich )
+ rSet.DisableItem( nWhich );
+ else if( RES_DDEFLD == nTempWhich &&
+ !((SwDDEFieldType*)pField->GetTyp())->GetBaseLink().IsVisible())
+ {
+ // nested links cannot be edited
+ rSet.DisableItem( nWhich );
+ }
+ }
+ break;
+
+ case FN_EXECUTE_MACROFIELD:
+ {
+ if(!bGetField)
+ {
+ pField = rSh.GetCurFld();
+ bGetField = sal_True;
+ }
+ if(!pField || pField->GetTyp()->Which() != RES_MACROFLD)
+ rSet.DisableItem(nWhich);
+ }
+ break;
+
+ case FN_INSERT_FIELD:
+ {
+ if ( rSh.CrsrInsideInputFld() )
+ {
+ rSet.DisableItem(nWhich);
+ }
+ else
+ {
+ SfxViewFrame* pVFrame = GetView().GetViewFrame();
+ //#i5788# prevent closing of the field dialog while a modal dialog ( Input field dialog ) is active
+ if(!pVFrame->IsInModalMode() &&
+ pVFrame->KnowsChildWindow(FN_INSERT_FIELD) && !pVFrame->HasChildWindow(FN_INSERT_FIELD_DATA_ONLY) )
+ rSet.Put(SfxBoolItem( FN_INSERT_FIELD, pVFrame->HasChildWindow(nWhich)));
+ else
+ rSet.DisableItem(FN_INSERT_FIELD);
+ }
+ }
+ break;
+
+ case FN_INSERT_REF_FIELD:
+ {
+ SfxViewFrame* pVFrame = GetView().GetViewFrame();
+ if ( !pVFrame->KnowsChildWindow(FN_INSERT_FIELD)
+ || rSh.CrsrInsideInputFld() )
+ {
+ rSet.DisableItem(FN_INSERT_REF_FIELD);
+ }
+ }
+ break;
+
+ case FN_INSERT_FIELD_CTRL:
+ if ( rSh.CrsrInsideInputFld() )
+ {
+ rSet.DisableItem(nWhich);
+ }
+ else
+ {
+ rSet.Put(SfxBoolItem( nWhich, GetView().GetViewFrame()->HasChildWindow(FN_INSERT_FIELD)));
+ }
+ break;
+
+ case FN_REDLINE_COMMENT:
+ if (!rSh.GetCurrRedline())
+ rSet.DisableItem(nWhich);
+ break;
+
+ case FN_POSTIT :
+ case FN_JAVAEDIT :
+ {
+ sal_Bool bCurField = sal_False;
+ pField = rSh.GetCurFld();
+ if(nWhich == FN_POSTIT)
+ bCurField = pField && pField->GetTyp()->Which() == RES_POSTITFLD;
+ else
+ bCurField = pField && pField->GetTyp()->Which() == RES_SCRIPTFLD;
+
+ if( !bCurField && rSh.IsReadOnlyAvailable() && rSh.HasReadonlySel() )
+ {
+ rSet.DisableItem(nWhich);
+ }
+ else if ( rSh.CrsrInsideInputFld() )
+ {
+ rSet.DisableItem(nWhich);
+ }
+ }
+
+ break;
+
+ case FN_INSERT_FLD_AUTHOR:
+ case FN_INSERT_FLD_DATE:
+ case FN_INSERT_FLD_PGCOUNT:
+ case FN_INSERT_FLD_PGNUMBER:
+ case FN_INSERT_FLD_TIME:
+ case FN_INSERT_FLD_TITLE:
+ case FN_INSERT_FLD_TOPIC:
+ case FN_INSERT_DBFIELD:
+ if ( rSh.CrsrInsideInputFld() )
+ {
+ rSet.DisableItem(nWhich);
+ }
+ break;
+
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+void SwTextShell::InsertHyperlink(const SvxHyperlinkItem& rHlnkItem)
+{
+ const OUString& rName = rHlnkItem.GetName();
+ const OUString& rURL = rHlnkItem.GetURL();
+ const OUString& rTarget = rHlnkItem.GetTargetFrame();
+ sal_uInt16 nType = (sal_uInt16)rHlnkItem.GetInsertMode();
+ nType &= ~HLINK_HTMLMODE;
+ const SvxMacroTableDtor* pMacroTbl = rHlnkItem.GetMacroTbl();
+
+ SwWrtShell& rSh = GetShell();
+
+ if( rSh.GetSelectionType() & nsSelectionType::SEL_TXT )
+ {
+ rSh.StartAction();
+ SfxItemSet aSet(GetPool(), RES_TXTATR_INETFMT, RES_TXTATR_INETFMT);
+ rSh.GetCurAttr( aSet );
+
+ const SfxPoolItem* pItem;
+ if(SFX_ITEM_SET == aSet.GetItemState(RES_TXTATR_INETFMT, false, &pItem))
+ {
+ // Select links
+ rSh.SwCrsrShell::SelectTxtAttr(RES_TXTATR_INETFMT, sal_False);
+ }
+ switch (nType)
+ {
+ case HLINK_DEFAULT:
+ case HLINK_FIELD:
+ {
+ SwFmtINetFmt aINetFmt( rURL, rTarget );
+ aINetFmt.SetName(rHlnkItem.GetIntName());
+ if(pMacroTbl)
+ {
+ const SvxMacro *pMacro = pMacroTbl->Get( SFX_EVENT_MOUSEOVER_OBJECT );
+ if( pMacro )
+ aINetFmt.SetMacro(SFX_EVENT_MOUSEOVER_OBJECT, *pMacro);
+ pMacro = pMacroTbl->Get( SFX_EVENT_MOUSECLICK_OBJECT );
+ if( pMacro )
+ aINetFmt.SetMacro(SFX_EVENT_MOUSECLICK_OBJECT, *pMacro);
+ pMacro = pMacroTbl->Get( SFX_EVENT_MOUSEOUT_OBJECT );
+ if( pMacro )
+ aINetFmt.SetMacro(SFX_EVENT_MOUSEOUT_OBJECT, *pMacro);
+ }
+ rSh.SttSelect();
+ rSh.InsertURL( aINetFmt, rName, sal_True );
+ rSh.EndSelect();
+ }
+ break;
+
+ case HLINK_BUTTON:
+ sal_Bool bSel = rSh.HasSelection();
+ if(bSel)
+ rSh.DelRight();
+ InsertURLButton( rURL, rTarget, rName );
+ rSh.EnterStdMode();
+ break;
+ }
+ rSh.EndAction();
+ }
+}
+
+IMPL_LINK( SwTextShell, RedlineNextHdl, AbstractSvxPostItDialog *, pBtn )
+{
+ SwWrtShell* pSh = GetShellPtr();
+ AbstractSvxPostItDialog *pDlg = (AbstractSvxPostItDialog*)pBtn;
+
+ // Insert or change a comment.
+ pSh->SetRedlineComment(pDlg->GetNote());
+
+ const SwRangeRedline *pRedline = pSh->GetCurrRedline();
+
+ if (pRedline)
+ {
+ // Traveling only if more than one field.
+ if( !pSh->IsCrsrPtAtEnd() )
+ pSh->SwapPam(); // Move the cursor behind the Redline.
+
+ pSh->Push();
+ const SwRangeRedline *pActRed = pSh->SelNextRedline();
+ pSh->Pop(pActRed != 0);
+
+ sal_Bool bEnable = sal_False;
+
+ if (pActRed)
+ {
+ pSh->StartAction();
+ pSh->Push();
+ bEnable = pSh->SelNextRedline() != 0;
+ pSh->Pop(sal_False);
+ pSh->EndAction();
+ }
+
+ pDlg->EnableTravel(bEnable, sal_True);
+
+ if( pSh->IsCrsrPtAtEnd() )
+ pSh->SwapPam();
+
+ pRedline = pSh->GetCurrRedline();
+ OUString sComment = convertLineEnd(pRedline->GetComment(), GetSystemLineEnd());
+
+ pDlg->SetNote(sComment);
+ pDlg->ShowLastAuthor( pRedline->GetAuthorString(),
+ GetAppLangDateTimeString(
+ pRedline->GetRedlineData().GetTimeStamp() ));
+
+ OUString sTitle(SW_RES(STR_REDLINE_COMMENT));
+ ::lcl_AppendRedlineStr( sTitle, pRedline->GetType() );
+
+ pDlg->SetText(sTitle);
+ }
+
+ return 0;
+}
+
+IMPL_LINK( SwTextShell, RedlinePrevHdl, AbstractSvxPostItDialog *, pBtn )
+{
+ SwWrtShell* pSh = GetShellPtr();
+ AbstractSvxPostItDialog *pDlg = (AbstractSvxPostItDialog*)pBtn;
+
+ // Insert or change a comment.
+ pSh->SetRedlineComment(pDlg->GetNote());
+
+ const SwRangeRedline *pRedline = pSh->GetCurrRedline();
+
+ if (pRedline)
+ {
+ // Traveling only if more than one field.
+ pSh->Push();
+ const SwRangeRedline *pActRed = pSh->SelPrevRedline();
+ pSh->Pop(pActRed != 0);
+
+ sal_Bool bEnable = sal_False;
+
+ if (pActRed)
+ {
+ pSh->StartAction();
+ pSh->Push();
+ bEnable = pSh->SelPrevRedline() != 0;
+ pSh->Pop(sal_False);
+ pSh->EndAction();
+ }
+
+ pDlg->EnableTravel(sal_True, bEnable);
+
+ pRedline = pSh->GetCurrRedline();
+ OUString sComment = convertLineEnd(pRedline->GetComment(), GetSystemLineEnd());
+
+ pDlg->SetNote(sComment);
+ pDlg->ShowLastAuthor(pRedline->GetAuthorString(),
+ GetAppLangDateTimeString(
+ pRedline->GetRedlineData().GetTimeStamp() ));
+
+ OUString sTitle(SW_RES(STR_REDLINE_COMMENT));
+ ::lcl_AppendRedlineStr( sTitle, pRedline->GetType() );
+
+ pDlg->SetText(sTitle);
+ }
+
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/shells/textglos.cxx b/sw/source/core/uibase/shells/textglos.cxx
new file mode 100644
index 000000000000..365534a38549
--- /dev/null
+++ b/sw/source/core/uibase/shells/textglos.cxx
@@ -0,0 +1,129 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <sfx2/request.hxx>
+#include <svl/eitem.hxx>
+#include <svl/stritem.hxx>
+
+#include "view.hxx"
+#include "cmdid.h"
+#include "textsh.hxx"
+#include "initui.hxx"
+#include "gloshdl.hxx"
+#include "glosdoc.hxx"
+#include "gloslst.hxx"
+#include "swabstdlg.hxx"
+#include <misc.hrc>
+
+void SwTextShell::ExecGlossary(SfxRequest &rReq)
+{
+ sal_uInt16 nSlot = rReq.GetSlot();
+ ::GetGlossaries()->UpdateGlosPath(!rReq.IsAPI() ||
+ FN_GLOSSARY_DLG == nSlot );
+ SwGlossaryHdl* pGlosHdl = GetView().GetGlosHdl();
+ // Update SwGlossaryList?
+ bool bUpdateList = false;
+
+ const SfxItemSet *pArgs = rReq.GetArgs();
+ const SfxPoolItem* pItem = 0;
+ if(pArgs)
+ pArgs->GetItemState(nSlot, false, &pItem );
+
+ switch( nSlot )
+ {
+ case FN_GLOSSARY_DLG:
+ pGlosHdl->GlossaryDlg();
+ bUpdateList = true;
+ rReq.Ignore();
+ break;
+ case FN_EXPAND_GLOSSARY:
+ {
+ sal_Bool bReturn;
+ bReturn = pGlosHdl->ExpandGlossary();
+ rReq.SetReturnValue( SfxBoolItem( nSlot, bReturn ) );
+ rReq.Done();
+ }
+ break;
+ case FN_NEW_GLOSSARY:
+ if(pItem && pArgs->Count() == 3 )
+ {
+ OUString aGroup = (( const SfxStringItem *)pItem)->GetValue();
+ OUString aName;
+ if(SFX_ITEM_SET == pArgs->GetItemState(FN_PARAM_1, false, &pItem ))
+ aName = (( const SfxStringItem *)pItem)->GetValue();
+ OUString aShortName;
+ if(SFX_ITEM_SET == pArgs->GetItemState(FN_PARAM_2, false, &pItem ))
+ aShortName = (( const SfxStringItem *)pItem)->GetValue();
+
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "Dialogdiet fail!");
+ ::GlossarySetActGroup fnSetActGroup = pFact->SetGlossaryActGroupFunc();
+ if ( fnSetActGroup )
+ (*fnSetActGroup)( aGroup );
+ pGlosHdl->SetCurGroup(aGroup, sal_True);
+ // Chosen group must be created in NewGlossary if necessary!
+ pGlosHdl->NewGlossary( aName, aShortName, sal_True );
+ rReq.Done();
+ }
+ bUpdateList = true;
+ break;
+ case FN_SET_ACT_GLOSSARY:
+ if(pItem)
+ {
+ OUString aGroup = (( const SfxStringItem *)pItem)->GetValue();
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "Dialogdiet fail!");
+ ::GlossarySetActGroup fnSetActGroup = pFact->SetGlossaryActGroupFunc();
+ if ( fnSetActGroup )
+ (*fnSetActGroup)( aGroup );
+ rReq.Done();
+ }
+ break;
+ case FN_INSERT_GLOSSARY:
+ {
+ if(pItem && pArgs->Count() > 1)
+ {
+ OUString aGroup = (( const SfxStringItem *)pItem)->GetValue();
+ OUString aName;
+ if(SFX_ITEM_SET == pArgs->GetItemState(FN_PARAM_1, false, &pItem ))
+ aName = (( const SfxStringItem *)pItem)->GetValue();
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "Dialogdiet fail!");
+ ::GlossarySetActGroup fnSetActGroup = pFact->SetGlossaryActGroupFunc();
+ if ( fnSetActGroup )
+ (*fnSetActGroup)( aGroup );
+ pGlosHdl->SetCurGroup(aGroup, sal_True);
+ rReq.SetReturnValue(SfxBoolItem(nSlot, pGlosHdl->InsertGlossary( aName ) ? sal_True : sal_False));
+ rReq.Done();
+ }
+ }
+ break;
+ default:
+ OSL_FAIL("wrong dispatcher");
+ return;
+ }
+ if(bUpdateList)
+ {
+ SwGlossaryList* pList = ::GetGlossaryList();
+ if(pList->IsActive())
+ pList->Update();
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/shells/textidx.cxx b/sw/source/core/uibase/shells/textidx.cxx
new file mode 100644
index 000000000000..05d9fc295c67
--- /dev/null
+++ b/sw/source/core/uibase/shells/textidx.cxx
@@ -0,0 +1,251 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <hintids.hxx>
+#include <vcl/msgbox.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <svl/stritem.hxx>
+#include <svl/eitem.hxx>
+#include <editeng/sizeitem.hxx>
+#include <fmtfsize.hxx>
+#include <fldbas.hxx>
+#include <uiitems.hxx>
+#include "viewopt.hxx"
+#include "cmdid.h"
+#include "view.hxx"
+#include "wrtsh.hxx"
+#include "swundo.hxx"
+#include "textsh.hxx"
+#include "idxmrk.hxx"
+#include "cnttab.hxx"
+#include "toxmgr.hxx"
+#include "swabstdlg.hxx"
+#include <index.hrc>
+#include <globals.hrc>
+
+void SwTextShell::ExecIdx(SfxRequest &rReq)
+{
+ const SfxItemSet *pArgs = rReq.GetArgs();
+ const SfxPoolItem* pItem = 0;
+ sal_uInt16 nSlot = rReq.GetSlot();
+ if(pArgs)
+ pArgs->GetItemState(nSlot, false, &pItem );
+
+ SfxViewFrame* pVFrame = GetView().GetViewFrame();
+ Window *pMDI = &pVFrame->GetWindow();
+
+ switch( nSlot )
+ {
+ case FN_EDIT_AUTH_ENTRY_DLG :
+ {
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "Dialogdiet fail!");
+ VclAbstractDialog* pDlg = pFact->CreateVclAbstractDialog( pMDI, GetShell(), DLG_EDIT_AUTHMARK);
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ pDlg->Execute();
+ delete pDlg;
+ }
+ break;
+ case FN_INSERT_AUTH_ENTRY_DLG:
+ {
+ // no BASIC support
+ pVFrame->ToggleChildWindow(FN_INSERT_AUTH_ENTRY_DLG);
+ Invalidate(rReq.GetSlot());
+ }
+ break;
+ case FN_INSERT_IDX_ENTRY_DLG:
+ {
+ pVFrame->ToggleChildWindow(FN_INSERT_IDX_ENTRY_DLG);
+ Invalidate(rReq.GetSlot());
+ }
+ break;
+ case FN_EDIT_IDX_ENTRY_DLG:
+ {
+ SwTOXMgr aMgr(GetShellPtr());
+ sal_uInt16 nRet = RET_OK;
+ if(aMgr.GetTOXMarkCount() > 1)
+ { // Several marks, which should it be?
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "Dialogdiet fail!");
+ VclAbstractDialog* pMultDlg = pFact->CreateMultiTOXMarkDlg(pMDI, aMgr);
+ OSL_ENSURE(pMultDlg, "Dialogdiet fail!");
+ nRet = pMultDlg->Execute();
+ delete pMultDlg;
+ }
+ if( nRet == RET_OK)
+ {
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "Dialogdiet fail!");
+ VclAbstractDialog* pDlg = pFact->CreateIndexMarkModalDlg(pMDI, GetShell(), aMgr.GetCurTOXMark());
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ pDlg->Execute();
+ delete pDlg;
+ }
+ break;
+ }
+ case FN_IDX_MARK_TO_IDX:
+ {
+ GetShell().GotoTOXMarkBase();
+ break;
+ }
+ case FN_INSERT_MULTI_TOX:
+ {
+ SfxItemSet aSet(GetPool(),
+ RES_COL, RES_COL,
+ RES_BACKGROUND, RES_BACKGROUND,
+ RES_FRM_SIZE, RES_FRM_SIZE,
+ SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE,
+ RES_LR_SPACE, RES_LR_SPACE,
+ FN_PARAM_TOX_TYPE, FN_PARAM_TOX_TYPE,
+ 0 );
+ SwWrtShell& rSh = GetShell();
+ SwRect aRect;
+ rSh.CalcBoundRect(aRect, FLY_AS_CHAR);
+
+ long nWidth = aRect.Width();
+ aSet.Put(SwFmtFrmSize(ATT_VAR_SIZE, nWidth));
+ // Height = width for a more consistent preview (analogous to edit range)
+ aSet.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE, Size(nWidth, nWidth)));
+ const SwTOXBase* pCurTOX = 0;
+ sal_Bool bGlobal = sal_False;
+ if(pItem)
+ {
+ pCurTOX = (const SwTOXBase* )((SwPtrItem*)pItem)->GetValue();
+ bGlobal = sal_True;
+ }
+ else
+ pCurTOX = rSh.GetCurTOX();
+ if(pCurTOX)
+ {
+ const SfxItemSet* pSet = pCurTOX->GetAttrSet();
+ if(pSet)
+ aSet.Put(*pSet);
+ }
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "Dialogdiet fail!");
+ AbstractMultiTOXTabDialog* pDlg = pFact->CreateMultiTOXTabDialog(
+ pMDI, aSet, rSh, (SwTOXBase* )pCurTOX,
+ USHRT_MAX, bGlobal);
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ pDlg->Execute();
+ delete pDlg;
+ }
+ break;
+ case FN_REMOVE_CUR_TOX:
+ {
+ SwWrtShell& rSh = GetShell();
+ const SwTOXBase* pBase = rSh.GetCurTOX();
+ OSL_ENSURE(pBase, "no TOXBase to remove");
+ if( pBase )
+ rSh.DeleteTOX(*pBase, true);
+ }
+ break;
+ default:
+ OSL_ENSURE(!this, "wrong dispatcher");
+ return;
+ }
+}
+
+void SwTextShell::GetIdxState(SfxItemSet &rSet)
+{
+ SwWrtShell& rSh = GetShell();
+ SfxViewFrame* pVFrame = GetView().GetViewFrame();
+ SwInsertIdxMarkWrapper *pIdxMrk = (SwInsertIdxMarkWrapper*)
+ pVFrame->GetChildWindow(FN_INSERT_IDX_ENTRY_DLG);
+
+ SfxChildWindow* pAuthMark = pVFrame->GetChildWindow(FN_INSERT_AUTH_ENTRY_DLG);
+
+ const bool bHtmlMode = 0 != ::GetHtmlMode( GetView().GetDocShell() );
+ const SwTOXBase* pBase = 0;
+ if( bHtmlMode || 0 != ( pBase = rSh.GetCurTOX()) )
+ {
+ if( pBase )
+ {
+ if(pBase->IsTOXBaseInReadonly())
+ {
+ rSet.DisableItem( FN_INSERT_MULTI_TOX );
+ }
+ }
+
+ rSet.DisableItem( FN_EDIT_IDX_ENTRY_DLG );
+ rSet.DisableItem( FN_EDIT_AUTH_ENTRY_DLG );
+
+ if(!pIdxMrk)
+ rSet.DisableItem( FN_INSERT_IDX_ENTRY_DLG );
+ else
+ rSet.Put(SfxBoolItem(FN_INSERT_IDX_ENTRY_DLG, true));
+
+ if(!pAuthMark)
+ rSet.DisableItem( FN_INSERT_AUTH_ENTRY_DLG );
+ else
+ rSet.Put(SfxBoolItem(FN_INSERT_AUTH_ENTRY_DLG, true));
+
+ }
+ else if ( rSh.CrsrInsideInputFld() )
+ {
+ rSet.DisableItem( FN_INSERT_IDX_ENTRY_DLG );
+ rSet.DisableItem( FN_INSERT_AUTH_ENTRY_DLG );
+ rSet.DisableItem( FN_EDIT_AUTH_ENTRY_DLG );
+ rSet.DisableItem( FN_EDIT_IDX_ENTRY_DLG );
+ rSet.DisableItem( FN_INSERT_MULTI_TOX );
+ rSet.DisableItem( FN_REMOVE_CUR_TOX );
+ }
+ else
+ {
+
+ bool bEnableEdit = true;
+ sal_Bool bInReadonly = rSh.HasReadonlySel();
+ if( rSh.HasSelection() || bInReadonly)
+ bEnableEdit = false;
+ else
+ {
+ SwTOXMarks aArr;
+ rSh.GetCurTOXMarks( aArr );
+ if( aArr.empty())
+ bEnableEdit = false;
+ }
+
+ if(!bEnableEdit)
+ rSet.DisableItem( FN_EDIT_IDX_ENTRY_DLG );
+
+ if(bInReadonly)
+ {
+ rSet.DisableItem(FN_INSERT_IDX_ENTRY_DLG);
+ rSet.DisableItem( FN_INSERT_MULTI_TOX );
+ }
+ else
+ rSet.Put(SfxBoolItem(FN_INSERT_IDX_ENTRY_DLG,
+ 0 != pIdxMrk));
+
+ SwField* pField = rSh.GetCurFld();
+
+ if(bInReadonly)
+ rSet.DisableItem(FN_INSERT_AUTH_ENTRY_DLG);
+ else
+ rSet.Put(SfxBoolItem(FN_INSERT_AUTH_ENTRY_DLG, 0 != pAuthMark));
+
+ if( bInReadonly || !pField ||
+ pField->GetTyp()->Which() != RES_AUTHORITY)
+ rSet.DisableItem(FN_EDIT_AUTH_ENTRY_DLG);
+ rSet.DisableItem(FN_REMOVE_CUR_TOX);
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/shells/textsh.cxx b/sw/source/core/uibase/shells/textsh.cxx
new file mode 100644
index 000000000000..57314e0e8848
--- /dev/null
+++ b/sw/source/core/uibase/shells/textsh.cxx
@@ -0,0 +1,1131 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <hintids.hxx>
+#include <comphelper/string.hxx>
+#include <svl/globalnameitem.hxx>
+#include <svl/ownlist.hxx>
+#include <sfx2/frmdescr.hxx>
+#include <sfx2/objface.hxx>
+#include <sfx2/lnkbase.hxx>
+
+#include <tools/errinf.hxx>
+#include <svx/svdview.hxx>
+#include <svl/ptitem.hxx>
+#include <svl/stritem.hxx>
+#include <unotools/moduleoptions.hxx>
+#include <vcl/msgbox.hxx>
+#include <sfx2/fcontnr.hxx>
+#include <svx/hlnkitem.hxx>
+#include <svl/srchitem.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/docfile.hxx>
+#include <svl/urihelper.hxx>
+#include <basic/sbxvar.hxx>
+#include <svl/whiter.hxx>
+#include <sfx2/request.hxx>
+#include <editeng/opaqitem.hxx>
+#include <editeng/fontitem.hxx>
+#include <editeng/adjustitem.hxx>
+#include <editeng/boxitem.hxx>
+#include <editeng/sizeitem.hxx>
+#include <editeng/svxacorr.hxx>
+#include <editeng/scripttypeitem.hxx>
+#include <vcl/graphicfilter.hxx>
+#include <sfx2/htmlmode.hxx>
+#include <svx/pfiledlg.hxx>
+#include <svtools/htmlcfg.hxx>
+#include <com/sun/star/i18n/TransliterationModules.hpp>
+#include <com/sun/star/i18n/TransliterationModulesExtra.hpp>
+#include <com/sun/star/embed/Aspects.hpp>
+
+#include <comphelper/classids.hxx>
+#include <editeng/acorrcfg.hxx>
+#include <wdocsh.hxx>
+#include <fmtinfmt.hxx>
+#include <fmtclds.hxx>
+#include <fmtsrnd.hxx>
+#include <fmtfsize.hxx>
+#include <swmodule.hxx>
+#include <wrtsh.hxx>
+#include <view.hxx>
+#include <docsh.hxx>
+#include <doc.hxx>
+#include <uitool.hxx>
+#include <cmdid.h>
+#include <globals.hrc>
+#include <frmmgr.hxx>
+#include <textsh.hxx>
+#include <frmfmt.hxx>
+#include <tablemgr.hxx>
+#include <swundo.hxx>
+#include <shellio.hxx>
+#include <frmdlg.hxx>
+#include <usrpref.hxx>
+#include <swtable.hxx>
+#include <tblafmt.hxx>
+#include <caption.hxx>
+#include <idxmrk.hxx>
+#include <poolfmt.hxx>
+#include <breakit.hxx>
+#include <crsskip.hxx>
+#include <modcfg.hxx>
+#include <column.hxx>
+#include <edtwin.hxx>
+#include <shells.hrc>
+#include <popup.hrc>
+#include <swerror.h>
+#include <unochart.hxx>
+
+#include <chartins.hxx>
+
+#define SwTextShell
+#include <sfx2/msg.hxx>
+#include <sfx2/sidebar/EnumContext.hxx>
+#include <swslots.hxx>
+#include <SwRewriter.hxx>
+#include <comcore.hrc>
+
+using namespace ::com::sun::star;
+
+#include <svx/svxdlg.hxx>
+#include <svx/dialogs.hrc>
+#include "swabstdlg.hxx"
+#include <misc.hrc>
+#include <table.hrc>
+#include <frmui.hrc>
+#include <unomid.h>
+
+SFX_IMPL_INTERFACE(SwTextShell, SwBaseShell, SW_RES(STR_SHELLNAME_TEXT))
+{
+ SFX_POPUPMENU_REGISTRATION(SW_RES(MN_TEXT_POPUPMENU));
+ SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_TEXT_TOOLBOX));
+ SFX_CHILDWINDOW_REGISTRATION(FN_EDIT_FORMULA);
+ SFX_CHILDWINDOW_REGISTRATION(FN_INSERT_FIELD);
+ SFX_CHILDWINDOW_REGISTRATION(FN_INSERT_IDX_ENTRY_DLG);
+ SFX_CHILDWINDOW_REGISTRATION(FN_INSERT_AUTH_ENTRY_DLG);
+ SFX_CHILDWINDOW_REGISTRATION(SID_RUBY_DIALOG);
+ SFX_CHILDWINDOW_REGISTRATION(FN_WORDCOUNT_DIALOG);
+}
+
+TYPEINIT1(SwTextShell,SwBaseShell)
+
+void SwTextShell::ExecInsert(SfxRequest &rReq)
+{
+ SwWrtShell &rSh = GetShell();
+
+ OSL_ENSURE( !rSh.IsObjSelected() && !rSh.IsFrmSelected(),
+ "wrong shell on dispatcher" );
+
+ const SfxItemSet *pArgs = rReq.GetArgs();
+ const SfxPoolItem* pItem = 0;
+ sal_uInt16 nSlot = rReq.GetSlot();
+ if(pArgs)
+ pArgs->GetItemState(nSlot, false, &pItem );
+
+ switch( nSlot )
+ {
+ case FN_INSERT_STRING:
+ if( pItem )
+ rSh.InsertByWord(((const SfxStringItem *)pItem)->GetValue());
+ break;
+
+ case FN_INSERT_SOFT_HYPHEN:
+ if( CHAR_SOFTHYPHEN != rSh.SwCrsrShell::GetChar( sal_True, 0 ) &&
+ CHAR_SOFTHYPHEN != rSh.SwCrsrShell::GetChar( sal_True, -1 ))
+ rSh.Insert( OUString( CHAR_SOFTHYPHEN ) );
+ break;
+
+ case FN_INSERT_HARDHYPHEN:
+ case FN_INSERT_HARD_SPACE:
+ {
+ const sal_Unicode cIns = FN_INSERT_HARD_SPACE == nSlot ? CHAR_HARDBLANK : CHAR_HARDHYPHEN;
+
+ SvxAutoCorrCfg& rACfg = SvxAutoCorrCfg::Get();
+ SvxAutoCorrect* pACorr = rACfg.GetAutoCorrect();
+ if( pACorr && rACfg.IsAutoFmtByInput()
+ && pACorr->IsAutoCorrFlag(
+ CptlSttSntnc | CptlSttWrd | AddNonBrkSpace | ChgOrdinalNumber | ChgToEnEmDash | SetINetAttr | Autocorrect ) )
+ {
+ rSh.AutoCorrect( *pACorr, cIns );
+ }
+ else
+ {
+ rSh.Insert( OUString( cIns ) );
+ }
+ }
+ break;
+
+ case SID_INSERT_RLM :
+ case SID_INSERT_LRM :
+ case SID_INSERT_ZWNBSP :
+ case SID_INSERT_ZWSP:
+ {
+ sal_Unicode cIns = 0;
+ switch(nSlot)
+ {
+ case SID_INSERT_RLM : cIns = CHAR_RLM ; break;
+ case SID_INSERT_LRM : cIns = CHAR_LRM ; break;
+ case SID_INSERT_ZWSP : cIns = CHAR_ZWSP ; break;
+ case SID_INSERT_ZWNBSP: cIns = CHAR_ZWNBSP; break;
+ }
+ rSh.Insert( OUString( cIns ) );
+ }
+ break;
+
+ case FN_INSERT_BREAK:
+ {
+ if( !rSh.CrsrInsideInputFld() )
+ {
+ rSh.SplitNode();
+ }
+ else
+ {
+ rSh.InsertLineBreak();
+ }
+ }
+ rReq.Done();
+ break;
+
+ case FN_INSERT_PAGEBREAK:
+ rSh.InsertPageBreak();
+ rReq.Done();
+ break;
+
+ case FN_INSERT_LINEBREAK:
+ rSh.InsertLineBreak();
+ rReq.Done();
+ break;
+
+ case FN_INSERT_COLUMN_BREAK:
+ rSh.InsertColumnBreak();
+ rReq.Done();
+ break;
+
+ case SID_HYPERLINK_SETLINK:
+ if (pItem)
+ InsertHyperlink(*((const SvxHyperlinkItem *)pItem));
+ rReq.Done();
+ break;
+
+ case SID_INSERT_AVMEDIA:
+ rReq.SetReturnValue(SfxBoolItem(nSlot, InsertMediaDlg( rReq )));
+ break;
+
+ case SID_INSERT_SOUND:
+ case SID_INSERT_VIDEO:
+ {
+ SvxPluginFileDlg aDlg( &GetView().GetViewFrame()->GetWindow(), nSlot );
+ aDlg.SetContext( nSlot == SID_INSERT_SOUND? sfx2::FileDialogHelper::SW_INSERT_SOUND : sfx2::FileDialogHelper::SW_INSERT_VIDEO );
+
+ if ( ERRCODE_NONE == aDlg.Execute() )
+ {
+ // Determine URL
+ OUString aStrURL( aDlg.GetPath() );
+ aStrURL = URIHelper::SmartRel2Abs(
+ INetURLObject(), aStrURL, URIHelper::GetMaybeFileHdl() );
+
+ INetURLObject url;
+ url.SetSmartProtocol( INET_PROT_FILE );
+
+ if ( url.SetURL( aStrURL, INetURLObject::WAS_ENCODED ) )
+ {
+ OUString aName;
+ comphelper::EmbeddedObjectContainer aCnt;
+ svt::EmbeddedObjectRef xObj( aCnt.CreateEmbeddedObject( SvGlobalName( SO3_PLUGIN_CLASSID ).GetByteSequence(), aName ), embed::Aspects::MSOLE_CONTENT );
+ if ( xObj.is() )
+ {
+ svt::EmbeddedObjectRef::TryRunningState( xObj.GetObject() );
+
+ // set properties from dialog
+ uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
+ if ( xSet.is() )
+ {
+ xSet->setPropertyValue("PluginURL",
+ uno::makeAny( OUString( url.GetMainURL( INetURLObject::NO_DECODE ) ) ) );
+ }
+ }
+
+ rSh.InsertObject( xObj, 0, sal_True, nSlot);
+ }
+ }
+ }
+ break;
+
+ case SID_INSERT_OBJECT:
+ case SID_INSERT_PLUGIN:
+ {
+ SFX_REQUEST_ARG( rReq, pNameItem, SfxGlobalNameItem, SID_INSERT_OBJECT, false );
+ SvGlobalName *pName = NULL;
+ SvGlobalName aName;
+ if ( pNameItem )
+ {
+ aName = pNameItem->GetValue();
+ pName = &aName;
+ }
+
+ SFX_REQUEST_ARG( rReq, pClassLocationItem, SfxStringItem, FN_PARAM_2, false );
+ SFX_REQUEST_ARG( rReq, pCommandsItem, SfxStringItem, FN_PARAM_3, false );
+ //TODO/LATER: recording currently not working, need code for Commandlist
+ svt::EmbeddedObjectRef xObj;
+ if( nSlot == SID_INSERT_PLUGIN && ( pClassLocationItem || pCommandsItem ) )
+ {
+ OUString sClassLocation;
+ if(pClassLocationItem)
+ sClassLocation = pClassLocationItem->GetValue();
+
+ SvCommandList aCommandList;
+ if(pCommandsItem)
+ {
+ sal_Int32 nTemp;
+ aCommandList.AppendCommands( pCommandsItem->GetValue(), &nTemp );
+ }
+
+ {
+ comphelper::EmbeddedObjectContainer aCnt;
+ OUString sName;
+ xObj.Assign( aCnt.CreateEmbeddedObject( SvGlobalName( SO3_PLUGIN_CLASSID ).GetByteSequence(), sName ),
+ embed::Aspects::MSOLE_CONTENT );
+ svt::EmbeddedObjectRef::TryRunningState( xObj.GetObject() );
+ uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
+ if ( xSet.is() )
+ {
+ try
+ {
+ if ( !sClassLocation.isEmpty() )
+ xSet->setPropertyValue("PluginURL",
+ uno::makeAny(
+ OUString(
+ URIHelper::SmartRel2Abs(
+ INetURLObject(), sClassLocation,
+ URIHelper::GetMaybeFileHdl()) ) ) );
+ uno::Sequence< beans::PropertyValue > aSeq;
+ if ( aCommandList.size() )
+ {
+ aCommandList.FillSequence( aSeq );
+ xSet->setPropertyValue("PluginCommands", uno::makeAny( aSeq ) );
+ }
+ }
+ catch (const uno::Exception&)
+ {
+ }
+ }
+ }
+
+ if(xObj.is())
+ rSh.InsertOleObject( xObj );
+ }
+ else
+ {
+ OSL_ENSURE( !pNameItem || nSlot == SID_INSERT_OBJECT, "Superfluous argument!" );
+ rSh.InsertObject( xObj, pName, sal_True, nSlot);
+ rReq.Done();
+ }
+ break;
+ }
+ case SID_INSERT_FLOATINGFRAME:
+ {
+ svt::EmbeddedObjectRef xObj;
+ SFX_REQUEST_ARG( rReq, pNameItem, SfxStringItem, FN_PARAM_1, false );
+ SFX_REQUEST_ARG( rReq, pURLItem, SfxStringItem, FN_PARAM_2, false );
+ SFX_REQUEST_ARG( rReq, pMarginItem, SvxSizeItem, FN_PARAM_3, false );
+ SFX_REQUEST_ARG( rReq, pScrollingItem, SfxByteItem, FN_PARAM_4, false );
+ SFX_REQUEST_ARG( rReq, pBorderItem, SfxBoolItem, FN_PARAM_5, false );
+
+ if(pURLItem) // URL is a _must_
+ {
+ comphelper::EmbeddedObjectContainer aCnt;
+ OUString aName;
+ xObj.Assign( aCnt.CreateEmbeddedObject( SvGlobalName( SO3_IFRAME_CLASSID ).GetByteSequence(), aName ),
+ embed::Aspects::MSOLE_CONTENT );
+ svt::EmbeddedObjectRef::TryRunningState( xObj.GetObject() );
+ uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
+ if ( xSet.is() )
+ {
+ try
+ {
+ ScrollingMode eScroll = ScrollingAuto;
+ if( pScrollingItem && pScrollingItem->GetValue() <= ScrollingAuto )
+ eScroll = (ScrollingMode) pScrollingItem->GetValue();
+
+ Size aMargin;
+ if ( pMarginItem )
+ aMargin = pMarginItem->GetSize();
+
+ if ( pURLItem )
+ xSet->setPropertyValue("FrameURL", uno::makeAny( OUString( pURLItem->GetValue() ) ) );
+ if ( pNameItem )
+ xSet->setPropertyValue("FrameName", uno::makeAny( OUString( pNameItem->GetValue() ) ) );
+
+ if ( eScroll == ScrollingAuto )
+ xSet->setPropertyValue("FrameIsAutoScroll",
+ uno::makeAny( sal_True ) );
+ else
+ xSet->setPropertyValue("FrameIsScrollingMode",
+ uno::makeAny( (sal_Bool) ( eScroll == ScrollingYes) ) );
+
+ if ( pBorderItem )
+ xSet->setPropertyValue("FrameIsBorder",
+ uno::makeAny( (sal_Bool) pBorderItem->GetValue() ) );
+
+ if ( pMarginItem )
+ {
+ xSet->setPropertyValue("FrameMarginWidth",
+ uno::makeAny( sal_Int32( aMargin.Width() ) ) );
+
+ xSet->setPropertyValue("FrameMarginHeight",
+ uno::makeAny( sal_Int32( aMargin.Height() ) ) );
+ }
+ }
+ catch (const uno::Exception&)
+ {
+ }
+ }
+
+ rSh.InsertOleObject( xObj );
+ }
+ else
+ {
+ rSh.InsertObject( xObj, 0, sal_True, nSlot);
+ rReq.Done();
+ }
+ }
+ break;
+ case SID_INSERT_DIAGRAM:
+ {
+ SvtModuleOptions aMOpt;
+ if ( !aMOpt.IsChart() )
+ break;
+ if(!rReq.IsAPI())
+ {
+ SfxViewFrame* pVFrame = GetView().GetViewFrame();
+ SwInsertChart( &GetView().GetEditWin(), &pVFrame->GetBindings() );
+ }
+ else
+ {
+ uno::Reference< chart2::data::XDataProvider > xDataProvider;
+ sal_Bool bFillWithData = sal_True;
+ OUString aRangeString;
+ if (!GetShell().IsTblComplexForChart())
+ {
+ SwFrmFmt* pTblFmt = GetShell().GetTableFmt();
+ aRangeString = pTblFmt->GetName();
+ aRangeString += OUString( '.' );
+ aRangeString += GetShell().GetBoxNms();
+
+ // get table data provider
+ xDataProvider.set( GetView().GetDocShell()->getIDocumentChartDataProviderAccess()->GetChartDataProvider() );
+ }
+ else
+ bFillWithData = sal_False; // will create chart with only it's default image
+
+ SwTableFUNC( &rSh, sal_False ).InsertChart( xDataProvider, bFillWithData, aRangeString );
+ rSh.LaunchOLEObj();
+
+ svt::EmbeddedObjectRef& xObj = rSh.GetOLEObject();
+ if(pItem && xObj.is())
+ {
+ Size aSize(((SvxSizeItem*)pItem)->GetSize());
+ aSize = OutputDevice::LogicToLogic
+ ( aSize, MapMode( MAP_TWIP ), MapMode( MAP_100TH_MM ) );
+
+ if(aSize.Width() > MINLAY&& aSize.Height()> MINLAY)
+ {
+ awt::Size aSz;
+ aSz.Width = aSize.Width();
+ aSz.Height = aSize.Height();
+ xObj->setVisualAreaSize( xObj.GetViewAspect(), aSz );
+ }
+ }
+ }
+ }
+ break;
+
+ case FN_INSERT_SMA:
+ {
+ // #i34343# Inserting a math object into an autocompletion crashes
+ // the suggestion has to be removed before
+ GetView().GetEditWin().StopQuickHelp();
+ SvGlobalName aGlobalName( SO3_SM_CLASSID );
+ rSh.InsertObject( svt::EmbeddedObjectRef(), &aGlobalName, sal_True, 0 );
+ }
+ break;
+
+ case FN_INSERT_TABLE:
+ InsertTable( rReq );
+ break;
+
+ case FN_INSERT_FRAME_INTERACT_NOCOL:
+ case FN_INSERT_FRAME_INTERACT:
+ {
+ sal_uInt16 nCols = 1;
+ bool bModifier1 = rReq.GetModifier() == KEY_MOD1;
+ if(pArgs)
+ {
+ if(FN_INSERT_FRAME_INTERACT_NOCOL != nSlot &&
+ pArgs->GetItemState(SID_ATTR_COLUMNS, false, &pItem) == SFX_ITEM_SET)
+ nCols = ((SfxUInt16Item *)pItem)->GetValue();
+ if(pArgs->GetItemState(SID_MODIFIER, false, &pItem) == SFX_ITEM_SET)
+ bModifier1 |= KEY_MOD1 == ((SfxUInt16Item *)pItem)->GetValue();
+ }
+ if(bModifier1 )
+ {
+ SwEditWin& rEdtWin = GetView().GetEditWin();
+ Size aWinSize = rEdtWin.GetSizePixel();
+ Point aStartPos(aWinSize.Width()/2, aWinSize.Height() / 2);
+ aStartPos = rEdtWin.PixelToLogic(aStartPos);
+ aStartPos.X() -= 8 * MM50;
+ aStartPos.Y() -= 4 * MM50;
+ Size aSize(16 * MM50, 8 * MM50);
+ GetShell().LockPaint();
+ GetShell().StartAllAction();
+ SwFlyFrmAttrMgr aMgr( sal_True, GetShellPtr(), FRMMGR_TYPE_TEXT );
+ if(nCols > 1)
+ {
+ SwFmtCol aCol;
+ aCol.Init( nCols, aCol.GetGutterWidth(), aCol.GetWishWidth() );
+ aMgr.SetCol( aCol );
+ }
+ aMgr.InsertFlyFrm(FLY_AT_PARA, aStartPos, aSize);
+ GetShell().EndAllAction();
+ GetShell().UnlockPaint();
+ }
+ else
+ {
+ GetView().InsFrmMode(nCols);
+ }
+ rReq.Ignore();
+ }
+ break;
+ case FN_INSERT_FRAME:
+ {
+ bool bSingleCol = false;
+ if( 0!= dynamic_cast< SwWebDocShell*>( GetView().GetDocShell()) )
+ {
+ SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get();
+ sal_uInt16 nExport = rHtmlOpt.GetExportMode();
+ if( HTML_CFG_MSIE == nExport )
+ {
+ bSingleCol = true;
+ }
+
+ }
+ // Create new border
+ SwFlyFrmAttrMgr aMgr( sal_True, GetShellPtr(), FRMMGR_TYPE_TEXT );
+ if(pArgs)
+ {
+ Size aSize(aMgr.GetSize());
+ aSize.Width() = GetShell().GetAnyCurRect(RECT_PAGE_PRT).Width();
+ Point aPos = aMgr.GetPos();
+ RndStdIds eAnchor = FLY_AT_PARA;
+ if(pArgs->GetItemState(nSlot, false, &pItem) == SFX_ITEM_SET)
+ eAnchor = (RndStdIds)((SfxUInt16Item *)pItem)->GetValue();
+ if(pArgs->GetItemState(FN_PARAM_1, false, &pItem) == SFX_ITEM_SET)
+ aPos = ((SfxPointItem *)pItem)->GetValue();
+ if(pArgs->GetItemState(FN_PARAM_2, false, &pItem) == SFX_ITEM_SET)
+ aSize = ((SvxSizeItem *)pItem)->GetSize();
+ if(pArgs->GetItemState(SID_ATTR_COLUMNS, false, &pItem) == SFX_ITEM_SET)
+ {
+ sal_uInt16 nCols = ((SfxUInt16Item *)pItem)->GetValue();
+ if( !bSingleCol && 1 < nCols )
+ {
+ SwFmtCol aFmtCol;
+ aFmtCol.Init( nCols , (rReq.IsAPI() ? 0
+ : DEF_GUTTER_WIDTH), USHRT_MAX );
+ aMgr.SetCol(aFmtCol);
+ }
+ }
+
+ GetShell().LockPaint();
+ GetShell().StartAllAction();
+
+ aMgr.InsertFlyFrm(eAnchor, aPos, aSize);
+
+ GetShell().EndAllAction();
+ GetShell().UnlockPaint();
+ }
+ else
+ {
+ static const sal_uInt16 aFrmAttrRange[] =
+ {
+ RES_FRMATR_BEGIN, RES_FRMATR_END-1,
+ SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
+ FN_GET_PRINT_AREA, FN_GET_PRINT_AREA,
+ SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE,
+ FN_SET_FRM_NAME, FN_SET_FRM_NAME,
+ SID_HTML_MODE, SID_HTML_MODE,
+ 0
+ };
+
+ SfxItemSet aSet(GetPool(), aFrmAttrRange );
+ aSet.Put(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(GetView().GetDocShell())));
+ const SwRect &rPg = GetShell().GetAnyCurRect(RECT_PAGE);
+ SwFmtFrmSize aFrmSize(ATT_VAR_SIZE, rPg.Width(), rPg.Height());
+ aFrmSize.SetWhich(GetPool().GetWhich(SID_ATTR_PAGE_SIZE));
+ aSet.Put(aFrmSize);
+
+ const SwRect &rPr = GetShell().GetAnyCurRect(RECT_PAGE_PRT);
+ SwFmtFrmSize aPrtSize(ATT_VAR_SIZE, rPr.Width(), rPr.Height());
+ aPrtSize.SetWhich(GetPool().GetWhich(FN_GET_PRINT_AREA));
+ aSet.Put(aPrtSize);
+
+ aSet.Put(aMgr.GetAttrSet());
+ aSet.SetParent( aMgr.GetAttrSet().GetParent() );
+
+ // Delete minimum size in columns.
+ SvxBoxInfoItem aBoxInfo((SvxBoxInfoItem &)aSet.Get(SID_ATTR_BORDER_INNER));
+ const SvxBoxItem& rBox = (const SvxBoxItem&)aSet.Get(RES_BOX);
+ aBoxInfo.SetMinDist(false);
+ aBoxInfo.SetDefDist(rBox.GetDistance(BOX_LINE_LEFT));
+ aSet.Put(aBoxInfo);
+
+ FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebDocShell, GetView().GetDocShell()));
+ SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)));
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "Dialogdiet fail!");
+ SfxAbstractTabDialog* pDlg = pFact->CreateFrmTabDialog("FrameDialog",
+ GetView().GetViewFrame(),
+ &GetView().GetViewFrame()->GetWindow(),
+ aSet, true);
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ if(pDlg->Execute() == RET_OK && pDlg->GetOutputItemSet())
+ {
+ //local variable necessary at least after call of .AutoCaption() because this could be deleted at this point
+ SwWrtShell& rShell = GetShell();
+ rShell.LockPaint();
+ rShell.StartAllAction();
+ rShell.StartUndo(UNDO_INSERT);
+
+ const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
+ aMgr.SetAttrSet(*pOutSet);
+
+ // At first delete the selection at the ClickToEditField.
+ if( rShell.IsInClickToEdit() )
+ rShell.DelRight();
+
+ aMgr.InsertFlyFrm();
+
+ uno::Reference< frame::XDispatchRecorder > xRecorder =
+ GetView().GetViewFrame()->GetBindings().GetRecorder();
+ if ( xRecorder.is() )
+ {
+ //FN_INSERT_FRAME
+ sal_uInt16 nAnchor = (sal_uInt16)aMgr.GetAnchor();
+ rReq.AppendItem(SfxUInt16Item(nSlot, nAnchor));
+ rReq.AppendItem(SfxPointItem(FN_PARAM_1, rShell.GetObjAbsPos()));
+ rReq.AppendItem(SvxSizeItem(FN_PARAM_2, rShell.GetObjSize()));
+ rReq.Done();
+ }
+
+ GetView().AutoCaption(FRAME_CAP);
+
+ {
+ SwRewriter aRewriter;
+
+ aRewriter.AddRule(UndoArg1, SW_RESSTR(STR_FRAME));
+
+ rShell.EndUndo(UNDO_INSERT, &aRewriter);
+ }
+ rShell.EndAllAction();
+ rShell.UnlockPaint();
+ }
+
+ DELETEZ(pDlg);
+ }
+ break;
+ }
+ case FN_FORMAT_COLUMN :
+ {
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "Dialogdiet fail!");
+ VclAbstractDialog* pColDlg = pFact->CreateVclAbstractDialog( GetView().GetWindow(), rSh, DLG_COLUMN);
+ OSL_ENSURE(pColDlg, "Dialogdiet fail!");
+ pColDlg->Execute();
+ delete pColDlg;
+ }
+ break;
+
+ default:
+ OSL_ENSURE(!this, "wrong dispatcher");
+ return;
+ }
+}
+
+static bool lcl_IsMarkInSameSection( SwWrtShell& rWrtSh, const SwSection* pSect )
+{
+ rWrtSh.SwapPam();
+ bool bRet = pSect == rWrtSh.GetCurrSection();
+ rWrtSh.SwapPam();
+ return bRet;
+}
+
+void SwTextShell::StateInsert( SfxItemSet &rSet )
+{
+ sal_uInt16 nHtmlMode = ::GetHtmlMode(GetView().GetDocShell());
+ SfxWhichIter aIter( rSet );
+ SwWrtShell &rSh = GetShell();
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ SvtModuleOptions aMOpt;
+ SfxObjectCreateMode eCreateMode =
+ GetView().GetDocShell()->GetCreateMode();
+
+ rSh.Push();
+ const sal_Bool bCrsrInHidden = rSh.SelectHiddenRange();
+ rSh.Pop();
+
+ while ( nWhich )
+ {
+ switch ( nWhich )
+ {
+ case SID_INSERT_AVMEDIA:
+ case SID_INSERT_SOUND:
+ case SID_INSERT_VIDEO:
+ if ( GetShell().IsSelFrmMode()
+ || GetShell().CrsrInsideInputFld()
+ || SFX_CREATE_MODE_EMBEDDED == eCreateMode
+ || bCrsrInHidden )
+ {
+ rSet.DisableItem( nWhich );
+ }
+ break;
+
+ case SID_INSERT_DIAGRAM:
+ if( !aMOpt.IsChart()
+ || GetShell().CrsrInsideInputFld()
+ || eCreateMode == SFX_CREATE_MODE_EMBEDDED
+ || bCrsrInHidden )
+ {
+ rSet.DisableItem( nWhich );
+ }
+ break;
+
+ case FN_INSERT_SMA:
+ if( !aMOpt.IsMath()
+ || eCreateMode == SFX_CREATE_MODE_EMBEDDED
+ || bCrsrInHidden
+ || rSh.CrsrInsideInputFld() )
+ {
+ rSet.DisableItem( nWhich );
+ }
+ break;
+
+ case SID_INSERT_FLOATINGFRAME:
+ case SID_INSERT_OBJECT:
+ case SID_INSERT_PLUGIN:
+ {
+ if( eCreateMode == SFX_CREATE_MODE_EMBEDDED || bCrsrInHidden )
+ {
+ rSet.DisableItem( nWhich );
+ }
+ else if( GetShell().IsSelFrmMode()
+ || GetShell().CrsrInsideInputFld() )
+ {
+ rSet.DisableItem( nWhich );
+ }
+ else if(SID_INSERT_FLOATINGFRAME == nWhich && nHtmlMode&HTMLMODE_ON)
+ {
+ SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get();
+ sal_uInt16 nExport = rHtmlOpt.GetExportMode();
+ if(HTML_CFG_MSIE != nExport && HTML_CFG_WRITER != nExport )
+ rSet.DisableItem(nWhich);
+ }
+ }
+ break;
+
+ case FN_INSERT_FRAME_INTERACT_NOCOL :
+ case FN_INSERT_FRAME_INTERACT:
+ {
+ if( GetShell().IsSelFrmMode()
+ || GetShell().CrsrInsideInputFld()
+ || bCrsrInHidden )
+ rSet.DisableItem(nWhich);
+ }
+ break;
+
+ case SID_HYPERLINK_GETLINK:
+ {
+ SfxItemSet aSet(GetPool(), RES_TXTATR_INETFMT, RES_TXTATR_INETFMT);
+ rSh.GetCurAttr( aSet );
+
+ SvxHyperlinkItem aHLinkItem;
+ const SfxPoolItem* pItem;
+ if(SFX_ITEM_SET == aSet.GetItemState(RES_TXTATR_INETFMT, false, &pItem))
+ {
+ const SwFmtINetFmt* pINetFmt = (const SwFmtINetFmt*)pItem;
+ aHLinkItem.SetURL(pINetFmt->GetValue());
+ aHLinkItem.SetTargetFrame(pINetFmt->GetTargetFrame());
+ aHLinkItem.SetIntName(pINetFmt->GetName());
+ const SvxMacro *pMacro = pINetFmt->GetMacro( SFX_EVENT_MOUSEOVER_OBJECT );
+ if( pMacro )
+ aHLinkItem.SetMacro(HYPERDLG_EVENT_MOUSEOVER_OBJECT, *pMacro);
+
+ pMacro = pINetFmt->GetMacro( SFX_EVENT_MOUSECLICK_OBJECT );
+ if( pMacro )
+ aHLinkItem.SetMacro(HYPERDLG_EVENT_MOUSECLICK_OBJECT, *pMacro);
+
+ pMacro = pINetFmt->GetMacro( SFX_EVENT_MOUSEOUT_OBJECT );
+ if( pMacro )
+ aHLinkItem.SetMacro(HYPERDLG_EVENT_MOUSEOUT_OBJECT, *pMacro);
+
+ // Get the text of the Link.
+ rSh.StartAction();
+ rSh.CreateCrsr();
+ rSh.SwCrsrShell::SelectTxtAttr(RES_TXTATR_INETFMT,sal_True);
+ OUString sLinkName = rSh.GetSelTxt();
+ aHLinkItem.SetName(sLinkName);
+ aHLinkItem.SetInsertMode(HLINK_FIELD);
+ rSh.DestroyCrsr();
+ rSh.EndAction();
+ }
+ else
+ {
+ OUString sReturn = rSh.GetSelTxt();
+ sReturn = sReturn.copy(0, std::min<sal_Int32>(255, sReturn.getLength()));
+ aHLinkItem.SetName(comphelper::string::stripEnd(sReturn, ' '));
+ }
+
+ aHLinkItem.SetInsertMode((SvxLinkInsertMode)(aHLinkItem.GetInsertMode() |
+ ((nHtmlMode & HTMLMODE_ON) != 0 ? HLINK_HTMLMODE : 0)));
+ aHLinkItem.SetMacroEvents ( HYPERDLG_EVENT_MOUSEOVER_OBJECT|
+ HYPERDLG_EVENT_MOUSECLICK_OBJECT | HYPERDLG_EVENT_MOUSEOUT_OBJECT );
+
+ rSet.Put(aHLinkItem);
+ }
+ break;
+
+ case FN_INSERT_FRAME:
+ if (rSh.IsSelFrmMode() )
+ {
+ const int nSel = rSh.GetSelectionType();
+ if( ((nsSelectionType::SEL_GRF | nsSelectionType::SEL_OLE ) & nSel ) || bCrsrInHidden )
+ rSet.DisableItem(nWhich);
+ }
+ else if ( rSh.CrsrInsideInputFld() )
+ {
+ rSet.DisableItem(nWhich);
+ }
+ break;
+
+ case FN_FORMAT_COLUMN :
+ {
+ //#i80458# column dialog cannot work if the selection contains different page styles and different sections
+ bool bDisable = true;
+ if( rSh.GetFlyFrmFmt() || rSh.GetSelectedPageDescs() )
+ bDisable = false;
+ if( bDisable )
+ {
+ const SwSection* pCurrSection = rSh.GetCurrSection();
+ sal_uInt16 nFullSectCnt = rSh.GetFullSelectedSectionCount();
+ if( pCurrSection && ( !rSh.HasSelection() || 0 != nFullSectCnt ))
+ bDisable = false;
+ else if(
+ rSh.HasSelection() && rSh.IsInsRegionAvailable() &&
+ ( !pCurrSection || ( 1 != nFullSectCnt &&
+ lcl_IsMarkInSameSection( rSh, pCurrSection ) )))
+ bDisable = false;
+ }
+ if(bDisable)
+ rSet.DisableItem(nWhich);
+ }
+ break;
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+void SwTextShell::ExecDelete(SfxRequest &rReq)
+{
+ SwWrtShell &rSh = GetShell();
+ switch( rReq.GetSlot() )
+ {
+ case FN_DELETE_SENT:
+ if( rSh.IsTableMode() )
+ {
+ rSh.DeleteRow();
+ rSh.EnterStdMode();
+ }
+ else
+ rSh.DelToEndOfSentence();
+ break;
+ case FN_DELETE_BACK_SENT:
+ rSh.DelToStartOfSentence();
+ break;
+ case FN_DELETE_WORD:
+ rSh.DelNxtWord();
+ break;
+ case FN_DELETE_BACK_WORD:
+ rSh.DelPrvWord();
+ break;
+ case FN_DELETE_LINE:
+ rSh.DelToEndOfLine();
+ break;
+ case FN_DELETE_BACK_LINE:
+ rSh.DelToStartOfLine();
+ break;
+ case FN_DELETE_PARA:
+ rSh.DelToEndOfPara();
+ break;
+ case FN_DELETE_BACK_PARA:
+ rSh.DelToStartOfPara();
+ break;
+ case FN_DELETE_WHOLE_LINE:
+ rSh.DelLine();
+ break;
+ default:
+ OSL_ENSURE(!this, "wrong dispatcher");
+ return;
+ }
+ rReq.Done();
+}
+
+void SwTextShell::ExecTransliteration( SfxRequest & rReq )
+{
+ using namespace ::com::sun::star::i18n;
+ sal_uInt32 nMode = 0;
+
+ switch( rReq.GetSlot() )
+ {
+ case SID_TRANSLITERATE_SENTENCE_CASE:
+ nMode = TransliterationModulesExtra::SENTENCE_CASE;
+ break;
+ case SID_TRANSLITERATE_TITLE_CASE:
+ nMode = TransliterationModulesExtra::TITLE_CASE;
+ break;
+ case SID_TRANSLITERATE_TOGGLE_CASE:
+ nMode = TransliterationModulesExtra::TOGGLE_CASE;
+ break;
+ case SID_TRANSLITERATE_UPPER:
+ nMode = TransliterationModules_LOWERCASE_UPPERCASE;
+ break;
+ case SID_TRANSLITERATE_LOWER:
+ nMode = TransliterationModules_UPPERCASE_LOWERCASE;
+ break;
+
+ case SID_TRANSLITERATE_HALFWIDTH:
+ nMode = TransliterationModules_FULLWIDTH_HALFWIDTH;
+ break;
+ case SID_TRANSLITERATE_FULLWIDTH:
+ nMode = TransliterationModules_HALFWIDTH_FULLWIDTH;
+ break;
+
+ case SID_TRANSLITERATE_HIRAGANA:
+ nMode = TransliterationModules_KATAKANA_HIRAGANA;
+ break;
+ case SID_TRANSLITERATE_KATAGANA:
+ nMode = TransliterationModules_HIRAGANA_KATAKANA;
+ break;
+
+ default:
+ OSL_ENSURE(!this, "wrong dispatcher");
+ }
+
+ if( nMode )
+ GetShell().TransliterateText( nMode );
+}
+
+void SwTextShell::ExecRotateTransliteration( SfxRequest & rReq )
+{
+ if( rReq.GetSlot() == SID_TRANSLITERATE_ROTATE_CASE )
+ GetShell().TransliterateText( m_aRotateCase.getNextMode() );
+}
+
+SwTextShell::SwTextShell(SwView &_rView) :
+ SwBaseShell(_rView), pPostItFldMgr( 0 )
+{
+ SetName(OUString("Text"));
+ SetHelpId(SW_TEXTSHELL);
+ SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_Text));
+}
+
+SwTextShell::~SwTextShell()
+{
+}
+
+void SwTextShell::InsertSymbol( SfxRequest& rReq )
+{
+ const SfxItemSet *pArgs = rReq.GetArgs();
+ const SfxPoolItem* pItem = 0;
+ if( pArgs )
+ pArgs->GetItemState(GetPool().GetWhich(SID_CHARMAP), false, &pItem);
+
+ OUString aChars, aFontName;
+ if ( pItem )
+ {
+ aChars = ((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 )
+ aFontName = pFontItem->GetValue();
+ }
+
+ SwWrtShell &rSh = GetShell();
+ SfxItemSet aSet( GetPool(), RES_CHRATR_FONT, RES_CHRATR_FONT,
+ RES_CHRATR_CJK_FONT, RES_CHRATR_CJK_FONT,
+ RES_CHRATR_CTL_FONT, RES_CHRATR_CTL_FONT,
+ 0 );
+ rSh.GetCurAttr( aSet );
+ sal_uInt16 nScript = rSh.GetScriptType();
+
+ SvxFontItem aFont( RES_CHRATR_FONT );
+ {
+ SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONT, *aSet.GetPool() );
+ aSetItem.GetItemSet().Put( aSet, false );
+ const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScript );
+ if( pI )
+ aFont = *(SvxFontItem*)pI;
+ else
+ aFont = (SvxFontItem&)aSet.Get( GetWhichOfScript(
+ RES_CHRATR_FONT,
+ GetI18NScriptTypeOfLanguage( (sal_uInt16)GetAppLanguage() ) ));
+ if (aFontName.isEmpty())
+ aFontName = aFont.GetFamilyName();
+ }
+
+ Font aNewFont(aFontName, Size(1,1)); // Size only because CTOR.
+ if( aChars.isEmpty() )
+ {
+ // Set selected font as default.
+ SfxAllItemSet aAllSet( rSh.GetAttrPool() );
+ aAllSet.Put( SfxBoolItem( FN_PARAM_1, false ) );
+
+ SwViewOption aOpt(*GetShell().GetViewOptions());
+ OUString sSymbolFont = aOpt.GetSymbolFont();
+ if( aFontName.isEmpty() && !sSymbolFont.isEmpty() )
+ aAllSet.Put( SfxStringItem( SID_FONT_NAME, sSymbolFont ) );
+ else
+ aAllSet.Put( SfxStringItem( SID_FONT_NAME, aFont.GetFamilyName() ) );
+
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( GetView().GetWindow(), aAllSet,
+ GetView().GetViewFrame()->GetFrame().GetFrameInterface(), RID_SVXDLG_CHARMAP );
+ if( RET_OK == pDlg->Execute() )
+ {
+ SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pCItem, SfxStringItem, SID_CHARMAP, false );
+ SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pFontItem, SvxFontItem, SID_ATTR_CHAR_FONT, false );
+ if ( pFontItem )
+ {
+ aNewFont.SetName( pFontItem->GetFamilyName() );
+ aNewFont.SetStyleName( pFontItem->GetStyleName() );
+ aNewFont.SetCharSet( pFontItem->GetCharSet() );
+ aNewFont.SetPitch( pFontItem->GetPitch() );
+ }
+
+ if ( pCItem )
+ {
+ aChars = pCItem->GetValue();
+ aOpt.SetSymbolFont(aNewFont.GetName());
+ SW_MOD()->ApplyUsrPref(aOpt, &GetView());
+ }
+ }
+
+ delete pDlg;
+ }
+
+ if( !aChars.isEmpty() )
+ {
+ rSh.StartAllAction();
+
+ // Delete selected content.
+ SwRewriter aRewriter;
+ aRewriter.AddRule(UndoArg1, SW_RESSTR(STR_SPECIALCHAR));
+
+ rSh.StartUndo( UNDO_INSERT, &aRewriter );
+ if ( rSh.HasSelection() )
+ {
+ rSh.DelRight();
+ aSet.ClearItem();
+ rSh.GetCurAttr( aSet );
+
+ SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONT, *aSet.GetPool() );
+ aSetItem.GetItemSet().Put( aSet, false );
+ const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScript );
+ if( pI )
+ aFont = *(SvxFontItem*)pI;
+ else
+ aFont = (SvxFontItem&)aSet.Get( GetWhichOfScript(
+ RES_CHRATR_FONT,
+ GetI18NScriptTypeOfLanguage( (sal_uInt16)GetAppLanguage() ) ));
+ }
+
+ // Insert character.
+ rSh.Insert( aChars );
+
+ // #108876# a font attribute has to be set always due to a guessed script type
+ if( !aNewFont.GetName().isEmpty() )
+ {
+ SvxFontItem aNewFontItem( aFont );
+ aNewFontItem.SetFamilyName( aNewFont.GetName());
+ aNewFontItem.SetFamily( aNewFont.GetFamily());
+ aNewFontItem.SetPitch( aNewFont.GetPitch());
+ aNewFontItem.SetCharSet( aNewFont.GetCharSet() );
+
+ SfxItemSet aRestoreSet( GetPool(), RES_CHRATR_FONT, RES_CHRATR_FONT,
+ RES_CHRATR_CJK_FONT, RES_CHRATR_CJK_FONT,
+ RES_CHRATR_CTL_FONT, RES_CHRATR_CTL_FONT, 0 );
+
+ nScript = g_pBreakIt->GetAllScriptsOfText( aChars );
+ if( SCRIPTTYPE_LATIN & nScript )
+ {
+ aRestoreSet.Put( aSet.Get( RES_CHRATR_FONT, sal_True ) );
+ aSet.Put( aNewFontItem, RES_CHRATR_FONT);
+ }
+ if( SCRIPTTYPE_ASIAN & nScript )
+ {
+ aRestoreSet.Put( aSet.Get( RES_CHRATR_CJK_FONT, sal_True ) );
+ aSet.Put( aNewFontItem, RES_CHRATR_CJK_FONT );
+ }
+ if( SCRIPTTYPE_COMPLEX & nScript )
+ {
+ aRestoreSet.Put( aSet.Get( RES_CHRATR_CTL_FONT, sal_True ) );
+ aSet.Put( aNewFontItem, RES_CHRATR_CTL_FONT );
+ }
+
+ rSh.SetMark();
+ rSh.ExtendSelection( sal_False, aChars.getLength() );
+ rSh.SetAttrSet( aSet, nsSetAttrMode::SETATTR_DONTEXPAND | nsSetAttrMode::SETATTR_NOFORMATATTR );
+ if( !rSh.IsCrsrPtAtEnd() )
+ rSh.SwapPam();
+
+ rSh.ClearMark();
+
+ // #i75891#
+ // SETATTR_DONTEXPAND does not work if there are already hard attributes.
+ // Therefore we have to restore the font attributes.
+ rSh.SetMark();
+ rSh.SetAttrSet( aRestoreSet );
+ rSh.ClearMark();
+
+ rSh.UpdateAttr();
+ aFont = aNewFontItem;
+ }
+
+ rSh.EndAllAction();
+ rSh.EndUndo();
+
+ if ( !aChars.isEmpty() )
+ {
+ rReq.AppendItem( SfxStringItem( GetPool().GetWhich(SID_CHARMAP), aChars ) );
+ rReq.AppendItem( SfxStringItem( SID_ATTR_SPECIALCHAR, aNewFont.GetName() ) );
+ rReq.Done();
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/shells/textsh1.cxx b/sw/source/core/uibase/shells/textsh1.cxx
new file mode 100644
index 000000000000..b346e8856bba
--- /dev/null
+++ b/sw/source/core/uibase/shells/textsh1.cxx
@@ -0,0 +1,1811 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <com/sun/star/i18n/WordType.hpp>
+#include <com/sun/star/ui/dialogs/XSLTFilterDialog.hpp>
+
+#include <comphelper/processfactory.hxx>
+#include <hintids.hxx>
+#include <cmdid.h>
+#include <helpid.h>
+
+#include <i18nlangtag/languagetag.hxx>
+#include <svl/languageoptions.hxx>
+#include <editeng/langitem.hxx>
+#include <svtools/langtab.hxx>
+#include <svl/slstitm.hxx>
+#include <string.h>
+#include <svl/stritem.hxx>
+#include <sfx2/htmlmode.hxx>
+#include <svl/whiter.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/objitem.hxx>
+#include <vcl/unohelp2.hxx>
+#include <sfx2/request.hxx>
+#include <svl/eitem.hxx>
+#include <svl/macitem.hxx>
+#include <editeng/lrspitem.hxx>
+#include <editeng/colritem.hxx>
+#include <editeng/tstpitem.hxx>
+#include <editeng/brushitem.hxx>
+#include <editeng/svxacorr.hxx>
+#include <svl/cjkoptions.hxx>
+#include <svl/ctloptions.hxx>
+#include <IDocumentSettingAccess.hxx>
+#include <charfmt.hxx>
+#include <editeng/fontitem.hxx>
+#include <svx/SmartTagItem.hxx>
+#include <fmtinfmt.hxx>
+#include <swwait.hxx>
+#include <wrtsh.hxx>
+#include <wview.hxx>
+#include <swmodule.hxx>
+#include <viewopt.hxx>
+#include <uitool.hxx>
+#include <swevent.hxx>
+#include <pagedesc.hxx>
+#include <textsh.hxx>
+#include <IMark.hxx>
+#include <swdtflvr.hxx>
+#include <docstat.hxx>
+#include <outline.hxx>
+#include <tablemgr.hxx>
+#include <swundo.hxx>
+#include <reffld.hxx>
+#include <docsh.hxx>
+#include <mdiexp.hxx>
+#include <inputwin.hxx>
+#include <chrdlgmodes.hxx>
+#include <pardlg.hxx>
+#include <frmatr.hxx>
+#include <fmtcol.hxx>
+#include <cellatr.hxx>
+#include <edtwin.hxx>
+#include <redlndlg.hxx>
+#include "fldmgr.hxx"
+
+#include <globals.hrc>
+#include <shells.hrc>
+#include <app.hrc>
+#include <web.hrc>
+#include "paratr.hxx"
+#include <crsskip.hxx>
+#include <vcl/svapp.hxx>
+#include <sfx2/app.hxx>
+#include <breakit.hxx>
+
+#include <SwSmartTagMgr.hxx>
+
+#include <editeng/acorrcfg.hxx>
+#include "swabstdlg.hxx"
+#include "misc.hrc"
+#include "chrdlg.hrc"
+#include <IDocumentStatistics.hxx>
+
+#include <sfx2/sfxdlg.hxx>
+#include <unotools/lingucfg.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/util/XChangesBatch.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <editeng/unolingu.hxx>
+#include <unotools/syslocaleoptions.hxx>
+#include <doc.hxx>
+#include <view.hxx>
+#include <ndtxt.hxx>
+#include <pam.hxx>
+#include <sfx2/objface.hxx>
+#include <langhelper.hxx>
+#include <uiitems.hxx>
+#include <wordcountdialog.hxx>
+#include <tools/diagnose_ex.h>
+#include <svx/nbdtmgfact.hxx>
+#include <svx/nbdtmg.hxx>
+#include <numrule.hxx>
+
+using namespace ::com::sun::star;
+using namespace svx::sidebar;
+
+void sw_CharDialog( SwWrtShell &rWrtSh, bool bUseDialog, sal_uInt16 nSlot,const SfxItemSet *pArgs, SfxRequest *pReq )
+{
+ FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, &rWrtSh.GetView()));
+ SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)));
+ SfxItemSet aCoreSet( rWrtSh.GetView().GetPool(),
+ RES_CHRATR_BEGIN, RES_CHRATR_END-1,
+ RES_TXTATR_INETFMT, RES_TXTATR_INETFMT,
+ RES_BACKGROUND, RES_BACKGROUND,
+ RES_BOX, RES_BOX,
+ RES_SHADOW, RES_SHADOW,
+ SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
+ FN_PARAM_SELECTION, FN_PARAM_SELECTION,
+ SID_HTML_MODE, SID_HTML_MODE,
+ SID_ATTR_CHAR_WIDTH_FIT_TO_LINE, SID_ATTR_CHAR_WIDTH_FIT_TO_LINE,
+ 0 );
+ rWrtSh.GetCurAttr( aCoreSet );
+ sal_Bool bSel = rWrtSh.HasSelection();
+ sal_Bool bSelectionPut = sal_False;
+ if(bSel || rWrtSh.IsInWord())
+ {
+ if(!bSel)
+ {
+ rWrtSh.StartAction();
+ rWrtSh.Push();
+ if(!rWrtSh.SelectTxtAttr( RES_TXTATR_INETFMT ))
+ rWrtSh.SelWrd();
+ }
+ aCoreSet.Put(SfxStringItem(FN_PARAM_SELECTION, rWrtSh.GetSelTxt()));
+ bSelectionPut = sal_True;
+ if(!bSel)
+ {
+ rWrtSh.Pop(sal_False);
+ rWrtSh.EndAction();
+ }
+ }
+ aCoreSet.Put( SfxUInt16Item( SID_ATTR_CHAR_WIDTH_FIT_TO_LINE,
+ rWrtSh.GetScalingOfSelectedText() ) );
+
+ ::ConvertAttrCharToGen(aCoreSet, CONV_ATTR_STD);
+
+ // Setting the BoxInfo
+ ::PrepareBoxInfo( aCoreSet, rWrtSh );
+
+ aCoreSet.Put(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(rWrtSh.GetView().GetDocShell())));
+ SfxAbstractTabDialog* pDlg = NULL;
+ if ( bUseDialog && GetActiveView() )
+ {
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+
+ pDlg = pFact->CreateSwCharDlg(rWrtSh.GetView().GetWindow(), rWrtSh.GetView(), aCoreSet, DLG_CHAR_STD);
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ if( FN_INSERT_HYPERLINK == nSlot )
+ pDlg->SetCurPageId("hyperlink");
+ }
+ if (pDlg && nSlot == SID_CHAR_DLG_EFFECT)
+ {
+ pDlg->SetCurPageId("fonteffect");
+ }
+
+ const SfxItemSet* pSet = NULL;
+ if ( !bUseDialog )
+ pSet = pArgs;
+ else if ( NULL != pDlg && pDlg->Execute() == RET_OK ) /* #110771# pDlg can be NULL */
+ {
+ pSet = pDlg->GetOutputItemSet();
+ }
+
+ if ( pSet)
+ {
+ SfxItemSet aTmpSet( *pSet );
+ ::ConvertAttrGenToChar(aTmpSet, CONV_ATTR_STD);
+
+ const SfxPoolItem* pSelectionItem;
+ sal_Bool bInsert = sal_False;
+ sal_Int32 nInsert = 0;
+
+ // The old item is for unknown reasons back in the set again.
+ if( !bSelectionPut && SFX_ITEM_SET == aTmpSet.GetItemState(FN_PARAM_SELECTION, false, &pSelectionItem) )
+ {
+ OUString sInsert = ((const SfxStringItem*)pSelectionItem)->GetValue();
+ bInsert = !sInsert.isEmpty();
+ if(bInsert)
+ {
+ nInsert = sInsert.getLength();
+ rWrtSh.StartAction();
+ rWrtSh.Insert( sInsert );
+ rWrtSh.SetMark();
+ rWrtSh.ExtendSelection(sal_False, sInsert.getLength());
+ SfxRequest aReq( rWrtSh.GetView().GetViewFrame(), FN_INSERT_STRING );
+ aReq.AppendItem( SfxStringItem( FN_INSERT_STRING, sInsert ) );
+ aReq.Done();
+ SfxRequest aReq1( rWrtSh.GetView().GetViewFrame(), FN_CHAR_LEFT );
+ aReq1.AppendItem( SfxInt32Item(FN_PARAM_MOVE_COUNT, nInsert) );
+ aReq1.AppendItem( SfxBoolItem(FN_PARAM_MOVE_SELECTION, true) );
+ aReq1.Done();
+ }
+ }
+ aTmpSet.ClearItem(FN_PARAM_SELECTION);
+
+ SwTxtFmtColl* pColl = rWrtSh.GetCurTxtFmtColl();
+ if(bSel && rWrtSh.IsSelFullPara() && pColl && pColl->IsAutoUpdateFmt())
+ {
+ rWrtSh.AutoUpdatePara(pColl, aTmpSet);
+ }
+ else
+ rWrtSh.SetAttrSet( aTmpSet );
+ if (pReq)
+ pReq->Done(aTmpSet);
+ if(bInsert)
+ {
+ SfxRequest aReq1( rWrtSh.GetView().GetViewFrame(), FN_CHAR_RIGHT );
+ aReq1.AppendItem( SfxInt32Item(FN_PARAM_MOVE_COUNT, nInsert) );
+ aReq1.AppendItem( SfxBoolItem(FN_PARAM_MOVE_SELECTION, false) );
+ aReq1.Done();
+ rWrtSh.SwapPam();
+ rWrtSh.ClearMark();
+ rWrtSh.DontExpandFmt();
+ rWrtSh.EndAction();
+ }
+ }
+
+ delete pDlg;
+}
+
+static short lcl_AskRedlineMode(Window *pWin)
+{
+ MessBox aQBox( pWin, 0,
+ OUString( SW_RES( STR_REDLINE_TITLE ) ),
+ OUString( SW_RES( STR_REDLINE_MSG ) ) );
+ aQBox.SetImage( QueryBox::GetStandardImage() );
+ sal_uInt16 nBtnFlags = BUTTONDIALOG_DEFBUTTON |
+ BUTTONDIALOG_OKBUTTON |
+ BUTTONDIALOG_FOCUSBUTTON;
+
+ aQBox.AddButton(OUString(SW_RES(STR_REDLINE_ACCEPT_ALL)), RET_OK, nBtnFlags);
+ aQBox.GetPushButton( RET_OK )->SetHelpId(HID_AUTOFORMAT_ACCEPT);
+ aQBox.AddButton(OUString(SW_RES(STR_REDLINE_REJECT_ALL)), RET_CANCEL, BUTTONDIALOG_CANCELBUTTON);
+ aQBox.GetPushButton( RET_CANCEL )->SetHelpId(HID_AUTOFORMAT_REJECT );
+ aQBox.AddButton(OUString(SW_RES(STR_REDLINE_EDIT)), 2, 0);
+ aQBox.GetPushButton( 2 )->SetHelpId(HID_AUTOFORMAT_EDIT_CHG);
+ aQBox.SetButtonHelpText( RET_OK, OUString() );
+
+ return aQBox.Execute();
+}
+
+void SwTextShell::Execute(SfxRequest &rReq)
+{
+ bool bUseDialog = true;
+ const SfxItemSet *pArgs = rReq.GetArgs();
+ SwWrtShell& rWrtSh = GetShell();
+ const SfxPoolItem* pItem = 0;
+ sal_uInt16 nSlot = rReq.GetSlot();
+ if(pArgs)
+ pArgs->GetItemState(GetPool().GetWhich(nSlot), false, &pItem);
+ switch( nSlot )
+ {
+ case SID_LANGUAGE_STATUS:
+ {
+ // get the language
+ OUString aNewLangTxt;
+ SFX_REQUEST_ARG( rReq, pItem2, SfxStringItem, SID_LANGUAGE_STATUS , false );
+ if (pItem2)
+ aNewLangTxt = pItem2->GetValue();
+
+ //!! Remember the view frame right now...
+ //!! (call to GetView().GetViewFrame() will break if the
+ //!! SwTextShell got destroyed meanwhile.)
+ SfxViewFrame *pViewFrame = GetView().GetViewFrame();
+
+ if (aNewLangTxt == "*")
+ {
+ // open the dialog "Tools/Options/Language Settings - Language"
+ // to set the documents default language
+ SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
+ if (pFact)
+ {
+ VclAbstractDialog* pDlg = pFact->CreateVclDialog( GetView().GetWindow(), SID_LANGUAGE_OPTIONS );
+ pDlg->Execute();
+ delete pDlg;
+ }
+ }
+ else
+ {
+ //!! We have to use StartAction / EndAction bracketing in
+ //!! order to prevent possible destruction of the SwTextShell
+ //!! due to the selection changes coming below.
+ rWrtSh.StartAction();
+ // prevent view from jumping because of (temporary) selection changes
+ rWrtSh.LockView( sal_True );
+
+ // setting the new language...
+ if (!aNewLangTxt.isEmpty())
+ {
+ const OUString aSelectionLangPrefix("Current_");
+ const OUString aParagraphLangPrefix("Paragraph_");
+ const OUString aDocumentLangPrefix("Default_");
+ const OUString aStrNone("LANGUAGE_NONE");
+ const OUString aStrResetLangs("RESET_LANGUAGES");
+
+ SfxItemSet aCoreSet( GetPool(),
+ RES_CHRATR_LANGUAGE, RES_CHRATR_LANGUAGE,
+ RES_CHRATR_CJK_LANGUAGE, RES_CHRATR_CJK_LANGUAGE,
+ RES_CHRATR_CTL_LANGUAGE, RES_CHRATR_CTL_LANGUAGE,
+ 0 );
+
+ sal_Int32 nPos = 0;
+ bool bForSelection = true;
+ bool bForParagraph = false;
+ if (-1 != (nPos = aNewLangTxt.indexOf( aSelectionLangPrefix, 0 )))
+ {
+ // ... for the current selection
+ aNewLangTxt = aNewLangTxt.replaceAt(nPos, aSelectionLangPrefix.getLength(), "");
+ bForSelection = true;
+ }
+ else if (-1 != (nPos = aNewLangTxt.indexOf(aParagraphLangPrefix, 0)))
+ {
+ // ... for the current paragraph language
+ aNewLangTxt = aNewLangTxt.replaceAt(nPos, aParagraphLangPrefix.getLength(), "");
+ bForSelection = true;
+ bForParagraph = true;
+ }
+ else if (-1 != (nPos = aNewLangTxt.indexOf(aDocumentLangPrefix, 0)))
+ {
+ // ... as default document language
+ aNewLangTxt = aNewLangTxt.replaceAt(nPos, aDocumentLangPrefix.getLength(), "");
+ bForSelection = false;
+ }
+
+ if (bForParagraph || !bForSelection)
+ {
+ rWrtSh.Push(); // save selection for later restoration
+ rWrtSh.ClearMark(); // fdo#67796: invalidate table crsr
+ }
+
+ if (bForParagraph)
+ SwLangHelper::SelectCurrentPara( rWrtSh );
+
+ if (!bForSelection) // document language to be changed...
+ {
+ rWrtSh.SelAll();
+ rWrtSh.ExtendedSelectAll();
+ }
+
+ rWrtSh.StartUndo( ( !bForParagraph && !bForSelection ) ? UNDO_SETDEFTATTR : UNDO_EMPTY );
+ if (aNewLangTxt == aStrNone)
+ SwLangHelper::SetLanguage_None( rWrtSh, bForSelection, aCoreSet );
+ else if (aNewLangTxt == aStrResetLangs)
+ SwLangHelper::ResetLanguages( rWrtSh, bForSelection );
+ else
+ SwLangHelper::SetLanguage( rWrtSh, aNewLangTxt, bForSelection, aCoreSet );
+ rWrtSh.EndUndo();
+
+ if (bForParagraph || !bForSelection)
+ {
+ rWrtSh.Pop(false); // restore selection...
+ }
+ }
+
+ rWrtSh.LockView( sal_False );
+ rWrtSh.EndAction();
+ }
+
+ // invalidate slot to get the new language displayed
+ pViewFrame->GetBindings().Invalidate( nSlot );
+
+ rReq.Done();
+ break;
+ }
+
+ case SID_THES:
+ {
+ // replace word/selection with text from selected sub menu entry
+ OUString aReplaceText;
+ SFX_REQUEST_ARG( rReq, pItem2, SfxStringItem, SID_THES , false );
+ if (pItem2)
+ aReplaceText = pItem2->GetValue();
+ if (!aReplaceText.isEmpty())
+ {
+ SwView &rView2 = rWrtSh.GetView();
+ const bool bSelection = rWrtSh.HasSelection();
+ const OUString aLookUpText = rView2.GetThesaurusLookUpText( bSelection );
+ rView2.InsertThesaurusSynonym( aReplaceText, aLookUpText, bSelection );
+ }
+ }
+ break;
+
+ case SID_CHARMAP:
+ {
+ InsertSymbol( rReq );
+ }
+ break;
+ case FN_INSERT_FOOTNOTE:
+ case FN_INSERT_ENDNOTE:
+ {
+ OUString aStr;
+ SFX_REQUEST_ARG( rReq, pFont, SfxStringItem, FN_PARAM_1 , false );
+ SFX_REQUEST_ARG( rReq, pNameItem, SfxStringItem, nSlot , false );
+ if ( pNameItem )
+ aStr = pNameItem->GetValue();
+ bool bFont = pFont && !pFont->GetValue().isEmpty();
+ rWrtSh.StartUndo( UNDO_UI_INSERT_FOOTNOTE );
+ rWrtSh.InsertFootnote( aStr, nSlot == FN_INSERT_ENDNOTE, !bFont );
+ if ( bFont )
+ {
+ rWrtSh.Left( CRSR_SKIP_CHARS, sal_True, 1, sal_False );
+ SfxItemSet aSet( rWrtSh.GetAttrPool(), RES_CHRATR_FONT, RES_CHRATR_FONT );
+ rWrtSh.GetCurAttr( aSet );
+ SvxFontItem &rFont = (SvxFontItem &) aSet.Get( RES_CHRATR_FONT );
+ SvxFontItem aFont( rFont.GetFamily(), pFont->GetValue(),
+ rFont.GetStyleName(), rFont.GetPitch(), RTL_TEXTENCODING_DONTKNOW, RES_CHRATR_FONT );
+ rWrtSh.SetAttrSet( aSet, nsSetAttrMode::SETATTR_DONTEXPAND );
+ rWrtSh.ResetSelect(0, sal_False);
+ rWrtSh.EndSelect();
+ rWrtSh.GotoFtnTxt();
+ }
+ rWrtSh.EndUndo( UNDO_UI_INSERT_FOOTNOTE );
+ rReq.Done();
+ }
+ break;
+ case FN_INSERT_FOOTNOTE_DLG:
+ {
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "Dialogdiet fail!");
+ AbstractInsFootNoteDlg* pDlg = pFact->CreateInsFootNoteDlg(
+ GetView().GetWindow(), rWrtSh, sal_False);
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ pDlg->SetHelpId(GetStaticInterface()->GetSlot(nSlot)->GetCommand());
+ if ( pDlg->Execute() == RET_OK )
+ {
+ sal_uInt16 nId = pDlg->IsEndNote() ? FN_INSERT_ENDNOTE : FN_INSERT_FOOTNOTE;
+ SfxRequest aReq( GetView().GetViewFrame(), nId );
+ if ( !pDlg->GetStr().isEmpty() )
+ aReq.AppendItem( SfxStringItem( nId, pDlg->GetStr() ) );
+ if ( !pDlg->GetFontName().isEmpty() )
+ aReq.AppendItem( SfxStringItem( FN_PARAM_1, pDlg->GetFontName() ) );
+ ExecuteSlot( aReq );
+ }
+
+ rReq.Ignore();
+ delete pDlg;
+ }
+ break;
+ case FN_FORMAT_FOOTNOTE_DLG:
+ {
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+
+ VclAbstractDialog* pDlg = pFact->CreateSwFootNoteOptionDlg(GetView().GetWindow(), rWrtSh);
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ pDlg->Execute();
+ delete pDlg;
+ break;
+ }
+ case SID_INSERTDOC:
+ {
+ GetView().ExecuteInsertDoc( rReq, pItem );
+ break;
+ }
+ case FN_FORMAT_RESET:
+ {
+ // #i78856, reset all attributes but not the language attributes
+ // (for this build an array of all relevant attributes and
+ // remove the languages from that)
+ std::set<sal_uInt16> aAttribs;
+
+ sal_uInt16 aResetableSetRange[] = {
+ RES_FRMATR_BEGIN, RES_FRMATR_END-1,
+ RES_CHRATR_BEGIN, RES_CHRATR_LANGUAGE - 1,
+ RES_CHRATR_LANGUAGE + 1, RES_CHRATR_CJK_LANGUAGE - 1,
+ RES_CHRATR_CJK_LANGUAGE + 1, RES_CHRATR_CTL_LANGUAGE - 1,
+ RES_CHRATR_CTL_LANGUAGE + 1, RES_CHRATR_END-1,
+ RES_PARATR_BEGIN, RES_PARATR_END-1,
+ RES_TXTATR_UNKNOWN_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER,
+ RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1,
+ 0
+ };
+ sal_uInt16 *pUShorts = aResetableSetRange;
+ while (*pUShorts)
+ {
+ sal_uInt16 nL = pUShorts[1] - pUShorts[0] + 1;
+ sal_uInt16 nE = pUShorts[0];
+ for (sal_uInt16 i = 0; i < nL; ++i)
+ aAttribs.insert( aAttribs.end(), nE++ );
+ pUShorts += 2;
+ }
+ // we don't want to change writing direction.
+ aAttribs.erase( RES_FRAMEDIR );
+ rWrtSh.ResetAttr( aAttribs );
+ rReq.Done();
+ break;
+ }
+ case FN_INSERT_BREAK_DLG:
+ {
+ sal_uInt16 nKind=0;
+ ::boost::optional<sal_uInt16> oPageNumber;
+ OUString aTemplateName;
+ if ( pItem )
+ {
+ nKind = ((SfxInt16Item*)pItem)->GetValue();
+ SFX_REQUEST_ARG( rReq, pTemplate, SfxStringItem, FN_PARAM_1 , false );
+ SFX_REQUEST_ARG( rReq, pNumber, SfxUInt16Item, FN_PARAM_2 , false );
+ SFX_REQUEST_ARG( rReq, pIsNumberFilled, SfxBoolItem, FN_PARAM_3, false );
+ if ( pTemplate )
+ aTemplateName = pTemplate->GetValue();
+ if ( pNumber && pIsNumberFilled && pIsNumberFilled->GetValue() )
+ oPageNumber = pNumber->GetValue();
+ }
+ else
+ {
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+
+ AbstractSwBreakDlg* pDlg = pFact->CreateSwBreakDlg(GetView().GetWindow(), rWrtSh);
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ if ( pDlg->Execute() == RET_OK )
+ {
+ nKind = pDlg->GetKind();
+ aTemplateName = pDlg->GetTemplateName();
+ oPageNumber = pDlg->GetPageNumber();
+
+ sal_Bool bIsNumberFilled = sal_False;
+ sal_uInt16 nPageNumber = 0;
+
+ if (oPageNumber)
+ {
+ bIsNumberFilled = sal_True;
+ nPageNumber = oPageNumber.get();
+ }
+
+ rReq.AppendItem( SfxInt16Item ( FN_INSERT_BREAK_DLG, nKind ) );
+ rReq.AppendItem( SfxStringItem( FN_PARAM_1, aTemplateName ) );
+ rReq.AppendItem( SfxUInt16Item( FN_PARAM_2, nPageNumber ) );
+ rReq.AppendItem( SfxBoolItem ( FN_PARAM_3, bIsNumberFilled ) );
+ rReq.Done();
+ }
+ else
+ rReq.Ignore();
+ delete pDlg;
+ }
+
+ switch ( nKind )
+ {
+ case 1 :
+ rWrtSh.InsertLineBreak(); break;
+ case 2 :
+ rWrtSh.InsertColumnBreak(); break;
+ case 3 :
+ {
+ rWrtSh.StartAllAction();
+ if( !aTemplateName.isEmpty() )
+ rWrtSh.InsertPageBreak( &aTemplateName, oPageNumber );
+ else
+ rWrtSh.InsertPageBreak();
+ rWrtSh.EndAllAction();
+ }
+ }
+
+ break;
+ }
+ case FN_INSERT_BOOKMARK:
+ {
+ if ( pItem )
+ {
+ OUString sName = ((SfxStringItem*)pItem)->GetValue();
+ rWrtSh.SetBookmark( KeyCode(), sName, OUString() );
+ }
+ else
+ {
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+
+ VclAbstractDialog* pDlg = pFact->CreateSwInsertBookmarkDlg( GetView().GetWindow(), rWrtSh, rReq, DLG_INSERT_BOOKMARK );
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ pDlg->Execute();
+ delete pDlg;
+ }
+
+ break;
+ }
+ case FN_DELETE_BOOKMARK:
+ {
+ if ( pItem )
+ {
+ IDocumentMarkAccess* const pMarkAccess = rWrtSh.getIDocumentMarkAccess();
+ pMarkAccess->deleteMark( pMarkAccess->findMark(((SfxStringItem*)pItem)->GetValue()) );
+ }
+ break;
+ }
+ case FN_AUTOFORMAT_REDLINE_APPLY:
+ {
+ SvxSwAutoFmtFlags aFlags(SvxAutoCorrCfg::Get().GetAutoCorrect()->GetSwFlags());
+ // This must always be sal_False for the postprocessing.
+ aFlags.bAFmtByInput = false;
+ aFlags.bWithRedlining = true;
+ rWrtSh.AutoFormat( &aFlags );
+ aFlags.bWithRedlining = false;
+
+ SfxViewFrame* pVFrame = GetView().GetViewFrame();
+ if (pVFrame->HasChildWindow(FN_REDLINE_ACCEPT))
+ pVFrame->ToggleChildWindow(FN_REDLINE_ACCEPT);
+
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+
+ AbstractSwModalRedlineAcceptDlg* pDlg = pFact->CreateSwModalRedlineAcceptDlg(&GetView().GetEditWin());
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+
+ switch (lcl_AskRedlineMode(&GetView().GetEditWin()))
+ {
+ case RET_OK:
+ {
+ pDlg->AcceptAll(sal_True);
+ SfxRequest aReq( pVFrame, FN_AUTOFORMAT_APPLY );
+ aReq.Done();
+ rReq.Ignore();
+ break;
+ }
+
+ case RET_CANCEL:
+ pDlg->AcceptAll(sal_False);
+ rReq.Ignore();
+ break;
+
+ case 2:
+ pDlg->Execute();
+ rReq.Done();
+ break;
+ }
+ delete pDlg;
+ }
+ break;
+
+ case FN_AUTOFORMAT_APPLY:
+ {
+ SvxSwAutoFmtFlags aFlags(SvxAutoCorrCfg::Get().GetAutoCorrect()->GetSwFlags());
+ // This must always be sal_False for the postprocessing.
+ aFlags.bAFmtByInput = false;
+ rWrtSh.AutoFormat( &aFlags );
+ rReq.Done();
+ }
+ break;
+ case FN_AUTOFORMAT_AUTO:
+ {
+ SvxAutoCorrCfg& rACfg = SvxAutoCorrCfg::Get();
+ bool bSet = pItem ? ((const SfxBoolItem*)pItem)->GetValue() : !rACfg.IsAutoFmtByInput();
+ if( bSet != rACfg.IsAutoFmtByInput() )
+ {
+ rACfg.SetAutoFmtByInput( bSet );
+ GetView().GetViewFrame()->GetBindings().Invalidate( nSlot );
+ if ( !pItem )
+ rReq.AppendItem( SfxBoolItem( GetPool().GetWhich(nSlot), bSet ) );
+ rReq.Done();
+ }
+ }
+ break;
+ case FN_AUTO_CORRECT:
+ {
+ // At first set to blank as default.
+ sal_Unicode cChar = ' ';
+ rWrtSh.AutoCorrect( *SvxAutoCorrCfg::Get().GetAutoCorrect(), cChar );
+ rReq.Done();
+ }
+ break;
+ case FN_TABLE_SORT_DIALOG:
+ case FN_SORTING_DLG:
+ {
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+
+ VclAbstractDialog* pDlg = pFact->CreateVclAbstractDialog( GetView().GetWindow(), rWrtSh, DLG_SORTING );
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ pDlg->Execute();
+ delete pDlg;
+ rReq.Done();
+ }
+ break;
+ case FN_NUMBERING_OUTLINE_DLG:
+ {
+ SfxItemSet aTmp(GetPool(), FN_PARAM_1, FN_PARAM_1);
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "Dialogdiet fail!");
+ SfxAbstractTabDialog* pDlg = pFact->CreateSwTabDialog( DLG_TAB_OUTLINE,
+ GetView().GetWindow(), &aTmp, rWrtSh);
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ pDlg->Execute();
+ delete pDlg;
+ rReq.Done();
+ }
+ break;
+ case FN_CALCULATE:
+ {
+ SwTransferable* pTransfer = new SwTransferable( rWrtSh );
+/*??*/ uno::Reference<
+ datatransfer::XTransferable > xRef(
+ pTransfer );
+ pTransfer->CalculateAndCopy();
+ rReq.Done();
+ }
+ break;
+ case FN_GOTO_REFERENCE:
+ {
+ SwField *pFld = rWrtSh.GetCurFld();
+ if(pFld && pFld->GetTypeId() == TYP_GETREFFLD)
+ {
+ rWrtSh.StartAllAction();
+ rWrtSh.SwCrsrShell::GotoRefMark( ((SwGetRefField*)pFld)->GetSetRefName(),
+ ((SwGetRefField*)pFld)->GetSubType(),
+ ((SwGetRefField*)pFld)->GetSeqNo() );
+ rWrtSh.EndAllAction();
+ rReq.Done();
+ }
+ }
+ break;
+ case FN_EDIT_FORMULA:
+ {
+ const sal_uInt16 nId = SwInputChild::GetChildWindowId();
+ SfxViewFrame* pVFrame = GetView().GetViewFrame();
+ if(pItem)
+ {
+ //if the ChildWindow is active it has to be removed
+ if( pVFrame->HasChildWindow( nId ) )
+ {
+ pVFrame->ToggleChildWindow( nId );
+ pVFrame->GetBindings().InvalidateAll( sal_True );
+ }
+
+ OUString sFormula(((const SfxStringItem*)pItem)->GetValue());
+ SwFldMgr aFldMgr;
+ rWrtSh.StartAllAction();
+ sal_Bool bDelSel;
+ if( 0 != (bDelSel = rWrtSh.HasSelection()) )
+ {
+ rWrtSh.StartUndo( UNDO_START );
+ rWrtSh.DelRight();
+ }
+ else
+ {
+ rWrtSh.EnterStdMode();
+ }
+
+ if( !bDelSel && aFldMgr.GetCurFld() && TYP_FORMELFLD == aFldMgr.GetCurTypeId() )
+ aFldMgr.UpdateCurFld( aFldMgr.GetCurFld()->GetFormat(), OUString(), sFormula );
+ else if( !sFormula.isEmpty() )
+ {
+ if( rWrtSh.IsCrsrInTbl() )
+ {
+ SfxItemSet aSet( rWrtSh.GetAttrPool(), RES_BOXATR_FORMULA, RES_BOXATR_FORMULA );
+ aSet.Put( SwTblBoxFormula( sFormula ));
+ rWrtSh.SetTblBoxFormulaAttrs( aSet );
+ rWrtSh.UpdateTable();
+ }
+ else
+ {
+ SvNumberFormatter* pFormatter = rWrtSh.GetNumberFormatter();
+ sal_uLong nSysNumFmt = pFormatter->GetFormatIndex( NF_NUMBER_STANDARD, LANGUAGE_SYSTEM);
+ SwInsertFld_Data aData(TYP_FORMELFLD, nsSwGetSetExpType::GSE_FORMULA, OUString(), sFormula, nSysNumFmt);
+ aFldMgr.InsertFld(aData);
+ }
+ }
+
+ if( bDelSel )
+ rWrtSh.EndUndo( UNDO_END );
+ rWrtSh.EndAllAction();
+ rReq.Done();
+ }
+ else
+ {
+ rWrtSh.EndAllTblBoxEdit();
+ pVFrame->ToggleChildWindow( nId );
+ if( !pVFrame->HasChildWindow( nId ) )
+ pVFrame->GetBindings().InvalidateAll( sal_True );
+ rReq.Ignore();
+ }
+ }
+
+ break;
+ case FN_TABLE_UNSET_READ_ONLY:
+ {
+ rWrtSh.UnProtectTbls();
+ }
+ break;
+ case FN_EDIT_HYPERLINK:
+ GetView().GetViewFrame()->ToggleChildWindow(SID_HYPERLINK_DIALOG);
+ break;
+ case FN_REMOVE_HYPERLINK:
+ {
+ sal_Bool bSel = rWrtSh.HasSelection();
+ if(!bSel)
+ {
+ rWrtSh.StartAction();
+ rWrtSh.Push();
+ if(!rWrtSh.SelectTxtAttr( RES_TXTATR_INETFMT ))
+ rWrtSh.SelWrd();
+ }
+ //now remove the attribute
+ std::set<sal_uInt16> aAttribs;
+ aAttribs.insert( RES_TXTATR_INETFMT );
+ rWrtSh.ResetAttr( aAttribs );
+ if(!bSel)
+ {
+ rWrtSh.Pop(sal_False);
+ rWrtSh.EndAction();
+ }
+ }
+ break;
+ case SID_ATTR_BRUSH_CHAR :
+ case SID_ATTR_CHAR_SCALEWIDTH :
+ case SID_ATTR_CHAR_ROTATED :
+ case FN_TXTATR_INET :
+ case FN_INSERT_HYPERLINK:
+ {
+ sal_uInt16 nWhich = GetPool().GetWhich( nSlot );
+ if ( pArgs && pArgs->GetItemState( nWhich ) == SFX_ITEM_SET )
+ bUseDialog = false;
+ // intentionally no break
+ }
+ case SID_CHAR_DLG:
+ case SID_CHAR_DLG_EFFECT:
+ {
+ sw_CharDialog( rWrtSh, bUseDialog, nSlot, pArgs, &rReq );
+ }
+ break;
+ case SID_CHAR_DLG_FOR_PARAGRAPH:
+ {
+ rWrtSh.Push(); //save current cursor
+ SwLangHelper::SelectCurrentPara( rWrtSh );
+ sw_CharDialog( rWrtSh, bUseDialog, nSlot, pArgs, &rReq );
+ rWrtSh.Pop( sal_False ); //restore old cursor
+ }
+ break;
+ case SID_ATTR_LRSPACE :
+ case SID_ATTR_ULSPACE :
+ case SID_ATTR_BRUSH :
+ case SID_PARA_VERTALIGN :
+ case SID_ATTR_PARA_NUMRULE :
+ case SID_ATTR_PARA_REGISTER :
+ case SID_ATTR_PARA_PAGENUM :
+ case FN_FORMAT_LINENUMBER :
+ case FN_NUMBER_NEWSTART :
+ case FN_NUMBER_NEWSTART_AT :
+ case FN_FORMAT_DROPCAPS :
+ case FN_DROP_TEXT:
+ case SID_ATTR_PARA_LRSPACE:
+ {
+ sal_uInt16 nWhich = GetPool().GetWhich( nSlot );
+ if ( pArgs && pArgs->GetItemState( nWhich ) == SFX_ITEM_SET )
+ bUseDialog = false;
+ // intentionally no break
+
+ }
+ case SID_PARA_DLG:
+ {
+ SwPaM* pPaM = NULL;
+
+ if ( pArgs )
+ {
+ const SfxPoolItem* pPaMItem = 0;
+ pArgs->GetItemState( GetPool().GetWhich( FN_PARAM_PAM ), false, &pPaMItem );
+ if ( pPaMItem )
+ pPaM = static_cast< const SwPaMItem* >( pPaMItem )->GetValue( );
+ }
+
+ if ( !pPaM )
+ pPaM = rWrtSh.GetCrsr();
+
+ FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, &GetView()));
+ SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)));
+
+ sal_Bool bApplyCharUnit = ::HasCharUnit(0 != PTR_CAST(SwWebView, &GetView()));
+ SW_MOD()->PutItem(SfxBoolItem(SID_ATTR_APPLYCHARUNIT, bApplyCharUnit));
+
+ SfxItemSet aCoreSet( GetPool(),
+ RES_PARATR_BEGIN, RES_PARATR_END - 1,
+ RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END - 1,
+ RES_FRMATR_BEGIN, RES_FRMATR_END - 1,
+ SID_ATTR_TABSTOP_POS, SID_ATTR_TABSTOP_POS,
+ SID_ATTR_TABSTOP_DEFAULTS, SID_ATTR_TABSTOP_DEFAULTS,
+ SID_ATTR_TABSTOP_OFFSET, SID_ATTR_TABSTOP_OFFSET,
+ SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
+ SID_ATTR_PARA_MODEL, SID_ATTR_PARA_KEEP,
+ SID_ATTR_PARA_PAGENUM, SID_ATTR_PARA_PAGENUM,
+ SID_HTML_MODE, SID_HTML_MODE,
+ FN_PARAM_1, FN_PARAM_1,
+ FN_NUMBER_NEWSTART, FN_NUMBER_NEWSTART_AT,
+ FN_DROP_TEXT, FN_DROP_CHAR_STYLE_NAME,
+ 0);
+ // get also the list level indent values merged as LR-SPACE item, if needed.
+ rWrtSh.GetPaMAttr( pPaM, aCoreSet, true );
+ aCoreSet.Put(SfxUInt16Item(SID_HTML_MODE,
+ ::GetHtmlMode(GetView().GetDocShell())));
+
+ // Tabulators: Put DefaultTabs into ItemSet
+ const SvxTabStopItem& rDefTabs = (const SvxTabStopItem&)
+ GetPool().GetDefaultItem(RES_PARATR_TABSTOP);
+
+ sal_uInt16 nDefDist = ::GetTabDist( rDefTabs );
+ SfxUInt16Item aDefDistItem( SID_ATTR_TABSTOP_DEFAULTS, nDefDist );
+ aCoreSet.Put( aDefDistItem );
+
+ // Current tabulator
+ SfxUInt16Item aTabPos( SID_ATTR_TABSTOP_POS, 0 );
+ aCoreSet.Put( aTabPos );
+
+ // Left border as offset
+ //#i24363# tab stops relative to indent
+ const long nOff = rWrtSh.getIDocumentSettingAccess()->get(IDocumentSettingAccess::TABS_RELATIVE_TO_INDENT) ?
+ ((SvxLRSpaceItem&)aCoreSet.Get( RES_LR_SPACE )).GetTxtLeft() : 0;
+ SfxInt32Item aOff( SID_ATTR_TABSTOP_OFFSET, nOff );
+ aCoreSet.Put( aOff );
+
+ // Setting the BoxInfo
+ ::PrepareBoxInfo( aCoreSet, rWrtSh );
+
+ // Current page format
+ ::SwToSfxPageDescAttr( aCoreSet );
+
+ // Properties of numbering
+ if( rWrtSh.GetDoc()->GetCurrNumRule( *pPaM->GetPoint() ) )
+ {
+ SfxBoolItem aStart( FN_NUMBER_NEWSTART, rWrtSh.IsNumRuleStart( pPaM ) );
+ aCoreSet.Put(aStart);
+ SfxUInt16Item aStartAt( FN_NUMBER_NEWSTART_AT,
+ rWrtSh.GetNodeNumStart( pPaM ) );
+ aCoreSet.Put(aStartAt);
+ }
+ SfxAbstractTabDialog* pDlg = NULL;
+
+ if ( bUseDialog && GetActiveView() )
+ {
+ OString sDefPage;
+ if (pItem)
+ sDefPage = OUStringToOString(((const SfxStringItem*)pItem)->GetValue(), RTL_TEXTENCODING_UTF8);
+
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+
+ pDlg = pFact->CreateSwParaDlg( GetView().GetWindow(),GetView(), aCoreSet, DLG_STD, NULL, sal_False, sDefPage );
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ }
+ SfxItemSet* pSet = NULL;
+ if ( !bUseDialog )
+ {
+ if ( nSlot == SID_ATTR_PARA_LRSPACE)
+ {
+ SvxLRSpaceItem aParaMargin((const SvxLRSpaceItem&)pArgs->Get(nSlot));
+ aParaMargin.SetWhich( RES_LR_SPACE);
+ aCoreSet.Put(aParaMargin);
+ pSet = &aCoreSet;
+
+ } else
+ pSet = (SfxItemSet*) pArgs;
+
+ }
+ else if ( NULL != pDlg && pDlg->Execute() == RET_OK )
+ {
+ // Apply defaults if nessecary.
+ pSet = (SfxItemSet*)pDlg->GetOutputItemSet();
+ sal_uInt16 nNewDist;
+ if( SFX_ITEM_SET == pSet->GetItemState( SID_ATTR_TABSTOP_DEFAULTS, false, &pItem ) &&
+ nDefDist != (nNewDist = ((SfxUInt16Item*)pItem)->GetValue()) )
+ {
+ SvxTabStopItem aDefTabs( 0, 0, SVX_TAB_ADJUST_DEFAULT, RES_PARATR_TABSTOP );
+ MakeDefTabs( nNewDist, aDefTabs );
+ rWrtSh.SetDefault( aDefTabs );
+ pSet->ClearItem( SID_ATTR_TABSTOP_DEFAULTS );
+ }
+
+ if ( SFX_ITEM_SET == pSet->GetItemState(FN_PARAM_1,false,&pItem) )
+ {
+ pSet->Put(SfxStringItem(FN_DROP_TEXT, ((const SfxStringItem*)pItem)->GetValue()));
+ pSet->ClearItem(FN_PARAM_1);
+ }
+
+ if( SFX_ITEM_SET == pSet->GetItemState( RES_PARATR_DROP, false, &pItem ))
+ {
+ OUString sCharStyleName;
+ if(((const SwFmtDrop*)pItem)->GetCharFmt())
+ sCharStyleName = ((const SwFmtDrop*)pItem)->GetCharFmt()->GetName();
+ pSet->Put(SfxStringItem(FN_DROP_CHAR_STYLE_NAME, sCharStyleName));
+ }
+ }
+
+ if ( pSet )
+ {
+ rReq.Done( *pSet );
+ ::SfxToSwPageDescAttr( rWrtSh, *pSet );
+ // #i56253#
+ // enclose all undos.
+ // Thus, check conditions, if actions will be performed.
+ const bool bUndoNeeded( pSet->Count() ||
+ SFX_ITEM_SET == pSet->GetItemState(FN_NUMBER_NEWSTART) ||
+ SFX_ITEM_SET == pSet->GetItemState(FN_NUMBER_NEWSTART_AT) );
+ if ( bUndoNeeded )
+ {
+ rWrtSh.StartUndo( UNDO_INSATTR );
+ }
+ if( pSet->Count() )
+ {
+ rWrtSh.StartAction();
+ if ( SFX_ITEM_SET == pSet->GetItemState(FN_DROP_TEXT, false, &pItem) )
+ {
+ if ( !((SfxStringItem*)pItem)->GetValue().isEmpty() )
+ rWrtSh.ReplaceDropTxt(((SfxStringItem*)pItem)->GetValue(), pPaM);
+ }
+ rWrtSh.SetAttrSet( *pSet, 0, pPaM );
+ rWrtSh.EndAction();
+ SwTxtFmtColl* pColl = rWrtSh.GetPaMTxtFmtColl( pPaM );
+ if(pColl && pColl->IsAutoUpdateFmt())
+ {
+ rWrtSh.AutoUpdatePara(pColl, *pSet, pPaM);
+ }
+ }
+
+ if( SFX_ITEM_SET == pSet->GetItemState(FN_NUMBER_NEWSTART) )
+ {
+ //SetNumRuleStart(sal_True) restarts the numbering at the value
+ //that is defined at the starting point of the numbering level
+ //otherwise the SetNodeNumStart() value determines the start
+ //if it's set to something different than (sal_uInt16)0xFFFF
+
+ sal_Bool bStart = ((SfxBoolItem&)pSet->Get(FN_NUMBER_NEWSTART)).GetValue();
+
+ // Default value for restart value has to be (sal_uInt16)0xFFFF
+ // in order to indicate that the restart value of the list
+ // style has to be used on restart.
+ sal_uInt16 nNumStart = (sal_uInt16)0xFFFF;
+ if( SFX_ITEM_SET == pSet->GetItemState(FN_NUMBER_NEWSTART_AT) )
+ {
+ nNumStart = ((SfxUInt16Item&)pSet->Get(FN_NUMBER_NEWSTART_AT)).GetValue();
+ }
+ rWrtSh.SetNumRuleStart(bStart, pPaM);
+ rWrtSh.SetNodeNumStart(nNumStart);
+ }
+ else if( SFX_ITEM_SET == pSet->GetItemState(FN_NUMBER_NEWSTART_AT) )
+ {
+ sal_uInt16 nNumStart = ((SfxUInt16Item&)pSet->Get(FN_NUMBER_NEWSTART_AT)).GetValue();
+ rWrtSh.SetNodeNumStart(nNumStart);
+ rWrtSh.SetNumRuleStart(sal_False, pPaM);
+ }
+ // #i56253#
+ if ( bUndoNeeded )
+ {
+ rWrtSh.EndUndo( UNDO_INSATTR );
+ }
+ }
+
+ delete pDlg;
+ }
+ break;
+ case FN_NUM_CONTINUE:
+ {
+ OUString sContinuedListId;
+ const SwNumRule* pRule =
+ rWrtSh.SearchNumRule( false, true, false, -1, sContinuedListId );
+ // #i86492#
+ // Search also for bullet list
+ if ( !pRule )
+ {
+ pRule = rWrtSh.SearchNumRule( false, false, false, -1, sContinuedListId );
+ }
+ if ( pRule )
+ {
+ rWrtSh.SetCurNumRule( *pRule, false, sContinuedListId );
+ }
+ }
+ break;
+ case FN_SELECT_PARA:
+ {
+ if(!rWrtSh.IsSttOfPara())
+ rWrtSh.SttPara(sal_False);
+ else
+ rWrtSh.EnterStdMode();
+ rWrtSh.EndPara(sal_True);
+ }
+ break;
+
+ case SID_DEC_INDENT:
+ case SID_INC_INDENT:
+ //According to the requirement, modified the behavior when user
+ //using the indent button on the toolbar. Now if we increase/decrease indent for a
+ //paragraph which has bullet style it will increase/decrease the bullet level.
+ {
+ //If the current paragraph has bullet call the function to
+ //increase or decrease the bullet level.
+ //Why could I know wheter a paragraph has bullet or not by checking the below conditions?
+ //Please refer to the "case KEY_TAB:" section in SwEditWin::KeyInput(..) :
+ // if( rSh.GetCurNumRule() && rSh.IsSttOfPara() &&
+ // !rSh.HasReadonlySel() )
+ // eKeyState = KS_NumDown;
+ //Above code demonstrates that when the cursor is at the start of a paragraph which has bullet,
+ //press TAB will increase the bullet level.
+ //So I copied from that ^^
+ if ( rWrtSh.GetCurNumRule() && !rWrtSh.HasReadonlySel() )
+ {
+ rWrtSh.NumUpDown( SID_INC_INDENT == nSlot );
+ }
+ else//execute the original processing functions
+ {
+ //below is copied of the old codes
+ rWrtSh.MoveLeftMargin( SID_INC_INDENT == nSlot,
+ rReq.GetModifier() != KEY_MOD1 );
+ }
+ }
+ rReq.Done();
+ break;
+ case FN_DEC_INDENT_OFFSET:
+ case FN_INC_INDENT_OFFSET:
+ rWrtSh.MoveLeftMargin( FN_INC_INDENT_OFFSET == nSlot,
+ rReq.GetModifier() == KEY_MOD1 );
+ rReq.Done();
+ break;
+
+ case SID_ATTR_CHAR_COLOR2:
+ {
+ if(pItem)
+ {
+ Color aSet = ((const SvxColorItem*)pItem)->GetValue();
+ SwEditWin& rEditWin = GetView().GetEditWin();
+ rEditWin.SetTextColor(aSet);
+ SwApplyTemplate* pApply = rEditWin.GetApplyTemplate();
+
+ // If there is a selection, then set the color on it
+ // otherwise, it'll be the color for the next text to be typed
+ if(!pApply || pApply->nColor != SID_ATTR_CHAR_COLOR_EXT)
+ {
+ rWrtSh.SetAttrItem(SvxColorItem (aSet, RES_CHRATR_COLOR));
+ }
+
+ rReq.Done();
+ }
+ }
+ break;
+ case SID_ATTR_CHAR_COLOR_BACKGROUND:
+ {
+ SwEditWin& rEdtWin = GetView().GetEditWin();
+ SwApplyTemplate* pApply = rEdtWin.GetApplyTemplate();
+ rEdtWin.SetTextBackColorTransparent(0 == pItem);
+ Color aSet;
+ if(pItem)
+ {
+ aSet = ((const SvxColorItem*)pItem)->GetValue();
+ rEdtWin.SetTextBackColor(aSet); //select last color
+ }
+ else
+ rEdtWin.SetTextBackColor(Color(COL_TRANSPARENT)); //if last was "no fill"
+ if(!pApply && (rWrtSh.HasSelection() || rReq.IsAPI()))
+ {
+ SvxBrushItem aBrushItem(RES_CHRATR_BACKGROUND);
+ if(pItem)
+ aBrushItem.SetColor(aSet); //set the selected color
+ else
+ aBrushItem.SetColor(Color(COL_TRANSPARENT));//set "no fill" color
+ rWrtSh.SetAttrItem( aBrushItem );
+ }
+ else if(!pApply || pApply->nColor != SID_ATTR_CHAR_COLOR_BACKGROUND_EXT)
+ {
+ GetView().GetViewFrame()->GetDispatcher()->Execute(SID_ATTR_CHAR_COLOR_BACKGROUND_EXT);
+ }
+
+ rReq.Done();
+
+ }
+ break;
+ case SID_ATTR_CHAR_COLOR_BACKGROUND_EXT:
+ case SID_ATTR_CHAR_COLOR_EXT:
+ {
+ SwEditWin& rEdtWin = GetView().GetEditWin();
+ SwApplyTemplate* pApply = rEdtWin.GetApplyTemplate();
+ SwApplyTemplate aTempl;
+ sal_Bool bSelection = rWrtSh.HasSelection();
+ if(bSelection)
+ {
+
+ if(nSlot == SID_ATTR_CHAR_COLOR_BACKGROUND_EXT)
+ {
+ rWrtSh.SetAttrItem(
+ SvxBrushItem( rEdtWin.GetTextBackColor(), RES_CHRATR_BACKGROUND) );
+ }
+ else
+ rWrtSh.SetAttrItem(
+ SvxColorItem( rEdtWin.GetTextColor(), RES_CHRATR_COLOR) );
+ }
+ else
+ {
+ if(!pApply || pApply->nColor != nSlot)
+ aTempl.nColor = nSlot;
+ rEdtWin.SetApplyTemplate(aTempl);
+ }
+
+ rReq.Done();
+ }
+ break;
+
+ case FN_NUM_BULLET_MOVEDOWN:
+ if (!rWrtSh.IsAddMode())
+ rWrtSh.MoveParagraph(1);
+ rReq.Done();
+ break;
+
+ case FN_NUM_BULLET_MOVEUP:
+ if (!rWrtSh.IsAddMode())
+ rWrtSh.MoveParagraph(-1);
+ rReq.Done();
+ break;
+ case SID_RUBY_DIALOG:
+ case SID_HYPERLINK_DIALOG:
+ {
+ SfxRequest aReq(nSlot, SFX_CALLMODE_SLOT, SFX_APP()->GetPool());
+ GetView().GetViewFrame()->ExecuteSlot( aReq);
+ rReq.Ignore();
+ }
+ break;
+ case FN_INSERT_PAGEHEADER:
+ case FN_INSERT_PAGEFOOTER:
+ if(pArgs && pArgs->Count())
+ {
+ OUString sStyleName;
+ if(pItem)
+ sStyleName = ((const SfxStringItem*)pItem)->GetValue();
+ sal_Bool bOn = sal_True;
+ if( SFX_ITEM_SET == pArgs->GetItemState(FN_PARAM_1, false, &pItem))
+ bOn = ((const SfxBoolItem*)pItem)->GetValue();
+ rWrtSh.ChangeHeaderOrFooter(sStyleName, FN_INSERT_PAGEHEADER == nSlot, bOn, !rReq.IsAPI());
+ rReq.Done();
+ }
+ break;
+ case FN_READONLY_SELECTION_MODE :
+ if(GetView().GetDocShell()->IsReadOnly())
+ {
+ rWrtSh.SetReadonlySelectionOption(
+ !rWrtSh.GetViewOptions()->IsSelectionInReadonly());
+ rWrtSh.ShowCrsr();
+ }
+ break;
+ case FN_SELECTION_MODE_DEFAULT:
+ case FN_SELECTION_MODE_BLOCK :
+ {
+ bool bSetBlockMode = !rWrtSh.IsBlockMode();
+ if( pArgs && SFX_ITEM_SET == pArgs->GetItemState(nSlot, false, &pItem))
+ bSetBlockMode = ((const SfxBoolItem*)pItem)->GetValue();
+ if( ( nSlot == FN_SELECTION_MODE_DEFAULT ) != bSetBlockMode )
+ rWrtSh.EnterBlockMode();
+ else
+ rWrtSh.EnterStdMode();
+ SfxBindings &rBnd = GetView().GetViewFrame()->GetBindings();
+ rBnd.Invalidate(FN_STAT_SELMODE);
+ rBnd.Update(FN_STAT_SELMODE);
+ }
+ break;
+ case SID_OPEN_HYPERLINK:
+ case FN_COPY_HYPERLINK_LOCATION:
+ {
+ SfxItemSet aSet(GetPool(),
+ RES_TXTATR_INETFMT,
+ RES_TXTATR_INETFMT);
+ rWrtSh.GetCurAttr(aSet);
+ if(SFX_ITEM_SET <= aSet.GetItemState( RES_TXTATR_INETFMT, true ))
+ {
+ const SwFmtINetFmt& rINetFmt = dynamic_cast<const SwFmtINetFmt&>( aSet.Get(RES_TXTATR_INETFMT, sal_True) );
+ if( nSlot == FN_COPY_HYPERLINK_LOCATION )
+ {
+ ::uno::Reference< datatransfer::clipboard::XClipboard > xClipboard = GetView().GetEditWin().GetClipboard();
+ vcl::unohelper::TextDataObject::CopyStringTo(
+ rINetFmt.GetValue(),
+ xClipboard );
+ }
+ else
+ rWrtSh.ClickToINetAttr(rINetFmt, URLLOAD_NOFILTER);
+ }
+ }
+ break;
+ case SID_OPEN_XML_FILTERSETTINGS:
+ {
+ try
+ {
+ uno::Reference < ui::dialogs::XExecutableDialog > xDialog = ui::dialogs::XSLTFilterDialog::create( ::comphelper::getProcessComponentContext() );
+ xDialog->execute();
+ }
+ catch (const uno::Exception&)
+ {
+ }
+ rReq.Ignore ();
+ }
+ break;
+ case FN_FORMAT_APPLY_HEAD1:
+ {
+ }
+ break;
+ case FN_FORMAT_APPLY_HEAD2:
+ {
+ }
+ break;
+ case FN_FORMAT_APPLY_HEAD3:
+ {
+ }
+ break;
+ case FN_FORMAT_APPLY_DEFAULT:
+ {
+ }
+ break;
+ case FN_FORMAT_APPLY_TEXTBODY:
+ {
+ }
+ break;
+ case FN_WORDCOUNT_DIALOG:
+ {
+ SfxViewFrame* pVFrame = GetView().GetViewFrame();
+ if (pVFrame != NULL)
+ {
+ pVFrame->ToggleChildWindow(FN_WORDCOUNT_DIALOG);
+ Invalidate(rReq.GetSlot());
+
+ SwWordCountWrapper *pWrdCnt = (SwWordCountWrapper*)pVFrame->GetChildWindow(SwWordCountWrapper::GetChildWindowId());
+ if (pWrdCnt)
+ pWrdCnt->UpdateCounts();
+ }
+ }
+ break;
+ default:
+ OSL_ENSURE(!this, "wrong dispatcher");
+ return;
+ }
+}
+
+void SwTextShell::GetState( SfxItemSet &rSet )
+{
+ SwWrtShell &rSh = GetShell();
+ SfxWhichIter aIter( rSet );
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ while ( nWhich )
+ {
+ switch ( nWhich )
+ {
+ case SID_LANGUAGE_STATUS:
+ {
+ // the value of used script types
+ OUString aScriptTypesInUse( OUString::number( rSh.GetScriptType() ) );
+
+ SvtLanguageTable aLangTable;
+
+ // get keyboard language
+ OUString aKeyboardLang;
+ SwEditWin& rEditWin = GetView().GetEditWin();
+ LanguageType nLang = rEditWin.GetInputLanguage();
+ if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
+ aKeyboardLang = aLangTable.GetString( nLang );
+
+ // get the language that is in use
+ OUString aCurrentLang = "*";
+ nLang = SwLangHelper::GetCurrentLanguage( rSh );
+ if (nLang != LANGUAGE_DONTKNOW)
+ aCurrentLang = aLangTable.GetString( nLang );
+
+ // build sequence for status value
+ uno::Sequence< OUString > aSeq( 4 );
+ aSeq[0] = aCurrentLang;
+ aSeq[1] = aScriptTypesInUse;
+ aSeq[2] = aKeyboardLang;
+ aSeq[3] = SwLangHelper::GetTextForLanguageGuessing( rSh );
+
+ // set sequence as status value
+ SfxStringListItem aItem( SID_LANGUAGE_STATUS );
+ aItem.SetStringList( aSeq );
+ rSet.Put( aItem, SID_LANGUAGE_STATUS );
+ }
+ break;
+
+ case SID_THES:
+ {
+ // is there a valid selection to get text from?
+ OUString aText;
+ bool bValid = !rSh.HasSelection() ||
+ (rSh.IsSelOnePara() && !rSh.IsMultiSelection());
+ // prevent context menu from showing when cursor is not in or at the end of a word
+ // (GetCurWord will return the next word if there is none at the current position...)
+ const sal_Int16 nWordType = ::i18n::WordType::DICTIONARY_WORD;
+ bool bWord = rSh.IsInWord( nWordType ) || rSh.IsStartWord( nWordType ) || rSh.IsEndWord( nWordType );
+ if (bValid && bWord)
+ aText = rSh.HasSelection()? OUString(rSh.GetSelTxt()) : rSh.GetCurWord();
+
+ LanguageType nLang = rSh.GetCurLang();
+ LanguageTag aLanguageTag( nLang);
+ lang::Locale aLocale( aLanguageTag.getLocale());
+ OUString aLangText( aLanguageTag.getBcp47() );
+
+ // set word and locale to look up as status value
+ OUString aStatusVal = aText + "#" + aLangText;
+
+ rSet.Put( SfxStringItem( SID_THES, aStatusVal ) );
+
+ // disable "Thesaurus" context menu entry if there is nothing to look up
+ uno::Reference< linguistic2::XThesaurus > xThes( ::GetThesaurus() );
+ if (aText.isEmpty() ||
+ !xThes.is() || nLang == LANGUAGE_NONE || !xThes->hasLocale( aLocale ))
+ rSet.DisableItem( SID_THES );
+ }
+ break;
+
+ case FN_NUMBER_NEWSTART :
+ if(!rSh.GetCurNumRule())
+ rSet.DisableItem(nWhich);
+ else
+ rSet.Put(SfxBoolItem(FN_NUMBER_NEWSTART,
+ rSh.IsNumRuleStart()));
+ break;
+
+ case FN_EDIT_FORMULA:
+ case SID_CHARMAP:
+ {
+ const int nType = rSh.GetSelectionType();
+ if (!(nType & nsSelectionType::SEL_TXT) &&
+ !(nType & nsSelectionType::SEL_TBL) &&
+ !(nType & nsSelectionType::SEL_NUM))
+ {
+ rSet.DisableItem(nWhich);
+ }
+ else if ( nWhich == FN_EDIT_FORMULA
+ && rSh.CrsrInsideInputFld() )
+ {
+ rSet.DisableItem( nWhich );
+ }
+ }
+ break;
+
+ case FN_INSERT_ENDNOTE:
+ case FN_INSERT_FOOTNOTE:
+ case FN_INSERT_FOOTNOTE_DLG:
+ {
+ const sal_uInt16 nNoType =
+ FRMTYPE_FLY_ANY | FRMTYPE_HEADER | FRMTYPE_FOOTER | FRMTYPE_FOOTNOTE;
+ if ( (rSh.GetFrmType(0,sal_True) & nNoType) )
+ rSet.DisableItem(nWhich);
+
+ if ( rSh.CrsrInsideInputFld() )
+ {
+ rSet.DisableItem( nWhich );
+ }
+ }
+ break;
+
+ case FN_INSERT_HYPERLINK:
+ case SID_INSERTDOC:
+ case FN_INSERT_GLOSSARY:
+ case FN_EXPAND_GLOSSARY:
+ if ( rSh.CrsrInsideInputFld() )
+ {
+ rSet.DisableItem( nWhich );
+ }
+ break;
+
+ case FN_INSERT_TABLE:
+ if ( rSh.CrsrInsideInputFld()
+ || rSh.GetTableFmt()
+ || (rSh.GetFrmType(0,sal_True) & FRMTYPE_FOOTNOTE) )
+ {
+ rSet.DisableItem( nWhich );
+ }
+ break;
+
+ case FN_CALCULATE:
+ if ( !rSh.IsSelection() )
+ rSet.DisableItem(nWhich);
+ break;
+ case FN_GOTO_REFERENCE:
+ {
+ SwField *pFld = rSh.GetCurFld();
+ if ( !pFld || (pFld && pFld->GetTypeId() != TYP_GETREFFLD) )
+ rSet.DisableItem(nWhich);
+ }
+ break;
+ case FN_AUTOFORMAT_AUTO:
+ {
+ rSet.Put( SfxBoolItem( nWhich, SvxAutoCorrCfg::Get().IsAutoFmtByInput() ));
+ }
+ break;
+
+ case SID_DEC_INDENT:
+ case SID_INC_INDENT:
+ {
+ //if the paragrah has bullet we'll do the following things:
+ //1: if the bullet level is the first level, disable the decrease-indent button
+ //2: if the bullet level is the last level, disable the increase-indent button
+ if ( rSh.GetCurNumRule() && !rSh.HasReadonlySel() )
+ {
+ sal_uInt8 nLevel = rSh.GetNumLevel();
+ if ( (nLevel == (MAXLEVEL-1) && nWhich == SID_INC_INDENT) ||
+ (nLevel == 0 && nWhich == SID_DEC_INDENT) )
+ {
+ rSet.DisableItem( nWhich );
+ }
+ }
+ else//if the paragraph has no bullet, execute the original functions
+ {
+ //below is copied of the old codes
+ sal_uInt16 nHtmlMode = ::GetHtmlMode(GetView().GetDocShell());
+ nHtmlMode &= HTMLMODE_ON|HTMLMODE_SOME_STYLES;
+ if( (nHtmlMode == HTMLMODE_ON) || !rSh.IsMoveLeftMargin(
+ SID_INC_INDENT == nWhich, true ))
+ rSet.DisableItem( nWhich );
+ }
+ }
+ break;
+
+ case FN_DEC_INDENT_OFFSET:
+ case FN_INC_INDENT_OFFSET:
+ {
+ sal_uInt16 nHtmlMode = ::GetHtmlMode(GetView().GetDocShell());
+ nHtmlMode &= HTMLMODE_ON|HTMLMODE_SOME_STYLES;
+ if( (nHtmlMode == HTMLMODE_ON) ||
+ !rSh.IsMoveLeftMargin( FN_INC_INDENT_OFFSET == nWhich,
+ false ))
+ rSet.DisableItem( nWhich );
+ }
+ break;
+
+ case SID_ATTR_CHAR_COLOR2:
+ {
+ rSet.Put(SvxColorItem(GetView().GetEditWin().GetTextColor(), SID_ATTR_CHAR_COLOR2));
+ }
+ break;
+ case SID_ATTR_CHAR_COLOR_BACKGROUND:
+ {
+ if(GetView().GetEditWin().IsTextBackColorTransparent())
+ rSet.Put(SvxColorItem(Color(COL_TRANSPARENT), SID_ATTR_CHAR_COLOR_BACKGROUND));
+ else
+ rSet.Put(SvxColorItem(GetView().GetEditWin().GetTextBackColor(), SID_ATTR_CHAR_COLOR_BACKGROUND));
+ }
+ break;
+ case SID_ATTR_CHAR_COLOR_BACKGROUND_EXT:
+ case SID_ATTR_CHAR_COLOR_EXT:
+ {
+ SwEditWin& rEdtWin = GetView().GetEditWin();
+ SwApplyTemplate* pApply = rEdtWin.GetApplyTemplate();
+ rSet.Put(SfxBoolItem(nWhich, pApply && pApply->nColor == nWhich));
+ }
+ break;
+
+ case FN_INSERT_BOOKMARK:
+ if( rSh.IsTableMode()
+ || rSh.CrsrInsideInputFld() )
+ {
+ rSet.DisableItem( nWhich );
+ }
+ break;
+
+ case FN_INSERT_BREAK:
+ if ( rSh.HasReadonlySel()
+ && !rSh.CrsrInsideInputFld() )
+ {
+ rSet.DisableItem( nWhich );
+ }
+ break;
+
+ case FN_INSERT_BREAK_DLG:
+ case FN_INSERT_COLUMN_BREAK:
+ case FN_INSERT_PAGEBREAK:
+ if( rSh.CrsrInsideInputFld() )
+ {
+ rSet.DisableItem( nWhich );
+ }
+ break;
+
+ case FN_INSERT_PAGEHEADER:
+ case FN_INSERT_PAGEFOOTER:
+ {
+ rSet.Put( SfxObjectShellItem( nWhich, GetView().GetDocShell() ));
+ }
+ break;
+ case FN_TABLE_SORT_DIALOG:
+ case FN_SORTING_DLG:
+ if(!rSh.HasSelection() ||
+ (FN_TABLE_SORT_DIALOG == nWhich && !rSh.GetTableFmt()))
+ rSet.DisableItem( nWhich );
+ break;
+
+ case SID_RUBY_DIALOG:
+ {
+ SvtCJKOptions aCJKOptions;
+ if( !aCJKOptions.IsRubyEnabled()
+ || rSh.CrsrInsideInputFld() )
+ {
+ GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_False );
+ rSet.DisableItem(nWhich);
+ }
+ else
+ GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_True );
+ }
+ break;
+
+ case SID_HYPERLINK_DIALOG:
+ if( GetView().GetDocShell()->IsReadOnly()
+ || ( !GetView().GetViewFrame()->HasChildWindow(nWhich)
+ && rSh.HasReadonlySel() )
+ || rSh.CrsrInsideInputFld() )
+ {
+ rSet.DisableItem(nWhich);
+ }
+ else
+ {
+ rSet.Put(SfxBoolItem( nWhich, 0 != GetView().GetViewFrame()->GetChildWindow( nWhich ) ));
+ }
+ break;
+
+ case FN_EDIT_HYPERLINK:
+ case FN_COPY_HYPERLINK_LOCATION:
+ {
+ SfxItemSet aSet(GetPool(),
+ RES_TXTATR_INETFMT,
+ RES_TXTATR_INETFMT);
+ rSh.GetCurAttr(aSet);
+ if(SFX_ITEM_SET > aSet.GetItemState( RES_TXTATR_INETFMT, true ) || rSh.HasReadonlySel())
+ {
+ rSet.DisableItem(nWhich);
+ }
+ }
+ break;
+ case FN_REMOVE_HYPERLINK:
+ {
+ SfxItemSet aSet(GetPool(),
+ RES_TXTATR_INETFMT,
+ RES_TXTATR_INETFMT);
+ rSh.GetCurAttr(aSet);
+
+ // If a hyperlink is selected, either alone or along with other text...
+ if( ((SFX_ITEM_DONTCARE & aSet.GetItemState( RES_TXTATR_INETFMT, true )) == 0) || rSh.HasReadonlySel())
+ {
+ rSet.DisableItem(nWhich);
+ }
+ }
+ break;
+ case SID_TRANSLITERATE_HALFWIDTH:
+ case SID_TRANSLITERATE_FULLWIDTH:
+ case SID_TRANSLITERATE_HIRAGANA:
+ case SID_TRANSLITERATE_KATAGANA:
+ {
+ SvtCJKOptions aCJKOptions;
+ if(!aCJKOptions.IsChangeCaseMapEnabled())
+ {
+ GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_False );
+ rSet.DisableItem(nWhich);
+ }
+ else
+ GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_True );
+ }
+ break;
+ case FN_READONLY_SELECTION_MODE :
+ if(!GetView().GetDocShell()->IsReadOnly())
+ rSet.DisableItem( nWhich );
+ else
+ {
+ rSet.Put(SfxBoolItem(nWhich, rSh.GetViewOptions()->IsSelectionInReadonly()));
+ }
+ break;
+ case FN_SELECTION_MODE_DEFAULT:
+ case FN_SELECTION_MODE_BLOCK :
+ rSet.Put(SfxBoolItem(nWhich, (nWhich == FN_SELECTION_MODE_DEFAULT) != rSh.IsBlockMode()));
+ break;
+ case SID_OPEN_HYPERLINK:
+ {
+ SfxItemSet aSet(GetPool(),
+ RES_TXTATR_INETFMT,
+ RES_TXTATR_INETFMT);
+ rSh.GetCurAttr(aSet);
+ if(SFX_ITEM_SET > aSet.GetItemState( RES_TXTATR_INETFMT, false ))
+ rSet.DisableItem(nWhich);
+ }
+ break;
+ case SID_OPEN_SMARTTAGMENU:
+ {
+ uno::Sequence< OUString > aSmartTagTypes;
+ uno::Sequence< uno::Reference< container::XStringKeyMap > > aStringKeyMaps;
+ uno::Reference<text::XTextRange> xRange;
+
+ rSh.GetSmartTagTerm( aSmartTagTypes, aStringKeyMaps, xRange );
+
+ if ( xRange.is() && aSmartTagTypes.getLength() )
+ {
+ uno::Sequence < uno::Sequence< uno::Reference< smarttags::XSmartTagAction > > > aActionComponentsSequence;
+ uno::Sequence < uno::Sequence< sal_Int32 > > aActionIndicesSequence;
+
+ const SmartTagMgr& rSmartTagMgr = SwSmartTagMgr::Get();
+ rSmartTagMgr.GetActionSequences( aSmartTagTypes,
+ aActionComponentsSequence,
+ aActionIndicesSequence );
+
+ uno::Reference <frame::XController> xController = GetView().GetController();
+ const lang::Locale aLocale( SW_BREAKITER()->GetLocale( GetAppLanguageTag() ) );
+ const OUString aApplicationName( rSmartTagMgr.GetApplicationName() );
+ const OUString aRangeText = xRange->getString();
+
+ const SvxSmartTagItem aItem( nWhich,
+ aActionComponentsSequence,
+ aActionIndicesSequence,
+ aStringKeyMaps,
+ xRange,
+ xController,
+ aLocale,
+ aApplicationName,
+ aRangeText );
+
+ rSet.Put( aItem );
+ }
+ else
+ rSet.DisableItem(nWhich);
+ }
+ break;
+ case FN_NUM_NUMBERING_ON:
+ rSet.Put(SfxBoolItem(FN_NUM_NUMBERING_ON,rSh.SelectionHasNumber()));
+ break;
+ case FN_NUM_BULLET_ON:
+ rSet.Put(SfxBoolItem(FN_NUM_BULLET_ON,rSh.SelectionHasBullet()));
+ break;
+ case FN_BUL_NUM_RULE_INDEX:
+ case FN_NUM_NUM_RULE_INDEX:
+ {
+ SwNumRule* pCurRule = (SwNumRule*)(GetShell().GetCurNumRule());
+ sal_uInt16 nActNumLvl = (sal_uInt16)0xFFFF;
+ rSet.Put(SfxUInt16Item(FN_NUM_NUM_RULE_INDEX,DEFAULT_NONE));
+ rSet.Put(SfxUInt16Item(FN_BUL_NUM_RULE_INDEX,DEFAULT_NONE));
+ if( pCurRule )
+ {
+ nActNumLvl = GetShell().GetNumLevel();
+ if( nActNumLvl < MAXLEVEL )
+ {
+ nActNumLvl = 1<<nActNumLvl;
+ }
+ SvxNumRule aSvxRule = pCurRule->MakeSvxNumRule();
+ if ( GetShell().HasBullet())
+ {
+ rSet.Put(SfxUInt16Item(FN_BUL_NUM_RULE_INDEX,(sal_uInt16)0xFFFF));
+ rSet.Put(SfxUInt16Item(FN_NUM_NUM_RULE_INDEX,(sal_uInt16)0xFFFF));
+ NBOTypeMgrBase* pBullets = NBOutlineTypeMgrFact::CreateInstance(eNBOType::MIXBULLETS);
+ if ( pBullets )
+ {
+ sal_uInt16 nBulIndex = pBullets->GetNBOIndexForNumRule(aSvxRule,nActNumLvl);
+ rSet.Put(SfxUInt16Item(FN_BUL_NUM_RULE_INDEX,nBulIndex));
+ }
+ }else if ( GetShell().HasNumber() )
+ {
+ rSet.Put(SfxUInt16Item(FN_BUL_NUM_RULE_INDEX,(sal_uInt16)0xFFFF));
+ rSet.Put(SfxUInt16Item(FN_NUM_NUM_RULE_INDEX,(sal_uInt16)0xFFFF));
+ NBOTypeMgrBase* pNumbering = NBOutlineTypeMgrFact::CreateInstance(eNBOType::NUMBERING);
+ if ( pNumbering )
+ {
+ sal_uInt16 nBulIndex = pNumbering->GetNBOIndexForNumRule(aSvxRule,nActNumLvl);
+ rSet.Put(SfxUInt16Item(FN_NUM_NUM_RULE_INDEX,nBulIndex));
+ }
+ }
+ }
+ }
+ break;
+ case FN_NUM_CONTINUE:
+ {
+ {
+ // #i86492#
+ // Search also for bullet list
+ OUString aDummy;
+ const SwNumRule* pRule =
+ rSh.SearchNumRule( false, true, false, -1, aDummy );
+ if ( !pRule )
+ {
+ pRule = rSh.SearchNumRule( false, false, false, -1, aDummy );
+ }
+ if ( !pRule )
+ rSet.DisableItem(nWhich);
+ }
+ }
+ break;
+ case SID_INSERT_RLM :
+ case SID_INSERT_LRM :
+ case SID_INSERT_ZWNBSP :
+ case SID_INSERT_ZWSP:
+ {
+ SvtCTLOptions aCTLOptions;
+ sal_Bool bEnabled = aCTLOptions.IsCTLFontEnabled();
+ GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, bEnabled );
+ if(!bEnabled)
+ rSet.DisableItem(nWhich);
+ }
+ break;
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/shells/textsh2.cxx b/sw/source/core/uibase/shells/textsh2.cxx
new file mode 100644
index 000000000000..ebd67d2a4d8a
--- /dev/null
+++ b/sw/source/core/uibase/shells/textsh2.cxx
@@ -0,0 +1,285 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <cstdarg>
+
+#include <svtools/svmedit.hxx>
+#include <svl/eitem.hxx>
+#include <svl/whiter.hxx>
+#include <sfx2/event.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <vcl/msgbox.hxx>
+#include <svl/stritem.hxx>
+#include <svl/itemset.hxx>
+#include <sfx2/request.hxx>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdb/XQueriesSupplier.hpp>
+#include <com/sun/star/sdb/XDatabaseAccess.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/sdbc/XRowSet.hpp>
+#include <sfx2/frame.hxx>
+#include <fldmgr.hxx>
+#include <fldbas.hxx>
+#include "dbmgr.hxx"
+#include <comphelper/uno3.hxx>
+#include <svx/dataaccessdescriptor.hxx>
+
+#include <vcl/svapp.hxx>
+
+#include "view.hxx"
+#include "wrtsh.hxx"
+#include "swtypes.hxx"
+#include "cmdid.h"
+#include "swevent.hxx"
+#include "shells.hrc"
+#include "textsh.hxx"
+#include "swabstdlg.hxx"
+#include "dbui.hrc"
+
+#include <unomid.h>
+
+#include <boost/scoped_ptr.hpp>
+
+using namespace ::svx;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::frame;
+
+struct DBTextStruct_Impl
+{
+ SwDBData aDBData;
+ Sequence<Any> aSelection;
+ Reference<XResultSet> xCursor;
+ Reference<XConnection> xConnection;
+};
+
+void SwTextShell::ExecDB(SfxRequest &rReq)
+{
+ const SfxItemSet *pArgs = rReq.GetArgs();
+ SwNewDBMgr* pNewDBMgr = GetShell().GetNewDBMgr();
+ sal_uInt16 nSlot = rReq.GetSlot();
+ OUString sSourceArg, sCommandArg;
+ sal_Int32 nCommandTypeArg = 0;
+
+ const SfxPoolItem* pSourceItem = 0;
+ const SfxPoolItem* pCursorItem = 0;
+ const SfxPoolItem* pConnectionItem = 0;
+ const SfxPoolItem* pCommandItem = 0;
+ const SfxPoolItem* pCommandTypeItem = 0;
+ const SfxPoolItem* pSelectionItem = 0;
+
+ // first get the selection of rows to be inserted
+ pArgs->GetItemState(FN_DB_DATA_SELECTION_ANY, false, &pSelectionItem);
+
+ Sequence<Any> aSelection;
+ if(pSelectionItem)
+ ((SfxUsrAnyItem*)pSelectionItem)->GetValue() >>= aSelection;
+
+ // get the data source name
+ pArgs->GetItemState(FN_DB_DATA_SOURCE_ANY, false, &pSourceItem);
+ if(pSourceItem)
+ ((const SfxUsrAnyItem*)pSourceItem)->GetValue() >>= sSourceArg;
+
+ // get the command
+ pArgs->GetItemState(FN_DB_DATA_COMMAND_ANY, false, &pCommandItem);
+ if(pCommandItem)
+ ((const SfxUsrAnyItem*)pCommandItem)->GetValue() >>= sCommandArg;
+
+ // get the command type
+ pArgs->GetItemState(FN_DB_DATA_COMMAND_TYPE_ANY, false, &pCommandTypeItem);
+ if(pCommandTypeItem)
+ ((const SfxUsrAnyItem*)pCommandTypeItem)->GetValue() >>= nCommandTypeArg;
+
+ Reference<XConnection> xConnection;
+ pArgs->GetItemState(FN_DB_CONNECTION_ANY, false, &pConnectionItem);
+ if ( pConnectionItem )
+ ((const SfxUsrAnyItem*)pConnectionItem)->GetValue() >>= xConnection;
+ // may be we even get no connection
+ if ( !xConnection.is() )
+ {
+ Reference<XDataSource> xSource;
+ xConnection = pNewDBMgr->GetConnection(sSourceArg, xSource);
+ }
+ if(!xConnection.is())
+ return ;
+
+ // get the cursor, we use to travel, may be NULL
+ Reference<XResultSet> xCursor;
+ pArgs->GetItemState(FN_DB_DATA_CURSOR_ANY, false, &pCursorItem);
+ if ( pCursorItem )
+ ((const SfxUsrAnyItem*)pCursorItem)->GetValue() >>= xCursor;
+
+ switch (nSlot)
+ {
+ case FN_QRY_INSERT:
+ {
+ if(pSourceItem && pCommandItem && pCommandTypeItem)
+ {
+ DBTextStruct_Impl* pNew = new DBTextStruct_Impl;
+ pNew->aDBData.sDataSource = sSourceArg;
+ pNew->aDBData.sCommand = sCommandArg;
+ pNew->aDBData.nCommandType = nCommandTypeArg;
+ pNew->aSelection = aSelection;
+ //if the cursor is NULL, it must be created inside InsertDBTextHdl
+ // because it called via a PostUserEvent
+ pNew->xCursor = xCursor;
+ pNew->xConnection = xConnection;
+
+ Application::PostUserEvent( STATIC_LINK( this, SwBaseShell,
+ InsertDBTextHdl ), pNew );
+ // the pNew will be removed in InsertDBTextHdl !!
+ }
+ }
+ break;
+
+ case FN_QRY_MERGE_FIELD:
+ {
+ // we don't get any cursor, so we must create our own
+ sal_Bool bDisposeResultSet = sal_False;
+ if ( !xCursor.is() )
+ {
+ xCursor = SwNewDBMgr::createCursor(sSourceArg,sCommandArg,nCommandTypeArg,xConnection);
+ bDisposeResultSet = xCursor.is();
+ }
+
+ ODataAccessDescriptor aDescriptor;
+ aDescriptor.setDataSource(sSourceArg);
+ aDescriptor[daCommand] <<= sCommandArg;
+ aDescriptor[daCursor] <<= xCursor;
+ aDescriptor[daSelection] <<= aSelection;
+ aDescriptor[daCommandType] <<= nCommandTypeArg;
+
+ SwMergeDescriptor aMergeDesc( DBMGR_MERGE, *GetShellPtr(), aDescriptor );
+ pNewDBMgr->MergeNew(aMergeDesc);
+
+ if ( bDisposeResultSet )
+ ::comphelper::disposeComponent(xCursor);
+ }
+ break;
+
+ case FN_QRY_INSERT_FIELD:
+ {
+ const SfxPoolItem* pColumnItem = 0;
+ const SfxPoolItem* pColumnNameItem = 0;
+
+ pArgs->GetItemState(FN_DB_COLUMN_ANY, false, &pColumnItem);
+ pArgs->GetItemState(FN_DB_DATA_COLUMN_NAME_ANY, false, &pColumnNameItem);
+
+ OUString sColumnName;
+ if(pColumnNameItem)
+ ((SfxUsrAnyItem*)pColumnNameItem)->GetValue() >>= sColumnName;
+ OUString sDBName = sSourceArg;
+ sDBName += OUString(DB_DELIM);
+ sDBName += sCommandArg;
+ sDBName += OUString(DB_DELIM);
+ sDBName += OUString::number(nCommandTypeArg);
+ sDBName += OUString(DB_DELIM);
+ sDBName += sColumnName;
+
+ SwFldMgr aFldMgr(GetShellPtr());
+ SwInsertFld_Data aData(TYP_DBFLD, 0, sDBName, OUString(), 0);
+ if(pConnectionItem)
+ aData.aDBConnection = ((SfxUsrAnyItem*)pConnectionItem)->GetValue();
+ if(pColumnItem)
+ aData.aDBColumn = ((SfxUsrAnyItem*)pColumnItem)->GetValue();
+ aFldMgr.InsertFld(aData);
+ SfxViewFrame* pViewFrame = GetView().GetViewFrame();
+ uno::Reference< XDispatchRecorder > xRecorder =
+ pViewFrame->GetBindings().GetRecorder();
+ if ( xRecorder.is() )
+ {
+ SfxRequest aReq( pViewFrame, FN_INSERT_DBFIELD );
+ aReq.AppendItem( SfxUInt16Item(FN_PARAM_FIELD_TYPE, TYP_DBFLD));
+ aReq.AppendItem( SfxStringItem( FN_INSERT_DBFIELD, sDBName ));
+ aReq.AppendItem( SfxStringItem( FN_PARAM_1, sCommandArg ));
+ aReq.AppendItem( SfxStringItem( FN_PARAM_2, sColumnName ));
+ aReq.AppendItem( SfxInt32Item( FN_PARAM_3, nCommandTypeArg));
+ aReq.Done();
+ }
+ }
+ break;
+
+ default:
+ OSL_ENSURE(!this, "wrong dispatcher");
+ return;
+ }
+}
+
+IMPL_STATIC_LINK( SwBaseShell, InsertDBTextHdl, DBTextStruct_Impl*, pDBStruct )
+{
+ if( pDBStruct )
+ {
+ bool bDispose = false;
+ Reference< sdbc::XConnection> xConnection = pDBStruct->xConnection;
+ Reference<XDataSource> xSource = SwNewDBMgr::getDataSourceAsParent(xConnection,pDBStruct->aDBData.sDataSource);
+ // #111987# the connection is disposed an so no parent has been found
+ if(xConnection.is() && !xSource.is())
+ return 0;
+
+ if ( !xConnection.is() )
+ {
+ xConnection = SwNewDBMgr::GetConnection(pDBStruct->aDBData.sDataSource, xSource);
+ bDispose = true;
+ }
+
+ Reference< XColumnsSupplier> xColSupp;
+ if(xConnection.is())
+ xColSupp = SwNewDBMgr::GetColumnSupplier(xConnection,
+ pDBStruct->aDBData.sCommand,
+ pDBStruct->aDBData.nCommandType == CommandType::QUERY ?
+ SW_DB_SELECT_QUERY : SW_DB_SELECT_TABLE);
+
+ if( xColSupp.is() )
+ {
+ SwDBData aDBData = pDBStruct->aDBData;
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+ boost::scoped_ptr<AbstractSwInsertDBColAutoPilot>pDlg (pFact->CreateSwInsertDBColAutoPilot(pThis->GetView(),
+ xSource,
+ xColSupp,
+ aDBData));
+ if( RET_OK == pDlg->Execute() )
+ {
+ Reference <XResultSet> xResSet = pDBStruct->xCursor;
+ pDlg->DataToDoc( pDBStruct->aSelection, xSource, xConnection, xResSet);
+ }
+ }
+ if ( bDispose )
+ ::comphelper::disposeComponent(xConnection);
+ }
+
+ delete pDBStruct;
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/shells/txtattr.cxx b/sw/source/core/uibase/shells/txtattr.cxx
new file mode 100644
index 000000000000..47d7e9312acb
--- /dev/null
+++ b/sw/source/core/uibase/shells/txtattr.cxx
@@ -0,0 +1,743 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <hintids.hxx>
+
+#include <vcl/msgbox.hxx>
+#include <svl/whiter.hxx>
+#include <svl/stritem.hxx>
+#include <svl/itemiter.hxx>
+#include <svl/ctloptions.hxx>
+#include <swmodule.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/request.hxx>
+#include <editeng/fhgtitem.hxx>
+#include <editeng/adjustitem.hxx>
+#include <editeng/lspcitem.hxx>
+#include <editeng/lrspitem.hxx>
+#include <editeng/udlnitem.hxx>
+#include <editeng/escapementitem.hxx>
+#include <sfx2/htmlmode.hxx>
+#include <editeng/scripttypeitem.hxx>
+#include <editeng/frmdiritem.hxx>
+#include "paratr.hxx"
+
+#include <fmtinfmt.hxx>
+#include <docsh.hxx>
+#include <wrtsh.hxx>
+#include <view.hxx>
+#include <viewopt.hxx>
+#include <uitool.hxx>
+#include <textsh.hxx>
+#include <num.hxx>
+#include <swundo.hxx>
+#include <fmtcol.hxx>
+
+#include <cmdid.h>
+#include <globals.h>
+#include <shells.hrc>
+#include <SwStyleNameMapper.hxx>
+#include "swabstdlg.hxx"
+#include "chrdlg.hrc"
+const sal_uInt32 nFontInc = 40; // 2pt
+const sal_uInt32 nFontMaxSz = 19998; // 999.9pt
+
+void SwTextShell::ExecCharAttr(SfxRequest &rReq)
+{
+ SwWrtShell &rSh = GetShell();
+ const SfxItemSet *pArgs = rReq.GetArgs();
+ int eState = STATE_TOGGLE;
+ sal_uInt16 nWhich = rReq.GetSlot();
+
+ if(pArgs )
+ {
+ const SfxPoolItem* pItem;
+ pArgs->GetItemState(nWhich, false, &pItem);
+ eState = ((const SfxBoolItem &) pArgs->
+ Get( nWhich )).GetValue() ? STATE_ON : STATE_OFF;
+ }
+
+ SfxItemSet aSet( GetPool(), RES_CHRATR_BEGIN, RES_CHRATR_END-1 );
+ if (STATE_TOGGLE == eState)
+ rSh.GetCurAttr( aSet );
+
+ switch ( nWhich )
+ {
+ case FN_SET_SUB_SCRIPT:
+ case FN_SET_SUPER_SCRIPT:
+ {
+ SvxEscapement eEscape = SVX_ESCAPEMENT_SUBSCRIPT;
+ switch (eState)
+ {
+ case STATE_TOGGLE:
+ {
+ short nTmpEsc = ((const SvxEscapementItem&)
+ aSet.Get( RES_CHRATR_ESCAPEMENT )).GetEsc();
+ eEscape = nWhich == FN_SET_SUPER_SCRIPT ?
+ SVX_ESCAPEMENT_SUPERSCRIPT:
+ SVX_ESCAPEMENT_SUBSCRIPT;
+ if( (nWhich == FN_SET_SUB_SCRIPT && nTmpEsc < 0) ||
+ (nWhich == FN_SET_SUPER_SCRIPT && nTmpEsc > 0) )
+ eEscape = SVX_ESCAPEMENT_OFF;
+
+ SfxBindings& rBind = GetView().GetViewFrame()->GetBindings();
+ if( nWhich == FN_SET_SUB_SCRIPT )
+ rBind.SetState( SfxBoolItem( FN_SET_SUPER_SCRIPT,
+ false ) );
+ else
+ rBind.SetState( SfxBoolItem( FN_SET_SUB_SCRIPT,
+ false ) );
+
+ }
+ break;
+ case STATE_ON:
+ eEscape = nWhich == FN_SET_SUPER_SCRIPT ?
+ SVX_ESCAPEMENT_SUPERSCRIPT:
+ SVX_ESCAPEMENT_SUBSCRIPT;
+ break;
+ case STATE_OFF:
+ eEscape = SVX_ESCAPEMENT_OFF;
+ break;
+ }
+ SvxEscapementItem aEscape( eEscape, RES_CHRATR_ESCAPEMENT );
+ if(eEscape == SVX_ESCAPEMENT_SUPERSCRIPT)
+ aEscape.GetEsc() = DFLT_ESC_AUTO_SUPER;
+ else if(eEscape == SVX_ESCAPEMENT_SUBSCRIPT)
+ aEscape.GetEsc() = DFLT_ESC_AUTO_SUB;
+ rSh.SetAttrItem( aEscape );
+ rReq.AppendItem( aEscape );
+ rReq.Done();
+ }
+ break;
+
+ case FN_UPDATE_STYLE_BY_EXAMPLE:
+ rSh.QuickUpdateStyle();
+ rReq.Done();
+ break;
+ case FN_UNDERLINE_DOUBLE:
+ {
+ FontUnderline eUnderline = ((const SvxUnderlineItem&)
+ aSet.Get(RES_CHRATR_UNDERLINE)).GetLineStyle();
+ switch( eState )
+ {
+ case STATE_TOGGLE:
+ eUnderline = eUnderline == UNDERLINE_DOUBLE ?
+ UNDERLINE_NONE :
+ UNDERLINE_DOUBLE;
+ break;
+ case STATE_ON:
+ eUnderline = UNDERLINE_DOUBLE;
+ break;
+ case STATE_OFF:
+ eUnderline = UNDERLINE_NONE;
+ break;
+ }
+ SvxUnderlineItem aUnderline(eUnderline, RES_CHRATR_UNDERLINE );
+ rSh.SetAttrItem( aUnderline );
+ rReq.AppendItem( aUnderline );
+ rReq.Done();
+ }
+ break;
+ case FN_REMOVE_DIRECT_CHAR_FORMATS:
+ if( !rSh.HasReadonlySel() && rSh.IsEndPara())
+ rSh.DontExpandFmt();
+ break;
+ default:
+ OSL_FAIL("wrong dispatcher");
+ return;
+ }
+}
+
+void SwTextShell::ExecCharAttrArgs(SfxRequest &rReq)
+{
+ sal_uInt16 nSlot = rReq.GetSlot();
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ bool bArgs = pArgs != 0 && pArgs->Count() > 0;
+ SwWrtShell& rWrtSh = GetShell();
+ SwTxtFmtColl* pColl = 0;
+
+ // Is only set if the whole paragraph is selected and AutoUpdateFmt is set.
+ if (rWrtSh.HasSelection() && rWrtSh.IsSelFullPara())
+ {
+ pColl = rWrtSh.GetCurTxtFmtColl();
+ if ( pColl && !pColl->IsAutoUpdateFmt() )
+ pColl = 0;
+ }
+ SfxItemPool& rPool = GetPool();
+ sal_uInt16 nWhich = rPool.GetWhich( nSlot );
+ switch (nSlot)
+ {
+ case FN_TXTATR_INET:
+ // Special treatment of the PoolId of the SwFmtInetFmt
+ if(bArgs)
+ {
+ const SfxPoolItem& rItem = pArgs->Get( nWhich );
+
+ SwFmtINetFmt aINetFmt( (const SwFmtINetFmt&) rItem );
+ if ( USHRT_MAX == aINetFmt.GetVisitedFmtId() )
+ {
+ OSL_ENSURE( false, "<SwTextShell::ExecCharAttrArgs(..)> - unexpected visited character format ID at hyperlink attribute" );
+ aINetFmt.SetVisitedFmtAndId(
+ aINetFmt.GetVisitedFmt(),
+ SwStyleNameMapper::GetPoolIdFromUIName( aINetFmt.GetVisitedFmt(), nsSwGetPoolIdFromName::GET_POOLID_CHRFMT ) );
+ }
+ if ( USHRT_MAX == aINetFmt.GetINetFmtId() )
+ {
+ OSL_ENSURE( false, "<SwTextShell::ExecCharAttrArgs(..)> - unexpected unvisited character format ID at hyperlink attribute" );
+ aINetFmt.SetINetFmtAndId(
+ aINetFmt.GetINetFmt(),
+ SwStyleNameMapper::GetPoolIdFromUIName( aINetFmt.GetINetFmt(), nsSwGetPoolIdFromName::GET_POOLID_CHRFMT ) );
+ }
+
+ if ( pColl )
+ pColl->SetFmtAttr( aINetFmt );
+ else
+ rWrtSh.SetAttrItem( aINetFmt );
+ rReq.Done();
+ }
+ break;
+
+ case FN_GROW_FONT_SIZE:
+ case FN_SHRINK_FONT_SIZE:
+ {
+ SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONTHEIGHT, rPool );
+ rWrtSh.GetCurAttr( aSetItem.GetItemSet() );
+ SfxItemSet aAttrSet( rPool, aSetItem.GetItemSet().GetRanges() );
+
+ sal_uInt16 nScriptTypes = rWrtSh.GetScriptType();
+
+ const SvxFontHeightItem* pSize( static_cast<const SvxFontHeightItem*>(
+ aSetItem.GetItemOfScript( nScriptTypes ) ) );
+
+ if (pSize)
+ {
+ SvxFontHeightItem aSize(*pSize);
+
+ sal_uInt32 nSize = aSize.GetHeight();
+
+ if ( nSlot == FN_GROW_FONT_SIZE && ( nSize += nFontInc ) > nFontMaxSz )
+ nSize = nFontMaxSz;
+ else if ( nSlot == FN_SHRINK_FONT_SIZE && ( nSize -= nFontInc ) < nFontInc )
+ nSize = nFontInc;
+
+ aSize.SetHeight( nSize );
+ aSetItem.PutItemForScriptType( nScriptTypes, aSize );
+ aAttrSet.Put( aSetItem.GetItemSet() );
+
+ if( pColl )
+ pColl->SetFmtAttr( aAttrSet );
+ else
+ rWrtSh.SetAttrSet( aAttrSet );
+ }
+
+ rReq.Done();
+ }
+ break;
+
+ default:
+ OSL_FAIL("wrong dispatcher");
+ return;
+ }
+}
+
+void SwTextShell::ExecParaAttr(SfxRequest &rReq)
+{
+ SvxAdjust eAdjst;
+ sal_uInt8 ePropL;
+ const SfxItemSet* pArgs = rReq.GetArgs();
+
+ // Get both attributes immediately isn't more expensive!!
+ SfxItemSet aSet( GetPool(),
+ RES_PARATR_LINESPACING, RES_PARATR_ADJUST,
+ RES_FRAMEDIR, RES_FRAMEDIR,
+ 0 );
+
+ sal_uInt16 nSlot = rReq.GetSlot();
+ switch (nSlot)
+ {
+ case SID_ATTR_PARA_ADJUST:
+ {
+ if( pArgs && SFX_ITEM_SET == pArgs->GetItemState(RES_PARATR_ADJUST) )
+ {
+ const SvxAdjustItem& rAdj = (const SvxAdjustItem&) pArgs->Get(RES_PARATR_ADJUST);
+ SvxAdjustItem aAdj( rAdj.GetAdjust(), RES_PARATR_ADJUST );
+ if ( rAdj.GetAdjust() == SVX_ADJUST_BLOCK )
+ {
+ aAdj.SetLastBlock( rAdj.GetLastBlock() );
+ aAdj.SetOneWord( rAdj.GetOneWord() );
+ }
+
+ aSet.Put(aAdj);
+ }
+ }
+ break;
+ case SID_ATTR_PARA_ADJUST_LEFT: eAdjst = SVX_ADJUST_LEFT; goto SET_ADJUST;
+ case SID_ATTR_PARA_ADJUST_RIGHT: eAdjst = SVX_ADJUST_RIGHT; goto SET_ADJUST;
+ case SID_ATTR_PARA_ADJUST_CENTER: eAdjst = SVX_ADJUST_CENTER; goto SET_ADJUST;
+ case SID_ATTR_PARA_ADJUST_BLOCK: eAdjst = SVX_ADJUST_BLOCK; goto SET_ADJUST;
+SET_ADJUST:
+ {
+ aSet.Put(SvxAdjustItem(eAdjst,RES_PARATR_ADJUST));
+ rReq.AppendItem( SfxBoolItem( GetPool().GetWhich(nSlot), true ) );
+ }
+ break;
+
+ case SID_ATTR_PARA_LINESPACE:
+ if(pArgs && SFX_ITEM_SET == pArgs->GetItemState( GetPool().GetWhich(nSlot) ))
+ {
+ SvxLineSpacingItem aLineSpace = (const SvxLineSpacingItem&)pArgs->Get(
+ GetPool().GetWhich(nSlot));
+ aSet.Put( aLineSpace );
+ }
+ break;
+ case SID_ATTR_PARA_LINESPACE_10: ePropL = 100; goto SET_LINESPACE;
+ case SID_ATTR_PARA_LINESPACE_15: ePropL = 150; goto SET_LINESPACE;
+ case SID_ATTR_PARA_LINESPACE_20: ePropL = 200; goto SET_LINESPACE;
+
+SET_LINESPACE:
+ {
+
+ SvxLineSpacingItem aLineSpacing(ePropL, RES_PARATR_LINESPACING );
+ aLineSpacing.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
+ if( 100 == ePropL )
+ aLineSpacing.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF;
+ else
+ aLineSpacing.SetPropLineSpace(ePropL);
+ aSet.Put( aLineSpacing );
+ }
+ break;
+
+ case SID_ATTR_PARA_LEFT_TO_RIGHT :
+ case SID_ATTR_PARA_RIGHT_TO_LEFT :
+ {
+ SfxItemSet aAdjustSet( GetPool(),
+ RES_PARATR_ADJUST, RES_PARATR_ADJUST );
+ GetShell().GetCurAttr(aAdjustSet);
+ bool bChgAdjust = false;
+ SfxItemState eAdjustState = aAdjustSet.GetItemState(RES_PARATR_ADJUST, false);
+ if(eAdjustState >= SFX_ITEM_DEFAULT)
+ {
+ int eAdjust = (int)(( const SvxAdjustItem& )
+ aAdjustSet.Get(RES_PARATR_ADJUST)).GetAdjust();
+ bChgAdjust = (SVX_ADJUST_LEFT == eAdjust && SID_ATTR_PARA_RIGHT_TO_LEFT == nSlot) ||
+ (SVX_ADJUST_RIGHT == eAdjust && SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot);
+ }
+ else
+ bChgAdjust = true;
+
+ SvxFrameDirection eFrmDirection =
+ (SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot) ?
+ FRMDIR_HORI_LEFT_TOP : FRMDIR_HORI_RIGHT_TOP;
+ aSet.Put( SvxFrameDirectionItem( eFrmDirection, RES_FRAMEDIR ) );
+
+ if (bChgAdjust)
+ {
+ SvxAdjust eAdjust = (SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot) ?
+ SVX_ADJUST_LEFT : SVX_ADJUST_RIGHT;
+ SvxAdjustItem aAdjust( eAdjust, RES_PARATR_ADJUST );
+ aSet.Put( aAdjust );
+ aAdjust.SetWhich(SID_ATTR_PARA_ADJUST);
+ GetView().GetViewFrame()->GetBindings().SetState( aAdjust );
+ // Toggle numbering alignment
+ const SwNumRule* pCurRule = GetShell().GetCurNumRule();
+ if( pCurRule )
+ {
+ SvxNumRule aRule = pCurRule->MakeSvxNumRule();
+
+ for(sal_uInt16 i = 0; i < aRule.GetLevelCount(); i++)
+ {
+ SvxNumberFormat aFmt(aRule.GetLevel(i));
+ if(SVX_ADJUST_LEFT == aFmt.GetNumAdjust())
+ aFmt.SetNumAdjust( SVX_ADJUST_RIGHT );
+
+ else if(SVX_ADJUST_RIGHT == aFmt.GetNumAdjust())
+ aFmt.SetNumAdjust( SVX_ADJUST_LEFT );
+
+ aRule.SetLevel(i, aFmt, aRule.Get(i) != 0);
+ }
+ SwNumRule aSetRule( pCurRule->GetName(),
+ pCurRule->Get( 0 ).GetPositionAndSpaceMode() );
+ aSetRule.SetSvxRule( aRule, GetShell().GetDoc());
+ aSetRule.SetAutoRule( sal_True );
+ // no start or continuation of a list - list style is only changed
+ GetShell().SetCurNumRule( aSetRule, false );
+ }
+ }
+ }
+ break;
+
+ default:
+ OSL_FAIL("wrong dispatcher");
+ return;
+ }
+ SwWrtShell& rWrtSh = GetShell();
+ SwTxtFmtColl* pColl = rWrtSh.GetCurTxtFmtColl();
+ if(pColl && pColl->IsAutoUpdateFmt())
+ {
+ rWrtSh.AutoUpdatePara(pColl, aSet);
+ }
+ else
+ rWrtSh.SetAttrSet( aSet );
+ rReq.Done();
+}
+
+void SwTextShell::ExecParaAttrArgs(SfxRequest &rReq)
+{
+ SwWrtShell &rSh = GetShell();
+ const SfxItemSet *pArgs = rReq.GetArgs();
+ const SfxPoolItem *pItem = 0;
+
+ sal_uInt16 nSlot = rReq.GetSlot();
+ if(pArgs)
+ pArgs->GetItemState(GetPool().GetWhich(nSlot), false, &pItem);
+ switch ( nSlot )
+ {
+ case FN_DROP_CHAR_STYLE_NAME:
+ if( pItem )
+ {
+ OUString sCharStyleName = ((const SfxStringItem*)pItem)->GetValue();
+ SfxItemSet aSet(GetPool(), RES_PARATR_DROP, RES_PARATR_DROP, 0L);
+ rSh.GetCurAttr(aSet);
+ SwFmtDrop aDropItem((const SwFmtDrop&)aSet.Get(RES_PARATR_DROP));
+ SwCharFmt* pFmt = 0;
+ if(!sCharStyleName.isEmpty())
+ pFmt = rSh.FindCharFmtByName( sCharStyleName );
+ aDropItem.SetCharFmt( pFmt );
+ aSet.Put(aDropItem);
+ rSh.SetAttrSet(aSet);
+ }
+ break;
+ case FN_FORMAT_DROPCAPS:
+ {
+ if(pItem)
+ {
+ rSh.SetAttrItem(*pItem);
+ rReq.Done();
+ }
+ else
+ {
+ SfxItemSet aSet(GetPool(), RES_PARATR_DROP, RES_PARATR_DROP,
+ HINT_END, HINT_END, 0);
+ rSh.GetCurAttr(aSet);
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+
+ SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( GetView().GetWindow(), aSet,
+ rSh.GetView().GetViewFrame()->GetFrame().GetFrameInterface(), DLG_SWDROPCAPS );
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ if (pDlg->Execute() == RET_OK)
+ {
+ rSh.StartAction();
+ rSh.StartUndo( UNDO_START );
+ if ( SFX_ITEM_SET == aSet.GetItemState(HINT_END,false,&pItem) )
+ {
+ if ( !((SfxStringItem*)pItem)->GetValue().isEmpty() )
+ rSh.ReplaceDropTxt(((SfxStringItem*)pItem)->GetValue());
+ }
+ rSh.SetAttrSet(*pDlg->GetOutputItemSet());
+ rSh.StartUndo( UNDO_END );
+ rSh.EndAction();
+ rReq.Done(*pDlg->GetOutputItemSet());
+ }
+ delete pDlg;
+ }
+ }
+ break;
+ case SID_ATTR_PARA_PAGEBREAK:
+ if(pItem)
+ {
+ rSh.SetAttrItem( *pItem );
+ rReq.Done();
+ }
+ break;
+ case SID_ATTR_PARA_MODEL:
+ {
+ if(pItem)
+ {
+ SfxItemSet aCoreSet( GetPool(),
+ RES_PAGEDESC, RES_PAGEDESC,
+ SID_ATTR_PARA_MODEL, SID_ATTR_PARA_MODEL, 0);
+ aCoreSet.Put(*pItem);
+ SfxToSwPageDescAttr( rSh, aCoreSet);
+ rSh.SetAttrSet(aCoreSet);
+ rReq.Done();
+ }
+ }
+ break;
+
+ default:
+ OSL_FAIL("wrong dispatcher");
+ return;
+ }
+}
+
+void SwTextShell::GetAttrState(SfxItemSet &rSet)
+{
+ SwWrtShell &rSh = GetShell();
+ SfxItemPool& rPool = GetPool();
+ SfxItemSet aCoreSet(rPool, aTxtFmtCollSetRange);
+ rSh.GetCurAttr(aCoreSet); // Request *all* text attributes from the core.
+
+ SfxWhichIter aIter(rSet);
+ sal_uInt16 nSlot = aIter.FirstWhich();
+ sal_Bool bFlag = sal_False;
+ SfxBoolItem aFlagItem;
+ const SfxPoolItem* pItem = 0;
+ int eAdjust = -1; // Illegal value to recognize DONTCARE.
+ SfxItemState eState = aCoreSet.GetItemState(RES_PARATR_ADJUST, false, &pItem);
+
+ if( SFX_ITEM_DEFAULT == eState )
+ pItem = &rPool.GetDefaultItem(RES_PARATR_ADJUST);
+ if( SFX_ITEM_DEFAULT <= eState )
+ eAdjust = (int)(( SvxAdjustItem* ) pItem)->GetAdjust();
+
+ short nEsc = 0;
+ eState = aCoreSet.GetItemState(RES_CHRATR_ESCAPEMENT, false, &pItem);
+ if( SFX_ITEM_DEFAULT == eState )
+ pItem = &rPool.GetDefaultItem(RES_CHRATR_ESCAPEMENT);
+ if( eState >= SFX_ITEM_DEFAULT )
+ nEsc = ((SvxEscapementItem* )pItem)->GetEsc();
+
+ sal_uInt16 nLineSpace = 0;
+ eState = aCoreSet.GetItemState(RES_PARATR_LINESPACING, false, &pItem);
+ if( SFX_ITEM_DEFAULT == eState )
+ pItem = &rPool.GetDefaultItem(RES_PARATR_LINESPACING);
+ if( SFX_ITEM_DEFAULT <= eState &&
+ ((SvxLineSpacingItem* )pItem)->GetLineSpaceRule() == SVX_LINE_SPACE_AUTO )
+ {
+ if(SVX_INTER_LINE_SPACE_OFF ==
+ ((SvxLineSpacingItem* )pItem)->GetInterLineSpaceRule())
+ nLineSpace = 100;
+ else
+ nLineSpace = ((SvxLineSpacingItem* )pItem)->GetPropLineSpace();
+ }
+
+ while (nSlot)
+ {
+ switch(nSlot)
+ {
+ case FN_SET_SUPER_SCRIPT:
+ bFlag = 0 < nEsc;
+ break;
+ case FN_SET_SUB_SCRIPT:
+ bFlag = 0 > nEsc;
+ break;
+ case SID_ATTR_PARA_ADJUST_LEFT:
+ if (eAdjust == -1)
+ {
+ rSet.InvalidateItem( nSlot );
+ nSlot = 0;
+ }
+ else
+ bFlag = SVX_ADJUST_LEFT == eAdjust;
+ break;
+ case SID_ATTR_PARA_ADJUST_RIGHT:
+ if (eAdjust == -1)
+ {
+ rSet.InvalidateItem( nSlot );
+ nSlot = 0;
+ }
+ else
+ bFlag = SVX_ADJUST_RIGHT == eAdjust;
+ break;
+ case SID_ATTR_PARA_ADJUST_CENTER:
+ if (eAdjust == -1)
+ {
+ rSet.InvalidateItem( nSlot );
+ nSlot = 0;
+ }
+ else
+ bFlag = SVX_ADJUST_CENTER == eAdjust;
+ break;
+ case SID_ATTR_PARA_ADJUST_BLOCK:
+ {
+ if (eAdjust == -1)
+ {
+ rSet.InvalidateItem( nSlot );
+ nSlot = 0;
+ }
+ else
+ {
+ bFlag = SVX_ADJUST_BLOCK == eAdjust;
+ sal_uInt16 nHtmlMode = GetHtmlMode(rSh.GetView().GetDocShell());
+ if((nHtmlMode & HTMLMODE_ON) && !(nHtmlMode & HTMLMODE_FULL_STYLES ))
+ {
+ rSet.DisableItem( nSlot );
+ nSlot = 0;
+ }
+ }
+ }
+ break;
+ case SID_ATTR_PARA_LINESPACE_10:
+ bFlag = nLineSpace == 100;
+ break;
+ case SID_ATTR_PARA_LINESPACE_15:
+ bFlag = nLineSpace == 150;
+ break;
+ case SID_ATTR_PARA_LINESPACE_20:
+ bFlag = nLineSpace == 200;
+ break;
+ case FN_GROW_FONT_SIZE:
+ case FN_SHRINK_FONT_SIZE:
+ {
+ SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONTHEIGHT,
+ *rSet.GetPool() );
+ aSetItem.GetItemSet().Put( aCoreSet, false );
+ const SvxFontHeightItem* pSize( static_cast<const SvxFontHeightItem*>(
+ aSetItem.GetItemOfScript( rSh.GetScriptType() ) ) );
+
+ if( !pSize )
+ rSet.DisableItem( nSlot );
+ else
+ {
+ sal_uInt32 nSize = pSize->GetHeight();
+ if( nSize == nFontMaxSz )
+ rSet.DisableItem( FN_GROW_FONT_SIZE );
+ else if( nSize == nFontInc )
+ rSet.DisableItem( FN_SHRINK_FONT_SIZE );
+ }
+ nSlot = 0;
+ }
+ break;
+ case FN_UNDERLINE_DOUBLE:
+ {
+ eState = aCoreSet.GetItemState(RES_CHRATR_UNDERLINE);
+ if( eState >= SFX_ITEM_DEFAULT )
+ {
+ FontUnderline eUnderline = ((const SvxUnderlineItem&)
+ aCoreSet.Get(RES_CHRATR_UNDERLINE)).GetLineStyle();
+ rSet.Put(SfxBoolItem(nSlot, eUnderline == UNDERLINE_DOUBLE));
+ }
+ else
+ rSet.InvalidateItem(nSlot);
+ nSlot = 0;
+ }
+ break;
+ case SID_ATTR_PARA_ADJUST:
+ if (eAdjust == -1)
+ rSet.InvalidateItem( nSlot );
+ else
+ rSet.Put(SvxAdjustItem((SvxAdjust)eAdjust, SID_ATTR_PARA_ADJUST ));
+ nSlot = 0;
+ break;
+ case SID_ATTR_PARA_LRSPACE:
+ {
+ eState = aCoreSet.GetItemState(RES_LR_SPACE);
+ if( eState >= SFX_ITEM_DEFAULT )
+ {
+ SvxLRSpaceItem aLR = ( (const SvxLRSpaceItem&) aCoreSet.Get( RES_LR_SPACE ) );
+ aLR.SetWhich(SID_ATTR_PARA_LRSPACE);
+ rSet.Put(aLR);
+ }
+ else
+ rSet.InvalidateItem(nSlot);
+ nSlot = 0;
+ }
+ break;
+
+ case SID_ATTR_PARA_LEFT_TO_RIGHT :
+ case SID_ATTR_PARA_RIGHT_TO_LEFT :
+ {
+ if ( !SW_MOD()->GetCTLOptions().IsCTLFontEnabled() )
+ {
+ rSet.DisableItem( nSlot );
+ nSlot = 0;
+ }
+ else
+ {
+ // is the item set?
+ sal_uInt16 nHtmlMode = GetHtmlMode(rSh.GetView().GetDocShell());
+ if((!(nHtmlMode & HTMLMODE_ON) || (0 != (nHtmlMode & HTMLMODE_SOME_STYLES))) &&
+ aCoreSet.GetItemState( RES_FRAMEDIR, false ) >= SFX_ITEM_DEFAULT)
+ {
+ SvxFrameDirection eFrmDir = (SvxFrameDirection)
+ ((const SvxFrameDirectionItem& )aCoreSet.Get(RES_FRAMEDIR)).GetValue();
+ if (FRMDIR_ENVIRONMENT == eFrmDir)
+ {
+ eFrmDir = rSh.IsInRightToLeftText() ?
+ FRMDIR_HORI_RIGHT_TOP : FRMDIR_HORI_LEFT_TOP;
+ }
+ bFlag = (SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot &&
+ FRMDIR_HORI_LEFT_TOP == eFrmDir) ||
+ (SID_ATTR_PARA_RIGHT_TO_LEFT == nSlot &&
+ FRMDIR_HORI_RIGHT_TOP == eFrmDir);
+ }
+ else
+ {
+ rSet.InvalidateItem(nSlot);
+ nSlot = 0;
+ }
+ }
+ }
+ break;
+
+ case SID_ATTR_CHAR_LANGUAGE:
+ case SID_ATTR_CHAR_KERNING:
+ case RES_PARATR_DROP:
+ {
+#if OSL_DEBUG_LEVEL > 1
+ const SfxPoolItem& rItem = aCoreSet.Get(GetPool().GetWhich(nSlot), sal_True);
+ rSet.Put(rItem);
+#else
+ rSet.Put(aCoreSet.Get( GetPool().GetWhich(nSlot), sal_True));
+#endif
+ nSlot = 0;
+ }
+ break;
+ case SID_ATTR_PARA_MODEL:
+ {
+ SfxItemSet aTemp(GetPool(),
+ RES_PAGEDESC,RES_PAGEDESC,
+ SID_ATTR_PARA_MODEL,SID_ATTR_PARA_MODEL,
+ 0L);
+ aTemp.Put(aCoreSet);
+ ::SwToSfxPageDescAttr(aTemp);
+ rSet.Put(aTemp.Get(SID_ATTR_PARA_MODEL));
+ nSlot = 0;
+ }
+ break;
+ case RES_TXTATR_INETFMT:
+ {
+ SfxItemSet aSet(GetPool(), RES_TXTATR_INETFMT, RES_TXTATR_INETFMT);
+ rSh.GetCurAttr(aSet);
+ const SfxPoolItem& rItem = aSet.Get(RES_TXTATR_INETFMT, sal_True);
+ rSet.Put(rItem);
+ nSlot = 0;
+ }
+ break;
+
+ default:
+ // Do nothing
+ nSlot = 0;
+ break;
+
+ }
+ if( nSlot )
+ {
+ aFlagItem.SetWhich( nSlot );
+ aFlagItem.SetValue( bFlag );
+ rSet.Put( aFlagItem );
+ }
+ nSlot = aIter.NextWhich();
+ }
+
+ rSet.Put(aCoreSet,false);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/shells/txtcrsr.cxx b/sw/source/core/uibase/shells/txtcrsr.cxx
new file mode 100644
index 000000000000..1c0b43e1181a
--- /dev/null
+++ b/sw/source/core/uibase/shells/txtcrsr.cxx
@@ -0,0 +1,376 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <sfx2/request.hxx>
+#include <svl/eitem.hxx>
+#include <basic/sbxvar.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/bindings.hxx>
+
+#include <view.hxx>
+#include <wrtsh.hxx>
+#include <textsh.hxx>
+#include <num.hxx>
+#include <edtwin.hxx>
+#include <crsskip.hxx>
+#include <doc.hxx>
+#include <docsh.hxx>
+
+#include <cmdid.h>
+#include <globals.h>
+#include <globals.hrc>
+
+#include <svx/svdouno.hxx>
+#include <svx/fmshell.hxx>
+#include <svx/sdrobjectfilter.hxx>
+
+#include <boost/scoped_ptr.hpp>
+
+using namespace ::com::sun::star;
+
+void SwTextShell::ExecBasicMove(SfxRequest &rReq)
+{
+ SwWrtShell &rSh = GetShell();
+ GetView().GetEditWin().FlushInBuffer();
+ const SfxItemSet *pArgs = rReq.GetArgs();
+ sal_Bool bSelect = sal_False;
+ sal_Int32 nCount = 1;
+ if(pArgs)
+ {
+ const SfxPoolItem *pItem;
+ if(SFX_ITEM_SET == pArgs->GetItemState(FN_PARAM_MOVE_COUNT, true, &pItem))
+ nCount = ((const SfxInt32Item *)pItem)->GetValue();
+ if(SFX_ITEM_SET == pArgs->GetItemState(FN_PARAM_MOVE_SELECTION, true, &pItem))
+ bSelect = ((const SfxBoolItem *)pItem)->GetValue();
+ }
+ switch(rReq.GetSlot())
+ {
+ case FN_CHAR_LEFT_SEL: rReq.SetSlot( FN_CHAR_LEFT ); bSelect = sal_True; break;
+ case FN_CHAR_RIGHT_SEL: rReq.SetSlot( FN_CHAR_RIGHT ); bSelect = sal_True; break;
+ case FN_LINE_UP_SEL: rReq.SetSlot( FN_LINE_UP ); bSelect = sal_True; break;
+ case FN_LINE_DOWN_SEL: rReq.SetSlot( FN_LINE_DOWN ); bSelect = sal_True; break;
+ }
+
+ uno::Reference< frame::XDispatchRecorder > xRecorder =
+ GetView().GetViewFrame()->GetBindings().GetRecorder();
+ if ( xRecorder.is() )
+ {
+ rReq.AppendItem( SfxInt32Item(FN_PARAM_MOVE_COUNT, nCount) );
+ rReq.AppendItem( SfxBoolItem(FN_PARAM_MOVE_SELECTION, bSelect) );
+ }
+ sal_uInt16 nSlot = rReq.GetSlot();
+ rReq.Done();
+ // Get EditWin before calling the move functions (shell change may occur!)
+ SwEditWin& rTmpEditWin = GetView().GetEditWin();
+ for( sal_Int32 i = 0; i < nCount; i++ )
+ {
+ switch(nSlot)
+ {
+ case FN_CHAR_LEFT: rSh.Left( CRSR_SKIP_CELLS, bSelect, 1, sal_False, sal_True ); break;
+ case FN_CHAR_RIGHT: rSh.Right( CRSR_SKIP_CELLS, bSelect, 1, sal_False, sal_True ); break;
+ case FN_LINE_UP: rSh.Up ( bSelect, 1 ); break;
+ case FN_LINE_DOWN: rSh.Down ( bSelect, 1 ); break;
+ default: OSL_FAIL("wrong Dispatcher"); return;
+ }
+ }
+
+ //#i42732# - notify the edit window that from now on we do not use the input language
+ rTmpEditWin.SetUseInputLanguage( sal_False );
+}
+
+void SwTextShell::ExecMove(SfxRequest &rReq)
+{
+ SwWrtShell &rSh = GetShell();
+ SwEditWin& rTmpEditWin = GetView().GetEditWin();
+ rTmpEditWin.FlushInBuffer();
+
+ sal_uInt16 nSlot = rReq.GetSlot();
+ sal_Bool bRet = sal_False;
+ switch ( nSlot )
+ {
+ case FN_START_OF_LINE_SEL:
+ case FN_START_OF_LINE: bRet = rSh.LeftMargin ( FN_START_OF_LINE_SEL == nSlot, sal_False );
+ break;
+
+ case FN_END_OF_LINE_SEL:
+ case FN_END_OF_LINE: bRet = rSh.RightMargin( FN_END_OF_LINE_SEL == nSlot, sal_False );
+ break;
+
+ case FN_START_OF_DOCUMENT_SEL:
+ case FN_START_OF_DOCUMENT: bRet = rSh.SttDoc ( FN_START_OF_DOCUMENT_SEL == nSlot);
+ break;
+
+ case FN_END_OF_DOCUMENT_SEL:
+ case FN_END_OF_DOCUMENT: bRet = rSh.EndDoc( FN_END_OF_DOCUMENT_SEL == nSlot );
+ break;
+
+ case FN_SELECT_WORD: bRet = rSh.SelNearestWrd(); break;
+
+ case SID_SELECTALL: bRet = 0 != rSh.SelAll(); break;
+ default: OSL_FAIL("wrong dispatcher"); return;
+ }
+
+ if ( bRet )
+ rReq.Done();
+ else
+ rReq.Ignore();
+
+ //#i42732# - notify the edit window that from now on we do not use the input language
+ rTmpEditWin.SetUseInputLanguage( sal_False );
+}
+
+void SwTextShell::ExecMovePage(SfxRequest &rReq)
+{
+ SwWrtShell &rSh = GetShell();
+ GetView().GetEditWin().FlushInBuffer();
+
+ sal_uInt16 nSlot = rReq.GetSlot();
+ switch( nSlot )
+ {
+ case FN_START_OF_NEXT_PAGE_SEL :
+ case FN_START_OF_NEXT_PAGE: rSh.SttNxtPg( FN_START_OF_NEXT_PAGE_SEL == nSlot ); break;
+
+ case FN_END_OF_NEXT_PAGE_SEL:
+ case FN_END_OF_NEXT_PAGE: rSh.EndNxtPg( FN_END_OF_NEXT_PAGE_SEL == nSlot ); break;
+
+ case FN_START_OF_PREV_PAGE_SEL:
+ case FN_START_OF_PREV_PAGE: rSh.SttPrvPg( FN_START_OF_PREV_PAGE_SEL == nSlot ); break;
+
+ case FN_END_OF_PREV_PAGE_SEL:
+ case FN_END_OF_PREV_PAGE: rSh.EndPrvPg( FN_END_OF_PREV_PAGE_SEL == nSlot ); break;
+
+ case FN_START_OF_PAGE_SEL:
+ case FN_START_OF_PAGE: rSh.SttPg ( FN_START_OF_PAGE_SEL == nSlot ); break;
+
+ case FN_END_OF_PAGE_SEL:
+ case FN_END_OF_PAGE: rSh.EndPg ( FN_END_OF_PAGE_SEL == nSlot ); break;
+ default: OSL_FAIL("wrong dispatcher"); return;
+ }
+ rReq.Done();
+}
+
+void SwTextShell::ExecMoveCol(SfxRequest &rReq)
+{
+ SwWrtShell &rSh = GetShell();
+ switch ( rReq.GetSlot() )
+ {
+ case FN_START_OF_COLUMN: rSh.StartOfColumn ( sal_False ); break;
+ case FN_END_OF_COLUMN: rSh.EndOfColumn ( sal_False ); break;
+ case FN_START_OF_NEXT_COLUMN: rSh.StartOfNextColumn( sal_False ) ; break;
+ case FN_END_OF_NEXT_COLUMN: rSh.EndOfNextColumn ( sal_False ); break;
+ case FN_START_OF_PREV_COLUMN: rSh.StartOfPrevColumn( sal_False ); break;
+ case FN_END_OF_PREV_COLUMN: rSh.EndOfPrevColumn ( sal_False ); break;
+ default: OSL_FAIL("wrong dispatcher"); return;
+ }
+ rReq.Done();
+}
+
+void SwTextShell::ExecMoveLingu(SfxRequest &rReq)
+{
+ SwWrtShell &rSh = GetShell();
+ GetView().GetEditWin().FlushInBuffer();
+
+ sal_uInt16 nSlot = rReq.GetSlot();
+ switch ( nSlot )
+ {
+ case FN_NEXT_WORD_SEL:
+ case FN_NEXT_WORD: rSh.NxtWrd( FN_NEXT_WORD_SEL == nSlot );
+ break;
+
+ case FN_START_OF_PARA_SEL:
+ case FN_START_OF_PARA: rSh.SttPara( FN_START_OF_PARA_SEL == nSlot );
+ break;
+
+ case FN_END_OF_PARA_SEL:
+ case FN_END_OF_PARA: rSh.EndPara( FN_END_OF_PARA_SEL == nSlot );
+ break;
+
+ case FN_PREV_WORD_SEL:
+ case FN_PREV_WORD: rSh.PrvWrd( FN_PREV_WORD_SEL == nSlot );
+ break;
+
+ case FN_NEXT_SENT_SEL:
+ case FN_NEXT_SENT: rSh.FwdSentence( FN_NEXT_SENT_SEL == nSlot );
+ break;
+
+ case FN_PREV_SENT_SEL:
+ case FN_PREV_SENT: rSh.BwdSentence( FN_PREV_SENT_SEL == nSlot );
+ break;
+
+ case FN_NEXT_PARA: rSh.FwdPara ( sal_False );
+ break;
+
+ case FN_PREV_PARA: rSh.BwdPara ( sal_False );
+ break;
+ default: OSL_FAIL("wrong dispatcher"); return;
+ }
+ rReq.Done();
+}
+
+void SwTextShell::ExecMoveMisc(SfxRequest &rReq)
+{
+ SwWrtShell &rSh = GetShell();
+ sal_uInt16 nSlot = rReq.GetSlot();
+ sal_Bool bSetRetVal = sal_True, bRet = sal_True;
+ switch ( nSlot )
+ {
+ case SID_FM_TOGGLECONTROLFOCUS:
+ {
+ const SwDoc* pDoc = rSh.GetDoc();
+ const SwDocShell* pDocShell = pDoc ? pDoc->GetDocShell() : NULL;
+ const SwView* pView = pDocShell ? pDocShell->GetView() : NULL;
+ const FmFormShell* pFormShell = pView ? pView->GetFormShell() : NULL;
+ SdrView* pDrawView = pView ? pView->GetDrawView() : NULL;
+ Window* pWindow = pView ? pView->GetWrtShell().GetWin() : NULL;
+
+ OSL_ENSURE( pFormShell && pDrawView && pWindow, "SwXTextView::ExecMoveMisc: no chance!" );
+ if ( !pFormShell || !pDrawView || !pWindow )
+ break;
+
+ boost::scoped_ptr< ::svx::ISdrObjectFilter > pFilter( pFormShell->CreateFocusableControlFilter(
+ *pDrawView, *pWindow ) );
+ if ( !pFilter.get() )
+ break;
+
+ const SdrObject* pNearestControl = rSh.GetBestObject( sal_True, GOTOOBJ_DRAW_CONTROL, sal_False, pFilter.get() );
+ if ( !pNearestControl )
+ break;
+
+ const SdrUnoObj* pUnoObject = dynamic_cast< const SdrUnoObj* >( pNearestControl );
+ OSL_ENSURE( pUnoObject, "SwTextShell::ExecMoveMisc: GetBestObject returned nonsense!" );
+ if ( !pUnoObject )
+ break;
+
+ pFormShell->ToggleControlFocus( *pUnoObject, *pDrawView, *pWindow );
+ }
+ break;
+ case FN_CNTNT_TO_NEXT_FRAME:
+ bRet = rSh.GotoObj(sal_True, GOTOOBJ_GOTO_ANY);
+ if(bRet)
+ {
+ rSh.HideCrsr();
+ rSh.EnterSelFrmMode();
+ }
+ break;
+ case FN_NEXT_FOOTNOTE:
+ rSh.MoveCrsr();
+ bRet = rSh.GotoNextFtnAnchor();
+ break;
+ case FN_PREV_FOOTNOTE:
+ rSh.MoveCrsr();
+ bRet = rSh.GotoPrevFtnAnchor();
+ break;
+ case FN_TO_HEADER:
+ rSh.MoveCrsr();
+ if ( FRMTYPE_HEADER & rSh.GetFrmType(0,sal_False) )
+ rSh.SttPg();
+ else
+ {
+ bool bMoved = rSh.GotoHeaderTxt();
+ if ( !bMoved )
+ rSh.SttPg();
+ }
+ bSetRetVal = sal_False;
+ break;
+ case FN_TO_FOOTER:
+ rSh.MoveCrsr();
+ if ( FRMTYPE_FOOTER & rSh.GetFrmType(0,sal_False) )
+ rSh.EndPg();
+ else
+ {
+ bool bMoved = rSh.GotoFooterTxt();
+ if ( !bMoved )
+ rSh.EndPg();
+ }
+ bSetRetVal = sal_False;
+ break;
+ case FN_FOOTNOTE_TO_ANCHOR:
+ rSh.MoveCrsr();
+ if ( FRMTYPE_FOOTNOTE & rSh.GetFrmType(0,sal_False) )
+ rSh.GotoFtnAnchor();
+ else
+ rSh.GotoFtnTxt();
+ bSetRetVal = sal_False;
+ break;
+ case FN_TO_FOOTNOTE_AREA :
+ rSh.GotoFtnTxt();
+ break;
+ case FN_PREV_TABLE:
+ bRet = rSh.MoveTable( fnTablePrev, fnTableStart);
+ break;
+ case FN_NEXT_TABLE:
+ bRet = rSh.MoveTable(fnTableNext, fnTableStart);
+ break;
+ case FN_GOTO_NEXT_REGION :
+ bRet = rSh.MoveRegion(fnRegionNext, fnRegionStart);
+ break;
+ case FN_GOTO_PREV_REGION :
+ bRet = rSh.MoveRegion(fnRegionPrev, fnRegionStart);
+ break;
+
+ case FN_NEXT_TOXMARK:
+ bRet = rSh.GotoNxtPrvTOXMark( sal_True );
+ break;
+ case FN_PREV_TOXMARK:
+ bRet = rSh.GotoNxtPrvTOXMark( sal_False );
+ break;
+ case FN_NEXT_TBLFML:
+ bRet = rSh.GotoNxtPrvTblFormula( sal_True, sal_False );
+ break;
+ case FN_PREV_TBLFML:
+ bRet = rSh.GotoNxtPrvTblFormula( sal_False, sal_False );
+ break;
+ case FN_NEXT_TBLFML_ERR:
+ bRet = rSh.GotoNxtPrvTblFormula( sal_True, sal_True );
+ break;
+ case FN_PREV_TBLFML_ERR:
+ bRet = rSh.GotoNxtPrvTblFormula( sal_False, sal_True );
+ break;
+
+ default:
+ OSL_FAIL("wrong dispatcher");
+ return;
+ }
+
+ if( bSetRetVal )
+ rReq.SetReturnValue(SfxBoolItem( nSlot, bRet ));
+ rReq.Done();
+
+ sal_Bool bInHeader = sal_True;
+ if ( rSh.IsInHeaderFooter( &bInHeader ) )
+ {
+ if ( !bInHeader )
+ {
+ rSh.SetShowHeaderFooterSeparator( Footer, true );
+ rSh.SetShowHeaderFooterSeparator( Header, false );
+ }
+ else
+ {
+ rSh.SetShowHeaderFooterSeparator( Header, true );
+ rSh.SetShowHeaderFooterSeparator( Footer, false );
+ }
+
+ // Force repaint
+ rSh.GetWin()->Invalidate();
+ }
+ if ( rSh.IsInHeaderFooter() != rSh.IsHeaderFooterEdit() )
+ rSh.ToggleHeaderFooterEdit();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/shells/txtnum.cxx b/sw/source/core/uibase/shells/txtnum.cxx
new file mode 100644
index 000000000000..bffbfc2c3583
--- /dev/null
+++ b/sw/source/core/uibase/shells/txtnum.cxx
@@ -0,0 +1,410 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <hintids.hxx>
+#include <vcl/msgbox.hxx>
+#include <sfx2/request.hxx>
+#include <svl/eitem.hxx>
+#include <svl/stritem.hxx>
+#include <editeng/numitem.hxx>
+#include <editeng/brushitem.hxx>
+#include <numrule.hxx>
+
+#include "cmdid.h"
+#include "wrtsh.hxx"
+#include "view.hxx"
+#include "viewopt.hxx"
+#include "wdocsh.hxx"
+#include "textsh.hxx"
+#include "uiitems.hxx"
+#include "swabstdlg.hxx"
+#include <globals.hrc>
+#include <sfx2/tabdlg.hxx>
+#include <svx/nbdtmg.hxx>
+#include <svx/nbdtmgfact.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/bindings.hxx>
+using namespace svx::sidebar;
+
+void SwTextShell::ExecEnterNum(SfxRequest &rReq)
+{
+ //Because the record before any shell exchange.
+ switch(rReq.GetSlot())
+ {
+ case FN_NUM_NUMBERING_ON:
+ {
+ GetShell().StartAllAction();
+ SFX_REQUEST_ARG( rReq, pItem, SfxBoolItem, FN_PARAM_1 , false );
+ sal_Bool bMode = !GetShell().SelectionHasNumber(); // #i29560#
+ if ( pItem )
+ bMode = pItem->GetValue();
+ else
+ rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bMode ) );
+
+ if ( bMode != (GetShell().SelectionHasNumber()) ) // #i29560#
+ {
+ rReq.Done();
+ if( bMode )
+ GetShell().NumOn();
+ else
+ GetShell().NumOrBulletOff(); // #i29560#
+ }
+ sal_Bool bNewResult = GetShell().SelectionHasNumber();
+ if (bNewResult!=bMode) {
+ SfxBindings& rBindings = GetView().GetViewFrame()->GetBindings();
+ SfxBoolItem aItem(FN_NUM_NUMBERING_ON,!bNewResult);
+ rBindings.SetState(aItem);
+ SfxBoolItem aNewItem(FN_NUM_NUMBERING_ON,bNewResult);
+ rBindings.SetState(aNewItem);
+ }
+ GetShell().EndAllAction();
+ }
+ break;
+ case FN_NUM_BULLET_ON:
+ {
+ GetShell().StartAllAction();
+ SFX_REQUEST_ARG( rReq, pItem, SfxBoolItem, FN_PARAM_1 , false );
+ sal_Bool bMode = !GetShell().SelectionHasBullet(); // #i29560#
+ if ( pItem )
+ bMode = pItem->GetValue();
+ else
+ rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bMode ) );
+
+ if ( bMode != (GetShell().SelectionHasBullet()) ) // #i29560#
+ {
+ rReq.Done();
+ if( bMode )
+ GetShell().BulletOn();
+ else
+ GetShell().NumOrBulletOff(); // #i29560#
+ }
+ sal_Bool bNewResult = GetShell().SelectionHasBullet();
+ if (bNewResult!=bMode) {
+ SfxBindings& rBindings = GetView().GetViewFrame()->GetBindings();
+ SfxBoolItem aItem(FN_NUM_BULLET_ON,!bNewResult);
+ rBindings.SetState(aItem);
+ SfxBoolItem aNewItem(FN_NUM_BULLET_ON,bNewResult);
+ rBindings.SetState(aNewItem);
+ }
+ GetShell().EndAllAction();
+ }
+ break;
+ case FN_NUMBER_BULLETS:
+ case SID_OUTLINE_BULLET:
+ {
+ SfxItemSet aSet(GetPool(),
+ SID_HTML_MODE, SID_HTML_MODE,
+ SID_ATTR_NUMBERING_RULE, SID_PARAM_CUR_NUM_LEVEL,
+ 0 );
+ SwDocShell* pDocSh = GetView().GetDocShell();
+ bool bHtml = 0 != PTR_CAST(SwWebDocShell, pDocSh);
+ const SwNumRule* pCurRule = GetShell().GetCurNumRule();
+ if( pCurRule )
+ {
+ SvxNumRule aRule = pCurRule->MakeSvxNumRule();
+
+ //convert type of linked bitmaps from SVX_NUM_BITMAP to (SVX_NUM_BITMAP|LINK_TOKEN)
+ for(sal_uInt16 i = 0; i < aRule.GetLevelCount(); i++)
+ {
+ SvxNumberFormat aFmt(aRule.GetLevel(i));
+ if(SVX_NUM_BITMAP == aFmt.GetNumberingType())
+ {
+ const SvxBrushItem* pBrush = aFmt.GetBrush();
+ if(pBrush && !pBrush->GetGraphicLink().isEmpty())
+ aFmt.SetNumberingType(SvxExtNumType(SVX_NUM_BITMAP|LINK_TOKEN));
+ aRule.SetLevel(i, aFmt, aRule.Get(i) != 0);
+ }
+ }
+ if(bHtml)
+ aRule.SetFeatureFlag(NUM_ENABLE_EMBEDDED_BMP, false);
+
+ aSet.Put(SvxNumBulletItem(aRule));
+ OSL_ENSURE( GetShell().GetNumLevel() < MAXLEVEL,
+ "<SwTextShell::ExecEnterNum()> - numbered node without valid list level. Serious defect -> please inform OD." );
+ sal_uInt16 nLevel = GetShell().GetNumLevel();
+ if( nLevel < MAXLEVEL )
+ {
+ nLevel = 1<<nLevel;
+ aSet.Put( SfxUInt16Item( SID_PARAM_CUR_NUM_LEVEL, nLevel ));
+ }
+ }
+ else
+ {
+ SwNumRule aRule( GetShell().GetUniqueNumRuleName(),
+ // #i89178#
+ numfunc::GetDefaultPositionAndSpaceMode() );
+ SvxNumRule aSvxRule = aRule.MakeSvxNumRule();
+ const bool bRightToLeft = GetShell().IsInRightToLeftText( 0 );
+
+ if( bHtml || bRightToLeft )
+ {
+ for( sal_uInt8 n = 0; n < MAXLEVEL; ++n )
+ {
+ SvxNumberFormat aFmt( aSvxRule.GetLevel( n ) );
+ if ( n && bHtml )
+ {
+ // 1/2" for HTML
+ aFmt.SetLSpace(720);
+ aFmt.SetAbsLSpace(n * 720);
+ }
+ // #i38904# Default alignment for
+ // numbering/bullet should be rtl in rtl paragraph:
+ if ( bRightToLeft )
+ {
+ aFmt.SetNumAdjust( SVX_ADJUST_RIGHT );
+ }
+ aSvxRule.SetLevel( n, aFmt, false );
+ }
+ aSvxRule.SetFeatureFlag(NUM_ENABLE_EMBEDDED_BMP, false);
+ }
+ aSet.Put(SvxNumBulletItem(aSvxRule));
+ }
+
+ aSet.Put( SfxBoolItem( SID_PARAM_NUM_PRESET,false ));
+
+ // Before the dialogue of the HTML mode will be dropped at the Docshell.
+ pDocSh->PutItem(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(pDocSh)));
+
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "Dialogdiet fail!");
+ SfxAbstractTabDialog* pDlg = pFact->CreateSwTabDialog( DLG_SVXTEST_NUM_BULLET,
+ GetView().GetWindow(), &aSet, GetShell());
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ sal_uInt16 nRet = pDlg->Execute();
+ const SfxPoolItem* pItem;
+ if( RET_OK == nRet )
+ {
+ if( SFX_ITEM_SET == pDlg->GetOutputItemSet()->GetItemState( SID_ATTR_NUMBERING_RULE, false, &pItem ))
+ {
+ rReq.AppendItem(*pItem);
+ rReq.Done();
+ SvxNumRule* pSetRule = ((SvxNumBulletItem*)pItem)->GetNumRule();
+ pSetRule->UnLinkGraphics();
+ SwNumRule aSetRule( pCurRule
+ ? pCurRule->GetName()
+ : GetShell().GetUniqueNumRuleName(),
+ // #i89178#
+ numfunc::GetDefaultPositionAndSpaceMode() );
+ aSetRule.SetSvxRule( *pSetRule, GetShell().GetDoc());
+ aSetRule.SetAutoRule( sal_True );
+ // No start of new list, if an existing list style is edited.
+ // Otherwise start a new list.
+ const bool bCreateList = (pCurRule == 0);
+ GetShell().SetCurNumRule( aSetRule, bCreateList );
+ }
+ // If the Dialog was leaved with OK but nothing was chosen then the
+ // numbering must be at least activated, if it is not already.
+ else if( !pCurRule && SFX_ITEM_SET == aSet.GetItemState( SID_ATTR_NUMBERING_RULE, false, &pItem ))
+ {
+ rReq.AppendItem( *pItem );
+ rReq.Done();
+ SvxNumRule* pSetRule = ((SvxNumBulletItem*)pItem)->GetNumRule();
+ SwNumRule aSetRule( GetShell().GetUniqueNumRuleName(),
+ // #i89178#
+ numfunc::GetDefaultPositionAndSpaceMode() );
+ aSetRule.SetSvxRule(*pSetRule, GetShell().GetDoc());
+ aSetRule.SetAutoRule( sal_True );
+ // start new list
+ GetShell().SetCurNumRule( aSetRule, true );
+ }
+ }
+ else if(RET_USER == nRet)
+ GetShell().DelNumRules();
+
+ delete pDlg;
+ }
+ break;
+ default:
+ OSL_FAIL("wrong dispatcher");
+ return;
+ }
+}
+
+void SwTextShell::ExecSetNumber(SfxRequest &rReq)
+{
+ SwNumRule aRule( GetShell().GetUniqueNumRuleName(),
+ // #i89178#
+ numfunc::GetDefaultPositionAndSpaceMode() );
+
+ SvxNumRule aSvxRule = aRule.MakeSvxNumRule();
+ const bool bRightToLeft = GetShell().IsInRightToLeftText( 0 );
+
+ if( bRightToLeft )
+ {
+ for( sal_uInt8 n = 0; n < MAXLEVEL; ++n )
+ {
+ SvxNumberFormat aFmt( aSvxRule.GetLevel( n ) );
+ /* if ( n && bHtml )
+ {
+ // 1/2" for HTML
+ aFmt.SetLSpace(720);
+ aFmt.SetAbsLSpace(n * 720);
+ }*/
+ // #i38904# Default alignment for
+ // numbering/bullet should be rtl in rtl paragraph:
+ if ( bRightToLeft )
+ {
+ aFmt.SetNumAdjust( SVX_ADJUST_RIGHT );
+ }
+ aSvxRule.SetLevel( n, aFmt, false );
+ }
+ aSvxRule.SetFeatureFlag(NUM_ENABLE_EMBEDDED_BMP, false);
+ }
+
+ const SwNumRule* pCurRule = GetShell().GetCurNumRule();
+ sal_uInt16 nActNumLvl = (sal_uInt16)0xFFFF;
+ if( pCurRule )
+ {
+ sal_uInt16 nLevel = GetShell().GetNumLevel();
+ if( nLevel < MAXLEVEL )
+ {
+ nActNumLvl = 1<<nLevel;
+ }
+
+ aSvxRule = pCurRule->MakeSvxNumRule();
+
+ //convert type of linked bitmaps from SVX_NUM_BITMAP to (SVX_NUM_BITMAP|LINK_TOKEN)
+ for(sal_uInt16 i = 0; i < aSvxRule.GetLevelCount(); i++)
+ {
+ SvxNumberFormat aFmt(aSvxRule.GetLevel(i));
+ if(SVX_NUM_BITMAP == aFmt.GetNumberingType())
+ {
+ const SvxBrushItem* pBrush = aFmt.GetBrush();
+ if( pBrush && !pBrush->GetGraphicLink().isEmpty() )
+ aFmt.SetNumberingType(SvxExtNumType(SVX_NUM_BITMAP|LINK_TOKEN));
+ aSvxRule.SetLevel(i, aFmt, aSvxRule.Get(i) != 0);
+ }
+ }
+ }
+
+ switch(rReq.GetSlot())
+ {
+ case FN_SVX_SET_NUMBER:
+ {
+ SFX_REQUEST_ARG( rReq, pItem, SfxUInt16Item, FN_SVX_SET_NUMBER , false );
+ if (pItem)
+ {
+ sal_uInt16 nIdx = pItem->GetValue();
+ if (nIdx==DEFAULT_NONE) {
+ GetShell().DelNumRules();
+ break;
+ }
+ --nIdx;
+
+ NBOTypeMgrBase* pNumbering = NBOutlineTypeMgrFact::CreateInstance(eNBOType::NUMBERING);
+ if ( pNumbering )
+ {
+ SwNumRule aTmpRule( GetShell().GetUniqueNumRuleName(),
+ numfunc::GetDefaultPositionAndSpaceMode() );
+
+ SvxNumRule aTempRule = aTmpRule.MakeSvxNumRule();
+ // set unit attribute to NB Manager
+ SfxItemSet aSet(GetPool(),
+ SID_ATTR_NUMBERING_RULE, SID_PARAM_CUR_NUM_LEVEL,
+ 0 );
+ aSet.Put(SvxNumBulletItem(aTempRule));
+ pNumbering->SetItems(&aSet);
+ pNumbering->ApplyNumRule(aTempRule,nIdx,nActNumLvl);
+
+ sal_uInt16 nMask = 1;
+ for(sal_uInt16 i = 0; i < aSvxRule.GetLevelCount(); i++)
+ {
+ if(nActNumLvl & nMask)
+ {
+ SvxNumberFormat aFmt(aTempRule.GetLevel(i));
+ aSvxRule.SetLevel(i, aFmt);
+ }
+ nMask <<= 1 ;
+ }
+
+ aSvxRule.UnLinkGraphics();
+ SwNumRule aSetRule( pCurRule
+ ? pCurRule->GetName()
+ : GetShell().GetUniqueNumRuleName(),
+ numfunc::GetDefaultPositionAndSpaceMode() );
+ aSetRule.SetSvxRule( aSvxRule, GetShell().GetDoc());
+
+ aSetRule.SetAutoRule( sal_True );
+ const bool bCreateList = (pCurRule == 0);
+ GetShell().SetCurNumRule( aSetRule, bCreateList );
+ }
+ //End
+ }
+ break;
+ }
+ case FN_SVX_SET_BULLET:
+ {
+ SFX_REQUEST_ARG( rReq, pItem, SfxUInt16Item, FN_SVX_SET_BULLET , false );
+ if (pItem)
+ {
+ sal_uInt16 nIdx = pItem->GetValue();
+ if (nIdx==DEFAULT_NONE) {
+ GetShell().DelNumRules();
+ break;
+ }
+ nIdx--;
+
+ NBOTypeMgrBase* pBullets = NBOutlineTypeMgrFact::CreateInstance(eNBOType::MIXBULLETS);
+ if ( pBullets )
+ {
+ SwNumRule aTmpRule( GetShell().GetUniqueNumRuleName(),
+ numfunc::GetDefaultPositionAndSpaceMode() );
+
+ SvxNumRule aTempRule = aTmpRule.MakeSvxNumRule();
+ // set unit attribute to NB Manager
+ SfxItemSet aSet(GetPool(),
+ SID_ATTR_NUMBERING_RULE, SID_PARAM_CUR_NUM_LEVEL,
+ 0 );
+ aSet.Put(SvxNumBulletItem(aTempRule));
+ pBullets->SetItems(&aSet);
+
+ //SvxNumRule aTempRule( 0, 10, false );
+ pBullets->ApplyNumRule(aTempRule,nIdx,nActNumLvl);
+ sal_uInt16 nMask = 1;
+ for(sal_uInt16 i = 0; i < aSvxRule.GetLevelCount(); i++)
+ {
+ if(nActNumLvl & nMask)
+ {
+ SvxNumberFormat aFmt(aTempRule.GetLevel(i));
+ aSvxRule.SetLevel(i, aFmt);
+ }
+ nMask <<= 1;
+ }
+ aSvxRule.UnLinkGraphics();
+
+ SwNumRule aSetRule( pCurRule
+ ? pCurRule->GetName()
+ : GetShell().GetUniqueNumRuleName(),
+ numfunc::GetDefaultPositionAndSpaceMode() );
+
+ aSetRule.SetSvxRule( aSvxRule, GetShell().GetDoc());
+
+ aSetRule.SetAutoRule( sal_True );
+ const bool bCreateList = (pCurRule == 0);
+ GetShell().SetCurNumRule( aSetRule, bCreateList );
+ }
+ //End
+ }
+
+ }
+ break;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/sidebar/PageColumnControl.cxx b/sw/source/core/uibase/sidebar/PageColumnControl.cxx
new file mode 100644
index 000000000000..f2a5f3857bee
--- /dev/null
+++ b/sw/source/core/uibase/sidebar/PageColumnControl.cxx
@@ -0,0 +1,110 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "PageColumnControl.hxx"
+#include "PagePropertyPanel.hxx"
+#include "PagePropertyPanel.hrc"
+
+#include <cmdid.h>
+#include <swtypes.hxx>
+
+#include <svx/sidebar/ValueSetWithTextControl.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#include <vcl/settings.hxx>
+
+namespace sw { namespace sidebar {
+
+PageColumnControl::PageColumnControl(
+ Window* pParent,
+ PagePropertyPanel& rPanel,
+ const sal_uInt16 nColumnType,
+ const bool bLandscape )
+ : ::svx::sidebar::PopupControl( pParent, SW_RES(RID_POPUP_SWPAGE_COLUMN) )
+ , mpColumnValueSet( new ::svx::sidebar::ValueSetWithTextControl( ::svx::sidebar::ValueSetWithTextControl::IMAGE_TEXT, this, SW_RES(VS_COLUMN) ) )
+ , maMoreButton( this, SW_RES(CB_COLUMN_MORE) )
+ , mnColumnType( nColumnType )
+ , mrPagePropPanel(rPanel)
+{
+ mpColumnValueSet->SetStyle( mpColumnValueSet->GetStyle() | WB_3DLOOK | WB_NO_DIRECTSELECT );
+ mpColumnValueSet->SetColor(GetSettings().GetStyleSettings().GetMenuColor());
+
+ if ( bLandscape )
+ {
+ mpColumnValueSet->AddItem(Image(SW_RES(IMG_ONE_L)), 0, SW_RES(STR_ONE), 0 );
+ mpColumnValueSet->AddItem(Image(SW_RES(IMG_TWO_L)), 0, SW_RES(STR_TWO), 0 );
+ mpColumnValueSet->AddItem(Image(SW_RES(IMG_THREE_L)), 0, SW_RES(STR_THREE), 0 );
+ mpColumnValueSet->AddItem(Image(SW_RES(IMG_LEFT_L)), 0, SW_RES(STR_LEFT), 0 );
+ mpColumnValueSet->AddItem(Image(SW_RES(IMG_RIGHT_L)), 0, SW_RES(STR_RIGHT), 0 );
+ }
+ else
+ {
+ mpColumnValueSet->AddItem(Image(SW_RES(IMG_ONE)), 0, SW_RES(STR_ONE), 0 );
+ mpColumnValueSet->AddItem(Image(SW_RES(IMG_TWO)), 0, SW_RES(STR_TWO), 0 );
+ mpColumnValueSet->AddItem(Image(SW_RES(IMG_THREE)), 0, SW_RES(STR_THREE), 0 );
+ mpColumnValueSet->AddItem(Image(SW_RES(IMG_LEFT)), 0, SW_RES(STR_LEFT), 0 );
+ mpColumnValueSet->AddItem(Image(SW_RES(IMG_RIGHT)), 0, SW_RES(STR_RIGHT), 0 );
+ }
+
+ mpColumnValueSet->SetNoSelection();
+ mpColumnValueSet->SetSelectHdl( LINK(this, PageColumnControl,ImplColumnHdl ) );
+ mpColumnValueSet->Show();
+ mpColumnValueSet->SelectItem( mnColumnType );
+ mpColumnValueSet->Format();
+ mpColumnValueSet->StartSelection();
+
+ maMoreButton.SetClickHdl( LINK( this, PageColumnControl, MoreButtonClickHdl_Impl ) );
+ maMoreButton.GrabFocus();
+
+ FreeResource();
+}
+
+PageColumnControl::~PageColumnControl(void)
+{
+ delete mpColumnValueSet;
+}
+
+IMPL_LINK(PageColumnControl, ImplColumnHdl, void *, pControl)
+{
+ mpColumnValueSet->SetNoSelection();
+ if ( pControl == mpColumnValueSet )
+ {
+ const sal_uInt32 nColumnType = mpColumnValueSet->GetSelectItemId();
+ if ( nColumnType != mnColumnType )
+ {
+ mnColumnType = nColumnType;
+ mrPagePropPanel.ExecuteColumnChange( mnColumnType );
+ }
+ }
+
+ mrPagePropPanel.ClosePageColumnPopup();
+ return 0;
+}
+
+IMPL_LINK(PageColumnControl, MoreButtonClickHdl_Impl, void *, EMPTYARG)
+{
+ mrPagePropPanel.GetBindings()->GetDispatcher()->Execute( FN_FORMAT_PAGE_COLUMN_DLG, SFX_CALLMODE_ASYNCHRON );
+
+ mrPagePropPanel.ClosePageColumnPopup();
+ return 0;
+}
+
+} } // end of namespace sw::sidebar
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/sidebar/PageColumnControl.hxx b/sw/source/core/uibase/sidebar/PageColumnControl.hxx
new file mode 100644
index 000000000000..875bea370fd7
--- /dev/null
+++ b/sw/source/core/uibase/sidebar/PageColumnControl.hxx
@@ -0,0 +1,65 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_SIDEBAR_PAGECOLUMNCONTROL_HXX
+#define INCLUDED_SW_SOURCE_UI_SIDEBAR_PAGECOLUMNCONTROL_HXX
+
+#include <svx/sidebar/PopupControl.hxx>
+
+#include <vcl/image.hxx>
+#include <vcl/button.hxx>
+
+#include <vector>
+
+namespace svx { namespace sidebar {
+ class ValueSetWithTextControl;
+} }
+
+namespace sw { namespace sidebar {
+
+class PagePropertyPanel;
+
+class PageColumnControl
+ : public ::svx::sidebar::PopupControl
+{
+public:
+ PageColumnControl(
+ Window* pParent,
+ PagePropertyPanel& rPanel,
+ const sal_uInt16 nColumnType,
+ const bool bLandscape );
+
+ ~PageColumnControl(void);
+
+private:
+ ::svx::sidebar::ValueSetWithTextControl* mpColumnValueSet;
+ PushButton maMoreButton;
+
+ sal_uInt16 mnColumnType;
+
+ PagePropertyPanel& mrPagePropPanel;
+
+ DECL_LINK(ImplColumnHdl, void*);
+ DECL_LINK(MoreButtonClickHdl_Impl, void*);
+};
+
+} } // end of namespace sw::sidebar
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/sidebar/PageMarginControl.cxx b/sw/source/core/uibase/sidebar/PageMarginControl.cxx
new file mode 100644
index 000000000000..dd3d031c8dff
--- /dev/null
+++ b/sw/source/core/uibase/sidebar/PageMarginControl.cxx
@@ -0,0 +1,518 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <sal/config.h>
+
+#include <cstdlib>
+
+#include "PageMarginControl.hxx"
+#include "PagePropertyPanel.hxx"
+#include "PagePropertyPanel.hrc"
+
+#include <swtypes.hxx>
+
+#include <svx/sidebar/ValueSetWithTextControl.hxx>
+#include <vcl/settings.hxx>
+
+#define SWPAGE_LEFT_GVALUE "Sw_Page_Left"
+#define SWPAGE_RIGHT_GVALUE "Sw_Page_Right"
+#define SWPAGE_TOP_GVALUE "Sw_Page_Top"
+#define SWPAGE_DOWN_GVALUE "Sw_Page_Down"
+#define SWPAGE_MIRROR_GVALUE "Sw_Page_Mirrored"
+
+namespace sw { namespace sidebar {
+
+PageMarginControl::PageMarginControl(
+ Window* pParent,
+ PagePropertyPanel& rPanel,
+ const SvxLongLRSpaceItem& aPageLRMargin,
+ const SvxLongULSpaceItem& aPageULMargin,
+ const bool bMirrored,
+ const Size aPageSize,
+ const sal_Bool bLandscape,
+ const FieldUnit eFUnit,
+ const SfxMapUnit eUnit )
+ : ::svx::sidebar::PopupControl( pParent, SW_RES(RID_POPUP_SWPAGE_MARGIN) )
+ , mpMarginValueSet( new ::svx::sidebar::ValueSetWithTextControl( ::svx::sidebar::ValueSetWithTextControl::IMAGE_TEXT, this, SW_RES(VS_MARGIN) ) )
+ , maCustom(this, SW_RES(FT_CUSTOM))
+ , maLeft(this, SW_RES(FT_LEFT))
+ , maInner(this, SW_RES(FT_INNER))
+ , maLeftMarginEdit(this, SW_RES(MF_SWLEFT_MARGIN))
+ , maRight(this, SW_RES(FT_RIGHT))
+ , maOuter(this, SW_RES(FT_OUTER))
+ , maRightMarginEdit(this, SW_RES(MF_SWRIGHT_MARGIN))
+ , maTop(this, SW_RES(FT_TOP))
+ , maTopMarginEdit(this, SW_RES(MF_SWTOP_MARGIN))
+ , maBottom(this, SW_RES(FT_BOTTOM))
+ , maBottomMarginEdit(this, SW_RES(MF_SWBOTTOM_MARGIN))
+ , maWidthHeightField( this, SW_RES(FLD_WIDTH_HEIGHT) )
+ , mnPageLeftMargin( aPageLRMargin.GetLeft() )
+ , mnPageRightMargin( aPageLRMargin.GetRight() )
+ , mnPageTopMargin( aPageULMargin.GetUpper() )
+ , mnPageBottomMargin( aPageULMargin.GetLower() )
+ , mbMirrored( bMirrored )
+ , meUnit( eUnit )
+ , mbUserCustomValuesAvailable(false)
+ , mnUserCustomPageLeftMargin(0)
+ , mnUserCustomPageRightMargin(0)
+ , mnUserCustomPageTopMargin(0)
+ , mnUserCustomPageBottomMargin(0)
+ , mbUserCustomMirrored(false)
+ , mbCustomValuesUsed( false )
+ , mrPagePropPanel(rPanel)
+{
+ maWidthHeightField.Hide();
+ SetFieldUnit( maWidthHeightField, eFUnit );
+
+ mbUserCustomValuesAvailable = GetUserCustomValues();
+
+ mpMarginValueSet->SetStyle( mpMarginValueSet->GetStyle() | WB_3DLOOK | WB_NO_DIRECTSELECT );
+ mpMarginValueSet->SetColor( GetSettings().GetStyleSettings().GetMenuColor() );
+
+ FillValueSet( bLandscape, mbUserCustomValuesAvailable );
+
+ mpMarginValueSet->SetNoSelection();
+ mpMarginValueSet->SetSelectHdl( LINK(this, PageMarginControl,ImplMarginHdl ) );
+ mpMarginValueSet->Show();
+
+ SelectValueSetItem();
+
+ SetFieldUnit( maLeftMarginEdit, eFUnit );
+ Link aLinkLR = LINK( this, PageMarginControl, ModifyLRMarginHdl );
+ maLeftMarginEdit.SetModifyHdl( aLinkLR );
+ SetMetricValue( maLeftMarginEdit, mnPageLeftMargin, meUnit );
+
+ SetFieldUnit( maRightMarginEdit, eFUnit );
+ maRightMarginEdit.SetModifyHdl( aLinkLR );
+ SetMetricValue( maRightMarginEdit, mnPageRightMargin, meUnit );
+
+ Link aLinkUL = LINK( this, PageMarginControl, ModifyULMarginHdl );
+ SetFieldUnit( maTopMarginEdit, eFUnit );
+ maTopMarginEdit.SetModifyHdl( aLinkUL );
+ SetMetricValue( maTopMarginEdit, mnPageTopMargin, meUnit );
+
+ SetFieldUnit( maBottomMarginEdit, eFUnit );
+ maBottomMarginEdit.SetModifyHdl( aLinkUL );
+ SetMetricValue( maBottomMarginEdit, mnPageBottomMargin, meUnit );
+
+ SetMetricFieldMaxValues( aPageSize );
+
+ if ( mbMirrored )
+ {
+ maLeft.Hide();
+ maRight.Hide();
+ maInner.Show();
+ maOuter.Show();
+ }
+ else
+ {
+ maLeft.Show();
+ maRight.Show();
+ maInner.Hide();
+ maOuter.Hide();
+ }
+
+ FreeResource();
+}
+
+PageMarginControl::~PageMarginControl(void)
+{
+ delete mpMarginValueSet;
+
+ StoreUserCustomValues();
+}
+
+void PageMarginControl::SetMetricFieldMaxValues( const Size aPageSize )
+{
+ const long nML = maLeftMarginEdit.Denormalize( maLeftMarginEdit.GetValue(FUNIT_TWIP) );
+ const long nMR = maRightMarginEdit.Denormalize( maRightMarginEdit.GetValue(FUNIT_TWIP) );
+ const long nMT = maTopMarginEdit.Denormalize(maTopMarginEdit.GetValue(FUNIT_TWIP) );
+ const long nMB = maBottomMarginEdit.Denormalize( maBottomMarginEdit.GetValue(FUNIT_TWIP) );
+
+ const long nPH = LogicToLogic( aPageSize.Height(), (MapUnit)meUnit, MAP_TWIP );
+ const long nPW = LogicToLogic( aPageSize.Width(), (MapUnit)meUnit, MAP_TWIP );
+
+ // Left
+ long nMax = nPW - nMR - MINBODY;
+ maLeftMarginEdit.SetMax(maLeftMarginEdit.Normalize(nMax), FUNIT_TWIP);
+
+ // Right
+ nMax = nPW - nML - MINBODY;
+ maRightMarginEdit.SetMax(maRightMarginEdit.Normalize(nMax), FUNIT_TWIP);
+
+ //Top
+ nMax = nPH - nMB - MINBODY;
+ maTopMarginEdit.SetMax(maTopMarginEdit.Normalize(nMax), FUNIT_TWIP);
+
+ //Bottom
+ nMax = nPH - nMT - MINBODY;
+ maBottomMarginEdit.SetMax(maTopMarginEdit.Normalize(nMax), FUNIT_TWIP);
+}
+
+void PageMarginControl::FillValueSet(
+ const bool bLandscape,
+ const bool bUserCustomValuesAvailable )
+{
+ const OUString aLeft = SW_RESSTR(STR_MARGIN_TOOLTIP_LEFT);
+ const OUString aRight = SW_RESSTR(STR_MARGIN_TOOLTIP_RIGHT);
+ const OUString aTop = SW_RESSTR(STR_MARGIN_TOOLTIP_TOP);
+ const OUString aBottom = SW_RESSTR(STR_MARGIN_TOOLTIP_BOT);
+
+ SetMetricValue( maWidthHeightField, SWPAGE_NARROW_VALUE, meUnit );
+ const OUString aNarrowValText = maWidthHeightField.GetText();
+ OUString aHelpText = aLeft;
+ aHelpText += aNarrowValText;
+ aHelpText += aRight;
+ aHelpText += aNarrowValText;
+ aHelpText += aTop;
+ aHelpText += aNarrowValText;
+ aHelpText += aBottom;
+ aHelpText += aNarrowValText;
+ mpMarginValueSet->AddItem(
+ Image((bLandscape) ? SW_RES(IMG_NARROW_L) : SW_RES(IMG_NARROW)), 0,
+ SW_RESSTR(STR_NARROW), &aHelpText );
+
+ SetMetricValue( maWidthHeightField, SWPAGE_NORMAL_VALUE, meUnit );
+ const OUString aNormalValText = maWidthHeightField.GetText();
+ aHelpText = aLeft;
+ aHelpText += aNormalValText;
+ aHelpText += aRight;
+ aHelpText += aNormalValText;
+ aHelpText += aTop;
+ aHelpText += aNormalValText;
+ aHelpText += aBottom;
+ aHelpText += aNormalValText;
+ mpMarginValueSet->AddItem(
+ Image((bLandscape) ? SW_RES(IMG_NORMAL_L) : SW_RES(IMG_NORMAL)), 0,
+ SW_RESSTR(STR_NORMAL), &aHelpText );
+
+ SetMetricValue( maWidthHeightField, SWPAGE_WIDE_VALUE1, meUnit );
+ const OUString aWide1ValText = maWidthHeightField.GetText();
+ SetMetricValue( maWidthHeightField, SWPAGE_WIDE_VALUE2, meUnit );
+ const OUString aWide2ValText = maWidthHeightField.GetText();
+ aHelpText = aLeft;
+ aHelpText += aWide2ValText;
+ aHelpText += aRight;
+ aHelpText += aWide2ValText;
+ aHelpText += aTop;
+ aHelpText += aWide1ValText;
+ aHelpText += aBottom;
+ aHelpText += aWide1ValText;
+ mpMarginValueSet->AddItem(
+ Image((bLandscape) ? SW_RES(IMG_WIDE_L) : SW_RES(IMG_WIDE)), 0,
+ SW_RESSTR(STR_WIDE), &aHelpText );
+
+ const OUString aInner = SW_RESSTR(STR_MARGIN_TOOLTIP_INNER);
+ const OUString aOuter = SW_RESSTR(STR_MARGIN_TOOLTIP_OUTER);
+
+ SetMetricValue( maWidthHeightField, SWPAGE_WIDE_VALUE3, meUnit );
+ const OUString aWide3ValText = maWidthHeightField.GetText();
+ aHelpText = aInner;
+ aHelpText += aWide3ValText;
+ aHelpText += aOuter;
+ aHelpText += aWide3ValText;
+ aHelpText += aTop;
+ aHelpText += aWide1ValText;
+ aHelpText += aBottom;
+ aHelpText += aWide1ValText;
+ mpMarginValueSet->AddItem(
+ Image((bLandscape) ? SW_RES(IMG_MIRRORED_L) : SW_RES(IMG_MIRRORED)), 0,
+ SW_RESSTR(STR_MIRRORED), &aHelpText );
+
+ if ( bUserCustomValuesAvailable )
+ {
+ aHelpText = mbUserCustomMirrored ? aInner : aLeft;
+ SetMetricValue( maWidthHeightField, mnUserCustomPageLeftMargin, meUnit );
+ aHelpText += maWidthHeightField.GetText();
+ aHelpText += mbUserCustomMirrored ? aOuter : aRight;
+ SetMetricValue( maWidthHeightField, mnUserCustomPageRightMargin, meUnit );
+ aHelpText += maWidthHeightField.GetText();
+ aHelpText += aTop;
+ SetMetricValue( maWidthHeightField, mnUserCustomPageTopMargin, meUnit );
+ aHelpText += maWidthHeightField.GetText();
+ aHelpText += aBottom;
+ SetMetricValue( maWidthHeightField, mnUserCustomPageBottomMargin, meUnit );
+ aHelpText += maWidthHeightField.GetText();
+ }
+ else
+ {
+ aHelpText = OUString();
+ }
+ mpMarginValueSet->AddItem(
+ Image((bUserCustomValuesAvailable) ? SW_RES(IMG_CUSTOM) : SW_RES(IMG_CUSTOM_DIS)), 0,
+ SW_RESSTR(STR_LCVALUE), &aHelpText );
+}
+
+void PageMarginControl::SelectValueSetItem()
+{
+ const long cTolerance = 5;
+
+ if( std::abs(mnPageLeftMargin - SWPAGE_NARROW_VALUE) <= cTolerance &&
+ std::abs(mnPageRightMargin - SWPAGE_NARROW_VALUE) <= cTolerance &&
+ std::abs(mnPageTopMargin - SWPAGE_NARROW_VALUE) <= cTolerance &&
+ std::abs(mnPageBottomMargin - SWPAGE_NARROW_VALUE) <= cTolerance &&
+ !mbMirrored )
+ {
+ mpMarginValueSet->SelectItem(1);
+ }
+ else if( std::abs(mnPageLeftMargin - SWPAGE_NORMAL_VALUE) <= cTolerance &&
+ std::abs(mnPageRightMargin - SWPAGE_NORMAL_VALUE) <= cTolerance &&
+ std::abs(mnPageTopMargin - SWPAGE_NORMAL_VALUE) <= cTolerance &&
+ std::abs(mnPageBottomMargin - SWPAGE_NORMAL_VALUE) <= cTolerance &&
+ !mbMirrored )
+ {
+ mpMarginValueSet->SelectItem(2);
+ }
+ else if( std::abs(mnPageLeftMargin - SWPAGE_WIDE_VALUE2) <= cTolerance &&
+ std::abs(mnPageRightMargin - SWPAGE_WIDE_VALUE2) <= cTolerance &&
+ std::abs(mnPageTopMargin - SWPAGE_WIDE_VALUE1) <= cTolerance &&
+ std::abs(mnPageBottomMargin - SWPAGE_WIDE_VALUE1) <= cTolerance &&
+ !mbMirrored )
+ {
+ mpMarginValueSet->SelectItem(3);
+ }
+ else if( std::abs(mnPageLeftMargin - SWPAGE_WIDE_VALUE3) <= cTolerance &&
+ std::abs(mnPageRightMargin - SWPAGE_WIDE_VALUE1) <= cTolerance &&
+ std::abs(mnPageTopMargin - SWPAGE_WIDE_VALUE1) <= cTolerance &&
+ std::abs(mnPageBottomMargin - SWPAGE_WIDE_VALUE1) <= cTolerance &&
+ mbMirrored )
+ {
+ mpMarginValueSet->SelectItem(4);
+ }
+ else
+ {
+ mpMarginValueSet->SelectItem(0);
+ }
+
+ mpMarginValueSet->Format();
+ mpMarginValueSet->StartSelection();
+};
+
+IMPL_LINK(PageMarginControl, ImplMarginHdl, void *, pControl)
+{
+ if ( pControl == mpMarginValueSet )
+ {
+ const sal_uInt16 iPos = mpMarginValueSet->GetSelectItemId();
+ bool bMirrored = false;
+ bool bApplyNewPageMargins = true;
+ switch ( iPos )
+ {
+ case 1:
+ mnPageLeftMargin = SWPAGE_NARROW_VALUE;
+ mnPageRightMargin = SWPAGE_NARROW_VALUE;
+ mnPageTopMargin = SWPAGE_NARROW_VALUE;
+ mnPageBottomMargin = SWPAGE_NARROW_VALUE;
+ bMirrored = false;
+ break;
+ case 2:
+ mnPageLeftMargin = SWPAGE_NORMAL_VALUE;
+ mnPageRightMargin = SWPAGE_NORMAL_VALUE;
+ mnPageTopMargin = SWPAGE_NORMAL_VALUE;
+ mnPageBottomMargin = SWPAGE_NORMAL_VALUE;
+ bMirrored = false;
+ break;
+ case 3:
+ mnPageLeftMargin = SWPAGE_WIDE_VALUE2;
+ mnPageRightMargin = SWPAGE_WIDE_VALUE2;
+ mnPageTopMargin = SWPAGE_WIDE_VALUE1;
+ mnPageBottomMargin = SWPAGE_WIDE_VALUE1;
+ bMirrored = false;
+ break;
+ case 4:
+ mnPageLeftMargin = SWPAGE_WIDE_VALUE3;
+ mnPageRightMargin = SWPAGE_WIDE_VALUE1;
+ mnPageTopMargin = SWPAGE_WIDE_VALUE1;
+ mnPageBottomMargin = SWPAGE_WIDE_VALUE1;
+ bMirrored = true;
+ break;
+ case 5:
+ if ( mbUserCustomValuesAvailable )
+ {
+ mnPageLeftMargin = mnUserCustomPageLeftMargin;
+ mnPageRightMargin = mnUserCustomPageRightMargin;
+ mnPageTopMargin = mnUserCustomPageTopMargin;
+ mnPageBottomMargin = mnUserCustomPageBottomMargin;
+ bMirrored = mbUserCustomMirrored;
+ }
+ else
+ {
+ bApplyNewPageMargins = false;
+ }
+ break;
+ }
+
+ if ( bApplyNewPageMargins )
+ {
+ mrPagePropPanel.StartUndo();
+ mpMarginValueSet->SetNoSelection();
+ mrPagePropPanel.ExecuteMarginLRChange( mnPageLeftMargin, mnPageRightMargin );
+ mrPagePropPanel.ExecuteMarginULChange( mnPageTopMargin, mnPageBottomMargin );
+ if ( mbMirrored != bMirrored )
+ {
+ mbMirrored = bMirrored;
+ mrPagePropPanel.ExecutePageLayoutChange( mbMirrored );
+ }
+ mrPagePropPanel.EndUndo();
+
+ mbCustomValuesUsed = false;
+ mrPagePropPanel.ClosePageMarginPopup();
+ }
+ else
+ {
+ // back to initial selection
+ SelectValueSetItem();
+ }
+ }
+
+ return 0;
+}
+
+IMPL_LINK( PageMarginControl, ModifyLRMarginHdl, MetricField *, EMPTYARG )
+{
+ mpMarginValueSet->SetNoSelection();
+ mpMarginValueSet->SelectItem(0);
+ mpMarginValueSet->Format();
+ mpMarginValueSet->StartSelection();
+
+ mnPageLeftMargin = GetCoreValue( maLeftMarginEdit, meUnit );
+ mnPageRightMargin = GetCoreValue( maRightMarginEdit, meUnit );
+ mrPagePropPanel.ExecuteMarginLRChange( mnPageLeftMargin, mnPageRightMargin );
+ mbCustomValuesUsed = true;
+ return 0;
+}
+
+IMPL_LINK( PageMarginControl, ModifyULMarginHdl, MetricField *, EMPTYARG )
+{
+ mpMarginValueSet->SetNoSelection();
+ mpMarginValueSet->SelectItem(0);
+ mpMarginValueSet->Format();
+ mpMarginValueSet->StartSelection();
+
+ mnPageTopMargin = GetCoreValue( maTopMarginEdit, meUnit );
+ mnPageBottomMargin = GetCoreValue( maBottomMarginEdit, meUnit );
+ mrPagePropPanel.ExecuteMarginULChange( mnPageTopMargin, mnPageBottomMargin );
+ mbCustomValuesUsed = true;
+ return 0;
+}
+
+bool PageMarginControl::GetUserCustomValues()
+{
+ bool bUserCustomValuesAvailable = false;
+
+ SvtViewOptions aWinOpt( E_WINDOW, SWPAGE_LEFT_GVALUE );
+ if ( aWinOpt.Exists() )
+ {
+ ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq = aWinOpt.GetUserData();
+ ::rtl::OUString aTmp;
+ if ( aSeq.getLength())
+ aSeq[0].Value >>= aTmp;
+ OUString aWinData( aTmp );
+ mnUserCustomPageLeftMargin = aWinData.toInt32();
+ bUserCustomValuesAvailable = true;
+ }
+
+ SvtViewOptions aWinOpt2( E_WINDOW, SWPAGE_RIGHT_GVALUE );
+ if ( aWinOpt2.Exists() )
+ {
+ ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq = aWinOpt2.GetUserData();
+ ::rtl::OUString aTmp;
+ if ( aSeq.getLength())
+ aSeq[0].Value >>= aTmp;
+ OUString aWinData( aTmp );
+ mnUserCustomPageRightMargin = aWinData.toInt32();
+ bUserCustomValuesAvailable = true;
+ }
+
+ SvtViewOptions aWinOpt3( E_WINDOW, SWPAGE_TOP_GVALUE );
+ if ( aWinOpt3.Exists() )
+ {
+ ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq = aWinOpt3.GetUserData();
+ ::rtl::OUString aTmp;
+ if ( aSeq.getLength())
+ aSeq[0].Value >>= aTmp;
+ OUString aWinData( aTmp );
+ mnUserCustomPageTopMargin = aWinData.toInt32();
+ bUserCustomValuesAvailable = true;
+ }
+
+ SvtViewOptions aWinOpt4( E_WINDOW, SWPAGE_DOWN_GVALUE );
+ if ( aWinOpt4.Exists() )
+ {
+ ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq = aWinOpt4.GetUserData();
+ ::rtl::OUString aTmp;
+ if ( aSeq.getLength())
+ aSeq[0].Value >>= aTmp;
+ OUString aWinData( aTmp );
+ mnUserCustomPageBottomMargin = aWinData.toInt32();
+ bUserCustomValuesAvailable = true;
+ }
+
+ SvtViewOptions aWinOpt5( E_WINDOW, SWPAGE_MIRROR_GVALUE );
+ if ( aWinOpt5.Exists() )
+ {
+ ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq = aWinOpt5.GetUserData();
+ ::rtl::OUString aTmp;
+ if ( aSeq.getLength())
+ aSeq[0].Value >>= aTmp;
+ OUString aWinData( aTmp );
+ mbUserCustomMirrored = aWinData.toInt32() == 0 ? false : true;
+ bUserCustomValuesAvailable = true;
+ }
+
+ return bUserCustomValuesAvailable;
+}
+
+void PageMarginControl::StoreUserCustomValues()
+{
+ if ( !mbCustomValuesUsed )
+ {
+ return;
+ }
+
+ ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq(1);
+ SvtViewOptions aWinOpt( E_WINDOW, SWPAGE_LEFT_GVALUE );
+
+ aSeq[0].Name = "mnPageLeftMargin";
+ aSeq[0].Value <<= ::rtl::OUString::number( mnPageLeftMargin );
+ aWinOpt.SetUserData( aSeq );
+
+ SvtViewOptions aWinOpt2( E_WINDOW, SWPAGE_RIGHT_GVALUE );
+ aSeq[0].Name = "mnPageRightMargin";
+ aSeq[0].Value <<= ::rtl::OUString::number( mnPageRightMargin );
+ aWinOpt2.SetUserData( aSeq );
+
+ SvtViewOptions aWinOpt3( E_WINDOW, SWPAGE_TOP_GVALUE );
+ aSeq[0].Name = "mnPageTopMargin";
+ aSeq[0].Value <<= ::rtl::OUString::number( mnPageTopMargin );
+ aWinOpt3.SetUserData( aSeq );
+
+ SvtViewOptions aWinOpt4( E_WINDOW, SWPAGE_DOWN_GVALUE );
+ aSeq[0].Name = "mnPageBottomMargin";
+ aSeq[0].Value <<= ::rtl::OUString::number( mnPageBottomMargin );
+ aWinOpt4.SetUserData( aSeq );
+
+ SvtViewOptions aWinOpt5( E_WINDOW, SWPAGE_MIRROR_GVALUE );
+ aSeq[0].Name = "mbMirrored";
+ aSeq[0].Value <<= ::rtl::OUString::number( (mbMirrored ? 1 : 0) );
+ aWinOpt5.SetUserData( aSeq );
+}
+
+} } // end of namespace sw::sidebar
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/sidebar/PageMarginControl.hxx b/sw/source/core/uibase/sidebar/PageMarginControl.hxx
new file mode 100644
index 000000000000..f32e8846329c
--- /dev/null
+++ b/sw/source/core/uibase/sidebar/PageMarginControl.hxx
@@ -0,0 +1,121 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_SIDEBAR_PAGEMARGINCONTROL_HXX
+#define INCLUDED_SW_SOURCE_UI_SIDEBAR_PAGEMARGINCONTROL_HXX
+
+#include <svx/sidebar/PopupControl.hxx>
+
+#include <tools/fldunit.hxx>
+#include <svl/poolitem.hxx>
+#include <svx/rulritem.hxx>
+#include <unotools/viewoptions.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/field.hxx>
+#include <svtools/unitconv.hxx>
+#include <vector>
+
+#define SWPAGE_NARROW_VALUE 720
+#define SWPAGE_NORMAL_VALUE 1136
+#define SWPAGE_WIDE_VALUE1 1440
+#define SWPAGE_WIDE_VALUE2 2880
+#define SWPAGE_WIDE_VALUE3 1800
+
+namespace svx { namespace sidebar {
+ class ValueSetWithTextControl;
+} }
+
+static const long MINBODY = 284; //0.5 cm in twips
+
+namespace sw { namespace sidebar {
+
+class PagePropertyPanel;
+
+class PageMarginControl
+ : public ::svx::sidebar::PopupControl
+{
+public:
+ PageMarginControl(
+ Window* pParent,
+ PagePropertyPanel& rPanel,
+ const SvxLongLRSpaceItem& aPageLRMargin,
+ const SvxLongULSpaceItem& aPageULMargin,
+ const bool bMirrored,
+ const Size aPageSize,
+ const sal_Bool bLandscape,
+ const FieldUnit eFUnit,
+ const SfxMapUnit eUnit );
+ ~PageMarginControl(void);
+
+private:
+ ::svx::sidebar::ValueSetWithTextControl* mpMarginValueSet;
+
+ FixedText maCustom;
+ FixedText maLeft;
+ FixedText maInner;
+ MetricField maLeftMarginEdit;
+ FixedText maRight;
+ FixedText maOuter;
+ MetricField maRightMarginEdit;
+ FixedText maTop;
+ MetricField maTopMarginEdit;
+ FixedText maBottom;
+ MetricField maBottomMarginEdit;
+
+ // hidden metric field
+ MetricField maWidthHeightField;
+
+ long mnPageLeftMargin;
+ long mnPageRightMargin;
+ long mnPageTopMargin;
+ long mnPageBottomMargin;
+ bool mbMirrored;
+
+ const SfxMapUnit meUnit;
+
+ bool mbUserCustomValuesAvailable;
+ long mnUserCustomPageLeftMargin;
+ long mnUserCustomPageRightMargin;
+ long mnUserCustomPageTopMargin;
+ long mnUserCustomPageBottomMargin;
+ bool mbUserCustomMirrored;
+
+ bool mbCustomValuesUsed;
+
+ PagePropertyPanel& mrPagePropPanel;
+
+ DECL_LINK( ImplMarginHdl, void* );
+ DECL_LINK( ModifyLRMarginHdl, MetricField* );
+ DECL_LINK( ModifyULMarginHdl, MetricField* );
+
+ void SetMetricFieldMaxValues( const Size aPageSize );
+
+ bool GetUserCustomValues();
+ void StoreUserCustomValues();
+
+ void FillValueSet(
+ const bool bLandscape,
+ const bool bUserCustomValuesAvailable );
+ void SelectValueSetItem();
+};
+
+} } // end of namespace sw::sidebar
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/sidebar/PageOrientationControl.cxx b/sw/source/core/uibase/sidebar/PageOrientationControl.cxx
new file mode 100644
index 000000000000..2dbf8bf8762a
--- /dev/null
+++ b/sw/source/core/uibase/sidebar/PageOrientationControl.cxx
@@ -0,0 +1,90 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "PageOrientationControl.hxx"
+#include "PagePropertyPanel.hxx"
+#include "PagePropertyPanel.hrc"
+
+#include <swtypes.hxx>
+
+#include <svx/sidebar/ValueSetWithTextControl.hxx>
+#include <vcl/settings.hxx>
+
+namespace sw { namespace sidebar {
+
+PageOrientationControl::PageOrientationControl(
+ Window* pParent,
+ PagePropertyPanel& rPanel,
+ const sal_Bool bLandscape )
+ : ::svx::sidebar::PopupControl( pParent, SW_RES(RID_POPUP_SWPAGE_ORIENTATION) )
+ , mpOrientationValueSet( new ::svx::sidebar::ValueSetWithTextControl( ::svx::sidebar::ValueSetWithTextControl::IMAGE_TEXT, this, SW_RES(VS_ORIENTATION) ) )
+ , mbLandscape( bLandscape )
+ , mrPagePropPanel(rPanel)
+{
+ mpOrientationValueSet->SetStyle( mpOrientationValueSet->GetStyle() | WB_3DLOOK | WB_NO_DIRECTSELECT );
+ mpOrientationValueSet->SetColor(GetSettings().GetStyleSettings().GetMenuColor());
+
+ // initialize <ValueSetWithText> control
+ {
+ mpOrientationValueSet->AddItem(Image(SW_RES(IMG_PORTRAIT)), 0,
+ SW_RES(STR_PORTRAIT), 0);
+ mpOrientationValueSet->AddItem(Image(SW_RES(IMG_LANDSCAPE)), 0,
+ SW_RES(STR_LANDSCAPE), 0 );
+ }
+
+ Link aLink = LINK(this, PageOrientationControl,ImplOrientationHdl );
+ mpOrientationValueSet->SetSelectHdl(aLink);
+ mpOrientationValueSet->SetNoSelection();
+ mpOrientationValueSet->StartSelection();
+ mpOrientationValueSet->Show();
+ mpOrientationValueSet->SelectItem( (mbLandscape == sal_True) ? 2 : 1 );
+ mpOrientationValueSet->GrabFocus();
+ mpOrientationValueSet->Format();
+ mpOrientationValueSet->StartSelection();
+
+ FreeResource();
+}
+
+PageOrientationControl::~PageOrientationControl(void)
+{
+ delete mpOrientationValueSet;
+}
+
+IMPL_LINK(PageOrientationControl, ImplOrientationHdl, void *, pControl)
+{
+ mpOrientationValueSet->SetNoSelection();
+ if ( pControl == mpOrientationValueSet )
+ {
+ const sal_uInt32 iPos = mpOrientationValueSet->GetSelectItemId();
+ const bool bChanged = ( ( iPos == 1 ) && mbLandscape ) ||
+ ( ( iPos == 2 ) && !mbLandscape );
+ if ( bChanged )
+ {
+ mbLandscape = !mbLandscape;
+ mrPagePropPanel.ExecuteOrientationChange( mbLandscape );
+ }
+ }
+
+ mrPagePropPanel.ClosePageOrientationPopup();
+ return 0;
+}
+
+} } // end of namespace sw::sidebar
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/sidebar/PageOrientationControl.hxx b/sw/source/core/uibase/sidebar/PageOrientationControl.hxx
new file mode 100644
index 000000000000..a4cfe4249376
--- /dev/null
+++ b/sw/source/core/uibase/sidebar/PageOrientationControl.hxx
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_SIDEBAR_PAGEORIENTATIONCONTROL_HXX
+#define INCLUDED_SW_SOURCE_UI_SIDEBAR_PAGEORIENTATIONCONTROL_HXX
+
+#include <svx/sidebar/PopupControl.hxx>
+
+namespace svx { namespace sidebar {
+ class ValueSetWithTextControl;
+} }
+
+namespace sw { namespace sidebar {
+
+class PagePropertyPanel;
+
+class PageOrientationControl
+ : public ::svx::sidebar::PopupControl
+{
+public:
+ PageOrientationControl(
+ Window* pParent,
+ PagePropertyPanel& rPanel,
+ const sal_Bool bLandscape );
+ ~PageOrientationControl(void);
+
+private:
+ ::svx::sidebar::ValueSetWithTextControl* mpOrientationValueSet;
+
+ sal_Bool mbLandscape;
+
+ PagePropertyPanel& mrPagePropPanel;
+
+ DECL_LINK(ImplOrientationHdl, void*);
+};
+
+} } // end of namespace sw::sidebar
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/sidebar/PagePropertyPanel.cxx b/sw/source/core/uibase/sidebar/PagePropertyPanel.cxx
new file mode 100644
index 000000000000..a5d02386cb52
--- /dev/null
+++ b/sw/source/core/uibase/sidebar/PagePropertyPanel.cxx
@@ -0,0 +1,742 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <sal/config.h>
+
+#include <cstdlib>
+
+#include "PagePropertyPanel.hxx"
+#include "PagePropertyPanel.hrc"
+
+#include "PropertyPanel.hrc"
+
+#include <svx/sidebar/PopupContainer.hxx>
+#include "PageOrientationControl.hxx"
+#include "PageMarginControl.hxx"
+#include "PageSizeControl.hxx"
+#include "PageColumnControl.hxx"
+
+#include <swtypes.hxx>
+#include <cmdid.h>
+
+#include <svl/intitem.hxx>
+#include <editeng/sizeitem.hxx>
+#include <editeng/paperinf.hxx>
+#include <svx/svxids.hrc>
+#include <svx/dlgutil.hxx>
+#include <svx/rulritem.hxx>
+
+#include <sfx2/sidebar/ControlFactory.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/viewsh.hxx>
+#include <sfx2/objsh.hxx>
+
+#include <boost/bind.hpp>
+
+#include <com/sun/star/frame/XController.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/document/XUndoManagerSupplier.hpp>
+
+const char UNO_ORIENTATION[] = ".uno:Orientation";
+const char UNO_MARGIN[] = ".uno:Margin";
+const char UNO_SIZE[] = ".uno:Size";
+const char UNO_COLUMN[] = ".uno:Column";
+
+namespace {
+ const cssu::Reference< css::document::XUndoManager > getUndoManager( const cssu::Reference< css::frame::XFrame >& rxFrame )
+ {
+ const cssu::Reference< css::frame::XController >& xController = rxFrame->getController();
+ if ( xController.is() )
+ {
+ const cssu::Reference< css::frame::XModel >& xModel = xController->getModel();
+ if ( xModel.is() )
+ {
+ const cssu::Reference< css::document::XUndoManagerSupplier > xSuppUndo( xModel, cssu::UNO_QUERY_THROW );
+ if ( xSuppUndo.is() )
+ {
+ const cssu::Reference< css::document::XUndoManager > xUndoManager( xSuppUndo->getUndoManager(), cssu::UNO_QUERY_THROW );
+ return xUndoManager;
+ }
+ }
+ }
+
+ return cssu::Reference< css::document::XUndoManager > ();
+ }
+}
+
+namespace sw { namespace sidebar {
+
+PagePropertyPanel* PagePropertyPanel::Create (
+ Window* pParent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame>& rxFrame,
+ SfxBindings* pBindings)
+{
+ if (pParent == NULL)
+ throw ::com::sun::star::lang::IllegalArgumentException("no parent Window given to PagePropertyPanel::Create", NULL, 0);
+ if ( ! rxFrame.is())
+ throw ::com::sun::star::lang::IllegalArgumentException("no XFrame given to PagePropertyPanel::Create", NULL, 1);
+ if (pBindings == NULL)
+ throw ::com::sun::star::lang::IllegalArgumentException("no SfxBindings given to PagePropertyPanel::Create", NULL, 2);
+
+ return new PagePropertyPanel(
+ pParent,
+ rxFrame,
+ pBindings);
+}
+
+PagePropertyPanel::PagePropertyPanel(
+ Window* pParent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame>& rxFrame,
+ SfxBindings* pBindings)
+ : PanelLayout(pParent, "PagePropertyPanel", "modules/swriter/ui/sidebarpage.ui", rxFrame)
+ , mpBindings(pBindings)
+
+ // image resources
+ , maImgSize (NULL)
+ , maImgSize_L (NULL)
+ , mImgPortrait (SW_RES(IMG_PAGE_PORTRAIT))
+ , mImgLandscape (SW_RES(IMG_PAGE_LANDSCAPE))
+ , mImgNarrow (SW_RES(IMG_PAGE_NARROW))
+ , mImgNormal (SW_RES(IMG_PAGE_NORMAL))
+ , mImgWide (SW_RES(IMG_PAGE_WIDE))
+ , mImgMirrored (SW_RES(IMG_PAGE_MIRRORED))
+ , mImgMarginCustom (SW_RES(IMG_PAGE_MARGIN_CUSTOM))
+ , mImgNarrow_L (SW_RES(IMG_PAGE_NARROW_L))
+ , mImgNormal_L (SW_RES(IMG_PAGE_NORMAL_L))
+ , mImgWide_L (SW_RES(IMG_PAGE_WIDE_L))
+ , mImgMirrored_L (SW_RES(IMG_PAGE_MIRRORED_L))
+ , mImgMarginCustom_L (SW_RES(IMG_PAGE_MARGIN_CUSTOM_L))
+ , mImgA3 (SW_RES(IMG_PAGE_A3))
+ , mImgA4 (SW_RES(IMG_PAGE_A4))
+ , mImgA5 (SW_RES(IMG_PAGE_A5))
+ , mImgB4 (SW_RES(IMG_PAGE_B4))
+ , mImgB5 (SW_RES(IMG_PAGE_B5))
+ , mImgC5 (SW_RES(IMG_PAGE_C5))
+ , mImgLetter (SW_RES(IMG_PAGE_LETTER))
+ , mImgLegal (SW_RES(IMG_PAGE_LEGAL))
+ , mImgSizeNone (SW_RES(IMG_PAGE_SIZE_NONE))
+ , mImgA3_L (SW_RES(IMG_PAGE_A3_L))
+ , mImgA4_L (SW_RES(IMG_PAGE_A4_L))
+ , mImgA5_L (SW_RES(IMG_PAGE_A5_L))
+ , mImgB4_L (SW_RES(IMG_PAGE_B4_L))
+ , mImgB5_L (SW_RES(IMG_PAGE_B5_L))
+ , mImgC5_L (SW_RES(IMG_PAGE_C5_L))
+ , mImgLetter_L (SW_RES(IMG_PAGE_LETTER_L))
+ , mImgLegal_L (SW_RES(IMG_PAGE_LEGAL_L))
+ , mImgSizeNone_L (SW_RES(IMG_PAGE_SIZE_NONE_L))
+ , mImgColumn1 (SW_RES(IMG_PAGE_COLUMN_1))
+ , mImgColumn2 (SW_RES(IMG_PAGE_COLUMN_2))
+ , mImgColumn3 (SW_RES(IMG_PAGE_COLUMN_3))
+ , mImgLeft (SW_RES(IMG_PAGE_COLUMN_LEFT))
+ , mImgRight (SW_RES(IMG_PAGE_COLUMN_RIGHT))
+ , mImgColumnNone (SW_RES(IMG_PAGE_COLUMN_NONE))
+ , mImgColumn1_L (SW_RES(IMG_PAGE_COLUMN_1_L))
+ , mImgColumn2_L (SW_RES(IMG_PAGE_COLUMN_2_L))
+ , mImgColumn3_L (SW_RES(IMG_PAGE_COLUMN_3_L))
+ , mImgLeft_L (SW_RES(IMG_PAGE_COLUMN_LEFT_L))
+ , mImgRight_L (SW_RES(IMG_PAGE_COLUMN_RIGHT_L))
+ , mImgColumnNone_L (SW_RES(IMG_PAGE_COLUMN_NONE_L))
+
+ , mpPageItem( new SvxPageItem(SID_ATTR_PAGE) )
+ , mpPageLRMarginItem( new SvxLongLRSpaceItem( 0, 0, SID_ATTR_PAGE_LRSPACE ) )
+ , mpPageULMarginItem( new SvxLongULSpaceItem( 0, 0, SID_ATTR_PAGE_ULSPACE ) )
+ , mpPageSizeItem( new SvxSizeItem(SID_ATTR_PAGE_SIZE) )
+ , mePaper( PAPER_USER )
+ , mpPageColumnTypeItem( new SfxInt16Item(SID_ATTR_PAGE_COLUMN) )
+
+ , meFUnit()
+ , meUnit()
+
+ , m_aSwPagePgULControl(SID_ATTR_PAGE_ULSPACE, *pBindings, *this)
+ , m_aSwPagePgLRControl(SID_ATTR_PAGE_LRSPACE, *pBindings, *this)
+ , m_aSwPagePgSizeControl(SID_ATTR_PAGE_SIZE, *pBindings, *this)
+ , m_aSwPagePgControl(SID_ATTR_PAGE, *pBindings, *this)
+ , m_aSwPageColControl(SID_ATTR_PAGE_COLUMN, *pBindings, *this)
+ , m_aSwPagePgMetricControl(SID_ATTR_METRIC, *pBindings, *this)
+
+ , maOrientationPopup( this,
+ ::boost::bind( &PagePropertyPanel::CreatePageOrientationControl, this, _1 ),
+ OUString("Page orientation") )
+ , maMarginPopup( this,
+ ::boost::bind( &PagePropertyPanel::CreatePageMarginControl, this, _1 ),
+ OUString("Page margins") )
+ , maSizePopup( this,
+ ::boost::bind( &PagePropertyPanel::CreatePageSizeControl, this, _1 ),
+ OUString("Page size") )
+ , maColumnPopup( this,
+ ::boost::bind( &PagePropertyPanel::CreatePageColumnControl, this, _1 ),
+ OUString("Page columns") )
+
+ , mxUndoManager( getUndoManager( rxFrame ) )
+
+ , mbInvalidateSIDAttrPageOnSIDAttrPageSizeNotify( false )
+{
+ // visible controls
+ get(mpToolBoxOrientation, "selectorientation");
+ get(mpToolBoxMargin, "selectmargin");
+ get(mpToolBoxSize, "selectsize");
+ get(mpToolBoxColumn, "selectcolumn");
+
+ Initialize();
+ mbInvalidateSIDAttrPageOnSIDAttrPageSizeNotify = true;
+}
+
+PagePropertyPanel::~PagePropertyPanel()
+{
+ delete[] maImgSize;
+ delete[] maImgSize_L;
+}
+
+void PagePropertyPanel::Initialize()
+{
+ // popup for page orientation
+ const sal_uInt16 nIdOrientation = mpToolBoxOrientation->GetItemId(UNO_ORIENTATION);
+ Link aLink = LINK( this, PagePropertyPanel, ClickOrientationHdl );
+ mpToolBoxOrientation->SetDropdownClickHdl( aLink );
+ mpToolBoxOrientation->SetSelectHdl( aLink );
+ mpToolBoxOrientation->SetItemImage( nIdOrientation, mImgPortrait);
+ mpToolBoxOrientation->SetItemBits( nIdOrientation, mpToolBoxOrientation->GetItemBits( nIdOrientation ) | TIB_DROPDOWNONLY );
+
+ // popup for page margins
+ const sal_uInt16 nIdMargin = mpToolBoxMargin->GetItemId(UNO_MARGIN);
+ aLink = LINK( this, PagePropertyPanel, ClickMarginHdl );
+ mpToolBoxMargin->SetDropdownClickHdl( aLink );
+ mpToolBoxMargin->SetSelectHdl( aLink );
+ mpToolBoxMargin->SetItemImage(nIdMargin, mImgNormal);
+ mpToolBoxMargin->SetItemBits( nIdMargin, mpToolBoxMargin->GetItemBits( nIdMargin ) | TIB_DROPDOWNONLY );
+
+ // popup for page size
+ const sal_uInt16 nIdSize = mpToolBoxSize->GetItemId(UNO_SIZE);
+ aLink = LINK( this, PagePropertyPanel, ClickSizeHdl );
+ mpToolBoxSize->SetDropdownClickHdl( aLink );
+ mpToolBoxSize->SetSelectHdl( aLink );
+ mpToolBoxSize->SetItemImage(nIdSize, mImgLetter);
+ mpToolBoxSize->SetItemBits( nIdSize, mpToolBoxSize->GetItemBits( nIdSize ) | TIB_DROPDOWNONLY );
+ maImgSize = new Image[8];
+ maImgSize[0] = mImgA3;
+ maImgSize[1] = mImgA4;
+ maImgSize[2] = mImgA5;
+ maImgSize[3] = mImgB4;
+ maImgSize[4] = mImgB5;
+ maImgSize[5] = mImgC5;
+ maImgSize[6] = mImgLetter;
+ maImgSize[7] = mImgLegal;
+ maImgSize_L = new Image[8];
+ maImgSize_L[0] = mImgA3_L;
+ maImgSize_L[1] = mImgA4_L;
+ maImgSize_L[2] = mImgA5_L;
+ maImgSize_L[3] = mImgB4_L;
+ maImgSize_L[4] = mImgB5_L;
+ maImgSize_L[5] = mImgC5_L;
+ maImgSize_L[6] = mImgLetter_L;
+ maImgSize_L[7] = mImgLegal_L;
+
+ // popup for page column property
+ const sal_uInt16 nIdColumn = mpToolBoxColumn->GetItemId(UNO_COLUMN);
+ aLink = LINK( this, PagePropertyPanel, ClickColumnHdl );
+ mpToolBoxColumn->SetDropdownClickHdl( aLink );
+ mpToolBoxColumn->SetSelectHdl( aLink );
+ mpToolBoxColumn->SetItemImage(nIdColumn, mImgColumn1);
+ mpToolBoxColumn->SetItemBits( nIdColumn, mpToolBoxColumn->GetItemBits( nIdColumn ) | TIB_DROPDOWNONLY );
+
+ meFUnit = GetModuleFieldUnit();
+ meUnit = m_aSwPagePgSizeControl.GetCoreMetric();
+
+ // 'pull' for page style's attribute values
+ mpBindings->Update( SID_ATTR_PAGE_LRSPACE );
+ mpBindings->Update( SID_ATTR_PAGE_ULSPACE );
+ mpBindings->Update( SID_ATTR_PAGE );
+ mpBindings->Update( SID_ATTR_PAGE_SIZE );
+}
+
+::svx::sidebar::PopupControl* PagePropertyPanel::CreatePageOrientationControl( ::svx::sidebar::PopupContainer* pParent )
+{
+ return new PageOrientationControl( pParent, *this , mpPageItem->IsLandscape() );
+}
+
+IMPL_LINK( PagePropertyPanel, ClickOrientationHdl, ToolBox*, pToolBox )
+{
+ maOrientationPopup.Show( *pToolBox );
+
+ return 0L;
+}
+
+void PagePropertyPanel::ExecuteOrientationChange( const sal_Bool bLandscape )
+{
+ StartUndo();
+
+ {
+ // set new page orientation
+ mpPageItem->SetLandscape( bLandscape );
+
+ // swap the width and height of the page size
+ mpPageSizeItem->SetSize( Size( mpPageSizeItem->GetSize().Height(), mpPageSizeItem->GetSize().Width() ) );
+
+ // apply changed attributes
+ GetBindings()->GetDispatcher()->Execute( SID_ATTR_PAGE_SIZE, SFX_CALLMODE_RECORD, mpPageSizeItem.get(), mpPageItem.get(), 0L );
+ }
+
+ // check, if margin values still fit to the changed page size.
+ // if not, adjust margin values
+ {
+ const long nML = mpPageLRMarginItem->GetLeft();
+ const long nMR = mpPageLRMarginItem->GetRight();
+ const long nTmpPW = nML + nMR + MINBODY;
+
+ const long nPW = mpPageSizeItem->GetSize().Width();
+
+ if ( nTmpPW > nPW )
+ {
+ if ( nML <= nMR )
+ {
+ ExecuteMarginLRChange( mpPageLRMarginItem->GetLeft(), nMR - (nTmpPW - nPW ) );
+ }
+ else
+ {
+ ExecuteMarginLRChange( nML - (nTmpPW - nPW ), mpPageLRMarginItem->GetRight() );
+ }
+ }
+
+ const long nMT = mpPageULMarginItem->GetUpper();
+ const long nMB = mpPageULMarginItem->GetLower();
+ const long nTmpPH = nMT + nMB + MINBODY;
+
+ const long nPH = mpPageSizeItem->GetSize().Height();
+
+ if ( nTmpPH > nPH )
+ {
+ if ( nMT <= nMB )
+ {
+ ExecuteMarginULChange( mpPageULMarginItem->GetUpper(), nMB - ( nTmpPH - nPH ) );
+ }
+ else
+ {
+ ExecuteMarginULChange( nMT - ( nTmpPH - nPH ), mpPageULMarginItem->GetLower() );
+ }
+ }
+ }
+
+ EndUndo();
+}
+
+void PagePropertyPanel::ClosePageOrientationPopup()
+{
+ maOrientationPopup.Hide();
+}
+
+::svx::sidebar::PopupControl* PagePropertyPanel::CreatePageMarginControl( ::svx::sidebar::PopupContainer* pParent )
+{
+ return new PageMarginControl(
+ pParent,
+ *this,
+ *mpPageLRMarginItem.get(),
+ *mpPageULMarginItem.get(),
+ mpPageItem->GetPageUsage() == SVX_PAGE_MIRROR,
+ mpPageSizeItem->GetSize(),
+ mpPageItem->IsLandscape(),
+ meFUnit,
+ meUnit );
+}
+
+void PagePropertyPanel::ExecuteMarginLRChange(
+ const long nPageLeftMargin,
+ const long nPageRightMargin )
+{
+ mpPageLRMarginItem->SetLeft( nPageLeftMargin );
+ mpPageLRMarginItem->SetRight( nPageRightMargin );
+ GetBindings()->GetDispatcher()->Execute( SID_ATTR_PAGE_LRSPACE, SFX_CALLMODE_RECORD, mpPageLRMarginItem.get(), 0L );
+}
+
+void PagePropertyPanel::ExecuteMarginULChange(
+ const long nPageTopMargin,
+ const long nPageBottomMargin )
+{
+ mpPageULMarginItem->SetUpper( nPageTopMargin );
+ mpPageULMarginItem->SetLower( nPageBottomMargin );
+ GetBindings()->GetDispatcher()->Execute( SID_ATTR_PAGE_ULSPACE, SFX_CALLMODE_RECORD, mpPageULMarginItem.get(), 0L );
+}
+
+void PagePropertyPanel::ExecutePageLayoutChange( const bool bMirrored )
+{
+ mpPageItem->SetPageUsage( bMirrored ? SVX_PAGE_MIRROR : SVX_PAGE_ALL );
+ GetBindings()->GetDispatcher()->Execute( SID_ATTR_PAGE, SFX_CALLMODE_RECORD, mpPageItem.get(), 0L );
+}
+
+IMPL_LINK( PagePropertyPanel, ClickMarginHdl, ToolBox*, pToolBox )
+{
+ maMarginPopup.Show( *pToolBox );
+
+ return 0L;
+}
+
+void PagePropertyPanel::ClosePageMarginPopup()
+{
+ maMarginPopup.Hide();
+}
+
+::svx::sidebar::PopupControl* PagePropertyPanel::CreatePageSizeControl( ::svx::sidebar::PopupContainer* pParent )
+{
+ return new PageSizeControl(
+ pParent,
+ *this,
+ mePaper,
+ mpPageItem->IsLandscape(),
+ meFUnit );
+}
+
+void PagePropertyPanel::ExecuteSizeChange( const Paper ePaper )
+{
+ Size aPageSize = SvxPaperInfo::GetPaperSize( ePaper, (MapUnit)(meUnit) );
+ if ( mpPageItem->IsLandscape() )
+ {
+ Swap( aPageSize );
+ }
+ mpPageSizeItem->SetSize( aPageSize );
+
+ mpBindings->GetDispatcher()->Execute(SID_ATTR_PAGE_SIZE, SFX_CALLMODE_RECORD, mpPageSizeItem.get(), 0L );
+}
+
+IMPL_LINK( PagePropertyPanel, ClickSizeHdl, ToolBox*, pToolBox )
+{
+ maSizePopup.Show( *pToolBox );
+
+ return 0L;
+}
+
+void PagePropertyPanel::ClosePageSizePopup()
+{
+ maSizePopup.Hide();
+}
+
+::svx::sidebar::PopupControl* PagePropertyPanel::CreatePageColumnControl( ::svx::sidebar::PopupContainer* pParent )
+{
+ return new PageColumnControl(
+ pParent,
+ *this,
+ mpPageColumnTypeItem->GetValue(),
+ mpPageItem->IsLandscape() );
+}
+
+void PagePropertyPanel::ExecuteColumnChange( const sal_uInt16 nColumnType )
+{
+ mpPageColumnTypeItem->SetValue( nColumnType );
+ mpBindings->GetDispatcher()->Execute(SID_ATTR_PAGE_COLUMN, SFX_CALLMODE_RECORD, mpPageColumnTypeItem.get(), 0L );
+}
+
+IMPL_LINK( PagePropertyPanel, ClickColumnHdl, ToolBox*, pToolBox )
+{
+ maColumnPopup.Show( *pToolBox );
+
+ return 0L;
+}
+
+void PagePropertyPanel::ClosePageColumnPopup()
+{
+ maColumnPopup.Hide();
+}
+
+void PagePropertyPanel::NotifyItemUpdate(
+ const sal_uInt16 nSId,
+ const SfxItemState eState,
+ const SfxPoolItem* pState,
+ const bool bIsEnabled)
+{
+ (void)bIsEnabled;
+
+ switch( nSId )
+ {
+ case SID_ATTR_PAGE_COLUMN:
+ {
+ if ( eState >= SFX_ITEM_AVAILABLE &&
+ pState && pState->ISA(SfxInt16Item) )
+ {
+ mpPageColumnTypeItem.reset( static_cast<SfxInt16Item*>(pState->Clone()) );
+ ChangeColumnImage( mpPageColumnTypeItem->GetValue() );
+ }
+ }
+ break;
+ case SID_ATTR_PAGE_LRSPACE:
+ if ( eState >= SFX_ITEM_AVAILABLE &&
+ pState && pState->ISA(SvxLongLRSpaceItem) )
+ {
+ mpPageLRMarginItem.reset( static_cast<SvxLongLRSpaceItem*>(pState->Clone()) );
+ ChangeMarginImage();
+ }
+ break;
+
+ case SID_ATTR_PAGE_ULSPACE:
+ if ( eState >= SFX_ITEM_AVAILABLE &&
+ pState && pState->ISA(SvxLongULSpaceItem) )
+ {
+ mpPageULMarginItem.reset( static_cast<SvxLongULSpaceItem*>(pState->Clone()) );
+ ChangeMarginImage();
+ }
+ break;
+
+ case SID_ATTR_PAGE:
+ if ( eState >= SFX_ITEM_AVAILABLE &&
+ pState && pState->ISA(SvxPageItem) )
+ {
+ const sal_uInt16 nIdOrientation = mpToolBoxOrientation->GetItemId(UNO_ORIENTATION);
+ mpPageItem.reset( static_cast<SvxPageItem*>(pState->Clone()) );
+ if ( mpPageItem->IsLandscape() )
+ {
+ mpToolBoxOrientation->SetItemImage(nIdOrientation, mImgLandscape);
+ }
+ else
+ {
+ mpToolBoxOrientation->SetItemImage(nIdOrientation, mImgPortrait);
+ }
+ ChangeMarginImage();
+ ChangeSizeImage();
+ ChangeColumnImage( mpPageColumnTypeItem->GetValue() );
+ }
+ break;
+
+ case SID_ATTR_PAGE_SIZE:
+ if ( mbInvalidateSIDAttrPageOnSIDAttrPageSizeNotify )
+ {
+ mpBindings->Invalidate( SID_ATTR_PAGE, sal_True, sal_False );
+ }
+ if ( eState >= SFX_ITEM_AVAILABLE &&
+ pState && pState->ISA(SvxSizeItem) )
+ {
+ mpPageSizeItem.reset( static_cast<SvxSizeItem*>(pState->Clone()) );
+ ChangeSizeImage();
+ }
+ break;
+ case SID_ATTR_METRIC:
+ MetricState( eState, pState );
+ break;
+ }
+}
+
+void PagePropertyPanel::MetricState( SfxItemState eState, const SfxPoolItem* pState )
+{
+ meFUnit = FUNIT_NONE;
+ if ( pState && eState >= SFX_ITEM_DEFAULT )
+ {
+ meFUnit = (FieldUnit)( (const SfxUInt16Item*)pState )->GetValue();
+ }
+ else
+ {
+ SfxViewFrame* pFrame = SfxViewFrame::Current();
+ SfxObjectShell* pSh = NULL;
+ if ( pFrame )
+ pSh = pFrame->GetObjectShell();
+ if ( pSh )
+ {
+ SfxModule* pModule = pSh->GetModule();
+ if ( pModule )
+ {
+ const SfxPoolItem* pItem = pModule->GetItem( SID_ATTR_METRIC );
+ if ( pItem )
+ meFUnit = (FieldUnit)( (SfxUInt16Item*)pItem )->GetValue();
+ }
+ else
+ {
+ DBG_ERRORFILE( "<PagePropertyPanel::MetricState(..)>: no module found" );
+ }
+ }
+ }
+}
+
+void PagePropertyPanel::ChangeMarginImage()
+{
+ if ( mpPageLRMarginItem.get() == 0 ||
+ mpPageULMarginItem.get() == 0 ||
+ mpPageItem.get() == 0 )
+ {
+ return;
+ }
+
+ const long cTolerance = 5;
+ const sal_uInt16 nIdMargin = mpToolBoxMargin->GetItemId(UNO_MARGIN);
+
+ if( std::abs(mpPageLRMarginItem->GetLeft() - SWPAGE_NARROW_VALUE) <= cTolerance &&
+ std::abs(mpPageLRMarginItem->GetRight() - SWPAGE_NARROW_VALUE) <= cTolerance &&
+ std::abs(mpPageULMarginItem->GetUpper() - SWPAGE_NARROW_VALUE) <= cTolerance &&
+ std::abs(mpPageULMarginItem->GetLower() - SWPAGE_NARROW_VALUE) <= cTolerance &&
+ mpPageItem->GetPageUsage() != SVX_PAGE_MIRROR )
+ mpToolBoxMargin->SetItemImage( nIdMargin, mpPageItem->IsLandscape() ? mImgNarrow_L : mImgNarrow );
+
+ else if( std::abs(mpPageLRMarginItem->GetLeft() - SWPAGE_NORMAL_VALUE) <= cTolerance &&
+ std::abs(mpPageLRMarginItem->GetRight() - SWPAGE_NORMAL_VALUE) <= cTolerance &&
+ std::abs(mpPageULMarginItem->GetUpper() - SWPAGE_NORMAL_VALUE) <= cTolerance &&
+ std::abs(mpPageULMarginItem->GetLower() - SWPAGE_NORMAL_VALUE) <= cTolerance &&
+ mpPageItem->GetPageUsage() != SVX_PAGE_MIRROR )
+ mpToolBoxMargin->SetItemImage( nIdMargin, mpPageItem->IsLandscape() ? mImgNormal_L : mImgNormal );
+
+ else if( std::abs(mpPageLRMarginItem->GetLeft() - SWPAGE_WIDE_VALUE2) <= cTolerance &&
+ std::abs(mpPageLRMarginItem->GetRight() - SWPAGE_WIDE_VALUE2) <= cTolerance &&
+ std::abs(mpPageULMarginItem->GetUpper() - SWPAGE_WIDE_VALUE1) <= cTolerance &&
+ std::abs(mpPageULMarginItem->GetLower() - SWPAGE_WIDE_VALUE1) <= cTolerance &&
+ mpPageItem->GetPageUsage() != SVX_PAGE_MIRROR )
+ mpToolBoxMargin->SetItemImage( nIdMargin, mpPageItem->IsLandscape() ? mImgWide_L : mImgWide );
+
+ else if( std::abs(mpPageLRMarginItem->GetLeft() - SWPAGE_WIDE_VALUE3) <= cTolerance &&
+ std::abs(mpPageLRMarginItem->GetRight() - SWPAGE_WIDE_VALUE1) <= cTolerance &&
+ std::abs(mpPageULMarginItem->GetUpper() - SWPAGE_WIDE_VALUE1) <= cTolerance &&
+ std::abs(mpPageULMarginItem->GetLower() - SWPAGE_WIDE_VALUE1) <= cTolerance &&
+ mpPageItem->GetPageUsage() == SVX_PAGE_MIRROR )
+ mpToolBoxMargin->SetItemImage( nIdMargin, mpPageItem->IsLandscape() ? mImgMirrored_L : mImgMirrored );
+
+ else
+ mpToolBoxMargin->SetItemImage( nIdMargin, mpPageItem->IsLandscape() ? mImgMarginCustom_L : mImgMarginCustom );
+}
+
+void PagePropertyPanel::ChangeSizeImage()
+{
+ if ( mpPageSizeItem.get() == 0 ||
+ mpPageItem.get() == 0 )
+ {
+ return;
+ }
+
+ Size aTmpPaperSize = mpPageSizeItem->GetSize();
+ if ( mpPageItem->IsLandscape() )
+ {
+ Swap( aTmpPaperSize ); // Swap(..) defined in editeng/paperinf.hxx
+ }
+
+ mePaper = SvxPaperInfo::GetSvxPaper( aTmpPaperSize, static_cast<MapUnit>(meUnit), true );
+
+ sal_uInt16 nImageIdx = 0;
+ switch ( mePaper )
+ {
+ case PAPER_A3:
+ nImageIdx = 1;
+ break;
+ case PAPER_A4:
+ nImageIdx = 2;
+ break;
+ case PAPER_A5:
+ nImageIdx = 3;
+ break;
+ case PAPER_B4_ISO:
+ nImageIdx = 4;
+ break;
+ case PAPER_B5_ISO:
+ nImageIdx = 5;
+ break;
+ case PAPER_ENV_C5:
+ nImageIdx = 6;
+ break;
+ case PAPER_LETTER:
+ nImageIdx = 7;
+ break;
+ case PAPER_LEGAL:
+ nImageIdx = 8;
+ break;
+ default:
+ nImageIdx = 0;
+ mePaper = PAPER_USER;
+ break;
+ }
+
+ const sal_uInt16 nIdSize = mpToolBoxSize->GetItemId(UNO_SIZE);
+
+ if ( nImageIdx == 0 )
+ {
+ mpToolBoxSize->SetItemImage( nIdSize,
+ ( mpPageItem->IsLandscape() ? mImgSizeNone_L : mImgSizeNone ) );
+ }
+ else
+ {
+ mpToolBoxSize->SetItemImage( nIdSize,
+ ( mpPageItem->IsLandscape() ? maImgSize_L[nImageIdx-1] : maImgSize[nImageIdx-1] ) );
+ }
+}
+
+void PagePropertyPanel::ChangeColumnImage( const sal_uInt16 nColumnType )
+{
+ if ( mpPageItem.get() == 0 )
+ {
+ return;
+ }
+
+ const sal_uInt16 nIdColumn = mpToolBoxColumn->GetItemId(UNO_COLUMN);
+ if ( !mpPageItem->IsLandscape() )
+ {
+ switch( nColumnType )
+ {
+ case 1:
+ mpToolBoxColumn->SetItemImage(nIdColumn, mImgColumn1);
+ break;
+ case 2:
+ mpToolBoxColumn->SetItemImage(nIdColumn, mImgColumn2);
+ break;
+ case 3:
+ mpToolBoxColumn->SetItemImage(nIdColumn, mImgColumn3);
+ break;
+ case 4:
+ mpToolBoxColumn->SetItemImage(nIdColumn, mImgLeft);
+ break;
+ case 5:
+ mpToolBoxColumn->SetItemImage(nIdColumn, mImgRight);
+ break;
+ default:
+ mpToolBoxColumn->SetItemImage(nIdColumn, mImgColumnNone);
+ }
+ }
+ else
+ {
+ switch( nColumnType )
+ {
+ case 1:
+ mpToolBoxColumn->SetItemImage(nIdColumn, mImgColumn1_L);
+ break;
+ case 2:
+ mpToolBoxColumn->SetItemImage(nIdColumn, mImgColumn2_L);
+ break;
+ case 3:
+ mpToolBoxColumn->SetItemImage(nIdColumn, mImgColumn3_L);
+ break;
+ case 4:
+ mpToolBoxColumn->SetItemImage(nIdColumn, mImgLeft_L);
+ break;
+ case 5:
+ mpToolBoxColumn->SetItemImage(nIdColumn, mImgRight_L);
+ break;
+ default:
+ mpToolBoxColumn->SetItemImage(nIdColumn, mImgColumnNone_L);
+ }
+ }
+}
+
+void PagePropertyPanel::StartUndo()
+{
+ if ( mxUndoManager.is() )
+ {
+ mxUndoManager->enterUndoContext( OUString("") );
+ }
+}
+
+void PagePropertyPanel::EndUndo()
+{
+ if ( mxUndoManager.is() )
+ {
+ mxUndoManager->leaveUndoContext();
+ }
+}
+
+} } // end of namespace ::sw::sidebar
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/sidebar/PagePropertyPanel.hrc b/sw/source/core/uibase/sidebar/PagePropertyPanel.hrc
new file mode 100644
index 000000000000..0f827f0d84fe
--- /dev/null
+++ b/sw/source/core/uibase/sidebar/PagePropertyPanel.hrc
@@ -0,0 +1,188 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <rcid.hrc>
+#include "PropertyPanel.hrc"
+
+// global definitions
+#define IMG_PAGE_PORTRAIT (RC_SIDEBAR_BEGIN + 0)
+#define IMG_PAGE_LANDSCAPE (RC_SIDEBAR_BEGIN + 1)
+#define IMG_PAGE_NARROW (RC_SIDEBAR_BEGIN + 2)
+#define IMG_PAGE_NORMAL (RC_SIDEBAR_BEGIN + 3)
+#define IMG_PAGE_WIDE (RC_SIDEBAR_BEGIN + 4)
+#define IMG_PAGE_MIRRORED (RC_SIDEBAR_BEGIN + 5)
+#define IMG_PAGE_MARGIN_CUSTOM (RC_SIDEBAR_BEGIN + 6)
+#define IMG_PAGE_NARROW_L (RC_SIDEBAR_BEGIN + 7)
+#define IMG_PAGE_NORMAL_L (RC_SIDEBAR_BEGIN + 8)
+#define IMG_PAGE_WIDE_L (RC_SIDEBAR_BEGIN + 9)
+#define IMG_PAGE_MIRRORED_L (RC_SIDEBAR_BEGIN + 10)
+#define IMG_PAGE_MARGIN_CUSTOM_L (RC_SIDEBAR_BEGIN+ 11)
+#define IMG_PAGE_A3 (RC_SIDEBAR_BEGIN + 12)
+#define IMG_PAGE_A4 (RC_SIDEBAR_BEGIN + 13)
+#define IMG_PAGE_A5 (RC_SIDEBAR_BEGIN + 14)
+#define IMG_PAGE_B4 (RC_SIDEBAR_BEGIN + 15)
+#define IMG_PAGE_B5 (RC_SIDEBAR_BEGIN + 16)
+#define IMG_PAGE_C5 (RC_SIDEBAR_BEGIN + 17)
+#define IMG_PAGE_LETTER (RC_SIDEBAR_BEGIN + 18)
+#define IMG_PAGE_LEGAL (RC_SIDEBAR_BEGIN + 19)
+#define IMG_PAGE_SIZE_NONE (RC_SIDEBAR_BEGIN + 20)
+#define IMG_PAGE_A3_L (RC_SIDEBAR_BEGIN + 21)
+#define IMG_PAGE_A4_L (RC_SIDEBAR_BEGIN + 22)
+#define IMG_PAGE_A5_L (RC_SIDEBAR_BEGIN + 23)
+#define IMG_PAGE_B4_L (RC_SIDEBAR_BEGIN + 24)
+#define IMG_PAGE_B5_L (RC_SIDEBAR_BEGIN + 25)
+#define IMG_PAGE_C5_L (RC_SIDEBAR_BEGIN + 26)
+#define IMG_PAGE_LETTER_L (RC_SIDEBAR_BEGIN + 27)
+#define IMG_PAGE_LEGAL_L (RC_SIDEBAR_BEGIN + 28)
+#define IMG_PAGE_SIZE_NONE_L (RC_SIDEBAR_BEGIN + 29)
+#define IMG_PAGE_COLUMN_1 (RC_SIDEBAR_BEGIN + 30)
+#define IMG_PAGE_COLUMN_2 (RC_SIDEBAR_BEGIN + 31)
+#define IMG_PAGE_COLUMN_3 (RC_SIDEBAR_BEGIN + 32)
+#define IMG_PAGE_COLUMN_LEFT (RC_SIDEBAR_BEGIN + 33)
+#define IMG_PAGE_COLUMN_RIGHT (RC_SIDEBAR_BEGIN + 34)
+#define IMG_PAGE_COLUMN_NONE (RC_SIDEBAR_BEGIN + 35)
+#define IMG_PAGE_COLUMN_1_L (RC_SIDEBAR_BEGIN + 36)
+#define IMG_PAGE_COLUMN_2_L (RC_SIDEBAR_BEGIN + 37)
+#define IMG_PAGE_COLUMN_3_L (RC_SIDEBAR_BEGIN + 38)
+#define IMG_PAGE_COLUMN_LEFT_L (RC_SIDEBAR_BEGIN + 39)
+#define IMG_PAGE_COLUMN_RIGHT_L (RC_SIDEBAR_BEGIN + 40)
+#define IMG_PAGE_COLUMN_NONE_L (RC_SIDEBAR_BEGIN + 41)
+
+// local
+#define IMG_PORTRAIT 10
+#define IMG_LANDSCAPE 11
+#define STR_PORTRAIT 12
+#define STR_LANDSCAPE 13
+#define ED_SWPAPER_WIDTH 14
+#define ED_SWPAPER_HEIGHT 15
+#define LB_SWPAPER_TRAY 16
+#define LB_SWPAPER_SIZE 17
+#define MF_SWLEFT_MARGIN 18
+#define MF_SWRIGHT_MARGIN 19
+#define MF_SWTOP_MARGIN 20
+#define MF_SWBOTTOM_MARGIN 21
+#define VS_SIZE 23
+#define STR_LCVALUE 24
+#define FT_CUSTOM 25
+#define FLD_WIDTH_HEIGHT 26
+
+#define VS_ORIENTATION 29
+#define IMG_NARROW 32
+#define IMG_NORMAL 33
+#define IMG_WIDE 34
+#define IMG_MIRRORED 35
+#define STR_NARROW 36
+#define STR_NORMAL 37
+#define STR_WIDE 38
+#define STR_MIRRORED 39
+#define VS_MARGIN 40
+#define IMG_CUSTOM 41
+#define FT_LEFT 42
+#define FT_RIGHT 43
+#define FT_TOP 44
+#define FT_BOTTOM 45
+#define FT_INNER 46
+#define FT_OUTER 47
+#define VS_COLUMN 49
+#define MBOX_WIDTH 50
+#define IMG_ONE 51
+#define IMG_TWO 52
+#define IMG_THREE 53
+#define IMG_LEFT 54
+#define IMG_RIGHT 55
+#define STR_ONE 56
+#define STR_TWO 57
+#define STR_THREE 58
+#define STR_LEFT 59
+#define STR_RIGHT 60
+#define CB_COLUMN_MORE 61
+
+#define CB_SIZE_MORE 61
+
+#define IMG_ONE_L 90
+#define IMG_TWO_L 91
+#define IMG_THREE_L 92
+#define IMG_LEFT_L 93
+#define IMG_RIGHT_L 94
+#define IMG_NARROW_L 109
+#define IMG_NORMAL_L 110
+#define IMG_WIDE_L 111
+#define IMG_MIRRORED_L 112
+#define FLD_LEFT_MARGIN 113
+#define FLD_RIGHT_MARGIN 114
+#define FLD_TOP_MARGIN 115
+#define FLD_BOTTOM_MARGIN 116
+
+#define IMG_CUSTOM_DIS 121
+
+#define STR_MARGIN_TOOLTIP_LEFT 122
+#define STR_MARGIN_TOOLTIP_RIGHT 123
+#define STR_MARGIN_TOOLTIP_INNER 124
+#define STR_MARGIN_TOOLTIP_OUTER 125
+#define STR_MARGIN_TOOLTIP_TOP 126
+#define STR_MARGIN_TOOLTIP_BOT 127
+
+#define POPUP_MARGIN 4
+#define VS_WIDTH 78
+#define ITEM_HEIGHT 17
+#define ITEM_HEIGHT2 15
+
+//========================================Position==============================================
+
+#define FT_ORIENTATION_X SECTIONPAGE_MARGIN_HORIZONTAL
+#define FT_ORIENTATION_Y SECTIONPAGE_MARGIN_VERTICAL_TOP
+#define TBX_ORIENTATION_X FT_ORIENTATION_X
+#define TBX_ORIENTATION_Y FT_ORIENTATION_Y + TEXT_HEIGHT + TEXT_CONTROL_SPACING_VERTICAL
+#define FT_MARGIN_X FT_ORIENTATION_X + MBOX_WIDTH + CONTROL_SPACING_HORIZONTAL
+#define FT_MARGIN_Y FT_ORIENTATION_Y
+#define TBX_MARGIN_X FT_MARGIN_X
+#define TBX_MARGIN_Y TBX_ORIENTATION_Y
+#define FT_SIZE_X FT_ORIENTATION_X
+#define FT_SIZE_Y TBX_ORIENTATION_Y + 20 + CONTROL_SPACING_VERTICAL
+#define TBX_SIZE_X FT_SIZE_X
+#define TBX_SIZE_Y FT_SIZE_Y + TEXT_HEIGHT + TEXT_CONTROL_SPACING_VERTICAL
+#define FT_COLUMN_X FT_MARGIN_X
+#define FT_COLUMN_Y FT_SIZE_Y
+#define TBX_COLUMN_X FT_COLUMN_X
+#define TBX_COLUMN_Y TBX_SIZE_Y
+
+#define FT_CUSTOM_X POPUP_MARGIN + OFFSET_X
+#define FT_CUSTOM_Y POPUPPANEL_MARGIN_SMALL * 2 + ITEM_HEIGHT * 5
+
+#define POP_BORDER_X POPUP_MARGIN + OFFSET_X + 1
+#define POP_BORDER_Y POPUPPANEL_MARGIN_SMALL * 3 + ITEM_HEIGHT * 5 + TEXT_HEIGHT
+#define BD_WIDTH VS_WIDTH - 6
+#define BD_HEIGHT MBOX_HEIGHT*4 + CONTROL_SPACING_VERTICAL*5
+
+#define FT_X POP_BORDER_X + CONTROL_SPACING_HORIZONTAL
+#define MF_X FT_X + 25 + CONTROL_SPACING_HORIZONTAL
+#define LEFT_MF_Y POP_BORDER_Y + CONTROL_SPACING_VERTICAL
+#define RIGHT_MF_Y LEFT_MF_Y + MBOX_HEIGHT + CONTROL_SPACING_VERTICAL
+#define TOP_MF_Y RIGHT_MF_Y + MBOX_HEIGHT + CONTROL_SPACING_VERTICAL
+#define BOTTOM_MF_Y TOP_MF_Y + MBOX_HEIGHT + CONTROL_SPACING_VERTICAL
+#define FT_LEFT_Y LEFT_MF_Y + 1
+#define FT_RIGHT_Y RIGHT_MF_Y + 1
+#define FT_TOP_Y TOP_MF_Y + 1
+#define FT_BOTTOM_Y BOTTOM_MF_Y + 1
+
+#define MARGIN_PANEL_HEIGHT POP_BORDER_Y + BD_HEIGHT + POPUP_MARGIN + OFFSET_Y
+#define CUST_MORE_BUTTON_IMG_OFF_X POPUPPANEL_MARGIN_HORIZONTAL + OFFSET_X
+#define PAGE_HEIGHT TBX_COLUMN_Y + 20 + SECTIONPAGE_MARGIN_VERTICAL_BOT
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/sidebar/PagePropertyPanel.hxx b/sw/source/core/uibase/sidebar/PagePropertyPanel.hxx
new file mode 100644
index 000000000000..d7b6e57153e0
--- /dev/null
+++ b/sw/source/core/uibase/sidebar/PagePropertyPanel.hxx
@@ -0,0 +1,223 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_SIDEBAR_PAGEPROPERTYPANEL_HXX
+#define INCLUDED_SW_SOURCE_UI_SIDEBAR_PAGEPROPERTYPANEL_HXX
+
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/document/XUndoManager.hpp>
+
+#include <svx/sidebar/Popup.hxx>
+#include <svx/sidebar/PanelLayout.hxx>
+
+#include <sfx2/sidebar/ControllerItem.hxx>
+
+namespace svx { namespace sidebar {
+ class PopupControl;
+} }
+
+#include <i18nutil/paper.hxx>
+
+#include <svx/pageitem.hxx>
+#include <svx/rulritem.hxx>
+#include <editeng/sizeitem.hxx>
+
+#include <vcl/ctrl.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/button.hxx>
+#include <vcl/toolbox.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/field.hxx>
+#include <svl/intitem.hxx>
+
+#include <boost/scoped_ptr.hpp>
+
+namespace cssu = ::com::sun::star::uno;
+
+namespace sw { namespace sidebar {
+
+ class PagePropertyPanel
+ : public PanelLayout,
+ public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface
+ {
+ public:
+ static PagePropertyPanel* Create(
+ Window* pParent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame>& rxFrame,
+ SfxBindings* pBindings );
+
+ // interface of ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface
+ virtual void NotifyItemUpdate(
+ const sal_uInt16 nSId,
+ const SfxItemState eState,
+ const SfxPoolItem* pState,
+ const bool bIsEnabled);
+
+ SfxBindings* GetBindings() const
+ {
+ return mpBindings;
+ }
+
+ ::svx::sidebar::PopupControl* CreatePageOrientationControl( ::svx::sidebar::PopupContainer* pParent );
+ void ExecuteOrientationChange( const sal_Bool bLandscape );
+ void ClosePageOrientationPopup();
+
+ ::svx::sidebar::PopupControl* CreatePageMarginControl( ::svx::sidebar::PopupContainer* pParent );
+ void ExecuteMarginLRChange(
+ const long nPageLeftMargin,
+ const long nPageRightMargin );
+ void ExecuteMarginULChange(
+ const long nPageTopMargin,
+ const long nPageBottomMargin );
+ void ExecutePageLayoutChange( const bool bMirrored );
+ void ClosePageMarginPopup();
+
+ ::svx::sidebar::PopupControl* CreatePageSizeControl( ::svx::sidebar::PopupContainer* pParent );
+ void ExecuteSizeChange( const Paper ePaper );
+ void ClosePageSizePopup();
+
+ ::svx::sidebar::PopupControl* CreatePageColumnControl( ::svx::sidebar::PopupContainer* pParent );
+ void ExecuteColumnChange( const sal_uInt16 nColumnType );
+ void ClosePageColumnPopup();
+
+ void StartUndo();
+ void EndUndo();
+
+ private:
+ PagePropertyPanel(
+ Window* pParent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame>& rxFrame,
+ SfxBindings* pBindings );
+ virtual ~PagePropertyPanel(void);
+
+ SfxBindings* mpBindings;
+
+ // toolboxes - on click open corresponding popup
+ ToolBox* mpToolBoxOrientation;
+ ToolBox* mpToolBoxMargin;
+ ToolBox* mpToolBoxSize;
+ ToolBox* mpToolBoxColumn;
+
+ Image* maImgSize;
+ Image* maImgSize_L;
+ Image mImgPortrait;
+ Image mImgLandscape;
+ Image mImgNarrow;
+ Image mImgNormal;
+ Image mImgWide;
+ Image mImgMirrored;
+ Image mImgMarginCustom;
+ Image mImgNarrow_L;
+ Image mImgNormal_L;
+ Image mImgWide_L;
+ Image mImgMirrored_L;
+ Image mImgMarginCustom_L;
+ Image mImgA3;
+ Image mImgA4;
+ Image mImgA5;
+ Image mImgB4;
+ Image mImgB5;
+ Image mImgC5;
+ Image mImgLetter;
+ Image mImgLegal;
+ Image mImgSizeNone;
+ Image mImgA3_L;
+ Image mImgA4_L;
+ Image mImgA5_L;
+ Image mImgB4_L;
+ Image mImgB5_L;
+ Image mImgC5_L;
+ Image mImgLetter_L;
+ Image mImgLegal_L;
+ Image mImgSizeNone_L;
+ Image mImgColumn1;
+ Image mImgColumn2;
+ Image mImgColumn3;
+ Image mImgLeft;
+ Image mImgRight;
+ Image mImgColumnNone;
+ Image mImgColumn1_L;
+ Image mImgColumn2_L;
+ Image mImgColumn3_L;
+ Image mImgLeft_L;
+ Image mImgRight_L;
+ Image mImgColumnNone_L;
+
+ // item keeping the following page style attributes:
+ // - page orientation
+ // - page usage - only left, only right, both, mirrored
+ // item also hold the numbering type for the page style which should
+ // be kept stable.
+ ::boost::scoped_ptr<SvxPageItem> mpPageItem;
+
+ // item keeping the page style's left and right margins
+ ::boost::scoped_ptr<SvxLongLRSpaceItem> mpPageLRMarginItem;
+ // item keeping the page style's top and bottom margins
+ ::boost::scoped_ptr<SvxLongULSpaceItem> mpPageULMarginItem;
+
+ // item keeping the page style's page size
+ ::boost::scoped_ptr<SvxSizeItem> mpPageSizeItem;
+ // Paper corresponding to the page style's page size
+ Paper mePaper;
+
+ // item keeping the page column type
+ ::boost::scoped_ptr<SfxInt16Item> mpPageColumnTypeItem;
+
+ FieldUnit meFUnit;
+ SfxMapUnit meUnit;
+
+ // controller items
+ ::sfx2::sidebar::ControllerItem m_aSwPagePgULControl;
+ ::sfx2::sidebar::ControllerItem m_aSwPagePgLRControl;
+ ::sfx2::sidebar::ControllerItem m_aSwPagePgSizeControl;
+ ::sfx2::sidebar::ControllerItem m_aSwPagePgControl;
+ ::sfx2::sidebar::ControllerItem m_aSwPageColControl;
+ ::sfx2::sidebar::ControllerItem m_aSwPagePgMetricControl;
+
+ // popups
+ ::svx::sidebar::Popup maOrientationPopup;
+ ::svx::sidebar::Popup maMarginPopup;
+ ::svx::sidebar::Popup maSizePopup;
+ ::svx::sidebar::Popup maColumnPopup;
+
+ const cssu::Reference< css::document::XUndoManager > mxUndoManager;
+
+ bool mbInvalidateSIDAttrPageOnSIDAttrPageSizeNotify;
+
+ // handler for popup toolboxes to show the popups
+ DECL_LINK(ClickOrientationHdl, ToolBox* );
+ DECL_LINK(ClickMarginHdl, ToolBox* );
+ DECL_LINK(ClickSizeHdl, ToolBox* );
+ DECL_LINK(ClickColumnHdl, ToolBox* );
+
+ void Initialize();
+
+ void MetricState( SfxItemState eState, const SfxPoolItem* pState );
+
+ // helper to adjust popup toolbox' images
+ void ChangeMarginImage();
+ void ChangeSizeImage();
+ void ChangeColumnImage( const sal_uInt16 nColumnType );
+
+ };
+
+} } // end of namespace ::sw::sidebar
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/sidebar/PageSizeControl.cxx b/sw/source/core/uibase/sidebar/PageSizeControl.cxx
new file mode 100644
index 000000000000..038e033235f2
--- /dev/null
+++ b/sw/source/core/uibase/sidebar/PageSizeControl.cxx
@@ -0,0 +1,177 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "PageSizeControl.hxx"
+#include "PagePropertyPanel.hxx"
+#include "PagePropertyPanel.hrc"
+
+#include <cmdid.h>
+#include <swtypes.hxx>
+
+#include <svx/sidebar/ValueSetWithTextControl.hxx>
+
+#include <rtl/character.hxx>
+#include <editeng/paperinf.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+
+#include <vcl/settings.hxx>
+
+namespace sw { namespace sidebar {
+
+PageSizeControl::PageSizeControl(
+ Window* pParent,
+ PagePropertyPanel& rPanel,
+ const Paper ePaper,
+ const sal_Bool bLandscape,
+ const FieldUnit eFUnit )
+ : ::svx::sidebar::PopupControl( pParent, SW_RES(RID_POPUP_SWPAGE_SIZE) )
+ , mpSizeValueSet( new ::svx::sidebar::ValueSetWithTextControl( ::svx::sidebar::ValueSetWithTextControl::TEXT_TEXT, this, SW_RES(VS_SIZE) ) )
+ , maMoreButton( this, SW_RES(CB_SIZE_MORE) )
+ , maWidthHeightField( this, SW_RES(FLD_WIDTH_HEIGHT) )
+ , mePaper( ePaper )
+ , maPaperList()
+ , mrPagePropPanel(rPanel)
+{
+ maWidthHeightField.Hide();
+ SetFieldUnit( maWidthHeightField, eFUnit );
+
+ maPaperList.push_back( PAPER_A3 );
+ maPaperList.push_back( PAPER_A4 );
+ maPaperList.push_back( PAPER_A5 );
+ maPaperList.push_back( PAPER_B4_ISO );
+ maPaperList.push_back( PAPER_B5_ISO );
+ maPaperList.push_back( PAPER_ENV_C5 );
+ maPaperList.push_back( PAPER_LETTER );
+ maPaperList.push_back( PAPER_LEGAL );
+
+ mpSizeValueSet->SetStyle( mpSizeValueSet->GetStyle() | WB_3DLOOK | WB_NO_DIRECTSELECT );
+ mpSizeValueSet->SetColor( GetSettings().GetStyleSettings().GetMenuColor() );
+
+ sal_uInt16 nSelectedItem = 0;
+ {
+ OUString aMetricStr;
+ {
+ const OUString aText = maWidthHeightField.GetText();
+ for (short i = aText.getLength() - 1; i >= 0; i--)
+ {
+ sal_Unicode c = aText[i];
+ if ( rtl::isAsciiAlpha(c) || (c == '\'') || (c == '\"') || (c == '%') )
+ {
+ aMetricStr = OUString(c) + aMetricStr;
+ }
+ else
+ {
+ if (!aMetricStr.isEmpty())
+ {
+ break;
+ }
+ }
+ }
+ }
+
+ const LocaleDataWrapper& localeDataWrapper = maWidthHeightField.GetLocaleDataWrapper();
+ OUString aWidthStr;
+ OUString aHeightStr;
+ OUString aItemText2;
+ for ( ::std::vector< Paper >::size_type nPaperIdx = 0;
+ nPaperIdx < maPaperList.size();
+ ++nPaperIdx )
+ {
+ Size aPaperSize = SvxPaperInfo::GetPaperSize( maPaperList[ nPaperIdx ] );
+ if ( bLandscape )
+ {
+ Swap( aPaperSize );
+ }
+ maWidthHeightField.SetValue( maWidthHeightField.Normalize( aPaperSize.Width() ), FUNIT_TWIP );
+ aWidthStr = localeDataWrapper.getNum(
+ maWidthHeightField.GetValue(),
+ maWidthHeightField.GetDecimalDigits(),
+ maWidthHeightField.IsUseThousandSep(),
+ maWidthHeightField.IsShowTrailingZeros() );
+
+ maWidthHeightField.SetValue( maWidthHeightField.Normalize( aPaperSize.Height() ), FUNIT_TWIP);
+ aHeightStr = localeDataWrapper.getNum(
+ maWidthHeightField.GetValue(),
+ maWidthHeightField.GetDecimalDigits(),
+ maWidthHeightField.IsUseThousandSep(),
+ maWidthHeightField.IsShowTrailingZeros() );
+
+ aItemText2 = aWidthStr + " x " + aHeightStr + " " + aMetricStr;
+
+ mpSizeValueSet->AddItem(
+ SvxPaperInfo::GetName( maPaperList[ nPaperIdx ] ),
+ aItemText2,
+ 0 );
+
+ if ( maPaperList[ nPaperIdx ] == mePaper )
+ {
+ nSelectedItem = nPaperIdx + 1;
+ }
+ }
+ }
+
+ mpSizeValueSet->SetNoSelection();
+ mpSizeValueSet->SetSelectHdl( LINK(this, PageSizeControl,ImplSizeHdl ) );
+ mpSizeValueSet->Show();
+
+ mpSizeValueSet->SelectItem( nSelectedItem );
+ mpSizeValueSet->Format();
+ mpSizeValueSet->StartSelection();
+
+ maMoreButton.SetClickHdl( LINK( this, PageSizeControl, MoreButtonClickHdl_Impl ) );
+ maMoreButton.GrabFocus();
+
+ FreeResource();
+}
+
+PageSizeControl::~PageSizeControl(void)
+{
+ delete mpSizeValueSet;
+}
+
+IMPL_LINK(PageSizeControl, ImplSizeHdl, void *, pControl)
+{
+ mpSizeValueSet->SetNoSelection();
+ if ( pControl == mpSizeValueSet )
+ {
+ const sal_uInt16 nSelectedPaper = mpSizeValueSet->GetSelectItemId();
+ const Paper ePaper = maPaperList[nSelectedPaper - 1];
+ if ( ePaper != mePaper )
+ {
+ mePaper = ePaper;
+ mrPagePropPanel.ExecuteSizeChange( mePaper );
+ }
+ }
+
+ mrPagePropPanel.ClosePageSizePopup();
+ return 0;
+}
+
+IMPL_LINK(PageSizeControl, MoreButtonClickHdl_Impl, void *, EMPTYARG)
+{
+ mrPagePropPanel.GetBindings()->GetDispatcher()->Execute( FN_FORMAT_PAGE_SETTING_DLG, SFX_CALLMODE_ASYNCHRON );
+
+ mrPagePropPanel.ClosePageSizePopup();
+ return 0;
+}
+
+} } // end of namespace sw::sidebar
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/sidebar/PageSizeControl.hxx b/sw/source/core/uibase/sidebar/PageSizeControl.hxx
new file mode 100644
index 000000000000..e1f0313a3649
--- /dev/null
+++ b/sw/source/core/uibase/sidebar/PageSizeControl.hxx
@@ -0,0 +1,71 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_SIDEBAR_PAGESIZECONTROL_HXX
+#define INCLUDED_SW_SOURCE_UI_SIDEBAR_PAGESIZECONTROL_HXX
+
+#include <svx/sidebar/PopupControl.hxx>
+
+#include <i18nutil/paper.hxx>
+
+#include <vcl/button.hxx>
+#include <vcl/field.hxx>
+#include <svtools/unitconv.hxx>
+
+#include <vector>
+
+namespace svx { namespace sidebar {
+ class ValueSetWithTextControl;
+} }
+
+namespace sw { namespace sidebar {
+
+class PagePropertyPanel;
+
+class PageSizeControl
+ : public ::svx::sidebar::PopupControl
+{
+public:
+ PageSizeControl(
+ Window* pParent,
+ PagePropertyPanel& rPanel,
+ const Paper ePaper,
+ const sal_Bool bLandscape,
+ const FieldUnit eFUnit );
+ ~PageSizeControl(void);
+
+private:
+ ::svx::sidebar::ValueSetWithTextControl* mpSizeValueSet;
+ PushButton maMoreButton;
+ // hidden metric field
+ MetricField maWidthHeightField;
+
+ Paper mePaper;
+ ::std::vector< Paper > maPaperList;
+
+ PagePropertyPanel& mrPagePropPanel;
+
+ DECL_LINK(ImplSizeHdl, void*);
+ DECL_LINK(MoreButtonClickHdl_Impl, void*);
+};
+
+} } // end of namespace sw::sidebar
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/sidebar/PropertyPanel.hrc b/sw/source/core/uibase/sidebar/PropertyPanel.hrc
new file mode 100644
index 000000000000..b374ab3dc96b
--- /dev/null
+++ b/sw/source/core/uibase/sidebar/PropertyPanel.hrc
@@ -0,0 +1,35 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef _SW_PROPERTY_PANEL_HRC
+#define _SW_PROPERTY_PANEL_HRC
+
+#include "rcid.hrc"
+
+#define RID_PROPERTYPANEL_SWOBJWRAP_PAGE (RC_PROPERTYPANEL_BEGIN + 1)
+#define RID_PROPERTYPANEL_SWPAGE (RC_PROPERTYPANEL_BEGIN + 2)
+#define RID_POPUP_SWPAGE_MARGIN (RC_PROPERTYPANEL_BEGIN + 3)
+#define RID_POPUP_SWPAGE_ORIENTATION (RC_PROPERTYPANEL_BEGIN + 4)
+#define RID_POPUP_SWPAGE_COLUMN (RC_PROPERTYPANEL_BEGIN + 5)
+#define RID_POPUP_SWPAGE_SIZE (RC_PROPERTYPANEL_BEGIN + 6)
+
+#define PROPERTY_PANEL_END RID_POPUP_SWPAGE_SIZE
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/sidebar/SwPanelFactory.cxx b/sw/source/core/uibase/sidebar/SwPanelFactory.cxx
new file mode 100644
index 000000000000..18220cdbdf80
--- /dev/null
+++ b/sw/source/core/uibase/sidebar/SwPanelFactory.cxx
@@ -0,0 +1,148 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <com/sun/star/ui/XUIElementFactory.hpp>
+
+#include <PagePropertyPanel.hxx>
+#include <WrapPropertyPanel.hxx>
+#include <navipi.hxx>
+
+#include <sfx2/sidebar/SidebarPanelBase.hxx>
+#include <sfx2/sfxbasecontroller.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <vcl/window.hxx>
+#include <rtl/ref.hxx>
+#include <comphelper/namedvaluecollection.hxx>
+#include <cppuhelper/compbase1.hxx>
+#include <cppuhelper/basemutex.hxx>
+
+#include <boost/bind.hpp>
+#include <boost/noncopyable.hpp>
+
+using namespace css;
+using namespace css::uno;
+
+namespace {
+
+typedef ::cppu::WeakComponentImplHelper1 <
+ css::ui::XUIElementFactory
+ > PanelFactoryInterfaceBase;
+
+class SwPanelFactory
+ : private ::boost::noncopyable,
+ private ::cppu::BaseMutex,
+ public PanelFactoryInterfaceBase
+{
+public:
+ SwPanelFactory(void);
+ virtual ~SwPanelFactory(void);
+
+ // XUIElementFactory
+ cssu::Reference<css::ui::XUIElement> SAL_CALL createUIElement(
+ const ::rtl::OUString& rsResourceURL,
+ const ::cssu::Sequence<css::beans::PropertyValue>& rArguments)
+ throw(
+ css::container::NoSuchElementException,
+ css::lang::IllegalArgumentException,
+ cssu::RuntimeException, std::exception );
+};
+
+SwPanelFactory::SwPanelFactory (void)
+ : PanelFactoryInterfaceBase(m_aMutex)
+{
+}
+
+SwPanelFactory::~SwPanelFactory (void)
+{
+}
+
+Reference<ui::XUIElement> SAL_CALL SwPanelFactory::createUIElement (
+ const ::rtl::OUString& rsResourceURL,
+ const ::cssu::Sequence<css::beans::PropertyValue>& rArguments)
+ throw(
+ container::NoSuchElementException,
+ lang::IllegalArgumentException,
+ RuntimeException, std::exception)
+{
+ Reference<ui::XUIElement> xElement;
+
+ const ::comphelper::NamedValueCollection aArguments (rArguments);
+ Reference<frame::XFrame> xFrame (aArguments.getOrDefault("Frame", Reference<frame::XFrame>()));
+ Reference<awt::XWindow> xParentWindow (aArguments.getOrDefault("ParentWindow", Reference<awt::XWindow>()));
+ const sal_uInt64 nBindingsValue (aArguments.getOrDefault("SfxBindings", sal_uInt64(0)));
+ SfxBindings* pBindings = reinterpret_cast<SfxBindings*>(nBindingsValue);
+
+ ::Window* pParentWindow = VCLUnoHelper::GetWindow(xParentWindow);
+ if ( ! xParentWindow.is() || pParentWindow==NULL)
+ throw RuntimeException(
+ "PanelFactory::createUIElement called without ParentWindow",
+ NULL);
+ if ( ! xFrame.is())
+ throw RuntimeException(
+ "PanelFactory::createUIElement called without Frame",
+ NULL);
+ if (pBindings == NULL)
+ throw RuntimeException(
+ "PanelFactory::createUIElement called without SfxBindings",
+ NULL);
+
+#define DoesResourceEndWith(s) rsResourceURL.endsWithAsciiL(s,strlen(s))
+ if (DoesResourceEndWith("/PagePropertyPanel"))
+ {
+ sw::sidebar::PagePropertyPanel* pPanel = sw::sidebar::PagePropertyPanel::Create( pParentWindow, xFrame, pBindings );
+ xElement = sfx2::sidebar::SidebarPanelBase::Create(
+ rsResourceURL,
+ xFrame,
+ pPanel,
+ ui::LayoutSize(-1,-1,-1));
+ }
+ else if (DoesResourceEndWith("/WrapPropertyPanel"))
+ {
+ sw::sidebar::WrapPropertyPanel* pPanel = sw::sidebar::WrapPropertyPanel::Create( pParentWindow, xFrame, pBindings );
+ xElement = sfx2::sidebar::SidebarPanelBase::Create(
+ rsResourceURL,
+ xFrame,
+ pPanel,
+ ui::LayoutSize(-1,-1,-1));
+ }
+ else if (DoesResourceEndWith("/NavigatorPanel"))
+ {
+ Window* pPanel = new SwNavigationPI(pBindings, NULL, pParentWindow);
+ xElement = sfx2::sidebar::SidebarPanelBase::Create(
+ rsResourceURL,
+ xFrame,
+ pPanel,
+ ui::LayoutSize(0,-1,-1));
+ }
+#undef DoesResourceEndWith
+
+ return xElement;
+}
+
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
+org_apache_openoffice_comp_sw_sidebar_SwPanelFactory_get_implementation(
+ css::uno::XComponentContext *,
+ css::uno::Sequence<css::uno::Any> const &)
+{
+ return cppu::acquire(new SwPanelFactory());
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/sidebar/WrapPropertyPanel.cxx b/sw/source/core/uibase/sidebar/WrapPropertyPanel.cxx
new file mode 100644
index 000000000000..6d4e8526f6fc
--- /dev/null
+++ b/sw/source/core/uibase/sidebar/WrapPropertyPanel.cxx
@@ -0,0 +1,243 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "WrapPropertyPanel.hxx"
+#include "PropertyPanel.hrc"
+
+#include <cmdid.h>
+#include <swtypes.hxx>
+
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/sidebar/ControlFactory.hxx>
+#include <sfx2/imagemgr.hxx>
+#include <svl/eitem.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/settings.hxx>
+
+#include "com/sun/star/lang/IllegalArgumentException.hpp"
+
+const char UNO_WRAPOFF[] = ".uno:WrapOff";
+const char UNO_WRAPLEFT[] = ".uno:WrapLeft";
+const char UNO_WRAPRIGHT[] = ".uno:WrapRight";
+const char UNO_WRAPON[] = ".uno:WrapOn";
+const char UNO_WRAPTHROUGH[] = ".uno:WrapThrough";
+const char UNO_WRAPIDEAL[] = ".uno:WrapIdeal";
+
+namespace sw { namespace sidebar {
+
+WrapPropertyPanel* WrapPropertyPanel::Create (
+ Window* pParent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxFrame,
+ SfxBindings* pBindings)
+{
+ if (pParent == NULL)
+ throw ::com::sun::star::lang::IllegalArgumentException("no parent Window given to WrapPropertyPanel::Create", NULL, 0);
+ if ( ! rxFrame.is())
+ throw ::com::sun::star::lang::IllegalArgumentException("no XFrame given to WrapPropertyPanel::Create", NULL, 1);
+ if (pBindings == NULL)
+ throw ::com::sun::star::lang::IllegalArgumentException("no SfxBindings given to WrapPropertyPanel::Create", NULL, 2);
+
+ return new WrapPropertyPanel(
+ pParent,
+ rxFrame,
+ pBindings);
+}
+
+WrapPropertyPanel::WrapPropertyPanel(
+ Window* pParent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxFrame,
+ SfxBindings* pBindings )
+ : PanelLayout(pParent, "WrapPropertyPanel", "modules/swriter/ui/sidebarwrap.ui", rxFrame)
+ , mxFrame( rxFrame )
+ , mpBindings(pBindings)
+ // resources
+ , aWrapIL(6,2)
+ // controller items
+ , maSwNoWrapControl(FN_FRAME_NOWRAP, *pBindings, *this)
+ , maSwWrapLeftControl(FN_FRAME_WRAP, *pBindings, *this)
+ , maSwWrapRightControl(FN_FRAME_WRAP_RIGHT, *pBindings, *this)
+ , maSwWrapParallelControl(FN_FRAME_WRAP_LEFT, *pBindings, *this)
+ , maSwWrapThroughControl(FN_FRAME_WRAPTHRU, *pBindings, *this)
+ , maSwWrapIdealControl(FN_FRAME_WRAP_IDEAL, *pBindings, *this)
+{
+ get(mpRBNoWrap, "buttonnone");
+ get(mpRBWrapLeft, "buttonbefore");
+ get(mpRBWrapRight, "buttonafter");
+ get(mpRBWrapParallel, "buttonparallel");
+ get(mpRBWrapThrough, "buttonthrough");
+ get(mpRBIdealWrap, "buttonoptimal");
+
+ Initialize();
+}
+
+WrapPropertyPanel::~WrapPropertyPanel()
+{
+}
+
+void WrapPropertyPanel::Initialize()
+{
+ Link aLink = LINK(this, WrapPropertyPanel, WrapTypeHdl);
+ mpRBNoWrap->SetClickHdl(aLink);
+ mpRBWrapLeft->SetClickHdl(aLink);
+ mpRBWrapRight->SetClickHdl(aLink);
+ mpRBWrapParallel->SetClickHdl(aLink);
+ mpRBWrapThrough->SetClickHdl(aLink);
+ mpRBIdealWrap->SetClickHdl(aLink);
+
+ aWrapIL.AddImage( UNO_WRAPOFF,
+ ::GetImage( mxFrame, UNO_WRAPOFF, false ) );
+ aWrapIL.AddImage( UNO_WRAPLEFT,
+ ::GetImage( mxFrame, UNO_WRAPLEFT, false ) );
+ aWrapIL.AddImage( UNO_WRAPRIGHT,
+ ::GetImage( mxFrame, UNO_WRAPRIGHT, false ) );
+ aWrapIL.AddImage( UNO_WRAPON,
+ ::GetImage( mxFrame, UNO_WRAPON, false ) );
+ aWrapIL.AddImage( UNO_WRAPTHROUGH,
+ ::GetImage( mxFrame, UNO_WRAPTHROUGH, false ) );
+ aWrapIL.AddImage( UNO_WRAPIDEAL,
+ ::GetImage( mxFrame, UNO_WRAPIDEAL, false ) );
+
+ mpRBNoWrap->SetModeRadioImage( aWrapIL.GetImage(UNO_WRAPOFF) );
+ if ( Application::GetSettings().GetLayoutRTL() )
+ {
+ mpRBWrapLeft->SetModeRadioImage( aWrapIL.GetImage(UNO_WRAPRIGHT) );
+ mpRBWrapRight->SetModeRadioImage( aWrapIL.GetImage(UNO_WRAPLEFT) );
+ }
+ else
+ {
+ mpRBWrapLeft->SetModeRadioImage( aWrapIL.GetImage(UNO_WRAPLEFT) );
+ mpRBWrapRight->SetModeRadioImage( aWrapIL.GetImage(UNO_WRAPRIGHT) );
+ }
+ mpRBWrapParallel->SetModeRadioImage( aWrapIL.GetImage(UNO_WRAPON) );
+ mpRBWrapThrough->SetModeRadioImage( aWrapIL.GetImage(UNO_WRAPTHROUGH) );
+ mpRBIdealWrap->SetModeRadioImage( aWrapIL.GetImage(UNO_WRAPIDEAL) );
+
+ mpRBNoWrap->SetAccessibleName(mpRBNoWrap->GetQuickHelpText());
+ mpRBWrapLeft->SetAccessibleName(mpRBWrapLeft->GetQuickHelpText());
+ mpRBWrapRight->SetAccessibleName(mpRBWrapRight->GetQuickHelpText());
+ mpRBWrapParallel->SetAccessibleName(mpRBWrapParallel->GetQuickHelpText());
+ mpRBWrapThrough->SetAccessibleName(mpRBWrapThrough->GetQuickHelpText());
+ mpRBIdealWrap->SetAccessibleName(mpRBIdealWrap->GetQuickHelpText());
+
+ mpBindings->Update( FN_FRAME_NOWRAP );
+ mpBindings->Update( FN_FRAME_WRAP );
+ mpBindings->Update( FN_FRAME_WRAP_RIGHT );
+ mpBindings->Update( FN_FRAME_WRAP_LEFT );
+ mpBindings->Update( FN_FRAME_WRAPTHRU );
+ mpBindings->Update( FN_FRAME_WRAP_IDEAL );
+}
+
+IMPL_LINK(WrapPropertyPanel, WrapTypeHdl, void *, EMPTYARG)
+{
+ sal_uInt16 nSlot = 0;
+ if ( mpRBWrapLeft->IsChecked() )
+ {
+ nSlot = FN_FRAME_WRAP_LEFT;
+ }
+ else if( mpRBWrapRight->IsChecked() )
+ {
+ nSlot = FN_FRAME_WRAP_RIGHT;
+ }
+ else if ( mpRBWrapParallel->IsChecked() )
+ {
+ nSlot = FN_FRAME_WRAP;
+ }
+ else if( mpRBWrapThrough->IsChecked() )
+ {
+ nSlot = FN_FRAME_WRAPTHRU;
+ }
+ else if( mpRBIdealWrap->IsChecked() )
+ {
+ nSlot = FN_FRAME_WRAP_IDEAL;
+ }
+ else
+ {
+ nSlot = FN_FRAME_NOWRAP;
+ }
+ SfxBoolItem bStateItem( nSlot, true );
+ mpBindings->GetDispatcher()->Execute( nSlot, SFX_CALLMODE_RECORD, &bStateItem, 0L );
+
+ return 0;
+}
+
+void WrapPropertyPanel::NotifyItemUpdate(
+ const sal_uInt16 nSId,
+ const SfxItemState eState,
+ const SfxPoolItem* pState,
+ const bool bIsEnabled)
+{
+ (void)bIsEnabled;
+
+ if ( eState == SFX_ITEM_AVAILABLE &&
+ pState->ISA(SfxBoolItem) )
+ {
+ //Set Radio Button enable
+ mpRBNoWrap->Enable(true);
+ mpRBWrapLeft->Enable(true);
+ mpRBWrapRight->Enable(true);
+ mpRBWrapParallel->Enable(true);
+ mpRBWrapThrough->Enable(true);
+ mpRBIdealWrap->Enable(true);
+
+ const SfxBoolItem* pBoolItem = static_cast< const SfxBoolItem* >( pState );
+ switch( nSId )
+ {
+ case FN_FRAME_WRAP_RIGHT:
+ mpRBWrapRight->Check( pBoolItem->GetValue() );
+ break;
+ case FN_FRAME_WRAP_LEFT:
+ mpRBWrapLeft->Check( pBoolItem->GetValue() );
+ break;
+ case FN_FRAME_WRAPTHRU:
+ mpRBWrapThrough->Check( pBoolItem->GetValue() );
+ break;
+ case FN_FRAME_WRAP_IDEAL:
+ mpRBIdealWrap->Check( pBoolItem->GetValue() );
+ break;
+ case FN_FRAME_WRAP:
+ mpRBWrapParallel->Check( pBoolItem->GetValue() );
+ break;
+ case FN_FRAME_NOWRAP:
+ default:
+ mpRBNoWrap->Check( pBoolItem->GetValue() );
+ break;
+ }
+ }
+ else
+ {
+ mpRBNoWrap->Enable(false);
+ mpRBWrapLeft->Enable(false);
+ mpRBWrapRight->Enable(false);
+ mpRBWrapParallel->Enable(false);
+ mpRBWrapThrough->Enable(false);
+ mpRBIdealWrap->Enable(false);
+
+ mpRBNoWrap->Check( false );
+ mpRBWrapLeft->Check( false );
+ mpRBWrapRight->Check( false );
+ mpRBWrapParallel->Check( false );
+ mpRBWrapThrough->Check( false );
+ mpRBIdealWrap->Check( false );
+ }
+}
+
+} } // end of namespace ::sw::sidebar
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/sidebar/WrapPropertyPanel.hxx b/sw/source/core/uibase/sidebar/WrapPropertyPanel.hxx
new file mode 100644
index 000000000000..c5e524c25a0f
--- /dev/null
+++ b/sw/source/core/uibase/sidebar/WrapPropertyPanel.hxx
@@ -0,0 +1,88 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_SIDEBAR_WRAPPROPERTYPANEL_HXX
+#define INCLUDED_SW_SOURCE_UI_SIDEBAR_WRAPPROPERTYPANEL_HXX
+
+#include <svx/sidebar/PanelLayout.hxx>
+#include <vcl/button.hxx>
+#include <vcl/image.hxx>
+
+#include <sfx2/sidebar/ControllerItem.hxx>
+#include <com/sun/star/frame/XFrame.hpp>
+
+#include <boost/scoped_ptr.hpp>
+
+namespace sw { namespace sidebar {
+
+ class WrapPropertyPanel
+ : public PanelLayout
+ , public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface
+ {
+ public:
+ static WrapPropertyPanel* Create(
+ Window* pParent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame>& rxFrame,
+ SfxBindings* pBindings );
+
+ // interface of ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface
+ virtual void NotifyItemUpdate(
+ const sal_uInt16 nSId,
+ const SfxItemState eState,
+ const SfxPoolItem* pState,
+ const bool bIsEnabled);
+
+ private:
+ WrapPropertyPanel(
+ Window* pParent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxFrame,
+ SfxBindings* pBindings );
+
+ virtual ~WrapPropertyPanel();
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > mxFrame;
+ SfxBindings* mpBindings;
+
+ RadioButton* mpRBNoWrap;
+ RadioButton* mpRBWrapLeft;
+ RadioButton* mpRBWrapRight;
+ RadioButton* mpRBWrapParallel;
+ RadioButton* mpRBWrapThrough;
+ RadioButton* mpRBIdealWrap;
+
+ //Image resource.
+ ImageList aWrapIL;
+
+ //Controler Items==================================
+ ::sfx2::sidebar::ControllerItem maSwNoWrapControl;
+ ::sfx2::sidebar::ControllerItem maSwWrapLeftControl;
+ ::sfx2::sidebar::ControllerItem maSwWrapRightControl;
+ ::sfx2::sidebar::ControllerItem maSwWrapParallelControl;
+ ::sfx2::sidebar::ControllerItem maSwWrapThroughControl;
+ ::sfx2::sidebar::ControllerItem maSwWrapIdealControl;
+
+ void Initialize();
+
+ DECL_LINK(WrapTypeHdl, void*);
+ };
+
+} } // end of namespace ::sw::sidebar
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/smartmenu/stmenu.cxx b/sw/source/core/uibase/smartmenu/stmenu.cxx
new file mode 100644
index 000000000000..79aa386c8b73
--- /dev/null
+++ b/sw/source/core/uibase/smartmenu/stmenu.cxx
@@ -0,0 +1,170 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+// SMARTTAGS
+
+#include <stmenu.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <svl/eitem.hxx>
+#include <sfx2/dispatch.hxx>
+
+#include <SwSmartTagMgr.hxx>
+
+#include <stmenu.hrc>
+#include <view.hxx>
+#include <breakit.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+SwSmartTagPopup::SwSmartTagPopup( SwView* pSwView,
+ Sequence< OUString >& rSmartTagTypes,
+ Sequence< Reference< container::XStringKeyMap > >& rStringKeyMaps,
+ Reference< text::XTextRange > xTextRange ) :
+ PopupMenu( SW_RES(MN_SMARTTAG_POPUP) ),
+ mpSwView ( pSwView ),
+ mxTextRange( xTextRange )
+{
+ Reference <frame::XController> xController = mpSwView->GetController();
+ const lang::Locale aLocale( SW_BREAKITER()->GetLocale( GetAppLanguageTag() ) );
+
+ sal_uInt16 nMenuPos = 0;
+ sal_uInt16 nSubMenuPos = 0;
+ sal_uInt16 nMenuId = 1;
+ sal_uInt16 nSubMenuId = MN_ST_INSERT_START;
+
+ const OUString aRangeText = mxTextRange->getString();
+
+ SmartTagMgr& rSmartTagMgr = SwSmartTagMgr::Get();
+ const OUString aApplicationName( rSmartTagMgr.GetApplicationName() );
+
+ Sequence < Sequence< Reference< smarttags::XSmartTagAction > > > aActionComponentsSequence;
+ Sequence < Sequence< sal_Int32 > > aActionIndicesSequence;
+
+ rSmartTagMgr.GetActionSequences( rSmartTagTypes,
+ aActionComponentsSequence,
+ aActionIndicesSequence );
+
+ InsertSeparator(OString(), 0);
+
+ for ( sal_uInt16 j = 0; j < aActionComponentsSequence.getLength(); ++j )
+ {
+ Reference< container::XStringKeyMap > xSmartTagProperties = rStringKeyMaps[j];
+
+ // Get all actions references associated with the current smart tag type:
+ const Sequence< Reference< smarttags::XSmartTagAction > >& rActionComponents = aActionComponentsSequence[j];
+ const Sequence< sal_Int32 >& rActionIndices = aActionIndicesSequence[j];
+
+ if ( 0 == rActionComponents.getLength() || 0 == rActionIndices.getLength() )
+ continue;
+
+ // Ask first entry for the smart tag type caption:
+ Reference< smarttags::XSmartTagAction > xAction = rActionComponents[0];
+
+ if ( !xAction.is() )
+ continue;
+
+ const sal_Int32 nSmartTagIndex = rActionIndices[0];
+ const OUString aSmartTagType = xAction->getSmartTagName( nSmartTagIndex );
+ const OUString aSmartTagCaption = xAction->getSmartTagCaption( nSmartTagIndex, aLocale );
+
+ // no sub-menus if there's only one smart tag type listed:
+ PopupMenu* pSbMenu = this;
+ if ( 1 < aActionComponentsSequence.getLength() )
+ {
+ InsertItem(nMenuId, aSmartTagCaption, 0, OString(), nMenuPos++);
+ pSbMenu = new PopupMenu;
+ SetPopupMenu( nMenuId++, pSbMenu );
+ }
+
+ // sub-menu starts with smart tag caption and separator
+ const OUString aSmartTagCaption2 = aSmartTagCaption + ": " + aRangeText;
+ nSubMenuPos = 0;
+ pSbMenu->InsertItem(nMenuId++, aSmartTagCaption2, MIB_NOSELECT, OString(), nSubMenuPos++);
+ pSbMenu->InsertSeparator(OString(), nSubMenuPos++);
+
+ // Add subitem for every action reference for the current smart tag type:
+ for ( sal_uInt16 i = 0; i < rActionComponents.getLength(); ++i )
+ {
+ xAction = rActionComponents[i];
+
+ for ( sal_Int32 k = 0; k < xAction->getActionCount( aSmartTagType, xController, xSmartTagProperties ); ++k )
+ {
+ const sal_uInt32 nActionID = xAction->getActionID( aSmartTagType, k, xController );
+ OUString aActionCaption = xAction->getActionCaptionFromID( nActionID,
+ aApplicationName,
+ aLocale,
+ xSmartTagProperties,
+ aRangeText,
+ OUString(),
+ xController,
+ mxTextRange );
+
+ pSbMenu->InsertItem(nSubMenuId++, aActionCaption, 0, OString(), nSubMenuPos++);
+ InvokeAction aEntry( xAction, xSmartTagProperties, nActionID );
+ maInvokeActions.push_back( aEntry );
+ }
+ }
+ }
+}
+
+/** Function: Execute
+
+ executes actions by calling the invoke function of the appropriate
+ smarttag library.
+
+*/
+sal_uInt16 SwSmartTagPopup::Execute( const Rectangle& rWordPos, Window* pWin )
+{
+ sal_uInt16 nId = PopupMenu::Execute(pWin, pWin->LogicToPixel(rWordPos));
+
+ if ( nId == MN_SMARTTAG_OPTIONS )
+ {
+ SfxBoolItem aBool(SID_OPEN_SMARTTAGOPTIONS, true);
+ mpSwView->GetViewFrame()->GetDispatcher()->Execute( SID_AUTO_CORRECT_DLG, SFX_CALLMODE_ASYNCHRON, &aBool, 0L );
+ }
+
+ if ( nId < MN_ST_INSERT_START) return nId;
+ nId -= MN_ST_INSERT_START;
+
+ // compute smarttag lib index and action index
+ if ( nId < maInvokeActions.size() )
+ {
+ Reference< smarttags::XSmartTagAction > xSmartTagAction = maInvokeActions[ nId ].mxAction;
+
+ // execute action
+ if ( xSmartTagAction.is() )
+ {
+ SmartTagMgr& rSmartTagMgr = SwSmartTagMgr::Get();
+
+ xSmartTagAction->invokeAction( maInvokeActions[ nId ].mnActionID,
+ rSmartTagMgr.GetApplicationName(),
+ mpSwView->GetController(),
+ mxTextRange,
+ maInvokeActions[ nId ].mxSmartTagProperties,
+ mxTextRange->getString(),
+ OUString(),
+ SW_BREAKITER()->GetLocale( GetAppLanguageTag() ) );
+ }
+ }
+
+ return nId;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/smartmenu/stmenu.hrc b/sw/source/core/uibase/smartmenu/stmenu.hrc
new file mode 100644
index 000000000000..315fb3535af5
--- /dev/null
+++ b/sw/source/core/uibase/smartmenu/stmenu.hrc
@@ -0,0 +1,33 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef _STMENU_HRC
+#define _STMENU_HRC
+
+#include "rcid.hrc"
+
+#define MN_SMARTTAG_POPUP (RC_SMARTTAG_BEGIN + 1)
+
+#define MN_SMARTTAG_OPTIONS 105
+
+#define MN_ST_INSERT_START 500
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/smartmenu/stmenu.src b/sw/source/core/uibase/smartmenu/stmenu.src
new file mode 100644
index 000000000000..326c13b8841e
--- /dev/null
+++ b/sw/source/core/uibase/smartmenu/stmenu.src
@@ -0,0 +1,37 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+/* StarView resource file */
+
+#include "stmenu.hrc"
+#include "helpid.h"
+
+Menu MN_SMARTTAG_POPUP
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = MN_SMARTTAG_OPTIONS ;
+ HelpID = HID_SMARTTAG_MAIN ;
+ Text [ en-US ] = "Smart Tag Options..." ;
+ };
+ };
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/table/chartins.cxx b/sw/source/core/uibase/table/chartins.cxx
new file mode 100644
index 000000000000..c33991127529
--- /dev/null
+++ b/sw/source/core/uibase/table/chartins.cxx
@@ -0,0 +1,254 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <sfx2/viewfrm.hxx>
+#include <vcl/msgbox.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/basedlgs.hxx>
+#include <IDocumentUndoRedo.hxx>
+
+#include <sfx2/app.hxx>
+#include <swtypes.hxx>
+#include <swmodule.hxx>
+#include <wrtsh.hxx>
+#include <docsh.hxx>
+#include <view.hxx>
+#include <chartins.hxx>
+#include <tablemgr.hxx>
+#include <frmfmt.hxx>
+#include <swtable.hxx>
+#include <tblsel.hxx>
+#include <unochart.hxx>
+#include <autoedit.hxx>
+#include <doc.hxx>
+
+#include <edtwin.hxx>
+
+#include <cmdid.h>
+#include <anchoredobject.hxx>
+
+#include <comphelper/classids.hxx>
+
+#include <cppuhelper/bootstrap.hxx>
+#include <cppuhelper/component_context.hxx>
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/chart2/data/XDataProvider.hpp>
+#include <com/sun/star/chart2/data/XDataReceiver.hpp>
+#include <com/sun/star/chart/ChartDataRowSource.hpp>
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
+#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+Point SwGetChartDialogPos( const Window *pParentWin, const Size& rDialogSize, const Rectangle& rLogicChart )
+{
+ // positioning code according to spepc; similar to Calc fuins2.cxx
+ Point aRet;
+
+ OSL_ENSURE( pParentWin, "Window not found" );
+ if (pParentWin)
+ {
+ Rectangle aObjPixel = pParentWin->LogicToPixel( rLogicChart, pParentWin->GetMapMode() );
+ Rectangle aObjAbs( pParentWin->OutputToAbsoluteScreenPixel( aObjPixel.TopLeft() ),
+ pParentWin->OutputToAbsoluteScreenPixel( aObjPixel.BottomRight() ) );
+
+ Rectangle aDesktop = pParentWin->GetDesktopRectPixel();
+ Size aSpace = pParentWin->LogicToPixel( Size( 8, 12 ), MAP_APPFONT );
+
+ sal_Bool bLayoutRTL = ::GetActiveView()->GetWrtShell().IsTableRightToLeft();
+ 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 SwInsertChart(Window* pParent, SfxBindings* pBindings )
+{
+ (void) pParent;
+ (void) pBindings;
+ SwView *pView = ::GetActiveView();
+
+ // get range string of marked data
+ SwWrtShell &rWrtShell = pView->GetWrtShell();
+ uno::Reference< chart2::data::XDataProvider > xDataProvider;
+ uno::Reference< frame::XModel > xChartModel;
+ OUString aRangeString;
+
+ if( rWrtShell.IsCrsrInTbl())
+ {
+ if (!rWrtShell.IsTableMode())
+ {
+ // select whole table
+ rWrtShell.GetView().GetViewFrame()->GetDispatcher()->
+ Execute(FN_TABLE_SELECT_ALL, SFX_CALLMODE_SYNCHRON);
+ }
+ if( ! rWrtShell.IsTblComplexForChart())
+ {
+ SwFrmFmt* pTblFmt = rWrtShell.GetTableFmt();
+ aRangeString = pTblFmt->GetName() + "." + rWrtShell.GetBoxNms();
+
+ // get table data provider
+ xDataProvider.set( pView->GetDocShell()->getIDocumentChartDataProviderAccess()->GetChartDataProvider( true ) );
+ }
+ }
+
+ SwFlyFrmFmt *pFlyFrmFmt = 0;
+ xChartModel.set( SwTableFUNC( &rWrtShell, sal_False ).InsertChart( xDataProvider, xDataProvider.is(), aRangeString, &pFlyFrmFmt ));
+
+ //open wizard
+ //@todo get context from writer if that has one
+ uno::Reference< uno::XComponentContext > xContext(
+ ::cppu::defaultBootstrap_InitialComponentContext() );
+ if( xContext.is() && xChartModel.is() && xDataProvider.is())
+ {
+ uno::Reference< lang::XMultiComponentFactory > xMCF( xContext->getServiceManager() );
+ if(xMCF.is())
+ {
+ uno::Reference< ui::dialogs::XExecutableDialog > xDialog(
+ xMCF->createInstanceWithContext(
+ OUString("com.sun.star.comp.chart2.WizardDialog")
+ , xContext), uno::UNO_QUERY);
+ uno::Reference< lang::XInitialization > xInit( xDialog, uno::UNO_QUERY );
+ if( 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 = "ParentWindow";
+ aParam1.Value <<= uno::makeAny(xDialogParentWindow);
+ beans::PropertyValue aParam2;
+ aParam2.Name = "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("Size")
+ >>= aDialogAWTSize )
+ {
+ Size aDialogSize( aDialogAWTSize.Width, aDialogAWTSize.Height );
+ if ( aDialogSize.Width() > 0 && aDialogSize.Height() > 0 )
+ {
+ //calculate and set new position
+ SwRect aSwRect;
+ if (pFlyFrmFmt)
+ aSwRect = pFlyFrmFmt->GetAnchoredObj()->GetObjRectWithSpaces();
+ Rectangle aRect( aSwRect.SVRect() );
+ Point aDialogPos = SwGetChartDialogPos( &rWrtShell.GetView().GetEditWin(), aDialogSize, aRect );
+ xDialogProps->setPropertyValue("Position",
+ uno::makeAny( awt::Point(aDialogPos.getX(),aDialogPos.getY()) ) );
+ }
+ }
+ }
+ catch (const uno::Exception&)
+ {
+ OSL_FAIL("Chart wizard couldn't be positioned automatically\n" );
+ }
+ }
+
+ sal_Int16 nDialogRet = xDialog->execute();
+ if( nDialogRet == ui::dialogs::ExecutableDialogResults::CANCEL )
+ {
+ rWrtShell.Undo();
+ rWrtShell.GetIDocumentUndoRedo().ClearRedo();
+ }
+ else
+ {
+ OSL_ENSURE( nDialogRet == ui::dialogs::ExecutableDialogResults::OK,
+ "dialog execution failed" );
+ }
+ }
+ uno::Reference< lang::XComponent > xComponent( xDialog, uno::UNO_QUERY );
+ if( xComponent.is())
+ xComponent->dispose();
+ }
+ }
+}
+
+void AutoEdit::KeyInput( const KeyEvent& rEvt )
+{
+ sal_uInt16 nCode = rEvt.GetKeyCode().GetCode();
+ if( nCode != KEY_SPACE )
+ Edit::KeyInput( rEvt );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/table/swtablerep.cxx b/sw/source/core/uibase/table/swtablerep.cxx
new file mode 100644
index 000000000000..f1176b07727f
--- /dev/null
+++ b/sw/source/core/uibase/table/swtablerep.cxx
@@ -0,0 +1,186 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <hintids.hxx>
+#include <vcl/msgbox.hxx>
+#include <svl/stritem.hxx>
+#include <svl/intitem.hxx>
+#include <editeng/keepitem.hxx>
+#include <editeng/formatbreakitem.hxx>
+#include <editeng/ulspitem.hxx>
+#include <editeng/frmdiritem.hxx>
+#include <svl/ctloptions.hxx>
+#include <swmodule.hxx>
+#include <fmtornt.hxx>
+#include <fmtpdsc.hxx>
+#include <fmtlsplt.hxx>
+
+#include <svtools/htmlcfg.hxx>
+#include <fmtrowsplt.hxx>
+#include <sfx2/htmlmode.hxx>
+
+#include <docsh.hxx>
+#include <wrtsh.hxx>
+#include <view.hxx>
+#include <viewopt.hxx>
+#include <uitool.hxx>
+#include <frmatr.hxx>
+
+#include <tablepg.hxx>
+#include <tablemgr.hxx>
+#include <pagedesc.hxx>
+#include <poolfmt.hxx>
+#include <SwStyleNameMapper.hxx>
+
+#include <cmdid.h>
+#include <table.hrc>
+#include "swtablerep.hxx"
+
+SwTableRep::SwTableRep( const SwTabCols& rTabCol )
+ :
+ nTblWidth(0),
+ nSpace(0),
+ nLeftSpace(0),
+ nRightSpace(0),
+ nAlign(0),
+ nWidthPercent(0),
+ bLineSelected(sal_False),
+ bWidthChanged(sal_False),
+ bColsChanged(sal_False)
+{
+ nAllCols = nColCount = rTabCol.Count();
+ pTColumns = new TColumn[ nColCount + 1 ];
+ SwTwips nStart = 0,
+ nEnd;
+ for( sal_uInt16 i = 0; i < nAllCols; ++i )
+ {
+ nEnd = rTabCol[ i ] - rTabCol.GetLeft();
+ pTColumns[ i ].nWidth = nEnd - nStart;
+ pTColumns[ i ].bVisible = !rTabCol.IsHidden(i);
+ if(!pTColumns[ i ].bVisible)
+ nColCount --;
+ nStart = nEnd;
+ }
+ pTColumns[ nAllCols ].nWidth = rTabCol.GetRight() - rTabCol.GetLeft() - nStart;
+ pTColumns[ nAllCols ].bVisible = sal_True;
+ nColCount++;
+ nAllCols++;
+}
+
+SwTableRep::~SwTableRep()
+{
+ delete[] pTColumns;
+}
+
+sal_Bool SwTableRep::FillTabCols( SwTabCols& rTabCols ) const
+{
+ long nOldLeft = rTabCols.GetLeft(),
+ nOldRight = rTabCols.GetRight();
+
+ sal_Bool bSingleLine = sal_False;
+ sal_uInt16 i;
+
+ for ( i = 0; i < rTabCols.Count(); ++i )
+ if(!pTColumns[i].bVisible)
+ {
+ bSingleLine = sal_True;
+ break;
+ }
+
+ SwTwips nPos = 0;
+ SwTwips nLeft = GetLeftSpace();
+ rTabCols.SetLeft(nLeft);
+ if(bSingleLine)
+ {
+ // The invisible separators are taken from the old TabCols,
+ // the visible coming from pTColumns.
+ TColumn* pOldTColumns = new TColumn[nAllCols + 1];
+ SwTwips nStart = 0,
+ nEnd;
+ for(i = 0; i < nAllCols - 1; i++)
+ {
+ nEnd = rTabCols[i] - rTabCols.GetLeft();
+ pOldTColumns[i].nWidth = nEnd - nStart;
+ pOldTColumns[i].bVisible = !rTabCols.IsHidden(i);
+ nStart = nEnd;
+ }
+ pOldTColumns[nAllCols - 1].nWidth = rTabCols.GetRight() - rTabCols.GetLeft() - nStart;
+ pOldTColumns[nAllCols - 1].bVisible = sal_True;
+
+ sal_uInt16 nOldPos = 0;
+ sal_uInt16 nNewPos = 0;
+ SwTwips nOld = 0;
+ SwTwips nNew = 0;
+ sal_Bool bOld = sal_False;
+ bool bFirst = true;
+ i = 0;
+
+ while ( i < nAllCols -1 )
+ {
+ while((bFirst || bOld ) && nOldPos < nAllCols )
+ {
+ nOld += pOldTColumns[nOldPos].nWidth;
+ nOldPos++;
+ if(!pOldTColumns[nOldPos - 1].bVisible)
+ break;
+ }
+ while((bFirst || !bOld ) && nNewPos < nAllCols )
+ {
+ nNew += pTColumns[nNewPos].nWidth;
+ nNewPos++;
+ if(pOldTColumns[nNewPos - 1].bVisible)
+ break;
+ }
+ bFirst = false;
+ // They have to be inserted sorted.
+ bOld = nOld < nNew;
+ nPos = sal_uInt16(bOld ? nOld : nNew);
+ rTabCols[i] = nPos + nLeft;
+ rTabCols.SetHidden( i, bOld );
+ i++;
+ }
+ rTabCols.SetRight(nLeft + nTblWidth);
+
+ delete[] pOldTColumns;
+ }
+ else
+ {
+ for ( i = 0; i < nAllCols - 1; ++i )
+ {
+ nPos += pTColumns[i].nWidth;
+ rTabCols[i] = nPos + rTabCols.GetLeft();
+ rTabCols.SetHidden( i, !pTColumns[i].bVisible );
+ rTabCols.SetRight(nLeft + pTColumns[nAllCols - 1].nWidth + nPos);
+ }
+ }
+
+ // intercept rounding errors
+ if(std::abs((long)nOldLeft - (long)rTabCols.GetLeft()) < 3)
+ rTabCols.SetLeft(nOldLeft);
+
+ if(std::abs((long)nOldRight - (long)rTabCols.GetRight()) < 3)
+ rTabCols.SetRight(nOldRight);
+
+ if(GetRightSpace() >= 0 &&
+ rTabCols.GetRight() > rTabCols.GetRightMax())
+ rTabCols.SetRight(rTabCols.GetRightMax());
+ return bSingleLine;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/table/tablemgr.cxx b/sw/source/core/uibase/table/tablemgr.cxx
new file mode 100644
index 000000000000..d823f4571932
--- /dev/null
+++ b/sw/source/core/uibase/table/tablemgr.cxx
@@ -0,0 +1,349 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <com/sun/star/chart/ChartDataRowSource.hpp>
+#include <com/sun/star/chart2/data/XDataProvider.hpp>
+#include <com/sun/star/chart2/data/XDataReceiver.hpp>
+#include <com/sun/star/beans/PropertyState.hpp>
+
+#include <sot/storage.hxx>
+#include <comphelper/classids.hxx>
+#include <svx/charthelper.hxx>
+
+#include "edtwin.hxx"
+#include "wrtsh.hxx"
+#include "cmdid.h"
+#include "frmatr.hxx"
+#include "view.hxx"
+#include "basesh.hxx"
+#include "swundo.hxx"
+#include "tablemgr.hxx"
+#include "frmfmt.hxx"
+#include "instable.hxx"
+#include "swerror.h"
+#include "table.hrc"
+#include "swabstdlg.hxx"
+#include "swcli.hxx"
+#include "docsh.hxx"
+#include "unotbl.hxx"
+#include "unochart.hxx"
+
+using namespace ::com::sun::star;
+
+// Adjust line height (dialogue)
+void SwTableFUNC::ColWidthDlg( Window *pParent )
+{
+ InitTabCols();
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+
+ VclAbstractDialog* pDlg = pFact->CreateSwTableWidthDlg(pParent, *this);
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ pDlg->Execute();
+ delete pDlg;
+}
+
+// Determine the width
+SwTwips SwTableFUNC::GetColWidth(sal_uInt16 nNum) const
+{
+ SwTwips nWidth = 0;
+
+ if( aCols.Count() > 0 )
+ {
+ if(aCols.Count() == GetColCount())
+ {
+ nWidth = (SwTwips)((nNum == aCols.Count()) ?
+ aCols.GetRight() - aCols[nNum-1] :
+ nNum == 0 ? aCols[nNum] - aCols.GetLeft() :
+ aCols[nNum] - aCols[nNum-1]);
+ }
+ else
+ {
+ SwTwips nRValid = nNum < GetColCount() ?
+ aCols[(sal_uInt16)GetRightSeparator((int)nNum)]:
+ aCols.GetRight();
+ SwTwips nLValid = nNum ?
+ aCols[(sal_uInt16)GetRightSeparator((int)nNum - 1)]:
+ aCols.GetLeft();
+ nWidth = nRValid - nLValid;
+ }
+ }
+ else
+ nWidth = aCols.GetRight();
+
+ return nWidth;
+}
+
+SwTwips SwTableFUNC::GetMaxColWidth( sal_uInt16 nNum ) const
+{
+ OSL_ENSURE(nNum <= aCols.Count(), "Index out of Area");
+
+ if ( GetColCount() > 0 )
+ {
+ // The maximum width arises from the own width and
+ // the width each of the neighbor cells reduced by MINLAY.
+ SwTwips nMax = nNum == 0 ?
+ GetColWidth(1) - MINLAY :
+ nNum == GetColCount() ?
+ GetColWidth( nNum-1 ) - MINLAY :
+ GetColWidth(nNum - 1) + GetColWidth( nNum + 1 ) - 2 * MINLAY;
+
+ return nMax + GetColWidth(nNum) ;
+ }
+ else
+ return GetColWidth(nNum);
+}
+
+void SwTableFUNC::SetColWidth(sal_uInt16 nNum, SwTwips nNewWidth )
+{
+ // set current width
+ // move all of the following
+ sal_Bool bCurrentOnly = sal_False;
+
+ if ( aCols.Count() > 0 )
+ {
+ if(aCols.Count() != GetColCount())
+ bCurrentOnly = sal_True;
+ SwTwips nWidth = GetColWidth(nNum);
+
+ int nDiff = (int)(nNewWidth - nWidth);
+ if( !nNum )
+ aCols[ static_cast< sal_uInt16 >(GetRightSeparator(0)) ] += nDiff;
+ else if( nNum < GetColCount() )
+ {
+ if(nDiff < GetColWidth(nNum + 1) - MINLAY)
+ aCols[ static_cast< sal_uInt16 >(GetRightSeparator(nNum)) ] += nDiff;
+ else
+ {
+ int nDiffLeft = nDiff - (int)GetColWidth(nNum + 1) + (int)MINLAY;
+ aCols[ static_cast< sal_uInt16 >(GetRightSeparator(nNum)) ] += (nDiff - nDiffLeft);
+ aCols[ static_cast< sal_uInt16 >(GetRightSeparator(nNum - 1)) ] -= nDiffLeft;
+ }
+ }
+ else
+ aCols[ static_cast< sal_uInt16 >(GetRightSeparator(nNum-1)) ] -= nDiff;
+ }
+ else
+ aCols.SetRight( std::min( nNewWidth, aCols.GetRightMax()) );
+
+ pSh->StartAllAction();
+ pSh->SetTabCols( aCols, bCurrentOnly );
+ pSh->EndAllAction();
+}
+
+void SwTableFUNC::InitTabCols()
+{
+ OSL_ENSURE(pSh, "no Shell");
+
+ if( pFmt && pSh)
+ pSh->GetTabCols( aCols );
+}
+
+SwTableFUNC::SwTableFUNC(SwWrtShell *pShell, sal_Bool bCopyFmt)
+ : pFmt(pShell->GetTableFmt()),
+ pSh(pShell),
+ bCopy(bCopyFmt)
+{
+ // if applicable copy the format for edit
+ if( pFmt && bCopy )
+ pFmt = new SwFrmFmt( *pFmt );
+}
+
+SwTableFUNC::~SwTableFUNC()
+{
+ if(bCopy)
+ delete pFmt;
+}
+
+void SwTableFUNC::UpdateChart()
+{
+ //Update of the fields triggered by the user, all Charts of
+ //the table will be brought up to date
+ SwFrmFmt *pFmt2 = pSh->GetTableFmt();
+ if ( pFmt2 && pSh->HasOLEObj( pFmt2->GetName() ) )
+ {
+ pSh->StartAllAction();
+ pSh->UpdateCharts( pFmt2->GetName() );
+ pSh->EndAllAction();
+ }
+}
+
+uno::Reference< frame::XModel > SwTableFUNC::InsertChart(
+ uno::Reference< chart2::data::XDataProvider > &rxDataProvider,
+ sal_Bool bFillWithData,
+ const OUString &rCellRange,
+ SwFlyFrmFmt** ppFlyFrmFmt )
+{
+ uno::Reference< frame::XModel > xChartModel;
+ pSh->StartUndo( UNDO_UI_INSERT_CHART );
+ pSh->StartAllAction();
+
+ OUString aName;
+ if (pSh->IsCrsrInTbl())
+ {
+ aName = pSh->GetTableFmt()->GetName();
+ // insert node before table
+ pSh->MoveTable( fnTableCurr, fnTableStart );
+ pSh->Up( sal_False, 1, sal_False );
+ if ( pSh->IsCrsrInTbl() )
+ {
+ if ( aName != pSh->GetTableFmt()->GetName() )
+ pSh->Down( sal_False, 1, sal_False ); // two adjacent tables
+ }
+ pSh->SplitNode();
+ }
+
+ // insert chart
+ OUString aObjName;
+ comphelper::EmbeddedObjectContainer aCnt;
+ uno::Reference < embed::XEmbeddedObject > xObj =
+ aCnt.CreateEmbeddedObject( SvGlobalName( SO3_SCH_CLASSID ).GetByteSequence(), aObjName );
+
+ ::svt::EmbeddedObjectRef aEmbObjRef( xObj, ::com::sun::star::embed::Aspects::MSOLE_CONTENT );
+ if ( xObj.is() )
+ {
+
+ SwFlyFrmFmt* pTmp = 0;
+ pSh->InsertOleObject( aEmbObjRef, &pTmp );
+ if (ppFlyFrmFmt)
+ *ppFlyFrmFmt = pTmp;
+
+ uno::Reference< embed::XComponentSupplier > xCompSupp( xObj, uno::UNO_QUERY );
+ if( xCompSupp.is())
+ {
+ xChartModel.set( xCompSupp->getComponent(), uno::UNO_QUERY );
+ if( xChartModel.is() )
+ xChartModel->lockControllers(); //#i79578# don't request a new replacement image for charts to often - block change notifications
+ }
+
+ // set the table name at the OLE-node
+ if (!aName.isEmpty())
+ pSh->SetChartName( aName );
+ }
+ pSh->EndAllAction();
+
+ if ( xObj.is() )
+ {
+ // Let the chart be activated after the inserting
+ SfxInPlaceClient* pClient = pSh->GetView().FindIPClient( xObj, &pSh->GetView().GetEditWin() );
+ if ( !pClient )
+ {
+ pClient = new SwOleClient( &pSh->GetView(), &pSh->GetView().GetEditWin(), aEmbObjRef );
+ pSh->SetCheckForOLEInCaption( sal_True );
+ }
+ pSh->CalcAndSetScale( aEmbObjRef );
+ //#50270# We don't need to handle errors,
+ //this does the DoVerb in the SfxViewShell.
+ ErrCode nErr = pClient->DoVerb( SVVERB_SHOW );
+ (void) nErr;
+
+ // #i121334#
+ ChartHelper::AdaptDefaultsForChart( xObj );
+ }
+
+ uno::Reference< chart2::data::XDataReceiver > xDataReceiver( xChartModel, uno::UNO_QUERY );
+ if (bFillWithData && xDataReceiver.is() && rxDataProvider.is())
+ {
+ xDataReceiver->attachDataProvider( rxDataProvider );
+
+ uno::Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier( pSh->GetView().GetDocShell()->GetModel(), uno::UNO_QUERY );
+ xDataReceiver->attachNumberFormatsSupplier( xNumberFormatsSupplier );
+
+ // default values for ranges that do not consist of a single row or column
+ bool bHasCategories = true;
+ bool bFirstCellAsLabel = true;
+ chart::ChartDataRowSource eDataRowSource = chart::ChartDataRowSource_COLUMNS;
+
+ SwRangeDescriptor aDesc;
+ FillRangeDescriptor( aDesc, rCellRange );
+ bool bSingleRowCol = aDesc.nTop == aDesc.nBottom || aDesc.nLeft == aDesc.nRight;
+ if (bSingleRowCol)
+ {
+ aDesc.Normalize();
+ sal_Int32 nRowLen = aDesc.nRight - aDesc.nLeft + 1;
+ sal_Int32 nColLen = aDesc.nBottom - aDesc.nTop + 1;
+
+ bHasCategories = false;
+ if (nRowLen == 1 && nColLen == 1)
+ bFirstCellAsLabel = false;
+ else if (nRowLen > 1)
+ eDataRowSource = chart::ChartDataRowSource_ROWS;
+ else if (nColLen > 1)
+ eDataRowSource = chart::ChartDataRowSource_COLUMNS;
+ else {
+ OSL_FAIL("unexpected state" );
+ }
+ }
+
+ uno::Sequence< beans::PropertyValue > aArgs( 4 );
+ aArgs[0] = beans::PropertyValue(
+ OUString("CellRangeRepresentation"), -1,
+ uno::makeAny( rCellRange ), beans::PropertyState_DIRECT_VALUE );
+ aArgs[1] = beans::PropertyValue(
+ OUString("HasCategories"), -1,
+ uno::makeAny( bHasCategories ), beans::PropertyState_DIRECT_VALUE );
+ aArgs[2] = beans::PropertyValue(
+ OUString("FirstCellAsLabel"), -1,
+ uno::makeAny( bFirstCellAsLabel ), beans::PropertyState_DIRECT_VALUE );
+ aArgs[3] = beans::PropertyValue(
+ OUString("DataRowSource"), -1,
+ uno::makeAny( eDataRowSource ), beans::PropertyState_DIRECT_VALUE );
+ xDataReceiver->setArguments( aArgs );
+ }
+
+ pSh->EndUndo( UNDO_UI_INSERT_CHART );
+
+ if( xChartModel.is() )
+ xChartModel->unlockControllers(); //#i79578# don't request a new replacement image for charts to often
+ return xChartModel;
+}
+
+sal_uInt16 SwTableFUNC::GetCurColNum() const
+{
+ sal_uInt16 nPos = pSh->GetCurTabColNum();
+ sal_uInt16 nCount = 0;
+ for(sal_uInt16 i = 0; i < nPos; i++ )
+ if(aCols.IsHidden(i))
+ nCount ++;
+ return nPos - nCount;
+}
+
+sal_uInt16 SwTableFUNC::GetColCount() const
+{
+ sal_uInt16 nCount = 0;
+ for(sal_uInt16 i = 0; i < aCols.Count(); i++ )
+ if(aCols.IsHidden(i))
+ nCount ++;
+ return aCols.Count() - nCount;
+}
+
+int SwTableFUNC::GetRightSeparator(int nNum) const
+{
+ OSL_ENSURE( nNum < (int)GetColCount() ,"Index out of range");
+ int i = 0;
+ while( nNum >= 0 )
+ {
+ if( !aCols.IsHidden( static_cast< sal_uInt16 >(i)) )
+ nNum--;
+ i++;
+ }
+ return i - 1;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/table/tablepg.hxx b/sw/source/core/uibase/table/tablepg.hxx
new file mode 100644
index 000000000000..17a708c7b3e3
--- /dev/null
+++ b/sw/source/core/uibase/table/tablepg.hxx
@@ -0,0 +1,195 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_TABLE_TABLEPG_HXX
+#define INCLUDED_SW_SOURCE_UI_TABLE_TABLEPG_HXX
+#include <sfx2/tabdlg.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/button.hxx>
+#include <vcl/lstbox.hxx>
+#include <actctrl.hxx>
+#include "prcntfld.hxx"
+#include "swtypes.hxx"
+
+class SwWrtShell;
+class SwTableRep;
+
+struct TColumn
+{
+ SwTwips nWidth;
+ sal_Bool bVisible;
+};
+
+class SwFormatTablePage : public SfxTabPage
+{
+ TableNameEdit* m_pNameED;
+ FixedText* m_pWidthFT;
+ PercentField m_aWidthMF;
+ CheckBox* m_pRelWidthCB;
+
+ RadioButton* m_pFullBtn;
+ RadioButton* m_pLeftBtn;
+ RadioButton* m_pFromLeftBtn;
+ RadioButton* m_pRightBtn;
+ RadioButton* m_pCenterBtn;
+ RadioButton* m_pFreeBtn;
+
+ FixedText* m_pLeftFT;
+ PercentField m_aLeftMF;
+ FixedText* m_pRightFT;
+ PercentField m_aRightMF;
+ FixedText* m_pTopFT;
+ MetricField* m_pTopMF;
+ FixedText* m_pBottomFT;
+ MetricField* m_pBottomMF;
+
+ ListBox* m_pTextDirectionLB;
+
+ SwTableRep* pTblData;
+ SwTwips nSaveWidth;
+ SwTwips nMinTableWidth;
+ sal_uInt16 nOldAlign;
+ sal_Bool bModified;
+ sal_Bool bFull:1;
+ sal_Bool bHtmlMode : 1;
+
+ void Init();
+ void ModifyHdl(const Edit* pEdit);
+
+ DECL_LINK( AutoClickHdl, CheckBox * );
+ DECL_LINK( RelWidthClickHdl, CheckBox * );
+ void RightModify();
+ DECL_LINK( UpDownLoseFocusHdl, MetricField * );
+
+ using TabPage::ActivatePage;
+ using TabPage::DeactivatePage;
+
+public:
+ SwFormatTablePage( Window* pParent, const SfxItemSet& rSet );
+
+ static SfxTabPage* Create( Window* pParent, const SfxItemSet& rAttrSet);
+ virtual sal_Bool FillItemSet( SfxItemSet& rSet );
+ virtual void Reset( const SfxItemSet& rSet );
+ virtual void ActivatePage( const SfxItemSet& rSet );
+ virtual int DeactivatePage( SfxItemSet* pSet = 0 );
+};
+
+// TabPage Format/Table/Columns
+#define MET_FIELDS 6 //Number of the used MetricFields
+
+class SwTableColumnPage : public SfxTabPage
+{
+ CheckBox* m_pModifyTableCB;
+ CheckBox* m_pProportionalCB;
+ FixedText* m_pSpaceFT;
+ MetricField* m_pSpaceED;
+ PushButton* m_pUpBtn;
+ PushButton* m_pDownBtn;
+
+ SwTableRep* pTblData;
+ PercentField m_aFieldArr[MET_FIELDS];
+ FixedText* m_pTextArr[MET_FIELDS];
+ SwTwips nTableWidth;
+ SwTwips nMinWidth;
+ sal_uInt16 nNoOfCols;
+ sal_uInt16 nNoOfVisibleCols;
+ // Remember the width, when switching to autoalign
+ sal_uInt16 aValueTbl[MET_FIELDS];// primary assignment of the MetricFields
+ sal_Bool bModified:1;
+ sal_Bool bModifyTbl:1;
+ sal_Bool bPercentMode:1;
+
+ void Init(sal_Bool bWeb);
+ DECL_LINK( AutoClickHdl, CheckBox * );
+ void ModifyHdl( MetricField* pEdit );
+ DECL_LINK( UpHdl, MetricField * );
+ DECL_LINK( DownHdl, MetricField * );
+ DECL_LINK( LoseFocusHdl, MetricField * );
+ DECL_LINK( ModeHdl, CheckBox * );
+ void UpdateCols( sal_uInt16 nAktPos );
+ SwTwips GetVisibleWidth(sal_uInt16 nPos);
+ void SetVisibleWidth(sal_uInt16 nPos, SwTwips nNewWidth);
+
+ using TabPage::ActivatePage;
+ using TabPage::DeactivatePage;
+
+public:
+ SwTableColumnPage( Window* pParent, const SfxItemSet& rSet );
+ ~SwTableColumnPage();
+
+ static SfxTabPage* Create( Window* pParent, const SfxItemSet& rAttrSet);
+ virtual sal_Bool FillItemSet( SfxItemSet& rSet );
+ virtual void Reset( const SfxItemSet& rSet );
+ virtual void ActivatePage( const SfxItemSet& rSet );
+ virtual int DeactivatePage( SfxItemSet* pSet = 0 );
+
+};
+
+class SwTextFlowPage : public SfxTabPage
+{
+ CheckBox* m_pPgBrkCB;
+
+ RadioButton* m_pPgBrkRB;
+ RadioButton* m_pColBrkRB;
+
+ RadioButton* m_pPgBrkBeforeRB;
+ RadioButton* m_pPgBrkAfterRB;
+
+ CheckBox* m_pPageCollCB;
+ ListBox* m_pPageCollLB;
+ FixedText* m_pPageNoFT;
+ NumericField* m_pPageNoNF;
+ CheckBox* m_pSplitCB;
+ TriStateBox* m_pSplitRowCB;
+ CheckBox* m_pKeepCB;
+ CheckBox* m_pHeadLineCB;
+ NumericField* m_pRepeatHeaderNF;
+ VclContainer* m_pRepeatHeaderCombo;
+ ListBox* m_pTextDirectionLB;
+
+ ListBox* m_pVertOrientLB;
+
+ SwWrtShell* pShell;
+
+ sal_Bool bPageBreak;
+ sal_Bool bHtmlMode;
+
+ DECL_LINK(PageBreakHdl_Impl, void *);
+ DECL_LINK(ApplyCollClickHdl_Impl, void *);
+ DECL_LINK( PageBreakPosHdl_Impl, RadioButton* );
+ DECL_LINK( PageBreakTypeHdl_Impl, RadioButton* );
+ DECL_LINK( SplitHdl_Impl, CheckBox* );
+ DECL_LINK( SplitRowHdl_Impl, TriStateBox* );
+ DECL_LINK( HeadLineCBClickHdl, void* p = 0 );
+
+ SwTextFlowPage( Window* pParent, const SfxItemSet& rSet );
+ ~SwTextFlowPage();
+
+public:
+ static SfxTabPage* Create( Window* pParent, const SfxItemSet& rAttrSet);
+ virtual sal_Bool FillItemSet( SfxItemSet& rSet );
+ virtual void Reset( const SfxItemSet& rSet );
+
+ void SetShell(SwWrtShell* pSh);
+
+ void DisablePageBreak();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/uiview/formatclipboard.cxx b/sw/source/core/uibase/uiview/formatclipboard.cxx
new file mode 100644
index 000000000000..b6dd3f5167c6
--- /dev/null
+++ b/sw/source/core/uibase/uiview/formatclipboard.cxx
@@ -0,0 +1,608 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "formatclipboard.hxx"
+
+#include <svx/svxids.hrc>
+#include <cmdid.h>
+#include <charfmt.hxx>
+#include <frmfmt.hxx>
+#include <docstyle.hxx>
+#include <fchrfmt.hxx>
+// header for class SdrView
+#include <svx/svdview.hxx>
+//SvxBrushItem
+#include <editeng/brushitem.hxx>
+#include <editeng/shaditem.hxx>
+// header for class SvxBoxInfoItem
+#include <editeng/boxitem.hxx>
+// header for class SvxFmtBreakItem
+#include <editeng/formatbreakitem.hxx>
+// header for class SwFmtLayoutSplit
+#include <fmtlsplt.hxx>
+// header for class SvxFmtKeepItem
+#include <editeng/keepitem.hxx>
+// header for class SvxFrameDirectionItem
+#include <editeng/frmdiritem.hxx>
+#include <fmtpdsc.hxx>
+#include <fmtrowsplt.hxx>
+
+namespace
+{
+#define FORMAT_PAINTBRUSH_FRAME_IDS \
+RES_FRMATR_BEGIN, RES_FILL_ORDER, \
+/* no RES_FRM_SIZE */ \
+RES_PAPER_BIN, RES_SURROUND, \
+/* no RES_VERT_ORIENT */ \
+/* no RES_HORI_ORIENT */ \
+/* no RES_ANCHOR */ \
+RES_BACKGROUND, RES_SHADOW, \
+/* no RES_FRMMACRO */ \
+RES_COL, RES_KEEP, \
+/* no RES_URL */ \
+RES_EDIT_IN_READONLY, RES_LAYOUT_SPLIT, \
+/* no RES_CHAIN */ \
+RES_TEXTGRID, RES_FRMATR_END-1,
+
+#define FORMAT_PAINTBRUSH_PARAGRAPH_IDS \
+RES_PARATR_BEGIN, RES_PARATR_END -1, \
+RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END -1, \
+FORMAT_PAINTBRUSH_FRAME_IDS
+
+SfxItemSet* lcl_CreateEmptyItemSet( int nSelectionType, SfxItemPool& rPool, bool bNoParagraphFormats = false )
+{
+ SfxItemSet* pItemSet = 0;
+ if( nSelectionType & (nsSelectionType::SEL_FRM | nsSelectionType::SEL_OLE | nsSelectionType::SEL_GRF) )
+ {
+ pItemSet = new SfxItemSet(rPool,
+ FORMAT_PAINTBRUSH_FRAME_IDS
+ 0);
+ }
+ else if( nSelectionType & nsSelectionType::SEL_DRW )
+ {
+ //is handled different
+ }
+ else if( nSelectionType & nsSelectionType::SEL_TXT )
+ {
+ if( bNoParagraphFormats )
+ pItemSet = new SfxItemSet(rPool,
+ RES_CHRATR_BEGIN, RES_CHRATR_END - 1,
+ 0);
+ else
+ pItemSet = new SfxItemSet(rPool,
+ RES_CHRATR_BEGIN, RES_CHRATR_END - 1,
+ FORMAT_PAINTBRUSH_PARAGRAPH_IDS
+ 0);
+ }
+ return pItemSet;
+}
+
+void lcl_getTableAttributes( SfxItemSet& rSet, SwWrtShell &rSh )
+{
+ SvxBrushItem aBrush( RES_BACKGROUND );
+ rSh.GetBoxBackground(aBrush);
+ rSet.Put( aBrush );
+ if(rSh.GetRowBackground(aBrush))
+ rSet.Put( aBrush, SID_ATTR_BRUSH_ROW );
+ else
+ rSet.InvalidateItem(SID_ATTR_BRUSH_ROW);
+ rSh.GetTabBackground(aBrush);
+ rSet.Put( aBrush, SID_ATTR_BRUSH_TABLE );
+
+ SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
+ rSet.Put(aBoxInfo);
+ rSh.GetTabBorders( rSet );
+
+ SvxFrameDirectionItem aBoxDirection( FRMDIR_ENVIRONMENT, RES_FRAMEDIR );
+ if(rSh.GetBoxDirection( aBoxDirection ))
+ rSet.Put(aBoxDirection, FN_TABLE_BOX_TEXTORIENTATION);
+
+ rSet.Put(SfxUInt16Item(FN_TABLE_SET_VERT_ALIGN, rSh.GetBoxAlign()));
+
+ rSet.Put( SfxUInt16Item( FN_PARAM_TABLE_HEADLINE, rSh.GetRowsToRepeat() ) );
+
+ SwFrmFmt *pFrmFmt = rSh.GetTableFmt();
+ if(pFrmFmt)
+ {
+ rSet.Put( pFrmFmt->GetShadow() );
+ rSet.Put( pFrmFmt->GetBreak() );
+ rSet.Put( pFrmFmt->GetPageDesc() );
+ rSet.Put( pFrmFmt->GetLayoutSplit() );
+ rSet.Put( pFrmFmt->GetKeep() );
+ rSet.Put( pFrmFmt->GetFrmDir() );
+ }
+
+ SwFmtRowSplit* pSplit = 0;
+ rSh.GetRowSplit(pSplit);
+ if(pSplit)
+ rSet.Put(*pSplit);
+}
+
+void lcl_setTableAttributes( const SfxItemSet& rSet, SwWrtShell &rSh )
+{
+ const SfxPoolItem* pItem = 0;
+ bool bBorder = ( SFX_ITEM_SET == rSet.GetItemState( RES_BOX ) ||
+ SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_BORDER_INNER ) );
+ bool bBackground = SFX_ITEM_SET == rSet.GetItemState( RES_BACKGROUND, false, &pItem );
+ const SfxPoolItem* pRowItem = 0, *pTableItem = 0;
+ bBackground |= SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_BRUSH_ROW, false, &pRowItem );
+ bBackground |= SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_BRUSH_TABLE, false, &pTableItem );
+
+ if(bBackground)
+ {
+ if(pItem)
+ rSh.SetBoxBackground( *(const SvxBrushItem*)pItem );
+ if(pRowItem)
+ {
+ SvxBrushItem aBrush(*(const SvxBrushItem*)pRowItem);
+ aBrush.SetWhich(RES_BACKGROUND);
+ rSh.SetRowBackground(aBrush);
+ }
+ if(pTableItem)
+ {
+ SvxBrushItem aBrush(*(const SvxBrushItem*)pTableItem);
+ aBrush.SetWhich(RES_BACKGROUND);
+ rSh.SetTabBackground( aBrush );
+ }
+ }
+ if(bBorder)
+ rSh.SetTabBorders( rSet );
+
+ if( SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_TABLE_HEADLINE, false, &pItem) )
+ rSh.SetRowsToRepeat( ((SfxUInt16Item*)pItem)->GetValue() );
+
+ SwFrmFmt* pFrmFmt = rSh.GetTableFmt();
+ if(pFrmFmt)
+ {
+ //RES_SHADOW
+ pItem=0;
+ rSet.GetItemState(rSet.GetPool()->GetWhich(RES_SHADOW), false, &pItem);
+ if(pItem)
+ pFrmFmt->SetFmtAttr( *pItem );
+
+ //RES_BREAK
+ pItem=0;
+ rSet.GetItemState(rSet.GetPool()->GetWhich(RES_BREAK), false, &pItem);
+ if(pItem)
+ pFrmFmt->SetFmtAttr( *pItem );
+
+ //RES_PAGEDESC
+ pItem=0;
+ rSet.GetItemState(rSet.GetPool()->GetWhich(RES_PAGEDESC), false, &pItem);
+ if(pItem)
+ pFrmFmt->SetFmtAttr( *pItem );
+
+ //RES_LAYOUT_SPLIT
+ pItem=0;
+ rSet.GetItemState(rSet.GetPool()->GetWhich(RES_LAYOUT_SPLIT), false, &pItem);
+ if(pItem)
+ pFrmFmt->SetFmtAttr( *pItem );
+
+ //RES_KEEP
+ pItem=0;
+ rSet.GetItemState(rSet.GetPool()->GetWhich(RES_KEEP), false, &pItem);
+ if(pItem)
+ pFrmFmt->SetFmtAttr( *pItem );
+
+ //RES_FRAMEDIR
+ pItem=0;
+ rSet.GetItemState(rSet.GetPool()->GetWhich(RES_FRAMEDIR), false, &pItem);
+ if(pItem)
+ pFrmFmt->SetFmtAttr( *pItem );
+ }
+
+ if( SFX_ITEM_SET == rSet.GetItemState( FN_TABLE_BOX_TEXTORIENTATION, false, &pItem) )
+ {
+ SvxFrameDirectionItem aDirection( FRMDIR_ENVIRONMENT, RES_FRAMEDIR );
+ aDirection.SetValue(static_cast< const SvxFrameDirectionItem* >(pItem)->GetValue());
+ rSh.SetBoxDirection(aDirection);
+ }
+
+ if( SFX_ITEM_SET == rSet.GetItemState( FN_TABLE_SET_VERT_ALIGN, false, &pItem))
+ rSh.SetBoxAlign(((SfxUInt16Item*)(pItem))->GetValue());
+
+ if( SFX_ITEM_SET == rSet.GetItemState( RES_ROW_SPLIT, false, &pItem) )
+ rSh.SetRowSplit(*static_cast<const SwFmtRowSplit*>(pItem));
+}
+}//end anonymous namespace
+
+SwFormatClipboard::SwFormatClipboard()
+ : m_nSelectionType(0)
+ , m_pItemSet_TxtAttr(0)
+ , m_pItemSet_ParAttr(0)
+ , m_pTableItemSet(0)
+ , m_bPersistentCopy(false)
+{
+}
+SwFormatClipboard::~SwFormatClipboard()
+{
+ delete m_pItemSet_TxtAttr;
+ delete m_pItemSet_ParAttr;
+ delete m_pTableItemSet;
+}
+
+bool SwFormatClipboard::HasContent() const
+{
+ return m_pItemSet_TxtAttr!=0
+ || m_pItemSet_ParAttr!=0
+ || m_pTableItemSet != 0
+ || !m_aCharStyle.isEmpty()
+ || !m_aParaStyle.isEmpty()
+ ;
+}
+bool SwFormatClipboard::HasContentForThisType( int nSelectionType ) const
+{
+ if( !HasContent() )
+ return false;
+
+ if( m_nSelectionType == nSelectionType )
+ return true;
+
+ if( ( nSelectionType & (nsSelectionType::SEL_FRM | nsSelectionType::SEL_OLE | nsSelectionType::SEL_GRF) )
+ &&
+ ( m_nSelectionType & (nsSelectionType::SEL_FRM | nsSelectionType::SEL_OLE | nsSelectionType::SEL_GRF) )
+ )
+ return true;
+
+ if( nSelectionType & nsSelectionType::SEL_TXT && m_nSelectionType & nsSelectionType::SEL_TXT )
+ return true;
+
+ return false;
+}
+
+bool SwFormatClipboard::CanCopyThisType( int nSelectionType ) const
+{
+ if( nSelectionType & (nsSelectionType::SEL_FRM | nsSelectionType::SEL_OLE | nsSelectionType::SEL_GRF
+ | nsSelectionType::SEL_TXT | nsSelectionType::SEL_DRW | nsSelectionType::SEL_TBL | nsSelectionType::SEL_TBL_CELLS ) )
+ return true;
+ return false;
+}
+
+void SwFormatClipboard::Copy( SwWrtShell& rWrtShell, SfxItemPool& rPool, bool bPersistentCopy )
+{
+ // first clear the previously stored attributes
+ this->Erase();
+ m_bPersistentCopy = bPersistentCopy;
+
+ int nSelectionType = rWrtShell.GetSelectionType();
+ SfxItemSet* pItemSet_TxtAttr = lcl_CreateEmptyItemSet( nSelectionType, rPool, true );
+ SfxItemSet* pItemSet_ParAttr = lcl_CreateEmptyItemSet( nSelectionType, rPool, false );
+
+ rWrtShell.StartAction();
+ rWrtShell.Push();
+
+ // modify the "Point and Mark" of the cursor
+ // in order to select only the last character of the
+ // selection(s) and then to get the attributes of this single character
+ if( nSelectionType == nsSelectionType::SEL_TXT )
+ {
+ // get the current PaM, the cursor
+ // if there several selection it curently point
+ // on the last (sort by there creation time) selection
+ SwPaM* pCrsr = rWrtShell.GetCrsr();
+
+ sal_Bool bHasSelection = pCrsr->HasMark();
+ bool bForwardSelection = false;
+
+ if(!bHasSelection && pCrsr->GetPrev() != pCrsr && pCrsr->GetPrev() != 0)
+ {
+ // if cursor has multiple selections
+
+ // clear all the selections except the last
+ rWrtShell.KillPams();
+
+ // reset the cursor to the remaining selection
+ pCrsr = rWrtShell.GetCrsr();
+ bHasSelection = true;
+ }
+
+ bool dontMove = false;
+ if (bHasSelection)
+ {
+ bForwardSelection = (*pCrsr->GetPoint()) > (*pCrsr->GetMark());
+
+ // clear the selection leaving just the cursor
+ pCrsr->DeleteMark();
+ pCrsr->SetMark();
+ }
+ else
+ {
+ bool rightToLeft = rWrtShell.IsInRightToLeftText();
+ // if there were no selection (only a cursor) and the cursor was at
+ // the end of the paragraph then don't move
+ if ( rWrtShell.IsEndPara() && !rightToLeft )
+ dontMove = true;
+
+ // revert left and right
+ if ( rightToLeft )
+ {
+ if (pCrsr->GetPoint()->nContent == 0)
+ dontMove = true;
+ else
+ bForwardSelection = !bForwardSelection;
+ }
+ }
+
+ // move the cursor in order to select one character
+ if (!dontMove)
+ pCrsr->Move( bForwardSelection ? fnMoveBackward : fnMoveForward );
+ }
+
+ if(pItemSet_TxtAttr)
+ {
+ if( nSelectionType & (nsSelectionType::SEL_FRM | nsSelectionType::SEL_OLE | nsSelectionType::SEL_GRF) )
+ rWrtShell.GetFlyFrmAttr(*pItemSet_TxtAttr);
+ else
+ {
+ // get the text attributes from named and automatic formatting
+ rWrtShell.GetCurAttr(*pItemSet_TxtAttr);
+
+ if( nSelectionType & nsSelectionType::SEL_TXT )
+ {
+ // get the paragraph attributes (could be character properties)
+ // from named and automatic formatting
+ rWrtShell.GetCurParAttr(*pItemSet_ParAttr);
+ }
+ }
+ }
+ else if ( nSelectionType & nsSelectionType::SEL_DRW )
+ {
+ SdrView* pDrawView = rWrtShell.GetDrawView();
+ if(pDrawView)
+ {
+ sal_Bool bOnlyHardAttr = sal_True;
+ if( pDrawView->AreObjectsMarked() )
+ {
+ pItemSet_TxtAttr = new SfxItemSet( pDrawView->GetAttrFromMarked(bOnlyHardAttr) );
+ //remove attributes defining the type/data of custom shapes
+ pItemSet_TxtAttr->ClearItem(SDRATTR_CUSTOMSHAPE_ENGINE);
+ pItemSet_TxtAttr->ClearItem(SDRATTR_CUSTOMSHAPE_DATA);
+ pItemSet_TxtAttr->ClearItem(SDRATTR_CUSTOMSHAPE_GEOMETRY);
+ pItemSet_TxtAttr->ClearItem(SDRATTR_CUSTOMSHAPE_REPLACEMENT_URL);
+ }
+ }
+ }
+
+ if( nSelectionType & nsSelectionType::SEL_TBL_CELLS )//only copy table attributes if really cells are selected (not only text in tables)
+ {
+ m_pTableItemSet = new SfxItemSet(rPool,
+ SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_SHADOW, //SID_ATTR_BORDER_OUTER is inbetween
+ RES_BACKGROUND, RES_SHADOW, //RES_BOX is inbetween
+ SID_ATTR_BRUSH_ROW, SID_ATTR_BRUSH_TABLE,
+ RES_BREAK, RES_BREAK,
+ RES_PAGEDESC, RES_PAGEDESC,
+ RES_LAYOUT_SPLIT, RES_LAYOUT_SPLIT,
+ RES_ROW_SPLIT, RES_ROW_SPLIT,
+ RES_KEEP, RES_KEEP,
+ RES_FRAMEDIR, RES_FRAMEDIR,
+ FN_PARAM_TABLE_HEADLINE, FN_PARAM_TABLE_HEADLINE,
+ FN_TABLE_BOX_TEXTORIENTATION, FN_TABLE_BOX_TEXTORIENTATION,
+ FN_TABLE_SET_VERT_ALIGN, FN_TABLE_SET_VERT_ALIGN,
+ 0);
+ lcl_getTableAttributes( *m_pTableItemSet, rWrtShell );
+ }
+
+ m_nSelectionType = nSelectionType;
+ m_pItemSet_TxtAttr = pItemSet_TxtAttr;
+ m_pItemSet_ParAttr = pItemSet_ParAttr;
+
+ if( nSelectionType & nsSelectionType::SEL_TXT )
+ {
+ // if text is selected save the named character format
+ SwFmt* pFmt = rWrtShell.GetCurCharFmt();
+ if( pFmt )
+ m_aCharStyle = pFmt->GetName();
+
+ // and the named paragraph format
+ pFmt = rWrtShell.GetCurTxtFmtColl();
+ if( pFmt )
+ m_aParaStyle = pFmt->GetName();
+ }
+
+ rWrtShell.Pop(sal_False);
+ rWrtShell.EndAction();
+}
+
+typedef boost::shared_ptr< SfxPoolItem > SfxPoolItemSharedPtr;
+typedef std::vector< SfxPoolItemSharedPtr > ItemVector;
+// collect all PoolItems from the applied styles
+static void lcl_AppendSetItems( ItemVector& rItemVector, const SfxItemSet& rStyleAttrSet )
+{
+ const sal_uInt16* pRanges = rStyleAttrSet.GetRanges();
+ while( *pRanges )
+ {
+ for ( sal_uInt16 nWhich = *pRanges; nWhich <= *(pRanges+1); ++nWhich )
+ {
+ const SfxPoolItem* pItem;
+ if( SFX_ITEM_SET == rStyleAttrSet.GetItemState( nWhich, false, &pItem ) )
+ {
+ rItemVector.push_back( SfxPoolItemSharedPtr( pItem->Clone() ) );
+ }
+ }
+ pRanges += 2;
+ }
+}
+// remove all items that are inherited from the styles
+static void lcl_RemoveEqualItems( SfxItemSet& rTemplateItemSet, const ItemVector& rItemVector )
+{
+ ItemVector::const_iterator aEnd = rItemVector.end();
+ ItemVector::const_iterator aIter = rItemVector.begin();
+ while( aIter != aEnd )
+ {
+ const SfxPoolItem* pItem;
+ if( SFX_ITEM_SET == rTemplateItemSet.GetItemState( (*aIter)->Which(), true, &pItem ) &&
+ *pItem == *(*aIter) )
+ {
+ rTemplateItemSet.ClearItem( (*aIter)->Which() );
+ }
+ ++aIter;
+ }
+}
+
+void SwFormatClipboard::Paste( SwWrtShell& rWrtShell, SfxStyleSheetBasePool* pPool
+ , bool bNoCharacterFormats, bool bNoParagraphFormats )
+{
+ int nSelectionType = rWrtShell.GetSelectionType();
+ if( !this->HasContentForThisType(nSelectionType) )
+ {
+ if(!m_bPersistentCopy)
+ this->Erase();
+ return;
+ }
+
+ rWrtShell.StartAction();
+ rWrtShell.StartUndo(UNDO_INSATTR);
+
+ ItemVector aItemVector;
+
+ if( nSelectionType & nsSelectionType::SEL_TXT )
+ {
+ // apply the named text and paragraph formatting
+ if( pPool )
+ {
+ // if there is a named text format recorded and the user wants to apply it
+ if(!m_aCharStyle.isEmpty() && !bNoCharacterFormats )
+ {
+ // look for the named text format in the pool
+ SwDocStyleSheet* pStyle = static_cast<SwDocStyleSheet*>(pPool->Find(m_aCharStyle, SFX_STYLE_FAMILY_CHAR));
+
+ // if the style is found
+ if( pStyle )
+ {
+ SwFmtCharFmt aFmt(pStyle->GetCharFmt());
+ // store the attributes from this style in aItemVector in order
+ // not to apply them as automatic formatting attributes later in the code
+ lcl_AppendSetItems( aItemVector, aFmt.GetCharFmt()->GetAttrSet());
+
+ // apply the named format
+ rWrtShell.SetAttrItem( aFmt );
+ }
+ }
+
+ // if there is a named paragraph format recorded and the user wants to apply it
+ if(!m_aParaStyle.isEmpty() && !bNoParagraphFormats )
+ {
+ // look for the named pragraph format in the pool
+ SwDocStyleSheet* pStyle = static_cast<SwDocStyleSheet*>(pPool->Find(m_aParaStyle, SFX_STYLE_FAMILY_PARA));
+ if( pStyle )
+ {
+ // store the attributes from this style in aItemVector in order
+ // not to apply them as automatic formatting attributes later in the code
+ lcl_AppendSetItems( aItemVector, pStyle->GetCollection()->GetAttrSet());
+
+ // apply the named format
+ rWrtShell.SetTxtFmtColl( pStyle->GetCollection() );
+ }
+ }
+ }
+
+ // apply the paragraph automatic attributes
+ if ( m_pItemSet_ParAttr && m_pItemSet_ParAttr->Count() != 0 && !bNoParagraphFormats )
+ {
+ // temporary SfxItemSet
+ SfxItemSet* pTemplateItemSet = lcl_CreateEmptyItemSet(
+ nSelectionType, *m_pItemSet_ParAttr->GetPool(), false);
+ // no need to verify the existance of pTemplateItemSet as we
+ // know that here the selection type is SEL_TXT
+
+ pTemplateItemSet->Put( *m_pItemSet_ParAttr );
+
+ // remove attribute that were applied by named text and paragraph formatting
+ lcl_RemoveEqualItems( *pTemplateItemSet, aItemVector );
+
+ // apply the paragraph automatic attributes to all the nodes in the selection
+ rWrtShell.SetAttrSet(*pTemplateItemSet);
+
+ // store the attributes in aItemVector in order not to apply them as
+ // text automatic formatting attributes later in the code
+ lcl_AppendSetItems( aItemVector, *pTemplateItemSet);
+
+ delete pTemplateItemSet;
+ }
+ }
+
+ if(m_pItemSet_TxtAttr)
+ {
+ if( nSelectionType & nsSelectionType::SEL_DRW )
+ {
+ SdrView* pDrawView = rWrtShell.GetDrawView();
+ if(pDrawView)
+ {
+ sal_Bool bReplaceAll = sal_True;
+ pDrawView->SetAttrToMarked(*m_pItemSet_TxtAttr, bReplaceAll);
+ }
+ }
+ else
+ {
+ // temporary SfxItemSet
+ SfxItemSet* pTemplateItemSet = lcl_CreateEmptyItemSet(
+ nSelectionType, *m_pItemSet_TxtAttr->GetPool(), true );
+
+ if(pTemplateItemSet)
+ {
+ // copy the stored automatic text attributes in a temporary SfxItemSet
+ pTemplateItemSet->Put( *m_pItemSet_TxtAttr );
+
+ // only attributes that were not apply by named style attributes and automatic
+ // paragraph attributes should be applied
+ lcl_RemoveEqualItems( *pTemplateItemSet, aItemVector );
+
+ // apply the character automatic attributes
+ if( nSelectionType & (nsSelectionType::SEL_FRM | nsSelectionType::SEL_OLE | nsSelectionType::SEL_GRF) )
+ rWrtShell.SetFlyFrmAttr(*pTemplateItemSet);
+ else if ( !bNoCharacterFormats )
+ rWrtShell.SetAttrSet(*pTemplateItemSet);
+
+ delete pTemplateItemSet;
+ }
+ }
+ }
+
+ if( m_pTableItemSet && nSelectionType & (nsSelectionType::SEL_TBL | nsSelectionType::SEL_TBL_CELLS) )
+ lcl_setTableAttributes( *m_pTableItemSet, rWrtShell );
+
+ rWrtShell.EndUndo(UNDO_INSATTR);
+ rWrtShell.EndAction();
+
+ if(!m_bPersistentCopy)
+ this->Erase();
+}
+
+void SwFormatClipboard::Erase()
+{
+ m_nSelectionType = 0;
+
+ delete m_pItemSet_TxtAttr;
+ m_pItemSet_TxtAttr = 0;
+
+ delete m_pItemSet_ParAttr;
+ m_pItemSet_ParAttr = 0;
+
+ delete m_pTableItemSet;
+ m_pTableItemSet = 0;
+
+ if( !m_aCharStyle.isEmpty() )
+ m_aCharStyle = "";
+ if( !m_aParaStyle.isEmpty() )
+ m_aParaStyle = "";
+
+ m_bPersistentCopy = false;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/uiview/pview.cxx b/sw/source/core/uibase/uiview/pview.cxx
new file mode 100644
index 000000000000..50aa5e1bd92a
--- /dev/null
+++ b/sw/source/core/uibase/uiview/pview.cxx
@@ -0,0 +1,1909 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <sfx2/objface.hxx>
+#include <vcl/timer.hxx>
+#include <vcl/field.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/help.hxx>
+#include <vcl/cmdevt.hxx>
+#include <vcl/button.hxx>
+#include <vcl/settings.hxx>
+
+#include <svl/whiter.hxx>
+#include <svl/stritem.hxx>
+#include <svl/eitem.hxx>
+#include <sfx2/printer.hxx>
+#include <sfx2/progress.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/dispatch.hxx>
+#include <vcl/msgbox.hxx>
+#include <svx/stddlg.hxx>
+#include <editeng/paperinf.hxx>
+#include <svl/srchitem.hxx>
+#include <svx/svdview.hxx>
+#include <svx/dlgutil.hxx>
+#include <svx/zoomslideritem.hxx>
+#include <svx/svxids.hrc>
+
+#include <swwait.hxx>
+#include <globdoc.hxx>
+#include <wdocsh.hxx>
+#include <pvprtdat.hxx>
+#include <swmodule.hxx>
+#include <modcfg.hxx>
+#include <wrtsh.hxx>
+#include <docsh.hxx>
+#include <viewopt.hxx>
+#include <doc.hxx>
+#include <pview.hxx>
+#include <view.hxx>
+#include <textsh.hxx>
+#include <scroll.hxx>
+#include <prtopt.hxx>
+#include <docstat.hxx>
+#include <usrpref.hxx>
+#include <viewfunc.hxx>
+
+#include <helpid.h>
+#include <cmdid.h>
+#include <globals.hrc>
+#include <popup.hrc>
+#include <view.hrc>
+
+#define SwPagePreview
+#include <sfx2/msg.hxx>
+#include <swslots.hxx>
+#include <pagepreviewlayout.hxx>
+
+#include <svx/svxdlg.hxx>
+#include <svx/dialogs.hrc>
+#include <osl/mutex.hxx>
+
+#include <boost/scoped_ptr.hpp>
+
+using namespace ::com::sun::star;
+SFX_IMPL_NAMED_VIEWFACTORY(SwPagePreview, "PrintPreview")
+{
+ SFX_VIEW_REGISTRATION(SwDocShell);
+ SFX_VIEW_REGISTRATION(SwWebDocShell);
+ SFX_VIEW_REGISTRATION(SwGlobalDocShell);
+}
+
+SFX_IMPL_INTERFACE(SwPagePreview, SfxViewShell, SW_RES(RID_PVIEW_TOOLBOX))
+{
+ SFX_POPUPMENU_REGISTRATION(SW_RES(MN_PPREVIEW_POPUPMENU));
+ SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT|SFX_VISIBILITY_STANDARD|
+ SFX_VISIBILITY_CLIENT|SFX_VISIBILITY_FULLSCREEN|
+ SFX_VISIBILITY_READONLYDOC,
+ SW_RES(RID_PVIEW_TOOLBOX));
+}
+
+TYPEINIT1(SwPagePreview,SfxViewShell)
+
+#define SWVIEWFLAGS ( SFX_VIEW_CAN_PRINT|SFX_VIEW_HAS_PRINTOPTIONS )
+
+#define MIN_PREVIEW_ZOOM 25
+#define MAX_PREVIEW_ZOOM 600
+
+static sal_uInt16 lcl_GetNextZoomStep(sal_uInt16 nCurrentZoom, sal_Bool bZoomIn)
+{
+ static const sal_uInt16 aZoomArr[] =
+ {
+ 25, 50, 75, 100, 150, 200, 400, 600
+ };
+ const sal_uInt16 nZoomArrSize = sizeof(aZoomArr)/sizeof(sal_uInt16);
+ if(bZoomIn)
+ for(int i = nZoomArrSize - 1; i >= 0; --i)
+ {
+ if(nCurrentZoom > aZoomArr[i] || !i)
+ return aZoomArr[i];
+ }
+ else
+ for(int i = 0; i < nZoomArrSize; ++i)
+ {
+ if(nCurrentZoom < aZoomArr[i])
+ return aZoomArr[i];
+ }
+ return bZoomIn ? MAX_PREVIEW_ZOOM : MIN_PREVIEW_ZOOM;
+};
+
+static void lcl_InvalidateZoomSlots(SfxBindings& rBindings)
+{
+ static sal_uInt16 const aInval[] =
+ {
+ SID_ATTR_ZOOM, SID_ZOOM_OUT, SID_ZOOM_IN, SID_ATTR_ZOOMSLIDER, FN_PREVIEW_ZOOM, FN_STAT_ZOOM,
+ 0
+ };
+ rBindings.Invalidate( aInval );
+}
+
+// At first the zoom dialog
+class SwPreviewZoomDlg : public SvxStandardDialog
+{
+ NumericField* m_pRowEdit;
+ NumericField* m_pColEdit;
+
+ virtual void Apply();
+
+public:
+ SwPreviewZoomDlg( SwPagePreviewWin& rParent );
+};
+
+SwPreviewZoomDlg::SwPreviewZoomDlg( SwPagePreviewWin& rParent )
+ : SvxStandardDialog(&rParent, "PreviewZoomDialog", "modules/swriter/ui/previewzoomdialog.ui")
+{
+ get(m_pRowEdit, "rows");
+ get(m_pColEdit, "cols");
+
+ m_pRowEdit->SetValue( rParent.GetRow() );
+ m_pColEdit->SetValue( rParent.GetCol() );
+}
+
+void SwPreviewZoomDlg::Apply()
+{
+ ((SwPagePreviewWin*)GetParent())->CalcWish(
+ sal_uInt8(m_pRowEdit->GetValue()),
+ sal_uInt8(m_pColEdit->GetValue()) );
+}
+
+// all for SwPagePreviewWin
+SwPagePreviewWin::SwPagePreviewWin( Window *pParent, SwPagePreview& rPView )
+ : Window(pParent, WinBits(WB_CLIPCHILDREN))
+ , mpViewShell(0)
+ , mrView(rPView)
+ , mbCalcScaleForPreviewLayout(true)
+ , maPaintedPreviewDocRect(Rectangle(0,0,0,0))
+ , mpPgPreviewLayout(NULL)
+{
+ SetOutDevViewType( OUTDEV_VIEWTYPE_PRINTPREVIEW );
+ SetHelpId(HID_PAGEPREVIEW);
+ SetFillColor( GetBackground().GetColor() );
+ SetLineColor( GetBackground().GetColor());
+ SetMapMode( MapMode(MAP_TWIP) );
+
+ const SwMasterUsrPref *pUsrPref = SW_MOD()->GetUsrPref(sal_False);
+ mnRow = pUsrPref->GetPagePrevRow(); // 1 row
+ mnCol = pUsrPref->GetPagePrevCol(); // 1 column
+ mnSttPage = USHRT_MAX;
+}
+
+SwPagePreviewWin::~SwPagePreviewWin()
+{
+}
+
+void SwPagePreviewWin::Paint( const Rectangle& rRect )
+{
+ if( !mpViewShell || !mpViewShell->GetLayout() )
+ return;
+
+ if( USHRT_MAX == mnSttPage ) // was never calculated ? (Init-Phase!)
+ {
+ // This is the size to which I always relate.
+ if( !maPxWinSize.Height() || !maPxWinSize.Width() )
+ maPxWinSize = GetOutputSizePixel();
+
+ Rectangle aRect( LogicToPixel( rRect ));
+ mpPgPreviewLayout->Prepare( 1, Point(0,0), maPxWinSize,
+ mnSttPage, maPaintedPreviewDocRect );
+ SetSelectedPage( 1 );
+ mpPgPreviewLayout->Paint( PixelToLogic( aRect ) );
+ SetPagePreview(mnRow, mnCol);
+ }
+ else
+ {
+ MapMode aMM( GetMapMode() );
+ aMM.SetScaleX( maScale );
+ aMM.SetScaleY( maScale );
+ SetMapMode( aMM );
+ mpPgPreviewLayout->Paint( rRect );
+ }
+}
+
+void SwPagePreviewWin::CalcWish( sal_uInt8 nNewRow, sal_uInt8 nNewCol )
+{
+ if( !mpViewShell || !mpViewShell->GetLayout() )
+ return;
+
+ sal_uInt16 nOldCol = mnCol;
+ mnRow = nNewRow;
+ mnCol = nNewCol;
+ sal_uInt16 nPages = mnRow * mnCol,
+ nLastSttPg = mrView.GetPageCount()+1 > nPages
+ ? mrView.GetPageCount()+1 - nPages : 0;
+ if( mnSttPage > nLastSttPg )
+ mnSttPage = nLastSttPg;
+
+ mpPgPreviewLayout->Init( mnCol, mnRow, maPxWinSize, true );
+ mpPgPreviewLayout->Prepare( mnSttPage, Point(0,0), maPxWinSize,
+ mnSttPage, maPaintedPreviewDocRect );
+ SetSelectedPage( mnSttPage );
+ SetPagePreview(mnRow, mnCol);
+ maScale = GetMapMode().GetScaleX();
+
+ // If changes have taken place at the columns, the special case "single column"
+ // must be considered and corrected if necessary.
+ if( (1 == nOldCol) != (1 == mnCol) )
+ mrView.ScrollDocSzChg();
+
+ // Order must be maintained!
+ // additional invalidate page status.
+ static sal_uInt16 aInval[] =
+ {
+ SID_ATTR_ZOOM, SID_ZOOM_OUT, SID_ZOOM_IN,
+ FN_PREVIEW_ZOOM,
+ FN_START_OF_DOCUMENT, FN_END_OF_DOCUMENT, FN_PAGEUP, FN_PAGEDOWN,
+ FN_STAT_PAGE, FN_STAT_ZOOM,
+ FN_SHOW_TWO_PAGES, FN_SHOW_MULTIPLE_PAGES,
+ 0
+ };
+ SfxBindings& rBindings = mrView.GetViewFrame()->GetBindings();
+ rBindings.Invalidate( aInval );
+ rBindings.Update( FN_SHOW_TWO_PAGES );
+ rBindings.Update( FN_SHOW_MULTIPLE_PAGES );
+ // adjust scrollbars
+ mrView.ScrollViewSzChg();
+}
+
+// mnSttPage is Absolute
+int SwPagePreviewWin::MovePage( int eMoveMode )
+{
+ // number of pages up
+ sal_uInt16 nPages = mnRow * mnCol;
+ sal_uInt16 nNewSttPage = mnSttPage;
+ sal_uInt16 nPageCount = mrView.GetPageCount();
+ sal_uInt16 nDefSttPg = GetDefSttPage();
+ bool bPaintPageAtFirstCol = true;
+
+ switch( eMoveMode )
+ {
+ case MV_PAGE_UP:
+ {
+ const sal_uInt16 nRelSttPage = mpPgPreviewLayout->ConvertAbsoluteToRelativePageNum( mnSttPage );
+ const sal_uInt16 nNewAbsSttPage = nRelSttPage - nPages > 0 ?
+ mpPgPreviewLayout->ConvertRelativeToAbsolutePageNum( nRelSttPage - nPages ) :
+ nDefSttPg;
+ nNewSttPage = nNewAbsSttPage;
+
+ const sal_uInt16 nRelSelPage = mpPgPreviewLayout->ConvertAbsoluteToRelativePageNum( SelectedPage() );
+ const sal_uInt16 nNewRelSelPage = nRelSelPage - nPages > 0 ?
+ nRelSelPage - nPages :
+ 1;
+ SetSelectedPage( mpPgPreviewLayout->ConvertRelativeToAbsolutePageNum( nNewRelSelPage ) );
+
+ break;
+ }
+ case MV_PAGE_DOWN:
+ {
+ const sal_uInt16 nRelSttPage = mpPgPreviewLayout->ConvertAbsoluteToRelativePageNum( mnSttPage );
+ const sal_uInt16 nNewAbsSttPage = mpPgPreviewLayout->ConvertRelativeToAbsolutePageNum( nRelSttPage + nPages );
+ nNewSttPage = nNewAbsSttPage < nPageCount ? nNewAbsSttPage : nPageCount;
+
+ const sal_uInt16 nRelSelPage = mpPgPreviewLayout->ConvertAbsoluteToRelativePageNum( SelectedPage() );
+ const sal_uInt16 nNewAbsSelPage = mpPgPreviewLayout->ConvertRelativeToAbsolutePageNum( nRelSelPage + nPages );
+ SetSelectedPage( nNewAbsSelPage < nPageCount ? nNewAbsSelPage : nPageCount );
+
+ break;
+ }
+ case MV_DOC_STT:
+ nNewSttPage = nDefSttPg;
+ SetSelectedPage( mpPgPreviewLayout->ConvertRelativeToAbsolutePageNum( nNewSttPage ? nNewSttPage : 1 ) );
+ break;
+ case MV_DOC_END:
+ // correct calculation of new start page.
+ nNewSttPage = nPageCount;
+ SetSelectedPage( nPageCount );
+ break;
+ case MV_SELPAGE:
+ // <nNewSttPage> and <SelectedPage()> are already set.
+ // not start at first column, only if the
+ // complete preview layout columns doesn't fit into window.
+ if ( !mpPgPreviewLayout->DoesPreviewLayoutColsFitIntoWindow() )
+ bPaintPageAtFirstCol = false;
+ break;
+ case MV_SCROLL:
+ // check, if paint page at first column
+ // has to be avoided
+ if ( !mpPgPreviewLayout->DoesPreviewLayoutRowsFitIntoWindow() ||
+ !mpPgPreviewLayout->DoesPreviewLayoutColsFitIntoWindow() )
+ bPaintPageAtFirstCol = false;
+ break;
+ case MV_NEWWINSIZE:
+ // nothing special to do.
+ break;
+ case MV_CALC:
+ // re-init page preview layout.
+ mpPgPreviewLayout->ReInit();
+
+ // correct calculation of new start page.
+ if( nNewSttPage > nPageCount )
+ nNewSttPage = nPageCount;
+
+ // correct selected page number
+ if( SelectedPage() > nPageCount )
+ SetSelectedPage( nNewSttPage ? nNewSttPage : 1 );
+ }
+
+ mpPgPreviewLayout->Prepare( nNewSttPage, Point(0,0), maPxWinSize,
+ nNewSttPage,
+ maPaintedPreviewDocRect, bPaintPageAtFirstCol );
+ if( nNewSttPage == mnSttPage &&
+ eMoveMode != MV_SELPAGE )
+ return sal_False;
+
+ SetPagePreview(mnRow, mnCol);
+ mnSttPage = nNewSttPage;
+
+ // additional invalidate page status.
+ static sal_uInt16 aInval[] =
+ {
+ FN_START_OF_DOCUMENT, FN_END_OF_DOCUMENT, FN_PAGEUP, FN_PAGEDOWN,
+ FN_STAT_PAGE, 0
+ };
+
+ SfxBindings& rBindings = mrView.GetViewFrame()->GetBindings();
+ rBindings.Invalidate( aInval );
+
+ return sal_True;
+}
+
+void SwPagePreviewWin::SetWinSize( const Size& rNewSize )
+{
+ // We always want the size as pixel units.
+ maPxWinSize = LogicToPixel( rNewSize );
+
+ if( USHRT_MAX == mnSttPage )
+ {
+ mnSttPage = GetDefSttPage();
+ SetSelectedPage( GetDefSttPage() );
+ }
+
+ if ( mbCalcScaleForPreviewLayout )
+ {
+ mpPgPreviewLayout->Init( mnCol, mnRow, maPxWinSize, true );
+ maScale = GetMapMode().GetScaleX();
+ }
+ mpPgPreviewLayout->Prepare( mnSttPage, Point(0,0), maPxWinSize,
+ mnSttPage, maPaintedPreviewDocRect );
+ if ( mbCalcScaleForPreviewLayout )
+ {
+ SetSelectedPage( mnSttPage );
+ mbCalcScaleForPreviewLayout = false;
+ }
+ SetPagePreview(mnRow, mnCol);
+ maScale = GetMapMode().GetScaleX();
+}
+
+OUString SwPagePreviewWin::GetStatusStr( sal_uInt16 nPageCnt ) const
+{
+ // show physical and virtual page number of
+ // selected page, if it's visible.
+ sal_uInt16 nPageNum;
+ if ( mpPgPreviewLayout->IsPageVisible( mpPgPreviewLayout->SelectedPage() ) )
+ {
+ nPageNum = mpPgPreviewLayout->SelectedPage();
+ }
+ else
+ {
+ nPageNum = mnSttPage > 1 ? mnSttPage : 1;
+ }
+ OUStringBuffer aStatusStr;
+ sal_uInt16 nVirtPageNum = mpPgPreviewLayout->GetVirtPageNumByPageNum( nPageNum );
+ if( nVirtPageNum && nVirtPageNum != nPageNum )
+ {
+ aStatusStr.append( OUString::number(nVirtPageNum) + " " );
+ }
+ aStatusStr.append( OUString::number(nPageNum) + " / " + OUString::number(nPageCnt) );
+ return aStatusStr.makeStringAndClear();
+}
+
+void SwPagePreviewWin::KeyInput( const KeyEvent &rKEvt )
+{
+ const KeyCode& rKeyCode = rKEvt.GetKeyCode();
+ sal_uInt16 nKey = rKeyCode.GetCode();
+ bool bHandled = false;
+ if(!rKeyCode.GetModifier())
+ {
+ sal_uInt16 nSlot = 0;
+ switch(nKey)
+ {
+ case KEY_ADD : nSlot = SID_ZOOM_OUT; break;
+ case KEY_ESCAPE: nSlot = FN_CLOSE_PAGEPREVIEW; break;
+ case KEY_SUBTRACT : nSlot = SID_ZOOM_IN; break;
+ }
+ if(nSlot)
+ {
+ bHandled = true;
+ mrView.GetViewFrame()->GetDispatcher()->Execute(
+ nSlot, SFX_CALLMODE_ASYNCHRON );
+ }
+ }
+ if( !bHandled && !mrView.KeyInput( rKEvt ) )
+ Window::KeyInput( rKEvt );
+}
+
+void SwPagePreviewWin::Command( const CommandEvent& rCEvt )
+{
+ bool bCallBase = true;
+ switch( rCEvt.GetCommand() )
+ {
+ case COMMAND_CONTEXTMENU:
+ mrView.GetViewFrame()->GetDispatcher()->ExecutePopup();
+ bCallBase = false;
+ break;
+
+ case COMMAND_WHEEL:
+ case COMMAND_STARTAUTOSCROLL:
+ case COMMAND_AUTOSCROLL:
+ {
+ const CommandWheelData* pData = rCEvt.GetWheelData();
+ if( pData )
+ {
+ const CommandWheelData aDataNew(pData->GetDelta(),pData->GetNotchDelta(),COMMAND_WHEEL_PAGESCROLL,
+ pData->GetMode(),pData->GetModifier(),pData->IsHorz(), pData->IsDeltaPixel());
+ const CommandEvent aEvent( rCEvt.GetMousePosPixel(),rCEvt.GetCommand(),rCEvt.IsMouseEvent(),&aDataNew);
+ bCallBase = !mrView.HandleWheelCommands( aEvent );
+ }
+ else
+ bCallBase = !mrView.HandleWheelCommands( rCEvt );
+ }
+ break;
+ default:
+ ;
+ }
+
+ if( bCallBase )
+ Window::Command( rCEvt );
+}
+
+void SwPagePreviewWin::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ // consider single-click to set selected page
+ if( MOUSE_LEFT == ( rMEvt.GetModifier() + rMEvt.GetButtons() ) )
+ {
+ Point aPreviewPos( PixelToLogic( rMEvt.GetPosPixel() ) );
+ Point aDocPos;
+ bool bPosInEmptyPage;
+ sal_uInt16 nNewSelectedPage;
+ bool bIsDocPos =
+ mpPgPreviewLayout->IsPreviewPosInDocPreviewPage( aPreviewPos,
+ aDocPos, bPosInEmptyPage, nNewSelectedPage );
+ if ( bIsDocPos && rMEvt.GetClicks() == 2 )
+ {
+ // close page preview, set new cursor position and switch to
+ // normal view.
+ OUString sNewCrsrPos = OUString::number( aDocPos.X() ) + ";" +
+ OUString::number( aDocPos.Y() ) + ";";
+ mrView.SetNewCrsrPos( sNewCrsrPos );
+
+ SfxViewFrame *pTmpFrm = mrView.GetViewFrame();
+ pTmpFrm->GetBindings().Execute( SID_VIEWSHELL0, NULL, 0,
+ SFX_CALLMODE_ASYNCHRON );
+ }
+ else if ( bIsDocPos || bPosInEmptyPage )
+ {
+ // show clicked page as the selected one
+ mpPgPreviewLayout->MarkNewSelectedPage( nNewSelectedPage );
+ GetViewShell()->ShowPreviewSelection( nNewSelectedPage );
+ // adjust position at vertical scrollbar.
+ if ( mpPgPreviewLayout->DoesPreviewLayoutRowsFitIntoWindow() )
+ {
+ mrView.SetVScrollbarThumbPos( nNewSelectedPage );
+ }
+ // invalidate page status.
+ static sal_uInt16 aInval[] =
+ {
+ FN_STAT_PAGE, 0
+ };
+ SfxBindings& rBindings = mrView.GetViewFrame()->GetBindings();
+ rBindings.Invalidate( aInval );
+ }
+ }
+}
+
+// Set user prefs or view options
+
+void SwPagePreviewWin::SetPagePreview( sal_uInt8 nRow, sal_uInt8 nCol )
+{
+ SwMasterUsrPref *pOpt = (SwMasterUsrPref *)SW_MOD()->GetUsrPref(sal_False);
+
+ if (nRow != pOpt->GetPagePrevRow() || nCol != pOpt->GetPagePrevCol())
+ {
+ pOpt->SetPagePrevRow( nRow );
+ pOpt->SetPagePrevCol( nCol );
+ pOpt->SetModified();
+
+ // Update scrollbar!
+ mrView.ScrollViewSzChg();
+ }
+}
+
+/** get selected page in document preview
+
+ @author OD
+*/
+sal_uInt16 SwPagePreviewWin::SelectedPage() const
+{
+ return mpPgPreviewLayout->SelectedPage();
+}
+
+/** set selected page number in document preview
+
+ @author OD
+*/
+void SwPagePreviewWin::SetSelectedPage( sal_uInt16 _nSelectedPageNum )
+{
+ mpPgPreviewLayout->SetSelectedPage( _nSelectedPageNum );
+}
+
+/** method to enable/disable book preview
+
+ @author OD
+*/
+bool SwPagePreviewWin::SetBookPreviewMode( const bool _bBookPreview )
+{
+ return mpPgPreviewLayout->SetBookPreviewMode( _bBookPreview,
+ mnSttPage,
+ maPaintedPreviewDocRect );
+}
+
+void SwPagePreviewWin::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ Window::DataChanged( rDCEvt );
+
+ switch( rDCEvt.GetType() )
+ {
+ case DATACHANGED_SETTINGS:
+ // Rearrange the scrollbars or trigger resize, because the
+ // size of the scrollbars may have be changed. Also the
+ // size of the scrollbars has to be retrieved from the settings
+ // out of the resize handler.
+ if( rDCEvt.GetFlags() & SETTINGS_STYLE )
+ mrView.InvalidateBorder(); // Scrollbar widths
+ // zoom has to be disabled if Accessibility support is switched on
+ lcl_InvalidateZoomSlots(mrView.GetViewFrame()->GetBindings());
+ break;
+
+ case DATACHANGED_PRINTER:
+ case DATACHANGED_DISPLAY:
+ case DATACHANGED_FONTS:
+ case DATACHANGED_FONTSUBSTITUTION:
+ mrView.GetDocShell()->UpdateFontList(); // Font change
+ if ( mpViewShell->GetWin() )
+ mpViewShell->GetWin()->Invalidate();
+ break;
+ }
+}
+
+/** help method to execute SfxRequest FN_PAGEUP and FN_PAGEDOWN
+
+ @author OD
+*/
+void SwPagePreview::_ExecPgUpAndPgDown( const bool _bPgUp,
+ SfxRequest* _pReq )
+{
+ SwPagePreviewLayout* pPagePreviewLay = GetViewShell()->PagePreviewLayout();
+ // check, if top/bottom of preview is *not* already visible.
+ if( pPagePreviewLay->GetWinPagesScrollAmount( _bPgUp ? -1 : 1 ) != 0 )
+ {
+ if ( pPagePreviewLay->DoesPreviewLayoutRowsFitIntoWindow() &&
+ pPagePreviewLay->DoesPreviewLayoutColsFitIntoWindow() )
+ {
+ const int eMvMode = _bPgUp ?
+ SwPagePreviewWin::MV_PAGE_UP :
+ SwPagePreviewWin::MV_PAGE_DOWN;
+ if ( ChgPage( eMvMode, sal_True ) )
+ pViewWin->Invalidate();
+ }
+ else
+ {
+ SwTwips nScrollAmount;
+ sal_uInt16 nNewSelectedPageNum = 0;
+ const sal_uInt16 nVisPages = pViewWin->GetRow() * pViewWin->GetCol();
+ if( _bPgUp )
+ {
+ if ( pPagePreviewLay->DoesPreviewLayoutRowsFitIntoWindow() )
+ {
+ nScrollAmount = pPagePreviewLay->GetWinPagesScrollAmount( -1 );
+ if ( (pViewWin->SelectedPage() - nVisPages) > 0 )
+ nNewSelectedPageNum = pViewWin->SelectedPage() - nVisPages;
+ else
+ nNewSelectedPageNum = 1;
+ }
+ else
+ nScrollAmount = - std::min( pViewWin->GetOutputSize().Height(),
+ pViewWin->GetPaintedPreviewDocRect().Top() );
+ }
+ else
+ {
+ if ( pPagePreviewLay->DoesPreviewLayoutRowsFitIntoWindow() )
+ {
+ nScrollAmount = pPagePreviewLay->GetWinPagesScrollAmount( 1 );
+ if ( (pViewWin->SelectedPage() + nVisPages) <= mnPageCount )
+ nNewSelectedPageNum = pViewWin->SelectedPage() + nVisPages;
+ else
+ nNewSelectedPageNum = mnPageCount;
+ }
+ else
+ nScrollAmount = std::min( pViewWin->GetOutputSize().Height(),
+ ( pPagePreviewLay->GetPreviewDocSize().Height() -
+ pViewWin->GetPaintedPreviewDocRect().Bottom() ) );
+ }
+ pViewWin->Scroll( 0, nScrollAmount );
+ if ( nNewSelectedPageNum != 0 )
+ {
+ pViewWin->SetSelectedPage( nNewSelectedPageNum );
+ }
+ ScrollViewSzChg();
+ // additional invalidate page status.
+ static sal_uInt16 aInval[] =
+ {
+ FN_START_OF_DOCUMENT, FN_END_OF_DOCUMENT, FN_PAGEUP, FN_PAGEDOWN,
+ FN_STAT_PAGE, 0
+ };
+ SfxBindings& rBindings = GetViewFrame()->GetBindings();
+ rBindings.Invalidate( aInval );
+ pViewWin->Invalidate();
+ }
+ }
+
+ if ( _pReq )
+ _pReq->Done();
+}
+
+// Then all for the SwPagePreview
+void SwPagePreview::Execute( SfxRequest &rReq )
+{
+ int eMvMode;
+ sal_uInt8 nRow = 1;
+ bool bRetVal = false;
+ bool bRefresh = true;
+
+ switch(rReq.GetSlot())
+ {
+ case FN_REFRESH_VIEW:
+ case FN_STAT_PAGE:
+ case FN_STAT_ZOOM:
+ break;
+
+ case FN_SHOW_MULTIPLE_PAGES:
+ {
+ const SfxItemSet *pArgs = rReq.GetArgs();
+ if( pArgs && pArgs->Count() >= 2 )
+ {
+ sal_uInt8 nCols = (sal_uInt8)((SfxUInt16Item &)pArgs->Get(
+ SID_ATTR_TABLE_COLUMN)).GetValue();
+ sal_uInt8 nRows = (sal_uInt8)((SfxUInt16Item &)pArgs->Get(
+ SID_ATTR_TABLE_ROW)).GetValue();
+ pViewWin->CalcWish( nRows, nCols );
+
+ }
+ else
+ SwPreviewZoomDlg( *pViewWin ).Execute();
+
+ }
+ break;
+ case FN_SHOW_BOOKVIEW:
+ {
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ const SfxPoolItem* pItem;
+ bool bBookPreview = GetViewShell()->GetViewOptions()->IsPagePrevBookview();
+ if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( FN_SHOW_BOOKVIEW, false, &pItem ) )
+ {
+ bBookPreview = static_cast< const SfxBoolItem* >( pItem )->GetValue();
+ ( ( SwViewOption* ) GetViewShell()->GetViewOptions() )->SetPagePrevBookview( bBookPreview );
+ // cast is not gentleman like, but it's common use in writer and in this case
+ }
+ if ( pViewWin->SetBookPreviewMode( bBookPreview ) )
+ {
+ // book preview mode changed. Thus, adjust scrollbars and
+ // invalidate corresponding states.
+ ScrollViewSzChg();
+ static sal_uInt16 aInval[] =
+ {
+ FN_START_OF_DOCUMENT, FN_END_OF_DOCUMENT, FN_PAGEUP, FN_PAGEDOWN,
+ FN_STAT_PAGE, FN_SHOW_BOOKVIEW, 0
+ };
+ SfxBindings& rBindings = GetViewFrame()->GetBindings();
+ rBindings.Invalidate( aInval );
+ pViewWin->Invalidate();
+ }
+
+ }
+ break;
+ case FN_SHOW_TWO_PAGES:
+ pViewWin->CalcWish( nRow, 2 );
+ break;
+
+ case FN_PREVIEW_ZOOM:
+ case SID_ATTR_ZOOM:
+ {
+ const SfxItemSet *pArgs = rReq.GetArgs();
+ const SfxPoolItem* pItem;
+ boost::scoped_ptr<AbstractSvxZoomDialog> pDlg;
+ if(!pArgs)
+ {
+ SfxItemSet aCoreSet(GetPool(), SID_ATTR_ZOOM, SID_ATTR_ZOOM);
+ const SwViewOption* pVOpt = GetViewShell()->GetViewOptions();
+ SvxZoomItem aZoom( (SvxZoomType)pVOpt->GetZoomType(),
+ pVOpt->GetZoom() );
+ aZoom.SetValueSet(
+ SVX_ZOOM_ENABLE_50|
+ SVX_ZOOM_ENABLE_75|
+ SVX_ZOOM_ENABLE_100|
+ SVX_ZOOM_ENABLE_150|
+ SVX_ZOOM_ENABLE_200|
+ SVX_ZOOM_ENABLE_WHOLEPAGE);
+ aCoreSet.Put( aZoom );
+
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ if(pFact)
+ {
+ pDlg.reset(pFact->CreateSvxZoomDialog(&GetViewFrame()->GetWindow(), aCoreSet));
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ }
+
+ pDlg->SetLimits( MINZOOM, MAXZOOM );
+
+ if( pDlg->Execute() != RET_CANCEL )
+ pArgs = pDlg->GetOutputItemSet();
+ }
+ if( pArgs )
+ {
+ enum SvxZoomType eType = SVX_ZOOM_PERCENT;
+ sal_uInt16 nZoomFactor = USHRT_MAX;
+ if(SFX_ITEM_SET == pArgs->GetItemState(SID_ATTR_ZOOM, true, &pItem))
+ {
+ eType = ((const SvxZoomItem *)pItem)->GetType();
+ nZoomFactor = ((const SvxZoomItem *)pItem)->GetValue();
+ }
+ else if(SFX_ITEM_SET == pArgs->GetItemState(FN_PREVIEW_ZOOM, true, &pItem))
+ nZoomFactor = ((const SfxUInt16Item *)pItem)->GetValue();
+ if(USHRT_MAX != nZoomFactor)
+ SetZoom(eType, nZoomFactor);
+ }
+ }
+ break;
+ case SID_ATTR_ZOOMSLIDER :
+ {
+ const SfxItemSet *pArgs = rReq.GetArgs();
+ const SfxPoolItem* pItem;
+
+ if ( pArgs && SFX_ITEM_SET == pArgs->GetItemState(SID_ATTR_ZOOMSLIDER, true, &pItem ) )
+ {
+ const sal_uInt16 nCurrentZoom = ((const SvxZoomSliderItem *)pItem)->GetValue();
+ SetZoom( SVX_ZOOM_PERCENT, nCurrentZoom );
+ }
+ }
+ break;
+ case SID_ZOOM_IN:
+ case SID_ZOOM_OUT:
+ {
+ enum SvxZoomType eType = SVX_ZOOM_PERCENT;
+ const SwViewOption* pVOpt = GetViewShell()->GetViewOptions();
+ SetZoom(eType,
+ lcl_GetNextZoomStep(pVOpt->GetZoom(), SID_ZOOM_IN == rReq.GetSlot()));
+ }
+ break;
+ case FN_CHAR_LEFT:
+ case FN_CHAR_RIGHT:
+ case FN_LINE_UP:
+ case FN_LINE_DOWN:
+ {
+ SwPagePreviewLayout* pPagePreviewLay = GetViewShell()->PagePreviewLayout();
+ sal_uInt16 nNewSelectedPage;
+ sal_uInt16 nNewStartPage;
+ Point aNewStartPos;
+ sal_Int16 nHoriMove = 0;
+ sal_Int16 nVertMove = 0;
+ switch(rReq.GetSlot())
+ {
+ case FN_CHAR_LEFT: nHoriMove = -1; break;
+ case FN_CHAR_RIGHT: nHoriMove = 1; break;
+ case FN_LINE_UP: nVertMove = -1; break;
+ case FN_LINE_DOWN: nVertMove = 1; break;
+ }
+ pPagePreviewLay->CalcStartValuesForSelectedPageMove( nHoriMove, nVertMove,
+ nNewSelectedPage, nNewStartPage, aNewStartPos );
+ if ( pViewWin->SelectedPage() != nNewSelectedPage )
+ {
+ if ( pPagePreviewLay->IsPageVisible( nNewSelectedPage ) )
+ {
+ pPagePreviewLay->MarkNewSelectedPage( nNewSelectedPage );
+ // adjust position at vertical scrollbar.
+ SetVScrollbarThumbPos( nNewSelectedPage );
+ bRefresh = false;
+ }
+ else
+ {
+ pViewWin->SetSelectedPage( nNewSelectedPage );
+ pViewWin->SetSttPage( nNewStartPage );
+ bRefresh = ChgPage( SwPagePreviewWin::MV_SELPAGE, sal_True );
+ }
+ GetViewShell()->ShowPreviewSelection( nNewSelectedPage );
+ // invalidate page status.
+ static sal_uInt16 aInval[] =
+ {
+ FN_STAT_PAGE, 0
+ };
+ SfxBindings& rBindings = GetViewFrame()->GetBindings();
+ rBindings.Invalidate( aInval );
+ rReq.Done();
+ }
+ else
+ {
+ bRefresh = false;
+ }
+ break;
+ }
+ case FN_PAGEUP:
+ case FN_PAGEDOWN:
+ {
+ _ExecPgUpAndPgDown( rReq.GetSlot() == FN_PAGEUP, &rReq );
+ break;
+ }
+ case FN_START_OF_LINE:
+ case FN_START_OF_DOCUMENT:
+ pViewWin->SetSelectedPage( 1 );
+ eMvMode = SwPagePreviewWin::MV_DOC_STT; bRetVal = true; goto MOVEPAGE;
+ case FN_END_OF_LINE:
+ case FN_END_OF_DOCUMENT:
+ pViewWin->SetSelectedPage( mnPageCount );
+ eMvMode = SwPagePreviewWin::MV_DOC_END; bRetVal = true; goto MOVEPAGE;
+MOVEPAGE:
+ {
+ bool nRet = ChgPage( eMvMode, sal_True );
+ // return value fuer Basic
+ if(bRetVal)
+ rReq.SetReturnValue(SfxBoolItem(rReq.GetSlot(), !nRet));
+
+ bRefresh = nRet;
+ rReq.Done();
+ }
+ break;
+
+ case FN_PRINT_PAGEPREVIEW:
+ {
+ const SwPagePreviewPrtData* pPPVPD = pViewWin->GetViewShell()->GetDoc()->GetPreviewPrtData();
+ // The thing with the orientation
+ if(pPPVPD)
+ {
+ SfxPrinter* pPrinter = GetPrinter( sal_True );
+ if((pPrinter->GetOrientation() == ORIENTATION_LANDSCAPE)
+ != pPPVPD->GetLandscape())
+ pPrinter->SetOrientation(pPPVPD->GetLandscape() ? ORIENTATION_LANDSCAPE : ORIENTATION_PORTRAIT);
+ }
+ ::SetAppPrintOptions( pViewWin->GetViewShell(), sal_False );
+ bNormalPrint = sal_False;
+ sal_uInt16 nPrtSlot = SID_PRINTDOC;
+ rReq.SetSlot( nPrtSlot );
+ SfxViewShell::ExecuteSlot( rReq, SfxViewShell::GetInterface() );
+ rReq.SetSlot( FN_PRINT_PAGEPREVIEW );
+ return;
+ }
+ case SID_PRINTDOCDIRECT:
+ case SID_PRINTDOC:
+ ::SetAppPrintOptions( pViewWin->GetViewShell(), sal_False );
+ bNormalPrint = sal_True;
+ SfxViewShell::ExecuteSlot( rReq, SfxViewShell::GetInterface() );
+ return;
+ case FN_CLOSE_PAGEPREVIEW:
+ case SID_PRINTPREVIEW:
+ // 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, 0, 0, SFX_CALLMODE_ASYNCHRON );
+ break;
+ case FN_INSERT_BREAK:
+ {
+ sal_uInt16 nSelPage = pViewWin->SelectedPage();
+ //if a dummy page is selected (e.g. a non-existing right/left page)
+ //the direct neighbor is used
+ if(GetViewShell()->IsDummyPage( nSelPage ) && GetViewShell()->IsDummyPage( --nSelPage ))
+ nSelPage +=2;
+ SetNewPage( nSelPage );
+ SfxViewFrame *pTmpFrm = GetViewFrame();
+ pTmpFrm->GetBindings().Execute( SID_VIEWSHELL0, NULL, 0,
+ SFX_CALLMODE_ASYNCHRON );
+ }
+ break;
+ default:
+ OSL_ENSURE(!this, "wrong dispatcher");
+ return;
+ }
+
+ if( bRefresh )
+ pViewWin->Invalidate();
+}
+
+void SwPagePreview::GetState( SfxItemSet& rSet )
+{
+ SfxWhichIter aIter(rSet);
+ sal_uInt8 nRow = 1;
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ OSL_ENSURE(nWhich, "empty set");
+ SwPagePreviewLayout* pPagePreviewLay = GetViewShell()->PagePreviewLayout();
+
+ while(nWhich)
+ {
+ switch(nWhich)
+ {
+ case SID_BROWSER_MODE:
+ case FN_PRINT_LAYOUT:
+ rSet.DisableItem(nWhich);
+ break;
+ case FN_START_OF_DOCUMENT:
+ {
+ if ( pPagePreviewLay->IsPageVisible( 1 ) )
+ rSet.DisableItem(nWhich);
+ break;
+ }
+ case FN_END_OF_DOCUMENT:
+ {
+ if ( pPagePreviewLay->IsPageVisible( mnPageCount ) )
+ rSet.DisableItem(nWhich);
+ break;
+ }
+ case FN_PAGEUP:
+ {
+ if( pPagePreviewLay->GetWinPagesScrollAmount( -1 ) == 0 )
+ rSet.DisableItem(nWhich);
+ break;
+ }
+ case FN_PAGEDOWN:
+ {
+ if( pPagePreviewLay->GetWinPagesScrollAmount( 1 ) == 0 )
+ rSet.DisableItem(nWhich);
+ break;
+ }
+
+ case FN_STAT_PAGE:
+ {
+ OUString aStr = sPageStr + pViewWin->GetStatusStr( mnPageCount );
+ rSet.Put( SfxStringItem( nWhich, aStr) );
+ }
+ break;
+
+ case SID_ATTR_ZOOM:
+ case FN_STAT_ZOOM:
+ {
+ const SwViewOption* pVOpt = GetViewShell()->GetViewOptions();
+ SvxZoomItem aZoom((SvxZoomType)pVOpt->GetZoomType(),
+ pVOpt->GetZoom());
+ aZoom.SetValueSet(
+ SVX_ZOOM_ENABLE_50|
+ SVX_ZOOM_ENABLE_75|
+ SVX_ZOOM_ENABLE_100|
+ SVX_ZOOM_ENABLE_150|
+ SVX_ZOOM_ENABLE_200);
+ rSet.Put( aZoom );
+ }
+ break;
+ case SID_ATTR_ZOOMSLIDER :
+ {
+ const SwViewOption* pVOpt = GetViewShell()->GetViewOptions();
+ const sal_uInt16 nCurrentZoom = pVOpt->GetZoom();
+ SvxZoomSliderItem aZoomSliderItem( nCurrentZoom, MINZOOM, MAXZOOM );
+ aZoomSliderItem.AddSnappingPoint( 100 );
+ rSet.Put( aZoomSliderItem );
+ }
+ break;
+ case FN_PREVIEW_ZOOM:
+ {
+ const SwViewOption* pVOpt = GetViewShell()->GetViewOptions();
+ rSet.Put(SfxUInt16Item(nWhich, pVOpt->GetZoom()));
+ }
+ break;
+ case SID_ZOOM_IN:
+ case SID_ZOOM_OUT:
+ {
+ const SwViewOption* pVOpt = GetViewShell()->GetViewOptions();
+ if((SID_ZOOM_OUT == nWhich && pVOpt->GetZoom() >= MAX_PREVIEW_ZOOM)||
+ (SID_ZOOM_IN == nWhich && pVOpt->GetZoom() <= MIN_PREVIEW_ZOOM))
+ {
+ rSet.DisableItem(nWhich);
+ }
+ }
+ break;
+ case FN_SHOW_MULTIPLE_PAGES:
+ // should never be disabled
+ break;
+ case FN_SHOW_BOOKVIEW:
+ {
+ sal_Bool b = GetViewShell()->GetViewOptions()->IsPagePrevBookview();
+ rSet.Put(SfxBoolItem(nWhich, b));
+ }
+ break;
+
+ case FN_SHOW_TWO_PAGES:
+ if( 2 == pViewWin->GetCol() && nRow == pViewWin->GetRow() )
+ rSet.DisableItem( nWhich );
+ break;
+
+ case FN_PRINT_PAGEPREVIEW:
+ // has the same status like the normal printing
+ {
+ const SfxPoolItem* pItem;
+ SfxItemSet aSet( *rSet.GetPool(), SID_PRINTDOC, SID_PRINTDOC );
+ GetSlotState( SID_PRINTDOC, SfxViewShell::GetInterface(), &aSet );
+ if( SFX_ITEM_DISABLED == aSet.GetItemState( SID_PRINTDOC,
+ false, &pItem ))
+ rSet.DisableItem( nWhich );
+ else if( SFX_ITEM_SET == aSet.GetItemState( SID_PRINTDOC,
+ false, &pItem ))
+ {
+ ((SfxPoolItem*)pItem)->SetWhich( FN_PRINT_PAGEPREVIEW );
+ rSet.Put( *pItem );
+ }
+ }
+ break;
+
+ case SID_PRINTPREVIEW:
+ rSet.Put( SfxBoolItem( nWhich, true ) );
+ break;
+
+ case SID_PRINTDOC:
+ case SID_PRINTDOCDIRECT:
+ GetSlotState( nWhich, SfxViewShell::GetInterface(), &rSet );
+ break;
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+void SwPagePreview::StateUndo(SfxItemSet& rSet)
+{
+ SfxWhichIter aIter(rSet);
+ sal_uInt16 nWhich = aIter.FirstWhich();
+
+ while (nWhich)
+ {
+ rSet.DisableItem(nWhich);
+ nWhich = aIter.NextWhich();
+ }
+}
+
+void SwPagePreview::Init(const SwViewOption * pPrefs)
+{
+ if ( GetViewShell()->HasDrawView() )
+ GetViewShell()->GetDrawView()->SetAnimationEnabled( sal_False );
+
+ bNormalPrint = sal_True;
+
+ // Check and process the DocSize. The shell could not be found via
+ // the handler, because the shell is unknown to the SFX management
+ // within the CTOR phase.
+
+ if( !pPrefs )
+ pPrefs = SW_MOD()->GetUsrPref(sal_False);
+
+ mbHScrollbarEnabled = pPrefs->IsViewHScrollBar();
+ mbVScrollbarEnabled = pPrefs->IsViewVScrollBar();
+
+ // Update the fields
+ // ATTENTION: Do cast the EditShell up, to use the SS.
+ // At the methodes the current shell will be queried!
+ SwEditShell* pESh = (SwEditShell*)GetViewShell();
+ sal_Bool bIsModified = pESh->IsModified();
+
+ SwViewOption aOpt( *pPrefs );
+ aOpt.SetPagePreview(sal_True);
+ aOpt.SetTab( sal_False );
+ aOpt.SetBlank( sal_False );
+ aOpt.SetHardBlank( sal_False );
+ aOpt.SetParagraph( sal_False );
+ aOpt.SetLineBreak( sal_False );
+ aOpt.SetPageBreak( sal_False );
+ aOpt.SetColumnBreak( sal_False );
+ aOpt.SetSoftHyph( sal_False );
+ aOpt.SetFldName( sal_False );
+ aOpt.SetPostIts( sal_False );
+ aOpt.SetShowHiddenChar( sal_False );
+ aOpt.SetShowHiddenField( sal_False );
+ aOpt.SetShowHiddenPara( sal_False );
+ aOpt.SetViewHRuler( sal_False );
+ aOpt.SetViewVRuler( sal_False );
+ aOpt.SetGraphic( sal_True );
+ aOpt.SetTable( sal_True );
+ aOpt.SetSnap( sal_False );
+ aOpt.SetGridVisible( sal_False );
+
+ GetViewShell()->ApplyViewOptions( aOpt );
+ GetViewShell()->ApplyAccessiblityOptions(SW_MOD()->GetAccessibilityOptions());
+
+ // adjust view shell option to the same as for print
+ SwPrintData const aPrintOptions = *SW_MOD()->GetPrtOptions(false);
+ GetViewShell()->AdjustOptionsForPagePreview( aPrintOptions );
+
+ GetViewShell()->CalcLayout();
+ DocSzChgd( GetViewShell()->GetDocSize() );
+
+ if( !bIsModified )
+ pESh->ResetModified();
+}
+
+SwPagePreview::SwPagePreview(SfxViewFrame *pViewFrame, SfxViewShell* pOldSh):
+ SfxViewShell( pViewFrame, SWVIEWFLAGS ),
+ pViewWin( new SwPagePreviewWin(&(GetViewFrame())->GetWindow(), *this ) ),
+ nNewPage(USHRT_MAX),
+ sPageStr(SW_RES(STR_PAGE)),
+ pHScrollbar(0),
+ pVScrollbar(0),
+ pScrollFill(new ScrollBarBox( &pViewFrame->GetWindow(),
+ pViewFrame->GetFrame().GetParentFrame() ? 0 : WB_SIZEABLE )),
+ mnPageCount( 0 ),
+ mbResetFormDesignMode( false ),
+ mbFormDesignModeToReset( false )
+{
+ SetName(OUString("PageView" ));
+ SetWindow( pViewWin );
+ SetHelpId(SW_PAGEPREVIEW);
+ _CreateScrollbar( sal_True );
+ _CreateScrollbar( sal_False );
+
+ SfxObjectShell* pObjShell = pViewFrame->GetObjectShell();
+ if ( !pOldSh )
+ {
+ // Exists already a view on the document?
+ SfxViewFrame *pF = SfxViewFrame::GetFirst( pObjShell );
+ if ( pF == pViewFrame )
+ pF = SfxViewFrame::GetNext( *pF, pObjShell );
+ if ( pF )
+ pOldSh = pF->GetViewShell();
+ }
+
+ SwViewShell *pVS, *pNew;
+
+ if( pOldSh && pOldSh->IsA( TYPE( SwPagePreview ) ) )
+ pVS = ((SwPagePreview*)pOldSh)->GetViewShell();
+ else
+ {
+ if( pOldSh && pOldSh->IsA( TYPE( SwView ) ) )
+ {
+ pVS = ((SwView*)pOldSh)->GetWrtShellPtr();
+ // save the current ViewData of the previous SwView
+ pOldSh->WriteUserData( sSwViewData, false );
+ }
+ else
+ pVS = GetDocShell()->GetWrtShell();
+ if( pVS )
+ {
+ // Set the current page as the first.
+ sal_uInt16 nPhysPg, nVirtPg;
+ ((SwCrsrShell*)pVS)->GetPageNum( nPhysPg, nVirtPg, sal_True, sal_False );
+ if( 1 != pViewWin->GetCol() && 1 == nPhysPg )
+ --nPhysPg;
+ pViewWin->SetSttPage( nPhysPg );
+ }
+ }
+
+ // for form shell remember design mode of draw view
+ // of previous view shell
+ if ( pVS && pVS->HasDrawView() )
+ {
+ mbResetFormDesignMode = true;
+ mbFormDesignModeToReset = pVS->GetDrawView()->IsDesignMode();
+ }
+
+ if( pVS )
+ pNew = new SwViewShell( *pVS, pViewWin, 0, VSHELLFLAG_ISPREVIEW );
+ else
+ pNew = new SwViewShell(
+ *((SwDocShell*)pViewFrame->GetObjectShell())->GetDoc(),
+ pViewWin, 0, 0, VSHELLFLAG_ISPREVIEW );
+
+ pViewWin->SetViewShell( pNew );
+ pNew->SetSfxViewShell( this );
+ Init();
+}
+
+SwPagePreview::~SwPagePreview()
+{
+ SetWindow( 0 );
+ SwViewShell* pVShell = pViewWin->GetViewShell();
+ pVShell->SetWin(0);
+ delete pVShell;
+ delete pViewWin;
+
+ delete pScrollFill;
+ delete pHScrollbar;
+ delete pVScrollbar;
+}
+
+SwDocShell* SwPagePreview::GetDocShell()
+{
+ return PTR_CAST(SwDocShell, GetViewFrame()->GetObjectShell());
+}
+
+int SwPagePreview::_CreateScrollbar( sal_Bool bHori )
+{
+ Window *pMDI = &GetViewFrame()->GetWindow();
+ SwScrollbar** ppScrollbar = bHori ? &pHScrollbar : &pVScrollbar;
+
+ OSL_ENSURE( !*ppScrollbar, "check beforehand!" );
+
+ *ppScrollbar = new SwScrollbar( pMDI, bHori );
+
+ ScrollDocSzChg();
+ (*ppScrollbar)->EnableDrag( true );
+ (*ppScrollbar)->SetEndScrollHdl( LINK( this, SwPagePreview, EndScrollHdl ));
+
+ (*ppScrollbar)->SetScrollHdl( LINK( this, SwPagePreview, ScrollHdl ));
+
+ InvalidateBorder();
+ (*ppScrollbar)->ExtendedShow();
+ return 1;
+}
+
+bool SwPagePreview::ChgPage( int eMvMode, int bUpdateScrollbar )
+{
+ Rectangle aPixVisArea( pViewWin->LogicToPixel( aVisArea ) );
+ bool bChg = pViewWin->MovePage( eMvMode ) ||
+ eMvMode == SwPagePreviewWin::MV_CALC ||
+ eMvMode == SwPagePreviewWin::MV_NEWWINSIZE;
+ aVisArea = pViewWin->PixelToLogic( aPixVisArea );
+
+ if( bChg )
+ {
+ // Update statusbar
+ OUString aStr = sPageStr + pViewWin->GetStatusStr( mnPageCount );
+ SfxBindings& rBindings = GetViewFrame()->GetBindings();
+
+ if( bUpdateScrollbar )
+ {
+ ScrollViewSzChg();
+
+ static sal_uInt16 aInval[] =
+ {
+ FN_START_OF_DOCUMENT, FN_END_OF_DOCUMENT,
+ FN_PAGEUP, FN_PAGEDOWN, 0
+ };
+ rBindings.Invalidate( aInval );
+ }
+ rBindings.SetState( SfxStringItem( FN_STAT_PAGE, aStr ) );
+ }
+ return bChg;
+}
+
+// From here, everything was taken from the SwView.
+void SwPagePreview::CalcAndSetBorderPixel( SvBorder &rToFill, sal_Bool /*bInner*/ )
+{
+ const StyleSettings &rSet = pViewWin->GetSettings().GetStyleSettings();
+ const long nTmp = rSet.GetScrollBarSize();
+ if ( pVScrollbar->IsVisible( true ) )
+ rToFill.Right() = nTmp;
+ if ( pHScrollbar->IsVisible( true ) )
+ rToFill.Bottom() = nTmp;
+ SetBorderPixel( rToFill );
+}
+
+void SwPagePreview::InnerResizePixel( const Point &rOfst, const Size &rSize )
+{
+ SvBorder aBorder;
+ CalcAndSetBorderPixel( aBorder, sal_True );
+ Rectangle aRect( rOfst, rSize );
+ aRect += aBorder;
+ ViewResizePixel( *pViewWin, aRect.TopLeft(), aRect.GetSize(),
+ pViewWin->GetOutputSizePixel(),
+ *pVScrollbar, *pHScrollbar, *pScrollFill );
+
+ // Never set EditWin !
+ // Never set VisArea !
+}
+
+void SwPagePreview::OuterResizePixel( const Point &rOfst, const Size &rSize )
+{
+ SvBorder aBorder;
+ CalcAndSetBorderPixel( aBorder, sal_False );
+
+ // Never set EditWin !
+
+ Size aTmpSize( pViewWin->GetOutputSizePixel() );
+ Point aBottomRight( pViewWin->PixelToLogic( Point( aTmpSize.Width(), aTmpSize.Height() ) ) );
+ SetVisArea( Rectangle( Point(), aBottomRight ) );
+
+ // Call of the DocSzChgd-Methode of the scrollbars is necessary,
+ // because from the maximum scoll range half the height of the
+ // VisArea is always deducted.
+ if ( pVScrollbar && aTmpSize.Width() > 0 && aTmpSize.Height() > 0 )
+ {
+ ScrollDocSzChg();
+ }
+
+ SvBorder aBorderNew;
+ CalcAndSetBorderPixel( aBorderNew, sal_False );
+ ViewResizePixel( *pViewWin, rOfst, rSize, pViewWin->GetOutputSizePixel(),
+ *pVScrollbar, *pHScrollbar, *pScrollFill );
+}
+
+void SwPagePreview::SetVisArea( const Rectangle &rRect, sal_Bool bUpdateScrollbar )
+{
+ const Point aTopLeft(AlignToPixel(rRect.TopLeft()));
+ const Point aBottomRight(AlignToPixel(rRect.BottomRight()));
+ Rectangle aLR(aTopLeft,aBottomRight);
+
+ if(aLR == aVisArea)
+ return;
+ // No negative position, no negative size
+
+ if(aLR.Top() < 0)
+ {
+ aLR.Bottom() += std::abs(aLR.Top());
+ aLR.Top() = 0;
+ }
+
+ if(aLR.Left() < 0)
+ {
+ aLR.Right() += std::abs(aLR.Left());
+ aLR.Left() = 0;
+ }
+ if(aLR.Right() < 0) aLR.Right() = 0;
+ if(aLR.Bottom() < 0) aLR.Bottom() = 0;
+ if(aLR == aVisArea ||
+ // Ignore empty rectangle
+ ( 0 == aLR.Bottom() - aLR.Top() && 0 == aLR.Right() - aLR.Left() ) )
+ return;
+
+ if( aLR.Left() > aLR.Right() || aLR.Top() > aLR.Bottom() )
+ return;
+
+ // Before the data can be changed call an update if necessary.
+ // Thereby ensured, that adjacent paints are correctly converted into
+ // document coordinates.
+ // As a precaution, we do this only when at the shell runs an action,
+ // because then we do not really paint but the rectangles are just
+ // bookmarked (in document coordinates).
+ if( GetViewShell()->ActionPend() )
+ pViewWin->Update();
+
+ // Set at View-Win the current size
+ aVisArea = aLR;
+ pViewWin->SetWinSize( aLR.GetSize() );
+ ChgPage( SwPagePreviewWin::MV_NEWWINSIZE, bUpdateScrollbar );
+
+ pViewWin->Invalidate();
+}
+
+IMPL_LINK( SwPagePreview, ScrollHdl, SwScrollbar *, pScrollbar )
+{
+ if(!GetViewShell())
+ return 0;
+ if( !pScrollbar->IsHoriScroll() &&
+ pScrollbar->GetType() == SCROLL_DRAG &&
+ Help::IsQuickHelpEnabled() &&
+ GetViewShell()->PagePreviewLayout()->DoesPreviewLayoutRowsFitIntoWindow())
+ {
+ // Scroll how many pages??
+ OUString sStateStr(sPageStr);
+ sal_uInt16 nThmbPos = (sal_uInt16)pScrollbar->GetThumbPos();
+ if( 1 == pViewWin->GetCol() || !nThmbPos )
+ ++nThmbPos;
+ sStateStr += OUString::number( nThmbPos );
+ Point aPos = pScrollbar->GetParent()->OutputToScreenPixel(
+ pScrollbar->GetPosPixel());
+ aPos.Y() = pScrollbar->OutputToScreenPixel(pScrollbar->GetPointerPosPixel()).Y();
+ Rectangle aRect;
+ aRect.Left() = aPos.X() -8;
+ aRect.Right() = aRect.Left();
+ aRect.Top() = aPos.Y();
+ aRect.Bottom() = aRect.Top();
+
+ Help::ShowQuickHelp(pScrollbar, aRect, sStateStr,
+ QUICKHELP_RIGHT|QUICKHELP_VCENTER);
+
+ }
+ else
+ EndScrollHdl( pScrollbar );
+ return 0;
+}
+
+IMPL_LINK( SwPagePreview, EndScrollHdl, SwScrollbar *, pScrollbar )
+{
+ if(!GetViewShell())
+ return 0;
+
+ // boolean to avoid unnecessary invalidation of the window.
+ bool bInvalidateWin = true;
+
+ if( !pScrollbar->IsHoriScroll() ) // scroll vertically
+ {
+ if ( Help::IsQuickHelpEnabled() )
+ Help::ShowQuickHelp(pScrollbar, Rectangle(), OUString(), 0);
+ if ( GetViewShell()->PagePreviewLayout()->DoesPreviewLayoutRowsFitIntoWindow() )
+ {
+ // Scroll how many pages ??
+ sal_uInt16 nThmbPos = (sal_uInt16)pScrollbar->GetThumbPos();
+ // adjust to new preview functionality
+ if( nThmbPos != pViewWin->SelectedPage() )
+ {
+ // consider case that page <nThmbPos>
+ // is already visible
+ SwPagePreviewLayout* pPagePreviewLay = GetViewShell()->PagePreviewLayout();
+ if ( pPagePreviewLay->IsPageVisible( nThmbPos ) )
+ {
+ pPagePreviewLay->MarkNewSelectedPage( nThmbPos );
+ // invalidation of window is unnecessary
+ bInvalidateWin = false;
+ }
+ else
+ {
+ // consider whether layout columns
+ // fit or not.
+ if ( !pPagePreviewLay->DoesPreviewLayoutColsFitIntoWindow() )
+ {
+ pViewWin->SetSttPage( nThmbPos );
+ pViewWin->SetSelectedPage( nThmbPos );
+ ChgPage( SwPagePreviewWin::MV_SCROLL, sal_False );
+ // update scrollbars
+ ScrollViewSzChg();
+ }
+ else
+ {
+ // correct scroll amount
+ const sal_Int16 nPageDiff = nThmbPos - pViewWin->SelectedPage();
+ const sal_uInt16 nVisPages = pViewWin->GetRow() * pViewWin->GetCol();
+ sal_Int16 nWinPagesToScroll = nPageDiff / nVisPages;
+ if ( nPageDiff % nVisPages )
+ {
+ // decrease/increase number of preview pages to scroll
+ nPageDiff < 0 ? --nWinPagesToScroll : ++nWinPagesToScroll;
+ }
+ pViewWin->SetSelectedPage( nThmbPos );
+ pViewWin->Scroll( 0, pPagePreviewLay->GetWinPagesScrollAmount( nWinPagesToScroll ) );
+ }
+ }
+ // update accessibility
+ GetViewShell()->ShowPreviewSelection( nThmbPos );
+ }
+ else
+ {
+ // invalidation of window is unnecessary
+ bInvalidateWin = false;
+ }
+ }
+ else
+ {
+ long nThmbPos = pScrollbar->GetThumbPos();
+ pViewWin->Scroll(0, nThmbPos - pViewWin->GetPaintedPreviewDocRect().Top());
+ }
+ }
+ else
+ {
+ long nThmbPos = pScrollbar->GetThumbPos();
+ pViewWin->Scroll(nThmbPos - pViewWin->GetPaintedPreviewDocRect().Left(), 0);
+ }
+ // additional invalidate page status.
+ static sal_uInt16 aInval[] =
+ {
+ FN_START_OF_DOCUMENT, FN_END_OF_DOCUMENT, FN_PAGEUP, FN_PAGEDOWN,
+ FN_STAT_PAGE, 0
+ };
+ SfxBindings& rBindings = GetViewFrame()->GetBindings();
+ rBindings.Invalidate( aInval );
+ // control invalidation of window
+ if ( bInvalidateWin )
+ {
+ pViewWin->Invalidate();
+ }
+ return 0;
+}
+
+Point SwPagePreview::AlignToPixel(const Point &rPt) const
+{
+ return pViewWin->PixelToLogic( pViewWin->LogicToPixel( rPt ) );
+}
+
+void SwPagePreview::DocSzChgd( const Size &rSz )
+{
+ if( aDocSz == rSz )
+ return;
+
+ aDocSz = rSz;
+
+ // #i96726#
+ // Due to the multiple page layout it is needed to trigger recalculation
+ // of the page preview layout, even if the count of pages is not changing.
+ mnPageCount = GetViewShell()->GetNumPages();
+
+ if( aVisArea.GetWidth() )
+ {
+ ChgPage( SwPagePreviewWin::MV_CALC, sal_True );
+ ScrollDocSzChg();
+
+ pViewWin->Invalidate();
+ }
+}
+
+void SwPagePreview::ScrollViewSzChg()
+{
+ if(!GetViewShell())
+ return ;
+
+ bool bShowVScrollbar = false, bShowHScrollbar = false;
+
+ if(pVScrollbar)
+ {
+ if(GetViewShell()->PagePreviewLayout()->DoesPreviewLayoutRowsFitIntoWindow())
+ {
+ //vertical scrolling by row
+ // adjust to new preview functionality
+ sal_uInt16 nVisPages = pViewWin->GetRow() * pViewWin->GetCol();
+
+ pVScrollbar->SetVisibleSize( nVisPages );
+ // set selected page as scroll bar position,
+ // if it is visible.
+ SwPagePreviewLayout* pPagePreviewLay = GetViewShell()->PagePreviewLayout();
+ if ( pPagePreviewLay->IsPageVisible( pViewWin->SelectedPage() ) )
+ {
+ pVScrollbar->SetThumbPos( pViewWin->SelectedPage() );
+ }
+ else
+ {
+ pVScrollbar->SetThumbPos( pViewWin->GetSttPage() );
+ }
+ pVScrollbar->SetLineSize( pViewWin->GetCol() );
+ pVScrollbar->SetPageSize( nVisPages );
+ // calculate and set scrollbar range
+ Range aScrollbarRange( 1, mnPageCount );
+ // increase range by one, because left-top-corner is left blank.
+ ++aScrollbarRange.Max();
+ // increase range in order to access all pages
+ aScrollbarRange.Max() += ( nVisPages - 1 );
+ pVScrollbar->SetRange( aScrollbarRange );
+
+ bShowVScrollbar = nVisPages < mnPageCount;
+ }
+ else //vertical scrolling by pixel
+ {
+ const Rectangle& rDocRect = pViewWin->GetPaintedPreviewDocRect();
+ const Size& rPreviewSize =
+ GetViewShell()->PagePreviewLayout()->GetPreviewDocSize();
+ pVScrollbar->SetRangeMax(rPreviewSize.Height()) ;
+ long nVisHeight = rDocRect.GetHeight();
+ pVScrollbar->SetVisibleSize( nVisHeight );
+ pVScrollbar->SetThumbPos( rDocRect.Top() );
+ pVScrollbar->SetLineSize( nVisHeight / 10 );
+ pVScrollbar->SetPageSize( nVisHeight / 2 );
+
+ bShowVScrollbar = true;
+ }
+
+ if (!mbVScrollbarEnabled)
+ bShowVScrollbar = false;
+
+ ShowVScrollbar(bShowVScrollbar);
+ }
+ if(pHScrollbar)
+ {
+ const Rectangle& rDocRect = pViewWin->GetPaintedPreviewDocRect();
+ const Size& rPreviewSize =
+ GetViewShell()->PagePreviewLayout()->GetPreviewDocSize();
+ long nVisWidth = 0;
+ long nThumb = 0;
+ Range aRange(0,0);
+
+ if(rDocRect.GetWidth() < rPreviewSize.Width())
+ {
+ bShowHScrollbar = true;
+
+ nVisWidth = rDocRect.GetWidth();
+ nThumb = rDocRect.Left();
+ aRange = Range(0, rPreviewSize.Width());
+
+ pHScrollbar->SetRange( aRange );
+ pHScrollbar->SetVisibleSize( nVisWidth );
+ pHScrollbar->SetThumbPos( nThumb );
+ pHScrollbar->SetLineSize( nVisWidth / 10 );
+ pHScrollbar->SetPageSize( nVisWidth / 2 );
+ }
+
+ if (!mbHScrollbarEnabled)
+ bShowHScrollbar = false;
+
+ ShowHScrollbar(bShowHScrollbar);
+ }
+ pScrollFill->Show(bShowVScrollbar && bShowHScrollbar);
+}
+
+void SwPagePreview::ScrollDocSzChg()
+{
+ ScrollViewSzChg();
+}
+
+// All about printing
+SfxPrinter* SwPagePreview::GetPrinter( sal_Bool bCreate )
+{
+ return pViewWin->GetViewShell()->getIDocumentDeviceAccess()->getPrinter( bCreate );
+}
+
+sal_uInt16 SwPagePreview::SetPrinter( SfxPrinter *pNew, sal_uInt16 nDiffFlags, bool )
+{
+ SwViewShell &rSh = *GetViewShell();
+ SfxPrinter* pOld = rSh.getIDocumentDeviceAccess()->getPrinter( false );
+ if ( pOld && pOld->IsPrinting() )
+ return SFX_PRINTERROR_BUSY;
+
+ SwEditShell &rESh = (SwEditShell&)rSh; //Buh...
+ if( ( SFX_PRINTER_PRINTER | SFX_PRINTER_JOBSETUP ) & nDiffFlags )
+ {
+ rSh.getIDocumentDeviceAccess()->setPrinter( pNew, true, true );
+ if( nDiffFlags & SFX_PRINTER_PRINTER )
+ rESh.SetModified();
+ }
+ if ( ( nDiffFlags & SFX_PRINTER_OPTIONS ) == SFX_PRINTER_OPTIONS )
+ ::SetPrinter( rSh.getIDocumentDeviceAccess(), pNew, sal_False );
+
+ const bool bChgOri = nDiffFlags & SFX_PRINTER_CHG_ORIENTATION;
+ const bool bChgSize= nDiffFlags & SFX_PRINTER_CHG_SIZE;
+ if ( bChgOri || bChgSize )
+ {
+ rESh.StartAllAction();
+ if ( bChgOri )
+ rSh.ChgAllPageOrientation( sal_uInt16(pNew->GetOrientation()) );
+ if ( bChgSize )
+ {
+ Size aSz( SvxPaperInfo::GetPaperSize( pNew ) );
+ rSh.ChgAllPageSize( aSz );
+ }
+ if( !bNormalPrint )
+ pViewWin->CalcWish( pViewWin->GetRow(), pViewWin->GetCol() );
+ rESh.SetModified();
+ rESh.EndAllAction();
+
+ static sal_uInt16 aInval[] =
+ {
+ SID_ATTR_LONG_ULSPACE, SID_ATTR_LONG_LRSPACE,
+ SID_RULER_BORDERS, SID_RULER_PAGE_POS, 0
+ };
+#if OSL_DEBUG_LEVEL > 0
+ {
+ const sal_uInt16* pPtr = aInval + 1;
+ do {
+ OSL_ENSURE( *(pPtr - 1) < *pPtr, "wrong sorting!" );
+ } while( *++pPtr );
+ }
+#endif
+
+ GetViewFrame()->GetBindings().Invalidate(aInval);
+ }
+
+ return 0;
+}
+
+bool SwPagePreview::HasPrintOptionsPage() const
+{
+ return true;
+}
+
+SfxTabPage* SwPagePreview::CreatePrintOptionsPage( Window *pParent,
+ const SfxItemSet &rOptions )
+{
+ return ::CreatePrintOptionsPage( pParent, rOptions, !bNormalPrint );
+}
+
+void SwPagePreviewWin::SetViewShell( SwViewShell* pShell )
+{
+ mpViewShell = pShell;
+ if ( mpViewShell && mpViewShell->IsPreview() )
+ {
+ mpPgPreviewLayout = mpViewShell->PagePreviewLayout();
+ }
+}
+
+void SwPagePreviewWin::RepaintCoreRect( const SwRect& rRect )
+{
+ // #i24183#
+ if ( mpPgPreviewLayout->PreviewLayoutValid() )
+ {
+ mpPgPreviewLayout->Repaint( Rectangle( rRect.Pos(), rRect.SSize() ) );
+ }
+}
+
+/** method to adjust preview to a new zoom factor
+
+ #i19975# also consider zoom type - adding parameter <_eZoomType>
+*/
+void SwPagePreviewWin::AdjustPreviewToNewZoom( const sal_uInt16 _nZoomFactor,
+ const SvxZoomType _eZoomType )
+{
+ // #i19975# consider zoom type
+ if ( _eZoomType == SVX_ZOOM_WHOLEPAGE )
+ {
+ mnRow = 1;
+ mnCol = 1;
+ mpPgPreviewLayout->Init( mnCol, mnRow, maPxWinSize, true );
+ mpPgPreviewLayout->Prepare( mnSttPage, Point(0,0), maPxWinSize,
+ mnSttPage, maPaintedPreviewDocRect );
+ SetSelectedPage( mnSttPage );
+ SetPagePreview(mnRow, mnCol);
+ maScale = GetMapMode().GetScaleX();
+ }
+ else if ( _nZoomFactor != 0 )
+ {
+ // calculate new scaling and set mapping mode appropriately.
+ Fraction aNewScale( _nZoomFactor, 100 );
+ MapMode aNewMapMode = GetMapMode();
+ aNewMapMode.SetScaleX( aNewScale );
+ aNewMapMode.SetScaleY( aNewScale );
+ SetMapMode( aNewMapMode );
+
+ // calculate new start position for preview paint
+ Size aNewWinSize = PixelToLogic( maPxWinSize );
+ Point aNewPaintStartPos =
+ mpPgPreviewLayout->GetPreviewStartPosForNewScale( aNewScale, maScale, aNewWinSize );
+
+ // remember new scaling and prepare preview paint
+ // Note: paint of preview will be performed by a corresponding invalidate
+ // due to property changes.
+ maScale = aNewScale;
+ mpPgPreviewLayout->Prepare( 0, aNewPaintStartPos, maPxWinSize,
+ mnSttPage, maPaintedPreviewDocRect );
+ }
+
+}
+
+/**
+ * pixel scrolling - horizontally always or vertically
+ * when less than the desired number of rows fits into
+ * the view
+ */
+void SwPagePreviewWin::Scroll(long nXMove, long nYMove, sal_uInt16 /*nFlags*/)
+{
+ maPaintedPreviewDocRect.Move(nXMove, nYMove);
+ mpPgPreviewLayout->Prepare( 0, maPaintedPreviewDocRect.TopLeft(),
+ maPxWinSize, mnSttPage,
+ maPaintedPreviewDocRect );
+
+}
+
+sal_Bool SwPagePreview::HandleWheelCommands( const CommandEvent& rCEvt )
+{
+ sal_Bool bOk = sal_False;
+ const CommandWheelData* pWData = rCEvt.GetWheelData();
+ if( pWData && COMMAND_WHEEL_ZOOM == pWData->GetMode() )
+ {
+ //only the Preference shouldn't control the Zoom, it is better to detect AT tools running. So the bridge can be used here
+ if (!Application::GetSettings().GetMiscSettings().GetEnableATToolSupport())
+ {
+ sal_uInt16 nFactor = GetViewShell()->GetViewOptions()->GetZoom();
+ const sal_uInt16 nOffset = 10;
+ if( 0L > pWData->GetDelta() )
+ {
+ nFactor -= nOffset;
+ if(nFactor < MIN_PREVIEW_ZOOM)
+ nFactor = MIN_PREVIEW_ZOOM;
+ }
+ else
+ {
+ nFactor += nOffset;
+ if(nFactor > MAX_PREVIEW_ZOOM)
+ nFactor = MAX_PREVIEW_ZOOM;
+ }
+ SetZoom(SVX_ZOOM_PERCENT, nFactor);
+ }
+ bOk = sal_True;
+ }
+ else
+ bOk = pViewWin->HandleScrollCommand( rCEvt, pHScrollbar, pVScrollbar );
+ return bOk;
+}
+
+uno::Reference< ::com::sun::star::accessibility::XAccessible >
+ SwPagePreviewWin::CreateAccessible()
+{
+ SolarMutexGuard aGuard; // this should have happened already!!!
+
+ OSL_ENSURE( GetViewShell() != NULL, "We need a view shell" );
+ ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xAcc = GetAccessible( false );
+ if (xAcc.is())
+ {
+ return xAcc;
+ }
+ if (mpViewShell)
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xAccPreview = mpViewShell->CreateAccessiblePreview();
+ SetAccessible(xAccPreview);
+ }
+ return GetAccessible( false );
+}
+
+// MT: Removed Windows::SwitchView() introduced with IA2 CWS.
+// There are other notifications for this when the active view has chnaged, so please update the code to use that event mechanism
+void SwPagePreviewWin::SwitchView()
+{
+#ifdef ACCESSIBLE_LAYOUT
+ if (!Application::IsAccessibilityEnabled())
+ {
+ return ;
+ }
+ if (mpViewShell)
+ {
+ mpViewShell->InvalidateAccessibleFocus();
+ }
+#endif
+}
+
+void SwPagePreview::ApplyAccessiblityOptions(SvtAccessibilityOptions& rAccessibilityOptions)
+{
+ GetViewShell()->ApplyAccessiblityOptions(rAccessibilityOptions);
+}
+
+void SwPagePreview::ShowHScrollbar(sal_Bool bShow)
+{
+ pHScrollbar->Show(bShow);
+ InvalidateBorder();
+}
+
+void SwPagePreview::ShowVScrollbar(sal_Bool bShow)
+{
+ pVScrollbar->Show(bShow);
+ InvalidateBorder();
+}
+
+void SwPagePreview::EnableHScrollbar(bool bEnable)
+{
+ if (mbHScrollbarEnabled != bEnable)
+ {
+ mbHScrollbarEnabled = bEnable;
+ ScrollViewSzChg();
+ }
+}
+
+void SwPagePreview::EnableVScrollbar(bool bEnable)
+{
+ if (mbVScrollbarEnabled != bEnable)
+ {
+ mbVScrollbarEnabled = bEnable;
+ ScrollViewSzChg();
+ }
+}
+
+void SwPagePreview::SetZoom(SvxZoomType eType, sal_uInt16 nFactor)
+{
+ SwViewShell& rSh = *GetViewShell();
+ SwViewOption aOpt(*rSh.GetViewOptions());
+ // perform action only on changes of zoom or zoom type.
+ if ( aOpt.GetZoom() != nFactor ||
+ aOpt.GetZoomType() != eType )
+ {
+ aOpt.SetZoom(nFactor);
+ aOpt.SetZoomType(eType);
+ rSh.ApplyViewOptions( aOpt );
+ lcl_InvalidateZoomSlots(GetViewFrame()->GetBindings());
+ // #i19975# also consider zoom type
+ pViewWin->AdjustPreviewToNewZoom( nFactor, eType );
+ ScrollViewSzChg();
+ }
+}
+
+/** adjust position of vertical scrollbar
+
+ @author OD
+*/
+void SwPagePreview::SetVScrollbarThumbPos( const sal_uInt16 _nNewThumbPos )
+{
+ if ( pVScrollbar )
+ {
+ pVScrollbar->SetThumbPos( _nNewThumbPos );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/uiview/scroll.cxx b/sw/source/core/uibase/uiview/scroll.cxx
new file mode 100644
index 000000000000..92ba2e43060a
--- /dev/null
+++ b/sw/source/core/uibase/uiview/scroll.cxx
@@ -0,0 +1,121 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "swtypes.hxx"
+#include "swrect.hxx"
+#include "scroll.hxx"
+
+#define SCROLL_LINE_SIZE 250
+
+SwScrollbar::SwScrollbar( Window *pWin, sal_Bool bHoriz ) :
+ ScrollBar( pWin,
+ WinBits( WB_3DLOOK | WB_HIDE | ( bHoriz ? WB_HSCROLL : WB_VSCROLL) ) ),
+ bHori( bHoriz ),
+ bAuto( sal_False ),
+ bVisible(sal_False),
+ bSizeSet(sal_False)
+{
+ // SSA: --- RTL --- no mirroring for horizontal scrollbars
+ if( bHoriz )
+ EnableRTL( false );
+}
+
+ SwScrollbar::~SwScrollbar() {}
+
+// Will be called after a change of the document size
+// to refresh the range of the scrollbars.
+
+void SwScrollbar::DocSzChgd( const Size &rSize )
+{
+ aDocSz = rSize;
+ SetRange( Range( 0, bHori ? rSize.Width() : rSize.Height()) );
+ const sal_uLong nVisSize = GetVisibleSize();
+ SetLineSize( SCROLL_LINE_SIZE );
+ SetPageSize( nVisSize * 77 / 100 );
+}
+
+// Will be called after a change of the visible view section.
+
+void SwScrollbar::ViewPortChgd( const Rectangle &rRect )
+{
+ long nThumb, nVisible;
+ if( bHori )
+ {
+ nThumb = rRect.Left();
+ nVisible = rRect.GetWidth();
+ }
+ else
+ {
+ nThumb = rRect.Top();
+ nVisible = rRect.GetHeight();
+ }
+
+ SetVisibleSize( nVisible );
+ DocSzChgd(aDocSz);
+ SetThumbPos( nThumb );
+ if(bAuto)
+ AutoShow();
+}
+
+void SwScrollbar::ExtendedShow( sal_Bool bSet )
+{
+ bVisible = bSet;
+ if( (!bSet || !bAuto) && IsUpdateMode() && bSizeSet)
+ ScrollBar::Show(bSet);
+}
+
+void SwScrollbar::SetPosSizePixel( const Point& rNewPos, const Size& rNewSize )
+{
+ ScrollBar::SetPosSizePixel(rNewPos, rNewSize);
+ bSizeSet = sal_True;
+ if(bVisible)
+ ExtendedShow();
+
+}
+
+void SwScrollbar::SetAuto(sal_Bool bSet)
+{
+ if(bAuto != bSet)
+ {
+ bAuto = bSet;
+
+ // hide autmatically - automatisch versteckt - then show
+ if(!bAuto && bVisible && !ScrollBar::IsVisible())
+ ExtendedShow(sal_True);
+ else if(bAuto)
+ AutoShow(); // or hide automatically
+ }
+}
+
+void SwScrollbar::AutoShow()
+{
+ long nVis = GetVisibleSize();
+ long nLen = GetRange().Len();
+ if( nVis >= nLen - 1)
+ {
+ if(ScrollBar::IsVisible())
+ ScrollBar::Show(false);
+ }
+ else if ( !ScrollBar::IsVisible() )
+ {
+ ScrollBar::Show(true);
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/uiview/srcview.cxx b/sw/source/core/uibase/uiview/srcview.cxx
new file mode 100644
index 000000000000..c31d1111c41d
--- /dev/null
+++ b/sw/source/core/uibase/uiview/srcview.cxx
@@ -0,0 +1,873 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <hintids.hxx>
+#include <com/sun/star/util/SearchOptions.hpp>
+#include <com/sun/star/util/SearchFlags.hpp>
+#include <com/sun/star/i18n/TransliterationModules.hpp>
+#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
+#include <comphelper/string.hxx>
+#include <unotools/tempfile.hxx>
+#include <tools/urlobj.hxx>
+#include <vcl/print.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/wrkwin.hxx>
+#include <vcl/metric.hxx>
+#include <svtools/ctrltool.hxx>
+#include <svl/intitem.hxx>
+#include <svl/stritem.hxx>
+#include <unotools/pathoptions.hxx>
+#include <svl/undo.hxx>
+#include <unotools/textsearch.hxx>
+#include <svl/eitem.hxx>
+#include <svl/whiter.hxx>
+#include <unotools/saveopt.hxx>
+#include <svtools/transfer.hxx>
+#include <svtools/svtools.hrc>
+#include <svtools/svtresid.hxx>
+#include <svx/svxids.hrc>
+#include <svtools/htmlcfg.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/objface.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/docfilt.hxx>
+#include <sfx2/fcontnr.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/prnmon.hxx>
+#include <sfx2/docfile.hxx>
+#include <editeng/fhgtitem.hxx>
+#include <svx/srchdlg.hxx>
+#include <svl/srchitem.hxx>
+#include <editeng/fontitem.hxx>
+#include <editeng/flstitem.hxx>
+#include "editeng/unolingu.hxx"
+#include <sfx2/sfxhtml.hxx>
+#include <swtypes.hxx>
+#include <swmodule.hxx>
+#include <docsh.hxx>
+#include <wdocsh.hxx>
+#include <srcview.hxx>
+#include <viewfunc.hxx>
+#include <doc.hxx>
+#include <sfx2/msg.hxx>
+#include <shellio.hxx>
+
+#include <cmdid.h>
+#include <helpid.h>
+#include <globals.hrc>
+#include <shells.hrc>
+#include <popup.hrc>
+#include <web.hrc>
+#include <view.hrc>
+#include <com/sun/star/ui/dialogs/XFilePicker.hpp>
+#include <com/sun/star/ui/dialogs/XFilterManager.hpp>
+#include <sfx2/filedlghelper.hxx>
+#define SwSrcView
+#include "swslots.hxx"
+
+#include <unomid.h>
+
+#include <com/sun/star/document/XDocumentProperties.hpp>
+#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::i18n;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::ui::dialogs;
+using namespace ::sfx2;
+using ::com::sun::star::util::SearchOptions;
+
+#define SWSRCVIEWFLAGS ( SFX_VIEW_CAN_PRINT|\
+ SFX_VIEW_NO_NEWWINDOW )
+
+#define SRC_SEARCHOPTIONS (0xFFFF & ~(SEARCH_OPTIONS_FORMAT|SEARCH_OPTIONS_FAMILIES|SEARCH_OPTIONS_SEARCH_ALL))
+
+// Printing margins -> like Basic - Ide
+#define LMARGPRN 1700
+#define RMARGPRN 900
+#define TMARGPRN 2000
+#define BMARGPRN 1000
+#define BORDERPRN 300
+
+SFX_IMPL_NAMED_VIEWFACTORY(SwSrcView, "SourceView")
+{
+ SFX_VIEW_REGISTRATION(SwWebDocShell);
+}
+
+SFX_IMPL_INTERFACE( SwSrcView, SfxViewShell, SW_RES(0) )
+{
+ SFX_POPUPMENU_REGISTRATION(SW_RES(MN_SRCVIEW_POPUPMENU));
+ SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_TOOLS|
+ SFX_VISIBILITY_STANDARD|SFX_VISIBILITY_SERVER,
+ SW_RES(RID_WEBTOOLS_TOOLBOX) );
+ SFX_CHILDWINDOW_REGISTRATION(SvxSearchDialogWrapper::GetChildWindowId());
+}
+
+TYPEINIT1(SwSrcView, SfxViewShell)
+
+static void lcl_PrintHeader( OutputDevice &rOutDev, sal_uInt16 nPages, sal_uInt16 nCurPage, const OUString& rTitle )
+{
+ short nLeftMargin = LMARGPRN;
+ Size aSz = rOutDev.GetOutputSize();
+ short nBorder = BORDERPRN;
+
+ Color aOldFillColor( rOutDev.GetFillColor() );
+ Font aOldFont( rOutDev.GetFont() );
+
+ rOutDev.SetFillColor( Color(COL_TRANSPARENT) );
+
+ Font aFont( aOldFont );
+ aFont.SetWeight( WEIGHT_BOLD );
+ aFont.SetAlign( ALIGN_BOTTOM );
+ rOutDev.SetFont( aFont );
+
+ long nFontHeight = rOutDev.GetTextHeight();
+
+ // 1.Border => Line, 2+3 Border = Space.
+ long nYTop = TMARGPRN-3*nBorder-nFontHeight;
+
+ long nXLeft = nLeftMargin-nBorder;
+ long nXRight = aSz.Width()-RMARGPRN+nBorder;
+
+ rOutDev.DrawRect( Rectangle(
+ Point( nXLeft, nYTop ),
+ Size( nXRight-nXLeft, aSz.Height() - nYTop - BMARGPRN + nBorder ) ) );
+
+ long nY = TMARGPRN-2*nBorder;
+ Point aPos( nLeftMargin, nY );
+ rOutDev.DrawText( aPos, rTitle );
+ if ( nPages != 1 )
+ {
+ aFont.SetWeight( WEIGHT_NORMAL );
+ rOutDev.SetFont( aFont );
+ OUString aPageStr( " [" );
+ aPageStr += SW_RES( STR_PAGE );
+ aPageStr += " ";
+ aPageStr += OUString::number( nCurPage );
+ aPageStr += "]";
+ aPos.X() += rOutDev.GetTextWidth( rTitle );
+ rOutDev.DrawText( aPos, aPageStr );
+ }
+
+ nY = TMARGPRN-nBorder;
+
+ rOutDev.DrawLine( Point( nXLeft, nY ), Point( nXRight, nY ) );
+
+ rOutDev.SetFont( aOldFont );
+ rOutDev.SetFillColor( aOldFillColor );
+}
+
+static rtl_TextEncoding lcl_GetStreamCharSet(rtl_TextEncoding eLoadEncoding)
+{
+ rtl_TextEncoding eRet = eLoadEncoding;
+ if(RTL_TEXTENCODING_DONTKNOW == eRet)
+ {
+ SvxHtmlOptions& rHtmlOptions = SvxHtmlOptions::Get();
+ const sal_Char *pCharSet =
+ rtl_getBestMimeCharsetFromTextEncoding( rHtmlOptions.GetTextEncoding() );
+ eRet = rtl_getTextEncodingFromMimeCharset( pCharSet );
+ }
+ return eRet;
+}
+
+static OUString lcl_ConvertTabsToSpaces( OUString sLine )
+{
+ if (!sLine.isEmpty())
+ {
+ const sal_Unicode aPadSpaces[4] = {' ', ' ', ' ', ' '};
+ sal_Int32 nPos = 0;
+ for (;;)
+ {
+ nPos = sLine.indexOf('\t', nPos);
+ if (nPos<0)
+ {
+ break;
+ }
+ // Not 4 blanks, but on 4th TabPos:
+ const sal_Int32 nPadLen = 4 - (nPos % 4);
+ sLine = sLine.replaceAt(nPos, 1, OUString(aPadSpaces, nPadLen));
+ nPos += nPadLen;
+ }
+ }
+ return sLine;
+}
+
+SwSrcView::SwSrcView(SfxViewFrame* pViewFrame, SfxViewShell*) :
+ SfxViewShell( pViewFrame, SWSRCVIEWFLAGS ),
+ aEditWin( &pViewFrame->GetWindow(), this ),
+ pSearchItem(0),
+ bSourceSaved(sal_False),
+ eLoadEncoding(RTL_TEXTENCODING_DONTKNOW)
+{
+ Init();
+}
+
+SwSrcView::~SwSrcView()
+{
+ SwDocShell* pDocShell = GetDocShell();
+ OSL_ENSURE(PTR_CAST(SwWebDocShell, pDocShell), "Why no WebDocShell?");
+ const TextSelection& rSel = aEditWin.GetTextView()->GetSelection();
+ ((SwWebDocShell*)pDocShell)->SetSourcePara( static_cast< sal_uInt16 >( rSel.GetStart().GetPara() ) );
+
+ uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
+ pDocShell->GetModel(), uno::UNO_QUERY_THROW);
+ uno::Reference<document::XDocumentProperties> xDocProps
+ = xDPS->getDocumentProperties();
+ OUString url = xDocProps->getAutoloadURL();
+ sal_Int32 delay = xDocProps->getAutoloadSecs();
+ pDocShell->SetAutoLoad(INetURLObject(url), delay,
+ (delay != 0) || !url.isEmpty());
+ EndListening(*pDocShell);
+ delete pSearchItem;
+}
+
+void SwSrcView::SaveContentTo(SfxMedium& rMed)
+{
+ SvStream* pOutStream = rMed.GetOutStream();
+ pOutStream->SetStreamCharSet(lcl_GetStreamCharSet(eLoadEncoding));
+ aEditWin.Write( *pOutStream );
+}
+
+void SwSrcView::Init()
+{
+ SetHelpId(SW_SRC_VIEWSHELL);
+ SetName(OUString("Source"));
+ SetWindow( &aEditWin );
+ SwDocShell* pDocShell = GetDocShell();
+ // If the doc is still loading, then the DocShell must fire up
+ // the Load if the loading is completed.
+ if(!pDocShell->IsLoading())
+ Load(pDocShell);
+ else
+ {
+ aEditWin.SetReadonly(sal_True);
+ }
+
+ SetNewWindowAllowed( sal_False );
+ StartListening(*pDocShell,true);
+}
+
+SwDocShell* SwSrcView::GetDocShell()
+{
+ SfxObjectShell* pObjShell = GetViewFrame()->GetObjectShell();
+ return PTR_CAST(SwDocShell, pObjShell);
+}
+
+void SwSrcView::SaveContent(const OUString& rTmpFile)
+{
+ SfxMedium aMedium( rTmpFile, STREAM_WRITE);
+ SvStream* pOutStream = aMedium.GetOutStream();
+ pOutStream->SetStreamCharSet( lcl_GetStreamCharSet(eLoadEncoding) );
+ aEditWin.Write(*pOutStream);
+ aMedium.Commit();
+}
+
+void SwSrcView::Execute(SfxRequest& rReq)
+{
+ sal_uInt16 nSlot = rReq.GetSlot();
+ TextView* pTextView = aEditWin.GetTextView();
+ switch( nSlot )
+ {
+ case SID_SAVEACOPY:
+ case SID_SAVEASDOC:
+ {
+ SvtPathOptions aPathOpt;
+ // filesave dialog with autoextension
+ FileDialogHelper aDlgHelper(
+ TemplateDescription::FILESAVE_AUTOEXTENSION, 0 );
+ uno::Reference < XFilePicker > xFP = aDlgHelper.GetFilePicker();
+ uno::Reference<XFilterManager> xFltMgr(xFP, UNO_QUERY);
+
+ // search for an html filter for export
+ SfxFilterContainer* pFilterCont = GetObjectShell()->GetFactory().GetFilterContainer();
+ const SfxFilter* pFilter =
+ pFilterCont->GetFilter4Extension( OUString("html"), SFX_FILTER_EXPORT );
+ if ( pFilter )
+ {
+ // filter found -> use its uiname and wildcard
+ const OUString& rUIName = pFilter->GetUIName();
+ const WildCard& rCard = pFilter->GetWildcard();
+ xFltMgr->appendFilter( rUIName, rCard.getGlob() );
+ xFltMgr->setCurrentFilter( rUIName ) ;
+ }
+ else
+ {
+ // filter not found
+ OUString sHtml("HTML");
+ xFltMgr->appendFilter( sHtml, OUString("*.html;*.htm") );
+ xFltMgr->setCurrentFilter( sHtml ) ;
+ }
+
+ xFP->setDisplayDirectory( aPathOpt.GetWorkPath() );
+ if( aDlgHelper.Execute() == ERRCODE_NONE)
+ {
+ SfxMedium aMedium( xFP->getFiles().getConstArray()[0],
+ STREAM_WRITE | STREAM_SHARE_DENYNONE );
+ SvStream* pOutStream = aMedium.GetOutStream();
+ pOutStream->SetStreamCharSet(lcl_GetStreamCharSet(eLoadEncoding));
+ aEditWin.Write( *pOutStream );
+ aMedium.Commit();
+ }
+ }
+ break;
+ case SID_SAVEDOC:
+ {
+ SwDocShell* pDocShell = GetDocShell();
+ SfxMedium* pMed = 0;
+ if(pDocShell->HasName())
+ pMed = pDocShell->GetMedium();
+ else
+ {
+ SfxBoolItem* pItem = (SfxBoolItem*)pDocShell->ExecuteSlot(rReq, pDocShell->GetInterface());
+ if(pItem && pItem->GetValue())
+ pMed = pDocShell->GetMedium();
+ }
+ if(pMed)
+ {
+ SvStream* pOutStream = pMed->GetOutStream();
+ pOutStream->Seek(0);
+ pOutStream->SetStreamSize(0);
+ pOutStream->SetStreamCharSet(lcl_GetStreamCharSet(eLoadEncoding));
+ aEditWin.Write( *pOutStream );
+ pMed->CloseOutStream();
+ pMed->Commit();
+ pDocShell->GetDoc()->ResetModified();
+ SourceSaved();
+ aEditWin.ClearModifyFlag();
+ }
+ }
+ break;
+ case FID_SEARCH_NOW:
+ {
+ const SfxItemSet* pTmpArgs = rReq.GetArgs();
+
+ sal_uInt16 nWhich = pTmpArgs->GetWhichByPos( 0 );
+ OSL_ENSURE( nWhich, "Which for SearchItem ?" );
+ const SfxPoolItem& rItem = pTmpArgs->Get( nWhich );
+ SetSearchItem( (const SvxSearchItem&)rItem);
+ StartSearchAndReplace( (const SvxSearchItem&)rItem, sal_False, rReq.IsAPI() );
+ if(aEditWin.IsModified())
+ GetDocShell()->GetDoc()->SetModified();
+ }
+ break;
+ case FN_REPEAT_SEARCH:
+ {
+ SvxSearchItem* pSrchItem = GetSearchItem();
+ if(pSrchItem)
+ {
+ StartSearchAndReplace( *pSrchItem, sal_False, rReq.IsAPI() );
+ if(aEditWin.IsModified())
+ GetDocShell()->GetDoc()->SetModified();
+ }
+ }
+ break;
+ case SID_PRINTDOC:
+ case SID_PRINTDOCDIRECT:
+ {
+ SfxViewShell::ExecuteSlot( rReq, SfxViewShell::GetInterface() );
+ }
+ break;
+ case SID_UNDO:
+ pTextView->Undo();
+ GetViewFrame()->GetBindings().InvalidateAll(sal_False);
+ break;
+ case SID_REDO:
+ pTextView->Redo();
+ GetViewFrame()->GetBindings().InvalidateAll(sal_False);
+ break;
+ case SID_REPEAT:
+ break;
+ case SID_CUT:
+ if(pTextView->HasSelection())
+ pTextView->Cut();
+ break;
+ case SID_COPY:
+ if(pTextView->HasSelection())
+ pTextView->Copy();
+ break;
+ case SID_PASTE:
+ pTextView->Paste();
+ break;
+ case SID_SELECTALL:
+ pTextView->SetSelection( TextSelection( TextPaM( 0, 0 ), TextPaM( 0xFFFFFFFF, 0xFFFF ) ) );
+ break;
+ }
+ aEditWin.Invalidate();
+}
+
+void SwSrcView::GetState(SfxItemSet& rSet)
+{
+ SfxWhichIter aIter(rSet);
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ TextView* pTextView = aEditWin.GetTextView();
+
+ while(nWhich)
+ {
+ switch(nWhich)
+ {
+ case SID_SAVEASDOC:
+ rSet.Put(SfxStringItem(nWhich, OUString(SW_RES(STR_SAVEAS_SRC))));
+ break;
+ case SID_SAVEACOPY:
+ rSet.Put(SfxStringItem(nWhich, OUString(SW_RES(STR_SAVEACOPY_SRC))));
+ break;
+ case SID_SAVEDOC:
+ {
+ SwDocShell* pDocShell = GetDocShell();
+ if(!pDocShell->IsModified())
+ rSet.DisableItem(nWhich);
+ }
+ break;
+ case SID_PRINTDOC:
+ case SID_PRINTDOCDIRECT:
+ break;
+ case SID_TABLE_CELL:
+ {
+ OUString aPos( SW_RES(STR_SRCVIEW_ROW) );
+ TextSelection aSel = pTextView->GetSelection();
+ aPos += OUString::number( aSel.GetEnd().GetPara()+1 );
+ aPos += " : ";
+ aPos += SW_RES(STR_SRCVIEW_COL);
+ aPos += OUString::number( aSel.GetEnd().GetIndex()+1 );
+ SfxStringItem aItem( nWhich, aPos );
+ rSet.Put( aItem );
+ }
+ break;
+ case SID_SEARCH_OPTIONS:
+ {
+ sal_uInt16 nOpt = SRC_SEARCHOPTIONS;
+ if(GetDocShell()->IsReadOnly())
+ nOpt &= ~(SEARCH_OPTIONS_REPLACE|SEARCH_OPTIONS_REPLACE_ALL);
+
+ rSet.Put( SfxUInt16Item( SID_SEARCH_OPTIONS, nOpt) );
+ }
+ break;
+ case SID_SEARCH_ITEM:
+ {
+ OUString sSelected;
+ if ( !pTextView->HasSelection() )
+ {
+ const TextSelection& rSel = pTextView->GetSelection();
+ sSelected = aEditWin.GetTextEngine()->GetWord( rSel.GetStart());
+ }
+ else
+ {
+ sSelected = pTextView->GetSelected();
+ }
+ SvxSearchItem * pSrchItem = GetSearchItem();
+ pSrchItem->SetSearchString( sSelected );
+ rSet.Put( *pSrchItem );
+ }
+ break;
+ case FN_REPEAT_SEARCH:
+ {
+ if(!GetSearchItem())
+ rSet.DisableItem(nWhich);
+ };
+ break;
+ case SID_UNDO:
+ case SID_REDO:
+ {
+ ::svl::IUndoManager& rMgr = pTextView->GetTextEngine()->GetUndoManager();
+ sal_uInt16 nCount = 0;
+ if(nWhich == SID_UNDO)
+ {
+ nCount = rMgr.GetUndoActionCount();
+ if(nCount)
+ {
+ OUString aStr(SvtResId( STR_UNDO));
+ aStr += rMgr.GetUndoActionComment(--nCount);
+ rSet.Put(SfxStringItem(nWhich, aStr));
+ }
+ else
+ rSet.DisableItem(nWhich);
+ }
+ else
+ {
+ nCount = rMgr.GetRedoActionCount();
+ if(nCount)
+ {
+ OUString aStr(SvtResId( STR_REDO));
+ aStr += rMgr.GetRedoActionComment(--nCount);
+ rSet.Put(SfxStringItem(nWhich,aStr));
+ }
+ else
+ rSet.DisableItem(nWhich);
+ }
+ }
+ break;
+ case SID_MAIL_SENDDOCASPDF:
+ case SID_MAIL_SENDDOC :
+ case SID_EXPORTDOCASPDF:
+ case SID_DIRECTEXPORTDOCASPDF:
+ case SID_EXPORTDOC:
+ case SID_REPEAT:
+ case SID_BROWSER_MODE:
+ case FN_PRINT_LAYOUT:
+ rSet.DisableItem(nWhich);
+ break;
+ case SID_CUT:
+ case SID_COPY:
+ if(!pTextView->HasSelection())
+ rSet.DisableItem(nWhich);
+ break;
+ case SID_PASTE:
+ {
+ TransferableDataHelper aDataHelper(
+ TransferableDataHelper::CreateFromSystemClipboard(
+ &aEditWin) );
+ bool bDisable = !aDataHelper.GetXTransferable().is() ||
+ 0 == aDataHelper.GetFormatCount();
+ if( bDisable )
+ rSet.DisableItem(nWhich);
+ }
+ break;
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+SvxSearchItem* SwSrcView::GetSearchItem()
+{
+ if(!pSearchItem)
+ {
+ pSearchItem = new SvxSearchItem(SID_SEARCH_ITEM);
+ }
+ return pSearchItem;
+}
+
+void SwSrcView::SetSearchItem( const SvxSearchItem& rItem )
+{
+ delete pSearchItem;
+ pSearchItem = (SvxSearchItem*)rItem.Clone();
+}
+
+sal_uInt16 SwSrcView::StartSearchAndReplace(const SvxSearchItem& rSearchItem,
+ sal_Bool bFromStart,
+ sal_Bool bApi,
+ sal_Bool bRecursive)
+{
+ ExtTextView* pTextView = aEditWin.GetTextView();
+ TextSelection aSel;
+ TextPaM aPaM;
+
+ sal_Bool bForward = !rSearchItem.GetBackward();
+ bool bAtStart = pTextView->GetSelection() == TextSelection( aPaM, aPaM );
+
+ if( !bForward )
+ aPaM = TextPaM( (sal_uLong)-1, (sal_uInt16)-1 );
+
+ if( bFromStart )
+ {
+ aSel = pTextView->GetSelection();
+ pTextView->SetSelection( TextSelection( aPaM, aPaM ));
+ }
+
+ util::SearchOptions aSearchOpt( rSearchItem.GetSearchOptions() );
+ aSearchOpt.Locale = GetAppLanguageTag().getLocale();
+
+ sal_uInt16 nFound;
+ sal_Bool bAll = sal_False;
+ switch( rSearchItem.GetCommand() )
+ {
+ case SVX_SEARCHCMD_FIND:
+ case SVX_SEARCHCMD_FIND_ALL:
+ nFound = pTextView->Search( aSearchOpt, bForward ) ? 1 : 0;
+ break;
+
+ case SVX_SEARCHCMD_REPLACE_ALL: bAll = sal_True;
+ case SVX_SEARCHCMD_REPLACE:
+ nFound = pTextView->Replace( aSearchOpt, bAll, bForward );
+ break;
+
+ default:
+ nFound = 0;
+ }
+
+ if( !nFound )
+ {
+ bool bNotFoundMessage = false;
+ if(!bRecursive)
+ {
+ if(!bFromStart)
+ {
+ bNotFoundMessage = bAtStart;
+ }
+ else
+ {
+ bNotFoundMessage = true;
+ pTextView->SetSelection( aSel );
+ }
+ }
+ else if(bAtStart)
+ {
+ bNotFoundMessage = true;
+ }
+
+ if(!bApi)
+ {
+ if(bNotFoundMessage)
+ {
+ MessageDialog(0, "InfoNotFoundDialog",
+ "modules/swriter/ui/infonotfounddialog.ui").Execute();
+ }
+ else if(!bRecursive)
+ {
+ int nRet;
+
+ if (!bForward)
+ {
+ nRet = MessageDialog(0, "QueryContinueEndDialog",
+ "modules/swriter/ui/querycontinueenddialog.ui").Execute();
+ }
+ else
+ {
+ nRet = MessageDialog(0, "QueryContinueBeginDialog",
+ "modules/swriter/ui/querycontinuebegindialog.ui").Execute();
+ }
+
+ if (nRet == RET_YES)
+ {
+ pTextView->SetSelection( TextSelection( aPaM, aPaM ) );
+ StartSearchAndReplace( rSearchItem, sal_False, sal_False, sal_True );
+ }
+ }
+ }
+ }
+ return nFound;
+}
+
+sal_uInt16 SwSrcView::SetPrinter(SfxPrinter* pNew, sal_uInt16 nDiffFlags, bool )
+{
+ SwDocShell* pDocSh = GetDocShell();
+ if ( (SFX_PRINTER_JOBSETUP | SFX_PRINTER_PRINTER) & nDiffFlags )
+ {
+ pDocSh->GetDoc()->setPrinter( pNew, true, true );
+ if ( nDiffFlags & SFX_PRINTER_PRINTER )
+ pDocSh->SetModified();
+ }
+ if ( nDiffFlags & SFX_PRINTER_OPTIONS )
+ ::SetPrinter( pDocSh->getIDocumentDeviceAccess(), pNew, sal_True );
+
+ const bool bChgOri = nDiffFlags & SFX_PRINTER_CHG_ORIENTATION;
+ const bool bChgSize= nDiffFlags & SFX_PRINTER_CHG_SIZE;
+ if ( bChgOri || bChgSize )
+ {
+ pDocSh->SetModified();
+ }
+ return 0;
+}
+
+SfxPrinter* SwSrcView::GetPrinter( sal_Bool bCreate )
+{
+ return GetDocShell()->GetDoc()->getPrinter( bCreate );
+}
+
+sal_Int32 SwSrcView::PrintSource(
+ OutputDevice *pOutDev,
+ sal_Int32 nPage,
+ bool bCalcNumPagesOnly )
+{
+ if (!pOutDev || nPage <= 0)
+ return 0;
+
+ //! This algorithm for printing the n-th page is very poor since it
+ //! needs to go over the text of all previous pages to get to the correct one.
+ //! But since HTML source code is expected to be just a small number of pages
+ //! even this poor algorithm should be enough...
+
+ pOutDev->Push();
+
+ TextEngine* pTextEngine = aEditWin.GetTextEngine();
+ pOutDev->SetMapMode( MAP_100TH_MM );
+ Font aFont( aEditWin.GetOutWin()->GetFont() );
+ Size aSize( aFont.GetSize() );
+ aSize = aEditWin.GetOutWin()->PixelToLogic( aSize, MAP_100TH_MM );
+ aFont.SetSize( aSize );
+ aFont.SetColor( COL_BLACK );
+ pOutDev->SetFont( aFont );
+
+ OUString aTitle( GetViewFrame()->GetWindow().GetText() );
+
+ sal_uInt16 nLineHeight = (sal_uInt16) pOutDev->GetTextHeight(); // slightly more
+ sal_uInt16 nParaSpace = 10;
+
+ Size aPaperSz = pOutDev->GetOutputSize();
+ aPaperSz.Width() -= (LMARGPRN + RMARGPRN);
+ aPaperSz.Height() -= (TMARGPRN + BMARGPRN);
+
+ // nLinepPage is not true, if lines have to be wrapped...
+ sal_uInt16 nLinespPage = (sal_uInt16) (aPaperSz.Height() / nLineHeight);
+ const sal_Int32 nCharspLine =
+ static_cast<sal_Int32>(aPaperSz.Width() / pOutDev->GetTextWidth("X"));
+ sal_uInt16 nParas = static_cast< sal_uInt16 >( pTextEngine->GetParagraphCount() );
+
+ sal_uInt16 nPages = (sal_uInt16) (nParas / nLinespPage + 1 );
+ sal_uInt16 nCurPage = 1;
+
+ // Print header...
+ if (!bCalcNumPagesOnly && nPage == nCurPage)
+ lcl_PrintHeader( *pOutDev, nPages, nCurPage, aTitle );
+ const Point aStartPos( LMARGPRN, TMARGPRN );
+ Point aPos( aStartPos );
+ for ( sal_uInt16 nPara = 0; nPara < nParas; ++nPara )
+ {
+ const OUString aLine( lcl_ConvertTabsToSpaces(pTextEngine->GetText( nPara )) );
+ const sal_Int32 nLineLen = aLine.getLength();
+ const sal_Int32 nLines = (nLineLen+nCharspLine-1) / nCharspLine;
+ for ( sal_Int32 nLine = 0; nLine < nLines; ++nLine )
+ {
+ aPos.Y() += nLineHeight;
+ if ( aPos.Y() > ( aPaperSz.Height() + TMARGPRN - nLineHeight/2 ) )
+ {
+ ++nCurPage;
+ if (!bCalcNumPagesOnly && nPage == nCurPage)
+ lcl_PrintHeader( *pOutDev, nPages, nCurPage, aTitle );
+ aPos = aStartPos;
+ }
+ if (!bCalcNumPagesOnly && nPage == nCurPage)
+ {
+ const sal_Int32 nStart = nLine * nCharspLine;
+ const sal_Int32 nLen = std::min(nLineLen-nStart, nCharspLine);
+ pOutDev->DrawText( aPos, aLine.copy(nStart, nLen) );
+ }
+ }
+ aPos.Y() += nParaSpace;
+ }
+
+ pOutDev->Pop();
+
+ OSL_ENSURE( bCalcNumPagesOnly || nPage <= nCurPage, "page number out of range" );
+ return nCurPage;
+}
+
+void SwSrcView::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
+{
+ if ( rHint.ISA(SfxSimpleHint) &&
+ (
+ ((SfxSimpleHint&) rHint).GetId() == SFX_HINT_MODECHANGED ||
+ (
+ ((SfxSimpleHint&) rHint).GetId() == SFX_HINT_TITLECHANGED &&
+ !GetDocShell()->IsReadOnly() && aEditWin.IsReadonly()
+ )
+ )
+ )
+ {
+ // Broadcast only comes once!
+ const SwDocShell* pDocSh = GetDocShell();
+ const sal_Bool bReadonly = pDocSh->IsReadOnly();
+ aEditWin.SetReadonly(bReadonly);
+ }
+ SfxViewShell::Notify(rBC, rHint);
+}
+
+void SwSrcView::Load(SwDocShell* pDocShell)
+{
+ SvxHtmlOptions& rHtmlOptions = SvxHtmlOptions::Get();
+ const sal_Char *pCharSet =
+ rtl_getBestMimeCharsetFromTextEncoding( rHtmlOptions.GetTextEncoding() );
+ rtl_TextEncoding eDestEnc = rtl_getTextEncodingFromMimeCharset( pCharSet );
+
+ aEditWin.SetReadonly(pDocShell->IsReadOnly());
+ aEditWin.SetTextEncoding(eDestEnc);
+ SfxMedium* pMedium = pDocShell->GetMedium();
+
+ const SfxFilter* pFilter = pMedium->GetFilter();
+ bool bHtml = pFilter && pFilter->GetUserData() == "HTML";
+ sal_Bool bDocModified = pDocShell->IsModified();
+ if(bHtml && !bDocModified && pDocShell->HasName())
+ {
+ SvStream* pStream = pMedium->GetInStream();
+ if(pStream && 0 == pStream->GetError() )
+ {
+ rtl_TextEncoding eHeaderEnc =
+ SfxHTMLParser::GetEncodingByHttpHeader(
+ pDocShell->GetHeaderAttributes() );
+ if( RTL_TEXTENCODING_DONTKNOW == eHeaderEnc )
+ {
+ const sal_Char *pTmpCharSet =
+ rtl_getBestMimeCharsetFromTextEncoding( RTL_TEXTENCODING_ISO_8859_1 );
+ eHeaderEnc = rtl_getTextEncodingFromMimeCharset( pTmpCharSet );
+ }
+ if( RTL_TEXTENCODING_DONTKNOW != eHeaderEnc &&
+ eDestEnc != eHeaderEnc )
+ {
+ eDestEnc = eHeaderEnc;
+ aEditWin.SetTextEncoding(eDestEnc);
+ }
+ pStream->SetStreamCharSet( eDestEnc );
+ pStream->Seek(0);
+ TextEngine* pTextEngine = aEditWin.GetTextEngine();
+ pTextEngine->EnableUndo(false);
+ aEditWin.Read(*pStream);
+ pTextEngine->EnableUndo(true);
+ }
+ else
+ {
+ Window *pTmpWindow = &GetViewFrame()->GetWindow();
+ InfoBox(pTmpWindow, SW_RES(MSG_ERR_SRCSTREAM)).Execute();
+ }
+ }
+ else
+ {
+ utl::TempFile aTempFile;
+ aTempFile.EnableKillingFile();
+ const OUString sFileURL( aTempFile.GetURL() );
+ SvtSaveOptions aOpt;
+
+ {
+ SfxMedium aMedium( sFileURL,STREAM_READWRITE );
+ SwWriter aWriter( aMedium, *pDocShell->GetDoc() );
+ WriterRef xWriter;
+ ::GetHTMLWriter(OUString(), aMedium.GetBaseURL( true ), xWriter);
+ const OUString sWriteName = pDocShell->HasName()
+ ? pMedium->GetName()
+ : sFileURL;
+ sal_uLong nRes = aWriter.Write(xWriter, &sWriteName);
+ if(nRes)
+ {
+ ErrorHandler::HandleError(ErrCode(nRes));
+ aEditWin.SetReadonly(sal_True);
+ }
+ aMedium.Commit();
+ SvStream* pInStream = aMedium.GetInStream();
+ pInStream->Seek(0);
+ pInStream->SetStreamCharSet( eDestEnc );
+
+ aEditWin.Read(*pInStream);
+ }
+ }
+ aEditWin.ClearModifyFlag();
+
+ eLoadEncoding = eDestEnc;
+
+ if(bDocModified)
+ pDocShell->SetModified();// The flag will be reset in between times.
+ // Disable AutoLoad
+ pDocShell->SetAutoLoad(INetURLObject(), 0, sal_False);
+ OSL_ENSURE(PTR_CAST(SwWebDocShell, pDocShell), "Why no WebDocShell?");
+ sal_uInt16 nLine = ((SwWebDocShell*)pDocShell)->GetSourcePara();
+ aEditWin.SetStartLine(nLine);
+ aEditWin.GetTextEngine()->ResetUndo();
+ aEditWin.GetOutWin()->GrabFocus();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/uiview/swcli.cxx b/sw/source/core/uibase/uiview/swcli.cxx
new file mode 100644
index 000000000000..3ee05fef848a
--- /dev/null
+++ b/sw/source/core/uibase/uiview/swcli.cxx
@@ -0,0 +1,172 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
+#include <wrtsh.hxx>
+#include <doc.hxx>
+#include <swtypes.hxx>
+#include <view.hxx>
+#include <edtwin.hxx>
+#include <swcli.hxx>
+#include <cmdid.h>
+#include <cfgitems.hxx>
+
+#include <toolkit/helper/vclunohelper.hxx>
+
+using namespace com::sun::star;
+
+SwOleClient::SwOleClient( SwView *pView, SwEditWin *pWin, const svt::EmbeddedObjectRef& xObj ) :
+ SfxInPlaceClient( pView, pWin, xObj.GetViewAspect() ), bInDoVerb( sal_False ),
+ bOldCheckForOLEInCaption( pView->GetWrtShell().IsCheckForOLEInCaption() )
+{
+ SetObject( xObj.GetObject() );
+}
+
+void SwOleClient::RequestNewObjectArea( Rectangle& aLogRect )
+{
+ // The server wants to change the client size.
+ // We put the desired size in the core. The attributes of the frame
+ // are set to the desired value. This value will be passed on to the
+ // InPlaceClient.
+ // The core accepts or formats the adjusted values not necessarily.
+ // If the Ole-Frm is formatted, then the CalcAndSetScale() of the WrtShell
+ // will be called. There the scaling of the SwOleClient is set if necessary.
+
+ SwWrtShell &rSh = ((SwView*)GetViewShell())->GetWrtShell();
+
+ rSh.StartAllAction();
+
+ // the aLogRect will get the preliminary size now
+ aLogRect.SetSize( rSh.RequestObjectResize( SwRect( aLogRect ), GetObject() ) );
+
+ // the EndAllAction() call will trigger CalcAndSetScale() call,
+ // so the embedded object must get the correct size before
+ if ( aLogRect.GetSize() != GetScaledObjArea().GetSize() )
+ {
+ // size has changed, so first change visual area of the object before we resize its view
+ // without this the object always would be scaled - now it has the choice
+
+ // TODO/LEAN: getMapUnit can switch object to running state
+ MapMode aObjectMap( VCLUnoHelper::UnoEmbed2VCLMapUnit( GetObject()->getMapUnit( GetAspect() ) ) );
+ MapMode aClientMap( GetEditWin()->GetMapMode().GetMapUnit() );
+
+ Size aNewObjSize( Fraction( aLogRect.GetWidth() ) / GetScaleWidth(),
+ Fraction( aLogRect.GetHeight() ) / GetScaleHeight() );
+
+ // convert to logical coordinates of the embedded object
+ Size aNewSize = GetEditWin()->LogicToLogic( aNewObjSize, &aClientMap, &aObjectMap );
+ GetObject()->setVisualAreaSize( GetAspect(), awt::Size( aNewSize.Width(), aNewSize.Height() ) );
+ }
+
+ rSh.EndAllAction();
+
+ SwRect aFrm( rSh.GetAnyCurRect( RECT_FLY_EMBEDDED, 0, GetObject() )),
+ aPrt( rSh.GetAnyCurRect( RECT_FLY_PRT_EMBEDDED, 0, GetObject() ));
+ aLogRect.SetPos( aPrt.Pos() + aFrm.Pos() );
+ aLogRect.SetSize( aPrt.SSize() );
+}
+
+void SwOleClient::ObjectAreaChanged()
+{
+ SwWrtShell &rSh = ((SwView*)GetViewShell())->GetWrtShell();
+ SwRect aFrm( rSh.GetAnyCurRect( RECT_FLY_EMBEDDED, 0, GetObject() ));
+ if ( !aFrm.IsOver( rSh.VisArea() ) )
+ rSh.MakeVisible( aFrm );
+}
+
+void SwOleClient::ViewChanged()
+{
+ if ( bInDoVerb )
+ return;
+
+ 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;
+ }
+
+ SwWrtShell &rSh = ((SwView*)GetViewShell())->GetWrtShell();
+
+ // Adjust the size of the object in the core. The Scaling must
+ // be considered. Repercussions on the object are considered by
+ // CalcAndSetScale() of the WrtShell if the size / position of
+ // the frame in the core changes.
+
+ // TODO/LEAN: getMapUnit can switch object to running state
+ awt::Size aSz;
+ try
+ {
+ aSz = GetObject()->getVisualAreaSize( GetAspect() );
+ }
+ catch (const embed::NoVisualAreaSizeException&)
+ {
+ // Nothing will be done
+ }
+ catch (const uno::Exception&)
+ {
+ OSL_FAIL( "Something goes wrong on requesting object size!\n" );
+ }
+
+ Size aVisSize( aSz.Width, aSz.Height );
+
+ // As long as from the object comes no reasonable size
+ // nothing can be scaled.
+ if( !aVisSize.Width() || !aVisSize.Height() )
+ return;
+
+ // first convert to TWIPS before scaling, because scaling factors are calculated for
+ // the TWIPS mapping and so they will produce the best results if applied to TWIPS based
+ // coordinates
+ const MapMode aMyMap ( MAP_TWIP );
+ const MapMode aObjMap( VCLUnoHelper::UnoEmbed2VCLMapUnit( GetObject()->getMapUnit( GetAspect() ) ) );
+ aVisSize = OutputDevice::LogicToLogic( aVisSize, aObjMap, aMyMap );
+
+ aVisSize.Width() = Fraction( aVisSize.Width() ) * GetScaleWidth();
+ aVisSize.Height()= Fraction( aVisSize.Height() ) * GetScaleHeight();
+
+ SwRect aRect( Point( LONG_MIN, LONG_MIN ), aVisSize );
+ rSh.LockView( sal_True ); // Prevent scrolling in the EndAction
+ rSh.StartAllAction();
+ rSh.RequestObjectResize( aRect, GetObject() );
+ rSh.EndAllAction();
+ rSh.LockView( sal_False );
+}
+
+void SwOleClient::MakeVisible()
+{
+ const SwWrtShell &rSh = ((SwView*)GetViewShell())->GetWrtShell();
+ rSh.MakeObjVisible( GetObject() );
+}
+
+void SwOleClient::FormatChanged()
+{
+ const uno::Reference < embed::XEmbeddedObject >& xObj( GetObject() );
+ SwView * pView = dynamic_cast< SwView * >( GetViewShell() );
+ if ( pView && xObj.is() && SotExchange::IsMath( xObj->getClassID() ) )
+ {
+ SwWrtShell & rWrtSh = pView->GetWrtShell();
+ if (rWrtSh.GetDoc()->get( IDocumentSettingAccess::MATH_BASELINE_ALIGNMENT ))
+ rWrtSh.AlignFormulaToBaseline( xObj );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/uiview/uivwimp.cxx b/sw/source/core/uibase/uiview/uivwimp.cxx
new file mode 100644
index 000000000000..6c6c1911d74e
--- /dev/null
+++ b/sw/source/core/uibase/uiview/uivwimp.cxx
@@ -0,0 +1,305 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <cmdid.h>
+#include "globals.hrc"
+
+#include <tools/shl.hxx>
+#include <com/sun/star/scanner/XScannerManager2.hpp>
+#include <com/sun/star/datatransfer/clipboard/XClipboardNotifier.hpp>
+#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <comphelper/processfactory.hxx>
+#include <osl/mutex.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/wrkwin.hxx>
+#include <vcl/msgbox.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/bindings.hxx>
+
+#include <sfx2/docinsert.hxx>
+#include <sfx2/request.hxx>
+#include <uivwimp.hxx>
+#include <wview.hxx>
+#include <unotxvw.hxx>
+#include <unodispatch.hxx>
+#include <swmodule.hxx>
+#include <swdtflvr.hxx>
+#include <edtwin.hxx>
+#include <mmconfigitem.hxx>
+
+#include <view.hrc>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::scanner;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::datatransfer::clipboard;
+
+SwView_Impl::SwView_Impl(SwView* pShell) :
+ pxXTextView(new uno::Reference<view::XSelectionSupplier>),
+ pView(pShell),
+ eShellMode(SHELL_MODE_TEXT),
+ pConfigItem(0),
+ nMailMergeRestartPage(0),
+ bMailMergeSourceView(sal_True),
+ m_pDocInserter(NULL),
+ m_pRequest(NULL),
+ m_bSelectObject(false),
+ m_bEditingPositionSet(false)
+{
+ *pxXTextView = new SwXTextView(pView);
+ xDisProvInterceptor = new SwXDispatchProviderInterceptor(*pView);
+}
+
+SwView_Impl::~SwView_Impl()
+{
+ Reference<XUnoTunnel> xDispTunnel(xDisProvInterceptor, UNO_QUERY);
+ SwXDispatchProviderInterceptor* pInterceptor = 0;
+ if(xDispTunnel.is() &&
+ 0 != (pInterceptor = reinterpret_cast< SwXDispatchProviderInterceptor * >(
+ sal::static_int_cast< sal_IntPtr >(
+ xDispTunnel->getSomething(SwXDispatchProviderInterceptor::getUnoTunnelId())))))
+ {
+ pInterceptor->Invalidate();
+ }
+ view::XSelectionSupplier* pTextView = pxXTextView->get();
+ ((SwXTextView*)pTextView)->Invalidate();
+ delete pxXTextView;
+ if( xScanEvtLstnr.is() )
+ pScanEvtLstnr->ViewDestroyed();
+ if( xClipEvtLstnr.is() )
+ {
+ pClipEvtLstnr->AddRemoveListener( sal_False );
+ pClipEvtLstnr->ViewDestroyed();
+ }
+ delete pConfigItem;
+
+ delete m_pDocInserter;
+ delete m_pRequest;
+}
+
+void SwView_Impl::SetShellMode(ShellModes eSet)
+{
+ eShellMode = eSet;
+}
+
+view::XSelectionSupplier* SwView_Impl::GetUNOObject()
+{
+ return pxXTextView->get();
+}
+
+SwXTextView* SwView_Impl::GetUNOObject_Impl()
+{
+ view::XSelectionSupplier* pTextView = pxXTextView->get();
+ return ((SwXTextView*)pTextView);
+}
+
+void SwView_Impl::ExecuteScan( SfxRequest& rReq )
+{
+ sal_uInt16 nSlot = rReq.GetSlot();
+ switch(nSlot)
+ {
+ case SID_TWAIN_SELECT:
+ {
+ sal_Bool bDone = sal_False;
+ Reference< XScannerManager2 > xScanMgr = SW_MOD()->GetScannerManager();
+
+ if( xScanMgr.is() )
+ {
+ try
+ {
+ SwScannerEventListener& rListener = GetScannerEventListener();
+ const Sequence< ScannerContext >
+ aContexts( xScanMgr->getAvailableScanners() );
+
+ if( aContexts.getLength() )
+ {
+ Reference< XEventListener > xLstner = &rListener;
+ ScannerContext aContext( aContexts.getConstArray()[ 0 ] );
+ bDone = xScanMgr->configureScannerAndScan( aContext, xLstner );
+ }
+ }
+ catch(...)
+ {
+ }
+
+ }
+ if( bDone )
+ rReq.Done();
+ else
+ {
+ rReq.Ignore();
+ }
+ }
+ break;
+
+ case SID_TWAIN_TRANSFER:
+ {
+ bool bDone = false;
+
+ Reference< XScannerManager2 > xScanMgr = SW_MOD()->GetScannerManager();
+ if( xScanMgr.is() )
+ {
+ SwScannerEventListener& rListener = GetScannerEventListener();
+ try
+ {
+ const Sequence< scanner::ScannerContext >aContexts( xScanMgr->getAvailableScanners() );
+ if( aContexts.getLength() )
+ {
+ Reference< XEventListener > xLstner = &rListener;
+ xScanMgr->startScan( aContexts.getConstArray()[ 0 ], xLstner );
+ bDone = true;
+ }
+ }
+ catch(...)
+ {
+ }
+ }
+
+ if( !bDone )
+ {
+ InfoBox( 0, SW_RES(MSG_SCAN_NOSOURCE) ).Execute();
+ rReq.Ignore();
+ }
+ else
+ {
+ rReq.Done();
+ SfxBindings& rBind = pView->GetViewFrame()->GetBindings();
+ rBind.Invalidate( SID_TWAIN_SELECT );
+ rBind.Invalidate( SID_TWAIN_TRANSFER );
+ }
+ }
+ break;
+ }
+}
+
+SwScannerEventListener& SwView_Impl::GetScannerEventListener()
+{
+ if(!xScanEvtLstnr.is())
+ xScanEvtLstnr = pScanEvtLstnr = new SwScannerEventListener(*pView);
+ return *pScanEvtLstnr;
+}
+
+void SwView_Impl::AddClipboardListener()
+{
+ if(!xClipEvtLstnr.is())
+ {
+ xClipEvtLstnr = pClipEvtLstnr = new SwClipboardChangeListener( *pView );
+ pClipEvtLstnr->AddRemoveListener( sal_True );
+ }
+}
+
+void SwView_Impl::Invalidate()
+{
+ GetUNOObject_Impl()->Invalidate();
+ Reference< XUnoTunnel > xTunnel(xTransferable.get(), UNO_QUERY);
+ if(xTunnel.is())
+
+ {
+ SwTransferable* pTransferable = reinterpret_cast< SwTransferable * >(
+ sal::static_int_cast< sal_IntPtr >(
+ xTunnel->getSomething(SwTransferable::getUnoTunnelId())));
+ if(pTransferable)
+ pTransferable->Invalidate();
+ }
+}
+
+void SwView_Impl::AddTransferable(SwTransferable& rTransferable)
+{
+ //prevent removing of the non-referenced SwTransferable
+ rTransferable.m_refCount++;
+ {
+ xTransferable = Reference<XUnoTunnel> (&rTransferable);
+ }
+ rTransferable.m_refCount--;
+}
+
+void SwView_Impl::StartDocumentInserter( const OUString& rFactory, const Link& rEndDialogHdl )
+{
+ delete m_pDocInserter;
+ m_pDocInserter = new ::sfx2::DocumentInserter( rFactory );
+ m_pDocInserter->StartExecuteModal( rEndDialogHdl );
+}
+
+SfxMedium* SwView_Impl::CreateMedium()
+{
+ return m_pDocInserter->CreateMedium();
+}
+
+void SwView_Impl::InitRequest( const SfxRequest& rRequest )
+{
+ delete m_pRequest;
+ m_pRequest = new SfxRequest( rRequest );
+}
+
+SwScannerEventListener::~SwScannerEventListener()
+{
+}
+
+void SAL_CALL SwScannerEventListener::disposing( const EventObject& rEventObject) throw(uno::RuntimeException, std::exception)
+{
+#if defined WNT || defined UNX
+ SolarMutexGuard aGuard;
+ if( pView )
+ pView->ScannerEventHdl( rEventObject );
+#endif
+}
+
+SwClipboardChangeListener::~SwClipboardChangeListener()
+{
+}
+
+void SAL_CALL SwClipboardChangeListener::disposing( const EventObject& /*rEventObject*/ )
+ throw ( RuntimeException, std::exception )
+{
+}
+
+void SAL_CALL SwClipboardChangeListener::changedContents( const ::com::sun::star::datatransfer::clipboard::ClipboardEvent& rEventObject )
+ throw (RuntimeException, std::exception)
+
+{
+ const SolarMutexGuard aGuard;
+ if( pView )
+ {
+ {
+ TransferableDataHelper aDataHelper( rEventObject.Contents );
+ SwWrtShell& rSh = pView->GetWrtShell();
+
+ pView->m_nLastPasteDestination = SwTransferable::GetSotDestination( rSh );
+ pView->m_bPasteState = aDataHelper.GetXTransferable().is() &&
+ SwTransferable::IsPaste( rSh, aDataHelper );
+
+ pView->m_bPasteSpecialState = aDataHelper.GetXTransferable().is() &&
+ SwTransferable::IsPasteSpecial( rSh, aDataHelper );
+ }
+
+ SfxBindings& rBind = pView->GetViewFrame()->GetBindings();
+ rBind.Invalidate( SID_PASTE );
+ rBind.Invalidate( SID_PASTE_SPECIAL );
+ rBind.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS );
+ }
+}
+
+void SwClipboardChangeListener::AddRemoveListener( sal_Bool bAdd )
+{
+ pView->AddRemoveClipboardListener( Reference< XClipboardListener >( this ), bAdd );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/uiview/view.cxx b/sw/source/core/uibase/uiview/view.cxx
new file mode 100644
index 000000000000..868ae5d5e18b
--- /dev/null
+++ b/sw/source/core/uibase/uiview/view.cxx
@@ -0,0 +1,1822 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <config_features.h>
+
+#include <string>
+#include <stdlib.h>
+#include <hintids.hxx>
+#include <comphelper/string.hxx>
+#include <officecfg/Office/Common.hxx>
+#include <vcl/graph.hxx>
+#include <vcl/inputctx.hxx>
+#include <basic/sbxobj.hxx>
+#include <svl/eitem.hxx>
+#include <unotools/lingucfg.hxx>
+#include <unotools/useroptions.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/printer.hxx>
+#include <sfx2/app.hxx>
+#include <svx/ruler.hxx>
+#include <editeng/protitem.hxx>
+#include <svx/fmshell.hxx>
+#include <svx/extrusionbar.hxx>
+#include <svx/fontworkbar.hxx>
+#include <unotxvw.hxx>
+#include <cmdid.h>
+#include <swhints.hxx>
+#include <swmodule.hxx>
+#include <inputwin.hxx>
+#include <chartins.hxx>
+#include <uivwimp.hxx>
+#include <uitool.hxx>
+#include <edtwin.hxx>
+#include <textsh.hxx>
+#include <listsh.hxx>
+#include <tabsh.hxx>
+#include <grfsh.hxx>
+#include <mediash.hxx>
+#include <docsh.hxx>
+#include <frmsh.hxx>
+#include <olesh.hxx>
+#include <drawsh.hxx>
+#include <drawbase.hxx>
+#include <drformsh.hxx>
+#include <drwtxtsh.hxx>
+#include <beziersh.hxx>
+#include <navsh.hxx>
+#include <globdoc.hxx>
+#include <scroll.hxx>
+#include <navipi.hxx>
+#include <gloshdl.hxx>
+#include <usrpref.hxx>
+#include <srcview.hxx>
+#include <doc.hxx>
+#include <IDocumentUndoRedo.hxx>
+#include <drawdoc.hxx>
+#include <wdocsh.hxx>
+#include <wview.hxx>
+#include <workctrl.hxx>
+#include <wrtsh.hxx>
+#include <barcfg.hxx>
+#include <pview.hxx>
+#include <swdtflvr.hxx>
+#include <view.hrc>
+#include <globdoc.hrc>
+#include <frmui.hrc>
+#include <cfgitems.hxx>
+#include <prtopt.hxx>
+#include <linguistic/lngprops.hxx>
+#include <editeng/unolingu.hxx>
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#include <com/sun/star/scanner/ScannerContext.hpp>
+#include <com/sun/star/scanner/XScannerManager2.hpp>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <sax/tools/converter.hxx>
+
+#include "formatclipboard.hxx"
+#include <PostItMgr.hxx>
+#include <annotsh.hxx>
+#include <swruler.hxx>
+
+#include <fldbas.hxx>
+
+#include <unomid.h>
+
+#include <com/sun/star/document/XDocumentProperties.hpp>
+#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
+
+#include <svl/cjkoptions.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::scanner;
+
+extern bool bNoInterrupt; // in mainwn.cxx
+
+#define SWVIEWFLAGS ( SFX_VIEW_CAN_PRINT| \
+ SFX_VIEW_HAS_PRINTOPTIONS)
+
+// Statics
+
+int bDocSzUpdated = 1;
+
+SvxSearchItem* SwView::m_pSrchItem = 0;
+
+sal_uInt16 SwView::m_nInsertCtrlState = FN_INSERT_TABLE;
+sal_uInt16 SwView::m_nWebInsertCtrlState = FN_INSERT_TABLE;
+sal_uInt16 SwView::m_nInsertObjectCtrlState = SID_INSERT_DIAGRAM;
+
+bool SwView::m_bExtra = false;
+sal_Bool SwView::m_bFound = sal_False;
+bool SwView::m_bJustOpened = false;
+
+SvxSearchDialog* SwView::m_pSrchDlg = 0;
+SearchAttrItemList* SwView::m_pSrchList = 0;
+SearchAttrItemList* SwView::m_pReplList = 0;
+
+DBG_NAME(viewhdl)
+
+inline SfxDispatcher &SwView::GetDispatcher()
+{
+ return *GetViewFrame()->GetDispatcher();
+}
+
+void SwView::ImpSetVerb( int nSelType )
+{
+ sal_Bool bResetVerbs = m_bVerbsActive;
+ if ( !GetViewFrame()->GetFrame().IsInPlace() &&
+ (nsSelectionType::SEL_OLE|nsSelectionType::SEL_GRF) & nSelType )
+ {
+ if ( !m_pWrtShell->IsSelObjProtected(FLYPROTECT_CONTENT) )
+ {
+ if ( nSelType & nsSelectionType::SEL_OLE )
+ {
+ SetVerbs( GetWrtShell().GetOLEObject()->getSupportedVerbs() );
+ m_bVerbsActive = sal_True;
+ bResetVerbs = sal_False;
+ }
+ }
+ }
+ if ( bResetVerbs )
+ {
+ SetVerbs( Sequence< embed::VerbDescriptor >() );
+ m_bVerbsActive = sal_False;
+ }
+}
+
+// Called by the SwEditWin when it gets the focus.
+
+void SwView::GotFocus() const
+{
+ // if we got the focus, and the form shell *is* on the top of the dispatcher
+ // stack, then we need to rebuild the stack (the form shell doesn't belong to
+ // the top then)
+ const SfxDispatcher& rDispatcher = const_cast< SwView* >( this )->GetDispatcher();
+ SfxShell* pTopShell = rDispatcher.GetShell( 0 );
+ FmFormShell* pAsFormShell = PTR_CAST( FmFormShell, pTopShell );
+ if ( pAsFormShell )
+ {
+ pAsFormShell->ForgetActiveControl();
+ const_cast< SwView* >( this )->AttrChangedNotify( m_pWrtShell );
+ }
+ else if ( m_pPostItMgr )
+ {
+ SwAnnotationShell* pAsAnnotationShell = PTR_CAST( SwAnnotationShell, pTopShell );
+ if ( pAsAnnotationShell )
+ {
+ m_pPostItMgr->SetActiveSidebarWin(0);
+ const_cast< SwView* >( this )->AttrChangedNotify( m_pWrtShell );
+ }
+ }
+ if( GetWrtShellPtr() )
+ {
+ SwWrtShell& rWrtShell = GetWrtShell();
+ rWrtShell.GetDoc()->SetCurrentViewShell( GetWrtShellPtr() );
+ rWrtShell.GetDoc()->set( IDocumentSettingAccess::BROWSE_MODE,
+ rWrtShell.GetViewOptions()->getBrowseMode() );
+ }
+}
+
+// called by the FormShell when a form control is focused. This is
+// a request to put the form shell on the top of the dispatcher stack
+
+IMPL_LINK_NOARG(SwView, FormControlActivated)
+{
+ // if a form control has been activated, and the form shell is not on the top
+ // of the dispatcher stack, then we need to activate it
+ const SfxDispatcher& rDispatcher = GetDispatcher();
+ const SfxShell* pTopShell = rDispatcher.GetShell( 0 );
+ const FmFormShell* pAsFormShell = PTR_CAST( FmFormShell, pTopShell );
+ if ( !pAsFormShell )
+ {
+ // if we're editing text currently, cancel this
+ SdrView *pSdrView = m_pWrtShell ? m_pWrtShell->GetDrawView() : NULL;
+ if ( pSdrView && pSdrView->IsTextEdit() )
+ pSdrView->SdrEndTextEdit( sal_True );
+
+ const_cast< SwView* >( this )->AttrChangedNotify( m_pWrtShell );
+ }
+
+ return 0L;
+}
+
+void SwView::SelectShell()
+{
+
+// Attention: Maintain the SelectShell for the WebView additionally
+
+ if(m_bInDtor)
+ return;
+ // Decision if the UpdateTable has to be called
+ sal_Bool bUpdateTable = sal_False;
+ const SwFrmFmt* pCurTableFmt = m_pWrtShell->GetTableFmt();
+ if(pCurTableFmt && pCurTableFmt != m_pLastTableFormat)
+ {
+ bUpdateTable = sal_True; // can only be executed later
+ }
+ m_pLastTableFormat = pCurTableFmt;
+
+ //SEL_TBL and SEL_TBL_CELLS can be ORed!
+ int nNewSelectionType = (m_pWrtShell->GetSelectionType()
+ & ~nsSelectionType::SEL_TBL_CELLS);
+
+ if ( m_pFormShell && m_pFormShell->IsActiveControl() )
+ nNewSelectionType |= nsSelectionType::SEL_FOC_FRM_CTRL;
+
+ if ( nNewSelectionType == m_nSelectionType )
+ {
+ GetViewFrame()->GetBindings().InvalidateAll( sal_False );
+ if ( m_nSelectionType & nsSelectionType::SEL_OLE ||
+ m_nSelectionType & nsSelectionType::SEL_GRF )
+ // For graphs and OLE the verb can be modified of course!
+ ImpSetVerb( nNewSelectionType );
+ }
+ else
+ {
+
+ SfxDispatcher &rDispatcher = GetDispatcher();
+ SwToolbarConfigItem *pBarCfg = SW_MOD()->GetToolbarConfig();
+
+ if ( m_pShell )
+ {
+ rDispatcher.Flush(); // Really erase all cached shells
+ //Remember to the old selection which toolbar was visible
+ sal_uInt16 nId = static_cast< sal_uInt16 >( rDispatcher.GetObjectBarId( SFX_OBJECTBAR_OBJECT ));
+ if ( nId )
+ pBarCfg->SetTopToolbar( m_nSelectionType, nId );
+
+ SfxShell *pSfxShell;
+ for ( sal_uInt16 i = 0; true; ++i )
+ {
+ pSfxShell = rDispatcher.GetShell( i );
+ if ( pSfxShell->ISA( SwBaseShell )
+ || pSfxShell->ISA( SwDrawTextShell )
+ || pSfxShell->ISA( svx::ExtrusionBar )
+ || pSfxShell->ISA( svx::FontworkBar )
+ || pSfxShell->ISA( SwAnnotationShell )
+ )
+ {
+ rDispatcher.Pop( *pSfxShell, SFX_SHELL_POP_DELETE );
+ }
+ else if ( pSfxShell->ISA( FmFormShell ) )
+ {
+ rDispatcher.Pop( *pSfxShell );
+ }
+ else
+ break;
+ }
+ }
+
+ sal_Bool bInitFormShell = sal_False;
+ if (!m_pFormShell)
+ {
+ bInitFormShell = sal_True;
+ m_pFormShell = new FmFormShell( this );
+ m_pFormShell->SetControlActivationHandler( LINK( this, SwView, FormControlActivated ) );
+ StartListening(*m_pFormShell);
+ }
+
+ sal_Bool bSetExtInpCntxt = sal_False;
+ m_nSelectionType = nNewSelectionType;
+ ShellModes eShellMode;
+
+ if ( !( m_nSelectionType & nsSelectionType::SEL_FOC_FRM_CTRL ) )
+ rDispatcher.Push( *m_pFormShell );
+
+ eShellMode = SHELL_MODE_NAVIGATION;
+ m_pShell = new SwNavigationShell( *this );
+ rDispatcher.Push( *m_pShell );
+
+ if ( m_nSelectionType & nsSelectionType::SEL_OLE )
+ {
+ eShellMode = SHELL_MODE_OBJECT;
+ m_pShell = new SwOleShell( *this );
+ rDispatcher.Push( *m_pShell );
+ }
+ else if ( m_nSelectionType & nsSelectionType::SEL_FRM
+ || m_nSelectionType & nsSelectionType::SEL_GRF)
+ {
+ eShellMode = SHELL_MODE_FRAME;
+ m_pShell = new SwFrameShell( *this );
+ rDispatcher.Push( *m_pShell );
+ if(m_nSelectionType & nsSelectionType::SEL_GRF )
+ {
+ eShellMode = SHELL_MODE_GRAPHIC;
+ m_pShell = new SwGrfShell( *this );
+ rDispatcher.Push( *m_pShell );
+ }
+ }
+ else if ( m_nSelectionType & nsSelectionType::SEL_DRW )
+ {
+ eShellMode = SHELL_MODE_DRAW;
+ m_pShell = new SwDrawShell( *this );
+ rDispatcher.Push( *m_pShell );
+
+ if ( m_nSelectionType & nsSelectionType::SEL_BEZ )
+ {
+ eShellMode = SHELL_MODE_BEZIER;
+ m_pShell = new SwBezierShell( *this );
+ rDispatcher.Push( *m_pShell );
+ }
+ else if( m_nSelectionType & nsSelectionType::SEL_MEDIA )
+ {
+ eShellMode = SHELL_MODE_MEDIA;
+ m_pShell = new SwMediaShell( *this );
+ rDispatcher.Push( *m_pShell );
+ }
+
+ if (m_nSelectionType & nsSelectionType::SEL_EXTRUDED_CUSTOMSHAPE)
+ {
+ eShellMode = SHELL_MODE_EXTRUDED_CUSTOMSHAPE;
+ m_pShell = new svx::ExtrusionBar(this);
+ rDispatcher.Push( *m_pShell );
+ }
+ if (m_nSelectionType & nsSelectionType::SEL_FONTWORK)
+ {
+ eShellMode = SHELL_MODE_FONTWORK;
+ m_pShell = new svx::FontworkBar(this);
+ rDispatcher.Push( *m_pShell );
+ }
+ }
+ else if ( m_nSelectionType & nsSelectionType::SEL_DRW_FORM )
+ {
+ eShellMode = SHELL_MODE_DRAW_FORM;
+ m_pShell = new SwDrawFormShell( *this );
+
+ rDispatcher.Push( *m_pShell );
+ }
+ else if ( m_nSelectionType & nsSelectionType::SEL_DRW_TXT )
+ {
+ bSetExtInpCntxt = sal_True;
+ eShellMode = SHELL_MODE_DRAWTEXT;
+ rDispatcher.Push( *(new SwBaseShell( *this )) );
+ m_pShell = new SwDrawTextShell( *this );
+ rDispatcher.Push( *m_pShell );
+ }
+ else if ( m_nSelectionType & nsSelectionType::SEL_POSTIT )
+ {
+ eShellMode = SHELL_MODE_POSTIT;
+ m_pShell = new SwAnnotationShell( *this );
+ rDispatcher.Push( *m_pShell );
+ }
+ else
+ {
+ bSetExtInpCntxt = sal_True;
+ eShellMode = SHELL_MODE_TEXT;
+ sal_uInt32 nHelpId = 0;
+ if ( m_nSelectionType & nsSelectionType::SEL_NUM )
+ {
+ eShellMode = SHELL_MODE_LIST_TEXT;
+ m_pShell = new SwListShell( *this );
+ nHelpId = m_pShell->GetHelpId();
+ rDispatcher.Push( *m_pShell );
+ }
+ m_pShell = new SwTextShell(*this);
+ if(nHelpId)
+ m_pShell->SetHelpId(nHelpId);
+ rDispatcher.Push( *m_pShell );
+ if ( m_nSelectionType & nsSelectionType::SEL_TBL )
+ {
+ eShellMode = eShellMode == SHELL_MODE_LIST_TEXT ? SHELL_MODE_TABLE_LIST_TEXT
+ : SHELL_MODE_TABLE_TEXT;
+ m_pShell = new SwTableShell( *this );
+ rDispatcher.Push( *m_pShell );
+ }
+ }
+
+ if ( m_nSelectionType & nsSelectionType::SEL_FOC_FRM_CTRL )
+ rDispatcher.Push( *m_pFormShell );
+
+ m_pViewImpl->SetShellMode(eShellMode);
+ ImpSetVerb( m_nSelectionType );
+
+ if( !GetDocShell()->IsReadOnly() )
+ {
+ if( bSetExtInpCntxt && GetWrtShell().HasReadonlySel() )
+ bSetExtInpCntxt = sal_False;
+
+ InputContext aCntxt( GetEditWin().GetInputContext() );
+ aCntxt.SetOptions( bSetExtInpCntxt
+ ? (aCntxt.GetOptions() |
+ ( INPUTCONTEXT_TEXT |
+ INPUTCONTEXT_EXTTEXTINPUT ))
+ : (aCntxt.GetOptions() & ~
+ ( INPUTCONTEXT_TEXT |
+ INPUTCONTEXT_EXTTEXTINPUT )) );
+ GetEditWin().SetInputContext( aCntxt );
+ }
+
+ // Activate the toolbar to the new selection which also was active last time.
+ // Before a flush () must be, but does not affect the UI according to MBA and
+ // is not a performance problem.
+ // TODO/LATER: maybe now the Flush() command is superfluous?!
+ rDispatcher.Flush();
+
+ Point aPnt = GetEditWin().OutputToScreenPixel(GetEditWin().GetPointerPosPixel());
+ aPnt = GetEditWin().PixelToLogic(aPnt);
+ GetEditWin().UpdatePointer(aPnt);
+
+ SdrView* pDView = GetWrtShell().GetDrawView();
+ if ( bInitFormShell && pDView )
+ m_pFormShell->SetView(PTR_CAST(FmFormView, pDView));
+
+ }
+ // Opportune time for the communication with OLE objects?
+ if ( GetDocShell()->GetDoc()->IsOLEPrtNotifyPending() )
+ GetDocShell()->GetDoc()->PrtOLENotify( sal_False );
+
+ // now the table-update
+ if(bUpdateTable)
+ m_pWrtShell->UpdateTable();
+
+ GetViewImpl()->GetUNOObject_Impl()->NotifySelChanged();
+}
+
+// Interaction: AttrChangedNotify() and TimeoutHdl.
+// No Update if actions are still open, since the cursor on the core side
+// can be somewhere in no man's land.
+// But since we can no longer supply status and we want instead lock
+// the dispatcher.
+
+extern "C"
+{
+ static int lcl_CmpIds( const void *pFirst, const void *pSecond)
+ {
+ return (*(sal_uInt16*)pFirst) - (*(sal_uInt16*)pSecond);
+ }
+}
+
+IMPL_LINK_NOARG(SwView, AttrChangedNotify)
+{
+ if ( GetEditWin().IsChainMode() )
+ GetEditWin().SetChainMode( sal_False );
+
+ //Opt: Not if PaintLocked. During unlock a notify will be once more triggered.
+ if( !m_pWrtShell->IsPaintLocked() && !bNoInterrupt &&
+ GetDocShell()->IsReadOnly() )
+ _CheckReadonlyState();
+
+ if( !m_pWrtShell->IsPaintLocked() && !bNoInterrupt )
+ _CheckReadonlySelection();
+
+ if( !m_bAttrChgNotified )
+ {
+ if ( m_pWrtShell->BasicActionPend() || bNoInterrupt ||
+ GetDispatcher().IsLocked() || //do not confuse the SFX
+ GetViewFrame()->GetBindings().IsInUpdate() )//do not confuse the SFX
+ {
+ m_bAttrChgNotified = sal_True;
+ m_aTimer.Start();
+
+ const SfxPoolItem *pItem;
+ if ( SFX_ITEM_SET != GetObjectShell()->GetMedium()->GetItemSet()->
+ GetItemState( SID_HIDDEN, false, &pItem ) ||
+ !((SfxBoolItem*)pItem)->GetValue() )
+ {
+ GetViewFrame()->GetBindings().ENTERREGISTRATIONS();
+ m_bAttrChgNotifiedWithRegistrations = sal_True;
+ }
+
+ }
+ else
+ SelectShell();
+
+ }
+
+ // change ui if cursor is at a SwPostItField
+ if (m_pPostItMgr)
+ {
+ // only perform the code that is needed to determine, if at the
+ // actual cursor position is a post-it field
+ m_pPostItMgr->SetShadowState( m_pWrtShell->GetPostItFieldAtCursor() );
+ }
+
+ return 0;
+}
+
+IMPL_LINK_NOARG(SwView, TimeoutHdl)
+{
+ DBG_PROFSTART(viewhdl);
+
+ if( m_pWrtShell->BasicActionPend() || bNoInterrupt )
+ {
+ m_aTimer.Start();
+ DBG_PROFSTOP(viewhdl);
+ return 0;
+ }
+
+ if ( m_bAttrChgNotifiedWithRegistrations )
+ {
+ GetViewFrame()->GetBindings().LEAVEREGISTRATIONS();
+ m_bAttrChgNotifiedWithRegistrations = sal_False;
+ }
+
+ _CheckReadonlyState();
+ _CheckReadonlySelection();
+
+ sal_Bool bOldUndo = m_pWrtShell->DoesUndo();
+ m_pWrtShell->DoUndo( sal_False );
+ SelectShell();
+ m_pWrtShell->DoUndo( bOldUndo );
+ m_bAttrChgNotified = sal_False;
+ GetViewImpl()->GetUNOObject_Impl()->NotifySelChanged();
+
+ DBG_PROFSTOP(viewhdl);
+ return 0;
+}
+
+void SwView::_CheckReadonlyState()
+{
+ SfxDispatcher &rDis = GetDispatcher();
+ // To be able to recognize if it is already disabled!
+ SfxItemState eStateRO, eStateProtAll;
+ const SfxPoolItem *pItem;
+ // Query the status from a slot which is only known to us.
+ // Otherwise the slot is known from other; like the BasidIde
+ eStateRO = rDis.QueryState( FN_INSERT_BOOKMARK, pItem );
+ eStateProtAll = rDis.QueryState( FN_EDIT_REGION, pItem );
+ sal_Bool bChgd = sal_False;
+
+ if ( !m_pWrtShell->IsCrsrReadonly() )
+ {
+ static sal_uInt16 aROIds[] =
+ {
+ SID_DELETE, FN_BACKSPACE, FN_SHIFT_BACKSPACE,
+ SID_UNDO,
+ SID_REDO, SID_REPEAT, SID_PASTE,
+ SID_PASTE_UNFORMATTED,
+ SID_PASTE_SPECIAL, SID_SBA_BRW_INSERT,
+ SID_BACKGROUND_COLOR, FN_INSERT_BOOKMARK,
+ SID_CHARMAP, FN_INSERT_SOFT_HYPHEN,
+ FN_INSERT_HARDHYPHEN, FN_INSERT_HARD_SPACE, FN_INSERT_BREAK,
+ FN_INSERT_LINEBREAK, FN_INSERT_COLUMN_BREAK, FN_INSERT_BREAK_DLG,
+ FN_DELETE_SENT, FN_DELETE_BACK_SENT, FN_DELETE_WORD,
+ FN_DELETE_BACK_WORD, FN_DELETE_LINE, FN_DELETE_BACK_LINE,
+ FN_DELETE_PARA, FN_DELETE_BACK_PARA, FN_DELETE_WHOLE_LINE,
+ FN_CALCULATE, FN_FORMAT_RESET,
+ FN_POSTIT, FN_JAVAEDIT, SID_ATTR_PARA_ADJUST_LEFT,
+ SID_ATTR_PARA_ADJUST_RIGHT, SID_ATTR_PARA_ADJUST_CENTER,SID_ATTR_PARA_ADJUST_BLOCK,
+ SID_ATTR_PARA_LINESPACE_10, SID_ATTR_PARA_LINESPACE_15, SID_ATTR_PARA_LINESPACE_20,
+ SID_ATTR_CHAR_FONT, SID_ATTR_CHAR_FONTHEIGHT, SID_ATTR_CHAR_COLOR_BACKGROUND,
+ SID_ATTR_CHAR_COLOR_BACKGROUND_EXT, SID_ATTR_CHAR_COLOR_EXT,
+ SID_ATTR_CHAR_COLOR, SID_ATTR_CHAR_WEIGHT, SID_ATTR_CHAR_POSTURE,
+ SID_ATTR_CHAR_OVERLINE,
+ SID_ATTR_CHAR_UNDERLINE, SID_ATTR_FLASH, SID_ATTR_CHAR_STRIKEOUT,
+ FN_UNDERLINE_DOUBLE, SID_ATTR_CHAR_CONTOUR, SID_ATTR_CHAR_SHADOWED,
+ SID_ATTR_CHAR_AUTOKERN, SID_ATTR_CHAR_ESCAPEMENT, FN_SET_SUPER_SCRIPT,
+ FN_SET_SUB_SCRIPT, SID_ATTR_CHAR_CASEMAP, SID_ATTR_CHAR_LANGUAGE,
+ SID_ATTR_CHAR_KERNING, SID_CHAR_DLG, SID_ATTR_CHAR_WORDLINEMODE,
+ FN_GROW_FONT_SIZE, FN_SHRINK_FONT_SIZE, FN_TXTATR_INET,
+ FN_FORMAT_DROPCAPS, SID_ATTR_PARA_ADJUST, SID_ATTR_PARA_LINESPACE,
+ SID_ATTR_PARA_SPLIT, SID_ATTR_PARA_KEEP, SID_ATTR_PARA_WIDOWS,
+ SID_ATTR_PARA_ORPHANS,
+ SID_ATTR_PARA_MODEL, SID_PARA_DLG,
+ FN_SELECT_PARA, SID_DEC_INDENT,
+ SID_INC_INDENT
+ };
+ static sal_Bool bFirst = sal_True;
+ if ( bFirst )
+ {
+ qsort( (void*)aROIds, sizeof(aROIds)/sizeof(sal_uInt16), sizeof(sal_uInt16), lcl_CmpIds );
+ bFirst = sal_False;
+ }
+ if ( SFX_ITEM_DISABLED == eStateRO )
+ {
+ rDis.SetSlotFilter( sal_Bool(2), sizeof(aROIds)/sizeof(sal_uInt16), aROIds );
+ bChgd = sal_True;
+ }
+ }
+ else if( m_pWrtShell->IsAllProtect() )
+ {
+ if ( SFX_ITEM_DISABLED == eStateProtAll )
+ {
+ static sal_uInt16 aAllProtIds[] = { SID_SAVEDOC, FN_EDIT_REGION };
+ static sal_Bool bAllProtFirst = sal_True;
+ if ( bAllProtFirst )
+ {
+ qsort( (void*)aAllProtIds, sizeof(aAllProtIds)/sizeof(sal_uInt16), sizeof(sal_uInt16), lcl_CmpIds );
+ bAllProtFirst = sal_False;
+ }
+ rDis.SetSlotFilter( sal_Bool(2),
+ sizeof(aAllProtIds)/sizeof(sal_uInt16),
+ aAllProtIds );
+ bChgd = sal_True;
+ }
+ }
+ else if ( SFX_ITEM_DISABLED != eStateRO ||
+ SFX_ITEM_DISABLED != eStateProtAll )
+ {
+ bChgd = sal_True;
+ rDis.SetSlotFilter();
+ }
+ if ( bChgd )
+ GetViewFrame()->GetBindings().InvalidateAll(sal_True);
+}
+
+void SwView::_CheckReadonlySelection()
+{
+ sal_uInt32 nDisableFlags = 0;
+ SfxDispatcher &rDis = GetDispatcher();
+
+ if( m_pWrtShell->HasReadonlySel(m_bAnnotationMode) &&
+ ( !m_pWrtShell->GetDrawView() ||
+ !m_pWrtShell->GetDrawView()->GetMarkedObjectList().GetMarkCount() ))
+ nDisableFlags |= SW_DISABLE_ON_PROTECTED_CURSOR;
+
+ if( (SW_DISABLE_ON_PROTECTED_CURSOR & nDisableFlags ) !=
+ (SW_DISABLE_ON_PROTECTED_CURSOR & rDis.GetDisableFlags() ) )
+ {
+ // Additionally move at the Window the InputContext, so that
+ // in japanese / chinese versions the external input will be
+ // turned on or off. This but only if the correct shell is on
+ // the stack.
+ switch( m_pViewImpl->GetShellMode() )
+ {
+ case SHELL_MODE_TEXT:
+ case SHELL_MODE_LIST_TEXT:
+ case SHELL_MODE_TABLE_TEXT:
+ case SHELL_MODE_TABLE_LIST_TEXT:
+ {
+// Temporary solution!!! Should set the font of the current insertion point
+// at each cursor movement, so outside of this "if". But TH does not
+// evaluates the font at this time and the "purchase" appears to me
+// as too expensive.
+// Moreover, we don't have a font, but only attributes from which the
+// text formatting and the correct font will be build together.
+
+ InputContext aCntxt( GetEditWin().GetInputContext() );
+ aCntxt.SetOptions( SW_DISABLE_ON_PROTECTED_CURSOR & nDisableFlags
+ ? (aCntxt.GetOptions() & ~
+ ( INPUTCONTEXT_TEXT |
+ INPUTCONTEXT_EXTTEXTINPUT ))
+ : (aCntxt.GetOptions() |
+ ( INPUTCONTEXT_TEXT |
+ INPUTCONTEXT_EXTTEXTINPUT )) );
+ GetEditWin().SetInputContext( aCntxt );
+ }
+ break;
+ default:
+ ;
+ }
+
+ }
+
+ if( nDisableFlags != rDis.GetDisableFlags() )
+ {
+ rDis.SetDisableFlags( nDisableFlags );
+ GetViewFrame()->GetBindings().InvalidateAll( sal_True );
+ }
+}
+
+SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* pOldSh )
+ : SfxViewShell( _pFrame, SWVIEWFLAGS ),
+ m_aPageStr( SW_RES( STR_PAGE )),
+ m_nNewPage(USHRT_MAX),
+ m_nOldPageNum(0),
+ m_pNumRuleNodeFromDoc(0),
+ m_pEditWin( new SwEditWin( &_pFrame->GetWindow(), *this ) ),
+ m_pWrtShell(0),
+ m_pShell(0),
+ m_pFormShell(0),
+ m_pHScrollbar(0),
+ m_pVScrollbar(0),
+ m_pScrollFill(new ScrollBarBox( &_pFrame->GetWindow(), _pFrame->GetFrame().GetParentFrame() ? 0 : WB_SIZEABLE )),
+ m_pVRuler(new SvxRuler(&GetViewFrame()->GetWindow(), m_pEditWin,
+ SVXRULER_SUPPORT_TABS | SVXRULER_SUPPORT_PARAGRAPH_MARGINS_VERTICAL|
+ SVXRULER_SUPPORT_BORDERS | SVXRULER_SUPPORT_REDUCED_METRIC,
+ GetViewFrame()->GetBindings(),
+ WB_VSCROLL | WB_EXTRAFIELD | WB_BORDER )),
+ m_pTogglePageBtn(0),
+ m_pGlosHdl(0),
+ m_pDrawActual(0),
+ m_pLastTableFormat(0),
+ m_pFormatClipboard(new SwFormatClipboard()),
+ m_pPostItMgr(0),
+ m_nSelectionType( INT_MAX ),
+ m_nPageCnt(0),
+ m_nDrawSfxId( USHRT_MAX ),
+ m_nFormSfxId( USHRT_MAX ),
+ m_nLastPasteDestination( 0xFFFF ),
+ m_nLeftBorderDistance( 0 ),
+ m_nRightBorderDistance( 0 ),
+ m_bWheelScrollInProgress(false),
+ m_bInMailMerge(sal_False),
+ m_bInDtor(sal_False),
+ m_bOldShellWasPagePreview(sal_False),
+ m_bIsPreviewDoubleClick(sal_False),
+ m_bAnnotationMode(false)
+{
+ // According to discussion with MBA and further
+ // investigations, no old SfxViewShell will be set as parameter <pOldSh>,
+ // if function "New Window" is performed to open an additional view beside
+ // an already existing one.
+ // If the view is switch from one to another, the 'old' view is given by
+ // parameter <pOldSh>.
+
+ m_bCenterCrsr = m_bTopCrsr = m_bAlwaysShowSel = m_bTabColFromDoc = m_bTabRowFromDoc =
+ m_bSetTabColFromDoc = m_bSetTabRowFromDoc = m_bAttrChgNotified = m_bAttrChgNotifiedWithRegistrations =
+ m_bVerbsActive = m_bDrawRotate = m_bInOuterResizePixel = m_bInInnerResizePixel =
+ m_bPasteState = m_bPasteSpecialState = m_bMakeSelectionVisible = sal_False;
+
+ m_bShowAtResize = m_bDrawSelMode = bDocSzUpdated = sal_True;
+
+ _CreateScrollbar( sal_True );
+ _CreateScrollbar( sal_False );
+
+ m_pViewImpl = new SwView_Impl(this);
+ SetName(OUString("View"));
+ SetWindow( m_pEditWin );
+
+ m_aTimer.SetTimeout( 120 );
+
+ SwDocShell* pDocSh = PTR_CAST( SwDocShell, _pFrame->GetObjectShell() );
+ sal_Bool bOldModifyFlag = pDocSh->IsEnableSetModified();
+ if(bOldModifyFlag)
+ pDocSh->EnableSetModified( sal_False );
+ // HACK: SwDocShell has some cached font info, VCL informs about font updates,
+ // but loading of docs with embedded fonts happens after SwDocShell is created
+ // but before SwEditWin (which handles the VCL event) is created. So update
+ // manually.
+ if( pDocSh->GetDoc()->get( IDocumentSettingAccess::EMBED_FONTS ))
+ pDocSh->UpdateFontList();
+ OSL_ENSURE( pDocSh, "view without DocShell." );
+ SwWebDocShell* pWebDShell = PTR_CAST( SwWebDocShell, pDocSh );
+
+ const SwMasterUsrPref *pUsrPref = SW_MOD()->GetUsrPref(0 != pWebDShell);
+ SwViewOption aUsrPref( *pUsrPref);
+
+ //! get lingu options without loading lingu DLL
+ SvtLinguOptions aLinguOpt;
+ SvtLinguConfig().GetOptions( aLinguOpt );
+ aUsrPref.SetOnlineSpell( aLinguOpt.bIsSpellAuto );
+
+ sal_Bool bOldShellWasSrcView = sal_False;
+
+ // determine if there is an existing view for
+ // document
+ SfxViewShell* pExistingSh = 0;
+ if ( pOldSh )
+ {
+ pExistingSh = pOldSh;
+ // determine type of existing view
+ if( pExistingSh->IsA( TYPE( SwPagePreview ) ) )
+ {
+ m_sSwViewData = ((SwPagePreview*)pExistingSh)->GetPrevSwViewData();
+ m_sNewCrsrPos = ((SwPagePreview*)pExistingSh)->GetNewCrsrPos();
+ m_nNewPage = ((SwPagePreview*)pExistingSh)->GetNewPage();
+ m_bOldShellWasPagePreview = sal_True;
+ m_bIsPreviewDoubleClick = !m_sNewCrsrPos.isEmpty() || m_nNewPage != USHRT_MAX;
+ }
+ else if( pExistingSh->IsA( TYPE( SwSrcView ) ) )
+ bOldShellWasSrcView = sal_True;
+ }
+
+ SAL_INFO( "sw.ui", "before create WrtShell" );
+ if(PTR_CAST( SwView, pExistingSh))
+ {
+ m_pWrtShell = new SwWrtShell( *((SwView*)pExistingSh)->m_pWrtShell,
+ m_pEditWin, *this);
+ }
+ else if( dynamic_cast<SwWrtShell*>( pDocSh->GetDoc()->GetCurrentViewShell() ) )
+ {
+ m_pWrtShell = new SwWrtShell( *(SwWrtShell*)pDocSh->GetDoc()->GetCurrentViewShell(),
+ m_pEditWin, *this);
+ }
+ else
+ {
+ SwDoc& rDoc = *((SwDocShell*)pDocSh)->GetDoc();
+
+ if( !bOldShellWasSrcView && pWebDShell && !m_bOldShellWasPagePreview )
+ aUsrPref.setBrowseMode( sal_True );
+ else
+ aUsrPref.setBrowseMode( rDoc.get(IDocumentSettingAccess::BROWSE_MODE) );
+
+ //For the BrowseMode we do not assume a factor.
+ if( aUsrPref.getBrowseMode() && aUsrPref.GetZoomType() != SVX_ZOOM_PERCENT )
+ {
+ aUsrPref.SetZoomType( SVX_ZOOM_PERCENT );
+ aUsrPref.SetZoom( 100 );
+ }
+ if(pDocSh->IsPreview())
+ {
+ aUsrPref.SetZoomType( SVX_ZOOM_WHOLEPAGE );
+ aUsrPref.SetViewLayoutBookMode( false );
+ aUsrPref.SetViewLayoutColumns( 1 );
+ }
+ m_pWrtShell = new SwWrtShell( rDoc, m_pEditWin, *this, &aUsrPref );
+ // creating an SwView from a SwPagePreview needs to
+ // add the SwViewShell to the ring of the other SwViewShell(s)
+ if(m_bOldShellWasPagePreview)
+ {
+ SwViewShell& rPreviewViewShell = *((SwPagePreview*)pExistingSh)->GetViewShell();
+ m_pWrtShell->MoveTo(&rPreviewViewShell);
+ // to update the field command et.al. if necessary
+ const SwViewOption* pPreviewOpt = rPreviewViewShell.GetViewOptions();
+ if( pPreviewOpt->IsFldName() != aUsrPref.IsFldName() ||
+ pPreviewOpt->IsShowHiddenField() != aUsrPref.IsShowHiddenField() ||
+ pPreviewOpt->IsShowHiddenPara() != aUsrPref.IsShowHiddenPara() ||
+ pPreviewOpt->IsShowHiddenChar() != aUsrPref.IsShowHiddenChar() )
+ rPreviewViewShell.ApplyViewOptions(aUsrPref);
+ // reset design mode at draw view for form
+ // shell, if needed.
+ if ( ((SwPagePreview*)pExistingSh)->ResetFormDesignMode() &&
+ m_pWrtShell->HasDrawView() )
+ {
+ SdrView* pDrawView = m_pWrtShell->GetDrawView();
+ pDrawView->SetDesignMode( ((SwPagePreview*)pExistingSh)->FormDesignModeToReset() );
+ }
+ }
+ }
+ SAL_INFO( "sw.ui", "after create WrtShell" );
+ m_pHRuler = new SwCommentRuler(m_pWrtShell, &GetViewFrame()->GetWindow(), m_pEditWin,
+ SVXRULER_SUPPORT_TABS |
+ SVXRULER_SUPPORT_PARAGRAPH_MARGINS |
+ SVXRULER_SUPPORT_BORDERS |
+ SVXRULER_SUPPORT_NEGATIVE_MARGINS|
+ SVXRULER_SUPPORT_REDUCED_METRIC,
+ GetViewFrame()->GetBindings(),
+ WB_STDRULER | WB_EXTRAFIELD | WB_BORDER);
+
+ // assure that modified state of document
+ // isn't reset, if document is already modified.
+ const bool bIsDocModified = m_pWrtShell->GetDoc()->IsModified();
+
+ // Thus among other things, the HRuler is not displayed in the read-only case.
+ aUsrPref.SetReadonly( m_pWrtShell->GetViewOptions()->IsReadonly() );
+
+ // no margin for OLE!
+ Size aBrwsBorder;
+ if( SFX_CREATE_MODE_EMBEDDED != pDocSh->GetCreateMode() )
+ aBrwsBorder = GetMargin();
+
+ m_pWrtShell->SetBrowseBorder( aBrwsBorder );
+
+ // In CTOR no shell changes may take place, which must be temporarily stored
+ // with the timer. Otherwise, the SFX removes them from the stack!
+ bool bOld = bNoInterrupt;
+ bNoInterrupt = true;
+
+ m_pHRuler->SetActive( sal_True );
+ m_pVRuler->SetActive( sal_True );
+
+ SfxViewFrame* pViewFrame = GetViewFrame();
+ if( pViewFrame->GetFrame().GetParentFrame())
+ {
+ aUsrPref.SetViewHRuler(sal_False);
+ aUsrPref.SetViewVRuler(sal_False);
+ }
+
+ StartListening( *pViewFrame, true );
+ StartListening( *pDocSh, true );
+
+ // Set Zoom-factor from HRuler
+ Fraction aZoomFract( aUsrPref.GetZoom(), 100 );
+ m_pHRuler->SetZoom( aZoomFract );
+ m_pVRuler->SetZoom( aZoomFract );
+ m_pHRuler->SetDoubleClickHdl(LINK( this, SwView, ExecRulerClick ));
+ FieldUnit eMetric = pUsrPref->GetHScrollMetric();
+ m_pHRuler->SetUnit( eMetric );
+
+ eMetric = pUsrPref->GetVScrollMetric();
+ m_pVRuler->SetUnit( eMetric );
+
+ m_pHRuler->SetCharWidth( 371 ); // default character width
+ m_pVRuler->SetLineHeight( 551 ); // default line height
+
+ // Set DocShell
+ pDocSh->SetView( this );
+ SW_MOD()->SetView( this );
+
+ m_pPostItMgr = new SwPostItMgr(this);
+
+ // Check and process the DocSize. Via the handler, the shell could not
+ // be found, because the shell is not known in the SFX management
+ // within the CTOR phase.
+ DocSzChgd( m_pWrtShell->GetDocSize() );
+
+ // Set AttrChangedNotify link
+ m_pWrtShell->SetChgLnk(LINK(this, SwView, AttrChangedNotify));
+
+ if( pDocSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED &&
+ //TODO/LATER: why a cast here?
+ //!((SvEmbeddedObject *)pDocSh)->GetVisArea().IsEmpty() )
+ //SetVisArea( ((SvEmbeddedObject *)pDocSh)->GetVisArea(),sal_False);
+ !pDocSh->GetVisArea(ASPECT_CONTENT).IsEmpty() )
+ SetVisArea( pDocSh->GetVisArea(ASPECT_CONTENT),sal_False);
+
+ SAL_WARN_IF(
+ officecfg::Office::Common::Undo::Steps::get() <= 0,
+ "sw", "/org.openoffice.Office.Common/Undo/Steps <= 0");
+ m_pWrtShell->DoUndo( true );
+
+ const sal_Bool bBrowse = m_pWrtShell->GetViewOptions()->getBrowseMode();
+ // Disable "multiple window"
+ SetNewWindowAllowed(!bBrowse);
+ // End of disabled multiple window
+
+ m_bVScrollbarEnabled = aUsrPref.IsViewVScrollBar();
+ m_bHScrollbarEnabled = aUsrPref.IsViewHScrollBar();
+ m_pHScrollbar->SetAuto(bBrowse);
+ if( aUsrPref.IsViewHRuler() )
+ CreateTab();
+ if( aUsrPref.IsViewVRuler() )
+ CreateVRuler();
+
+ m_pWrtShell->SetUIOptions( aUsrPref );
+ m_pWrtShell->SetReadOnlyAvailable( aUsrPref.IsCursorInProtectedArea() );
+ m_pWrtShell->ApplyAccessiblityOptions(SW_MOD()->GetAccessibilityOptions());
+
+ if( m_pWrtShell->GetDoc()->IsUpdateExpFld() )
+ {
+ if (m_pWrtShell->GetDoc()->containsUpdatableFields())
+ {
+ SET_CURR_SHELL( m_pWrtShell );
+ m_pWrtShell->StartAction();
+ m_pWrtShell->CalcLayout();
+ m_pWrtShell->GetDoc()->UpdateFlds(NULL, false);
+ m_pWrtShell->EndAction();
+ }
+ m_pWrtShell->GetDoc()->SetUpdateExpFldStat( false );
+ }
+
+ // Update all tables if necessary:
+ if( m_pWrtShell->GetDoc()->IsUpdateTOX() )
+ {
+ SfxRequest aSfxRequest( FN_UPDATE_TOX, SFX_CALLMODE_SLOT, GetPool() );
+ Execute( aSfxRequest );
+ m_pWrtShell->GetDoc()->SetUpdateTOX( false ); // reset again
+ m_pWrtShell->SttEndDoc(sal_True);
+ }
+
+ // No ResetModified, if there is already a view to this doc.
+ SfxViewFrame* pVFrame = GetViewFrame();
+ SfxViewFrame* pFirst = SfxViewFrame::GetFirst(pDocSh);
+ // Currently(360) the view is registered firstly after the CTOR,
+ // the following expression is also working if this changes.
+ // If the modification cannot be canceled by undo, then do NOT set
+ // the modify back.
+ // no reset of modified state, if document
+ // was already modified.
+ if (!m_pWrtShell->GetDoc()->GetIDocumentUndoRedo().IsUndoNoResetModified() &&
+ ( !pFirst || pFirst == pVFrame ) &&
+ !bIsDocModified )
+ {
+ m_pWrtShell->ResetModified();
+ }
+
+ bNoInterrupt = bOld;
+
+ // If a new GlobalDoc will be created, the navigator will also be generated.
+ if( pDocSh->IsA(SwGlobalDocShell::StaticType()) &&
+ !pVFrame->GetChildWindow( SID_NAVIGATOR ))
+ {
+ SfxBoolItem aNavi(SID_NAVIGATOR, true);
+ GetDispatcher().Execute(SID_NAVIGATOR, SFX_CALLMODE_ASYNCHRON, &aNavi, 0L);
+ }
+
+ uno::Reference< frame::XFrame > xFrame = pVFrame->GetFrame().GetFrameInterface();
+
+ uno::Reference< frame::XFrame > xBeamerFrame = xFrame->findFrame(
+ OUString("_beamer"), frame::FrameSearchFlag::CHILDREN);
+ if(xBeamerFrame.is())
+ {
+ SwDBData aData = m_pWrtShell->GetDBData();
+ SW_MOD()->ShowDBObj( *this, aData );
+ }
+
+ // has anybody calls the attrchanged handler in the constructor?
+ if( m_bAttrChgNotifiedWithRegistrations )
+ {
+ GetViewFrame()->GetBindings().LEAVEREGISTRATIONS();
+ if( m_aTimer.IsActive() )
+ m_aTimer.Stop();
+ }
+
+ m_aTimer.SetTimeoutHdl(LINK(this, SwView, TimeoutHdl));
+ m_bAttrChgNotified = m_bAttrChgNotifiedWithRegistrations = sal_False;
+ if(bOldModifyFlag)
+ pDocSh->EnableSetModified( sal_True );
+ InvalidateBorder();
+
+ if( !m_pHScrollbar->IsVisible( sal_True ) )
+ ShowHScrollbar( sal_False );
+ if( !m_pVScrollbar->IsVisible( sal_True ) )
+ ShowVScrollbar( sal_False );
+
+ GetViewFrame()->GetWindow().AddChildEventListener( LINK( this, SwView, WindowChildEventListener ) );
+}
+
+SwView::~SwView()
+{
+ GetViewFrame()->GetWindow().RemoveChildEventListener( LINK( this, SwView, WindowChildEventListener ) );
+ delete m_pPostItMgr;
+ m_pPostItMgr = 0;
+
+ m_bInDtor = sal_True;
+ m_pEditWin->Hide(); // damit kein Paint Aerger machen kann!
+ // An der SwDocShell den Pointer auf die View ruecksetzen
+
+ SwDocShell* pDocSh = GetDocShell();
+ if( pDocSh && pDocSh->GetView() == this )
+ pDocSh->SetView( 0 );
+ if ( SW_MOD()->GetView() == this )
+ SW_MOD()->SetView( 0 );
+
+ if( m_aTimer.IsActive() && m_bAttrChgNotifiedWithRegistrations )
+ GetViewFrame()->GetBindings().LEAVEREGISTRATIONS();
+
+ // the last view must end the text edit
+ SdrView *pSdrView = m_pWrtShell ? m_pWrtShell->GetDrawView() : 0;
+ if( pSdrView && pSdrView->IsTextEdit() )
+ pSdrView->SdrEndTextEdit( sal_True );
+
+ SetWindow( 0 );
+
+ m_pViewImpl->Invalidate();
+ EndListening(*GetViewFrame());
+ EndListening(*GetDocShell());
+ delete m_pScrollFill;
+ delete m_pWrtShell;
+ m_pWrtShell = 0; // Set to 0, so that it is not accessable by the following dtors cannot.
+ m_pShell = 0;
+ delete m_pHScrollbar;
+ delete m_pVScrollbar;
+ delete m_pHRuler;
+ delete m_pVRuler;
+ delete m_pTogglePageBtn;
+ delete m_pGlosHdl;
+ delete m_pViewImpl;
+ delete m_pEditWin;
+ delete m_pFormatClipboard;
+}
+
+SwDocShell* SwView::GetDocShell()
+{
+ SfxObjectShell* pDocShell = GetViewFrame()->GetObjectShell();
+ return PTR_CAST(SwDocShell, pDocShell);
+}
+
+// Remember CursorPos
+
+void SwView::WriteUserData( OUString &rUserData, bool bBrowse )
+{
+ // The browse flag will be passed from Sfx when documents are browsed
+ // (not to be confused with the BrowseMode).
+ // Then that stored data are not persistent!
+
+ const SwRect& rRect = m_pWrtShell->GetCharRect();
+ const Rectangle& rVis = GetVisArea();
+
+ rUserData = OUString::number( rRect.Left() );
+ rUserData += ";";
+ rUserData += OUString::number( rRect.Top() );
+ rUserData += ";";
+ rUserData += OUString::number( m_pWrtShell->GetViewOptions()->GetZoom() );
+ rUserData += ";";
+ rUserData += OUString::number( rVis.Left() );
+ rUserData += ";";
+ rUserData += OUString::number( rVis.Top() );
+ rUserData += ";";
+ rUserData += OUString::number( bBrowse ? SAL_MIN_INT32 : rVis.Right());
+ rUserData += ";";
+ rUserData += OUString::number( bBrowse ? SAL_MIN_INT32 : rVis.Bottom());
+ rUserData += ";";
+ rUserData += OUString::number(
+ (sal_uInt16)m_pWrtShell->GetViewOptions()->GetZoomType());//eZoom;
+ rUserData += ";";
+ rUserData += FRMTYPE_NONE == m_pWrtShell->GetSelFrmType() ? OUString("0") : OUString("1");
+}
+
+// Set CursorPos
+
+static bool lcl_IsOwnDocument( SwView& rView )
+{
+ uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
+ rView.GetDocShell()->GetModel(), uno::UNO_QUERY_THROW);
+ uno::Reference<document::XDocumentProperties> xDocProps
+ = xDPS->getDocumentProperties();
+ OUString Created = xDocProps->getAuthor();
+ OUString Changed = xDocProps->getModifiedBy();
+ OUString FullName = SW_MOD()->GetUserOptions().GetFullName();
+ return (!FullName.isEmpty() &&
+ (!Changed.isEmpty() && Changed == FullName )) ||
+ (Changed.isEmpty() && !Created.isEmpty() && Created == FullName );
+}
+
+void SwView::ReadUserData( const OUString &rUserData, bool bBrowse )
+{
+ if ( comphelper::string::getTokenCount(rUserData, ';') > 1 &&
+ // For document without layout only in the onlinelayout or
+ // while forward/backward
+ (!m_pWrtShell->IsNewLayout() || m_pWrtShell->GetViewOptions()->getBrowseMode() || bBrowse) )
+ {
+ bool bIsOwnDocument = lcl_IsOwnDocument( *this );
+
+ SET_CURR_SHELL(m_pWrtShell);
+
+ sal_Int32 nPos = 0;
+
+ // No it is *no* good idea to call GetToken within Point-Konstr. immediately,
+ // because which parameter is evaluated first?
+ long nX = rUserData.getToken( 0, ';', nPos ).toInt32(),
+ nY = rUserData.getToken( 0, ';', nPos ).toInt32();
+ Point aCrsrPos( nX, nY );
+
+ sal_uInt16 nZoomFactor =
+ static_cast< sal_uInt16 >( rUserData.getToken(0, ';', nPos ).toInt32() );
+
+ long nLeft = rUserData.getToken(0, ';', nPos ).toInt32(),
+ nTop = rUserData.getToken(0, ';', nPos ).toInt32(),
+ nRight = rUserData.getToken(0, ';', nPos ).toInt32(),
+ nBottom= rUserData.getToken(0, ';', nPos ).toInt32();
+
+ const long nAdd = m_pWrtShell->GetViewOptions()->getBrowseMode() ? DOCUMENTBORDER : DOCUMENTBORDER*2;
+ if ( nBottom <= (m_pWrtShell->GetDocSize().Height()+nAdd) )
+ {
+ m_pWrtShell->EnableSmooth( sal_False );
+
+ const Rectangle aVis( nLeft, nTop, nRight, nBottom );
+
+ sal_Int32 nOff = 0;
+ SvxZoomType eZoom;
+ if( !m_pWrtShell->GetViewOptions()->getBrowseMode() )
+ eZoom = (SvxZoomType) (sal_uInt16)rUserData.getToken(nOff, ';', nPos ).toInt32();
+ else
+ {
+ eZoom = SVX_ZOOM_PERCENT;
+ ++nOff;
+ }
+
+ sal_Bool bSelectObj = (0 != rUserData.getToken( nOff, ';', nPos ).toInt32())
+ && m_pWrtShell->IsObjSelectable( aCrsrPos );
+
+ // restore editing position
+ m_pViewImpl->SetRestorePosition(aCrsrPos, bSelectObj);
+ // set flag value to avoid macro execution.
+ bool bSavedFlagValue = m_pWrtShell->IsMacroExecAllowed();
+ m_pWrtShell->SetMacroExecAllowed( false );
+// os: changed: The user data has to be read if the view is switched back from page preview
+// go to the last editing position when opening own files
+ if(m_bOldShellWasPagePreview || bIsOwnDocument)
+ {
+ m_pWrtShell->SwCrsrShell::SetCrsr( aCrsrPos, !bSelectObj );
+ if( bSelectObj )
+ {
+ m_pWrtShell->SelectObj( aCrsrPos );
+ m_pWrtShell->EnterSelFrmMode( &aCrsrPos );
+ }
+ }
+
+ // reset flag value
+ m_pWrtShell->SetMacroExecAllowed( bSavedFlagValue );
+
+ // set visible area before applying
+ // information from print preview. Otherwise, the applied information
+ // is lost.
+// os: changed: The user data has to be read if the view is switched back from page preview
+// go to the last editing position when opening own files
+ if(m_bOldShellWasPagePreview || bIsOwnDocument )
+ {
+ if ( bBrowse )
+ SetVisArea( aVis.TopLeft() );
+ else
+ SetVisArea( aVis );
+ }
+
+ //apply information from print preview - if available
+ if( !m_sNewCrsrPos.isEmpty() )
+ {
+ long nXTmp = m_sNewCrsrPos.getToken( 0, ';' ).toInt32(),
+ nYTmp = m_sNewCrsrPos.getToken( 1, ';' ).toInt32();
+ Point aCrsrPos2( nXTmp, nYTmp );
+ bSelectObj = m_pWrtShell->IsObjSelectable( aCrsrPos2 );
+
+ m_pWrtShell->SwCrsrShell::SetCrsr( aCrsrPos2, sal_False );
+ if( bSelectObj )
+ {
+ m_pWrtShell->SelectObj( aCrsrPos2 );
+ m_pWrtShell->EnterSelFrmMode( &aCrsrPos2 );
+ }
+ m_pWrtShell->MakeSelVisible();
+ m_sNewCrsrPos = "";
+ }
+ else if(USHRT_MAX != m_nNewPage)
+ {
+ m_pWrtShell->GotoPage(m_nNewPage, sal_True);
+ m_nNewPage = USHRT_MAX;
+ }
+
+ SelectShell();
+
+ m_pWrtShell->StartAction();
+ const SwViewOption* pVOpt = m_pWrtShell->GetViewOptions();
+ if( pVOpt->GetZoom() != nZoomFactor || pVOpt->GetZoomType() != eZoom )
+ SetZoom( eZoom, nZoomFactor);
+
+ m_pWrtShell->LockView( sal_True );
+ m_pWrtShell->EndAction();
+ m_pWrtShell->LockView( sal_False );
+ m_pWrtShell->EnableSmooth( sal_True );
+ }
+ }
+}
+
+void SwView::ReadUserDataSequence ( const uno::Sequence < beans::PropertyValue >& rSequence, sal_Bool bBrowse )
+{
+ if(GetDocShell()->IsPreview()||m_bIsPreviewDoubleClick)
+ return;
+ bool bIsOwnDocument = lcl_IsOwnDocument( *this );
+ sal_Int32 nLength = rSequence.getLength();
+ if (nLength && (!m_pWrtShell->IsNewLayout() || m_pWrtShell->GetViewOptions()->getBrowseMode() || bBrowse) )
+ {
+ SET_CURR_SHELL(m_pWrtShell);
+ const beans::PropertyValue *pValue = rSequence.getConstArray();
+ const SwRect& rRect = m_pWrtShell->GetCharRect();
+ const Rectangle &rVis = GetVisArea();
+ const SwViewOption* pVOpt = m_pWrtShell->GetViewOptions();
+
+ long nX = rRect.Left(), nY = rRect.Top(), nLeft = rVis.Left(), nTop = rVis.Top();
+ long nRight = bBrowse ? LONG_MIN : rVis.Right(), nBottom = bBrowse ? LONG_MIN : rVis.Bottom();
+ sal_Int16 nZoomType = static_cast< sal_Int16 >(pVOpt->GetZoomType());
+ sal_Int16 nZoomFactor = static_cast < sal_Int16 > (pVOpt->GetZoom());
+ bool bViewLayoutBookMode = pVOpt->IsViewLayoutBookMode();
+ sal_Int16 nViewLayoutColumns = pVOpt->GetViewLayoutColumns();
+
+ sal_Bool bSelectedFrame = ( m_pWrtShell->GetSelFrmType() != FRMTYPE_NONE ),
+ bGotVisibleLeft = sal_False,
+ bGotVisibleTop = sal_False, bGotVisibleRight = sal_False,
+ bGotVisibleBottom = sal_False, bGotZoomType = sal_False,
+ bGotZoomFactor = sal_False, bGotIsSelectedFrame = sal_False,
+ bGotViewLayoutColumns = sal_False, bGotViewLayoutBookMode = sal_False;
+
+ for (sal_Int16 i = 0 ; i < nLength; i++)
+ {
+ if ( pValue->Name == "ViewLeft" )
+ {
+ pValue->Value >>= nX;
+ nX = MM100_TO_TWIP( nX );
+ }
+ else if ( pValue->Name == "ViewTop" )
+ {
+ pValue->Value >>= nY;
+ nY = MM100_TO_TWIP( nY );
+ }
+ else if ( pValue->Name == "VisibleLeft" )
+ {
+ pValue->Value >>= nLeft;
+ nLeft = MM100_TO_TWIP( nLeft );
+ bGotVisibleLeft = sal_True;
+ }
+ else if ( pValue->Name == "VisibleTop" )
+ {
+ pValue->Value >>= nTop;
+ nTop = MM100_TO_TWIP( nTop );
+ bGotVisibleTop = sal_True;
+ }
+ else if ( pValue->Name == "VisibleRight" )
+ {
+ pValue->Value >>= nRight;
+ nRight = MM100_TO_TWIP( nRight );
+ bGotVisibleRight = sal_True;
+ }
+ else if ( pValue->Name == "VisibleBottom" )
+ {
+ pValue->Value >>= nBottom;
+ nBottom = MM100_TO_TWIP( nBottom );
+ bGotVisibleBottom = sal_True;
+ }
+ else if ( pValue->Name == "ZoomType" )
+ {
+ pValue->Value >>= nZoomType;
+ bGotZoomType = sal_True;
+ }
+ else if ( pValue->Name == "ZoomFactor" )
+ {
+ pValue->Value >>= nZoomFactor;
+ bGotZoomFactor = sal_True;
+ }
+ else if ( pValue->Name == "ViewLayoutColumns" )
+ {
+ pValue->Value >>= nViewLayoutColumns;
+ bGotViewLayoutColumns = sal_True;
+ }
+ else if ( pValue->Name == "ViewLayoutBookMode" )
+ {
+ bViewLayoutBookMode = * (sal_Bool *) pValue->Value.getValue();
+ bGotViewLayoutBookMode = sal_True;
+ }
+ else if ( pValue->Name == "IsSelectedFrame" )
+ {
+ pValue->Value >>= bSelectedFrame;
+ bGotIsSelectedFrame = sal_True;
+ }
+ pValue++;
+ }
+ if (bGotVisibleBottom)
+ {
+ Point aCrsrPos( nX, nY );
+ const long nAdd = m_pWrtShell->GetViewOptions()->getBrowseMode() ? DOCUMENTBORDER : DOCUMENTBORDER*2;
+ if (nBottom <= (m_pWrtShell->GetDocSize().Height()+nAdd) )
+ {
+ m_pWrtShell->EnableSmooth( sal_False );
+ const Rectangle aVis( nLeft, nTop, nRight, nBottom );
+
+ SvxZoomType eZoom;
+ if ( !m_pWrtShell->GetViewOptions()->getBrowseMode() )
+ eZoom = static_cast < SvxZoomType > ( nZoomType );
+ else
+ {
+ eZoom = SVX_ZOOM_PERCENT;
+ }
+ if (bGotIsSelectedFrame)
+ {
+ sal_Bool bSelectObj = (sal_False != bSelectedFrame )
+ && m_pWrtShell->IsObjSelectable( aCrsrPos );
+
+ // set flag value to avoid macro execution.
+ bool bSavedFlagValue = m_pWrtShell->IsMacroExecAllowed();
+ m_pWrtShell->SetMacroExecAllowed( false );
+// os: changed: The user data has to be read if the view is switched back from page preview
+// go to the last editing position when opening own files
+ m_pViewImpl->SetRestorePosition(aCrsrPos, bSelectObj);
+ if(m_bOldShellWasPagePreview|| bIsOwnDocument)
+ {
+ m_pWrtShell->SwCrsrShell::SetCrsr( aCrsrPos, !bSelectObj );
+
+ // Update the shell to toggle Header/Footer edit if needed
+ sal_Bool bInHeader = sal_True;
+ if ( m_pWrtShell->IsInHeaderFooter( &bInHeader ) )
+ {
+ if ( !bInHeader )
+ {
+ m_pWrtShell->SetShowHeaderFooterSeparator( Footer, true );
+ m_pWrtShell->SetShowHeaderFooterSeparator( Header, false );
+ }
+ else
+ {
+ m_pWrtShell->SetShowHeaderFooterSeparator( Header, true );
+ m_pWrtShell->SetShowHeaderFooterSeparator( Footer, false );
+ }
+
+ // Force repaint
+ m_pWrtShell->GetWin()->Invalidate();
+ }
+ if ( m_pWrtShell->IsInHeaderFooter() != m_pWrtShell->IsHeaderFooterEdit() )
+ m_pWrtShell->ToggleHeaderFooterEdit();
+
+ if( bSelectObj )
+ {
+ m_pWrtShell->SelectObj( aCrsrPos );
+ m_pWrtShell->EnterSelFrmMode( &aCrsrPos );
+ }
+ }
+
+ // reset flag value
+ m_pWrtShell->SetMacroExecAllowed( bSavedFlagValue );
+ }
+ SelectShell();
+
+ // Set ViewLayoutSettings
+ const bool bSetViewLayoutSettings = bGotViewLayoutColumns && bGotViewLayoutBookMode &&
+ ( pVOpt->GetViewLayoutColumns() != nViewLayoutColumns || pVOpt->IsViewLayoutBookMode() != bViewLayoutBookMode );
+
+ const bool bSetViewSettings = bGotZoomType && bGotZoomFactor &&
+ ( pVOpt->GetZoom() != nZoomFactor || pVOpt->GetZoomType() != eZoom );
+
+ // In case we have a 'fixed' view layout of 2 or more columns,
+ // we have to apply the view options *before* starting the action.
+ // Otherwsie the SetZoom function cannot work correctly, because
+ // the view layout hasn't been calculated.
+ const bool bZoomNeedsViewLayout = bSetViewLayoutSettings &&
+ 1 < nViewLayoutColumns &&
+ bSetViewSettings &&
+ eZoom != SVX_ZOOM_PERCENT;
+
+ if ( !bZoomNeedsViewLayout )
+ m_pWrtShell->StartAction();
+
+ if ( bSetViewLayoutSettings )
+ SetViewLayout( nViewLayoutColumns, bViewLayoutBookMode, sal_True );
+
+ if ( bZoomNeedsViewLayout )
+ m_pWrtShell->StartAction();
+
+ if ( bSetViewSettings )
+ SetZoom( eZoom, nZoomFactor, sal_True );
+
+// os: changed: The user data has to be read if the view is switched back from page preview
+// go to the last editing position when opening own files
+ if(m_bOldShellWasPagePreview||bIsOwnDocument)
+ {
+ if ( bBrowse && bGotVisibleLeft && bGotVisibleTop )
+ {
+ Point aTopLeft(aVis.TopLeft());
+ // make sure the document is still centered
+ const SwTwips lBorder = IsDocumentBorder() ? DOCUMENTBORDER : 2 * DOCUMENTBORDER;
+ SwTwips nEditWidth = GetEditWin().GetOutputSize().Width();
+ if(nEditWidth > (m_aDocSz.Width() + lBorder ))
+ aTopLeft.X() = ( m_aDocSz.Width() + lBorder - nEditWidth ) / 2;
+ else
+ {
+ //check if the values are possible
+ long nXMax = m_pHScrollbar->GetRangeMax() - m_pHScrollbar->GetVisibleSize();
+ if( aTopLeft.X() > nXMax )
+ aTopLeft.X() = nXMax < 0 ? 0 : nXMax;
+ }
+ SetVisArea( aTopLeft );
+ }
+ else if (bGotVisibleLeft && bGotVisibleTop && bGotVisibleRight && bGotVisibleBottom )
+ SetVisArea( aVis );
+ }
+
+ m_pWrtShell->LockView( sal_True );
+ m_pWrtShell->EndAction();
+ m_pWrtShell->LockView( sal_False );
+ m_pWrtShell->EnableSmooth( sal_True );
+ }
+ }
+ }
+}
+
+#define NUM_VIEW_SETTINGS 12
+void SwView::WriteUserDataSequence ( uno::Sequence < beans::PropertyValue >& rSequence, sal_Bool bBrowse )
+{
+ const SwRect& rRect = m_pWrtShell->GetCharRect();
+ const Rectangle& rVis = GetVisArea();
+
+ rSequence.realloc ( NUM_VIEW_SETTINGS );
+ sal_Int16 nIndex = 0;
+ beans::PropertyValue *pValue = rSequence.getArray();
+
+ sal_uInt16 nViewID( GetViewFrame()->GetCurViewId());
+ pValue->Name = "ViewId";
+ OUStringBuffer sBuffer ( OUString( "view" ) );
+ ::sax::Converter::convertNumber(sBuffer, static_cast<sal_Int32>(nViewID));
+ pValue->Value <<= sBuffer.makeStringAndClear();
+ pValue++;nIndex++;
+
+ pValue->Name = "ViewLeft";
+ pValue->Value <<= TWIP_TO_MM100 ( rRect.Left() );
+ pValue++;nIndex++;
+
+ pValue->Name = "ViewTop";
+ pValue->Value <<= TWIP_TO_MM100 ( rRect.Top() );
+ pValue++;nIndex++;
+
+ pValue->Name = "VisibleLeft";
+ pValue->Value <<= TWIP_TO_MM100 ( rVis.Left() );
+ pValue++;nIndex++;
+
+ pValue->Name = "VisibleTop";
+ pValue->Value <<= TWIP_TO_MM100 ( rVis.Top() );
+ pValue++;nIndex++;
+
+ pValue->Name = "VisibleRight";
+ pValue->Value <<= TWIP_TO_MM100 ( bBrowse ? LONG_MIN : rVis.Right() );
+ pValue++;nIndex++;
+
+ pValue->Name = "VisibleBottom";
+ pValue->Value <<= TWIP_TO_MM100 ( bBrowse ? LONG_MIN : rVis.Bottom() );
+ pValue++;nIndex++;
+
+ pValue->Name = "ZoomType";
+ const sal_Int16 nZoomType = static_cast< sal_Int16 >(m_pWrtShell->GetViewOptions()->GetZoomType());
+ pValue->Value <<= nZoomType;
+ pValue++;nIndex++;
+
+ pValue->Name = "ViewLayoutColumns";
+ const sal_Int16 nViewLayoutColumns = static_cast< sal_Int16 >(m_pWrtShell->GetViewOptions()->GetViewLayoutColumns());
+ pValue->Value <<= nViewLayoutColumns;
+ pValue++;nIndex++;
+
+ pValue->Name = "ViewLayoutBookMode";
+ const sal_Bool bIsViewLayoutBookMode = m_pWrtShell->GetViewOptions()->IsViewLayoutBookMode();
+ pValue->Value.setValue( &bIsViewLayoutBookMode, ::getBooleanCppuType() );
+ pValue++;nIndex++;
+
+ pValue->Name = "ZoomFactor";
+ pValue->Value <<= static_cast < sal_Int16 > (m_pWrtShell->GetViewOptions()->GetZoom());
+ pValue++;nIndex++;
+
+ pValue->Name = "IsSelectedFrame";
+ const sal_Bool bIsSelected = FRMTYPE_NONE == m_pWrtShell->GetSelFrmType() ? sal_False : sal_True;
+ pValue->Value.setValue ( &bIsSelected, ::getBooleanCppuType() );
+ nIndex++;
+
+ if ( nIndex < NUM_VIEW_SETTINGS )
+ rSequence.realloc ( nIndex );
+}
+#undef NUM_VIEW_SETTINGS
+
+void SwView::ShowCursor( bool bOn )
+{
+ //don't scroll the cursor into the visible area
+ sal_Bool bUnlockView = !m_pWrtShell->IsViewLocked();
+ m_pWrtShell->LockView( sal_True ); //lock visible section
+
+ if( !bOn )
+ m_pWrtShell->HideCrsr();
+ else if( !m_pWrtShell->IsFrmSelected() && !m_pWrtShell->IsObjSelected() )
+ m_pWrtShell->ShowCrsr();
+
+ if( bUnlockView )
+ m_pWrtShell->LockView( sal_False );
+}
+
+ErrCode SwView::DoVerb( long nVerb )
+{
+ if ( !GetViewFrame()->GetFrame().IsInPlace() )
+ {
+ SwWrtShell &rSh = GetWrtShell();
+ const int nSel = rSh.GetSelectionType();
+ if ( nSel & nsSelectionType::SEL_OLE )
+ rSh.LaunchOLEObj( nVerb );
+ }
+ return ERRCODE_NONE;
+}
+
+// only return sal_True for a text selection
+
+sal_Bool SwView::HasSelection( sal_Bool bText ) const
+{
+ return bText ? GetWrtShell().SwCrsrShell::HasSelection()
+ : GetWrtShell().HasSelection();
+}
+
+OUString SwView::GetSelectionText( bool bCompleteWrds )
+{
+ return GetSelectionTextParam( bCompleteWrds, true );
+}
+
+OUString SwView::GetSelectionTextParam( bool bCompleteWrds, bool bEraseTrail )
+{
+ OUString sReturn;
+ if( bCompleteWrds && !GetWrtShell().HasSelection() )
+ GetWrtShell().SelWrd();
+
+ GetWrtShell().GetSelectedText( sReturn );
+ if( bEraseTrail )
+ sReturn = comphelper::string::stripEnd(sReturn, ' ');
+ return sReturn;
+}
+
+SwGlossaryHdl* SwView::GetGlosHdl()
+{
+ if(!m_pGlosHdl)
+ m_pGlosHdl = new SwGlossaryHdl(GetViewFrame(), m_pWrtShell);
+ return m_pGlosHdl;
+}
+
+void SwView::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
+{
+ sal_Bool bCallBase = sal_True;
+ if ( rHint.ISA(SfxSimpleHint) )
+ {
+ sal_uInt32 nId = ((SfxSimpleHint&)rHint).GetId();
+ switch ( nId )
+ {
+ // sub shells will be destroyed by the
+ // dispatcher, if the view frame is dying. Thus, reset member <pShell>.
+ case SFX_HINT_DYING:
+ {
+ if ( &rBC == GetViewFrame() )
+ {
+ ResetSubShell();
+ }
+ }
+ break;
+ case SFX_HINT_MODECHANGED:
+ {
+ // Modal mode change-over?
+ sal_Bool bModal = GetDocShell()->IsInModalMode();
+ m_pHRuler->SetActive( !bModal );
+ m_pVRuler->SetActive( !bModal );
+ }
+
+ /* no break here */
+
+ case SFX_HINT_TITLECHANGED:
+ if ( GetDocShell()->IsReadOnly() != GetWrtShell().GetViewOptions()->IsReadonly() )
+ {
+ SwWrtShell &rSh = GetWrtShell();
+ rSh.SetReadonlyOption( GetDocShell()->IsReadOnly() );
+
+ if ( rSh.GetViewOptions()->IsViewVRuler() )
+ CreateVRuler();
+ else
+ KillVRuler();
+ if ( rSh.GetViewOptions()->IsViewHRuler() )
+ CreateTab();
+ else
+ KillTab();
+ bool bReadonly = GetDocShell()->IsReadOnly();
+ // if document is to be opened in alive-mode then this has to be
+ // regarded while switching from readonly-mode to edit-mode
+ if( !bReadonly )
+ {
+ SwDrawDocument * pDrawDoc = 0;
+ if ( 0 != ( pDrawDoc = dynamic_cast< SwDrawDocument * > (GetDocShell()->GetDoc()->GetDrawModel() ) ) )
+ {
+ if( !pDrawDoc->GetOpenInDesignMode() )
+ break;// don't touch the design mode
+ }
+ }
+ SfxBoolItem aItem( SID_FM_DESIGN_MODE, !bReadonly);
+ GetDispatcher().Execute( SID_FM_DESIGN_MODE, SFX_CALLMODE_ASYNCHRON,
+ &aItem, 0L );
+ }
+ break;
+
+ case SW_BROADCAST_DRAWVIEWS_CREATED:
+ {
+ bCallBase = sal_False;
+ if ( GetFormShell() )
+ {
+ GetFormShell()->SetView(
+ PTR_CAST(FmFormView, GetWrtShell().GetDrawView()) );
+ SfxBoolItem aItem( SID_FM_DESIGN_MODE, !GetDocShell()->IsReadOnly());
+ GetDispatcher().Execute( SID_FM_DESIGN_MODE, SFX_CALLMODE_SYNCHRON,
+ &aItem, 0L );
+ }
+ }
+ break;
+ }
+ }
+ else if(rHint.ISA(FmDesignModeChangedHint))
+ {
+ sal_Bool bDesignMode = ((FmDesignModeChangedHint&)rHint).GetDesignMode();
+ if (!bDesignMode && GetDrawFuncPtr())
+ {
+ GetDrawFuncPtr()->Deactivate();
+ SetDrawFuncPtr(NULL);
+ LeaveDrawCreate();
+ AttrChangedNotify(m_pWrtShell);
+ }
+ }
+
+ if ( bCallBase )
+ SfxViewShell::Notify(rBC, rHint);
+}
+
+#if defined WNT || defined UNX
+
+void SwView::ScannerEventHdl( const EventObject& /*rEventObject*/ )
+{
+ uno::Reference< XScannerManager2 > xScanMgr = SW_MOD()->GetScannerManager();
+ if( xScanMgr.is() )
+ {
+ const ScannerContext aContext( xScanMgr->getAvailableScanners().getConstArray()[ 0 ] );
+ const ScanError eError = xScanMgr->getError( aContext );
+
+ if( ScanError_ScanErrorNone == eError )
+ {
+ const uno::Reference< awt::XBitmap > xBitmap( xScanMgr->getBitmap( aContext ) );
+
+ if( xBitmap.is() )
+ {
+ const BitmapEx aScanBmp( VCLUnoHelper::GetBitmap( xBitmap ) );
+
+ if( !!aScanBmp )
+ {
+ Graphic aGrf(aScanBmp);
+ m_pWrtShell->Insert( OUString(), OUString(), aGrf );
+ }
+ }
+ }
+ }
+ SfxBindings& rBind = GetViewFrame()->GetBindings();
+ rBind.Invalidate( SID_TWAIN_SELECT );
+ rBind.Invalidate( SID_TWAIN_TRANSFER );
+}
+#endif
+
+void SwView::StopShellTimer()
+{
+ if(m_aTimer.IsActive())
+ {
+ m_aTimer.Stop();
+ if ( m_bAttrChgNotifiedWithRegistrations )
+ {
+ GetViewFrame()->GetBindings().LEAVEREGISTRATIONS();
+ m_bAttrChgNotifiedWithRegistrations = sal_False;
+ }
+ SelectShell();
+ m_bAttrChgNotified = sal_False;
+ }
+}
+
+bool SwView::PrepareClose( sal_Bool bUI )
+{
+ SfxViewFrame* pVFrame = GetViewFrame();
+ pVFrame->SetChildWindow( SwInputChild::GetChildWindowId(), sal_False );
+ if( pVFrame->GetDispatcher()->IsLocked() )
+ pVFrame->GetDispatcher()->Lock(sal_False);
+
+ if ( m_pFormShell && !m_pFormShell->PrepareClose( bUI ) )
+ {
+ return false;
+ }
+ return SfxViewShell::PrepareClose( bUI );
+}
+
+// status methods for clipboard.
+// Status changes now notified from the clipboard.
+sal_Bool SwView::IsPasteAllowed()
+{
+ sal_uInt16 nPasteDestination = SwTransferable::GetSotDestination( *m_pWrtShell );
+ if( m_nLastPasteDestination != nPasteDestination )
+ {
+ TransferableDataHelper aDataHelper(
+ TransferableDataHelper::CreateFromSystemClipboard(
+ &GetEditWin()) );
+ if( aDataHelper.GetXTransferable().is() )
+ {
+ m_bPasteState = SwTransferable::IsPaste( *m_pWrtShell, aDataHelper );
+ m_bPasteSpecialState = SwTransferable::IsPasteSpecial(
+ *m_pWrtShell, aDataHelper );
+ }
+ else
+ m_bPasteState = m_bPasteSpecialState = sal_False;
+
+ if( 0xFFFF == m_nLastPasteDestination ) // the init value
+ m_pViewImpl->AddClipboardListener();
+ m_nLastPasteDestination = nPasteDestination;
+ }
+ return m_bPasteState;
+}
+
+sal_Bool SwView::IsPasteSpecialAllowed()
+{
+ if ( m_pFormShell && m_pFormShell->IsActiveControl() )
+ return sal_False;
+
+ sal_uInt16 nPasteDestination = SwTransferable::GetSotDestination( *m_pWrtShell );
+ if( m_nLastPasteDestination != nPasteDestination )
+ {
+ TransferableDataHelper aDataHelper(
+ TransferableDataHelper::CreateFromSystemClipboard(
+ &GetEditWin()) );
+ if( aDataHelper.GetXTransferable().is() )
+ {
+ m_bPasteState = SwTransferable::IsPaste( *m_pWrtShell, aDataHelper );
+ m_bPasteSpecialState = SwTransferable::IsPasteSpecial(
+ *m_pWrtShell, aDataHelper );
+ }
+ else
+ m_bPasteState = m_bPasteSpecialState = sal_False;
+
+ if( 0xFFFF == m_nLastPasteDestination ) // the init value
+ m_pViewImpl->AddClipboardListener();
+ }
+ return m_bPasteSpecialState;
+}
+
+void SwView::NotifyDBChanged()
+{
+ GetViewImpl()->GetUNOObject_Impl()->NotifyDBChanged();
+}
+
+// Printing
+
+SfxObjectShellLock SwView::CreateTmpSelectionDoc()
+{
+ SwXTextView *const pImpl = GetViewImpl()->GetUNOObject_Impl();
+ return pImpl->BuildTmpSelectionDoc();
+}
+
+void SwView::AddTransferable(SwTransferable& rTransferable)
+{
+ GetViewImpl()->AddTransferable(rTransferable);
+}
+
+namespace sw {
+
+void InitPrintOptionsFromApplication(SwPrintData & o_rData, bool const bWeb)
+{
+ o_rData = *SW_MOD()->GetPrtOptions(bWeb);
+}
+
+} // namespace sw
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/uiview/view.hrc b/sw/source/core/uibase/uiview/view.hrc
new file mode 100644
index 000000000000..aa55887e0f6a
--- /dev/null
+++ b/sw/source/core/uibase/uiview/view.hrc
@@ -0,0 +1,74 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef _VIEW_HRC
+#define _VIEW_HRC
+
+#include "rcid.hrc"
+
+// STR
+
+#define STR_NUM_LEVEL (RC_VIEW_BEGIN + 3)
+#define STR_NUM_OUTLINE (RC_VIEW_BEGIN + 4)
+
+#define STR_ERROR_NOLANG (RC_VIEW_BEGIN + 6)
+
+#define STR_EDIT_FOOTNOTE (RC_VIEW_BEGIN + 14)
+
+#define STR_NB_REPLACED (RC_VIEW_BEGIN + 20)
+#define MSG_SCAN_NOSOURCE (RC_VIEW_BEGIN + 21)
+
+#define STR_SRCVIEW_ROW (RC_VIEW_BEGIN + 22)
+#define STR_SRCVIEW_COL (RC_VIEW_BEGIN + 23)
+#define STR_SAVEAS_SRC (RC_VIEW_BEGIN + 24)
+
+#define MSG_NO_MERGE_ENTRY (RC_VIEW_BEGIN + 25)
+
+#define STR_PRINT_TITLE (RC_VIEW_BEGIN + 26)
+#define STR_PRINT_MSG (RC_VIEW_BEGIN + 27)
+#define STR_PRINT_ALL (RC_VIEW_BEGIN + 28)
+#define STR_PRINT_SELECTION (RC_VIEW_BEGIN + 29)
+
+#define RID_PVIEW_TOOLBOX (RC_VIEW_BEGIN + 31)
+#define STR_WEBOPTIONS (RC_VIEW_BEGIN + 32)
+#define STR_TEXTOPTIONS (RC_VIEW_BEGIN + 33)
+
+#define STR_SAVEACOPY_SRC (RC_VIEW_BEGIN + 34)
+
+// MSG
+
+#define MSG_ERR_INSERT_GLOS (RC_VIEW_BEGIN)
+
+#define MSG_ERR_NO_FAX (RC_VIEW_BEGIN + 5)
+#define MSG_ERR_SRCSTREAM (RC_VIEW_BEGIN + 6)
+
+// DLG
+
+#define DLG_SPECIAL_FORCED (RC_VIEW_BEGIN)
+
+// Overflow checking
+
+#define VIEW_ACT_END STR_EDIT_FOOTNOTE
+
+#if VIEW_ACT_END > RC_VIEW_END
+#error Resource-Id Ueberlauf in #file, #line
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/uiview/view.src b/sw/source/core/uibase/uiview/view.src
new file mode 100644
index 000000000000..17794b074479
--- /dev/null
+++ b/sw/source/core/uibase/uiview/view.src
@@ -0,0 +1,149 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <svx/svxids.hrc>
+#include <svx/globlmn.hrc>
+#include "view.hrc"
+#include "shells.hrc"
+#include "globals.hrc"
+#include "popup.hrc"
+#include "helpid.h"
+#include "cmdid.h"
+
+QueryBox DLG_SPECIAL_FORCED
+{
+ BUTTONS = WB_YES_NO ;
+ DEFBUTTON = WB_DEF_NO ;
+ Message [ en-US ] = "Check special regions is deactivated. Check anyway?" ;
+};
+InfoBox MSG_NO_MERGE_ENTRY
+{
+ Message [ en-US ] = "Could not merge documents." ;
+};
+InfoBox MSG_ERR_INSERT_GLOS
+{
+ Message [ en-US ] = "AutoText could not be created." ;
+};
+InfoBox MSG_ERR_SRCSTREAM
+{
+ Message [ en-US ] = "The source cannot be loaded." ;
+};
+InfoBox MSG_ERR_NO_FAX
+{
+ Message [ en-US ] = "No fax printer has been set under Tools/Options/%1/Print." ;
+};
+String STR_WEBOPTIONS
+{
+ Text [ en-US ] = "HTML document";
+};
+String STR_TEXTOPTIONS
+{
+ Text [ en-US ] = "Text document";
+};
+InfoBox MSG_SCAN_NOSOURCE
+{
+ Message [ en-US ] = "Source not specified." ;
+};
+String STR_NUM_LEVEL
+{
+ Text [ en-US ] = "Level " ;
+};
+String STR_NUM_OUTLINE
+{
+ Text [ en-US ] = "Outline ";
+};
+String STR_ERROR_NOLANG
+{
+ Text [ en-US ] = "No language is selected in the proofed section." ;
+};
+String STR_EDIT_FOOTNOTE
+{
+ Text [ en-US ] = "Edit Footnote/Endnote" ;
+};
+String STR_NB_REPLACED
+{
+ Text [ en-US ] = "Search key replaced XX times." ;
+};
+String RID_TOOLS_TOOLBOX
+{
+ Text [ en-US ] = "Main Toolbar" ;
+};
+String STR_SRCVIEW_ROW
+{
+ Text [ en-US ] = "Row " ;
+};
+String STR_SRCVIEW_COL
+{
+ Text [ en-US ] = "Column " ;
+};
+String STR_PRINT_TITLE
+{
+ Text [ en-US ] = "Printing selection";
+};
+String STR_PRINT_MSG
+{
+ Text [ en-US ] = "Do you want to print the selection or the entire document?";
+};
+String STR_PRINT_ALL
+{
+ Text [ en-US ] = "All";
+};
+String STR_PRINT_SELECTION
+{
+ Text [ en-US ] = "Selection";
+};
+String STR_SAVEAS_SRC
+{
+ Text [ en-US ] = "~Export source..." ;
+};
+String MN_SRCVIEW_POPUPMENU
+{
+ Text [ en-US ] = "HTML source" ;
+};
+String RID_PVIEW_TOOLBOX
+{
+ Text [ en-US ] = "Page Preview" ;
+};
+
+Menu MN_SRCVIEW_POPUPMENU
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ ITEM_FORMAT_ATTR_CHAR_FONT
+ };
+ MenuItem
+ {
+ ITEM_FORMAT_ATTR_CHAR_FONTHEIGHT
+ };
+ MenuItem
+ {
+ Separator = TRUE ;
+ };
+ MenuItem
+ {
+ Identifier = SID_SOURCEVIEW ;
+ HelpID = HID_SOURCEVIEW ;
+ Text [ en-US ] = "HTML Source" ;
+ };
+ };
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/uiview/view0.cxx b/sw/source/core/uibase/uiview/view0.cxx
new file mode 100644
index 000000000000..5363d04bebf9
--- /dev/null
+++ b/sw/source/core/uibase/uiview/view0.cxx
@@ -0,0 +1,581 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "hintids.hxx"
+#include <vcl/graph.hxx>
+#include <svx/galbrws.hxx>
+#include <svl/srchitem.hxx>
+#include <SwSpellDialogChildWindow.hxx>
+#include <svl/eitem.hxx>
+#include <unotools/linguprops.hxx>
+#include <unotools/lingucfg.hxx>
+#include <viewopt.hxx>
+#include <globals.h>
+#include <sfx2/app.hxx>
+#include <sfx2/infobar.hxx>
+#include <sfx2/request.hxx>
+#include <svl/whiter.hxx>
+#include <svx/srchdlg.hxx>
+#include <sfx2/templdlg.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/sidebar/SidebarChildWindow.hxx>
+#include <uivwimp.hxx>
+#include <avmedia/mediaplayer.hxx>
+#include <swmodule.hxx>
+#include <com/sun/star/linguistic2/XLinguProperties.hpp>
+
+#include <sfx2/objface.hxx>
+#include <navipi.hxx>
+#include <wrtsh.hxx>
+#include <edtwin.hxx>
+#include "view.hxx"
+#include "basesh.hxx"
+#include "docsh.hxx"
+#include "doc.hxx"
+#include "globals.hrc"
+#include "cmdid.h"
+#include "globdoc.hxx"
+#include "wview.hxx"
+#include "shells.hrc"
+
+#define SwView
+#define GlobalContents
+#define Text
+#define TextDrawText
+#define TextInTable
+#define ListInText
+#define ListInTable
+#define WebTextInTable
+#define WebListInText
+#define WebListInTable
+#include <sfx2/msg.hxx>
+#include "swslots.hxx"
+#include <PostItMgr.hxx>
+
+using namespace ::com::sun::star;
+
+#include <unotools/moduleoptions.hxx>
+
+#include <IDocumentSettingAccess.hxx>
+
+#include <unomid.h>
+
+SFX_IMPL_NAMED_VIEWFACTORY(SwView, "Default")
+{
+ if ( SvtModuleOptions().IsWriter() )
+ {
+ SFX_VIEW_REGISTRATION(SwDocShell);
+ SFX_VIEW_REGISTRATION(SwGlobalDocShell);
+ }
+}
+
+SFX_IMPL_INTERFACE( SwView, SfxViewShell, SW_RES(RID_TOOLS_TOOLBOX) )
+{
+ SFX_CHILDWINDOW_CONTEXT_REGISTRATION(SID_NAVIGATOR);
+ SFX_CHILDWINDOW_REGISTRATION(::sfx2::sidebar::SidebarChildWindow::GetChildWindowId());
+ SFX_CHILDWINDOW_REGISTRATION(SfxTemplateDialogWrapper::GetChildWindowId());
+ SFX_CHILDWINDOW_REGISTRATION(SfxInfoBarContainerChild::GetChildWindowId());
+ SFX_CHILDWINDOW_REGISTRATION(SvxSearchDialogWrapper::GetChildWindowId());
+ SFX_CHILDWINDOW_REGISTRATION(SwSpellDialogChildWindow::GetChildWindowId());
+ SFX_CHILDWINDOW_REGISTRATION(FN_REDLINE_ACCEPT);
+ SFX_CHILDWINDOW_REGISTRATION(SID_HYPERLINK_DIALOG);
+ SFX_CHILDWINDOW_REGISTRATION(FN_WORDCOUNT_DIALOG);
+ SFX_CHILDWINDOW_REGISTRATION(GalleryChildWindow::GetChildWindowId());
+ SFX_CHILDWINDOW_REGISTRATION(::avmedia::MediaPlayer::GetChildWindowId());
+ SFX_CHILDWINDOW_REGISTRATION(FN_INSERT_FIELD_DATA_ONLY);
+ SFX_FEATURED_CHILDWINDOW_REGISTRATION(FN_SYNC_LABELS, CHILDWIN_LABEL );
+ SFX_FEATURED_CHILDWINDOW_REGISTRATION(FN_MAILMERGE_CHILDWINDOW, CHILDWIN_MAILMERGE);
+ SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_TOOLS|
+ SFX_VISIBILITY_STANDARD|SFX_VISIBILITY_SERVER,
+ SW_RES(RID_TOOLS_TOOLBOX) );
+}
+
+TYPEINIT1(SwView,SfxViewShell)
+
+ShellModes SwView::GetShellMode()
+{
+ return m_pViewImpl->GetShellMode();
+}
+
+view::XSelectionSupplier* SwView::GetUNOObject()
+{
+ return m_pViewImpl->GetUNOObject();
+}
+
+void SwView::ApplyAccessiblityOptions(SvtAccessibilityOptions& rAccessibilityOptions)
+{
+ m_pWrtShell->ApplyAccessiblityOptions(rAccessibilityOptions);
+ //to enable the right state of the selection cursor in readonly documents
+ if(GetDocShell()->IsReadOnly())
+ m_pWrtShell->ShowCrsr();
+
+}
+
+void SwView::SetMailMergeConfigItem(SwMailMergeConfigItem* pConfigItem,
+ sal_uInt16 nRestart, sal_Bool bIsSource)
+{
+ m_pViewImpl->SetMailMergeConfigItem(pConfigItem, nRestart, bIsSource);
+ UIFeatureChanged();
+}
+
+SwMailMergeConfigItem* SwView::GetMailMergeConfigItem()
+{
+ return m_pViewImpl->GetMailMergeConfigItem();
+}
+
+sal_uInt16 SwView::GetMailMergeRestartPage() const
+{
+ return m_pViewImpl->GetMailMergeRestartPage();
+}
+
+sal_Bool SwView::IsMailMergeSourceView() const
+{
+ return m_pViewImpl->IsMailMergeSourceView();
+}
+
+static sal_Bool lcl_IsViewMarks( const SwViewOption& rVOpt )
+{
+ return rVOpt.IsHardBlank() &&
+ rVOpt.IsSoftHyph() &&
+ SwViewOption::IsFieldShadings();
+}
+static void lcl_SetViewMarks(SwViewOption& rVOpt, sal_Bool bOn )
+{
+ rVOpt.SetHardBlank(bOn);
+ rVOpt.SetSoftHyph(bOn);
+ SwViewOption::SetAppearanceFlag(
+ VIEWOPT_FIELD_SHADINGS, bOn, sal_True);
+}
+
+static void lcl_SetViewMetaChars( SwViewOption& rVOpt, sal_Bool bOn)
+{
+ rVOpt.SetViewMetaChars( bOn );
+ if(bOn && !(rVOpt.IsParagraph() ||
+ rVOpt.IsTab() ||
+ rVOpt.IsLineBreak() ||
+ rVOpt.IsShowHiddenChar() ||
+ rVOpt.IsBlank()))
+ {
+ rVOpt.SetParagraph(bOn);
+ rVOpt.SetTab(bOn);
+ rVOpt.SetLineBreak(bOn);
+ rVOpt.SetBlank(bOn);
+ rVOpt.SetShowHiddenChar(bOn);
+ }
+}
+
+void SwView::RecheckBrowseMode()
+{
+ // OS: pay attention to numerical order!
+ static sal_uInt16 const aInva[] =
+ {
+ //SID_NEWWINDOW,/*5620*/
+ SID_BROWSER_MODE, /*6313*/
+ SID_RULER_BORDERS, SID_RULER_PAGE_POS,
+ //SID_ATTR_LONG_LRSPACE,
+ SID_HTML_MODE,
+ SID_RULER_PROTECT,
+ //SID_AUTOSPELL_CHECK,
+ //SID_AUTOSPELL_MARKOFF,
+ FN_RULER, /*20211*/
+ FN_VIEW_GRAPHIC, /*20213*/
+ FN_VIEW_BOUNDS, /**/
+ FN_VIEW_FIELDS, /*20215*/
+ FN_VLINEAL, /*20216*/
+ FN_VSCROLLBAR, /*20217*/
+ FN_HSCROLLBAR, /*20218*/
+ FN_VIEW_META_CHARS, /**/
+ FN_VIEW_MARKS, /**/
+ //FN_VIEW_FIELDNAME, /**/
+ FN_VIEW_TABLEGRID, /*20227*/
+ FN_PRINT_LAYOUT, /*20237*/
+ FN_QRY_MERGE, /*20364*/
+ FN_SHADOWCURSOR, /**/
+ 0
+ };
+ // the view must not exist!
+ GetViewFrame()->GetBindings().Invalidate(aInva);
+ CheckVisArea();
+
+ SvxZoomType eType;
+ if( GetWrtShell().GetViewOptions()->getBrowseMode() && SVX_ZOOM_PERCENT != (eType = (SvxZoomType)
+ GetWrtShell().GetViewOptions()->GetZoomType()) )
+ SetZoom( eType );
+ InvalidateBorder();
+}
+
+// State of view options
+
+void SwView::StateViewOptions(SfxItemSet &rSet)
+{
+ SfxWhichIter aIter(rSet);
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ SfxBoolItem aBool;
+ const SwViewOption* pOpt = GetWrtShell().GetViewOptions();
+ const IDocumentSettingAccess* pIDSA = GetDocShell()->getIDocumentSettingAccess();
+
+ while(nWhich)
+ {
+ sal_Bool bReadonly = GetDocShell()->IsReadOnly();
+ if ( bReadonly && nWhich != FN_VIEW_GRAPHIC )
+ {
+ rSet.DisableItem(nWhich);
+ nWhich = 0;
+ }
+ switch(nWhich)
+ {
+ case FN_RULER:
+ {
+ if(!pOpt->IsViewHRuler(sal_True) && !pOpt->IsViewVRuler(sal_True))
+ {
+ rSet.DisableItem(nWhich);
+ nWhich = 0;
+ }
+ else
+ aBool.SetValue( pOpt->IsViewAnyRuler());
+ }
+ break;
+ case SID_BROWSER_MODE:
+ case FN_PRINT_LAYOUT:
+ {
+ sal_Bool bState = pOpt->getBrowseMode();
+ if(FN_PRINT_LAYOUT == nWhich)
+ bState = !bState;
+ aBool.SetValue( bState );
+ }
+ break;
+ case FN_VIEW_BOUNDS:
+ aBool.SetValue( SwViewOption::IsDocBoundaries()); break;
+ case FN_VIEW_GRAPHIC:
+ aBool.SetValue( !pOpt->IsGraphic() ); break;
+ case FN_VIEW_FIELDS:
+ aBool.SetValue( SwViewOption::IsFieldShadings() ); break;
+ case FN_VIEW_FIELDNAME:
+ aBool.SetValue( pOpt->IsFldName() ); break;
+ case FN_VIEW_MARKS:
+ aBool.SetValue( lcl_IsViewMarks(*pOpt) ); break;
+ case FN_VIEW_META_CHARS:
+ aBool.SetValue( pOpt->IsViewMetaChars() ); break;
+ case FN_VIEW_TABLEGRID:
+ aBool.SetValue( SwViewOption::IsTableBoundaries() ); break;
+ case FN_VIEW_NOTES:
+ {
+ aBool.SetValue( pOpt->IsPostIts());
+ if (!GetPostItMgr()->HasNotes())
+ {
+ aBool.SetWhich( nWhich );
+ rSet.Put( aBool );
+ rSet.DisableItem(nWhich);
+ nWhich = 0;
+ }
+ break;
+ }
+ case FN_VIEW_HIDDEN_PARA:
+ aBool.SetValue( pOpt->IsShowHiddenPara()); break;
+ case SID_GRID_VISIBLE:
+ aBool.SetValue( pOpt->IsGridVisible() ); break;
+ case SID_GRID_USE:
+ aBool.SetValue( pOpt->IsSnap() ); break;
+ case SID_HELPLINES_MOVE:
+ aBool.SetValue( pOpt->IsCrossHair() ); break;
+ case FN_VIEW_SMOOTH_SCROLL:
+ aBool.SetValue( pOpt->IsSmoothScroll()); break;
+ case FN_VLINEAL:
+ aBool.SetValue( StatVRuler() ); break;
+ case FN_HSCROLLBAR:
+ if( pOpt->getBrowseMode() )
+ {
+ rSet.DisableItem(nWhich);
+ nWhich = 0;
+ }
+ else
+ aBool.SetValue( IsHScrollbarVisible() ); break;
+ case FN_VSCROLLBAR:
+ aBool.SetValue( IsVScrollbarVisible() ); break;
+ case SID_AUTOSPELL_CHECK:
+ aBool.SetValue( pOpt->IsOnlineSpell() );
+ break;
+ case FN_SHADOWCURSOR:
+ if (pIDSA == 0 || pOpt->getBrowseMode() )
+ {
+ rSet.DisableItem( nWhich );
+ nWhich = 0;
+ }
+ else
+ aBool.SetValue( pOpt->IsShadowCursor() );
+ break;
+
+ }
+
+ if( nWhich )
+ {
+ aBool.SetWhich( nWhich );
+ rSet.Put( aBool );
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+// execute view options
+
+void SwView::ExecViewOptions(SfxRequest &rReq)
+{
+ SwViewOption* pOpt = new SwViewOption( *GetWrtShell().GetViewOptions() );
+ sal_Bool bModified = GetWrtShell().IsModified();
+
+ int eState = STATE_TOGGLE;
+ sal_Bool bSet = sal_False;
+ bool bBrowseModeChanged = false;
+
+ const SfxItemSet *pArgs = rReq.GetArgs();
+ sal_uInt16 nSlot = rReq.GetSlot();
+ const SfxPoolItem* pAttr=NULL;
+
+ if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( nSlot , false, &pAttr ))
+ {
+ bSet = ((SfxBoolItem*)pAttr)->GetValue();
+ eState = bSet ? STATE_ON : STATE_OFF;
+ }
+
+ sal_Bool bFlag = STATE_ON == eState;
+ uno::Reference< linguistic2::XLinguProperties > xLngProp( ::GetLinguPropertySet() );
+
+ switch ( nSlot )
+ {
+ case FN_VIEW_GRAPHIC:
+ if( STATE_TOGGLE == eState )
+ bFlag = !pOpt->IsGraphic();
+ pOpt->SetGraphic( bFlag );
+ break;
+
+ case FN_VIEW_FIELDS:
+ if( STATE_TOGGLE == eState )
+ bFlag = !SwViewOption::IsFieldShadings() ;
+ SwViewOption::SetAppearanceFlag(VIEWOPT_FIELD_SHADINGS, bFlag, sal_True );
+ break;
+
+ case FN_VIEW_BOUNDS:
+ if( STATE_TOGGLE == eState )
+ bFlag = !SwViewOption::IsDocBoundaries();
+ SwViewOption::SetAppearanceFlag(VIEWOPT_DOC_BOUNDARIES, bFlag, sal_True );
+ break;
+
+ case SID_GRID_VISIBLE:
+ if( STATE_TOGGLE == eState )
+ bFlag = !pOpt->IsGridVisible();
+
+ pOpt->SetGridVisible( bFlag );
+ break;
+
+ case SID_GRID_USE:
+ if( STATE_TOGGLE == eState )
+ bFlag = !pOpt->IsSnap();
+
+ pOpt->SetSnap( bFlag );
+ break;
+
+ case SID_HELPLINES_MOVE:
+ if( STATE_TOGGLE == eState )
+ bFlag = !pOpt->IsCrossHair();
+
+ pOpt->SetCrossHair( bFlag );
+ break;
+
+ case SID_BROWSER_MODE:
+ case FN_PRINT_LAYOUT:
+ if( STATE_TOGGLE == eState )
+ bFlag = !pOpt->getBrowseMode();
+ else if( nSlot == FN_PRINT_LAYOUT )
+ bFlag = !bFlag;
+ bBrowseModeChanged = bFlag != pOpt->getBrowseMode();
+ // Disable "multiple layout"
+ GetDocShell()->ToggleBrowserMode( bFlag, this );
+ pOpt->setBrowseMode( bFlag );
+ break;
+
+ case FN_VIEW_NOTES:
+ if ( STATE_TOGGLE == eState )
+ bFlag = !pOpt->IsPostIts();
+
+ GetPostItMgr()->SetLayout();
+ pOpt->SetPostIts( bFlag );
+ if (pOpt->IsPostIts())
+ GetPostItMgr()->CheckMetaText();
+ break;
+
+ case FN_VIEW_HIDDEN_PARA:
+ if ( STATE_TOGGLE == eState )
+ bFlag = !pOpt->IsShowHiddenPara();
+
+ pOpt->SetShowHiddenPara( bFlag );
+ break;
+
+ case FN_VIEW_SMOOTH_SCROLL:
+
+ if ( STATE_TOGGLE == eState )
+ bFlag = !pOpt->IsSmoothScroll();
+
+ pOpt->SetSmoothScroll( bFlag );
+ break;
+
+ case FN_VLINEAL:
+ if( STATE_TOGGLE == eState )
+ bFlag = !pOpt->IsViewVRuler();
+
+ pOpt->SetViewVRuler( bFlag );
+ break;
+
+ case FN_VSCROLLBAR:
+ if( STATE_TOGGLE == eState )
+ bFlag = !pOpt->IsViewVScrollBar();
+
+ pOpt->SetViewVScrollBar( bFlag );
+ break;
+
+ case FN_HSCROLLBAR:
+ if( STATE_TOGGLE == eState )
+ bFlag = !pOpt->IsViewHScrollBar();
+
+ pOpt->SetViewHScrollBar( bFlag );
+ break;
+
+ case FN_RULER:
+ if( STATE_TOGGLE == eState )
+ bFlag = !pOpt->IsViewAnyRuler();
+
+ pOpt->SetViewAnyRuler( bFlag );
+ break;
+
+ case FN_VIEW_TABLEGRID:
+ if( STATE_TOGGLE == eState )
+ bFlag = !SwViewOption::IsTableBoundaries();
+ SwViewOption::SetAppearanceFlag(VIEWOPT_TABLE_BOUNDARIES, bFlag, sal_True );
+ break;
+
+ case FN_VIEW_FIELDNAME:
+ if( STATE_TOGGLE == eState )
+ bFlag = !pOpt->IsFldName() ;
+
+ pOpt->SetFldName( bFlag );
+ break;
+
+ case FN_VIEW_MARKS:
+ if( STATE_TOGGLE == eState )
+ bFlag = !lcl_IsViewMarks(*pOpt) ;
+
+ lcl_SetViewMarks( *pOpt, bFlag );
+ break;
+
+ case FN_VIEW_META_CHARS:
+ if( STATE_TOGGLE == eState )
+ bFlag = !pOpt->IsViewMetaChars();
+
+ lcl_SetViewMetaChars( *pOpt, bFlag );
+ break;
+
+ case SID_AUTOSPELL_CHECK:
+ if( STATE_TOGGLE == eState )
+ bFlag = bSet = !pOpt->IsOnlineSpell();
+
+ pOpt->SetOnlineSpell(bSet);
+ {
+ uno::Any aVal( &bSet, ::getCppuBooleanType() );
+ OUString aPropName(UPN_IS_SPELL_AUTO);
+
+ SvtLinguConfig aCfg;
+ aCfg.SetProperty( aPropName, aVal );
+
+ if (xLngProp.is())
+ xLngProp->setIsSpellAuto( bSet );
+
+ // for the time being we do not have a specific option for grammarchecking.
+ // thus we'll use the one for spell checking...
+ if (bSet)
+ {
+ SwDocShell *pDocSh = GetDocShell();
+ SwDoc *pDoc = pDocSh? pDocSh->GetDoc() : NULL;
+
+ // right now we don't have view options for automatic grammar checking. Thus...
+ sal_Bool bIsAutoGrammar = sal_False;
+ aCfg.GetProperty( UPN_IS_GRAMMAR_AUTO ) >>= bIsAutoGrammar;
+
+ if (pDoc && bIsAutoGrammar)
+ StartGrammarChecking( *pDoc );
+ }
+ }
+ break;
+
+ case FN_SHADOWCURSOR:
+ if( STATE_TOGGLE == eState )
+ bFlag = bSet = !pOpt->IsShadowCursor();
+
+ pOpt->SetShadowCursor(bSet);
+ break;
+
+ default:
+ delete pOpt;
+ OSL_FAIL("wrong request method");
+ return;
+ }
+
+ // Set UserPrefs, mark request as modified
+ sal_Bool bWebView = 0 != dynamic_cast<const SwWebView*>(this);
+ SwWrtShell &rSh = GetWrtShell();
+ rSh.StartAction();
+ SwModule* pModule = SW_MOD();
+ if( !(*rSh.GetViewOptions() == *pOpt ))
+ {
+ rSh.ApplyViewOptions( *pOpt );
+ if( bBrowseModeChanged )
+ {
+ RecheckBrowseMode();
+ CheckVisArea();
+ }
+
+ // The UsrPref must be marked as modified.
+ // call for initialization
+ pModule->GetUsrPref(bWebView);
+ pModule->CheckSpellChanges( pOpt->IsOnlineSpell(), false, false, false );
+ }
+ //OS: Set back modified again, because view/fields sets the Doc modified.
+ if( !bModified )
+ rSh.ResetModified();
+
+ pModule->ApplyUsrPref( *pOpt, this, bWebView ? VIEWOPT_DEST_WEB : VIEWOPT_DEST_TEXT );
+
+ // #i6193# let postits know about new spellcheck setting
+ if ( nSlot == SID_AUTOSPELL_CHECK )
+ GetPostItMgr()->SetSpellChecking();
+
+ const sal_Bool bLockedView = rSh.IsViewLocked();
+ rSh.LockView( sal_True ); //lock visible section
+ GetWrtShell().EndAction();
+ if( bBrowseModeChanged && !bFlag )
+ CalcVisArea( GetEditWin().GetOutputSizePixel() );
+ rSh.LockView( bLockedView );
+
+ delete pOpt;
+ Invalidate(rReq.GetSlot());
+ if(!pArgs)
+ rReq.AppendItem(SfxBoolItem(nSlot, (sal_Bool)bFlag));
+ rReq.Done();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/uiview/view1.cxx b/sw/source/core/uibase/uiview/view1.cxx
new file mode 100644
index 000000000000..40e001c6fa4f
--- /dev/null
+++ b/sw/source/core/uibase/uiview/view1.cxx
@@ -0,0 +1,185 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <svx/svdpagv.hxx>
+#include <svx/svdview.hxx>
+#include <svx/ruler.hxx>
+#include <svx/sidebar/ContextChangeEventMultiplexer.hxx>
+#include <idxmrk.hxx>
+#include <view.hxx>
+#include <wrtsh.hxx>
+#include <swmodule.hxx>
+#include <viewopt.hxx>
+#include <docsh.hxx>
+#include <globdoc.hxx>
+#include <navipi.hxx>
+#include <fldwrap.hxx>
+#include <redlndlg.hxx>
+#include <dpage.hxx>
+#include <edtwin.hxx>
+#include "formatclipboard.hxx"
+#include <cmdid.h>
+// header for class SfxRequest
+#include <sfx2/request.hxx>
+
+#include <sfx2/viewfrm.hxx>
+
+extern int bDocSzUpdated;
+
+void SwView::Activate(sal_Bool bMDIActivate)
+{
+ // fdo#40438 Update the layout to make sure everything is correct before showing the content
+ m_pWrtShell->StartAction();
+ m_pWrtShell->EndAction( sal_True );
+
+ // Register the current View at the DocShell.
+ // The view remains active at the DocShell until it will
+ // be destroyed or by Activate a new one will be set.
+ SwDocShell* pDocSh = GetDocShell();
+ if(pDocSh)
+ pDocSh->SetView(this);
+ SwModule* pSwMod = SW_MOD();
+ pSwMod->SetView(this);
+
+ // Document size has changed.
+ if(!bDocSzUpdated)
+ DocSzChgd(m_aDocSz);
+
+ // make selection visible
+ if(m_bMakeSelectionVisible)
+ {
+ m_pWrtShell->MakeSelVisible();
+ m_bMakeSelectionVisible = sal_False;
+ }
+ m_pHRuler->SetActive( sal_True );
+ m_pVRuler->SetActive( sal_True );
+
+ if ( bMDIActivate )
+ {
+ m_pWrtShell->ShGetFcs(sal_False); // Selections visible
+
+ if( !m_sSwViewData.isEmpty() )
+ {
+ ReadUserData(m_sSwViewData, false);
+ m_sSwViewData = "";
+ }
+
+ AttrChangedNotify(m_pWrtShell);
+
+ // Initialize Flddlg newly if necessary (e.g. for TYP_SETVAR)
+ sal_uInt16 nId = SwFldDlgWrapper::GetChildWindowId();
+ SfxViewFrame* pVFrame = GetViewFrame();
+ SwFldDlgWrapper *pWrp = (SwFldDlgWrapper*)pVFrame->GetChildWindow(nId);
+ if (pWrp)
+ pWrp->ReInitDlg(GetDocShell());
+
+ // Initialize RedlineDlg newly if necessary
+ nId = SwRedlineAcceptChild::GetChildWindowId();
+ SwRedlineAcceptChild *pRed = (SwRedlineAcceptChild*)pVFrame->GetChildWindow(nId);
+ if (pRed)
+ pRed->ReInitDlg(GetDocShell());
+
+ // reinit IdxMarkDlg
+ nId = SwInsertIdxMarkWrapper::GetChildWindowId();
+ SwInsertIdxMarkWrapper *pIdxMrk = (SwInsertIdxMarkWrapper*)pVFrame->GetChildWindow(nId);
+ if (pIdxMrk)
+ pIdxMrk->ReInitDlg(*m_pWrtShell);
+
+ // reinit AuthMarkDlg
+ nId = SwInsertAuthMarkWrapper::GetChildWindowId();
+ SwInsertAuthMarkWrapper *pAuthMrk = (SwInsertAuthMarkWrapper*)pVFrame->
+ GetChildWindow(nId);
+ if (pAuthMrk)
+ pAuthMrk->ReInitDlg(*m_pWrtShell);
+ }
+ else
+ // At least call the Notify (as a precaution because of the SlotFilter).
+ AttrChangedNotify(m_pWrtShell);
+
+ SfxViewShell::Activate(bMDIActivate);
+}
+
+void SwView::Deactivate(sal_Bool bMDIActivate)
+{
+ extern bool bFlushCharBuffer ;
+ // Are Characters still in the input buffer?
+ if( bFlushCharBuffer )
+ GetEditWin().FlushInBuffer();
+
+ if( bMDIActivate )
+ {
+ m_pWrtShell->ShLooseFcs(); // Selections invisible
+
+ m_pHRuler->SetActive( sal_False );
+ m_pVRuler->SetActive( sal_False );
+ }
+ SfxViewShell::Deactivate(bMDIActivate);
+}
+
+void SwView::MarginChanged()
+{
+ GetWrtShell().SetBrowseBorder( GetMargin() );
+}
+
+void SwView::ExecFormatPaintbrush(SfxRequest& rReq)
+{
+ if(!m_pFormatClipboard)
+ return;
+
+ if( m_pFormatClipboard->HasContent() )
+ {
+ m_pFormatClipboard->Erase();
+
+ SwApplyTemplate aTemplate;
+ GetEditWin().SetApplyTemplate(aTemplate);
+ }
+ else
+ {
+ bool bPersistentCopy = false;
+ const SfxItemSet *pArgs = rReq.GetArgs();
+ if( pArgs && pArgs->Count() >= 1 )
+ {
+ bPersistentCopy = static_cast<bool>(((SfxBoolItem &)pArgs->Get(
+ SID_FORMATPAINTBRUSH)).GetValue());
+ }
+
+ m_pFormatClipboard->Copy( GetWrtShell(), GetPool(), bPersistentCopy );
+
+ SwApplyTemplate aTemplate;
+ aTemplate.m_pFormatClipboard = m_pFormatClipboard;
+ GetEditWin().SetApplyTemplate(aTemplate);
+ }
+ GetViewFrame()->GetBindings().Invalidate(SID_FORMATPAINTBRUSH);
+}
+
+void SwView::StateFormatPaintbrush(SfxItemSet &rSet)
+{
+ if(!m_pFormatClipboard)
+ return;
+
+ bool bHasContent = m_pFormatClipboard && m_pFormatClipboard->HasContent();
+ rSet.Put(SfxBoolItem(SID_FORMATPAINTBRUSH, bHasContent));
+ if(!bHasContent)
+ {
+ if( !m_pFormatClipboard->CanCopyThisType( GetWrtShell().GetSelectionType() ) )
+ rSet.DisableItem( SID_FORMATPAINTBRUSH );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/uiview/view2.cxx b/sw/source/core/uibase/uiview/view2.cxx
new file mode 100644
index 000000000000..9133455ca429
--- /dev/null
+++ b/sw/source/core/uibase/uiview/view2.cxx
@@ -0,0 +1,2469 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <com/sun/star/util/SearchOptions.hpp>
+#include <com/sun/star/util/SearchFlags.hpp>
+#include <com/sun/star/i18n/TransliterationModules.hpp>
+#include <vcl/graphicfilter.hxx>
+#include <com/sun/star/sdb/DatabaseContext.hpp>
+#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
+#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
+#include <com/sun/star/ui/dialogs/ListboxControlActions.hpp>
+#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
+#include <svl/aeitem.hxx>
+#include <SwStyleNameMapper.hxx>
+#include <docary.hxx>
+#include <hintids.hxx>
+#include <SwRewriter.hxx>
+#include <numrule.hxx>
+#include <swundo.hxx>
+#include <caption.hxx>
+#include <svl/PasswordHelper.hxx>
+#include <svl/urihelper.hxx>
+#include <svtools/miscopt.hxx>
+#include <sfx2/passwd.hxx>
+#include <sfx2/sfxdlg.hxx>
+#include <sfx2/filedlghelper.hxx>
+#include <sfx2/sfxhelp.hxx>
+#include <editeng/langitem.hxx>
+#include <svx/viewlayoutitem.hxx>
+#include <svx/zoomslideritem.hxx>
+#include <svtools/xwindowitem.hxx>
+#include <svx/linkwarn.hxx>
+#include <sfx2/htmlmode.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/wrkwin.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/bindings.hxx>
+#include <editeng/lrspitem.hxx>
+#include <unotools/textsearch.hxx>
+#include "editeng/unolingu.hxx"
+#include <vcl/msgbox.hxx>
+#include <editeng/tstpitem.hxx>
+#include <sfx2/event.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/docfilt.hxx>
+#include <sfx2/fcontnr.hxx>
+#include <editeng/sizeitem.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svl/whiter.hxx>
+#include <svl/ptitem.hxx>
+#include <sfx2/linkmgr.hxx>
+#include <tools/errinf.hxx>
+#include <tools/urlobj.hxx>
+#include <svx/svdview.hxx>
+#include <swtypes.hxx>
+#include <swwait.hxx>
+#include <redlndlg.hxx>
+#include <view.hxx>
+#include <uivwimp.hxx>
+#include <docsh.hxx>
+#include <doc.hxx>
+#include <IDocumentUndoRedo.hxx>
+#include <wrtsh.hxx>
+#include <viewopt.hxx>
+#include <basesh.hxx>
+#include <swmodule.hxx>
+#include <uitool.hxx>
+#include <shellio.hxx>
+#include <fmtinfmt.hxx>
+#include <mdiexp.hxx>
+#include <drawbase.hxx>
+#include <frmmgr.hxx>
+#include <pagedesc.hxx>
+#include <section.hxx>
+#include <usrpref.hxx>
+#include <IMark.hxx>
+#include <navipi.hxx>
+#include <tox.hxx>
+#include <workctrl.hxx>
+#include <scroll.hxx>
+#include <edtwin.hxx>
+#include <wview.hxx>
+#include <textsh.hxx>
+#include <tabsh.hxx>
+#include <listsh.hxx>
+#include <cmdid.h>
+#include <comcore.hrc>
+#include <poolfmt.hrc>
+#include <statstr.hrc>
+#include <swerror.h>
+#include <globals.hrc>
+#include <shells.hrc>
+#include <web.hrc>
+#include <view.hrc>
+#include <app.hrc>
+#include <fmtclds.hxx>
+#include <helpid.h>
+#include <svtools/templdlg.hxx>
+#include <dbconfig.hxx>
+#include <dbmgr.hxx>
+#include <reffld.hxx>
+
+#include <PostItMgr.hxx>
+
+#include <ndtxt.hxx>
+
+#include <comphelper/processfactory.hxx>
+#include <comphelper/string.hxx>
+
+#include <svx/svxdlg.hxx>
+#include <svx/dialogs.hrc>
+#include "swabstdlg.hxx"
+#include <envelp.hrc>
+#include <fmthdft.hxx>
+#include <svx/ofaitem.hxx>
+#include <unomid.h>
+#include <unotextrange.hxx>
+#include <docstat.hxx>
+#include <wordcountdialog.hxx>
+
+#include <vcl/GraphicNativeTransform.hxx>
+#include <vcl/GraphicNativeMetadata.hxx>
+#include <vcl/settings.hxx>
+
+#include <boost/scoped_ptr.hpp>
+
+const char sStatusDelim[] = " : ";
+const char sStatusComma[] = " , ";
+
+using namespace sfx2;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::i18n;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::scanner;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::ui::dialogs;
+
+static void lcl_SetAllTextToDefaultLanguage( SwWrtShell &rWrtSh, sal_uInt16 nWhichId )
+{
+ if (nWhichId == RES_CHRATR_LANGUAGE ||
+ nWhichId == RES_CHRATR_CJK_LANGUAGE ||
+ nWhichId == RES_CHRATR_CTL_LANGUAGE)
+ {
+ rWrtSh.StartAction();
+ rWrtSh.LockView( sal_True );
+ rWrtSh.Push();
+
+ // prepare to apply new language to all text in document
+ rWrtSh.SelAll();
+ rWrtSh.ExtendedSelectAll();
+
+ // set language attribute to default for all text
+ std::set<sal_uInt16> aAttribs;
+ aAttribs.insert( nWhichId );
+ rWrtSh.ResetAttr( aAttribs );
+
+ rWrtSh.Pop( sal_False );
+ rWrtSh.LockView( sal_False );
+ rWrtSh.EndAction();
+ }
+}
+
+/* Create string for showing of page in statusbar */
+OUString SwView::GetPageStr( sal_uInt16 nPg, sal_uInt16 nLogPg,
+ const OUString& rDisplay )
+{
+ OUString aStr( m_aPageStr );
+ if( !rDisplay.isEmpty() )
+ aStr += rDisplay;
+ else
+ aStr += OUString::number(nLogPg);
+
+ if( nLogPg && nLogPg != nPg )
+ {
+ aStr += " ";
+ aStr += OUString::number(nPg);
+ }
+ aStr += " / ";
+ aStr += OUString::number( GetWrtShell().GetPageCnt() );
+
+ return aStr;
+}
+
+int SwView::InsertGraphic( const OUString &rPath, const OUString &rFilter,
+ sal_Bool bLink, GraphicFilter *pFilter,
+ Graphic* pPreviewGrf, sal_Bool bRule )
+{
+ SwWait aWait( *GetDocShell(), true );
+
+ Graphic aGraphic;
+ int aResult = GRFILTER_OK;
+ if ( pPreviewGrf )
+ aGraphic = *pPreviewGrf;
+ else
+ {
+ if( !pFilter )
+ {
+ pFilter = &GraphicFilter::GetGraphicFilter();
+ }
+ aResult = GraphicFilter::LoadGraphic( rPath, rFilter, aGraphic, pFilter );
+ }
+
+ if( GRFILTER_OK == aResult )
+ {
+ GraphicNativeMetadata aMetadata;
+ if ( aMetadata.read(aGraphic) )
+ {
+ sal_uInt16 aRotation = aMetadata.getRotation();
+ if (aRotation != 0)
+ {
+ MessageDialog aQueryBox( GetWindow(),"QueryRotateIntoStandardOrientationDialog","modules/swriter/ui/queryrotateintostandarddialog.ui");
+ if (aQueryBox.Execute() == RET_YES)
+ {
+ GraphicNativeTransform aTransform( aGraphic );
+ aTransform.rotate( aRotation );
+ }
+ }
+ }
+
+ SwFlyFrmAttrMgr aFrameManager( sal_True, GetWrtShellPtr(), FRMMGR_TYPE_GRF );
+ SwWrtShell& rShell = GetWrtShell();
+
+ // #i123922# determine if we really want to insert or replace the graphic at a selected object
+ const bool bReplaceMode(rShell.HasSelection() && nsSelectionType::SEL_FRM == rShell.GetSelectionType());
+
+ if(bReplaceMode)
+ {
+ // #i123922# Do same as in D&D, ReRead graphic and all is done
+ rShell.ReRead(
+ bLink ? rPath : OUString(),
+ bLink ? rFilter : OUString(),
+ &aGraphic);
+ }
+ else
+ {
+ rShell.StartAction();
+ if( bLink )
+ {
+ SwDocShell* pDocSh = GetDocShell();
+ INetURLObject aTemp(
+ pDocSh->HasName() ?
+ pDocSh->GetMedium()->GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) :
+ OUString());
+
+ OUString sURL = URIHelper::SmartRel2Abs(
+ aTemp, rPath, URIHelper::GetMaybeFileHdl() );
+
+ rShell.Insert( sURL,
+ rFilter, aGraphic, &aFrameManager, bRule );
+ }
+ else
+ {
+ rShell.Insert( OUString(), OUString(), aGraphic, &aFrameManager );
+ }
+
+ // it is too late after "EndAction" because the Shell can already be destroyed.
+ rShell.EndAction();
+ }
+ }
+ return aResult;
+}
+
+sal_Bool SwView::InsertGraphicDlg( SfxRequest& rReq )
+{
+ sal_Bool bReturn = sal_False;
+ SwDocShell* pDocShell = GetDocShell();
+ sal_uInt16 nHtmlMode = ::GetHtmlMode(pDocShell);
+ // when in HTML mode insert only as a link
+ boost::scoped_ptr<FileDialogHelper> pFileDlg(new FileDialogHelper(
+ ui::dialogs::TemplateDescription::FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE,
+ SFXWB_GRAPHIC ));
+ pFileDlg->SetTitle(SW_RESSTR(STR_INSERT_GRAPHIC ));
+ pFileDlg->SetContext( FileDialogHelper::SW_INSERT_GRAPHIC );
+ uno::Reference < XFilePicker > xFP = pFileDlg->GetFilePicker();
+ uno::Reference < XFilePickerControlAccess > xCtrlAcc(xFP, UNO_QUERY);
+ if(nHtmlMode & HTMLMODE_ON)
+ {
+ sal_Bool bTrue = sal_True;
+ Any aVal(&bTrue, ::getBooleanCppuType());
+ xCtrlAcc->setValue( ExtendedFilePickerElementIds::CHECKBOX_LINK, 0, aVal);
+ xCtrlAcc->enableControl( ExtendedFilePickerElementIds::CHECKBOX_LINK, sal_False);
+ }
+
+ std::vector<OUString> aFormats;
+ SwDoc* pDoc = pDocShell->GetDoc();
+ const sal_uInt16 nArrLen = pDoc->GetFrmFmts()->size();
+ sal_uInt16 i;
+ for( i = 0; i < nArrLen; i++ )
+ {
+ SwFrmFmt* pFmt = (*pDoc->GetFrmFmts())[ i ];
+ if(pFmt->IsDefault() || pFmt->IsAuto())
+ continue;
+ aFormats.push_back(pFmt->GetName());
+ }
+
+ // pool formats
+
+ const ::std::vector<OUString>& rFrmPoolArr(
+ SwStyleNameMapper::GetFrmFmtUINameArray());
+ for( i = 0; i < rFrmPoolArr.size(); ++i )
+ {
+ aFormats.push_back(rFrmPoolArr[i]);
+ }
+
+ std::sort(aFormats.begin(), aFormats.end());
+ aFormats.erase(std::unique(aFormats.begin(), aFormats.end()), aFormats.end());
+
+ Sequence<OUString> aListBoxEntries(aFormats.size());
+ OUString* pEntries = aListBoxEntries.getArray();
+ sal_Int16 nSelect = 0;
+ OUString sGraphicFormat = SW_RESSTR(STR_POOLFRM_GRAPHIC);
+ for( i = 0; i < aFormats.size(); i++ )
+ {
+ pEntries[i] = aFormats[i];
+ if(pEntries[i].equals(sGraphicFormat))
+ nSelect = i;
+ }
+ try
+ {
+ Any aTemplates(&aListBoxEntries, ::getCppuType(&aListBoxEntries));
+
+ xCtrlAcc->setValue( ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE,
+ ListboxControlActions::ADD_ITEMS , aTemplates );
+
+ Any aSelectPos(&nSelect, ::getCppuType(&nSelect));
+ xCtrlAcc->setValue( ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE,
+ ListboxControlActions::SET_SELECT_ITEM, aSelectPos );
+ }
+ catch (const Exception&)
+ {
+ OSL_FAIL("control acces failed");
+ }
+
+ SFX_REQUEST_ARG( rReq, pName, SfxStringItem, SID_INSERT_GRAPHIC , false );
+ sal_Bool bShowError = !pName;
+ if( pName || ERRCODE_NONE == pFileDlg->Execute() )
+ {
+
+ OUString aFileName, aFilterName;
+ if ( pName )
+ {
+ aFileName = pName->GetValue();
+ SFX_REQUEST_ARG( rReq, pFilter, SfxStringItem, FN_PARAM_FILTER , false );
+ if ( pFilter )
+ aFilterName = pFilter->GetValue();
+ }
+ else
+ {
+ aFileName = pFileDlg->GetPath();
+ aFilterName = pFileDlg->GetCurrentFilter();
+ rReq.AppendItem( SfxStringItem( SID_INSERT_GRAPHIC, aFileName ) );
+ rReq.AppendItem( SfxStringItem( FN_PARAM_FILTER, aFilterName ) );
+
+ sal_Bool bAsLink = sal_False;
+ if(nHtmlMode & HTMLMODE_ON)
+ bAsLink = sal_True;
+ else
+ {
+ try
+ {
+ Any aVal = xCtrlAcc->getValue( ExtendedFilePickerElementIds::CHECKBOX_LINK, 0);
+ OSL_ENSURE(aVal.hasValue(), "Value CBX_INSERT_AS_LINK not found");
+ bAsLink = aVal.hasValue() ? *(sal_Bool*) aVal.getValue() : sal_True;
+ Any aTemplateValue = xCtrlAcc->getValue(
+ ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE,
+ ListboxControlActions::GET_SELECTED_ITEM );
+ OUString sTmpl;
+ aTemplateValue >>= sTmpl;
+ rReq.AppendItem( SfxStringItem( FN_PARAM_2, sTmpl) );
+ }
+ catch (const Exception&)
+ {
+ OSL_FAIL("control access failed");
+ }
+ }
+ rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bAsLink ) );
+ }
+
+ SFX_REQUEST_ARG( rReq, pAsLink, SfxBoolItem, FN_PARAM_1 , false );
+ SFX_REQUEST_ARG( rReq, pStyle, SfxStringItem, FN_PARAM_2 , false );
+
+ sal_Bool bAsLink = sal_False;
+ if( nHtmlMode & HTMLMODE_ON )
+ bAsLink = sal_True;
+ else
+ {
+ if ( rReq.GetArgs() )
+ {
+ if ( pAsLink )
+ bAsLink = pAsLink->GetValue();
+ if ( pStyle && !pStyle->GetValue().isEmpty() )
+ sGraphicFormat = pStyle->GetValue();
+ }
+ else
+ {
+ Any aVal = xCtrlAcc->getValue( ExtendedFilePickerElementIds::CHECKBOX_LINK, 0);
+ OSL_ENSURE(aVal.hasValue(), "Value CBX_INSERT_AS_LINK not found");
+ bAsLink = aVal.hasValue() ? *(sal_Bool*) aVal.getValue() : sal_True;
+ Any aTemplateValue = xCtrlAcc->getValue(
+ ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE,
+ ListboxControlActions::GET_SELECTED_ITEM );
+ OUString sTmpl;
+ aTemplateValue >>= sTmpl;
+ if( !sTmpl.isEmpty() )
+ sGraphicFormat = sTmpl;
+ rReq.AppendItem( SfxStringItem( FN_PARAM_2, sGraphicFormat ) );
+ rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bAsLink ) );
+ }
+
+ // really store as link only?
+ if( bAsLink && SvtMiscOptions().ShowLinkWarningDialog() )
+ {
+ SvxLinkWarningDialog aWarnDlg(GetWindow(),pFileDlg->GetPath());
+ if( aWarnDlg.Execute() != RET_OK )
+ bAsLink=sal_False; // don't store as link
+ }
+ }
+
+ SwWrtShell& rSh = GetWrtShell();
+ rSh.LockPaint();
+ rSh.StartAction();
+
+ SwRewriter aRewriter;
+ aRewriter.AddRule(UndoArg1, SW_RESSTR(STR_GRAPHIC_DEFNAME));
+
+ // #i123922# determine if we really want to insert or replace the graphic at a selected object
+ const bool bReplaceMode(rSh.HasSelection() && nsSelectionType::SEL_FRM == rSh.GetSelectionType());
+
+ rSh.StartUndo(UNDO_INSERT, &aRewriter);
+
+ int nError = InsertGraphic( aFileName, aFilterName, bAsLink, &GraphicFilter::GetGraphicFilter() );
+
+ // format not equal to current filter (with autodetection)
+ if( nError == GRFILTER_FORMATERROR )
+ nError = InsertGraphic( aFileName, OUString(), bAsLink, &GraphicFilter::GetGraphicFilter() );
+
+ // #i123922# no new FrameFormat for replace mode, only when new object was created,
+ // else this would reset the current setting for the frame holding the graphic
+ if ( !bReplaceMode && rSh.IsFrmSelected() )
+ {
+ SwFrmFmt* pFmt = pDoc->FindFrmFmtByName( sGraphicFormat );
+ if(!pFmt)
+ pFmt = pDoc->MakeFrmFmt(sGraphicFormat,
+ pDocShell->GetDoc()->GetDfltFrmFmt(),
+ true, false);
+ rSh.SetFrmFmt( pFmt );
+ }
+
+ RESOURCE_TYPE nResId = 0;
+ switch( nError )
+ {
+ case GRFILTER_OPENERROR:
+ nResId = STR_GRFILTER_OPENERROR;
+ break;
+ case GRFILTER_IOERROR:
+ nResId = STR_GRFILTER_IOERROR;
+ break;
+ case GRFILTER_FORMATERROR:
+ nResId = STR_GRFILTER_FORMATERROR;
+ break;
+ case GRFILTER_VERSIONERROR:
+ nResId = STR_GRFILTER_VERSIONERROR;
+ break;
+ case GRFILTER_FILTERERROR:
+ nResId = STR_GRFILTER_FILTERERROR;
+ break;
+ case GRFILTER_TOOBIG:
+ nResId = STR_GRFILTER_TOOBIG;
+ break;
+ }
+
+ rSh.EndAction();
+ rSh.UnlockPaint();
+ if( nResId )
+ {
+ if( bShowError )
+ {
+ InfoBox aInfoBox( GetWindow(), SW_RESSTR( nResId ));
+ aInfoBox.Execute();
+ }
+ rReq.Ignore();
+ }
+ else
+ {
+ // set the specific graphic attrbutes to the graphic
+ bReturn = sal_True;
+ AutoCaption( GRAPHIC_CAP );
+ rReq.Done();
+ }
+
+ rSh.EndUndo(); // due to possible change of Shell
+ }
+
+ return bReturn;
+}
+
+void SwView::Execute(SfxRequest &rReq)
+{
+ sal_uInt16 nSlot = rReq.GetSlot();
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ const SfxPoolItem* pItem;
+ sal_Bool bIgnore = sal_False;
+ switch( nSlot )
+ {
+ case SID_CREATE_SW_DRAWVIEW:
+ m_pWrtShell->getIDocumentDrawModelAccess()->GetOrCreateDrawModel();
+ break;
+
+ case FN_LINE_NUMBERING_DLG:
+ {
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "Dialogdiet fail!");
+ boost::scoped_ptr<VclAbstractDialog> pDlg(pFact->CreateVclSwViewDialog(*this));
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ pDlg->Execute();
+ break;
+ }
+ case FN_EDIT_LINK_DLG:
+ EditLinkDlg();
+ break;
+ case FN_REFRESH_VIEW:
+ GetEditWin().Invalidate();
+ break;
+ case FN_PAGEUP:
+ case FN_PAGEUP_SEL:
+ case FN_PAGEDOWN:
+ case FN_PAGEDOWN_SEL:
+ {
+ Rectangle aVis( GetVisArea() );
+ SwEditWin& rTmpWin = GetEditWin();
+ if ( FN_PAGEUP == nSlot || FN_PAGEUP_SEL == nSlot )
+ PageUpCrsr(FN_PAGEUP_SEL == nSlot);
+ else
+ PageDownCrsr(FN_PAGEDOWN_SEL == nSlot);
+
+ rReq.SetReturnValue(SfxBoolItem(nSlot,
+ aVis != GetVisArea()));
+ //#i42732# - notify the edit window that from now on we do not use the input language
+ rTmpWin.SetUseInputLanguage( sal_False );
+ }
+ break;
+ case FN_REDLINE_ON:
+ {
+ if( pArgs &&
+ SFX_ITEM_SET == pArgs->GetItemState(nSlot, false, &pItem ))
+ {
+ IDocumentRedlineAccess* pIDRA = m_pWrtShell->getIDocumentRedlineAccess();
+ Sequence <sal_Int8> aPasswd = pIDRA->GetRedlinePassword();
+ if( aPasswd.getLength() )
+ {
+ OSL_ENSURE( !((const SfxBoolItem*)pItem)->GetValue(), "SwView::Execute(): password set an redlining off doesn't match!" );
+ // xmlsec05: new password dialog
+ Window* pParent;
+ const SfxPoolItem* pParentItem;
+ if( SFX_ITEM_SET == pArgs->GetItemState( SID_ATTR_XWINDOW, false, &pParentItem ) )
+ pParent = ( ( const XWindowItem* ) pParentItem )->GetWindowPtr();
+ else
+ pParent = &GetViewFrame()->GetWindow();
+ SfxPasswordDialog aPasswdDlg( pParent );
+ aPasswdDlg.SetMinLen( 1 );
+ //#i69751# the result of Execute() can be ignored
+ aPasswdDlg.Execute();
+ OUString sNewPasswd( aPasswdDlg.GetPassword() );
+ Sequence <sal_Int8> aNewPasswd = pIDRA->GetRedlinePassword();
+ SvPasswordHelper::GetHashPassword( aNewPasswd, sNewPasswd );
+ if(SvPasswordHelper::CompareHashPassword(aPasswd, sNewPasswd))
+ pIDRA->SetRedlinePassword(Sequence <sal_Int8> ());
+ else
+ { // xmlsec05: message box for wrong password
+ break;
+ }
+ }
+
+ sal_uInt16 nOn = ((const SfxBoolItem*)pItem)->GetValue() ? nsRedlineMode_t::REDLINE_ON : 0;
+ sal_uInt16 nMode = m_pWrtShell->GetRedlineMode();
+ m_pWrtShell->SetRedlineModeAndCheckInsMode( (nMode & ~nsRedlineMode_t::REDLINE_ON) | nOn);
+ }
+ }
+ break;
+ case FN_REDLINE_PROTECT :
+ {
+ IDocumentRedlineAccess* pIDRA = m_pWrtShell->getIDocumentRedlineAccess();
+ Sequence <sal_Int8> aPasswd = pIDRA->GetRedlinePassword();
+ if( pArgs && SFX_ITEM_SET == pArgs->GetItemState(nSlot, false, &pItem )
+ && ((SfxBoolItem*)pItem)->GetValue() == ( aPasswd.getLength() != 0 ) )
+ break;
+
+ // xmlsec05: new password dialog
+ // message box for wrong password
+ Window* pParent;
+ const SfxPoolItem* pParentItem;
+ if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( SID_ATTR_XWINDOW, false, &pParentItem ) )
+ pParent = ( ( const XWindowItem* ) pParentItem )->GetWindowPtr();
+ else
+ pParent = &GetViewFrame()->GetWindow();
+ SfxPasswordDialog aPasswdDlg( pParent );
+ aPasswdDlg.SetMinLen( 1 );
+ if(!aPasswd.getLength())
+ aPasswdDlg.ShowExtras(SHOWEXTRAS_CONFIRM);
+ if (aPasswdDlg.Execute())
+ {
+ sal_uInt16 nOn = nsRedlineMode_t::REDLINE_ON;
+ OUString sNewPasswd( aPasswdDlg.GetPassword() );
+ Sequence <sal_Int8> aNewPasswd =
+ pIDRA->GetRedlinePassword();
+ SvPasswordHelper::GetHashPassword( aNewPasswd, sNewPasswd );
+ if(!aPasswd.getLength())
+ {
+ pIDRA->SetRedlinePassword(aNewPasswd);
+ }
+ else if(SvPasswordHelper::CompareHashPassword(aPasswd, sNewPasswd))
+ {
+ pIDRA->SetRedlinePassword(Sequence <sal_Int8> ());
+ nOn = 0;
+ }
+ sal_uInt16 nMode = pIDRA->GetRedlineMode();
+ m_pWrtShell->SetRedlineModeAndCheckInsMode( (nMode & ~nsRedlineMode_t::REDLINE_ON) | nOn);
+ rReq.AppendItem( SfxBoolItem( FN_REDLINE_PROTECT, ((nMode&nsRedlineMode_t::REDLINE_ON)==0) ) );
+ }
+ else
+ bIgnore = sal_True;
+ }
+ break;
+ case FN_REDLINE_SHOW:
+
+ if( pArgs &&
+ SFX_ITEM_SET == pArgs->GetItemState(nSlot, false, &pItem))
+ {
+ sal_uInt16 nMode = ( ~(nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE)
+ & m_pWrtShell->GetRedlineMode() ) | nsRedlineMode_t::REDLINE_SHOW_INSERT;
+ if( ((const SfxBoolItem*)pItem)->GetValue() )
+ nMode |= nsRedlineMode_t::REDLINE_SHOW_DELETE;
+
+ m_pWrtShell->SetRedlineModeAndCheckInsMode( nMode );
+ }
+ break;
+ case FN_MAILMERGE_SENDMAIL_CHILDWINDOW:
+ case FN_REDLINE_ACCEPT:
+ GetViewFrame()->ToggleChildWindow(nSlot);
+ break;
+ case FN_REDLINE_ACCEPT_DIRECT:
+ case FN_REDLINE_REJECT_DIRECT:
+ {
+ // We check for a redline at the start of the selection/cursor, not the point.
+ // This ensures we work properly with FN_REDLINE_NEXT_CHANGE, which leaves the
+ // point at the *end* of the redline and the mark at the start (so GetRedline
+ // would return NULL if called on the point)
+ SwDoc *pDoc = m_pWrtShell->GetDoc();
+ SwPaM *pCursor = m_pWrtShell->GetCrsr();
+
+ sal_uInt16 nRedline = 0;
+ const SwRangeRedline *pRedline = pDoc->GetRedline(*pCursor->Start(), &nRedline);
+ assert(pRedline != 0);
+ if (pRedline)
+ {
+ if (FN_REDLINE_ACCEPT_DIRECT == nSlot)
+ m_pWrtShell->AcceptRedline(nRedline);
+ else
+ m_pWrtShell->RejectRedline(nRedline);
+ }
+ }
+ break;
+
+ case FN_REDLINE_NEXT_CHANGE:
+ {
+ const SwRangeRedline *pCurrent = m_pWrtShell->GetCurrRedline();
+ const SwRangeRedline *pNext = m_pWrtShell->SelNextRedline();
+
+ // FN_REDLINE_PREV_CHANGE leaves the selection point at the start of the redline.
+ // In such cases, SelNextRedline (which starts searching from the selection point)
+ // immediately finds the current redline and advances the selection point to its end.
+
+ // This behavior means that PREV_CHANGE followed by NEXT_CHANGE would not change
+ // the current redline, so we detect it and select the next redline again.
+ if (pCurrent && pCurrent == pNext)
+ pNext = m_pWrtShell->SelNextRedline();
+
+ if (pNext)
+ m_pWrtShell->SetInSelect();
+ }
+ break;
+
+ case FN_REDLINE_PREV_CHANGE:
+ {
+ const SwPaM *pCursor = m_pWrtShell->GetCrsr();
+ const SwPosition initialCursorStart = *pCursor->Start();
+ const SwRangeRedline *pPrev = m_pWrtShell->SelPrevRedline();
+
+ if (pPrev)
+ {
+ // FN_REDLINE_NEXT_CHANGE leaves the selection point at the end of the redline.
+ // In such cases, SelPrevRedline (which starts searching from the selection point)
+ // immediately finds the current redline and advances the selection point to its
+ // start.
+
+ // This behavior means that NEXT_CHANGE followed by PREV_CHANGE would not change
+ // the current redline, so we detect it and move to the previous redline again.
+ if (initialCursorStart == *pPrev->Start())
+ pPrev = m_pWrtShell->SelPrevRedline();
+ }
+
+ if (pPrev)
+ m_pWrtShell->SetInSelect();
+ }
+ break;
+
+ case SID_DOCUMENT_COMPARE:
+ case SID_DOCUMENT_MERGE:
+ {
+ OUString sFileName, sFilterName;
+ sal_Int16 nVersion = 0;
+ bool bHasFileName = false;
+ m_pViewImpl->SetParam( 0 );
+
+ if( pArgs )
+ {
+ if( SFX_ITEM_SET == pArgs->GetItemState( SID_FILE_NAME, false, &pItem ))
+ sFileName = ((const SfxStringItem*)pItem)->GetValue();
+ bHasFileName = !sFileName.isEmpty();
+
+ if( SFX_ITEM_SET == pArgs->GetItemState( SID_FILTER_NAME, false, &pItem ))
+ sFilterName = ((const SfxStringItem*)pItem)->GetValue();
+
+ if( SFX_ITEM_SET == pArgs->GetItemState( SID_VERSION, false, &pItem ))
+ {
+ nVersion = ((const SfxInt16Item *)pItem)->GetValue();
+ m_pViewImpl->SetParam( nVersion );
+ }
+ }
+
+ m_pViewImpl->InitRequest( rReq );
+ long nFound = InsertDoc( nSlot, sFileName, sFilterName, nVersion );
+
+ if ( bHasFileName )
+ {
+ rReq.SetReturnValue( SfxInt32Item( nSlot, nFound ));
+
+ if (nFound > 0) // show Redline browser
+ {
+ SfxViewFrame* pVFrame = GetViewFrame();
+ pVFrame->ShowChildWindow(FN_REDLINE_ACCEPT);
+
+ // re-initialize the Redline dialog
+ sal_uInt16 nId = SwRedlineAcceptChild::GetChildWindowId();
+ SwRedlineAcceptChild *pRed = (SwRedlineAcceptChild*)
+ pVFrame->GetChildWindow(nId);
+ if (pRed)
+ pRed->ReInitDlg(GetDocShell());
+ }
+ }
+ else
+ bIgnore = sal_True;
+ }
+ break;
+ case FN_SYNC_LABELS:
+ case FN_MAILMERGE_CHILDWINDOW:
+ GetViewFrame()->ShowChildWindow(nSlot, sal_True);
+ break;
+ case FN_ESCAPE:
+ {
+ if ( m_pWrtShell->HasDrawView() && m_pWrtShell->GetDrawView()->IsDragObj() )
+ {
+ m_pWrtShell->BreakDrag();
+ m_pWrtShell->EnterSelFrmMode();
+ }
+ else if ( m_pWrtShell->IsDrawCreate() )
+ {
+ GetDrawFuncPtr()->BreakCreate();
+ AttrChangedNotify(m_pWrtShell); // shell change if needed
+ }
+ else if ( m_pWrtShell->HasSelection() || IsDrawMode() )
+ {
+ SdrView *pSdrView = m_pWrtShell->HasDrawView() ? m_pWrtShell->GetDrawView() : 0;
+ if(pSdrView && pSdrView->AreObjectsMarked() &&
+ pSdrView->GetHdlList().GetFocusHdl())
+ {
+ ((SdrHdlList&)pSdrView->GetHdlList()).ResetFocusHdl();
+ }
+ else
+ {
+ if(pSdrView)
+ {
+ LeaveDrawCreate();
+ Point aPt(LONG_MIN, LONG_MIN);
+ //go out of the frame
+ m_pWrtShell->SelectObj(aPt, SW_LEAVE_FRAME);
+ SfxBindings& rBind = GetViewFrame()->GetBindings();
+ rBind.Invalidate( SID_ATTR_SIZE );
+ }
+ m_pWrtShell->EnterStdMode();
+ AttrChangedNotify(m_pWrtShell); // shell change if necessary
+ }
+ }
+ else if ( GetEditWin().GetApplyTemplate() )
+ {
+ GetEditWin().SetApplyTemplate(SwApplyTemplate());
+ }
+ else if( ((SfxObjectShell*)GetDocShell())->IsInPlaceActive() )
+ {
+ Escape();
+ }
+ else if ( GetEditWin().IsChainMode() )
+ {
+ GetEditWin().SetChainMode( sal_False );
+ }
+ else if( m_pWrtShell->GetFlyFrmFmt() )
+ {
+ const SwFrmFmt* pFmt = m_pWrtShell->GetFlyFrmFmt();
+ if(m_pWrtShell->GotoFly( pFmt->GetName(), FLYCNTTYPE_FRM ))
+ {
+ m_pWrtShell->HideCrsr();
+ m_pWrtShell->EnterSelFrmMode();
+ }
+ }
+ else
+ {
+ SfxBoolItem aItem( SID_WIN_FULLSCREEN, false );
+ GetViewFrame()->GetDispatcher()->Execute( SID_WIN_FULLSCREEN, SFX_CALLMODE_RECORD, &aItem, 0L );
+ bIgnore = sal_True;
+ }
+ }
+ break;
+ case SID_ATTR_BORDER_INNER:
+ case SID_ATTR_BORDER_OUTER:
+ case SID_ATTR_BORDER_SHADOW:
+ if(pArgs)
+ m_pWrtShell->SetAttrSet(*pArgs);
+ break;
+
+ case SID_ATTR_PAGE:
+ case SID_ATTR_PAGE_SIZE:
+ case SID_ATTR_PAGE_MAXSIZE:
+ case SID_ATTR_PAGE_PAPERBIN:
+ case SID_ATTR_PAGE_EXT1:
+ case FN_PARAM_FTN_INFO:
+ {
+ if(pArgs)
+ {
+ const sal_uInt16 nCurIdx = m_pWrtShell->GetCurPageDesc();
+ SwPageDesc aPageDesc( m_pWrtShell->GetPageDesc( nCurIdx ) );
+ ::ItemSetToPageDesc( *pArgs, aPageDesc );
+ // change the descriptor of the core
+ m_pWrtShell->ChgPageDesc( nCurIdx, aPageDesc );
+ }
+ }
+ break;
+ case FN_NAVIGATION_PI_GOTO_PAGE:
+ {
+ SfxViewFrame* pVFrame = GetViewFrame();
+ SfxChildWindow* pCh = pVFrame->GetChildWindow( SID_NAVIGATOR );
+ if(!pCh)
+ {
+ pVFrame->ToggleChildWindow( SID_NAVIGATOR );
+ pCh = pVFrame->GetChildWindow( SID_NAVIGATOR );
+
+ }
+ ((SwNavigationPI*) pCh->GetContextWindow(SW_MOD()))->GotoPage();
+ }
+ break;
+ case FN_EDIT_CURRENT_TOX:
+ {
+ GetViewFrame()->GetDispatcher()->Execute(
+ FN_INSERT_MULTI_TOX, SFX_CALLMODE_ASYNCHRON);
+ }
+ break;
+ case FN_UPDATE_CUR_TOX:
+ {
+ const SwTOXBase* pBase = m_pWrtShell->GetCurTOX();
+ if(pBase)
+ {
+ m_pWrtShell->StartAction();
+ if(TOX_INDEX == pBase->GetType())
+ m_pWrtShell->ApplyAutoMark();
+ m_pWrtShell->UpdateTableOf( *pBase );
+ m_pWrtShell->EndAction();
+ }
+ }
+ break;
+ case FN_UPDATE_TOX:
+ {
+ m_pWrtShell->StartAction();
+ m_pWrtShell->EnterStdMode();
+ sal_Bool bOldCrsrInReadOnly = m_pWrtShell->IsReadOnlyAvailable();
+ m_pWrtShell->SetReadOnlyAvailable( sal_True );
+
+ for( sal_uInt16 i = 0; i < 2; ++i )
+ {
+ sal_uInt16 nCount = m_pWrtShell->GetTOXCount();
+ if( 1 == nCount )
+ ++i;
+
+ while( m_pWrtShell->GotoPrevTOXBase() )
+ ; // jump to the first "table of ..."
+
+ // if we are not in one, jump to next
+ const SwTOXBase* pBase = m_pWrtShell->GetCurTOX();
+ if( !pBase )
+ {
+ m_pWrtShell->GotoNextTOXBase();
+ pBase = m_pWrtShell->GetCurTOX();
+ }
+
+ sal_Bool bAutoMarkApplied = sal_False;
+ while( pBase )
+ {
+ if(TOX_INDEX == pBase->GetType() && !bAutoMarkApplied)
+ {
+ m_pWrtShell->ApplyAutoMark();
+ bAutoMarkApplied = sal_True;
+ }
+ // pBase is needed only for the interface. Should be changed in future! (JP 1996)
+ m_pWrtShell->UpdateTableOf( *pBase );
+
+ if( m_pWrtShell->GotoNextTOXBase() )
+ pBase = m_pWrtShell->GetCurTOX();
+ else
+ pBase = 0;
+ }
+ }
+ m_pWrtShell->SetReadOnlyAvailable( bOldCrsrInReadOnly );
+ m_pWrtShell->EndAction();
+ }
+ break;
+ case SID_ATTR_BRUSH:
+ {
+ if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(RES_BACKGROUND, false, &pItem))
+ {
+ const sal_uInt16 nCurIdx = m_pWrtShell->GetCurPageDesc();
+ SwPageDesc aDesc( m_pWrtShell->GetPageDesc( nCurIdx ));
+ SwFrmFmt& rMaster = aDesc.GetMaster();
+ rMaster.SetFmtAttr(*pItem);
+ m_pWrtShell->ChgPageDesc( nCurIdx, aDesc);
+ }
+ }
+ break;
+ case SID_CLEARHISTORY:
+ {
+ m_pWrtShell->DelAllUndoObj();
+ }
+ break;
+ case SID_UNDO:
+ {
+ m_pShell->ExecuteSlot(rReq);
+ }
+ break;
+ case FN_INSERT_CTRL:
+ case FN_INSERT_OBJ_CTRL:
+ {
+ if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(nSlot, false, &pItem))
+ {
+ sal_uInt16 nValue = ((SfxUInt16Item*)pItem)->GetValue();
+ switch ( nSlot )
+ {
+ case FN_INSERT_CTRL:
+ {
+ sal_Bool bWeb = 0 != PTR_CAST(SwWebView, this);
+ if(bWeb)
+ SwView::m_nWebInsertCtrlState = nValue;
+ else
+ SwView::m_nInsertCtrlState = nValue;
+ }
+ break;
+ case FN_INSERT_OBJ_CTRL: SwView::m_nInsertObjectCtrlState = nValue ;break;
+ }
+
+ }
+ GetViewFrame()->GetBindings().Invalidate( nSlot );
+ }
+ break;
+#if defined WNT || defined UNX
+ case SID_TWAIN_SELECT:
+ case SID_TWAIN_TRANSFER:
+ GetViewImpl()->ExecuteScan( rReq );
+ break;
+#endif
+
+ case SID_ATTR_DEFTABSTOP:
+ {
+ if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(SID_ATTR_DEFTABSTOP, false, &pItem))
+ {
+ SvxTabStopItem aDefTabs( 0, 0, SVX_TAB_ADJUST_DEFAULT, RES_PARATR_TABSTOP );
+ sal_uInt16 nTab = ((const SfxUInt16Item*)pItem)->GetValue();
+ MakeDefTabs( nTab, aDefTabs );
+ m_pWrtShell->SetDefault( aDefTabs );
+ }
+ }
+ break;
+ case SID_ATTR_LANGUAGE :
+ if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(SID_ATTR_LANGUAGE, false, &pItem))
+ {
+ SvxLanguageItem aLang(((SvxLanguageItem*)pItem)->GetLanguage(), RES_CHRATR_LANGUAGE);
+ m_pWrtShell->SetDefault( aLang );
+ lcl_SetAllTextToDefaultLanguage( *m_pWrtShell, RES_CHRATR_LANGUAGE );
+ }
+ break;
+ case SID_ATTR_CHAR_CTL_LANGUAGE:
+ if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(RES_CHRATR_CTL_LANGUAGE, false, &pItem))
+ {
+ m_pWrtShell->SetDefault( *pItem );
+ lcl_SetAllTextToDefaultLanguage( *m_pWrtShell, RES_CHRATR_CTL_LANGUAGE );
+ }
+ break;
+ case SID_ATTR_CHAR_CJK_LANGUAGE:
+ if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(RES_CHRATR_CJK_LANGUAGE, false, &pItem))
+ {
+ m_pWrtShell->SetDefault( *pItem );
+ lcl_SetAllTextToDefaultLanguage( *m_pWrtShell, RES_CHRATR_CJK_LANGUAGE );
+ }
+ break;
+ case FN_SCROLL_PREV:
+ case FN_SCROLL_NEXT:
+ {
+ // call the handlers of PageUp/DownButtons, only
+ bool *pbNext = new bool(true); // FN_SCROLL_NEXT
+ if (nSlot == FN_SCROLL_PREV)
+ *pbNext = false;
+ // #i75416# move the execution of the search to an asynchronously called static link
+ Application::PostUserEvent( STATIC_LINK(this, SwView, MoveNavigationHdl), pbNext );
+ }
+ break;
+ case FN_NAVIGATION_POPUP:
+ {
+ SfxViewFrame* pVFrame = GetViewFrame();
+ SfxChildWindow* pCh = pVFrame->GetChildWindow( SID_NAVIGATOR );
+ if (!pCh)
+ {
+ pVFrame->ToggleChildWindow( SID_NAVIGATOR );
+ pCh = pVFrame->GetChildWindow( SID_NAVIGATOR );
+ }
+ ((SwNavigationPI*) pCh->GetContextWindow(SW_MOD()))->CreateNavigationTool(
+ GetVisArea(), true, &pVFrame->GetWindow());
+ }
+ break;
+ case SID_JUMPTOMARK:
+ if( pArgs && SFX_ITEM_SET == pArgs->GetItemState(SID_JUMPTOMARK, false, &pItem))
+ JumpToSwMark( (( const SfxStringItem*)pItem)->GetValue() );
+ break;
+ case SID_GALLERY :
+ GetViewFrame()->ChildWindowExecute(rReq);
+ break;
+ case SID_AVMEDIA_PLAYER :
+ GetViewFrame()->ChildWindowExecute(rReq);
+ break;
+ case SID_VIEW_DATA_SOURCE_BROWSER:
+ {
+ SfxViewFrame* pVFrame = GetViewFrame();
+ pVFrame->ChildWindowExecute(rReq);
+ if(pVFrame->HasChildWindow(SID_BROWSER))
+ {
+ const SwDBData& rData = GetWrtShell().GetDBDesc();
+ SW_MOD()->ShowDBObj(*this, rData, sal_False);
+ }
+ }
+ break;
+ case FN_INSERT_FIELD_DATA_ONLY :
+ {
+ sal_Bool bShow = sal_False;
+ if( pArgs &&
+ SFX_ITEM_SET == pArgs->GetItemState(nSlot, false, &pItem ))
+ bShow = ((const SfxBoolItem*)pItem)->GetValue();
+ if((bShow && m_bInMailMerge) != GetViewFrame()->HasChildWindow(nSlot))
+ GetViewFrame()->ToggleChildWindow(nSlot);
+ //if fields have been successfully inserted call the "real"
+ //mail merge dialog
+ SwWrtShell &rSh = GetWrtShell();
+ if(m_bInMailMerge && rSh.IsAnyDatabaseFieldInDoc())
+ {
+ SwNewDBMgr* pNewDBMgr = rSh.GetNewDBMgr();
+ if (pNewDBMgr)
+ {
+ SwDBData aData;
+ aData = rSh.GetDBData();
+ rSh.EnterStdMode(); // force change in text shell; necessary for mixing DB fields
+ AttrChangedNotify( &rSh );
+
+ Sequence<PropertyValue> aProperties(3);
+ PropertyValue* pValues = aProperties.getArray();
+ pValues[0].Name = "DataSourceName";
+ pValues[1].Name = "Command";
+ pValues[2].Name = "CommandType";
+ pValues[0].Value <<= aData.sDataSource;
+ pValues[1].Value <<= aData.sCommand;
+ pValues[2].Value <<= aData.nCommandType;
+ pNewDBMgr->ExecuteFormLetter(rSh, aProperties, sal_True);
+ }
+ }
+ m_bInMailMerge &= bShow;
+ GetViewFrame()->GetBindings().Invalidate(FN_INSERT_FIELD);
+ }
+ break;
+ case FN_QRY_MERGE:
+ {
+ sal_Bool bUseCurrentDocument = sal_True;
+ sal_Bool bQuery = !pArgs||SFX_ITEM_SET != pArgs->GetItemState(nSlot);
+ if(bQuery)
+ {
+ SfxViewFrame* pTmpFrame = GetViewFrame();
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "Dialogdiet fail!");
+ AbstractMailMergeCreateFromDlg* pDlg = pFact->CreateMailMergeCreateFromDlg(&pTmpFrame->GetWindow());
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ if(RET_OK == pDlg->Execute())
+ bUseCurrentDocument = pDlg->IsThisDocument();
+ else
+ break;
+ }
+ GenerateFormLetter(bUseCurrentDocument);
+ }
+ break;
+ case SID_RECHECK_DOCUMENT:
+ {
+ SwDocShell* pDocShell = GetDocShell();
+ SwDoc* pDoc = pDocShell->GetDoc();
+ uno::Reference< linguistic2::XProofreadingIterator > xGCIterator( pDoc->GetGCIterator() );
+ if( xGCIterator.is() )
+ {
+ xGCIterator->resetIgnoreRules();
+ }
+ // reset ignore lists
+ pDoc->SpellItAgainSam( true, false, false );
+ // clear ignore dictionary
+ uno::Reference< linguistic2::XDictionary > xDictionary( SvxGetIgnoreAllList(), uno::UNO_QUERY );
+ if( xDictionary.is() )
+ xDictionary->clear();
+ // put cursor to the start of the document
+ m_pWrtShell->SttDoc();
+ }
+ // no break; - but call spell/grammar dialog
+ case FN_SPELL_GRAMMAR_DIALOG:
+ {
+ SfxViewFrame* pViewFrame = GetViewFrame();
+ if (rReq.GetArgs() != NULL)
+ pViewFrame->SetChildWindow (FN_SPELL_GRAMMAR_DIALOG,
+ ((const SfxBoolItem&) (rReq.GetArgs()->
+ Get(FN_SPELL_GRAMMAR_DIALOG))).GetValue());
+ else
+ pViewFrame->ToggleChildWindow(FN_SPELL_GRAMMAR_DIALOG);
+
+ pViewFrame->GetBindings().Invalidate(FN_SPELL_GRAMMAR_DIALOG);
+ rReq.Ignore ();
+ }
+ break;
+ case SID_ALIGN_ANY_LEFT :
+ case SID_ALIGN_ANY_HCENTER :
+ case SID_ALIGN_ANY_RIGHT :
+ case SID_ALIGN_ANY_JUSTIFIED:
+ case SID_ALIGN_ANY_TOP :
+ case SID_ALIGN_ANY_VCENTER :
+ case SID_ALIGN_ANY_BOTTOM :
+ case SID_ALIGN_ANY_HDEFAULT :
+ case SID_ALIGN_ANY_VDEFAULT :
+ {
+ sal_uInt16 nAlias = 0;
+ if( m_nSelectionType & (nsSelectionType::SEL_DRW_TXT|nsSelectionType::SEL_TXT) )
+ {
+ switch( nSlot )
+ {
+ case SID_ALIGN_ANY_LEFT : nAlias = SID_ATTR_PARA_ADJUST_LEFT; break;
+ case SID_ALIGN_ANY_HCENTER : nAlias = SID_ATTR_PARA_ADJUST_CENTER; break;
+ case SID_ALIGN_ANY_RIGHT : nAlias = SID_ATTR_PARA_ADJUST_RIGHT; break;
+ case SID_ALIGN_ANY_JUSTIFIED: nAlias = SID_ATTR_PARA_ADJUST_BLOCK; break;
+ case SID_ALIGN_ANY_TOP : nAlias = SID_TABLE_VERT_NONE; break;
+ case SID_ALIGN_ANY_VCENTER : nAlias = SID_TABLE_VERT_CENTER; break;
+ case SID_ALIGN_ANY_BOTTOM : nAlias = SID_TABLE_VERT_BOTTOM; break;
+ }
+ }
+ else
+ {
+ switch( nSlot )
+ {
+ case SID_ALIGN_ANY_LEFT : nAlias = SID_OBJECT_ALIGN_LEFT ; break;
+ case SID_ALIGN_ANY_HCENTER : nAlias = SID_OBJECT_ALIGN_CENTER ; break;
+ case SID_ALIGN_ANY_RIGHT : nAlias = SID_OBJECT_ALIGN_RIGHT ; break;
+ case SID_ALIGN_ANY_TOP : nAlias = SID_OBJECT_ALIGN_UP ; break;
+ case SID_ALIGN_ANY_VCENTER : nAlias = SID_OBJECT_ALIGN_MIDDLE ; break;
+ case SID_ALIGN_ANY_BOTTOM : nAlias = SID_OBJECT_ALIGN_DOWN ; break;
+ }
+ }
+ //special handling for the draw shell
+ if(nAlias && (m_nSelectionType & (nsSelectionType::SEL_DRW)))
+ {
+ SfxAllEnumItem aEnumItem(SID_OBJECT_ALIGN, nAlias - SID_OBJECT_ALIGN_LEFT);
+ GetViewFrame()->GetDispatcher()->Execute(
+ SID_OBJECT_ALIGN, SFX_CALLMODE_ASYNCHRON, &aEnumItem, 0L);
+ }
+ else if(nAlias)
+ //these slots are either re-mapped to text or object alignment
+ GetViewFrame()->GetDispatcher()->Execute(
+ nAlias, SFX_CALLMODE_ASYNCHRON);
+ }
+ break;
+ case SID_RESTORE_EDITING_VIEW:
+ {
+ //#i33307# restore editing position
+ Point aCrsrPos;
+ bool bSelectObj;
+ if(m_pViewImpl->GetRestorePosition(aCrsrPos, bSelectObj))
+ {
+ m_pWrtShell->SwCrsrShell::SetCrsr( aCrsrPos, !bSelectObj );
+ if( bSelectObj )
+ {
+ m_pWrtShell->SelectObj( aCrsrPos );
+ m_pWrtShell->EnterSelFrmMode( &aCrsrPos );
+ }
+ }
+ }
+ break;
+ case SID_INSERT_GRAPHIC:
+ {
+ rReq.SetReturnValue(SfxBoolItem(nSlot, InsertGraphicDlg( rReq )));
+ }
+ break;
+
+ default:
+ OSL_ENSURE(!this, "wrong dispatcher");
+ return;
+ }
+ if(!bIgnore)
+ rReq.Done();
+}
+
+/// invalidate page numbering field
+void SwView::UpdatePageNums(sal_uInt16 nPhyNum, sal_uInt16 nVirtNum, const OUString& rPgStr)
+{
+ OUString sTemp(GetPageStr( nPhyNum, nVirtNum, rPgStr ));
+ const SfxStringItem aTmp( FN_STAT_PAGE, sTemp );
+ SfxBindings &rBnd = GetViewFrame()->GetBindings();
+ rBnd.SetState( aTmp );
+ rBnd.Update( FN_STAT_PAGE );
+}
+
+void SwView::UpdateDocStats()
+{
+ SfxBindings &rBnd = GetViewFrame()->GetBindings();
+ rBnd.Invalidate( FN_STAT_WORDCOUNT );
+ rBnd.Update( FN_STAT_WORDCOUNT );
+}
+
+void SwView::SetAnnotationMode(bool bMode)
+{
+ m_bAnnotationMode = bMode;
+}
+
+/// get status of the status line
+void SwView::StateStatusLine(SfxItemSet &rSet)
+{
+ SwWrtShell& rShell = GetWrtShell();
+
+ SfxWhichIter aIter( rSet );
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ OSL_ENSURE( nWhich, "empty set");
+
+ //get section change event
+ const SwSection* CurrSect = rShell.GetCurrSection();
+ if( CurrSect )
+ {
+ OUString sCurrentSectionName = CurrSect->GetSectionName();
+ if(sCurrentSectionName != m_sOldSectionName)
+ {
+ rShell.FireSectionChangeEvent(2, 1);
+ }
+ m_sOldSectionName = sCurrentSectionName;
+ }
+ else if (!m_sOldSectionName.isEmpty())
+ {
+ rShell.FireSectionChangeEvent(2, 1);
+ m_sOldSectionName= OUString();
+ }
+ //get column change event
+ if(rShell.bColumnChange())
+ {
+ rShell.FireColumnChangeEvent(2, 1);
+ }
+
+ while( nWhich )
+ {
+ switch( nWhich )
+ {
+ case FN_STAT_PAGE: {
+ // number of pages, log. page number
+ sal_uInt16 nPage, nLogPage;
+ OUString sDisplay;
+ rShell.GetPageNumber( -1, rShell.IsCrsrVisible(), nPage, nLogPage, sDisplay );
+ rSet.Put( SfxStringItem( FN_STAT_PAGE,
+ GetPageStr( nPage, nLogPage, sDisplay) ));
+ //if existing page number is not equal to old page number, send out this event.
+ if (m_nOldPageNum != nLogPage )
+ {
+ if (m_nOldPageNum != 0)
+ rShell.FirePageChangeEvent(m_nOldPageNum, nLogPage);
+ m_nOldPageNum = nLogPage;
+ }
+ sal_uInt16 nCnt = GetWrtShell().GetPageCnt();
+ if (m_nPageCnt != nCnt) // notify Basic
+ {
+ m_nPageCnt = nCnt;
+ SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_PAGE_COUNT, SwDocShell::GetEventName(STR_SW_EVENT_PAGE_COUNT), GetViewFrame()->GetObjectShell()), false);
+ }
+ }
+ break;
+
+ case FN_STAT_WORDCOUNT:
+ {
+ SwDocStat selectionStats;
+ SwDocStat documentStats;
+ {
+ rShell.CountWords(selectionStats);
+ documentStats = rShell.GetDoc()->GetUpdatedDocStat( true /* complete-async */, false /* don't update fields */ );
+ }
+
+ OUString wordCount(SW_RES(selectionStats.nWord ?
+ STR_STATUSBAR_WORDCOUNT : STR_STATUSBAR_WORDCOUNT_NO_SELECTION));
+ wordCount = wordCount.replaceFirst("%1",
+ OUString::number(selectionStats.nWord ? selectionStats.nWord : documentStats.nWord));
+ wordCount = wordCount.replaceFirst("%2",
+ OUString::number(selectionStats.nChar ? selectionStats.nChar : documentStats.nChar));
+ rSet.Put(SfxStringItem(FN_STAT_WORDCOUNT, wordCount));
+
+ SwWordCountWrapper *pWrdCnt = (SwWordCountWrapper*)GetViewFrame()->GetChildWindow(SwWordCountWrapper::GetChildWindowId());
+ if (pWrdCnt)
+ pWrdCnt->SetCounts(selectionStats, documentStats);
+ }
+ break;
+
+ case FN_STAT_TEMPLATE:
+ {
+ rSet.Put(SfxStringItem( FN_STAT_TEMPLATE,
+ rShell.GetCurPageStyle(sal_False)));
+
+ }
+ break;
+ case SID_ATTR_ZOOM:
+ {
+ if ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) || !GetDocShell()->IsInPlaceActive() )
+ {
+ const SwViewOption* pVOpt = rShell.GetViewOptions();
+ SvxZoomType eZoom = (SvxZoomType) pVOpt->GetZoomType();
+ SvxZoomItem aZoom(eZoom,
+ pVOpt->GetZoom());
+ if( pVOpt->getBrowseMode() )
+ {
+ aZoom.SetValueSet(
+ SVX_ZOOM_ENABLE_50|
+ SVX_ZOOM_ENABLE_75|
+ SVX_ZOOM_ENABLE_100|
+ SVX_ZOOM_ENABLE_150|
+ SVX_ZOOM_ENABLE_200);
+ }
+ rSet.Put( aZoom );
+ }
+ else
+ rSet.DisableItem( SID_ATTR_ZOOM );
+ }
+ break;
+ case SID_ATTR_VIEWLAYOUT:
+ {
+ if ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) || !GetDocShell()->IsInPlaceActive() )
+ {
+ const SwViewOption* pVOpt = rShell.GetViewOptions();
+ const sal_uInt16 nColumns = pVOpt->GetViewLayoutColumns();
+ const bool bBookMode = pVOpt->IsViewLayoutBookMode();
+ SvxViewLayoutItem aViewLayout(nColumns, bBookMode);
+ rSet.Put( aViewLayout );
+ }
+ else
+ rSet.DisableItem( SID_ATTR_VIEWLAYOUT );
+ }
+ break;
+ case SID_ATTR_ZOOMSLIDER:
+ {
+ if ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) || !GetDocShell()->IsInPlaceActive() )
+ {
+ const SwViewOption* pVOpt = rShell.GetViewOptions();
+ const sal_uInt16 nCurrentZoom = pVOpt->GetZoom();
+ SvxZoomSliderItem aZoomSliderItem( nCurrentZoom, MINZOOM, MAXZOOM );
+ aZoomSliderItem.AddSnappingPoint( 100 );
+
+ if ( !m_pWrtShell->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) )
+ {
+ const sal_uInt16 nColumns = pVOpt->GetViewLayoutColumns();
+ const bool bAutomaticViewLayout = 0 == nColumns;
+ const SwPostItMgr* pMgr = GetPostItMgr();
+
+ // snapping points:
+ // automatic mode: 1 Page, 2 Pages, 100%
+ // n Columns mode: n Pages, 100%
+ // n Columns book mode: nPages without gaps, 100%
+ const SwRect aPageRect( m_pWrtShell->GetAnyCurRect( RECT_PAGE_CALC ) );
+ const SwRect aRootRect( m_pWrtShell->GetAnyCurRect( RECT_PAGES_AREA ) ); // width of columns
+ Size aPageSize( aPageRect.SSize() );
+ aPageSize.Width() += pMgr->HasNotes() && pMgr->ShowNotes() ?
+ pMgr->GetSidebarWidth() + pMgr->GetSidebarBorderWidth() :
+ 0;
+
+ Size aRootSize( aRootRect.SSize() );
+
+ const MapMode aTmpMap( MAP_TWIP );
+ const Size& rEditSize = GetEditWin().GetOutputSizePixel();
+ const Size aWindowSize( GetEditWin().PixelToLogic( rEditSize, aTmpMap ) );
+
+ const long nOf = DOCUMENTBORDER * 2L;
+ long nTmpWidth = bAutomaticViewLayout ? aPageSize.Width() : aRootSize.Width();
+ nTmpWidth += nOf;
+ aPageSize.Height() += nOf;
+ long nFac = aWindowSize.Width() * 100 / nTmpWidth;
+
+ long nVisPercent = aWindowSize.Height() * 100 / aPageSize.Height();
+ nFac = std::min( nFac, nVisPercent );
+
+ aZoomSliderItem.AddSnappingPoint( nFac );
+
+ if ( bAutomaticViewLayout )
+ {
+ nTmpWidth += aPageSize.Width() + GAPBETWEENPAGES;
+ nFac = aWindowSize.Width() * 100 / nTmpWidth;
+ nFac = std::min( nFac, nVisPercent );
+ aZoomSliderItem.AddSnappingPoint( nFac );
+ }
+ }
+
+ rSet.Put( aZoomSliderItem );
+ }
+ else
+ rSet.DisableItem( SID_ATTR_ZOOMSLIDER );
+ }
+ break;
+ case SID_ATTR_POSITION:
+ case SID_ATTR_SIZE:
+ {
+ if( !rShell.IsFrmSelected() && !rShell.IsObjSelected() )
+ SwBaseShell::_SetFrmMode( FLY_DRAG_END );
+ else
+ {
+ FlyMode eFrameMode = SwBaseShell::GetFrmMode();
+ if ( eFrameMode == FLY_DRAG_START || eFrameMode == FLY_DRAG )
+ {
+ if ( nWhich == SID_ATTR_POSITION )
+ rSet.Put( SfxPointItem( SID_ATTR_POSITION,
+ rShell.GetAnchorObjDiff()));
+ else
+ rSet.Put( SvxSizeItem( SID_ATTR_SIZE,
+ rShell.GetObjSize()));
+ }
+ }
+ }
+ break;
+ case SID_TABLE_CELL:
+
+ if( rShell.IsFrmSelected() || rShell.IsObjSelected() )
+ {
+ // #i39171# Don't put a SvxSizeItem into a slot which is defined as SfxStringItem.
+ // SvxPosSizeStatusBarControl no longer resets to empty display if only one slot
+ // has no item, so SID_TABLE_CELL can remain empty (the SvxSizeItem is supplied
+ // in SID_ATTR_SIZE).
+ }
+ else
+ {
+ OUString sStr;
+ if( rShell.IsCrsrInTbl() )
+ {
+ // table name + cell coordinate
+ sStr = rShell.GetTableFmt()->GetName();
+ sStr += ":";
+ sStr += rShell.GetBoxNms();
+ }
+ else
+ {
+ const SwSection* pCurrSect = rShell.GetCurrSection();
+ if( pCurrSect )
+ {
+ switch( pCurrSect->GetType() )
+ {
+ case TOX_HEADER_SECTION:
+ case TOX_CONTENT_SECTION:
+ {
+ const SwTOXBase* pTOX = m_pWrtShell->GetCurTOX();
+ if( pTOX )
+ sStr = pTOX->GetTOXName();
+ else
+ {
+ OSL_ENSURE( !this,
+ "Unknown kind of section" );
+ sStr = pCurrSect->GetSectionName();
+ }
+ }
+ break;
+ default:
+ sStr = pCurrSect->GetSectionName();
+ break;
+ }
+ }
+ }
+
+ const SwNumRule* pNumRule = rShell.GetCurNumRule();
+ const bool bOutlineNum = pNumRule ? pNumRule->IsOutlineRule() : 0;
+
+ if (pNumRule && !bOutlineNum ) // cursor in numbering
+ {
+ sal_uInt8 nNumLevel = rShell.GetNumLevel();
+ if ( nNumLevel < MAXLEVEL )
+ {
+ if(!pNumRule->IsAutoRule())
+ {
+ SfxItemSet aSet(GetPool(),
+ RES_PARATR_NUMRULE, RES_PARATR_NUMRULE);
+ rShell.GetCurAttr(aSet);
+ if(SFX_ITEM_AVAILABLE <=
+ aSet.GetItemState(RES_PARATR_NUMRULE, true))
+ {
+ const OUString& rNumStyle =
+ ((const SfxStringItem &)
+ aSet.Get(RES_PARATR_NUMRULE)).GetValue();
+ if(!rNumStyle.isEmpty())
+ {
+ if(!sStr.isEmpty())
+ sStr += sStatusDelim;
+ sStr += rNumStyle;
+ }
+ }
+ }
+ if (!sStr.isEmpty())
+ sStr += sStatusDelim;
+ sStr += SW_RESSTR(STR_NUM_LEVEL);
+ sStr += OUString::number( nNumLevel + 1 );
+
+ }
+ }
+ const int nOutlineLevel = rShell.GetCurrentParaOutlineLevel();
+ if( nOutlineLevel != 0 )
+ {
+ if (!sStr.isEmpty())
+ sStr += sStatusComma;
+ if( bOutlineNum )
+ {
+ sStr += SW_RESSTR(STR_OUTLINE_NUMBERING);
+ sStr += sStatusDelim;
+ sStr += SW_RESSTR(STR_NUM_LEVEL);
+ }
+ else
+ sStr += SW_RESSTR(STR_NUM_OUTLINE);
+ sStr += OUString::number( nOutlineLevel);
+ }
+
+ if( rShell.HasReadonlySel() )
+ {
+ if (!sStr.isEmpty())
+ sStr = sStatusDelim + sStr;
+ sStr = SW_RESSTR(SW_STR_READONLY) + sStr;
+ }
+ if (!sStr.isEmpty())
+ rSet.Put( SfxStringItem( SID_TABLE_CELL, sStr ));
+ }
+ break;
+ case FN_STAT_SELMODE:
+ {
+ if(rShell.IsStdMode())
+ rSet.Put(SfxUInt16Item(FN_STAT_SELMODE, 0));
+ else if(rShell.IsAddMode())
+ rSet.Put(SfxUInt16Item(FN_STAT_SELMODE, 2));
+ else if(rShell.IsBlockMode())
+ rSet.Put(SfxUInt16Item(FN_STAT_SELMODE, 3));
+ else
+ rSet.Put(SfxUInt16Item(FN_STAT_SELMODE, 1));
+ break;
+ }
+ case SID_ATTR_INSERT:
+ if( rShell.IsRedlineOn() )
+ rSet.DisableItem( nWhich );
+ else
+ {
+ rSet.Put(SfxBoolItem(SID_ATTR_INSERT,rShell.IsInsMode()));
+ }
+ break;
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+/** excecute method for the status line
+ *
+ * @param rReq ???
+ */
+void SwView::ExecuteStatusLine(SfxRequest &rReq)
+{
+ SwWrtShell &rSh = GetWrtShell();
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ const SfxPoolItem* pItem=NULL;
+ sal_Bool bUp = sal_False;
+ sal_uInt16 nWhich = rReq.GetSlot();
+ switch( nWhich )
+ {
+ case FN_STAT_PAGE:
+ {
+ GetViewFrame()->GetDispatcher()->Execute( SID_NAVIGATOR,
+ SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD );
+ }
+ break;
+
+ case FN_STAT_WORDCOUNT:
+ {
+ GetViewFrame()->GetDispatcher()->Execute(FN_WORDCOUNT_DIALOG,
+ SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD );
+ }
+ break;
+
+ case FN_STAT_BOOKMARK:
+ if ( pArgs )
+ {
+ if (SFX_ITEM_SET == pArgs->GetItemState( nWhich, true, &pItem))
+ {
+ const IDocumentMarkAccess* pMarkAccess = rSh.getIDocumentMarkAccess();
+ const sal_Int32 nIdx = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
+ if(nIdx < pMarkAccess->getBookmarksCount())
+ {
+ const IDocumentMarkAccess::const_iterator_t ppBookmark = rSh.getIDocumentMarkAccess()->getBookmarksBegin() + nIdx;
+ rSh.EnterStdMode();
+ rSh.GotoMark( ppBookmark->get() );
+ }
+ else
+ OSL_FAIL("SwView::ExecuteStatusLine(..)"
+ " - Ignoring out of range bookmark index");
+ }
+ }
+ break;
+
+ case FN_STAT_TEMPLATE:
+ {
+ GetViewFrame()->GetDispatcher()->Execute(FN_FORMAT_PAGE_DLG,
+ SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD );
+ }
+ break;
+ case SID_ATTR_ZOOM:
+ {
+ if ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) || !GetDocShell()->IsInPlaceActive() )
+ {
+ const SfxItemSet *pSet = 0;
+ boost::scoped_ptr<AbstractSvxZoomDialog> pDlg;
+ if ( pArgs )
+ pSet = pArgs;
+ else
+ {
+ const SwViewOption& rViewOptions = *rSh.GetViewOptions();
+ SfxItemSet aCoreSet(m_pShell->GetPool(), SID_ATTR_ZOOM, SID_ATTR_ZOOM, SID_ATTR_VIEWLAYOUT, SID_ATTR_VIEWLAYOUT, 0 );
+ SvxZoomItem aZoom( (SvxZoomType)rViewOptions.GetZoomType(), rViewOptions.GetZoom() );
+
+ const bool bBrowseMode = rSh.GetViewOptions()->getBrowseMode();
+ if( bBrowseMode )
+ {
+ aZoom.SetValueSet(
+ SVX_ZOOM_ENABLE_50|
+ SVX_ZOOM_ENABLE_75|
+ SVX_ZOOM_ENABLE_100|
+ SVX_ZOOM_ENABLE_150|
+ SVX_ZOOM_ENABLE_200);
+ }
+ aCoreSet.Put( aZoom );
+
+ if ( !bBrowseMode )
+ {
+ const SvxViewLayoutItem aViewLayout( rViewOptions.GetViewLayoutColumns(), rViewOptions.IsViewLayoutBookMode() );
+ aCoreSet.Put( aViewLayout );
+ }
+
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ if(pFact)
+ {
+ pDlg.reset(pFact->CreateSvxZoomDialog(&GetViewFrame()->GetWindow(), aCoreSet));
+ OSL_ENSURE(pDlg, "Zooming fail!");
+ if (pDlg)
+ {
+ pDlg->SetLimits( MINZOOM, MAXZOOM );
+ if( pDlg->Execute() != RET_CANCEL )
+ pSet = pDlg->GetOutputItemSet();
+ }
+ }
+ }
+
+ const SfxPoolItem* pViewLayoutItem = 0;
+ if ( pSet && SFX_ITEM_SET == pSet->GetItemState(SID_ATTR_VIEWLAYOUT, true, &pViewLayoutItem))
+ {
+ const sal_uInt16 nColumns = ((const SvxViewLayoutItem *)pViewLayoutItem)->GetValue();
+ const bool bBookMode = ((const SvxViewLayoutItem *)pViewLayoutItem)->IsBookMode();
+ SetViewLayout( nColumns, bBookMode );
+ }
+
+ if ( pSet && SFX_ITEM_SET == pSet->GetItemState(SID_ATTR_ZOOM, true, &pItem))
+ {
+ enum SvxZoomType eType = ((const SvxZoomItem *)pItem)->GetType();
+ SetZoom( eType, ((const SvxZoomItem *)pItem)->GetValue() );
+ }
+ bUp = sal_True;
+ if ( pItem )
+ rReq.AppendItem( *pItem );
+ rReq.Done();
+ }
+ }
+ break;
+
+ case SID_ATTR_VIEWLAYOUT:
+ {
+ if ( pArgs && !rSh.getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) &&
+ ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) || !GetDocShell()->IsInPlaceActive() ) )
+ {
+ if ( SFX_ITEM_SET == pArgs->GetItemState(SID_ATTR_VIEWLAYOUT, true, &pItem ))
+ {
+ const sal_uInt16 nColumns = ((const SvxViewLayoutItem *)pItem)->GetValue();
+ const bool bBookMode = (0 == nColumns || 0 != (nColumns % 2)) ?
+ false :
+ ((const SvxViewLayoutItem *)pItem)->IsBookMode();
+
+ SetViewLayout( nColumns, bBookMode );
+ }
+
+ bUp = sal_True;
+ rReq.Done();
+
+ InvalidateRulerPos();
+ }
+ }
+ break;
+
+ case SID_ATTR_ZOOMSLIDER:
+ {
+ if ( pArgs && ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) || !GetDocShell()->IsInPlaceActive() ) )
+ {
+ if ( SFX_ITEM_SET == pArgs->GetItemState(SID_ATTR_ZOOMSLIDER, true, &pItem ))
+ {
+ const sal_uInt16 nCurrentZoom = ((const SvxZoomSliderItem *)pItem)->GetValue();
+ SetZoom( SVX_ZOOM_PERCENT, nCurrentZoom );
+ }
+
+ bUp = sal_True;
+ rReq.Done();
+ }
+ }
+ break;
+
+ case SID_ATTR_SIZE:
+ {
+ sal_uLong nId = FN_INSERT_FIELD;
+ if( rSh.IsCrsrInTbl() )
+ nId = FN_FORMAT_TABLE_DLG;
+ else if( rSh.GetCurTOX() )
+ nId = FN_INSERT_MULTI_TOX;
+ else if( rSh.GetCurrSection() )
+ nId = FN_EDIT_REGION;
+ else
+ {
+ const SwNumRule* pNumRule = rSh.GetCurNumRule();
+ if( pNumRule ) // cursor in numbering
+ {
+ if( pNumRule->IsAutoRule() )
+ nId = FN_NUMBER_BULLETS;
+ else
+ {
+ // start dialog of the painter
+ nId = 0;
+ }
+ }
+ else if( rSh.IsFrmSelected() )
+ nId = FN_FORMAT_FRAME_DLG;
+ else if( rSh.IsObjSelected() )
+ nId = SID_ATTR_TRANSFORM;
+ }
+ if( nId )
+ GetViewFrame()->GetDispatcher()->Execute(
+ static_cast< sal_uInt16 >( nId ), SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD );
+ }
+ break;
+
+ case FN_STAT_SELMODE:
+ {
+ if ( pArgs )
+ {
+ if (SFX_ITEM_SET == pArgs->GetItemState( nWhich, true, &pItem))
+ {
+ switch ( ((const SfxUInt16Item *)pItem)->GetValue() )
+ {
+ case 0: rSh.EnterStdMode(); break;
+ case 1: rSh.EnterExtMode(); break;
+ case 2: rSh.EnterAddMode(); break;
+ case 3: rSh.EnterBlockMode(); break;
+ }
+ }
+ }
+ else
+ {
+
+ if( !rSh.IsAddMode() && !rSh.IsExtMode() && !rSh.IsBlockMode() )
+ rSh.ToggleExtMode();
+ else if ( rSh.IsExtMode() )
+ {
+ rSh.ToggleExtMode();
+ rSh.ToggleAddMode();
+ }
+ else if ( rSh.IsAddMode() )
+ {
+ rSh.ToggleAddMode();
+ rSh.ToggleBlockMode();
+ }
+ else
+ rSh.ToggleBlockMode();
+ }
+ bUp = sal_True;
+ break;
+ }
+ case FN_SET_ADD_MODE:
+ rSh.ToggleAddMode();
+ nWhich = FN_STAT_SELMODE;
+ bUp = sal_True;
+ break;
+ case FN_SET_BLOCK_MODE:
+ rSh.ToggleBlockMode();
+ nWhich = FN_STAT_SELMODE;
+ bUp = sal_True;
+ break;
+ case FN_SET_EXT_MODE:
+ rSh.ToggleExtMode();
+ nWhich = FN_STAT_SELMODE;
+ bUp = sal_True;
+ break;
+ case SID_ATTR_INSERT:
+ SwPostItMgr* pMgr = GetPostItMgr();
+ if ( pMgr && pMgr->HasActiveSidebarWin() )
+ {
+ pMgr->ToggleInsModeOnActiveSidebarWin();
+ }
+ else
+ rSh.ToggleInsMode();
+ bUp = sal_True;
+ break;
+
+ }
+ if ( bUp )
+ {
+ SfxBindings &rBnd = GetViewFrame()->GetBindings();
+ rBnd.Invalidate(nWhich);
+ rBnd.Update(nWhich);
+ }
+}
+
+void SwView::InsFrmMode(sal_uInt16 nCols)
+{
+ if ( m_pWrtShell->HasWholeTabSelection() )
+ {
+ SwFlyFrmAttrMgr aMgr( sal_True, m_pWrtShell, FRMMGR_TYPE_TEXT );
+
+ const SwFrmFmt &rPageFmt =
+ m_pWrtShell->GetPageDesc(m_pWrtShell->GetCurPageDesc()).GetMaster();
+ SwTwips lWidth = rPageFmt.GetFrmSize().GetWidth();
+ const SvxLRSpaceItem &rLR = rPageFmt.GetLRSpace();
+ lWidth -= rLR.GetLeft() + rLR.GetRight();
+ aMgr.SetSize(Size(lWidth, aMgr.GetSize().Height()));
+ if(nCols > 1)
+ {
+ SwFmtCol aCol;
+ aCol.Init( nCols, aCol.GetGutterWidth(), aCol.GetWishWidth() );
+ aMgr.SetCol( aCol );
+ }
+ aMgr.InsertFlyFrm();
+ }
+ else
+ GetEditWin().InsFrm(nCols);
+}
+
+/// show "edit link" dialog
+void SwView::EditLinkDlg()
+{
+ sal_Bool bWeb = 0 != PTR_CAST(SwWebView, this);
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ boost::scoped_ptr<SfxAbstractLinksDialog> pDlg(pFact->CreateLinksDialog( &GetViewFrame()->GetWindow(), &GetWrtShell().GetLinkManager(), bWeb ));
+ if ( pDlg )
+ {
+ pDlg->Execute();
+ }
+}
+
+bool SwView::JumpToSwMark( const OUString& rMark )
+{
+ bool bRet = false;
+ if( !rMark.isEmpty() )
+ {
+ // place bookmark at top-center
+ sal_Bool bSaveCC = IsCrsrAtCenter();
+ sal_Bool bSaveCT = IsCrsrAtTop();
+ SetCrsrAtTop( sal_True );
+
+ // For scrolling the FrameSet, the corresponding shell needs to have the focus.
+ sal_Bool bHasShFocus = m_pWrtShell->HasShFcs();
+ if( !bHasShFocus )
+ m_pWrtShell->ShGetFcs( sal_False );
+
+ const SwFmtINetFmt* pINet;
+ OUString sCmp;
+ OUString sMark( INetURLObject::decode( rMark, INET_HEX_ESCAPE,
+ INetURLObject::DECODE_WITH_CHARSET,
+ RTL_TEXTENCODING_UTF8 ));
+
+ sal_Int32 nLastPos, nPos = sMark.indexOf( cMarkSeparator );
+ if( -1 != nPos )
+ while( -1 != ( nLastPos = sMark.indexOf( cMarkSeparator, nPos + 1 )) )
+ nPos = nLastPos;
+
+ IDocumentMarkAccess::const_iterator_t ppMark;
+ IDocumentMarkAccess* const pMarkAccess = m_pWrtShell->getIDocumentMarkAccess();
+ if( -1 != nPos )
+ sCmp = comphelper::string::remove(sMark.copy(nPos + 1), ' ');
+
+ if( !sCmp.isEmpty() )
+ {
+ rtl::OUString sName( sMark.copy( 0, nPos ) );
+ sCmp = sCmp.toAsciiLowerCase();
+ FlyCntType eFlyType = FLYCNTTYPE_ALL;
+
+ if( sCmp == "region" )
+ {
+ m_pWrtShell->EnterStdMode();
+ bRet = m_pWrtShell->GotoRegion( sName );
+ }
+ else if( sCmp == "outline" )
+ {
+ m_pWrtShell->EnterStdMode();
+ bRet = m_pWrtShell->GotoOutline( sName );
+ }
+ else if( sCmp == "frame" )
+ eFlyType = FLYCNTTYPE_FRM;
+ else if( sCmp == "graphic" )
+ eFlyType = FLYCNTTYPE_GRF;
+ else if( sCmp == "ole" )
+ eFlyType = FLYCNTTYPE_OLE;
+ else if( sCmp == "table" )
+ {
+ m_pWrtShell->EnterStdMode();
+ bRet = m_pWrtShell->GotoTable( sName );
+ }
+ else if( sCmp == "sequence" )
+ {
+ m_pWrtShell->EnterStdMode();
+ sal_Int32 nNoPos = sName.indexOf( cSequenceMarkSeparator );
+ if ( nNoPos != -1 )
+ {
+ sal_uInt16 nSeqNo = sName.copy( nNoPos + 1 ).toInt32();
+ sName = sName.copy( 0, nNoPos );
+ m_pWrtShell->GotoRefMark( sName, REF_SEQUENCEFLD, nSeqNo );
+ }
+ }
+ else if( sCmp == "text" )
+ {
+ // normal text search
+ m_pWrtShell->EnterStdMode();
+
+ SearchOptions aSearchOpt(
+ SearchAlgorithms_ABSOLUTE, 0,
+ sName, OUString(),
+ SvtSysLocale().GetLanguageTag().getLocale(),
+ 0,0,0,
+ TransliterationModules_IGNORE_CASE );
+
+ //todo/mba: assuming that notes shouldn't be searched
+ sal_Bool bSearchInNotes = sal_False;
+ if( m_pWrtShell->SearchPattern( aSearchOpt, bSearchInNotes, DOCPOS_START, DOCPOS_END ))
+ {
+ m_pWrtShell->EnterStdMode(); // remove the selection
+ bRet = true;
+ }
+ }
+ else if( pMarkAccess->getAllMarksEnd() != (ppMark = pMarkAccess->findMark(sMark)) )
+ m_pWrtShell->GotoMark( ppMark->get(), sal_False, sal_True ), bRet = true;
+ else if( 0 != ( pINet = m_pWrtShell->FindINetAttr( sMark ) )) {
+ m_pWrtShell->addCurrentPosition();
+ bRet = m_pWrtShell->GotoINetAttr( *pINet->GetTxtINetFmt() );
+ }
+
+ // for all types of Flys
+ if( FLYCNTTYPE_ALL != eFlyType && m_pWrtShell->GotoFly( sName, eFlyType ))
+ {
+ bRet = true;
+ if( FLYCNTTYPE_FRM == eFlyType )
+ {
+ // TextFrames: set Cursor in the frame
+ m_pWrtShell->UnSelectFrm();
+ m_pWrtShell->LeaveSelFrmMode();
+ }
+ else
+ {
+ m_pWrtShell->HideCrsr();
+ m_pWrtShell->EnterSelFrmMode();
+ }
+ }
+ }
+ else if( pMarkAccess->getAllMarksEnd() != (ppMark = pMarkAccess->findMark(sMark)))
+ m_pWrtShell->GotoMark( ppMark->get(), sal_False, sal_True ), bRet = true;
+ else if( 0 != ( pINet = m_pWrtShell->FindINetAttr( sMark ) ))
+ bRet = m_pWrtShell->GotoINetAttr( *pINet->GetTxtINetFmt() );
+
+ // make selection visible later
+ if ( m_aVisArea.IsEmpty() )
+ m_bMakeSelectionVisible = sal_True;
+
+ // reset ViewStatus
+ SetCrsrAtTop( bSaveCT, bSaveCC );
+
+ if( !bHasShFocus )
+ m_pWrtShell->ShLooseFcs();
+ }
+ return bRet;
+}
+
+// #i67305# Undo after insert from file:
+// Undo "Insert form file" crashes with documents imported from binary filter (.sdw) => disabled
+// Undo "Insert form file" crashes with (.odt) documents crashes if these documents contains
+// page styles with active header/footer => disabled for those documents
+static sal_uInt16 lcl_PageDescWithHeader( const SwDoc& rDoc )
+{
+ sal_uInt16 nRet = 0;
+ sal_uInt16 nCnt = rDoc.GetPageDescCnt();
+ for( sal_uInt16 i = 0; i < nCnt; ++i )
+ {
+ const SwPageDesc& rPageDesc = rDoc.GetPageDesc( i );
+ const SwFrmFmt& rMaster = rPageDesc.GetMaster();
+ const SfxPoolItem* pItem;
+ if( ( SFX_ITEM_SET == rMaster.GetAttrSet().GetItemState( RES_HEADER, false, &pItem ) &&
+ ((SwFmtHeader*)pItem)->IsActive() ) ||
+ ( SFX_ITEM_SET == rMaster.GetAttrSet().GetItemState( RES_FOOTER, false, &pItem ) &&
+ ((SwFmtFooter*)pItem)->IsActive()) )
+ ++nRet;
+ }
+ return nRet; // number of page styles with active header/footer
+}
+
+void SwView::ExecuteInsertDoc( SfxRequest& rRequest, const SfxPoolItem* pItem )
+{
+ m_pViewImpl->InitRequest( rRequest );
+ m_pViewImpl->SetParam( pItem ? 1 : 0 );
+ sal_uInt16 nSlot = rRequest.GetSlot();
+
+ if ( !pItem )
+ {
+ OUString sEmpty;
+ InsertDoc( nSlot, sEmpty, sEmpty );
+ }
+ else
+ {
+ OUString sFile, sFilter;
+ sFile = ( (const SfxStringItem *)pItem )->GetValue();
+ if ( SFX_ITEM_SET == rRequest.GetArgs()->GetItemState( FN_PARAM_1, true, &pItem ) )
+ sFilter = ( (const SfxStringItem *)pItem )->GetValue();
+
+ bool bHasFileName = !sFile.isEmpty();
+ long nFound = InsertDoc( nSlot, sFile, sFilter );
+
+ if ( bHasFileName )
+ {
+ rRequest.SetReturnValue( SfxBoolItem( nSlot, nFound != -1 ) );
+ rRequest.Done();
+ }
+ }
+}
+
+long SwView::InsertDoc( sal_uInt16 nSlotId, const OUString& rFileName, const OUString& rFilterName, sal_Int16 nVersion )
+{
+ SfxMedium* pMed = 0;
+ SwDocShell* pDocSh = GetDocShell();
+
+ if( !rFileName.isEmpty() )
+ {
+ SfxObjectFactory& rFact = pDocSh->GetFactory();
+ const SfxFilter* pFilter = rFact.GetFilterContainer()->GetFilter4FilterName( rFilterName );
+ if ( !pFilter )
+ {
+ pMed = new SfxMedium(rFileName, STREAM_READ, 0, 0 );
+ SfxFilterMatcher aMatcher( rFact.GetFilterContainer()->GetName() );
+ pMed->UseInteractionHandler( sal_True );
+ ErrCode nErr = aMatcher.GuessFilter( *pMed, &pFilter, sal_False );
+ if ( nErr )
+ DELETEZ(pMed);
+ else
+ pMed->SetFilter( pFilter );
+ }
+ else
+ pMed = new SfxMedium(rFileName, STREAM_READ, pFilter, 0);
+ }
+ else
+ {
+ OUString sFactory = OUString::createFromAscii( pDocSh->GetFactory().GetShortName() );
+ m_pViewImpl->StartDocumentInserter( sFactory, LINK( this, SwView, DialogClosedHdl ) );
+ return -1;
+ }
+
+ if( !pMed )
+ return -1;
+
+ return InsertMedium( nSlotId, pMed, nVersion );
+}
+
+long SwView::InsertMedium( sal_uInt16 nSlotId, SfxMedium* pMedium, sal_Int16 nVersion )
+{
+ sal_Bool bInsert = sal_False, bCompare = sal_False;
+ long nFound = 0;
+ SwDocShell* pDocSh = GetDocShell();
+
+ switch( nSlotId )
+ {
+ case SID_DOCUMENT_MERGE: break;
+ case SID_DOCUMENT_COMPARE: bCompare = sal_True; break;
+ case SID_INSERTDOC: bInsert = sal_True; break;
+
+ default:
+ OSL_ENSURE( !this, "unknown SlotId!" );
+ bInsert = sal_True;
+ nSlotId = SID_INSERTDOC;
+ break;
+ }
+
+ if( bInsert )
+ {
+ uno::Reference< frame::XDispatchRecorder > xRecorder =
+ GetViewFrame()->GetBindings().GetRecorder();
+ if ( xRecorder.is() )
+ {
+ SfxRequest aRequest(GetViewFrame(), SID_INSERTDOC);
+ aRequest.AppendItem(SfxStringItem(SID_INSERTDOC, pMedium->GetOrigURL()));
+ if(pMedium->GetFilter())
+ aRequest.AppendItem(SfxStringItem(FN_PARAM_1, pMedium->GetFilter()->GetName()));
+ aRequest.Done();
+ }
+
+ SfxObjectShellRef aRef( pDocSh );
+
+ sal_uInt32 nError = SfxObjectShell::HandleFilter( pMedium, pDocSh );
+ // #i16722# aborted?
+ if(nError != ERRCODE_NONE)
+ {
+ delete pMedium;
+ return -1;
+ }
+
+ pMedium->DownLoad(); // start download if needed
+ if( aRef.Is() && 1 < aRef->GetRefCount() ) // still a valid ref?
+ {
+ SwReader* pRdr;
+ Reader *pRead = pDocSh->StartConvertFrom( *pMedium, &pRdr, m_pWrtShell );
+ if( pRead ||
+ (pMedium->GetFilter()->GetFilterFlags() & SFX_FILTER_STARONEFILTER) != 0 )
+ {
+ sal_uInt16 nUndoCheck = 0;
+ SwDoc *pDoc = pDocSh->GetDoc();
+ if( pRead && pDocSh->GetDoc() )
+ nUndoCheck = lcl_PageDescWithHeader( *pDoc );
+ sal_uLong nErrno;
+ { //Scope for SwWait-Object, to be able to execute slots
+ //outside this scope.
+ SwWait aWait( *GetDocShell(), true );
+ m_pWrtShell->StartAllAction();
+ if ( m_pWrtShell->HasSelection() )
+ m_pWrtShell->DelRight(); // delete selections
+ if( pRead )
+ {
+ nErrno = pRdr->Read( *pRead ); // and insert document
+ delete pRdr;
+ }
+ else
+ {
+ ::sw::UndoGuard const ug(pDoc->GetIDocumentUndoRedo());
+ uno::Reference<text::XTextRange> const xInsertPosition(
+ SwXTextRange::CreateXTextRange(*pDoc,
+ *m_pWrtShell->GetCrsr()->GetPoint(), 0));
+ nErrno = pDocSh->ImportFrom(*pMedium, xInsertPosition)
+ ? 0 : ERR_SWG_READ_ERROR;
+ }
+
+ }
+
+ // update all "table of ..." sections if needed
+ if( m_pWrtShell->IsUpdateTOX() )
+ {
+ SfxRequest aReq( FN_UPDATE_TOX, SFX_CALLMODE_SLOT, GetPool() );
+ Execute( aReq );
+ m_pWrtShell->SetUpdateTOX( sal_False ); // reset
+ }
+
+ if( pDoc )
+ { // Disable Undo for .sdw or
+ // if the number of page styles with header/footer has changed
+ if( !pRead || nUndoCheck != lcl_PageDescWithHeader( *pDoc ) )
+ {
+ pDoc->GetIDocumentUndoRedo().DelAllUndoObj();
+ }
+ }
+
+ m_pWrtShell->EndAllAction();
+ if( nErrno )
+ {
+ ErrorHandler::HandleError( nErrno );
+ nFound = IsError( nErrno ) ? -1 : 0;
+ }
+ else
+ nFound = 0;
+ }
+ }
+ }
+ else
+ {
+ SfxObjectShellRef xDocSh;
+ SfxObjectShellLock xLockRef;
+
+ OUString sFltNm;
+ const int nRet = SwFindDocShell( xDocSh, xLockRef, pMedium->GetName(), OUString(),
+ sFltNm, nVersion, pDocSh );
+ if( nRet )
+ {
+ SwWait aWait( *GetDocShell(), true );
+ m_pWrtShell->StartAllAction();
+
+ m_pWrtShell->EnterStdMode(); // delete selections
+
+ if( bCompare )
+ nFound = m_pWrtShell->CompareDoc( *((SwDocShell*)&xDocSh)->GetDoc() );
+ else
+ nFound = m_pWrtShell->MergeDoc( *((SwDocShell*)&xDocSh)->GetDoc() );
+
+ m_pWrtShell->EndAllAction();
+
+ if (!bCompare && !nFound)
+ {
+ Window* pWin = &GetEditWin();
+ InfoBox(pWin, SW_RES(MSG_NO_MERGE_ENTRY)).Execute();
+ }
+ if( nRet==2 && xDocSh.Is() )
+ xDocSh->DoClose();
+ }
+ }
+
+ delete pMedium;
+ return nFound;
+}
+
+void SwView::EnableMailMerge(sal_Bool bEnable )
+{
+ m_bInMailMerge = bEnable;
+ SfxBindings& rBind = GetViewFrame()->GetBindings();
+ rBind.Invalidate(FN_INSERT_FIELD_DATA_ONLY);
+ rBind.Update(FN_INSERT_FIELD_DATA_ONLY);
+}
+
+namespace
+{
+ sal_Bool lcl_NeedAdditionalDataSource( const uno::Reference< XDatabaseContext >& _rDatasourceContext )
+ {
+ Sequence < OUString > aNames = _rDatasourceContext->getElementNames();
+
+ return ( !aNames.getLength()
+ || ( ( 1 == aNames.getLength() )
+ && aNames.getConstArray()[0] == SW_MOD()->GetDBConfig()->GetBibliographySource().sDataSource
+ )
+ );
+ }
+}
+
+void SwView::GenerateFormLetter(sal_Bool bUseCurrentDocument)
+{
+ if(bUseCurrentDocument)
+ {
+ if(!GetWrtShell().IsAnyDatabaseFieldInDoc())
+ {
+ //check availability of data sources (except biblio source)
+ uno::Reference<XComponentContext> xContext( ::comphelper::getProcessComponentContext() );
+ uno::Reference<XDatabaseContext> xDBContext = DatabaseContext::create(xContext);
+ sal_Bool bCallAddressPilot = sal_False;
+ if ( lcl_NeedAdditionalDataSource( xDBContext ) )
+ {
+ // no data sources are available - create a new one
+ MessageDialog aQuery(&GetViewFrame()->GetWindow(),
+ "DataSourcesUnavailableDialog",
+ "modules/swriter/ui/datasourcesunavailabledialog.ui");
+ // no cancel allowed
+ if (RET_OK != aQuery.Execute())
+ return;
+ bCallAddressPilot = sal_True;
+ }
+ else
+ {
+ //take an existing data source or create a new one?
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "Dialogdiet fail!");
+ AbstractMailMergeFieldConnectionsDlg* pConnectionsDlg = pFact->CreateMailMergeFieldConnectionsDlg(&GetViewFrame()->GetWindow());
+ OSL_ENSURE(pConnectionsDlg, "Dialogdiet fail!");
+ if(RET_OK == pConnectionsDlg->Execute())
+ bCallAddressPilot = !pConnectionsDlg->IsUseExistingConnections();
+ else
+ return;
+
+ }
+ if(bCallAddressPilot)
+ {
+ GetViewFrame()->GetDispatcher()->Execute(
+ SID_ADDRESS_DATA_SOURCE, SFX_CALLMODE_SYNCHRON);
+ if ( lcl_NeedAdditionalDataSource( xDBContext ) )
+ // no additional data source has been created
+ // -> assume that the user has cancelled the pilot
+ return;
+ }
+
+ //call insert fields with database field page available, only
+ SfxViewFrame* pVFrame = GetViewFrame();
+ //at first hide the default field dialog if currently visible
+ pVFrame->SetChildWindow(FN_INSERT_FIELD, sal_False);
+ //enable the status of the db field dialog - it is disabled in the status method
+ //to prevent creation of the dialog without mail merge active
+ EnableMailMerge();
+ //then show the "Data base only" field dialog
+ SfxBoolItem aOn(FN_INSERT_FIELD_DATA_ONLY, true);
+ pVFrame->GetDispatcher()->Execute(FN_INSERT_FIELD_DATA_ONLY,
+ SFX_CALLMODE_SYNCHRON, &aOn, 0L);
+ return;
+ }
+ else
+ {
+ OUString sSource;
+ if(!GetWrtShell().IsFieldDataSourceAvailable(sSource))
+ {
+ MessageDialog aWarning(&GetViewFrame()->GetWindow(),
+ "WarnDataSourceDialog",
+ "modules/swriter/ui/warndatasourcedialog.ui");
+ OUString sTmp(aWarning.get_primary_text());
+ aWarning.set_primary_text(sTmp.replaceFirst("%1", "SOURCE"));
+ if (RET_OK == aWarning.Execute())
+ {
+ SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
+ if ( pFact )
+ {
+ boost::scoped_ptr<VclAbstractDialog> pDlg(pFact->CreateVclDialog( NULL, SID_OPTIONS_DATABASES ));
+ pDlg->Execute();
+ }
+ }
+ return ;
+ }
+ }
+ SwNewDBMgr* pNewDBMgr = GetWrtShell().GetNewDBMgr();
+
+ SwDBData aData;
+ SwWrtShell &rSh = GetWrtShell();
+
+ std::vector<OUString> aDBNameList;
+ std::vector<OUString> aAllDBNames;
+ rSh.GetAllUsedDB( aDBNameList, &aAllDBNames );
+ if(!aDBNameList.empty())
+ {
+ OUString sDBName(aDBNameList[0]);
+ aData.sDataSource = sDBName.getToken(0, DB_DELIM);
+ aData.sCommand = sDBName.getToken(1, DB_DELIM);
+ aData.nCommandType = sDBName.getToken(2, DB_DELIM ).toInt32();
+ }
+ rSh.EnterStdMode(); // force change in text shell; necessary for mixing DB fields
+ AttrChangedNotify( &rSh );
+
+ if (pNewDBMgr)
+ {
+ Sequence<PropertyValue> aProperties(3);
+ PropertyValue* pValues = aProperties.getArray();
+ pValues[0].Name = "DataSourceName";
+ pValues[1].Name = "Command";
+ pValues[2].Name = "CommandType";
+ pValues[0].Value <<= aData.sDataSource;
+ pValues[1].Value <<= aData.sCommand;
+ pValues[2].Value <<= aData.nCommandType;
+ pNewDBMgr->ExecuteFormLetter(GetWrtShell(), aProperties, sal_True);
+ }
+ }
+ else
+ {
+ // call documents and template dialog
+ SfxApplication* pSfxApp = SFX_APP();
+ Window* pTopWin = pSfxApp->GetTopWindow();
+ SvtDocumentTemplateDialog* pDocTemplDlg = new SvtDocumentTemplateDialog( pTopWin );
+ pDocTemplDlg->SelectTemplateFolder();
+
+ int nRet = pDocTemplDlg->Execute();
+ sal_Bool bNewWin = sal_False;
+ if ( nRet == RET_OK )
+ {
+ if ( pTopWin != pSfxApp->GetTopWindow() )
+ {
+ // the dialogue opens a document -> a new TopWindow appears
+ pTopWin = pSfxApp->GetTopWindow();
+ bNewWin = sal_True;
+ }
+ }
+
+ delete pDocTemplDlg;
+ if ( bNewWin )
+ // after the destruction of the dialogue its parent comes to top,
+ // but we want that the new document is on top
+ pTopWin->ToTop();
+ }
+}
+
+IMPL_LINK( SwView, DialogClosedHdl, sfx2::FileDialogHelper*, _pFileDlg )
+{
+ if ( ERRCODE_NONE == _pFileDlg->GetError() )
+ {
+ SfxMedium* pMed = m_pViewImpl->CreateMedium();
+ if ( pMed )
+ {
+ sal_uInt16 nSlot = m_pViewImpl->GetRequest()->GetSlot();
+ long nFound = InsertMedium( nSlot, pMed, m_pViewImpl->GetParam() );
+
+ if ( SID_INSERTDOC == nSlot )
+ {
+ if ( m_pViewImpl->GetParam() == 0 )
+ {
+ m_pViewImpl->GetRequest()->SetReturnValue( SfxBoolItem( nSlot, nFound != -1 ) );
+ m_pViewImpl->GetRequest()->Ignore();
+ }
+ else
+ {
+ m_pViewImpl->GetRequest()->SetReturnValue( SfxBoolItem( nSlot, nFound != -1 ) );
+ m_pViewImpl->GetRequest()->Done();
+ }
+ }
+ else if ( SID_DOCUMENT_COMPARE == nSlot || SID_DOCUMENT_MERGE == nSlot )
+ {
+ m_pViewImpl->GetRequest()->SetReturnValue( SfxInt32Item( nSlot, nFound ) );
+
+ if ( nFound > 0 ) // show Redline browser
+ {
+ SfxViewFrame* pVFrame = GetViewFrame();
+ pVFrame->ShowChildWindow(FN_REDLINE_ACCEPT);
+
+ // re-initialize Redline dialog
+ sal_uInt16 nId = SwRedlineAcceptChild::GetChildWindowId();
+ SwRedlineAcceptChild* pRed = (SwRedlineAcceptChild*)pVFrame->GetChildWindow( nId );
+ if ( pRed )
+ pRed->ReInitDlg( GetDocShell() );
+ }
+ }
+ }
+ }
+ return 0;
+}
+
+void SwView::ExecuteScan( SfxRequest& rReq )
+{
+ if (m_pViewImpl)
+ m_pViewImpl->ExecuteScan(rReq) ;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/uiview/viewcoll.cxx b/sw/source/core/uibase/uiview/viewcoll.cxx
new file mode 100644
index 000000000000..1c87105ba737
--- /dev/null
+++ b/sw/source/core/uibase/uiview/viewcoll.cxx
@@ -0,0 +1,80 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "cmdid.h"
+#include "uiitems.hxx"
+#include <vcl/window.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <svl/stritem.hxx>
+#include <rsc/rscsfx.hxx>
+
+#include "view.hxx"
+#include "wrtsh.hxx"
+#include "basesh.hxx"
+
+void SwView::ExecColl(SfxRequest &rReq)
+{
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ const SfxPoolItem* pItem = 0;
+ sal_uInt16 nWhich = rReq.GetSlot();
+ switch( nWhich )
+ {
+ case FN_SET_PAGE:
+ {
+ OSL_ENSURE(!this, "Not implemented");
+ }
+ break;
+ case FN_SET_PAGE_STYLE:
+ {
+ if( pArgs )
+ {
+ if (pArgs &&
+ SFX_ITEM_SET == pArgs->GetItemState( nWhich , true, &pItem ))
+ {
+ if( ((SfxStringItem*)pItem)->GetValue() !=
+ GetWrtShell().GetCurPageStyle(sal_False) )
+ {
+ SfxStringItem aName(SID_STYLE_APPLY,
+ ((SfxStringItem*)pItem)->GetValue());
+ SfxUInt16Item aFamItem( SID_STYLE_FAMILY,
+ SFX_STYLE_FAMILY_PAGE);
+ SwPtrItem aShell(FN_PARAM_WRTSHELL, GetWrtShellPtr());
+ SfxRequest aReq(SID_STYLE_APPLY, 0, GetPool());
+ aReq.AppendItem(aName);
+ aReq.AppendItem(aFamItem);
+ aReq.AppendItem(aShell);
+ GetCurShell()->ExecuteSlot(aReq);
+ }
+ }
+ }
+ else
+ {
+ SfxRequest aReq(FN_FORMAT_PAGE_DLG, 0, GetPool());
+ GetCurShell()->ExecuteSlot(aReq);
+ }
+ }
+ break;
+ default:
+ OSL_FAIL("wrong CommandProcessor for Dispatch");
+ return;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/uiview/viewdlg.cxx b/sw/source/core/uibase/uiview/viewdlg.cxx
new file mode 100644
index 000000000000..b41d6ca345e5
--- /dev/null
+++ b/sw/source/core/uibase/uiview/viewdlg.cxx
@@ -0,0 +1,75 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "hintids.hxx"
+#include <sfx2/viewfrm.hxx>
+#include <editeng/tstpitem.hxx>
+#include <svl/stritem.hxx>
+#include <sfx2/request.hxx>
+
+#include "view.hxx"
+#include "wrtsh.hxx"
+#include "basesh.hxx"
+#include "viewopt.hxx"
+#include "uitool.hxx"
+#include "cmdid.h"
+#include <sfx2/tabdlg.hxx>
+
+#include "pagedesc.hxx"
+
+void SwView::ExecDlg(SfxRequest &rReq)
+{
+ // Thus, from the basic no dialogues for background views are called:
+ const SfxPoolItem* pItem = 0;
+ const SfxItemSet* pArgs = rReq.GetArgs();
+
+ sal_uInt16 nSlot = rReq.GetSlot();
+ if(pArgs)
+ pArgs->GetItemState( GetPool().GetWhich(nSlot), false, &pItem );
+
+ switch ( nSlot )
+ {
+ case FN_CHANGE_PAGENUM:
+ {
+ if ( pItem )
+ {
+ sal_uInt16 nValue = ((SfxUInt16Item *)pItem)->GetValue();
+ sal_uInt16 nOldValue = m_pWrtShell->GetPageOffset();
+ sal_uInt16 nPage, nLogPage;
+ m_pWrtShell->GetPageNum( nPage, nLogPage,
+ m_pWrtShell->IsCrsrVisible(), sal_False);
+
+ if(nValue != nOldValue || nValue != nLogPage)
+ {
+ if(!nOldValue)
+ m_pWrtShell->SetNewPageOffset( nValue );
+ else
+ m_pWrtShell->SetPageOffset( nValue );
+ }
+ }
+ }
+ break;
+
+ default:
+ OSL_ENSURE(!this, "wrong dispatcher");
+ return;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/uiview/viewdlg2.cxx b/sw/source/core/uibase/uiview/viewdlg2.cxx
new file mode 100644
index 000000000000..af466021ead5
--- /dev/null
+++ b/sw/source/core/uibase/uiview/viewdlg2.cxx
@@ -0,0 +1,202 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <sfx2/request.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/objface.hxx>
+#include <fldmgr.hxx>
+#include <expfld.hxx>
+#include <modcfg.hxx>
+
+#include <tools/shl.hxx>
+
+#include "swmodule.hxx"
+#include "view.hxx"
+#include "wview.hxx"
+#include "wrtsh.hxx"
+#include "cmdid.h"
+#include "caption.hxx"
+#include "poolfmt.hxx"
+#include "edtwin.hxx"
+#include <SwStyleNameMapper.hxx>
+
+#include "initui.hxx"
+#include "swabstdlg.hxx"
+#include "frmui.hrc"
+#include "misc.hrc"
+
+#include "view.hrc"
+
+#include <boost/scoped_ptr.hpp>
+
+void SwView::ExecDlgExt(SfxRequest &rReq)
+{
+ Window *pMDI = &GetViewFrame()->GetWindow();
+
+ switch ( rReq.GetSlot() )
+ {
+ case FN_INSERT_CAPTION:
+ {
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+
+ boost::scoped_ptr<VclAbstractDialog> pDialog(pFact->CreateSwCaptionDialog( pMDI, *this, DLG_CAPTION ));
+ OSL_ENSURE(pDialog, "Dialogdiet fail!");
+ if ( pDialog )
+ {
+ pDialog->Execute();
+ }
+ break;
+ }
+ case FN_EDIT_FOOTNOTE:
+ {
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "Dialogdiet fail!");
+ boost::scoped_ptr<AbstractInsFootNoteDlg> pDlg(pFact->CreateInsFootNoteDlg(
+ pMDI, *m_pWrtShell, sal_True));
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+
+ pDlg->SetHelpId(GetStaticInterface()->GetSlot(FN_EDIT_FOOTNOTE)->GetCommand());
+ pDlg->SetText( SW_RESSTR(STR_EDIT_FOOTNOTE) );
+ pDlg->Execute();
+ break;
+ }
+ }
+}
+
+void SwView::AutoCaption(const sal_uInt16 nType, const SvGlobalName *pOleId)
+{
+ SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
+
+ sal_Bool bWeb = 0 != PTR_CAST(SwWebView, this);
+ if (pModOpt->IsInsWithCaption(bWeb))
+ {
+ const InsCaptionOpt *pOpt = pModOpt->GetCapOption(bWeb, (SwCapObjType)nType, pOleId);
+ if (pOpt && pOpt->UseCaption() == sal_True)
+ InsertCaption(pOpt);
+ }
+}
+
+void SwView::InsertCaption(const InsCaptionOpt *pOpt)
+{
+ if (!pOpt)
+ return;
+
+ const OUString &rName = pOpt->GetCategory();
+
+ // Is there a pool template with the same name?
+ SwWrtShell &rSh = GetWrtShell();
+ if(!rName.isEmpty())
+ {
+ sal_uInt16 nPoolId = SwStyleNameMapper::GetPoolIdFromUIName(rName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL);
+ if( USHRT_MAX != nPoolId )
+ rSh.GetTxtCollFromPool(nPoolId);
+ // Pool template does not exist: Does it exist on the document?
+ else if( !rSh.GetParaStyle(rName) )
+ {
+ // It also does not exist in the document: generate
+ SwTxtFmtColl* pDerivedFrom = rSh.GetTxtCollFromPool(RES_POOLCOLL_LABEL);
+ rSh.MakeTxtFmtColl(rName, pDerivedFrom);
+ }
+ }
+
+ SelectionType eType = rSh.GetSelectionType();
+ if (eType & nsSelectionType::SEL_OLE)
+ eType = nsSelectionType::SEL_GRF;
+
+ const SwLabelType eT = eType & nsSelectionType::SEL_TBL ? LTYPE_TABLE :
+ eType & nsSelectionType::SEL_FRM ? LTYPE_FLY :
+ eType == nsSelectionType::SEL_TXT ? LTYPE_FLY :
+ eType & nsSelectionType::SEL_DRW ? LTYPE_DRAW :
+ LTYPE_OBJECT;
+
+ SwFldMgr aMgr(&rSh);
+ SwSetExpFieldType* pFldType =
+ (SwSetExpFieldType*)aMgr.GetFldType(RES_SETEXPFLD, rName);
+ if (!pFldType && !rName.isEmpty() )
+ {
+ // Create new field types
+ SwSetExpFieldType aSwSetExpFieldType(rSh.GetDoc(), rName, nsSwGetSetExpType::GSE_SEQ);
+ aMgr.InsertFldType(aSwSetExpFieldType);
+ pFldType = (SwSetExpFieldType*)aMgr.GetFldType(RES_SETEXPFLD, rName);
+ }
+
+ if (!pOpt->IgnoreSeqOpts())
+ {
+ if (pFldType)
+ {
+ pFldType->SetDelimiter(pOpt->GetSeparator());
+ pFldType->SetOutlineLvl( static_cast< sal_uInt8 >(pOpt->GetLevel()) );
+ }
+ }
+
+ sal_uInt16 nID = USHRT_MAX;
+ SwFieldType* pType = 0;
+ const sal_uInt16 nCount = aMgr.GetFldTypeCount();
+ if( !rName.isEmpty() )
+ {
+ for (sal_uInt16 i = 0; i < nCount; ++i)
+ {
+ pType = aMgr.GetFldType(USHRT_MAX, i);
+ OUString aTmpName( pType->GetName() );
+ if (aTmpName == rName && pType->Which() == RES_SETEXPFLD)
+ {
+ nID = i;
+ break;
+ }
+ }
+ }
+ rSh.StartAllAction();
+
+ GetWrtShell().InsertLabel( eT,
+ pOpt->GetCaption(),
+ !pOpt->IgnoreSeqOpts() ? OUString() : pOpt->GetSeparator(),
+ pOpt->GetNumSeparator(),
+ !pOpt->GetPos(),
+ nID,
+ pOpt->GetCharacterStyle(),
+ pOpt->CopyAttributes() );
+ // Set Number Format
+ if(pType)
+ ((SwSetExpFieldType*)pType)->SetSeqFormat(pOpt->GetNumType());
+
+ rSh.UpdateExpFlds( sal_True );
+
+ rSh.EndAllAction();
+
+ if ( rSh.IsFrmSelected() )
+ {
+ GetEditWin().StopInsFrm();
+ rSh.EnterSelFrmMode();
+ }
+
+ // rember category
+ if (eType & nsSelectionType::SEL_GRF)
+ SetOldGrfCat(rName);
+ else if( eType & nsSelectionType::SEL_TBL)
+ SetOldTabCat(rName);
+ else if( eType & nsSelectionType::SEL_FRM)
+ SetOldFrmCat(rName);
+ else if( eType == nsSelectionType::SEL_TXT)
+ SetOldFrmCat(rName);
+ else if( eType & nsSelectionType::SEL_DRW)
+ SetOldDrwCat(rName);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/uiview/viewdraw.cxx b/sw/source/core/uibase/uiview/viewdraw.cxx
new file mode 100644
index 000000000000..0e9849c797c4
--- /dev/null
+++ b/sw/source/core/uibase/uiview/viewdraw.cxx
@@ -0,0 +1,755 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "hintids.hxx"
+#include <svl/aeitem.hxx>
+#include <svl/itempool.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/svdview.hxx>
+#include <svx/svdpage.hxx>
+#include <editeng/editview.hxx>
+#include <editeng/editeng.hxx>
+#include <editeng/outliner.hxx>
+#include <svx/fmview.hxx>
+#include <svx/dataaccessdescriptor.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <doc.hxx>
+#include <editeng/langitem.hxx>
+#include <linguistic/lngprops.hxx>
+#include <editeng/unolingu.hxx>
+#include <svx/fontworkbar.hxx>
+#include <svx/fontworkgallery.hxx>
+#include <editeng/eeitem.hxx>
+#include <svx/svdogrp.hxx>
+#include <svx/svdetc.hxx>
+#include <editeng/editstat.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/printer.hxx>
+#include <svx/fmglob.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svx/svdoutl.hxx>
+
+#include "view.hxx"
+#include "wrtsh.hxx"
+#include "viewopt.hxx"
+#include "cmdid.h"
+#include "drawsh.hxx"
+#include "drwbassh.hxx"
+#include "beziersh.hxx"
+#include "conrect.hxx"
+#include "conpoly.hxx"
+#include "conarc.hxx"
+#include "conform.hxx"
+#include "concustomshape.hxx"
+#include "dselect.hxx"
+#include "edtwin.hxx"
+
+#include <dcontact.hxx>
+
+#include <svx/svdpagv.hxx>
+#include <svx/extrusionbar.hxx>
+#include <vcl/svapp.hxx>
+
+using namespace ::com::sun::star;
+
+// Execute Drawing-Ids
+
+void SwView::ExecDraw(SfxRequest& rReq)
+{
+ const SfxItemSet *pArgs = rReq.GetArgs();
+ const SfxPoolItem* pItem;
+ const SfxAllEnumItem* pEItem = 0;
+ const SfxStringItem* pStringItem = 0;
+ SdrView *pSdrView = m_pWrtShell->GetDrawView();
+ sal_Bool bDeselect = sal_False;
+
+ sal_uInt16 nSlotId = rReq.GetSlot();
+ if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(GetPool().GetWhich(nSlotId), false, &pItem))
+ {
+ pEItem = dynamic_cast< const SfxAllEnumItem*>(pItem);
+ pStringItem = dynamic_cast< const SfxStringItem*>(pItem);
+ }
+
+ if (SID_INSERT_DRAW == nSlotId && pEItem)
+ switch ( pEItem->GetValue() )
+ {
+ case SVX_SNAP_DRAW_SELECT: nSlotId = SID_OBJECT_SELECT; break;
+ case SVX_SNAP_DRAW_LINE: nSlotId = SID_DRAW_LINE; break;
+ case SVX_SNAP_DRAW_RECT: nSlotId = SID_DRAW_RECT; break;
+ case SVX_SNAP_DRAW_ELLIPSE: nSlotId = SID_DRAW_ELLIPSE; break;
+ case SVX_SNAP_DRAW_POLYGON_NOFILL: nSlotId = SID_DRAW_POLYGON_NOFILL; break;
+ case SVX_SNAP_DRAW_BEZIER_NOFILL: nSlotId = SID_DRAW_BEZIER_NOFILL; break;
+ case SVX_SNAP_DRAW_FREELINE_NOFILL: nSlotId = SID_DRAW_FREELINE_NOFILL; break;
+ case SVX_SNAP_DRAW_ARC: nSlotId = SID_DRAW_ARC; break;
+ case SVX_SNAP_DRAW_PIE: nSlotId = SID_DRAW_PIE; break;
+ case SVX_SNAP_DRAW_CIRCLECUT: nSlotId = SID_DRAW_CIRCLECUT; break;
+ case SVX_SNAP_DRAW_TEXT: nSlotId = SID_DRAW_TEXT; break;
+ case SVX_SNAP_DRAW_TEXT_VERTICAL: nSlotId = SID_DRAW_TEXT_VERTICAL; break;
+ case SVX_SNAP_DRAW_TEXT_MARQUEE: nSlotId = SID_DRAW_TEXT_MARQUEE; break;
+ case SVX_SNAP_DRAW_CAPTION: nSlotId = SID_DRAW_CAPTION; break;
+ case SVX_SNAP_DRAW_CAPTION_VERTICAL: nSlotId = SID_DRAW_CAPTION_VERTICAL; break;
+ }
+
+ if (nSlotId == SID_OBJECT_SELECT && m_nFormSfxId == nSlotId)
+ {
+ bDeselect = sal_True;
+ }
+ else if (nSlotId == SID_FM_CREATE_CONTROL)
+ {
+ SFX_REQUEST_ARG( rReq, pIdentifierItem, SfxUInt16Item, SID_FM_CONTROL_IDENTIFIER, false );
+ if( pIdentifierItem )
+ {
+ sal_uInt16 nNewId = pIdentifierItem->GetValue();
+ if (nNewId == m_nFormSfxId)
+ {
+ bDeselect = sal_True;
+ GetViewFrame()->GetDispatcher()->Execute(SID_FM_LEAVE_CREATE); // Button should popping out
+ }
+ }
+ }
+ else if( nSlotId == SID_FM_CREATE_FIELDCONTROL)
+ {
+ FmFormView* pFormView = PTR_CAST( FmFormView, pSdrView );
+ if ( pFormView )
+ {
+ SFX_REQUEST_ARG( rReq, pDescriptorItem, SfxUnoAnyItem, SID_FM_DATACCESS_DESCRIPTOR, false );
+ OSL_ENSURE( pDescriptorItem, "SwView::ExecDraw(SID_FM_CREATE_FIELDCONTROL): invalid request args!" );
+ if( pDescriptorItem )
+ {
+ ::svx::ODataAccessDescriptor aDescriptor( pDescriptorItem->GetValue() );
+ SdrObject* pObj = pFormView->CreateFieldControl( aDescriptor );
+
+ if ( pObj )
+ {
+ Size aDocSize(m_pWrtShell->GetDocSize());
+ const SwRect& rVisArea = m_pWrtShell->VisArea();
+ Point aStartPos = rVisArea.Center();
+ if(rVisArea.Width() > aDocSize.Width())
+ aStartPos.X() = aDocSize.Width() / 2 + rVisArea.Left();
+ if(rVisArea.Height() > aDocSize.Height())
+ aStartPos.Y() = aDocSize.Height() / 2 + rVisArea.Top();
+
+ //determine the size of the object
+ if(pObj->IsGroupObject())
+ {
+ const Rectangle& rBoundRect = ((SdrObjGroup*)pObj)->GetCurrentBoundRect();
+ aStartPos.X() -= rBoundRect.GetWidth()/2;
+ aStartPos.Y() -= rBoundRect.GetHeight()/2;
+ }
+
+ // TODO: unmark all other
+ m_pWrtShell->EnterStdMode();
+ m_pWrtShell->SwFEShell::InsertDrawObj( *pObj, aStartPos );
+ }
+ }
+ }
+ }
+ else if ( nSlotId == SID_FONTWORK_GALLERY_FLOATER )
+ {
+ Window* pWin = &( m_pWrtShell->GetView().GetViewFrame()->GetWindow() );
+
+ if ( pWin )
+ pWin->EnterWait();
+
+ if( !m_pWrtShell->HasDrawView() )
+ m_pWrtShell->MakeDrawView();
+
+ pSdrView = m_pWrtShell->GetDrawView();
+ if ( pSdrView )
+ {
+ SdrObject* pObj = NULL;
+ svx::FontWorkGalleryDialog aDlg( pSdrView, pWin, nSlotId );
+ aDlg.SetSdrObjectRef( &pObj, pSdrView->GetModel() );
+ aDlg.Execute();
+ if ( pObj )
+ {
+ Size aDocSize( m_pWrtShell->GetDocSize() );
+ const SwRect& rVisArea = m_pWrtShell->VisArea();
+ Point aPos( rVisArea.Center() );
+ Size aSize;
+ Size aPrefSize( pObj->GetSnapRect().GetSize() );
+
+ if( rVisArea.Width() > aDocSize.Width())
+ aPos.X() = aDocSize.Width() / 2 + rVisArea.Left();
+
+ if(rVisArea.Height() > aDocSize.Height())
+ aPos.Y() = aDocSize.Height() / 2 + rVisArea.Top();
+
+ if( aPrefSize.Width() && aPrefSize.Height() )
+ {
+ if( pWin )
+ aSize = pWin->PixelToLogic( aPrefSize, MAP_TWIP );
+ else
+ aSize = Application::GetDefaultDevice()->PixelToLogic( aPrefSize, MAP_TWIP );
+ }
+ else
+ aSize = Size( 2835, 2835 );
+
+ m_pWrtShell->EnterStdMode();
+ m_pWrtShell->SwFEShell::InsertDrawObj( *pObj, aPos );
+ rReq.Ignore ();
+ }
+ }
+ if( pWin )
+ pWin->LeaveWait();
+ }
+
+ if( nSlotId == SID_DRAW_CS_ID )
+ {
+ //deselect if same custom shape is selected again
+ SwDrawBase* pFuncPtr = GetDrawFuncPtr();
+ if( pFuncPtr && pFuncPtr->GetSlotId() == SID_DRAW_CS_ID )
+ {
+ ConstCustomShape* pConstCustomShape = (ConstCustomShape*)(pFuncPtr);
+ OUString aNew = ConstCustomShape::GetShapeTypeFromRequest( rReq );
+ OUString aOld = pConstCustomShape->GetShapeType();
+ if( aNew == aOld )
+ {
+ bDeselect = true;
+ }
+ }
+ }
+
+ //deselect if same shape is selected again (but different custom shapes do have same slot id)
+ if ( bDeselect || (nSlotId == m_nDrawSfxId &&
+ (!pStringItem || (pStringItem->GetValue() == m_sDrawCustom))
+ && (nSlotId != SID_DRAW_CS_ID) ) )
+ {
+ if (GetDrawFuncPtr())
+ {
+ GetDrawFuncPtr()->Deactivate();
+ SetDrawFuncPtr(NULL);
+ }
+
+ if (m_pWrtShell->IsObjSelected() && !m_pWrtShell->IsSelFrmMode())
+ m_pWrtShell->EnterSelFrmMode(NULL);
+ LeaveDrawCreate();
+
+ GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW);
+
+ AttrChangedNotify(m_pWrtShell);
+ return;
+ }
+
+ LeaveDrawCreate();
+
+ if (m_pWrtShell->IsFrmSelected())
+ m_pWrtShell->EnterStdMode(); // because bug #45639
+
+ SwDrawBase* pFuncPtr = NULL;
+
+ switch (nSlotId)
+ {
+ case SID_OBJECT_SELECT:
+ case SID_DRAW_SELECT:
+ pFuncPtr = new DrawSelection(m_pWrtShell, m_pEditWin, this);
+ m_nDrawSfxId = m_nFormSfxId = SID_OBJECT_SELECT;
+ m_sDrawCustom = "";
+ break;
+
+ case SID_DRAW_LINE:
+ case SID_DRAW_RECT:
+ case SID_DRAW_ELLIPSE:
+ case SID_DRAW_TEXT:
+ case SID_DRAW_TEXT_VERTICAL:
+ case SID_DRAW_TEXT_MARQUEE:
+ case SID_DRAW_CAPTION:
+ case SID_DRAW_CAPTION_VERTICAL:
+ pFuncPtr = new ConstRectangle(m_pWrtShell, m_pEditWin, this);
+ m_nDrawSfxId = nSlotId;
+ m_sDrawCustom = "";
+ break;
+
+ case SID_DRAW_POLYGON_NOFILL:
+ case SID_DRAW_BEZIER_NOFILL:
+ case SID_DRAW_FREELINE_NOFILL:
+ pFuncPtr = new ConstPolygon(m_pWrtShell, m_pEditWin, this);
+ m_nDrawSfxId = nSlotId;
+ m_sDrawCustom = "";
+ break;
+
+ case SID_DRAW_ARC:
+ case SID_DRAW_PIE:
+ case SID_DRAW_CIRCLECUT:
+ pFuncPtr = new ConstArc(m_pWrtShell, m_pEditWin, this);
+ m_nDrawSfxId = nSlotId;
+ m_sDrawCustom = "";
+ break;
+
+ case SID_FM_CREATE_CONTROL:
+ {
+ SFX_REQUEST_ARG( rReq, pIdentifierItem, SfxUInt16Item, SID_FM_CONTROL_IDENTIFIER, false );
+ if( pIdentifierItem )
+ nSlotId = pIdentifierItem->GetValue();
+ pFuncPtr = new ConstFormControl(m_pWrtShell, m_pEditWin, this);
+ m_nFormSfxId = nSlotId;
+ }
+ 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 :
+ {
+ pFuncPtr = new ConstCustomShape(m_pWrtShell, m_pEditWin, this, rReq );
+ m_nDrawSfxId = nSlotId;
+ if ( nSlotId != SID_DRAW_CS_ID )
+ {
+ if ( pStringItem )
+ {
+ m_sDrawCustom = pStringItem->GetValue();
+ m_aCurrShapeEnumCommand[ nSlotId - SID_DRAWTBX_CS_BASIC ] = m_sDrawCustom;
+ SfxBindings& rBind = GetViewFrame()->GetBindings();
+ rBind.Invalidate( nSlotId );
+ rBind.Update( nSlotId );
+ }
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ static sal_uInt16 const aInval[] =
+ {
+ // Slot IDs must be sorted when calling Invalidate!
+ SID_ATTRIBUTES_AREA,
+ SID_INSERT_DRAW,
+ 0
+ };
+ GetViewFrame()->GetBindings().Invalidate(aInval);
+
+ sal_Bool bEndTextEdit = sal_True;
+ if (pFuncPtr)
+ {
+ if (GetDrawFuncPtr())
+ {
+ GetDrawFuncPtr()->Deactivate();
+ SetDrawFuncPtr(NULL);
+ }
+
+ SetDrawFuncPtr(pFuncPtr);
+ AttrChangedNotify(m_pWrtShell);
+
+ pFuncPtr->Activate(nSlotId);
+ NoRotate();
+ if(rReq.GetModifier() == KEY_MOD1)
+ {
+ if(SID_OBJECT_SELECT == m_nDrawSfxId )
+ {
+ m_pWrtShell->GotoObj(sal_True);
+ }
+ else
+ {
+ pFuncPtr->CreateDefaultObject();
+ pFuncPtr->Deactivate();
+ SetDrawFuncPtr(NULL);
+ LeaveDrawCreate();
+ m_pWrtShell->EnterStdMode();
+ SdrView *pTmpSdrView = m_pWrtShell->GetDrawView();
+ const SdrMarkList& rMarkList = pTmpSdrView->GetMarkedObjectList();
+ if(rMarkList.GetMarkCount() == 1 &&
+ (SID_DRAW_TEXT == nSlotId || SID_DRAW_TEXT_VERTICAL == nSlotId ||
+ SID_DRAW_TEXT_MARQUEE == nSlotId ))
+ {
+ SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+ BeginTextEdit(pObj);
+ bEndTextEdit = sal_False;
+ }
+ }
+ }
+ }
+ else
+ {
+ if (m_pWrtShell->IsObjSelected() && !m_pWrtShell->IsSelFrmMode())
+ m_pWrtShell->EnterSelFrmMode(NULL);
+ }
+
+ if(bEndTextEdit && pSdrView && pSdrView->IsTextEdit())
+ pSdrView->SdrEndTextEdit( sal_True );
+
+ AttrChangedNotify(m_pWrtShell);
+}
+
+// End drawing
+
+void SwView::ExitDraw()
+{
+ NoRotate();
+
+ if(m_pShell)
+ {
+ // the shell may be invalid at close/reload/SwitchToViewShell
+ SfxDispatcher* pDispatch = GetViewFrame()->GetDispatcher();
+ sal_uInt16 nIdx = 0;
+ SfxShell* pTest = 0;
+ do
+ {
+ pTest = pDispatch->GetShell(nIdx++);
+ }
+ while( pTest && pTest != this && pTest != m_pShell);
+ if(pTest == m_pShell &&
+ // don't call LeaveSelFrmMode() etc. for the below,
+ // because objects may still be selected:
+ !m_pShell->ISA(SwDrawBaseShell) &&
+ !m_pShell->ISA(SwBezierShell) &&
+ !m_pShell->ISA(svx::ExtrusionBar) &&
+ !m_pShell->ISA(svx::FontworkBar))
+ {
+ SdrView *pSdrView = m_pWrtShell->GetDrawView();
+
+ if (pSdrView && pSdrView->IsGroupEntered())
+ {
+ pSdrView->LeaveOneGroup();
+ pSdrView->UnmarkAll();
+ GetViewFrame()->GetBindings().Invalidate(SID_ENTER_GROUP);
+ }
+
+ if (GetDrawFuncPtr())
+ {
+ if (m_pWrtShell->IsSelFrmMode())
+ m_pWrtShell->LeaveSelFrmMode();
+ GetDrawFuncPtr()->Deactivate();
+
+ SetDrawFuncPtr(NULL);
+ LeaveDrawCreate();
+
+ GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW);
+ }
+ GetEditWin().SetPointer(Pointer(POINTER_TEXT));
+ }
+ }
+}
+
+// Disable rotate mode
+
+void SwView::NoRotate()
+{
+ if (IsDrawRotate())
+ {
+ m_pWrtShell->SetDragMode(SDRDRAG_MOVE);
+ FlipDrawRotate();
+
+ const SfxBoolItem aTmp( SID_OBJECT_ROTATE, false );
+ GetViewFrame()->GetBindings().SetState( aTmp );
+ }
+}
+
+// Enable DrawTextEditMode
+
+sal_Bool SwView::EnterDrawTextMode(const Point& aDocPos)
+{
+ SdrObject* pObj;
+ SdrPageView* pPV;
+ SwWrtShell *pSh = &GetWrtShell();
+ SdrView *pSdrView = pSh->GetDrawView();
+ OSL_ENSURE( pSdrView, "EnterDrawTextMode without DrawView?" );
+
+ sal_Bool bReturn = sal_False;
+
+ sal_uInt16 nOld = pSdrView->GetHitTolerancePixel();
+ pSdrView->SetHitTolerancePixel( 2 );
+
+ if( pSdrView->IsMarkedHit( aDocPos ) &&
+ !pSdrView->PickHandle( aDocPos ) && IsTextTool() &&
+ pSdrView->PickObj( aDocPos, pSdrView->getHitTolLog(), pObj, pPV, SDRSEARCH_PICKTEXTEDIT ) &&
+
+ // To allow SwDrawVirtObj text objects to be activated, allow their type, too.
+ ( pObj->ISA( SdrTextObj ) ||
+ ( pObj->ISA(SwDrawVirtObj) &&
+ ((SwDrawVirtObj*)pObj)->GetReferencedObj().ISA(SdrTextObj) ) ) &&
+
+ !m_pWrtShell->IsSelObjProtected(FLYPROTECT_CONTENT))
+ {
+ bReturn = BeginTextEdit( pObj, pPV, m_pEditWin, false );
+ }
+
+ pSdrView->SetHitTolerancePixel( nOld );
+
+ return bReturn;
+}
+
+// Enable DrawTextEditMode
+
+sal_Bool SwView::BeginTextEdit(SdrObject* pObj, SdrPageView* pPV, Window* pWin,
+ bool bIsNewObj, bool bSetSelectionToStart)
+{
+ SwWrtShell *pSh = &GetWrtShell();
+ SdrView *pSdrView = pSh->GetDrawView();
+ SdrOutliner* pOutliner = ::SdrMakeOutliner(OUTLINERMODE_TEXTOBJECT, pSdrView->GetModel());
+ uno::Reference< linguistic2::XSpellChecker1 > xSpell( ::GetSpellChecker() );
+ if (pOutliner)
+ {
+ pOutliner->SetRefDevice(pSh->getIDocumentDeviceAccess()->getReferenceDevice(false));
+ pOutliner->SetSpeller(xSpell);
+ uno::Reference<linguistic2::XHyphenator> xHyphenator( ::GetHyphenator() );
+ pOutliner->SetHyphenator( xHyphenator );
+ pSh->SetCalcFieldValueHdl(pOutliner);
+
+ sal_uInt32 nCntrl = pOutliner->GetControlWord();
+ nCntrl |= EE_CNTRL_ALLOWBIGOBJS;
+ nCntrl |= EE_CNTRL_URLSFXEXECUTE;
+
+ const SwViewOption *pOpt = pSh->GetViewOptions();
+
+ if (SwViewOption::IsFieldShadings())
+ nCntrl |= EE_CNTRL_MARKFIELDS;
+ else
+ nCntrl &= ~EE_CNTRL_MARKFIELDS;
+
+ if (pOpt->IsOnlineSpell())
+ nCntrl |= EE_CNTRL_ONLINESPELLING;
+ else
+ nCntrl &= ~EE_CNTRL_ONLINESPELLING;
+
+ pOutliner->SetControlWord(nCntrl);
+ const SfxPoolItem& rItem = pSh->GetDoc()->GetDefault(RES_CHRATR_LANGUAGE);
+ pOutliner->SetDefaultLanguage(((const SvxLanguageItem&)rItem).GetLanguage());
+
+ if( bIsNewObj )
+ pOutliner->SetVertical( SID_DRAW_TEXT_VERTICAL == m_nDrawSfxId ||
+ SID_DRAW_CAPTION_VERTICAL == m_nDrawSfxId );
+
+ // set default horizontal text direction at outliner
+ EEHorizontalTextDirection aDefHoriTextDir =
+ pSh->IsShapeDefaultHoriTextDirR2L() ? EE_HTEXTDIR_R2L : EE_HTEXTDIR_L2R;
+ pOutliner->SetDefaultHorizontalTextDirection( aDefHoriTextDir );
+ }
+
+ // To allow editing the referenced object from a SwDrawVirtObj here
+ // the original needs to be fetched evenually. This ATM activates the
+ // text edit mode for the original object.
+ SdrObject* pToBeActivated = pObj;
+
+ // Always the original object is edited. To allow the TextEdit to happen
+ // where the VirtObj is positioned, on demand a occurring offset is set at
+ // the TextEdit object. That offset is used for creating and managing the
+ // OutlinerView.
+ Point aNewTextEditOffset(0, 0);
+
+ if(pObj->ISA(SwDrawVirtObj))
+ {
+ SwDrawVirtObj* pVirtObj = (SwDrawVirtObj*)pObj;
+ pToBeActivated = &((SdrObject&)pVirtObj->GetReferencedObj());
+ aNewTextEditOffset = pVirtObj->GetOffset();
+ }
+
+ // set in each case, thus it will be correct for all objects
+ ((SdrTextObj*)pToBeActivated)->SetTextEditOffset(aNewTextEditOffset);
+
+ sal_Bool bRet(pSdrView->SdrBeginTextEdit( pToBeActivated, pPV, pWin, sal_True, pOutliner, 0, sal_False, sal_False, sal_False ));
+
+ // #i7672#
+ // Since SdrBeginTextEdit actually creates the OutlinerView and thus also
+ // sets the background color, an own background color needs to be set
+ // after TextEditing was started. This is now done here.
+ if(bRet)
+ {
+ OutlinerView* pView = pSdrView->GetTextEditOutlinerView();
+
+ if(pView)
+ {
+ Color aBackground(pSh->GetShapeBackgrd());
+ pView->SetBackgroundColor(aBackground);
+ }
+
+ // editing should start at the end of text, spell checking at the beginning ...
+ ESelection aNewSelection(EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND, EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND);
+ if (bSetSelectionToStart)
+ aNewSelection = ESelection();
+ pView->SetSelection(aNewSelection);
+ }
+
+ return bRet;
+}
+
+// Is a DrawTextObjekt selected?
+
+bool SwView::IsTextTool() const
+{
+ sal_uInt16 nId;
+ sal_uInt32 nInvent;
+ SdrView *pSdrView = GetWrtShell().GetDrawView();
+ OSL_ENSURE( pSdrView, "IsTextTool without DrawView?" );
+
+ if (pSdrView->IsCreateMode())
+ pSdrView->SetCreateMode(sal_False);
+
+ pSdrView->TakeCurrentObj(nId,nInvent);
+ return (nInvent==SdrInventor);
+}
+
+SdrView* SwView::GetDrawView() const
+{
+ return GetWrtShell().GetDrawView();
+}
+
+bool SwView::IsBezierEditMode()
+{
+ return (!IsDrawSelMode() && GetWrtShell().GetDrawView()->HasMarkablePoints());
+}
+
+bool SwView::IsFormMode() const
+{
+ if (GetDrawFuncPtr() && GetDrawFuncPtr()->IsCreateObj())
+ {
+ return (GetDrawFuncPtr()->IsInsertForm());
+ }
+
+ return AreOnlyFormsSelected();
+}
+
+void SwView::SetDrawFuncPtr(SwDrawBase* pFuncPtr)
+{
+ delete m_pDrawActual;
+ m_pDrawActual = pFuncPtr;
+}
+
+void SwView::SetSelDrawSlot()
+{
+ m_nDrawSfxId = SID_OBJECT_SELECT;
+ m_sDrawCustom = "";
+}
+
+bool SwView::AreOnlyFormsSelected() const
+{
+ if ( GetWrtShell().IsFrmSelected() )
+ return false;
+
+ bool bForm = true;
+
+ SdrView* pSdrView = GetWrtShell().GetDrawView();
+
+ const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
+ sal_uInt32 nCount = rMarkList.GetMarkCount();
+
+ if (nCount)
+ {
+ for (sal_uInt32 i = 0; i < nCount; i++)
+ {
+ // Except controls, are still normal draw objects selected?
+ SdrObject *pSdrObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
+
+ if (!HasOnlyObj(pSdrObj, FmFormInventor))
+ {
+ bForm = false;
+ break;
+ }
+ }
+ }
+ else
+ bForm = false;
+
+ return bForm;
+}
+
+sal_Bool SwView::HasDrwObj(SdrObject *pSdrObj) const
+{
+ sal_Bool bRet = sal_False;
+
+ if (pSdrObj->IsGroupObject())
+ {
+ SdrObjList* pList = pSdrObj->GetSubList();
+ sal_uInt32 nCnt = pList->GetObjCount();
+
+ for (sal_uInt32 i = 0; i < nCnt; i++)
+ if ((bRet = HasDrwObj(pList->GetObj(i))) == sal_True)
+ break;
+ }
+ else if (SdrInventor == pSdrObj->GetObjInventor() || pSdrObj->Is3DObj())
+ return sal_True;
+
+ return bRet;
+}
+
+sal_Bool SwView::HasOnlyObj(SdrObject *pSdrObj, sal_uInt32 eObjInventor) const
+{
+ sal_Bool bRet = sal_False;
+
+ if (pSdrObj->IsGroupObject())
+ {
+ SdrObjList* pList = pSdrObj->GetSubList();
+ sal_uInt32 nCnt = pList->GetObjCount();
+
+ for (sal_uInt32 i = 0; i < nCnt; i++)
+ if ((bRet = HasOnlyObj(pList->GetObj(i), eObjInventor)) == sal_False)
+ break;
+ }
+ else if (eObjInventor == pSdrObj->GetObjInventor())
+ return sal_True;
+
+ return bRet;
+}
+
+//#i87414# mod
+IMPL_LINK(SwView, OnlineSpellCallback, SpellCallbackInfo*, pInfo)
+{
+ if (pInfo->nCommand == SPELLCMD_STARTSPELLDLG)
+ GetViewFrame()->GetDispatcher()->Execute( FN_SPELL_GRAMMAR_DIALOG, SFX_CALLMODE_ASYNCHRON);
+ return 0;
+}
+
+sal_Bool SwView::ExecDrwTxtSpellPopup(const Point& rPt)
+{
+ sal_Bool bRet = sal_False;
+ SdrView *pSdrView = m_pWrtShell->GetDrawView();
+ OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
+ Point aPos( GetEditWin().LogicToPixel( rPt ) );
+
+ if (pOLV->IsWrongSpelledWordAtPos( aPos ))
+ {
+ bRet = sal_True;
+ Link aLink = LINK(this, SwView, OnlineSpellCallback);
+ pOLV->ExecuteSpellPopup( aPos,&aLink );
+ }
+ return bRet;
+}
+
+sal_Bool SwView::IsDrawTextHyphenate()
+{
+ SdrView *pSdrView = m_pWrtShell->GetDrawView();
+ sal_Bool bHyphenate = sal_False;
+
+ SfxItemSet aNewAttr( pSdrView->GetModel()->GetItemPool(),
+ EE_PARA_HYPHENATE, EE_PARA_HYPHENATE );
+ if( pSdrView->GetAttributes( aNewAttr ) &&
+ aNewAttr.GetItemState( EE_PARA_HYPHENATE ) >= SFX_ITEM_AVAILABLE )
+ bHyphenate = ((const SfxBoolItem&)aNewAttr.Get( EE_PARA_HYPHENATE )).
+ GetValue();
+
+ return bHyphenate;
+}
+
+void SwView::HyphenateDrawText()
+{
+ SdrView *pSdrView = m_pWrtShell->GetDrawView();
+ sal_Bool bHyphenate = IsDrawTextHyphenate();
+
+ SfxItemSet aSet( GetPool(), EE_PARA_HYPHENATE, EE_PARA_HYPHENATE );
+ aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE, !bHyphenate ) );
+ pSdrView->SetAttributes( aSet );
+ GetViewFrame()->GetBindings().Invalidate(FN_HYPHENATE_OPT_DLG);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/uiview/viewfunc.hxx b/sw/source/core/uibase/uiview/viewfunc.hxx
new file mode 100644
index 000000000000..6036509db172
--- /dev/null
+++ b/sw/source/core/uibase/uiview/viewfunc.hxx
@@ -0,0 +1,53 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_UIVIEW_VIEWFUNC_HXX
+#define INCLUDED_SW_SOURCE_UI_UIVIEW_VIEWFUNC_HXX
+#include <tools/solar.h>
+
+class ImageButton;
+class Point;
+class SfxItemSet;
+class SfxPrinter;
+class SfxTabPage;
+class Size;
+class SvxRuler;
+class SwScrollbar;
+class SwViewShell;
+class Window;
+
+// The following functions are available in viewprt.cxx
+void SetPrinter( IDocumentDeviceAccess*, SfxPrinter*, sal_Bool bWeb );
+SfxTabPage* CreatePrintOptionsPage( Window*, const SfxItemSet& );
+void SetAppPrintOptions( SwViewShell* pSh, sal_Bool bWeb );
+
+// The following functions are available in viewport.cxx
+void ViewResizePixel( const Window &rRef,
+ const Point &rOfst,
+ const Size &rSize,
+ const Size &rEditSz,
+ SwScrollbar& rVScrollbar,
+ SwScrollbar& rHScrollbar,
+ Window& rScrollBarBox,
+ SvxRuler* pVRuler = 0,
+ SvxRuler* pHRuler = 0,
+ sal_Bool bVRulerRight = sal_False );
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/uiview/viewling.cxx b/sw/source/core/uibase/uiview/viewling.cxx
new file mode 100644
index 000000000000..45b2f12d5fb9
--- /dev/null
+++ b/sw/source/core/uibase/uiview/viewling.cxx
@@ -0,0 +1,898 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <hintids.hxx>
+
+#include <com/sun/star/lang/Locale.hpp>
+#include <com/sun/star/linguistic2/XThesaurus.hpp>
+#include <com/sun/star/linguistic2/ProofreadingResult.hpp>
+#include <com/sun/star/i18n/TextConversionOption.hpp>
+#include <linguistic/lngprops.hxx>
+#include <comphelper/processfactory.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <vcl/msgbox.hxx>
+#include <svtools/ehdl.hxx>
+#include <svl/stritem.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/request.hxx>
+#include <svx/dlgutil.hxx>
+#include <svx/dialmgr.hxx>
+#include <editeng/langitem.hxx>
+#include <svx/svxerr.hxx>
+#include <editeng/unolingu.hxx>
+#include <svx/svxdlg.hxx>
+#include <editeng/SpellPortions.hxx>
+#include <swmodule.hxx>
+#include <swwait.hxx>
+#include <initui.hxx>
+#include <uitool.hxx>
+#include <view.hxx>
+#include <wrtsh.hxx>
+#include <basesh.hxx>
+#include <docsh.hxx>
+#include <viewopt.hxx>
+#include <swundo.hxx>
+#include <hyp.hxx>
+#include <olmenu.hxx>
+#include <pam.hxx>
+#include <edtwin.hxx>
+#include <crsskip.hxx>
+#include <ndtxt.hxx>
+#include <vcl/lstbox.hxx>
+#include <cmdid.h>
+#include <globals.hrc>
+#include <comcore.hrc>
+#include <view.hrc>
+#include <hhcwrp.hxx>
+#include <com/sun/star/frame/XStorable.hpp>
+
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/frame/XDispatch.hpp>
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/util/URL.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/util/URLTransformer.hpp>
+#include <com/sun/star/util/XURLTransformer.hpp>
+
+#include <vcl/svapp.hxx>
+#include <rtl/ustring.hxx>
+
+#include <cppuhelper/bootstrap.hxx>
+#include "stmenu.hxx"
+#include <svx/dialogs.hrc>
+#include <svtools/langtab.hxx>
+#include <unomid.h>
+#include <IMark.hxx>
+#include <xmloff/odffields.hxx>
+
+#include <editeng/editerr.hxx>
+
+#include <boost/scoped_ptr.hpp>
+
+using namespace sw::mark;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::linguistic2;
+using namespace ::com::sun::star::smarttags;
+
+// Lingu-Dispatcher
+
+void SwView::ExecLingu(SfxRequest &rReq)
+{
+ switch(rReq.GetSlot())
+ {
+ case SID_THESAURUS:
+ StartThesaurus();
+ rReq.Ignore();
+ break;
+ case SID_HANGUL_HANJA_CONVERSION:
+ StartTextConversion( LANGUAGE_KOREAN, LANGUAGE_KOREAN, NULL,
+ i18n::TextConversionOption::CHARACTER_BY_CHARACTER, sal_True );
+ 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(
+ OUString("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 = "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( "IsDirectionToSimplified" ) >>= bToSimplified;
+ xProp->getPropertyValue( "IsUseCharacterVariants" ) >>= bUseVariants;
+ xProp->getPropertyValue( "IsTranslateCommonTerms" ) >>= bCommonTerms;
+ }
+ catch (const Exception&)
+ {
+ }
+ }
+
+ //execute translation
+ sal_Int16 nSourceLang = bToSimplified ? LANGUAGE_CHINESE_TRADITIONAL : LANGUAGE_CHINESE_SIMPLIFIED;
+ sal_Int16 nTargetLang = bToSimplified ? LANGUAGE_CHINESE_SIMPLIFIED : LANGUAGE_CHINESE_TRADITIONAL;
+ sal_Int32 nOptions = bUseVariants ? i18n::TextConversionOption::USE_CHARACTER_VARIANTS : 0;
+ if( !bCommonTerms )
+ nOptions = nOptions | i18n::TextConversionOption::CHARACTER_BY_CHARACTER;
+
+ Font aTargetFont = GetEditWin().GetDefaultFont( DEFAULTFONT_CJK_TEXT,
+ nTargetLang, DEFAULTFONT_FLAGS_ONLYONE );
+
+ // disallow formatting, updating the view, ... while
+ // converting the document. (saves time)
+ // Also remember the current view and cursor position for later
+ m_pWrtShell->StartAction();
+
+ // remember cursor position data for later restoration of the cursor
+ const SwPosition *pPoint = m_pWrtShell->GetCrsr()->GetPoint();
+ sal_Bool bRestoreCursor = pPoint->nNode.GetNode().IsTxtNode();
+ const SwNodeIndex aPointNodeIndex( pPoint->nNode );
+ sal_Int32 nPointIndex = pPoint->nContent.GetIndex();
+
+ // since this conversion is not interactive the whole converted
+ // document should be undone in a single undo step.
+ m_pWrtShell->StartUndo( UNDO_OVERWRITE );
+
+ StartTextConversion( nSourceLang, nTargetLang, &aTargetFont, nOptions, sal_False );
+
+ m_pWrtShell->EndUndo( UNDO_OVERWRITE );
+
+ if (bRestoreCursor)
+ {
+ SwTxtNode *pTxtNode = aPointNodeIndex.GetNode().GetTxtNode();
+ // check for unexpected error case
+ OSL_ENSURE(pTxtNode && pTxtNode->GetTxt().getLength() >= nPointIndex,
+ "text missing: corrupted node?" );
+ if (!pTxtNode || pTxtNode->GetTxt().getLength() < nPointIndex)
+ nPointIndex = 0;
+ // restore cursor to its original position
+ m_pWrtShell->GetCrsr()->GetPoint()->nContent.Assign( pTxtNode, nPointIndex );
+ }
+
+ // enable all, restore view and cursor position
+ m_pWrtShell->EndAction();
+ }
+ }
+ Reference< lang::XComponent > xComponent( xDialog, UNO_QUERY );
+ if( xComponent.is() )
+ xComponent->dispose();
+ }
+ }
+ break;
+ }
+ case FN_HYPHENATE_OPT_DLG:
+ HyphenateDocument();
+ break;
+ default:
+ OSL_ENSURE(!this, "wrong Dispatcher");
+ return;
+ }
+}
+
+// start language specific text conversion
+
+void SwView::StartTextConversion(
+ LanguageType nSourceLang,
+ LanguageType nTargetLang,
+ const Font *pTargetFont,
+ sal_Int32 nOptions,
+ sal_Bool bIsInteractive )
+{
+ // do not do text conversion if it is active elsewhere
+ if (GetWrtShell().HasConvIter())
+ {
+ return;
+ }
+
+ SpellKontext(sal_True);
+
+ const SwViewOption* pVOpt = m_pWrtShell->GetViewOptions();
+ const sal_Bool bOldIdle = pVOpt->IsIdle();
+ pVOpt->SetIdle( sal_False );
+
+ sal_Bool bOldIns = m_pWrtShell->IsInsMode();
+ m_pWrtShell->SetInsMode( sal_True );
+
+ const bool bSelection = ((SwCrsrShell*)m_pWrtShell)->HasSelection() ||
+ m_pWrtShell->GetCrsr() != m_pWrtShell->GetCrsr()->GetNext();
+
+ const bool bStart = bSelection || m_pWrtShell->IsStartOfDoc();
+ const bool bOther = !bSelection && !(m_pWrtShell->GetFrmType(0,sal_True) & FRMTYPE_BODY);
+
+ {
+ const uno::Reference< uno::XComponentContext > xContext(
+ comphelper::getProcessComponentContext() );
+ SwHHCWrapper aWrap( this, xContext, nSourceLang, nTargetLang, pTargetFont,
+ nOptions, bIsInteractive,
+ bStart, bOther, bSelection );
+ aWrap.Convert();
+ }
+
+ m_pWrtShell->SetInsMode( bOldIns );
+ pVOpt->SetIdle( bOldIdle );
+ SpellKontext(sal_False);
+}
+
+// spellcheck and text conversion related stuff
+
+void SwView::SpellStart( SvxSpellArea eWhich,
+ bool bStartDone, bool bEndDone,
+ SwConversionArgs *pConvArgs )
+{
+ Reference< XLinguProperties > xProp = ::GetLinguPropertySet();
+ sal_Bool bIsWrapReverse = (!pConvArgs && xProp.is()) ? xProp->getIsWrapReverse() : sal_False;
+
+ SwDocPositions eStart = DOCPOS_START;
+ SwDocPositions eEnde = DOCPOS_END;
+ SwDocPositions eCurr = DOCPOS_CURR;
+ switch ( eWhich )
+ {
+ case SVX_SPELL_BODY:
+ if( bIsWrapReverse )
+ eCurr = DOCPOS_END;
+ else
+ eCurr = DOCPOS_START;
+ break;
+ case SVX_SPELL_BODY_END:
+ if( bIsWrapReverse )
+ {
+ if( bStartDone )
+ eStart = DOCPOS_CURR;
+ eCurr = DOCPOS_END;
+ }
+ else if( bStartDone )
+ eCurr = DOCPOS_START;
+ break;
+ case SVX_SPELL_BODY_START:
+ if( !bIsWrapReverse )
+ {
+ if( bEndDone )
+ eEnde = DOCPOS_CURR;
+ eCurr = DOCPOS_START;
+ }
+ else if( bEndDone )
+ eCurr = DOCPOS_END;
+ break;
+ case SVX_SPELL_OTHER:
+ if( bIsWrapReverse )
+ {
+ eStart = DOCPOS_OTHERSTART;
+ eEnde = DOCPOS_OTHEREND;
+ eCurr = DOCPOS_OTHEREND;
+ }
+ else
+ {
+ eStart = DOCPOS_OTHERSTART;
+ eEnde = DOCPOS_OTHEREND;
+ eCurr = DOCPOS_OTHERSTART;
+ }
+ break;
+ default:
+ OSL_ENSURE( !this, "SpellStart with unknown Area" );
+ }
+ m_pWrtShell->SpellStart( eStart, eEnde, eCurr, pConvArgs );
+}
+
+// Error message while Spelling
+
+// The passed pointer nlang is itself the value
+void SwView::SpellError(LanguageType eLang)
+{
+#if OSL_DEBUG_LEVEL > 1
+ sal_Bool bFocus = GetEditWin().HasFocus();
+#endif
+ sal_uInt16 nPend = 0;
+
+ if ( m_pWrtShell->ActionPend() )
+ {
+ m_pWrtShell->Push();
+ m_pWrtShell->ClearMark();
+ do
+ {
+ m_pWrtShell->EndAction();
+ ++nPend;
+ }
+ while( m_pWrtShell->ActionPend() );
+ }
+ OUString aErr(SvtLanguageTable::GetLanguageString( eLang ) );
+
+ SwEditWin &rEditWin = GetEditWin();
+#if OSL_DEBUG_LEVEL > 1
+ bFocus = rEditWin.HasFocus();
+#endif
+ sal_uInt16 nWaitCnt = 0;
+ while( rEditWin.IsWait() )
+ {
+ rEditWin.LeaveWait();
+ ++nWaitCnt;
+ }
+ if ( LANGUAGE_NONE == eLang )
+ ErrorHandler::HandleError( ERRCODE_SVX_LINGU_NOLANGUAGE );
+ else
+ ErrorHandler::HandleError( *new StringErrorInfo( ERRCODE_SVX_LINGU_LANGUAGENOTEXISTS, aErr ) );
+
+ while( nWaitCnt )
+ {
+ rEditWin.EnterWait();
+ --nWaitCnt;
+ }
+#if OSL_DEBUG_LEVEL > 1
+ bFocus = GetEditWin().HasFocus();
+#endif
+
+ if ( nPend )
+ {
+ while( nPend-- )
+ m_pWrtShell->StartAction();
+ m_pWrtShell->Combine();
+ }
+#if OSL_DEBUG_LEVEL > 1
+ if( !bFocus )
+ GetEditWin().GrabFocus();
+#endif
+
+}
+
+// Finish spelling and restore cursor
+
+void SwView::SpellEnd( SwConversionArgs *pConvArgs )
+{
+ m_pWrtShell->SpellEnd( pConvArgs );
+ if( m_pWrtShell->IsExtMode() )
+ m_pWrtShell->SetMark();
+}
+
+void SwView::HyphStart( SvxSpellArea eWhich )
+{
+ switch ( eWhich )
+ {
+ case SVX_SPELL_BODY:
+ m_pWrtShell->HyphStart( DOCPOS_START, DOCPOS_END );
+ break;
+ case SVX_SPELL_BODY_END:
+ m_pWrtShell->HyphStart( DOCPOS_CURR, DOCPOS_END );
+ break;
+ case SVX_SPELL_BODY_START:
+ m_pWrtShell->HyphStart( DOCPOS_START, DOCPOS_CURR );
+ break;
+ case SVX_SPELL_OTHER:
+ m_pWrtShell->HyphStart( DOCPOS_OTHERSTART, DOCPOS_OTHEREND );
+ break;
+ default:
+ OSL_ENSURE( !this, "HyphStart with unknown Area" );
+ }
+}
+
+// Interactive separation
+
+void SwView::HyphenateDocument()
+{
+ // do not hyphenate if interactive hyphenation is active elsewhere
+ if (GetWrtShell().HasHyphIter())
+ {
+ MessBox( 0, WB_OK, OUString( SW_RES( STR_HYPH_TITLE ) ),
+ OUString( SW_RES( STR_MULT_INTERACT_HYPH_WARN ) ) ).Execute();
+ return;
+ }
+
+ SfxErrorContext aContext( ERRCTX_SVX_LINGU_HYPHENATION, OUString(), m_pEditWin,
+ RID_SVXERRCTX, &DIALOG_MGR() );
+
+ Reference< XHyphenator > xHyph( ::GetHyphenator() );
+ if (!xHyph.is())
+ {
+ ErrorHandler::HandleError( ERRCODE_SVX_LINGU_LINGUNOTEXISTS );
+ return;
+ }
+
+ if (m_pWrtShell->GetSelectionType() & (nsSelectionType::SEL_DRW_TXT|nsSelectionType::SEL_DRW))
+ {
+ // Hyphenation in a Draw object
+ HyphenateDrawText();
+ }
+ else
+ {
+ SwViewOption* pVOpt = (SwViewOption*)m_pWrtShell->GetViewOptions();
+ sal_Bool bOldIdle = pVOpt->IsIdle();
+ pVOpt->SetIdle( sal_False );
+
+ Reference< XLinguProperties > xProp( ::GetLinguPropertySet() );
+
+ m_pWrtShell->StartUndo(UNDO_INSATTR); // valid later
+
+ sal_Bool bHyphSpecial = xProp.is() ? xProp->getIsHyphSpecial() : sal_False;
+ sal_Bool bSelection = ((SwCrsrShell*)m_pWrtShell)->HasSelection() ||
+ m_pWrtShell->GetCrsr() != m_pWrtShell->GetCrsr()->GetNext();
+ sal_Bool bOther = m_pWrtShell->HasOtherCnt() && bHyphSpecial && !bSelection;
+ sal_Bool bStart = bSelection || ( !bOther && m_pWrtShell->IsStartOfDoc() );
+ bool bStop = false;
+ if( !bOther && !(m_pWrtShell->GetFrmType(0,sal_True) & FRMTYPE_BODY) && !bSelection )
+ // turned on no special area
+ {
+ // I want also in special areas hyphenation
+ QueryBox aBox( &GetEditWin(), SW_RES( DLG_SPECIAL_FORCED ) );
+ if( aBox.Execute() == RET_YES )
+ {
+ bOther = sal_True;
+ if (xProp.is())
+ {
+ xProp->setIsHyphSpecial( sal_True );
+ }
+ }
+ else
+ bStop = true; // No hyphenation
+ }
+
+ if( !bStop )
+ {
+ SwHyphWrapper aWrap( this, xHyph, bStart, bOther, bSelection );
+ aWrap.SpellDocument();
+ m_pWrtShell->EndUndo(UNDO_INSATTR);
+ }
+ pVOpt->SetIdle( bOldIdle );
+ }
+}
+
+bool SwView::IsValidSelectionForThesaurus() const
+{
+ // must not be a multi-selection, and if it is a selection it needs
+ // to be within a single paragraph
+
+ const bool bMultiSel = m_pWrtShell->GetCrsr() != m_pWrtShell->GetCrsr()->GetNext();
+ const sal_Bool bSelection = ((SwCrsrShell*)m_pWrtShell)->HasSelection();
+ return !bMultiSel && (!bSelection || m_pWrtShell->IsSelOnePara() );
+}
+
+OUString SwView::GetThesaurusLookUpText( bool bSelection ) const
+{
+ return bSelection ? OUString(m_pWrtShell->GetSelTxt()) : m_pWrtShell->GetCurWord();
+}
+
+void SwView::InsertThesaurusSynonym( const OUString &rSynonmText, const OUString &rLookUpText, bool bSelection )
+{
+ sal_Bool bOldIns = m_pWrtShell->IsInsMode();
+ m_pWrtShell->SetInsMode( sal_True );
+
+ m_pWrtShell->StartAllAction();
+ m_pWrtShell->StartUndo(UNDO_DELETE);
+
+ if( !bSelection )
+ {
+ if(m_pWrtShell->IsEndWrd())
+ m_pWrtShell->Left(CRSR_SKIP_CELLS, sal_False, 1, sal_False );
+
+ m_pWrtShell->SelWrd();
+
+ // make sure the selection build later from the data below does not
+ // include "in word" character to the left and right in order to
+ // preserve those. Therefore count those "in words" in order to modify
+ // the selection accordingly.
+ const sal_Unicode* pChar = rLookUpText.getStr();
+ sal_Int32 nLeft = 0;
+ while (pChar && *pChar++ == CH_TXTATR_INWORD)
+ ++nLeft;
+ pChar = rLookUpText.getLength() ? rLookUpText.getStr() + rLookUpText.getLength() - 1 : 0;
+ sal_Int32 nRight = 0;
+ while (pChar && *pChar-- == CH_TXTATR_INWORD)
+ ++nRight;
+
+ // adjust existing selection
+ SwPaM *pCrsr = m_pWrtShell->GetCrsr();
+ pCrsr->GetPoint()->nContent -= nRight;
+ pCrsr->GetMark()->nContent += nLeft;
+ }
+
+ m_pWrtShell->Insert( rSynonmText );
+
+ m_pWrtShell->EndUndo(UNDO_DELETE);
+ m_pWrtShell->EndAllAction();
+
+ m_pWrtShell->SetInsMode( bOldIns );
+}
+
+// Start thesaurus
+
+void SwView::StartThesaurus()
+{
+ if (!IsValidSelectionForThesaurus())
+ return;
+
+ SfxErrorContext aContext( ERRCTX_SVX_LINGU_THESAURUS, OUString(), m_pEditWin,
+ RID_SVXERRCTX, &DIALOG_MGR() );
+
+ // Determine language
+ LanguageType eLang = m_pWrtShell->GetCurLang();
+ if( LANGUAGE_SYSTEM == eLang )
+ eLang = GetAppLanguage();
+
+ if( eLang == LANGUAGE_DONTKNOW || eLang == LANGUAGE_NONE )
+ {
+ SpellError( LANGUAGE_NONE );
+ return;
+ }
+
+ SwViewOption* pVOpt = (SwViewOption*)m_pWrtShell->GetViewOptions();
+ sal_Bool bOldIdle = pVOpt->IsIdle();
+ pVOpt->SetIdle( sal_False );
+
+ // get initial LookUp text
+ const sal_Bool bSelection = ((SwCrsrShell*)m_pWrtShell)->HasSelection();
+ OUString aTmp = GetThesaurusLookUpText( bSelection );
+
+ Reference< XThesaurus > xThes( ::GetThesaurus() );
+
+ if ( !xThes.is() || !xThes->hasLocale( LanguageTag::convertToLocale( eLang ) ) )
+ SpellError( eLang );
+ else
+ {
+ boost::scoped_ptr<AbstractThesaurusDialog> pDlg;
+ // create dialog
+ { //Scope for SwWait-Object
+ SwWait aWait( *GetDocShell(), true );
+ // load library with dialog only on demand ...
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ pDlg.reset(pFact->CreateThesaurusDialog( &GetEditWin(), xThes, aTmp, eLang ));
+ }
+
+ if ( pDlg->Execute()== RET_OK )
+ InsertThesaurusSynonym( pDlg->GetWord(), aTmp, bSelection );
+ }
+
+ pVOpt->SetIdle( bOldIdle );
+}
+
+// Offer online suggestions
+
+//!! Start of extra code for context menu modifying extensions
+struct ExecuteInfo
+{
+ uno::Reference< frame::XDispatch > xDispatch;
+ util::URL aTargetURL;
+ uno::Sequence< PropertyValue > aArgs;
+};
+
+class AsyncExecute
+{
+public:
+ DECL_STATIC_LINK( AsyncExecute, ExecuteHdl_Impl, ExecuteInfo* );
+};
+
+IMPL_STATIC_LINK_NOINSTANCE( AsyncExecute, ExecuteHdl_Impl, ExecuteInfo*, pExecuteInfo )
+{
+ const sal_uInt32 nRef = Application::ReleaseSolarMutex();
+ try
+ {
+ // Asynchronous execution as this can lead to our own destruction!
+ // Framework can recycle our current frame and the layout manager disposes all user interface
+ // elements if a component gets detached from its frame!
+ pExecuteInfo->xDispatch->dispatch( pExecuteInfo->aTargetURL, pExecuteInfo->aArgs );
+ }
+ catch (const Exception&)
+ {
+ }
+
+ Application::AcquireSolarMutex( nRef );
+ delete pExecuteInfo;
+ return 0;
+}
+//!! End of extra code for context menu modifying extensions
+
+sal_Bool SwView::ExecSpellPopup(const Point& rPt)
+{
+ sal_Bool bRet = sal_False;
+ const SwViewOption* pVOpt = m_pWrtShell->GetViewOptions();
+ if( pVOpt->IsOnlineSpell() &&
+ !m_pWrtShell->IsSelection())
+ {
+ if (m_pWrtShell->GetSelectionType() & nsSelectionType::SEL_DRW_TXT)
+ bRet = ExecDrwTxtSpellPopup(rPt);
+ else if (!m_pWrtShell->IsSelFrmMode())
+ {
+ const sal_Bool bOldViewLock = m_pWrtShell->IsViewLocked();
+ m_pWrtShell->LockView( sal_True );
+ m_pWrtShell->Push();
+ SwRect aToFill;
+
+ // decide which variant of the context menu to use...
+ // if neither spell checking nor grammar checking provides suggestions use the
+ // default context menu.
+ bool bUseGrammarContext = false;
+ Reference< XSpellAlternatives > xAlt( m_pWrtShell->GetCorrection(&rPt, aToFill) );
+ ProofreadingResult aGrammarCheckRes;
+ sal_Int32 nErrorInResult = -1;
+ uno::Sequence< OUString > aSuggestions;
+ bool bCorrectionRes = false;
+ if (!xAlt.is() || xAlt->getAlternatives().getLength() == 0)
+ {
+ sal_Int32 nErrorPosInText = -1;
+ bCorrectionRes = m_pWrtShell->GetGrammarCorrection( aGrammarCheckRes, nErrorPosInText, nErrorInResult, aSuggestions, &rPt, aToFill );
+ OUString aMessageText;
+ if (nErrorInResult >= 0)
+ aMessageText = aGrammarCheckRes.aErrors[ nErrorInResult ].aShortComment;
+ // we like to use the grammar checking context menu if we either get
+ // some suggestions or at least a comment about the error found...
+ bUseGrammarContext = bCorrectionRes &&
+ (aSuggestions.getLength() > 0 || !aMessageText.isEmpty());
+ }
+
+ // open respective context menu for spell check or grammar errors with correction suggestions...
+ if ((!bUseGrammarContext && xAlt.is()) ||
+ (bUseGrammarContext && bCorrectionRes && aGrammarCheckRes.aErrors.getLength() > 0))
+ {
+ // get paragraph text
+ OUString aParaText;
+ SwPosition aPoint( *m_pWrtShell->GetCrsr()->GetPoint() );
+ const SwTxtNode *pNode = dynamic_cast< const SwTxtNode * >(
+ &aPoint.nNode.GetNode() );
+ if (pNode)
+ aParaText = pNode->GetTxt(); // this may include hidden text but that should be Ok
+ else
+ {
+ OSL_FAIL("text node expected but not found" );
+ }
+
+ bRet = sal_True;
+ m_pWrtShell->SttSelect();
+ boost::scoped_ptr< SwSpellPopup > pPopup;
+ if (bUseGrammarContext)
+ {
+ sal_Int32 nPos = aPoint.nContent.GetIndex();
+ (void) nPos;
+ pPopup.reset(new SwSpellPopup( m_pWrtShell, aGrammarCheckRes, nErrorInResult, aSuggestions, aParaText ));
+ }
+ else
+ pPopup.reset(new SwSpellPopup( m_pWrtShell, xAlt, aParaText ));
+ ui::ContextMenuExecuteEvent aEvent;
+ const Point aPixPos = GetEditWin().LogicToPixel( rPt );
+
+ aEvent.SourceWindow = VCLUnoHelper::GetInterface( m_pEditWin );
+ aEvent.ExecutePosition.X = aPixPos.X();
+ aEvent.ExecutePosition.Y = aPixPos.Y();
+ Menu* pMenu = 0;
+
+ OUString sMenuName = bUseGrammarContext ?
+ OUString("private:resource/GrammarContextMenu") : OUString("private:resource/SpellContextMenu");
+ if(TryContextMenuInterception( *pPopup, sMenuName, pMenu, aEvent ))
+ {
+
+ //! happy hacking for context menu modifying extensions of this
+ //! 'custom made' menu... *sigh* (code copied from sfx2 and framework)
+ if ( pMenu )
+ {
+ sal_uInt16 nId = ((PopupMenu*)pMenu)->Execute(m_pEditWin, aPixPos);
+ OUString aCommand = ((PopupMenu*)pMenu)->GetItemCommand(nId);
+ if (aCommand.isEmpty() )
+ {
+ if(!ExecuteMenuCommand( *dynamic_cast<PopupMenu*>(pMenu), *GetViewFrame(), nId ))
+ pPopup->Execute(nId);
+ }
+ else
+ {
+ SfxViewFrame *pSfxViewFrame = GetViewFrame();
+ uno::Reference< frame::XFrame > xFrame;
+ if ( pSfxViewFrame )
+ xFrame = pSfxViewFrame->GetFrame().GetFrameInterface();
+ com::sun::star::util::URL aURL;
+ uno::Reference< frame::XDispatchProvider > xDispatchProvider( xFrame, UNO_QUERY );
+
+ try
+ {
+ uno::Reference< frame::XDispatch > xDispatch;
+ uno::Reference< util::XURLTransformer > xURLTransformer = util::URLTransformer::create(comphelper::getProcessComponentContext());
+
+ aURL.Complete = aCommand;
+ xURLTransformer->parseStrict(aURL);
+ uno::Sequence< beans::PropertyValue > aArgs;
+ xDispatch = xDispatchProvider->queryDispatch( aURL, OUString(), 0 );
+
+ if (xDispatch.is())
+ {
+ // Execute dispatch asynchronously
+ ExecuteInfo* pExecuteInfo = new ExecuteInfo;
+ pExecuteInfo->xDispatch = xDispatch;
+ pExecuteInfo->aTargetURL = aURL;
+ pExecuteInfo->aArgs = aArgs;
+ Application::PostUserEvent( STATIC_LINK(0, AsyncExecute , ExecuteHdl_Impl), pExecuteInfo );
+ }
+ }
+ catch (const Exception&)
+ {
+ }
+ }
+ }
+ else
+ {
+ pPopup->Execute( aToFill.SVRect(), m_pEditWin );
+ }
+ }
+ }
+
+ m_pWrtShell->Pop( sal_False );
+ m_pWrtShell->LockView( bOldViewLock );
+ }
+ }
+ return bRet;
+}
+
+/** Function: ExecSmartTagPopup
+
+ This function shows the popup menu for smarttag
+ actions.
+*/
+sal_Bool SwView::ExecSmartTagPopup( const Point& rPt )
+{
+ sal_Bool bRet = sal_False;
+ const sal_Bool bOldViewLock = m_pWrtShell->IsViewLocked();
+ m_pWrtShell->LockView( sal_True );
+ m_pWrtShell->Push();
+
+ // get word that was clicked on
+ // This data structure maps a smart tag type string to the property bag
+ SwRect aToFill;
+ Sequence< OUString > aSmartTagTypes;
+ Sequence< Reference< container::XStringKeyMap > > aStringKeyMaps;
+ Reference<text::XTextRange> xRange;
+
+ m_pWrtShell->GetSmartTagTerm( rPt, aToFill, aSmartTagTypes, aStringKeyMaps, xRange);
+ if ( xRange.is() && aSmartTagTypes.getLength() )
+ {
+ bRet = sal_True;
+ m_pWrtShell->SttSelect();
+ SwSmartTagPopup aPopup( this, aSmartTagTypes, aStringKeyMaps, xRange );
+ aPopup.Execute( aToFill.SVRect(), m_pEditWin );
+ }
+
+ m_pWrtShell->Pop( sal_False );
+ m_pWrtShell->LockView( bOldViewLock );
+
+ return bRet;
+}
+
+class SwFieldDialog : public FloatingWindow
+{
+private:
+ ListBox aListBox;
+ IFieldmark *pFieldmark;
+
+ DECL_LINK( MyListBoxHandler, ListBox * );
+
+public:
+ SwFieldDialog( SwEditWin* parent, IFieldmark *fieldBM );
+};
+
+SwFieldDialog::SwFieldDialog( SwEditWin* parent, IFieldmark *fieldBM ) :
+ FloatingWindow( parent, WB_BORDER | WB_SYSTEMWINDOW ),
+ aListBox(this),
+ pFieldmark( fieldBM )
+{
+ if ( fieldBM != NULL )
+ {
+ const IFieldmark::parameter_map_t* const pParameters = fieldBM->GetParameters();
+
+ OUString sListKey = OUString( ODF_FORMDROPDOWN_LISTENTRY );
+ IFieldmark::parameter_map_t::const_iterator pListEntries = pParameters->find( sListKey );
+ if(pListEntries != pParameters->end())
+ {
+ Sequence< OUString > vListEntries;
+ pListEntries->second >>= vListEntries;
+ for( OUString* pCurrent = vListEntries.getArray();
+ pCurrent != vListEntries.getArray() + vListEntries.getLength();
+ ++pCurrent)
+ {
+ aListBox.InsertEntry(*pCurrent);
+ }
+ }
+
+ // Select the current one
+ OUString sResultKey = OUString( ODF_FORMDROPDOWN_RESULT );
+ IFieldmark::parameter_map_t::const_iterator pResult = pParameters->find( sResultKey );
+ if ( pResult != pParameters->end() )
+ {
+ sal_Int32 nSelection = -1;
+ pResult->second >>= nSelection;
+ aListBox.SelectEntryPos( nSelection );
+ }
+ }
+
+ Size lbSize(aListBox.GetOptimalSize());
+ lbSize.Width()+=50;
+ lbSize.Height()+=20;
+ aListBox.SetSizePixel(lbSize);
+ aListBox.SetSelectHdl( LINK( this, SwFieldDialog, MyListBoxHandler ) );
+ aListBox.Show();
+
+ SetSizePixel( lbSize );
+}
+
+IMPL_LINK( SwFieldDialog, MyListBoxHandler, ListBox *, pBox )
+{
+ short res = 0;
+ if ( !pBox->IsTravelSelect() )
+ {
+ sal_Int32 selection = pBox->GetSelectEntryPos();
+ if ( selection >= 0 )
+ {
+ OUString sKey = OUString( ODF_FORMDROPDOWN_RESULT );
+ (*pFieldmark->GetParameters())[ sKey ] = makeAny(selection);
+ pFieldmark->Invalidate();
+ SwView& rView = ( ( SwEditWin* )GetParent() )->GetView();
+ rView.GetDocShell()->SetModified( sal_True );
+ }
+
+ EndPopupMode();
+ res = 1;
+ }
+ return res;
+}
+
+IMPL_LINK_NOARG(SwView, FieldPopupModeEndHdl)
+{
+ if ( m_pFieldPopup )
+ {
+ delete m_pFieldPopup;
+ m_pFieldPopup = NULL;
+ }
+ return 0;
+}
+
+void SwView::ExecFieldPopup( const Point& rPt, IFieldmark *fieldBM )
+{
+ const Point aPixPos = GetEditWin().LogicToPixel( rPt );
+
+ m_pFieldPopup = new SwFieldDialog( m_pEditWin, fieldBM );
+ m_pFieldPopup->SetPopupModeEndHdl( LINK( this, SwView, FieldPopupModeEndHdl ) );
+
+ Rectangle aRect( m_pEditWin->OutputToScreenPixel( aPixPos ), Size( 0, 0 ) );
+ m_pFieldPopup->StartPopupMode( aRect, FLOATWIN_POPUPMODE_DOWN|FLOATWIN_POPUPMODE_GRABFOCUS );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/uiview/viewmdi.cxx b/sw/source/core/uibase/uiview/viewmdi.cxx
new file mode 100644
index 000000000000..4ff2f9443fea
--- /dev/null
+++ b/sw/source/core/uibase/uiview/viewmdi.cxx
@@ -0,0 +1,614 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <string>
+
+#include "hintids.hxx"
+#include <vcl/svapp.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svx/ruler.hxx>
+#include <editeng/lrspitem.hxx>
+#include <svl/srchitem.hxx>
+#include <svl/stritem.hxx>
+#include <sfx2/request.hxx>
+#include <swmodule.hxx>
+#include <view.hxx>
+#include <wrtsh.hxx>
+#include <docsh.hxx>
+#include <viewopt.hxx>
+#include <frmatr.hxx>
+#include <wdocsh.hxx>
+#include <uitool.hxx>
+#include <edtwin.hxx>
+#include <pagedesc.hxx>
+#include <IMark.hxx>
+#include <fldbas.hxx>
+#include <workctrl.hxx>
+#include <usrpref.hxx>
+#include <scroll.hxx>
+#include <wview.hxx>
+
+#include <cmdid.h>
+#include <view.hrc>
+#include <ribbar.hrc>
+#include <helpid.h>
+#include <globals.hrc>
+
+#include <IDocumentSettingAccess.hxx>
+#include <PostItMgr.hxx>
+
+sal_uInt16 SwView::m_nMoveType = NID_PGE;
+sal_Int32 SwView::m_nActMark = 0;
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::frame;
+
+void SwView::SetZoom( SvxZoomType eZoomType, short nFactor, sal_Bool bViewOnly )
+{
+ bool const bCrsrIsVisible(m_pWrtShell->IsCrsrVisible());
+ _SetZoom( GetEditWin().GetOutputSizePixel(), eZoomType, nFactor, bViewOnly );
+ // fdo#40465 force the cursor to stay in view whilst zooming
+ if (bCrsrIsVisible)
+ m_pWrtShell->ShowCrsr();
+}
+
+void SwView::_SetZoom( const Size &rEditSize, SvxZoomType eZoomType,
+ short nFactor, sal_Bool bViewOnly )
+{
+ sal_Bool bUnLockView = !m_pWrtShell->IsViewLocked();
+ m_pWrtShell->LockView( sal_True );
+ m_pWrtShell->LockPaint();
+
+ {
+ SwActContext aActContext(m_pWrtShell);
+
+ long nFac = nFactor;
+
+ sal_Bool bWeb = 0 != PTR_CAST(SwWebView, this);
+ SwMasterUsrPref *pUsrPref = (SwMasterUsrPref*)SW_MOD()->GetUsrPref(bWeb);
+
+ const SwPageDesc &rDesc = m_pWrtShell->GetPageDesc( m_pWrtShell->GetCurPageDesc() );
+ const SvxLRSpaceItem &rLRSpace = rDesc.GetMaster().GetLRSpace();
+ const SwViewOption *pOpt = m_pWrtShell->GetViewOptions();
+ long lLeftMargin = 0;
+
+ if( eZoomType != SVX_ZOOM_PERCENT )
+ {
+ const bool bAutomaticViewLayout = 0 == pOpt->GetViewLayoutColumns();
+
+ const SwRect aPageRect( m_pWrtShell->GetAnyCurRect( RECT_PAGE_CALC ) );
+ const SwRect aRootRect( m_pWrtShell->GetAnyCurRect( RECT_PAGES_AREA ) );
+ Size aPageSize( aPageRect.SSize() );
+ Size aRootSize( aRootRect.SSize() );
+
+ //mod #i6193# added sidebar width
+ SwPostItMgr* pPostItMgr = GetPostItMgr();
+ if (pPostItMgr->HasNotes() && pPostItMgr->ShowNotes())
+ aPageSize.Width() += pPostItMgr->GetSidebarWidth() + pPostItMgr->GetSidebarBorderWidth();
+
+ const MapMode aTmpMap( MAP_TWIP );
+ const Size aWindowSize( GetEditWin().PixelToLogic( rEditSize, aTmpMap ) );
+
+ if( nsUseOnPage::PD_MIRROR == rDesc.GetUseOn() ) // mirrored pages
+ {
+ const SvxLRSpaceItem &rLeftLRSpace = rDesc.GetLeft().GetLRSpace();
+ aPageSize.Width() += std::abs( long(rLeftLRSpace.GetLeft()) - long(rLRSpace.GetLeft()) );
+ }
+
+ if( SVX_ZOOM_OPTIMAL == eZoomType )
+ {
+ if (!pPostItMgr->HasNotes() || !pPostItMgr->ShowNotes())
+ aPageSize.Width() -= ( rLRSpace.GetLeft() + rLRSpace.GetRight() + nLeftOfst * 2 );
+ lLeftMargin = long(rLRSpace.GetLeft()) + DOCUMENTBORDER + nLeftOfst;
+ nFac = aWindowSize.Width() * 100 / aPageSize.Width();
+ }
+ else if(SVX_ZOOM_WHOLEPAGE == eZoomType || SVX_ZOOM_PAGEWIDTH == eZoomType )
+ {
+ const long nOf = DOCUMENTBORDER * 2L;
+ long nTmpWidth = bAutomaticViewLayout ? aPageSize.Width() : aRootSize.Width();
+ nTmpWidth += nOf;
+ aPageSize.Height() += nOf;
+ nFac = aWindowSize.Width() * 100 / nTmpWidth;
+
+ if ( SVX_ZOOM_WHOLEPAGE == eZoomType )
+ {
+ long nVisPercent = aWindowSize.Height() * 100 / aPageSize.Height();
+ nFac = std::min( nFac, nVisPercent );
+ }
+ }
+ else
+ {
+ const long nTmpWidth = bAutomaticViewLayout ? aPageSize.Width() : aRootSize.Width();
+ nFac = aWindowSize.Width() * 100 / nTmpWidth;
+ }
+ }
+
+ nFac = std::max( long( MINZOOM ), nFac );
+
+ SwViewOption aOpt( *pOpt );
+ if ( !GetViewFrame()->GetFrame().IsInPlace() )
+ {
+ //Update MasterUsrPrefs and after that update the ViewOptions of the current View.
+ if ( !bViewOnly &&
+ (sal_uInt16(nFac) != pUsrPref->GetZoom() ||
+ sal_uInt8 (eZoomType) != pUsrPref->GetZoomType()) )
+ {
+ pUsrPref->SetZoom ( sal_uInt16(nFac) );
+ pUsrPref->SetZoomType( eZoomType );
+ SW_MOD()->ApplyUsrPref( *pUsrPref,
+ bViewOnly ? this: 0,
+ bViewOnly ? VIEWOPT_DEST_VIEW_ONLY : 0 );
+ pUsrPref->SetModified();
+ }
+ if ( pOpt->GetZoom() != (sal_uInt16) nFac )
+ {
+ aOpt.SetZoom ( sal_uInt16(nFac) );
+ aOpt.SetReadonly(pOpt->IsReadonly());
+ m_pWrtShell->ApplyViewOptions( aOpt );
+ }
+ if ( eZoomType != SVX_ZOOM_PERCENT )
+ {
+ Point aPos;
+
+ if ( eZoomType == SVX_ZOOM_WHOLEPAGE )
+ aPos.Y() = m_pWrtShell->GetAnyCurRect(RECT_PAGE).Top() - DOCUMENTBORDER;
+ else
+ {
+ // Make sure that the cursor is in the visible range, so that
+ // the scrolling will be performed only once.
+ aPos.X() = lLeftMargin;
+ const SwRect &rCharRect = m_pWrtShell->GetCharRect();
+ if ( rCharRect.Top() > GetVisArea().Bottom() ||
+ rCharRect.Bottom() < aPos.Y() )
+ aPos.Y() = rCharRect.Top() - rCharRect.Height();
+ else
+ aPos.Y() = GetVisArea().Top();
+ }
+ SetVisArea( aPos );
+ }
+ // Compromise solution - Under certain circumstances SetZoom is called
+ // in CalcVisAreas again and thus be set wrong values.
+ ((SwViewOption*)m_pWrtShell->GetViewOptions())->SetZoomType( eZoomType );
+ CalcVisArea( rEditSize ); // for the recalculation of the viewable area
+ }
+ else if ( sal_uInt16(nFac) != pOpt->GetZoom() )
+ {
+ aOpt.SetZoom ( sal_uInt16(nFac) );
+ m_pWrtShell->ApplyViewOptions( aOpt );
+ }
+
+ const Fraction aFrac( nFac, 100 );
+ m_pVRuler->SetZoom( aFrac );
+ m_pVRuler->ForceUpdate();
+ m_pHRuler->SetZoom( aFrac );
+ m_pHRuler->ForceUpdate();
+ ((SwViewOption*)m_pWrtShell->GetViewOptions())->SetZoomType( eZoomType );
+ }
+ m_pWrtShell->UnlockPaint();
+ if( bUnLockView )
+ m_pWrtShell->LockView( sal_False );
+}
+
+void SwView::SetViewLayout( sal_uInt16 nColumns, bool bBookMode, sal_Bool bViewOnly )
+{
+ const sal_Bool bUnLockView = !m_pWrtShell->IsViewLocked();
+ m_pWrtShell->LockView( sal_True );
+ m_pWrtShell->LockPaint();
+
+ {
+
+ SwActContext aActContext(m_pWrtShell);
+
+ if ( !GetViewFrame()->GetFrame().IsInPlace() && !bViewOnly )
+ {
+ const sal_Bool bWeb = 0 != PTR_CAST(SwWebView, this);
+ SwMasterUsrPref *pUsrPref = (SwMasterUsrPref*)SW_MOD()->GetUsrPref(bWeb);
+
+ // Update MasterUsrPrefs and after that update the ViewOptions of the current View.
+ if ( nColumns != pUsrPref->GetViewLayoutColumns() ||
+ bBookMode != pUsrPref->IsViewLayoutBookMode() )
+ {
+ pUsrPref->SetViewLayoutColumns( nColumns );
+ pUsrPref->SetViewLayoutBookMode( bBookMode );
+ SW_MOD()->ApplyUsrPref( *pUsrPref,
+ bViewOnly ? this: 0,
+ bViewOnly ? VIEWOPT_DEST_VIEW_ONLY : 0 );
+ pUsrPref->SetModified();
+ }
+ }
+
+ const SwViewOption *pOpt = m_pWrtShell->GetViewOptions();
+
+ if ( nColumns != pOpt->GetViewLayoutColumns() ||
+ bBookMode != pOpt->IsViewLayoutBookMode() )
+ {
+ SwViewOption aOpt( *pOpt );
+ aOpt.SetViewLayoutColumns( nColumns );
+ aOpt.SetViewLayoutBookMode( bBookMode );
+ m_pWrtShell->ApplyViewOptions( aOpt );
+ }
+
+ m_pVRuler->ForceUpdate();
+ m_pHRuler->ForceUpdate();
+
+ }
+
+ m_pWrtShell->UnlockPaint();
+ if( bUnLockView )
+ m_pWrtShell->LockView( sal_False );
+
+ SfxBindings& rBnd = GetViewFrame()->GetBindings();
+ rBnd.Invalidate( SID_ATTR_VIEWLAYOUT );
+ rBnd.Invalidate( SID_ATTR_ZOOMSLIDER);
+}
+
+// Scrollbar - Handler
+
+IMPL_LINK( SwView, WindowChildEventListener, VclSimpleEvent*, pEvent )
+{
+ OSL_ENSURE( pEvent && pEvent->ISA( VclWindowEvent ), "Unknown WindowEvent!" );
+ if ( pEvent && pEvent->ISA( VclWindowEvent ) )
+ {
+ VclWindowEvent *pVclEvent = static_cast< VclWindowEvent * >( pEvent );
+ OSL_ENSURE( pVclEvent->GetWindow(), "Window???" );
+ Window* pChildWin = static_cast< Window* >( pVclEvent->GetData() );
+
+ switch ( pVclEvent->GetId() )
+ {
+ case VCLEVENT_WINDOW_HIDE:
+ if( pChildWin == m_pHScrollbar )
+ ShowHScrollbar( sal_False );
+ else if( pChildWin == m_pVScrollbar )
+ ShowVScrollbar( sal_False );
+ break;
+ case VCLEVENT_WINDOW_SHOW:
+ if( pChildWin == m_pHScrollbar )
+ ShowHScrollbar( sal_True );
+ else if( pChildWin == m_pVScrollbar )
+ ShowVScrollbar( sal_True );
+ break;
+ }
+ }
+
+ return 0;
+}
+
+int SwView::_CreateScrollbar( sal_Bool bHori )
+{
+ Window *pMDI = &GetViewFrame()->GetWindow();
+ SwScrollbar** ppScrollbar = bHori ? &m_pHScrollbar : &m_pVScrollbar;
+
+ OSL_ENSURE( !*ppScrollbar, "check beforehand!" );
+
+ *ppScrollbar = new SwScrollbar( pMDI, bHori );
+ UpdateScrollbars();
+ if(bHori)
+ (*ppScrollbar)->SetScrollHdl( LINK( this, SwView, EndScrollHdl ));
+ else
+ (*ppScrollbar)->SetScrollHdl( LINK( this, SwView, ScrollHdl ));
+ (*ppScrollbar)->SetEndScrollHdl( LINK( this, SwView, EndScrollHdl ));
+
+ (*ppScrollbar)->EnableDrag( true );
+
+ if(GetWindow())
+ InvalidateBorder();
+
+ // The scrollbar has to be tested again, as in InvalidateBorder possibly
+ // the scrollbar has been deleted.
+ if ( !m_bShowAtResize && (*ppScrollbar))
+ (*ppScrollbar)->ExtendedShow();
+
+ return 1;
+}
+
+IMPL_STATIC_LINK( SwView, MoveNavigationHdl, bool *, pbNext )
+{
+ if ( !pbNext )
+ return 0;
+ const bool bNext = *pbNext;
+ SwWrtShell& rSh = pThis->GetWrtShell();
+ switch( m_nMoveType )
+ {
+ case NID_PGE:
+ bNext ? pThis->PhyPageDown() : pThis->PhyPageUp();
+ break;
+ case NID_TBL :
+ rSh.EnterStdMode();
+ if(bNext)
+ rSh.MoveTable(fnTableNext, fnTableStart);
+ else
+ rSh.MoveTable(fnTablePrev, fnTableStart);
+ break;
+ case NID_FRM :
+ case NID_GRF:
+ case NID_OLE:
+ {
+ sal_uInt16 eType = GOTOOBJ_FLY_FRM;
+ if(m_nMoveType == NID_GRF)
+ eType = GOTOOBJ_FLY_GRF;
+ else if(m_nMoveType == NID_OLE)
+ eType = GOTOOBJ_FLY_OLE;
+ sal_Bool bSuccess = bNext ?
+ rSh.GotoNextFly(eType) :
+ rSh.GotoPrevFly(eType);
+ if(bSuccess)
+ {
+ rSh.HideCrsr();
+ rSh.EnterSelFrmMode();
+ }
+ }
+ break;
+ case NID_DRW :
+ case NID_CTRL:
+ rSh.GotoObj(bNext,
+ m_nMoveType == NID_DRW ?
+ GOTOOBJ_DRAW_SIMPLE :
+ GOTOOBJ_DRAW_CONTROL);
+ break;
+ case NID_REG :
+ rSh.EnterStdMode();
+ if(bNext)
+ rSh.MoveRegion(fnRegionNext, fnRegionStart);
+ else
+ rSh.MoveRegion(fnRegionPrev, fnRegionStart);
+
+ break;
+ case NID_BKM :
+ rSh.EnterStdMode();
+ pThis->GetViewFrame()->GetDispatcher()->Execute(bNext ?
+ FN_NEXT_BOOKMARK :
+ FN_PREV_BOOKMARK);
+ break;
+ case NID_OUTL:
+ rSh.EnterStdMode();
+ bNext ? rSh.GotoNextOutline() : rSh.GotoPrevOutline();
+ break;
+ case NID_SEL :
+ bNext ? rSh.GoNextCrsr() : rSh.GoPrevCrsr();
+ break;
+ case NID_FTN:
+ rSh.EnterStdMode();
+ bNext ?
+ rSh.GotoNextFtnAnchor() :
+ rSh.GotoPrevFtnAnchor();
+ break;
+ case NID_MARK:
+ {
+ // unselect
+ rSh.MoveCrsr();
+ rSh.EnterStdMode();
+
+ // collect navigator reminders
+ IDocumentMarkAccess* const pMarkAccess = rSh.getIDocumentMarkAccess();
+ ::std::vector< const ::sw::mark::IMark* > vNavMarks;
+ for( IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getAllMarksBegin();
+ ppMark != pMarkAccess->getAllMarksEnd();
+ ppMark++)
+ {
+ if( IDocumentMarkAccess::GetType(**ppMark) == IDocumentMarkAccess::NAVIGATOR_REMINDER )
+ vNavMarks.push_back(ppMark->get());
+ }
+
+ // move
+ if(!vNavMarks.empty())
+ {
+ if(bNext)
+ {
+ m_nActMark++;
+ if (m_nActMark >= MAX_MARKS || m_nActMark >= static_cast<sal_Int32>(vNavMarks.size()))
+ m_nActMark = 0;
+ }
+ else
+ {
+ m_nActMark--;
+ if (m_nActMark < 0 || m_nActMark >= static_cast<sal_Int32>(vNavMarks.size()))
+ m_nActMark = vNavMarks.size()-1;
+ }
+ rSh.GotoMark(vNavMarks[m_nActMark]);
+ }
+ }
+ break;
+
+ case NID_POSTIT:
+ {
+ sw::sidebarwindows::SwSidebarWin* pPostIt = pThis->GetPostItMgr()->GetActiveSidebarWin();
+ if (pPostIt)
+ pThis->GetPostItMgr()->SetActiveSidebarWin(0);
+ SwFieldType* pFldType = rSh.GetFldType(0, RES_POSTITFLD);
+ if ( rSh.MoveFldType( pFldType, bNext ) )
+ pThis->GetViewFrame()->GetDispatcher()->Execute(FN_POSTIT);
+ else
+ //first/last item
+ pThis->GetPostItMgr()->SetActiveSidebarWin(pPostIt);
+ }
+ break;
+
+ case NID_SRCH_REP:
+ if(m_pSrchItem)
+ {
+ sal_Bool bBackward = m_pSrchItem->GetBackward();
+ if(rSh.HasSelection() && !bNext == rSh.IsCrsrPtAtEnd())
+ rSh.SwapPam();
+ m_pSrchItem->SetBackward(!bNext);
+ SfxRequest aReq(FN_REPEAT_SEARCH, SFX_CALLMODE_SLOT, pThis->GetPool());
+ pThis->ExecSearch(aReq);
+ m_pSrchItem->SetBackward(bBackward);
+ }
+ break;
+ case NID_INDEX_ENTRY:
+ rSh.GotoNxtPrvTOXMark(bNext);
+ break;
+
+ case NID_TABLE_FORMULA:
+ rSh.GotoNxtPrvTblFormula( bNext );
+ break;
+
+ case NID_TABLE_FORMULA_ERROR:
+ rSh.GotoNxtPrvTblFormula( bNext, sal_True );
+ break;
+ }
+ pThis->m_pEditWin->GrabFocus();
+ delete pbNext;
+ return 0;
+}
+
+int SwView::CreateTab()
+{
+ m_pHRuler->SetActive(GetFrame() && IsActive());
+
+ m_pHRuler->Show();
+ InvalidateBorder();
+ return 1;
+}
+
+int SwView::KillTab()
+{
+ m_pHRuler->Hide();
+ InvalidateBorder();
+ return 1;
+}
+
+void SwView::ChangeTabMetric( FieldUnit eUnit )
+{
+ if(m_pHRuler->GetUnit() != eUnit )
+ {
+ m_pHRuler->SetUnit( eUnit );
+ m_pHRuler->Invalidate();
+ }
+}
+
+void SwView::ChangeVRulerMetric( FieldUnit eUnit )
+{
+ if(m_pVRuler->GetUnit() != eUnit)
+ {
+ m_pVRuler->SetUnit( eUnit );
+ m_pVRuler->Invalidate();
+ }
+}
+
+void SwView::GetVRulerMetric(FieldUnit& eToFill) const
+{
+ eToFill = m_pVRuler->GetUnit();
+}
+
+void SwView::GetHRulerMetric(FieldUnit& eToFill) const
+{
+ eToFill = m_pHRuler->GetUnit();
+}
+
+int SwView::CreateVRuler()
+{
+ m_pHRuler->SetBorderPos( m_pVRuler->GetSizePixel().Width()-1 );
+
+ m_pVRuler->SetActive(GetFrame() && IsActive());
+ m_pVRuler->Show();
+ InvalidateBorder();
+ return 1;
+}
+
+int SwView::KillVRuler()
+{
+ m_pVRuler->Hide();
+ m_pHRuler->SetBorderPos( 0 );
+ InvalidateBorder();
+ return 1;
+}
+
+IMPL_LINK( SwView, ExecRulerClick, Ruler *, pRuler )
+{
+ OUString sDefPage;
+ switch( pRuler->GetClickType() )
+ {
+ case RULER_TYPE_DONTKNOW:
+ case RULER_TYPE_OUTSIDE:
+ case RULER_TYPE_INDENT:
+ case RULER_TYPE_MARGIN1:
+ case RULER_TYPE_MARGIN2:
+ sDefPage = "indents";
+ break;
+ default:
+ sDefPage = "tabs";
+
+ }
+
+ SfxStringItem aDefPage(SID_PARA_DLG, sDefPage);
+ GetViewFrame()->GetDispatcher()->Execute( SID_PARA_DLG,
+ SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD,
+ &aDefPage, 0L );
+ return 0;
+}
+
+sal_uInt16 SwView::GetMoveType()
+{
+ return m_nMoveType;
+}
+
+void SwView::SetMoveType(sal_uInt16 nSet)
+{
+ m_nMoveType = nSet;
+}
+
+void SwView::SetActMark(sal_Int32 nSet)
+{
+ m_nActMark = nSet;
+}
+
+void SwView::ShowHScrollbar(sal_Bool bShow)
+{
+ OSL_ENSURE(m_pHScrollbar, "Scrollbar invalid");
+ m_pHScrollbar->ExtendedShow(bShow);
+}
+
+sal_Bool SwView::IsHScrollbarVisible()const
+{
+ OSL_ENSURE(m_pHScrollbar, "Scrollbar invalid");
+ return m_pHScrollbar->IsVisible( sal_False ) || m_pHScrollbar->IsAuto();
+}
+
+void SwView::ShowVScrollbar(sal_Bool bShow)
+{
+ OSL_ENSURE(m_pVScrollbar, "Scrollbar invalid");
+ m_pVScrollbar->ExtendedShow(bShow);
+}
+
+sal_Bool SwView::IsVScrollbarVisible()const
+{
+ OSL_ENSURE(m_pVScrollbar, "Scrollbar invalid");
+ return m_pVScrollbar->IsVisible( sal_False );
+}
+
+void SwView::EnableHScrollbar(bool bEnable)
+{
+ if (m_bHScrollbarEnabled != bEnable)
+ {
+ m_bHScrollbarEnabled = bEnable;
+ InvalidateBorder();
+ }
+}
+
+void SwView::EnableVScrollbar(bool bEnable)
+{
+ if (m_bVScrollbarEnabled != bEnable)
+ {
+ m_bVScrollbarEnabled = bEnable;
+ InvalidateBorder();
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/uiview/viewport.cxx b/sw/source/core/uibase/uiview/viewport.cxx
new file mode 100644
index 000000000000..119e03e05d91
--- /dev/null
+++ b/sw/source/core/uibase/uiview/viewport.cxx
@@ -0,0 +1,1275 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <config_features.h>
+
+#include "hintids.hxx"
+
+#include <vcl/help.hxx>
+#include <vcl/settings.hxx>
+
+#include <svx/ruler.hxx>
+#include <editeng/paperinf.hxx>
+#include <editeng/lrspitem.hxx>
+#include <sfx2/bindings.hxx>
+#include <view.hxx>
+#include <wrtsh.hxx>
+#include <swmodule.hxx>
+#include <viewopt.hxx>
+#include <frmatr.hxx>
+#include <docsh.hxx>
+#include <cmdid.h>
+#include <edtwin.hxx>
+#include <scroll.hxx>
+#include <wview.hxx>
+#include <usrpref.hxx>
+#include <pagedesc.hxx>
+#include <workctrl.hxx>
+#include <crsskip.hxx>
+#include <touch/touch.h>
+
+#include <PostItMgr.hxx>
+
+#include <IDocumentSettingAccess.hxx>
+
+#include <basegfx/tools/zoomtools.hxx>
+
+// The SetVisArea of the DocShell must not be called from InnerResizePixel.
+// But our adjustments must take place.
+#ifndef WB_RIGHT_ALIGNED
+#define WB_RIGHT_ALIGNED ((WinBits)0x00008000)
+#endif
+
+static bool bProtectDocShellVisArea = false;
+
+static sal_uInt16 nPgNum = 0;
+
+bool SwView::IsDocumentBorder()
+{
+ return GetDocShell()->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED ||
+ m_pWrtShell->GetViewOptions()->getBrowseMode() ||
+ SVX_ZOOM_PAGEWIDTH_NOBORDER == (SvxZoomType)m_pWrtShell->GetViewOptions()->GetZoomType();
+}
+
+inline long GetLeftMargin( SwView &rView )
+{
+ SvxZoomType eType = (SvxZoomType)rView.GetWrtShell().GetViewOptions()->GetZoomType();
+ long lRet = rView.GetWrtShell().GetAnyCurRect(RECT_PAGE_PRT).Left();
+ return eType == SVX_ZOOM_PERCENT ? lRet + DOCUMENTBORDER :
+ eType == SVX_ZOOM_PAGEWIDTH || eType == SVX_ZOOM_PAGEWIDTH_NOBORDER ? 0 :
+ lRet + DOCUMENTBORDER + nLeftOfst;
+}
+
+static void lcl_GetPos(SwView* pView,
+ Point& rPos,
+ SwScrollbar* pScrollbar,
+ bool bBorder)
+{
+ SwWrtShell &rSh = pView->GetWrtShell();
+ const Size m_aDocSz( rSh.GetDocSize() );
+
+ const long lBorder = bBorder ? DOCUMENTBORDER : DOCUMENTBORDER * 2;
+ const bool bHori = pScrollbar->IsHoriScroll();
+
+ const long lPos = pScrollbar->GetThumbPos() + (bBorder ? DOCUMENTBORDER : 0);
+
+ long lDelta = lPos - (bHori ? rSh.VisArea().Pos().X() : rSh.VisArea().Pos().Y());
+
+ const long lSize = (bHori ? m_aDocSz.A() : m_aDocSz.B()) + lBorder;
+ // Should right or below are too much space,
+ // then they must be subtracted out of the VisArea!
+ long nTmp = pView->GetVisArea().Right()+lDelta;
+ if ( bHori && nTmp > lSize )
+ lDelta -= nTmp - lSize;
+ nTmp = pView->GetVisArea().Bottom()+lDelta;
+ if ( !bHori && nTmp > lSize )
+ lDelta -= nTmp - lSize;
+
+ // use a reference to access/moodify the correct coordinate
+ // returned by accessors to non-const object
+ long & rCoord = bHori ? rPos.X() : rPos.Y();
+ rCoord += lDelta;
+ if ( bBorder && rCoord < DOCUMENTBORDER )
+ rCoord = DOCUMENTBORDER;
+}
+
+// Set zero ruler
+
+void SwView::InvalidateRulerPos()
+{
+ static sal_uInt16 aInval[] =
+ {
+ SID_ATTR_PARA_LRSPACE, SID_RULER_BORDERS, SID_RULER_PAGE_POS,
+ SID_RULER_LR_MIN_MAX, SID_ATTR_LONG_ULSPACE, SID_ATTR_LONG_LRSPACE,
+ SID_RULER_BORDER_DISTANCE,
+ SID_ATTR_PARA_LRSPACE_VERTICAL, SID_RULER_BORDERS_VERTICAL,
+ SID_RULER_TEXT_RIGHT_TO_LEFT,
+ SID_RULER_ROWS, SID_RULER_ROWS_VERTICAL, FN_STAT_PAGE,
+ 0
+ };
+
+ GetViewFrame()->GetBindings().Invalidate(aInval);
+
+ OSL_ENSURE(m_pHRuler, "Why is the ruler not there?");
+ m_pHRuler->ForceUpdate();
+ m_pVRuler->ForceUpdate();
+}
+
+// Limits the scrolling so far that only a quarter of the
+// screen can be scrolled up before the end of the document.
+
+long SwView::SetHScrollMax( long lMax )
+{
+ const long lBorder = IsDocumentBorder() ? DOCUMENTBORDER : DOCUMENTBORDER * 2;
+ const long lSize = GetDocSz().Width() + lBorder - m_aVisArea.GetWidth();
+
+ // At negative values the document is completely visible.
+ // In this case, no scrolling.
+ return std::max( std::min( lMax, lSize ), 0L );
+}
+
+long SwView::SetVScrollMax( long lMax )
+{
+ const long lBorder = IsDocumentBorder() ? DOCUMENTBORDER : DOCUMENTBORDER * 2;
+ long lSize = GetDocSz().Height() + lBorder - m_aVisArea.GetHeight();
+ return std::max( std::min( lMax, lSize), 0L ); // see horizontal
+}
+
+Point SwView::AlignToPixel(const Point &rPt) const
+{
+ return GetEditWin().PixelToLogic( GetEditWin().LogicToPixel( rPt ) );
+}
+
+// Document size has changed.
+
+void SwView::DocSzChgd(const Size &rSz)
+{
+
+extern int bDocSzUpdated;
+
+m_aDocSz = rSz;
+
+ if( !m_pWrtShell || m_aVisArea.IsEmpty() ) // no shell -> no change
+ {
+ bDocSzUpdated = sal_False;
+ return;
+ }
+
+ //If text has been deleted, it may be that the VisArea points behind the visible range.
+ Rectangle aNewVisArea( m_aVisArea );
+ bool bModified = false;
+ SwTwips lGreenOffset = IsDocumentBorder() ? DOCUMENTBORDER : DOCUMENTBORDER * 2;
+ SwTwips lTmp = m_aDocSz.Width() + lGreenOffset;
+
+ if ( aNewVisArea.Right() >= lTmp )
+ {
+ lTmp = aNewVisArea.Right() - lTmp;
+ aNewVisArea.Right() -= lTmp;
+ aNewVisArea.Left() -= lTmp;
+ bModified = true;
+ }
+
+ lTmp = m_aDocSz.Height() + lGreenOffset;
+ if ( aNewVisArea.Bottom() >= lTmp )
+ {
+ lTmp = aNewVisArea.Bottom() - lTmp;
+ aNewVisArea.Bottom() -= lTmp;
+ aNewVisArea.Top() -= lTmp;
+ bModified = true;
+ }
+
+ if ( bModified )
+ SetVisArea( aNewVisArea, sal_False );
+
+ if ( UpdateScrollbars() && !m_bInOuterResizePixel && !m_bInInnerResizePixel &&
+ !GetViewFrame()->GetFrame().IsInPlace())
+ OuterResizePixel( Point(),
+ GetViewFrame()->GetWindow().GetOutputSizePixel() );
+}
+
+// Set VisArea newly
+
+void SwView::SetVisArea( const Rectangle &rRect, sal_Bool bUpdateScrollbar )
+{
+ const Size aOldSz( m_aVisArea.GetSize() );
+
+ const Point aTopLeft( AlignToPixel( rRect.TopLeft() ));
+ const Point aBottomRight( AlignToPixel( rRect.BottomRight() ));
+ Rectangle aLR( aTopLeft, aBottomRight );
+
+ if( aLR == m_aVisArea )
+ return;
+
+ const SwTwips lMin = IsDocumentBorder() ? DOCUMENTBORDER : 0;
+
+ // No negative position, no negative size
+ if( aLR.Top() < lMin )
+ {
+ aLR.Bottom() += lMin - aLR.Top();
+ aLR.Top() = lMin;
+ }
+ if( aLR.Left() < lMin )
+ {
+ aLR.Right() += lMin - aLR.Left();
+ aLR.Left() = lMin;
+ }
+ if( aLR.Right() < 0 )
+ aLR.Right() = 0;
+ if( aLR.Bottom() < 0 )
+ aLR.Bottom() = 0;
+
+ if( aLR == m_aVisArea )
+ return;
+
+ const Size aSize( aLR.GetSize() );
+ if( aSize.Width() < 0 || aSize.Height() < 0 )
+ return;
+
+ // Before the data can be changed, call an update if necessary. This
+ // ensures that adjacent Paints in document coordinates are converted
+ // correctly.
+ // As a precaution, we do this only when an action is running in the
+ // shell, because then it is not really drawn but the rectangles will
+ // be only marked (in document coordinates).
+ if ( m_pWrtShell && m_pWrtShell->ActionPend() )
+ m_pWrtShell->GetWin()->Update();
+
+ m_aVisArea = aLR;
+
+ const sal_Bool bOuterResize = bUpdateScrollbar && UpdateScrollbars();
+
+ if ( m_pWrtShell )
+ {
+ m_pWrtShell->VisPortChgd( m_aVisArea );
+ if ( aOldSz != m_pWrtShell->VisArea().SSize() &&
+ ( std::abs(aOldSz.Width() - m_pWrtShell->VisArea().Width()) > 2 ||
+ std::abs(aOldSz.Height() - m_pWrtShell->VisArea().Height()) > 2 ) )
+ m_pWrtShell->CheckBrowseView( sal_False );
+ }
+
+ if ( !bProtectDocShellVisArea )
+ {
+ // If the size of VisArea is unchanged, we extend the size of the VisArea
+ // InternalObject on. By that the transport of errors shall be avoided.
+ Rectangle aVis( m_aVisArea );
+ if ( aVis.GetSize() == aOldSz )
+ aVis.SetSize( GetDocShell()->SfxObjectShell::GetVisArea(ASPECT_CONTENT).GetSize() );
+ // TODO/LATER: why casting?!
+ //GetDocShell()->SfxInPlaceObject::GetVisArea().GetSize() );
+
+ // With embedded always with modify...
+ // TODO/LATER: why casting?!
+ GetDocShell()->SfxObjectShell::SetVisArea( aVis );
+ /*
+ if ( GetDocShell()->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
+ GetDocShell()->SfxInPlaceObject::SetVisArea( aVis );
+ else
+ GetDocShell()->SvEmbeddedObject::SetVisArea( aVis );*/
+ }
+
+ SfxViewShell::VisAreaChanged( m_aVisArea );
+
+ InvalidateRulerPos();
+
+ if ( bOuterResize && !m_bInOuterResizePixel && !m_bInInnerResizePixel)
+ OuterResizePixel( Point(),
+ GetViewFrame()->GetWindow().GetOutputSizePixel() );
+}
+
+// Set Pos VisArea
+
+void SwView::SetVisArea( const Point &rPt, sal_Bool bUpdateScrollbar )
+{
+ // Align once, so brushes will be inserted correctly.
+ // This goes wrong in the BrowseView, because the entire document may
+ // not be visible. Since the content in frames is fitting exactly,
+ // align is not possible (better idea?!?!)
+ // (fix: Bild.de, 200%) It does not work completly without alignment
+ // Let's see how far we get with half BrushSize.
+ Point aPt( rPt );
+ aPt = GetEditWin().LogicToPixel( aPt );
+#if HAVE_FEATURE_DESKTOP
+ const long nTmp = GetWrtShell().IsFrameView() ? 4 : 8;
+ aPt.X() -= aPt.X() % nTmp;
+ aPt.Y() -= aPt.Y() % nTmp;
+#endif
+ aPt = GetEditWin().PixelToLogic( aPt );
+
+ if ( aPt == m_aVisArea.TopLeft() )
+ return;
+
+ const long lXDiff = m_aVisArea.Left() - aPt.X();
+ const long lYDiff = m_aVisArea.Top() - aPt.Y();
+ SetVisArea( Rectangle( aPt,
+ Point( m_aVisArea.Right() - lXDiff, m_aVisArea.Bottom() - lYDiff ) ),
+ bUpdateScrollbar);
+}
+
+void SwView::CheckVisArea()
+{
+ m_pHScrollbar->SetAuto( m_pWrtShell->GetViewOptions()->getBrowseMode() &&
+ !GetViewFrame()->GetFrame().IsInPlace() );
+ if ( IsDocumentBorder() )
+ {
+ if ( m_aVisArea.Left() != DOCUMENTBORDER ||
+ m_aVisArea.Top() != DOCUMENTBORDER )
+ {
+ Rectangle aNewVisArea( m_aVisArea );
+ aNewVisArea.Move( DOCUMENTBORDER - m_aVisArea.Left(),
+ DOCUMENTBORDER - m_aVisArea.Top() );
+ SetVisArea( aNewVisArea, sal_True );
+ }
+ }
+}
+
+/// Calculate the visible range.
+
+// OUT Point *pPt: new position of the visible area
+
+// IN Rectangle &rRect: Rectangle, which should be located
+// within the new visible area.
+// sal_uInt16 nRange optional accurate indication of the
+// range by which to scroll if necessary.
+
+void SwView::CalcPt( Point *pPt, const Rectangle &rRect,
+ sal_uInt16 nRangeX, sal_uInt16 nRangeY)
+{
+
+ const SwTwips lMin = IsDocumentBorder() ? DOCUMENTBORDER : 0;
+
+ long nYScroll = GetYScroll();
+ long nDesHeight = rRect.GetHeight();
+ long nCurHeight = m_aVisArea.GetHeight();
+ nYScroll = std::min(nYScroll, nCurHeight - nDesHeight); // If it is scarce, then scroll not too much.
+ if(nDesHeight > nCurHeight) // the height is not sufficient, then nYScroll is no longer of interest
+ {
+ pPt->Y() = rRect.Top();
+ pPt->Y() = std::max( lMin, pPt->Y() );
+ }
+ else if ( rRect.Top() < m_aVisArea.Top() ) // Upward shift
+ {
+ pPt->Y() = rRect.Top() - (nRangeY != USHRT_MAX ? nRangeY : nYScroll);
+ pPt->Y() = std::max( lMin, pPt->Y() );
+ }
+ else if( rRect.Bottom() > m_aVisArea.Bottom() ) // Downward shift
+ {
+ pPt->Y() = rRect.Bottom() -
+ (m_aVisArea.GetHeight()) + ( nRangeY != USHRT_MAX ?
+ nRangeY : nYScroll );
+ pPt->Y() = SetVScrollMax( pPt->Y() );
+ }
+ long nXScroll = GetXScroll();
+ if ( rRect.Right() > m_aVisArea.Right() ) // Shift right
+ {
+ pPt->X() = rRect.Right() -
+ (m_aVisArea.GetWidth()) +
+ (nRangeX != USHRT_MAX ? nRangeX : nXScroll);
+ pPt->X() = SetHScrollMax( pPt->X() );
+ }
+ else if ( rRect.Left() < m_aVisArea.Left() ) // Shift left
+ {
+ pPt->X() = rRect.Left() - (nRangeX != USHRT_MAX ? nRangeX : nXScroll);
+ pPt->X() = std::max( ::GetLeftMargin( *this ) + nLeftOfst, pPt->X() );
+ pPt->X() = std::min( rRect.Left() - nScrollX, pPt->X() );
+ pPt->X() = std::max( 0L, pPt->X() );
+ }
+}
+
+// Scrolling
+
+sal_Bool SwView::IsScroll( const Rectangle &rRect ) const
+{
+ return m_bCenterCrsr || m_bTopCrsr || !m_aVisArea.IsInside(rRect);
+}
+
+void SwView::Scroll( const Rectangle &rRect, sal_uInt16 nRangeX, sal_uInt16 nRangeY )
+{
+ if ( m_aVisArea.IsEmpty() )
+ return;
+
+ Rectangle aOldVisArea( m_aVisArea );
+ long nDiffY = 0;
+
+ Window* pCareWn = SwViewShell::GetCareWin(GetWrtShell());
+ if ( pCareWn )
+ {
+ Rectangle aDlgRect( GetEditWin().PixelToLogic(
+ pCareWn->GetWindowExtentsRelative( &GetEditWin() ) ) );
+ // Only if the dialogue is not the VisArea right or left:
+ if ( aDlgRect.Left() < m_aVisArea.Right() &&
+ aDlgRect.Right() > m_aVisArea.Left() )
+ {
+ // If we are not supposed to be centered, lying in the VisArea
+ // and are not covered by the dialogue ...
+ if ( !m_bCenterCrsr && aOldVisArea.IsInside( rRect )
+ && ( rRect.Left() > aDlgRect.Right()
+ || rRect.Right() < aDlgRect.Left()
+ || rRect.Top() > aDlgRect.Bottom()
+ || rRect.Bottom() < aDlgRect.Top() ) )
+ return;
+
+ // Is above or below the dialogue more space?
+ long nTopDiff = aDlgRect.Top() - m_aVisArea.Top();
+ long nBottomDiff = m_aVisArea.Bottom() - aDlgRect.Bottom();
+ if ( nTopDiff < nBottomDiff )
+ {
+ if ( nBottomDiff > 0 ) // Is there room below at all?
+ { // then we move the upper edge and we remember this
+ nDiffY = aDlgRect.Bottom() - m_aVisArea.Top();
+ m_aVisArea.Top() += nDiffY;
+ }
+ }
+ else
+ {
+ if ( nTopDiff > 0 ) // Is there room below at all?
+ m_aVisArea.Bottom() = aDlgRect.Top(); // Modify the lower edge
+ }
+ }
+ }
+
+ //s.o. !IsScroll()
+ if( !(m_bCenterCrsr || m_bTopCrsr) && m_aVisArea.IsInside( rRect ) )
+ {
+ m_aVisArea = aOldVisArea;
+ return;
+ }
+ // If the rectangle is larger than the visible area -->
+ // upper left corner
+ Size aSize( rRect.GetSize() );
+ const Size aVisSize( m_aVisArea.GetSize() );
+ if( !m_aVisArea.IsEmpty() && (
+ aSize.Width() + GetXScroll() > aVisSize.Width() ||
+ aSize.Height()+ GetYScroll() > aVisSize.Height() ))
+ {
+ Point aPt( m_aVisArea.TopLeft() );
+ aSize.Width() = std::min( aSize.Width(), aVisSize.Width() );
+ aSize.Height()= std::min( aSize.Height(),aVisSize.Height());
+
+ CalcPt( &aPt, Rectangle( rRect.TopLeft(), aSize ),
+ static_cast< sal_uInt16 >((aVisSize.Width() - aSize.Width()) / 2),
+ static_cast< sal_uInt16 >((aVisSize.Height()- aSize.Height())/ 2) );
+
+ if( m_bTopCrsr )
+ {
+ const long nBorder = IsDocumentBorder() ? DOCUMENTBORDER : 0;
+ aPt.Y() = std::min( std::max( nBorder, rRect.Top() ),
+ m_aDocSz.Height() + nBorder -
+ m_aVisArea.GetHeight() );
+ }
+ aPt.Y() -= nDiffY;
+ m_aVisArea = aOldVisArea;
+ SetVisArea( aPt );
+ return;
+ }
+ if( !m_bCenterCrsr )
+ {
+ Point aPt( m_aVisArea.TopLeft() );
+ CalcPt( &aPt, rRect, nRangeX, nRangeY );
+
+ if( m_bTopCrsr )
+ {
+ const long nBorder = IsDocumentBorder() ? DOCUMENTBORDER : 0;
+ aPt.Y() = std::min( std::max( nBorder, rRect.Top() ),
+ m_aDocSz.Height() + nBorder -
+ m_aVisArea.GetHeight() );
+ }
+
+ aPt.Y() -= nDiffY;
+ m_aVisArea = aOldVisArea;
+ SetVisArea( aPt );
+ return;
+ }
+
+ //Center cursor
+ Point aPnt( m_aVisArea.TopLeft() );
+ // ... in Y-direction in any case
+ aPnt.Y() += ( rRect.Top() + rRect.Bottom()
+ - m_aVisArea.Top() - m_aVisArea.Bottom() ) / 2 - nDiffY;
+ // ... in X-direction, only if the rectangle protrudes over the right or left of the VisArea.
+ if ( rRect.Right() > m_aVisArea.Right() || rRect.Left() < m_aVisArea.Left() )
+ {
+ aPnt.X() += ( rRect.Left() + rRect.Right()
+ - m_aVisArea.Left() - m_aVisArea.Right() ) / 2;
+ aPnt.X() = SetHScrollMax( aPnt.X() );
+ const SwTwips lMin = IsDocumentBorder() ? DOCUMENTBORDER : 0;
+ aPnt.X() = std::max( (GetLeftMargin( *this ) - lMin) + nLeftOfst, aPnt.X() );
+ }
+ m_aVisArea = aOldVisArea;
+ if( pCareWn )
+ { // If we want to avoid only a dialogue, we do
+ // not want to go beyond the end of the document.
+ aPnt.Y() = SetVScrollMax( aPnt.Y() );
+ }
+ SetVisArea( aPnt );
+}
+
+/// Scroll page by page
+// Returns the value by which to be scrolled with PageUp / Down
+
+sal_Bool SwView::GetPageScrollUpOffset( SwTwips &rOff ) const
+{
+ if ( !m_aVisArea.Top() || !m_aVisArea.GetHeight() )
+ return sal_False;
+ long nYScrl = GetYScroll() / 2;
+ rOff = -(m_aVisArea.GetHeight() - nYScrl);
+ // Do not scroll before the beginning of the document.
+ if( m_aVisArea.Top() - rOff < 0 )
+ rOff = rOff - m_aVisArea.Top();
+ else if( GetWrtShell().GetCharRect().Top() < (m_aVisArea.Top() + nYScrl))
+ rOff += nYScrl;
+ return sal_True;
+}
+
+sal_Bool SwView::GetPageScrollDownOffset( SwTwips &rOff ) const
+{
+ if ( !m_aVisArea.GetHeight() ||
+ (m_aVisArea.GetHeight() > m_aDocSz.Height()) )
+ return sal_False;
+ long nYScrl = GetYScroll() / 2;
+ rOff = m_aVisArea.GetHeight() - nYScrl;
+ // Do not scroll past the end of the document.
+ if ( m_aVisArea.Top() + rOff > m_aDocSz.Height() )
+ rOff = m_aDocSz.Height() - m_aVisArea.Bottom();
+ else if( GetWrtShell().GetCharRect().Bottom() >
+ ( m_aVisArea.Bottom() - nYScrl ))
+ rOff -= nYScrl;
+ return rOff > 0;
+}
+
+// Scroll page by page
+long SwView::PageUp()
+{
+ if (!m_aVisArea.GetHeight())
+ return 0;
+
+ Point aPos(m_aVisArea.TopLeft());
+ aPos.Y() -= m_aVisArea.GetHeight() - (GetYScroll() / 2);
+ aPos.Y() = std::max(0L, aPos.Y());
+ SetVisArea( aPos );
+ return 1;
+}
+
+long SwView::PageDown()
+{
+ if ( !m_aVisArea.GetHeight() )
+ return 0;
+ Point aPos( m_aVisArea.TopLeft() );
+ aPos.Y() += m_aVisArea.GetHeight() - (GetYScroll() / 2);
+ aPos.Y() = SetVScrollMax( aPos.Y() );
+ SetVisArea( aPos );
+ return 1;
+}
+
+long SwView::PhyPageUp()
+{
+ // Check for the currently visible page, do not format
+ sal_uInt16 nActPage = m_pWrtShell->GetNextPrevPageNum( sal_False );
+
+ if( USHRT_MAX != nActPage )
+ {
+ const Point aPt( m_aVisArea.Left(),
+ m_pWrtShell->GetPagePos( nActPage ).Y() );
+ Point aAlPt( AlignToPixel( aPt ) );
+ // If there is a difference, has been truncated --> then add one pixel,
+ // so that no residue of the previous page is visible.
+ if( aPt.Y() != aAlPt.Y() )
+ aAlPt.Y() += 3 * GetEditWin().PixelToLogic( Size( 0, 1 ) ).Height();
+ SetVisArea( aAlPt );
+ }
+ return 1;
+}
+
+long SwView::PhyPageDown()
+{
+ // Check for the currently visible page, do not format
+ sal_uInt16 nActPage = m_pWrtShell->GetNextPrevPageNum( sal_True );
+ // If the last page of the document is visible, do nothing.
+ if( USHRT_MAX != nActPage )
+ {
+ const Point aPt( m_aVisArea.Left(),
+ m_pWrtShell->GetPagePos( nActPage ).Y() );
+ Point aAlPt( AlignToPixel( aPt ) );
+ // If there is a difference, has been truncated --> then add one pixel,
+ // so that no residue of the previous page is visible.
+ if( aPt.Y() != aAlPt.Y() )
+ aAlPt.Y() += 3 * GetEditWin().PixelToLogic( Size( 0, 1 ) ).Height();
+ SetVisArea( aAlPt );
+ }
+ return 1;
+}
+
+long SwView::PageUpCrsr( sal_Bool bSelect )
+{
+ if ( !bSelect )
+ {
+ const sal_uInt16 eType = m_pWrtShell->GetFrmType(0,sal_True);
+ if ( eType & FRMTYPE_FOOTNOTE )
+ {
+ m_pWrtShell->MoveCrsr();
+ m_pWrtShell->GotoFtnAnchor();
+ m_pWrtShell->Right(CRSR_SKIP_CHARS, sal_False, 1, sal_False );
+ return 1;
+ }
+ }
+
+ SwTwips lOff = 0;
+ if ( GetPageScrollUpOffset( lOff ) &&
+ (m_pWrtShell->IsCrsrReadonly() ||
+ !m_pWrtShell->PageCrsr( lOff, bSelect )) &&
+ PageUp() )
+ {
+ m_pWrtShell->ResetCursorStack();
+ return sal_True;
+ }
+ return sal_False;
+}
+
+long SwView::PageDownCrsr(sal_Bool bSelect)
+{
+ SwTwips lOff = 0;
+ if ( GetPageScrollDownOffset( lOff ) &&
+ (m_pWrtShell->IsCrsrReadonly() ||
+ !m_pWrtShell->PageCrsr( lOff, bSelect )) &&
+ PageDown() )
+ {
+ m_pWrtShell->ResetCursorStack();
+ return sal_True;
+ }
+ return sal_False;
+}
+
+// Handler of the scrollbars
+
+IMPL_LINK( SwView, ScrollHdl, SwScrollbar *, pScrollbar )
+{
+ if ( GetWrtShell().ActionPend() )
+ return 0;
+
+ if ( pScrollbar->GetType() == SCROLL_DRAG )
+ m_pWrtShell->EnableSmooth( sal_False );
+
+ if(!m_pWrtShell->GetViewOptions()->getBrowseMode() &&
+ pScrollbar->GetType() == SCROLL_DRAG)
+ {
+ // Here comment out again if it is not desired to scroll together:
+ // The end scrollhandler invalidate the FN_STAT_PAGE,
+ // so we don't must do it again.
+ EndScrollHdl(pScrollbar);
+
+ if ( !m_bWheelScrollInProgress && Help::IsQuickHelpEnabled() &&
+ m_pWrtShell->GetViewOptions()->IsShowScrollBarTips())
+ {
+
+ Point aPos( m_aVisArea.TopLeft() );
+ lcl_GetPos(this, aPos, pScrollbar, IsDocumentBorder());
+
+ sal_uInt16 nPhNum = 1;
+ sal_uInt16 nVirtNum = 1;
+
+ OUString sDisplay;
+ if(m_pWrtShell->GetPageNumber( aPos.Y(), sal_False, nPhNum, nVirtNum, sDisplay ))
+ {
+ // The end scrollhandler invalidate the FN_STAT_PAGE,
+ // so we don't must do it again.
+ // if(!GetViewFrame()->GetFrame().IsInPlace())
+ // S F X_BINDINGS().Update(FN_STAT_PAGE);
+
+ //QuickHelp:
+ if( m_pWrtShell->GetPageCnt() > 1 )
+ {
+ Rectangle aRect;
+ aRect.Left() = pScrollbar->GetParent()->OutputToScreenPixel(
+ pScrollbar->GetPosPixel() ).X() -8;
+ aRect.Top() = pScrollbar->OutputToScreenPixel(
+ pScrollbar->GetPointerPosPixel() ).Y();
+ aRect.Right() = aRect.Left();
+ aRect.Bottom() = aRect.Top();
+
+ OUString sPageStr( GetPageStr( nPhNum, nVirtNum, sDisplay ));
+ SwContentAtPos aCnt( SwContentAtPos::SW_OUTLINE );
+ m_pWrtShell->GetContentAtPos( aPos, aCnt );
+ if( !aCnt.sStr.isEmpty() )
+ {
+ sPageStr += " - ";
+ sal_Int32 nChunkLen = std::min<sal_Int32>(aCnt.sStr.getLength(), 80);
+ OUString sChunk = aCnt.sStr.copy(0, nChunkLen);
+ sPageStr = sChunk + sPageStr;
+ sPageStr = sPageStr.replace('\t', ' ');
+ sPageStr = sPageStr.replace(0x0a, ' ');
+ }
+ nPgNum = nPhNum;
+ }
+ }
+ }
+ }
+ else
+ EndScrollHdl(pScrollbar);
+
+ if ( pScrollbar->GetType() == SCROLL_DRAG )
+ m_pWrtShell->EnableSmooth( sal_True );
+
+ return 0;
+}
+
+// Handler of the scrollbars
+
+IMPL_LINK( SwView, EndScrollHdl, SwScrollbar *, pScrollbar )
+{
+ if ( !GetWrtShell().ActionPend() )
+ {
+ if(nPgNum)
+ {
+ nPgNum = 0;
+ Help::ShowQuickHelp(pScrollbar, Rectangle(), OUString(), 0);
+ }
+ Point aPos( m_aVisArea.TopLeft() );
+ bool bBorder = IsDocumentBorder();
+ lcl_GetPos(this, aPos, pScrollbar, bBorder);
+ if ( bBorder && aPos == m_aVisArea.TopLeft() )
+ UpdateScrollbars();
+ else
+ SetVisArea( aPos, sal_False );
+
+ GetViewFrame()->GetBindings().Update(FN_STAT_PAGE);
+ }
+ return 0;
+}
+
+// Calculates the size of the m_aVisArea in dependency of the size of
+// EditWin on the screen.
+
+void SwView::CalcVisArea( const Size &rOutPixel )
+{
+ Point aTopLeft;
+ Rectangle aRect( aTopLeft, rOutPixel );
+ aTopLeft = GetEditWin().PixelToLogic( aTopLeft );
+ Point aBottomRight( GetEditWin().PixelToLogic( aRect.BottomRight() ) );
+
+ aRect.Left() = aTopLeft.X();
+ aRect.Top() = aTopLeft.Y();
+ aRect.Right() = aBottomRight.X();
+ aRect.Bottom() = aBottomRight.Y();
+
+ // The shifts to the right and/or below can now be incorrect
+ // (e.g. change zoom level, change view size).
+ const long lBorder = IsDocumentBorder() ? DOCUMENTBORDER : DOCUMENTBORDER*2;
+ if ( aRect.Left() )
+ {
+ const long lWidth = GetWrtShell().GetDocSize().Width() + lBorder;
+ if ( aRect.Right() > lWidth )
+ {
+ long lDelta = aRect.Right() - lWidth;
+ aRect.Left() -= lDelta;
+ aRect.Right() -= lDelta;
+ }
+ }
+ if ( aRect.Top() )
+ {
+ const long lHeight = GetWrtShell().GetDocSize().Height() + lBorder;
+ if ( aRect.Bottom() > lHeight )
+ {
+ long lDelta = aRect.Bottom() - lHeight;
+ aRect.Top() -= lDelta;
+ aRect.Bottom() -= lDelta;
+ }
+ }
+ SetVisArea( aRect );
+ GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM );
+ GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER ); // for snapping points
+}
+
+// Rearrange control elements
+
+void SwView::CalcAndSetBorderPixel( SvBorder &rToFill, sal_Bool /*bInner*/ )
+{
+ sal_Bool bRightVRuler = m_pWrtShell->GetViewOptions()->IsVRulerRight();
+ if ( m_pVRuler->IsVisible() )
+ {
+ long nWidth = m_pVRuler->GetSizePixel().Width();
+ if(bRightVRuler)
+ rToFill.Right() = nWidth;
+ else
+ rToFill.Left() = nWidth;
+ }
+
+ OSL_ENSURE(m_pHRuler, "Why is the ruler not present?");
+ if ( m_pHRuler->IsVisible() )
+ rToFill.Top() = m_pHRuler->GetSizePixel().Height();
+
+ const StyleSettings &rSet = GetEditWin().GetSettings().GetStyleSettings();
+ const long nTmp = rSet.GetScrollBarSize();
+ if( m_pVScrollbar->IsVisible(sal_True) )
+ {
+ if(bRightVRuler)
+ rToFill.Left() = nTmp;
+ else
+ rToFill.Right() = nTmp;
+ }
+ if ( m_pHScrollbar->IsVisible(sal_True) )
+ rToFill.Bottom() = nTmp;
+
+ SetBorderPixel( rToFill );
+}
+
+void ViewResizePixel( const Window &rRef,
+ const Point &rOfst,
+ const Size &rSize,
+ const Size &rEditSz,
+ SwScrollbar& rVScrollbar,
+ SwScrollbar& rHScrollbar,
+ Window& rScrollBarBox,
+ SvxRuler* pVRuler,
+ SvxRuler* pHRuler,
+ sal_Bool bVRulerRight )
+{
+// ViewResizePixel is also used by Preview!!!
+
+ const sal_Bool bHRuler = pHRuler && pHRuler->IsVisible();
+ const long nHLinSzHeight = bHRuler ?
+ pHRuler->GetSizePixel().Height() : 0;
+ const sal_Bool bVRuler = pVRuler && pVRuler->IsVisible();
+ const long nVLinSzWidth = bVRuler ?
+ pVRuler->GetSizePixel().Width() : 0;
+
+ long nScrollBarSize = rRef.GetSettings().GetStyleSettings().GetScrollBarSize();
+ long nHBSzHeight = rHScrollbar.IsVisible(true) ? nScrollBarSize : 0;
+ long nVBSzWidth = rVScrollbar.IsVisible(true) ? nScrollBarSize : 0;
+
+ if(pVRuler)
+ {
+ WinBits nStyle = pVRuler->GetStyle()&~WB_RIGHT_ALIGNED;
+ Point aPos( rOfst.X(), rOfst.Y()+nHLinSzHeight );
+ if(bVRulerRight)
+ {
+ aPos.X() += rSize.Width() - nVLinSzWidth;
+ nStyle |= WB_RIGHT_ALIGNED;
+ }
+ Size aSize( nVLinSzWidth, rEditSz.Height() );
+ if(!aSize.Width())
+ aSize.Width() = pVRuler->GetSizePixel().Width();
+ pVRuler->SetStyle(nStyle);
+ pVRuler->SetPosSizePixel( aPos, aSize );
+ if(!pVRuler->IsVisible())
+ pVRuler->Resize();
+ }
+ // Ruler needs a resize, otherwise it will not work in the invisible condition
+ if(pHRuler)
+ {
+ Size aSize( rSize.Width(), nHLinSzHeight );
+ if ( nVBSzWidth && !bVRulerRight)
+ aSize.Width() -= nVBSzWidth;
+ if(!aSize.Height())
+ aSize.Height() = pHRuler->GetSizePixel().Height();
+ pHRuler->SetPosSizePixel( rOfst, aSize );
+ // VCL calls no resize on invisible windows
+ // but that is not a good idea for the ruler
+ if(!pHRuler->IsVisible())
+ pHRuler->Resize();
+ }
+
+ // Arrange scrollbars and SizeBox
+ Point aScrollFillPos;
+ {
+ Point aPos( rOfst.X(),
+ rOfst.Y()+rSize.Height()-nHBSzHeight );
+ if(bVRulerRight)
+ {
+ aPos.X() += nVBSzWidth;
+ }
+
+ Size aSize( rSize.Width(), nHBSzHeight );
+ if ( nVBSzWidth )
+ aSize.Width() -= nVBSzWidth;
+ rHScrollbar.SetPosSizePixel( aPos, aSize );
+ aScrollFillPos.Y() = aPos.Y();
+ }
+ {
+ Point aPos( rOfst.X()+rSize.Width()-nVBSzWidth,
+ rOfst.Y() );
+ Size aSize( nVBSzWidth, rSize.Height() );
+ if(bVRulerRight)
+ {
+ aPos.X() = rOfst.X();
+ if(bHRuler)
+ {
+ aPos.Y() += nHLinSzHeight;
+ aSize.Height() -= nHLinSzHeight;
+ }
+ }
+
+ if ( nHBSzHeight )
+ aSize.Height() -= nHBSzHeight;
+ rVScrollbar.SetPosSizePixel( aPos, aSize );
+
+ aPos.Y() += aSize.Height();
+
+ aScrollFillPos.X() = aPos.X();
+ }
+
+ rScrollBarBox.SetPosSizePixel( aScrollFillPos, Size( nHBSzHeight, nVBSzWidth) );
+}
+
+void SwView::ShowAtResize()
+{
+ m_bShowAtResize = sal_False;
+ if ( m_pWrtShell->GetViewOptions()->IsViewHRuler() )
+ m_pHRuler->Show();
+}
+
+void SwView::InnerResizePixel( const Point &rOfst, const Size &rSize )
+{
+ Size aObjSize = GetObjectShell()->GetVisArea().GetSize();
+ if ( aObjSize.Width() > 0 && aObjSize.Height() > 0 )
+ {
+ SvBorder aBorder( GetBorderPixel() );
+ Size aSize( rSize );
+ aSize.Width() -= (aBorder.Left() + aBorder.Right());
+ aSize.Height() -= (aBorder.Top() + aBorder.Bottom());
+ Size aObjSizePixel = GetWindow()->LogicToPixel( aObjSize, MAP_TWIP );
+ SfxViewShell::SetZoomFactor( Fraction( aSize.Width(), aObjSizePixel.Width() ),
+ Fraction( aSize.Height(), aObjSizePixel.Height() ) );
+ }
+
+ m_bInInnerResizePixel = sal_True;
+ const sal_Bool bHScrollVisible = m_pHScrollbar->IsVisible(sal_True);
+ const sal_Bool bVScrollVisible = m_pVScrollbar->IsVisible(sal_True);
+ sal_Bool bRepeat = sal_False;
+ do
+ {
+ Size aSz( rSize );
+ SvBorder aBorder;
+ CalcAndSetBorderPixel( aBorder, sal_True );
+ if ( GetViewFrame()->GetFrame().IsInPlace() )
+ {
+ Size aViewSize( aSz );
+ Point aViewPos( rOfst );
+ aViewSize.Height() -= (aBorder.Top() + aBorder.Bottom());
+ aViewSize.Width() -= (aBorder.Left() + aBorder.Right());
+ aViewPos.X() += aBorder.Left();
+ aViewPos.Y() += aBorder.Top();
+ GetEditWin().SetPosSizePixel( aViewPos, aViewSize );
+ }
+ else
+ {
+ aSz.Height() += aBorder.Top() + aBorder.Bottom();
+ aSz.Width() += aBorder.Left() + aBorder.Right();
+ }
+
+ Size aEditSz( GetEditWin().GetOutputSizePixel() );
+ ViewResizePixel( GetEditWin(), rOfst, aSz, aEditSz, *m_pVScrollbar,
+ *m_pHScrollbar, *m_pScrollFill, m_pVRuler, m_pHRuler,
+ m_pWrtShell->GetViewOptions()->IsVRulerRight());
+ if ( m_bShowAtResize )
+ ShowAtResize();
+
+ if( m_pHRuler->IsVisible() || m_pVRuler->IsVisible() )
+ {
+ const Fraction& rFrac = GetEditWin().GetMapMode().GetScaleX();
+ sal_uInt16 nZoom = 100;
+ if (0 != rFrac.GetDenominator())
+ nZoom = sal_uInt16(rFrac.GetNumerator() * 100L / rFrac.GetDenominator());
+
+ const Fraction aFrac( nZoom, 100 );
+ m_pVRuler->SetZoom( aFrac );
+ m_pHRuler->SetZoom( aFrac );
+ InvalidateRulerPos(); // Invalidate content.
+ }
+ // Reset the cursor stack because the cursor positions for PageUp/Down
+ // no longer fit the currently visible area.
+ m_pWrtShell->ResetCursorStack();
+
+ // EditWin never set!
+
+ // Set VisArea, but do not call the SetVisArea of the Docshell there!
+ bProtectDocShellVisArea = true;
+ CalcVisArea( aEditSz );
+ // Visibility changes of the automatic horizontal scrollbar
+ // require to repeat the ViewResizePixel() call - but only once!
+ if(bRepeat)
+ bRepeat = sal_False;
+ else if(bHScrollVisible != m_pHScrollbar->IsVisible(sal_True) ||
+ bVScrollVisible != m_pVScrollbar->IsVisible(sal_True))
+ bRepeat = sal_True;
+ }while( bRepeat );
+ bProtectDocShellVisArea = false;
+ m_bInInnerResizePixel = sal_False;
+}
+
+void SwView::OuterResizePixel( const Point &rOfst, const Size &rSize )
+{
+ // #i16909# return, if no size (caused by minimize window).
+ if ( m_bInOuterResizePixel || ( !rSize.Width() && !rSize.Height() ) )
+ return;
+ m_bInOuterResizePixel = sal_True;
+
+ // Determine whether scroll bars may be displayed.
+ sal_Bool bShowH = sal_True,
+ bShowV = sal_True,
+ bAuto = sal_True,
+ bHAuto = sal_True;
+
+ const SwViewOption *pVOpt = m_pWrtShell->GetViewOptions();
+ if ( !pVOpt->IsReadonly() || pVOpt->IsStarOneSetting() )
+ {
+ bShowH = pVOpt->IsViewHScrollBar();
+ bShowV = pVOpt->IsViewVScrollBar();
+ }
+
+ if (!m_bHScrollbarEnabled)
+ {
+ bHAuto = bShowH = false;
+ }
+ if (!m_bVScrollbarEnabled)
+ {
+ bAuto = bShowV = false;
+ }
+
+ SwDocShell* pDocSh = GetDocShell();
+ sal_Bool bIsPreview = pDocSh->IsPreview();
+ if( bIsPreview )
+ {
+ bShowH = bShowV = bHAuto = bAuto = sal_False;
+ }
+ if(m_pHScrollbar->IsVisible(sal_False) != bShowH && !bHAuto)
+ ShowHScrollbar(bShowH);
+ m_pHScrollbar->SetAuto( bHAuto );
+ if(m_pVScrollbar->IsVisible(sal_False) != bShowV && !bAuto)
+ ShowVScrollbar(bShowV);
+ m_pVScrollbar->SetAuto(bAuto);
+
+ SET_CURR_SHELL( m_pWrtShell );
+ sal_Bool bRepeat = sal_False;
+ long nCnt = 0;
+
+ sal_Bool bUnLockView = !m_pWrtShell->IsViewLocked();
+ m_pWrtShell->LockView( sal_True );
+ m_pWrtShell->LockPaint();
+
+ do {
+ ++nCnt;
+ const sal_Bool bScroll1 = m_pVScrollbar->IsVisible(sal_True);
+ const sal_Bool bScroll2 = m_pHScrollbar->IsVisible(sal_True);
+ SvBorder aBorder;
+ CalcAndSetBorderPixel( aBorder, sal_False );
+ const Size aEditSz( GetEditWin().GetOutputSizePixel() );
+ ViewResizePixel( GetEditWin(), rOfst, rSize, aEditSz, *m_pVScrollbar,
+ *m_pHScrollbar, *m_pScrollFill, m_pVRuler, m_pHRuler,
+ m_pWrtShell->GetViewOptions()->IsVRulerRight() );
+ if ( m_bShowAtResize )
+ ShowAtResize();
+
+ if( m_pHRuler->IsVisible() || m_pVRuler->IsVisible() )
+ InvalidateRulerPos(); // Invalidate content.
+
+ // Reset the cursor stack because the cursor positions for PageUp/Down
+ // no longer fit the currently visible area.
+ m_pWrtShell->ResetCursorStack();
+
+ OSL_ENSURE( !GetEditWin().IsVisible() ||
+ (( aEditSz.Width() > 0 && aEditSz.Height() > 0 )
+ || !m_aVisArea.IsEmpty()), "Small world, isn't it?" );
+
+ // Never set EditWin!
+
+ // Of course the VisArea must also be set.
+ // Now is the right time to re-calculate the zoom if it is not a simple factor.
+ m_pWrtShell->StartAction();
+ CalcVisArea( aEditSz );
+
+ //Thus also in the outplace editing the page width will be adjusted immediately.
+ //TODO/LATER: is that still necessary?!
+ /*
+ if ( pDocSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
+ pDocSh->SetVisArea(
+ pDocSh->SfxInPlaceObject::GetVisArea() );*/
+ if ( m_pWrtShell->GetViewOptions()->GetZoomType() != SVX_ZOOM_PERCENT &&
+ !m_pWrtShell->GetViewOptions()->getBrowseMode() )
+ _SetZoom( aEditSz, (SvxZoomType)m_pWrtShell->GetViewOptions()->GetZoomType(), 100, sal_True );
+ m_pWrtShell->EndAction();
+
+ bRepeat = bScroll1 != m_pVScrollbar->IsVisible(sal_True);
+ if ( !bRepeat )
+ bRepeat = bScroll2 != m_pHScrollbar->IsVisible(sal_True);
+
+ // Do no infinite loops.
+ // If possible stop when the (auto-) scroll bars are visible.
+ if ( bRepeat &&
+ ( nCnt > 10 || ( nCnt > 3 && bHAuto && bAuto ) )
+ )
+ {
+ bRepeat = sal_False;
+ }
+
+ } while ( bRepeat );
+
+ m_pWrtShell->UnlockPaint();
+ if( bUnLockView )
+ m_pWrtShell->LockView( sal_False );
+
+ m_bInOuterResizePixel = sal_False;
+
+ if ( m_pPostItMgr )
+ {
+ m_pPostItMgr->CalcRects();
+ m_pPostItMgr->LayoutPostIts();
+ }
+}
+
+void SwView::SetZoomFactor( const Fraction &rX, const Fraction &rY )
+{
+ const Fraction &rFrac = rX < rY ? rX : rY;
+ SetZoom( SVX_ZOOM_PERCENT, (short) long(rFrac * Fraction( 100, 1 )) );
+
+ // To minimize rounding errors we also adjust the odd values
+ // of the base class if necessary.
+ SfxViewShell::SetZoomFactor( rX, rY );
+}
+
+sal_Bool SwView::UpdateScrollbars()
+{
+ sal_Bool bRet = sal_False;
+ if ( !m_aVisArea.IsEmpty() )
+ {
+ const bool bBorder = IsDocumentBorder();
+ Rectangle aTmpRect( m_aVisArea );
+ if ( bBorder )
+ {
+ Point aPt( DOCUMENTBORDER, DOCUMENTBORDER );
+ aPt = AlignToPixel( aPt );
+ aTmpRect.Move( -aPt.X(), -aPt.Y() );
+ }
+
+ Size aTmpSz( m_aDocSz );
+ const long lOfst = bBorder ? 0 : DOCUMENTBORDER * 2L;
+ aTmpSz.Width() += lOfst; aTmpSz.Height() += lOfst;
+
+ {
+ const sal_Bool bVScrollVisible = m_pVScrollbar->IsVisible(sal_True);
+ m_pVScrollbar->DocSzChgd( aTmpSz );
+ m_pVScrollbar->ViewPortChgd( aTmpRect );
+ if ( bVScrollVisible != m_pVScrollbar->IsVisible(sal_True) )
+ bRet = sal_True;
+ }
+ {
+ const sal_Bool bHScrollVisible = m_pHScrollbar->IsVisible(sal_True);
+ m_pHScrollbar->DocSzChgd( aTmpSz );
+ m_pHScrollbar->ViewPortChgd( aTmpRect );
+ if ( bHScrollVisible != m_pHScrollbar->IsVisible(sal_True) )
+ bRet = sal_True;
+ m_pScrollFill->Show(m_pHScrollbar->IsVisible(sal_True) && m_pVScrollbar->IsVisible(sal_True) );
+ }
+ }
+ return bRet;
+}
+
+void SwView::Move()
+{
+ if ( GetWrtShell().IsInSelect() )
+ GetWrtShell().EndSelect();
+ SfxViewShell::Move();
+}
+
+sal_Bool SwView::HandleWheelCommands( const CommandEvent& rCEvt )
+{
+ const CommandWheelData* pWData = rCEvt.GetWheelData();
+ if (!pWData)
+ {
+ return sal_False;
+ }
+
+ sal_Bool bOk = sal_False;
+ if( COMMAND_WHEEL_ZOOM == pWData->GetMode() )
+ {
+ long nFact = m_pWrtShell->GetViewOptions()->GetZoom();
+ if( 0L > pWData->GetDelta() )
+ nFact = std::max( (long) 20, basegfx::zoomtools::zoomOut( nFact ));
+ else
+ nFact = std::min( (long) 600, basegfx::zoomtools::zoomIn( nFact ));
+
+ SetZoom( SVX_ZOOM_PERCENT, nFact );
+ bOk = sal_True;
+ }
+ else if( COMMAND_WHEEL_ZOOM_SCALE == pWData->GetMode() )
+ {
+ // mobile touch zoom (pinch) section
+ // remember the center location to reach in logic
+
+ Size winSize = GetViewFrame()->GetWindow().GetOutputSizePixel();
+ Point centerInPixels(winSize.getWidth() / 2, winSize.getHeight() / 2);
+ const Point & preZoomTargetCenterInLogic = GetEditWin().PixelToLogic(centerInPixels);
+
+ double scale = double(pWData->GetDelta()) / double(MOBILE_ZOOM_SCALE_MULTIPLIER);
+
+ int preZoomByVCL = m_pWrtShell->GetViewOptions()->GetZoom();
+
+ // each zooming event is scaling the initial zoom
+ int zoomTarget = int(preZoomByVCL * scale);
+
+ // thresholding the zoom
+ zoomTarget = std::max( MOBILE_MAX_ZOOM_OUT, std::min( MOBILE_MAX_ZOOM_IN, zoomTarget ) );
+
+ // no point zooming if the target zoom is the same as the current zoom
+ if(zoomTarget!=preZoomByVCL)
+ {
+
+ SetZoom( SVX_ZOOM_PERCENT, zoomTarget );
+ }
+ // we move to the center, and add additional tilt from center
+ const Point & postZoomTargetCenterInPixels = GetEditWin().LogicToPixel(preZoomTargetCenterInLogic);
+ long deltaX = rCEvt.GetMousePosPixel().X() + centerInPixels.X() - postZoomTargetCenterInPixels.X();
+ long deltaY = rCEvt.GetMousePosPixel().Y() + centerInPixels.Y() - postZoomTargetCenterInPixels.Y();
+
+ if((deltaX!=0) || (deltaY!=0))
+ {
+
+ // scrolling the deltaX deltaY
+ Point deltaPoint( deltaX, deltaY );
+ CommandWheelData cmd( 0, 0, 0, COMMAND_WHEEL_SCROLL, 0, false, true);
+ CommandEvent event(deltaPoint , COMMAND_WHEEL, true, &cmd );
+ m_pEditWin->HandleScrollCommand(event, m_pHScrollbar, m_pVScrollbar);
+ }
+
+ bOk = sal_True;
+ }
+ else
+ {
+ if( pWData->GetMode()==COMMAND_WHEEL_SCROLL )
+ {
+ // This influences whether quick help is shown
+ m_bWheelScrollInProgress=true;
+ }
+
+ if( (COMMAND_WHEEL_SCROLL==pWData->GetMode()) && (((sal_uLong)0xFFFFFFFF) == pWData->GetScrollLines()) )
+ {
+ if (pWData->GetDelta()<0)
+ PhyPageDown();
+ else
+ PhyPageUp();
+ bOk = sal_True;
+ }
+ else
+ bOk = m_pEditWin->HandleScrollCommand(rCEvt, m_pHScrollbar, m_pVScrollbar);
+
+ // Restore default state for case when scroll command comes from dragging scrollbar handle
+ m_bWheelScrollInProgress=false;
+ }
+ return bOk;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/uiview/viewprt.cxx b/sw/source/core/uibase/uiview/viewprt.cxx
new file mode 100644
index 000000000000..955fb77ec7cd
--- /dev/null
+++ b/sw/source/core/uibase/uiview/viewprt.cxx
@@ -0,0 +1,306 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <com/sun/star/text/NotePrintMode.hpp>
+#include <cstdarg>
+#include <cmdid.h>
+#include <sfx2/request.hxx>
+#include <sfx2/progress.hxx>
+#include <sfx2/app.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/oldprintadaptor.hxx>
+#include <sfx2/printer.hxx>
+#include <sfx2/prnmon.hxx>
+#include <editeng/paperinf.hxx>
+#include <sfx2/dispatch.hxx>
+#include <unotools/misccfg.hxx>
+#include <svx/prtqry.hxx>
+#include <svx/svdview.hxx>
+#include <svl/eitem.hxx>
+#include <svl/stritem.hxx>
+#include <svl/intitem.hxx>
+#include <svl/flagitem.hxx>
+#include <sfx2/linkmgr.hxx>
+
+#include <modcfg.hxx>
+#include <edtwin.hxx>
+#include <view.hxx>
+#include <wrtsh.hxx>
+#include <docsh.hxx>
+#include <viewopt.hxx>
+#include <prtopt.hxx>
+#include <fontcfg.hxx>
+#include <cfgitems.hxx>
+#include <dbmgr.hxx>
+#include <docstat.hxx>
+#include <viewfunc.hxx>
+#include <swmodule.hxx>
+#include <wview.hxx>
+#include <doc.hxx>
+#include <fldbas.hxx>
+
+#include <globals.hrc>
+#include <view.hrc>
+#include <app.hrc>
+#include <swwrtshitem.hxx>
+#include "swabstdlg.hxx"
+#include <svl/slstitm.hxx>
+
+#include <unomid.h>
+
+using namespace ::com::sun::star;
+
+// Hand over the printer to Sfx
+
+SfxPrinter* SwView::GetPrinter( sal_Bool bCreate )
+{
+ const IDocumentDeviceAccess* pIDDA = GetWrtShell().getIDocumentDeviceAccess();
+ SfxPrinter *pOld = pIDDA->getPrinter( false );
+ SfxPrinter *pPrt = pIDDA->getPrinter( bCreate );
+ if ( pOld != pPrt )
+ {
+ sal_Bool bWeb = 0 != PTR_CAST(SwWebView, this);
+ ::SetAppPrintOptions( &GetWrtShell(), bWeb );
+ }
+ return pPrt;
+}
+
+// Propagate printer change
+
+void SetPrinter( IDocumentDeviceAccess* pIDDA, SfxPrinter* pNew, sal_Bool bWeb )
+{
+ SwPrintOptions* pOpt = SW_MOD()->GetPrtOptions(bWeb);
+ if( !pOpt)
+ return;
+
+ // Reading Application own printing options from SfxPrinter
+ const SfxItemSet& rSet = pNew->GetOptions();
+
+ const SwAddPrinterItem* pAddPrinterAttr;
+ if( SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_ADDPRINTER, false,
+ (const SfxPoolItem**)&pAddPrinterAttr ) )
+ {
+ if( pIDDA )
+ pIDDA->setPrintData( *pAddPrinterAttr );
+ if( !pAddPrinterAttr->GetFax().isEmpty() )
+ pOpt->SetFaxName(pAddPrinterAttr->GetFax());
+ }
+}
+
+sal_uInt16 SwView::SetPrinter(SfxPrinter* pNew, sal_uInt16 nDiffFlags, bool )
+{
+ SwWrtShell &rSh = GetWrtShell();
+ SfxPrinter* pOld = rSh.getIDocumentDeviceAccess()->getPrinter( false );
+ if ( pOld && pOld->IsPrinting() )
+ return SFX_PRINTERROR_BUSY;
+
+ if ( (SFX_PRINTER_JOBSETUP | SFX_PRINTER_PRINTER) & nDiffFlags )
+ {
+ rSh.getIDocumentDeviceAccess()->setPrinter( pNew, true, true );
+ if ( nDiffFlags & SFX_PRINTER_PRINTER )
+ rSh.SetModified();
+ }
+ sal_Bool bWeb = 0 != PTR_CAST(SwWebView, this);
+ if ( nDiffFlags & SFX_PRINTER_OPTIONS )
+ ::SetPrinter( rSh.getIDocumentDeviceAccess(), pNew, bWeb );
+
+ const sal_Bool bChgOri = nDiffFlags & SFX_PRINTER_CHG_ORIENTATION ? sal_True : sal_False;
+ const sal_Bool bChgSize= nDiffFlags & SFX_PRINTER_CHG_SIZE ? sal_True : sal_False;
+ if ( bChgOri || bChgSize )
+ {
+ rSh.StartAllAction();
+ if ( bChgOri )
+ rSh.ChgAllPageOrientation( sal_uInt16(pNew->GetOrientation()) );
+ if ( bChgSize )
+ {
+ Size aSz( SvxPaperInfo::GetPaperSize( pNew ) );
+ rSh.ChgAllPageSize( aSz );
+ }
+ rSh.SetModified();
+ rSh.EndAllAction();
+ InvalidateRulerPos();
+ }
+ return 0;
+}
+
+bool SwView::HasPrintOptionsPage() const
+{
+ return true;
+}
+
+// TabPage for application-specific print options
+
+SfxTabPage* SwView::CreatePrintOptionsPage(Window* pParent,
+ const SfxItemSet& rSet)
+{
+ return ::CreatePrintOptionsPage( pParent, rSet, sal_False );
+}
+
+// Print dispatcher
+
+void SwView::ExecutePrint(SfxRequest& rReq)
+{
+ sal_Bool bWeb = 0 != PTR_CAST(SwWebView, this);
+ ::SetAppPrintOptions( &GetWrtShell(), bWeb );
+ switch (rReq.GetSlot())
+ {
+ case FN_FAX:
+ {
+ SwPrintOptions* pPrintOptions = SW_MOD()->GetPrtOptions(bWeb);
+ OUString sFaxName(pPrintOptions->GetFaxName());
+ if (!sFaxName.isEmpty())
+ {
+ SfxStringItem aPrinterName(SID_PRINTER_NAME, sFaxName);
+ SfxBoolItem aSilent( SID_SILENT, true );
+ GetViewFrame()->GetDispatcher()->Execute( SID_PRINTDOC,
+ SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD,
+ &aPrinterName, &aSilent, 0L );
+ }
+ else
+ {
+ InfoBox aInfoBox(&GetEditWin(), SW_RES(MSG_ERR_NO_FAX));
+ OUString sMsg = aInfoBox.GetMessText();
+ sal_uInt16 nResNo = bWeb ? STR_WEBOPTIONS : STR_TEXTOPTIONS;
+ sMsg = sMsg.replaceFirst("%1", OUString(SW_RES(nResNo)));
+ aInfoBox.SetMessText(sMsg);
+ aInfoBox.Execute();
+ SfxUInt16Item aDefPage(SID_SW_EDITOPTIONS, TP_OPTPRINT_PAGE);
+ GetViewFrame()->GetDispatcher()->Execute(SID_SW_EDITOPTIONS,
+ SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD,
+ &aDefPage, 0L );
+ }
+ }
+ break;
+ case SID_PRINTDOC:
+ case SID_PRINTDOCDIRECT:
+ {
+ SwWrtShell* pSh = &GetWrtShell();
+ SFX_REQUEST_ARG(rReq, pSilentItem, SfxBoolItem, SID_SILENT, false);
+ sal_Bool bSilent = pSilentItem ? pSilentItem->GetValue() : sal_False;
+ SFX_REQUEST_ARG(rReq, pPrintFromMergeItem, SfxBoolItem, FN_QRY_MERGE, false);
+ if(pPrintFromMergeItem)
+ rReq.RemoveItem(FN_QRY_MERGE);
+ sal_Bool bFromMerge = pPrintFromMergeItem ? pPrintFromMergeItem->GetValue() : sal_False;
+ SwMiscConfig aMiscConfig;
+ bool bPrintSelection = false;
+ if(!bSilent && !bFromMerge &&
+ SW_MOD()->GetModuleConfig()->IsAskForMailMerge() && pSh->IsAnyDatabaseFieldInDoc())
+ {
+ QueryBox aBox( &GetEditWin(), SW_RES( MSG_PRINT_AS_MERGE ));
+ short nRet = aBox.Execute();
+ if(RET_YES == nRet)
+ {
+ SfxBoolItem aBool(FN_QRY_MERGE, true);
+ GetViewFrame()->GetDispatcher()->Execute(
+ FN_QRY_MERGE, SFX_CALLMODE_ASYNCHRON, &aBool, 0L);
+ rReq.Ignore();
+ return;
+ }
+ }
+ else if( rReq.GetSlot() == SID_PRINTDOCDIRECT && ! bSilent )
+ {
+ if( ( pSh->IsSelection() || pSh->IsFrmSelected() || pSh->IsObjSelected() ) )
+ {
+ short nBtn = SvxPrtQryBox(&GetEditWin()).Execute();
+ if( RET_CANCEL == nBtn )
+ return;
+
+ if( RET_OK == nBtn )
+ bPrintSelection = true;
+ }
+ }
+
+ //#i61455# if master documentes are printed silently without loaded links then update the links now
+ if( bSilent && pSh->IsGlobalDoc() && !pSh->IsGlblDocSaveLinks() )
+ {
+ pSh->GetLinkManager().UpdateAllLinks( false, false, false, 0 );
+ }
+ SfxRequest aReq( rReq );
+ SfxBoolItem aBool(SID_SELECTION, bPrintSelection);
+ aReq.AppendItem( aBool );
+ SfxViewShell::ExecuteSlot( aReq, SfxViewShell::GetInterface() );
+ return;
+ }
+ default:
+ OSL_ENSURE(!this, "wrong dispatcher");
+ return;
+ }
+}
+
+// Create page printer/additions for SwView and SwPagePreview
+
+SfxTabPage* CreatePrintOptionsPage( Window *pParent,
+ const SfxItemSet &rOptions, sal_Bool bPreview )
+{
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "No Print Dialog");
+ if (!pFact)
+ return NULL;
+
+ ::CreateTabPage fnCreatePage = pFact->GetTabPageCreatorFunc(TP_OPTPRINT_PAGE);
+ OSL_ENSURE(pFact, "No Page Creator");
+ if (!fnCreatePage)
+ return NULL;
+
+ SfxTabPage* pPage = (*fnCreatePage)(pParent, rOptions);
+ OSL_ENSURE(pPage, "No page");
+ if (!pPage)
+ return NULL;
+
+ SfxAllItemSet aSet(*(rOptions.GetPool()));
+ aSet.Put(SfxBoolItem(SID_PREVIEWFLAG_TYPE, bPreview));
+ aSet.Put(SfxBoolItem(SID_FAX_LIST, true));
+ pPage->PageCreated(aSet);
+ return pPage;
+}
+
+void SetAppPrintOptions( SwViewShell* pSh, sal_Bool bWeb )
+{
+ const IDocumentDeviceAccess* pIDDA = pSh->getIDocumentDeviceAccess();
+ SwPrintData aPrtData = pIDDA->getPrintData();
+
+ if( pIDDA->getPrinter( false ) )
+ {
+ // Close application own printing options in SfxPrinter.
+ SwAddPrinterItem aAddPrinterItem (FN_PARAM_ADDPRINTER, aPrtData);
+ SfxItemSet aSet( pSh->GetAttrPool(),
+ FN_PARAM_ADDPRINTER, FN_PARAM_ADDPRINTER,
+ SID_HTML_MODE, SID_HTML_MODE,
+ SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN,
+ SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC,
+ 0 );
+
+ utl::MiscCfg aMisc;
+
+ if(bWeb)
+ aSet.Put(SfxUInt16Item(SID_HTML_MODE,
+ ::GetHtmlMode(((SwWrtShell*)pSh)->GetView().GetDocShell())));
+ aSet.Put(SfxBoolItem(SID_PRINTER_NOTFOUND_WARN,
+ aMisc.IsNotFoundWarning() ));
+ aSet.Put(aAddPrinterItem);
+ aSet.Put( SfxFlagItem( SID_PRINTER_CHANGESTODOC,
+ (aMisc.IsPaperSizeWarning() ? SFX_PRINTER_CHG_SIZE : 0) |
+ (aMisc.IsPaperOrientationWarning() ? SFX_PRINTER_CHG_ORIENTATION : 0 )));
+
+ pIDDA->getPrinter( true )->SetOptions( aSet );
+ }
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/uiview/viewsrch.cxx b/sw/source/core/uibase/uiview/viewsrch.cxx
new file mode 100644
index 000000000000..5a1e30fd6d69
--- /dev/null
+++ b/sw/source/core/uibase/uiview/viewsrch.cxx
@@ -0,0 +1,814 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <string>
+
+#include <boost/scoped_ptr.hpp>
+
+#include <hintids.hxx>
+
+#include <com/sun/star/util/SearchOptions.hpp>
+#include <svl/cjkoptions.hxx>
+#include <svl/ctloptions.hxx>
+#include <svx/pageitem.hxx>
+#include <svl/whiter.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svl/stritem.hxx>
+#include <unotools/textsearch.hxx>
+#include <svl/itempool.hxx>
+#include <svl/eitem.hxx>
+#include <svl/srchitem.hxx>
+#include <sal/macros.h>
+#include <sfx2/request.hxx>
+#include <svx/srchdlg.hxx>
+#include <svx/dialmgr.hxx>
+#include <svx/dialogs.hrc>
+#include <vcl/layout.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/wrkwin.hxx>
+#include "editeng/unolingu.hxx"
+#include <swmodule.hxx>
+#include <swwait.hxx>
+#include <workctrl.hxx>
+#include <view.hxx>
+#include <wrtsh.hxx>
+#include <swundo.hxx>
+#include <uitool.hxx>
+#include <cmdid.h>
+#include <docsh.hxx>
+#include <doc.hxx>
+#include <unocrsr.hxx>
+
+#include <view.hrc>
+#include <SwRewriter.hxx>
+#include <comcore.hrc>
+
+#include "PostItMgr.hxx"
+
+using namespace com::sun::star;
+using namespace ::com::sun::star::i18n;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::util;
+
+//Search Parameter
+
+struct SwSearchOptions
+{
+ SwDocPositions eStart, eEnd;
+ sal_Bool bDontWrap;
+
+ SwSearchOptions( SwWrtShell* pSh, sal_Bool bBackward );
+};
+
+static Window* GetParentWindow( SvxSearchDialog* pSrchDlg )
+{
+ return pSrchDlg && pSrchDlg->IsVisible() ? pSrchDlg : 0;
+}
+
+void SwView::ExecSearch(SfxRequest& rReq, sal_Bool bNoMessage)
+{
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ const SfxPoolItem* pItem = 0;
+ sal_Bool bQuiet = sal_False;
+ if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(SID_SEARCH_QUIET, false, &pItem))
+ bQuiet = ((const SfxBoolItem*) pItem)->GetValue();
+
+ sal_Bool bApi = bQuiet | bNoMessage;
+
+ sal_uInt16 nSlot = rReq.GetSlot();
+ if (nSlot == FN_REPEAT_SEARCH && !m_pSrchItem)
+ {
+ if(bApi)
+ {
+ rReq.SetReturnValue(SfxBoolItem(nSlot, false));
+ nSlot = 0;
+ }
+ }
+ if( m_pWrtShell->IsBlockMode() )
+ m_pWrtShell->LeaveBlockMode();
+ switch (nSlot)
+ {
+ // for now do nothing
+ case SID_SEARCH_ITEM:
+ {
+ delete m_pSrchItem;
+ m_pSrchItem = (SvxSearchItem*) pArgs->Get(SID_SEARCH_ITEM).Clone();
+ }
+ break;
+
+ case FID_SEARCH_ON:
+ m_bJustOpened = true;
+ GetViewFrame()->GetBindings().Invalidate(SID_SEARCH_ITEM);
+ break;
+
+ case FID_SEARCH_OFF:
+ if(pArgs)
+ {
+ // Unregister dialog
+ delete m_pSrchItem;
+ m_pSrchItem = (SvxSearchItem*) pArgs->Get(SID_SEARCH_ITEM).Clone();
+
+ DELETEZ( m_pSrchList );
+ DELETEZ( m_pReplList );
+
+ m_pSrchDlg = GetSearchDialog();
+ if (m_pSrchDlg)
+ {
+ // We will remember the search-/replace items.
+ const SearchAttrItemList* pList = m_pSrchDlg->GetSearchItemList();
+ if( pList && pList->Count() )
+ m_pSrchList = new SearchAttrItemList( *pList );
+
+ if( 0 != (pList = m_pSrchDlg->GetReplaceItemList() ) &&
+ pList->Count() )
+ m_pReplList = new SearchAttrItemList( *pList );
+ }
+ }
+ break;
+
+ case FN_REPEAT_SEARCH:
+ case FID_SEARCH_NOW:
+ {
+ {
+ if(FID_SEARCH_NOW == nSlot && !rReq.IsAPI())
+ SwView::SetMoveType(NID_SRCH_REP);
+ }
+
+ m_pSrchDlg = GetSearchDialog();
+ if (m_pSrchDlg)
+ {
+ DELETEZ( m_pSrchList );
+ DELETEZ( m_pReplList );
+
+ const SearchAttrItemList* pList = m_pSrchDlg->GetSearchItemList();
+ if( pList && pList->Count() )
+ m_pSrchList = new SearchAttrItemList( *pList );
+
+ if( 0 != (pList = m_pSrchDlg->GetReplaceItemList() ) &&
+ pList->Count() )
+ m_pReplList = new SearchAttrItemList( *pList );
+ }
+
+ if (nSlot == FN_REPEAT_SEARCH)
+ {
+ OSL_ENSURE(m_pSrchItem, "SearchItem missing");
+ if( !m_pSrchItem )
+ m_pSrchItem = new SvxSearchItem(SID_SEARCH_ITEM);
+ }
+ else
+ {
+ // Get SearchItem from request
+ OSL_ENSURE(pArgs, "Args missing");
+ if ( pArgs )
+ {
+ delete m_pSrchItem;
+ m_pSrchItem = (SvxSearchItem*) pArgs->Get(SID_SEARCH_ITEM).Clone();
+ }
+ }
+ switch (m_pSrchItem->GetCommand())
+ {
+ case SVX_SEARCHCMD_FIND:
+ {
+ sal_Bool bRet = SearchAndWrap(bApi);
+ if( bRet )
+ Scroll(m_pWrtShell->GetCharRect().SVRect());
+ rReq.SetReturnValue(SfxBoolItem(nSlot, bRet));
+ {
+ const sal_uInt16 nChildId = SvxSearchDialogWrapper::GetChildWindowId();
+ SvxSearchDialogWrapper *pDlgWrp = (SvxSearchDialogWrapper*)GetViewFrame()->GetChildWindow(nChildId);
+ if ( pDlgWrp )
+ {
+ m_pSrchDlg = (SvxSearchDialog*)(pDlgWrp->GetWindow());
+ m_pSrchDlg->SetDocWin( (Window*)m_pEditWin);
+ m_pSrchDlg->SetSrchFlag();
+ }
+ }
+ }
+ break;
+ case SVX_SEARCHCMD_FIND_ALL:
+ {
+ sal_Bool bRet = SearchAll();
+ if( !bRet )
+ {
+ if( !bApi )
+ SvxSearchDialogWrapper::SetSearchLabel(SL_NotFound);
+ m_bFound = sal_False;
+ }
+ rReq.SetReturnValue(SfxBoolItem(nSlot, bRet));
+ {
+ const sal_uInt16 nChildId = SvxSearchDialogWrapper::GetChildWindowId();
+ SvxSearchDialogWrapper *pDlgWrp = (SvxSearchDialogWrapper*)GetViewFrame()->GetChildWindow(nChildId);
+
+ if ( pDlgWrp )
+ {
+ m_pSrchDlg = (SvxSearchDialog*)(pDlgWrp->GetWindow());
+ m_pSrchDlg->SetDocWin( (Window*)m_pEditWin);
+ m_pSrchDlg->SetSrchFlag();
+ }
+ }
+ }
+ break;
+ case SVX_SEARCHCMD_REPLACE:
+ {
+
+ // 1) Replace selection (Not if only attributes should be replaced)
+//JP 27.04.95: Why ?
+// what if you only want to assign attributes to the found??
+
+ sal_uInt16 nCmd = SVX_SEARCHCMD_FIND;
+ if( !m_pSrchItem->GetReplaceString().isEmpty() ||
+ !m_pReplList )
+ {
+ // Prevent, that the replaced string will be found again
+ // if the replacement string is containing the search string.
+ sal_Bool bBack = m_pSrchItem->GetBackward();
+ if (bBack)
+ m_pWrtShell->Push();
+ OUString aReplace( m_pSrchItem->GetReplaceString() );
+ SearchOptions aTmp( m_pSrchItem->GetSearchOptions() );
+ OUString *pBackRef = ReplaceBackReferences( aTmp, m_pWrtShell->GetCrsr() );
+ if( pBackRef )
+ m_pSrchItem->SetReplaceString( *pBackRef );
+ Replace();
+ if( pBackRef )
+ {
+ m_pSrchItem->SetReplaceString( aReplace );
+ delete pBackRef;
+ }
+ if (bBack)
+ {
+ m_pWrtShell->Pop();
+ m_pWrtShell->SwapPam();
+ }
+ }
+ else if( m_pReplList )
+ nCmd = SVX_SEARCHCMD_REPLACE;
+
+ // 2) Search further (without replacing!)
+
+ sal_uInt16 nOldCmd = m_pSrchItem->GetCommand();
+ m_pSrchItem->SetCommand( nCmd );
+ sal_Bool bRet = SearchAndWrap(bApi);
+ if( bRet )
+ Scroll( m_pWrtShell->GetCharRect().SVRect());
+ m_pSrchItem->SetCommand( nOldCmd );
+ rReq.SetReturnValue(SfxBoolItem(nSlot, bRet));
+ }
+ {
+ const sal_uInt16 nChildId = SvxSearchDialogWrapper::GetChildWindowId();
+ SvxSearchDialogWrapper *pDlgWrp = (SvxSearchDialogWrapper*)GetViewFrame()->GetChildWindow(nChildId);
+
+ if ( pDlgWrp )
+ {
+ m_pSrchDlg = (SvxSearchDialog*)(pDlgWrp->GetWindow());
+ m_pSrchDlg->SetDocWin( (Window*)m_pEditWin);
+ m_pSrchDlg->SetSrchFlag();
+ }
+ }
+ break;
+
+ case SVX_SEARCHCMD_REPLACE_ALL:
+ {
+ SwSearchOptions aOpts( m_pWrtShell, m_pSrchItem->GetBackward() );
+ m_bExtra = false;
+ sal_uLong nFound;
+
+ { //Scope for SwWait-Object
+ SwWait aWait( *GetDocShell(), true );
+ m_pWrtShell->StartAllAction();
+ if (!m_pSrchItem->GetSelection())
+ {
+ // if we don't want to search in the selection...
+ m_pWrtShell->KillSelection(0, false);
+ // i#8288 "replace all" should not change cursor
+ // position, so save current cursor
+ m_pWrtShell->Push();
+ if (DOCPOS_START == aOpts.eEnd)
+ {
+ m_pWrtShell->EndDoc();
+ }
+ else
+ {
+ m_pWrtShell->SttDoc();
+ }
+ }
+ nFound = FUNC_Search( aOpts );
+ if (!m_pSrchItem->GetSelection())
+ {
+ // create it just to overwrite it with stack cursor
+ m_pWrtShell->CreateCrsr();
+ // i#8288 restore the original cursor position
+ m_pWrtShell->Pop(false);
+ }
+ m_pWrtShell->EndAllAction();
+ }
+
+ rReq.SetReturnValue(SfxBoolItem(nSlot, nFound != 0 && ULONG_MAX != nFound));
+ if( !nFound )
+ {
+ if( !bApi )
+ SvxSearchDialogWrapper::SetSearchLabel(SL_NotFound);
+ m_bFound = sal_False;
+ return;
+ }
+
+ if( !bApi && ULONG_MAX != nFound)
+ {
+ OUString aText( SW_RES( STR_NB_REPLACED ) );
+ aText = aText.replaceFirst("XX", OUString::number( nFound ));
+ Window* pParentWindow = GetParentWindow( m_pSrchDlg );
+ InfoBox( pParentWindow, aText ).Execute();
+ }
+ }
+ const sal_uInt16 nChildId = SvxSearchDialogWrapper::GetChildWindowId();
+ SvxSearchDialogWrapper *pDlgWrp = (SvxSearchDialogWrapper*)GetViewFrame()->GetChildWindow(nChildId);
+
+ if ( pDlgWrp )
+ {
+ m_pSrchDlg = (SvxSearchDialog*)(pDlgWrp->GetWindow());
+ m_pSrchDlg->SetDocWin( (Window*)m_pEditWin);
+ m_pSrchDlg->SetSrchFlag();
+ }
+ break;
+ }
+
+ uno::Reference< frame::XDispatchRecorder > xRecorder =
+ GetViewFrame()->GetBindings().GetRecorder();
+ //prevent additional dialogs in recorded macros
+ if ( xRecorder.is() )
+ rReq.AppendItem(SfxBoolItem(SID_SEARCH_QUIET, true));
+
+ rReq.Done();
+ }
+ break;
+ case FID_SEARCH_SEARCHSET:
+ case FID_SEARCH_REPLACESET:
+ {
+ static const sal_uInt16 aNormalAttr[] =
+ {
+/* 0 */ RES_CHRATR_CASEMAP, RES_CHRATR_CASEMAP,
+/* 2 */ RES_CHRATR_COLOR, RES_CHRATR_POSTURE,
+/* 4 */ RES_CHRATR_SHADOWED, RES_CHRATR_WORDLINEMODE,
+/* 6 */ RES_CHRATR_BLINK, RES_CHRATR_BLINK,
+/* 8 */ RES_CHRATR_BACKGROUND, RES_CHRATR_BACKGROUND,
+/*10 */ RES_CHRATR_ROTATE, RES_CHRATR_ROTATE,
+/*12 */ RES_CHRATR_SCALEW, RES_CHRATR_RELIEF,
+// insert position for CJK/CTL attributes!
+/*14 */ RES_PARATR_LINESPACING, RES_PARATR_HYPHENZONE,
+/*16 */ RES_PARATR_REGISTER, RES_PARATR_REGISTER,
+/*18 */ RES_PARATR_VERTALIGN, RES_PARATR_VERTALIGN,
+/*20 */ RES_LR_SPACE, RES_UL_SPACE,
+/*22 */ SID_ATTR_PARA_MODEL, SID_ATTR_PARA_KEEP,
+/*24 */ 0
+ };
+
+ static const sal_uInt16 aCJKAttr[] =
+ {
+ RES_CHRATR_CJK_FONT, RES_CHRATR_CJK_WEIGHT,
+ RES_CHRATR_EMPHASIS_MARK, RES_CHRATR_TWO_LINES,
+ RES_PARATR_SCRIPTSPACE, RES_PARATR_FORBIDDEN_RULES
+ };
+ static const sal_uInt16 aCTLAttr[] =
+ {
+ RES_CHRATR_CTL_FONT, RES_CHRATR_CTL_WEIGHT
+ };
+
+ std::vector<sal_uInt16> aArr;
+ aArr.insert( aArr.begin(), aNormalAttr,
+ aNormalAttr + SAL_N_ELEMENTS( aNormalAttr ));
+ if( SW_MOD()->GetCTLOptions().IsCTLFontEnabled() )
+ {
+ aArr.insert( aArr.begin() + 14, aCTLAttr,
+ aCTLAttr + SAL_N_ELEMENTS( aCTLAttr ));
+ }
+ SvtCJKOptions aCJKOpt;
+ if( aCJKOpt.IsAnyEnabled() )
+ {
+ aArr.insert( aArr.begin() + 14, aCJKAttr,
+ aCJKAttr + SAL_N_ELEMENTS( aCJKAttr ));
+ }
+
+ SfxItemSet aSet( m_pWrtShell->GetAttrPool(), &aArr[0] );
+ sal_uInt16 nWhich = SID_SEARCH_SEARCHSET;
+
+ if ( FID_SEARCH_REPLACESET == nSlot )
+ {
+ nWhich = SID_SEARCH_REPLACESET;
+
+ if ( m_pReplList )
+ {
+ m_pReplList->Get( aSet );
+ DELETEZ( m_pReplList );
+ }
+ }
+ else if ( m_pSrchList )
+ {
+ m_pSrchList->Get( aSet );
+ DELETEZ( m_pSrchList );
+ }
+ rReq.SetReturnValue( SvxSetItem( nWhich, aSet ) );
+ }
+ break;
+ default:
+#if OSL_DEBUG_LEVEL > 1
+ if(nSlot)
+ {
+ OString sStr("nSlot: " + OString::number(nSlot) + " wrong Dispatcher (viewsrch.cxx)");
+ OSL_FAIL(sStr.getStr());
+ }
+#endif
+ return;
+ }
+}
+
+sal_Bool SwView::SearchAndWrap(sal_Bool bApi)
+{
+ SwSearchOptions aOpts( m_pWrtShell, m_pSrchItem->GetBackward() );
+
+ // Remember starting position of the search for wraparound
+ // Start- / EndAction perhaps because existing selections of 'search all'
+ m_pWrtShell->StartAllAction();
+ m_pWrtShell->Push();
+
+ // fdo#65014 : Ensure that the point of the cursor is at the extremity of the
+ // selection closest to the end being searched to as to exclude the selected
+ // region from the search. (This doesn't work in the case of multiple
+ // selected regions as the cursor doesn't mark the selection in that case.)
+ m_pWrtShell->GetCrsr()->Normalize( m_pSrchItem->GetBackward() );
+
+ // If you want to search in selected areas, they must not be unselected.
+ if (!m_pSrchItem->GetSelection())
+ m_pWrtShell->KillSelection(0, false);
+
+ boost::scoped_ptr<SwWait> pWait(new SwWait( *GetDocShell(), true ));
+ if( FUNC_Search( aOpts ) )
+ {
+ m_bFound = sal_True;
+ if(m_pWrtShell->IsSelFrmMode())
+ {
+ m_pWrtShell->UnSelectFrm();
+ m_pWrtShell->LeaveSelFrmMode();
+ }
+ m_pWrtShell->Pop();
+ m_pWrtShell->EndAllAction();
+ return sal_True;
+ }
+ pWait.reset();
+
+ // Search in the specialized areas when no search is present in selections.
+ // When searching selections will already searched in these special areas.
+ bool bHasSrchInOther = m_bExtra;
+ if (!m_pSrchItem->GetSelection() && !m_bExtra )
+ {
+ m_bExtra = true;
+ if( FUNC_Search( aOpts ) )
+ {
+ m_bFound = sal_True;
+ m_pWrtShell->Pop();
+ m_pWrtShell->EndAllAction();
+ return sal_True;
+ }
+ m_bExtra = false;
+ }
+ else
+ m_bExtra = !m_bExtra;
+
+ // If starting position is at the end or beginning of the document.
+ if (aOpts.bDontWrap)
+ {
+ m_pWrtShell->EndAllAction();
+ if( !bApi )
+ SvxSearchDialogWrapper::SetSearchLabel(SL_NotFound);
+ m_bFound = sal_False;
+ m_pWrtShell->Pop();
+ return sal_False;
+ }
+ m_pWrtShell->EndAllAction();
+ // Try again with WrapAround?
+
+ m_pWrtShell->StartAllAction();
+ m_pWrtShell->Pop(sal_False);
+ pWait.reset(new SwWait( *GetDocShell(), true ));
+
+ bool bSrchBkwrd = DOCPOS_START == aOpts.eEnd;
+
+ aOpts.eEnd = bSrchBkwrd ? DOCPOS_START : DOCPOS_END;
+ aOpts.eStart = bSrchBkwrd ? DOCPOS_END : DOCPOS_START;
+
+ if (bHasSrchInOther)
+ {
+ m_pWrtShell->ClearMark();
+ if (bSrchBkwrd)
+ m_pWrtShell->EndDoc();
+ else
+ m_pWrtShell->SttDoc();
+ }
+
+ m_bFound = bool(FUNC_Search( aOpts ));
+ m_pWrtShell->EndAllAction();
+ pWait.reset();
+
+ if (m_bFound)
+ SvxSearchDialogWrapper::SetSearchLabel(SL_End);
+ else if(!bApi)
+ SvxSearchDialogWrapper::SetSearchLabel(SL_NotFound);
+ return m_bFound;
+}
+
+sal_Bool SwView::SearchAll(sal_uInt16* pFound)
+{
+ SwWait aWait( *GetDocShell(), true );
+ m_pWrtShell->StartAllAction();
+
+ SwSearchOptions aOpts( m_pWrtShell, m_pSrchItem->GetBackward() );
+
+ if (!m_pSrchItem->GetSelection())
+ {
+ // Cancel existing selections, if should not be sought in selected areas.
+ m_pWrtShell->KillSelection(0, false);
+
+ if( DOCPOS_START == aOpts.eEnd )
+ m_pWrtShell->EndDoc();
+ else
+ m_pWrtShell->SttDoc();
+ }
+ m_bExtra = false;
+ sal_uInt16 nFound = (sal_uInt16)FUNC_Search( aOpts );
+ if(pFound)
+ *pFound = nFound;
+ m_bFound = 0 != nFound;
+
+ m_pWrtShell->EndAllAction();
+ return m_bFound;
+}
+
+void SwView::Replace()
+{
+ SwWait aWait( *GetDocShell(), true );
+
+ m_pWrtShell->StartAllAction();
+
+ if( m_pSrchItem->GetPattern() ) // Templates?
+ {
+ SwRewriter aRewriter;
+ aRewriter.AddRule(UndoArg1, m_pSrchItem->GetSearchString());
+ aRewriter.AddRule(UndoArg2, SW_RESSTR(STR_YIELDS));
+ aRewriter.AddRule(UndoArg3, m_pSrchItem->GetReplaceString());
+
+ m_pWrtShell->StartUndo(UNDO_UI_REPLACE_STYLE, &aRewriter);
+
+ m_pWrtShell->SetTxtFmtColl( m_pWrtShell->GetParaStyle(
+ m_pSrchItem->GetReplaceString(),
+ SwWrtShell::GETSTYLE_CREATESOME ));
+
+ m_pWrtShell->EndUndo();
+ }
+ else
+ {
+ if (GetPostItMgr()->HasActiveSidebarWin())
+ GetPostItMgr()->Replace(m_pSrchItem);
+
+ sal_Bool bReqReplace = true;
+
+ if(m_pWrtShell->HasSelection())
+ {
+ /* check that the selection match the search string*/
+ //save state
+ SwPosition aStartPos = (* m_pWrtShell->GetSwCrsr()->Start());
+ SwPosition aEndPos = (* m_pWrtShell->GetSwCrsr()->End());
+ sal_Bool bHasSelection = m_pSrchItem->GetSelection();
+ sal_uInt16 nOldCmd = m_pSrchItem->GetCommand();
+
+ //set state for checking if current selection has a match
+ m_pSrchItem->SetCommand( SVX_SEARCHCMD_FIND );
+ m_pSrchItem->SetSelection(true);
+
+ //check if it matchs
+ SwSearchOptions aOpts( m_pWrtShell, m_pSrchItem->GetBackward() );
+ if( ! FUNC_Search(aOpts) )
+ {
+
+ //no matching therefore should not replace selection
+ // => remove selection
+
+ if(! m_pSrchItem->GetBackward() )
+ {
+ (* m_pWrtShell->GetSwCrsr()->Start()) = aStartPos;
+ (* m_pWrtShell->GetSwCrsr()->End()) = aEndPos;
+ }
+ else
+ {
+ (* m_pWrtShell->GetSwCrsr()->Start()) = aEndPos;
+ (* m_pWrtShell->GetSwCrsr()->End()) = aStartPos;
+ }
+ bReqReplace = false;
+ }
+
+ //set back old search state
+ m_pSrchItem->SetCommand( nOldCmd );
+ m_pSrchItem->SetSelection(bHasSelection);
+ }
+ /*
+ * remove current selection
+ * otherwise it is always replaced
+ * no matter if the search string exists or not in the selection
+ * Now the selection is removed and the next matching string is selected
+ */
+
+ if( bReqReplace )
+ {
+
+ sal_Bool bReplaced = m_pWrtShell->SwEditShell::Replace( m_pSrchItem->GetReplaceString(),
+ m_pSrchItem->GetRegExp());
+ if( bReplaced && m_pReplList && m_pReplList->Count() && m_pWrtShell->HasSelection() )
+ {
+ SfxItemSet aReplSet( m_pWrtShell->GetAttrPool(),
+ aTxtFmtCollSetRange );
+ if( m_pReplList->Get( aReplSet ).Count() )
+ {
+ ::SfxToSwPageDescAttr( *m_pWrtShell, aReplSet );
+ m_pWrtShell->SwEditShell::SetAttrSet( aReplSet );
+ }
+ }
+ }
+ }
+
+ m_pWrtShell->EndAllAction();
+}
+
+SwSearchOptions::SwSearchOptions( SwWrtShell* pSh, sal_Bool bBackward )
+{
+ eStart = DOCPOS_CURR;
+ if( bBackward )
+ {
+ eEnd = DOCPOS_START;
+ bDontWrap = pSh->IsEndOfDoc();
+ }
+ else
+ {
+ eEnd = DOCPOS_END;
+ bDontWrap = pSh->IsStartOfDoc();
+ }
+}
+
+sal_uLong SwView::FUNC_Search( const SwSearchOptions& rOptions )
+{
+ SvxSearchDialogWrapper::SetSearchLabel(SL_Empty);
+
+ sal_Bool bDoReplace = m_pSrchItem->GetCommand() == SVX_SEARCHCMD_REPLACE ||
+ m_pSrchItem->GetCommand() == SVX_SEARCHCMD_REPLACE_ALL;
+
+ int eRanges = m_pSrchItem->GetSelection() ?
+ FND_IN_SEL : m_bExtra ? FND_IN_OTHER : FND_IN_BODY;
+ if (m_pSrchItem->GetCommand() == SVX_SEARCHCMD_FIND_ALL ||
+ m_pSrchItem->GetCommand() == SVX_SEARCHCMD_REPLACE_ALL)
+ eRanges |= FND_IN_SELALL;
+
+ m_pWrtShell->SttSelect();
+
+ static const sal_uInt16 aSearchAttrRange[] = {
+ RES_FRMATR_BEGIN, RES_FRMATR_END-1,
+ RES_CHRATR_BEGIN, RES_CHRATR_END-1,
+ RES_PARATR_BEGIN, RES_PARATR_END-1,
+ SID_ATTR_PARA_MODEL, SID_ATTR_PARA_KEEP,
+ 0 };
+
+ SfxItemSet aSrchSet( m_pWrtShell->GetAttrPool(), aSearchAttrRange);
+ if( m_pSrchList && m_pSrchList->Count() )
+ {
+ m_pSrchList->Get( aSrchSet );
+
+ // -- Page break with page template
+ ::SfxToSwPageDescAttr( *m_pWrtShell, aSrchSet );
+ }
+
+ SfxItemSet* pReplSet = 0;
+ if( bDoReplace && m_pReplList && m_pReplList->Count() )
+ {
+ pReplSet = new SfxItemSet( m_pWrtShell->GetAttrPool(),
+ aSearchAttrRange );
+ m_pReplList->Get( *pReplSet );
+
+ // -- Page break with page template
+ ::SfxToSwPageDescAttr( *m_pWrtShell, *pReplSet );
+
+ if( !pReplSet->Count() ) // too bad, we don't know
+ DELETEZ( pReplSet ); // the attributes
+ }
+
+ // build SearchOptions to be used
+
+ SearchOptions aSearchOpt( m_pSrchItem->GetSearchOptions() );
+ aSearchOpt.Locale = GetAppLanguageTag().getLocale();
+ if( !bDoReplace )
+ aSearchOpt.replaceString = OUString();
+
+ sal_uLong nFound;
+ if( aSrchSet.Count() || ( pReplSet && pReplSet->Count() ))
+ {
+ nFound = m_pWrtShell->SearchAttr(
+ aSrchSet,
+ !m_pSrchItem->GetPattern(),
+ rOptions.eStart,
+ rOptions.eEnd,
+ FindRanges(eRanges),
+ !m_pSrchItem->GetSearchString().isEmpty() ? &aSearchOpt : 0,
+ pReplSet );
+ }
+ else if( m_pSrchItem->GetPattern() )
+ {
+ // Searching (and replacing) templates
+ const OUString sRplStr( m_pSrchItem->GetReplaceString() );
+ nFound = m_pWrtShell->SearchTempl( m_pSrchItem->GetSearchString(),
+ rOptions.eStart,
+ rOptions.eEnd,
+ FindRanges(eRanges),
+ bDoReplace ? &sRplStr : 0 );
+ }
+ else
+ {
+ // Normal search
+ nFound = m_pWrtShell->SearchPattern(aSearchOpt, m_pSrchItem->GetNotes(),
+ rOptions.eStart,
+ rOptions.eEnd,
+ FindRanges(eRanges),
+ bDoReplace );
+ }
+ m_pWrtShell->EndSelect();
+ return nFound;
+}
+
+SvxSearchDialog* SwView::GetSearchDialog()
+{
+ const sal_uInt16 nId = SvxSearchDialogWrapper::GetChildWindowId();
+ SvxSearchDialogWrapper *pWrp = (SvxSearchDialogWrapper*) SfxViewFrame::Current()->GetChildWindow(nId);
+ m_pSrchDlg = pWrp ? pWrp->getDialog () : 0;
+ return m_pSrchDlg;
+}
+
+void SwView::StateSearch(SfxItemSet &rSet)
+{
+ SfxWhichIter aIter(rSet);
+ sal_uInt16 nWhich = aIter.FirstWhich();
+
+ while(nWhich)
+ {
+ switch(nWhich)
+ {
+ case SID_SEARCH_OPTIONS:
+ {
+ sal_uInt16 nOpt = 0xFFFF;
+ if( GetDocShell()->IsReadOnly() )
+ nOpt &= ~( SEARCH_OPTIONS_REPLACE |
+ SEARCH_OPTIONS_REPLACE_ALL );
+ rSet.Put( SfxUInt16Item( SID_SEARCH_OPTIONS, nOpt));
+ }
+ break;
+ case SID_SEARCH_ITEM:
+ {
+ if ( !m_pSrchItem )
+ {
+ m_pSrchItem = new SvxSearchItem( SID_SEARCH_ITEM );
+ m_pSrchItem->SetFamily(SFX_STYLE_FAMILY_PARA);
+ m_pSrchItem->SetSearchString( m_pWrtShell->GetSelTxt() );
+ }
+
+ if( m_bJustOpened && m_pWrtShell->IsSelection() )
+ {
+ OUString aTxt;
+ if( 1 == m_pWrtShell->GetCrsrCnt() &&
+ !( aTxt = m_pWrtShell->SwCrsrShell::GetSelTxt() ).isEmpty() )
+ {
+ m_pSrchItem->SetSearchString( aTxt );
+ m_pSrchItem->SetSelection( false );
+ }
+ else
+ m_pSrchItem->SetSelection( true );
+ }
+
+ m_bJustOpened = false;
+ rSet.Put( *m_pSrchItem );
+ }
+ break;
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/uiview/viewstat.cxx b/sw/source/core/uibase/uiview/viewstat.cxx
new file mode 100644
index 000000000000..6314f4784007
--- /dev/null
+++ b/sw/source/core/uibase/uiview/viewstat.cxx
@@ -0,0 +1,526 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <hintids.hxx>
+#include <com/sun/star/linguistic2/XThesaurus.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <svl/aeitem.hxx>
+#include <svl/whiter.hxx>
+#include <svl/cjkoptions.hxx>
+
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/objitem.hxx>
+#include <svl/imageitm.hxx>
+#include <svl/languageoptions.hxx>
+#include <editeng/protitem.hxx>
+#include <sfx2/linkmgr.hxx>
+#include <editeng/langitem.hxx>
+#include <editeng/brushitem.hxx>
+#include <sfx2/htmlmode.hxx>
+#include <editeng/unolingu.hxx>
+#include <sfx2/msgpool.hxx>
+#include <swmodule.hxx>
+#include <tox.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/app.hxx>
+#include <view.hxx>
+#include <wrtsh.hxx>
+#include <basesh.hxx>
+#include <uitool.hxx>
+#include <viewopt.hxx>
+#include <tablemgr.hxx>
+#include <pagedesc.hxx>
+#include <wview.hxx>
+#include <globdoc.hxx>
+#include <svl/stritem.hxx>
+#include <unotools/moduleoptions.hxx>
+#include <svl/visitem.hxx>
+
+#include <cmdid.h>
+
+#include <IDocumentRedlineAccess.hxx>
+#include <doc.hxx>
+
+using namespace ::com::sun::star;
+
+void SwView::GetState(SfxItemSet &rSet)
+{
+ SfxWhichIter aIter(rSet);
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ sal_uInt16 eFrmType = FRMTYPE_NONE;
+ int bGetFrmType = sal_False;
+ bool bWeb = 0 != PTR_CAST(SwWebView, this);
+
+ while(nWhich)
+ {
+ switch(nWhich)
+ {
+ case FN_EDIT_LINK_DLG:
+ if( m_pWrtShell->GetLinkManager().GetLinks().empty() )
+ rSet.DisableItem(nWhich);
+ else if( m_pWrtShell->IsSelFrmMode() &&
+ m_pWrtShell->IsSelObjProtected(FLYPROTECT_CONTENT))
+ {
+ rSet.DisableItem(nWhich);
+ }
+ break;
+
+ case SID_INSERT_GRAPHIC:
+ if( m_pWrtShell->CrsrInsideInputFld() )
+ {
+ rSet.DisableItem(nWhich);
+ }
+ break;
+
+ case FN_INSERT_CAPTION:
+ {
+ // There are captions for graphics, OLE objects, frames and tables
+ if( !bGetFrmType )
+ eFrmType = m_pWrtShell->GetFrmType(0,sal_True), bGetFrmType = sal_True;
+ if (! ( ((eFrmType & FRMTYPE_FLY_ANY) && m_nSelectionType != nsSelectionType::SEL_DRW_TXT)||
+ m_nSelectionType & nsSelectionType::SEL_TBL ||
+ m_nSelectionType & nsSelectionType::SEL_DRW) )
+ {
+ rSet.DisableItem(nWhich);
+ }
+ else if((m_pWrtShell->IsObjSelected() || m_pWrtShell->IsFrmSelected()) &&
+ (m_pWrtShell->IsSelObjProtected( FLYPROTECT_PARENT)||
+ m_pWrtShell->IsSelObjProtected( FLYPROTECT_CONTENT )))
+ {
+ rSet.DisableItem(nWhich);
+ }
+ else if( m_pWrtShell->IsTableMode()
+ || m_pWrtShell->CrsrInsideInputFld() )
+ {
+ rSet.DisableItem(nWhich);
+ }
+ }
+ break;
+
+ case FN_EDIT_FOOTNOTE:
+ {
+ if( !m_pWrtShell->GetCurFtn() )
+ rSet.DisableItem(nWhich);
+ }
+ break;
+
+ case FN_CHANGE_PAGENUM:
+ {
+ sal_uInt16 nType = m_pWrtShell->GetFrmType(0,sal_True);
+ if( ( FRMTYPE_FLY_ANY | FRMTYPE_HEADER | FRMTYPE_FOOTER |
+ FRMTYPE_FOOTNOTE | FRMTYPE_DRAWOBJ ) & nType )
+ rSet.DisableItem(nWhich);
+ else
+ rSet.Put(SfxUInt16Item(nWhich, m_pWrtShell->GetPageOffset()));
+ }
+ break;
+ case SID_PRINTDOC:
+ case SID_PRINTDOCDIRECT:
+ GetSlotState( nWhich, SfxViewShell::GetInterface(), &rSet );
+ break;
+ case SID_ATTR_PAGE:
+ case SID_ATTR_PAGE_SIZE:
+ case SID_ATTR_PAGE_PAPERBIN:
+ case RES_PAPER_BIN:
+ case FN_PARAM_FTN_INFO:
+ {
+ const sal_uInt16 nCurIdx = m_pWrtShell->GetCurPageDesc();
+ const SwPageDesc& rDesc = m_pWrtShell->GetPageDesc( nCurIdx );
+ ::PageDescToItemSet( rDesc, rSet);
+ }
+ break;
+ case RES_BACKGROUND:
+ case SID_ATTR_BRUSH:
+ {
+ const sal_uInt16 nCurIdx = m_pWrtShell->GetCurPageDesc();
+ const SwPageDesc& rDesc = m_pWrtShell->GetPageDesc( nCurIdx );
+ const SwFrmFmt& rMaster = rDesc.GetMaster();
+ const SvxBrushItem& rBrush = (const SvxBrushItem&)
+ rMaster.GetFmtAttr(RES_BACKGROUND, sal_True);
+ rSet.Put(rBrush);
+ }
+ break;
+ case SID_CLEARHISTORY:
+ {
+ rSet.Put(SfxBoolItem(nWhich, m_pWrtShell->GetLastUndoInfo(0, 0)));
+ }
+ break;
+ case SID_UNDO:
+ {
+ // which must not be present, so let them create:
+ if( !m_pShell )
+ SelectShell();
+
+ const SfxPoolItem* pState = m_pShell->GetSlotState(SID_UNDO);
+ if(pState)
+ rSet.Put(*pState);
+ else
+ rSet.DisableItem(nWhich);
+ }
+ break;
+ case FN_INSERT_CTRL:
+ {
+ SfxImageItem aImgItem(nWhich, bWeb ? SwView::m_nWebInsertCtrlState : SwView::m_nInsertCtrlState);
+ SfxSlotPool& rPool = SfxSlotPool::GetSlotPool( GetViewFrame() );
+ const SfxSlot* pSlot = rPool.GetSlot( aImgItem.GetValue() );
+ if(pSlot && pSlot->IsMode( SFX_SLOT_IMAGEROTATION ))
+ {
+ if(m_pWrtShell->IsInVerticalText())
+ aImgItem.SetRotation(2700);
+ if(m_pWrtShell->IsInRightToLeftText())
+ aImgItem.SetMirrored(true);
+ }
+ rSet.Put(aImgItem);
+ }
+ break;
+
+ case FN_INSERT_OBJ_CTRL:
+ if( bWeb
+ || m_pWrtShell->CrsrInsideInputFld() )
+ {
+ rSet.DisableItem(nWhich);
+ }
+ else
+ {
+ SfxImageItem aImgItem(nWhich, SwView::m_nInsertObjectCtrlState);
+ SfxSlotPool& rPool = SfxSlotPool::GetSlotPool( GetViewFrame() );
+ const SfxSlot* pSlot = rPool.GetSlot( aImgItem.GetValue() );
+ if(pSlot && pSlot->IsMode( SFX_SLOT_IMAGEROTATION ))
+ {
+ if (m_pWrtShell->IsInVerticalText())
+ aImgItem.SetRotation(2700);
+ if (m_pWrtShell->IsInRightToLeftText())
+ aImgItem.SetMirrored(true);
+ }
+ rSet.Put(aImgItem);
+ }
+ break;
+
+ case FN_UPDATE_TOX:
+ if(!m_pWrtShell->GetTOXCount())
+ rSet.DisableItem(nWhich);
+ break;
+ case FN_EDIT_CURRENT_TOX:
+ case FN_UPDATE_CUR_TOX:
+ {
+ const SwTOXBase* pBase = 0;
+ if(0 == (pBase = m_pWrtShell->GetCurTOX()) ||
+ (FN_EDIT_CURRENT_TOX == nWhich && pBase->IsTOXBaseInReadonly()))
+ rSet.DisableItem(nWhich);
+ }
+ break;
+ case SID_TWAIN_SELECT:
+ case SID_TWAIN_TRANSFER:
+#if defined WNT || defined UNX
+ {
+ if(!SW_MOD()->GetScannerManager().is())
+ rSet.DisableItem(nWhich);
+ }
+#endif
+ break;
+ case RES_PARATR_TABSTOP:
+ case SID_ATTR_DEFTABSTOP:
+ {
+ const SvxTabStopItem& rDefTabs =
+ (const SvxTabStopItem&)m_pWrtShell->
+ GetDefault(RES_PARATR_TABSTOP);
+ rSet.Put( SfxUInt16Item( nWhich,
+ (sal_uInt16)::GetTabDist(rDefTabs)));
+ }
+ break;
+ case SID_ATTR_LANGUAGE:
+ {
+ rSet.Put((const SvxLanguageItem&)
+ m_pWrtShell->GetDefault(RES_CHRATR_LANGUAGE), SID_ATTR_LANGUAGE);
+ }
+ break;
+ case RES_CHRATR_CJK_LANGUAGE:
+ rSet.Put((const SvxLanguageItem&)
+ m_pWrtShell->GetDefault(RES_CHRATR_CJK_LANGUAGE), RES_CHRATR_CJK_LANGUAGE);
+ break;
+ case RES_CHRATR_CTL_LANGUAGE:
+ rSet.Put((const SvxLanguageItem&)
+ m_pWrtShell->GetDefault(RES_CHRATR_CTL_LANGUAGE), RES_CHRATR_CTL_LANGUAGE);
+ break;
+ case FN_REDLINE_ON:
+ rSet.Put( SfxBoolItem( nWhich, GetDocShell()->IsChangeRecording() ) );
+ break;
+ case FN_REDLINE_PROTECT :
+ rSet.Put( SfxBoolItem( nWhich, GetDocShell()->HasChangeRecordProtection() ) );
+ break;
+ case FN_REDLINE_SHOW:
+ {
+ sal_uInt16 nMask = nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE;
+ rSet.Put( SfxBoolItem( nWhich,
+ (m_pWrtShell->GetRedlineMode() & nMask) == nMask ));
+ }
+ break;
+ case SID_GALLERY :
+ case SID_AVMEDIA_PLAYER :
+ case FN_REDLINE_ACCEPT :
+ {
+ SfxViewFrame* pVFrame = GetViewFrame();
+ if (pVFrame->KnowsChildWindow(nWhich))
+ rSet.Put(SfxBoolItem( nWhich, pVFrame->HasChildWindow(nWhich)));
+ else
+ rSet.DisableItem(nWhich);
+ }
+ break;
+ case FN_REDLINE_ACCEPT_DIRECT:
+ case FN_REDLINE_REJECT_DIRECT:
+ {
+ // If the selection/cursor start position isn't on a redline, disable
+ // accepting/rejecting changes.
+ SwDoc *pDoc = m_pWrtShell->GetDoc();
+ SwPaM *pCursor = m_pWrtShell->GetCrsr();
+ if (0 == pDoc->GetRedline(*pCursor->Start(), 0))
+ rSet.DisableItem(nWhich);
+ if (GetDocShell()->HasChangeRecordProtection())
+ rSet.DisableItem(nWhich);
+ }
+ break;
+
+ case FN_REDLINE_NEXT_CHANGE:
+ case FN_REDLINE_PREV_CHANGE:
+ {
+ // Enable change navigation if we have any redlines. Ideally we should disable
+ // "Next Change" if we're at or past the last change, and similarly for
+ // "Previous Change"
+ if (0 == m_pWrtShell->GetRedlineCount())
+ rSet.DisableItem(nWhich);
+ }
+ break;
+
+ case SID_THESAURUS:
+ {
+ SwWrtShell &rSh = GetWrtShell();
+ if (2 <= rSh.GetCrsrCnt()) // multi selection?
+ rSet.DisableItem(nWhich);
+ else
+ {
+ LanguageType nLang = rSh.GetCurLang();
+
+ // disable "Thesaurus" (menu entry and key shortcut) if the
+ // language is not supported (by default it is enabled)
+ uno::Reference< linguistic2::XThesaurus > xThes( ::GetThesaurus() );
+ if (!xThes.is() || nLang == LANGUAGE_NONE ||
+ !xThes->hasLocale( LanguageTag::convertToLocale( nLang ) ))
+ rSet.DisableItem(nWhich);
+ }
+ }
+ break;
+ case SID_HANGUL_HANJA_CONVERSION:
+ case SID_CHINESE_CONVERSION:
+ {
+ if (!SvtCJKOptions().IsAnyEnabled())
+ {
+ GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_False );
+ rSet.DisableItem(nWhich);
+ }
+ else
+ GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_True );
+ }
+ break;
+ case SID_MAIL_SCROLLBODY_PAGEDOWN:
+ {
+ const long nBottom = m_pWrtShell->GetDocSize().Height() + DOCUMENTBORDER;
+ const long nAct = GetVisArea().Bottom();
+ rSet.Put(SfxBoolItem(SID_MAIL_SCROLLBODY_PAGEDOWN, nAct < nBottom ));
+ }
+ break;
+
+ case SID_DOCUMENT_COMPARE:
+ case SID_DOCUMENT_MERGE:
+ if( GetDocShell()->IsA( SwGlobalDocShell::StaticType() ) ||
+ (SID_DOCUMENT_MERGE == nWhich && m_pWrtShell->getIDocumentRedlineAccess()->GetRedlinePassword().getLength()))
+ rSet.DisableItem(nWhich);
+ break;
+ case SID_VIEW_DATA_SOURCE_BROWSER:
+ if ( !SvtModuleOptions().IsModuleInstalled( SvtModuleOptions::E_SDATABASE ) )
+ rSet.Put( SfxVisibilityItem( nWhich, false ) );
+ else
+ rSet.Put( SfxBoolItem( nWhich, GetViewFrame()->HasChildWindow( SID_BROWSER ) ) );
+ break;
+ case SID_READONLY_MODE:
+ rSet.Put(SfxBoolItem(nWhich,
+ m_pWrtShell->HasReadonlySel()||GetDocShell()->IsReadOnly()));
+ break;
+ case SID_IMAGE_ORIENTATION:
+ {
+ SfxImageItem aImageItem(nWhich);
+ if(m_pWrtShell->IsInVerticalText())
+ aImageItem.SetRotation( 2700 );
+ if(m_pWrtShell->IsInRightToLeftText())
+ aImageItem.SetMirrored( true );
+ rSet.Put(aImageItem);
+ }
+ break;
+ case FN_INSERT_FIELD_DATA_ONLY :
+ if(!m_bInMailMerge && !GetViewFrame()->HasChildWindow(nWhich))
+ rSet.DisableItem(nWhich);
+ break;
+ case FN_MAILMERGE_SENDMAIL_CHILDWINDOW:
+ break;
+ case FN_MAILMERGE_CHILDWINDOW:
+ {
+ if(!GetMailMergeConfigItem())
+ rSet.DisableItem(nWhich);
+ }
+ break;
+ case SID_ALIGN_ANY_LEFT :
+ case SID_ALIGN_ANY_HCENTER :
+ case SID_ALIGN_ANY_RIGHT :
+ case SID_ALIGN_ANY_JUSTIFIED:
+ case SID_ALIGN_ANY_TOP :
+ case SID_ALIGN_ANY_VCENTER :
+ case SID_ALIGN_ANY_BOTTOM :
+ case SID_ALIGN_ANY_HDEFAULT :
+ case SID_ALIGN_ANY_VDEFAULT :
+ {
+ if( !m_pShell )
+ SelectShell();
+ sal_uInt16 nAlias = 0;
+ bool bDraw = false;
+ if( m_nSelectionType & (nsSelectionType::SEL_DRW_TXT|nsSelectionType::SEL_TXT) )
+ {
+ switch( nWhich )
+ {
+ case SID_ALIGN_ANY_LEFT : nAlias = SID_ATTR_PARA_ADJUST_LEFT; break;
+ case SID_ALIGN_ANY_HCENTER : nAlias = SID_ATTR_PARA_ADJUST_CENTER; break;
+ case SID_ALIGN_ANY_RIGHT : nAlias = SID_ATTR_PARA_ADJUST_RIGHT; break;
+ case SID_ALIGN_ANY_JUSTIFIED: nAlias = SID_ATTR_PARA_ADJUST_BLOCK; break;
+ case SID_ALIGN_ANY_TOP : nAlias = SID_TABLE_VERT_NONE; break;
+ case SID_ALIGN_ANY_VCENTER : nAlias = SID_TABLE_VERT_CENTER; break;
+ case SID_ALIGN_ANY_BOTTOM : nAlias = SID_TABLE_VERT_BOTTOM; break;
+ }
+ }
+ else if(m_nSelectionType & (nsSelectionType::SEL_DRW))
+ {
+ //the draw shell cannot provide a status per item - only one for SID_OBJECT_ALIGN
+ if(nWhich != SID_ALIGN_ANY_JUSTIFIED)
+ {
+ const SfxPoolItem* pItem = 0;
+ GetViewFrame()->GetDispatcher()->QueryState( SID_OBJECT_ALIGN, pItem );
+ if(pItem)
+ bDraw = true;
+ }
+ }
+ else
+ {
+ switch( nWhich )
+ {
+ case SID_ALIGN_ANY_LEFT : nAlias = SID_OBJECT_ALIGN_LEFT ; break;
+ case SID_ALIGN_ANY_HCENTER : nAlias = SID_OBJECT_ALIGN_CENTER ; break;
+ case SID_ALIGN_ANY_RIGHT : nAlias = SID_OBJECT_ALIGN_RIGHT ; break;
+ case SID_ALIGN_ANY_TOP : nAlias = SID_OBJECT_ALIGN_UP ; break;
+ case SID_ALIGN_ANY_VCENTER : nAlias = SID_OBJECT_ALIGN_MIDDLE ; break;
+ case SID_ALIGN_ANY_BOTTOM : nAlias = SID_OBJECT_ALIGN_DOWN ; break;
+ }
+ }
+ //these slots are either re-mapped to text or object alignment
+ const SfxPoolItem* pState = 0;
+ if(nAlias)
+ GetViewFrame()->GetDispatcher()->QueryState( nAlias, pState );
+ if(pState)
+ rSet.Put(*pState, nWhich);
+ else if(!bDraw)
+ rSet.DisableItem(nWhich);
+ }
+ break;
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+void SwView::GetDrawState(SfxItemSet &rSet)
+{
+ SfxWhichIter aIter(rSet);
+ bool bWeb = 0 != PTR_CAST(SwWebView, this);
+
+ for( sal_uInt16 nWhich = aIter.FirstWhich(); nWhich;
+ nWhich = aIter.NextWhich() )
+ switch(nWhich)
+ {
+ case SID_INSERT_DRAW:
+ if ( bWeb )
+ rSet.DisableItem( nWhich );
+ else
+ {
+ SfxAllEnumItem aEnum(SID_INSERT_DRAW, m_nDrawSfxId);
+ if ( !SvtLanguageOptions().IsVerticalTextEnabled() )
+ {
+ aEnum.DisableValue( SID_DRAW_CAPTION_VERTICAL );
+ aEnum.DisableValue( SID_DRAW_TEXT_VERTICAL );
+ }
+ rSet.Put(aEnum);
+ }
+ break;
+
+ case SID_SHOW_HIDDEN:
+ case SID_SHOW_FORMS:
+ rSet.DisableItem( nWhich );
+ break;
+
+ case SID_DRAW_TEXT_MARQUEE:
+ if (::GetHtmlMode(GetDocShell()) & HTMLMODE_SOME_STYLES)
+ rSet.Put( SfxBoolItem(nWhich, m_nDrawSfxId == nWhich));
+ else
+ rSet.DisableItem(nWhich);
+ break;
+ case SID_OBJECT_SELECT:
+ rSet.Put( SfxBoolItem(nWhich, m_nDrawSfxId == nWhich ||
+ m_nFormSfxId == nWhich));
+ break;
+
+ case SID_FONTWORK_GALLERY_FLOATER :
+ {
+ if ( bWeb )
+ rSet.DisableItem( nWhich );
+ }
+ 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 :
+ {
+ if ( bWeb )
+ rSet.DisableItem( nWhich );
+ else
+ rSet.Put(SfxStringItem(nWhich, m_aCurrShapeEnumCommand[ nWhich - SID_DRAWTBX_CS_BASIC ] ));
+ }
+ break;
+
+ }
+}
+
+sal_Bool SwView::HasUIFeature( sal_uInt32 nFeature )
+{
+ sal_Bool bRet = sal_False;
+ switch(nFeature)
+ {
+ case CHILDWIN_LABEL : bRet = m_pWrtShell->IsLabelDoc(); break;
+ case CHILDWIN_MAILMERGE : bRet = 0 != GetMailMergeConfigItem(); break;
+ }
+ return bRet;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/uiview/viewtab.cxx b/sw/source/core/uibase/uiview/viewtab.cxx
new file mode 100644
index 000000000000..e0bc61098195
--- /dev/null
+++ b/sw/source/core/uibase/uiview/viewtab.cxx
@@ -0,0 +1,2010 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <hintids.hxx>
+#include "uitool.hxx"
+#include <sfx2/app.hxx>
+#include <svx/rulritem.hxx>
+#include <editeng/tstpitem.hxx>
+#include <sfx2/request.hxx>
+#include <editeng/lrspitem.hxx>
+#include <editeng/ulspitem.hxx>
+#include <editeng/boxitem.hxx>
+#include <editeng/frmdiritem.hxx>
+#include <svl/eitem.hxx>
+#include <svl/whiter.hxx>
+#include <svx/ruler.hxx>
+#include <editeng/protitem.hxx>
+#include <svl/rectitem.hxx>
+#include <sfx2/bindings.hxx>
+#include <fmtfsize.hxx>
+#include <fmthdft.hxx>
+#include <fmtclds.hxx>
+#include <fmtornt.hxx>
+#include <frmatr.hxx>
+#include <edtwin.hxx>
+#include "view.hxx"
+#include "wrtsh.hxx"
+#include "basesh.hxx"
+#include "cmdid.h"
+#include "viewopt.hxx"
+#include "tabcol.hxx"
+#include "frmfmt.hxx"
+#include "pagedesc.hxx"
+#include "wview.hxx"
+#include "fmtcol.hxx"
+#include "section.hxx"
+
+#include "ndtxt.hxx"
+#include "pam.hxx"
+
+#include <IDocumentSettingAccess.hxx>
+
+using namespace ::com::sun::star;
+
+// Pack columns
+static void lcl_FillSvxColumn(const SwFmtCol& rCol,
+ sal_uInt16 nTotalWidth,
+ SvxColumnItem& rColItem,
+ long nDistance)
+{
+ const SwColumns& rCols = rCol.GetColumns();
+ sal_uInt16 nWidth = 0;
+
+ bool bOrtho = rCol.IsOrtho() && rCols.size();
+ long nInnerWidth = 0;
+ if( bOrtho )
+ {
+ nInnerWidth = nTotalWidth;
+ for ( sal_uInt16 i = 0; i < rCols.size(); ++i )
+ {
+ const SwColumn* pCol = &rCols[i];
+ nInnerWidth -= pCol->GetLeft() + pCol->GetRight();
+ }
+ if( nInnerWidth < 0 )
+ nInnerWidth = 0;
+ else
+ nInnerWidth /= rCols.size();
+ }
+ for ( sal_uInt16 i = 0; i < rCols.size(); ++i )
+ {
+ const SwColumn* pCol = &rCols[i];
+ const sal_uInt16 nStart = sal_uInt16(pCol->GetLeft() + nWidth + nDistance);
+ if( bOrtho )
+ nWidth = static_cast< sal_uInt16 >(nWidth + nInnerWidth + pCol->GetLeft() + pCol->GetRight());
+ else
+ nWidth = static_cast< sal_uInt16 >(nWidth + rCol.CalcColWidth(i, nTotalWidth));
+ const sal_uInt16 nEnd = sal_uInt16(nWidth - pCol->GetRight() + nDistance);
+
+ SvxColumnDescription aColDesc(nStart, nEnd, sal_True);
+ rColItem.Append(aColDesc);
+ }
+}
+
+// Transfer ColumnItem in ColumnInfo
+static void lcl_ConvertToCols(const SvxColumnItem& rColItem,
+ sal_uInt16 nTotalWidth,
+ SwFmtCol& rCols)
+{
+ OSL_ENSURE( rCols.GetNumCols() == rColItem.Count(), "Column count mismatch" );
+ // ruler executes that change the columns shortly after the selection has changed
+ // can result in a crash
+ if(rCols.GetNumCols() != rColItem.Count())
+ return;
+
+ sal_uInt16 nLeft = 0;
+ SwTwips nSumAll= 0; // Sum up all columns and margins
+
+ SwColumns& rArr = rCols.GetColumns();
+
+ // Tabcols sequentially
+ for( sal_uInt16 i=0; i < rColItem.Count()-1; ++i )
+ {
+ OSL_ENSURE(rColItem[i+1].nStart >= rColItem[i].nEnd,"overlapping columns" );
+ sal_uInt16 nStart = static_cast< sal_uInt16 >(rColItem[i+1].nStart);
+ sal_uInt16 nEnd = static_cast< sal_uInt16 >(rColItem[i].nEnd);
+ if(nStart < nEnd)
+ nStart = nEnd;
+ const sal_uInt16 nDiff = nStart - nEnd;
+ const sal_uInt16 nRight = nDiff / 2;
+
+ sal_uInt16 nWidth = static_cast< sal_uInt16 >(rColItem[i].nEnd - rColItem[i].nStart);
+ nWidth += nLeft + nRight;
+
+ SwColumn* pCol = &rArr[i];
+ pCol->SetWishWidth( sal_uInt16(long(rCols.GetWishWidth()) * long(nWidth) /
+ long(nTotalWidth) ));
+ pCol->SetLeft( nLeft );
+ pCol->SetRight( nRight );
+ nSumAll += pCol->GetWishWidth();
+
+ nLeft = nRight;
+ }
+ rArr[rColItem.Count()-1].SetLeft( nLeft );
+
+ // The difference between the total sum of the desired width and the so far
+ // calculated columns and margins should result in the width of the last column.
+ rArr[rColItem.Count()-1].SetWishWidth( rCols.GetWishWidth() - (sal_uInt16)nSumAll );
+
+ rCols.SetOrtho(sal_False, 0, 0 );
+}
+
+// Delete tabs
+static void lcl_EraseDefTabs(SvxTabStopItem& rTabStops)
+{
+ // Delete DefTabs
+ for ( sal_uInt16 i = 0; i < rTabStops.Count(); )
+ {
+ // Here also throw out the DefTab to zero
+ if ( SVX_TAB_ADJUST_DEFAULT == rTabStops[i].GetAdjustment() ||
+ rTabStops[i].GetTabPos() == 0 )
+ {
+ rTabStops.Remove(i);
+ continue;
+ }
+ ++i;
+ }
+}
+
+// Flip page margin
+void SwView::SwapPageMargin(const SwPageDesc& rDesc, SvxLRSpaceItem& rLRSpace)
+{
+ sal_uInt16 nPhyPage, nVirPage;
+ GetWrtShell().GetPageNum( nPhyPage, nVirPage );
+
+ if ( rDesc.GetUseOn() == nsUseOnPage::PD_MIRROR && (nPhyPage % 2) == 0 )
+ {
+ long nTmp = rLRSpace.GetRight();
+ rLRSpace.SetRight( rLRSpace.GetLeft() );
+ rLRSpace.SetLeft( nTmp );
+ }
+}
+
+// If the frame border is moved, the column separator
+// should stay in the same absolute position.
+static void lcl_Scale(long& nVal, long nScale)
+{
+ nVal *= nScale;
+ nVal >>= 8;
+}
+
+void ResizeFrameCols(SwFmtCol& rCol,
+ long nOldWidth,
+ long nNewWidth,
+ long nLeftDelta )
+{
+ SwColumns& rArr = rCol.GetColumns();
+ long nWishSum = (long)rCol.GetWishWidth();
+ long nWishDiff = (nWishSum * 100/nOldWidth * nNewWidth) / 100 - nWishSum;
+ long nNewWishWidth = nWishSum + nWishDiff;
+ if(nNewWishWidth > 0xffffl)
+ {
+ // If the desired width is getting too large, then all values
+ // must be scaled appropriately.
+ long nScale = (0xffffl << 8)/ nNewWishWidth;
+ for(sal_uInt16 i = 0; i < rArr.size(); i++)
+ {
+ SwColumn* pCol = &rArr[i];
+ long nVal = pCol->GetWishWidth();
+ lcl_Scale(nVal, nScale);
+ pCol->SetWishWidth((sal_uInt16) nVal);
+ nVal = pCol->GetLeft();
+ lcl_Scale(nVal, nScale);
+ pCol->SetLeft((sal_uInt16) nVal);
+ nVal = pCol->GetRight();
+ lcl_Scale(nVal, nScale);
+ pCol->SetRight((sal_uInt16) nVal);
+ }
+ lcl_Scale(nNewWishWidth, nScale);
+ lcl_Scale(nWishDiff, nScale);
+ }
+ rCol.SetWishWidth( (sal_uInt16) (nNewWishWidth) );
+
+ if( nLeftDelta >= 2 || nLeftDelta <= -2)
+ rArr.front().SetWishWidth(rArr.front().GetWishWidth() + (sal_uInt16)nWishDiff);
+ else
+ rArr.back().SetWishWidth(rArr.back().GetWishWidth() + (sal_uInt16)nWishDiff);
+ // Reset auto width
+ rCol.SetOrtho(sal_False, 0, 0 );
+}
+
+// Here all changes to the tab bar will be shot again into the model.
+void SwView::ExecTabWin( SfxRequest& rReq )
+{
+ SwWrtShell &rSh = GetWrtShell();
+ const sal_uInt16 nFrmType = rSh.IsObjSelected() ?
+ FRMTYPE_DRAWOBJ :
+ rSh.GetFrmType(0,sal_True);
+ const sal_Bool bFrmSelection = rSh.IsFrmSelected();
+ const sal_Bool bBrowse = rSh.GetViewOptions()->getBrowseMode();
+
+ const sal_uInt16 nSlot = rReq.GetSlot();
+ const SfxItemSet* pReqArgs = rReq.GetArgs();
+ const sal_uInt16 nDescId = rSh.GetCurPageDesc();
+ const SwPageDesc& rDesc = rSh.GetPageDesc( nDescId );
+
+ const bool bVerticalWriting = rSh.IsInVerticalText();
+ const SwFmtHeader& rHeaderFmt = rDesc.GetMaster().GetHeader();
+ SwFrmFmt *pHeaderFmt = (SwFrmFmt*)rHeaderFmt.GetHeaderFmt();
+
+ const SwFmtFooter& rFooterFmt = rDesc.GetMaster().GetFooter();
+ SwFrmFmt *pFooterFmt = (SwFrmFmt*)rFooterFmt.GetFooterFmt();
+
+ const SwFmtFrmSize &rFrmSize = rDesc.GetMaster().GetFrmSize();
+
+ const SwRect& rPageRect = rSh.GetAnyCurRect(RECT_PAGE);
+ const long nPageWidth = bBrowse ? rPageRect.Width() : rFrmSize.GetWidth();
+ const long nPageHeight = bBrowse ? rPageRect.Height() : rFrmSize.GetHeight();
+
+ bool bUnlockView = false;
+ rSh.StartAllAction();
+ bool bSect = 0 != (nFrmType & FRMTYPE_COLSECT);
+
+ switch (nSlot)
+ {
+ case SID_ATTR_LONG_LRSPACE:
+ if ( pReqArgs )
+ {
+ SvxLongLRSpaceItem aLongLR( (const SvxLongLRSpaceItem&)pReqArgs->
+ Get( SID_ATTR_LONG_LRSPACE ) );
+ SvxLRSpaceItem aLR(RES_LR_SPACE);
+ if ( !bSect && (bFrmSelection || nFrmType & FRMTYPE_FLY_ANY) )
+ {
+ SwFrmFmt* pFmt = ((SwFrmFmt*)rSh.GetFlyFrmFmt());
+ const SwRect &rRect = rSh.GetAnyCurRect(RECT_FLY_EMBEDDED);
+
+ bool bVerticalFrame(false);
+ {
+ sal_Bool bRTL;
+ sal_Bool bVertL2R;
+ bVerticalFrame = ( bFrmSelection &&
+ rSh.IsFrmVertical(sal_True, bRTL, bVertL2R) ) ||
+ ( !bFrmSelection && bVerticalWriting);
+ }
+ long nDeltaX = bVerticalFrame ?
+ rRect.Right() - rPageRect.Right() + aLongLR.GetRight() :
+ rPageRect.Left() + aLongLR.GetLeft() - rRect.Left();
+
+ SfxItemSet aSet( GetPool(), RES_FRM_SIZE, RES_FRM_SIZE,
+ RES_VERT_ORIENT, RES_HORI_ORIENT,
+ RES_COL, RES_COL, 0 );
+
+ if(bVerticalFrame)
+ {
+ SwFmtVertOrient aVertOrient(pFmt->GetVertOrient());
+ aVertOrient.SetVertOrient(text::VertOrientation::NONE);
+ aVertOrient.SetPos(aVertOrient.GetPos() + nDeltaX );
+ aSet.Put( aVertOrient );
+ }
+ else
+ {
+ SwFmtHoriOrient aHoriOrient( pFmt->GetHoriOrient() );
+ aHoriOrient.SetHoriOrient( text::HoriOrientation::NONE );
+ aHoriOrient.SetPos( aHoriOrient.GetPos() + nDeltaX );
+ aSet.Put( aHoriOrient );
+ }
+
+ SwFmtFrmSize aSize( pFmt->GetFrmSize() );
+ long nOldWidth = (long) aSize.GetWidth();
+
+ if(aSize.GetWidthPercent())
+ {
+ SwRect aRect;
+ rSh.CalcBoundRect(aRect, FLY_AS_CHAR);
+ long nPrtWidth = aRect.Width();
+ aSize.SetWidthPercent(sal_uInt8((nPageWidth - aLongLR.GetLeft() - aLongLR.GetRight()) * 100 /nPrtWidth));
+ }
+ else
+ aSize.SetWidth( nPageWidth -
+ (aLongLR.GetLeft() + aLongLR.GetRight()));
+
+ if( nFrmType & FRMTYPE_COLUMN )
+ {
+ SwFmtCol aCol(pFmt->GetCol());
+
+ ::ResizeFrameCols(aCol, nOldWidth, (long)aSize.GetWidth(), nDeltaX );
+ aSet.Put(aCol);
+ }
+
+ aSet.Put( aSize );
+
+ rSh.StartAction();
+ rSh.Push();
+ rSh.SetFlyFrmAttr( aSet );
+ // Cancel the frame selection
+ if(!bFrmSelection && rSh.IsFrmSelected())
+ {
+ rSh.UnSelectFrm();
+ rSh.LeaveSelFrmMode();
+ }
+ rSh.Pop();
+ rSh.EndAction();
+ }
+ else if ( nFrmType & ( FRMTYPE_HEADER | FRMTYPE_FOOTER ))
+ {
+ // Subtract out page margins
+ long nOld = rDesc.GetMaster().GetLRSpace().GetLeft();
+ aLongLR.SetLeft( nOld > aLongLR.GetLeft() ? 0 : aLongLR.GetLeft() - nOld );
+
+ nOld = rDesc.GetMaster().GetLRSpace().GetRight();
+ aLongLR.SetRight( nOld > (sal_uInt16)aLongLR.GetRight() ? 0 : aLongLR.GetRight() - nOld );
+ aLR.SetLeft((sal_uInt16)aLongLR.GetLeft());
+ aLR.SetRight((sal_uInt16)aLongLR.GetRight());
+
+ if ( nFrmType & FRMTYPE_HEADER && pHeaderFmt )
+ pHeaderFmt->SetFmtAttr( aLR );
+ else if( nFrmType & FRMTYPE_FOOTER && pFooterFmt )
+ pFooterFmt->SetFmtAttr( aLR );
+ }
+ else if( nFrmType == FRMTYPE_DRAWOBJ)
+ {
+ SwRect aRect( rSh.GetObjRect() );
+ aRect.Left( aLongLR.GetLeft() + rPageRect.Left() );
+ aRect.Right( rPageRect.Right() - aLongLR.GetRight());
+ rSh.SetObjRect( aRect );
+ }
+ else if(bSect || rSh.IsDirectlyInSection())
+ {
+ //change the section indents and the columns if available
+ //at first determine the changes
+ SwRect aSectRect = rSh.GetAnyCurRect(RECT_SECTION_PRT, 0);
+ const SwRect aTmpRect = rSh.GetAnyCurRect(RECT_SECTION, 0);
+ aSectRect.Pos() += aTmpRect.Pos();
+ long nLeftDiff = aLongLR.GetLeft() - (long)(aSectRect.Left() - rPageRect.Left() );
+ long nRightDiff = aLongLR.GetRight() - (long)( rPageRect.Right() - aSectRect.Right());
+ //change the LRSpaceItem of the section accordingly
+ const SwSection* pCurrSect = rSh.GetCurrSection();
+ const SwSectionFmt* pSectFmt = pCurrSect->GetFmt();
+ SvxLRSpaceItem aLRTmp = pSectFmt->GetLRSpace();
+ aLRTmp.SetLeft(aLRTmp.GetLeft() + nLeftDiff);
+ aLRTmp.SetRight(aLRTmp.GetRight() + nRightDiff);
+ SfxItemSet aSet(rSh.GetAttrPool(), RES_LR_SPACE, RES_LR_SPACE, RES_COL, RES_COL, 0L);
+ aSet.Put(aLRTmp);
+ //change the first/last column
+ if(bSect)
+ {
+ SwFmtCol aCols( pSectFmt->GetCol() );
+ long nDiffWidth = nLeftDiff + nRightDiff;
+ ::ResizeFrameCols(aCols, aSectRect.Width(), aSectRect.Width() - nDiffWidth, nLeftDiff );
+ aSet.Put( aCols );
+ }
+ SwSectionData aData(*pCurrSect);
+ rSh.UpdateSection(rSh.GetSectionFmtPos(*pSectFmt), aData, &aSet);
+ }
+ else
+ { // Adjust page margins
+ aLR.SetLeft((sal_uInt16)aLongLR.GetLeft());
+ aLR.SetRight((sal_uInt16)aLongLR.GetRight());
+ SwapPageMargin( rDesc, aLR );
+ SwPageDesc aDesc( rDesc );
+ aDesc.GetMaster().SetFmtAttr( aLR );
+ rSh.ChgPageDesc( nDescId, aDesc );
+ }
+ }
+ break;
+
+ // apply new left and right margins to current page style
+ case SID_ATTR_PAGE_LRSPACE:
+ if ( pReqArgs )
+ {
+ const SvxLongLRSpaceItem aLongLR( static_cast<const SvxLongLRSpaceItem&>(pReqArgs->Get( SID_ATTR_PAGE_LRSPACE )) );
+
+ SwPageDesc aDesc( rDesc );
+ {
+ SvxLRSpaceItem aLR( RES_LR_SPACE );
+ aLR.SetLeft((sal_uInt16)aLongLR.GetLeft());
+ aLR.SetRight((sal_uInt16)aLongLR.GetRight());
+ SwapPageMargin( rDesc, aLR );
+ aDesc.GetMaster().SetFmtAttr( aLR );
+ }
+ rSh.ChgPageDesc( nDescId, aDesc );
+ }
+ break;
+
+ case SID_ATTR_LONG_ULSPACE:
+ if ( pReqArgs )
+ {
+ SvxLongULSpaceItem aLongULSpace( (const SvxLongULSpaceItem&)pReqArgs->
+ Get( SID_ATTR_LONG_ULSPACE ));
+
+ if( bFrmSelection || nFrmType & FRMTYPE_FLY_ANY )
+ {
+ SwFrmFmt* pFmt = ((SwFrmFmt*)rSh.GetFlyFrmFmt());
+ const SwRect &rRect = rSh.GetAnyCurRect(RECT_FLY_EMBEDDED);
+ const long nDeltaY = rPageRect.Top() + aLongULSpace.GetUpper() - rRect.Top();
+ const long nHeight = nPageHeight - (aLongULSpace.GetUpper() + aLongULSpace.GetLower());
+
+ SfxItemSet aSet( GetPool(), RES_FRM_SIZE, RES_FRM_SIZE,
+ RES_VERT_ORIENT, RES_HORI_ORIENT, 0 );
+ //which of the orientation attributes is to be put depends on the frame's environment
+ sal_Bool bRTL;
+ sal_Bool bVertL2R;
+ if ( ( bFrmSelection &&
+ rSh.IsFrmVertical(sal_True, bRTL, bVertL2R ) ) ||
+ ( !bFrmSelection && bVerticalWriting ) )
+ {
+ SwFmtHoriOrient aHoriOrient(pFmt->GetHoriOrient());
+ aHoriOrient.SetHoriOrient(text::HoriOrientation::NONE);
+ aHoriOrient.SetPos(aHoriOrient.GetPos() + nDeltaY );
+ aSet.Put( aHoriOrient );
+ }
+ else
+ {
+ SwFmtVertOrient aVertOrient(pFmt->GetVertOrient());
+ aVertOrient.SetVertOrient(text::VertOrientation::NONE);
+ aVertOrient.SetPos(aVertOrient.GetPos() + nDeltaY );
+ aSet.Put( aVertOrient );
+ }
+ SwFmtFrmSize aSize(pFmt->GetFrmSize());
+ if(aSize.GetHeightPercent())
+ {
+ SwRect aRect;
+ rSh.CalcBoundRect(aRect, FLY_AS_CHAR);
+ long nPrtHeight = aRect.Height();
+ aSize.SetHeightPercent(sal_uInt8(nHeight * 100 /nPrtHeight));
+ }
+ else
+ aSize.SetHeight(nHeight );
+
+ aSet.Put( aSize );
+ rSh.SetFlyFrmAttr( aSet );
+ }
+ else if( nFrmType == FRMTYPE_DRAWOBJ )
+ {
+ SwRect aRect( rSh.GetObjRect() );
+ aRect.Top( aLongULSpace.GetUpper() + rPageRect.Top() );
+ aRect.Bottom( rPageRect.Bottom() - aLongULSpace.GetLower() );
+ rSh.SetObjRect( aRect ) ;
+ }
+ else if(bVerticalWriting && (bSect || rSh.IsDirectlyInSection()))
+ {
+ //change the section indents and the columns if available
+ //at first determine the changes
+ SwRect aSectRect = rSh.GetAnyCurRect(RECT_SECTION_PRT, 0);
+ const SwRect aTmpRect = rSh.GetAnyCurRect(RECT_SECTION, 0);
+ aSectRect.Pos() += aTmpRect.Pos();
+ const long nLeftDiff = aLongULSpace.GetUpper() - (long)(aSectRect.Top() - rPageRect.Top());
+ const long nRightDiff = aLongULSpace.GetLower() - (long)(nPageHeight - aSectRect.Bottom() + rPageRect.Top());
+ //change the LRSpaceItem of the section accordingly
+ const SwSection* pCurrSect = rSh.GetCurrSection();
+ const SwSectionFmt* pSectFmt = pCurrSect->GetFmt();
+ SvxLRSpaceItem aLR = pSectFmt->GetLRSpace();
+ aLR.SetLeft(aLR.GetLeft() + nLeftDiff);
+ aLR.SetRight(aLR.GetRight() + nRightDiff);
+ SfxItemSet aSet(rSh.GetAttrPool(), RES_LR_SPACE, RES_LR_SPACE, RES_COL, RES_COL, 0L);
+ aSet.Put(aLR);
+ //change the first/last column
+ if(bSect)
+ {
+ SwFmtCol aCols( pSectFmt->GetCol() );
+ long nDiffWidth = nLeftDiff + nRightDiff;
+ ::ResizeFrameCols(aCols, aSectRect.Height(), aSectRect.Height() - nDiffWidth, nLeftDiff );
+ aSet.Put( aCols );
+ }
+ SwSectionData aData(*pCurrSect);
+ rSh.UpdateSection(rSh.GetSectionFmtPos(*pSectFmt), aData, &aSet);
+ }
+ else
+ { SwPageDesc aDesc( rDesc );
+
+ if ( nFrmType & ( FRMTYPE_HEADER | FRMTYPE_FOOTER ))
+ {
+
+ const bool bHead = nFrmType & FRMTYPE_HEADER;
+ SvxULSpaceItem aUL( rDesc.GetMaster().GetULSpace() );
+ if ( bHead )
+ aUL.SetUpper( (sal_uInt16)aLongULSpace.GetUpper() );
+ else
+ aUL.SetLower( (sal_uInt16)aLongULSpace.GetLower() );
+ aDesc.GetMaster().SetFmtAttr( aUL );
+
+ if( (bHead && pHeaderFmt) || (!bHead && pFooterFmt) )
+ {
+ SwFmtFrmSize aSz( bHead ? pHeaderFmt->GetFrmSize() :
+ pFooterFmt->GetFrmSize() );
+ aSz.SetHeightSizeType( ATT_FIX_SIZE );
+ aSz.SetHeight(nPageHeight - aLongULSpace.GetLower() -
+ aLongULSpace.GetUpper() );
+ if ( bHead )
+ pHeaderFmt->SetFmtAttr( aSz );
+ else
+ pFooterFmt->SetFmtAttr( aSz );
+ }
+ }
+ else
+ {
+ SvxULSpaceItem aUL(RES_UL_SPACE);
+ aUL.SetUpper((sal_uInt16)aLongULSpace.GetUpper());
+ aUL.SetLower((sal_uInt16)aLongULSpace.GetLower());
+ aDesc.GetMaster().SetFmtAttr(aUL);
+ }
+
+ rSh.ChgPageDesc( nDescId, aDesc );
+ }
+ }
+ break;
+
+ // apply new top and bottom margins to current page style
+ case SID_ATTR_PAGE_ULSPACE:
+ if ( pReqArgs )
+ {
+ SvxLongULSpaceItem aLongULSpace(
+ static_cast<const SvxLongULSpaceItem&>(pReqArgs->Get( SID_ATTR_PAGE_ULSPACE ) ) );
+
+ SwPageDesc aDesc( rDesc );
+ {
+ SvxULSpaceItem aUL(RES_UL_SPACE);
+ aUL.SetUpper((sal_uInt16)aLongULSpace.GetUpper());
+ aUL.SetLower((sal_uInt16)aLongULSpace.GetLower());
+ aDesc.GetMaster().SetFmtAttr(aUL);
+ }
+ rSh.ChgPageDesc( nDescId, aDesc );
+ }
+ break;
+
+ case SID_ATTR_PAGE_COLUMN:
+ if ( pReqArgs )
+ {
+ const SfxInt16Item aColumnItem( (const SfxInt16Item&)pReqArgs->Get(nSlot) );
+ const sal_uInt16 nPageColumnType = aColumnItem.GetValue();
+
+ // nPageColumnType =
+ // 1 - single-columned page
+ // 2 - two-columned page
+ // 3 - three-columned page
+ // 4 - two-columned page with left column width of 2/3 of page width
+ // 5 - two-columned page with right column width of 2/3 of page width
+
+ sal_uInt16 nCount = 2;
+ if ( nPageColumnType == 1 )
+ {
+ nCount = 0;
+ }
+ else if ( nPageColumnType == 3 )
+ {
+ nCount = 3;
+ }
+
+ const sal_uInt16 nGutterWidth = 0;
+
+ const SvxLRSpaceItem aLR( rDesc.GetMaster().GetLRSpace() );
+ const long nLeft = aLR.GetLeft();
+ const long nRight = aLR.GetRight();
+ const long nWidth = nPageWidth - nLeft - nRight;
+
+ SwFmtCol aCols( rDesc.GetMaster().GetCol() );
+ aCols.Init( nCount, nGutterWidth, nWidth );
+ aCols.SetWishWidth( nWidth );
+ aCols.SetGutterWidth( nGutterWidth, nWidth );
+ aCols.SetOrtho( sal_False, nGutterWidth, nWidth );
+
+ long nColumnLeft = 0;
+ long nColumnRight = 0;
+ if ( nPageColumnType == 4 )
+ {
+ nColumnRight = (long)(nWidth/3);
+ nColumnLeft = nWidth - nColumnRight;
+ aCols.GetColumns()[0].SetWishWidth( nColumnLeft );
+ aCols.GetColumns()[1].SetWishWidth( nColumnRight );
+ }
+ else if ( nPageColumnType == 5 )
+ {
+ nColumnLeft = (long)(nWidth/3);
+ nColumnRight = nWidth - nColumnLeft;
+ aCols.GetColumns()[0].SetWishWidth( nColumnLeft );
+ aCols.GetColumns()[1].SetWishWidth( nColumnRight );
+ }
+
+ SwPageDesc aDesc( rDesc );
+ aDesc.GetMaster().SetFmtAttr( aCols );
+ rSh.ChgPageDesc( rSh.GetCurPageDesc(), aDesc );
+ }
+ break;
+
+ case SID_ATTR_TABSTOP_VERTICAL:
+ case SID_ATTR_TABSTOP:
+ if (pReqArgs)
+ {
+ sal_uInt16 nWhich = GetPool().GetWhich(nSlot);
+ SvxTabStopItem aTabStops( (const SvxTabStopItem&)pReqArgs->
+ Get( nWhich ));
+ aTabStops.SetWhich(RES_PARATR_TABSTOP);
+ const SvxTabStopItem& rDefTabs =
+ (const SvxTabStopItem&)rSh.GetDefault(RES_PARATR_TABSTOP);
+
+ // Default tab at pos 0
+ SfxItemSet aSet( GetPool(), RES_LR_SPACE, RES_LR_SPACE );
+ rSh.GetCurAttr( aSet );
+ const SvxLRSpaceItem& rLR = (const SvxLRSpaceItem&)aSet.Get(RES_LR_SPACE);
+
+ if ( rLR.GetTxtFirstLineOfst() < 0 )
+ {
+ SvxTabStop aSwTabStop( 0, SVX_TAB_ADJUST_DEFAULT );
+ aTabStops.Insert( aSwTabStop );
+ }
+
+ // Populate with default tabs.
+ sal_uInt16 nDef = ::GetTabDist( rDefTabs );
+ ::MakeDefTabs( nDef, aTabStops );
+
+ SwTxtFmtColl* pColl = rSh.GetCurTxtFmtColl();
+ if( pColl && pColl->IsAutoUpdateFmt() )
+ {
+ SfxItemSet aTmp(GetPool(), RES_PARATR_TABSTOP, RES_PARATR_TABSTOP);
+ aTmp.Put(aTabStops);
+ rSh.AutoUpdatePara( pColl, aTmp );
+ }
+ else
+ rSh.SetAttrItem( aTabStops );
+ }
+ break;
+
+ case SID_ATTR_PARA_LRSPACE_VERTICAL:
+ case SID_ATTR_PARA_LRSPACE:
+ if ( pReqArgs )
+ {
+ SvxLRSpaceItem aParaMargin((const SvxLRSpaceItem&)pReqArgs->Get(nSlot));
+
+ aParaMargin.SetRight( aParaMargin.GetRight() - m_nRightBorderDistance );
+ aParaMargin.SetTxtLeft(aParaMargin.GetTxtLeft() - m_nLeftBorderDistance );
+
+ aParaMargin.SetWhich( RES_LR_SPACE );
+ SwTxtFmtColl* pColl = rSh.GetCurTxtFmtColl();
+
+ // #i23726#
+ if (m_pNumRuleNodeFromDoc)
+ {
+ // --> #i42922# Mouse move of numbering label
+ // has to consider the left indent of the paragraph
+ SfxItemSet aSet( GetPool(), RES_LR_SPACE, RES_LR_SPACE );
+ rSh.GetCurAttr( aSet );
+ const SvxLRSpaceItem& rLR =
+ static_cast<const SvxLRSpaceItem&>(aSet.Get(RES_LR_SPACE));
+
+ SwPosition aPos(*m_pNumRuleNodeFromDoc);
+ // #i90078#
+ rSh.SetIndent( static_cast< short >(aParaMargin.GetTxtLeft() - rLR.GetTxtLeft()), aPos);
+ // #i42921# invalidate state of indent in order to get a ruler update.
+ aParaMargin.SetWhich( nSlot );
+ GetViewFrame()->GetBindings().SetState( aParaMargin );
+ }
+ else if( pColl && pColl->IsAutoUpdateFmt() )
+ {
+ SfxItemSet aSet(GetPool(), RES_LR_SPACE, RES_LR_SPACE);
+ aSet.Put(aParaMargin);
+ rSh.AutoUpdatePara( pColl, aSet);
+ }
+ else
+ rSh.SetAttrItem( aParaMargin );
+
+ if ( aParaMargin.GetTxtFirstLineOfst() < 0 )
+ {
+ SfxItemSet aSet( GetPool(), RES_PARATR_TABSTOP, RES_PARATR_TABSTOP );
+
+ rSh.GetCurAttr( aSet );
+ const SvxTabStopItem& rTabStops = (const SvxTabStopItem&)aSet.Get(RES_PARATR_TABSTOP);
+
+ // Do we have a tab at position zero?
+ sal_uInt16 i;
+
+ for ( i = 0; i < rTabStops.Count(); ++i )
+ if ( rTabStops[i].GetTabPos() == 0 )
+ break;
+
+ if ( i >= rTabStops.Count() )
+ {
+ // No DefTab
+ SvxTabStopItem aTabStops( RES_PARATR_TABSTOP );
+ aTabStops = rTabStops;
+
+ ::lcl_EraseDefTabs(aTabStops);
+
+ SvxTabStop aSwTabStop( 0, SVX_TAB_ADJUST_DEFAULT );
+ aTabStops.Insert(aSwTabStop);
+
+ const SvxTabStopItem& rDefTabs =
+ (const SvxTabStopItem&)rSh.GetDefault(RES_PARATR_TABSTOP);
+ sal_uInt16 nDef = ::GetTabDist(rDefTabs);
+ ::MakeDefTabs( nDef, aTabStops );
+
+ if( pColl && pColl->IsAutoUpdateFmt())
+ {
+ SfxItemSet aSetTmp(GetPool(), RES_PARATR_TABSTOP, RES_PARATR_TABSTOP);
+ aSetTmp.Put(aTabStops);
+ rSh.AutoUpdatePara( pColl, aSetTmp );
+ }
+ else
+ rSh.SetAttrItem( aTabStops );
+ }
+ }
+ }
+ break;
+
+ case SID_ATTR_PARA_ULSPACE:
+ if ( pReqArgs )
+ {
+ SvxULSpaceItem aParaMargin((const SvxULSpaceItem&)pReqArgs->Get(nSlot));
+
+ long nUDist = 0;
+ long nLDist = 0;
+ aParaMargin.SetUpper( aParaMargin.GetUpper() - nUDist );
+ aParaMargin.SetLower(aParaMargin.GetLower() - nLDist);
+
+ aParaMargin.SetWhich( RES_UL_SPACE );
+ SwTxtFmtColl* pColl = rSh.GetCurTxtFmtColl();
+ if( pColl && pColl->IsAutoUpdateFmt() )
+ {
+ SfxItemSet aSet(GetPool(), RES_UL_SPACE, RES_UL_SPACE);
+ aSet.Put(aParaMargin);
+ rSh.AutoUpdatePara( pColl, aSet);
+ }
+ else
+ rSh.SetAttrItem( aParaMargin );
+ }
+ break;
+
+ case SID_RULER_BORDERS_VERTICAL:
+ case SID_RULER_BORDERS:
+ if ( pReqArgs )
+ {
+ SvxColumnItem aColItem((const SvxColumnItem&)pReqArgs->Get(nSlot));
+
+ if( m_bSetTabColFromDoc || (!bSect && rSh.GetTableFmt()) )
+ {
+ OSL_ENSURE(aColItem.Count(), "ColDesc is empty!!");
+
+ const sal_Bool bSingleLine = ((const SfxBoolItem&)rReq.
+ GetArgs()->Get(SID_RULER_ACT_LINE_ONLY)).GetValue();
+
+ SwTabCols aTabCols;
+ if ( m_bSetTabColFromDoc )
+ rSh.GetMouseTabCols( aTabCols, m_aTabColFromDocPos );
+ else
+ rSh.GetTabCols(aTabCols);
+
+ // left table border
+ long nBorder = (long)(aColItem.GetLeft() - aTabCols.GetLeftMin());
+ aTabCols.SetLeft( nBorder );
+
+ nBorder = (bVerticalWriting ? nPageHeight : nPageWidth) - aTabCols.GetLeftMin() - aColItem.GetRight();
+
+ if ( aColItem.GetRight() > 0 )
+ aTabCols.SetRight( nBorder );
+
+ // Tabcols sequentially
+ // The last column is defined by the edge.
+ // Columns in right-to-left tables need to be mirrored
+ sal_Bool bIsTableRTL =
+ IsTabColFromDoc() ?
+ rSh.IsMouseTableRightToLeft(m_aTabColFromDocPos)
+ : rSh.IsTableRightToLeft();
+ if(bIsTableRTL)
+ {
+ sal_uInt16 nColCount = aColItem.Count() - 1;
+ for ( sal_uInt16 i = 0; i < nColCount && i < aTabCols.Count(); ++i )
+ {
+ const SvxColumnDescription& rCol = aColItem[nColCount - i];
+ aTabCols[i] = aTabCols.GetRight() - rCol.nStart;
+ aTabCols.SetHidden( i, !rCol.bVisible );
+ }
+ }
+ else
+ {
+ for ( sal_uInt16 i = 0; i < aColItem.Count()-1 && i < aTabCols.Count(); ++i )
+ {
+ const SvxColumnDescription& rCol = aColItem[i];
+ aTabCols[i] = rCol.nEnd + aTabCols.GetLeft();
+ aTabCols.SetHidden( i, !rCol.bVisible );
+ }
+ }
+
+ if ( m_bSetTabColFromDoc )
+ {
+ if( !rSh.IsViewLocked() )
+ {
+ bUnlockView = true;
+ rSh.LockView( sal_True );
+ }
+ rSh.SetMouseTabCols( aTabCols, bSingleLine,
+ m_aTabColFromDocPos );
+ }
+ else
+ rSh.SetTabCols(aTabCols, bSingleLine);
+
+ }
+ else
+ {
+ if ( bFrmSelection || nFrmType & FRMTYPE_FLY_ANY || bSect)
+ {
+ SwSectionFmt *pSectFmt = 0;
+ SfxItemSet aSet( GetPool(), RES_COL, RES_COL );
+ if(bSect)
+ {
+ const SwSection *pSect = rSh.GetAnySection();
+ OSL_ENSURE( pSect, "Which section?");
+ pSectFmt = pSect->GetFmt();
+ }
+ else
+ {
+ rSh.GetFlyFrmAttr( aSet );
+ }
+ SwFmtCol aCols(
+ bSect ?
+ pSectFmt->GetCol() :
+ (const SwFmtCol&)aSet.Get( RES_COL, sal_False ));
+ SwRect aCurRect = rSh.GetAnyCurRect(bSect ? RECT_SECTION_PRT : RECT_FLY_PRT_EMBEDDED);
+ const long lWidth = bVerticalWriting ? aCurRect.Height() : aCurRect.Width();
+ ::lcl_ConvertToCols( aColItem, sal_uInt16(lWidth), aCols );
+ aSet.Put( aCols );
+ if(bSect)
+ rSh.SetSectionAttr( aSet, pSectFmt );
+ else
+ {
+ rSh.StartAction();
+ rSh.Push();
+ rSh.SetFlyFrmAttr( aSet );
+ // Cancel the frame selection again
+ if(!bFrmSelection && rSh.IsFrmSelected())
+ {
+ rSh.UnSelectFrm();
+ rSh.LeaveSelFrmMode();
+ }
+ rSh.Pop();
+ rSh.EndAction();
+ }
+ }
+ else
+ {
+ SwFmtCol aCols( rDesc.GetMaster().GetCol() );
+ const SwRect aPrtRect = rSh.GetAnyCurRect(RECT_PAGE_PRT);
+ ::lcl_ConvertToCols( aColItem,
+ sal_uInt16(bVerticalWriting ? aPrtRect.Height() : aPrtRect.Width()),
+ aCols );
+ SwPageDesc aDesc( rDesc );
+ aDesc.GetMaster().SetFmtAttr( aCols );
+ rSh.ChgPageDesc( rSh.GetCurPageDesc(), aDesc );
+ }
+ }
+ }
+ break;
+
+ case SID_RULER_ROWS :
+ case SID_RULER_ROWS_VERTICAL:
+ if (pReqArgs)
+ {
+ SvxColumnItem aColItem((const SvxColumnItem&)pReqArgs->Get(nSlot));
+
+ if( m_bSetTabColFromDoc || (!bSect && rSh.GetTableFmt()) )
+ {
+ OSL_ENSURE(aColItem.Count(), "ColDesc is empty!!");
+
+ SwTabCols aTabCols;
+ if ( m_bSetTabRowFromDoc )
+ rSh.GetMouseTabRows( aTabCols, m_aTabColFromDocPos );
+ else
+ rSh.GetTabRows(aTabCols);
+
+ if ( bVerticalWriting )
+ {
+ aTabCols.SetRight(nPageWidth - aColItem.GetRight() - aColItem.GetLeft());
+ aTabCols.SetLeftMin(aColItem.GetLeft());
+ }
+ else
+ {
+ long nBorder = nPageHeight - aTabCols.GetLeftMin() - aColItem.GetRight();
+ aTabCols.SetRight( nBorder );
+ }
+
+ if(bVerticalWriting)
+ {
+ for ( sal_uInt16 i = aColItem.Count() - 1; i; --i )
+ {
+ const SvxColumnDescription& rCol = aColItem[i - 1];
+ long nColumnPos = aTabCols.GetRight() - rCol.nEnd ;
+ aTabCols[i - 1] = nColumnPos;
+ aTabCols.SetHidden( i - 1, !rCol.bVisible );
+ }
+ }
+ else
+ {
+ for ( sal_uInt16 i = 0; i < aColItem.Count()-1; ++i )
+ {
+ const SvxColumnDescription& rCol = aColItem[i];
+ aTabCols[i] = rCol.nEnd + aTabCols.GetLeft();
+ aTabCols.SetHidden( i, !rCol.bVisible );
+ }
+ }
+ sal_Bool bSingleLine = sal_False;
+ const SfxPoolItem* pSingleLine;
+ if( SFX_ITEM_SET == rReq.GetArgs()->GetItemState(SID_RULER_ACT_LINE_ONLY, false, &pSingleLine))
+ bSingleLine = ((const SfxBoolItem*)pSingleLine)->GetValue();
+ if ( m_bSetTabRowFromDoc )
+ {
+ if( !rSh.IsViewLocked() )
+ {
+ bUnlockView = true;
+ rSh.LockView( sal_True );
+ }
+ rSh.SetMouseTabRows( aTabCols, bSingleLine, m_aTabColFromDocPos );
+ }
+ else
+ rSh.SetTabRows(aTabCols, bSingleLine);
+ }
+ }
+ break;
+
+ default:
+ OSL_ENSURE( !this, "wrong SlotId");
+ }
+ rSh.EndAllAction();
+
+ if( bUnlockView )
+ rSh.LockView( sal_False );
+
+ m_bSetTabColFromDoc = m_bSetTabRowFromDoc = m_bTabColFromDoc = m_bTabRowFromDoc = sal_False;
+ SetNumRuleNodeFromDoc(NULL);
+}
+
+// Here the status of the tab bar will be determined.
+// This means that all relevant attributes at the CursorPos
+// will be submittet to the tab bar.
+void SwView::StateTabWin(SfxItemSet& rSet)
+{
+ SwWrtShell &rSh = GetWrtShell();
+
+ const Point* pPt = IsTabColFromDoc() || IsTabRowFromDoc() ? &m_aTabColFromDocPos : 0;
+ const sal_uInt16 nFrmType = rSh.IsObjSelected()
+ ? FRMTYPE_DRAWOBJ
+ : rSh.GetFrmType( pPt, sal_True );
+
+ const sal_Bool bFrmSelection = rSh.IsFrmSelected();
+ const sal_Bool bBrowse = rSh.GetViewOptions()->getBrowseMode();
+ // PageOffset/limiter
+ const SwRect& rPageRect = rSh.GetAnyCurRect( RECT_PAGE, pPt );
+ const SwRect& rPagePrtRect = rSh.GetAnyCurRect( RECT_PAGE_PRT, pPt );
+ const long nPageWidth = rPageRect.Width();
+ const long nPageHeight = rPageRect.Height();
+
+ const SwPageDesc& rDesc = rSh.GetPageDesc(
+ IsTabColFromDoc() || m_bTabRowFromDoc ?
+ rSh.GetMousePageDesc(m_aTabColFromDocPos) : rSh.GetCurPageDesc() );
+
+ const SvxFrameDirectionItem& rFrameDir = rDesc.GetMaster().GetFrmDir();
+ const bool bVerticalWriting = rSh.IsInVerticalText();
+
+ //enable tab stop display on the rulers depending on the writing direction
+ WinBits nRulerStyle = m_pHRuler->GetStyle() & ~WB_EXTRAFIELD;
+ m_pHRuler->SetStyle(bVerticalWriting||bBrowse ? nRulerStyle : nRulerStyle|WB_EXTRAFIELD);
+ nRulerStyle = m_pVRuler->GetStyle() & ~WB_EXTRAFIELD;
+ m_pVRuler->SetStyle(bVerticalWriting ? nRulerStyle|WB_EXTRAFIELD : nRulerStyle);
+
+ //#i24363# tab stops relative to indent
+ bool bRelative = rSh.getIDocumentSettingAccess()->get(IDocumentSettingAccess::TABS_RELATIVE_TO_INDENT);
+ m_pHRuler->SetTabsRelativeToIndent( bRelative );
+ m_pVRuler->SetTabsRelativeToIndent( bRelative );
+
+ SvxLRSpaceItem aPageLRSpace( rDesc.GetMaster().GetLRSpace() );
+ SwapPageMargin( rDesc, aPageLRSpace );
+
+ SfxItemSet aCoreSet( GetPool(), RES_PARATR_TABSTOP, RES_PARATR_TABSTOP,
+ RES_LR_SPACE, RES_UL_SPACE, 0 );
+ // get also the list level indent values merged as LR-SPACE item, if needed.
+ rSh.GetCurAttr( aCoreSet, true );
+ const SelectionType nSelType = rSh.GetSelectionType();
+
+ SfxWhichIter aIter( rSet );
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ bool bPutContentProtection = false;
+
+ while ( nWhich )
+ {
+ switch ( nWhich )
+ {
+
+ case SID_ATTR_PAGE_COLUMN:
+ {
+ sal_uInt16 nColumnType = 0;
+
+ const SwFrmFmt& rMaster = rDesc.GetMaster();
+ SwFmtCol aCol(rMaster.GetCol());
+ const sal_uInt16 nCols = aCol.GetNumCols();
+ if ( nCols == 0 )
+ {
+ nColumnType = 1;
+ }
+ else if ( nCols == 2 )
+ {
+ const sal_uInt16 nColLeft = aCol.CalcPrtColWidth(0, aCol.GetWishWidth());
+ const sal_uInt16 nColRight = aCol.CalcPrtColWidth(1, aCol.GetWishWidth());
+
+ if ( abs(nColLeft - nColRight) <= 10 )
+ {
+ nColumnType = 2;
+ }
+ else if( abs(nColLeft - nColRight*2) < 20 )
+ {
+ nColumnType = 4;
+ }
+ else if( abs(nColLeft*2 - nColRight) < 20 )
+ {
+ nColumnType = 5;
+ }
+ }
+ else if( nCols == 3 )
+ {
+ nColumnType = 3;
+ }
+
+ rSet.Put( SfxInt16Item( SID_ATTR_PAGE_COLUMN, nColumnType ) );
+ }
+ break;
+
+ case SID_ATTR_LONG_LRSPACE:
+ {
+ SvxLongLRSpaceItem aLongLR( (long)aPageLRSpace.GetLeft(),
+ (long)aPageLRSpace.GetRight(),
+ SID_ATTR_LONG_LRSPACE);
+ if(bBrowse)
+ {
+ aLongLR.SetLeft(rPagePrtRect.Left());
+ aLongLR.SetRight(nPageWidth - rPagePrtRect.Right());
+ }
+ if ( ( nFrmType & FRMTYPE_HEADER || nFrmType & FRMTYPE_FOOTER ) &&
+ !(nFrmType & FRMTYPE_COLSECT) )
+ {
+ SwFrmFmt *pFmt = (SwFrmFmt*) (nFrmType & FRMTYPE_HEADER ?
+ rDesc.GetMaster().GetHeader().GetHeaderFmt() :
+ rDesc.GetMaster().GetFooter().GetFooterFmt());
+ if( pFmt )// #i80890# if rDesc is not the one belonging to the current page is might crash
+ {
+ SwRect aRect( rSh.GetAnyCurRect( RECT_HEADERFOOTER, pPt));
+ aRect.Pos() -= rSh.GetAnyCurRect( RECT_PAGE, pPt ).Pos();
+ const SvxLRSpaceItem& aLR = pFmt->GetLRSpace();
+ aLongLR.SetLeft ( (long)aLR.GetLeft() + (long)aRect.Left() );
+ aLongLR.SetRight( (nPageWidth -
+ (long)aRect.Right() + (long)aLR.GetRight()));
+ }
+ }
+ else
+ {
+ SwRect aRect;
+ if( !bFrmSelection && ((nFrmType & FRMTYPE_COLSECT) || rSh.IsDirectlyInSection()) )
+ {
+ aRect = rSh.GetAnyCurRect(RECT_SECTION_PRT, pPt);
+ const SwRect aTmpRect = rSh.GetAnyCurRect(RECT_SECTION, pPt);
+ aRect.Pos() += aTmpRect.Pos();
+ }
+
+ else if ( bFrmSelection || nFrmType & FRMTYPE_FLY_ANY )
+ aRect = rSh.GetAnyCurRect(RECT_FLY_EMBEDDED, pPt);
+ else if( nFrmType & FRMTYPE_DRAWOBJ)
+ aRect = rSh.GetObjRect();
+
+ if( aRect.Width() )
+ {
+ // make relative to page position:
+ aLongLR.SetLeft ((long)( aRect.Left() - rPageRect.Left() ));
+ aLongLR.SetRight((long)( rPageRect.Right() - aRect.Right()));
+ }
+ }
+ if( nWhich == SID_ATTR_LONG_LRSPACE )
+ rSet.Put( aLongLR );
+ else
+ {
+ SvxLRSpaceItem aLR( aLongLR.GetLeft(),
+ aLongLR.GetRight(),
+ 0, 0,
+ nWhich);
+ rSet.Put(aLR);
+ }
+ break;
+ }
+
+ // provide left and right margins of current page style
+ case SID_ATTR_PAGE_LRSPACE:
+ {
+ const SvxLRSpaceItem aTmpPageLRSpace( rDesc.GetMaster().GetLRSpace() );
+ const SvxLongLRSpaceItem aLongLR(
+ (long)aTmpPageLRSpace.GetLeft(),
+ (long)aTmpPageLRSpace.GetRight(),
+ SID_ATTR_PAGE_LRSPACE );
+ rSet.Put( aLongLR );
+ }
+ break;
+
+ case SID_ATTR_LONG_ULSPACE:
+ {
+ // Page margin top bottom
+ SvxULSpaceItem aUL( rDesc.GetMaster().GetULSpace() );
+ SvxLongULSpaceItem aLongUL( (long)aUL.GetUpper(),
+ (long)aUL.GetLower(),
+ SID_ATTR_LONG_ULSPACE);
+
+ if ( bFrmSelection || nFrmType & FRMTYPE_FLY_ANY )
+ {
+ // Convert document coordinates into page coordinates.
+ const SwRect &rRect = rSh.GetAnyCurRect(RECT_FLY_EMBEDDED, pPt);
+ aLongUL.SetUpper((sal_uInt16)(rRect.Top() - rPageRect.Top() ));
+ aLongUL.SetLower((sal_uInt16)(rPageRect.Bottom() - rRect.Bottom() ));
+ }
+ else if ( nFrmType & FRMTYPE_HEADER || nFrmType & FRMTYPE_FOOTER )
+ {
+ SwRect aRect( rSh.GetAnyCurRect( RECT_HEADERFOOTER, pPt));
+ aRect.Pos() -= rSh.GetAnyCurRect( RECT_PAGE, pPt ).Pos();
+ aLongUL.SetUpper( (sal_uInt16)aRect.Top() );
+ aLongUL.SetLower( (sal_uInt16)(nPageHeight - aRect.Bottom()) );
+ }
+ else if( nFrmType & FRMTYPE_DRAWOBJ)
+ {
+ const SwRect &rRect = rSh.GetObjRect();
+ aLongUL.SetUpper((rRect.Top() - rPageRect.Top()));
+ aLongUL.SetLower((rPageRect.Bottom() - rRect.Bottom()));
+ }
+ else if(bBrowse)
+ {
+ aLongUL.SetUpper(rPagePrtRect.Top());
+ aLongUL.SetLower(nPageHeight - rPagePrtRect.Bottom());
+ }
+ if( nWhich == SID_ATTR_LONG_ULSPACE )
+ rSet.Put( aLongUL );
+ else
+ {
+ SvxULSpaceItem aULTmp((sal_uInt16)aLongUL.GetUpper(),
+ (sal_uInt16)aLongUL.GetLower(),
+ nWhich);
+ rSet.Put(aULTmp);
+ }
+ break;
+ }
+
+ // provide top and bottom margins of current page style
+ case SID_ATTR_PAGE_ULSPACE:
+ {
+ const SvxULSpaceItem aUL( rDesc.GetMaster().GetULSpace() );
+ SvxLongULSpaceItem aLongUL(
+ (long)aUL.GetUpper(),
+ (long)aUL.GetLower(),
+ SID_ATTR_PAGE_ULSPACE );
+
+ rSet.Put( aLongUL );
+ }
+ break;
+
+ case SID_ATTR_TABSTOP_VERTICAL :
+ case RES_PARATR_TABSTOP:
+ {
+ if ( ISA( SwWebView ) ||
+ IsTabColFromDoc() ||
+ IsTabRowFromDoc() ||
+ ( nSelType & nsSelectionType::SEL_GRF ) ||
+ ( nSelType & nsSelectionType::SEL_FRM ) ||
+ ( nSelType & nsSelectionType::SEL_OLE ) ||
+ ( SFX_ITEM_AVAILABLE > aCoreSet.GetItemState(RES_LR_SPACE) ) ||
+ (!bVerticalWriting && (SID_ATTR_TABSTOP_VERTICAL == nWhich) ) ||
+ ( bVerticalWriting && (RES_PARATR_TABSTOP == nWhich))
+ )
+ rSet.DisableItem( nWhich );
+ else
+ {
+ SvxTabStopItem aTabStops((const SvxTabStopItem&)
+ aCoreSet.Get( RES_PARATR_TABSTOP ));
+
+ const SvxTabStopItem& rDefTabs = (const SvxTabStopItem&)
+ rSh.GetDefault(RES_PARATR_TABSTOP);
+
+ OSL_ENSURE(m_pHRuler, "why is there no ruler?");
+ long nDefTabDist = ::GetTabDist(rDefTabs);
+ m_pHRuler->SetDefTabDist( nDefTabDist );
+ m_pVRuler->SetDefTabDist( nDefTabDist );
+ ::lcl_EraseDefTabs(aTabStops);
+ rSet.Put(aTabStops, nWhich);
+ }
+ break;
+ }
+
+ case SID_ATTR_PARA_LRSPACE_VERTICAL:
+ case SID_ATTR_PARA_LRSPACE:
+ {
+ if ( nSelType & nsSelectionType::SEL_GRF ||
+ nSelType & nsSelectionType::SEL_FRM ||
+ nSelType & nsSelectionType::SEL_OLE ||
+ nFrmType == FRMTYPE_DRAWOBJ ||
+ (!bVerticalWriting && (SID_ATTR_PARA_LRSPACE_VERTICAL == nWhich)) ||
+ ( bVerticalWriting && (SID_ATTR_PARA_LRSPACE == nWhich))
+ )
+ {
+ rSet.DisableItem(nWhich);
+ }
+ else
+ {
+ SvxLRSpaceItem aLR( RES_LR_SPACE );
+ if ( !IsTabColFromDoc() )
+ {
+ aLR = (const SvxLRSpaceItem&)aCoreSet.Get(RES_LR_SPACE);
+
+ // #i23726#
+ if (m_pNumRuleNodeFromDoc)
+ {
+ short nOffset = static_cast< short >(aLR.GetTxtLeft() +
+ // #i42922# Mouse move of numbering label
+ // has to consider the left indent of the paragraph
+ m_pNumRuleNodeFromDoc->GetLeftMarginWithNum( true ) );
+
+ short nFLOffset;
+ m_pNumRuleNodeFromDoc->GetFirstLineOfsWithNum( nFLOffset );
+
+ aLR.SetLeft( nOffset + nFLOffset );
+ }
+ }
+ aLR.SetWhich(nWhich);
+ rSet.Put(aLR);
+ }
+ break;
+ }
+
+ case SID_ATTR_PARA_ULSPACE:
+ {
+ SvxULSpaceItem aUL = (const SvxULSpaceItem&)aCoreSet.Get(RES_UL_SPACE);
+ aUL.SetWhich(nWhich);
+
+ SfxItemState e = aCoreSet.GetItemState(RES_UL_SPACE);
+ if( e >= SFX_ITEM_AVAILABLE )
+ rSet.Put( aUL );
+ else
+ rSet.InvalidateItem(nWhich);
+ }
+ break;
+
+ case SID_RULER_BORDER_DISTANCE:
+ {
+ m_nLeftBorderDistance = 0;
+ m_nRightBorderDistance = 0;
+ if ( nSelType & nsSelectionType::SEL_GRF ||
+ nSelType & nsSelectionType::SEL_FRM ||
+ nSelType & nsSelectionType::SEL_OLE ||
+ nFrmType == FRMTYPE_DRAWOBJ )
+ rSet.DisableItem(SID_RULER_BORDER_DISTANCE);
+ else
+ {
+ SvxLRSpaceItem aDistLR(SID_RULER_BORDER_DISTANCE);
+ if(nFrmType & FRMTYPE_FLY_ANY)
+ {
+ if( IsTabColFromDoc() )
+ {
+ const SwRect& rFlyPrtRect = rSh.GetAnyCurRect( RECT_FLY_PRT_EMBEDDED, pPt );
+ aDistLR.SetLeft(rFlyPrtRect.Left());
+ aDistLR.SetRight(rFlyPrtRect.Left());
+ }
+ else
+ {
+ SfxItemSet aCoreSet2( GetPool(),
+ RES_BOX, RES_BOX,
+ SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 0 );
+ SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
+ aCoreSet.Put( aBoxInfo );
+ rSh.GetFlyFrmAttr( aCoreSet );
+ const SvxBoxItem& rBox = (const SvxBoxItem&)aCoreSet.Get(RES_BOX);
+ aDistLR.SetLeft((sal_uInt16)rBox.GetDistance(BOX_LINE_LEFT ));
+ aDistLR.SetRight((sal_uInt16)rBox.GetDistance(BOX_LINE_RIGHT));
+
+ //add the paragraph border distance
+ SfxItemSet aCoreSet1( GetPool(),
+ RES_BOX, RES_BOX,
+ 0 );
+ rSh.GetCurAttr( aCoreSet1 );
+ const SvxBoxItem& rParaBox = (const SvxBoxItem&)aCoreSet1.Get(RES_BOX);
+ aDistLR.SetLeft(aDistLR.GetLeft() + (sal_uInt16)rParaBox.GetDistance(BOX_LINE_LEFT ));
+ aDistLR.SetRight(aDistLR.GetRight() + (sal_uInt16)rParaBox.GetDistance(BOX_LINE_RIGHT));
+ }
+ rSet.Put(aDistLR);
+ m_nLeftBorderDistance = static_cast< sal_uInt16 >(aDistLR.GetLeft());
+ m_nRightBorderDistance = static_cast< sal_uInt16 >(aDistLR.GetRight());
+ }
+ else if ( IsTabColFromDoc() ||
+ ( rSh.GetTableFmt() && !bFrmSelection &&
+ !(nFrmType & FRMTYPE_COLSECT ) ) )
+ {
+ SfxItemSet aCoreSet2( GetPool(),
+ RES_BOX, RES_BOX,
+ SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 0 );
+ SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
+ aBoxInfo.SetTable(false);
+ aBoxInfo.SetDist(true);
+ aCoreSet2.Put(aBoxInfo);
+ rSh.GetTabBorders( aCoreSet2 );
+ const SvxBoxItem& rBox = (const SvxBoxItem&)aCoreSet2.Get(RES_BOX);
+ aDistLR.SetLeft((sal_uInt16)rBox.GetDistance(BOX_LINE_LEFT ));
+ aDistLR.SetRight((sal_uInt16)rBox.GetDistance(BOX_LINE_RIGHT));
+
+ //add the border distance of the paragraph
+ SfxItemSet aCoreSet1( GetPool(), RES_BOX, RES_BOX );
+ rSh.GetCurAttr( aCoreSet1 );
+ const SvxBoxItem& rParaBox = (const SvxBoxItem&)aCoreSet1.Get(RES_BOX);
+ aDistLR.SetLeft(aDistLR.GetLeft() + (sal_uInt16)rParaBox.GetDistance(BOX_LINE_LEFT ));
+ aDistLR.SetRight(aDistLR.GetRight() + (sal_uInt16)rParaBox.GetDistance(BOX_LINE_RIGHT));
+ rSet.Put(aDistLR);
+ m_nLeftBorderDistance = static_cast< sal_uInt16 >(aDistLR.GetLeft());
+ m_nRightBorderDistance = static_cast< sal_uInt16 >(aDistLR.GetRight());
+ }
+ else if ( !rSh.IsDirectlyInSection() )
+ {
+ //get the page/header/footer border distance
+ const SwFrmFmt& rMaster = rDesc.GetMaster();
+ const SvxBoxItem& rBox = (const SvxBoxItem&)rMaster.GetAttrSet().Get(RES_BOX);
+ aDistLR.SetLeft((sal_uInt16)rBox.GetDistance(BOX_LINE_LEFT ));
+ aDistLR.SetRight((sal_uInt16)rBox.GetDistance(BOX_LINE_RIGHT));
+
+ const SvxBoxItem* pBox = 0;
+ if(nFrmType & FRMTYPE_HEADER)
+ {
+ rMaster.GetHeader();
+ const SwFmtHeader& rHeaderFmt = rMaster.GetHeader();
+ SwFrmFmt *pHeaderFmt = (SwFrmFmt*)rHeaderFmt.GetHeaderFmt();
+ if( pHeaderFmt )// #i80890# if rDesc is not the one belonging to the current page is might crash
+ pBox = & (const SvxBoxItem&)pHeaderFmt->GetBox();
+ }
+ else if(nFrmType & FRMTYPE_FOOTER )
+ {
+ const SwFmtFooter& rFooterFmt = rMaster.GetFooter();
+ SwFrmFmt *pFooterFmt = (SwFrmFmt*)rFooterFmt.GetFooterFmt();
+ if( pFooterFmt )// #i80890# if rDesc is not the one belonging to the current page is might crash
+ pBox = & (const SvxBoxItem&)pFooterFmt->GetBox();
+ }
+ if(pBox)
+ {
+ aDistLR.SetLeft((sal_uInt16)pBox->GetDistance(BOX_LINE_LEFT ));
+ aDistLR.SetRight((sal_uInt16)pBox->GetDistance(BOX_LINE_RIGHT));
+ }
+
+ //add the border distance of the paragraph
+ SfxItemSet aCoreSetTmp( GetPool(),
+ RES_BOX, RES_BOX,
+ SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 0 );
+ rSh.GetCurAttr( aCoreSetTmp );
+ const SvxBoxItem& rParaBox = (const SvxBoxItem&)aCoreSetTmp.Get(RES_BOX);
+ aDistLR.SetLeft(aDistLR.GetLeft() + (sal_uInt16)rParaBox.GetDistance(BOX_LINE_LEFT ));
+ aDistLR.SetRight(aDistLR.GetRight() + (sal_uInt16)rParaBox.GetDistance(BOX_LINE_RIGHT));
+ rSet.Put(aDistLR);
+ m_nLeftBorderDistance = static_cast< sal_uInt16 >(aDistLR.GetLeft());
+ m_nRightBorderDistance = static_cast< sal_uInt16 >(aDistLR.GetRight());
+ }
+ }
+ }
+ break;
+
+ case SID_RULER_TEXT_RIGHT_TO_LEFT:
+ {
+ if ( nSelType & nsSelectionType::SEL_GRF ||
+ nSelType & nsSelectionType::SEL_FRM ||
+ nSelType & nsSelectionType::SEL_OLE ||
+ nFrmType == FRMTYPE_DRAWOBJ)
+ rSet.DisableItem(nWhich);
+ else
+ {
+ sal_Bool bFlag = rSh.IsInRightToLeftText();
+ rSet.Put(SfxBoolItem(nWhich, bFlag));
+ }
+ }
+ break;
+
+ case SID_RULER_BORDERS_VERTICAL:
+ case SID_RULER_BORDERS:
+ {
+ bool bFrameHasVerticalColumns(false);
+ {
+ sal_Bool bFrameRTL;
+ sal_Bool bFrameVertL2R;
+ bFrameHasVerticalColumns = rSh.IsFrmVertical(sal_False, bFrameRTL, bFrameVertL2R) &&
+ bFrmSelection;
+ }
+ bool bHasTable = ( IsTabColFromDoc() ||
+ ( rSh.GetTableFmt() && !bFrmSelection &&
+ !(nFrmType & FRMTYPE_COLSECT ) ) );
+
+ bool bTableVertical = bHasTable && rSh.IsTableVertical();
+
+ if(((SID_RULER_BORDERS_VERTICAL == nWhich) &&
+ ((bHasTable && !bTableVertical) ||
+ (!bVerticalWriting && !bFrmSelection && !bHasTable ) ||
+ ( bFrmSelection && !bFrameHasVerticalColumns))) ||
+ ((SID_RULER_BORDERS == nWhich) &&
+ ((bHasTable && bTableVertical) ||
+ (bVerticalWriting && !bFrmSelection&& !bHasTable) || bFrameHasVerticalColumns)))
+ rSet.DisableItem(nWhich);
+ else if ( bHasTable )
+ {
+ SwTabCols aTabCols;
+ sal_uInt16 nNum;
+ if ( 0 != ( m_bSetTabColFromDoc = IsTabColFromDoc() ) )
+ {
+ rSh.GetMouseTabCols( aTabCols, m_aTabColFromDocPos );
+ nNum = rSh.GetCurMouseTabColNum( m_aTabColFromDocPos );
+ }
+ else
+ {
+ rSh.GetTabCols( aTabCols );
+ nNum = rSh.GetCurTabColNum();
+ if(rSh.IsTableRightToLeft())
+ nNum = aTabCols.Count() - nNum;
+ }
+
+ OSL_ENSURE(nNum <= aTabCols.Count(), "TabCol not found");
+ const int nLft = aTabCols.GetLeftMin() + aTabCols.GetLeft();
+ const int nRgt = (sal_uInt16)(bTableVertical ? nPageHeight : nPageWidth) -
+ (aTabCols.GetLeftMin() +
+ aTabCols.GetRight());
+
+ const sal_uInt16 nL = static_cast< sal_uInt16 >(nLft > 0 ? nLft : 0);
+ const sal_uInt16 nR = static_cast< sal_uInt16 >(nRgt > 0 ? nRgt : 0);
+
+ SvxColumnItem aColItem(nNum, nL, nR);
+
+ sal_uInt16 nStart = 0,
+ nEnd;
+
+ //columns in right-to-left tables need to be mirrored
+ sal_Bool bIsTableRTL =
+ IsTabColFromDoc() ?
+ rSh.IsMouseTableRightToLeft(m_aTabColFromDocPos)
+ : rSh.IsTableRightToLeft();
+ if(bIsTableRTL)
+ {
+ for ( sal_uInt16 i = aTabCols.Count(); i ; --i )
+ {
+ const SwTabColsEntry& rEntry = aTabCols.GetEntry( i - 1 );
+ nEnd = (sal_uInt16)aTabCols.GetRight();
+ nEnd = nEnd - (sal_uInt16)rEntry.nPos;
+ SvxColumnDescription aColDesc( nStart, nEnd,
+ (sal_uInt16(aTabCols.GetRight() - rEntry.nMax)),
+ (sal_uInt16(aTabCols.GetRight() - rEntry.nMin)),
+ !aTabCols.IsHidden(i - 1) );
+ aColItem.Append(aColDesc);
+ nStart = nEnd;
+ }
+ SvxColumnDescription aColDesc(nStart,
+ aTabCols.GetRight() - aTabCols.GetLeft(), sal_True);
+ aColItem.Append(aColDesc);
+ }
+ else
+ {
+ for ( sal_uInt16 i = 0; i < aTabCols.Count(); ++i )
+ {
+ const SwTabColsEntry& rEntry = aTabCols.GetEntry( i );
+ nEnd = static_cast< sal_uInt16 >(rEntry.nPos - aTabCols.GetLeft());
+ SvxColumnDescription aColDesc( nStart, nEnd,
+ rEntry.nMin - aTabCols.GetLeft(), rEntry.nMax - aTabCols.GetLeft(),
+ !aTabCols.IsHidden(i) );
+ aColItem.Append(aColDesc);
+ nStart = nEnd;
+ }
+ SvxColumnDescription aColDesc(nStart, aTabCols.GetRight() - aTabCols.GetLeft(),
+ 0, 0,
+ sal_True);
+ aColItem.Append(aColDesc);
+ }
+ rSet.Put(aColItem, nWhich);
+ }
+ else if ( bFrmSelection || nFrmType & ( FRMTYPE_COLUMN | FRMTYPE_COLSECT ) )
+ {
+ // Out of frame or page?
+ sal_uInt16 nNum = 0;
+ if(bFrmSelection)
+ {
+ const SwFrmFmt* pFmt = rSh.GetFlyFrmFmt();
+ if(pFmt)
+ nNum = pFmt->GetCol().GetNumCols();
+ }
+ else
+ nNum = rSh.GetCurColNum();
+
+ if(
+ // For that matter FRMTYPE_COLSECT should not be included
+ // if the border is selected!
+ !bFrmSelection &&
+ nFrmType & FRMTYPE_COLSECT )
+ {
+ const SwSection *pSect = rSh.GetAnySection(sal_False, pPt);
+ OSL_ENSURE( pSect, "Which section?");
+ if( pSect )
+ {
+ SwSectionFmt *pFmt = pSect->GetFmt();
+ const SwFmtCol& rCol = pFmt->GetCol();
+ if(rSh.IsInRightToLeftText())
+ nNum = rCol.GetColumns().size() - nNum;
+ else
+ --nNum;
+ SvxColumnItem aColItem(nNum);
+ SwRect aRect = rSh.GetAnyCurRect(RECT_SECTION_PRT, pPt);
+ const SwRect aTmpRect = rSh.GetAnyCurRect(RECT_SECTION, pPt);
+
+ ::lcl_FillSvxColumn(rCol, sal_uInt16(bVerticalWriting ? aRect.Height() : aRect.Width()), aColItem, 0);
+
+ if(bVerticalWriting)
+ {
+ aRect.Pos() += Point(aTmpRect.Left(), aTmpRect.Top());
+ aRect.Pos().Y() -= rPageRect.Top();
+ aColItem.SetLeft ((sal_uInt16)(aRect.Top()));
+ aColItem.SetRight((sal_uInt16)(nPageHeight - aRect.Bottom() ));
+ }
+ else
+ {
+ aRect.Pos() += aTmpRect.Pos();
+
+ // make relative to page position:
+ aColItem.SetLeft ((sal_uInt16)( aRect.Left() - rPageRect.Left() ));
+ aColItem.SetRight((sal_uInt16)( rPageRect.Right() - aRect.Right()));
+ }
+ aColItem.SetOrtho(aColItem.CalcOrtho());
+
+ rSet.Put(aColItem, nWhich);
+ }
+ }
+ else if( bFrmSelection || nFrmType & FRMTYPE_FLY_ANY )
+ {
+ // Columns in frame
+ if ( nNum )
+ {
+ const SwFrmFmt* pFmt = rSh.GetFlyFrmFmt() ;
+
+ const SwFmtCol& rCol = pFmt->GetCol();
+ if(rSh.IsInRightToLeftText())
+ nNum = rCol.GetColumns().size() - nNum;
+ else
+ nNum--;
+ SvxColumnItem aColItem(nNum);
+ const SwRect &rSizeRect = rSh.GetAnyCurRect(RECT_FLY_PRT_EMBEDDED, pPt);
+
+ bool bUseVertical = bFrameHasVerticalColumns || (!bFrmSelection && bVerticalWriting);
+ const long lWidth = bUseVertical ? rSizeRect.Height() : rSizeRect.Width();
+ const SwRect &rRect = rSh.GetAnyCurRect(RECT_FLY_EMBEDDED, pPt);
+ long nDist2 = ((bUseVertical ? rRect.Height() : rRect.Width()) - lWidth) /2;
+ ::lcl_FillSvxColumn(rCol, sal_uInt16(lWidth), aColItem, nDist2);
+
+ SfxItemSet aFrameSet(GetPool(), RES_LR_SPACE, RES_LR_SPACE);
+ rSh.GetFlyFrmAttr( aFrameSet );
+
+ if(bUseVertical)
+ {
+ aColItem.SetLeft ((sal_uInt16)(rRect.Top()- rPageRect.Top()));
+ aColItem.SetRight((sal_uInt16)(nPageHeight + rPageRect.Top() - rRect.Bottom() ));
+ }
+ else
+ {
+ aColItem.SetLeft ((sal_uInt16)(rRect.Left() - rPageRect.Left() ));
+ aColItem.SetRight((sal_uInt16)(rPageRect.Right() - rRect.Right() ));
+ }
+
+ aColItem.SetOrtho(aColItem.CalcOrtho());
+
+ rSet.Put(aColItem, nWhich);
+ }
+ else
+ rSet.DisableItem(nWhich);
+ }
+ else
+ { // Columns on the page
+ const SwFrmFmt& rMaster = rDesc.GetMaster();
+ SwFmtCol aCol(rMaster.GetCol());
+ if(rFrameDir.GetValue() == FRMDIR_HORI_RIGHT_TOP)
+ nNum = aCol.GetColumns().size() - nNum;
+ else
+ nNum--;
+
+ SvxColumnItem aColItem(nNum);
+ const SwRect aPrtRect = rSh.GetAnyCurRect(RECT_PAGE_PRT, pPt);
+ const SvxBoxItem& rBox = (const SvxBoxItem&)rMaster.GetFmtAttr(RES_BOX);
+ long nDist = rBox.GetDistance();
+
+ lcl_FillSvxColumn(
+ aCol,
+ sal_uInt16(bVerticalWriting ? aPrtRect.Height() : aPrtRect.Width() ),
+ aColItem, nDist);
+
+ if(bBrowse)
+ {
+ if (bVerticalWriting)
+ {
+ aColItem.SetLeft((sal_uInt16)rPagePrtRect.Top());
+ aColItem.SetRight(sal_uInt16(nPageHeight - rPagePrtRect.Bottom()));
+ }
+ else
+ {
+ aColItem.SetLeft((sal_uInt16)rPagePrtRect.Left());
+ aColItem.SetRight(sal_uInt16(nPageWidth - rPagePrtRect.Right()));
+ }
+ }
+ else
+ {
+ if (bVerticalWriting)
+ {
+ SvxULSpaceItem aUL( rDesc.GetMaster().GetULSpace() );
+ aColItem.SetLeft (aUL.GetUpper());
+ aColItem.SetRight(aUL.GetLower());
+ }
+ else
+ {
+ aColItem.SetLeft (aPageLRSpace.GetLeft());
+ aColItem.SetRight(aPageLRSpace.GetRight());
+ }
+ }
+ aColItem.SetOrtho(aColItem.CalcOrtho());
+
+ rSet.Put(aColItem, nWhich);
+ }
+ }
+ else
+ rSet.DisableItem(nWhich);
+ break;
+ }
+
+ case SID_RULER_ROWS :
+ case SID_RULER_ROWS_VERTICAL:
+ {
+ bool bFrameHasVerticalColumns(false);
+ {
+ sal_Bool bFrameRTL;
+ sal_Bool bFrameVertL2R;
+ bFrameHasVerticalColumns = rSh.IsFrmVertical(sal_False, bFrameRTL, bFrameVertL2R) &&
+ bFrmSelection;
+ }
+
+ if(((SID_RULER_ROWS == nWhich) &&
+ ((!bVerticalWriting && !bFrmSelection) || (bFrmSelection && !bFrameHasVerticalColumns))) ||
+ ((SID_RULER_ROWS_VERTICAL == nWhich) &&
+ ((bVerticalWriting && !bFrmSelection) || bFrameHasVerticalColumns)))
+ rSet.DisableItem(nWhich);
+ else if ( IsTabRowFromDoc() ||
+ ( rSh.GetTableFmt() && !bFrmSelection &&
+ !(nFrmType & FRMTYPE_COLSECT ) ) )
+ {
+ SwTabCols aTabCols;
+ //no current value necessary
+ sal_uInt16 nNum = 0;
+ if ( 0 != ( m_bSetTabRowFromDoc = IsTabRowFromDoc() ) )
+ {
+ rSh.GetMouseTabRows( aTabCols, m_aTabColFromDocPos );
+ }
+ else
+ {
+ rSh.GetTabRows( aTabCols );
+ }
+
+ const int nLft = aTabCols.GetLeftMin();
+ const int nRgt = (sal_uInt16)(bVerticalWriting ? nPageWidth : nPageHeight) -
+ (aTabCols.GetLeftMin() +
+ aTabCols.GetRight());
+
+ const sal_uInt16 nL = static_cast< sal_uInt16 >(nLft > 0 ? nLft : 0);
+ const sal_uInt16 nR = static_cast< sal_uInt16 >(nRgt > 0 ? nRgt : 0);
+
+ SvxColumnItem aColItem(nNum, nL, nR);
+
+ sal_uInt16 nStart = 0,
+ nEnd;
+
+ for ( sal_uInt16 i = 0; i < aTabCols.Count(); ++i )
+ {
+ const SwTabColsEntry& rEntry = aTabCols.GetEntry( i );
+ if(bVerticalWriting)
+ {
+ nEnd = sal_uInt16(aTabCols.GetRight() - rEntry.nPos);
+ SvxColumnDescription aColDesc( nStart, nEnd,
+ aTabCols.GetRight() - rEntry.nMax, aTabCols.GetRight() - rEntry.nMin,
+ !aTabCols.IsHidden(i) );
+ aColItem.Append(aColDesc);
+ }
+ else
+ {
+ nEnd = sal_uInt16(rEntry.nPos - aTabCols.GetLeft());
+ SvxColumnDescription aColDesc( nStart, nEnd,
+ sal_uInt16(rEntry.nMin - aTabCols.GetLeft()), sal_uInt16(rEntry.nMax - aTabCols.GetLeft()),
+ !aTabCols.IsHidden(i) );
+ aColItem.Append(aColDesc);
+ }
+ nStart = nEnd;
+ }
+ if(bVerticalWriting)
+ nEnd = static_cast< sal_uInt16 >(aTabCols.GetRight());
+ else
+ nEnd = static_cast< sal_uInt16 >(aTabCols.GetLeft());
+ // put a position protection when the last row cannot be moved
+ // due to a page break inside of a row
+ if(!aTabCols.IsLastRowAllowedToChange())
+ bPutContentProtection = true;
+
+ SvxColumnDescription aColDesc( nStart, nEnd,
+ aTabCols.GetRight(), aTabCols.GetRight(),
+ sal_False );
+ aColItem.Append(aColDesc);
+
+ rSet.Put(aColItem, nWhich);
+ }
+ else
+ rSet.DisableItem(nWhich);
+ }
+ break;
+
+ case SID_RULER_PAGE_POS:
+ {
+ SvxPagePosSizeItem aPagePosSize(
+ Point( rPageRect.Left(), rPageRect.Top()) , nPageWidth, nPageHeight);
+
+ rSet.Put(aPagePosSize);
+ break;
+ }
+
+ case SID_RULER_LR_MIN_MAX:
+ {
+ Rectangle aRectangle;
+ if( ( nFrmType & FRMTYPE_COLSECT ) && !IsTabColFromDoc() &&
+ ( nFrmType & ( FRMTYPE_TABLE|FRMTYPE_COLUMN ) ) )
+ {
+ if( nFrmType & FRMTYPE_TABLE )
+ {
+ const sal_uInt16 nNum = rSh.GetCurTabColNum();
+ SwTabCols aTabCols;
+ rSh.GetTabCols( aTabCols );
+
+ const int nLft = aTabCols.GetLeftMin() + aTabCols.GetLeft();
+ const int nRgt = (sal_uInt16)nPageWidth -(aTabCols.GetLeftMin() + aTabCols.GetRight());
+
+ const sal_uInt16 nL = static_cast< sal_uInt16 >(nLft > 0 ? nLft : 0);
+ const sal_uInt16 nR = static_cast< sal_uInt16 >(nRgt > 0 ? nRgt : 0);
+
+ aRectangle.Left() = nL;
+ if(nNum > 1)
+ aRectangle.Left() += aTabCols[nNum - 2];
+ if(nNum)
+ aRectangle.Left() += MINLAY;
+ if(aTabCols.Count() <= nNum + 1 )
+ aRectangle.Right() = nR;
+ else
+ aRectangle.Right() = nPageWidth - (nL + aTabCols[nNum + 1]);
+
+ if(nNum < aTabCols.Count())
+ aRectangle.Right() += MINLAY;
+ }
+ else
+ {
+ const SwFrmFmt* pFmt = rSh.GetFlyFrmFmt();
+ const SwFmtCol* pCols = pFmt ? &pFmt->GetCol():
+ &rDesc.GetMaster().GetCol();
+ const SwColumns& rCols = pCols->GetColumns();
+ sal_uInt16 nNum = rSh.GetCurOutColNum();
+ sal_uInt16 nCount = std::min(sal_uInt16(nNum + 1), sal_uInt16(rCols.size()));
+ const SwRect aRect( rSh.GetAnyCurRect( pFmt
+ ? RECT_FLY_PRT_EMBEDDED
+ : RECT_PAGE_PRT, pPt ));
+ const SwRect aAbsRect( rSh.GetAnyCurRect( pFmt
+ ? RECT_FLY_EMBEDDED
+ : RECT_PAGE, pPt ));
+
+ // The width of the frame or within the page margins.
+ const sal_uInt16 nTotalWidth = (sal_uInt16)aRect.Width();
+ // The entire frame width - The difference is twice the distance to the edge.
+ const sal_uInt16 nOuterWidth = (sal_uInt16)aAbsRect.Width();
+ int nWidth = 0,
+ nStart = 0,
+ nEnd = 0;
+ aRectangle.Left() = 0;
+ for ( sal_uInt16 i = 0; i < nCount; ++i )
+ {
+ const SwColumn* pCol = &rCols[i];
+ nStart = pCol->GetLeft() + nWidth;
+ if(i == nNum - 2)
+ aRectangle.Left() = nStart;
+ nWidth += pCols->CalcColWidth( i, nTotalWidth );
+ nEnd = nWidth - pCol->GetRight();
+ }
+ aRectangle.Right() = rPageRect.Right() - nEnd;
+ aRectangle.Left() -= rPageRect.Left();
+
+ if(nNum > 1)
+ {
+ aRectangle.Left() += MINLAY;
+ aRectangle.Left() += aRect.Left();
+ }
+ if(pFmt) // Range in frame - here you may up to the edge
+ aRectangle.Left() = aRectangle.Right() = 0;
+ else
+ {
+ // Move the rectangle to the correct absolute position.
+ aRectangle.Left() += aAbsRect.Left();
+ aRectangle.Right() -= aAbsRect.Left();
+ // Include distance to the border.
+ aRectangle.Right() -= (nOuterWidth - nTotalWidth) / 2;
+ }
+
+ if(nNum < rCols.size())
+ {
+ aRectangle.Right() += MINLAY;
+ }
+ else
+ // Right is only the margin now.
+ aRectangle.Right() = 0;
+
+ }
+ }
+ else if ( ((nFrmType & FRMTYPE_TABLE) || IsTabColFromDoc()) &&
+ !bFrmSelection )
+ {
+ bool bColumn;
+ if ( IsTabColFromDoc() )
+ bColumn = rSh.GetCurMouseColNum( m_aTabColFromDocPos ) != 0;
+ else
+ bColumn = (nFrmType & (FRMTYPE_COLUMN|FRMTYPE_FLY_ANY|FRMTYPE_COLSECTOUTTAB))
+ ? sal_True
+ : sal_False;
+
+ if ( !bColumn )
+ {
+ if( nFrmType & FRMTYPE_FLY_ANY && IsTabColFromDoc() )
+ {
+ SwRect aRect( rSh.GetAnyCurRect(
+ RECT_FLY_PRT_EMBEDDED, pPt ) );
+ aRect.Pos() += rSh.GetAnyCurRect( RECT_FLY_EMBEDDED,
+ pPt ).Pos();
+
+ aRectangle.Left() = aRect.Left() - rPageRect.Left();
+ aRectangle.Right() = rPageRect.Right() - aRect.Right();
+ }
+ else if( bBrowse )
+ {
+ aRectangle.Left() = rPagePrtRect.Left();
+ aRectangle.Right() = nPageWidth - rPagePrtRect.Right();
+ }
+ else
+ {
+ aRectangle.Left() = aPageLRSpace.GetLeft();
+ aRectangle.Right() = aPageLRSpace.GetRight();
+ }
+ }
+ else
+ { // Here only for table in multi-column pages and borders.
+ sal_Bool bSectOutTbl = (nFrmType & FRMTYPE_TABLE) ? sal_True : sal_False;
+ bool bFrame = (nFrmType & FRMTYPE_FLY_ANY);
+ bool bColSct = (nFrmType & ( bSectOutTbl
+ ? FRMTYPE_COLSECTOUTTAB
+ : FRMTYPE_COLSECT )
+ );
+ //So you can also drag with the mouse, without being in the table.
+ CurRectType eRecType = RECT_PAGE_PRT;
+ sal_uInt16 nNum = IsTabColFromDoc() ?
+ rSh.GetCurMouseColNum( m_aTabColFromDocPos ):
+ rSh.GetCurOutColNum();
+ const SwFrmFmt* pFmt = NULL;
+ if( bColSct )
+ {
+ eRecType = bSectOutTbl ? RECT_OUTTABSECTION
+ : RECT_SECTION;
+ const SwSection *pSect = rSh.GetAnySection( bSectOutTbl, pPt );
+ OSL_ENSURE( pSect, "Which section?");
+ pFmt = pSect->GetFmt();
+ }
+ else if( bFrame )
+ {
+ pFmt = rSh.GetFlyFrmFmt();
+ eRecType = RECT_FLY_PRT_EMBEDDED;
+ }
+
+ const SwFmtCol* pCols = pFmt ? &pFmt->GetCol():
+ &rDesc.GetMaster().GetCol();
+ const SwColumns& rCols = pCols->GetColumns();
+ const sal_uInt16 nBorder = pFmt ? pFmt->GetBox().GetDistance() :
+ rDesc.GetMaster().GetBox().GetDistance();
+
+ // RECT_FLY_PRT_EMBEDDED returns the relative position to RECT_FLY_EMBEDDED
+ // the absolute position must be added here
+
+ SwRect aRect( rSh.GetAnyCurRect( eRecType, pPt ) );
+ if(RECT_FLY_PRT_EMBEDDED == eRecType)
+ aRect.Pos() += rSh.GetAnyCurRect( RECT_FLY_EMBEDDED,
+ pPt ).Pos();
+
+ const sal_uInt16 nTotalWidth = (sal_uInt16)aRect.Width();
+ // Initialize nStart and nEnd initialisieren for nNum == 0
+ int nWidth = 0,
+ nStart = 0,
+ nEnd = nTotalWidth;
+
+ if( nNum > rCols.size() )
+ {
+ OSL_ENSURE( !this, "wrong FmtCol is being edited!" );
+ nNum = rCols.size();
+ }
+
+ for( sal_uInt16 i = 0; i < nNum; ++i )
+ {
+ const SwColumn* pCol = &rCols[i];
+ nStart = pCol->GetLeft() + nWidth;
+ nWidth += pCols->CalcColWidth( i, nTotalWidth );
+ nEnd = nWidth - pCol->GetRight();
+ }
+ if( bFrame || bColSct )
+ {
+ aRectangle.Left() = aRect.Left() - rPageRect.Left() + nStart;
+ aRectangle.Right() = nPageWidth - aRectangle.Left() - nEnd + nStart;
+ }
+ else if(!bBrowse)
+ {
+ aRectangle.Left() = aPageLRSpace.GetLeft() + nStart;
+ aRectangle.Right() = nPageWidth - nEnd - aPageLRSpace.GetLeft();
+ }
+ else
+ {
+ long nLeft = rPagePrtRect.Left();
+ aRectangle.Left() = nStart + nLeft;
+ aRectangle.Right() = nPageWidth - nEnd - nLeft;
+ }
+ if(!bFrame)
+ {
+ aRectangle.Left() += nBorder;
+ aRectangle.Right() -= nBorder;
+ }
+ }
+ }
+ else if ( nFrmType & ( FRMTYPE_HEADER | FRMTYPE_FOOTER ))
+ {
+ aRectangle.Left() = aPageLRSpace.GetLeft();
+ aRectangle.Right() = aPageLRSpace.GetRight();
+ }
+ else
+ aRectangle.Left() = aRectangle.Right() = 0;
+
+ SfxRectangleItem aLR( SID_RULER_LR_MIN_MAX , aRectangle);
+ rSet.Put(aLR);
+ }
+ break;
+
+ case SID_RULER_PROTECT:
+ {
+ if(bFrmSelection)
+ {
+ sal_uInt8 nProtect = m_pWrtShell->IsSelObjProtected( FLYPROTECT_SIZE|FLYPROTECT_POS|FLYPROTECT_CONTENT );
+
+ SvxProtectItem aProt(SID_RULER_PROTECT);
+ aProt.SetCntntProtect((nProtect & FLYPROTECT_CONTENT) != 0);
+ aProt.SetSizeProtect ((nProtect & FLYPROTECT_SIZE) != 0);
+ aProt.SetPosProtect ((nProtect & FLYPROTECT_POS) != 0);
+ rSet.Put(aProt);
+ }
+ else
+ {
+ SvxProtectItem aProtect(SID_RULER_PROTECT);
+ if(bBrowse && !(nFrmType & (FRMTYPE_DRAWOBJ|FRMTYPE_COLUMN)) && !rSh.GetTableFmt())
+ {
+ aProtect.SetSizeProtect(true);
+ aProtect.SetPosProtect(true);
+ }
+ rSet.Put(aProtect);
+ }
+ }
+ break;
+ }
+ nWhich = aIter.NextWhich();
+ }
+ if(bPutContentProtection)
+ {
+ SvxProtectItem aProtect(SID_RULER_PROTECT);
+ aProtect.SetCntntProtect(true);
+ rSet.Put(aProtect);
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/uno/SwXDocumentSettings.cxx b/sw/source/core/uibase/uno/SwXDocumentSettings.cxx
new file mode 100644
index 000000000000..48f68dbe6dfd
--- /dev/null
+++ b/sw/source/core/uibase/uno/SwXDocumentSettings.cxx
@@ -0,0 +1,1254 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <osl/mutex.hxx>
+#include <sfx2/sfxbasecontroller.hxx>
+#include <SwXDocumentSettings.hxx>
+#include <comphelper/MasterPropertySetInfo.hxx>
+#include <cppuhelper/supportsservice.hxx>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/i18n/XForbiddenCharacters.hpp>
+#include <com/sun/star/document/PrinterIndependentLayout.hpp>
+#include <doc.hxx>
+#include <docsh.hxx>
+#include <fldupde.hxx>
+#include <linkenum.hxx>
+#include <sfx2/printer.hxx>
+#include <editsh.hxx>
+#include <drawdoc.hxx>
+#include <svl/zforlist.hxx>
+#include <unotxdoc.hxx>
+#include <cmdid.h>
+#include <sfx2/zoomitem.hxx>
+#include <unomod.hxx>
+#include <vcl/svapp.hxx>
+#include <comphelper/servicehelper.hxx>
+
+#include "swmodule.hxx"
+#include "cfgitems.hxx"
+#include "prtopt.hxx"
+
+using namespace comphelper;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::i18n;
+
+enum SwDocumentSettingsPropertyHandles
+{
+ HANDLE_FORBIDDEN_CHARS,
+ HANDLE_LINK_UPDATE_MODE,
+ HANDLE_FIELD_AUTO_UPDATE,
+ HANDLE_CHART_AUTO_UPDATE,
+ HANDLE_ADD_PARA_TABLE_SPACING,
+ HANDLE_ADD_PARA_TABLE_SPACING_AT_START,
+ HANDLE_ALIGN_TAB_STOP_POSITION,
+ HANDLE_PRINTER_NAME,
+ HANDLE_PRINTER_SETUP,
+ HANDLE_IS_KERN_ASIAN_PUNCTUATION,
+ HANDLE_CHARACTER_COMPRESSION_TYPE,
+ HANDLE_APPLY_USER_DATA,
+ HANDLE_SAVE_GLOBAL_DOCUMENT_LINKS,
+ HANDLE_CURRENT_DATABASE_DATA_SOURCE,
+ HANDLE_CURRENT_DATABASE_COMMAND,
+ HANDLE_CURRENT_DATABASE_COMMAND_TYPE,
+ HANDLE_SAVE_VERSION_ON_CLOSE,
+ HANDLE_IS_GRID_VISIBLE,
+ HANDLE_IS_SNAP_TO_GRID,
+ HANDLE_IS_SYNCHRONISE_AXES,
+ HANDLE_HORIZONTAL_GRID_RESOLUTION,
+ HANDLE_HORIZONTAL_GRID_SUBDIVISION,
+ HANDLE_VERTICAL_GRID_RESOLUTION,
+ HANDLE_VERTICAL_GRID_SUBDIVISION,
+ HANDLE_UPDATE_FROM_TEMPLATE,
+ HANDLE_PRINTER_INDEPENDENT_LAYOUT,
+ HANDLE_IS_LABEL_DOC,
+ HANDLE_IS_ADD_FLY_OFFSET,
+ HANDLE_IS_ADD_EXTERNAL_LEADING,
+ HANDLE_OLD_NUMBERING, // #111955#
+ HANDLE_OUTLINELEVEL_YIELDS_NUMBERING,
+ /* Stampit It disable the print cancel button of the shown progress dialog. */
+ HANDLE_ALLOW_PRINTJOB_CANCEL,
+ HANDLE_USE_FORMER_LINE_SPACING,
+ HANDLE_ADD_PARA_SPACING_TO_TABLE_CELLS,
+ HANDLE_USE_FORMER_OBJECT_POSITIONING,
+ HANDLE_USE_FORMER_TEXT_WRAPPING,
+ HANDLE_CHANGES_PASSWORD,
+ HANDLE_CONSIDER_WRAP_ON_OBJPOS,
+ HANDLE_IGNORE_FIRST_LINE_INDENT_IN_NUMBERING,
+ HANDLE_DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK,
+ HANDLE_DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT,
+ HANDLE_TABLE_ROW_KEEP,
+ HANDLE_IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION,
+ HANDLE_LOAD_READONLY,
+ HANDLE_DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE,
+ HANDLE_CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAMES,
+ HANDLE_UNIX_FORCE_ZERO_EXT_LEADING,
+ HANDLE_USE_OLD_PRINTER_METRICS,
+ HANDLE_PROTECT_FORM,
+ HANDLE_TABS_RELATIVE_TO_INDENT,
+ HANDLE_RSID,
+ HANDLE_RSID_ROOT,
+ // #i89181#
+ HANDLE_TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST,
+ HANDLE_MODIFYPASSWORDINFO,
+ HANDLE_MATH_BASELINE_ALIGNMENT,
+ HANDLE_INVERT_BORDER_SPACING,
+ HANDLE_COLLAPSE_EMPTY_CELL_PARA,
+ HANDLE_SMALL_CAPS_PERCENTAGE_66,
+ HANDLE_TAB_OVERFLOW,
+ HANDLE_UNBREAKABLE_NUMBERINGS,
+ HANDLE_STYLES_NODEFAULT,
+ HANDLE_FLOATTABLE_NOMARGINS,
+ HANDLE_CLIPPED_PICTURES,
+ HANDLE_BACKGROUND_PARA_OVER_DRAWINGS,
+ HANDLE_EMBED_FONTS,
+ HANDLE_EMBED_SYSTEM_FONTS,
+ HANDLE_TAB_OVER_MARGIN,
+ HANDLE_SURROUND_TEXT_WRAP_SMALL
+};
+
+static MasterPropertySetInfo * lcl_createSettingsInfo()
+{
+ static PropertyInfo const aWriterSettingsInfoMap[] =
+ {
+ { OUString("ForbiddenCharacters"), HANDLE_FORBIDDEN_CHARS, cppu::UnoType<css::i18n::XForbiddenCharacters>::get(), 0, 0},
+ { OUString("LinkUpdateMode"), HANDLE_LINK_UPDATE_MODE, cppu::UnoType<sal_Int16>::get(), 0, 0},
+ { OUString("FieldAutoUpdate"), HANDLE_FIELD_AUTO_UPDATE, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("ChartAutoUpdate"), HANDLE_CHART_AUTO_UPDATE, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("AddParaTableSpacing"), HANDLE_ADD_PARA_TABLE_SPACING, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("AddParaTableSpacingAtStart"), HANDLE_ADD_PARA_TABLE_SPACING_AT_START, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("AlignTabStopPosition"), HANDLE_ALIGN_TAB_STOP_POSITION, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("PrinterName"), HANDLE_PRINTER_NAME, cppu::UnoType<OUString>::get(), 0, 0},
+ { OUString("PrinterSetup"), HANDLE_PRINTER_SETUP, cppu::UnoType< cppu::UnoSequenceType<sal_Int8> >::get(), 0, 0},
+ { OUString("IsKernAsianPunctuation"), HANDLE_IS_KERN_ASIAN_PUNCTUATION, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("CharacterCompressionType"), HANDLE_CHARACTER_COMPRESSION_TYPE, cppu::UnoType<sal_Int16>::get(), 0, 0},
+ { OUString("ApplyUserData"), HANDLE_APPLY_USER_DATA, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("SaveGlobalDocumentLinks"), HANDLE_SAVE_GLOBAL_DOCUMENT_LINKS, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("CurrentDatabaseDataSource"), HANDLE_CURRENT_DATABASE_DATA_SOURCE, cppu::UnoType<OUString>::get(), 0, 0},
+ { OUString("CurrentDatabaseCommand"), HANDLE_CURRENT_DATABASE_COMMAND, cppu::UnoType<OUString>::get(), 0, 0},
+ { OUString("CurrentDatabaseCommandType"), HANDLE_CURRENT_DATABASE_COMMAND_TYPE, cppu::UnoType<sal_Int32>::get(), 0, 0},
+ { OUString("SaveVersionOnClose"), HANDLE_SAVE_VERSION_ON_CLOSE, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("UpdateFromTemplate"), HANDLE_UPDATE_FROM_TEMPLATE, cppu::UnoType<bool>::get(), 0, 0},
+
+ { OUString("PrinterIndependentLayout"), HANDLE_PRINTER_INDEPENDENT_LAYOUT, cppu::UnoType<sal_Int16>::get(), 0, 0},
+ { OUString("IsLabelDocument"), HANDLE_IS_LABEL_DOC, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("AddFrameOffsets"), HANDLE_IS_ADD_FLY_OFFSET, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("AddExternalLeading"), HANDLE_IS_ADD_EXTERNAL_LEADING, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("UseOldNumbering"), HANDLE_OLD_NUMBERING, cppu::UnoType<bool>::get(), 0, 0}, // #111955#
+ { OUString("OutlineLevelYieldsNumbering"), HANDLE_OUTLINELEVEL_YIELDS_NUMBERING, cppu::UnoType<bool>::get(), 0, 0},
+ /* Stampit It disable the print cancel button of the shown progress dialog. */
+ { OUString("AllowPrintJobCancel"), HANDLE_ALLOW_PRINTJOB_CANCEL, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("UseFormerLineSpacing"), HANDLE_USE_FORMER_LINE_SPACING, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("AddParaSpacingToTableCells"), HANDLE_ADD_PARA_SPACING_TO_TABLE_CELLS, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("UseFormerObjectPositioning"), HANDLE_USE_FORMER_OBJECT_POSITIONING, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("UseFormerTextWrapping"), HANDLE_USE_FORMER_TEXT_WRAPPING, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("RedlineProtectionKey"), HANDLE_CHANGES_PASSWORD, cppu::UnoType< cppu::UnoSequenceType<sal_Int8> >::get(), 0, 0},
+ { OUString("ConsiderTextWrapOnObjPos"), HANDLE_CONSIDER_WRAP_ON_OBJPOS, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("IgnoreFirstLineIndentInNumbering"), HANDLE_IGNORE_FIRST_LINE_INDENT_IN_NUMBERING, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("DoNotJustifyLinesWithManualBreak"), HANDLE_DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("DoNotResetParaAttrsForNumFont"), HANDLE_DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("TableRowKeep"), HANDLE_TABLE_ROW_KEEP, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("IgnoreTabsAndBlanksForLineCalculation"), HANDLE_IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("LoadReadonly"), HANDLE_LOAD_READONLY, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("DoNotCaptureDrawObjsOnPage"), HANDLE_DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("ClipAsCharacterAnchoredWriterFlyFrames"), HANDLE_CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAMES, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("UnxForceZeroExtLeading"), HANDLE_UNIX_FORCE_ZERO_EXT_LEADING, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("UseOldPrinterMetrics"), HANDLE_USE_OLD_PRINTER_METRICS, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("TabsRelativeToIndent"), HANDLE_TABS_RELATIVE_TO_INDENT, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("Rsid"), HANDLE_RSID, cppu::UnoType<sal_Int32>::get(), 0, 0},
+ { OUString("RsidRoot"), HANDLE_RSID_ROOT, cppu::UnoType<sal_Int32>::get(), 0, 0},
+ { OUString("ProtectForm"), HANDLE_PROTECT_FORM, cppu::UnoType<bool>::get(), 0, 0},
+ // #i89181#
+ { OUString("TabAtLeftIndentForParagraphsInList"), HANDLE_TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("ModifyPasswordInfo"), HANDLE_MODIFYPASSWORDINFO, cppu::UnoType< cppu::UnoSequenceType<css::beans::PropertyValue> >::get(), 0, 0},
+ { OUString("MathBaselineAlignment"), HANDLE_MATH_BASELINE_ALIGNMENT, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("InvertBorderSpacing"), HANDLE_INVERT_BORDER_SPACING, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("CollapseEmptyCellPara"), HANDLE_COLLAPSE_EMPTY_CELL_PARA, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("SmallCapsPercentage66"), HANDLE_SMALL_CAPS_PERCENTAGE_66, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("TabOverflow"), HANDLE_TAB_OVERFLOW, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("UnbreakableNumberings"), HANDLE_UNBREAKABLE_NUMBERINGS, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("StylesNoDefault"), HANDLE_STYLES_NODEFAULT, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("FloattableNomargins"), HANDLE_FLOATTABLE_NOMARGINS, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("ClippedPictures"), HANDLE_CLIPPED_PICTURES, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("BackgroundParaOverDrawings"), HANDLE_BACKGROUND_PARA_OVER_DRAWINGS, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("EmbedFonts"), HANDLE_EMBED_FONTS, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("EmbedSystemFonts"), HANDLE_EMBED_SYSTEM_FONTS, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("TabOverMargin"), HANDLE_TAB_OVER_MARGIN, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("SurroundTextWrapSmall"), HANDLE_SURROUND_TEXT_WRAP_SMALL, cppu::UnoType<bool>::get(), 0, 0},
+/*
+ * As OS said, we don't have a view when we need to set this, so I have to
+ * find another solution before adding them to this property set - MTG
+ { OUString("IsGridVisible"), HANDLE_IS_GRID_VISIBLE, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("IsSnapToGrid"), HANDLE_IS_SNAP_TO_GRID, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("IsSynchroniseAxes"), HANDLE_IS_SYNCHRONISE_AXES, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("HorizontalGridResolution"), HANDLE_HORIZONTAL_GRID_RESOLUTION, cppu::UnoType<sal_Int32>::get(), 0, 0},
+ { OUString("HorizontalGridSubdivision"), HANDLE_HORIZONTAL_GRID_SUBDIVISION, cppu::UnoType<sal_Int16>::get(), 0, 0},
+ { OUString("VerticalGridResolution"), HANDLE_VERTICAL_GRID_RESOLUTION, cppu::UnoType<sal_Int32>::get(), 0, 0},
+ { OUString("VerticalGridSubdivision"), HANDLE_VERTICAL_GRID_SUBDIVISION, cppu::UnoType<sal_Int16>::get(), 0, 0},
+
+ { OUString("ShowParagraphEnd"), HANDLE_SHOW_PARAGRAPH_END, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("ShowOptionalHyphens"), HANDLE_SHOW_OPTIONAL_HYPHENS, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("ShowSpaces"), HANDLE_SHOW_SPACES, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("ShowTabs"), HANDLE_SHOW_TABS, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("ShowBreaks"), HANDLE_SHOW_BREAKS, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("ShowHiddenText"), HANDLE_SHOW_HIDDEN_TEXT, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("ShowHiddenParagraphs"), HANDLE_SHOW_HIDDEN_PARAGRAPHS, cppu::UnoType<bool>::get(), 0, 0},
+
+ { OUString("ShowTextLimitGuide"), HANDLE_SHOW_TEXT_LIMIT_GUIDE, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("ShowTableLimitGuide"), HANDLE_SHOW_TABLE_LIMIT_GUIDE, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("ShowSectionLimitGuide"), HANDLE_SHOW_SECTION_LIMIT_GUIDE, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("ShowGuidesWhileMoving"), HANDLE_SHOW_GUIDES_WHILE_MOVING, cppu::UnoType<bool>::get(), 0, 0},
+*/
+ { OUString(), 0, css::uno::Type(), 0, 0 }
+ };
+ return new MasterPropertySetInfo ( aWriterSettingsInfoMap );
+}
+
+SwXDocumentSettings::SwXDocumentSettings ( SwXTextDocument * pModel )
+: MasterPropertySet ( lcl_createSettingsInfo (),
+ &Application::GetSolarMutex () )
+, mxModel ( pModel )
+, mpModel ( pModel )
+, mpDocSh ( NULL )
+, mpDoc ( NULL )
+, mpPrinter( NULL )
+{
+ registerSlave ( new SwXPrintSettings ( PRINT_SETTINGS_DOCUMENT, mpModel->GetDocShell()->GetDoc() ) );
+}
+
+SwXDocumentSettings::~SwXDocumentSettings()
+ throw()
+{
+}
+
+Any SAL_CALL SwXDocumentSettings::queryInterface( const Type& rType )
+ throw(RuntimeException, std::exception)
+{
+ return ::cppu::queryInterface ( rType,
+ // OWeakObject interfaces
+ dynamic_cast< XInterface* > ( dynamic_cast< OWeakObject* >(this) ),
+ dynamic_cast< XWeak* > ( this ),
+ // my own interfaces
+ dynamic_cast< XPropertySet* > ( this ),
+ dynamic_cast< XPropertyState* > ( this ),
+ dynamic_cast< XMultiPropertySet* > ( this ),
+ dynamic_cast< XServiceInfo* > ( this ),
+ dynamic_cast< XTypeProvider* > ( this ) );
+}
+void SwXDocumentSettings::acquire ()
+ throw ()
+{
+ OWeakObject::acquire();
+}
+void SwXDocumentSettings::release ()
+ throw ()
+{
+ OWeakObject::release();
+}
+
+uno::Sequence< uno::Type > SAL_CALL SwXDocumentSettings::getTypes( )
+ throw (RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+
+ uno::Sequence< uno::Type > aBaseTypes( 5 );
+ uno::Type* pBaseTypes = aBaseTypes.getArray();
+
+ // from MasterPropertySet
+ pBaseTypes[0] = ::getCppuType((Reference< XPropertySet >*)0);
+ pBaseTypes[1] = ::getCppuType((Reference< XPropertyState >*)0);
+ pBaseTypes[2] = ::getCppuType((Reference< XMultiPropertySet >*)0);
+
+ pBaseTypes[3] = ::getCppuType((Reference< XServiceInfo >*)0);
+ pBaseTypes[4] = ::getCppuType((Reference< XTypeProvider >*)0);
+
+ return aBaseTypes;
+}
+
+namespace
+{
+ class theSwXDocumentSettingsImplementationId : public rtl::Static< UnoTunnelIdInit, theSwXDocumentSettingsImplementationId > {};
+}
+
+uno::Sequence< sal_Int8 > SAL_CALL SwXDocumentSettings::getImplementationId( )
+ throw (RuntimeException, std::exception)
+{
+ return theSwXDocumentSettingsImplementationId::get().getSeq();
+}
+
+void SwXDocumentSettings::_preSetValues ()
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException )
+{
+ mpDocSh = mpModel->GetDocShell();
+ mpDoc = mpDocSh->GetDoc();
+
+ if( NULL == mpDoc || NULL == mpDocSh )
+ throw UnknownPropertyException();
+}
+
+void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInfo, const uno::Any &rValue )
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException )
+{
+ if (rInfo.mnAttributes & PropertyAttribute::READONLY)
+ throw PropertyVetoException ("Property is read-only: " + rInfo.maName, static_cast < cppu::OWeakObject * > ( 0 ) );
+
+ switch( rInfo.mnHandle )
+ {
+ case HANDLE_FORBIDDEN_CHARS:
+ break;
+ case HANDLE_LINK_UPDATE_MODE:
+ {
+ sal_Int16 nMode = 0;
+ rValue >>= nMode;
+ switch (nMode)
+ {
+ case NEVER:
+ case MANUAL:
+ case AUTOMATIC:
+ case GLOBALSETTING:
+ break;
+ default:
+ throw IllegalArgumentException();
+ }
+ mpDoc->setLinkUpdateMode(nMode);
+ }
+ break;
+ case HANDLE_FIELD_AUTO_UPDATE:
+ {
+ sal_Bool bUpdateField = *(sal_Bool*)rValue.getValue();
+ SwFldUpdateFlags nFlag = mpDoc->getFieldUpdateFlags(true);
+ mpDoc->setFieldUpdateFlags( bUpdateField ?
+ nFlag == AUTOUPD_FIELD_AND_CHARTS ?
+ AUTOUPD_FIELD_AND_CHARTS :
+ AUTOUPD_FIELD_ONLY :
+ AUTOUPD_OFF );
+ }
+ break;
+ case HANDLE_CHART_AUTO_UPDATE:
+ {
+ sal_Bool bUpdateChart = *(sal_Bool*)rValue.getValue();
+ SwFldUpdateFlags nFlag = mpDoc->getFieldUpdateFlags(true);
+ mpDoc->setFieldUpdateFlags( (nFlag == AUTOUPD_FIELD_ONLY || nFlag == AUTOUPD_FIELD_AND_CHARTS ) ?
+ bUpdateChart ?
+ AUTOUPD_FIELD_AND_CHARTS :
+ AUTOUPD_FIELD_ONLY :
+ AUTOUPD_OFF );
+ }
+ break;
+ case HANDLE_ADD_PARA_TABLE_SPACING:
+ {
+ sal_Bool bParaSpace = sal_False;
+ rValue >>= bParaSpace;
+ mpDoc->set(IDocumentSettingAccess::PARA_SPACE_MAX, bParaSpace );
+ }
+ break;
+ case HANDLE_ADD_PARA_TABLE_SPACING_AT_START:
+ {
+ sal_Bool bParaSpacePage = sal_False;
+ rValue >>= bParaSpacePage;
+ mpDoc->set(IDocumentSettingAccess::PARA_SPACE_MAX_AT_PAGES, bParaSpacePage );
+ }
+ break;
+ case HANDLE_ALIGN_TAB_STOP_POSITION:
+ {
+ sal_Bool bAlignTab = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::TAB_COMPAT, bAlignTab);
+ }
+ break;
+ case HANDLE_PRINTER_NAME:
+ {
+ //the printer must be created
+ OUString sPrinterName;
+ if( rValue >>= sPrinterName )
+ {
+ if( !mpPrinter && !sPrinterName.isEmpty() && mpDocSh->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED )
+ {
+ SfxPrinter* pPrinter = mpDoc->getPrinter( true );
+ if ( OUString ( pPrinter->GetName()) != sPrinterName )
+ {
+ SfxPrinter *pNewPrinter = new SfxPrinter ( pPrinter->GetOptions().Clone(), sPrinterName );
+ if( pNewPrinter->IsKnown() )
+ {
+ // set printer only once; in _postSetValues
+ mpPrinter = pNewPrinter;
+ }
+ else
+ {
+ delete pNewPrinter;
+ }
+ }
+ }
+ }
+ else
+ throw IllegalArgumentException();
+ }
+ break;
+ case HANDLE_PRINTER_SETUP:
+ {
+ Sequence < sal_Int8 > aSequence;
+ if ( rValue >>= aSequence )
+ {
+ sal_uInt32 nSize = aSequence.getLength();
+ if( nSize > 0 )
+ {
+ SvMemoryStream aStream (aSequence.getArray(), nSize,
+ STREAM_READ );
+ aStream.Seek ( STREAM_SEEK_TO_BEGIN );
+ static sal_uInt16 const nRange[] =
+ {
+ FN_PARAM_ADDPRINTER, FN_PARAM_ADDPRINTER,
+ SID_HTML_MODE, SID_HTML_MODE,
+ SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN,
+ SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC,
+ 0
+ };
+ SfxItemSet *pItemSet = new SfxItemSet( mpDoc->GetAttrPool(), nRange );
+ SfxPrinter *pPrinter = SfxPrinter::Create ( aStream, pItemSet );
+
+ // set printer only once; in _postSetValues
+ delete mpPrinter;
+ mpPrinter = pPrinter;
+ }
+ }
+ else
+ throw IllegalArgumentException();
+ }
+ break;
+ case HANDLE_IS_KERN_ASIAN_PUNCTUATION:
+ {
+ sal_Bool bIsKern = *(sal_Bool*)(rValue).getValue();
+ mpDoc->set(IDocumentSettingAccess::KERN_ASIAN_PUNCTUATION, bIsKern);
+ SwEditShell* pEditSh = mpDoc->GetEditShell();
+ if(pEditSh)
+ pEditSh->ChgHyphenation();
+ }
+ break;
+ case HANDLE_CHARACTER_COMPRESSION_TYPE:
+ {
+ sal_Int16 nMode = 0;
+ rValue >>= nMode;
+ switch (nMode)
+ {
+ case CHARCOMPRESS_NONE:
+ case CHARCOMPRESS_PUNCTUATION:
+ case CHARCOMPRESS_PUNCTUATION_KANA:
+ break;
+ default:
+ throw IllegalArgumentException();
+ }
+ mpDoc->setCharacterCompressionType(static_cast < SwCharCompressType > (nMode) );
+ }
+ break;
+ case HANDLE_APPLY_USER_DATA:
+ {
+ mpDocSh->SetUseUserData( *(sal_Bool*)rValue.getValue() );
+ }
+ break;
+ case HANDLE_SAVE_GLOBAL_DOCUMENT_LINKS:
+ {
+ sal_Bool bSaveGlobal = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::GLOBAL_DOCUMENT_SAVE_LINKS, bSaveGlobal );
+ }
+ break;
+ case HANDLE_CURRENT_DATABASE_DATA_SOURCE:
+ {
+ SwDBData aData = mpDoc->GetDBData();
+ if ( rValue >>= aData.sDataSource )
+ mpDoc->ChgDBData( aData );
+ }
+ break;
+ case HANDLE_CURRENT_DATABASE_COMMAND:
+ {
+ SwDBData aData = mpDoc->GetDBData();
+
+ if ( rValue >>= aData.sCommand )
+ mpDoc->ChgDBData( aData );
+
+ SAL_WARN_IF( aData.sDataSource.isEmpty() && !aData.sCommand.isEmpty(), "sw.uno",
+ "\"CurrentDatabaseCommand\" property possibly set before \"CurrentDatabaseDataSource\"" );
+ }
+ break;
+ case HANDLE_CURRENT_DATABASE_COMMAND_TYPE:
+ {
+ SwDBData aData = mpDoc->GetDBData();
+ if ( rValue >>= aData.nCommandType )
+ mpDoc->ChgDBData( aData );
+ SAL_WARN_IF( aData.nCommandType && aData.sDataSource.isEmpty(), "sw.uno",
+ "\"CurrentDatabaseCommandType\" property possibly set before \"CurrentDatabaseDataSource\"" );
+ SAL_WARN_IF( aData.nCommandType && aData.sCommand.isEmpty(), "sw.uno",
+ "\"CurrentDatabaseCommandType\" property possibly set before \"CurrentDatabaseCommand\"" );
+ }
+ break;
+ case HANDLE_SAVE_VERSION_ON_CLOSE:
+ {
+ mpDocSh->SetSaveVersionOnClose( *(sal_Bool*)rValue.getValue() );
+ }
+ break;
+ case HANDLE_UPDATE_FROM_TEMPLATE:
+ {
+ mpDocSh->SetQueryLoadTemplate( *(sal_Bool*)rValue.getValue() );
+ }
+ break;
+ case HANDLE_PRINTER_INDEPENDENT_LAYOUT:
+ {
+ sal_Int16 nTmp = 0;
+ rValue >>= nTmp;
+
+ bool bUseVirDev = true;
+ bool bHiResVirDev = true;
+ if( nTmp == document::PrinterIndependentLayout::DISABLED )
+ bUseVirDev = false;
+ else if ( nTmp == document::PrinterIndependentLayout::LOW_RESOLUTION )
+ bHiResVirDev = false;
+ else if ( nTmp != document::PrinterIndependentLayout::HIGH_RESOLUTION )
+ throw IllegalArgumentException();
+
+ mpDoc->setReferenceDeviceType( bUseVirDev, bHiResVirDev );
+ }
+ break;
+ case HANDLE_IS_LABEL_DOC :
+ {
+ sal_Bool bSet = sal_False;
+ if(!(rValue >>= bSet))
+ throw IllegalArgumentException();
+ mpDoc->set(IDocumentSettingAccess::LABEL_DOCUMENT, bSet);
+ }
+ break;
+ case HANDLE_IS_ADD_FLY_OFFSET:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::ADD_FLY_OFFSETS, bTmp);
+ }
+ break;
+ case HANDLE_IS_ADD_EXTERNAL_LEADING:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::ADD_EXT_LEADING, bTmp);
+ }
+ break;
+ case HANDLE_OLD_NUMBERING: // #111955#
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::OLD_NUMBERING, bTmp);
+ }
+ break;
+ case HANDLE_OUTLINELEVEL_YIELDS_NUMBERING:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::OUTLINE_LEVEL_YIELDS_OUTLINE_RULE, bTmp);
+ }
+ break;
+ case HANDLE_ALLOW_PRINTJOB_CANCEL:
+ {
+ sal_Bool bState = sal_False;
+ if (!(rValue >>= bState))
+ throw IllegalArgumentException();
+ mpDocSh->Stamp_SetPrintCancelState(bState);
+ }
+ break;
+ case HANDLE_USE_FORMER_LINE_SPACING:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::OLD_LINE_SPACING, bTmp);
+ }
+ break;
+ case HANDLE_ADD_PARA_SPACING_TO_TABLE_CELLS:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::ADD_PARA_SPACING_TO_TABLE_CELLS, bTmp);
+ }
+ break;
+ case HANDLE_USE_FORMER_OBJECT_POSITIONING:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::USE_FORMER_OBJECT_POS, bTmp);
+ }
+ break;
+ case HANDLE_USE_FORMER_TEXT_WRAPPING:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::USE_FORMER_TEXT_WRAPPING, bTmp);
+ }
+ break;
+ case HANDLE_CHANGES_PASSWORD:
+ {
+ Sequence <sal_Int8> aNew;
+ if(rValue >>= aNew)
+ {
+ mpDoc->SetRedlinePassword(aNew);
+ if(aNew.getLength())
+ {
+ sal_uInt16 eMode = mpDoc->GetRedlineMode();
+ eMode = eMode|nsRedlineMode_t::REDLINE_ON;
+ mpDoc->SetRedlineMode((RedlineMode_t)( eMode ));
+ }
+ }
+ }
+ break;
+ case HANDLE_CONSIDER_WRAP_ON_OBJPOS:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::CONSIDER_WRAP_ON_OBJECT_POSITION, bTmp );
+ }
+ break;
+ case HANDLE_IGNORE_FIRST_LINE_INDENT_IN_NUMBERING:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::IGNORE_FIRST_LINE_INDENT_IN_NUMBERING, bTmp);
+ }
+ break;
+ case HANDLE_DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK, bTmp);
+ }
+ break;
+ case HANDLE_DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT, bTmp);
+ }
+ break;
+ case HANDLE_TABLE_ROW_KEEP:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::TABLE_ROW_KEEP, bTmp);
+ }
+ break;
+ case HANDLE_IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION, bTmp);
+ }
+ break;
+ case HANDLE_LOAD_READONLY:
+ {
+ mpDocSh->SetLoadReadonly( *(sal_Bool*)rValue.getValue() );
+ }
+ break;
+ case HANDLE_DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE, bTmp);
+ }
+ break;
+ case HANDLE_CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAMES:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAME, bTmp);
+ }
+ break;
+ case HANDLE_UNIX_FORCE_ZERO_EXT_LEADING:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::UNIX_FORCE_ZERO_EXT_LEADING, bTmp);
+ }
+ break;
+ case HANDLE_USE_OLD_PRINTER_METRICS:
+ // ignore - this is a dead property
+ break;
+ case HANDLE_TABS_RELATIVE_TO_INDENT:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::TABS_RELATIVE_TO_INDENT, bTmp);
+ }
+ break;
+ case HANDLE_RSID:
+ {
+ sal_uInt32 nTmp = 0;
+ rValue >>= nTmp;
+ mpDoc->setRsid( nTmp );
+ }
+ break;
+ case HANDLE_RSID_ROOT:
+ {
+ sal_uInt32 nTmp = 0;
+ rValue >>= nTmp;
+ mpDoc->setRsidRoot( nTmp );
+ }
+ break;
+ case HANDLE_PROTECT_FORM:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::PROTECT_FORM, bTmp);
+ }
+ break;
+ // #i89181#
+ case HANDLE_TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST, bTmp);
+ }
+ break;
+ case HANDLE_MODIFYPASSWORDINFO:
+ {
+ uno::Sequence< beans::PropertyValue > aInfo;
+ if ( !( rValue >>= aInfo ) )
+ throw lang::IllegalArgumentException(
+ OUString( "Value of type Sequence<PropertyValue> expected!" ),
+ uno::Reference< uno::XInterface >(),
+ 2 );
+
+ if ( !mpDocSh->SetModifyPasswordInfo( aInfo ) )
+ throw beans::PropertyVetoException(
+ OUString( "The hash is not allowed to be changed now!" ),
+ uno::Reference< uno::XInterface >() );
+ }
+ break;
+ case HANDLE_MATH_BASELINE_ALIGNMENT:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set( IDocumentSettingAccess::MATH_BASELINE_ALIGNMENT, bTmp );
+ }
+ break;
+ case HANDLE_INVERT_BORDER_SPACING:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::INVERT_BORDER_SPACING, bTmp);
+ }
+ break;
+ case HANDLE_COLLAPSE_EMPTY_CELL_PARA:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::COLLAPSE_EMPTY_CELL_PARA, bTmp);
+ }
+ break;
+ case HANDLE_SMALL_CAPS_PERCENTAGE_66:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::SMALL_CAPS_PERCENTAGE_66, bTmp);
+ }
+ break;
+ case HANDLE_TAB_OVERFLOW:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::TAB_OVERFLOW, bTmp);
+ }
+ break;
+ case HANDLE_UNBREAKABLE_NUMBERINGS:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::UNBREAKABLE_NUMBERINGS, bTmp);
+ }
+ break;
+ case HANDLE_STYLES_NODEFAULT:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::STYLES_NODEFAULT, bTmp);
+ }
+ break;
+ case HANDLE_FLOATTABLE_NOMARGINS:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::FLOATTABLE_NOMARGINS, bTmp);
+ }
+ break;
+ case HANDLE_CLIPPED_PICTURES:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::CLIPPED_PICTURES, bTmp);
+ }
+ break;
+ case HANDLE_BACKGROUND_PARA_OVER_DRAWINGS:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::BACKGROUND_PARA_OVER_DRAWINGS, bTmp);
+ }
+ break;
+ case HANDLE_EMBED_FONTS:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::EMBED_FONTS, bTmp);
+ }
+ case HANDLE_EMBED_SYSTEM_FONTS:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::EMBED_SYSTEM_FONTS, bTmp);
+ }
+ break;
+ case HANDLE_TAB_OVER_MARGIN:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::TAB_OVER_MARGIN, bTmp);
+ }
+ break;
+ case HANDLE_SURROUND_TEXT_WRAP_SMALL:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::SURROUND_TEXT_WRAP_SMALL, bTmp);
+ }
+ break;
+ default:
+ throw UnknownPropertyException();
+ }
+}
+
+void SwXDocumentSettings::_postSetValues ()
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException )
+{
+ // set printer only once, namely here!
+ if( mpPrinter != NULL )
+ {
+ // #i86352# the printer is also used as container for options by sfx
+ // when setting a printer it should have decent default options
+ SfxItemSet aOptions( mpPrinter->GetOptions() );
+ SwPrintData aPrtData( mpDoc->getPrintData() );
+ SwAddPrinterItem aAddPrinterItem (FN_PARAM_ADDPRINTER, aPrtData);
+ aOptions.Put(aAddPrinterItem);
+ mpPrinter->SetOptions( aOptions );
+
+ mpDoc->setPrinter( mpPrinter, true, true );
+ }
+
+ mpPrinter = 0;
+ mpDocSh = 0;
+ mpDoc = 0;
+}
+
+void SwXDocumentSettings::_preGetValues ()
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException )
+{
+ mpDocSh = mpModel->GetDocShell();
+ mpDoc = mpDocSh->GetDoc();
+ if( NULL == mpDoc || NULL == mpDocSh )
+ throw UnknownPropertyException();
+}
+
+void SwXDocumentSettings::_getSingleValue( const comphelper::PropertyInfo & rInfo, uno::Any & rValue )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException )
+{
+ switch( rInfo.mnHandle )
+ {
+ case HANDLE_FORBIDDEN_CHARS:
+ {
+ Reference<XForbiddenCharacters> xRet(*mpModel->GetPropertyHelper(), UNO_QUERY);
+ rValue <<= xRet;
+ }
+ break;
+ case HANDLE_LINK_UPDATE_MODE:
+ {
+ rValue <<= static_cast < sal_Int16 > ( mpDoc->getLinkUpdateMode(true) );
+ }
+ break;
+ case HANDLE_FIELD_AUTO_UPDATE:
+ {
+ SwFldUpdateFlags nFlags = mpDoc->getFieldUpdateFlags(true);
+ sal_Bool bFieldUpd = (nFlags == AUTOUPD_FIELD_ONLY || nFlags == AUTOUPD_FIELD_AND_CHARTS );
+ rValue.setValue(&bFieldUpd, ::getBooleanCppuType());
+ }
+ break;
+ case HANDLE_CHART_AUTO_UPDATE:
+ {
+ SwFldUpdateFlags nFlags = mpDoc->getFieldUpdateFlags(true);
+ sal_Bool bChartUpd = nFlags == AUTOUPD_FIELD_AND_CHARTS;
+ rValue.setValue(&bChartUpd, ::getBooleanCppuType());
+ }
+ break;
+ case HANDLE_ADD_PARA_TABLE_SPACING:
+ {
+ sal_Bool bParaSpace = mpDoc->get(IDocumentSettingAccess::PARA_SPACE_MAX);
+ rValue.setValue(&bParaSpace, ::getBooleanCppuType());
+ }
+ break;
+ case HANDLE_ADD_PARA_TABLE_SPACING_AT_START:
+ {
+ sal_Bool bParaSpace = mpDoc->get(IDocumentSettingAccess::PARA_SPACE_MAX_AT_PAGES);
+ rValue.setValue(&bParaSpace, ::getBooleanCppuType());
+ }
+ break;
+ case HANDLE_ALIGN_TAB_STOP_POSITION:
+ {
+ sal_Bool bAlignTab = mpDoc->get(IDocumentSettingAccess::TAB_COMPAT);
+ rValue.setValue(&bAlignTab, ::getBooleanCppuType());
+ }
+ break;
+ case HANDLE_PRINTER_NAME:
+ {
+ SfxPrinter *pPrinter = mpDoc->getPrinter( false );
+ rValue <<= pPrinter ? OUString ( pPrinter->GetName()) : OUString();
+ }
+ break;
+ case HANDLE_PRINTER_SETUP:
+ {
+ SfxPrinter *pPrinter = mpDoc->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 );
+ Sequence < sal_Int8 > aSequence( nSize );
+ aStream.Read ( aSequence.getArray(), nSize );
+ rValue <<= aSequence;
+ }
+ else
+ {
+ Sequence < sal_Int8 > aSequence ( 0 );
+ rValue <<= aSequence;
+ }
+ }
+ break;
+ case HANDLE_IS_KERN_ASIAN_PUNCTUATION:
+ {
+ sal_Bool bParaSpace = mpDoc->get(IDocumentSettingAccess::KERN_ASIAN_PUNCTUATION);
+ rValue.setValue(&bParaSpace, ::getBooleanCppuType());
+ }
+ break;
+ case HANDLE_APPLY_USER_DATA:
+ {
+ rValue <<= mpDocSh->IsUseUserData();
+ }
+ break;
+ case HANDLE_CHARACTER_COMPRESSION_TYPE:
+ {
+ rValue <<= static_cast < sal_Int16 > (mpDoc->getCharacterCompressionType());
+ }
+ break;
+ case HANDLE_SAVE_GLOBAL_DOCUMENT_LINKS:
+ {
+ sal_Bool bSaveGlobal = mpDoc->get(IDocumentSettingAccess::GLOBAL_DOCUMENT_SAVE_LINKS);
+ rValue.setValue(&bSaveGlobal, ::getBooleanCppuType());
+ }
+ break;
+ case HANDLE_CURRENT_DATABASE_DATA_SOURCE:
+ {
+ const SwDBData& rData = mpDoc->GetDBDesc();
+ rValue <<= rData.sDataSource;
+ }
+ break;
+ case HANDLE_CURRENT_DATABASE_COMMAND:
+ {
+ const SwDBData& rData = mpDoc->GetDBDesc();
+ rValue <<= rData.sCommand;
+ }
+ break;
+ case HANDLE_CURRENT_DATABASE_COMMAND_TYPE:
+ {
+ const SwDBData& rData = mpDoc->GetDBDesc();
+ rValue <<= rData.nCommandType;
+ }
+ break;
+ case HANDLE_SAVE_VERSION_ON_CLOSE:
+ {
+ rValue <<= mpDocSh->IsSaveVersionOnClose();
+ }
+ break;
+ case HANDLE_UPDATE_FROM_TEMPLATE:
+ {
+ rValue <<= mpDocSh->IsQueryLoadTemplate();
+ }
+ break;
+ case HANDLE_PRINTER_INDEPENDENT_LAYOUT:
+ {
+ // returns short (see css.document.PrinterIndependentLayout)
+ sal_Int16 nVirDevType = mpDoc->get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE) ?
+ ( mpDoc->get(IDocumentSettingAccess::USE_HIRES_VIRTUAL_DEVICE) ?
+ document::PrinterIndependentLayout::HIGH_RESOLUTION :
+ document::PrinterIndependentLayout::LOW_RESOLUTION ) :
+ document::PrinterIndependentLayout::DISABLED;
+ rValue <<= nVirDevType;
+ }
+ break;
+ case HANDLE_IS_LABEL_DOC:
+ {
+ sal_Bool bLabel = mpDoc->get(IDocumentSettingAccess::LABEL_DOCUMENT);
+ rValue <<= bLabel;
+ }
+ break;
+ case HANDLE_IS_ADD_FLY_OFFSET:
+ {
+ sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::ADD_FLY_OFFSETS);
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_IS_ADD_EXTERNAL_LEADING:
+ {
+ sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::ADD_EXT_LEADING);
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_OLD_NUMBERING: // #111955#
+ {
+ sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::OLD_NUMBERING);
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_OUTLINELEVEL_YIELDS_NUMBERING: // #111955#
+ {
+ sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::OUTLINE_LEVEL_YIELDS_OUTLINE_RULE);
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_ALLOW_PRINTJOB_CANCEL:
+ {
+ sal_Bool bPrintCancelState = mpDocSh->Stamp_GetPrintCancelState();
+ rValue.setValue(&bPrintCancelState, ::getBooleanCppuType());
+ }
+ break;
+ case HANDLE_USE_FORMER_LINE_SPACING:
+ {
+ sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::OLD_LINE_SPACING);
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_ADD_PARA_SPACING_TO_TABLE_CELLS:
+ {
+ sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::ADD_PARA_SPACING_TO_TABLE_CELLS);
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_USE_FORMER_OBJECT_POSITIONING:
+ {
+ sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::USE_FORMER_OBJECT_POS);
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_USE_FORMER_TEXT_WRAPPING:
+ {
+ sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::USE_FORMER_TEXT_WRAPPING);
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_CHANGES_PASSWORD:
+ {
+ rValue <<= mpDoc->GetRedlinePassword();
+ }
+ break;
+ case HANDLE_CONSIDER_WRAP_ON_OBJPOS:
+ {
+ sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::CONSIDER_WRAP_ON_OBJECT_POSITION);
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_IGNORE_FIRST_LINE_INDENT_IN_NUMBERING:
+ {
+ sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::IGNORE_FIRST_LINE_INDENT_IN_NUMBERING);
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK:
+ {
+ sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK);
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT:
+ {
+ sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT);
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_TABLE_ROW_KEEP :
+ {
+ sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::TABLE_ROW_KEEP);
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION:
+ {
+ sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION);
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_LOAD_READONLY:
+ {
+ rValue <<= mpDocSh->IsLoadReadonly();
+ }
+ break;
+ case HANDLE_DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE:
+ {
+ sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE);
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAMES:
+ {
+ sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAME);
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_UNIX_FORCE_ZERO_EXT_LEADING:
+ {
+ sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::UNIX_FORCE_ZERO_EXT_LEADING);
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_USE_OLD_PRINTER_METRICS:
+ {
+ sal_Bool bTmp = sal_False;
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_TABS_RELATIVE_TO_INDENT:
+ {
+ sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::TABS_RELATIVE_TO_INDENT);
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_RSID:
+ {
+ rValue <<= static_cast < sal_Int32 > ( mpDoc->getRsid() );
+ }
+ break;
+ case HANDLE_RSID_ROOT:
+ {
+ rValue <<= static_cast < sal_Int32 > ( mpDoc->getRsidRoot() );
+ }
+ break;
+ case HANDLE_PROTECT_FORM:
+ {
+ sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::PROTECT_FORM);
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ // #i89181#
+ case HANDLE_TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST:
+ {
+ sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST);
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_MODIFYPASSWORDINFO:
+ {
+ rValue <<= mpDocSh->GetModifyPasswordInfo();
+ }
+ break;
+ case HANDLE_MATH_BASELINE_ALIGNMENT:
+ {
+ sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::MATH_BASELINE_ALIGNMENT );
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_INVERT_BORDER_SPACING:
+ {
+ sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::INVERT_BORDER_SPACING);
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_COLLAPSE_EMPTY_CELL_PARA:
+ {
+ sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::COLLAPSE_EMPTY_CELL_PARA );
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_SMALL_CAPS_PERCENTAGE_66:
+ {
+ sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::SMALL_CAPS_PERCENTAGE_66 );
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_TAB_OVERFLOW:
+ {
+ sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::TAB_OVERFLOW );
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_UNBREAKABLE_NUMBERINGS:
+ {
+ sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::UNBREAKABLE_NUMBERINGS );
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_STYLES_NODEFAULT:
+ {
+ sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::STYLES_NODEFAULT );
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_FLOATTABLE_NOMARGINS:
+ {
+ sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::FLOATTABLE_NOMARGINS );
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_CLIPPED_PICTURES:
+ {
+ sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::CLIPPED_PICTURES );
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_BACKGROUND_PARA_OVER_DRAWINGS:
+ {
+ sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::BACKGROUND_PARA_OVER_DRAWINGS );
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_EMBED_FONTS:
+ {
+ sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::EMBED_FONTS );
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_EMBED_SYSTEM_FONTS:
+ {
+ sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::EMBED_SYSTEM_FONTS );
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_TAB_OVER_MARGIN:
+ {
+ sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::TAB_OVER_MARGIN );
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_SURROUND_TEXT_WRAP_SMALL:
+ {
+ sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::SURROUND_TEXT_WRAP_SMALL );
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ default:
+ throw UnknownPropertyException();
+ }
+}
+
+void SwXDocumentSettings::_postGetValues ()
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException )
+{
+ mpDocSh = 0;
+ mpDoc = 0;
+}
+
+// XServiceInfo
+OUString SAL_CALL SwXDocumentSettings::getImplementationName( )
+ throw(RuntimeException, std::exception)
+{
+ return OUString("com.sun.star.comp.Writer.DocumentSettings");
+}
+
+sal_Bool SAL_CALL SwXDocumentSettings::supportsService( const OUString& ServiceName )
+ throw(RuntimeException, std::exception)
+{
+ return cppu::supportsService(this, ServiceName);
+}
+
+Sequence< OUString > SAL_CALL SwXDocumentSettings::getSupportedServiceNames( )
+ throw(RuntimeException, std::exception)
+{
+ Sequence< OUString > aSeq( 3 );
+ aSeq[0] = "com.sun.star.document.Settings";
+ aSeq[1] = "com.sun.star.text.DocumentSettings";
+ aSeq[2] = "com.sun.star.text.PrintSettings";
+ return aSeq;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/uno/SwXDocumentSettings.hxx b/sw/source/core/uibase/uno/SwXDocumentSettings.hxx
new file mode 100644
index 000000000000..49edf23964a0
--- /dev/null
+++ b/sw/source/core/uibase/uno/SwXDocumentSettings.hxx
@@ -0,0 +1,93 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SW_SOURCE_UI_UNO_SWXDOCUMENTSETTINGS_HXX
+#define INCLUDED_SW_SOURCE_UI_UNO_SWXDOCUMENTSETTINGS_HXX
+
+#include <comphelper/MasterPropertySet.hxx>
+#include <com/sun/star/text/XTextDocument.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XTypeProvider.hpp>
+#include <cppuhelper/weak.hxx>
+#include <cppuhelper/implbase5.hxx>
+
+class SwXTextDocument;
+class SwDocShell;
+class SwDoc;
+class SfxPrinter;
+
+class SwXDocumentSettings :
+ public comphelper::MasterPropertySet,
+ public com::sun::star::lang::XServiceInfo,
+ public com::sun::star::lang::XTypeProvider,
+ public cppu::OWeakObject
+{
+protected:
+ com::sun::star::uno::Reference< com::sun::star::text::XTextDocument > mxModel;
+ SwXTextDocument* mpModel;
+ SwDocShell* mpDocSh;
+ SwDoc* mpDoc;
+
+ /** the printer should be set only once; since there are several
+ * printer-related properties, remember the last printer and set it in
+ * _postSetValues */
+ SfxPrinter* mpPrinter;
+
+ virtual void _preSetValues ()
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException );
+ virtual void _setSingleValue( const comphelper::PropertyInfo & rInfo, const ::com::sun::star::uno::Any &rValue )
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException );
+ virtual void _postSetValues ()
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException );
+
+ virtual void _preGetValues ()
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException );
+ virtual void _getSingleValue( const comphelper::PropertyInfo & rInfo, ::com::sun::star::uno::Any & rValue )
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException );
+ virtual void _postGetValues ()
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException );
+protected:
+ virtual ~SwXDocumentSettings()
+ throw();
+public:
+ SwXDocumentSettings( SwXTextDocument* pModel );
+
+ // XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType )
+ throw (::com::sun::star::uno::RuntimeException, std::exception);
+ virtual void SAL_CALL acquire( )
+ throw ();
+ virtual void SAL_CALL release( )
+ throw ();
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName( )
+ throw(com::sun::star::uno::RuntimeException, std::exception);
+ virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
+ throw(com::sun::star::uno::RuntimeException, std::exception);
+ virtual com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( )
+ throw(com::sun::star::uno::RuntimeException, std::exception);
+
+ // XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw (::com::sun::star::uno::RuntimeException, std::exception);
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (::com::sun::star::uno::RuntimeException, std::exception);
+};
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/uno/SwXFilterOptions.cxx b/sw/source/core/uibase/uno/SwXFilterOptions.cxx
new file mode 100644
index 000000000000..b944a9e0b6f4
--- /dev/null
+++ b/sw/source/core/uibase/uno/SwXFilterOptions.cxx
@@ -0,0 +1,179 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <SwXFilterOptions.hxx>
+#include <shellio.hxx>
+#include <swdll.hxx>
+#include <unoprnms.hxx>
+#include <osl/mutex.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/msgbox.hxx>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
+#include <cppuhelper/supportsservice.hxx>
+#include <unotools/ucbstreamhelper.hxx>
+#include <unotxdoc.hxx>
+
+#include "swabstdlg.hxx"
+#include "dialog.hrc"
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::ui::dialogs;
+using namespace ::com::sun::star::document;
+using namespace ::com::sun::star::lang;
+
+#define SWFILTEROPTIONSOBJ_IMPLNAME "com.sun.star.comp.Writer.FilterOptionsDialog"
+#define FILTER_OPTIONS_NAME "FilterOptions"
+
+SwXFilterOptions::SwXFilterOptions() :
+ bExport( sal_False )
+{
+}
+
+SwXFilterOptions::~SwXFilterOptions()
+{
+}
+
+OUString SwXFilterOptions::getImplementationName_Static()
+{
+ return OUString(SWFILTEROPTIONSOBJ_IMPLNAME);
+}
+
+uno::Sequence< OUString> SwXFilterOptions::getSupportedServiceNames_Static()
+{
+ OUString sService("com.sun.star.ui.dialogs.FilterOptionsDialog");
+ return uno::Sequence< OUString> (&sService, 1);
+}
+
+uno::Sequence< beans::PropertyValue > SwXFilterOptions::getPropertyValues() throw (uno::RuntimeException, std::exception)
+{
+ uno::Sequence<beans::PropertyValue> aRet(1);
+ beans::PropertyValue* pArray = aRet.getArray();
+
+ pArray[0].Name = OUString( FILTER_OPTIONS_NAME );
+ pArray[0].Value <<= sFilterOptions;
+
+ return aRet;
+}
+
+void SwXFilterOptions::setPropertyValues( const uno::Sequence<beans::PropertyValue >& aProps )
+ throw (beans::UnknownPropertyException, beans::PropertyVetoException,
+ IllegalArgumentException, WrappedTargetException, uno::RuntimeException, std::exception)
+{
+ const beans::PropertyValue* pPropArray = aProps.getConstArray();
+ long nPropCount = aProps.getLength();
+ for (long i = 0; i < nPropCount; i++)
+ {
+ const beans::PropertyValue& rProp = pPropArray[i];
+ OUString aPropName = rProp.Name;
+
+ if ( aPropName == UNO_NAME_FILTER_NAME )
+ rProp.Value >>= sFilterName;
+ else if ( aPropName == FILTER_OPTIONS_NAME )
+ rProp.Value >>= sFilterOptions;
+ else if ( aPropName == "InputStream" )
+ rProp.Value >>= xInputStream;
+ }
+}
+
+void SwXFilterOptions::setTitle( const OUString& /*rTitle*/ )
+ throw (uno::RuntimeException, std::exception)
+{
+}
+
+sal_Int16 SwXFilterOptions::execute() throw (uno::RuntimeException, std::exception)
+{
+ sal_Int16 nRet = ui::dialogs::ExecutableDialogResults::CANCEL;
+
+ SvStream* pInStream = NULL;
+ if ( xInputStream.is() )
+ pInStream = utl::UcbStreamHelper::CreateStream( xInputStream );
+
+ uno::Reference< XUnoTunnel > xTunnel(xModel, uno::UNO_QUERY);
+ SwDocShell* pDocShell = 0;
+ if(xTunnel.is())
+ {
+ SwXTextDocument* pXDoc = reinterpret_cast< SwXTextDocument * >(
+ sal::static_int_cast< sal_IntPtr >(xTunnel->getSomething(SwXTextDocument::getUnoTunnelId())));
+ pDocShell = pXDoc ? pXDoc->GetDocShell() : 0;
+ }
+ if(pDocShell)
+ {
+
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+
+ AbstractSwAsciiFilterDlg* pAsciiDlg = pFact->CreateSwAsciiFilterDlg(NULL, *pDocShell,
+ pInStream);
+ OSL_ENSURE(pAsciiDlg, "Dialogdiet fail!");
+ if(RET_OK == pAsciiDlg->Execute())
+ {
+ SwAsciiOptions aOptions;
+ pAsciiDlg->FillOptions( aOptions );
+ aOptions.WriteUserData(sFilterOptions);
+ nRet = ui::dialogs::ExecutableDialogResults::OK;
+ }
+ delete pAsciiDlg;
+ }
+
+ delete pInStream;
+
+ return nRet;
+}
+
+void SwXFilterOptions::setTargetDocument( const uno::Reference< XComponent >& xDoc )
+ throw (IllegalArgumentException, uno::RuntimeException, std::exception)
+{
+ bExport = sal_False;
+ xModel = xDoc;
+}
+
+void SwXFilterOptions::setSourceDocument( const uno::Reference<XComponent >& xDoc )
+ throw (IllegalArgumentException,uno::RuntimeException, std::exception)
+{
+ bExport = sal_True;
+ xModel = xDoc;
+}
+
+OUString SwXFilterOptions::getImplementationName() throw(uno::RuntimeException, std::exception)
+{
+ return OUString(SWFILTEROPTIONSOBJ_IMPLNAME);
+}
+
+sal_Bool SwXFilterOptions::supportsService( const OUString& rServiceName )
+ throw(uno::RuntimeException, std::exception)
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+uno::Sequence< OUString > SwXFilterOptions::getSupportedServiceNames()
+ throw(uno::RuntimeException, std::exception)
+{
+ return SwXFilterOptions::getSupportedServiceNames_Static();
+}
+
+uno::Reference<uno::XInterface> SAL_CALL SwXFilterOptions_createInstance(
+ const uno::Reference<lang::XMultiServiceFactory>& )
+{
+ SolarMutexGuard aGuard;
+ SwGlobals::ensure();
+ return (::cppu::OWeakObject*) new SwXFilterOptions;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/uno/dlelstnr.cxx b/sw/source/core/uibase/uno/dlelstnr.cxx
new file mode 100644
index 000000000000..802d45c40f4b
--- /dev/null
+++ b/sw/source/core/uibase/uno/dlelstnr.cxx
@@ -0,0 +1,165 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <com/sun/star/frame/Desktop.hpp>
+#include <com/sun/star/linguistic2/DictionaryListEventFlags.hpp>
+#include <com/sun/star/linguistic2/XDictionaryList.hpp>
+#include <com/sun/star/linguistic2/LinguServiceManager.hpp>
+#include <com/sun/star/linguistic2/XLinguServiceEventBroadcaster.hpp>
+#include <com/sun/star/linguistic2/ProofreadingIterator.hpp>
+#include <com/sun/star/linguistic2/LinguServiceEventFlags.hpp>
+
+#include <unotools/lingucfg.hxx>
+
+#include <com/sun/star/uno/Reference.h>
+#include <comphelper/processfactory.hxx>
+#include <osl/mutex.hxx>
+#include <vcl/svapp.hxx>
+#include <tools/shl.hxx>
+#include "dlelstnr.hxx"
+#include <swmodule.hxx>
+#include <wrtsh.hxx>
+#include <view.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::linguistic2;
+using namespace ::com::sun::star::linguistic2::LinguServiceEventFlags;
+
+SwLinguServiceEventListener::SwLinguServiceEventListener()
+{
+ Reference< XComponentContext > xContext( comphelper::getProcessComponentContext() );
+ try
+ {
+ xDesktop = frame::Desktop::create(xContext);
+ xDesktop->addTerminateListener( this );
+
+ xLngSvcMgr = LinguServiceManager::create(xContext);
+ xLngSvcMgr->addLinguServiceManagerListener( (XLinguServiceEventListener *) this );
+
+ if (SvtLinguConfig().HasGrammarChecker())
+ {
+ xGCIterator = ProofreadingIterator::create(xContext);
+ Reference< XLinguServiceEventBroadcaster > xBC( xGCIterator, UNO_QUERY );
+ if (xBC.is())
+ xBC->addLinguServiceEventListener( (XLinguServiceEventListener *) this );
+ }
+ }
+ catch (const uno::Exception&)
+ {
+ OSL_FAIL("exception caught in SwLinguServiceEventListener c-tor" );
+ }
+}
+
+SwLinguServiceEventListener::~SwLinguServiceEventListener()
+{
+}
+
+void SwLinguServiceEventListener::processDictionaryListEvent(
+ const DictionaryListEvent& rDicListEvent)
+ throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+
+ sal_Int16 nEvt = rDicListEvent.nCondensedEvent;
+
+ sal_Int16 nSpellWrongFlags =
+ DictionaryListEventFlags::ADD_POS_ENTRY |
+ DictionaryListEventFlags::DEL_NEG_ENTRY |
+ DictionaryListEventFlags::ACTIVATE_POS_DIC |
+ DictionaryListEventFlags::DEACTIVATE_NEG_DIC;
+ bool bIsSpellWrong = 0 != (nEvt & nSpellWrongFlags);
+ sal_Int16 nSpellAllFlags =
+ DictionaryListEventFlags::ADD_NEG_ENTRY |
+ DictionaryListEventFlags::DEL_POS_ENTRY |
+ DictionaryListEventFlags::ACTIVATE_NEG_DIC |
+ DictionaryListEventFlags::DEACTIVATE_POS_DIC;
+ bool bIsSpellAll = 0 != (nEvt & nSpellAllFlags);
+
+ if (bIsSpellWrong || bIsSpellAll)
+ SW_MOD()->CheckSpellChanges( false, bIsSpellWrong, bIsSpellAll, false );
+}
+
+void SAL_CALL SwLinguServiceEventListener::processLinguServiceEvent(
+ const LinguServiceEvent& rLngSvcEvent )
+ throw(RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+
+ bool bIsSpellWrong = 0 != (rLngSvcEvent.nEvent & SPELL_WRONG_WORDS_AGAIN);
+ bool bIsSpellAll = 0 != (rLngSvcEvent.nEvent & SPELL_CORRECT_WORDS_AGAIN);
+ if (0 != (rLngSvcEvent.nEvent & PROOFREAD_AGAIN))
+ bIsSpellWrong = bIsSpellAll = true; // have all spelling and grammar checked...
+ if (bIsSpellWrong || bIsSpellAll)
+ {
+ SW_MOD()->CheckSpellChanges( false, bIsSpellWrong, bIsSpellAll, false );
+ }
+ if (rLngSvcEvent.nEvent & HYPHENATE_AGAIN)
+ {
+ SwView *pSwView = SW_MOD()->GetFirstView();
+
+ //!! since this function may be called within the ctor of
+ //!! SwView (during formatting) where the WrtShell is not yet
+ //!! created, we have to check for the WrtShellPtr to see
+ //!! if it is already availbale
+ while (pSwView && pSwView->GetWrtShellPtr())
+ {
+ pSwView->GetWrtShell().ChgHyphenation();
+ pSwView = SW_MOD()->GetNextView( pSwView );
+ }
+ }
+}
+
+void SAL_CALL SwLinguServiceEventListener::disposing(
+ const EventObject& rEventObj )
+ throw(RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+
+ if (xLngSvcMgr.is() && rEventObj.Source == xLngSvcMgr)
+ xLngSvcMgr = 0;
+ if (xLngSvcMgr.is() && rEventObj.Source == xGCIterator)
+ xGCIterator = 0;
+}
+
+void SAL_CALL SwLinguServiceEventListener::queryTermination(
+ const EventObject& /*rEventObj*/ )
+ throw(TerminationVetoException, RuntimeException, std::exception)
+{
+}
+
+void SAL_CALL SwLinguServiceEventListener::notifyTermination(
+ const EventObject& rEventObj )
+ throw(RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+
+ if (xDesktop.is() && rEventObj.Source == xDesktop)
+ {
+ if (xLngSvcMgr.is())
+ xLngSvcMgr = 0;
+ if (xGCIterator.is())
+ xGCIterator = 0;
+ xDesktop = NULL;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/uno/unoatxt.cxx b/sw/source/core/uibase/uno/unoatxt.cxx
new file mode 100644
index 000000000000..3b381151a758
--- /dev/null
+++ b/sw/source/core/uibase/uno/unoatxt.cxx
@@ -0,0 +1,1121 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <osl/mutex.hxx>
+#include <osl/diagnose.h>
+#include <vcl/svapp.hxx>
+#include <svtools/unoevent.hxx>
+#include <svl/urihelper.hxx>
+#include <sfx2/event.hxx>
+#include <swtypes.hxx>
+#include <glosdoc.hxx>
+#include <shellio.hxx>
+#include <initui.hxx>
+#include <gloslst.hxx>
+#include <unoatxt.hxx>
+#include <unomap.hxx>
+#include <unomid.h>
+#include <unotextbodyhf.hxx>
+#include <unotextrange.hxx>
+#include <TextCursorHelper.hxx>
+#include <swevent.hxx>
+#include <doc.hxx>
+#include <unocrsr.hxx>
+#include <IMark.hxx>
+#include <unoprnms.hxx>
+#include <docsh.hxx>
+#include <swmodule.hxx>
+#include <svl/smplhint.hxx>
+#include <svl/macitem.hxx>
+#include <editeng/acorrcfg.hxx>
+#include <comphelper/servicehelper.hxx>
+#include <comphelper/string.hxx>
+#include <cppuhelper/supportsservice.hxx>
+
+#include <boost/scoped_ptr.hpp>
+
+SV_IMPL_REF ( SwDocShell )
+using namespace ::com::sun::star;
+
+uno::Reference< uno::XInterface > SAL_CALL SwXAutoTextContainer_createInstance(
+ const uno::Reference< lang::XMultiServiceFactory > & ) throw( uno::Exception )
+{
+ //the module may not be loaded
+ SolarMutexGuard aGuard;
+ SwGlobals::ensure();
+ static uno::Reference< uno::XInterface > xAText = (cppu::OWeakObject*)new SwXAutoTextContainer();
+ return xAText;
+}
+
+uno::Sequence< OUString > SAL_CALL SwXAutoTextContainer_getSupportedServiceNames() throw()
+{
+ OUString sService("com.sun.star.text.AutoTextContainer");
+ const uno::Sequence< OUString > aSeq( &sService, 1 );
+ return aSeq;
+}
+
+OUString SAL_CALL SwXAutoTextContainer_getImplementationName() throw()
+{
+ return OUString("SwXAutoTextContainer" );
+}
+
+SwXAutoTextContainer::SwXAutoTextContainer()
+{
+ pGlossaries = ::GetGlossaries();
+
+}
+
+SwXAutoTextContainer::~SwXAutoTextContainer()
+{
+
+}
+
+sal_Int32 SwXAutoTextContainer::getCount(void) throw( uno::RuntimeException, std::exception )
+{
+ return pGlossaries->GetGroupCnt();
+}
+
+uno::Any SwXAutoTextContainer::getByIndex(sal_Int32 nIndex)
+ throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ uno::Any aRet;
+ sal_uInt16 nCount = pGlossaries->GetGroupCnt();
+ if ( 0 <= nIndex && nIndex < nCount )
+ aRet = getByName(pGlossaries->GetGroupName( static_cast< sal_uInt16 >(nIndex) ));
+ else
+ throw lang::IndexOutOfBoundsException();
+ return aRet;
+}
+
+uno::Type SwXAutoTextContainer::getElementType(void) throw( uno::RuntimeException, std::exception )
+{
+ return ::getCppuType((const uno::Reference<text::XAutoTextGroup>*)0);
+
+}
+
+sal_Bool SwXAutoTextContainer::hasElements(void) throw( uno::RuntimeException, std::exception )
+{
+ // At least standard should always exists!
+ return sal_True;
+}
+
+uno::Any SwXAutoTextContainer::getByName(const OUString& GroupName)
+ throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+
+ uno::Reference< text::XAutoTextGroup > xGroup;
+ if ( pGlossaries && hasByName( GroupName ) ) // group name already known?
+ // sal_True = create group if not already available
+ xGroup = pGlossaries->GetAutoTextGroup( GroupName, true );
+
+ if ( !xGroup.is() )
+ throw container::NoSuchElementException();
+
+ return makeAny( xGroup );
+}
+
+uno::Sequence< OUString > SwXAutoTextContainer::getElementNames(void) throw( uno::RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ sal_uInt16 nCount = pGlossaries->GetGroupCnt();
+
+ uno::Sequence< OUString > aGroupNames(nCount);
+ OUString *pArr = aGroupNames.getArray();
+
+ for ( sal_uInt16 i = 0; i < nCount; i++ )
+ {
+ // The names will be passed without a path extension.
+ OUString sGroupName(pGlossaries->GetGroupName(i));
+ pArr[i] = sGroupName.getToken(0, GLOS_DELIM);
+ }
+ return aGroupNames;
+}
+// Finds group names with or without path index.
+sal_Bool SwXAutoTextContainer::hasByName(const OUString& Name)
+ throw( uno::RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ OUString sGroupName( pGlossaries->GetCompleteGroupName( Name ) );
+ if(!sGroupName.isEmpty())
+ return sal_True;
+ return sal_False;
+}
+
+uno::Reference< text::XAutoTextGroup > SwXAutoTextContainer::insertNewByName(
+ const OUString& aGroupName)
+ throw( lang::IllegalArgumentException, container::ElementExistException, uno::RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ if(hasByName(aGroupName))
+ throw container::ElementExistException();
+ //check for non-ASCII characters
+ if(aGroupName.isEmpty())
+ {
+ lang::IllegalArgumentException aIllegal;
+ aIllegal.Message = "group name must not be empty";
+ throw aIllegal;
+ }
+ for(sal_Int32 nPos = 0; nPos < aGroupName.getLength(); nPos++)
+ {
+ sal_Unicode cChar = aGroupName[nPos];
+ if (comphelper::string::isalnumAscii(cChar) ||
+ (cChar == '_') ||
+ (cChar == 0x20) ||
+ (cChar == GLOS_DELIM) )
+ {
+ continue;
+ }
+ lang::IllegalArgumentException aIllegal;
+ aIllegal.Message = "group name must contain a-z, A-z, '_', ' ' only";
+ throw aIllegal;
+ }
+ OUString sGroup(aGroupName);
+ if (sGroup.indexOf(GLOS_DELIM)<0)
+ {
+ sGroup += OUString(GLOS_DELIM) + "0";
+ }
+ pGlossaries->NewGroupDoc(sGroup, sGroup.getToken(0, GLOS_DELIM));
+
+ uno::Reference< text::XAutoTextGroup > xGroup = pGlossaries->GetAutoTextGroup( sGroup, true );
+ OSL_ENSURE( xGroup.is(), "SwXAutoTextContainer::insertNewByName: no UNO object created? How this?" );
+ // We just inserted the group into the glossaries, so why doesn't it exist?
+
+ return xGroup;
+}
+
+void SwXAutoTextContainer::removeByName(const OUString& aGroupName)
+ throw( container::NoSuchElementException, uno::RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ // At first find the name with path extension
+ OUString sGroupName = pGlossaries->GetCompleteGroupName( aGroupName );
+ if(sGroupName.isEmpty())
+ throw container::NoSuchElementException();
+ pGlossaries->DelGroupDoc(sGroupName);
+}
+
+OUString SwXAutoTextContainer::getImplementationName(void) throw( uno::RuntimeException, std::exception )
+{
+ return SwXAutoTextContainer_getImplementationName();
+}
+
+sal_Bool SwXAutoTextContainer::supportsService(const OUString& rServiceName) throw( uno::RuntimeException, std::exception )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+uno::Sequence< OUString > SwXAutoTextContainer::getSupportedServiceNames(void) throw( uno::RuntimeException, std::exception )
+{
+ return SwXAutoTextContainer_getSupportedServiceNames();
+}
+
+namespace
+{
+ class theSwXAutoTextGroupUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXAutoTextGroupUnoTunnelId > {};
+}
+
+const uno::Sequence< sal_Int8 > & SwXAutoTextGroup::getUnoTunnelId()
+{
+ return theSwXAutoTextGroupUnoTunnelId::get().getSeq();
+}
+
+sal_Int64 SAL_CALL SwXAutoTextGroup::getSomething( const uno::Sequence< sal_Int8 >& rId )
+ throw(uno::RuntimeException, std::exception)
+{
+ if( rId.getLength() == 16
+ && 0 == memcmp( getUnoTunnelId().getConstArray(),
+ rId.getConstArray(), 16 ) )
+ {
+ return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this ));
+ }
+ return 0;
+}
+
+SwXAutoTextGroup::SwXAutoTextGroup(const OUString& rName,
+ SwGlossaries* pGlos) :
+ pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_AUTO_TEXT_GROUP)),
+ pGlossaries(pGlos),
+ sName(rName),
+ m_sGroupName(rName)
+{
+ OSL_ENSURE( -1 != rName.indexOf( GLOS_DELIM ),
+ "SwXAutoTextGroup::SwXAutoTextGroup: to be constructed with a complete name only!" );
+}
+
+SwXAutoTextGroup::~SwXAutoTextGroup()
+{
+}
+
+uno::Sequence< OUString > SwXAutoTextGroup::getTitles(void) throw( uno::RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ sal_uInt16 nCount = 0;
+ SwTextBlocks* pGlosGroup = pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName, sal_False) : 0;
+ if(pGlosGroup && !pGlosGroup->GetError())
+ nCount = pGlosGroup->GetCount();
+ else
+ throw uno::RuntimeException();
+
+ uno::Sequence< OUString > aEntryTitles(nCount);
+ OUString *pArr = aEntryTitles.getArray();
+
+ for ( sal_uInt16 i = 0; i < nCount; i++ )
+ pArr[i] = pGlosGroup->GetLongName(i);
+ delete pGlosGroup;
+ return aEntryTitles;
+}
+
+void SwXAutoTextGroup::renameByName(const OUString& aElementName,
+ const OUString& aNewElementName, const OUString& aNewElementTitle)
+ throw( lang::IllegalArgumentException, container::ElementExistException, io::IOException,
+ uno::RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ // throw exception only if the programmatic name is to be changed into an existing name
+ if(aNewElementName != aElementName && hasByName(aNewElementName))
+ throw container::ElementExistException();
+ SwTextBlocks* pGlosGroup = pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName, sal_False) : 0;
+ if(pGlosGroup && !pGlosGroup->GetError())
+ {
+ sal_uInt16 nIdx = pGlosGroup->GetIndex( aElementName);
+ if(USHRT_MAX == nIdx)
+ throw lang::IllegalArgumentException();
+ OUString aNewShort(aNewElementName);
+ OUString aNewName(aNewElementTitle);
+ sal_uInt16 nOldLongIdx = pGlosGroup->GetLongIndex( aNewShort );
+ sal_uInt16 nOldIdx = pGlosGroup->GetIndex( aNewName );
+
+ if( nIdx != USHRT_MAX &&
+ (nOldLongIdx == USHRT_MAX || nOldLongIdx == nIdx )&&
+ (nOldIdx == USHRT_MAX || nOldIdx == nIdx ))
+ {
+ pGlosGroup->Rename( nIdx, &aNewShort, &aNewName );
+ if(pGlosGroup->GetError() != 0)
+ throw io::IOException();
+ }
+ delete pGlosGroup;
+ }
+ else
+ throw uno::RuntimeException();
+}
+
+static bool lcl_CopySelToDoc( SwDoc* pInsDoc, OTextCursorHelper* pxCursor, SwXTextRange* pxRange)
+{
+ OSL_ENSURE( pInsDoc, "no InsDoc");
+
+ SwNodes& rNds = pInsDoc->GetNodes();
+
+ SwNodeIndex aIdx( rNds.GetEndOfContent(), -1 );
+ SwCntntNode * pNd = aIdx.GetNode().GetCntntNode();
+ SwPosition aPos( aIdx, SwIndex( pNd, pNd->Len() ));
+
+ bool bRet = false;
+ pInsDoc->LockExpFlds();
+ {
+ SwDoc *const pDoc((pxCursor) ? pxCursor->GetDoc() : pxRange->GetDoc());
+ SwPaM aPam(pDoc->GetNodes());
+ SwPaM * pPam(0);
+ if(pxCursor)
+ {
+ pPam = pxCursor->GetPaM();
+ }
+ else
+ {
+ if (pxRange->GetPositions(aPam))
+ {
+ pPam = & aPam;
+ }
+ }
+ if (!pPam) { return false; }
+ bRet = pDoc->CopyRange( *pPam, aPos, false ) || bRet;
+ }
+
+ pInsDoc->UnlockExpFlds();
+ if( !pInsDoc->IsExpFldsLocked() )
+ pInsDoc->UpdateExpFlds(NULL, true);
+
+ return bRet;
+}
+
+uno::Reference< text::XAutoTextEntry > SwXAutoTextGroup::insertNewByName(const OUString& aName,
+ const OUString& aTitle, const uno::Reference< text::XTextRange > & xTextRange)
+ throw( container::ElementExistException, uno::RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ if(hasByName(aName))
+ throw container::ElementExistException();
+ if(!xTextRange.is())
+ throw uno::RuntimeException();
+
+ SwTextBlocks* pGlosGroup = pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName, sal_False) : 0;
+ OUString sShortName(aName);
+ OUString sLongName(aTitle);
+ if(pGlosGroup && !pGlosGroup->GetError())
+ {
+ uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY);
+ SwXTextRange* pxRange = 0;
+ OTextCursorHelper* pxCursor = 0;
+ if(xRangeTunnel.is())
+ {
+ pxRange = reinterpret_cast<SwXTextRange*>(xRangeTunnel->getSomething(
+ SwXTextRange::getUnoTunnelId()));
+ pxCursor = reinterpret_cast<OTextCursorHelper*>(xRangeTunnel->getSomething(
+ OTextCursorHelper::getUnoTunnelId()));
+ }
+
+ OUString sOnlyTxt;
+ OUString* pOnlyTxt = 0;
+ bool bNoAttr = !pxCursor && !pxRange;
+ if(bNoAttr)
+ {
+ sOnlyTxt = OUString(xTextRange->getString());
+ pOnlyTxt = &sOnlyTxt;
+ }
+
+ const SvxAutoCorrCfg& rCfg = SvxAutoCorrCfg::Get();
+
+ SwDoc* pGDoc = pGlosGroup->GetDoc();
+
+ // Until there is an option for that, delete base util::URL
+ if(rCfg.IsSaveRelFile())
+ {
+ INetURLObject aTemp(pGlosGroup->GetFileName());
+ pGlosGroup->SetBaseURL( aTemp.GetMainURL(INetURLObject::NO_DECODE));
+ }
+ else
+ pGlosGroup->SetBaseURL( OUString() );
+
+ sal_uInt16 nRet;
+ if( pOnlyTxt )
+ nRet = pGlosGroup->PutText( sShortName, sLongName, *pOnlyTxt );
+ else
+ {
+ pGlosGroup->ClearDoc();
+ if( pGlosGroup->BeginPutDoc( sShortName, sLongName ) )
+ {
+ pGDoc->SetRedlineMode_intern( nsRedlineMode_t::REDLINE_DELETE_REDLINES );
+ lcl_CopySelToDoc( pGDoc, pxCursor, pxRange );
+ pGDoc->SetRedlineMode_intern((RedlineMode_t)( 0 ));
+ nRet = pGlosGroup->PutDoc();
+ }
+ else
+ nRet = (sal_uInt16) -1;
+ }
+
+ if(nRet == (sal_uInt16) -1 )
+ {
+ throw uno::RuntimeException();
+ }
+ pGlossaries->PutGroupDoc( pGlosGroup );
+ }
+
+ uno::Reference< text::XAutoTextEntry > xEntry = pGlossaries->GetAutoTextEntry( m_sGroupName, sName, sShortName, true );
+ OSL_ENSURE( xEntry.is(), "SwXAutoTextGroup::insertNewByName: no UNO object created? How this?" );
+ // we just inserted the entry into the group, so why doesn't it exist?
+
+ return xEntry;
+}
+
+void SwXAutoTextGroup::removeByName(const OUString& aEntryName) throw( container::NoSuchElementException, uno::RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ SwTextBlocks* pGlosGroup = pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName, sal_False) : 0;
+ if(pGlosGroup && !pGlosGroup->GetError())
+ {
+ sal_uInt16 nIdx = pGlosGroup->GetIndex(aEntryName);
+ if ( nIdx != USHRT_MAX )
+ pGlosGroup->Delete(nIdx);
+ delete pGlosGroup;
+ }
+ else
+ throw container::NoSuchElementException();
+}
+
+OUString SwXAutoTextGroup::getName(void) throw( uno::RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ return sName;
+}
+
+void SwXAutoTextGroup::setName(const OUString& rName) throw( uno::RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ if( !pGlossaries )
+ throw uno::RuntimeException();
+
+ sal_Int32 nNewDelimPos = rName.lastIndexOf( GLOS_DELIM );
+ sal_Int32 nOldDelimPos = sName.lastIndexOf( GLOS_DELIM );
+
+ OUString aNewSuffix;
+ if (nNewDelimPos > -1)
+ aNewSuffix = rName.copy( nNewDelimPos + 1 );
+ OUString aOldSuffix;
+ if (nOldDelimPos > -1)
+ aOldSuffix = sName.copy( nOldDelimPos + 1 );
+
+ sal_Int32 nNewNumeric = aNewSuffix.toInt32();
+ sal_Int32 nOldNumeric = aOldSuffix.toInt32();
+
+ OUString aNewPrefix( (nNewDelimPos > 1) ? rName.copy( 0, nNewDelimPos ) : rName );
+ OUString aOldPrefix( (nOldDelimPos > 1) ? sName.copy( 0, nOldDelimPos ) : sName );
+
+ if ( sName == rName ||
+ ( nNewNumeric == nOldNumeric && aNewPrefix == aOldPrefix ) )
+ return;
+ OUString sNewGroup(rName);
+ if (sNewGroup.indexOf(GLOS_DELIM)<0)
+ {
+ sNewGroup += OUString(GLOS_DELIM) + "0";
+ }
+
+ //the name must be saved, the group may be invalidated while in RenameGroupDoc()
+ SwGlossaries* pTempGlossaries = pGlossaries;
+
+ OUString sPreserveTitle( pGlossaries->GetGroupTitle( sName ) );
+ if ( !pGlossaries->RenameGroupDoc( sName, sNewGroup, sPreserveTitle ) )
+ throw uno::RuntimeException();
+ else
+ {
+ sName = rName;
+ m_sGroupName = sNewGroup;
+ pGlossaries = pTempGlossaries;
+ }
+}
+
+sal_Int32 SwXAutoTextGroup::getCount(void) throw( uno::RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ int nCount = 0;
+ SwTextBlocks* pGlosGroup = pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName, sal_False) : 0;
+ if(pGlosGroup && !pGlosGroup->GetError())
+ nCount = pGlosGroup->GetCount();
+ else
+ throw uno::RuntimeException();
+ delete pGlosGroup;
+ return nCount;
+}
+
+uno::Any SwXAutoTextGroup::getByIndex(sal_Int32 nIndex)
+ throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ uno::Any aRet;
+ sal_uInt16 nCount = 0;
+ SwTextBlocks* pGlosGroup = pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName, sal_False) : 0;
+ if(pGlosGroup && !pGlosGroup->GetError())
+ nCount = pGlosGroup->GetCount();
+ else
+ throw uno::RuntimeException();
+ if(0 <= nIndex && nIndex < nCount)
+ aRet = getByName(pGlosGroup->GetShortName((sal_uInt16) nIndex));
+ else
+ throw lang::IndexOutOfBoundsException();
+ delete pGlosGroup;
+ return aRet;
+}
+
+uno::Type SwXAutoTextGroup::getElementType(void) throw( uno::RuntimeException, std::exception )
+{
+ return ::getCppuType((uno::Reference<text::XAutoTextEntry>*)0);
+
+}
+
+sal_Bool SwXAutoTextGroup::hasElements(void) throw( uno::RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ SwTextBlocks* pGlosGroup = pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName, sal_False) : 0;
+ sal_uInt16 nCount = 0;
+ if(pGlosGroup && !pGlosGroup->GetError())
+ nCount = pGlosGroup->GetCount();
+ else
+ throw uno::RuntimeException();
+ delete pGlosGroup;
+ return nCount > 0;
+
+}
+
+uno::Any SwXAutoTextGroup::getByName(const OUString& _rName)
+ throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ uno::Reference< text::XAutoTextEntry > xEntry = pGlossaries->GetAutoTextEntry( m_sGroupName, sName, _rName, true );
+ OSL_ENSURE( xEntry.is(), "SwXAutoTextGroup::getByName: GetAutoTextEntry is fractious!" );
+ // we told it to create the object, so why didn't it?
+ return makeAny( xEntry );
+}
+
+uno::Sequence< OUString > SwXAutoTextGroup::getElementNames(void)
+ throw( uno::RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ sal_uInt16 nCount = 0;
+ SwTextBlocks* pGlosGroup = pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName, sal_False) : 0;
+ if(pGlosGroup && !pGlosGroup->GetError())
+ nCount = pGlosGroup->GetCount();
+ else
+ throw uno::RuntimeException();
+
+ uno::Sequence< OUString > aEntryNames(nCount);
+ OUString *pArr = aEntryNames.getArray();
+
+ for ( sal_uInt16 i = 0; i < nCount; i++ )
+ pArr[i] = pGlosGroup->GetShortName(i);
+ delete pGlosGroup;
+ return aEntryNames;
+}
+
+sal_Bool SwXAutoTextGroup::hasByName(const OUString& rName)
+ throw( uno::RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ sal_Bool bRet = sal_False;
+ sal_uInt16 nCount = 0;
+ SwTextBlocks* pGlosGroup = pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName, sal_False) : 0;
+ if(pGlosGroup && !pGlosGroup->GetError())
+ nCount = pGlosGroup->GetCount();
+ else
+ throw uno::RuntimeException();
+
+ for( sal_uInt16 i = 0; i < nCount; ++i )
+ {
+ OUString sCompare(pGlosGroup->GetShortName(i));
+ if(sCompare.equalsIgnoreAsciiCase(rName))
+ {
+ bRet = true;
+ break;
+ }
+ }
+ delete pGlosGroup;
+ return bRet;
+}
+
+uno::Reference< beans::XPropertySetInfo > SwXAutoTextGroup::getPropertySetInfo(void)
+ throw( uno::RuntimeException, std::exception )
+{
+ static uno::Reference< beans::XPropertySetInfo > xRet = pPropSet->getPropertySetInfo();
+ return xRet;
+}
+
+void SwXAutoTextGroup::setPropertyValue(
+ const OUString& rPropertyName, const uno::Any& aValue)
+ throw( beans::UnknownPropertyException, beans::PropertyVetoException,
+ lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ const SfxItemPropertySimpleEntry* pEntry = pPropSet->getPropertyMap().getByName( rPropertyName );
+
+ if(!pEntry)
+ throw beans::UnknownPropertyException();
+
+ SwTextBlocks* pGlosGroup = pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName, sal_False) : 0;
+ if(!pGlosGroup || pGlosGroup->GetError())
+ throw uno::RuntimeException();
+ switch(pEntry->nWID)
+ {
+ case WID_GROUP_TITLE:
+ {
+ OUString sNewTitle;
+ aValue >>= sNewTitle;
+ if(sNewTitle.isEmpty())
+ throw lang::IllegalArgumentException();
+ bool bChanged = !sNewTitle.equals(pGlosGroup->GetName());
+ pGlosGroup->SetName(sNewTitle);
+ if(bChanged && HasGlossaryList())
+ GetGlossaryList()->ClearGroups();
+ }
+ break;
+ }
+ delete pGlosGroup;
+}
+
+uno::Any SwXAutoTextGroup::getPropertyValue(const OUString& rPropertyName)
+ throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ const SfxItemPropertySimpleEntry* pEntry = pPropSet->getPropertyMap().getByName( rPropertyName);
+
+ if(!pEntry)
+ throw beans::UnknownPropertyException();
+ SwTextBlocks* pGlosGroup = pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName, sal_False) : 0;
+ if(!pGlosGroup || pGlosGroup->GetError())
+ throw uno::RuntimeException();
+
+ uno::Any aAny;
+ switch(pEntry->nWID)
+ {
+ case WID_GROUP_PATH:
+ aAny <<= OUString(pGlosGroup->GetFileName());
+ break;
+ case WID_GROUP_TITLE:
+ aAny <<= OUString(pGlosGroup->GetName());
+ break;
+ }
+ delete pGlosGroup;
+ return aAny;
+}
+
+void SwXAutoTextGroup::addPropertyChangeListener(
+ const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/)
+ throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
+{
+}
+
+void SwXAutoTextGroup::removePropertyChangeListener(
+ const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/)
+ throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
+{
+}
+
+void SwXAutoTextGroup::addVetoableChangeListener(
+ const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/)
+ throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
+{
+}
+
+void SwXAutoTextGroup::removeVetoableChangeListener(
+ const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/)
+ throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
+{
+}
+
+void SwXAutoTextGroup::Invalidate()
+{
+ pGlossaries = 0;
+ sName = OUString();
+ m_sGroupName = OUString();
+}
+
+OUString SwXAutoTextGroup::getImplementationName(void) throw( uno::RuntimeException, std::exception )
+{
+ return OUString("SwXAutoTextGroup");
+}
+
+sal_Bool SwXAutoTextGroup::supportsService(const OUString& rServiceName) throw( uno::RuntimeException, std::exception )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+uno::Sequence< OUString > SwXAutoTextGroup::getSupportedServiceNames(void) throw( uno::RuntimeException, std::exception )
+{
+ uno::Sequence< OUString > aRet(1);
+ OUString* pArray = aRet.getArray();
+ pArray[0] = "com.sun.star.text.AutoTextGroup";
+ return aRet;
+}
+
+namespace
+{
+ class theSwXAutoTextEntryUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXAutoTextEntryUnoTunnelId > {};
+}
+
+const uno::Sequence< sal_Int8 > & SwXAutoTextEntry::getUnoTunnelId()
+{
+ return theSwXAutoTextEntryUnoTunnelId::get().getSeq();
+}
+
+sal_Int64 SAL_CALL SwXAutoTextEntry::getSomething( const uno::Sequence< sal_Int8 >& rId )
+ throw(uno::RuntimeException, std::exception)
+{
+ if( rId.getLength() == 16
+ && 0 == memcmp( getUnoTunnelId().getConstArray(),
+ rId.getConstArray(), 16 ) )
+ {
+ return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this ));
+ }
+ return 0;
+}
+
+SwXAutoTextEntry::SwXAutoTextEntry(SwGlossaries* pGlss, const OUString& rGroupName,
+ const OUString& rEntryName) :
+ pGlossaries(pGlss),
+ sGroupName(rGroupName),
+ sEntryName(rEntryName),
+ pBodyText ( NULL )
+{
+}
+
+SwXAutoTextEntry::~SwXAutoTextEntry()
+{
+ {
+ SolarMutexGuard aGuard;
+
+ // ensure that any pending modifications are written
+ implFlushDocument( true );
+
+ //! Bug #96559
+ // DocShell must be cleared before mutex is lost.
+ // Needs to be done explicitly since xDocSh is a class member.
+ // Thus, an own block here, guarded by the SolarMutex
+ }
+}
+
+void SwXAutoTextEntry::implFlushDocument( bool _bCloseDoc )
+{
+ if ( xDocSh.Is() )
+ {
+ if ( xDocSh->GetDoc()->IsModified () )
+ xDocSh->Save();
+
+ if ( _bCloseDoc )
+ {
+ // stop listening at the document
+ EndListening( *&xDocSh );
+
+ xDocSh->DoClose();
+ xDocSh.Clear();
+ }
+ }
+}
+
+void SwXAutoTextEntry::Notify( SfxBroadcaster& _rBC, const SfxHint& _rHint )
+{
+ if ( &_rBC == &xDocSh )
+ { // it's our document
+ if ( _rHint.ISA( SfxSimpleHint ) )
+ {
+ if ( SFX_HINT_DEINITIALIZING == static_cast< const SfxSimpleHint& >( _rHint ).GetId() )
+ {
+ // our document is dying (possibly because we're shuting down, and the document was notified
+ // earlier than we are?)
+ // stop listening at the docu
+ EndListening( *&xDocSh );
+ // and release our reference
+ xDocSh.Clear();
+ }
+ }
+ else if(_rHint.ISA(SfxEventHint))
+ {
+ if(SFX_EVENT_PREPARECLOSEDOC == static_cast< const SfxEventHint& >( _rHint ).GetEventId())
+ {
+ implFlushDocument( false );
+ xBodyText = 0;
+ xDocSh.Clear();
+ }
+ }
+ }
+}
+
+void SwXAutoTextEntry::GetBodyText ()
+{
+ SolarMutexGuard aGuard;
+
+ xDocSh = pGlossaries->EditGroupDoc ( sGroupName, sEntryName, sal_False );
+ OSL_ENSURE( xDocSh.Is(), "SwXAutoTextEntry::GetBodyText: unexpected: no doc returned by EditGroupDoc!" );
+
+ // start listening at the document
+ StartListening( *&xDocSh );
+
+ pBodyText = new SwXBodyText ( xDocSh->GetDoc() );
+ xBodyText = uno::Reference < lang::XServiceInfo > ( *pBodyText, uno::UNO_QUERY);
+}
+
+uno::Reference< text::XTextCursor > SwXAutoTextEntry::createTextCursor(void) throw( uno::RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ EnsureBodyText();
+ return pBodyText->createTextCursor();
+}
+
+uno::Reference< text::XTextCursor > SwXAutoTextEntry::createTextCursorByRange(
+ const uno::Reference< text::XTextRange > & aTextPosition) throw( uno::RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ EnsureBodyText();
+ return pBodyText->createTextCursorByRange ( aTextPosition );
+}
+
+void SwXAutoTextEntry::insertString(const uno::Reference< text::XTextRange > & xRange, const OUString& aString, sal_Bool bAbsorb) throw( uno::RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ EnsureBodyText();
+ pBodyText->insertString ( xRange, aString, bAbsorb );
+}
+
+void SwXAutoTextEntry::insertControlCharacter(const uno::Reference< text::XTextRange > & xRange,
+ sal_Int16 nControlCharacter, sal_Bool bAbsorb)
+ throw( lang::IllegalArgumentException, uno::RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ EnsureBodyText();
+ pBodyText->insertControlCharacter ( xRange, nControlCharacter, bAbsorb );
+}
+
+void SwXAutoTextEntry::insertTextContent(
+ const uno::Reference< text::XTextRange > & xRange,
+ const uno::Reference< text::XTextContent > & xContent, sal_Bool bAbsorb)
+ throw( lang::IllegalArgumentException, uno::RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ EnsureBodyText();
+ pBodyText->insertTextContent ( xRange, xContent, bAbsorb );
+}
+
+void SwXAutoTextEntry::removeTextContent(
+ const uno::Reference< text::XTextContent > & xContent)
+ throw( container::NoSuchElementException, uno::RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ EnsureBodyText();
+ pBodyText->removeTextContent ( xContent );
+}
+
+uno::Reference< text::XText > SwXAutoTextEntry::getText(void) throw( uno::RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ uno::Reference< text::XText > xRet = (text::XText*)this;
+ return xRet;
+}
+
+uno::Reference< text::XTextRange > SwXAutoTextEntry::getStart(void) throw( uno::RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ EnsureBodyText();
+ return pBodyText->getStart();
+}
+
+uno::Reference< text::XTextRange > SwXAutoTextEntry::getEnd(void) throw( uno::RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ EnsureBodyText();
+ return pBodyText->getEnd();
+}
+
+OUString SwXAutoTextEntry::getString(void) throw( uno::RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ EnsureBodyText();
+ return pBodyText->getString();
+}
+
+void SwXAutoTextEntry::setString(const OUString& aString) throw( uno::RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ EnsureBodyText();
+ pBodyText->setString( aString );
+}
+
+void SwXAutoTextEntry::applyTo(const uno::Reference< text::XTextRange > & xTextRange)throw( uno::RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+
+ // ensure that any pending modifications are written
+ // reason is that we're holding the _copy_ of the auto text, while the real auto text
+ // is stored somewhere. And below, we're not working with our copy, but only tell the target
+ // TextRange to work with the stored version.
+ // #96380# - 2003-03-03 - fs@openoffice.org
+ implFlushDocument( false );
+ // TODO: think about if we should pass "true" here
+ // The difference would be that when the next modification is made to this instance here, then
+ // we would be forced to open the document again, instead of working on our current copy.
+ // This means that we would reflect any changes which were done to the AutoText by foreign instances
+ // in the meantime
+
+ uno::Reference<lang::XUnoTunnel> xTunnel( xTextRange, uno::UNO_QUERY);
+ SwXTextRange* pRange = 0;
+ OTextCursorHelper* pCursor = 0;
+ SwXText *pText = 0;
+
+ if(xTunnel.is())
+ {
+ pRange = reinterpret_cast < SwXTextRange* >
+ ( xTunnel->getSomething( SwXTextRange::getUnoTunnelId() ) );
+ pCursor = reinterpret_cast < OTextCursorHelper*>
+ ( xTunnel->getSomething( OTextCursorHelper::getUnoTunnelId() ) );
+ pText = reinterpret_cast < SwXText* >
+ ( xTunnel->getSomething( SwXText::getUnoTunnelId() ) );
+ }
+
+ SwDoc* pDoc = 0;
+ if (pRange)
+ pDoc = pRange->GetDoc();
+ else if ( pCursor )
+ pDoc = pCursor->GetDoc();
+ else if ( pText && pText->GetDoc() )
+ {
+ xTunnel = uno::Reference < lang::XUnoTunnel > (pText->getStart(), uno::UNO_QUERY);
+ if (xTunnel.is())
+ {
+ pCursor = reinterpret_cast < OTextCursorHelper* >
+ ( xTunnel->getSomething( OTextCursorHelper::getUnoTunnelId() ) );
+ if (pCursor)
+ pDoc = pText->GetDoc();
+ }
+ }
+
+ if(!pDoc)
+ throw uno::RuntimeException();
+
+ SwPaM InsertPaM(pDoc->GetNodes());
+ if (pRange)
+ {
+ if (!pRange->GetPositions(InsertPaM))
+ {
+ throw uno::RuntimeException();
+ }
+ }
+ else
+ {
+ InsertPaM = *pCursor->GetPaM();
+ }
+
+ boost::scoped_ptr<SwTextBlocks> pBlock(pGlossaries->GetGroupDoc(sGroupName));
+ const bool bResult = pBlock.get() && !pBlock->GetError()
+ && pDoc->InsertGlossary( *pBlock, sEntryName, InsertPaM);
+
+ if(!bResult)
+ throw uno::RuntimeException();
+}
+
+OUString SwXAutoTextEntry::getImplementationName(void) throw( uno::RuntimeException, std::exception )
+{
+ return OUString("SwXAutoTextEntry");
+}
+
+sal_Bool SwXAutoTextEntry::supportsService(const OUString& rServiceName) throw( uno::RuntimeException, std::exception )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+uno::Sequence< OUString > SwXAutoTextEntry::getSupportedServiceNames(void) throw( uno::RuntimeException, std::exception )
+{
+ uno::Sequence< OUString > aRet(1);
+ OUString* pArray = aRet.getArray();
+ pArray[0] = "com.sun.star.text.AutoTextEntry";
+ return aRet;
+}
+
+uno::Reference< container::XNameReplace > SwXAutoTextEntry::getEvents()
+ throw( uno::RuntimeException, std::exception )
+{
+ return new SwAutoTextEventDescriptor( *this );
+}
+
+const struct SvEventDescription aAutotextEvents[] =
+{
+ { SW_EVENT_START_INS_GLOSSARY, "OnInsertStart" },
+ { SW_EVENT_END_INS_GLOSSARY, "OnInsertDone" },
+ { 0, NULL }
+};
+
+SwAutoTextEventDescriptor::SwAutoTextEventDescriptor(
+ SwXAutoTextEntry& rAutoText ) :
+ SvBaseEventDescriptor(aAutotextEvents),
+ sSwAutoTextEventDescriptor(
+ "SwAutoTextEventDescriptor"),
+ rAutoTextEntry(rAutoText)
+{
+}
+
+SwAutoTextEventDescriptor::~SwAutoTextEventDescriptor()
+{
+}
+
+OUString SwAutoTextEventDescriptor::getImplementationName()
+ throw( uno::RuntimeException, std::exception )
+{
+ return sSwAutoTextEventDescriptor;
+}
+
+void SwAutoTextEventDescriptor::replaceByName(
+ const sal_uInt16 nEvent,
+ const SvxMacro& rMacro)
+ throw(
+ lang::IllegalArgumentException,
+ container::NoSuchElementException,
+ lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ OSL_ENSURE( NULL != rAutoTextEntry.GetGlossaries(),
+ "Strangely enough, the AutoText vanished!" );
+ OSL_ENSURE( (nEvent == SW_EVENT_END_INS_GLOSSARY) ||
+ (nEvent == SW_EVENT_START_INS_GLOSSARY) ,
+ "Unknown event ID" );
+
+ SwGlossaries *const pGlossaries =
+ const_cast<SwGlossaries*>(rAutoTextEntry.GetGlossaries());
+ SwTextBlocks* pBlocks =
+ pGlossaries->GetGroupDoc( rAutoTextEntry.GetGroupName() );
+ OSL_ENSURE( NULL != pBlocks,
+ "can't get autotext group; SwAutoTextEntry has illegal name?");
+
+ if( pBlocks && !pBlocks->GetError())
+ {
+ sal_uInt16 nIndex = pBlocks->GetIndex( rAutoTextEntry.GetEntryName() );
+ if( nIndex != USHRT_MAX )
+ {
+ SvxMacroTableDtor aMacroTable;
+ if( pBlocks->GetMacroTable( nIndex, aMacroTable ) )
+ {
+ aMacroTable.Insert( nEvent, rMacro );
+ pBlocks->SetMacroTable( nIndex, aMacroTable );
+ }
+ }
+
+ delete pBlocks;
+ }
+ // else: ignore
+}
+
+void SwAutoTextEventDescriptor::getByName(
+ SvxMacro& rMacro,
+ const sal_uInt16 nEvent )
+ throw(
+ container::NoSuchElementException,
+ lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ OSL_ENSURE( NULL != rAutoTextEntry.GetGlossaries(), "no AutoText" );
+ OSL_ENSURE( (nEvent == SW_EVENT_END_INS_GLOSSARY) ||
+ (nEvent == SW_EVENT_START_INS_GLOSSARY) ,
+ "Unknown event ID" );
+
+ SwGlossaries *const pGlossaries =
+ const_cast<SwGlossaries*>(rAutoTextEntry.GetGlossaries());
+ SwTextBlocks* pBlocks =
+ pGlossaries->GetGroupDoc( rAutoTextEntry.GetGroupName() );
+ OSL_ENSURE( NULL != pBlocks,
+ "can't get autotext group; SwAutoTextEntry has illegal name?");
+
+ // return empty macro, unless macro is found
+ OUString sEmptyStr;
+ SvxMacro aEmptyMacro(sEmptyStr, sEmptyStr);
+ rMacro = aEmptyMacro;
+
+ if ( pBlocks && !pBlocks->GetError())
+ {
+ sal_uInt16 nIndex = pBlocks->GetIndex( rAutoTextEntry.GetEntryName() );
+ if( nIndex != USHRT_MAX )
+ {
+ SvxMacroTableDtor aMacroTable;
+ if( pBlocks->GetMacroTable( nIndex, aMacroTable ) )
+ {
+ SvxMacro *pMacro = aMacroTable.Get( nEvent );
+ if( pMacro )
+ rMacro = *pMacro;
+ }
+ }
+
+ delete pBlocks;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/uno/unodefaults.cxx b/sw/source/core/uibase/uno/unodefaults.cxx
new file mode 100644
index 000000000000..1959f742947c
--- /dev/null
+++ b/sw/source/core/uibase/uno/unodefaults.cxx
@@ -0,0 +1,51 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <unodefaults.hxx>
+#include <svx/svdmodel.hxx>
+#include <svx/unoprov.hxx>
+#include <doc.hxx>
+
+SwSvxUnoDrawPool::SwSvxUnoDrawPool( SwDoc* pDoc ) throw() :
+ SvxUnoDrawPool(pDoc->GetDrawModel(), SVXUNO_SERVICEID_COM_SUN_STAR_DRAWING_DEFAULTS_WRITER),
+ m_pDoc(pDoc)
+{
+}
+
+SwSvxUnoDrawPool::~SwSvxUnoDrawPool() throw()
+{
+}
+
+SfxItemPool* SwSvxUnoDrawPool::getModelPool( bool /*bReadOnly*/ ) throw()
+{
+ if(m_pDoc)
+ {
+
+ // DVO, OD 01.10.2003 #i18732# - return item pool of writer document;
+ // it contains draw model item pool as secondary pool.
+ //SdrModel* pModel = m_pDoc->MakeDrawModel();
+ //return &pModel->GetItemPool();
+ // #i52858# - method name changed
+ m_pDoc->GetOrCreateDrawModel();
+ return &(m_pDoc->GetAttrPool());
+ }
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/uno/unodefaults.hxx b/sw/source/core/uibase/uno/unodefaults.hxx
new file mode 100644
index 000000000000..dc4a160596ed
--- /dev/null
+++ b/sw/source/core/uibase/uno/unodefaults.hxx
@@ -0,0 +1,40 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_UNO_UNODEFAULTS_HXX
+#define INCLUDED_SW_SOURCE_UI_UNO_UNODEFAULTS_HXX
+
+#include <svx/unopool.hxx>
+
+class SwDoc;
+
+class SwSvxUnoDrawPool : public SvxUnoDrawPool
+{
+ SwDoc* m_pDoc;
+public:
+ SwSvxUnoDrawPool( SwDoc* pDoc ) throw();
+ virtual ~SwSvxUnoDrawPool() throw();
+
+ virtual SfxItemPool* getModelPool( bool bReadOnly ) throw() SAL_OVERRIDE;
+
+ void Invalidate() {m_pDoc = 0;}
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/uno/unodispatch.cxx b/sw/source/core/uibase/uno/unodispatch.cxx
new file mode 100644
index 000000000000..9815c9f3b424
--- /dev/null
+++ b/sw/source/core/uibase/uno/unodispatch.cxx
@@ -0,0 +1,392 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <vcl/svapp.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svx/dataaccessdescriptor.hxx>
+#include <comphelper/servicehelper.hxx>
+#include <unodispatch.hxx>
+#include <unobaseclass.hxx>
+#include <view.hxx>
+#include <cmdid.h>
+#include "wrtsh.hxx"
+#include "dbmgr.hxx"
+
+using namespace ::com::sun::star;
+
+static const char* cURLFormLetter = ".uno:DataSourceBrowser/FormLetter";
+static const char* cURLInsertContent = ".uno:DataSourceBrowser/InsertContent";//data into fields
+static const char* cURLInsertColumns = ".uno:DataSourceBrowser/InsertColumns";//data into text
+static const char* cURLDocumentDataSource = ".uno:DataSourceBrowser/DocumentDataSource";//current data source of the document
+static const sal_Char* cInternalDBChangeNotification = ".uno::Writer/DataSourceChanged";
+
+SwXDispatchProviderInterceptor::SwXDispatchProviderInterceptor(SwView& rVw) :
+ m_pView(&rVw)
+{
+ uno::Reference< frame::XFrame> xUnoFrame = m_pView->GetViewFrame()->GetFrame().GetFrameInterface();
+ m_xIntercepted = uno::Reference< frame::XDispatchProviderInterception>(xUnoFrame, uno::UNO_QUERY);
+ if(m_xIntercepted.is())
+ {
+ m_refCount++;
+ m_xIntercepted->registerDispatchProviderInterceptor((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((lang::XEventListener*)this);
+ m_refCount--;
+ }
+}
+
+SwXDispatchProviderInterceptor::~SwXDispatchProviderInterceptor()
+{
+}
+
+uno::Reference< frame::XDispatch > SwXDispatchProviderInterceptor::queryDispatch(
+ const util::URL& aURL, const OUString& aTargetFrameName, sal_Int32 nSearchFlags )
+ throw(uno::RuntimeException, std::exception)
+{
+ DispatchMutexLock_Impl aLock(*this);
+ uno::Reference< frame::XDispatch> xResult;
+ // create some dispatch ...
+ if(m_pView && aURL.Complete.startsWith(".uno:DataSourceBrowser/"))
+ {
+ if(aURL.Complete.equalsAscii(cURLFormLetter) ||
+ aURL.Complete.equalsAscii(cURLInsertContent) ||
+ aURL.Complete.equalsAscii(cURLInsertColumns)||
+ aURL.Complete.equalsAscii(cURLDocumentDataSource))
+ {
+ if(!m_xDispatch.is())
+ m_xDispatch = new SwXDispatch(*m_pView);
+ xResult = m_xDispatch;
+ }
+ }
+
+ // 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 > > SwXDispatchProviderInterceptor::queryDispatches(
+ const uno::Sequence< frame::DispatchDescriptor >& aDescripts ) throw(uno::RuntimeException, std::exception)
+{
+ DispatchMutexLock_Impl aLock(*this);
+ 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;
+}
+
+uno::Reference< frame::XDispatchProvider > SwXDispatchProviderInterceptor::getSlaveDispatchProvider( )
+ throw(uno::RuntimeException, std::exception)
+{
+ DispatchMutexLock_Impl aLock(*this);
+ return m_xSlaveDispatcher;
+}
+
+void SwXDispatchProviderInterceptor::setSlaveDispatchProvider(
+ const uno::Reference< frame::XDispatchProvider >& xNewDispatchProvider ) throw(uno::RuntimeException, std::exception)
+{
+ DispatchMutexLock_Impl aLock(*this);
+ m_xSlaveDispatcher = xNewDispatchProvider;
+}
+
+uno::Reference< frame::XDispatchProvider > SwXDispatchProviderInterceptor::getMasterDispatchProvider( )
+ throw(uno::RuntimeException, std::exception)
+{
+ DispatchMutexLock_Impl aLock(*this);
+ return m_xMasterDispatcher;
+}
+
+void SwXDispatchProviderInterceptor::setMasterDispatchProvider(
+ const uno::Reference< frame::XDispatchProvider >& xNewSupplier ) throw(uno::RuntimeException, std::exception)
+{
+ DispatchMutexLock_Impl aLock(*this);
+ m_xMasterDispatcher = xNewSupplier;
+}
+
+void SwXDispatchProviderInterceptor::disposing( const lang::EventObject& )
+ throw(uno::RuntimeException, std::exception)
+{
+ DispatchMutexLock_Impl aLock(*this);
+ if (m_xIntercepted.is())
+ {
+ m_xIntercepted->releaseDispatchProviderInterceptor((frame::XDispatchProviderInterceptor*)this);
+ uno::Reference< lang::XComponent> xInterceptedComponent(m_xIntercepted, uno::UNO_QUERY);
+ if (xInterceptedComponent.is())
+ xInterceptedComponent->removeEventListener((lang::XEventListener*)this);
+ m_xDispatch = 0;
+ }
+ m_xIntercepted = NULL;
+}
+
+namespace
+{
+ class theSwXDispatchProviderInterceptorUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXDispatchProviderInterceptorUnoTunnelId > {};
+}
+
+const uno::Sequence< sal_Int8 > & SwXDispatchProviderInterceptor::getUnoTunnelId()
+{
+ return theSwXDispatchProviderInterceptorUnoTunnelId::get().getSeq();
+}
+
+sal_Int64 SwXDispatchProviderInterceptor::getSomething(
+ const uno::Sequence< sal_Int8 >& aIdentifier )
+ throw(uno::RuntimeException, std::exception)
+{
+ if( aIdentifier.getLength() == 16
+ && 0 == memcmp( getUnoTunnelId().getConstArray(),
+ aIdentifier.getConstArray(), 16 ) )
+ {
+ return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this ));
+ }
+ return 0;
+}
+
+void SwXDispatchProviderInterceptor::Invalidate()
+{
+ DispatchMutexLock_Impl aLock(*this);
+ if (m_xIntercepted.is())
+ {
+ m_xIntercepted->releaseDispatchProviderInterceptor((frame::XDispatchProviderInterceptor*)this);
+ uno::Reference< lang::XComponent> xInterceptedComponent(m_xIntercepted, uno::UNO_QUERY);
+ if (xInterceptedComponent.is())
+ xInterceptedComponent->removeEventListener((lang::XEventListener*)this);
+ m_xDispatch = 0;
+ }
+ m_xIntercepted = NULL;
+ m_pView = 0;
+}
+
+SwXDispatch::SwXDispatch(SwView& rVw) :
+ m_pView(&rVw),
+ m_bOldEnable(sal_False),
+ m_bListenerAdded(sal_False)
+{
+}
+
+SwXDispatch::~SwXDispatch()
+{
+ if(m_bListenerAdded && m_pView)
+ {
+ uno::Reference<view::XSelectionSupplier> xSupplier = m_pView->GetUNOObject();
+ uno::Reference<view::XSelectionChangeListener> xThis = this;
+ xSupplier->removeSelectionChangeListener(xThis);
+ }
+}
+
+void SwXDispatch::dispatch(const util::URL& aURL,
+ const uno::Sequence< beans::PropertyValue >& aArgs)
+ throw (uno::RuntimeException, std::exception)
+{
+ if(!m_pView)
+ throw uno::RuntimeException();
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ SwNewDBMgr* pNewDBMgr = rSh.GetNewDBMgr();
+ if(aURL.Complete.equalsAscii(cURLInsertContent))
+ {
+ ::svx::ODataAccessDescriptor aDescriptor(aArgs);
+ SwMergeDescriptor aMergeDesc( DBMGR_MERGE, rSh, aDescriptor );
+ pNewDBMgr->MergeNew(aMergeDesc);
+ }
+ else if(aURL.Complete.equalsAscii(cURLInsertColumns))
+ {
+ pNewDBMgr->InsertText(rSh, aArgs);
+ }
+ else if(aURL.Complete.equalsAscii(cURLFormLetter))
+ {
+ SfxUsrAnyItem aDBProperties(FN_PARAM_DATABASE_PROPERTIES, uno::makeAny(aArgs));
+ m_pView->GetViewFrame()->GetDispatcher()->Execute(
+ FN_MAILMERGE_WIZARD,
+ SFX_CALLMODE_ASYNCHRON,
+ &aDBProperties, 0L);
+ }
+ else if(aURL.Complete.equalsAscii(cURLDocumentDataSource))
+ {
+ OSL_FAIL("SwXDispatch::dispatch: this URL is not to be dispatched!");
+ }
+ else if(aURL.Complete.equalsAscii(cInternalDBChangeNotification))
+ {
+ frame::FeatureStateEvent aEvent;
+ aEvent.IsEnabled = sal_True;
+ aEvent.Source = *(cppu::OWeakObject*)this;
+
+ const SwDBData& rData = m_pView->GetWrtShell().GetDBDesc();
+ ::svx::ODataAccessDescriptor aDescriptor;
+ aDescriptor.setDataSource(rData.sDataSource);
+ aDescriptor[::svx::daCommand] <<= rData.sCommand;
+ aDescriptor[::svx::daCommandType] <<= rData.nCommandType;
+
+ aEvent.State <<= aDescriptor.createPropertyValueSequence();
+ aEvent.IsEnabled = !rData.sDataSource.isEmpty();
+
+ StatusListenerList::iterator aListIter = m_aListenerList.begin();
+ for(aListIter = m_aListenerList.begin(); aListIter != m_aListenerList.end(); ++aListIter)
+ {
+ StatusStruct_Impl aStatus = *aListIter;
+ if(aStatus.aURL.Complete.equalsAscii(cURLDocumentDataSource))
+ {
+ aEvent.FeatureURL = aStatus.aURL;
+ aStatus.xListener->statusChanged( aEvent );
+ }
+ }
+ }
+ else
+ throw uno::RuntimeException();
+
+}
+
+void SwXDispatch::addStatusListener(
+ const uno::Reference< frame::XStatusListener >& xControl, const util::URL& aURL ) throw(uno::RuntimeException, std::exception)
+{
+ if(!m_pView)
+ throw uno::RuntimeException();
+ ShellModes eMode = m_pView->GetShellMode();
+ sal_Bool bEnable = SHELL_MODE_TEXT == eMode ||
+ SHELL_MODE_LIST_TEXT == eMode ||
+ SHELL_MODE_TABLE_TEXT == eMode ||
+ SHELL_MODE_TABLE_LIST_TEXT == eMode;
+
+ m_bOldEnable = bEnable;
+ frame::FeatureStateEvent aEvent;
+ aEvent.IsEnabled = bEnable;
+ aEvent.Source = *(cppu::OWeakObject*)this;
+ aEvent.FeatureURL = aURL;
+
+ // one of the URLs requires a special state ....
+ if (aURL.Complete.equalsAscii(cURLDocumentDataSource))
+ {
+ const SwDBData& rData = m_pView->GetWrtShell().GetDBDesc();
+
+ ::svx::ODataAccessDescriptor aDescriptor;
+ aDescriptor.setDataSource(rData.sDataSource);
+ aDescriptor[::svx::daCommand] <<= rData.sCommand;
+ aDescriptor[::svx::daCommandType] <<= rData.nCommandType;
+
+ aEvent.State <<= aDescriptor.createPropertyValueSequence();
+ aEvent.IsEnabled = !rData.sDataSource.isEmpty();
+ }
+
+ xControl->statusChanged( aEvent );
+
+ StatusListenerList::iterator aListIter = m_aListenerList.begin();
+ StatusStruct_Impl aStatus;
+ aStatus.xListener = xControl;
+ aStatus.aURL = aURL;
+ m_aListenerList.insert(aListIter, aStatus);
+
+ if(!m_bListenerAdded)
+ {
+ uno::Reference<view::XSelectionSupplier> xSupplier = m_pView->GetUNOObject();
+ uno::Reference<view::XSelectionChangeListener> xThis = this;
+ xSupplier->addSelectionChangeListener(xThis);
+ m_bListenerAdded = sal_True;
+ }
+}
+
+void SwXDispatch::removeStatusListener(
+ const uno::Reference< frame::XStatusListener >& xControl, const util::URL& ) throw(uno::RuntimeException, std::exception)
+{
+ StatusListenerList::iterator aListIter = m_aListenerList.begin();
+ for(aListIter = m_aListenerList.begin(); aListIter != m_aListenerList.end(); ++aListIter)
+ {
+ StatusStruct_Impl aStatus = *aListIter;
+ if(aStatus.xListener.get() == xControl.get())
+ {
+ m_aListenerList.erase(aListIter);
+ break;
+ }
+ }
+ if(m_aListenerList.empty() && m_pView)
+ {
+ uno::Reference<view::XSelectionSupplier> xSupplier = m_pView->GetUNOObject();
+ uno::Reference<view::XSelectionChangeListener> xThis = this;
+ xSupplier->removeSelectionChangeListener(xThis);
+ m_bListenerAdded = sal_False;
+ }
+}
+
+void SwXDispatch::selectionChanged( const lang::EventObject& ) throw(uno::RuntimeException, std::exception)
+{
+ ShellModes eMode = m_pView->GetShellMode();
+ sal_Bool bEnable = SHELL_MODE_TEXT == eMode ||
+ SHELL_MODE_LIST_TEXT == eMode ||
+ SHELL_MODE_TABLE_TEXT == eMode ||
+ SHELL_MODE_TABLE_LIST_TEXT == eMode;
+ if(bEnable != m_bOldEnable)
+ {
+ m_bOldEnable = bEnable;
+ frame::FeatureStateEvent aEvent;
+ aEvent.IsEnabled = bEnable;
+ aEvent.Source = *(cppu::OWeakObject*)this;
+
+ StatusListenerList::iterator aListIter = m_aListenerList.begin();
+ for(aListIter = m_aListenerList.begin(); aListIter != m_aListenerList.end(); ++aListIter)
+ {
+ StatusStruct_Impl aStatus = *aListIter;
+ aEvent.FeatureURL = aStatus.aURL;
+ if (!aStatus.aURL.Complete.equalsAscii(cURLDocumentDataSource))
+ // the document's data source does not depend on the selection, so it's state does not change here
+ aStatus.xListener->statusChanged( aEvent );
+ }
+ }
+}
+
+void SwXDispatch::disposing( const lang::EventObject& rSource ) throw(uno::RuntimeException, std::exception)
+{
+ uno::Reference<view::XSelectionSupplier> xSupplier(rSource.Source, uno::UNO_QUERY);
+ uno::Reference<view::XSelectionChangeListener> xThis = this;
+ xSupplier->removeSelectionChangeListener(xThis);
+ m_bListenerAdded = sal_False;
+
+ lang::EventObject aObject;
+ aObject.Source = (cppu::OWeakObject*)this;
+ StatusListenerList::iterator aListIter = m_aListenerList.begin();
+ for(; aListIter != m_aListenerList.end(); ++aListIter)
+ {
+ StatusStruct_Impl aStatus = *aListIter;
+ aStatus.xListener->disposing(aObject);
+ }
+ m_pView = 0;
+}
+
+const sal_Char* SwXDispatch::GetDBChangeURL()
+{
+ return cInternalDBChangeNotification;
+}
+
+SwXDispatchProviderInterceptor::DispatchMutexLock_Impl::DispatchMutexLock_Impl(
+ SwXDispatchProviderInterceptor& ) :
+ aGuard(Application::GetSolarMutex())
+{
+}
+
+SwXDispatchProviderInterceptor::DispatchMutexLock_Impl::~DispatchMutexLock_Impl()
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/uno/unodoc.cxx b/sw/source/core/uibase/uno/unodoc.cxx
new file mode 100644
index 000000000000..94c2f8570561
--- /dev/null
+++ b/sw/source/core/uibase/uno/unodoc.cxx
@@ -0,0 +1,113 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <sfx2/docfac.hxx>
+#include <sfx2/sfxmodelfactory.hxx>
+#include "swdll.hxx"
+#include "docsh.hxx"
+#include "globdoc.hxx"
+#include "wdocsh.hxx"
+#include <osl/mutex.hxx>
+#include <vcl/svapp.hxx>
+
+using namespace ::com::sun::star;
+
+// com.sun.star.comp.Writer.TextDocument
+
+uno::Sequence< OUString > SAL_CALL SwTextDocument_getSupportedServiceNames() throw()
+{
+ // return only top level services here! All others must be
+ // resolved by rtti!
+ uno::Sequence< OUString > aRet ( 1 );
+ OUString* pArray = aRet.getArray();
+ pArray[0] = "com.sun.star.text.TextDocument";
+
+ return aRet;
+}
+
+OUString SAL_CALL SwTextDocument_getImplementationName() throw()
+{
+ return OUString( "com.sun.star.comp.Writer.TextDocument" );
+}
+
+uno::Reference< uno::XInterface > SAL_CALL SwTextDocument_createInstance(
+ const uno::Reference< lang::XMultiServiceFactory >&, const sal_uInt64 _nCreationFlags )
+ throw( uno::Exception )
+{
+ SolarMutexGuard aGuard;
+ SwGlobals::ensure();
+ SfxObjectShell* pShell = new SwDocShell( _nCreationFlags );
+ return uno::Reference< uno::XInterface >( pShell->GetModel() );
+}
+
+// com.sun.star.comp.Writer.WebDocument
+
+uno::Sequence< OUString > SAL_CALL SwWebDocument_getSupportedServiceNames() throw()
+{
+ // return only top level services here! All others must be
+ // resolved by rtti!
+ uno::Sequence< OUString > aRet ( 1 );
+ OUString* pArray = aRet.getArray();
+ pArray[0] = "com.sun.star.text.WebDocument";
+
+ return aRet;
+}
+
+OUString SAL_CALL SwWebDocument_getImplementationName() throw()
+{
+ return OUString( "com.sun.star.comp.Writer.WebDocument" );
+}
+
+uno::Reference< uno::XInterface > SAL_CALL SwWebDocument_createInstance(
+ const uno::Reference< lang::XMultiServiceFactory > & )
+ throw( uno::Exception )
+{
+ SolarMutexGuard aGuard;
+ SwGlobals::ensure();
+ SfxObjectShell* pShell = new SwWebDocShell( SFX_CREATE_MODE_STANDARD );
+ return uno::Reference< uno::XInterface >( pShell->GetModel() );
+}
+
+// com.sun.star.comp.Writer.GlobalDocument
+
+uno::Sequence< OUString > SAL_CALL SwGlobalDocument_getSupportedServiceNames() throw()
+{
+ uno::Sequence< OUString > aRet ( 1 );
+ OUString* pArray = aRet.getArray();
+ pArray[0] = "com.sun.star.text.GlobalDocument";
+
+ return aRet;
+}
+
+OUString SAL_CALL SwGlobalDocument_getImplementationName() throw()
+{
+ return OUString( "com.sun.star.comp.Writer.GlobalDocument" );
+}
+
+uno::Reference< uno::XInterface > SAL_CALL SwGlobalDocument_createInstance(
+ const uno::Reference< lang::XMultiServiceFactory > &)
+ throw( uno::Exception )
+{
+ SolarMutexGuard aGuard;
+ SwGlobals::ensure();
+ SfxObjectShell* pShell = new SwGlobalDocShell( SFX_CREATE_MODE_STANDARD );
+ return uno::Reference< uno::XInterface >( pShell->GetModel() );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/uno/unofreg.cxx b/sw/source/core/uibase/uno/unofreg.cxx
new file mode 100644
index 000000000000..c8b3252df75b
--- /dev/null
+++ b/sw/source/core/uibase/uno/unofreg.cxx
@@ -0,0 +1,373 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "SwXFilterOptions.hxx"
+#include "sal/types.h"
+#include <osl/diagnose.h>
+#include <cppuhelper/factory.hxx>
+#include <sfx2/sfxmodelfactory.hxx>
+
+#include <string.h>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::lang;
+
+// module
+extern uno::Sequence< OUString > SAL_CALL SwUnoModule_getSupportedServiceNames() throw();
+extern OUString SAL_CALL SwUnoModule_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL SwUnoModule_createInstance( const uno::Reference< XMultiServiceFactory > &rSMgr ) throw( uno::Exception );
+
+// writer documents
+extern uno::Sequence< OUString > SAL_CALL SwTextDocument_getSupportedServiceNames() throw();
+extern OUString SAL_CALL SwTextDocument_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL SwTextDocument_createInstance( const uno::Reference< XMultiServiceFactory > &rSMgr, const sal_uInt64 _nCreationFlags ) throw( uno::Exception );
+extern uno::Sequence< OUString > SAL_CALL SwWebDocument_getSupportedServiceNames() throw();
+extern OUString SAL_CALL SwWebDocument_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL SwWebDocument_createInstance( const uno::Reference< XMultiServiceFactory > &rSMgr ) throw( uno::Exception );
+extern uno::Sequence< OUString > SAL_CALL SwGlobalDocument_getSupportedServiceNames() throw();
+extern OUString SAL_CALL SwGlobalDocument_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL SwGlobalDocument_createInstance( const uno::Reference< XMultiServiceFactory > &rSMgr ) throw( uno::Exception );
+
+// xml import
+extern uno::Sequence< OUString > SAL_CALL SwXMLImport_getSupportedServiceNames() throw();
+extern OUString SAL_CALL SwXMLImport_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL SwXMLImport_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr) throw( uno::Exception );
+extern uno::Sequence< OUString > SAL_CALL SwXMLImportStyles_getSupportedServiceNames() throw();
+extern OUString SAL_CALL SwXMLImportStyles_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL SwXMLImportStyles_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr) throw( uno::Exception );
+extern uno::Sequence< OUString > SAL_CALL SwXMLImportContent_getSupportedServiceNames() throw();
+extern OUString SAL_CALL SwXMLImportContent_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL SwXMLImportContent_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr) throw( uno::Exception );
+
+extern uno::Sequence< OUString > SAL_CALL SwXMLImportMeta_getSupportedServiceNames() throw();
+extern OUString SAL_CALL SwXMLImportMeta_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL SwXMLImportMeta_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr) throw( uno::Exception );
+
+extern uno::Sequence< OUString > SAL_CALL SwXMLImportSettings_getSupportedServiceNames() throw();
+extern OUString SAL_CALL SwXMLImportSettings_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL SwXMLImportSettings_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr) throw( uno::Exception );
+
+// xml export (OOo)
+extern uno::Sequence< OUString > SAL_CALL SwXMLExportOOO_getSupportedServiceNames() throw();
+extern OUString SAL_CALL SwXMLExportOOO_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL SwXMLExportOOO_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr) throw( uno::Exception );
+extern uno::Sequence< OUString > SAL_CALL SwXMLExportContentOOO_getSupportedServiceNames() throw();
+extern OUString SAL_CALL SwXMLExportContentOOO_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL SwXMLExportContentOOO_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr) throw( uno::Exception );
+extern uno::Sequence< OUString > SAL_CALL SwXMLExportStylesOOO_getSupportedServiceNames() throw();
+extern OUString SAL_CALL SwXMLExportStylesOOO_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL SwXMLExportStylesOOO_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr) throw( uno::Exception );
+extern uno::Sequence< OUString > SAL_CALL SwXMLExportMetaOOO_getSupportedServiceNames() throw();
+extern OUString SAL_CALL SwXMLExportMetaOOO_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL SwXMLExportMetaOOO_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr) throw( uno::Exception );
+extern uno::Sequence< OUString > SAL_CALL SwXMLExportSettingsOOO_getSupportedServiceNames() throw();
+extern OUString SAL_CALL SwXMLExportSettingsOOO_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL SwXMLExportSettingsOOO_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr) throw( uno::Exception );
+
+// xml export (OASIS)
+extern uno::Sequence< OUString > SAL_CALL SwXMLExport_getSupportedServiceNames() throw();
+extern OUString SAL_CALL SwXMLExport_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL SwXMLExport_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr) throw( uno::Exception );
+extern uno::Sequence< OUString > SAL_CALL SwXMLExportContent_getSupportedServiceNames() throw();
+extern OUString SAL_CALL SwXMLExportContent_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL SwXMLExportContent_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr) throw( uno::Exception );
+extern uno::Sequence< OUString > SAL_CALL SwXMLExportStyles_getSupportedServiceNames() throw();
+extern OUString SAL_CALL SwXMLExportStyles_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL SwXMLExportStyles_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr) throw( uno::Exception );
+extern uno::Sequence< OUString > SAL_CALL SwXMLExportMeta_getSupportedServiceNames() throw();
+extern OUString SAL_CALL SwXMLExportMeta_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL SwXMLExportMeta_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr) throw( uno::Exception );
+extern uno::Sequence< OUString > SAL_CALL SwXMLExportSettings_getSupportedServiceNames() throw();
+extern OUString SAL_CALL SwXMLExportSettings_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL SwXMLExportSettings_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr) throw( uno::Exception );
+
+//API objects
+extern uno::Sequence< OUString > SAL_CALL SwXAutoTextContainer_getSupportedServiceNames() throw();
+extern OUString SAL_CALL SwXAutoTextContainer_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL SwXAutoTextContainer_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr) throw( uno::Exception );
+
+extern uno::Sequence< OUString > SAL_CALL SwXModule_getSupportedServiceNames() throw();
+extern OUString SAL_CALL SwXModule_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL SwXModule_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr) throw( uno::Exception );
+
+extern uno::Sequence< OUString > SAL_CALL SwXMailMerge_getSupportedServiceNames() throw();
+extern OUString SAL_CALL SwXMailMerge_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL SwXMailMerge_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr) throw( uno::Exception );
+
+extern uno::Sequence< OUString > SAL_CALL SwXMailMerge_getSupportedServiceNames() throw();
+extern OUString SAL_CALL SwXMailMerge_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL SwXMailMerge_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr) throw( uno::Exception );
+
+// Layout dump filter
+extern uno::Sequence< OUString > SAL_CALL LayoutDumpFilter_getSupportedServiceNames() throw();
+extern OUString SAL_CALL LayoutDumpFilter_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL LayoutDumpFilter_createInstance( const uno::Reference< XMultiServiceFactory > &rSMgr ) throw( uno::Exception );
+
+// #i73788#
+#include "cppuhelper/implementationentry.hxx"
+namespace comp_FinalThreadManager {
+
+// component and service helper functions:
+OUString SAL_CALL _getImplementationName();
+com::sun::star::uno::Sequence< OUString > SAL_CALL _getSupportedServiceNames();
+com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL _create(
+ com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > const & context );
+
+}
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+static ::cppu::ImplementationEntry const entries[] = {
+ { &comp_FinalThreadManager::_create,
+ &comp_FinalThreadManager::_getImplementationName,
+ &comp_FinalThreadManager::_getSupportedServiceNames,
+ &::cppu::createSingleComponentFactory, 0, 0 },
+ { 0, 0, 0, 0, 0, 0 }
+};
+
+SAL_DLLPUBLIC_EXPORT void * SAL_CALL sw_component_getFactory(
+ const sal_Char * pImplName,
+ void * pServiceManager,
+ void * pRegistryKey )
+{
+ void * pRet = 0;
+ if( pServiceManager )
+ {
+ uno::Reference< XMultiServiceFactory > xMSF(
+ reinterpret_cast< XMultiServiceFactory * >( pServiceManager ) );
+
+ uno::Reference< XSingleServiceFactory > xFactory;
+
+ const sal_Int32 nImplNameLen = strlen( pImplName );
+ if( SwXMLImport_getImplementationName().equalsAsciiL( pImplName,
+ nImplNameLen ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xMSF,
+ SwXMLImport_getImplementationName(),
+ SwXMLImport_createInstance,
+ SwXMLImport_getSupportedServiceNames() );
+ }
+ else if( SwXMLImportStyles_getImplementationName().equalsAsciiL(
+ pImplName, nImplNameLen ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xMSF,
+ SwXMLImportStyles_getImplementationName(),
+ SwXMLImportStyles_createInstance,
+ SwXMLImportStyles_getSupportedServiceNames() );
+ }
+ else if( SwXMLImportContent_getImplementationName().equalsAsciiL(
+ pImplName, nImplNameLen ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xMSF,
+ SwXMLImportContent_getImplementationName(),
+ SwXMLImportContent_createInstance,
+ SwXMLImportContent_getSupportedServiceNames() );
+ }
+ else if( SwXMLImportMeta_getImplementationName().equalsAsciiL(
+ pImplName, nImplNameLen ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xMSF,
+ SwXMLImportMeta_getImplementationName(),
+ SwXMLImportMeta_createInstance,
+ SwXMLImportMeta_getSupportedServiceNames() );
+ }
+ else if( SwXMLImportSettings_getImplementationName().equalsAsciiL(
+ pImplName, nImplNameLen ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xMSF,
+ SwXMLImportSettings_getImplementationName(),
+ SwXMLImportSettings_createInstance,
+ SwXMLImportSettings_getSupportedServiceNames() );
+ }
+ else if( SwXMLExportOOO_getImplementationName().equalsAsciiL( pImplName,
+ nImplNameLen ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xMSF,
+ SwXMLExportOOO_getImplementationName(),
+ SwXMLExportOOO_createInstance,
+ SwXMLExportOOO_getSupportedServiceNames() );
+ }
+ else if( SwXMLExportStylesOOO_getImplementationName().equalsAsciiL(
+ pImplName, nImplNameLen ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xMSF,
+ SwXMLExportStylesOOO_getImplementationName(),
+ SwXMLExportStylesOOO_createInstance,
+ SwXMLExportStylesOOO_getSupportedServiceNames() );
+ }
+ else if( SwXMLExportContentOOO_getImplementationName().equalsAsciiL(
+ pImplName, nImplNameLen ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xMSF,
+ SwXMLExportContentOOO_getImplementationName(),
+ SwXMLExportContentOOO_createInstance,
+ SwXMLExportContentOOO_getSupportedServiceNames() );
+ }
+ else if( SwXMLExportMetaOOO_getImplementationName().equalsAsciiL(
+ pImplName, nImplNameLen ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xMSF,
+ SwXMLExportMetaOOO_getImplementationName(),
+ SwXMLExportMetaOOO_createInstance,
+ SwXMLExportMetaOOO_getSupportedServiceNames() );
+ }
+ else if( SwXMLExportSettingsOOO_getImplementationName().equalsAsciiL(
+ pImplName, nImplNameLen ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xMSF,
+ SwXMLExportSettingsOOO_getImplementationName(),
+ SwXMLExportSettingsOOO_createInstance,
+ SwXMLExportSettingsOOO_getSupportedServiceNames() );
+ }
+ else if( SwXMLExport_getImplementationName().equalsAsciiL( pImplName,
+ nImplNameLen ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xMSF,
+ SwXMLExport_getImplementationName(),
+ SwXMLExport_createInstance,
+ SwXMLExport_getSupportedServiceNames() );
+ }
+ else if( SwXMLExportStyles_getImplementationName().equalsAsciiL(
+ pImplName, nImplNameLen ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xMSF,
+ SwXMLExportStyles_getImplementationName(),
+ SwXMLExportStyles_createInstance,
+ SwXMLExportStyles_getSupportedServiceNames() );
+ }
+ else if( SwXMLExportContent_getImplementationName().equalsAsciiL(
+ pImplName, nImplNameLen ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xMSF,
+ SwXMLExportContent_getImplementationName(),
+ SwXMLExportContent_createInstance,
+ SwXMLExportContent_getSupportedServiceNames() );
+ }
+ else if( SwXMLExportMeta_getImplementationName().equalsAsciiL(
+ pImplName, nImplNameLen ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xMSF,
+ SwXMLExportMeta_getImplementationName(),
+ SwXMLExportMeta_createInstance,
+ SwXMLExportMeta_getSupportedServiceNames() );
+ }
+ else if( SwXMLExportSettings_getImplementationName().equalsAsciiL(
+ pImplName, nImplNameLen ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xMSF,
+ SwXMLExportSettings_getImplementationName(),
+ SwXMLExportSettings_createInstance,
+ SwXMLExportSettings_getSupportedServiceNames() );
+ }
+ else if( SwXAutoTextContainer_getImplementationName().equalsAsciiL(
+ pImplName, nImplNameLen ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xMSF,
+ SwXAutoTextContainer_getImplementationName(),
+ SwXAutoTextContainer_createInstance,
+ SwXAutoTextContainer_getSupportedServiceNames() );
+ }
+ else if( SwXModule_getImplementationName().equalsAsciiL(
+ pImplName, nImplNameLen ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xMSF,
+ SwXModule_getImplementationName(),
+ SwXModule_createInstance,
+ SwXModule_getSupportedServiceNames() );
+ }
+ else if( SwXMailMerge_getImplementationName().equalsAsciiL(
+ pImplName, nImplNameLen ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xMSF,
+ SwXMailMerge_getImplementationName(),
+ SwXMailMerge_createInstance,
+ SwXMailMerge_getSupportedServiceNames() );
+ }
+ else if( SwXFilterOptions::getImplementationName_Static().equalsAsciiL(
+ pImplName, nImplNameLen ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xMSF,
+ SwXFilterOptions::getImplementationName_Static(),
+ SwXFilterOptions_createInstance,
+ SwXFilterOptions::getSupportedServiceNames_Static() );
+ }
+ else if( SwTextDocument_getImplementationName().equalsAsciiL(
+ pImplName, nImplNameLen ) )
+ {
+ xFactory = ::sfx2::createSfxModelFactory( xMSF,
+ SwTextDocument_getImplementationName(),
+ SwTextDocument_createInstance,
+ SwTextDocument_getSupportedServiceNames() );
+ }
+ else if( SwWebDocument_getImplementationName().equalsAsciiL(
+ pImplName, nImplNameLen ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xMSF,
+ SwWebDocument_getImplementationName(),
+ SwWebDocument_createInstance,
+ SwWebDocument_getSupportedServiceNames() );
+ }
+ else if( SwGlobalDocument_getImplementationName().equalsAsciiL(
+ pImplName, nImplNameLen ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xMSF,
+ SwGlobalDocument_getImplementationName(),
+ SwGlobalDocument_createInstance,
+ SwGlobalDocument_getSupportedServiceNames() );
+ }
+ else if( SwUnoModule_getImplementationName().equalsAsciiL(
+ pImplName, nImplNameLen ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xMSF,
+ SwUnoModule_getImplementationName(),
+ SwUnoModule_createInstance,
+ SwUnoModule_getSupportedServiceNames() );
+ }
+ else if( LayoutDumpFilter_getImplementationName().equalsAsciiL(
+ pImplName, nImplNameLen ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xMSF,
+ LayoutDumpFilter_getImplementationName(),
+ LayoutDumpFilter_createInstance,
+ LayoutDumpFilter_getSupportedServiceNames() );
+ }
+ else if( comp_FinalThreadManager::_getImplementationName().equalsAsciiL(
+ pImplName, nImplNameLen ) )
+ {
+ pRet = ::cppu::component_getFactoryHelper(
+ pImplName, pServiceManager, pRegistryKey, entries);
+ }
+
+ if( xFactory.is())
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+ return pRet;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/uno/unomailmerge.cxx b/sw/source/core/uibase/uno/unomailmerge.cxx
new file mode 100644
index 000000000000..8e80738003e2
--- /dev/null
+++ b/sw/source/core/uibase/uno/unomailmerge.cxx
@@ -0,0 +1,1227 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <vcl/svapp.hxx>
+#include <osl/mutex.hxx>
+#include <svl/itemprop.hxx>
+#include <svl/urihelper.hxx>
+#include <svx/dataaccessdescriptor.hxx>
+#include <tools/shl.hxx>
+#include <unotools/tempfile.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/docfilt.hxx>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/string.hxx>
+#include <cppuhelper/supportsservice.hxx>
+#include <vcl/timer.hxx>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/text/MailMergeType.hpp>
+#include <com/sun/star/text/MailMergeEvent.hpp>
+#include <com/sun/star/text/XMailMergeListener.hpp>
+#include <com/sun/star/text/XMailMergeBroadcaster.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/sdbc/XRowSet.hpp>
+#include <com/sun/star/frame/Desktop.hpp>
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#include <com/sun/star/util/XCloseable.hpp>
+#include <com/sun/star/util/CloseVetoException.hpp>
+#include <com/sun/star/sdbcx/XRowLocate.hpp>
+#include <com/sun/star/frame/XStorable.hpp>
+#include "com/sun/star/mail/XSmtpService.hpp"
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/event.hxx>
+#include <swevent.hxx>
+#include <unomailmerge.hxx>
+#include <swdll.hxx>
+#include <swmodule.hxx>
+#include <unoprnms.hxx>
+#include <unomap.hxx>
+#include <swunohelper.hxx>
+#include <docsh.hxx>
+#include <IDocumentDeviceAccess.hxx>
+#include <view.hxx>
+#include <dbmgr.hxx>
+#include <unotxdoc.hxx>
+#include <prtopt.hxx>
+#include <wrtsh.hxx>
+#include <shellio.hxx>
+#include <mmconfigitem.hxx>
+#include <mailmergehelper.hxx>
+
+#include <unomid.h>
+
+#include <boost/scoped_ptr.hpp>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::text;
+using namespace SWUnoHelper;
+
+typedef ::utl::SharedUNOComponent< XInterface > SharedComponent;
+
+osl::Mutex & GetMailMergeMutex()
+{
+ static osl::Mutex aMutex;
+ return aMutex;
+}
+
+enum CloseResult
+{
+ eSuccess, // successfully closed
+ eVetoed, // vetoed, ownership transferred to the vetoing instance
+ eFailed // failed for some unknown reason
+};
+static CloseResult CloseModelAndDocSh(
+ Reference< frame::XModel > &rxModel,
+ SfxObjectShellRef &rxDocSh )
+{
+ CloseResult eResult = eSuccess;
+
+ rxDocSh = 0;
+
+ //! models/documents should never be disposed (they may still be
+ //! used for printing which is called asynchronously for example)
+ //! instead call close
+ Reference< util::XCloseable > xClose( rxModel, UNO_QUERY );
+ if (xClose.is())
+ {
+ try
+ {
+ //! 'sal_True' -> transfer ownership to vetoing object if vetoed!
+ //! I.e. now that object is responsible for closing the model and doc shell.
+ xClose->close( sal_True );
+ }
+ catch (const util::CloseVetoException&)
+ {
+ //! here we have the problem that the temporary file that is
+ //! currently being printed will never be deleted. :-(
+ eResult = eVetoed;
+ }
+ catch (const uno::RuntimeException&)
+ {
+ eResult = eFailed;
+ }
+ }
+ return eResult;
+}
+
+static bool LoadFromURL_impl(
+ Reference< frame::XModel > &rxModel,
+ SfxObjectShellRef &rxDocSh,
+ const OUString &rURL,
+ bool bClose )
+ throw (RuntimeException)
+{
+ // try to open the document readonly and hidden
+ Reference< frame::XModel > xTmpModel;
+ Sequence < PropertyValue > aArgs( 1 );
+ aArgs[0].Name = "Hidden";
+ sal_Bool bVal = sal_True;
+ aArgs[0].Value <<= bVal;
+ try
+ {
+ Reference < XDesktop2 > xDesktop = Desktop::create( ::comphelper::getProcessComponentContext() );
+ xTmpModel = Reference < XModel >( xDesktop->loadComponentFromURL(
+ rURL, "_blank", 0, aArgs ), UNO_QUERY );
+ }
+ catch (const Exception&)
+ {
+ return false;
+ }
+
+ // try to get the DocShell
+ SwDocShell *pTmpDocShell = 0;
+ Reference < XUnoTunnel > xTunnel( xTmpModel, UNO_QUERY );
+ if (xTunnel.is())
+ {
+ SwXTextDocument* pTextDoc = reinterpret_cast<SwXTextDocument *>(
+ xTunnel->getSomething( SwXTextDocument::getUnoTunnelId() ));
+ pTmpDocShell = pTextDoc ? pTextDoc->GetDocShell() : 0;
+ }
+
+ bool bRes = false;
+ if (xTmpModel.is() && pTmpDocShell) // everything available?
+ {
+ if (bClose)
+ CloseModelAndDocSh( rxModel, rxDocSh );
+ // set new stuff
+ rxModel = xTmpModel;
+ rxDocSh = pTmpDocShell;
+ bRes = true;
+ }
+ else
+ {
+ // SfxObjectShellRef is ok here, since the document will be explicitly closed
+ SfxObjectShellRef xTmpDocSh = pTmpDocShell;
+ CloseModelAndDocSh( xTmpModel, xTmpDocSh );
+ }
+
+ return bRes;
+}
+
+namespace
+{
+ class DelayedFileDeletion : public ::cppu::WeakImplHelper1< util::XCloseListener >
+ {
+ protected:
+ ::osl::Mutex m_aMutex;
+ Reference< util::XCloseable > m_xDocument;
+ Timer m_aDeleteTimer;
+ OUString m_sTemporaryFile;
+ sal_Int32 m_nPendingDeleteAttempts;
+
+ public:
+ DelayedFileDeletion( const Reference< XModel >& _rxModel,
+ const OUString& _rTemporaryFile );
+
+ protected:
+ ~DelayedFileDeletion( );
+
+ // XCloseListener
+ virtual void SAL_CALL queryClosing( const EventObject& _rSource, sal_Bool _bGetsOwnership ) throw (util::CloseVetoException, RuntimeException, std::exception);
+ virtual void SAL_CALL notifyClosing( const EventObject& _rSource ) throw (RuntimeException, std::exception);
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const EventObject& Source ) throw (RuntimeException, std::exception);
+
+ private:
+ void implTakeOwnership( );
+ DECL_LINK( OnTryDeleteFile, void* );
+
+ private:
+ DelayedFileDeletion( const DelayedFileDeletion& ); // never implemented
+ DelayedFileDeletion& operator=( const DelayedFileDeletion& ); // never implemented
+ };
+
+ DelayedFileDeletion::DelayedFileDeletion( const Reference< XModel >& _rxModel, const OUString& _rTemporaryFile )
+ :
+ m_xDocument( _rxModel, UNO_QUERY )
+ ,m_sTemporaryFile( _rTemporaryFile )
+ ,m_nPendingDeleteAttempts( 0 )
+ {
+ osl_atomic_increment( &m_refCount );
+ try
+ {
+ if ( m_xDocument.is() )
+ {
+ m_xDocument->addCloseListener( this );
+ // successfully added -> keep ourself alive
+ acquire();
+ }
+ else {
+ OSL_FAIL("DelayedFileDeletion::DelayedFileDeletion: model is no component!" );
+ }
+ }
+ catch (const Exception&)
+ {
+ OSL_FAIL("DelayedFileDeletion::DelayedFileDeletion: could not register as event listener at the model!" );
+ }
+ osl_atomic_decrement( &m_refCount );
+ }
+
+ IMPL_LINK_NOARG(DelayedFileDeletion, OnTryDeleteFile)
+ {
+ ::osl::ClearableMutexGuard aGuard( m_aMutex );
+
+ bool bSuccess = false;
+ try
+ {
+ sal_Bool bDeliverOwnership = ( 0 == m_nPendingDeleteAttempts );
+ // if this is our last attemt, then anybody which vetoes this has to take the consequences
+ // (means take the ownership)
+ m_xDocument->close( bDeliverOwnership );
+ bSuccess = true;
+ }
+ catch (const util::CloseVetoException&)
+ {
+ // somebody vetoed -> next try
+ if ( m_nPendingDeleteAttempts )
+ {
+ // next attempt
+ --m_nPendingDeleteAttempts;
+ m_aDeleteTimer.Start();
+ }
+ else
+ bSuccess = true; // can't do anything here ...
+ }
+ catch (const Exception&)
+ {
+ OSL_FAIL("DelayedFileDeletion::OnTryDeleteFile: caught a strange exception!" );
+ bSuccess = true;
+ // can't do anything here ...
+ }
+
+ if ( bSuccess )
+ {
+ SWUnoHelper::UCB_DeleteFile( m_sTemporaryFile );
+ aGuard.clear();
+ release(); // this should be our last reference, we should be dead after this
+ }
+ return 0L;
+ }
+
+ void DelayedFileDeletion::implTakeOwnership( )
+ {
+ // revoke ourself as listener
+ try
+ {
+ m_xDocument->removeCloseListener( this );
+ }
+ catch (const Exception&)
+ {
+ OSL_FAIL("DelayedFileDeletion::implTakeOwnership: could not revoke the listener!" );
+ }
+
+ m_aDeleteTimer.SetTimeout( 3000 ); // 3 seconds
+ m_aDeleteTimer.SetTimeoutHdl( LINK( this, DelayedFileDeletion, OnTryDeleteFile ) );
+ m_nPendingDeleteAttempts = 3; // try 3 times at most
+ m_aDeleteTimer.Start( );
+ }
+
+ void SAL_CALL DelayedFileDeletion::queryClosing( const EventObject& , sal_Bool _bGetsOwnership ) throw (util::CloseVetoException, RuntimeException, std::exception)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( _bGetsOwnership )
+ implTakeOwnership( );
+
+ // always veto: We want to take the ownership ourself, as this is the only chance to delete
+ // the temporary file which the model is based on
+ throw util::CloseVetoException( );
+ }
+
+ void SAL_CALL DelayedFileDeletion::notifyClosing( const EventObject& ) throw (RuntimeException, std::exception)
+ {
+ OSL_FAIL("DelayedFileDeletion::notifyClosing: how this?" );
+ // this should not happen:
+ // Either, a foreign instance closes the document, then we should veto this, and take the ownership
+ // Or, we ourself close the document, then we should not be a listener anymore
+ }
+
+ void SAL_CALL DelayedFileDeletion::disposing( const EventObject& ) throw (RuntimeException, std::exception)
+ {
+ OSL_FAIL("DelayedFileDeletion::disposing: how this?" );
+ // this should not happen:
+ // Either, a foreign instance closes the document, then we should veto this, and take the ownership
+ // Or, we ourself close the document, then we should not be a listener anymore
+ }
+
+ DelayedFileDeletion::~DelayedFileDeletion( )
+ {
+ }
+}
+
+static bool DeleteTmpFile_Impl(
+ Reference< frame::XModel > &rxModel,
+ SfxObjectShellRef &rxDocSh,
+ const OUString &rTmpFileURL )
+{
+ bool bRes = false;
+ if (!rTmpFileURL.isEmpty())
+ {
+ bool bDelete = true;
+ if ( eVetoed == CloseModelAndDocSh( rxModel, rxDocSh ) )
+ {
+ // somebody vetoed the closing, and took the ownership of the document
+ // -> ensure that the temporary file is deleted later on
+ Reference< XEventListener > xEnsureDelete( new DelayedFileDeletion( rxModel, rTmpFileURL ) );
+ // note: as soon as #106931# is fixed, the whole DelayedFileDeletion is to be superseeded by
+ // a better solution
+ bDelete = false;
+ }
+
+ rxModel = 0;
+ rxDocSh = 0; // destroy doc shell
+
+ if ( bDelete )
+ {
+ if ( !SWUnoHelper::UCB_DeleteFile( rTmpFileURL ) )
+ {
+ Reference< XEventListener > xEnsureDelete( new DelayedFileDeletion( rxModel, rTmpFileURL ) );
+ // same not as above: as soon as #106931#, ...
+ }
+ }
+ else
+ bRes = true; // file will be deleted delayed
+ }
+ return bRes;
+}
+
+SwXMailMerge::SwXMailMerge() :
+ aEvtListeners ( GetMailMergeMutex() ),
+ aMergeListeners ( GetMailMergeMutex() ),
+ aPropListeners ( GetMailMergeMutex() ),
+ pPropSet( aSwMapProvider.GetPropertySet( PROPERTY_MAP_MAILMERGE ) ),
+ nDataCommandType(sdb::CommandType::TABLE),
+ nOutputType(MailMergeType::PRINTER),
+ bEscapeProcessing(sal_True), //!! allow to process properties like "Filter", "Order", ...
+ bSinglePrintJobs(sal_False),
+ bFileNameFromColumn(sal_False),
+ bSendAsHTML(sal_False),
+ bSendAsAttachment(sal_False),
+ bSaveAsSingleFile(sal_False),
+ bDisposing(sal_False),
+ m_pMgr(0)
+{
+ // create empty document
+ // like in: SwModule::InsertEnv (appenv.cxx)
+ xDocSh = new SwDocShell( SFX_CREATE_MODE_STANDARD );
+ xDocSh->DoInitNew( 0 );
+ SfxViewFrame *pFrame = SfxViewFrame::LoadHiddenDocument( *xDocSh, 0 );
+ SwView *pView = (SwView*) pFrame->GetViewShell();
+ pView->AttrChangedNotify( &pView->GetWrtShell() ); //So that SelectShell is called.
+ xModel = xDocSh->GetModel();
+}
+
+SwXMailMerge::~SwXMailMerge()
+{
+ if (!aTmpFileName.isEmpty())
+ DeleteTmpFile_Impl( xModel, xDocSh, aTmpFileName );
+ else // there was no temporary file in use
+ {
+ //! we still need to close the model and doc shell manually
+ //! because there is no automatism that will do that later.
+ //! #120086#
+ if ( eVetoed == CloseModelAndDocSh( xModel, xDocSh ) )
+ OSL_FAIL("owner ship transfered to vetoing object!" );
+
+ xModel = 0;
+ xDocSh = 0; // destroy doc shell
+ }
+}
+
+// Guarantee object consistence in case of an exception
+class MailMergeExecuteFinalizer {
+public:
+ MailMergeExecuteFinalizer(SwXMailMerge *mailmerge)
+ : m_pMailMerge(mailmerge)
+ {
+ assert(m_pMailMerge); //mailmerge object missing
+ }
+ ~MailMergeExecuteFinalizer()
+ {
+ osl::MutexGuard pMgrGuard( GetMailMergeMutex() );
+ m_pMailMerge->m_pMgr = 0;
+ }
+
+private:
+ // Disallow copy
+ MailMergeExecuteFinalizer(const MailMergeExecuteFinalizer&) {}
+
+ SwXMailMerge *m_pMailMerge;
+};
+
+uno::Any SAL_CALL SwXMailMerge::execute(
+ const uno::Sequence< beans::NamedValue >& rArguments )
+ throw (IllegalArgumentException, Exception,
+ RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ MailMergeExecuteFinalizer aFinalizer(this);
+
+ // get property values to be used
+ // (use values from the service as default and override them with
+ // the values that are provided as arguments)
+
+ uno::Sequence< uno::Any > aCurSelection = aSelection;
+ uno::Reference< sdbc::XResultSet > xCurResultSet = xResultSet;
+ uno::Reference< sdbc::XConnection > xCurConnection = xConnection;
+ uno::Reference< frame::XModel > xCurModel = xModel;
+ OUString aCurDataSourceName = aDataSourceName;
+ OUString aCurDataCommand = aDataCommand;
+ OUString aCurFilter = aFilter;
+ OUString aCurDocumentURL = aDocumentURL;
+ OUString aCurOutputURL = aOutputURL;
+ OUString aCurFileNamePrefix = aFileNamePrefix;
+ sal_Int32 nCurDataCommandType = nDataCommandType;
+ sal_Int16 nCurOutputType = nOutputType;
+ sal_Bool bCurEscapeProcessing = bEscapeProcessing;
+ sal_Bool bCurSinglePrintJobs = bSinglePrintJobs;
+ sal_Bool bCurFileNameFromColumn = bFileNameFromColumn;
+
+ SfxObjectShellRef xCurDocSh = xDocSh; // the document
+
+ const beans::NamedValue *pArguments = rArguments.getConstArray();
+ sal_Int32 nArgs = rArguments.getLength();
+ for (sal_Int32 i = 0; i < nArgs; ++i)
+ {
+ const OUString &rName = pArguments[i].Name;
+ const Any &rValue = pArguments[i].Value;
+
+ sal_Bool bOK = sal_True;
+ if (rName == UNO_NAME_SELECTION)
+ bOK = rValue >>= aCurSelection;
+ else if (rName == UNO_NAME_RESULT_SET)
+ bOK = rValue >>= xCurResultSet;
+ else if (rName == UNO_NAME_CONNECTION)
+ bOK = rValue >>= xCurConnection;
+ else if (rName == UNO_NAME_MODEL)
+ throw PropertyVetoException("Property is read-only: " + rName, static_cast < cppu::OWeakObject * > ( this ) );
+ else if (rName == UNO_NAME_DATA_SOURCE_NAME)
+ bOK = rValue >>= aCurDataSourceName;
+ else if (rName == UNO_NAME_DAD_COMMAND)
+ bOK = rValue >>= aCurDataCommand;
+ else if (rName == UNO_NAME_FILTER)
+ bOK = rValue >>= aCurFilter;
+ else if (rName == UNO_NAME_DOCUMENT_URL)
+ {
+ bOK = rValue >>= aCurDocumentURL;
+ if (!aCurDocumentURL.isEmpty()
+ && !LoadFromURL_impl( xCurModel, xCurDocSh, aCurDocumentURL, false ))
+ throw RuntimeException("Failed to create document from URL: " + aCurDocumentURL, static_cast < cppu::OWeakObject * > ( this ) );
+ }
+ else if (rName == UNO_NAME_OUTPUT_URL)
+ {
+ bOK = rValue >>= aCurOutputURL;
+ if (!aCurOutputURL.isEmpty())
+ {
+ if (!UCB_IsDirectory(aCurOutputURL))
+ throw IllegalArgumentException("URL does not point to a directory: " + aCurOutputURL, static_cast < cppu::OWeakObject * > ( this ), 0 );
+ if (UCB_IsReadOnlyFileName(aCurOutputURL))
+ throw IllegalArgumentException("URL is read-only: " + aCurOutputURL, static_cast < cppu::OWeakObject * > ( this ), 0 );
+ }
+ }
+ else if (rName == UNO_NAME_FILE_NAME_PREFIX)
+ bOK = rValue >>= aCurFileNamePrefix;
+ else if (rName == UNO_NAME_DAD_COMMAND_TYPE)
+ bOK = rValue >>= nCurDataCommandType;
+ else if (rName == UNO_NAME_OUTPUT_TYPE)
+ bOK = rValue >>= nCurOutputType;
+ else if (rName == UNO_NAME_ESCAPE_PROCESSING)
+ bOK = rValue >>= bCurEscapeProcessing;
+ else if (rName == UNO_NAME_SINGLE_PRINT_JOBS)
+ bOK = rValue >>= bCurSinglePrintJobs;
+ else if (rName == UNO_NAME_FILE_NAME_FROM_COLUMN)
+ bOK = rValue >>= bCurFileNameFromColumn;
+ else if (rName == UNO_NAME_SUBJECT)
+ bOK = rValue >>= sSubject;
+ else if (rName == UNO_NAME_ADDRESS_FROM_COLUMN)
+ bOK = rValue >>= sAddressFromColumn;
+ else if (rName == UNO_NAME_SEND_AS_HTML)
+ bOK = rValue >>= bSendAsHTML;
+ else if (rName == UNO_NAME_MAIL_BODY)
+ bOK = rValue >>= sMailBody;
+ else if (rName == UNO_NAME_ATTACHMENT_NAME)
+ bOK = rValue >>= sAttachmentName;
+ else if (rName == UNO_NAME_ATTACHMENT_FILTER)
+ bOK = rValue >>= sAttachmentFilter;
+ else if (rName == UNO_NAME_COPIES_TO)
+ bOK = rValue >>= aCopiesTo;
+ else if (rName == UNO_NAME_BLIND_COPIES_TO)
+ bOK = rValue >>= aBlindCopiesTo;
+ else if (rName == UNO_NAME_SEND_AS_ATTACHMENT)
+ bOK = rValue >>= bSendAsAttachment;
+ else if (rName == UNO_NAME_PRINT_OPTIONS)
+ bOK = rValue >>= aPrintSettings;
+ else if (rName == UNO_NAME_SAVE_AS_SINGLE_FILE)
+ bOK = rValue >>= bSaveAsSingleFile;
+ else if (rName == UNO_NAME_SAVE_FILTER)
+ bOK = rValue >>= sSaveFilter;
+ else if (rName == UNO_NAME_SAVE_FILTER_OPTIONS)
+ bOK = rValue >>= sSaveFilterOptions;
+ else if (rName == UNO_NAME_SAVE_FILTER_DATA)
+ bOK = rValue >>= aSaveFilterData;
+ else if (rName == UNO_NAME_IN_SERVER_PASSWORD)
+ bOK = rValue >>= sInServerPassword;
+ else if (rName == UNO_NAME_OUT_SERVER_PASSWORD)
+ bOK = rValue >>= sOutServerPassword;
+ else
+ throw UnknownPropertyException( OUString( "Property is unknown: " ) + rName, static_cast < cppu::OWeakObject * > ( this ) );
+
+ if (!bOK)
+ throw IllegalArgumentException("Property type mismatch or property not set: " + rName, static_cast < cppu::OWeakObject * > ( this ), 0 );
+ }
+
+ // need to translate the selection: the API here requires a sequence of bookmarks, but the MergeNew
+ // method we will call below requires a sequence of indicies.
+ if ( aCurSelection.getLength() )
+ {
+ Sequence< Any > aTranslated( aCurSelection.getLength() );
+
+ bool bValid = false;
+ Reference< sdbcx::XRowLocate > xRowLocate( xCurResultSet, UNO_QUERY );
+ if ( xRowLocate.is() )
+ {
+
+ const Any* pBookmarks = aCurSelection.getConstArray();
+ const Any* pBookmarksEnd = pBookmarks + aCurSelection.getLength();
+ Any* pTranslated = aTranslated.getArray();
+
+ try
+ {
+ bool bEverythingsFine = true;
+ for ( ; ( pBookmarks != pBookmarksEnd ) && bEverythingsFine; ++pBookmarks )
+ {
+ if ( xRowLocate->moveToBookmark( *pBookmarks ) )
+ *pTranslated <<= xCurResultSet->getRow();
+ else
+ bEverythingsFine = false;
+ }
+ if ( bEverythingsFine )
+ bValid = true;
+ }
+ catch (const Exception&)
+ {
+ bValid = false;
+ }
+ }
+
+ if ( !bValid )
+ {
+ throw IllegalArgumentException(
+ OUString( "The current 'Selection' does not describe a valid array of bookmarks, relative to the current 'ResultSet'." ),
+ static_cast < cppu::OWeakObject * > ( this ),
+ 0
+ );
+ }
+
+ aCurSelection = aTranslated;
+ }
+
+ SfxViewFrame* pFrame = SfxViewFrame::GetFirst( xCurDocSh, sal_False);
+ SwView *pView = PTR_CAST( SwView, pFrame->GetViewShell() );
+ if (!pView)
+ throw RuntimeException();
+ SwWrtShell &rSh = *pView->GetWrtShellPtr();
+
+ // avoid assertion in 'Update' from Sfx by supplying a shell
+ // and thus avoiding the SelectShell call in Writers GetState function
+ // while still in Update of Sfx.
+ // (GetSelection in Update is not allowed)
+ if (!aCurDocumentURL.isEmpty())
+ pView->AttrChangedNotify( &pView->GetWrtShell() );//So that SelectShell is called.
+
+ SharedComponent aRowSetDisposeHelper;
+ if (!xCurResultSet.is())
+ {
+ if (aCurDataSourceName.isEmpty() || aCurDataCommand.isEmpty() )
+ {
+ OSL_FAIL("PropertyValues missing or unset");
+ throw IllegalArgumentException("Either the ResultSet or DataSourceName and DataCommand must be set.", static_cast < cppu::OWeakObject * > ( this ), 0 );
+ }
+
+ // build ResultSet from DataSourceName, DataCommand and DataCommandType
+
+ Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
+ if (xMgr.is())
+ {
+ Reference< XInterface > xInstance = xMgr->createInstance( "com.sun.star.sdb.RowSet" );
+ aRowSetDisposeHelper.reset( xInstance, SharedComponent::TakeOwnership );
+ Reference< XPropertySet > xRowSetPropSet( xInstance, UNO_QUERY );
+ OSL_ENSURE( xRowSetPropSet.is(), "failed to get XPropertySet interface from RowSet" );
+ if (xRowSetPropSet.is())
+ {
+ if (xCurConnection.is())
+ xRowSetPropSet->setPropertyValue( "ActiveConnection", makeAny( xCurConnection ) );
+ xRowSetPropSet->setPropertyValue( "DataSourceName", makeAny( aCurDataSourceName ) );
+ xRowSetPropSet->setPropertyValue( "Command", makeAny( aCurDataCommand ) );
+ xRowSetPropSet->setPropertyValue( "CommandType", makeAny( nCurDataCommandType ) );
+ xRowSetPropSet->setPropertyValue( "EscapeProcessing", makeAny( bCurEscapeProcessing ) );
+ xRowSetPropSet->setPropertyValue( "ApplyFilter", makeAny( sal_True ) );
+ xRowSetPropSet->setPropertyValue( "Filter", makeAny( aCurFilter ) );
+
+ Reference< sdbc::XRowSet > xRowSet( xInstance, UNO_QUERY );
+ if (xRowSet.is())
+ xRowSet->execute(); // build ResultSet from properties
+ if( !xCurConnection.is() )
+ xCurConnection.set( xRowSetPropSet->getPropertyValue( "ActiveConnection" ), UNO_QUERY );
+ xCurResultSet = Reference< sdbc::XResultSet >( xRowSet, UNO_QUERY );
+ OSL_ENSURE( xCurResultSet.is(), "failed to build ResultSet" );
+ }
+ }
+ }
+
+ svx::ODataAccessDescriptor aDescriptor;
+ aDescriptor.setDataSource(aCurDataSourceName);
+ aDescriptor[ svx::daConnection ] <<= xCurConnection;
+ aDescriptor[ svx::daCommand ] <<= aCurDataCommand;
+ aDescriptor[ svx::daCommandType ] <<= nCurDataCommandType;
+ aDescriptor[ svx::daEscapeProcessing ] <<= bCurEscapeProcessing;
+ aDescriptor[ svx::daCursor ] <<= xCurResultSet;
+ // aDescriptor[ svx::daColumnName ] not used
+ // aDescriptor[ svx::daColumnObject ] not used
+ aDescriptor[ svx::daSelection ] <<= aCurSelection;
+
+ sal_uInt16 nMergeType;
+ switch (nCurOutputType)
+ {
+ case MailMergeType::PRINTER : nMergeType = DBMGR_MERGE_MAILMERGE; break;
+ case MailMergeType::FILE : nMergeType = DBMGR_MERGE_MAILFILES; break;
+ case MailMergeType::MAIL : nMergeType = DBMGR_MERGE_MAILING; break;
+ default:
+ throw IllegalArgumentException("Invalid value of property: OutputType", static_cast < cppu::OWeakObject * > ( this ), 0 );
+ }
+
+ SwNewDBMgr* pMgr = rSh.GetNewDBMgr();
+ //force layout creation
+ rSh.CalcLayout();
+ OSL_ENSURE( pMgr, "database manager missing" );
+ m_pMgr = pMgr;
+
+ SwMergeDescriptor aMergeDesc( nMergeType, rSh, aDescriptor );
+
+ boost::scoped_ptr< SwMailMergeConfigItem > pMMConfigItem;
+ uno::Reference< mail::XMailService > xInService;
+ if (MailMergeType::PRINTER == nCurOutputType)
+ {
+ IDocumentDeviceAccess* pIDDA = rSh.getIDocumentDeviceAccess();
+ SwPrintData aPrtData( pIDDA->getPrintData() );
+ aPrtData.SetPrintSingleJobs( bCurSinglePrintJobs );
+ pIDDA->setPrintData( aPrtData );
+ // #i25686# printing should not be done asynchronously to prevent dangling offices
+ // when mail merge is called as command line macro
+ aMergeDesc.bPrintAsync = sal_False;
+ aMergeDesc.aPrintOptions = aPrintSettings;
+ aMergeDesc.bCreateSingleFile = true;
+ }
+ else /* FILE and MAIL*/
+ {
+ INetURLObject aURLObj;
+ aURLObj.SetSmartProtocol( INET_PROT_FILE );
+
+ if (!aCurDocumentURL.isEmpty())
+ {
+ // if OutputURL or FileNamePrefix are missing get
+ // them from DocumentURL
+ aURLObj.SetSmartURL( aCurDocumentURL );
+ if (aCurFileNamePrefix.isEmpty())
+ aCurFileNamePrefix = aURLObj.GetBase(); // filename without extension
+ if (aCurOutputURL.isEmpty())
+ {
+ aURLObj.removeSegment();
+ aCurOutputURL = aURLObj.GetMainURL( INetURLObject::DECODE_TO_IURI );
+ }
+ }
+ else // default empty document without URL
+ {
+ if (aCurOutputURL.isEmpty())
+ throw RuntimeException("OutputURL is not set and can not be obtained.", static_cast < cppu::OWeakObject * > ( this ) );
+ }
+
+ aURLObj.SetSmartURL( aCurOutputURL );
+ OUString aPath = aURLObj.GetMainURL( INetURLObject::DECODE_TO_IURI );
+
+ OUString aDelim = OUString(INET_PATH_TOKEN);
+ if (aPath.getLength() >= aDelim.getLength() &&
+ aPath.copy( aPath.getLength() - aDelim.getLength() ) == aDelim)
+ aPath += aDelim;
+ if (bCurFileNameFromColumn)
+ pMgr->SetEMailColumn( aCurFileNamePrefix );
+ else
+ {
+ aPath += aCurFileNamePrefix;
+ pMgr->SetEMailColumn( OUString() );
+ }
+ pMgr->SetSubject( aPath );
+ if(MailMergeType::FILE == nCurOutputType)
+ {
+ aMergeDesc.sSaveToFilter = sSaveFilter;
+ aMergeDesc.sSaveToFilterOptions = sSaveFilterOptions;
+ aMergeDesc.aSaveToFilterData = aSaveFilterData;
+ aMergeDesc.bCreateSingleFile = bSaveAsSingleFile;
+ }
+ else
+ {
+ pMgr->SetEMailColumn( sAddressFromColumn );
+ if(sAddressFromColumn.isEmpty())
+ throw RuntimeException("Mail address column not set.", static_cast < cppu::OWeakObject * > ( this ) );
+ aMergeDesc.sSaveToFilter = sAttachmentFilter;
+ aMergeDesc.sSubject = sSubject;
+ aMergeDesc.sMailBody = sMailBody;
+ aMergeDesc.sAttachmentName = sAttachmentName;
+ aMergeDesc.aCopiesTo = aCopiesTo;
+ aMergeDesc.aBlindCopiesTo = aBlindCopiesTo;
+ aMergeDesc.bSendAsHTML = bSendAsHTML;
+ aMergeDesc.bSendAsAttachment = bSendAsAttachment;
+
+ aMergeDesc.bCreateSingleFile = sal_False;
+ pMMConfigItem.reset(new SwMailMergeConfigItem);
+ aMergeDesc.pMailMergeConfigItem = pMMConfigItem.get();
+ aMergeDesc.xSmtpServer = SwMailMergeHelper::ConnectToSmtpServer(
+ *pMMConfigItem,
+ xInService,
+ sInServerPassword, sOutServerPassword );
+ if( !aMergeDesc.xSmtpServer.is() || !aMergeDesc.xSmtpServer->isConnected())
+ throw RuntimeException("Failed to connect to mail server.", static_cast < cppu::OWeakObject * > ( this ) );
+ }
+ }
+
+ // save document with temporary filename
+ const SfxFilter *pSfxFlt = SwIoSystem::GetFilterOfFormat(
+ OUString( FILTER_XML ),
+ SwDocShell::Factory().GetFilterContainer() );
+ OUString aExtension(comphelper::string::stripStart(pSfxFlt->GetDefaultExtension(), '*'));
+ utl::TempFile aTempFile( OUString("SwMM"), &aExtension );
+ aTmpFileName = aTempFile.GetURL();
+
+ Reference< XStorable > xStorable( xCurModel, UNO_QUERY );
+ bool bStoredAsTemporary = false;
+ if ( xStorable.is() )
+ {
+ try
+ {
+ xStorable->storeAsURL( aTmpFileName, Sequence< PropertyValue >() );
+ bStoredAsTemporary = true;
+ }
+ catch (const Exception&)
+ {
+ }
+ }
+ if ( !bStoredAsTemporary )
+ throw RuntimeException("Failed to save temporary file.", static_cast < cppu::OWeakObject * > ( this ) );
+
+ pMgr->SetMergeSilent( sal_True ); // suppress dialogs, message boxes, etc.
+ const SwXMailMerge *pOldSrc = pMgr->GetMailMergeEvtSrc();
+ OSL_ENSURE( !pOldSrc || pOldSrc == this, "Ooops... different event source already set." );
+ pMgr->SetMailMergeEvtSrc( this ); // launch events for listeners
+
+ SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE, SwDocShell::GetEventName(STR_SW_EVENT_MAIL_MERGE), xCurDocSh));
+ sal_Bool bSucc = pMgr->MergeNew( aMergeDesc );
+ SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE_END, SwDocShell::GetEventName(STR_SW_EVENT_MAIL_MERGE_END), xCurDocSh));
+
+ pMgr->SetMailMergeEvtSrc( pOldSrc );
+
+ if ( xCurModel.get() != xModel.get() )
+ { // in case it was a temporary model -> close it, and delete the file
+ DeleteTmpFile_Impl( xCurModel, xCurDocSh, aTmpFileName );
+ aTmpFileName = "";
+ }
+ // (in case it wasn't a temporary model, it will be closed in the dtor, at the latest)
+
+ if (!bSucc)
+ throw Exception("Mail merge failed. Sorry, no further information available.", static_cast < cppu::OWeakObject * > ( this ) );
+
+ //de-initialize services
+ if(xInService.is() && xInService->isConnected())
+ xInService->disconnect();
+ if(aMergeDesc.xSmtpServer.is() && aMergeDesc.xSmtpServer->isConnected())
+ aMergeDesc.xSmtpServer->disconnect();
+
+ return makeAny( sal_True );
+}
+
+void SAL_CALL SwXMailMerge::cancel() throw (com::sun::star::uno::RuntimeException, std::exception)
+{
+ // Cancel may be called from a second thread, so this protects from m_pMgr
+ /// cleanup in the execute function.
+ osl::MutexGuard pMgrGuard( GetMailMergeMutex() );
+ if (m_pMgr)
+ m_pMgr->MergeCancel();
+}
+
+void SwXMailMerge::LaunchMailMergeEvent( const MailMergeEvent &rEvt ) const
+{
+ cppu::OInterfaceIteratorHelper aIt( ((SwXMailMerge *) this)->aMergeListeners );
+ while (aIt.hasMoreElements())
+ {
+ Reference< XMailMergeListener > xRef( aIt.next(), UNO_QUERY );
+ if (xRef.is())
+ xRef->notifyMailMergeEvent( rEvt );
+ }
+}
+
+void SwXMailMerge::launchEvent( const PropertyChangeEvent &rEvt ) const
+{
+ cppu::OInterfaceContainerHelper *pContainer =
+ aPropListeners.getContainer( rEvt.PropertyHandle );
+ if (pContainer)
+ {
+ cppu::OInterfaceIteratorHelper aIt( *pContainer );
+ while (aIt.hasMoreElements())
+ {
+ Reference< XPropertyChangeListener > xRef( aIt.next(), UNO_QUERY );
+ if (xRef.is())
+ xRef->propertyChange( rEvt );
+ }
+ }
+}
+
+uno::Reference< beans::XPropertySetInfo > SAL_CALL SwXMailMerge::getPropertySetInfo( )
+ throw (RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ static Reference< XPropertySetInfo > aRef = pPropSet->getPropertySetInfo();
+ return aRef;
+}
+
+void SAL_CALL SwXMailMerge::setPropertyValue(
+ const OUString& rPropertyName, const uno::Any& rValue )
+ throw (UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+
+ const SfxItemPropertySimpleEntry* pCur = pPropSet->getPropertyMap().getByName( rPropertyName );
+ if (!pCur)
+ throw UnknownPropertyException();
+ else if (pCur->nFlags & PropertyAttribute::READONLY)
+ throw PropertyVetoException();
+ else
+ {
+ void *pData = NULL;
+ switch (pCur->nWID)
+ {
+ case WID_SELECTION : pData = &aSelection; break;
+ case WID_RESULT_SET : pData = &xResultSet; break;
+ case WID_CONNECTION : pData = &xConnection; break;
+ case WID_MODEL : pData = &xModel; break;
+ case WID_DATA_SOURCE_NAME : pData = &aDataSourceName; break;
+ case WID_DATA_COMMAND : pData = &aDataCommand; break;
+ case WID_FILTER : pData = &aFilter; break;
+ case WID_DOCUMENT_URL : pData = &aDocumentURL; break;
+ case WID_OUTPUT_URL : pData = &aOutputURL; break;
+ case WID_DATA_COMMAND_TYPE : pData = &nDataCommandType; break;
+ case WID_OUTPUT_TYPE : pData = &nOutputType; break;
+ case WID_ESCAPE_PROCESSING : pData = &bEscapeProcessing; break;
+ case WID_SINGLE_PRINT_JOBS : pData = &bSinglePrintJobs; break;
+ case WID_FILE_NAME_FROM_COLUMN : pData = &bFileNameFromColumn; break;
+ case WID_FILE_NAME_PREFIX : pData = &aFileNamePrefix; break;
+ case WID_MAIL_SUBJECT: pData = &sSubject; break;
+ case WID_ADDRESS_FROM_COLUMN: pData = &sAddressFromColumn; break;
+ case WID_SEND_AS_HTML: pData = &bSendAsHTML; break;
+ case WID_SEND_AS_ATTACHMENT: pData = &bSendAsAttachment; break;
+ case WID_MAIL_BODY: pData = &sMailBody; break;
+ case WID_ATTACHMENT_NAME: pData = &sAttachmentName; break;
+ case WID_ATTACHMENT_FILTER: pData = &sAttachmentFilter;break;
+ case WID_PRINT_OPTIONS: pData = &aPrintSettings; break;
+ case WID_SAVE_AS_SINGLE_FILE: pData = &bSaveAsSingleFile; break;
+ case WID_SAVE_FILTER: pData = &sSaveFilter; break;
+ case WID_SAVE_FILTER_OPTIONS: pData = &sSaveFilterOptions; break;
+ case WID_SAVE_FILTER_DATA: pData = &aSaveFilterData; break;
+ case WID_COPIES_TO: pData = &aCopiesTo; break;
+ case WID_BLIND_COPIES_TO: pData = &aBlindCopiesTo;break;
+ case WID_IN_SERVER_PASSWORD: pData = &sInServerPassword; break;
+ case WID_OUT_SERVER_PASSWORD: pData = &sOutServerPassword; break;
+ default :
+ OSL_FAIL("unknown WID");
+ }
+ Any aOld( pData, pCur->aType );
+
+ bool bChanged = false;
+ sal_Bool bOK = sal_True;
+ if (aOld != rValue)
+ {
+ if (pData == &aSelection)
+ bOK = rValue >>= aSelection;
+ else if (pData == &xResultSet)
+ bOK = rValue >>= xResultSet;
+ else if (pData == &xConnection)
+ bOK = rValue >>= xConnection;
+ else if (pData == &xModel)
+ bOK = rValue >>= xModel;
+ else if (pData == &aDataSourceName)
+ bOK = rValue >>= aDataSourceName;
+ else if (pData == &aDataCommand)
+ bOK = rValue >>= aDataCommand;
+ else if (pData == &aFilter)
+ bOK = rValue >>= aFilter;
+ else if (pData == &aDocumentURL)
+ {
+ OUString aText;
+ bOK = rValue >>= aText;
+ if (!aText.isEmpty()
+ && !LoadFromURL_impl( xModel, xDocSh, aText, true ))
+ throw RuntimeException("Failed to create document from URL: " + aText, static_cast < cppu::OWeakObject * > ( this ) );
+ aDocumentURL = aText;
+ }
+ else if (pData == &aOutputURL)
+ {
+ OUString aText;
+ bOK = rValue >>= aText;
+ if (!aText.isEmpty())
+ {
+ if (!UCB_IsDirectory(aText))
+ throw IllegalArgumentException("URL does not point to a directory: " + aText, static_cast < cppu::OWeakObject * > ( this ), 0 );
+ if (UCB_IsReadOnlyFileName(aText))
+ throw IllegalArgumentException("URL is read-only: " + aText, static_cast < cppu::OWeakObject * > ( this ), 0 );
+ }
+ aOutputURL = aText;
+ }
+ else if (pData == &nDataCommandType)
+ bOK = rValue >>= nDataCommandType;
+ else if (pData == &nOutputType)
+ bOK = rValue >>= nOutputType;
+ else if (pData == &bEscapeProcessing)
+ bOK = rValue >>= bEscapeProcessing;
+ else if (pData == &bSinglePrintJobs)
+ bOK = rValue >>= bSinglePrintJobs;
+ else if (pData == &bFileNameFromColumn)
+ bOK = rValue >>= bFileNameFromColumn;
+ else if (pData == &aFileNamePrefix)
+ bOK = rValue >>= aFileNamePrefix;
+ else if (pData == &sSubject)
+ bOK = rValue >>= sSubject;
+ else if (pData == &sAddressFromColumn)
+ bOK = rValue >>= sAddressFromColumn;
+ else if (pData == &bSendAsHTML)
+ bOK = rValue >>= bSendAsHTML;
+ else if (pData == &bSendAsAttachment)
+ bOK = rValue >>= bSendAsAttachment;
+ else if (pData == &sMailBody)
+ bOK = rValue >>= sMailBody;
+ else if (pData == &sAttachmentName)
+ bOK = rValue >>= sAttachmentName;
+ else if (pData == &sAttachmentFilter)
+ bOK = rValue >>= sAttachmentFilter;
+ else if (pData == &aPrintSettings)
+ bOK = rValue >>= aPrintSettings;
+ else if (pData == &bSaveAsSingleFile)
+ bOK = rValue >>= bSaveAsSingleFile;
+ else if (pData == &sSaveFilter)
+ bOK = rValue >>= sSaveFilter;
+ else if (pData == &sSaveFilterOptions)
+ bOK = rValue >>= sSaveFilterOptions;
+ else if (pData == &aSaveFilterData)
+ bOK = rValue >>= aSaveFilterData;
+ else if (pData == &aCopiesTo)
+ bOK = rValue >>= aCopiesTo;
+ else if (pData == &aBlindCopiesTo)
+ bOK = rValue >>= aBlindCopiesTo;
+ else if(pData == &sInServerPassword)
+ bOK = rValue >>= sInServerPassword;
+ else if(pData == &sOutServerPassword)
+ bOK = rValue >>= sInServerPassword;
+ else {
+ OSL_FAIL("invalid pointer" );
+ }
+ OSL_ENSURE( bOK, "set value failed" );
+ bChanged = true;
+ }
+ if (!bOK)
+ throw IllegalArgumentException("Property type mismatch or property not set: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ), 0 );
+
+ if (bChanged)
+ {
+ PropertyChangeEvent aChgEvt( (XPropertySet *) this, rPropertyName,
+ sal_False, pCur->nWID, aOld, rValue );
+ launchEvent( aChgEvt );
+ }
+ }
+}
+
+uno::Any SAL_CALL SwXMailMerge::getPropertyValue(
+ const OUString& rPropertyName )
+ throw (UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+
+ Any aRet;
+
+ const SfxItemPropertySimpleEntry* pCur = pPropSet->getPropertyMap().getByName( rPropertyName );
+ if (!pCur)
+ throw UnknownPropertyException();
+ else
+ {
+ switch (pCur->nWID)
+ {
+ case WID_SELECTION : aRet <<= aSelection; break;
+ case WID_RESULT_SET : aRet <<= xResultSet; break;
+ case WID_CONNECTION : aRet <<= xConnection; break;
+ case WID_MODEL : aRet <<= xModel; break;
+ case WID_DATA_SOURCE_NAME : aRet <<= aDataSourceName; break;
+ case WID_DATA_COMMAND : aRet <<= aDataCommand; break;
+ case WID_FILTER : aRet <<= aFilter; break;
+ case WID_DOCUMENT_URL : aRet <<= aDocumentURL; break;
+ case WID_OUTPUT_URL : aRet <<= aOutputURL; break;
+ case WID_DATA_COMMAND_TYPE : aRet <<= nDataCommandType; break;
+ case WID_OUTPUT_TYPE : aRet <<= nOutputType; break;
+ case WID_ESCAPE_PROCESSING : aRet <<= bEscapeProcessing; break;
+ case WID_SINGLE_PRINT_JOBS : aRet <<= bSinglePrintJobs; break;
+ case WID_FILE_NAME_FROM_COLUMN : aRet <<= bFileNameFromColumn; break;
+ case WID_FILE_NAME_PREFIX : aRet <<= aFileNamePrefix; break;
+ case WID_MAIL_SUBJECT: aRet <<= sSubject; break;
+ case WID_ADDRESS_FROM_COLUMN: aRet <<= sAddressFromColumn; break;
+ case WID_SEND_AS_HTML: aRet <<= bSendAsHTML; break;
+ case WID_SEND_AS_ATTACHMENT: aRet <<= bSendAsAttachment; break;
+ case WID_MAIL_BODY: aRet <<= sMailBody; break;
+ case WID_ATTACHMENT_NAME: aRet <<= sAttachmentName; break;
+ case WID_ATTACHMENT_FILTER: aRet <<= sAttachmentFilter;break;
+ case WID_PRINT_OPTIONS: aRet <<= aPrintSettings; break;
+ case WID_SAVE_AS_SINGLE_FILE: aRet <<= bSaveAsSingleFile; break;
+ case WID_SAVE_FILTER: aRet <<= sSaveFilter; break;
+ case WID_SAVE_FILTER_OPTIONS: aRet <<= sSaveFilterOptions; break;
+ case WID_SAVE_FILTER_DATA: aRet <<= aSaveFilterData; break;
+ case WID_COPIES_TO: aRet <<= aCopiesTo; break;
+ case WID_BLIND_COPIES_TO: aRet <<= aBlindCopiesTo;break;
+ case WID_IN_SERVER_PASSWORD: aRet <<= sInServerPassword; break;
+ case WID_OUT_SERVER_PASSWORD: aRet <<= sOutServerPassword; break;
+ default :
+ OSL_FAIL("unknown WID");
+ }
+ }
+
+ return aRet;
+}
+
+void SAL_CALL SwXMailMerge::addPropertyChangeListener(
+ const OUString& rPropertyName,
+ const uno::Reference< beans::XPropertyChangeListener >& rListener )
+ throw (UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ if (!bDisposing && rListener.is())
+ {
+ const SfxItemPropertySimpleEntry* pCur = pPropSet->getPropertyMap().getByName( rPropertyName );
+ if (pCur)
+ aPropListeners.addInterface( pCur->nWID, rListener );
+ else
+ throw UnknownPropertyException();
+ }
+}
+
+void SAL_CALL SwXMailMerge::removePropertyChangeListener(
+ const OUString& rPropertyName,
+ const uno::Reference< beans::XPropertyChangeListener >& rListener )
+ throw (UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ if (!bDisposing && rListener.is())
+ {
+ const SfxItemPropertySimpleEntry* pCur = pPropSet->getPropertyMap().getByName( rPropertyName );
+ if (pCur)
+ aPropListeners.removeInterface( pCur->nWID, rListener );
+ else
+ throw UnknownPropertyException();
+ }
+}
+
+void SAL_CALL SwXMailMerge::addVetoableChangeListener(
+ const OUString& /*rPropertyName*/,
+ const uno::Reference< beans::XVetoableChangeListener >& /*rListener*/ )
+ throw (UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
+{
+ // no vetoable property, thus no support for vetoable change listeners
+ OSL_FAIL("not implemented");
+}
+
+void SAL_CALL SwXMailMerge::removeVetoableChangeListener(
+ const OUString& /*rPropertyName*/,
+ const uno::Reference< beans::XVetoableChangeListener >& /*rListener*/ )
+ throw (UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
+{
+ // no vetoable property, thus no support for vetoable change listeners
+ OSL_FAIL("not implemented");
+}
+
+void SAL_CALL SwXMailMerge::dispose()
+ throw(RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+
+ if (!bDisposing)
+ {
+ bDisposing = sal_True;
+
+ EventObject aEvtObj( (XPropertySet *) this );
+ aEvtListeners.disposeAndClear( aEvtObj );
+ aMergeListeners.disposeAndClear( aEvtObj );
+ aPropListeners.disposeAndClear( aEvtObj );
+ }
+}
+
+void SAL_CALL SwXMailMerge::addEventListener(
+ const Reference< XEventListener >& rxListener )
+ throw(RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ if (!bDisposing && rxListener.is())
+ aEvtListeners.addInterface( rxListener );
+}
+
+void SAL_CALL SwXMailMerge::removeEventListener(
+ const Reference< XEventListener >& rxListener )
+ throw(RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ if (!bDisposing && rxListener.is())
+ aEvtListeners.removeInterface( rxListener );
+}
+
+void SAL_CALL SwXMailMerge::addMailMergeEventListener(
+ const uno::Reference< XMailMergeListener >& rxListener )
+ throw (RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ if (!bDisposing && rxListener.is())
+ aMergeListeners.addInterface( rxListener );
+}
+
+void SAL_CALL SwXMailMerge::removeMailMergeEventListener(
+ const uno::Reference< XMailMergeListener >& rxListener )
+ throw (RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ if (!bDisposing && rxListener.is())
+ aMergeListeners.removeInterface( rxListener );
+}
+
+OUString SAL_CALL SwXMailMerge::getImplementationName()
+ throw(RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ return SwXMailMerge_getImplementationName();
+}
+
+sal_Bool SAL_CALL SwXMailMerge::supportsService( const OUString& rServiceName )
+ throw(RuntimeException, std::exception)
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+uno::Sequence< OUString > SAL_CALL SwXMailMerge::getSupportedServiceNames()
+ throw(RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ return SwXMailMerge_getSupportedServiceNames();
+}
+
+uno::Sequence< OUString > SAL_CALL SwXMailMerge_getSupportedServiceNames()
+ throw()
+{
+ uno::Sequence< OUString > aNames(2);
+ OUString *pName = aNames.getArray();
+ pName[0] = "com.sun.star.text.MailMerge";
+ pName[1] = "com.sun.star.sdb.DataAccessDescriptor";
+ return aNames;
+}
+
+OUString SAL_CALL SwXMailMerge_getImplementationName()
+ throw()
+{
+ return OUString( "SwXMailMerge" );
+}
+
+uno::Reference< uno::XInterface > SAL_CALL SwXMailMerge_createInstance(
+ const uno::Reference< XMultiServiceFactory > & /*rSMgr*/)
+ throw( uno::Exception )
+{
+ SolarMutexGuard aGuard;
+
+ //the module may not be loaded
+ SwGlobals::ensure();
+ uno::Reference< uno::XInterface > xRef = (cppu::OWeakObject *) new SwXMailMerge();
+ return xRef;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/uno/unomod.cxx b/sw/source/core/uibase/uno/unomod.cxx
new file mode 100644
index 000000000000..ba9293248b9a
--- /dev/null
+++ b/sw/source/core/uibase/uno/unomod.cxx
@@ -0,0 +1,990 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <swtypes.hxx>
+#include <osl/diagnose.h>
+#include <unomod.hxx>
+#include <unomid.h>
+#include <unoprnms.hxx>
+#include <unomap.hxx>
+#include <prtopt.hxx>
+#include <tools/shl.hxx>
+#include <swmodule.hxx>
+#include <view.hxx>
+#include <docsh.hxx>
+#include <wrtsh.hxx>
+#include <viewopt.hxx>
+#include <osl/mutex.hxx>
+#include <vcl/svapp.hxx>
+#include <com/sun/star/text/NotePrintMode.hpp>
+#include <doc.hxx>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/view/DocumentZoomType.hpp>
+#include <comphelper/ChainablePropertySetInfo.hxx>
+#include <cppuhelper/supportsservice.hxx>
+#include <edtwin.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <tools/urlobj.hxx>
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+using namespace ::comphelper;
+
+enum SwViewSettingsPropertyHandles
+{
+ HANDLE_VIEWSET_ANNOTATIONS,
+ HANDLE_VIEWSET_BREAKS,
+ HANDLE_VIEWSET_DRAWINGS,
+ HANDLE_VIEWSET_FIELD_COMMANDS,
+ HANDLE_VIEWSET_FOOTNOTE_BACKGROUND,
+ HANDLE_VIEWSET_GRAPHICS,
+ HANDLE_VIEWSET_HIDDEN_CHARACTERS,
+ HANDLE_VIEWSET_HIDDEN_PARAGRAPHS,
+ HANDLE_VIEWSET_HIDDEN_TEXT,
+ HANDLE_VIEWSET_HRULER,
+ HANDLE_VIEWSET_HSCROLL,
+ HANDLE_VIEWSET_INDEX_MARK_BACKGROUND,
+ HANDLE_VIEWSET_NONPRINTING_CHARACTERS,
+ HANDLE_VIEWSET_ONLINE_LAYOUT,
+ HANDLE_VIEWSET_PARA_BREAKS,
+ HANDLE_VIEWSET_PROTECTED_SPACES,
+ HANDLE_VIEWSET_SOFT_HYPHENS,
+ HANDLE_VIEWSET_SPACES,
+ HANDLE_VIEWSET_TABLE_BOUNDARIES,
+ HANDLE_VIEWSET_TABLES,
+ HANDLE_VIEWSET_TABSTOPS,
+ HANDLE_VIEWSET_TEXT_BOUNDARIES,
+ HANDLE_VIEWSET_TEXT_FIELD_BACKGROUND,
+ HANDLE_VIEWSET_VRULER,
+ HANDLE_VIEWSET_VSCROLL,
+ HANDLE_VIEWSET_SMOOTH_SCROLLING,
+ HANDLE_VIEWSET_ZOOM_TYPE,
+ HANDLE_VIEWSET_ZOOM,
+ HANDLE_VIEWSET_SHOW_CONTENT_TIPS,
+ HANDLE_VIEWSET_HELP_URL,
+ HANDLE_VIEWSET_VRULER_RIGHT,
+ HANDLE_VIEWSET_SHOW_RULER,
+ HANDLE_VIEWSET_IS_RASTER_VISIBLE,
+ HANDLE_VIEWSET_IS_SNAP_TO_RASTER,
+ HANDLE_VIEWSET_RASTER_RESOLUTION_X,
+ HANDLE_VIEWSET_RASTER_RESOLUTION_Y,
+ HANDLE_VIEWSET_RASTER_SUBDIVISION_X,
+ HANDLE_VIEWSET_RASTER_SUBDIVISION_Y,
+ HANDLE_VIEWSET_HORI_RULER_METRIC,
+ HANDLE_VIEWSET_VERT_RULER_METRIC,
+ HANDLE_VIEWSET_SCROLLBAR_TIPS
+};
+
+enum SwPrintSettingsPropertyHandles
+{
+ HANDLE_PRINTSET_ANNOTATION_MODE,
+ HANDLE_PRINTSET_BLACK_FONTS,
+ HANDLE_PRINTSET_CONTROLS,
+ HANDLE_PRINTSET_DRAWINGS,
+ HANDLE_PRINTSET_GRAPHICS,
+ HANDLE_PRINTSET_LEFT_PAGES,
+ HANDLE_PRINTSET_PAGE_BACKGROUND,
+ HANDLE_PRINTSET_PROSPECT,
+ HANDLE_PRINTSET_REVERSED,
+ HANDLE_PRINTSET_RIGHT_PAGES,
+ HANDLE_PRINTSET_FAX_NAME,
+ HANDLE_PRINTSET_PAPER_FROM_SETUP,
+ HANDLE_PRINTSET_TABLES,
+ HANDLE_PRINTSET_SINGLE_JOBS,
+ HANDLE_PRINTSET_EMPTY_PAGES,
+ HANDLE_PRINTSET_PROSPECT_RTL,
+ HANDLE_PRINTSET_PLACEHOLDER,
+ HANDLE_PRINTSET_HIDDEN_TEXT
+};
+
+static ChainablePropertySetInfo * lcl_createViewSettingsInfo()
+{
+ static PropertyInfo const aViewSettingsMap_Impl[] =
+ {
+ { OUString( "HelpURL" ), HANDLE_VIEWSET_HELP_URL , cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0},
+ { OUString( "HorizontalRulerMetric"),HANDLE_VIEWSET_HORI_RULER_METRIC , cppu::UnoType<sal_Int32>::get(), PROPERTY_NONE, 0},
+ { OUString( "IsRasterVisible"), HANDLE_VIEWSET_IS_RASTER_VISIBLE, cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
+ { OUString( "IsSnapToRaster"), HANDLE_VIEWSET_IS_SNAP_TO_RASTER, cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
+ { OUString( "IsVertRulerRightAligned"),HANDLE_VIEWSET_VRULER_RIGHT , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
+ { OUString( "ShowContentTips" ), HANDLE_VIEWSET_SHOW_CONTENT_TIPS , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
+ { OUString( "RasterResolutionX"), HANDLE_VIEWSET_RASTER_RESOLUTION_X, cppu::UnoType<sal_Int32>::get(), PROPERTY_NONE, 0},
+ { OUString( "RasterResolutionY"), HANDLE_VIEWSET_RASTER_RESOLUTION_Y, cppu::UnoType<sal_Int32>::get(), PROPERTY_NONE, 0},
+ { OUString( "RasterSubdivisionX"), HANDLE_VIEWSET_RASTER_SUBDIVISION_X, cppu::UnoType<sal_Int32>::get(), PROPERTY_NONE, 0},
+ { OUString( "RasterSubdivisionY"), HANDLE_VIEWSET_RASTER_SUBDIVISION_Y, cppu::UnoType<sal_Int32>::get(), PROPERTY_NONE, 0},
+ { OUString( "ShowAnnotations" ), HANDLE_VIEWSET_ANNOTATIONS , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
+ { OUString( "ShowBreaks"), HANDLE_VIEWSET_BREAKS , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
+ { OUString( "ShowDrawings"), HANDLE_VIEWSET_DRAWINGS , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
+ { OUString( "ShowFieldCommands"), HANDLE_VIEWSET_FIELD_COMMANDS , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
+ { OUString( "ShowFootnoteBackground"),HANDLE_VIEWSET_FOOTNOTE_BACKGROUND , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
+ { OUString( "ShowGraphics"), HANDLE_VIEWSET_GRAPHICS , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
+ { OUString( "ShowHiddenCharacters"), HANDLE_VIEWSET_HIDDEN_CHARACTERS , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
+ { OUString( "ShowHiddenParagraphs"), HANDLE_VIEWSET_HIDDEN_PARAGRAPHS , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
+ { OUString( "ShowHiddenText"), HANDLE_VIEWSET_HIDDEN_TEXT , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
+ { OUString( "ShowHoriRuler"), HANDLE_VIEWSET_HRULER , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
+ { OUString( "ShowHoriScrollBar"), HANDLE_VIEWSET_HSCROLL , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
+ { OUString( "ShowIndexMarkBackground"),HANDLE_VIEWSET_INDEX_MARK_BACKGROUND, cppu::UnoType<bool>::get(),PROPERTY_NONE, 0},
+ { OUString( "ShowNonprintingCharacters"),HANDLE_VIEWSET_NONPRINTING_CHARACTERS, cppu::UnoType<bool>::get(),PROPERTY_NONE, 0},
+ { OUString( "ShowOnlineLayout"), HANDLE_VIEWSET_ONLINE_LAYOUT , cppu::UnoType<bool>::get(), PropertyAttribute::MAYBEVOID, 0},
+ { OUString( "ShowParaBreaks"), HANDLE_VIEWSET_PARA_BREAKS , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
+ { OUString( "ShowProtectedSpaces"), HANDLE_VIEWSET_PROTECTED_SPACES , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
+ { OUString( "ShowRulers"), HANDLE_VIEWSET_SHOW_RULER , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
+ { OUString( "ShowScrollBarTips"), HANDLE_VIEWSET_SCROLLBAR_TIPS , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
+ { OUString( "ShowSoftHyphens"), HANDLE_VIEWSET_SOFT_HYPHENS , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
+ { OUString( "ShowSpaces"), HANDLE_VIEWSET_SPACES , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
+ { OUString( "ShowTableBoundaries"), HANDLE_VIEWSET_TABLE_BOUNDARIES , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
+ { OUString( "ShowTables"), HANDLE_VIEWSET_TABLES , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
+ { OUString( "ShowTabstops"), HANDLE_VIEWSET_TABSTOPS , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
+ { OUString( "ShowTextBoundaries"), HANDLE_VIEWSET_TEXT_BOUNDARIES , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
+ { OUString( "ShowTextFieldBackground"),HANDLE_VIEWSET_TEXT_FIELD_BACKGROUND, cppu::UnoType<bool>::get(),PROPERTY_NONE, 0},
+ { OUString( "ShowVertRuler"), HANDLE_VIEWSET_VRULER , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
+ { OUString( "ShowVertScrollBar"), HANDLE_VIEWSET_VSCROLL , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
+ { OUString( "SmoothScrolling"), HANDLE_VIEWSET_SMOOTH_SCROLLING , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
+ { OUString( "VerticalRulerMetric"), HANDLE_VIEWSET_VERT_RULER_METRIC , cppu::UnoType<sal_Int32>::get(), PROPERTY_NONE, 0},
+ { OUString( "ZoomType"), HANDLE_VIEWSET_ZOOM_TYPE , cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, 0},
+ { OUString( "ZoomValue"), HANDLE_VIEWSET_ZOOM , cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, 0},
+ { OUString(), 0, css::uno::Type(), 0, 0 }
+ };
+ return new ChainablePropertySetInfo ( aViewSettingsMap_Impl );
+}
+
+static ChainablePropertySetInfo * lcl_createPrintSettingsInfo()
+{
+ static PropertyInfo const aPrintSettingsMap_Impl[] =
+ {
+ { OUString( "PrintAnnotationMode" ), HANDLE_PRINTSET_ANNOTATION_MODE , cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, 0},
+ { OUString( "PrintBlackFonts" ), HANDLE_PRINTSET_BLACK_FONTS , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
+ { OUString( "PrintControls" ), HANDLE_PRINTSET_CONTROLS , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
+ { OUString( "PrintDrawings" ), HANDLE_PRINTSET_DRAWINGS , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
+ { OUString( "PrintGraphics" ), HANDLE_PRINTSET_GRAPHICS , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
+ { OUString( "PrintHiddenText"), HANDLE_PRINTSET_HIDDEN_TEXT , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
+ { OUString( "PrintLeftPages" ), HANDLE_PRINTSET_LEFT_PAGES , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
+ { OUString( "PrintPageBackground" ), HANDLE_PRINTSET_PAGE_BACKGROUND , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
+ { OUString( "PrintProspect" ), HANDLE_PRINTSET_PROSPECT , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
+ { OUString( "PrintProspectRTL" ), HANDLE_PRINTSET_PROSPECT_RTL , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
+ { OUString( "PrintReversed" ), HANDLE_PRINTSET_REVERSED , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
+ { OUString( "PrintRightPages" ), HANDLE_PRINTSET_RIGHT_PAGES , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
+ { OUString( "PrintFaxName" ), HANDLE_PRINTSET_FAX_NAME , cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0},
+ { OUString( "PrintPaperFromSetup" ), HANDLE_PRINTSET_PAPER_FROM_SETUP , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
+ { OUString( "PrintTables" ), HANDLE_PRINTSET_TABLES , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
+ { OUString( "PrintTextPlaceholder"), HANDLE_PRINTSET_PLACEHOLDER , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
+ { OUString( "PrintSingleJobs" ), HANDLE_PRINTSET_SINGLE_JOBS , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
+ { OUString( "PrintEmptyPages" ), HANDLE_PRINTSET_EMPTY_PAGES , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
+ { OUString(), 0, css::uno::Type(), 0, 0 }
+ };
+ return new ChainablePropertySetInfo ( aPrintSettingsMap_Impl );
+}
+
+Reference< uno::XInterface > SAL_CALL SwXModule_createInstance(
+ const Reference< XMultiServiceFactory > & /*rSMgr*/) throw( Exception )
+{
+ static Reference< uno::XInterface > xModule = (cppu::OWeakObject*)new SwXModule();
+ return xModule;
+}
+
+Sequence< OUString > SAL_CALL SwXModule_getSupportedServiceNames() throw()
+{
+ OUString sService( "com.sun.star.text.GlobalSettings");
+ const Sequence< OUString > aSeq( &sService, 1 );
+ return aSeq;
+}
+
+OUString SAL_CALL SwXModule_getImplementationName() throw()
+{
+ return OUString( "SwXModule" );
+}
+
+SwXModule::SwXModule() :
+ pxViewSettings(0),
+ pxPrintSettings(0)
+{
+}
+
+SwXModule::~SwXModule()
+{
+ delete pxViewSettings;
+ delete pxPrintSettings;
+}
+
+Reference< XPropertySet > SwXModule::getViewSettings(void) throw( uno::RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ if(!pxViewSettings)
+ {
+ ((SwXModule*)this)->pxViewSettings = new Reference< XPropertySet > ;
+ OSL_FAIL("Web or Text?");
+ *pxViewSettings = static_cast < HelperBaseNoState * > ( new SwXViewSettings( sal_False, 0 ) );
+ }
+ return *pxViewSettings;
+}
+
+Reference< XPropertySet > SwXModule::getPrintSettings(void) throw( uno::RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ if(!pxPrintSettings)
+ {
+ ((SwXModule*)this)->pxPrintSettings = new Reference< XPropertySet > ;
+ OSL_FAIL("Web or Text?");
+ *pxPrintSettings = static_cast < HelperBaseNoState * > ( new SwXPrintSettings ( PRINT_SETTINGS_MODULE ) );
+ }
+ return *pxPrintSettings;
+}
+
+OUString SwXModule::getImplementationName(void) throw( RuntimeException, std::exception )
+{
+ return SwXModule_getImplementationName();
+}
+
+sal_Bool SwXModule::supportsService(const OUString& rServiceName) throw( RuntimeException, std::exception )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+Sequence< OUString > SwXModule::getSupportedServiceNames(void) throw( RuntimeException, std::exception )
+{
+ return SwXModule_getSupportedServiceNames();
+}
+
+SwXPrintSettings::SwXPrintSettings(SwXPrintSettingsType eType, SwDoc* pDoc)
+: ChainableHelperNoState ( lcl_createPrintSettingsInfo (), &Application::GetSolarMutex() )
+, meType(eType)
+, mpPrtOpt ( NULL )
+, mpDoc ( pDoc )
+{
+}
+
+SwXPrintSettings::~SwXPrintSettings()
+ throw()
+{
+}
+
+void SwXPrintSettings::_preSetValues ()
+ throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
+{
+ switch (meType)
+ {
+ case PRINT_SETTINGS_MODULE:
+ mpPrtOpt = SW_MOD()->GetPrtOptions( sal_False );
+ break;
+ case PRINT_SETTINGS_WEB:
+ mpPrtOpt = SW_MOD()->GetPrtOptions( sal_True );
+ break;
+ case PRINT_SETTINGS_DOCUMENT:
+ {
+ if (!mpDoc)
+ throw IllegalArgumentException ();
+ mpPrtOpt = const_cast< SwPrintData * >(&mpDoc->getPrintData());
+ }
+ break;
+ }
+}
+
+void SwXPrintSettings::_setSingleValue( const comphelper::PropertyInfo & rInfo, const uno::Any &rValue )
+ throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
+{
+ sal_Bool bVal;
+ if ( rInfo.mnHandle != HANDLE_PRINTSET_ANNOTATION_MODE &&
+ rInfo.mnHandle != HANDLE_PRINTSET_FAX_NAME )
+ bVal = *(sal_Bool*)rValue.getValue();
+
+ switch( rInfo.mnHandle )
+ {
+ case HANDLE_PRINTSET_LEFT_PAGES:
+ {
+ bVal = *(sal_Bool*)rValue.getValue();
+ mpPrtOpt->SetPrintLeftPage(bVal);
+ }
+ break;
+ case HANDLE_PRINTSET_RIGHT_PAGES:
+ {
+ bVal = *(sal_Bool*)rValue.getValue();
+ mpPrtOpt->SetPrintRightPage(bVal);
+ }
+ break;
+ case HANDLE_PRINTSET_REVERSED:
+ {
+ bVal = *(sal_Bool*)rValue.getValue();
+ mpPrtOpt->SetPrintReverse(bVal);
+ }
+ break;
+ case HANDLE_PRINTSET_PROSPECT:
+ {
+ bVal = *(sal_Bool*)rValue.getValue();
+ mpPrtOpt->SetPrintProspect(bVal);
+ }
+ break;
+ case HANDLE_PRINTSET_GRAPHICS:
+ {
+ bVal = *(sal_Bool*)rValue.getValue();
+ mpPrtOpt->SetPrintGraphic(bVal);
+ }
+ break;
+ case HANDLE_PRINTSET_TABLES:
+ {
+ bVal = *(sal_Bool*)rValue.getValue();
+ mpPrtOpt->SetPrintTable(bVal);
+ }
+ break;
+ case HANDLE_PRINTSET_DRAWINGS:
+ {
+ bVal = *(sal_Bool*)rValue.getValue();
+ mpPrtOpt->SetPrintDraw(bVal);
+ }
+ break;
+ case HANDLE_PRINTSET_CONTROLS:
+ {
+ bVal = *(sal_Bool*)rValue.getValue();
+ mpPrtOpt->SetPrintControl(bVal);
+ }
+ break;
+ case HANDLE_PRINTSET_PAGE_BACKGROUND:
+ {
+ bVal = *(sal_Bool*)rValue.getValue();
+ mpPrtOpt->SetPrintPageBackground(bVal);
+ }
+ break;
+ case HANDLE_PRINTSET_BLACK_FONTS:
+ {
+ bVal = *(sal_Bool*)rValue.getValue();
+ mpPrtOpt->SetPrintBlackFont(bVal);
+ }
+ break;
+ case HANDLE_PRINTSET_SINGLE_JOBS:
+ {
+ bVal = *(sal_Bool*)rValue.getValue();
+ mpPrtOpt->SetPrintSingleJobs(bVal);
+ }
+ break;
+ case HANDLE_PRINTSET_PAPER_FROM_SETUP:
+ {
+ bVal = *(sal_Bool*)rValue.getValue();
+ mpPrtOpt->SetPaperFromSetup(bVal);
+ }
+ break;
+ case HANDLE_PRINTSET_ANNOTATION_MODE:
+ {
+ sal_Int16 nVal = 0;
+ rValue >>= nVal;
+ if(nVal <= text::NotePrintMode_PAGE_END)
+ mpPrtOpt->SetPrintPostIts(nVal);
+ else
+ throw lang::IllegalArgumentException();
+ }
+ break;
+ case HANDLE_PRINTSET_EMPTY_PAGES:
+ {
+ bVal = *(sal_Bool*)rValue.getValue();
+ mpPrtOpt->SetPrintEmptyPages(bVal);
+ }
+ break;
+ case HANDLE_PRINTSET_FAX_NAME:
+ {
+ OUString sString;
+ if ( rValue >>= sString)
+ mpPrtOpt->SetFaxName(sString);
+ else
+ throw lang::IllegalArgumentException();
+ }
+ break;
+ case HANDLE_PRINTSET_PROSPECT_RTL:
+ {
+ bVal = *(sal_Bool*)rValue.getValue();
+ mpPrtOpt->SetPrintProspect_RTL(bVal);
+ }
+ break;
+ case HANDLE_PRINTSET_PLACEHOLDER:
+ {
+ bVal = *(sal_Bool*)rValue.getValue();
+ mpPrtOpt->SetPrintTextPlaceholder(bVal);
+ }
+ break;
+ case HANDLE_PRINTSET_HIDDEN_TEXT:
+ {
+ bVal = *(sal_Bool*)rValue.getValue();
+ mpPrtOpt->SetPrintHiddenText(bVal);
+ }
+ break;
+ default:
+ throw UnknownPropertyException();
+ }
+}
+
+void SwXPrintSettings::_postSetValues ()
+ throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
+{
+ mpPrtOpt = NULL;
+}
+
+void SwXPrintSettings::_preGetValues ()
+ throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
+{
+ switch (meType)
+ {
+ case PRINT_SETTINGS_MODULE:
+ mpPrtOpt = SW_MOD()->GetPrtOptions( sal_False );
+ break;
+ case PRINT_SETTINGS_WEB:
+ mpPrtOpt = SW_MOD()->GetPrtOptions( sal_True );
+ break;
+ case PRINT_SETTINGS_DOCUMENT:
+ {
+ if (!mpDoc)
+ throw IllegalArgumentException ();
+ mpPrtOpt = const_cast< SwPrintData * >(&mpDoc->getPrintData());
+ }
+ break;
+ }
+}
+
+void SwXPrintSettings::_getSingleValue( const comphelper::PropertyInfo & rInfo, uno::Any & rValue )
+ throw(UnknownPropertyException, WrappedTargetException )
+{
+ switch( rInfo.mnHandle )
+ {
+ case HANDLE_PRINTSET_LEFT_PAGES:
+ rValue <<= mpPrtOpt->IsPrintLeftPage();
+ break;
+ case HANDLE_PRINTSET_RIGHT_PAGES:
+ rValue <<= mpPrtOpt->IsPrintRightPage();
+ break;
+ case HANDLE_PRINTSET_REVERSED:
+ rValue <<= mpPrtOpt->IsPrintReverse();
+ break;
+ case HANDLE_PRINTSET_PROSPECT:
+ rValue <<= mpPrtOpt->IsPrintProspect();
+ break;
+ case HANDLE_PRINTSET_GRAPHICS:
+ rValue <<= mpPrtOpt->IsPrintGraphic();
+ break;
+ case HANDLE_PRINTSET_TABLES:
+ rValue <<= mpPrtOpt->IsPrintTable();
+ break;
+ case HANDLE_PRINTSET_DRAWINGS:
+ rValue <<= mpPrtOpt->IsPrintDraw();
+ break;
+ case HANDLE_PRINTSET_CONTROLS:
+ rValue <<= mpPrtOpt->IsPrintControl();
+ break;
+ case HANDLE_PRINTSET_PAGE_BACKGROUND:
+ rValue <<= mpPrtOpt->IsPrintPageBackground();
+ break;
+ case HANDLE_PRINTSET_BLACK_FONTS:
+ rValue <<= mpPrtOpt->IsPrintBlackFont();
+ break;
+ case HANDLE_PRINTSET_SINGLE_JOBS:
+ rValue <<= mpPrtOpt->IsPrintSingleJobs();
+ break;
+ case HANDLE_PRINTSET_EMPTY_PAGES:
+ rValue <<= mpPrtOpt->IsPrintEmptyPages();
+ break;
+ case HANDLE_PRINTSET_PAPER_FROM_SETUP:
+ rValue <<= mpPrtOpt->IsPaperFromSetup();
+ break;
+ case HANDLE_PRINTSET_ANNOTATION_MODE:
+ {
+ rValue <<= static_cast < sal_Int16 > ( mpPrtOpt->GetPrintPostIts() );
+ }
+ break;
+ case HANDLE_PRINTSET_FAX_NAME :
+ {
+ rValue <<= mpPrtOpt->GetFaxName();
+ }
+ break;
+ case HANDLE_PRINTSET_PROSPECT_RTL:
+ {
+ rValue <<= mpPrtOpt->IsPrintProspectRTL();
+ }
+ break;
+ case HANDLE_PRINTSET_PLACEHOLDER:
+ {
+ rValue <<= mpPrtOpt->IsPrintTextPlaceholder();
+ }
+ break;
+ case HANDLE_PRINTSET_HIDDEN_TEXT:
+ {
+ rValue <<= mpPrtOpt->IsPrintHiddenText();
+ }
+ break;
+ default:
+ throw UnknownPropertyException();
+ }
+}
+
+void SwXPrintSettings::_postGetValues ()
+ throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
+{
+ mpPrtOpt = NULL;
+}
+
+OUString SwXPrintSettings::getImplementationName(void) throw( RuntimeException, std::exception )
+{
+ return OUString("SwXPrintSettings");
+}
+
+sal_Bool SwXPrintSettings::supportsService(const OUString& rServiceName) throw( RuntimeException, std::exception )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+Sequence< OUString > SwXPrintSettings::getSupportedServiceNames(void) throw( RuntimeException, std::exception )
+{
+ Sequence< OUString > aRet(1);
+ OUString* pArray = aRet.getArray();
+ pArray[0] = "com.sun.star.text.PrintSettings";
+ return aRet;
+}
+
+SwXViewSettings::SwXViewSettings(sal_Bool bWebView, SwView* pVw)
+: ChainableHelperNoState( lcl_createViewSettingsInfo (), &Application::GetSolarMutex() )
+, pView(pVw)
+, mpViewOption ( NULL )
+, mpConstViewOption ( NULL )
+, bObjectValid(sal_True)
+, bWeb(bWebView)
+, eHRulerUnit( FUNIT_CM )
+, mbApplyHRulerMetric( sal_False )
+, eVRulerUnit( FUNIT_CM )
+, mbApplyVRulerMetric( sal_False )
+{
+ // This property only exists if we have a view (ie, not at the module )
+ if ( !pView )
+ mpInfo->remove ( OUString ( "HelpURL" ) );
+
+}
+
+SwXViewSettings::~SwXViewSettings()
+ throw()
+{
+
+}
+
+void SwXViewSettings::_preSetValues ()
+ throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
+{
+ const SwViewOption* pVOpt = 0;
+ if(pView)
+ {
+ if(!IsValid())
+ return;
+ pVOpt = pView->GetWrtShell().GetViewOptions();
+ }
+ else
+ pVOpt = SW_MOD()->GetViewOption(bWeb);
+
+ mpViewOption = new SwViewOption (*pVOpt);
+ mbApplyZoom = sal_False;
+ if(pView)
+ mpViewOption->SetStarOneSetting(sal_True);
+}
+
+void SwXViewSettings::_setSingleValue( const comphelper::PropertyInfo & rInfo, const uno::Any &rValue )
+ throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
+{
+ sal_Bool bVal = HANDLE_VIEWSET_ZOOM != rInfo.mnHandle ?
+ *(sal_Bool*)rValue.getValue() : sal_False;
+ // the API flag should not be set to the application's view settings
+ switch( rInfo.mnHandle )
+ {
+ case HANDLE_VIEWSET_SHOW_RULER : mpViewOption->SetViewAnyRuler(bVal); break;
+ case HANDLE_VIEWSET_HRULER : mpViewOption->SetViewHRuler(bVal); break;
+ case HANDLE_VIEWSET_VRULER : mpViewOption->SetViewVRuler(bVal);break;
+ case HANDLE_VIEWSET_VRULER_RIGHT : mpViewOption->SetVRulerRight(bVal);break;
+ case HANDLE_VIEWSET_HSCROLL : mpViewOption->SetViewHScrollBar(bVal);break;
+ case HANDLE_VIEWSET_VSCROLL : mpViewOption->SetViewVScrollBar(bVal);break;
+ case HANDLE_VIEWSET_GRAPHICS : mpViewOption->SetGraphic(bVal);break;
+ case HANDLE_VIEWSET_TABLES : mpViewOption->SetTable(bVal); break;
+ case HANDLE_VIEWSET_DRAWINGS : mpViewOption->SetDraw(bVal); break;
+ case HANDLE_VIEWSET_FIELD_COMMANDS : mpViewOption->SetFldName(bVal); break;
+ case HANDLE_VIEWSET_ANNOTATIONS : mpViewOption->SetPostIts(bVal); break;
+ case HANDLE_VIEWSET_INDEX_MARK_BACKGROUND : mpViewOption->SetAppearanceFlag(VIEWOPT_FIELD_SHADINGS, bVal, sal_True); break;
+ case HANDLE_VIEWSET_NONPRINTING_CHARACTERS: mpViewOption->SetViewMetaChars( bVal ); break;
+ case HANDLE_VIEWSET_FOOTNOTE_BACKGROUND : mpViewOption->SetAppearanceFlag(VIEWOPT_FIELD_SHADINGS, bVal, sal_True); break;
+ case HANDLE_VIEWSET_TEXT_FIELD_BACKGROUND : mpViewOption->SetAppearanceFlag(VIEWOPT_FIELD_SHADINGS, bVal, sal_True); break;
+ case HANDLE_VIEWSET_PARA_BREAKS : mpViewOption->SetParagraph(bVal); break;
+ case HANDLE_VIEWSET_SOFT_HYPHENS : mpViewOption->SetSoftHyph(bVal); break;
+ case HANDLE_VIEWSET_SPACES : mpViewOption->SetBlank(bVal); break;
+ case HANDLE_VIEWSET_PROTECTED_SPACES : mpViewOption->SetHardBlank(bVal); break;
+ case HANDLE_VIEWSET_TABSTOPS : mpViewOption->SetTab(bVal); break;
+ case HANDLE_VIEWSET_BREAKS : mpViewOption->SetLineBreak(bVal); break;
+ case HANDLE_VIEWSET_HIDDEN_TEXT : mpViewOption->SetShowHiddenField(bVal); break;
+ case HANDLE_VIEWSET_HIDDEN_CHARACTERS : mpViewOption->SetShowHiddenChar(bVal); break;
+ case HANDLE_VIEWSET_HIDDEN_PARAGRAPHS : mpViewOption->SetShowHiddenPara(bVal); break;
+ case HANDLE_VIEWSET_TABLE_BOUNDARIES : mpViewOption->SetAppearanceFlag(VIEWOPT_TABLE_BOUNDARIES, bVal, sal_True); break;
+ case HANDLE_VIEWSET_TEXT_BOUNDARIES : mpViewOption->SetDocBoundaries(bVal); break;
+ case HANDLE_VIEWSET_SMOOTH_SCROLLING : mpViewOption->SetSmoothScroll(bVal); break;
+ case HANDLE_VIEWSET_SHOW_CONTENT_TIPS : mpViewOption->SetShowContentTips(bVal); break;
+ case HANDLE_VIEWSET_IS_RASTER_VISIBLE : mpViewOption->SetGridVisible(bVal); break;
+ case HANDLE_VIEWSET_IS_SNAP_TO_RASTER : mpViewOption->SetSnap(bVal); break;
+ case HANDLE_VIEWSET_SCROLLBAR_TIPS : mpViewOption->SetShowScrollBarTips(bVal); break;
+ case HANDLE_VIEWSET_RASTER_RESOLUTION_X :
+ {
+ sal_Int32 nTmp = 0;
+ if(!(rValue >>= nTmp) || nTmp < 10)
+ throw IllegalArgumentException();
+ Size aSize( mpViewOption->GetSnapSize() );
+ aSize.Width() = MM100_TO_TWIP( nTmp );
+ mpViewOption->SetSnapSize( aSize );
+ }
+ break;
+ case HANDLE_VIEWSET_RASTER_RESOLUTION_Y :
+ {
+ sal_Int32 nTmp = 0;
+ if(!(rValue >>= nTmp) || nTmp < 10)
+ throw IllegalArgumentException();
+ Size aSize( mpViewOption->GetSnapSize() );
+ aSize.Height() = MM100_TO_TWIP( nTmp );
+ mpViewOption->SetSnapSize( aSize );
+ }
+ break;
+ case HANDLE_VIEWSET_RASTER_SUBDIVISION_X :
+ {
+ sal_Int32 nTmp = 0;
+ if(!(rValue >>= nTmp) || !(0 <= nTmp && nTmp < 100))
+ throw IllegalArgumentException();
+ mpViewOption->SetDivisionX( (short) nTmp );
+ }
+ break;
+ case HANDLE_VIEWSET_RASTER_SUBDIVISION_Y :
+ {
+ sal_Int32 nTmp = 0;
+ if(!(rValue >>= nTmp) || !(0 <= nTmp && nTmp < 100))
+ throw IllegalArgumentException();
+ mpViewOption->SetDivisionY( (short) nTmp );
+ }
+ break;
+ case HANDLE_VIEWSET_ZOOM :
+ {
+ sal_Int16 nZoom = 0;
+ if(!(rValue >>= nZoom) || nZoom > 1000 || nZoom < 5)
+ throw lang::IllegalArgumentException();
+ mpViewOption->SetZoom((sal_uInt16)nZoom);
+ mbApplyZoom = sal_True;
+ }
+ break;
+ case HANDLE_VIEWSET_ZOOM_TYPE:
+ {
+ sal_Int16 nZoom = 0;
+ if(!(rValue >>= nZoom))
+ throw IllegalArgumentException();
+ SvxZoomType eZoom;
+ switch (nZoom)
+ {
+ case view::DocumentZoomType::OPTIMAL:
+ eZoom = SVX_ZOOM_OPTIMAL;
+ break;
+ case view::DocumentZoomType::PAGE_WIDTH:
+ eZoom = SVX_ZOOM_PAGEWIDTH;
+ break;
+ case view::DocumentZoomType::ENTIRE_PAGE:
+ eZoom = SVX_ZOOM_WHOLEPAGE;
+ break;
+ case view::DocumentZoomType::BY_VALUE:
+ eZoom = SVX_ZOOM_PERCENT;
+ break;
+ case view::DocumentZoomType::PAGE_WIDTH_EXACT:
+ eZoom = SVX_ZOOM_PAGEWIDTH_NOBORDER;
+ break;
+ default:
+ throw IllegalArgumentException(
+ OUString( "SwXViewSettings: invalid zoom type"), 0, 0);
+ }
+ mpViewOption->SetZoomType( eZoom );
+ mbApplyZoom = sal_True;
+ }
+ break;
+ case HANDLE_VIEWSET_ONLINE_LAYOUT :
+ {
+ if( pView && !bVal != !pView->GetWrtShell().GetViewOptions()->getBrowseMode() )
+ {
+ SwViewOption aOpt( *pView->GetWrtShell().GetViewOptions() );
+ aOpt.setBrowseMode( bVal );
+ pView->GetWrtShell().ApplyViewOptions( aOpt );
+ pView->RecheckBrowseMode();
+
+ // must be set in mpViewOption as this will overwrite settings in _post!
+ if(mpViewOption)
+ mpViewOption->setBrowseMode(bVal);
+
+ // disable multiple layout
+ pView->GetDocShell()->ToggleBrowserMode(bVal, pView );
+ }
+ }
+ break;
+ case HANDLE_VIEWSET_HELP_URL :
+ {
+ if ( pView )
+ {
+ OUString sHelpURL;
+ if ( ! ( rValue >>= sHelpURL ) )
+ throw IllegalArgumentException();
+
+ INetURLObject aHID( sHelpURL );
+ if ( aHID.GetProtocol() == INET_PROT_HID )
+ pView->GetEditWin().SetHelpId( OUStringToOString( aHID.GetURLPath(), RTL_TEXTENCODING_UTF8 ) );
+ else
+ throw IllegalArgumentException ();
+ }
+ else
+ throw UnknownPropertyException();
+ }
+ break;
+ case HANDLE_VIEWSET_HORI_RULER_METRIC:
+ case HANDLE_VIEWSET_VERT_RULER_METRIC:
+ {
+ sal_Int32 nUnit = -1;
+ if( rValue >>= nUnit )
+ switch( nUnit )
+ {
+ case FUNIT_MM:
+ case FUNIT_CM:
+ case FUNIT_POINT:
+ case FUNIT_PICA:
+ case FUNIT_INCH:
+ if( rInfo.mnHandle == HANDLE_VIEWSET_HORI_RULER_METRIC )
+ {
+ eHRulerUnit = nUnit;
+ mbApplyHRulerMetric = sal_True;
+ }
+ else
+ {
+ eVRulerUnit = nUnit;
+ mbApplyVRulerMetric = sal_True;
+ }
+ break;
+ default:
+ throw IllegalArgumentException();
+ }
+ }
+ break;
+ default:
+ throw UnknownPropertyException();
+ }
+}
+
+void SwXViewSettings::_postSetValues ()
+ throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
+{
+ if( pView )
+ {
+ if(mbApplyZoom )
+ pView->SetZoom( (SvxZoomType)mpViewOption->GetZoomType(),
+ mpViewOption->GetZoom(), sal_True );
+ if(mbApplyHRulerMetric)
+ pView->ChangeTabMetric((FieldUnit)eHRulerUnit);
+ if(mbApplyVRulerMetric)
+ pView->ChangeVRulerMetric((FieldUnit)eVRulerUnit);
+
+ }
+ else
+ {
+ if(mbApplyHRulerMetric)
+ SW_MOD()->ApplyRulerMetric( (FieldUnit)eHRulerUnit, sal_True, bWeb );
+ if(mbApplyVRulerMetric)
+ SW_MOD()->ApplyRulerMetric( (FieldUnit)eVRulerUnit, sal_False, bWeb );
+ }
+
+ SW_MOD()->ApplyUsrPref( *mpViewOption, pView, pView ? VIEWOPT_DEST_VIEW_ONLY
+ : bWeb ? VIEWOPT_DEST_WEB
+ : VIEWOPT_DEST_TEXT );
+
+ delete mpViewOption;
+ mpViewOption = NULL;
+}
+
+void SwXViewSettings::_preGetValues ()
+ throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
+{
+ if(pView)
+ {
+ if(!IsValid())
+ return;
+ mpConstViewOption = pView->GetWrtShell().GetViewOptions();
+ }
+ else
+ mpConstViewOption = SW_MOD()->GetViewOption(bWeb);
+}
+
+void SwXViewSettings::_getSingleValue( const comphelper::PropertyInfo & rInfo, uno::Any & rValue )
+ throw(UnknownPropertyException, WrappedTargetException )
+{
+ bool bBool = true;
+ sal_Bool bBoolVal;
+ switch( rInfo.mnHandle )
+ {
+ case HANDLE_VIEWSET_SHOW_RULER: bBoolVal = mpConstViewOption->IsViewAnyRuler(); break;
+ case HANDLE_VIEWSET_HRULER : bBoolVal = mpConstViewOption->IsViewHRuler(sal_True); break;
+ case HANDLE_VIEWSET_VRULER : bBoolVal = mpConstViewOption->IsViewVRuler(sal_True);break;
+ case HANDLE_VIEWSET_VRULER_RIGHT : bBoolVal = mpConstViewOption->IsVRulerRight();break;
+ case HANDLE_VIEWSET_HSCROLL: bBoolVal = mpConstViewOption->IsViewHScrollBar();break;
+ case HANDLE_VIEWSET_VSCROLL: bBoolVal = mpConstViewOption->IsViewVScrollBar();break;
+ case HANDLE_VIEWSET_GRAPHICS : bBoolVal = mpConstViewOption->IsGraphic();break;
+ case HANDLE_VIEWSET_TABLES : bBoolVal = mpConstViewOption->IsTable(); break;
+ case HANDLE_VIEWSET_DRAWINGS : bBoolVal = mpConstViewOption->IsDraw(); break;
+ case HANDLE_VIEWSET_FIELD_COMMANDS : bBoolVal = mpConstViewOption->IsFldName(); break;
+ case HANDLE_VIEWSET_ANNOTATIONS : bBoolVal = mpConstViewOption->IsPostIts(); break;
+ case HANDLE_VIEWSET_INDEX_MARK_BACKGROUND : bBoolVal = SwViewOption::IsFieldShadings(); break;
+ case HANDLE_VIEWSET_NONPRINTING_CHARACTERS: bBoolVal = mpConstViewOption->IsViewMetaChars(); break;
+ case HANDLE_VIEWSET_FOOTNOTE_BACKGROUND : bBoolVal = SwViewOption::IsFieldShadings(); break;
+ case HANDLE_VIEWSET_TEXT_FIELD_BACKGROUND : bBoolVal = SwViewOption::IsFieldShadings(); break;
+ case HANDLE_VIEWSET_PARA_BREAKS : bBoolVal = mpConstViewOption->IsParagraph(sal_True); break;
+ case HANDLE_VIEWSET_SOFT_HYPHENS : bBoolVal = mpConstViewOption->IsSoftHyph(); break;
+ case HANDLE_VIEWSET_SPACES : bBoolVal = mpConstViewOption->IsBlank(sal_True); break;
+ case HANDLE_VIEWSET_PROTECTED_SPACES : bBoolVal = mpConstViewOption->IsHardBlank(); break;
+ case HANDLE_VIEWSET_TABSTOPS : bBoolVal = mpConstViewOption->IsTab(sal_True); break;
+ case HANDLE_VIEWSET_BREAKS : bBoolVal = mpConstViewOption->IsLineBreak(sal_True); break;
+ case HANDLE_VIEWSET_HIDDEN_TEXT : bBoolVal = mpConstViewOption->IsShowHiddenField(); break;
+ case HANDLE_VIEWSET_HIDDEN_CHARACTERS : bBoolVal = mpConstViewOption->IsShowHiddenChar(sal_True); break;
+ case HANDLE_VIEWSET_HIDDEN_PARAGRAPHS : bBoolVal = mpConstViewOption->IsShowHiddenPara(); break;
+ case HANDLE_VIEWSET_TABLE_BOUNDARIES : bBoolVal = SwViewOption::IsTableBoundaries(); break;
+ case HANDLE_VIEWSET_TEXT_BOUNDARIES : bBoolVal = SwViewOption::IsDocBoundaries(); break;
+ case HANDLE_VIEWSET_SMOOTH_SCROLLING : bBoolVal = mpConstViewOption->IsSmoothScroll(); break;
+ case HANDLE_VIEWSET_SHOW_CONTENT_TIPS : bBoolVal = mpConstViewOption->IsShowContentTips(); break;
+ case HANDLE_VIEWSET_IS_RASTER_VISIBLE : bBoolVal = mpConstViewOption->IsGridVisible(); break;
+ case HANDLE_VIEWSET_IS_SNAP_TO_RASTER : bBoolVal = mpConstViewOption->IsSnap(); break;
+ case HANDLE_VIEWSET_SCROLLBAR_TIPS : bBoolVal = mpConstViewOption->IsShowScrollBarTips(); break;
+ case HANDLE_VIEWSET_RASTER_RESOLUTION_X :
+ bBool = false;
+ rValue <<= (sal_Int32) TWIP_TO_MM100(mpConstViewOption->GetSnapSize().Width());
+ break;
+ case HANDLE_VIEWSET_RASTER_RESOLUTION_Y :
+ bBool = false;
+ rValue <<= (sal_Int32) TWIP_TO_MM100(mpConstViewOption->GetSnapSize().Height());
+ break;
+ case HANDLE_VIEWSET_RASTER_SUBDIVISION_X :
+ bBool = false;
+ rValue <<= (sal_Int32) mpConstViewOption->GetDivisionX();
+ break;
+ case HANDLE_VIEWSET_RASTER_SUBDIVISION_Y :
+ bBool = false;
+ rValue <<= (sal_Int32) mpConstViewOption->GetDivisionY();
+ break;
+ case HANDLE_VIEWSET_ZOOM :
+ bBool = false;
+ rValue <<= (sal_Int16)mpConstViewOption->GetZoom();
+ break;
+ case HANDLE_VIEWSET_ZOOM_TYPE:
+ {
+ bBool = false;
+ sal_Int16 nRet(0);
+ switch (mpConstViewOption->GetZoomType())
+ {
+ case SVX_ZOOM_OPTIMAL:
+ nRet = view::DocumentZoomType::OPTIMAL;
+ break;
+ case SVX_ZOOM_PAGEWIDTH:
+ nRet = view::DocumentZoomType::PAGE_WIDTH;
+ break;
+ case SVX_ZOOM_WHOLEPAGE:
+ nRet = view::DocumentZoomType::ENTIRE_PAGE;
+ break;
+ case SVX_ZOOM_PERCENT:
+ nRet = view::DocumentZoomType::BY_VALUE;
+ break;
+ case SVX_ZOOM_PAGEWIDTH_NOBORDER:
+ nRet = view::DocumentZoomType::PAGE_WIDTH_EXACT;
+ break;
+ default:
+ OSL_FAIL("SwXViewSettings: invalid zoom type");
+ break;
+ }
+ rValue <<= nRet;
+ }
+ break;
+ case HANDLE_VIEWSET_ONLINE_LAYOUT:
+ if(pView)
+ bBoolVal = pView->GetWrtShell().GetViewOptions()->getBrowseMode();
+ break;
+ case HANDLE_VIEWSET_HELP_URL :
+ {
+ if ( pView )
+ {
+ bBool = false;
+ OUStringBuffer sHelpURL;
+ sHelpURL.appendAscii ( INET_HID_SCHEME );
+ SwEditWin &rEditWin = pView->GetEditWin();
+ sHelpURL.append( OStringToOUString( rEditWin.GetHelpId(), RTL_TEXTENCODING_UTF8 ) );
+ rValue <<= sHelpURL.makeStringAndClear();
+ }
+ else
+ throw UnknownPropertyException();
+ }
+ break;
+ case HANDLE_VIEWSET_HORI_RULER_METRIC:
+ {
+ if ( pView )
+ {
+ FieldUnit eUnit;
+ pView->GetHRulerMetric( eUnit );
+ rValue <<= (sal_Int32)eUnit;
+ }
+ else
+ {
+ const SwMasterUsrPref* pUsrPref = SW_MOD()->GetUsrPref( bWeb );
+ rValue <<= (sal_Int32)pUsrPref->GetHScrollMetric();
+ }
+ bBool = false;
+ }
+ break;
+ case HANDLE_VIEWSET_VERT_RULER_METRIC:
+ {
+ if ( pView )
+ {
+ FieldUnit eUnit;
+ pView->GetVRulerMetric( eUnit );
+ rValue <<= (sal_Int32)eUnit;
+ }
+ else
+ {
+ const SwMasterUsrPref* pUsrPref = SW_MOD()->GetUsrPref( bWeb );
+ rValue <<= (sal_Int32)pUsrPref->GetVScrollMetric();
+ }
+ bBool = false;
+ }
+ break;
+ default: OSL_FAIL("there is no such ID!");
+ }
+ if( bBool )
+ rValue.setValue(&bBoolVal, ::getBooleanCppuType());
+}
+
+void SwXViewSettings::_postGetValues ()
+ throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
+{
+ mpConstViewOption = NULL;
+}
+
+OUString SwXViewSettings::getImplementationName(void) throw( RuntimeException, std::exception )
+{
+ return OUString("SwXViewSettings");
+}
+
+sal_Bool SwXViewSettings::supportsService(const OUString& rServiceName) throw( RuntimeException, std::exception )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+Sequence< OUString > SwXViewSettings::getSupportedServiceNames(void) throw( RuntimeException, std::exception )
+{
+ Sequence< OUString > aRet(1);
+ OUString* pArray = aRet.getArray();
+ pArray[0] = "com.sun.star.text.ViewSettings";
+ return aRet;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/uno/unomodule.cxx b/sw/source/core/uibase/uno/unomodule.cxx
new file mode 100644
index 000000000000..4acb8e88d816
--- /dev/null
+++ b/sw/source/core/uibase/uno/unomodule.cxx
@@ -0,0 +1,154 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/frame/DispatchResultState.hpp>
+
+#include "swmodule.hxx"
+#include "swdll.hxx"
+#include "unomodule.hxx"
+#include <cppuhelper/supportsservice.hxx>
+#include <sfx2/objface.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/request.hxx>
+#include <osl/mutex.hxx>
+#include <vcl/svapp.hxx>
+
+using namespace css;
+
+OUString SAL_CALL SwUnoModule_getImplementationName() throw( uno::RuntimeException )
+{
+ return OUString( "com.sun.star.comp.Writer.WriterModule" );
+}
+
+uno::Sequence< OUString > SAL_CALL SwUnoModule_getSupportedServiceNames() throw( uno::RuntimeException )
+{
+ uno::Sequence< OUString > aSeq( 1 );
+ aSeq[0] = "com.sun.star.text.ModuleDispatcher";
+ return aSeq;
+}
+
+uno::Reference< uno::XInterface > SAL_CALL SwUnoModule_createInstance(
+ const uno::Reference< lang::XMultiServiceFactory > & rSMgr )
+{
+ SolarMutexGuard aGuard;
+ return uno::Reference< uno::XInterface >( dynamic_cast< frame::XDispatch * >(new SwUnoModule( rSMgr )), uno::UNO_QUERY );
+}
+
+ // XNotifyingDispatch
+void SAL_CALL SwUnoModule::dispatchWithNotification( const util::URL& aURL, const uno::Sequence< beans::PropertyValue >& aArgs, const uno::Reference< frame::XDispatchResultListener >& xListener ) throw (uno::RuntimeException, std::exception)
+{
+ // there is no guarantee, that we are holded alive during this method!
+ // May the outside dispatch container will be updated by a CONTEXT_CHANGED
+ // asynchronous ...
+ uno::Reference< uno::XInterface > xThis(static_cast< frame::XNotifyingDispatch* >(this));
+
+ SolarMutexGuard aGuard;
+ SwGlobals::ensure();
+ const SfxSlot* pSlot = SW_MOD()->GetInterface()->GetSlot( aURL.Complete );
+
+ sal_Int16 aState = frame::DispatchResultState::DONTKNOW;
+ if ( !pSlot )
+ aState = frame::DispatchResultState::FAILURE;
+ else
+ {
+ SfxRequest aReq( pSlot, aArgs, SFX_CALLMODE_SYNCHRON, SW_MOD()->GetPool() );
+ const SfxPoolItem* pResult = SW_MOD()->ExecuteSlot( aReq );
+ if ( pResult )
+ aState = frame::DispatchResultState::SUCCESS;
+ else
+ aState = frame::DispatchResultState::FAILURE;
+ }
+
+ if ( xListener.is() )
+ {
+ xListener->dispatchFinished(
+ frame::DispatchResultEvent(
+ xThis, aState, uno::Any()));
+ }
+}
+
+ // XDispatch
+void SAL_CALL SwUnoModule::dispatch( const util::URL& aURL, const uno::Sequence< beans::PropertyValue >& aArgs ) throw( uno::RuntimeException, std::exception )
+{
+ dispatchWithNotification(aURL, aArgs, uno::Reference< frame::XDispatchResultListener >());
+}
+
+void SAL_CALL SwUnoModule::addStatusListener(
+ const uno::Reference< frame::XStatusListener > & /*xControl*/,
+ const util::URL& /*aURL*/)
+ throw( uno::RuntimeException, std::exception )
+{
+}
+
+void SAL_CALL SwUnoModule::removeStatusListener(
+ const uno::Reference< frame::XStatusListener > & /*xControl*/,
+ const util::URL& /*aURL*/) throw( uno::RuntimeException, std::exception )
+{
+}
+
+uno::Sequence< uno::Reference< frame::XDispatch > > SAL_CALL SwUnoModule::queryDispatches(
+ const uno::Sequence< frame::DispatchDescriptor >& seqDescripts ) throw( uno::RuntimeException, std::exception )
+{
+ sal_Int32 nCount = seqDescripts.getLength();
+ uno::Sequence< uno::Reference< frame::XDispatch > > lDispatcher( nCount );
+
+ for( sal_Int32 i=0; i<nCount; ++i )
+ {
+ lDispatcher[i] = queryDispatch( seqDescripts[i].FeatureURL ,
+ seqDescripts[i].FrameName ,
+ seqDescripts[i].SearchFlags );
+ }
+
+ return lDispatcher;
+}
+
+// XDispatchProvider
+uno::Reference< frame::XDispatch > SAL_CALL SwUnoModule::queryDispatch(
+ const util::URL& aURL, const OUString& /*sTargetFrameName*/,
+ sal_Int32 /*eSearchFlags*/ ) throw( uno::RuntimeException, std::exception )
+{
+ uno::Reference< frame::XDispatch > xReturn;
+
+ SolarMutexGuard aGuard;
+ SwGlobals::ensure();
+ const SfxSlot* pSlot = SW_MOD()->GetInterface()->GetSlot( aURL.Complete );
+ if ( pSlot )
+ xReturn = uno::Reference< frame::XDispatch >(static_cast< frame::XDispatch* >(this), uno::UNO_QUERY);
+
+ return xReturn;
+}
+
+// XServiceInfo
+OUString SAL_CALL SwUnoModule::getImplementationName( ) throw(uno::RuntimeException, std::exception)
+{
+ return SwUnoModule_getImplementationName();
+}
+
+sal_Bool SAL_CALL SwUnoModule::supportsService( const OUString& sServiceName ) throw(uno::RuntimeException, std::exception)
+{
+ return cppu::supportsService(this, sServiceName);
+}
+
+uno::Sequence< OUString > SAL_CALL SwUnoModule::getSupportedServiceNames( ) throw(uno::RuntimeException, std::exception)
+{
+ return SwUnoModule_getSupportedServiceNames();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/uno/unomodule.hxx b/sw/source/core/uibase/uno/unomodule.hxx
new file mode 100644
index 000000000000..a32e2c5dfc4b
--- /dev/null
+++ b/sw/source/core/uibase/uno/unomodule.hxx
@@ -0,0 +1,81 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SW_SOURCE_UI_UNO_UNOMODULE_HXX
+#define INCLUDED_SW_SOURCE_UI_UNO_UNOMODULE_HXX
+
+#include <rtl/ustring.hxx>
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#include <com/sun/star/frame/XNotifyingDispatch.hpp>
+#include <com/sun/star/uno/RuntimeException.hpp>
+#include <com/sun/star/frame/DispatchDescriptor.hpp>
+#include <com/sun/star/uno/Reference.h>
+#include <cppuhelper/implbase3.hxx>
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+
+namespace com
+{
+ namespace sun
+ {
+ namespace star
+ {
+ namespace lang
+ {
+ class XMultiServiceFactory;
+ }
+ namespace beans
+ {
+ struct PropertyValue;
+ }
+ }
+ }
+}
+
+class SwUnoModule : public ::cppu::WeakImplHelper3< css::frame::XDispatchProvider, css::frame::XNotifyingDispatch, css::lang::XServiceInfo >
+{
+ css::uno::Reference < css::lang::XMultiServiceFactory > m_xFactory;
+
+public:
+ SwUnoModule( const css::uno::Reference < css::lang::XMultiServiceFactory >& xFactory )
+ : m_xFactory( xFactory )
+ {}
+
+ // XNotifyingDispatch
+ virtual void SAL_CALL dispatchWithNotification( const css::util::URL& aURL, const css::uno::Sequence< css::beans::PropertyValue >& aArgs, const css::uno::Reference< css::frame::XDispatchResultListener >& xListener ) throw (css::uno::RuntimeException, std::exception);
+
+ // XDispatch
+ virtual void SAL_CALL dispatch( const css::util::URL& aURL, const css::uno::Sequence< css::beans::PropertyValue >& aArgs ) throw( css::uno::RuntimeException, std::exception );
+ virtual void SAL_CALL addStatusListener(const css::uno::Reference< css::frame::XStatusListener > & xControl, const css::util::URL& aURL) throw( css::uno::RuntimeException, std::exception );
+ virtual void SAL_CALL removeStatusListener(const css::uno::Reference< css::frame::XStatusListener > & xControl, const css::util::URL& aURL) throw( css::uno::RuntimeException, std::exception );
+
+ // XDispatchProvider
+ virtual css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL queryDispatches( const css::uno::Sequence< css::frame::DispatchDescriptor >& seqDescriptor ) throw( css::uno::RuntimeException, std::exception ) ;
+ virtual css::uno::Reference< css::frame::XDispatch > SAL_CALL queryDispatch( const css::util::URL & aURL ,
+ const OUString & sTargetFrameName,
+ sal_Int32 eSearchFlags ) throw( css::uno::RuntimeException, std::exception ) ;
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName( ) throw(css::uno::RuntimeException, std::exception);
+ virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(css::uno::RuntimeException, std::exception);
+ virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw(css::uno::RuntimeException, std::exception);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/uno/unotxdoc.cxx b/sw/source/core/uibase/uno/unotxdoc.cxx
new file mode 100644
index 000000000000..6a6ce86d52f6
--- /dev/null
+++ b/sw/source/core/uibase/uno/unotxdoc.cxx
@@ -0,0 +1,3994 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <osl/mutex.hxx>
+#include <vcl/image.hxx>
+#include <vcl/virdev.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/print.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/sfxbasecontroller.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/printer.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <toolkit/awt/vclxdevice.hxx>
+#include <cmdid.h>
+#include <swtypes.hxx>
+#include <wdocsh.hxx>
+#include <wrtsh.hxx>
+#include <pview.hxx>
+#include <viewsh.hxx>
+#include <pvprtdat.hxx>
+#include <printdata.hxx>
+#include <svl/stritem.hxx>
+#include <unotxdoc.hxx>
+#include <svl/numuno.hxx>
+#include <fldbas.hxx>
+#include <unotextbodyhf.hxx>
+#include <unotextrange.hxx>
+#include <unotextcursor.hxx>
+#include <unosett.hxx>
+#include <unocoll.hxx>
+#include <unoredlines.hxx>
+#include <unosrch.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/objsh.hxx>
+#include <unoprnms.hxx>
+#include <unostyle.hxx>
+#include <unodraw.hxx>
+#include <svl/eitem.hxx>
+#include <pagedesc.hxx>
+#include <unotools/textsearch.hxx>
+#include <unocrsr.hxx>
+#include <unofieldcoll.hxx>
+#include <unoidxcoll.hxx>
+#include <unocrsrhelper.hxx>
+#include <unotxvw.hxx>
+#include <poolfmt.hxx>
+#include <globdoc.hxx>
+#include <viewopt.hxx>
+#include <unochart.hxx>
+#include <charatr.hxx>
+#include <svx/xmleohlp.hxx>
+#include <globals.hrc>
+#include <unomid.h>
+#include <unotools/printwarningoptions.hxx>
+#include <com/sun/star/util/SearchOptions.hpp>
+#include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/beans/XFastPropertySet.hpp>
+#include <com/sun/star/document/RedlineDisplayType.hpp>
+#include <com/sun/star/document/XDocumentEventBroadcaster.hpp>
+#include <com/sun/star/frame/XController.hpp>
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/script/XInvocation.hpp>
+#include <sfx2/linkmgr.hxx>
+#include <svx/unofill.hxx>
+#include <editeng/unolingu.hxx>
+#include <sfx2/progress.hxx>
+#include <swmodule.hxx>
+#include <docstat.hxx>
+#include <modcfg.hxx>
+#include <ndtxt.hxx>
+#include <utlui.hrc>
+#include <swcont.hxx>
+#include <unodefaults.hxx>
+#include <SwXDocumentSettings.hxx>
+#include <doc.hxx>
+#include <editeng/forbiddencharacterstable.hxx>
+#include <svl/zforlist.hxx>
+#include <drawdoc.hxx>
+#include <SwStyleNameMapper.hxx>
+#include <osl/file.hxx>
+#include <comphelper/storagehelper.hxx>
+#include <cppuhelper/supportsservice.hxx>
+
+// #i12836# enhanced pdf export
+#include <EnhancedPDFExportHelper.hxx>
+#include <numrule.hxx>
+
+#include <editeng/langitem.hxx>
+#include <docary.hxx>
+#include <i18nlangtag/languagetag.hxx>
+
+#include <format.hxx>
+#include <charfmt.hxx>
+#include <fmtcol.hxx>
+#include <istyleaccess.hxx>
+
+#include <svl/stylepool.hxx>
+#include <swatrset.hxx>
+#include <view.hxx>
+#include <srcview.hxx>
+
+#include <svtools/langtab.hxx>
+#include <map>
+#include <set>
+#include <vector>
+
+#include <editeng/eeitem.hxx>
+#include <editeng/editeng.hxx>
+#include <svx/svdoutl.hxx>
+#include <svl/languageoptions.hxx>
+#include <svx/svdview.hxx>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/servicehelper.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::text;
+using namespace ::com::sun::star::i18n;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::document;
+using ::osl::FileBase;
+
+#define SW_CREATE_DASH_TABLE 0x01
+#define SW_CREATE_GRADIENT_TABLE 0x02
+#define SW_CREATE_HATCH_TABLE 0x03
+#define SW_CREATE_BITMAP_TABLE 0x04
+#define SW_CREATE_TRANSGRADIENT_TABLE 0x05
+#define SW_CREATE_MARKER_TABLE 0x06
+#define SW_CREATE_DRAW_DEFAULTS 0x07
+
+extern bool sw_GetPostIts( IDocumentFieldsAccess* pIDFA, _SetGetExpFlds * pSrtLst );
+
+static SwPrintUIOptions * lcl_GetPrintUIOptions(
+ SwDocShell * pDocShell,
+ const SfxViewShell * pView )
+{
+ if (!pDocShell)
+ return NULL;
+
+ const sal_Bool bWebDoc = NULL != dynamic_cast< const SwWebDocShell * >(pDocShell);
+ const bool bSwSrcView = NULL != dynamic_cast< const SwSrcView * >(pView);
+ const SwView * pSwView = dynamic_cast< const SwView * >(pView);
+ const bool bHasSelection = pSwView ? pSwView->HasSelection( sal_False ) : false; // check for any selection, not just text selection
+ const bool bHasPostIts = sw_GetPostIts( pDocShell->GetDoc(), 0 );
+
+ // get default values to use in dialog from documents SwPrintData
+ const SwPrintData &rPrintData = pDocShell->GetDoc()->getPrintData();
+
+ // Get current page number
+ sal_uInt16 nCurrentPage = 1;
+ SwWrtShell* pSh = pDocShell->GetWrtShell();
+ if (pSh)
+ {
+ SwPaM* pShellCrsr = pSh->GetCrsr();
+ nCurrentPage = pShellCrsr->GetPageNum(true, 0);
+ }
+ else if (!bSwSrcView)
+ {
+ const SwPagePreview* pPreview = dynamic_cast< const SwPagePreview* >(pView);
+ OSL_ENSURE(pPreview, "Unexpected type of the view shell");
+ if (pPreview)
+ nCurrentPage = pPreview->GetSelectedPage();
+ }
+ return new SwPrintUIOptions( nCurrentPage, bWebDoc, bSwSrcView, bHasSelection, bHasPostIts, rPrintData );
+}
+
+static SwTxtFmtColl *lcl_GetParaStyle(const OUString& rCollName, SwDoc* pDoc)
+{
+ SwTxtFmtColl* pColl = pDoc->FindTxtFmtCollByName( rCollName );
+ if( !pColl )
+ {
+ sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( rCollName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
+ if( USHRT_MAX != nId )
+ pColl = pDoc->GetTxtCollFromPool( nId );
+ }
+ return pColl;
+}
+
+static void lcl_DisposeView( SfxViewFrame* pToClose, SwDocShell* pDocShell )
+{
+ // check if the view frame still exists
+ SfxViewFrame* pFound = SfxViewFrame::GetFirst( pDocShell,
+ sal_False );
+ while(pFound)
+ {
+ if( pFound == pToClose)
+ {
+ pToClose->DoClose();
+ break;
+ }
+ pFound = SfxViewFrame::GetNext( *pFound,
+ pDocShell,
+ sal_False );
+ }
+}
+
+class SwXTextDocument::Impl
+{
+private:
+ ::osl::Mutex m_Mutex; // just for OInterfaceContainerHelper
+
+public:
+ ::cppu::OInterfaceContainerHelper m_RefreshListeners;
+
+ Impl() : m_RefreshListeners(m_Mutex) { }
+
+};
+
+namespace
+{
+ class theSwXTextDocumentUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXTextDocumentUnoTunnelId > {};
+}
+
+const Sequence< sal_Int8 > & SwXTextDocument::getUnoTunnelId()
+{
+ return theSwXTextDocumentUnoTunnelId::get().getSeq();
+}
+
+sal_Int64 SAL_CALL SwXTextDocument::getSomething( const Sequence< sal_Int8 >& rId )
+ throw(RuntimeException, std::exception)
+{
+ if( rId.getLength() == 16
+ && 0 == memcmp( getUnoTunnelId().getConstArray(),
+ rId.getConstArray(), 16 ) )
+ {
+ return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this ));
+ }
+ if( rId.getLength() == 16
+ && 0 == memcmp( SfxObjectShell::getUnoTunnelId().getConstArray(),
+ rId.getConstArray(), 16 ) )
+ {
+ return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(pDocShell ));
+ }
+
+ sal_Int64 nRet = SfxBaseModel::getSomething( rId );
+ if ( nRet )
+ return nRet;
+ else
+ {
+ GetNumberFormatter();
+ Any aNumTunnel = xNumFmtAgg->queryAggregation(::getCppuType((Reference<XUnoTunnel>*)0));
+ Reference<XUnoTunnel> xNumTunnel;
+ aNumTunnel >>= xNumTunnel;
+ if(xNumTunnel.is())
+ return xNumTunnel->getSomething(rId);
+ }
+
+ return SfxBaseModel::getSomething( rId );
+}
+
+Any SAL_CALL SwXTextDocument::queryInterface( const uno::Type& rType ) throw(RuntimeException, std::exception)
+{
+ Any aRet = SwXTextDocumentBaseClass::queryInterface(rType);
+ if ( !aRet.hasValue() )
+ aRet = SfxBaseModel::queryInterface(rType);
+ if ( !aRet.hasValue() &&
+ rType == ::getCppuType((Reference<lang::XMultiServiceFactory>*)0))
+ {
+ Reference<lang::XMultiServiceFactory> xTmp = this;
+ aRet <<= xTmp;
+ }
+
+ if ( !aRet.hasValue()
+ && rType != ::getCppuType((Reference< com::sun::star::document::XDocumentEventBroadcaster>*)0)
+ && rType != ::getCppuType((Reference< com::sun::star::frame::XController>*)0)
+ && rType != ::getCppuType((Reference< com::sun::star::frame::XFrame>*)0)
+ && rType != ::getCppuType((Reference< com::sun::star::script::XInvocation>*)0)
+ && rType != ::getCppuType((Reference< com::sun::star::beans::XFastPropertySet>*)0)
+ && rType != ::getCppuType((Reference< com::sun::star::awt::XWindow>*)0))
+ {
+ GetNumberFormatter();
+ if(xNumFmtAgg.is())
+ aRet = xNumFmtAgg->queryAggregation(rType);
+ }
+ return aRet;
+}
+
+void SAL_CALL SwXTextDocument::acquire()throw()
+{
+ SfxBaseModel::acquire();
+}
+
+void SAL_CALL SwXTextDocument::release()throw()
+{
+ SfxBaseModel::release();
+}
+
+Reference< XAdapter > SwXTextDocument::queryAdapter( ) throw(RuntimeException, std::exception)
+{
+ return SfxBaseModel::queryAdapter();
+}
+
+Sequence< uno::Type > SAL_CALL SwXTextDocument::getTypes() throw(RuntimeException, std::exception)
+{
+ Sequence< uno::Type > aBaseTypes = SfxBaseModel::getTypes();
+ Sequence< uno::Type > aTextTypes = SwXTextDocumentBaseClass::getTypes();
+
+ Sequence< uno::Type > aNumTypes;
+ GetNumberFormatter();
+ if(xNumFmtAgg.is())
+ {
+ const uno::Type& rProvType = ::getCppuType((Reference <XTypeProvider>*)0);
+ Any aNumProv = xNumFmtAgg->queryAggregation(rProvType);
+ Reference<XTypeProvider> xNumProv;
+ if(aNumProv >>= xNumProv)
+ {
+ aNumTypes = xNumProv->getTypes();
+ }
+ }
+ long nIndex = aBaseTypes.getLength();
+ // don't forget the lang::XMultiServiceFactory
+ aBaseTypes.realloc(aBaseTypes.getLength() + aTextTypes.getLength() + aNumTypes.getLength() + 1);
+ uno::Type* pBaseTypes = aBaseTypes.getArray();
+ const uno::Type* pTextTypes = aTextTypes.getConstArray();
+ long nPos;
+ for(nPos = 0; nPos < aTextTypes.getLength(); nPos++)
+ {
+ pBaseTypes[nIndex++] = pTextTypes[nPos];
+ }
+ const uno::Type* pNumTypes = aNumTypes.getConstArray();
+ for(nPos = 0; nPos < aNumTypes.getLength(); nPos++)
+ {
+ pBaseTypes[nIndex++] = pNumTypes[nPos];
+ }
+ pBaseTypes[nIndex++] = ::getCppuType((Reference<lang::XMultiServiceFactory>*)0);
+ return aBaseTypes;
+}
+
+SwXTextDocument::SwXTextDocument(SwDocShell* pShell)
+ : SfxBaseModel(pShell)
+ , m_pImpl(new Impl)
+ ,
+ pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_DOCUMENT)),
+
+ pDocShell(pShell),
+
+ bObjectValid(pShell != 0),
+
+ pDrawPage(0),
+ pxXDrawPage(0),
+
+ pxXNumberingRules(0),
+ pxXFootnotes(0),
+ pxXFootnoteSettings(0),
+ pxXEndnotes(0),
+ pxXEndnoteSettings(0),
+ pxXReferenceMarks(0),
+ pxXTextFieldTypes(0),
+ pxXTextFieldMasters(0),
+ pxXTextSections(0),
+ pxXBookmarks(0),
+ pxXTextTables(0),
+ pxXTextFrames(0),
+ pxXGraphicObjects(0),
+ pxXEmbeddedObjects(0),
+ pxXStyleFamilies(0),
+ pxXAutoStyles(0),
+ pxXChapterNumbering(0),
+ pxXDocumentIndexes(0),
+
+ pxXLineNumberingProperties(0),
+ pxLinkTargetSupplier(0),
+ pxXRedlines(0),
+ m_pHiddenViewFrame(0),
+ m_pPrintUIOptions( NULL ),
+ m_pRenderData( NULL ),
+ // #i117783#
+ bApplyPagePrintSettingsFromXPagePrintable( sal_False )
+{
+}
+
+SwXTextDocument::~SwXTextDocument()
+{
+ InitNewDoc();
+ if(xNumFmtAgg.is())
+ {
+ Reference< XInterface > x0;
+ xNumFmtAgg->setDelegator(x0);
+ xNumFmtAgg = 0;
+ }
+ delete m_pPrintUIOptions;
+ if (m_pRenderData && m_pRenderData->IsViewOptionAdjust())
+ { // rhbz#827695: this can happen if the last page is not printed
+ // the SwViewShell has been deleted already by SwView::~SwView
+ // FIXME: replace this awful implementation of XRenderable with
+ // something less insane that has its own view
+ m_pRenderData->ViewOptionAdjustCrashPreventionKludge();
+ }
+ delete m_pRenderData;
+}
+
+SwXDocumentPropertyHelper * SwXTextDocument::GetPropertyHelper ()
+{
+ if(!xPropertyHelper.is())
+ {
+ pPropertyHelper = new SwXDocumentPropertyHelper(*pDocShell->GetDoc());
+ xPropertyHelper = (cppu::OWeakObject*)pPropertyHelper;
+ }
+ return pPropertyHelper;
+}
+
+void SwXTextDocument::GetNumberFormatter()
+{
+ if(IsValid())
+ {
+ if(!xNumFmtAgg.is())
+ {
+ if ( pDocShell->GetDoc() )
+ {
+ SvNumberFormatsSupplierObj* pNumFmt = new SvNumberFormatsSupplierObj(
+ pDocShell->GetDoc()->GetNumberFormatter( sal_True ));
+ Reference< util::XNumberFormatsSupplier > xTmp = pNumFmt;
+ xNumFmtAgg = Reference< XAggregation >(xTmp, UNO_QUERY);
+ }
+ if(xNumFmtAgg.is())
+ xNumFmtAgg->setDelegator((cppu::OWeakObject*)(SwXTextDocumentBaseClass*)this);
+ }
+ else
+ {
+ const uno::Type& rTunnelType = ::getCppuType((Reference <XUnoTunnel>*)0);
+ Any aNumTunnel = xNumFmtAgg->queryAggregation(rTunnelType);
+ SvNumberFormatsSupplierObj* pNumFmt = 0;
+ Reference< XUnoTunnel > xNumTunnel;
+ if(aNumTunnel >>= xNumTunnel)
+ {
+ pNumFmt = reinterpret_cast<SvNumberFormatsSupplierObj*>(
+ xNumTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId()));
+
+ }
+ OSL_ENSURE(pNumFmt, "No number formatter available");
+ if (pNumFmt && !pNumFmt->GetNumberFormatter())
+ pNumFmt->SetNumberFormatter(pDocShell->GetDoc()->GetNumberFormatter( sal_True ));
+ }
+ }
+}
+
+Reference< XText > SwXTextDocument::getText(void) throw( RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ if(!xBodyText.is())
+ {
+ pBodyText = new SwXBodyText(pDocShell->GetDoc());
+ xBodyText = pBodyText;
+ }
+ return xBodyText;
+}
+
+void SwXTextDocument::reformat(void) throw( RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+}
+
+void SwXTextDocument::lockControllers(void) throw( RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ if(IsValid())
+ {
+ UnoActionContext* pContext = new UnoActionContext(pDocShell->GetDoc());
+ aActionArr.push_front(pContext);
+ }
+ else
+ throw RuntimeException();
+}
+
+void SwXTextDocument::unlockControllers(void) throw( RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ if(!aActionArr.empty())
+ {
+ UnoActionContext* pContext = aActionArr.front();
+ aActionArr.pop_front();
+ delete pContext;
+ }
+ else
+ throw RuntimeException();
+}
+
+sal_Bool SwXTextDocument::hasControllersLocked(void) throw( RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ return !aActionArr.empty();
+}
+
+Reference< frame::XController > SwXTextDocument::getCurrentController(void) throw( RuntimeException, std::exception )
+{
+ return SfxBaseModel::getCurrentController();
+}
+
+void SwXTextDocument::setCurrentController(const Reference< frame::XController > & xController)
+ throw( NoSuchElementException, RuntimeException, std::exception )
+{
+ SfxBaseModel::setCurrentController(xController);
+}
+
+Reference< XInterface > SwXTextDocument::getCurrentSelection() throw( RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ Reference< XInterface > xRef;
+ if(IsValid())
+ {
+
+ const TypeId aTypeId = TYPE(SwView);
+ SwView* pView = (SwView*)SfxViewShell::GetFirst(&aTypeId);
+ while(pView && pView->GetObjectShell() != pDocShell)
+ {
+ pView = (SwView*)SfxViewShell::GetNext(*pView, &aTypeId);
+ }
+ if(pView)
+ {
+ Any aRef = pView->GetUNOObject()->getSelection();
+ aRef >>= xRef;
+ }
+ }
+ return xRef;
+}
+
+sal_Bool SwXTextDocument::attachResource(const OUString& aURL, const Sequence< beans::PropertyValue >& aArgs)
+ throw( RuntimeException, std::exception )
+{
+ return SfxBaseModel::attachResource(aURL, aArgs);
+}
+
+OUString SwXTextDocument::getURL(void) throw( RuntimeException, std::exception )
+{
+ return SfxBaseModel::getURL();
+}
+
+Sequence< beans::PropertyValue > SwXTextDocument::getArgs(void) throw( RuntimeException, std::exception )
+{
+ return SfxBaseModel::getArgs();
+}
+
+void SwXTextDocument::connectController(const Reference< frame::XController > & xController) throw( RuntimeException, std::exception )
+{
+ SfxBaseModel::connectController(xController);
+}
+
+void SwXTextDocument::disconnectController(const Reference< frame::XController > & xController) throw( RuntimeException, std::exception )
+{
+ SfxBaseModel::disconnectController(xController);
+}
+
+void SwXTextDocument::dispose(void) throw( RuntimeException, std::exception )
+{
+ SfxBaseModel::dispose();
+}
+
+void SwXTextDocument::close( sal_Bool bDeliverOwnership ) throw( util::CloseVetoException, RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ if(IsValid() && m_pHiddenViewFrame)
+ lcl_DisposeView( m_pHiddenViewFrame, pDocShell);
+ SfxBaseModel::close(bDeliverOwnership);
+}
+
+void SwXTextDocument::addEventListener(const Reference< lang::XEventListener > & aListener) throw( RuntimeException, std::exception )
+{
+ SfxBaseModel::addEventListener(aListener);
+}
+
+void SwXTextDocument::removeEventListener(const Reference< lang::XEventListener > & aListener) throw( RuntimeException, std::exception )
+{
+ SfxBaseModel::removeEventListener(aListener);
+}
+
+Reference< XPropertySet > SwXTextDocument::getLineNumberingProperties(void)
+ throw( RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ if(IsValid())
+ {
+ if(!pxXLineNumberingProperties)
+ {
+ pxXLineNumberingProperties = new Reference<XPropertySet>;
+ (*pxXLineNumberingProperties) = new SwXLineNumberingProperties(pDocShell->GetDoc());
+ }
+ }
+ else
+ throw RuntimeException();
+ return *pxXLineNumberingProperties;
+}
+
+Reference< XIndexReplace > SwXTextDocument::getChapterNumberingRules(void)
+ throw( RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ if(!pxXChapterNumbering)
+ {
+ pxXChapterNumbering = new Reference< XIndexReplace > ;
+ *pxXChapterNumbering = new SwXChapterNumbering(*pDocShell);
+ }
+ return *pxXChapterNumbering;
+}
+
+Reference< XIndexAccess > SwXTextDocument::getNumberingRules(void) throw( RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ if(!pxXNumberingRules )
+ {
+ ((SwXTextDocument*)this)->pxXNumberingRules = new Reference< XIndexAccess > ;
+ *pxXNumberingRules = new SwXNumberingRulesCollection( pDocShell->GetDoc() );
+ }
+ return *pxXNumberingRules;
+}
+
+Reference< XIndexAccess > SwXTextDocument::getFootnotes(void) throw( RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ if(!pxXFootnotes)
+ {
+ ((SwXTextDocument*)this)->pxXFootnotes = new Reference< XIndexAccess > ;
+ *pxXFootnotes = new SwXFootnotes(sal_False, pDocShell->GetDoc());
+ }
+ return *pxXFootnotes;
+}
+
+Reference< XPropertySet > SAL_CALL
+ SwXTextDocument::getFootnoteSettings(void) throw( RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ if(!pxXFootnoteSettings)
+ {
+ ((SwXTextDocument*)this)->pxXFootnoteSettings = new Reference< XPropertySet > ;
+ *pxXFootnoteSettings = new SwXFootnoteProperties(pDocShell->GetDoc());
+ }
+ return *pxXFootnoteSettings;
+}
+
+Reference< XIndexAccess > SwXTextDocument::getEndnotes(void) throw( RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ if(!pxXEndnotes)
+ {
+ ((SwXTextDocument*)this)->pxXEndnotes = new Reference< XIndexAccess > ;
+ *pxXEndnotes = new SwXFootnotes(sal_True, pDocShell->GetDoc());
+ }
+ return *pxXEndnotes;
+}
+
+Reference< XPropertySet > SwXTextDocument::getEndnoteSettings(void) throw( RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ if(!pxXEndnoteSettings)
+ {
+ ((SwXTextDocument*)this)->pxXEndnoteSettings = new Reference< XPropertySet > ;
+ *pxXEndnoteSettings = new SwXEndnoteProperties(pDocShell->GetDoc());
+ }
+ return *pxXEndnoteSettings;
+}
+
+Reference< util::XReplaceDescriptor > SwXTextDocument::createReplaceDescriptor(void)
+ throw( RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ Reference< util::XReplaceDescriptor > xRet = new SwXTextSearch;
+ return xRet;
+}
+
+SwUnoCrsr* SwXTextDocument::CreateCursorForSearch(Reference< XTextCursor > & xCrsr)
+{
+ getText();
+ XText *const pText = xBodyText.get();
+ SwXBodyText* pBText = (SwXBodyText*)pText;
+ SwXTextCursor *const pXTextCursor = pBText->CreateTextCursor(true);
+ xCrsr.set( static_cast<text::XWordCursor*>(pXTextCursor) );
+
+ SwUnoCrsr *const pUnoCrsr = pXTextCursor->GetCursor();
+ pUnoCrsr->SetRemainInSection(sal_False);
+ return pUnoCrsr;
+}
+
+sal_Int32 SwXTextDocument::replaceAll(const Reference< util::XSearchDescriptor > & xDesc)
+ throw( RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ Reference< XUnoTunnel > xDescTunnel(xDesc, UNO_QUERY);
+ if(!IsValid() || !xDescTunnel.is() || !xDescTunnel->getSomething(SwXTextSearch::getUnoTunnelId()))
+ throw RuntimeException();
+
+ Reference< XTextCursor > xCrsr;
+ SwUnoCrsr* pUnoCrsr = CreateCursorForSearch(xCrsr);
+
+ const SwXTextSearch* pSearch = reinterpret_cast<const SwXTextSearch*>(
+ xDescTunnel->getSomething(SwXTextSearch::getUnoTunnelId()));
+
+ int eRanges(FND_IN_BODY|FND_IN_SELALL);
+
+ util::SearchOptions aSearchOpt;
+ pSearch->FillSearchOptions( aSearchOpt );
+
+ SwDocPositions eStart = pSearch->bBack ? DOCPOS_END : DOCPOS_START;
+ SwDocPositions eEnd = pSearch->bBack ? DOCPOS_START : DOCPOS_END;
+
+ // Search should take place anywhere
+ pUnoCrsr->SetRemainInSection(sal_False);
+ sal_uInt32 nResult;
+ UnoActionContext aContext(pDocShell->GetDoc());
+ //try attribute search first
+ if(pSearch->HasSearchAttributes()||pSearch->HasReplaceAttributes())
+ {
+ SfxItemSet aSearch(pDocShell->GetDoc()->GetAttrPool(),
+ RES_CHRATR_BEGIN, RES_CHRATR_END-1,
+ RES_PARATR_BEGIN, RES_PARATR_END-1,
+ RES_FRMATR_BEGIN, RES_FRMATR_END-1,
+ 0);
+ SfxItemSet aReplace(pDocShell->GetDoc()->GetAttrPool(),
+ RES_CHRATR_BEGIN, RES_CHRATR_END-1,
+ RES_PARATR_BEGIN, RES_PARATR_END-1,
+ RES_FRMATR_BEGIN, RES_FRMATR_END-1,
+ 0);
+ pSearch->FillSearchItemSet(aSearch);
+ pSearch->FillReplaceItemSet(aReplace);
+ sal_Bool bCancel;
+ nResult = (sal_Int32)pUnoCrsr->Find( aSearch, !pSearch->bStyles,
+ eStart, eEnd, bCancel,
+ (FindRanges)eRanges,
+ !pSearch->sSearchText.isEmpty() ? &aSearchOpt : 0,
+ &aReplace );
+ }
+ else if(pSearch->bStyles)
+ {
+ SwTxtFmtColl *pSearchColl = lcl_GetParaStyle(pSearch->sSearchText, pUnoCrsr->GetDoc());
+ SwTxtFmtColl *pReplaceColl = lcl_GetParaStyle(pSearch->sReplaceText, pUnoCrsr->GetDoc());
+
+ sal_Bool bCancel;
+ nResult = pUnoCrsr->Find( *pSearchColl,
+ eStart, eEnd, bCancel,
+ (FindRanges)eRanges, pReplaceColl );
+
+ }
+ else
+ {
+ //todo/mba: assuming that notes should be omitted
+ sal_Bool bSearchInNotes = sal_False;
+ sal_Bool bCancel;
+ nResult = pUnoCrsr->Find( aSearchOpt, bSearchInNotes,
+ eStart, eEnd, bCancel,
+ (FindRanges)eRanges,
+ sal_True );
+ }
+ return (sal_Int32)nResult;
+
+}
+
+Reference< util::XSearchDescriptor > SwXTextDocument::createSearchDescriptor(void)
+ throw( RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ Reference< util::XSearchDescriptor > xRet = new SwXTextSearch;
+ return xRet;
+
+}
+
+// Used for findAll/First/Next
+
+SwUnoCrsr* SwXTextDocument::FindAny(const Reference< util::XSearchDescriptor > & xDesc,
+ Reference< XTextCursor > & xCrsr, sal_Bool bAll,
+ sal_Int32& nResult,
+ Reference< XInterface > xLastResult)
+{
+ Reference< XUnoTunnel > xDescTunnel(xDesc, UNO_QUERY);
+ if(!IsValid() || !xDescTunnel.is() || !xDescTunnel->getSomething(SwXTextSearch::getUnoTunnelId()))
+ return 0;
+
+ SwUnoCrsr* pUnoCrsr = CreateCursorForSearch(xCrsr);
+ const SwXTextSearch* pSearch = reinterpret_cast<const SwXTextSearch*>(
+ xDescTunnel->getSomething(SwXTextSearch::getUnoTunnelId()));
+
+ sal_Bool bParentInExtra = sal_False;
+ if(xLastResult.is())
+ {
+ Reference<XUnoTunnel> xCursorTunnel( xLastResult, UNO_QUERY);
+ OTextCursorHelper* pPosCrsr = 0;
+ if(xCursorTunnel.is())
+ {
+ pPosCrsr = reinterpret_cast<OTextCursorHelper*>(xCursorTunnel->getSomething(
+ OTextCursorHelper::getUnoTunnelId()));
+ }
+ SwPaM* pCrsr = pPosCrsr ? pPosCrsr->GetPaM() : 0;
+ if(pCrsr)
+ {
+ *pUnoCrsr->GetPoint() = *pCrsr->End();
+ pUnoCrsr->DeleteMark();
+ }
+ else
+ {
+ SwXTextRange* pRange = 0;
+ if(xCursorTunnel.is())
+ {
+ pRange = reinterpret_cast<SwXTextRange*>(xCursorTunnel->getSomething(
+ SwXTextRange::getUnoTunnelId()));
+ }
+ if(!pRange)
+ return 0;
+ pRange->GetPositions(*pUnoCrsr);
+ if(pUnoCrsr->HasMark())
+ {
+ if(*pUnoCrsr->GetPoint() < *pUnoCrsr->GetMark())
+ pUnoCrsr->Exchange();
+ pUnoCrsr->DeleteMark();
+ }
+ }
+ const SwNode* pRangeNode = pUnoCrsr->GetNode();
+ bParentInExtra = pRangeNode->FindFlyStartNode() ||
+ pRangeNode->FindFootnoteStartNode() ||
+ pRangeNode->FindHeaderStartNode() ||
+ pRangeNode->FindFooterStartNode() ;
+ }
+
+ util::SearchOptions aSearchOpt;
+ pSearch->FillSearchOptions( aSearchOpt );
+
+/**
+ * The following combinations are allowed:
+ * - Search in the body: -> FND_IN_BODY
+ * - Search all in the body: -> FND_IN_BODYONLY | FND_IN_SELALL
+ * - Search in selections: one / all -> FND_IN_SEL [ | FND_IN_SELALL ]
+ * - Search outside the body: one / all -> FND_IN_OTHER [ | FND_IN_SELALL ]
+ * - Search everywhere all: -> FND_IN_SELALL
+ */
+ int eRanges(FND_IN_BODY);
+ if(bParentInExtra)
+ eRanges = FND_IN_OTHER;
+ if(bAll) //always - everywhere?
+ eRanges = FND_IN_SELALL;
+ SwDocPositions eStart = !bAll ? DOCPOS_CURR : pSearch->bBack ? DOCPOS_END : DOCPOS_START;
+ SwDocPositions eEnd = pSearch->bBack ? DOCPOS_START : DOCPOS_END;
+
+ nResult = 0;
+ sal_uInt16 nSearchProc = 0;
+ while(nSearchProc < 2)
+ {
+ //try attribute search first
+ if(pSearch->HasSearchAttributes())
+ {
+ SfxItemSet aSearch(pDocShell->GetDoc()->GetAttrPool(),
+ RES_CHRATR_BEGIN, RES_CHRATR_END-1,
+ RES_PARATR_BEGIN, RES_PARATR_END-1,
+ RES_FRMATR_BEGIN, RES_FRMATR_END-1,
+ RES_TXTATR_INETFMT, RES_TXTATR_CHARFMT,
+ 0);
+ pSearch->FillSearchItemSet(aSearch);
+ sal_Bool bCancel;
+ nResult = (sal_Int32)pUnoCrsr->Find( aSearch, !pSearch->bStyles,
+ eStart, eEnd, bCancel,
+ (FindRanges)eRanges,
+ !pSearch->sSearchText.isEmpty() ? &aSearchOpt : 0,
+ 0 );
+ }
+ else if(pSearch->bStyles)
+ {
+ SwTxtFmtColl *pSearchColl = lcl_GetParaStyle(pSearch->sSearchText, pUnoCrsr->GetDoc());
+ //pSearch->sReplaceText
+ SwTxtFmtColl *pReplaceColl = 0;
+ sal_Bool bCancel;
+ nResult = (sal_Int32)pUnoCrsr->Find( *pSearchColl,
+ eStart, eEnd, bCancel,
+ (FindRanges)eRanges, pReplaceColl );
+ }
+ else
+ {
+ //todo/mba: assuming that notes should be omitted
+ sal_Bool bSearchInNotes = sal_False;
+ sal_Bool bCancel;
+ nResult = (sal_Int32)pUnoCrsr->Find( aSearchOpt, bSearchInNotes,
+ eStart, eEnd, bCancel,
+ (FindRanges)eRanges,
+ /*int bReplace =*/sal_False );
+ }
+ nSearchProc++;
+ if(nResult || (eRanges&(FND_IN_SELALL|FND_IN_OTHER)))
+ break;
+ //second step - find in other
+ eRanges = FND_IN_OTHER;
+ }
+ return pUnoCrsr;
+}
+
+Reference< XIndexAccess >
+ SwXTextDocument::findAll(const Reference< util::XSearchDescriptor > & xDesc)
+ throw( RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ Reference< XInterface > xTmp;
+ sal_Int32 nResult = 0;
+ Reference< XTextCursor > xCrsr;
+ SwUnoCrsr* pResultCrsr = FindAny(xDesc, xCrsr, sal_True, nResult, xTmp);
+ if(!pResultCrsr)
+ throw RuntimeException();
+ Reference< XIndexAccess > xRet;
+ xRet = new SwXTextRanges( (nResult) ? pResultCrsr : 0 );
+ delete pResultCrsr;
+ return xRet;
+}
+
+Reference< XInterface > SwXTextDocument::findFirst(const Reference< util::XSearchDescriptor > & xDesc)
+ throw( RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ Reference< XInterface > xTmp;
+ sal_Int32 nResult = 0;
+ Reference< XTextCursor > xCrsr;
+ SwUnoCrsr* pResultCrsr = FindAny(xDesc, xCrsr, sal_False, nResult, xTmp);
+ if(!pResultCrsr)
+ throw RuntimeException();
+ Reference< XInterface > xRet;
+ if(nResult)
+ {
+ const uno::Reference< text::XText > xParent =
+ ::sw::CreateParentXText(*pDocShell->GetDoc(),
+ *pResultCrsr->GetPoint());
+ xRet = *new SwXTextCursor(xParent, *pResultCrsr);
+ delete pResultCrsr;
+ }
+ return xRet;
+}
+
+Reference< XInterface > SwXTextDocument::findNext(const Reference< XInterface > & xStartAt,
+ const Reference< util::XSearchDescriptor > & xDesc)
+ throw( RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ Reference< XInterface > xTmp;
+ sal_Int32 nResult = 0;
+ Reference< XTextCursor > xCrsr;
+ if(!xStartAt.is())
+ throw RuntimeException();
+ SwUnoCrsr* pResultCrsr = FindAny(xDesc, xCrsr, sal_False, nResult, xStartAt);
+ if(!pResultCrsr)
+ throw RuntimeException();
+ Reference< XInterface > xRet;
+ if(nResult)
+ {
+ const uno::Reference< text::XText > xParent =
+ ::sw::CreateParentXText(*pDocShell->GetDoc(),
+ *pResultCrsr->GetPoint());
+
+ xRet = *new SwXTextCursor(xParent, *pResultCrsr);
+ delete pResultCrsr;
+ }
+ return xRet;
+}
+
+Sequence< beans::PropertyValue > SwXTextDocument::getPagePrintSettings(void)
+ throw( RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ Sequence< beans::PropertyValue > aSeq(9);
+ if(IsValid())
+ {
+ beans::PropertyValue* pArray = aSeq.getArray();
+ SwPagePreviewPrtData aData;
+ const SwPagePreviewPrtData* pData = pDocShell->GetDoc()->GetPreviewPrtData();
+ if(pData)
+ aData = *pData;
+ Any aVal;
+ aVal <<= (sal_Int16)aData.GetRow();
+ pArray[0] = beans::PropertyValue("PageRows", -1, aVal, PropertyState_DIRECT_VALUE);
+ aVal <<= (sal_Int16)aData.GetCol();
+ pArray[1] = beans::PropertyValue("PageColumns", -1, aVal, PropertyState_DIRECT_VALUE);
+ aVal <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(aData.GetLeftSpace());
+ pArray[2] = beans::PropertyValue("LeftMargin", -1, aVal, PropertyState_DIRECT_VALUE);
+ aVal <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(aData.GetRightSpace());
+ pArray[3] = beans::PropertyValue("RightMargin", -1, aVal, PropertyState_DIRECT_VALUE);
+ aVal <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(aData.GetTopSpace());
+ pArray[4] = beans::PropertyValue("TopMargin", -1, aVal, PropertyState_DIRECT_VALUE);
+ aVal <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(aData.GetBottomSpace());
+ pArray[5] = beans::PropertyValue("BottomMargin", -1, aVal, PropertyState_DIRECT_VALUE);
+ aVal <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(aData.GetHorzSpace());
+ pArray[6] = beans::PropertyValue("HoriMargin", -1, aVal, PropertyState_DIRECT_VALUE);
+ aVal <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(aData.GetVertSpace());
+ pArray[7] = beans::PropertyValue("VertMargin", -1, aVal, PropertyState_DIRECT_VALUE);
+ sal_Bool bTemp = aData.GetLandscape();
+ aVal.setValue(&bTemp, ::getCppuBooleanType());
+ pArray[8] = beans::PropertyValue("IsLandscape", -1, aVal, PropertyState_DIRECT_VALUE);
+ }
+ else
+ throw RuntimeException();
+ return aSeq;
+}
+
+static sal_uInt32 lcl_Any_To_ULONG(const Any& rValue, sal_Bool& bException)
+{
+ bException = sal_False;
+ TypeClass eType = rValue.getValueType().getTypeClass();
+
+ sal_uInt32 nRet = 0;
+ if( eType == TypeClass_UNSIGNED_LONG )
+ rValue >>= nRet;
+ else
+ {
+ sal_Int32 nVal=0;
+ bException = !(rValue >>= nVal);
+ if( !bException )
+ nRet = (sal_uInt32)nVal;
+ }
+
+ return nRet;
+}
+
+static OUString lcl_CreateOutlineString( sal_uInt16 nIndex,
+ const SwOutlineNodes& rOutlineNodes, const SwNumRule* pOutlRule)
+{
+ OUString sEntry;
+ const SwTxtNode * pTxtNd = rOutlineNodes[ nIndex ]->GetTxtNode();
+ SwNumberTree::tNumberVector aNumVector = pTxtNd->GetNumberVector();
+ if( pOutlRule && pTxtNd->GetNumRule())
+ for( sal_Int8 nLevel = 0;
+ nLevel <= pTxtNd->GetActualListLevel();
+ nLevel++ )
+ {
+ long nVal = aNumVector[nLevel];
+ nVal ++;
+ nVal -= pOutlRule->Get(nLevel).GetStart();
+ sEntry += OUString::number( nVal );
+ sEntry += ".";
+ }
+ sEntry += rOutlineNodes[ nIndex ]->
+ GetTxtNode()->GetExpandTxt( 0, -1, false );
+ return sEntry;
+}
+
+void SwXTextDocument::setPagePrintSettings(const Sequence< beans::PropertyValue >& aSettings)
+ throw( RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ if(IsValid())
+ {
+ SwPagePreviewPrtData aData;
+ //if only a few properties are coming, then use the current settings
+ const SwPagePreviewPrtData* pData = pDocShell->GetDoc()->GetPreviewPrtData();
+ if(pData)
+ aData = *pData;
+ const beans::PropertyValue* pProperties = aSettings.getConstArray();
+ int nCount = aSettings.getLength();
+ for(int i = 0; i < nCount; i++)
+ {
+ OUString sName = pProperties[i].Name;
+ const Any& rVal = pProperties[i].Value;
+ sal_Bool bException;
+ sal_uInt32 nVal = lcl_Any_To_ULONG(rVal, bException);
+ if( sName.equalsAscii("PageRows" ) )
+ {
+ if(!nVal || nVal > 0xff)
+ throw RuntimeException();
+ aData.SetRow((sal_uInt8)nVal);
+ }
+ else if(sName.equalsAscii("PageColumns"))
+ {
+ if(!nVal || nVal > 0xff)
+ throw RuntimeException();
+ aData.SetCol((sal_uInt8)nVal);
+ }
+ else if(sName.equalsAscii("LeftMargin"))
+ {
+ aData.SetLeftSpace(MM100_TO_TWIP_UNSIGNED(nVal));
+ }
+ else if(sName.equalsAscii("RightMargin"))
+ {
+ aData.SetRightSpace(MM100_TO_TWIP_UNSIGNED(nVal));
+ }
+ else if(sName.equalsAscii("TopMargin"))
+ {
+ aData.SetTopSpace(MM100_TO_TWIP_UNSIGNED(nVal));
+ }
+ else if(sName.equalsAscii("BottomMargin"))
+ {
+ aData.SetBottomSpace(MM100_TO_TWIP_UNSIGNED(nVal));
+ }
+ else if(sName.equalsAscii("HoriMargin"))
+ {
+ aData.SetHorzSpace(MM100_TO_TWIP_UNSIGNED(nVal));
+ }
+ else if(sName.equalsAscii("VertMargin"))
+ {
+ aData.SetVertSpace(MM100_TO_TWIP_UNSIGNED(nVal));
+ }
+ else if(sName.equalsAscii("IsLandscape"))
+ {
+ bException = (::getBooleanCppuType() != rVal.getValueType());
+ aData.SetLandscape(*(sal_Bool*)rVal.getValue());
+ }
+ else
+ bException = sal_True;
+ if(bException)
+ throw RuntimeException();
+ }
+ pDocShell->GetDoc()->SetPreviewPrtData(&aData);
+ }
+ else
+ throw RuntimeException();
+}
+
+void SwXTextDocument::printPages(const Sequence< beans::PropertyValue >& xOptions)
+ throw( IllegalArgumentException, RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ if(IsValid())
+ {
+ SfxViewFrame* pFrame = SfxViewFrame::LoadHiddenDocument( *pDocShell, 7 );
+ SfxRequest aReq(FN_PRINT_PAGEPREVIEW, SFX_CALLMODE_SYNCHRON,
+ pDocShell->GetDoc()->GetAttrPool());
+ aReq.AppendItem(SfxBoolItem(FN_PRINT_PAGEPREVIEW, true));
+
+ for ( int n = 0; n < xOptions.getLength(); ++n )
+ {
+ // get Property-Value from options
+ const beans::PropertyValue &rProp = xOptions.getConstArray()[n];
+ Any aValue( rProp.Value );
+
+ // FileName-Property?
+ if ( rProp.Name == UNO_NAME_FILE_NAME )
+ {
+ OUString sFileURL;
+ if ( (rProp.Value >>= sFileURL ) )
+ {
+ // Convert the File URL into a system dependent path, as the SalPrinter expects
+ OUString sSystemPath;
+ FileBase::getSystemPathFromFileURL ( sFileURL, sSystemPath );
+ aReq.AppendItem(SfxStringItem( SID_FILE_NAME, sSystemPath ) );
+ }
+ else if ( rProp.Value.getValueType() != ::getVoidCppuType() )
+ throw IllegalArgumentException();
+ }
+
+ // CopyCount-Property
+ else if ( rProp.Name == UNO_NAME_COPY_COUNT )
+ {
+ sal_Int32 nCopies = 0;
+ aValue >>= nCopies;
+ aReq.AppendItem(SfxInt16Item( SID_PRINT_COPIES, (sal_Int16)nCopies ) );
+ }
+
+ // Collate-Property
+ else if ( rProp.Name == UNO_NAME_COLLATE )
+ {
+ if ( rProp.Value.getValueType() == ::getBooleanCppuType())
+
+ aReq.AppendItem(SfxBoolItem( SID_PRINT_COLLATE, *(sal_Bool*)rProp.Value.getValue() ) );
+ else
+ throw IllegalArgumentException();
+ }
+
+ // Sort-Property
+ else if ( rProp.Name == UNO_NAME_SORT )
+ {
+ if ( rProp.Value.getValueType() == ::getBooleanCppuType() )
+ aReq.AppendItem(SfxBoolItem( SID_PRINT_SORT, *(sal_Bool*)rProp.Value.getValue() ) );
+ else
+ throw IllegalArgumentException();
+ }
+
+ // Pages-Property
+ else if ( rProp.Name == UNO_NAME_PAGES )
+ {
+ OUString sTmp;
+ if ( rProp.Value >>= sTmp )
+ aReq.AppendItem( SfxStringItem( SID_PRINT_PAGES, sTmp ) );
+ else
+ throw IllegalArgumentException();
+ }
+ }
+
+ // #i117783#
+ bApplyPagePrintSettingsFromXPagePrintable = sal_True;
+ pFrame->GetViewShell()->ExecuteSlot(aReq);
+ // Frame close
+ pFrame->DoClose();
+
+ }
+ else
+ throw RuntimeException();
+}
+
+Reference< XNameAccess > SwXTextDocument::getReferenceMarks(void)
+ throw( RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ if(!pxXReferenceMarks)
+ {
+ ((SwXTextDocument*)this)->pxXReferenceMarks = new Reference< XNameAccess > ;
+ *pxXReferenceMarks = new SwXReferenceMarks(pDocShell->GetDoc());
+ }
+ return *pxXReferenceMarks;
+}
+
+Reference< XEnumerationAccess > SwXTextDocument::getTextFields(void) throw( RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ if(!pxXTextFieldTypes)
+ {
+ ((SwXTextDocument*)this)->pxXTextFieldTypes = new Reference< XEnumerationAccess > ;
+ *pxXTextFieldTypes = new SwXTextFieldTypes(pDocShell->GetDoc());
+ }
+ return *pxXTextFieldTypes;
+}
+
+Reference< XNameAccess > SwXTextDocument::getTextFieldMasters(void)
+ throw( RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ if(!pxXTextFieldMasters)
+ {
+ ((SwXTextDocument*)this)->pxXTextFieldMasters = new Reference< XNameAccess > ;
+ *pxXTextFieldMasters = new SwXTextFieldMasters(pDocShell->GetDoc());
+ }
+ return *pxXTextFieldMasters;
+}
+
+Reference< XNameAccess > SwXTextDocument::getEmbeddedObjects(void) throw( RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ if(!pxXEmbeddedObjects)
+ {
+ ((SwXTextDocument*)this)->pxXEmbeddedObjects = new Reference< XNameAccess > ;
+ *pxXEmbeddedObjects = new SwXTextEmbeddedObjects(pDocShell->GetDoc());
+ }
+ return *pxXEmbeddedObjects;
+}
+
+Reference< XNameAccess > SwXTextDocument::getBookmarks(void) throw( RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ if(!pxXBookmarks)
+ {
+ ((SwXTextDocument*)this)->pxXBookmarks = new Reference< XNameAccess > ;
+ *pxXBookmarks = new SwXBookmarks(pDocShell->GetDoc());
+ }
+ return *pxXBookmarks;
+}
+
+Reference< XNameAccess > SwXTextDocument::getTextSections(void) throw( RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ if(!pxXTextSections)
+ {
+ ((SwXTextDocument*)this)->pxXTextSections = new Reference< XNameAccess > ;
+ *pxXTextSections = new SwXTextSections(pDocShell->GetDoc());
+ }
+ return *pxXTextSections;
+}
+
+Reference< XNameAccess > SwXTextDocument::getTextTables(void) throw( RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ if(!pxXTextTables)
+ {
+ ((SwXTextDocument*)this)->pxXTextTables = new Reference< XNameAccess > ;
+ *pxXTextTables = new SwXTextTables(pDocShell->GetDoc());
+ }
+ return *pxXTextTables;
+}
+
+Reference< XNameAccess > SwXTextDocument::getGraphicObjects(void) throw( RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ if(!pxXGraphicObjects)
+ {
+ ((SwXTextDocument*)this)->pxXGraphicObjects = new Reference< XNameAccess > ;
+ *pxXGraphicObjects = new SwXTextGraphicObjects(pDocShell->GetDoc());
+ }
+ return *pxXGraphicObjects;
+}
+
+Reference< XNameAccess > SwXTextDocument::getTextFrames(void) throw( RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ if(!pxXTextFrames)
+ {
+ ((SwXTextDocument*)this)->pxXTextFrames = new Reference< XNameAccess > ;
+ *pxXTextFrames = new SwXTextFrames(pDocShell->GetDoc());
+ }
+ return *pxXTextFrames;
+}
+
+Reference< XNameAccess > SwXTextDocument::getStyleFamilies(void) throw( RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ if(!pxXStyleFamilies)
+ {
+ ((SwXTextDocument*)this)->pxXStyleFamilies = new Reference< XNameAccess > ;
+ *pxXStyleFamilies = new SwXStyleFamilies(*pDocShell);
+ }
+ return *pxXStyleFamilies;
+}
+
+uno::Reference< style::XAutoStyles > SwXTextDocument::getAutoStyles( )
+ throw (uno::RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ if(!pxXAutoStyles)
+ {
+ pxXAutoStyles = new Reference< style::XAutoStyles > ;
+ *pxXAutoStyles = new SwXAutoStyles(*pDocShell);
+ }
+ return *pxXAutoStyles;
+
+}
+
+Reference< drawing::XDrawPage > SwXTextDocument::getDrawPage(void) throw( RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ if(!pxXDrawPage)
+ {
+ ((SwXTextDocument*)this)->pDrawPage = new SwXDrawPage(pDocShell->GetDoc());
+ ((SwXTextDocument*)this)->pxXDrawPage = new Reference< drawing::XDrawPage >(pDrawPage);
+ // Create a Reference to trigger the complete initialization of the
+ // object. Otherwise in some corner cases it would get initialized
+ // at ::InitNewDoc -> which would get called during
+ // close() or dispose() -> n#681746
+ uno::Reference<lang::XComponent> xComp( *pxXDrawPage, uno::UNO_QUERY );
+ }
+ return *pxXDrawPage;
+}
+
+SwXDrawPage* SwXTextDocument::GetDrawPage()
+{
+ if(!IsValid())
+ return 0;
+ if(!pDrawPage)
+ getDrawPage();
+ return pDrawPage;
+}
+
+void SwXTextDocument::Invalidate()
+{
+ bObjectValid = sal_False;
+ if(xNumFmtAgg.is())
+ {
+ const uno::Type& rTunnelType = ::getCppuType((Reference <XUnoTunnel>*)0);
+ Any aNumTunnel = xNumFmtAgg->queryAggregation(rTunnelType);
+ SvNumberFormatsSupplierObj* pNumFmt = 0;
+ Reference< XUnoTunnel > xNumTunnel;
+ if(aNumTunnel >>= xNumTunnel)
+ {
+ pNumFmt = reinterpret_cast<SvNumberFormatsSupplierObj*>(
+ xNumTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId()));
+ pNumFmt->SetNumberFormatter(0);
+ }
+ OSL_ENSURE(pNumFmt, "No number formatter available");
+ }
+ InitNewDoc();
+ pDocShell = 0;
+ lang::EventObject const ev(static_cast<SwXTextDocumentBaseClass &>(*this));
+ m_pImpl->m_RefreshListeners.disposeAndClear(ev);
+}
+
+void SwXTextDocument::Reactivate(SwDocShell* pNewDocShell)
+{
+ if(pDocShell && pDocShell != pNewDocShell)
+ Invalidate();
+ pDocShell = pNewDocShell;
+ bObjectValid = sal_True;
+}
+
+void SwXTextDocument::InitNewDoc()
+{
+ // first invalidate all collections, then delete references and Set to zero
+ if(pxXTextTables)
+ {
+ XNameAccess* pTbls = pxXTextTables->get();
+ ((SwXTextTables*)pTbls)->Invalidate();
+ delete pxXTextTables;
+ pxXTextTables = 0;
+ }
+
+ if(pxXTextFrames)
+ {
+ XNameAccess* pFrms = pxXTextFrames->get();
+ ((SwXTextFrames*)pFrms)->Invalidate();
+ delete pxXTextFrames;
+ pxXTextFrames = 0;
+ }
+
+ if(pxXGraphicObjects)
+ {
+ XNameAccess* pFrms = pxXGraphicObjects->get();
+ ((SwXTextGraphicObjects*)pFrms)->Invalidate();
+ delete pxXGraphicObjects;
+ pxXGraphicObjects = 0;
+ }
+
+ if(pxXEmbeddedObjects)
+ {
+ XNameAccess* pOLE = pxXEmbeddedObjects->get();
+ ((SwXTextEmbeddedObjects*)pOLE)->Invalidate();
+ delete pxXEmbeddedObjects;
+ pxXEmbeddedObjects = 0;
+ }
+
+ if(xBodyText.is())
+ {
+ xBodyText = 0;
+ pBodyText = 0;
+ }
+
+ if(xNumFmtAgg.is())
+ {
+ const uno::Type& rTunnelType = ::getCppuType((Reference <XUnoTunnel>*)0);
+ Any aNumTunnel = xNumFmtAgg->queryAggregation(rTunnelType);
+ SvNumberFormatsSupplierObj* pNumFmt = 0;
+ Reference< XUnoTunnel > xNumTunnel;
+ if(aNumTunnel >>= xNumTunnel)
+ {
+ pNumFmt = reinterpret_cast<SvNumberFormatsSupplierObj*>(
+ xNumTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId()));
+
+ }
+ OSL_ENSURE(pNumFmt, "No number formatter available");
+ pNumFmt->SetNumberFormatter(0);
+ }
+
+ if(pxXTextFieldTypes)
+ {
+ XEnumerationAccess* pT = pxXTextFieldTypes->get();
+ ((SwXTextFieldTypes*)pT)->Invalidate();
+ delete pxXTextFieldTypes;
+ pxXTextFieldTypes = 0;
+ }
+
+ if(pxXTextFieldMasters)
+ {
+ XNameAccess* pT = pxXTextFieldMasters->get();
+ ((SwXTextFieldMasters*)pT)->Invalidate();
+ delete pxXTextFieldMasters;
+ pxXTextFieldMasters = 0;
+ }
+
+ if(pxXTextSections)
+ {
+ XNameAccess* pSect = pxXTextSections->get();
+ ((SwXTextSections*)pSect)->Invalidate();
+ delete pxXTextSections;
+ pxXTextSections = 0;
+ }
+
+ if(pxXDrawPage)
+ {
+ // #i91798#, #i91895#
+ // dispose XDrawPage here. We are the owner and know that it is no longer in a valid condition.
+ uno::Reference<lang::XComponent> xComp( *pxXDrawPage, uno::UNO_QUERY );
+ xComp->dispose();
+ pDrawPage->InvalidateSwDoc();
+ delete pxXDrawPage;
+ pxXDrawPage = 0;
+ }
+
+ if ( pxXNumberingRules )
+ {
+ XIndexAccess* pNum = pxXNumberingRules->get();
+ ((SwXNumberingRulesCollection*)pNum)->Invalidate();
+ delete pxXNumberingRules;
+ pxXNumberingRules = 0;
+ }
+
+ if(pxXFootnotes)
+ {
+ XIndexAccess* pFtn = pxXFootnotes->get();
+ ((SwXFootnotes*)pFtn)->Invalidate();
+ delete pxXFootnotes;
+ pxXFootnotes = 0;
+ }
+
+ if(pxXEndnotes)
+ {
+ XIndexAccess* pFtn = pxXEndnotes->get();
+ ((SwXFootnotes*)pFtn)->Invalidate();
+ delete pxXEndnotes;
+ pxXEndnotes = 0;
+ }
+
+ if(pxXDocumentIndexes)
+ {
+ XIndexAccess* pIdxs = pxXDocumentIndexes->get();
+ ((SwXDocumentIndexes*)pIdxs)->Invalidate();
+ delete pxXDocumentIndexes;
+ pxXDocumentIndexes = 0;
+ }
+
+ if(pxXStyleFamilies)
+ {
+ XNameAccess* pStyles = pxXStyleFamilies->get();
+ ((SwXStyleFamilies*)pStyles)->Invalidate();
+ delete pxXStyleFamilies;
+ pxXStyleFamilies = 0;
+ }
+ if(pxXAutoStyles)
+ {
+ XNameAccess* pStyles = pxXAutoStyles->get();
+ ((SwXAutoStyles*)pStyles)->Invalidate();
+ delete pxXAutoStyles;
+ pxXAutoStyles = 0;
+ }
+
+ if(pxXBookmarks)
+ {
+ XNameAccess* pBm = pxXBookmarks->get();
+ ((SwXBookmarks*)pBm)->Invalidate();
+ delete pxXBookmarks;
+ pxXBookmarks = 0;
+ }
+
+ if(pxXChapterNumbering)
+ {
+ XIndexReplace* pCh = pxXChapterNumbering->get();
+ ((SwXChapterNumbering*)pCh)->Invalidate();
+ delete pxXChapterNumbering;
+ pxXChapterNumbering = 0;
+ }
+
+ if(pxXFootnoteSettings)
+ {
+ XPropertySet* pFntSet = pxXFootnoteSettings->get();
+ ((SwXFootnoteProperties*)pFntSet)->Invalidate();
+ delete pxXFootnoteSettings;
+ pxXFootnoteSettings = 0;
+ }
+
+ if(pxXEndnoteSettings)
+ {
+ XPropertySet* pEndSet = pxXEndnoteSettings->get();
+ ((SwXEndnoteProperties*)pEndSet)->Invalidate();
+ delete pxXEndnoteSettings;
+ pxXEndnoteSettings = 0;
+ }
+
+ if(pxXLineNumberingProperties)
+ {
+ XPropertySet* pLine = pxXLineNumberingProperties->get();
+ ((SwXLineNumberingProperties*)pLine)->Invalidate();
+ delete pxXLineNumberingProperties;
+ pxXLineNumberingProperties = 0;
+ }
+ if(pxXReferenceMarks)
+ {
+ XNameAccess* pMarks = pxXReferenceMarks->get();
+ ((SwXReferenceMarks*)pMarks)->Invalidate();
+ delete pxXReferenceMarks;
+ pxXReferenceMarks = 0;
+ }
+ if(pxLinkTargetSupplier)
+ {
+ XNameAccess* pAccess = (*pxLinkTargetSupplier).get();
+ ((SwXLinkTargetSupplier*)pAccess)->Invalidate();
+ delete pxLinkTargetSupplier;
+ pxLinkTargetSupplier = 0;
+ }
+ if(pxXRedlines)
+ {
+ XEnumerationAccess* pMarks = pxXRedlines->get();
+ ((SwXRedlines*)pMarks)->Invalidate();
+ delete pxXRedlines;
+ pxXRedlines = 0;
+ }
+ if(xPropertyHelper.is())
+ {
+ pPropertyHelper->Invalidate();
+ xPropertyHelper = 0;
+ pPropertyHelper = 0;
+ }
+}
+
+css::uno::Reference<css::uno::XInterface> SwXTextDocument::create(
+ OUString const & rServiceName,
+ css::uno::Sequence<css::uno::Any> const * arguments)
+{
+ SolarMutexGuard aGuard;
+ if (!IsValid())
+ {
+ throw RuntimeException();
+ }
+ sal_uInt16 nType = SwXServiceProvider::GetProviderType(rServiceName);
+ if (nType != SW_SERVICE_INVALID)
+ {
+ return SwXServiceProvider::MakeInstance(nType, pDocShell->GetDoc());
+ }
+ if (rServiceName == "com.sun.star.drawing.DashTable")
+ {
+ return GetPropertyHelper()->GetDrawTable(SW_CREATE_DASH_TABLE);
+ }
+ if (rServiceName == "com.sun.star.drawing.GradientTable")
+ {
+ return GetPropertyHelper()->GetDrawTable(SW_CREATE_GRADIENT_TABLE);
+ }
+ if (rServiceName == "com.sun.star.drawing.HatchTable")
+ {
+ return GetPropertyHelper()->GetDrawTable(SW_CREATE_HATCH_TABLE);
+ }
+ if (rServiceName == "com.sun.star.drawing.BitmapTable")
+ {
+ return GetPropertyHelper()->GetDrawTable(SW_CREATE_BITMAP_TABLE);
+ }
+ if (rServiceName == "com.sun.star.drawing.TransparencyGradientTable")
+ {
+ return GetPropertyHelper()->GetDrawTable(SW_CREATE_TRANSGRADIENT_TABLE);
+ }
+ if (rServiceName == "com.sun.star.drawing.MarkerTable")
+ {
+ return GetPropertyHelper()->GetDrawTable(SW_CREATE_MARKER_TABLE);
+ }
+ if (rServiceName == "com.sun.star.drawing.Defaults")
+ {
+ return GetPropertyHelper()->GetDrawTable(SW_CREATE_DRAW_DEFAULTS);
+ }
+ if (rServiceName == "com.sun.star.document.Settings")
+ {
+ return Reference<XInterface>(*new SwXDocumentSettings(this));
+ }
+ if (rServiceName == "com.sun.star.document.ImportEmbeddedObjectResolver")
+ {
+ return static_cast<cppu::OWeakObject *>(
+ new SvXMLEmbeddedObjectHelper(
+ *pDocShell, EMBEDDEDOBJECTHELPER_MODE_READ));
+ }
+ if (rServiceName == "com.sun.star.text.DocumentSettings")
+ {
+ return Reference<XInterface>(*new SwXDocumentSettings(this));
+ }
+ if (rServiceName == "com.sun.star.chart2.data.DataProvider")
+ {
+ return Reference<XInterface>(
+ dynamic_cast<chart2::data::XDataProvider *>(
+ pDocShell->getIDocumentChartDataProviderAccess()->
+ GetChartDataProvider()));
+ }
+ if (!rServiceName.startsWith("com.sun.star.")
+ || rServiceName.endsWith(".OLE2Shape"))
+ {
+ // We do not want to insert OLE2 Shapes (e.g.,
+ // "com.sun.star.drawing.OLE2Shape", ...) like this (by creating them
+ // with the documents factory and adding the shapes to the draw page);
+ // for inserting OLE objects the proper way is to use
+ // "com.sun.star.text.TextEmbeddedObject":
+ throw ServiceNotRegisteredException();
+ }
+ // The XML import is allowed to create instances of
+ // "com.sun.star.drawing.OLE2Shape"; thus, a temporary service name is
+ // introduced to make this possible:
+ OUString aTmpServiceName(rServiceName);
+ if (rServiceName == "com.sun.star.drawing.temporaryForXMLImportOLE2Shape")
+ {
+ aTmpServiceName = "com.sun.star.drawing.OLE2Shape";
+ }
+ Reference<XInterface> xTmp(
+ arguments == 0
+ ? SvxFmMSFactory::createInstance(aTmpServiceName)
+ : SvxFmMSFactory::createInstanceWithArguments(
+ aTmpServiceName, *arguments));
+ if (rServiceName == "com.sun.star.drawing.GroupShape"
+ || rServiceName == "com.sun.star.drawing.Shape3DSceneObject")
+ {
+ return *new SwXGroupShape(xTmp);
+ }
+ if (rServiceName.startsWith("com.sun.star.drawing."))
+ {
+ return *new SwXShape(xTmp);
+ }
+ return xTmp;
+}
+
+Reference< XInterface > SwXTextDocument::createInstance(const OUString& rServiceName)
+ throw( Exception, RuntimeException, std::exception )
+{
+ return create(rServiceName, 0);
+}
+
+Reference< XInterface > SwXTextDocument::createInstanceWithArguments(
+ const OUString& ServiceSpecifier,
+ const Sequence< Any >& Arguments)
+ throw( Exception, RuntimeException, std::exception )
+{
+ return create(ServiceSpecifier, &Arguments);
+}
+
+Sequence< OUString > SwXTextDocument::getAvailableServiceNames(void)
+ throw( RuntimeException, std::exception )
+{
+ static Sequence< OUString > aServices;
+ if ( aServices.getLength() == 0 )
+ {
+ Sequence< OUString > aRet = SvxFmMSFactory::getAvailableServiceNames();
+ OUString* pRet = aRet.getArray();
+ for ( sal_Int32 i = 0; i < aRet.getLength(); ++i )
+ {
+ if ( pRet[i].equalsAscii( "com.sun.star.drawing.OLE2Shape" ) )
+ {
+ pRet[i] = pRet[aRet.getLength() - 1];
+ aRet.realloc( aRet.getLength() - 1 ); // <pRet> no longer valid.
+ break;
+ }
+ }
+ Sequence< OUString > aOwn = SwXServiceProvider::GetAllServiceNames();
+ aServices = SvxFmMSFactory::concatServiceNames(aRet, aOwn);
+ }
+
+ return aServices;
+}
+
+OUString SwXTextDocument::getImplementationName(void) throw( RuntimeException, std::exception )
+{
+ return OUString("SwXTextDocument");
+}
+
+sal_Bool SwXTextDocument::supportsService(const OUString& rServiceName) throw( RuntimeException, std::exception )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+Sequence< OUString > SwXTextDocument::getSupportedServiceNames(void) throw( RuntimeException, std::exception )
+{
+ bool bWebDoc = (0 != PTR_CAST(SwWebDocShell, pDocShell));
+ bool bGlobalDoc = (0 != PTR_CAST(SwGlobalDocShell, pDocShell));
+ bool bTextDoc = (!bWebDoc && !bGlobalDoc);
+
+ Sequence< OUString > aRet (3);
+ OUString* pArray = aRet.getArray();
+
+ pArray[0] = OUString ( ( "com.sun.star.document.OfficeDocument" ) );
+ pArray[1] = OUString ( ( "com.sun.star.text.GenericTextDocument" ) );
+
+ if (bTextDoc)
+ pArray[2] = OUString ( ( "com.sun.star.text.TextDocument" ) );
+ else if (bWebDoc)
+ pArray[2] = OUString ( ( "com.sun.star.text.WebDocument" ) );
+ else if (bGlobalDoc)
+ pArray[2] = OUString ( ( "com.sun.star.text.GlobalDocument" ) );
+
+ return aRet;
+}
+
+Reference< XIndexAccess > SwXTextDocument::getDocumentIndexes(void) throw( RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ if(!pxXDocumentIndexes)
+ {
+ ((SwXTextDocument*)this)->pxXDocumentIndexes = new Reference< XIndexAccess > ;
+ *pxXDocumentIndexes = new SwXDocumentIndexes(pDocShell->GetDoc());
+ }
+ return *pxXDocumentIndexes;
+}
+
+Reference< XPropertySetInfo > SwXTextDocument::getPropertySetInfo(void) throw( RuntimeException, std::exception )
+{
+ static Reference< XPropertySetInfo > xRet = pPropSet->getPropertySetInfo();
+ return xRet;
+}
+
+void SwXTextDocument::setPropertyValue(const OUString& rPropertyName, const Any& aValue)
+ throw (UnknownPropertyException, PropertyVetoException,
+ IllegalArgumentException, WrappedTargetException,
+ RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException(
+ "invalid SwXTextDocument",
+ static_cast< cppu::OWeakObject * >(
+ static_cast< SwXTextDocumentBaseClass * >(this)));
+ const SfxItemPropertySimpleEntry* pEntry = pPropSet->getPropertyMap().getByName( rPropertyName);
+
+ if(!pEntry)
+ throw UnknownPropertyException();
+ if(pEntry->nFlags & PropertyAttribute::READONLY)
+ throw PropertyVetoException();
+ switch(pEntry->nWID)
+ {
+ case WID_DOC_CHAR_COUNT :
+ case WID_DOC_PARA_COUNT :
+ case WID_DOC_WORD_COUNT :
+ throw RuntimeException(
+ "bad WID",
+ static_cast< cppu::OWeakObject * >(
+ static_cast< SwXTextDocumentBaseClass * >(this)));
+ case WID_DOC_WORD_SEPARATOR :
+ {
+ OUString sDelim;
+ aValue >>= sDelim;
+ SW_MOD()->GetModuleConfig()->SetWordDelimiter(sDelim);
+ }
+ break;
+ case WID_DOC_CHANGES_RECORD:
+ case WID_DOC_CHANGES_SHOW:
+ {
+ sal_Bool bSet = *(sal_Bool*)aValue.getValue();
+ sal_uInt16 eMode = pDocShell->GetDoc()->GetRedlineMode();
+ if(WID_DOC_CHANGES_SHOW == pEntry->nWID)
+ {
+ eMode &= ~(nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE);
+ eMode |= nsRedlineMode_t::REDLINE_SHOW_INSERT;
+ if( bSet )
+ eMode |= nsRedlineMode_t::REDLINE_SHOW_DELETE;
+ }
+ else if(WID_DOC_CHANGES_RECORD == pEntry->nWID)
+ {
+ eMode = bSet ? eMode|nsRedlineMode_t::REDLINE_ON : eMode&~nsRedlineMode_t::REDLINE_ON;
+ }
+ pDocShell->GetDoc()->SetRedlineMode( (RedlineMode_t)(eMode ));
+ }
+ break;
+ case WID_DOC_CHANGES_PASSWORD:
+ {
+ Sequence <sal_Int8> aNew;
+ if(aValue >>= aNew)
+ {
+ SwDoc* pDoc = pDocShell->GetDoc();
+ pDoc->SetRedlinePassword(aNew);
+ if(aNew.getLength())
+ {
+ sal_uInt16 eMode = pDoc->GetRedlineMode();
+ eMode = eMode|nsRedlineMode_t::REDLINE_ON;
+ pDoc->SetRedlineMode( (RedlineMode_t)(eMode ));
+ }
+ }
+ }
+ break;
+ case WID_DOC_AUTO_MARK_URL :
+ {
+ OUString sURL;
+ aValue >>= sURL;
+ pDocShell->GetDoc()->SetTOIAutoMarkURL(sURL);
+ }
+ break;
+ case WID_DOC_HIDE_TIPS :
+ SW_MOD()->GetModuleConfig()->SetHideFieldTips(*(sal_Bool*)aValue.getValue());
+ break;
+ case WID_DOC_REDLINE_DISPLAY:
+ {
+ sal_Int16 eRedMode = pDocShell->GetDoc()->GetRedlineMode();
+ eRedMode = eRedMode & (~nsRedlineMode_t::REDLINE_SHOW_MASK);
+ sal_Int16 nSet = 0;
+ aValue >>= nSet;
+ switch(nSet)
+ {
+ case RedlineDisplayType::NONE: break;
+ case RedlineDisplayType::INSERTED: eRedMode |= nsRedlineMode_t::REDLINE_SHOW_INSERT; break;
+ case RedlineDisplayType::REMOVED: eRedMode |= nsRedlineMode_t::REDLINE_SHOW_DELETE; break;
+ case RedlineDisplayType::
+ INSERTED_AND_REMOVED: eRedMode |= nsRedlineMode_t::REDLINE_SHOW_INSERT|nsRedlineMode_t::REDLINE_SHOW_DELETE;
+ break;
+ default: throw IllegalArgumentException();
+ }
+ pDocShell->GetDoc()->SetRedlineMode(eRedMode);
+ }
+ break;
+ case WID_DOC_TWO_DIGIT_YEAR:
+ {
+ sal_Int16 nYear = 0;
+ aValue >>= nYear;
+ SfxRequest aRequest ( SID_ATTR_YEAR2000, SFX_CALLMODE_SLOT, pDocShell->GetDoc()->GetAttrPool());
+ aRequest.AppendItem(SfxUInt16Item( SID_ATTR_YEAR2000, static_cast < sal_uInt16 > ( nYear ) ) );
+ pDocShell->Execute ( aRequest );
+ }
+ break;
+ case WID_DOC_AUTOMATIC_CONTROL_FOCUS:
+ {
+ SwDrawDocument * pDrawDoc;
+ sal_Bool bAuto = *(sal_Bool*) aValue.getValue();
+
+ if ( 0 != ( pDrawDoc = dynamic_cast< SwDrawDocument * >( pDocShell->GetDoc()->GetDrawModel() ) ) )
+ pDrawDoc->SetAutoControlFocus( bAuto );
+ else if (bAuto)
+ {
+ // if setting to true, and we don't have an
+ // SdrModel, then we are changing the default and
+ // must thus create an SdrModel, if we don't have an
+ // SdrModel and we are leaving the default at false,
+ // we don't need to make an SdrModel and can do nothing
+ // #i52858# - method name changed
+ pDrawDoc = dynamic_cast< SwDrawDocument * > (pDocShell->GetDoc()->GetOrCreateDrawModel() );
+ pDrawDoc->SetAutoControlFocus ( bAuto );
+ }
+ }
+ break;
+ case WID_DOC_APPLY_FORM_DESIGN_MODE:
+ {
+ SwDrawDocument * pDrawDoc;
+ sal_Bool bMode = *(sal_Bool*)aValue.getValue();
+
+ if ( 0 != ( pDrawDoc = dynamic_cast< SwDrawDocument * > (pDocShell->GetDoc()->GetDrawModel() ) ) )
+ pDrawDoc->SetOpenInDesignMode( bMode );
+ else if (!bMode)
+ {
+ // if setting to false, and we don't have an
+ // SdrModel, then we are changing the default and
+ // must thus create an SdrModel, if we don't have an
+ // SdrModel and we are leaving the default at true,
+ // we don't need to make an SdrModel and can do
+ // nothing
+ // #i52858# - method name changed
+ pDrawDoc = dynamic_cast< SwDrawDocument * > (pDocShell->GetDoc()->GetOrCreateDrawModel() );
+ pDrawDoc->SetOpenInDesignMode ( bMode );
+ }
+ }
+ break;
+ // #i42634# New property to set the bInReading
+ // flag at the document, used during binary import
+ case WID_DOC_LOCK_UPDATES :
+ {
+ SwDoc* pDoc = pDocShell->GetDoc();
+ bool bBool (false);
+ if( aValue >>= bBool )
+ pDoc->SetInReading( bBool );
+ }
+ break;
+ case WID_DOC_BUILDID:
+ aValue >>= maBuildId;
+ break;
+
+ case WID_DOC_DEFAULT_PAGE_MODE:
+ {
+ bool bDefaultPageMode( false );
+ aValue >>= bDefaultPageMode;
+ pDocShell->GetDoc()->SetDefaultPageMode( bDefaultPageMode );
+ }
+ break;
+ case WID_DOC_INTEROP_GRAB_BAG:
+ setGrabBagItem(aValue);
+ break;
+
+ default:
+ {
+ const SfxPoolItem& rItem = pDocShell->GetDoc()->GetDefault(pEntry->nWID);
+ SfxPoolItem* pNewItem = rItem.Clone();
+ pNewItem->PutValue(aValue, pEntry->nMemberId);
+ pDocShell->GetDoc()->SetDefault(*pNewItem);
+ delete pNewItem;
+ }
+ }
+}
+
+Any SwXTextDocument::getPropertyValue(const OUString& rPropertyName)
+ throw( UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ const SfxItemPropertySimpleEntry* pEntry = pPropSet->getPropertyMap().getByName( rPropertyName);
+
+ if(!pEntry)
+ throw UnknownPropertyException();
+ Any aAny;
+ switch(pEntry->nWID)
+ {
+ case WID_DOC_ISTEMPLATEID :
+ aAny <<= pDocShell->IsTemplate();
+ break;
+ case WID_DOC_CHAR_COUNT :
+ case WID_DOC_PARA_COUNT :
+ case WID_DOC_WORD_COUNT :
+ {
+ const SwDocStat& rStat(pDocShell->GetDoc()->GetUpdatedDocStat());
+ sal_Int32 nValue;
+ switch(pEntry->nWID)
+ {
+ case WID_DOC_CHAR_COUNT :nValue = rStat.nChar;break;
+ case WID_DOC_PARA_COUNT :nValue = rStat.nPara;break;
+ case WID_DOC_WORD_COUNT :nValue = rStat.nWord;break;
+ }
+ aAny <<= nValue;
+ }
+ break;
+ case WID_DOC_WORD_SEPARATOR :
+ {
+ aAny <<= SW_MOD()->GetDocStatWordDelim();
+ }
+ break;
+ case WID_DOC_CHANGES_RECORD:
+ case WID_DOC_CHANGES_SHOW:
+ {
+ sal_uInt16 eMode = pDocShell->GetDoc()->GetRedlineMode();
+ sal_Bool bSet = sal_False;
+ if(WID_DOC_CHANGES_SHOW == pEntry->nWID)
+ {
+ sal_uInt16 nMask = nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE;
+ bSet = (eMode & nMask) == nMask;
+ }
+ else if(WID_DOC_CHANGES_RECORD == pEntry->nWID)
+ {
+ bSet = (eMode& nsRedlineMode_t::REDLINE_ON) != 0;
+ }
+ aAny.setValue(&bSet, ::getBooleanCppuType());
+ }
+ break;
+ case WID_DOC_CHANGES_PASSWORD:
+ {
+ SwDoc* pDoc = pDocShell->GetDoc();
+ aAny <<= pDoc->GetRedlinePassword();
+ }
+ break;
+ case WID_DOC_AUTO_MARK_URL :
+ aAny <<= pDocShell->GetDoc()->GetTOIAutoMarkURL();
+ break;
+ case WID_DOC_HIDE_TIPS :
+ {
+ sal_Bool bTemp = SW_MOD()->GetModuleConfig()->IsHideFieldTips();
+ aAny.setValue(&bTemp, ::getBooleanCppuType());
+ }
+ break;
+ case WID_DOC_REDLINE_DISPLAY:
+ {
+ sal_Int16 eRedMode = pDocShell->GetDoc()->GetRedlineMode();
+ eRedMode = eRedMode & nsRedlineMode_t::REDLINE_SHOW_MASK;
+ sal_Int16 nRet = RedlineDisplayType::NONE;
+ if(nsRedlineMode_t::REDLINE_SHOW_INSERT == eRedMode)
+ nRet = RedlineDisplayType::INSERTED;
+ else if(nsRedlineMode_t::REDLINE_SHOW_DELETE == eRedMode)
+ nRet = RedlineDisplayType::REMOVED;
+ else if(nsRedlineMode_t::REDLINE_SHOW_MASK == eRedMode)
+ nRet = RedlineDisplayType::INSERTED_AND_REMOVED;
+ aAny <<= nRet;
+ }
+ break;
+ case WID_DOC_FORBIDDEN_CHARS:
+ {
+ GetPropertyHelper();
+ Reference<XForbiddenCharacters> xRet(xPropertyHelper, UNO_QUERY);
+ aAny <<= xRet;
+ }
+ break;
+ case WID_DOC_TWO_DIGIT_YEAR:
+ {
+ aAny <<= static_cast < sal_Int16 > (pDocShell->GetDoc()->GetNumberFormatter ( sal_True )->GetYear2000());
+ }
+ break;
+ case WID_DOC_AUTOMATIC_CONTROL_FOCUS:
+ {
+ SwDrawDocument * pDrawDoc;
+ sal_Bool bAuto;
+ if ( 0 != ( pDrawDoc = dynamic_cast< SwDrawDocument * > (pDocShell->GetDoc()->GetDrawModel() ) ) )
+ bAuto = pDrawDoc->GetAutoControlFocus();
+ else
+ bAuto = sal_False;
+ aAny.setValue(&bAuto, ::getBooleanCppuType());
+ }
+ break;
+ case WID_DOC_APPLY_FORM_DESIGN_MODE:
+ {
+ SwDrawDocument * pDrawDoc;
+ sal_Bool bMode;
+ if ( 0 != ( pDrawDoc = dynamic_cast< SwDrawDocument * > (pDocShell->GetDoc()->GetDrawModel() ) ) )
+ bMode = pDrawDoc->GetOpenInDesignMode();
+ else
+ bMode = sal_True;
+ aAny.setValue(&bMode, ::getBooleanCppuType());
+ }
+ break;
+ case WID_DOC_BASIC_LIBRARIES:
+ aAny <<= pDocShell->GetBasicContainer();
+ break;
+ case WID_DOC_DIALOG_LIBRARIES:
+ aAny <<= pDocShell->GetDialogContainer();
+ break;
+ case WID_DOC_VBA_DOCOBJ:
+ {
+ beans::PropertyValue aProp;
+ aProp.Name = "ThisWordDoc";
+ aProp.Value <<= pDocShell->GetModel();
+ aAny <<= aProp;
+ }
+ break;
+ case WID_DOC_RUNTIME_UID:
+ aAny <<= getRuntimeUID();
+ break;
+ case WID_DOC_LOCK_UPDATES :
+ aAny <<= static_cast<bool>( pDocShell->GetDoc()->IsInReading() );
+ break;
+ case WID_DOC_BUILDID:
+ aAny <<= maBuildId;
+ break;
+ case WID_DOC_HAS_VALID_SIGNATURES:
+ aAny <<= hasValidSignatures();
+ break;
+ case WID_DOC_INTEROP_GRAB_BAG:
+ getGrabBagItem(aAny);
+ break;
+
+ default:
+ {
+ const SfxPoolItem& rItem = pDocShell->GetDoc()->GetDefault(pEntry->nWID);
+ rItem.QueryValue(aAny, pEntry->nMemberId);
+ }
+ }
+ return aAny;
+}
+
+void SwXTextDocument::addPropertyChangeListener(const OUString& /*PropertyName*/,
+ const Reference< XPropertyChangeListener > & /*aListener*/)
+ throw( UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception )
+{
+ OSL_FAIL("not implemented");
+}
+
+void SwXTextDocument::removePropertyChangeListener(const OUString& /*PropertyName*/,
+ const Reference< XPropertyChangeListener > & /*aListener*/)
+ throw( UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception )
+{
+ OSL_FAIL("not implemented");
+}
+
+void SwXTextDocument::addVetoableChangeListener(const OUString& /*PropertyName*/,
+ const Reference< XVetoableChangeListener > & /*aListener*/)
+ throw( UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception )
+{
+ OSL_FAIL("not implemented");
+}
+
+void SwXTextDocument::removeVetoableChangeListener(const OUString& /*PropertyName*/,
+ const Reference< XVetoableChangeListener > & /*aListener*/)
+ throw( UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception )
+{
+ OSL_FAIL("not implemented");
+}
+
+Reference< XNameAccess > SwXTextDocument::getLinks(void) throw( RuntimeException, std::exception )
+{
+ if(!pxLinkTargetSupplier)
+ {
+ pxLinkTargetSupplier = new Reference< XNameAccess > ;
+ (*pxLinkTargetSupplier) = new SwXLinkTargetSupplier(*(SwXTextDocument*)this);
+ }
+ return (*pxLinkTargetSupplier);
+}
+
+Reference< XEnumerationAccess > SwXTextDocument::getRedlines( ) throw(RuntimeException, std::exception)
+{
+ if(!pxXRedlines)
+ {
+ pxXRedlines = new Reference< XEnumerationAccess > ;
+ (*pxXRedlines) = new SwXRedlines(pDocShell->GetDoc());
+ }
+ return *pxXRedlines;
+}
+
+void SwXTextDocument::NotifyRefreshListeners()
+{
+ // why does SwBaseShell not just call refresh? maybe because it's rSh is
+ // (sometimes) a different shell than GetWrtShell()?
+ lang::EventObject const ev(static_cast<SwXTextDocumentBaseClass &>(*this));
+ m_pImpl->m_RefreshListeners.notifyEach(
+ & util::XRefreshListener::refreshed, ev);
+}
+
+void SwXTextDocument::refresh(void) throw( RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ SwViewShell *pViewShell = pDocShell->GetWrtShell();
+ NotifyRefreshListeners();
+ if(pViewShell)
+ pViewShell->CalcLayout();
+}
+
+void SAL_CALL SwXTextDocument::addRefreshListener(
+ const Reference<util::XRefreshListener> & xListener)
+throw (RuntimeException, std::exception)
+{
+ // no need to lock here as m_pImpl is const and container threadsafe
+ m_pImpl->m_RefreshListeners.addInterface(xListener);
+}
+
+void SAL_CALL SwXTextDocument::removeRefreshListener(
+ const Reference<util::XRefreshListener> & xListener)
+throw (RuntimeException, std::exception)
+{
+ // no need to lock here as m_pImpl is const and container threadsafe
+ m_pImpl->m_RefreshListeners.removeInterface(xListener);
+}
+
+void SwXTextDocument::updateLinks( ) throw(RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ SwDoc* pDoc = pDocShell->GetDoc();
+ sfx2::LinkManager& rLnkMan = pDoc->GetLinkManager();
+ if( !rLnkMan.GetLinks().empty() )
+ {
+ UnoActionContext aAction(pDoc);
+ rLnkMan.UpdateAllLinks( false, false, true );
+ }
+}
+
+//XPropertyState
+PropertyState SAL_CALL SwXTextDocument::getPropertyState( const OUString& rPropertyName )
+ throw (UnknownPropertyException, RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ PropertyState eRet = PropertyState_DIRECT_VALUE;
+ if(!IsValid())
+ throw RuntimeException();
+ const SfxItemPropertySimpleEntry* pEntry = pPropSet->getPropertyMap().getByName( rPropertyName);
+
+ if(!pEntry)
+ throw UnknownPropertyException();
+ switch(pEntry->nWID)
+ {
+ case 0:default:break;
+ }
+ return eRet;
+}
+
+Sequence< PropertyState > SAL_CALL SwXTextDocument::getPropertyStates( const Sequence< OUString >& rPropertyNames )
+ throw (UnknownPropertyException, RuntimeException, std::exception)
+{
+ const sal_Int32 nCount = rPropertyNames.getLength();
+ const OUString * pNames = rPropertyNames.getConstArray();
+ Sequence < PropertyState > aRet ( nCount );
+ PropertyState *pState = aRet.getArray();
+
+ for ( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++)
+ pState[nIndex] = getPropertyState( pNames[nIndex] );
+
+ return aRet;
+}
+
+void SAL_CALL SwXTextDocument::setPropertyToDefault( const OUString& rPropertyName )
+ throw (UnknownPropertyException, RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ const SfxItemPropertySimpleEntry* pEntry = pPropSet->getPropertyMap().getByName( rPropertyName);
+ if(!pEntry)
+ throw UnknownPropertyException();
+ switch(pEntry->nWID)
+ {
+ case 0:default:break;
+ }
+}
+
+Any SAL_CALL SwXTextDocument::getPropertyDefault( const OUString& rPropertyName )
+ throw (UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ const SfxItemPropertySimpleEntry* pEntry = pPropSet->getPropertyMap().getByName( rPropertyName);
+ if(!pEntry)
+ throw UnknownPropertyException();
+ Any aAny;
+ switch(pEntry->nWID)
+ {
+ case 0:default:break;
+ }
+ return aAny;
+}
+
+static OutputDevice * lcl_GetOutputDevice( const SwPrintUIOptions &rPrintUIOptions )
+{
+ OutputDevice *pOut = 0;
+
+ uno::Any aAny( rPrintUIOptions.getValue( "RenderDevice" ));
+ uno::Reference< awt::XDevice > xRenderDevice;
+ aAny >>= xRenderDevice;
+ if (xRenderDevice.is())
+ {
+ VCLXDevice* pDevice = VCLXDevice::GetImplementation( xRenderDevice );
+ pOut = pDevice ? pDevice->GetOutputDevice() : 0;
+ }
+
+ return pOut;
+}
+
+static bool lcl_SeqHasProperty(
+ const uno::Sequence< beans::PropertyValue >& rOptions,
+ const sal_Char *pPropName )
+{
+ bool bRes = false;
+ const sal_Int32 nLen = rOptions.getLength();
+ const beans::PropertyValue *pProps = rOptions.getConstArray();
+ for (sal_Int32 i = 0; i < nLen && !bRes; ++i)
+ {
+ if (pProps[i].Name.equalsAscii( pPropName ))
+ bRes = true;
+ }
+ return bRes;
+}
+
+SfxViewShell * SwXTextDocument::GetRenderView(
+ bool &rbIsSwSrcView,
+ const uno::Sequence< beans::PropertyValue >& rOptions,
+ bool bIsPDFExport )
+{
+ // get view shell to use
+ SfxViewShell *pView = 0;
+ if (bIsPDFExport)
+ pView = GuessViewShell( rbIsSwSrcView );
+ else
+ {
+ uno::Any aTmp;
+ const sal_Int32 nLen = rOptions.getLength();
+ const beans::PropertyValue *pProps = rOptions.getConstArray();
+ for (sal_Int32 i = 0; i < nLen; ++i)
+ {
+ if ( pProps[i].Name == "View" )
+ {
+ aTmp = pProps[i].Value;
+ break;
+ }
+ }
+
+ uno::Reference< frame::XController > xController;
+ if (aTmp >>= xController)
+ {
+ OSL_ENSURE( xController.is(), "controller is empty!" );
+ pView = GuessViewShell( rbIsSwSrcView, xController );
+ }
+ }
+ return pView;
+}
+
+/*
+ * GetRenderDoc:
+ * returns the document to be rendered, usually this will be the 'regular'
+ * document but in case of PDF export of (multi-)selection it will
+ * be a temporary document that gets created if not already done.
+ * The rpView variable will be set (if not already done) to the used
+ * SfxViewShell.
+*/
+SwDoc * SwXTextDocument::GetRenderDoc(
+ SfxViewShell *&rpView,
+ const uno::Any& rSelection,
+ bool bIsPDFExport )
+{
+ SwDoc *pDoc = 0;
+
+ uno::Reference< frame::XModel > xModel;
+ rSelection >>= xModel;
+ if (xModel == pDocShell->GetModel())
+ pDoc = pDocShell->GetDoc();
+ else
+ {
+ OSL_ENSURE( !xModel.is(), "unexpected model found" );
+
+ if (rSelection.hasValue()) // is anything selected ?
+ {
+ // this part should only be called when a temporary document needs to be created,
+ // for example for PDF export or printing of (multi-)selection only.
+
+ bool bIsSwSrcView = false;
+ if (!rpView)
+ {
+ (void) bIsPDFExport;
+ // aside from maybe PDF export the view should always have been provided!
+ OSL_ENSURE( bIsPDFExport, "view is missing, guessing one..." );
+
+ rpView = GuessViewShell( bIsSwSrcView );
+ }
+ OSL_ENSURE( rpView, "SwViewShell missing" );
+ // the view shell should be SwView for documents PDF export.
+ // for the page preview no selection should be possible
+ // (the export dialog does not allow for this option)
+ const TypeId aSwViewTypeId = TYPE(SwView);
+ if (rpView && rpView->IsA(aSwViewTypeId))
+ {
+ if (!m_pRenderData)
+ {
+ OSL_FAIL("GetRenderDoc: no renderdata");
+ return 0;
+ }
+ SwView *const pSwView(static_cast<SwView *>(rpView));
+ SfxObjectShellLock xDocSh(m_pRenderData->GetTempDocShell());
+ if (!xDocSh.Is())
+ {
+ xDocSh = pSwView->CreateTmpSelectionDoc();
+ m_pRenderData->SetTempDocShell(xDocSh);
+ }
+ if (xDocSh.Is())
+ {
+ pDoc = ((SwDocShell*)&xDocSh)->GetDoc();
+ rpView = pDoc->GetDocShell()->GetView();
+ }
+ }
+ else
+ {
+ OSL_FAIL("unexpected SwViewShell" );
+ }
+ }
+ }
+ return pDoc;
+}
+
+static void lcl_SavePrintUIOptionsToDocumentPrintData(
+ SwDoc &rDoc,
+ const SwPrintUIOptions &rPrintUIOptions,
+ bool bIsPDFEXport )
+{
+ SwPrintData aDocPrintData( rDoc.getPrintData() );
+
+ aDocPrintData.SetPrintGraphic( rPrintUIOptions.IsPrintGraphics() );
+ aDocPrintData.SetPrintTable( rPrintUIOptions.IsPrintTables() );
+ aDocPrintData.SetPrintDraw( rPrintUIOptions.IsPrintDrawings() );
+ aDocPrintData.SetPrintControl( rPrintUIOptions.IsPrintFormControls() );
+ aDocPrintData.SetPrintLeftPage( rPrintUIOptions.IsPrintLeftPages() );
+ aDocPrintData.SetPrintRightPage( rPrintUIOptions.IsPrintRightPages() );
+ aDocPrintData.SetPrintReverse( rPrintUIOptions.IsPrintReverse() );
+ aDocPrintData.SetPaperFromSetup( rPrintUIOptions.IsPaperFromSetup() );
+ aDocPrintData.SetPrintEmptyPages( rPrintUIOptions.IsPrintEmptyPages( bIsPDFEXport ) );
+ aDocPrintData.SetPrintPostIts( rPrintUIOptions.GetPrintPostItsType() );
+ aDocPrintData.SetPrintProspect( rPrintUIOptions.IsPrintProspect() );
+ aDocPrintData.SetPrintProspect_RTL( rPrintUIOptions.IsPrintProspectRTL() );
+ aDocPrintData.SetPrintPageBackground( rPrintUIOptions.IsPrintPageBackground() );
+ aDocPrintData.SetPrintBlackFont( rPrintUIOptions.IsPrintWithBlackTextColor() );
+ // aDocPrintData.SetPrintSingleJobs( b ); handled by File/Print dialog itself
+ // arDocPrintData.SetFaxName( s ); n/a in File/Print dialog
+ aDocPrintData.SetPrintHiddenText( rPrintUIOptions.IsPrintHiddenText() );
+ aDocPrintData.SetPrintTextPlaceholder( rPrintUIOptions.IsPrintTextPlaceholders() );
+
+ rDoc.setPrintData( aDocPrintData );
+}
+
+sal_Int32 SAL_CALL SwXTextDocument::getRendererCount(
+ const uno::Any& rSelection,
+ const uno::Sequence< beans::PropertyValue >& rxOptions )
+ throw (IllegalArgumentException, RuntimeException,
+ std::exception)
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ {
+ throw DisposedException( OUString(),
+ static_cast< XTextDocument* >(this) );
+ }
+
+ const bool bIsPDFExport = !lcl_SeqHasProperty( rxOptions, "IsPrinter" );
+ bool bIsSwSrcView = false;
+ SfxViewShell *pView = GetRenderView( bIsSwSrcView, rxOptions, bIsPDFExport );
+
+ if (!bIsSwSrcView && !m_pRenderData)
+ m_pRenderData = new SwRenderData;
+ if (!m_pPrintUIOptions)
+ m_pPrintUIOptions = lcl_GetPrintUIOptions( pDocShell, pView );
+ bool bFormat = m_pPrintUIOptions->processPropertiesAndCheckFormat( rxOptions );
+
+ SwDoc *pDoc = GetRenderDoc( pView, rSelection, bIsPDFExport );
+ OSL_ENSURE( pDoc && pView, "doc or view shell missing!" );
+ if (!pDoc || !pView)
+ return 0;
+
+ // save current UI options from the print dialog for the next call to that dialog
+ lcl_SavePrintUIOptionsToDocumentPrintData( *pDoc, *m_pPrintUIOptions, bIsPDFExport );
+
+ sal_Int32 nRet = 0;
+ if (bIsSwSrcView)
+ {
+ SwSrcView *pSwSrcView = dynamic_cast< SwSrcView * >(pView);
+ OutputDevice *pOutDev = lcl_GetOutputDevice( *m_pPrintUIOptions );
+ nRet = pSwSrcView->PrintSource( pOutDev, 1 /* dummy */, true /* get page count only */ );
+ }
+ else
+ {
+ SwDocShell *pRenderDocShell = pDoc->GetDocShell();
+
+ // TODO/mba: we really need a generic way to get the SwViewShell!
+ SwViewShell* pViewShell = 0;
+ SwView* pSwView = PTR_CAST(SwView, pView);
+ if ( pSwView )
+ {
+ pViewShell = pSwView->GetWrtShellPtr();
+ }
+ else
+ {
+ if ( bIsPDFExport && bFormat )
+ {
+ //create a hidden view to be able to export as PDF also in print preview
+ //pView and pSwView are not changed intentionally!
+ m_pHiddenViewFrame = SfxViewFrame::LoadHiddenDocument( *pRenderDocShell, 2 );
+ pViewShell = ((SwView*)m_pHiddenViewFrame->GetViewShell())->GetWrtShellPtr();
+ }
+ else
+ pViewShell = ((SwPagePreview*)pView)->GetViewShell();
+ }
+
+ if (!pViewShell || !pViewShell->GetLayout())
+ return 0;
+
+ if (bFormat)
+ {
+ // #i38289
+ if( pViewShell->GetViewOptions()->getBrowseMode() )
+ {
+ SwViewOption aOpt( *pViewShell->GetViewOptions() );
+ aOpt.setBrowseMode( false );
+ pViewShell->ApplyViewOptions( aOpt );
+ if (pSwView)
+ {
+ pSwView->RecheckBrowseMode();
+ }
+ }
+
+ // reformatting the document for printing will show the changes in the view
+ // which is likely to produce many unwanted and not nice to view actions.
+ // We don't want that! Thus we disable updating of the view.
+ pViewShell->StartAction();
+
+ if (pSwView)
+ {
+ if (m_pRenderData && m_pRenderData->NeedNewViewOptionAdjust( *pViewShell ) )
+ m_pRenderData->ViewOptionAdjustStop();
+ if (m_pRenderData && !m_pRenderData->IsViewOptionAdjust())
+ {
+ m_pRenderData->ViewOptionAdjustStart(
+ *pViewShell, *pViewShell->GetViewOptions() );
+ }
+ }
+
+ m_pRenderData->MakeSwPrtOptions( pRenderDocShell,
+ m_pPrintUIOptions, bIsPDFExport );
+
+ if (pSwView)
+ {
+ // PDF export should not make use of the SwPrtOptions
+ const SwPrintData *pPrtOptions = (bIsPDFExport)
+ ? NULL : m_pRenderData->GetSwPrtOptions();
+ m_pRenderData->ViewOptionAdjust( pPrtOptions );
+ }
+
+ // since printing now also use the API for PDF export this option
+ // should be set for printing as well ...
+ pViewShell->SetPDFExportOption( sal_True );
+ bool bOrigStatus = pRenderDocShell->IsEnableSetModified();
+ // check configuration: shall update of printing information in DocInfo set the document to "modified"?
+ bool bStateChanged = false;
+ if ( bOrigStatus && !SvtPrintWarningOptions().IsModifyDocumentOnPrintingAllowed() )
+ {
+ pRenderDocShell->EnableSetModified( sal_False );
+ bStateChanged = true;
+ }
+
+ // #122919# Force field update before PDF export
+ pViewShell->SwViewShell::UpdateFlds(sal_True);
+ if( bStateChanged )
+ pRenderDocShell->EnableSetModified( sal_True );
+
+ // there is some redundancy between those two function calls, but right now
+ // there is no time to sort this out.
+ //TODO: check what exatly needs to be done and make just one function for that
+ pViewShell->CalcLayout();
+ pViewShell->CalcPagesForPrint( pViewShell->GetPageCount() );
+
+ pViewShell->SetPDFExportOption( sal_False );
+
+ // enable view again
+ pViewShell->EndAction();
+ }
+
+ const sal_Int32 nPageCount = pViewShell->GetPageCount();
+
+ // get number of pages to be rendered
+
+ const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintProspect", false );
+ if (bPrintProspect)
+ {
+ pDoc->CalculatePagePairsForProspectPrinting( *pViewShell->GetLayout(), *m_pRenderData, *m_pPrintUIOptions, nPageCount );
+ nRet = m_pRenderData->GetPagePairsForProspectPrinting().size();
+ }
+ else
+ {
+ const sal_Int16 nPostItMode = (sal_Int16) m_pPrintUIOptions->getIntValue( "PrintAnnotationMode", 0 );
+ if (nPostItMode != POSTITS_NONE)
+ {
+ OutputDevice *pOutDev = lcl_GetOutputDevice( *m_pPrintUIOptions );
+ m_pRenderData->CreatePostItData( pDoc, pViewShell->GetViewOptions(), pOutDev );
+ }
+
+ // get set of valid document pages (according to the current settings)
+ // and their start frames
+ pDoc->CalculatePagesForPrinting( *pViewShell->GetLayout(), *m_pRenderData, *m_pPrintUIOptions, bIsPDFExport, nPageCount );
+
+ if (nPostItMode != POSTITS_NONE)
+ {
+ pDoc->UpdatePagesForPrintingWithPostItData( *m_pRenderData,
+ *m_pPrintUIOptions, bIsPDFExport, nPageCount );
+ }
+
+ nRet = m_pRenderData->GetPagesToPrint().size();
+ }
+ }
+ OSL_ENSURE( nRet >= 0, "negative number of pages???" );
+
+ return nRet;
+}
+
+uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer(
+ sal_Int32 nRenderer,
+ const uno::Any& rSelection,
+ const uno::Sequence< beans::PropertyValue >& rxOptions )
+ throw (IllegalArgumentException, RuntimeException,
+ std::exception)
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ {
+ throw DisposedException( OUString(),
+ static_cast< XTextDocument* >(this) );
+ }
+
+ const bool bIsPDFExport = !lcl_SeqHasProperty( rxOptions, "IsPrinter" );
+ bool bIsSwSrcView = false;
+ SfxViewShell *pView = GetRenderView( bIsSwSrcView, rxOptions, bIsPDFExport );
+
+ // m_pRenderData should NOT be created here!
+ // That should only be done in getRendererCount. If this function is called before
+ // getRendererCount was called then the caller will probably just retrieve the extra UI options
+ // and is not interested in getting valid information about the other data that would
+ // otherwise be provided here!
+// if( ! m_pRenderData )
+// m_pRenderData = new SwRenderData;
+ if (!m_pPrintUIOptions)
+ m_pPrintUIOptions = lcl_GetPrintUIOptions( pDocShell, pView );
+ m_pPrintUIOptions->processProperties( rxOptions );
+ const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintProspect", false );
+ const bool bIsSkipEmptyPages = !m_pPrintUIOptions->IsPrintEmptyPages( bIsPDFExport );
+ const bool bPrintPaperFromSetup = m_pPrintUIOptions->getBoolValue( "PrintPaperFromSetup", false );
+
+ SwDoc *pDoc = GetRenderDoc( pView, rSelection, bIsPDFExport );
+ OSL_ENSURE( pDoc && pView, "doc or view shell missing!" );
+ if (!pDoc || !pView)
+ return uno::Sequence< beans::PropertyValue >();
+
+ // due to #110067# (document page count changes sometimes during
+ // PDF export/printing) we can not check for the upper bound properly.
+ // Thus instead of throwing the exception we silently return.
+ if (0 > nRenderer)
+ throw IllegalArgumentException();
+
+ // TODO/mba: we really need a generic way to get the SwViewShell!
+ SwViewShell* pVwSh = 0;
+ SwView* pSwView = PTR_CAST(SwView, pView);
+ if ( pSwView )
+ pVwSh = pSwView->GetWrtShellPtr();
+ else
+ pVwSh = ((SwPagePreview*)pView)->GetViewShell();
+
+ sal_Int32 nMaxRenderer = 0;
+ if (!bIsSwSrcView && m_pRenderData)
+ {
+ OSL_ENSURE( m_pRenderData, "m_pRenderData missing!!" );
+ nMaxRenderer = bPrintProspect?
+ m_pRenderData->GetPagePairsForProspectPrinting().size() - 1 :
+ m_pRenderData->GetPagesToPrint().size() - 1;
+ }
+ // since SwSrcView::PrintSource is a poor implementation to get the number of pages to print
+ // we obmit checking of the upper bound in this case.
+ if (!bIsSwSrcView && m_pRenderData && nRenderer > nMaxRenderer)
+ return uno::Sequence< beans::PropertyValue >();
+
+ uno::Sequence< beans::PropertyValue > aRenderer;
+ if (m_pRenderData)
+ {
+ // #i114210#
+ // determine the correct page number from the renderer index
+ // #i114875
+ // consider brochure print
+ const sal_uInt16 nPage = bPrintProspect
+ ? nRenderer + 1
+ : m_pRenderData->GetPagesToPrint()[ nRenderer ];
+
+ // get paper tray to use ...
+ sal_Int32 nPrinterPaperTray = -1;
+ if (! bPrintPaperFromSetup)
+ {
+ // ... from individual page style (see the page tab in Format/Page dialog)
+ const std::map< sal_Int32, sal_Int32 > &rPaperTrays = m_pRenderData->GetPrinterPaperTrays();
+ std::map< sal_Int32, sal_Int32 >::const_iterator aIt( rPaperTrays.find( nPage ) );
+ if (aIt != rPaperTrays.end())
+ nPrinterPaperTray = aIt->second;
+ }
+
+ awt::Size aPageSize;
+ awt::Size aPreferredPageSize;
+ Size aTmpSize;
+ if (bIsSwSrcView || bPrintProspect)
+ {
+ // for printing of HTML source code and prospect printing we should use
+ // the printers paper size since
+ // a) HTML source view has no page size
+ // b) prospect printing has a different page size from the documents page
+ // since two document pages will get rendered on one printer page
+
+ // since PageIncludesNonprintableArea will be set to true we can return the
+ // printers paper size here.
+ // Sometimes 'getRenderer' is only called to get "ExtraPrintUIOptions", in this
+ // case we won't get an OutputDevice here, but then the caller also has no need
+ // for the correct PageSisze right now...
+ Printer *pPrinter = dynamic_cast< Printer * >(lcl_GetOutputDevice( *m_pPrintUIOptions ));
+ if (pPrinter)
+ {
+ // HTML source view and prospect adapt to the printer's paper size
+ aTmpSize = pPrinter->GetPaperSize();
+ aTmpSize = pPrinter->LogicToLogic( aTmpSize,
+ pPrinter->GetMapMode(), MapMode( MAP_100TH_MM ));
+ aPageSize = awt::Size( aTmpSize.Width(), aTmpSize.Height() );
+ #if 0
+ // #i115048# it seems users didn't like getting double the formatted page size
+ // revert to "old" behavior scaling to the current paper size of the printer
+ if (bPrintProspect)
+ {
+ // we just state what output size we would need
+ // which may cause vcl to set that page size on the printer
+ // (if available and not overridden by the user)
+ aTmpSize = pVwSh->GetPageSize( nPage, bIsSkipEmptyPages );
+ aPreferredPageSize = awt::Size ( TWIP_TO_MM100( 2 * aTmpSize.Width() ),
+ TWIP_TO_MM100( aTmpSize.Height() ));
+ }
+ #else
+ if( bPrintProspect )
+ {
+ // just switch to an appropriate portrait/landscape format
+ // FIXME: brochure printing with landscape pages puts the
+ // pages next to each other, so landscape is currently always
+ // the better choice
+ if( aPageSize.Width < aPageSize.Height )
+ {
+ aPreferredPageSize.Width = aPageSize.Height;
+ aPreferredPageSize.Height = aPageSize.Width;
+ }
+ }
+ #endif
+ }
+ }
+ else
+ {
+ aTmpSize = pVwSh->GetPageSize( nPage, bIsSkipEmptyPages );
+ aPageSize = awt::Size ( TWIP_TO_MM100( aTmpSize.Width() ),
+ TWIP_TO_MM100( aTmpSize.Height() ));
+ }
+
+ sal_Int32 nLen = 2;
+ aRenderer.realloc(2);
+ aRenderer[0].Name = "PageSize";
+ aRenderer[0].Value <<= aPageSize;
+ aRenderer[1].Name = "PageIncludesNonprintableArea";
+ aRenderer[1].Value <<= sal_True;
+ if (aPreferredPageSize.Width && aPreferredPageSize.Height)
+ {
+ ++nLen;
+ aRenderer.realloc( nLen );
+ aRenderer[ nLen - 1 ].Name = "PreferredPageSize";
+ aRenderer[ nLen - 1 ].Value <<= aPreferredPageSize;
+ }
+ if (nPrinterPaperTray >= 0)
+ {
+ ++nLen;
+ aRenderer.realloc( nLen );
+ aRenderer[ nLen - 1 ].Name = "PrinterPaperTray";
+ aRenderer[ nLen - 1 ].Value <<= nPrinterPaperTray;
+ }
+ }
+
+ // #i117783#
+ if ( bApplyPagePrintSettingsFromXPagePrintable )
+ {
+ const SwPagePreviewPrtData* pPagePrintSettings =
+ pDocShell->GetDoc()->GetPreviewPrtData();
+ if ( pPagePrintSettings &&
+ ( pPagePrintSettings->GetRow() > 1 ||
+ pPagePrintSettings->GetCol() > 1 ) )
+ {
+ // extend render data by page print settings attributes
+ sal_Int32 nLen = aRenderer.getLength();
+ const sal_Int32 nRenderDataIdxStart = nLen;
+ nLen += 9;
+ aRenderer.realloc( nLen );
+ // put page print settings attribute into render data
+ const sal_Int32 nRow = pPagePrintSettings->GetRow();
+ aRenderer[ nRenderDataIdxStart + 0 ].Name = "NUpRows";
+ aRenderer[ nRenderDataIdxStart + 0 ].Value <<= ( nRow > 1 ? nRow : 1 );
+ const sal_Int32 nCol = pPagePrintSettings->GetCol();
+ aRenderer[ nRenderDataIdxStart + 1 ].Name = "NUpColumns";
+ aRenderer[ nRenderDataIdxStart + 1 ].Value <<= ( nCol > 1 ? nCol : 1 );
+ aRenderer[ nRenderDataIdxStart + 2 ].Name = "NUpPageMarginLeft";
+ aRenderer[ nRenderDataIdxStart + 2 ].Value <<= pPagePrintSettings->GetLeftSpace();
+ aRenderer[ nRenderDataIdxStart + 3 ].Name = "NUpPageMarginRight";
+ aRenderer[ nRenderDataIdxStart + 3 ].Value <<= pPagePrintSettings->GetRightSpace();
+ aRenderer[ nRenderDataIdxStart + 4 ].Name = "NUpPageMarginTop";
+ aRenderer[ nRenderDataIdxStart + 4 ].Value <<= pPagePrintSettings->GetTopSpace();
+ aRenderer[ nRenderDataIdxStart + 5 ].Name = "NUpPageMarginBottom";
+ aRenderer[ nRenderDataIdxStart + 5 ].Value <<= pPagePrintSettings->GetBottomSpace();
+ aRenderer[ nRenderDataIdxStart + 6 ].Name = "NUpHorizontalSpacing";
+ aRenderer[ nRenderDataIdxStart + 6 ].Value <<= pPagePrintSettings->GetHorzSpace();
+ aRenderer[ nRenderDataIdxStart + 7 ].Name = "NUpVerticalSpacing";
+ aRenderer[ nRenderDataIdxStart + 7 ].Value <<= pPagePrintSettings->GetVertSpace();
+ {
+ Printer* pPrinter = pDocShell->GetDoc()->getPrinter( false );
+ if ( pPrinter )
+ {
+ awt::Size aNewPageSize;
+ const Size aPageSize = pPrinter->PixelToLogic( pPrinter->GetPaperSizePixel(), MapMode( MAP_100TH_MM ) );
+ aNewPageSize = awt::Size( aPageSize.Width(), aPageSize.Height() );
+ if ( ( pPagePrintSettings->GetLandscape() &&
+ aPageSize.Width() < aPageSize.Height() ) ||
+ ( !pPagePrintSettings->GetLandscape() &&
+ aPageSize.Width() > aPageSize.Height() ) )
+ {
+ aNewPageSize = awt::Size( aPageSize.Height(), aPageSize.Width() );
+ }
+ aRenderer[ nRenderDataIdxStart + 8 ].Name = "NUpPaperSize";
+ aRenderer[ nRenderDataIdxStart + 8 ].Value <<= aNewPageSize;
+ }
+ }
+ }
+
+ bApplyPagePrintSettingsFromXPagePrintable = sal_False;
+ }
+
+ m_pPrintUIOptions->appendPrintUIOptions( aRenderer );
+
+ return aRenderer;
+}
+
+SfxViewShell * SwXTextDocument::GuessViewShell(
+ /* out */ bool &rbIsSwSrcView,
+ const uno::Reference< css::frame::XController > xController )
+{
+ // #130810# SfxViewShell::Current() / SfxViewShell::GetObjectShell()
+ // must not be used (see comment from MBA)
+
+ SfxViewShell *pView = 0;
+ SwView *pSwView = 0;
+ SwPagePreview *pSwPagePreview = 0;
+ SwSrcView *pSwSrcView = 0;
+ SfxViewFrame *pFrame = SfxViewFrame::GetFirst( pDocShell, sal_False );
+
+ // look for the view shell with the same controller in use,
+ // otherwise look for a suitable view, preferably a SwView,
+ // if that one is not found use a SwPagePreview if found.
+ while (pFrame)
+ {
+ pView = pFrame->GetViewShell();
+ pSwView = dynamic_cast< SwView * >(pView);
+ pSwSrcView = dynamic_cast< SwSrcView * >(pView);
+ if (!pSwPagePreview)
+ pSwPagePreview = dynamic_cast< SwPagePreview * >(pView);
+ if (xController.is())
+ {
+ if (pView && pView->GetController() == xController)
+ break;
+ }
+ else if (pSwView || pSwSrcView)
+ break;
+ pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell, sal_False );
+ }
+
+ OSL_ENSURE( pSwView || pSwPagePreview || pSwSrcView, "failed to get view shell" );
+ if (pView)
+ rbIsSwSrcView = pSwSrcView != 0;
+ return pView;
+}
+
+void SAL_CALL SwXTextDocument::render(
+ sal_Int32 nRenderer,
+ const uno::Any& rSelection,
+ const uno::Sequence< beans::PropertyValue >& rxOptions )
+ throw (IllegalArgumentException, RuntimeException,
+ std::exception)
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ {
+ throw DisposedException( OUString(),
+ static_cast< XTextDocument* >(this) );
+ }
+
+ // due to #110067# (document page count changes sometimes during
+ // PDF export/printing) we can not check for the upper bound properly.
+ // Thus instead of throwing the exception we silently return.
+ if (0 > nRenderer)
+ throw IllegalArgumentException();
+
+ const bool bIsPDFExport = !lcl_SeqHasProperty( rxOptions, "IsPrinter" );
+ bool bIsSwSrcView = false;
+ SfxViewShell *pView = GetRenderView( bIsSwSrcView, rxOptions, bIsPDFExport );
+
+ OSL_ENSURE( m_pRenderData, "data should have been created already in getRendererCount..." );
+ OSL_ENSURE( m_pPrintUIOptions, "data should have been created already in getRendererCount..." );
+ if (!bIsSwSrcView && !m_pRenderData)
+ m_pRenderData = new SwRenderData;
+ if (!m_pPrintUIOptions)
+ m_pPrintUIOptions = lcl_GetPrintUIOptions( pDocShell, pView );
+ m_pPrintUIOptions->processProperties( rxOptions );
+ const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintProspect", false );
+ const bool bLastPage = m_pPrintUIOptions->getBoolValue( "IsLastPage", false );
+
+ SwDoc *pDoc = GetRenderDoc( pView, rSelection, bIsPDFExport );
+ OSL_ENSURE( pDoc && pView, "doc or view shell missing!" );
+ if (pDoc && pView)
+ {
+ sal_Int32 nMaxRenderer = 0;
+ if (!bIsSwSrcView)
+ {
+ OSL_ENSURE( m_pRenderData, "m_pRenderData missing!!" );
+ nMaxRenderer = bPrintProspect?
+ m_pRenderData->GetPagePairsForProspectPrinting().size() - 1 :
+ m_pRenderData->GetPagesToPrint().size() - 1;
+ }
+ // since SwSrcView::PrintSource is a poor implementation to get the number of pages to print
+ // we obmit checking of the upper bound in this case.
+ if (bIsSwSrcView || nRenderer <= nMaxRenderer)
+ {
+ if (bIsSwSrcView)
+ {
+ SwSrcView *pSwSrcView = dynamic_cast< SwSrcView * >(pView);
+ OutputDevice *pOutDev = lcl_GetOutputDevice( *m_pPrintUIOptions );
+ pSwSrcView->PrintSource( pOutDev, nRenderer + 1, false );
+ }
+ else
+ {
+ // the view shell should be SwView for documents PDF export
+ // or SwPagePreview for PDF export of the page preview
+ //!! (check for SwView first as in GuessViewShell) !!
+ OSL_ENSURE( pView, "!! view missing !!" );
+ const TypeId aSwViewTypeId = TYPE(SwView);
+ SwViewShell* pVwSh = 0;
+ if (pView)
+ {
+ // TODO/mba: we really need a generic way to get the SwViewShell!
+ SwView* pSwView = PTR_CAST(SwView, pView);
+ if ( pSwView )
+ pVwSh = pSwView->GetWrtShellPtr();
+ else
+ pVwSh = ((SwPagePreview*)pView)->GetViewShell();
+ }
+
+ // get output device to use
+ OutputDevice * pOut = lcl_GetOutputDevice( *m_pPrintUIOptions );
+
+ if(pVwSh && pOut && m_pRenderData->HasSwPrtOptions())
+ {
+ const OUString aPageRange = m_pPrintUIOptions->getStringValue( "PageRange", OUString() );
+ const bool bFirstPage = m_pPrintUIOptions->getBoolValue( "IsFirstPage", false );
+ bool bIsSkipEmptyPages = !m_pPrintUIOptions->IsPrintEmptyPages( bIsPDFExport );
+
+ OSL_ENSURE(( pView->IsA(aSwViewTypeId) && m_pRenderData->IsViewOptionAdjust())
+ || (!pView->IsA(aSwViewTypeId) && !m_pRenderData->IsViewOptionAdjust()),
+ "SwView / SwViewOptionAdjust_Impl availability mismatch" );
+
+ // since printing now also use the API for PDF export this option
+ // should be set for printing as well ...
+ pVwSh->SetPDFExportOption( sal_True );
+
+ // #i12836# enhanced pdf export
+
+ // First, we have to export hyperlinks, notes, and outline to pdf.
+ // During this process, additional information required for tagging
+ // the pdf file are collected, which are evaulated during painting.
+
+ SwWrtShell* pWrtShell = pView->IsA(aSwViewTypeId) ?
+ ((SwView*)pView)->GetWrtShellPtr() :
+ 0;
+
+ if (bIsPDFExport && bFirstPage && pWrtShell)
+ {
+ SwEnhancedPDFExportHelper aHelper( *pWrtShell, *pOut, aPageRange, bIsSkipEmptyPages, false );
+ }
+
+ SwPrintData const& rSwPrtOptions =
+ *m_pRenderData->GetSwPrtOptions();
+ if (bPrintProspect)
+ pVwSh->PrintProspect( pOut, rSwPrtOptions, nRenderer );
+ else // normal printing and PDF export
+ pVwSh->PrintOrPDFExport( pOut, rSwPrtOptions, nRenderer );
+
+ // #i35176#
+
+ // After printing the last page, we take care for the links coming
+ // from the EditEngine. The links are generated during the painting
+ // process, but the destinations are still missing.
+
+ if (bIsPDFExport && bLastPage && pWrtShell)
+ {
+ SwEnhancedPDFExportHelper aHelper( *pWrtShell, *pOut, aPageRange, bIsSkipEmptyPages, true );
+ }
+
+ pVwSh->SetPDFExportOption( sal_False );
+
+ // last page to be rendered? (not necessarily the last page of the document)
+ // -> do clean-up of data
+ if (bLastPage)
+ {
+ // #i96167# haggai: delete ViewOptionsAdjust here because it makes use
+ // of the shell, which might get destroyed in lcl_DisposeView!
+ if (m_pRenderData->IsViewOptionAdjust())
+ m_pRenderData->ViewOptionAdjustStop();
+
+ if (m_pRenderData->HasPostItData())
+ m_pRenderData->DeletePostItData();
+ if (m_pHiddenViewFrame)
+ {
+ lcl_DisposeView( m_pHiddenViewFrame, pDocShell );
+ m_pHiddenViewFrame = 0;
+
+ // prevent crash described in #i108805
+ SwDocShell *pRenderDocShell = pDoc->GetDocShell();
+ SfxItemSet *pSet = pRenderDocShell->GetMedium()->GetItemSet();
+ pSet->Put( SfxBoolItem( SID_HIDDEN, false ) );
+
+ }
+ }
+ }
+ }
+ }
+ }
+ if( bLastPage )
+ {
+ delete m_pRenderData; m_pRenderData = NULL;
+ delete m_pPrintUIOptions; m_pPrintUIOptions = NULL;
+ }
+}
+
+// xforms::XFormsSupplier
+Reference<XNameContainer> SAL_CALL SwXTextDocument::getXForms()
+ throw( RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ if ( !pDocShell )
+ throw DisposedException( OUString(), static_cast< XTextDocument* >( this ) );
+ SwDoc* pDoc = pDocShell->GetDoc();
+ return pDoc->getXForms();
+}
+
+uno::Reference< text::XFlatParagraphIterator > SAL_CALL SwXTextDocument::getFlatParagraphIterator(::sal_Int32 nTextMarkupType, sal_Bool bAutomatic)
+ throw ( uno::RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ if (!IsValid())
+ {
+ throw DisposedException("SwXTextDocument not valid",
+ static_cast<XTextDocument*>(this));
+ }
+
+ return SwUnoCursorHelper::CreateFlatParagraphIterator(
+ *pDocShell->GetDoc(), nTextMarkupType, bAutomatic);
+}
+
+uno::Reference< util::XCloneable > SwXTextDocument::createClone( ) throw (uno::RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+
+ // create a new document - hidden - copy the storage and return it
+ // SfxObjectShellRef is used here, since the model should control object lifetime after creation
+ // and thus SfxObjectShellLock is not allowed here
+ // the model holds reference to the shell, so the shell will not destructed at the end of method
+ SfxObjectShellRef pShell = pDocShell->GetDoc()->CreateCopy(false);
+ uno::Reference< frame::XModel > xNewModel = pShell->GetModel();
+ uno::Reference< embed::XStorage > xNewStorage = ::comphelper::OStorageHelper::GetTemporaryStorage( );
+ uno::Sequence< beans::PropertyValue > aTempMediaDescriptor;
+ storeToStorage( xNewStorage, aTempMediaDescriptor );
+ uno::Reference< document::XStorageBasedDocument > xStorageDoc( xNewModel, uno::UNO_QUERY );
+ xStorageDoc->loadFromStorage( xNewStorage, aTempMediaDescriptor );
+ return uno::Reference< util::XCloneable >( xNewModel, UNO_QUERY );
+}
+
+void * SAL_CALL SwXTextDocument::operator new( size_t t) throw()
+{
+ return SwXTextDocumentBaseClass::operator new(t);
+}
+
+void SAL_CALL SwXTextDocument::operator delete( void * p) throw()
+{
+ SwXTextDocumentBaseClass::operator delete(p);
+}
+
+/**
+ * retrieve languages already used in current document
+ */
+uno::Sequence< lang::Locale > SAL_CALL SwXTextDocument::getDocumentLanguages(
+ ::sal_Int16 nScriptTypes,
+ ::sal_Int16 nMaxCount )
+ throw (lang::IllegalArgumentException,
+ uno::RuntimeException,
+ std::exception)
+{
+ SolarMutexGuard aGuard;
+
+ // possible canonical values for nScriptTypes
+ // any bit wise combination is allowed
+ const sal_Int16 nLatin = 0x001;
+ const sal_Int16 nAsian = 0x002;
+ const sal_Int16 nComplex = 0x004;
+
+ // script types for which to get the languages
+ const bool bLatin = 0 != (nScriptTypes & nLatin);
+ const bool bAsian = 0 != (nScriptTypes & nAsian);
+ const bool bComplex = 0 != (nScriptTypes & nComplex);
+
+ if (nScriptTypes < nLatin || nScriptTypes > (nLatin | nAsian | nComplex))
+ throw IllegalArgumentException("nScriptTypes ranges from 1 to 7!", Reference< XInterface >(), 1);
+ if (!pDocShell)
+ throw DisposedException();
+ SwDoc* pDoc = pDocShell->GetDoc();
+
+ // avoid duplicate values
+ std::set< LanguageType > aAllLangs;
+
+ //USER STYLES
+
+ const SwCharFmts *pFmts = pDoc->GetCharFmts();
+ for(sal_uInt16 i = 0; i < pFmts->size(); ++i)
+ {
+ const SwAttrSet &rAttrSet = (*pFmts)[i]->GetAttrSet();
+ LanguageType nLang = LANGUAGE_DONTKNOW;
+ if (bLatin)
+ {
+ nLang = rAttrSet.GetLanguage( sal_False ).GetLanguage();
+ if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
+ aAllLangs.insert( nLang );
+ }
+ if (bAsian)
+ {
+ nLang = rAttrSet.GetCJKLanguage( sal_False ).GetLanguage();
+ if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
+ aAllLangs.insert( nLang );
+ }
+ if (bComplex)
+ {
+ nLang = rAttrSet.GetCTLLanguage( sal_False ).GetLanguage();
+ if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
+ aAllLangs.insert( nLang );
+ }
+ }
+
+ const SwTxtFmtColls *pColls = pDoc->GetTxtFmtColls();
+ for (sal_uInt16 i = 0; i < pColls->size(); ++i)
+ {
+ const SwAttrSet &rAttrSet = (*pColls)[i]->GetAttrSet();
+ LanguageType nLang = LANGUAGE_DONTKNOW;
+ if (bLatin)
+ {
+ nLang = rAttrSet.GetLanguage( sal_False ).GetLanguage();
+ if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
+ aAllLangs.insert( nLang );
+ }
+ if (bAsian)
+ {
+ nLang = rAttrSet.GetCJKLanguage( sal_False ).GetLanguage();
+ if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
+ aAllLangs.insert( nLang );
+ }
+ if (bComplex)
+ {
+ nLang = rAttrSet.GetCTLLanguage( sal_False ).GetLanguage();
+ if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
+ aAllLangs.insert( nLang );
+ }
+ }
+
+ //AUTO STYLES
+ const IStyleAccess::SwAutoStyleFamily aFam[2] =
+ {
+ IStyleAccess::AUTO_STYLE_CHAR,
+ IStyleAccess::AUTO_STYLE_PARA
+ };
+ for (sal_uInt16 i = 0; i < 2; ++i)
+ {
+ std::vector< SfxItemSet_Pointer_t > rStyles;
+ pDoc->GetIStyleAccess().getAllStyles(rStyles, aFam[i]);
+ while (!rStyles.empty())
+ {
+ SfxItemSet_Pointer_t pStyle = rStyles.back();
+ rStyles.pop_back();
+ const SfxItemSet *pSet = dynamic_cast< const SfxItemSet * >(pStyle.get());
+
+ LanguageType nLang = LANGUAGE_DONTKNOW;
+ if (bLatin)
+ {
+ nLang = dynamic_cast< const SvxLanguageItem & >(pSet->Get( RES_CHRATR_LANGUAGE, sal_False )).GetLanguage();
+ if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
+ aAllLangs.insert( nLang );
+ }
+ if (bAsian)
+ {
+ nLang = dynamic_cast< const SvxLanguageItem & >(pSet->Get( RES_CHRATR_CJK_LANGUAGE, sal_False )).GetLanguage();
+ if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
+ aAllLangs.insert( nLang );
+ }
+ if (bComplex)
+ {
+ nLang = dynamic_cast< const SvxLanguageItem & >(pSet->Get( RES_CHRATR_CTL_LANGUAGE, sal_False )).GetLanguage();
+ if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
+ aAllLangs.insert( nLang );
+ }
+ }
+ }
+
+ //TODO/mba: it's a strange concept that a view is needed to retrieve core data
+ SwWrtShell *pWrtSh = pDocShell->GetWrtShell();
+ SdrView *pSdrView = pWrtSh->GetDrawView();
+
+ if( pSdrView )
+ {
+ SdrOutliner* pOutliner = pSdrView->GetTextEditOutliner();
+ if(pOutliner)
+ {
+ EditEngine& rEditEng = (EditEngine&)pOutliner->GetEditEngine();
+ sal_Int32 nParCount = pOutliner->GetParagraphCount();
+ for (sal_Int32 nPar=0; nPar<nParCount; nPar++)
+ {
+ //every paragraph
+ std::vector<sal_Int32> aPortions;
+ rEditEng.GetPortions( nPar, aPortions );
+
+ for ( size_t nPos = aPortions.size(); nPos; )
+ {
+ //every position
+ --nPos;
+ sal_Int32 nEnd = aPortions[ nPos ];
+ sal_Int32 nStart = nPos ? aPortions[ nPos - 1 ] : 0;
+ ESelection aSelection( nPar, nStart, nPar, nEnd );
+ SfxItemSet aAttr = rEditEng.GetAttribs( aSelection );
+
+ LanguageType nLang = LANGUAGE_DONTKNOW;
+ if (bLatin)
+ {
+ nLang = dynamic_cast< const SvxLanguageItem & >(aAttr.Get( EE_CHAR_LANGUAGE, sal_False )).GetLanguage();
+ if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
+ aAllLangs.insert( nLang );
+ }
+ if (bAsian)
+ {
+ nLang = dynamic_cast< const SvxLanguageItem & >(aAttr.Get( EE_CHAR_LANGUAGE_CJK, sal_False )).GetLanguage();
+ if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
+ aAllLangs.insert( nLang );
+ }
+ if (bComplex)
+ {
+ nLang = dynamic_cast< const SvxLanguageItem & >(aAttr.Get( EE_CHAR_LANGUAGE_CTL, sal_False )).GetLanguage();
+ if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
+ aAllLangs.insert( nLang );
+ }
+ }
+ }
+ }
+ }
+ // less than nMaxCount languages
+ if (nMaxCount > static_cast< sal_Int16 >( aAllLangs.size() ))
+ nMaxCount = static_cast< sal_Int16 >( aAllLangs.size() );
+
+ // build return value
+ uno::Sequence< lang::Locale > aLanguages( nMaxCount );
+ lang::Locale* pLanguage = aLanguages.getArray();
+ if (nMaxCount > 0)
+ {
+ sal_Int32 nCount = 0;
+ const SvtLanguageTable aLangTab;
+ for (std::set< LanguageType >::const_iterator it = aAllLangs.begin(); it != aAllLangs.end(); ++it)
+ {
+ if (nCount >= nMaxCount)
+ break;
+ if (LANGUAGE_NONE != *it)
+ {
+ pLanguage[nCount] = LanguageTag::convertToLocale( *it );
+ pLanguage[nCount].Language = aLangTab.GetString( *it );
+ nCount += 1;
+ }
+ }
+ }
+
+ return aLanguages;
+}
+
+SwXLinkTargetSupplier::SwXLinkTargetSupplier(SwXTextDocument& rxDoc) :
+ pxDoc(&rxDoc)
+{
+ sTables = SW_RES(STR_CONTENT_TYPE_TABLE);
+ sFrames = SW_RES(STR_CONTENT_TYPE_FRAME);
+ sGraphics = SW_RES(STR_CONTENT_TYPE_GRAPHIC);
+ sOLEs = SW_RES(STR_CONTENT_TYPE_OLE);
+ sSections = SW_RES(STR_CONTENT_TYPE_REGION);
+ sOutlines = SW_RES(STR_CONTENT_TYPE_OUTLINE);
+ sBookmarks = SW_RES(STR_CONTENT_TYPE_BOOKMARK);
+}
+
+SwXLinkTargetSupplier::~SwXLinkTargetSupplier()
+{
+}
+
+Any SwXLinkTargetSupplier::getByName(const OUString& rName)
+ throw( NoSuchElementException, WrappedTargetException, RuntimeException, std::exception )
+{
+ Any aRet;
+ if(!pxDoc)
+ throw RuntimeException();
+ OUString sToCompare(rName);
+ OUString sSuffix("|");
+ if(sToCompare == sTables)
+ {
+ sSuffix += "table";
+
+ Reference< XNameAccess > xTbls = new SwXLinkNameAccessWrapper(
+ pxDoc->getTextTables(), sToCompare, sSuffix );
+ Reference< XPropertySet > xRet(xTbls, UNO_QUERY);
+ aRet.setValue(&xRet, ::getCppuType((Reference<XPropertySet>*)0));
+ }
+ else if(sToCompare == sFrames)
+ {
+ sSuffix += "frame";
+ Reference< XNameAccess > xTbls = new SwXLinkNameAccessWrapper(
+ pxDoc->getTextFrames(), sToCompare, sSuffix );
+ Reference< XPropertySet > xRet(xTbls, UNO_QUERY);
+ aRet.setValue(&xRet, ::getCppuType((Reference< XPropertySet>*)0));
+ }
+ else if(sToCompare == sSections)
+ {
+ sSuffix += "region";
+ Reference< XNameAccess > xTbls = new SwXLinkNameAccessWrapper(
+ pxDoc->getTextSections(), sToCompare, sSuffix );
+ Reference< XPropertySet > xRet(xTbls, UNO_QUERY);
+ aRet.setValue(&xRet, ::getCppuType((Reference< XPropertySet>*)0));
+ }
+ else if(sToCompare == sGraphics)
+ {
+ sSuffix += "graphic";
+ Reference< XNameAccess > xTbls = new SwXLinkNameAccessWrapper(
+ pxDoc->getGraphicObjects(), sToCompare, sSuffix );
+ Reference< XPropertySet > xRet(xTbls, UNO_QUERY);
+ aRet.setValue(&xRet, ::getCppuType((Reference< XPropertySet>*)0));
+ }
+ else if(sToCompare == sOLEs)
+ {
+ sSuffix += "ole";
+ Reference< XNameAccess > xTbls = new SwXLinkNameAccessWrapper(
+ pxDoc->getEmbeddedObjects(), sToCompare, sSuffix );
+ Reference< XPropertySet > xRet(xTbls, UNO_QUERY);
+ aRet.setValue(&xRet, ::getCppuType((Reference< XPropertySet>*)0));
+ }
+ else if(sToCompare == sOutlines)
+ {
+ sSuffix += "outline";
+ Reference< XNameAccess > xTbls = new SwXLinkNameAccessWrapper(
+ *pxDoc, sToCompare, sSuffix );
+ Reference< XPropertySet > xRet(xTbls, UNO_QUERY);
+ aRet.setValue(&xRet, ::getCppuType((Reference< XPropertySet>*)0));
+ }
+ else if(sToCompare == sBookmarks)
+ {
+ sSuffix = "";
+ Reference< XNameAccess > xBkms = new SwXLinkNameAccessWrapper(
+ pxDoc->getBookmarks(), sToCompare, sSuffix );
+ Reference< XPropertySet > xRet(xBkms, UNO_QUERY);
+ aRet.setValue(&xRet, ::getCppuType((Reference< XPropertySet>*)0));
+ }
+ else
+ throw NoSuchElementException();
+ return aRet;
+}
+
+Sequence< OUString > SwXLinkTargetSupplier::getElementNames(void)
+ throw( RuntimeException, std::exception )
+{
+ Sequence< OUString > aRet(7);
+ OUString* pNames = aRet.getArray();
+ pNames[0] = sTables;
+ pNames[1] = sFrames ;
+ pNames[2] = sGraphics;
+ pNames[3] = sOLEs ;
+ pNames[4] = sSections;
+ pNames[5] = sOutlines;
+ pNames[6] = sBookmarks;
+ return aRet;
+}
+
+sal_Bool SwXLinkTargetSupplier::hasByName(const OUString& rName)
+ throw( RuntimeException, std::exception )
+{
+ OUString sToCompare(rName);
+ if( sToCompare == sTables ||
+ sToCompare == sFrames ||
+ sToCompare == sGraphics||
+ sToCompare == sOLEs ||
+ sToCompare == sSections ||
+ sToCompare == sOutlines ||
+ sToCompare == sBookmarks )
+ return sal_True;
+ return sal_False;
+}
+
+uno::Type SwXLinkTargetSupplier::getElementType(void)
+ throw( RuntimeException, std::exception )
+{
+ return ::getCppuType((Reference< XPropertySet>*)0);
+
+}
+
+sal_Bool SwXLinkTargetSupplier::hasElements(void) throw( RuntimeException, std::exception )
+{
+ return 0 != pxDoc;
+}
+
+OUString SwXLinkTargetSupplier::getImplementationName(void) throw( RuntimeException, std::exception )
+{
+ return OUString("SwXLinkTargetSupplier");
+}
+
+sal_Bool SwXLinkTargetSupplier::supportsService(const OUString& rServiceName)
+ throw( RuntimeException, std::exception )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+Sequence< OUString > SwXLinkTargetSupplier::getSupportedServiceNames(void)
+ throw( RuntimeException, std::exception )
+{
+ Sequence< OUString > aRet(1);
+ OUString* pNames = aRet.getArray();
+ pNames[0] = "com.sun.star.document.LinkTargets";
+ return aRet;
+}
+
+SwXLinkNameAccessWrapper::SwXLinkNameAccessWrapper(
+ Reference< XNameAccess > xAccess, const OUString& rLinkDisplayName, OUString sSuffix ) :
+ xRealAccess(xAccess),
+ pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_LINK_TARGET)),
+ sLinkSuffix(sSuffix),
+ sLinkDisplayName(rLinkDisplayName),
+ pxDoc(0)
+{
+}
+
+SwXLinkNameAccessWrapper::SwXLinkNameAccessWrapper(SwXTextDocument& rxDoc,
+ const OUString& rLinkDisplayName, OUString sSuffix) :
+ pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_LINK_TARGET)),
+ sLinkSuffix(sSuffix),
+ sLinkDisplayName(rLinkDisplayName),
+ xDoc(&rxDoc),
+ pxDoc(&rxDoc)
+{
+}
+
+SwXLinkNameAccessWrapper::~SwXLinkNameAccessWrapper()
+{
+}
+
+Any SwXLinkNameAccessWrapper::getByName(const OUString& rName)
+ throw( NoSuchElementException, WrappedTargetException, RuntimeException, std::exception )
+{
+ Any aRet;
+ bool bFound = false;
+ //cut link extension and call the real NameAccess
+ OUString sParam = rName;
+ OUString sSuffix(sLinkSuffix);
+ if(sParam.getLength() > sSuffix.getLength() )
+ {
+ OUString sCmp = sParam.copy(sParam.getLength() - sSuffix.getLength(),
+ sSuffix.getLength());
+ if(sCmp == sSuffix)
+ {
+ if(pxDoc)
+ {
+ sParam = sParam.copy(0, sParam.getLength() - sSuffix.getLength());
+ if(!pxDoc->GetDocShell())
+ throw RuntimeException();
+ SwDoc* pDoc = pxDoc->GetDocShell()->GetDoc();
+ sal_uInt16 nOutlineCount = pDoc->GetNodes().GetOutLineNds().size();
+
+ for (sal_uInt16 i = 0; i < nOutlineCount && !bFound; ++i)
+ {
+ const SwOutlineNodes& rOutlineNodes = pDoc->GetNodes().GetOutLineNds();
+ const SwNumRule* pOutlRule = pDoc->GetOutlineNumRule();
+ if(sParam ==
+ lcl_CreateOutlineString(i, rOutlineNodes, pOutlRule))
+ {
+ Reference< XPropertySet > xOutline = new SwXOutlineTarget(sParam);
+ aRet.setValue(&xOutline, ::getCppuType((Reference<XPropertySet>*)0));
+ bFound = true;
+ }
+ }
+ }
+ else
+ {
+ aRet = xRealAccess->getByName(sParam.copy(0, sParam.getLength() - sSuffix.getLength()));
+ Reference< XInterface > xInt;
+ if(!(aRet >>= xInt))
+ throw RuntimeException();
+ Reference< XPropertySet > xProp(xInt, UNO_QUERY);
+ aRet <<= xProp;
+ bFound = true;
+ }
+ }
+ }
+ if(!bFound)
+ throw NoSuchElementException();
+ return aRet;
+}
+
+Sequence< OUString > SwXLinkNameAccessWrapper::getElementNames(void)
+ throw( RuntimeException, std::exception )
+{
+ Sequence< OUString > aRet;
+ if(pxDoc)
+ {
+ if(!pxDoc->GetDocShell())
+ throw RuntimeException();
+
+ SwDoc* pDoc = pxDoc->GetDocShell()->GetDoc();
+ const SwOutlineNodes& rOutlineNodes = pDoc->GetNodes().GetOutLineNds();
+ sal_uInt16 nOutlineCount = rOutlineNodes.size();
+ aRet.realloc(nOutlineCount);
+ OUString* pResArr = aRet.getArray();
+ OUString sSuffix("|outline");
+ const SwNumRule* pOutlRule = pDoc->GetOutlineNumRule();
+ for (sal_uInt16 i = 0; i < nOutlineCount; ++i)
+ {
+ OUString sEntry = lcl_CreateOutlineString(i, rOutlineNodes, pOutlRule);
+ sEntry += sSuffix;
+ pResArr[i] = sEntry;
+ }
+ }
+ else
+ {
+ Sequence< OUString > aOrg = xRealAccess->getElementNames();
+ const OUString* pOrgArr = aOrg.getConstArray();
+ aRet.realloc(aOrg.getLength());
+ OUString* pResArr = aRet.getArray();
+ for(long i = 0; i < aOrg.getLength(); i++)
+ {
+ pResArr[i] = pOrgArr[i] + sLinkSuffix;
+ }
+ }
+ return aRet;
+}
+
+sal_Bool SwXLinkNameAccessWrapper::hasByName(const OUString& rName)
+ throw( RuntimeException, std::exception )
+{
+ sal_Bool bRet = sal_False;
+ OUString sParam(rName);
+ if(sParam.getLength() > sLinkSuffix.getLength() )
+ {
+ OUString sCmp = sParam.copy(sParam.getLength() - sLinkSuffix.getLength(),
+ sLinkSuffix.getLength());
+ if(sCmp == sLinkSuffix)
+ {
+ sParam = sParam.copy(0, sParam.getLength() - sLinkSuffix.getLength());
+ if(pxDoc)
+ {
+ if(!pxDoc->GetDocShell())
+ throw RuntimeException();
+ SwDoc* pDoc = pxDoc->GetDocShell()->GetDoc();
+ sal_uInt16 nOutlineCount = pDoc->GetNodes().GetOutLineNds().size();
+
+ for (sal_uInt16 i = 0; i < nOutlineCount && !bRet; ++i)
+ {
+ const SwOutlineNodes& rOutlineNodes = pDoc->GetNodes().GetOutLineNds();
+ const SwNumRule* pOutlRule = pDoc->GetOutlineNumRule();
+ if(sParam ==
+ lcl_CreateOutlineString(i, rOutlineNodes, pOutlRule))
+ {
+ bRet = sal_True;
+ }
+ }
+ }
+ else
+ {
+ bRet = xRealAccess->hasByName(sParam);
+ }
+ }
+ }
+ return bRet;
+}
+
+uno::Type SwXLinkNameAccessWrapper::getElementType(void)
+ throw( RuntimeException, std::exception )
+{
+ return ::getCppuType((Reference<XPropertySet>*)0);
+}
+
+sal_Bool SwXLinkNameAccessWrapper::hasElements(void) throw( RuntimeException, std::exception )
+{
+ sal_Bool bRet = sal_False;
+ if(pxDoc)
+ {
+ OSL_FAIL("not implemented");
+ }
+ else
+ {
+ bRet = xRealAccess->hasElements();
+ }
+ return bRet;
+}
+
+Reference< XPropertySetInfo > SwXLinkNameAccessWrapper::getPropertySetInfo(void)
+ throw( RuntimeException, std::exception )
+{
+ static Reference< XPropertySetInfo > xRet = pPropSet->getPropertySetInfo();
+ return xRet;
+}
+
+void SwXLinkNameAccessWrapper::setPropertyValue(
+ const OUString& , const Any& )
+ throw( UnknownPropertyException,
+ PropertyVetoException,
+ IllegalArgumentException,
+ WrappedTargetException,
+ RuntimeException, std::exception)
+{
+ throw UnknownPropertyException();
+}
+
+static Any lcl_GetDisplayBitmap(OUString sLinkSuffix)
+{
+ Any aRet;
+ if(!sLinkSuffix.isEmpty())
+ sLinkSuffix = sLinkSuffix.copy(1);
+ sal_uInt16 nImgId = USHRT_MAX;
+
+ if(sLinkSuffix == "outline")
+ nImgId = CONTENT_TYPE_OUTLINE;
+ else if(sLinkSuffix == "table")
+ nImgId = CONTENT_TYPE_TABLE;
+ else if(sLinkSuffix == "frame")
+ nImgId = CONTENT_TYPE_FRAME;
+ else if(sLinkSuffix == "graphic")
+ nImgId = CONTENT_TYPE_GRAPHIC;
+ else if(sLinkSuffix == "region")
+ nImgId = CONTENT_TYPE_REGION;
+ else if(sLinkSuffix == "ole")
+ nImgId = CONTENT_TYPE_OLE;
+ else if(sLinkSuffix.isEmpty())
+ nImgId = CONTENT_TYPE_BOOKMARK;
+ if(USHRT_MAX != nImgId)
+ {
+ nImgId += 20000;
+ ImageList aEntryImages( SW_RES(IMG_NAVI_ENTRYBMP) );
+ const Image& rImage = aEntryImages.GetImage( nImgId );
+ Bitmap aBitmap( rImage.GetBitmapEx().GetBitmap() );
+ Reference<awt::XBitmap> xBmp = VCLUnoHelper::CreateBitmap( aBitmap );
+ aRet.setValue( &xBmp, ::getCppuType((Reference<awt::XBitmap>*)0) );
+ }
+ return aRet;
+}
+
+Any SwXLinkNameAccessWrapper::getPropertyValue(const OUString& rPropertyName)
+ throw( UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception )
+{
+ Any aRet;
+ if( rPropertyName == UNO_LINK_DISPLAY_NAME )
+ {
+ aRet <<= OUString(sLinkDisplayName);
+ }
+ else if( rPropertyName == UNO_LINK_DISPLAY_BITMAP )
+ {
+ aRet = lcl_GetDisplayBitmap(sLinkSuffix);
+ }
+ else
+ throw UnknownPropertyException();
+ return aRet;
+}
+
+void SwXLinkNameAccessWrapper::addPropertyChangeListener(
+ const OUString& /*PropertyName*/, const Reference< XPropertyChangeListener > & /*aListener*/)
+ throw( UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception )
+{}
+
+void SwXLinkNameAccessWrapper::removePropertyChangeListener(
+ const OUString& /*PropertyName*/, const Reference< XPropertyChangeListener > & /*aListener*/)
+ throw( UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception )
+{}
+
+void SwXLinkNameAccessWrapper::addVetoableChangeListener(
+ const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener > & /*aListener*/)
+ throw( UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception )
+{}
+
+void SwXLinkNameAccessWrapper::removeVetoableChangeListener(
+ const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener > & /*aListener*/)
+ throw( UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception )
+{}
+
+Reference< XNameAccess > SwXLinkNameAccessWrapper::getLinks(void)
+ throw( RuntimeException, std::exception )
+{
+ return (SwXLinkNameAccessWrapper*)this;
+}
+
+OUString SwXLinkNameAccessWrapper::getImplementationName(void) throw( RuntimeException, std::exception )
+{
+ return OUString("SwXLinkNameAccessWrapper");
+}
+
+sal_Bool SwXLinkNameAccessWrapper::supportsService(const OUString& rServiceName)
+ throw( RuntimeException, std::exception )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+Sequence< OUString > SwXLinkNameAccessWrapper::getSupportedServiceNames(void)
+ throw( RuntimeException, std::exception )
+{
+ Sequence< OUString > aRet(1);
+ OUString* pNames = aRet.getArray();
+ pNames[0] = "com.sun.star.document.LinkTargets";
+ return aRet;
+}
+
+SwXOutlineTarget::SwXOutlineTarget(const OUString& rOutlineText) :
+ pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_LINK_TARGET)),
+ sOutlineText(rOutlineText)
+{
+}
+
+SwXOutlineTarget::~SwXOutlineTarget()
+{
+}
+
+Reference< XPropertySetInfo > SwXOutlineTarget::getPropertySetInfo(void) throw( RuntimeException, std::exception )
+{
+ static Reference< XPropertySetInfo > xRet = pPropSet->getPropertySetInfo();
+ return xRet;
+}
+
+void SwXOutlineTarget::setPropertyValue(
+ const OUString& /*PropertyName*/, const Any& /*aValue*/)
+ throw( UnknownPropertyException, PropertyVetoException,
+ IllegalArgumentException, WrappedTargetException, RuntimeException, std::exception)
+{
+ throw UnknownPropertyException();
+}
+
+Any SwXOutlineTarget::getPropertyValue(const OUString& rPropertyName)
+ throw( UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception )
+{
+ Any aRet;
+ if(rPropertyName == UNO_LINK_DISPLAY_NAME)
+ aRet <<= OUString(sOutlineText);
+ else
+ throw UnknownPropertyException();
+ return aRet;
+}
+
+void SwXOutlineTarget::addPropertyChangeListener(
+ const OUString& /*PropertyName*/, const Reference< XPropertyChangeListener > & /*aListener*/)
+ throw( UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception )
+{
+}
+
+void SwXOutlineTarget::removePropertyChangeListener(
+ const OUString& /*PropertyName*/, const Reference< XPropertyChangeListener > & /*aListener*/)
+ throw( UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception )
+{
+}
+
+void SwXOutlineTarget::addVetoableChangeListener(
+ const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener > & /*aListener*/)
+ throw( UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception )
+{
+}
+
+void SwXOutlineTarget::removeVetoableChangeListener(
+ const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener > & /*aListener*/)
+ throw( UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception )
+{
+}
+
+OUString SwXOutlineTarget::getImplementationName(void) throw( RuntimeException, std::exception )
+{
+ return OUString("SwXOutlineTarget");
+}
+
+sal_Bool SwXOutlineTarget::supportsService(const OUString& ServiceName) throw( RuntimeException, std::exception )
+{
+ return cppu::supportsService(this, ServiceName);
+}
+
+Sequence< OUString > SwXOutlineTarget::getSupportedServiceNames(void) throw( RuntimeException, std::exception )
+{
+ Sequence < OUString > aRet(1);
+ OUString* pArray = aRet.getArray();
+ pArray[0] = "com.sun.star.document.LinkTarget";
+
+ return aRet;
+}
+
+SwXDocumentPropertyHelper::SwXDocumentPropertyHelper(SwDoc& rDoc) :
+SvxUnoForbiddenCharsTable ( rDoc.getForbiddenCharacterTable() )
+,m_pDoc(&rDoc)
+{
+}
+
+SwXDocumentPropertyHelper::~SwXDocumentPropertyHelper()
+{
+}
+
+Reference<XInterface> SwXDocumentPropertyHelper::GetDrawTable(short nWhich)
+{
+ Reference<XInterface> xRet;
+ if(m_pDoc)
+ {
+ switch(nWhich)
+ {
+ // #i52858#
+ // assure that Draw model is created, if it doesn't exist.
+ case SW_CREATE_DASH_TABLE :
+ if(!xDashTable.is())
+ xDashTable = SvxUnoDashTable_createInstance( m_pDoc->GetOrCreateDrawModel() );
+ xRet = xDashTable;
+ break;
+ case SW_CREATE_GRADIENT_TABLE :
+ if(!xGradientTable.is())
+ xGradientTable = SvxUnoGradientTable_createInstance( m_pDoc->GetOrCreateDrawModel() );
+ xRet = xGradientTable;
+ break;
+ case SW_CREATE_HATCH_TABLE :
+ if(!xHatchTable.is())
+ xHatchTable = SvxUnoHatchTable_createInstance( m_pDoc->GetOrCreateDrawModel() );
+ xRet = xHatchTable;
+ break;
+ case SW_CREATE_BITMAP_TABLE :
+ if(!xBitmapTable.is())
+ xBitmapTable = SvxUnoBitmapTable_createInstance( m_pDoc->GetOrCreateDrawModel() );
+ xRet = xBitmapTable;
+ break;
+ case SW_CREATE_TRANSGRADIENT_TABLE:
+ if(!xTransGradientTable.is())
+ xTransGradientTable = SvxUnoTransGradientTable_createInstance( m_pDoc->GetOrCreateDrawModel() );
+ xRet = xTransGradientTable;
+ break;
+ case SW_CREATE_MARKER_TABLE :
+ if(!xMarkerTable.is())
+ xMarkerTable = SvxUnoMarkerTable_createInstance( m_pDoc->GetOrCreateDrawModel() );
+ xRet = xMarkerTable;
+ break;
+ case SW_CREATE_DRAW_DEFAULTS:
+ if(!xDrawDefaults.is())
+ xDrawDefaults = (cppu::OWeakObject*)new SwSvxUnoDrawPool(m_pDoc);
+ xRet = xDrawDefaults;
+ break;
+#if OSL_DEBUG_LEVEL > 0
+ default: OSL_FAIL("which table?");
+#endif
+ }
+ }
+ return xRet;
+}
+
+void SwXDocumentPropertyHelper::Invalidate()
+{
+ xDashTable = 0;
+ xGradientTable = 0;
+ xHatchTable = 0;
+ xBitmapTable = 0;
+ xTransGradientTable = 0;
+ xMarkerTable = 0;
+ xDrawDefaults = 0;
+ m_pDoc = 0;
+ SvxUnoForbiddenCharsTable::mxForbiddenChars.clear();
+}
+
+void SwXDocumentPropertyHelper::onChange()
+{
+ if(m_pDoc)
+ m_pDoc->SetModified();
+}
+
+SwViewOptionAdjust_Impl::SwViewOptionAdjust_Impl(
+ SwViewShell& rSh, const SwViewOption &rViewOptions)
+ : m_pShell(&rSh)
+ , m_aOldViewOptions( rViewOptions )
+{
+}
+
+SwViewOptionAdjust_Impl::~SwViewOptionAdjust_Impl()
+{
+ if (m_pShell)
+ {
+ m_pShell->ApplyViewOptions( m_aOldViewOptions );
+ }
+}
+
+void
+SwViewOptionAdjust_Impl::AdjustViewOptions(SwPrintData const*const pPrtOptions)
+{
+ // to avoid unnecessary reformatting the view options related to the content
+ // below should only change if necessary, that is if respective content is present
+ const bool bContainsHiddenChars = m_pShell->GetDoc()->ContainsHiddenChars();
+ const SwFieldType* pFldType = m_pShell->GetDoc()->GetSysFldType( RES_HIDDENTXTFLD );
+ const bool bContainsHiddenFields = pFldType && pFldType->GetDepends();
+ pFldType = m_pShell->GetDoc()->GetSysFldType( RES_HIDDENPARAFLD );
+ const bool bContainsHiddenParagraphs = pFldType && pFldType->GetDepends();
+ pFldType = m_pShell->GetDoc()->GetSysFldType( RES_JUMPEDITFLD );
+ const bool bContainsPlaceHolders = pFldType && pFldType->GetDepends();
+ const bool bContainsFields = m_pShell->IsAnyFieldInDoc();
+
+ SwViewOption aRenderViewOptions( m_aOldViewOptions );
+
+ // disable anything in the view that should not be printed (or exported to PDF) by default
+ // (see also dialog "Tools/Options - StarOffice Writer - Formatting Aids"
+ // in section "Display of ...")
+ aRenderViewOptions.SetParagraph( sal_False ); // paragraph end
+ aRenderViewOptions.SetSoftHyph( sal_False ); // aka custom hyphens
+ aRenderViewOptions.SetBlank( sal_False ); // spaces
+ aRenderViewOptions.SetHardBlank( sal_False ); // non-breaking spaces
+ aRenderViewOptions.SetTab( sal_False ); // tabs
+ aRenderViewOptions.SetLineBreak( sal_False ); // breaks (type 1)
+ aRenderViewOptions.SetPageBreak( sal_False ); // breaks (type 2)
+ aRenderViewOptions.SetColumnBreak( sal_False ); // breaks (type 3)
+ sal_Bool bVal = pPrtOptions? pPrtOptions->bPrintHiddenText : sal_False;
+ if (bContainsHiddenChars)
+ aRenderViewOptions.SetShowHiddenChar( bVal ); // hidden text
+ if (bContainsHiddenFields)
+ aRenderViewOptions.SetShowHiddenField( bVal );
+ if (bContainsHiddenParagraphs)
+ aRenderViewOptions.SetShowHiddenPara( bVal );
+
+ if (bContainsPlaceHolders)
+ {
+ // should always be printed in PDF export!
+ bVal = pPrtOptions ? pPrtOptions->bPrintTextPlaceholder : sal_True;
+ aRenderViewOptions.SetShowPlaceHolderFields( bVal );
+ }
+
+ if (bContainsFields)
+ aRenderViewOptions.SetFldName( sal_False );
+
+ // we need to set this flag in order to get to see the visible effect of
+ // some of the above settings (needed for correct rendering)
+ aRenderViewOptions.SetViewMetaChars( sal_True );
+
+ if (m_aOldViewOptions != aRenderViewOptions) // check if reformatting is necessary
+ {
+ aRenderViewOptions.SetPrinting( pPrtOptions != NULL );
+ m_pShell->ApplyViewOptions( aRenderViewOptions );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/uno/unotxvw.cxx b/sw/source/core/uibase/uno/unotxvw.cxx
new file mode 100644
index 000000000000..c7e9c4ee4883
--- /dev/null
+++ b/sw/source/core/uibase/uno/unotxvw.cxx
@@ -0,0 +1,1851 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "viscrs.hxx"
+#include <sfx2/frame.hxx>
+#include <sfx2/printer.hxx>
+#include <cmdid.h>
+#include <hintids.hxx>
+#include <docsh.hxx>
+#include <rubylist.hxx>
+#include <doc.hxx>
+#include <unotxvw.hxx>
+#include <unodispatch.hxx>
+#include <unomap.hxx>
+#include <unostyle.hxx>
+#include <unoprnms.hxx>
+#include <view.hxx>
+#include <viewopt.hxx>
+#include <unomod.hxx>
+#include <unoframe.hxx>
+#include <unocrsr.hxx>
+#include <wrtsh.hxx>
+#include <unotbl.hxx>
+#include <svx/fmshell.hxx>
+#include <svx/svdview.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdouno.hxx>
+#include <svx/svdogrp.hxx>
+#include <editeng/pbinitem.hxx>
+#include <pagedesc.hxx>
+#include <editeng/lrspitem.hxx>
+#include <editeng/ulspitem.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/request.hxx>
+#include <frmatr.hxx>
+#include <osl/mutex.hxx>
+#include <IMark.hxx>
+#include <unotxdoc.hxx>
+#include <unodraw.hxx>
+#include <svx/unoshape.hxx>
+#include <svx/svdpagv.hxx>
+#include <swerror.h>
+#include <shellio.hxx>
+#include <ndtxt.hxx>
+#include <SwStyleNameMapper.hxx>
+#include <crsskip.hxx>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/drawing/ShapeCollection.hpp>
+#include <editeng/outliner.hxx>
+#include <editeng/editview.hxx>
+#include <unoparagraph.hxx>
+#include <unocrsrhelper.hxx>
+#include <unotextrange.hxx>
+#include <sfx2/docfile.hxx>
+#include <switerator.hxx>
+#include "swdtflvr.hxx"
+#include <vcl/svapp.hxx>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/servicehelper.hxx>
+#include <cppuhelper/supportsservice.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::text;
+using namespace ::com::sun::star::view;
+using namespace ::com::sun::star::frame;
+
+using ::com::sun::star::util::URL;
+using comphelper::HelperBaseNoState;
+
+SwXTextView::SwXTextView(SwView* pSwView) :
+ SfxBaseController(pSwView),
+ m_SelChangedListeners(m_aMutex),
+ m_pView(pSwView),
+ m_pPropSet( aSwMapProvider.GetPropertySet( PROPERTY_MAP_TEXT_VIEW ) ),
+ pxViewSettings(0),
+ pxTextViewCursor(0)
+{
+
+}
+
+SwXTextView::~SwXTextView()
+{
+ Invalidate();
+}
+
+void SwXTextView::Invalidate()
+{
+ if(pxViewSettings)
+ {
+ HelperBaseNoState *pSettings = static_cast < HelperBaseNoState * > ( pxViewSettings->get() );
+ static_cast < SwXViewSettings* > ( pSettings )->Invalidate();
+ DELETEZ(pxViewSettings);
+ }
+ if(pxTextViewCursor)
+ {
+ text::XTextViewCursor* pCrsr = pxTextViewCursor->get();
+ ((SwXTextViewCursor*)pCrsr)->Invalidate();
+ DELETEZ(pxTextViewCursor);
+ }
+
+ m_refCount++; //prevent second d'tor call
+
+ {
+ uno::Reference<uno::XInterface> const xInt(static_cast<
+ cppu::OWeakObject*>(static_cast<SfxBaseController*>(this)));
+ lang::EventObject aEvent(xInt);
+ m_SelChangedListeners.disposeAndClear(aEvent);
+ }
+
+ m_refCount--;
+ m_pView = 0;
+}
+
+Sequence< uno::Type > SAL_CALL SwXTextView::getTypes( ) throw(uno::RuntimeException, std::exception)
+{
+ uno::Sequence< uno::Type > aBaseTypes = SfxBaseController::getTypes();
+
+ long nIndex = aBaseTypes.getLength();
+ aBaseTypes.realloc(
+ aBaseTypes.getLength() + 8 );
+
+ uno::Type* pBaseTypes = aBaseTypes.getArray();
+ pBaseTypes[nIndex++] = ::getCppuType((uno::Reference<XSelectionSupplier >*)0);
+ pBaseTypes[nIndex++] = ::getCppuType((uno::Reference<XServiceInfo >*)0);
+ pBaseTypes[nIndex++] = ::getCppuType((uno::Reference<XFormLayerAccess >*)0);
+ pBaseTypes[nIndex++] = ::getCppuType((uno::Reference<XTextViewCursorSupplier>*)0);
+ pBaseTypes[nIndex++] = ::getCppuType((uno::Reference<XViewSettingsSupplier >*)0);
+ pBaseTypes[nIndex++] = ::getCppuType((uno::Reference<XRubySelection >*)0);
+ pBaseTypes[nIndex++] = ::getCppuType((uno::Reference<XPropertySet >*)0);
+ pBaseTypes[nIndex++] = ::getCppuType((uno::Reference<datatransfer::XTransferableSupplier >*)0);
+ return aBaseTypes;
+}
+
+namespace
+{
+ class theSwXTextViewImplementationId : public rtl::Static< UnoTunnelIdInit, theSwXTextViewImplementationId > {};
+}
+
+Sequence< sal_Int8 > SAL_CALL SwXTextView::getImplementationId( ) throw(uno::RuntimeException, std::exception)
+{
+ return theSwXTextViewImplementationId::get().getSeq();
+}
+
+void SAL_CALL SwXTextView::acquire( )throw()
+{
+ SfxBaseController::acquire();
+}
+
+void SAL_CALL SwXTextView::release( )throw()
+{
+ SfxBaseController::release();
+}
+
+uno::Any SAL_CALL SwXTextView::queryInterface( const uno::Type& aType )
+ throw (RuntimeException, std::exception)
+{
+ uno::Any aRet;
+ if(aType == ::getCppuType((uno::Reference<view::XSelectionSupplier >*)0))
+ {
+ uno::Reference<view::XSelectionSupplier> xRet = this;
+ aRet.setValue(&xRet, aType);
+ }
+ else if(aType == ::getCppuType((uno::Reference<lang::XServiceInfo >*)0))
+ {
+ uno::Reference<lang::XServiceInfo> xRet = this;
+ aRet.setValue(&xRet, aType);
+ }
+ else if(aType == ::getCppuType((uno::Reference<view::XControlAccess >*)0))
+ {
+ uno::Reference<view::XControlAccess> xRet = this;
+ aRet.setValue(&xRet, aType);
+ }
+ else if(aType == ::getCppuType((uno::Reference<view::XFormLayerAccess >*)0))
+ {
+ uno::Reference<view::XFormLayerAccess> xRet = this;
+ aRet.setValue(&xRet, aType);
+ }
+ else if(aType == ::getCppuType((uno::Reference<text::XTextViewCursorSupplier>*)0))
+ {
+ uno::Reference<text::XTextViewCursorSupplier> xRet = this;
+ aRet.setValue(&xRet, aType);
+ }
+ else if(aType == ::getCppuType((uno::Reference<view::XViewSettingsSupplier >*)0))
+ {
+ uno::Reference<view::XViewSettingsSupplier> xRet = this;
+ aRet.setValue(&xRet, aType);
+ }
+ else if(aType == ::getCppuType((uno::Reference<XRubySelection>*)0))
+ {
+ uno::Reference<XRubySelection> xRet = this;
+ aRet.setValue(&xRet, aType);
+ }
+ else if(aType == ::getCppuType((uno::Reference<XPropertySet>*)0))
+ {
+ uno::Reference<XPropertySet> xRet = this;
+ aRet.setValue(&xRet, aType);
+ }
+ else if(aType == ::getCppuType((uno::Reference<datatransfer::XTransferableSupplier >*)0))
+ {
+ uno::Reference<datatransfer::XTransferableSupplier> xRet = this;
+ aRet.setValue(&xRet, aType);
+ }
+ else
+ aRet = SfxBaseController::queryInterface(aType);
+ return aRet;
+}
+
+sal_Bool SwXTextView::select(const uno::Any& aInterface)
+ throw (lang::IllegalArgumentException, uno::RuntimeException,
+ std::exception)
+{
+ SolarMutexGuard aGuard;
+
+ uno::Reference< uno::XInterface > xInterface;
+ if (!GetView() || !(aInterface >>= xInterface))
+ {
+ return sal_False;
+ }
+
+ SwWrtShell& rSh = GetView()->GetWrtShell();
+ SwDoc* pDoc = GetView()->GetDocShell()->GetDoc();
+ std::vector<SdrObject *> sdrObjects;
+ uno::Reference<awt::XControlModel> const xCtrlModel(xInterface,
+ UNO_QUERY);
+ if (xCtrlModel.is())
+ {
+ uno::Reference<awt::XControl> xControl;
+ SdrObject *const pSdrObject = GetControl(xCtrlModel, xControl);
+ if (pSdrObject) // hmm... needs view to verify it's in right doc...
+ {
+ sdrObjects.push_back(pSdrObject);
+ }
+ }
+ else
+ {
+ SwPaM * pPaM(0);
+ std::pair<OUString, FlyCntType> frame;
+ OUString tableName;
+ SwUnoTableCrsr const* pTableCursor(0);
+ ::sw::mark::IMark const* pMark(0);
+ SwUnoCursorHelper::GetSelectableFromAny(xInterface, *pDoc,
+ pPaM, frame, tableName, pTableCursor, pMark, sdrObjects);
+ if (pPaM)
+ {
+ rSh.EnterStdMode();
+ rSh.SetSelection(*pPaM);
+ // the pPaM has been copied - delete it
+ while (pPaM->GetNext() != pPaM)
+ delete pPaM->GetNext();
+ delete pPaM;
+ return sal_True;
+ }
+ else if (!frame.first.isEmpty())
+ {
+ bool const bSuccess(rSh.GotoFly(frame.first, frame.second));
+ if (bSuccess)
+ {
+ rSh.HideCrsr();
+ rSh.EnterSelFrmMode();
+ }
+ return sal_True;
+ }
+ else if (!tableName.isEmpty())
+ {
+ rSh.EnterStdMode();
+ rSh.GotoTable(tableName);
+ return sal_True;
+ }
+ else if (pTableCursor)
+ {
+ UnoActionRemoveContext const aContext(pDoc);
+ rSh.EnterStdMode();
+ rSh.SetSelection(*pTableCursor);
+ return sal_True;
+ }
+ else if (pMark)
+ {
+ rSh.EnterStdMode();
+ rSh.GotoMark(pMark);
+ return sal_True;
+ }
+ // sdrObjects handled below
+ }
+ sal_Bool bRet(sal_False);
+ if (sdrObjects.size())
+ {
+
+ SdrView *const pDrawView = rSh.GetDrawView();
+ SdrPageView *const pPV = pDrawView->GetSdrPageView();
+
+ pDrawView->SdrEndTextEdit();
+ pDrawView->UnmarkAll();
+
+ for (size_t i = 0; i < sdrObjects.size(); ++i)
+ {
+ SdrObject *const pSdrObject(sdrObjects[i]);
+ // GetSelectableFromAny did not check pSdrObject is in right doc!
+ if (pPV && pSdrObject->GetPage() == pPV->GetPage())
+ {
+ pDrawView->MarkObj(pSdrObject, pPV);
+ bRet = sal_True;
+ }
+ }
+ }
+ return bRet;
+}
+
+uno::Any SwXTextView::getSelection()
+ throw (uno::RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference< uno::XInterface > aRef;
+ if(GetView())
+ {
+ //force immediat shell update
+ m_pView->StopShellTimer();
+ //Generating an interface from the current selection.
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ ShellModes eSelMode = m_pView->GetShellMode();
+ switch(eSelMode)
+ {
+ case SHELL_MODE_TABLE_TEXT :
+ {
+ if(rSh.GetTableCrsr())
+ {
+ OSL_ENSURE(rSh.GetTableFmt(), "not a table format?");
+ uno::Reference< text::XTextTableCursor > xCrsr = new SwXTextTableCursor(*rSh.GetTableFmt(),
+ rSh.GetTableCrsr());
+ aRef = uno::Reference< uno::XInterface > (xCrsr, uno::UNO_QUERY);
+ break;
+ }
+
+ }
+ //Without a table selection the text will be delivered.
+ //break;
+ case SHELL_MODE_LIST_TEXT :
+ case SHELL_MODE_TABLE_LIST_TEXT:
+ case SHELL_MODE_TEXT :
+ {
+ uno::Reference< container::XIndexAccess > xPos = new SwXTextRanges(rSh.GetCrsr());
+ aRef = uno::Reference< uno::XInterface >(xPos, uno::UNO_QUERY);
+ }
+ break;
+ case SHELL_MODE_FRAME :
+ case SHELL_MODE_GRAPHIC :
+ case SHELL_MODE_OBJECT :
+ {
+ //Get FlyFrameFormat; for UI-Macro connection to flys
+ const SwFrmFmt* pFmt = rSh.GetFlyFrmFmt();
+ if (pFmt)
+ {
+ SwXFrame* pxFrame = SwIterator<SwXFrame,SwFmt>::FirstElement(*pFmt);
+ if(pxFrame) //The only common interface for all frames.
+ {
+ aRef = uno::Reference< uno::XInterface >((cppu::OWeakObject*)pxFrame, uno::UNO_QUERY);
+ }
+ else
+ {
+ if(SHELL_MODE_FRAME == eSelMode)
+ {
+ uno::Reference< text::XTextFrame > xFrm = new SwXTextFrame((SwFrmFmt&)*pFmt);
+ aRef = uno::Reference< uno::XInterface >(xFrm, uno::UNO_QUERY);
+ }
+ else if(SHELL_MODE_GRAPHIC == eSelMode)
+ {
+ uno::Reference< text::XTextContent > xFrm = new SwXTextGraphicObject((SwFrmFmt&)*pFmt);
+ aRef = xFrm;
+ }
+ else
+ {
+ uno::Reference< text::XTextContent > xFrm = new SwXTextEmbeddedObject((SwFrmFmt&)*pFmt);
+ aRef = xFrm;
+ }
+ }
+ }
+ }
+ break;
+ case SHELL_MODE_DRAW :
+ case SHELL_MODE_DRAW_CTRL :
+ case SHELL_MODE_DRAW_FORM :
+ case SHELL_MODE_DRAWTEXT :
+ case SHELL_MODE_BEZIER :
+ {
+ uno::Reference< drawing::XDrawPageSupplier > xPageSupp;
+ uno::Reference< frame::XModel > xModel = m_pView->GetDocShell()->GetBaseModel();
+ uno::Reference< lang::XUnoTunnel > xModelTunnel(xModel, uno::UNO_QUERY);
+ SwXTextDocument* pTextDoc = reinterpret_cast<SwXTextDocument*>(xModelTunnel->
+ getSomething(SwXTextDocument::getUnoTunnelId()));
+
+ SwFmDrawPage* pSvxDrawPage = pTextDoc->GetDrawPage()->GetSvxPage();
+ uno::Reference< drawing::XShapes > xShCol = drawing::ShapeCollection::create(
+ comphelper::getProcessComponentContext());
+
+ const SdrMarkList& rMarkList = rSh.GetDrawView()->GetMarkedObjectList();
+ for(sal_uInt16 i = 0; i < rMarkList.GetMarkCount(); i++)
+ {
+ SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
+ uno::Reference< uno::XInterface > xInt = pSvxDrawPage->GetInterface( pObj );
+ uno::Reference< drawing::XShape > xShape(xInt, uno::UNO_QUERY);
+ xShCol->add(xShape);
+ }
+ aRef = uno::Reference< uno::XInterface >(xShCol, uno::UNO_QUERY);
+ }
+ break;
+ default:;//prevent warning
+ }
+ }
+ uno::Any aRet(&aRef, ::getCppuType((uno::Reference<uno::XInterface>*)0));
+ return aRet;
+}
+
+void SwXTextView::addSelectionChangeListener(
+ const uno::Reference< view::XSelectionChangeListener > & rxListener)
+ throw( uno::RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ m_SelChangedListeners.addInterface(rxListener);
+}
+
+void SwXTextView::removeSelectionChangeListener(
+ const uno::Reference< view::XSelectionChangeListener > & rxListener)
+ throw( uno::RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ m_SelChangedListeners.removeInterface(rxListener);
+}
+
+SdrObject* SwXTextView::GetControl(
+ const uno::Reference< awt::XControlModel > & xModel,
+ uno::Reference< awt::XControl >& xToFill )
+{
+ SwView* pView2 = GetView();
+ FmFormShell* pFormShell = pView2 ? pView2->GetFormShell() : NULL;
+ SdrView* pDrawView = pView2 ? pView2->GetDrawView() : NULL;
+ Window* pWindow = pView2 ? pView2->GetWrtShell().GetWin() : NULL;
+
+ OSL_ENSURE( pFormShell && pDrawView && pWindow, "SwXTextView::GetControl: how could I?" );
+
+ SdrObject* pControl = NULL;
+ if ( pFormShell && pDrawView && pWindow )
+ pControl = pFormShell->GetFormControl( xModel, *pDrawView, *pWindow, xToFill );
+ return pControl;
+}
+
+uno::Reference< awt::XControl > SwXTextView::getControl(const uno::Reference< awt::XControlModel > & xModel)
+ throw( container::NoSuchElementException, uno::RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ uno::Reference< awt::XControl > xRet;
+ GetControl(xModel, xRet);
+ return xRet;
+}
+
+uno::Reference< form::runtime::XFormController > SAL_CALL SwXTextView::getFormController( const uno::Reference< form::XForm >& _Form ) throw (RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+
+ SwView* pView2 = GetView();
+ FmFormShell* pFormShell = pView2 ? pView2->GetFormShell() : NULL;
+ SdrView* pDrawView = pView2 ? pView2->GetDrawView() : NULL;
+ Window* pWindow = pView2 ? pView2->GetWrtShell().GetWin() : NULL;
+ OSL_ENSURE( pFormShell && pDrawView && pWindow, "SwXTextView::getFormController: how could I?" );
+
+ uno::Reference< form::runtime::XFormController > xController;
+ if ( pFormShell && pDrawView && pWindow )
+ xController = pFormShell->GetFormController( _Form, *pDrawView, *pWindow );
+ return xController;
+}
+
+::sal_Bool SAL_CALL SwXTextView::isFormDesignMode( ) throw (uno::RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ SwView* pView2 = GetView();
+ FmFormShell* pFormShell = pView2 ? pView2->GetFormShell() : NULL;
+ return pFormShell ? pFormShell->IsDesignMode() : sal_True;
+}
+
+void SAL_CALL SwXTextView::setFormDesignMode( ::sal_Bool _DesignMode ) throw (RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ SwView* pView2 = GetView();
+ FmFormShell* pFormShell = pView2 ? pView2->GetFormShell() : NULL;
+ if ( pFormShell )
+ pFormShell->SetDesignMode( _DesignMode );
+}
+
+uno::Reference< text::XTextViewCursor > SwXTextView::getViewCursor(void) throw( uno::RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ if(GetView())
+ {
+ if(!pxTextViewCursor)
+ {
+ ((SwXTextView*)this)->pxTextViewCursor = new uno::Reference< text::XTextViewCursor > ;
+ *pxTextViewCursor = new SwXTextViewCursor(GetView());
+ }
+ return *pxTextViewCursor;
+ }
+ else
+ throw uno::RuntimeException();
+}
+
+uno::Reference< beans::XPropertySet > SwXTextView::getViewSettings(void) throw( uno::RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ if(m_pView)
+ {
+ if(!pxViewSettings)
+ {
+ ((SwXTextView*)this)->pxViewSettings = new uno::Reference< beans::XPropertySet > ;
+ *pxViewSettings = static_cast < HelperBaseNoState * > ( new SwXViewSettings( sal_False, m_pView ) );
+ }
+ }
+ else
+ throw uno::RuntimeException();
+ return *pxViewSettings;
+}
+
+Sequence< Sequence< PropertyValue > > SwXTextView::getRubyList( sal_Bool /*bAutomatic*/ )
+ throw (RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+
+ if(!GetView())
+ throw RuntimeException();
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ ShellModes eSelMode = m_pView->GetShellMode();
+ if (eSelMode != SHELL_MODE_LIST_TEXT &&
+ eSelMode != SHELL_MODE_TABLE_LIST_TEXT &&
+ eSelMode != SHELL_MODE_TABLE_TEXT &&
+ eSelMode != SHELL_MODE_TEXT )
+ return Sequence< Sequence< PropertyValue > > ();
+
+ SwDoc* pDoc = m_pView->GetDocShell()->GetDoc();
+ SwRubyList aList;
+
+ sal_uInt16 nCount = pDoc->FillRubyList( *rSh.GetCrsr(), aList, 0 );
+ Sequence< Sequence< PropertyValue > > aRet(nCount);
+ Sequence< PropertyValue >* pRet = aRet.getArray();
+ OUString aString;
+ for(sal_uInt16 n = 0; n < nCount; n++)
+ {
+ const SwRubyListEntry* pEntry = &aList[n];
+
+ const OUString& rEntryText = pEntry->GetText();
+ const SwFmtRuby& rAttr = pEntry->GetRubyAttr();
+
+ pRet[n].realloc(5);
+ PropertyValue* pValues = pRet[n].getArray();
+ pValues[0].Name = UNO_NAME_RUBY_BASE_TEXT;
+ pValues[0].Value <<= OUString(rEntryText);
+ pValues[1].Name = UNO_NAME_RUBY_TEXT;
+ pValues[1].Value <<= OUString(rAttr.GetText());
+ pValues[2].Name = UNO_NAME_RUBY_CHAR_STYLE_NAME;
+ SwStyleNameMapper::FillProgName(rAttr.GetCharFmtName(), aString, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, true );
+ pValues[2].Value <<= aString;
+ pValues[3].Name = UNO_NAME_RUBY_ADJUST;
+ pValues[3].Value <<= (sal_Int16)rAttr.GetAdjustment();
+ pValues[4].Name = UNO_NAME_RUBY_IS_ABOVE;
+ sal_Bool bVal = !rAttr.GetPosition();
+ pValues[4].Value.setValue(&bVal, ::getBooleanCppuType());
+ }
+ return aRet;
+}
+
+void SAL_CALL SwXTextView::setRubyList(
+ const Sequence< Sequence< PropertyValue > >& rRubyList, sal_Bool /*bAutomatic*/ )
+ throw (RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+
+ if(!GetView() || !rRubyList.getLength())
+ throw RuntimeException();
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ ShellModes eSelMode = m_pView->GetShellMode();
+ if (eSelMode != SHELL_MODE_LIST_TEXT &&
+ eSelMode != SHELL_MODE_TABLE_LIST_TEXT &&
+ eSelMode != SHELL_MODE_TABLE_TEXT &&
+ eSelMode != SHELL_MODE_TEXT )
+ throw RuntimeException();
+
+ SwRubyList aList;
+
+ const Sequence<PropertyValue>* pRubyList = rRubyList.getConstArray();
+ for(sal_Int32 nPos = 0; nPos < rRubyList.getLength(); nPos++)
+ {
+ SwRubyListEntry* pEntry = new SwRubyListEntry;
+ const PropertyValue* pProperties = pRubyList[nPos].getConstArray();
+ OUString sTmp;
+ for(sal_Int32 nProp = 0; nProp < pRubyList[nPos].getLength(); nProp++)
+ {
+ if(pProperties[nProp].Name == UNO_NAME_RUBY_BASE_TEXT)
+ {
+ pProperties[nProp].Value >>= sTmp;
+ pEntry->SetText(sTmp);
+ }
+ else if(pProperties[nProp].Name == UNO_NAME_RUBY_TEXT)
+ {
+ pProperties[nProp].Value >>= sTmp;
+ pEntry->GetRubyAttr().SetText(sTmp);
+ }
+ else if(pProperties[nProp].Name == UNO_NAME_RUBY_CHAR_STYLE_NAME)
+ {
+ if((pProperties[nProp].Value >>= sTmp))
+ {
+ OUString sName;
+ SwStyleNameMapper::FillUIName(sTmp, sName, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, true );
+ sal_uInt16 nPoolId = sName.isEmpty() ? 0
+ : SwStyleNameMapper::GetPoolIdFromUIName(sName,
+ nsSwGetPoolIdFromName::GET_POOLID_CHRFMT );
+
+ pEntry->GetRubyAttr().SetCharFmtName( sName );
+ pEntry->GetRubyAttr().SetCharFmtId( nPoolId );
+ }
+ }
+ else if(pProperties[nProp].Name == UNO_NAME_RUBY_ADJUST)
+ {
+ sal_Int16 nTmp = 0;
+ if((pProperties[nProp].Value >>= nTmp))
+ pEntry->GetRubyAttr().SetAdjustment(nTmp);
+ }
+ else if(pProperties[nProp].Name == UNO_NAME_RUBY_IS_ABOVE)
+ {
+ sal_Bool bValue = pProperties[nProp].Value.hasValue() ?
+ *(sal_Bool*)pProperties[nProp].Value.getValue() : sal_True;
+ pEntry->GetRubyAttr().SetPosition(bValue ? 0 : 1);
+ }
+ }
+ aList.insert(aList.begin() + nPos, pEntry);
+ }
+ SwDoc* pDoc = m_pView->GetDocShell()->GetDoc();
+ pDoc->SetRubyList( *rSh.GetCrsr(), aList, 0 );
+}
+
+SfxObjectShellLock SwXTextView::BuildTmpSelectionDoc()
+{
+ SwWrtShell& rOldSh = m_pView->GetWrtShell();
+ SfxPrinter *pPrt = rOldSh.getIDocumentDeviceAccess()->getPrinter( false );
+ SwDocShell* pDocSh;
+ SfxObjectShellLock xDocSh( pDocSh = new SwDocShell( /*pPrtDoc, */SFX_CREATE_MODE_STANDARD ) );
+ xDocSh->DoInitNew( 0 );
+ SwDoc *const pTempDoc( pDocSh->GetDoc() );
+ // #i103634#, #i112425#: do not expand numbering and fields on PDF export
+ pTempDoc->SetClipBoard(true);
+ rOldSh.FillPrtDoc(pTempDoc, pPrt);
+ SfxViewFrame* pDocFrame = SfxViewFrame::LoadHiddenDocument( *xDocSh, 0 );
+ SwView* pDocView = (SwView*) pDocFrame->GetViewShell();
+ pDocView->AttrChangedNotify( &pDocView->GetWrtShell() );//So that SelectShell is called.
+ SwWrtShell* pSh = pDocView->GetWrtShellPtr();
+
+ IDocumentDeviceAccess* pIDDA = pSh->getIDocumentDeviceAccess();
+ SfxPrinter* pTempPrinter = pIDDA->getPrinter( true );
+
+ const SwPageDesc& rCurPageDesc = rOldSh.GetPageDesc(rOldSh.GetCurPageDesc());
+
+ IDocumentDeviceAccess* pIDDA_old = rOldSh.getIDocumentDeviceAccess();
+
+ if( pIDDA_old->getPrinter( false ) )
+ {
+ pIDDA->setJobsetup( *pIDDA_old->getJobsetup() );
+ //#69563# if it isn't the same printer then the pointer has been invalidated!
+ pTempPrinter = pIDDA->getPrinter( true );
+ }
+
+ pTempPrinter->SetPaperBin(rCurPageDesc.GetMaster().GetPaperBin().GetValue());
+
+ return xDocSh;
+}
+
+void SwXTextView::NotifySelChanged()
+{
+ OSL_ENSURE( m_pView, "view is missing" );
+
+ uno::Reference<uno::XInterface> const xInt(
+ static_cast<cppu::OWeakObject*>(static_cast<SfxBaseController*>(this)));
+
+ lang::EventObject const aEvent(xInt);
+ m_SelChangedListeners.notifyEach(
+ &view::XSelectionChangeListener::selectionChanged, aEvent);
+}
+
+namespace {
+ struct DispatchListener
+ {
+ URL const & m_rURL;
+ Sequence<PropertyValue> const& m_rSeq;
+ explicit DispatchListener(URL const& rURL,
+ Sequence<PropertyValue> const& rSeq)
+ : m_rURL(rURL), m_rSeq(rSeq) { }
+ void operator()(uno::Reference<XDispatch> const & xListener) const
+ {
+ xListener->dispatch(m_rURL, m_rSeq);
+ }
+ };
+}
+
+void SwXTextView::NotifyDBChanged()
+{
+ URL aURL;
+ aURL.Complete = OUString::createFromAscii(SwXDispatch::GetDBChangeURL());
+
+ m_SelChangedListeners.forEach<XDispatch>(
+ DispatchListener(aURL, Sequence<PropertyValue>(0)));
+}
+
+uno::Reference< beans::XPropertySetInfo > SAL_CALL SwXTextView::getPropertySetInfo( )
+ throw (uno::RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ static uno::Reference< XPropertySetInfo > aRef = m_pPropSet->getPropertySetInfo();
+ return aRef;
+}
+
+void SAL_CALL SwXTextView::setPropertyValue(
+ const OUString& rPropertyName, const uno::Any& rValue )
+ throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap().getByName( rPropertyName );
+ if (!pEntry)
+ throw UnknownPropertyException();
+ else if (pEntry->nFlags & PropertyAttribute::READONLY)
+ throw PropertyVetoException();
+ else
+ {
+ switch (pEntry->nWID)
+ {
+ case WID_IS_HIDE_SPELL_MARKS :
+ // deprecated #i91949
+ break;
+ case WID_IS_CONSTANT_SPELLCHECK :
+ {
+ sal_Bool bVal = sal_False;
+ const SwViewOption *pOpt = m_pView->GetWrtShell().GetViewOptions();
+ if (!pOpt || !(rValue >>= bVal))
+ throw RuntimeException();
+ SwViewOption aNewOpt( *pOpt );
+ if (pEntry->nWID == WID_IS_CONSTANT_SPELLCHECK)
+ aNewOpt.SetOnlineSpell(bVal);
+ m_pView->GetWrtShell().ApplyViewOptions( aNewOpt );
+ }
+ break;
+ default :
+ OSL_FAIL("unknown WID");
+ }
+ }
+}
+
+uno::Any SAL_CALL SwXTextView::getPropertyValue(
+ const OUString& rPropertyName )
+ throw (beans::UnknownPropertyException,
+ lang::WrappedTargetException,
+ uno::RuntimeException,
+ std::exception)
+{
+ SolarMutexGuard aGuard;
+
+ Any aRet;
+
+ const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap().getByName( rPropertyName );
+ if (!pEntry)
+ throw UnknownPropertyException();
+ else
+ {
+ sal_Int16 nWID = pEntry->nWID;
+ switch (nWID)
+ {
+ case WID_PAGE_COUNT :
+ case WID_LINE_COUNT :
+ {
+ // format document completely in order to get meaningful
+ // values for page count and line count
+ m_pView->GetWrtShell().CalcLayout();
+
+ sal_Int32 nCount = -1;
+ if (nWID == WID_PAGE_COUNT)
+ nCount = m_pView->GetWrtShell().GetPageCount();
+ else // WID_LINE_COUNT
+ nCount = m_pView->GetWrtShell().GetLineCount( sal_False /*of whole document*/ );
+ aRet <<= nCount;
+ }
+ break;
+ case WID_IS_HIDE_SPELL_MARKS :
+ // deprecated #i91949
+ break;
+ case WID_IS_CONSTANT_SPELLCHECK :
+ {
+ const SwViewOption *pOpt = m_pView->GetWrtShell().GetViewOptions();
+ if (!pOpt)
+ throw RuntimeException();
+ sal_uInt32 nFlag = VIEWOPT_1_ONLINESPELL;
+ sal_Bool bVal = 0 != (pOpt->GetCoreOptions() & nFlag);
+ aRet <<= bVal;
+ }
+ break;
+ default :
+ OSL_FAIL("unknown WID");
+ }
+ }
+
+ return aRet;
+}
+
+void SAL_CALL SwXTextView::addPropertyChangeListener(
+ const OUString& /*rPropertyName*/,
+ const uno::Reference< beans::XPropertyChangeListener >& /*rxListener*/ )
+ throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
+{
+ OSL_FAIL("not implemented");
+}
+
+void SAL_CALL SwXTextView::removePropertyChangeListener(
+ const OUString& /*rPropertyName*/,
+ const uno::Reference< beans::XPropertyChangeListener >& /*rxListener*/ )
+ throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
+{
+ OSL_FAIL("not implemented");
+}
+
+void SAL_CALL SwXTextView::addVetoableChangeListener(
+ const OUString& /*rPropertyName*/,
+ const uno::Reference< beans::XVetoableChangeListener >& /*rxListener*/ )
+ throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
+{
+ OSL_FAIL("not implemented");
+}
+
+void SAL_CALL SwXTextView::removeVetoableChangeListener(
+ const OUString& /*rPropertyName*/,
+ const uno::Reference< beans::XVetoableChangeListener >& /*rxListener*/ )
+ throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
+{
+ OSL_FAIL("not implemented");
+}
+
+OUString SwXTextView::getImplementationName(void) throw( RuntimeException, std::exception )
+{
+ return OUString("SwXTextView");
+}
+
+sal_Bool SwXTextView::supportsService(const OUString& rServiceName) throw( RuntimeException, std::exception )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+Sequence< OUString > SwXTextView::getSupportedServiceNames(void) throw( RuntimeException, std::exception )
+{
+ Sequence< OUString > aRet(2);
+ OUString* pArray = aRet.getArray();
+ pArray[0] = "com.sun.star.text.TextDocumentView";
+ pArray[1] = "com.sun.star.view.OfficeDocumentView";
+ return aRet;
+}
+
+SwXTextViewCursor::SwXTextViewCursor(SwView* pVw) :
+ m_pView(pVw),
+ m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR))
+{
+}
+
+SwXTextViewCursor::~SwXTextViewCursor()
+{
+}
+
+// used to determine if there is a text selction or not.
+// If there is no text selection the functions that need a working
+// cursor will be disabled (throw RuntimeException). This will be the case
+// for the following interfaces:
+// - XViewCursor
+// - XTextCursor
+// - XTextRange
+// - XLineCursor
+sal_Bool SwXTextViewCursor::IsTextSelection( sal_Bool bAllowTables ) const
+{
+
+ sal_Bool bRes = sal_False;
+ OSL_ENSURE(m_pView, "m_pView is NULL ???");
+ if(m_pView)
+ {
+ //! m_pView->GetShellMode() will only work after the shell
+ //! has already changed and thus can not be used here!
+ SelectionType eSelType = m_pView->GetWrtShell().GetSelectionType();
+ bRes = ( (nsSelectionType::SEL_TXT & eSelType) ||
+ (nsSelectionType::SEL_NUM & eSelType) ) &&
+ (!(nsSelectionType::SEL_TBL_CELLS & eSelType) || bAllowTables);
+ }
+ return bRes;
+}
+
+sal_Bool SwXTextViewCursor::isVisible(void) throw( uno::RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ OSL_FAIL("not implemented");
+ return sal_True;
+}
+
+void SwXTextViewCursor::setVisible(sal_Bool /*bVisible*/) throw( uno::RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ OSL_FAIL("not implemented");
+}
+
+awt::Point SwXTextViewCursor::getPosition(void) throw( uno::RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ awt::Point aRet;
+ if(m_pView)
+ {
+ const SwWrtShell& rSh = m_pView->GetWrtShell();
+ const SwRect aCharRect(rSh.GetCharRect());
+
+ const SwFrmFmt& rMaster = rSh.GetPageDesc( rSh.GetCurPageDesc() ).GetMaster();
+
+ const SvxULSpaceItem& rUL = rMaster.GetULSpace();
+ const long nY = aCharRect.Top() - (rUL.GetUpper() + DOCUMENTBORDER);
+ aRet.Y = TWIP_TO_MM100(nY);
+
+ const SvxLRSpaceItem& rLR = rMaster.GetLRSpace();
+ const long nX = aCharRect.Left() - (rLR.GetLeft() + DOCUMENTBORDER);
+ aRet.X = TWIP_TO_MM100(nX);
+ }
+ else
+ throw uno::RuntimeException();
+ return aRet;
+}
+
+void SwXTextViewCursor::collapseToStart()
+ throw(uno::RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ if(m_pView)
+ {
+ if (!IsTextSelection())
+ throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) );
+
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ if(rSh.HasSelection())
+ {
+ SwPaM* pShellCrsr = rSh.GetCrsr();
+ if(*pShellCrsr->GetPoint() > *pShellCrsr->GetMark())
+ pShellCrsr->Exchange();
+ pShellCrsr->DeleteMark();
+ rSh.EnterStdMode();
+ rSh.SetSelection(*pShellCrsr);
+ }
+ }
+ else
+ throw uno::RuntimeException();
+}
+
+void SwXTextViewCursor::collapseToEnd()
+ throw (uno::RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ if(m_pView)
+ {
+ if (!IsTextSelection())
+ throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) );
+
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ if(rSh.HasSelection())
+ {
+ SwPaM* pShellCrsr = rSh.GetCrsr();
+ if(*pShellCrsr->GetPoint() < *pShellCrsr->GetMark())
+ pShellCrsr->Exchange();
+ pShellCrsr->DeleteMark();
+ rSh.EnterStdMode();
+ rSh.SetSelection(*pShellCrsr);
+ }
+ }
+ else
+ throw uno::RuntimeException();
+}
+
+sal_Bool SwXTextViewCursor::isCollapsed()
+ throw (uno::RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ sal_Bool bRet = sal_False;
+ if(m_pView)
+ {
+ if (!IsTextSelection())
+ throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) );
+
+ const SwWrtShell& rSh = m_pView->GetWrtShell();
+ bRet = !rSh.HasSelection();
+ }
+ else
+ throw uno::RuntimeException();
+ return bRet;
+
+}
+
+sal_Bool SwXTextViewCursor::goLeft(sal_Int16 nCount, sal_Bool bExpand)
+ throw (uno::RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ sal_Bool bRet = sal_False;
+ if(m_pView)
+ {
+ if (!IsTextSelection())
+ throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) );
+
+ for( sal_uInt16 i = 0; i < nCount; i++ )
+ bRet = m_pView->GetWrtShell().Left( CRSR_SKIP_CHARS, bExpand, 1, sal_True );
+ }
+ else
+ throw uno::RuntimeException();
+ return bRet;
+}
+
+sal_Bool SwXTextViewCursor::goRight(sal_Int16 nCount, sal_Bool bExpand)
+ throw (uno::RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ sal_Bool bRet = sal_False;
+ if(m_pView)
+ {
+ if (!IsTextSelection())
+ throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) );
+
+ for( sal_uInt16 i = 0; i < nCount; i++ )
+ bRet = m_pView->GetWrtShell().Right( CRSR_SKIP_CHARS, bExpand, 1, sal_True );
+ }
+ else
+ throw uno::RuntimeException();
+ return bRet;
+
+}
+
+void SwXTextViewCursor::gotoRange(
+ const uno::Reference< text::XTextRange > & xRange,
+ sal_Bool bExpand)
+ throw (RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ if(m_pView && xRange.is())
+ {
+ if (!IsTextSelection())
+ throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) );
+
+ SwUnoInternalPaM rDestPam(*m_pView->GetDocShell()->GetDoc());
+ if (!::sw::XTextRangeToSwPaM(rDestPam, xRange))
+ {
+ throw uno::RuntimeException();
+ }
+
+ ShellModes eSelMode = m_pView->GetShellMode();
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ // call EnterStdMode in non-text selections only
+ if(!bExpand ||
+ (eSelMode != SHELL_MODE_TABLE_TEXT &&
+ eSelMode != SHELL_MODE_LIST_TEXT &&
+ eSelMode != SHELL_MODE_TABLE_LIST_TEXT &&
+ eSelMode != SHELL_MODE_TEXT ))
+ rSh.EnterStdMode();
+ SwPaM* pShellCrsr = rSh.GetCrsr();
+ SwPaM aOwnPaM(*pShellCrsr->GetPoint());
+ if(pShellCrsr->HasMark())
+ {
+ aOwnPaM.SetMark();
+ *aOwnPaM.GetMark() = *pShellCrsr->GetMark();
+ }
+
+ uno::Reference<lang::XUnoTunnel> xRangeTunnel( xRange, uno::UNO_QUERY);
+ SwXTextRange* pRange = 0;
+ SwXParagraph* pPara = 0;
+ OTextCursorHelper* pCursor = 0;
+ if(xRangeTunnel.is())
+ {
+ pRange = reinterpret_cast<SwXTextRange*>(xRangeTunnel->getSomething(
+ SwXTextRange::getUnoTunnelId()));
+ pCursor = reinterpret_cast<OTextCursorHelper*>(xRangeTunnel->getSomething(
+ OTextCursorHelper::getUnoTunnelId()));
+ pPara = reinterpret_cast<SwXParagraph*>(xRangeTunnel->getSomething(
+ SwXParagraph::getUnoTunnelId()));
+ }
+
+ const sal_uInt16 nFrmType = rSh.GetFrmType(0,sal_True);
+
+ SwStartNodeType eSearchNodeType = SwNormalStartNode;
+ if(nFrmType & FRMTYPE_FLY_ANY)
+ eSearchNodeType = SwFlyStartNode;
+ else if(nFrmType &FRMTYPE_HEADER)
+ eSearchNodeType = SwHeaderStartNode;
+ else if(nFrmType & FRMTYPE_FOOTER)
+ eSearchNodeType = SwFooterStartNode;
+ else if(nFrmType & FRMTYPE_TABLE)
+ eSearchNodeType = SwTableBoxStartNode;
+ else if(nFrmType & FRMTYPE_FOOTNOTE)
+ eSearchNodeType = SwFootnoteStartNode;
+
+ const SwStartNode* pOwnStartNode = aOwnPaM.GetNode()->
+ FindSttNodeByType(eSearchNodeType);
+
+ const SwNode* pSrcNode = 0;
+ if(pCursor && pCursor->GetPaM())
+ {
+ pSrcNode = pCursor->GetPaM()->GetNode();
+ }
+ else if (pRange)
+ {
+ SwPaM aPam(pRange->GetDoc()->GetNodes());
+ if (pRange->GetPositions(aPam))
+ {
+ pSrcNode = aPam.GetNode();
+ }
+ }
+ else if (pPara && pPara->GetTxtNode())
+ {
+ pSrcNode = pPara->GetTxtNode();
+ }
+ const SwStartNode* pTmp = pSrcNode ? pSrcNode->FindSttNodeByType(eSearchNodeType) : 0;
+
+ //Skip SectionNodes
+ while(pTmp && pTmp->IsSectionNode())
+ {
+ pTmp = pTmp->StartOfSectionNode();
+ }
+ while(pOwnStartNode && pOwnStartNode->IsSectionNode())
+ {
+ pOwnStartNode = pOwnStartNode->StartOfSectionNode();
+ }
+ //Without Expand it is allowed to jump out with the ViewCursor everywhere,
+ //with Expand only in the same environment
+ if(bExpand &&
+ (pOwnStartNode != pTmp ||
+ (eSelMode != SHELL_MODE_TABLE_TEXT &&
+ eSelMode != SHELL_MODE_LIST_TEXT &&
+ eSelMode != SHELL_MODE_TABLE_LIST_TEXT &&
+ eSelMode != SHELL_MODE_TEXT)))
+ throw uno::RuntimeException();
+
+ //Now, the selection must be expanded.
+ if(bExpand)
+ {
+ // The cursor should include everything that has been included
+ // by him and the transfered Range.
+ SwPosition aOwnLeft(*aOwnPaM.Start());
+ SwPosition aOwnRight(*aOwnPaM.End());
+ SwPosition* pParamLeft = rDestPam.Start();
+ SwPosition* pParamRight = rDestPam.End();
+ // Now four SwPositions are there, two of them are needed, but which?
+ if(aOwnRight > *pParamRight)
+ *aOwnPaM.GetPoint() = aOwnRight;
+ else
+ *aOwnPaM.GetPoint() = *pParamRight;
+ aOwnPaM.SetMark();
+ if(aOwnLeft < *pParamLeft)
+ *aOwnPaM.GetMark() = aOwnLeft;
+ else
+ *aOwnPaM.GetMark() = *pParamLeft;
+ }
+ else
+ {
+ //The cursor shall match the passed range.
+ *aOwnPaM.GetPoint() = *rDestPam.GetPoint();
+ if(rDestPam.HasMark())
+ {
+ aOwnPaM.SetMark();
+ *aOwnPaM.GetMark() = *rDestPam.GetMark();
+ }
+ else
+ aOwnPaM.DeleteMark();
+ }
+ rSh.SetSelection(aOwnPaM);
+ }
+ else
+ throw uno::RuntimeException();
+
+}
+
+void SwXTextViewCursor::gotoStart(sal_Bool bExpand)
+ throw (uno::RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ if(m_pView)
+ {
+ if (!IsTextSelection())
+ throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) );
+
+ m_pView->GetWrtShell().SttDoc( bExpand );
+ }
+ else
+ throw uno::RuntimeException();
+}
+
+void SwXTextViewCursor::gotoEnd(sal_Bool bExpand)
+ throw (uno::RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ if(m_pView)
+ {
+ if (!IsTextSelection())
+ throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) );
+
+ m_pView->GetWrtShell().EndDoc( bExpand );
+ }
+ else
+ throw uno::RuntimeException();
+}
+
+sal_Bool SwXTextViewCursor::jumpToFirstPage()
+ throw (uno::RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ sal_Bool bRet = sal_False;
+ if(m_pView)
+ {
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ if (rSh.IsSelFrmMode())
+ {
+ rSh.UnSelectFrm();
+ rSh.LeaveSelFrmMode();
+ }
+ rSh.EnterStdMode();
+ bRet = rSh.SttEndDoc(sal_True);
+ }
+ else
+ throw uno::RuntimeException();
+ return bRet;
+}
+
+sal_Bool SwXTextViewCursor::jumpToLastPage()
+ throw(uno::RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ sal_Bool bRet = sal_False;
+ if(m_pView)
+ {
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ if (rSh.IsSelFrmMode())
+ {
+ rSh.UnSelectFrm();
+ rSh.LeaveSelFrmMode();
+ }
+ rSh.EnterStdMode();
+ bRet = rSh.SttEndDoc(sal_False);
+ rSh.SttPg();
+ }
+ else
+ throw uno::RuntimeException();
+ return bRet;
+}
+
+sal_Bool SwXTextViewCursor::jumpToPage(sal_Int16 nPage) throw( uno::RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ sal_Bool bRet = sal_False;
+ if(m_pView)
+ bRet = m_pView->GetWrtShell().GotoPage(nPage, sal_True);
+ else
+ throw uno::RuntimeException();
+ return bRet;
+}
+
+sal_Bool SwXTextViewCursor::jumpToNextPage(void) throw( uno::RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ sal_Bool bRet = sal_False;
+ if(m_pView)
+ bRet = m_pView->GetWrtShell().SttNxtPg();
+ else
+ throw uno::RuntimeException();
+ return bRet;
+}
+
+sal_Bool SwXTextViewCursor::jumpToPreviousPage(void) throw( uno::RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ sal_Bool bRet = sal_False;
+ if(m_pView)
+ bRet = m_pView->GetWrtShell().EndPrvPg();
+ else
+ throw uno::RuntimeException();
+ return bRet;
+}
+
+sal_Bool SwXTextViewCursor::jumpToEndOfPage(void) throw( uno::RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ sal_Bool bRet = sal_False;
+ if(m_pView)
+ bRet = m_pView->GetWrtShell().EndPg();
+ else
+ throw uno::RuntimeException();
+ return bRet;
+}
+
+sal_Bool SwXTextViewCursor::jumpToStartOfPage(void) throw( uno::RuntimeException, std::exception )
+{
+ SolarMutexGuard aGuard;
+ sal_Bool bRet = sal_False;
+ if(m_pView)
+ bRet = m_pView->GetWrtShell().SttPg();
+ else
+ throw uno::RuntimeException();
+ return bRet;
+}
+
+sal_Int16 SwXTextViewCursor::getPage()
+ throw (uno::RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ sal_Int16 nRet = 0;
+ if(m_pView)
+ {
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ SwPaM* pShellCrsr = rSh.GetCrsr();
+ nRet = static_cast<sal_Int16>(pShellCrsr->GetPageNum( true, 0 ));
+ }
+ else
+ throw uno::RuntimeException();
+ return nRet;
+}
+
+sal_Bool SwXTextViewCursor::screenDown()
+ throw (uno::RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ sal_Bool bRet = sal_False;
+ if(m_pView)
+ {
+ SfxRequest aReq(FN_PAGEDOWN, SFX_CALLMODE_SLOT, m_pView->GetPool());
+ m_pView->Execute(aReq);
+ const SfxPoolItem* pRet = aReq.GetReturnValue();
+ bRet = pRet && ((const SfxBoolItem*)pRet)->GetValue();
+ }
+ else
+ throw uno::RuntimeException();
+ return bRet;
+}
+
+sal_Bool SwXTextViewCursor::screenUp()
+ throw (uno::RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ sal_Bool bRet = sal_False;
+ if(m_pView)
+ {
+ SfxRequest aReq(FN_PAGEUP, SFX_CALLMODE_SLOT, m_pView->GetPool());
+ m_pView->Execute(aReq);
+ const SfxPoolItem* pRet = aReq.GetReturnValue();
+ bRet = pRet && ((const SfxBoolItem*)pRet)->GetValue();
+ }
+ else
+ throw uno::RuntimeException();
+ return bRet;
+}
+
+uno::Reference< text::XText > SwXTextViewCursor::getText()
+ throw (uno::RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference< text::XText > xRet;
+ if(m_pView)
+ {
+ if (!IsTextSelection( sal_False ))
+ throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) );
+
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ SwPaM* pShellCrsr = rSh.GetCrsr();
+ SwDoc* pDoc = m_pView->GetDocShell()->GetDoc();
+ xRet = ::sw::CreateParentXText(*pDoc, *pShellCrsr->Start());
+ }
+ else
+ throw uno::RuntimeException();
+ return xRet;
+}
+
+uno::Reference< text::XTextRange > SwXTextViewCursor::getStart()
+ throw (uno::RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference< text::XTextRange > xRet;
+ if(m_pView)
+ {
+ if (!IsTextSelection())
+ throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) );
+
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ SwPaM* pShellCrsr = rSh.GetCrsr();
+ SwDoc* pDoc = m_pView->GetDocShell()->GetDoc();
+ xRet = SwXTextRange::CreateXTextRange(*pDoc, *pShellCrsr->Start(), 0);
+ }
+ else
+ throw uno::RuntimeException();
+ return xRet;
+}
+
+uno::Reference< text::XTextRange > SwXTextViewCursor::getEnd()
+ throw (uno::RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference< text::XTextRange > xRet;
+ if(m_pView)
+ {
+ if (!IsTextSelection())
+ throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) );
+
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ SwPaM* pShellCrsr = rSh.GetCrsr();
+ SwDoc* pDoc = m_pView->GetDocShell()->GetDoc();
+ xRet = SwXTextRange::CreateXTextRange(*pDoc, *pShellCrsr->End(), 0);
+ }
+ else
+ throw uno::RuntimeException();
+ return xRet;
+}
+
+OUString SwXTextViewCursor::getString()
+ throw (uno::RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ OUString uRet;
+ if(m_pView)
+ {
+ if (!IsTextSelection( sal_False ))
+ throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) );
+
+ ShellModes eSelMode = m_pView->GetShellMode();
+ switch(eSelMode)
+ {
+ //! since setString for SEL_TABLE_TEXT (with possible
+ //! multi selection of cells) would not work properly we
+ //! will ignore this case for both
+ //! functions (setString AND getString) because of symmetrie.
+
+ case SHELL_MODE_LIST_TEXT :
+ case SHELL_MODE_TABLE_LIST_TEXT:
+ case SHELL_MODE_TEXT :
+ {
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ SwPaM* pShellCrsr = rSh.GetCrsr();
+ SwUnoCursorHelper::GetTextFromPam(*pShellCrsr, uRet);
+ }
+ default:;//prevent warning
+ }
+ }
+ return uRet;
+}
+
+void SwXTextViewCursor::setString(const OUString& aString)
+ throw (uno::RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ if(m_pView)
+ {
+ if (!IsTextSelection( sal_False ))
+ throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) );
+
+ ShellModes eSelMode = m_pView->GetShellMode();
+ switch(eSelMode)
+ {
+ //! since setString for SEL_TABLE_TEXT (with possible
+ //! multi selection of cells) would not work properly we
+ //! will ignore this case for both
+ //! functions (setString AND getString) because of symmetrie.
+
+ case SHELL_MODE_LIST_TEXT :
+ case SHELL_MODE_TABLE_LIST_TEXT :
+ case SHELL_MODE_TEXT :
+ {
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ SwCursor* pShellCrsr = rSh.GetSwCrsr();
+ SwUnoCursorHelper::SetString(*pShellCrsr, aString);
+ }
+ default:;//prevent warning
+ }
+ }
+}
+
+uno::Reference< XPropertySetInfo > SwXTextViewCursor::getPropertySetInfo( ) throw(RuntimeException, std::exception)
+{
+ static uno::Reference< XPropertySetInfo > xRef = m_pPropSet->getPropertySetInfo();
+ return xRef;
+}
+
+void SwXTextViewCursor::setPropertyValue( const OUString& rPropertyName, const Any& aValue )
+ throw (UnknownPropertyException, PropertyVetoException,
+ IllegalArgumentException, WrappedTargetException,
+ RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ if(m_pView)
+ {
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ SwPaM* pShellCrsr = rSh.GetCrsr();
+ SwNode *pNode = pShellCrsr->GetNode();
+ if (pNode && pNode->IsTxtNode())
+ {
+ SwUnoCursorHelper::SetPropertyValue(
+ *pShellCrsr, *m_pPropSet, rPropertyName, aValue );
+ }
+ else
+ throw RuntimeException();
+ }
+ else
+ throw RuntimeException();
+}
+
+Any SwXTextViewCursor::getPropertyValue( const OUString& rPropertyName )
+ throw (UnknownPropertyException, WrappedTargetException,
+ RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ Any aRet;
+ if(m_pView)
+ {
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ SwPaM* pShellCrsr = rSh.GetCrsr();
+ aRet = SwUnoCursorHelper::GetPropertyValue(
+ *pShellCrsr, *m_pPropSet, rPropertyName);
+ }
+ else
+ throw RuntimeException();
+ return aRet;
+}
+
+void SwXTextViewCursor::addPropertyChangeListener(
+ const OUString& /*aPropertyName*/, const uno::Reference< XPropertyChangeListener >& /*xListener*/ )
+ throw(UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
+{
+}
+
+void SwXTextViewCursor::removePropertyChangeListener(
+ const OUString& /*aPropertyName*/, const uno::Reference< XPropertyChangeListener >& /*aListener*/ )
+ throw(UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
+{
+}
+
+void SwXTextViewCursor::addVetoableChangeListener(
+ const OUString& /*PropertyName*/, const uno::Reference< XVetoableChangeListener >& /*aListener*/ )
+ throw(UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
+{
+}
+
+void SwXTextViewCursor::removeVetoableChangeListener(
+ const OUString& /*PropertyName*/, const uno::Reference< XVetoableChangeListener >& /*aListener*/ ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
+{
+}
+
+PropertyState SwXTextViewCursor::getPropertyState( const OUString& rPropertyName )
+ throw (UnknownPropertyException, RuntimeException,
+ std::exception)
+{
+ SolarMutexGuard aGuard;
+ PropertyState eState;
+ if(m_pView)
+ {
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ SwPaM* pShellCrsr = rSh.GetCrsr();
+ eState = SwUnoCursorHelper::GetPropertyState(
+ *pShellCrsr, *m_pPropSet, rPropertyName);
+ }
+ else
+ throw RuntimeException();
+ return eState;
+}
+
+Sequence< PropertyState > SwXTextViewCursor::getPropertyStates(
+ const Sequence< OUString >& rPropertyNames )
+ throw (UnknownPropertyException, RuntimeException,
+ std::exception)
+{
+ SolarMutexGuard aGuard;
+ Sequence< PropertyState > aRet;
+ if(m_pView)
+ {
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ SwPaM* pShellCrsr = rSh.GetCrsr();
+ aRet = SwUnoCursorHelper::GetPropertyStates(
+ *pShellCrsr, *m_pPropSet, rPropertyNames);
+ }
+ return aRet;
+}
+
+void SwXTextViewCursor::setPropertyToDefault( const OUString& rPropertyName )
+ throw (UnknownPropertyException, RuntimeException,
+ std::exception)
+{
+ SolarMutexGuard aGuard;
+ if(m_pView)
+ {
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ SwPaM* pShellCrsr = rSh.GetCrsr();
+ SwUnoCursorHelper::SetPropertyToDefault(
+ *pShellCrsr, *m_pPropSet, rPropertyName);
+ }
+}
+
+Any SwXTextViewCursor::getPropertyDefault( const OUString& rPropertyName )
+ throw (UnknownPropertyException, WrappedTargetException,
+ RuntimeException, std::exception)
+{
+ Any aRet;
+ SolarMutexGuard aGuard;
+ if(m_pView)
+ {
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ SwPaM* pShellCrsr = rSh.GetCrsr();
+ aRet = SwUnoCursorHelper::GetPropertyDefault(
+ *pShellCrsr, *m_pPropSet, rPropertyName);
+ }
+ return aRet;
+}
+
+sal_Bool SwXTextViewCursor::goDown(sal_Int16 nCount, sal_Bool bExpand)
+ throw (uno::RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ sal_Bool bRet = sal_False;
+ if(m_pView)
+ {
+ if (!IsTextSelection())
+ throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) );
+
+ for( sal_uInt16 i = 0; i < nCount; i++ )
+ bRet = m_pView->GetWrtShell().Down( bExpand, 1, sal_True );
+ }
+ else
+ throw uno::RuntimeException();
+ return bRet;
+}
+
+sal_Bool SwXTextViewCursor::goUp(sal_Int16 nCount, sal_Bool bExpand)
+ throw (uno::RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ sal_Bool bRet = sal_False;
+ if(m_pView)
+ {
+ if (!IsTextSelection())
+ throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) );
+
+ for( sal_uInt16 i = 0; i < nCount; i++ )
+ bRet = m_pView->GetWrtShell().Up( bExpand, 1, sal_True );
+ }
+ else
+ throw uno::RuntimeException();
+ return bRet;
+}
+
+sal_Bool SwXTextViewCursor::isAtStartOfLine()
+ throw(uno::RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ sal_Bool bRet = sal_False;
+ if(m_pView)
+ {
+ if (!IsTextSelection( sal_False ))
+ throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) );
+
+ bRet = m_pView->GetWrtShell().IsAtLeftMargin();
+ }
+ else
+ throw uno::RuntimeException();
+ return bRet;
+}
+
+sal_Bool SwXTextViewCursor::isAtEndOfLine()
+ throw(uno::RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ sal_Bool bRet = sal_False;
+ if(m_pView)
+ {
+ if (!IsTextSelection( sal_False ))
+ throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) );
+
+ bRet = m_pView->GetWrtShell().IsAtRightMargin(sal_True);
+ }
+ else
+ throw uno::RuntimeException();
+ return bRet;
+}
+
+void SwXTextViewCursor::gotoEndOfLine(sal_Bool bExpand)
+ throw (uno::RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ if(m_pView)
+ {
+ if (!IsTextSelection( sal_False ))
+ throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) );
+
+ m_pView->GetWrtShell().RightMargin(bExpand, sal_True);
+ }
+ else
+ throw uno::RuntimeException();
+}
+
+void SwXTextViewCursor::gotoStartOfLine(sal_Bool bExpand)
+ throw (uno::RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ if(m_pView)
+ {
+ if (!IsTextSelection( sal_False ))
+ throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) );
+
+ m_pView->GetWrtShell().LeftMargin(bExpand, sal_True);
+ }
+ else
+ throw uno::RuntimeException();
+}
+
+OUString SwXTextViewCursor::getImplementationName(void) throw( RuntimeException, std::exception )
+{
+ return OUString("SwXTextViewCursor");
+}
+
+sal_Bool SwXTextViewCursor::supportsService(const OUString& rServiceName) throw( RuntimeException, std::exception )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+Sequence< OUString > SwXTextViewCursor::getSupportedServiceNames(void) throw( RuntimeException, std::exception )
+{
+ Sequence< OUString > aRet(7);
+ OUString* pArray = aRet.getArray();
+ pArray[0] = "com.sun.star.text.TextViewCursor";
+ pArray[1] = "com.sun.star.style.CharacterProperties";
+ pArray[2] = "com.sun.star.style.CharacterPropertiesAsian";
+ pArray[3] = "com.sun.star.style.CharacterPropertiesComplex";
+ pArray[4] = "com.sun.star.style.ParagraphProperties";
+ pArray[5] = "com.sun.star.style.ParagraphPropertiesAsian";
+ pArray[6] = "com.sun.star.style.ParagraphPropertiesComplex";
+ return aRet;
+}
+
+namespace
+{
+ class theSwXTextViewCursorUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXTextViewCursorUnoTunnelId > {};
+}
+
+const uno::Sequence< sal_Int8 > & SwXTextViewCursor::getUnoTunnelId()
+{
+ return theSwXTextViewCursorUnoTunnelId::get().getSeq();
+}
+
+//XUnoTunnel
+sal_Int64 SAL_CALL SwXTextViewCursor::getSomething(
+ const uno::Sequence< sal_Int8 >& rId )
+ throw(uno::RuntimeException, std::exception)
+{
+ if( rId.getLength() == 16
+ && 0 == memcmp( getUnoTunnelId().getConstArray(),
+ rId.getConstArray(), 16 ) )
+ {
+ return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this ));
+ }
+ return OTextCursorHelper::getSomething(rId);
+}
+
+IMPLEMENT_FORWARD_XINTERFACE2(SwXTextViewCursor,SwXTextViewCursor_Base,OTextCursorHelper)
+const SwDoc* SwXTextViewCursor::GetDoc() const
+{
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ return rSh.GetCrsr() ? rSh.GetCrsr()->GetDoc() : 0;
+}
+
+SwDoc* SwXTextViewCursor::GetDoc()
+{
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ return rSh.GetCrsr() ? rSh.GetCrsr()->GetDoc() : 0;
+}
+
+const SwPaM* SwXTextViewCursor::GetPaM() const
+{
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ return rSh.GetCrsr();
+}
+
+SwPaM* SwXTextViewCursor::GetPaM()
+{
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ return rSh.GetCrsr();
+}
+
+uno::Reference< datatransfer::XTransferable > SAL_CALL SwXTextView::getTransferable()
+ throw (uno::RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+
+ //force immediat shell update
+ GetView()->StopShellTimer();
+ SwWrtShell& rSh = GetView()->GetWrtShell();
+ if ( GetView()->GetShellMode() == SHELL_MODE_DRAWTEXT )
+ {
+ SdrView *pSdrView = rSh.GetDrawView();
+ OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
+ return pOLV->GetEditView().GetTransferable();
+ }
+ else
+ {
+ SwTransferable* pTransfer = new SwTransferable( rSh );
+ const sal_Bool bLockedView = rSh.IsViewLocked();
+ rSh.LockView( sal_True ); //lock visible section
+ pTransfer->PrepareForCopy();
+ rSh.LockView( bLockedView );
+ return uno::Reference< datatransfer::XTransferable >( pTransfer );
+ }
+}
+
+void SAL_CALL SwXTextView::insertTransferable( const uno::Reference< datatransfer::XTransferable >& xTrans ) throw (datatransfer::UnsupportedFlavorException, uno::RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+
+ //force immediat shell update
+ GetView()->StopShellTimer();
+ SwWrtShell& rSh = GetView()->GetWrtShell();
+ if ( GetView()->GetShellMode() == SHELL_MODE_DRAWTEXT )
+ {
+ SdrView *pSdrView = rSh.GetDrawView();
+ OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
+ pOLV->GetEditView().InsertText( xTrans, GetView()->GetDocShell()->GetMedium()->GetBaseURL(), false );
+ }
+ else
+ {
+ TransferableDataHelper aDataHelper( xTrans );
+ if ( SwTransferable::IsPaste( rSh, aDataHelper ) )
+ {
+ SwTransferable::Paste( rSh, aDataHelper );
+ if( rSh.IsFrmSelected() || rSh.IsObjSelected() )
+ rSh.EnterSelFrmMode();
+ GetView()->AttrChangedNotify( &rSh );
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/utlui/attrdesc.cxx b/sw/source/core/uibase/utlui/attrdesc.cxx
new file mode 100644
index 000000000000..6c3889384182
--- /dev/null
+++ b/sw/source/core/uibase/utlui/attrdesc.cxx
@@ -0,0 +1,1248 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <i18nutil/unicode.hxx>
+#include <svl/itemiter.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/settings.hxx>
+
+#include <editeng/itemtype.hxx>
+#include <svtools/grfmgr.hxx>
+#include <unotools/intlwrapper.hxx>
+#include <comphelper/processfactory.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <fmtanchr.hxx>
+#include <fmtfsize.hxx>
+#include <fmtinfmt.hxx>
+#include <fchrfmt.hxx>
+#include <fmtautofmt.hxx>
+#include <fmtsrnd.hxx>
+#include <fmtornt.hxx>
+#include <fmtlsplt.hxx>
+#include <fmtrowsplt.hxx>
+#include <fmtpdsc.hxx>
+#include <fmtclds.hxx>
+#include <fmteiro.hxx>
+#include <fmturl.hxx>
+#include <fmthdft.hxx>
+#include <fmtcnct.hxx>
+#include <fmtline.hxx>
+#include <tgrditem.hxx>
+#include <hfspacingitem.hxx>
+#include <fmtruby.hxx>
+#include <paratr.hxx>
+#include <grfatr.hxx>
+#include <pagedesc.hxx>
+#include <charfmt.hxx>
+#include <fmtcol.hxx>
+#include <tox.hxx>
+#include <attrdesc.hrc>
+#include <fmtftntx.hxx>
+#include <fmtfollowtextflow.hxx>
+
+using namespace com::sun::star;
+
+TYPEINIT2(SwFmtCharFmt,SfxPoolItem,SwClient);
+
+// query the attribute descriptions
+void SwAttrSet::GetPresentation(
+ SfxItemPresentation ePres,
+ SfxMapUnit eCoreMetric,
+ SfxMapUnit ePresMetric,
+ OUString &rText ) const
+{
+ static sal_Char const sComma[] = ", ";
+
+ rText = OUString();
+ OUString aStr;
+ if( Count() )
+ {
+ SfxItemIter aIter( *this );
+ const IntlWrapper rInt( ::comphelper::getProcessComponentContext(),
+ GetAppLanguageTag() );
+ while( true )
+ {
+ aIter.GetCurItem()->GetPresentation( ePres, eCoreMetric,
+ ePresMetric, aStr,
+ &rInt );
+ if( rText.getLength() && aStr.getLength() )
+ rText += OUString(sComma);
+ rText += aStr;
+ if( aIter.IsAtEnd() )
+ break;
+ aIter.NextItem();
+ }
+ }
+}
+
+SfxItemPresentation SwFmtCharFmt::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit eCoreUnit,
+ SfxMapUnit ePresUnit,
+ OUString& rText,
+ const IntlWrapper* /*pIntl*/
+) const
+{
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ rText = OUString();
+ break;
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ {
+ const SwCharFmt *pCharFmt = GetCharFmt();
+ if ( pCharFmt )
+ {
+ OUString aStr;
+ rText = OUString( SW_RESSTR( STR_CHARFMT ) );
+ pCharFmt->GetPresentation( ePres, eCoreUnit, ePresUnit, aStr );
+ rText = rText + "(" + aStr + ")";
+ }
+ else
+ rText = OUString( SW_RESSTR( STR_NO_CHARFMT ) );
+ return ePres;
+ }
+ default:;//prevent warning
+ }
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+SfxItemPresentation SwFmtAutoFmt::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ OUString& rText,
+ const IntlWrapper* /*pIntl*/
+) const
+{
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ rText = OUString();
+ break;
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ {
+ rText = OUString(); //TODO
+ return ePres;
+ }
+ default:;//prevent warning
+ }
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+SfxItemPresentation SwFmtINetFmt::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ OUString& rText,
+ const IntlWrapper* /*pIntl*/
+) const
+{
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ rText = OUString();
+ break;
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ {
+ rText = GetValue();
+ return ePres;
+ }
+ default:;//prevent warning
+ }
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+SfxItemPresentation SwFmtRuby::GetPresentation( SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresMetric*/,
+ OUString &rText, const IntlWrapper* /*pIntl*/ ) const
+{
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ rText = OUString();
+ break;
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ {
+ rText = OUString();
+ return ePres;
+ }
+ default:;//prevent warning
+ }
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+SfxItemPresentation SwFmtDrop::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ OUString& rText,
+ const IntlWrapper* /*pIntl*/
+) const
+{
+ rText = OUString();
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ break;
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ {
+ if ( GetLines() > 1 )
+ {
+ if ( GetChars() > 1 )
+ {
+ rText = OUString::number( GetChars() ) + " ";
+ }
+ rText = rText +
+ OUString( SW_RESSTR( STR_DROP_OVER ) ) +
+ " " +
+ OUString::number( GetLines() ) +
+ " " +
+ OUString( SW_RESSTR( STR_DROP_LINES ) );
+ }
+ else
+ rText = SW_RESSTR( STR_NO_DROP_LINES );
+ return ePres;
+ }
+ default:;//prevent warning
+ }
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+SfxItemPresentation SwRegisterItem::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ OUString& rText,
+ const IntlWrapper* /*pIntl*/
+) const
+{
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ rText = OUString();
+ return SFX_ITEM_PRESENTATION_NONE;
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ {
+ sal_uInt16 nId = GetValue() ? STR_REGISTER_ON : STR_REGISTER_OFF;
+ rText = SW_RESSTR( nId );
+ return ePres;
+ }
+ default:;//prevent warning
+ }
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+SfxItemPresentation SwNumRuleItem::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ OUString& rText,
+ const IntlWrapper* /*pIntl*/
+) const
+{
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ rText = OUString();
+ return SFX_ITEM_PRESENTATION_NONE;
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ {
+ if( !GetValue().isEmpty() )
+ rText = SW_RESSTR( STR_NUMRULE_ON ) +
+ "(" + GetValue() + ")";
+ else
+ rText = SW_RESSTR( STR_NUMRULE_OFF );
+ return ePres;
+ }
+ default:;//prevent warning
+ }
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+SfxItemPresentation SwParaConnectBorderItem::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ OUString& rText,
+ const IntlWrapper* /*pIntl*/
+) const
+{
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ rText = OUString();
+ return SFX_ITEM_PRESENTATION_NONE;
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ {
+ sal_uInt16 nId = GetValue() ? STR_CONNECT_BORDER_ON : STR_CONNECT_BORDER_OFF;
+ rText = SW_RESSTR( nId );
+ return ePres;
+ }
+ default:;//prevent warning
+ }
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+// Frame attribute
+
+SfxItemPresentation SwFmtFrmSize::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit eCoreUnit,
+ SfxMapUnit ePresUnit,
+ OUString& rText,
+ const IntlWrapper* pIntl
+) const
+{
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ {
+ rText = OUString();
+ break;
+ }
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ {
+ rText = SW_RESSTR( STR_FRM_WIDTH ) + " ";
+ if ( GetWidthPercent() )
+ {
+ rText = rText + unicode::formatPercent(GetWidthPercent(),
+ Application::GetSettings().GetUILanguageTag());
+ }
+ else
+ {
+ rText = rText + ::GetMetricText( GetWidth(), eCoreUnit, ePresUnit, pIntl ) +
+ " " + ::GetSvxString( ::GetMetricId( ePresUnit ) );
+ }
+ if ( ATT_VAR_SIZE != GetHeightSizeType() )
+ {
+ const sal_uInt16 nId = ATT_FIX_SIZE == m_eFrmHeightType ?
+ STR_FRM_FIXEDHEIGHT : STR_FRM_MINHEIGHT;
+ rText = rText + ", " + SW_RESSTR( nId ) + " ";
+ if ( GetHeightPercent() )
+ {
+ rText = rText + unicode::formatPercent(GetHeightPercent(),
+ Application::GetSettings().GetUILanguageTag());
+ }
+ else
+ {
+ rText = OUString( ::GetMetricText( GetHeight(), eCoreUnit, ePresUnit, pIntl ) ) +
+ " " + ::GetSvxString( ::GetMetricId( ePresUnit ) );
+ }
+ }
+ return ePres;
+ }
+ default:;//prevent warning
+ }
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+//Header for page formats.
+//Client of FrmFmt which describes the header.
+
+SfxItemPresentation SwFmtHeader::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ OUString& rText,
+ const IntlWrapper* /*pIntl*/
+) const
+{
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ rText = OUString();
+ break;
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ {
+ const sal_uInt16 nId = GetHeaderFmt() ? STR_HEADER : STR_NO_HEADER;
+ rText = SW_RESSTR( nId );
+ return ePres;
+ }
+ default:;//prevent warning
+ }
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+//Footer for page formats.
+//Client of FrmFmt which describes the footer.
+
+SfxItemPresentation SwFmtFooter::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ OUString& rText,
+ const IntlWrapper* /*pIntl*/
+) const
+{
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ rText = OUString();
+ break;
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ {
+ const sal_uInt16 nId = GetFooterFmt() ? STR_FOOTER : STR_NO_FOOTER;
+ rText = SW_RESSTR( nId );
+ return ePres;
+ }
+ default:;//prevent warning
+ }
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+SfxItemPresentation SwFmtSurround::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ OUString& rText,
+ const IntlWrapper* /*pIntl*/
+) const
+{
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ rText = OUString();
+ break;
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ {
+ sal_uInt16 nId = 0;
+ switch ( (SwSurround)GetValue() )
+ {
+ case SURROUND_NONE:
+ nId = STR_SURROUND_NONE;
+ break;
+ case SURROUND_THROUGHT:
+ nId = STR_SURROUND_THROUGHT;
+ break;
+ case SURROUND_PARALLEL:
+ nId = STR_SURROUND_PARALLEL;
+ break;
+ case SURROUND_IDEAL:
+ nId = STR_SURROUND_IDEAL;
+ break;
+ case SURROUND_LEFT:
+ nId = STR_SURROUND_LEFT;
+ break;
+ case SURROUND_RIGHT:
+ nId = STR_SURROUND_RIGHT;
+ break;
+ default:;//prevent warning
+ }
+ if ( nId )
+ rText = SW_RESSTR( nId );
+
+ if ( IsAnchorOnly() )
+ {
+ rText = rText + " " + SW_RESSTR( STR_SURROUND_ANCHORONLY );
+ }
+ return ePres;
+ }
+ default:;//prevent warning
+ }
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+//VertOrientation, how and by what orientate the FlyFrm in the vertical?
+
+SfxItemPresentation SwFmtVertOrient::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit eCoreUnit,
+ SfxMapUnit ePresUnit,
+ OUString& rText,
+ const IntlWrapper* pIntl
+) const
+{
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ rText = OUString();
+ break;
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ {
+ sal_uInt16 nId = 0;
+ switch ( GetVertOrient() )
+ {
+ case text::VertOrientation::NONE:
+ {
+ rText = rText + SW_RESSTR( STR_POS_Y ) + " " +
+ ::GetMetricText( GetPos(), eCoreUnit, ePresUnit, pIntl ) +
+ " " + ::GetSvxString( ::GetMetricId( ePresUnit ) );
+ }
+ break;
+ case text::VertOrientation::TOP:
+ nId = STR_VERT_TOP;
+ break;
+ case text::VertOrientation::CENTER:
+ nId = STR_VERT_CENTER;
+ break;
+ case text::VertOrientation::BOTTOM:
+ nId = STR_VERT_BOTTOM;
+ break;
+ case text::VertOrientation::LINE_TOP:
+ nId = STR_LINE_TOP;
+ break;
+ case text::VertOrientation::LINE_CENTER:
+ nId = STR_LINE_CENTER;
+ break;
+ case text::VertOrientation::LINE_BOTTOM:
+ nId = STR_LINE_BOTTOM;
+ break;
+ default:;//prevent warning
+ }
+ if ( nId )
+ rText += SW_RESSTR( nId );
+ return ePres;
+ }
+ default:;//prevent warning
+ }
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+//HoriOrientation, how and by what orientate the FlyFrm in the horizontal?
+
+SfxItemPresentation SwFmtHoriOrient::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit eCoreUnit,
+ SfxMapUnit ePresUnit,
+ OUString& rText,
+ const IntlWrapper* pIntl
+) const
+{
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ rText = OUString();
+ break;
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ {
+ sal_uInt16 nId = 0;
+ switch ( GetHoriOrient() )
+ {
+ case text::HoriOrientation::NONE:
+ {
+ rText = rText + SW_RESSTR( STR_POS_X ) + " " +
+ ::GetMetricText( GetPos(), eCoreUnit, ePresUnit, pIntl ) +
+ " " + ::GetSvxString( ::GetMetricId( ePresUnit ) );
+ }
+ break;
+ case text::HoriOrientation::RIGHT:
+ nId = STR_HORI_RIGHT;
+ break;
+ case text::HoriOrientation::CENTER:
+ nId = STR_HORI_CENTER;
+ break;
+ case text::HoriOrientation::LEFT:
+ nId = STR_HORI_LEFT;
+ break;
+ case text::HoriOrientation::INSIDE:
+ nId = STR_HORI_INSIDE;
+ break;
+ case text::HoriOrientation::OUTSIDE:
+ nId = STR_HORI_OUTSIDE;
+ break;
+ case text::HoriOrientation::FULL:
+ nId = STR_HORI_FULL;
+ break;
+ default:;//prevent warning
+ }
+ if ( nId )
+ rText += SW_RESSTR( nId );
+ return ePres;
+ }
+ default:;//prevent warning
+ }
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+// FlyAnchor, Anchor of the free-flying frame
+
+SfxItemPresentation SwFmtAnchor::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ OUString& rText,
+ const IntlWrapper* /*pIntl*/
+) const
+{
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ rText = OUString();
+ break;
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ {
+ sal_uInt16 nId = 0;
+ switch ( GetAnchorId() )
+ {
+ case FLY_AT_PARA:
+ nId = STR_FLY_AT_PARA;
+ break;
+ case FLY_AS_CHAR:
+ nId = STR_FLY_AS_CHAR;
+ break;
+ case FLY_AT_PAGE:
+ nId = STR_FLY_AT_PAGE;
+ break;
+ default:;//prevent warning
+ }
+ if ( nId )
+ rText += SW_RESSTR( nId );
+ return ePres;
+ }
+ default:;//prevent warning
+ }
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+SfxItemPresentation SwFmtPageDesc::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ OUString& rText,
+ const IntlWrapper* /*pIntl*/
+) const
+{
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ rText = OUString();
+ break;
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ {
+ const SwPageDesc *pPageDesc = GetPageDesc();
+ if ( pPageDesc )
+ rText = pPageDesc->GetName();
+ else
+ rText = SW_RESSTR( STR_NO_PAGEDESC );
+ return ePres;
+ }
+ default:;//prevent warning
+ }
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+//The ColumnDescriptor
+
+SfxItemPresentation SwFmtCol::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit eCoreUnit,
+ SfxMapUnit /*ePresUnit*/,
+ OUString& rText,
+ const IntlWrapper* pIntl
+) const
+{
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ rText = OUString();
+ break;
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ {
+ sal_uInt16 nCnt = GetNumCols();
+ if ( nCnt > 1 )
+ {
+ rText = OUString(nCnt) + " " + SW_RESSTR( STR_COLUMNS );
+ if ( COLADJ_NONE != GetLineAdj() )
+ {
+ sal_uInt16 nWdth = sal_uInt16(GetLineWidth());
+ rText = rText + " " + SW_RESSTR( STR_LINE_WIDTH ) + " " +
+ ::GetMetricText( nWdth, eCoreUnit,
+ SFX_MAPUNIT_POINT, pIntl );
+ }
+ }
+ else
+ rText = OUString();
+ return ePres;
+ }
+ default:;//prevent warning
+ }
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+//URL's and maps
+
+SfxItemPresentation SwFmtURL::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ OUString& rText,
+ const IntlWrapper* /*pIntl*/
+) const
+{
+ rText = OUString();
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ break;
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ {
+ if ( pMap )
+ rText += "Client-Map";
+ if ( !sURL.isEmpty() )
+ {
+ if ( pMap )
+ rText += " - ";
+ rText = rText + "URL: " + sURL;
+ if ( bIsServerMap )
+ rText += " (Server-Map)";
+ }
+ if ( !sTargetFrameName.isEmpty() )
+ {
+ rText = rText + ", Target: " + sTargetFrameName;
+ }
+ return ePres;
+ }
+ default:;//prevent warning
+ }
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+SfxItemPresentation SwFmtEditInReadonly::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ OUString& rText,
+ const IntlWrapper* /*pIntl*/
+) const
+{
+ rText = OUString();
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ rText = OUString();
+ break;
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ {
+ if ( GetValue() )
+ rText = SW_RESSTR(STR_EDIT_IN_READONLY);
+ return ePres;
+ }
+ default:;//prevent warning
+ }
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+SfxItemPresentation SwFmtLayoutSplit::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ OUString& rText,
+ const IntlWrapper* /*pIntl*/
+) const
+{
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ rText = OUString();
+ return SFX_ITEM_PRESENTATION_NONE;
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ {
+ if ( GetValue() )
+ rText = SW_RESSTR(STR_LAYOUT_SPLIT);
+ return ePres;
+ }
+ default:;//prevent warning
+ }
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+SfxItemPresentation SwFmtRowSplit::GetPresentation
+(
+ SfxItemPresentation /*ePres*/,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ OUString& /*rText*/,
+ const IntlWrapper* /*pIntl*/
+) const
+{
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+SfxItemPresentation SwFmtFtnEndAtTxtEnd::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ OUString& rText,
+ const IntlWrapper* /*pIntl*/
+) const
+{
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ rText = OUString();
+ break;
+
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ {
+ switch( GetValue() )
+ {
+ case FTNEND_ATPGORDOCEND:
+ break;
+
+ case FTNEND_ATTXTEND:
+ break;
+
+ case FTNEND_ATTXTEND_OWNNUMSEQ:
+ break;
+ }
+ }
+ break;
+
+ default:
+ ePres = SFX_ITEM_PRESENTATION_NONE;
+ break;
+ }
+ return ePres;
+}
+
+SfxItemPresentation SwFmtChain::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ OUString& rText,
+ const IntlWrapper* /*pIntl*/
+) const
+{
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ rText = OUString();
+ return SFX_ITEM_PRESENTATION_NONE;
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ {
+ if ( GetPrev() || GetNext() )
+ {
+ rText = SW_RESSTR(STR_CONNECT1);
+ if ( GetPrev() )
+ {
+ rText += GetPrev()->GetName();
+ if ( GetNext() )
+ rText += SW_RESSTR(STR_CONNECT2);
+ }
+ if ( GetNext() )
+ rText += GetNext()->GetName();
+ }
+ return ePres;
+ }
+ default:;//prevent warning
+ }
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+SfxItemPresentation SwFmtLineNumber::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ OUString& rText,
+ const IntlWrapper* /*pIntl*/
+) const
+{
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ rText = OUString();
+ return SFX_ITEM_PRESENTATION_NONE;
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ {
+ if ( IsCount() )
+ rText += SW_RESSTR(STR_LINECOUNT);
+ else
+ rText += SW_RESSTR(STR_DONTLINECOUNT);
+ if ( GetStartValue() )
+ {
+ rText = rText + " " + SW_RESSTR(STR_LINCOUNT_START) +
+ OUString::number( GetStartValue() );
+ }
+ return ePres;
+ }
+ default:;//prevent warning
+ }
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+SfxItemPresentation SwTextGridItem::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ OUString& rText,
+ const IntlWrapper* /*pIntl*/
+) const
+{
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ rText = OUString();
+ return SFX_ITEM_PRESENTATION_NONE;
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ {
+ sal_uInt16 nId = 0;
+
+ switch ( GetGridType() )
+ {
+ case GRID_NONE :
+ nId = STR_GRID_NONE;
+ break;
+ case GRID_LINES_ONLY :
+ nId = STR_GRID_LINES_ONLY;
+ break;
+ case GRID_LINES_CHARS :
+ nId = STR_GRID_LINES_CHARS;
+ break;
+ }
+ if ( nId )
+ rText += SW_RESSTR( nId );
+ return ePres;
+ }
+ default:;//prevent warning
+ }
+
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+SfxItemPresentation SwHeaderAndFooterEatSpacingItem::GetPresentation
+(
+ SfxItemPresentation /*ePres*/,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ OUString& /*rText*/,
+ const IntlWrapper* /*pIntl*/
+) const
+{
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+// Graphic attributes
+
+SfxItemPresentation SwMirrorGrf::GetPresentation(
+ SfxItemPresentation ePres, SfxMapUnit /*eCoreUnit*/, SfxMapUnit /*ePresUnit*/,
+ OUString& rText, const IntlWrapper* /*pIntl*/ ) const
+{
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ {
+ sal_uInt16 nId;
+ switch( GetValue() )
+ {
+ case RES_MIRROR_GRAPH_DONT: nId = STR_NO_MIRROR; break;
+ case RES_MIRROR_GRAPH_VERT: nId = STR_VERT_MIRROR; break;
+ case RES_MIRROR_GRAPH_HOR: nId = STR_HORI_MIRROR; break;
+ case RES_MIRROR_GRAPH_BOTH: nId = STR_BOTH_MIRROR; break;
+ default: nId = 0; break;
+ }
+ if ( nId )
+ {
+ rText = SW_RESSTR( nId );
+ if (bGrfToggle)
+ rText += SW_RESSTR( STR_MIRROR_TOGGLE );
+ }
+ }
+ break;
+ default:
+ ePres = SFX_ITEM_PRESENTATION_NONE;
+ rText = OUString();
+ break;
+ }
+ return ePres;
+}
+
+SfxItemPresentation SwRotationGrf::GetPresentation(
+ SfxItemPresentation ePres, SfxMapUnit /*eCoreUnit*/, SfxMapUnit /*ePresUnit*/,
+ OUString &rText, const IntlWrapper* /*pIntl*/) const
+{
+ switch( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ if( SFX_ITEM_PRESENTATION_COMPLETE == ePres )
+ rText = SW_RESSTR( STR_ROTATION );
+ else if( rText.getLength() )
+ rText = OUString();
+ rText = rText + OUString::number( GetValue() ) + "\xB0";
+ break;
+
+ default:
+ ePres = SFX_ITEM_PRESENTATION_NONE;
+ rText = OUString();
+ break;
+ }
+ return ePres;
+}
+
+SfxItemPresentation SwLuminanceGrf::GetPresentation(
+ SfxItemPresentation ePres, SfxMapUnit /*eCoreUnit*/, SfxMapUnit /*ePresUnit*/,
+ OUString &rText, const IntlWrapper* /*pIntl*/) const
+{
+ switch( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ if( SFX_ITEM_PRESENTATION_COMPLETE == ePres )
+ rText = SW_RESSTR( STR_LUMINANCE );
+ else if( rText.getLength() )
+ rText = OUString();
+ rText = rText + unicode::formatPercent(GetValue(),
+ Application::GetSettings().GetUILanguageTag());
+ break;
+
+ default:
+ ePres = SFX_ITEM_PRESENTATION_NONE;
+ rText = OUString();
+ break;
+ }
+ return ePres;
+}
+
+SfxItemPresentation SwContrastGrf::GetPresentation(
+ SfxItemPresentation ePres, SfxMapUnit /*eCoreUnit*/, SfxMapUnit /*ePresUnit*/,
+ OUString &rText, const IntlWrapper* /*pIntl*/) const
+{
+ switch( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ if( SFX_ITEM_PRESENTATION_COMPLETE == ePres )
+ rText = SW_RESSTR( STR_CONTRAST );
+ else if( rText.getLength() )
+ rText = OUString();
+ rText = rText + unicode::formatPercent(GetValue(),
+ Application::GetSettings().GetUILanguageTag());
+ break;
+
+ default:
+ ePres = SFX_ITEM_PRESENTATION_NONE;
+ rText = OUString();
+ break;
+ }
+ return ePres;
+}
+
+SfxItemPresentation SwChannelGrf::GetPresentation(
+ SfxItemPresentation ePres, SfxMapUnit /*eCoreUnit*/, SfxMapUnit /*ePresUnit*/,
+ OUString &rText, const IntlWrapper* /*pIntl*/) const
+{
+ switch( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ if( SFX_ITEM_PRESENTATION_COMPLETE == ePres )
+ {
+ sal_uInt16 nId;
+ switch ( Which() )
+ {
+ case RES_GRFATR_CHANNELR: nId = STR_CHANNELR; break;
+ case RES_GRFATR_CHANNELG: nId = STR_CHANNELG; break;
+ case RES_GRFATR_CHANNELB: nId = STR_CHANNELB; break;
+ default: nId = 0; break;
+ }
+ if( nId )
+ rText = SW_RESSTR( nId );
+ else if( rText.getLength() )
+ rText = OUString();
+ }
+ else if( rText.getLength() )
+ rText = OUString();
+ rText = rText + unicode::formatPercent(GetValue(),
+ Application::GetSettings().GetUILanguageTag());
+ break;
+
+ default:
+ ePres = SFX_ITEM_PRESENTATION_NONE;
+ rText = OUString();
+ break;
+ }
+ return ePres;
+}
+
+SfxItemPresentation SwGammaGrf::GetPresentation(
+ SfxItemPresentation ePres, SfxMapUnit /*eCoreUnit*/, SfxMapUnit /*ePresUnit*/,
+ OUString &rText, const IntlWrapper* /*pIntl*/) const
+{
+ OUStringBuffer aText;
+ switch( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ if( SFX_ITEM_PRESENTATION_COMPLETE == ePres )
+ aText.append(SW_RESSTR(STR_GAMMA));
+ aText.append(unicode::formatPercent(GetValue(),
+ Application::GetSettings().GetUILanguageTag()));
+ break;
+
+ default:
+ ePres = SFX_ITEM_PRESENTATION_NONE;
+ break;
+ }
+ rText = aText.makeStringAndClear();
+ return ePres;
+}
+
+SfxItemPresentation SwInvertGrf::GetPresentation(
+ SfxItemPresentation ePres, SfxMapUnit /*eCoreUnit*/, SfxMapUnit /*ePresUnit*/,
+ OUString &rText, const IntlWrapper* /*pIntl*/) const
+{
+ rText = OUString();
+ switch( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ if( SFX_ITEM_PRESENTATION_COMPLETE == ePres )
+ {
+ sal_uInt16 nId = GetValue() ? STR_INVERT : STR_INVERT_NOT;
+ rText = SW_RESSTR( nId );
+ }
+ break;
+
+ default:
+ ePres = SFX_ITEM_PRESENTATION_NONE;
+ break;
+ }
+ return ePres;
+}
+
+SfxItemPresentation SwTransparencyGrf::GetPresentation(
+ SfxItemPresentation ePres, SfxMapUnit /*eCoreUnit*/, SfxMapUnit /*ePresUnit*/,
+ OUString &rText, const IntlWrapper* /*pIntl*/) const
+{
+ switch( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ if( SFX_ITEM_PRESENTATION_COMPLETE == ePres )
+ rText = SW_RESSTR( STR_TRANSPARENCY );
+ else if( rText.getLength() )
+ rText = OUString();
+ rText = rText + unicode::formatPercent(GetValue(),
+ Application::GetSettings().GetUILanguageTag());
+ break;
+
+ default:
+ ePres = SFX_ITEM_PRESENTATION_NONE;
+ rText = OUString();
+ break;
+ }
+ return ePres;
+}
+
+SfxItemPresentation SwDrawModeGrf::GetPresentation(
+ SfxItemPresentation ePres, SfxMapUnit /*eCoreUnit*/, SfxMapUnit /*ePresUnit*/,
+ OUString &rText, const IntlWrapper* /*pIntl*/) const
+{
+ rText = OUString();
+ switch( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ if( SFX_ITEM_PRESENTATION_COMPLETE == ePres )
+ {
+ sal_uInt16 nId;
+ switch ( GetValue() )
+ {
+
+ case GRAPHICDRAWMODE_GREYS: nId = STR_DRAWMODE_GREY; break;
+ case GRAPHICDRAWMODE_MONO: nId = STR_DRAWMODE_BLACKWHITE; break;
+ case GRAPHICDRAWMODE_WATERMARK: nId = STR_DRAWMODE_WATERMARK; break;
+ default: nId = STR_DRAWMODE_STD; break;
+ }
+ rText = SW_RESSTR( STR_DRAWMODE ) + SW_RESSTR( nId );
+ }
+ break;
+
+ default:
+ ePres = SFX_ITEM_PRESENTATION_NONE;
+ break;
+ }
+ return ePres;
+}
+
+SfxItemPresentation SwFmtFollowTextFlow::GetPresentation( SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreMetric*/,
+ SfxMapUnit /*ePresMetric*/,
+ OUString &rText,
+ const IntlWrapper* /*pIntl*/ ) const
+{
+ rText = OUString();
+ switch( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ break;
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ {
+ sal_uInt16 nId = GetValue() ? STR_FOLLOW_TEXT_FLOW : STR_DONT_FOLLOW_TEXT_FLOW;
+ rText = SW_RESSTR( nId );
+ }
+ break;
+
+ default:
+ ePres = SFX_ITEM_PRESENTATION_NONE;
+ break;
+ }
+ return ePres;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/utlui/attrdesc.hrc b/sw/source/core/uibase/utlui/attrdesc.hrc
new file mode 100644
index 000000000000..5f8f5b683657
--- /dev/null
+++ b/sw/source/core/uibase/utlui/attrdesc.hrc
@@ -0,0 +1,115 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef _ATTRDESC_HRC
+#define _ATTRDESC_HRC
+
+#include "rcid.hrc"
+
+#define STR_DROP_OVER (RC_ATTR_BEGIN + 1)
+#define STR_DROP_LINES (RC_ATTR_BEGIN + 2)
+#define STR_NO_DROP_LINES (RC_ATTR_BEGIN + 3)
+#define STR_NO_PAGEDESC (RC_ATTR_BEGIN + 4)
+#define STR_NO_MIRROR (RC_ATTR_BEGIN + 5)
+#define STR_VERT_MIRROR (RC_ATTR_BEGIN + 6)
+#define STR_HORI_MIRROR (RC_ATTR_BEGIN + 7)
+#define STR_BOTH_MIRROR (RC_ATTR_BEGIN + 8)
+#define STR_CHARFMT (RC_ATTR_BEGIN + 9)
+#define STR_NO_CHARFMT (RC_ATTR_BEGIN + 10)
+#define STR_FOOTER (RC_ATTR_BEGIN + 11)
+#define STR_NO_FOOTER (RC_ATTR_BEGIN + 12)
+#define STR_HEADER (RC_ATTR_BEGIN + 13)
+#define STR_NO_HEADER (RC_ATTR_BEGIN + 14)
+#define STR_SURROUND_NONE (RC_ATTR_BEGIN + 15)
+#define STR_SURROUND_THROUGHT (RC_ATTR_BEGIN + 16)
+#define STR_SURROUND_PARALLEL (RC_ATTR_BEGIN + 17)
+#define STR_SURROUND_COLUMN (RC_ATTR_BEGIN + 18)
+#define STR_SURROUND_LEFT (RC_ATTR_BEGIN + 19)
+#define STR_SURROUND_RIGHT (RC_ATTR_BEGIN + 20)
+#define STR_SURROUND_INSIDE (RC_ATTR_BEGIN + 21)
+#define STR_SURROUND_OUTSIDE (RC_ATTR_BEGIN + 22)
+#define STR_FRM_WIDTH (RC_ATTR_BEGIN + 23)
+#define STR_FRM_FIXEDHEIGHT (RC_ATTR_BEGIN + 24)
+#define STR_FRM_MINHEIGHT (RC_ATTR_BEGIN + 25)
+#define STR_FLY_AT_PARA (RC_ATTR_BEGIN + 26)
+#define STR_FLY_AS_CHAR (RC_ATTR_BEGIN + 27)
+#define STR_FLY_AT_PAGE (RC_ATTR_BEGIN + 28)
+#define STR_POS_X (RC_ATTR_BEGIN + 29)
+#define STR_POS_Y (RC_ATTR_BEGIN + 30)
+#define STR_VERT_TOP (RC_ATTR_BEGIN + 31)
+#define STR_VERT_CENTER (RC_ATTR_BEGIN + 32)
+#define STR_VERT_BOTTOM (RC_ATTR_BEGIN + 33)
+#define STR_HORI_RIGHT (RC_ATTR_BEGIN + 34)
+#define STR_HORI_CENTER (RC_ATTR_BEGIN + 35)
+#define STR_HORI_LEFT (RC_ATTR_BEGIN + 36)
+#define STR_HORI_INSIDE (RC_ATTR_BEGIN + 37)
+#define STR_HORI_OUTSIDE (RC_ATTR_BEGIN + 38)
+#define STR_HORI_FULL (RC_ATTR_BEGIN + 39)
+#define STR_COLUMNS (RC_ATTR_BEGIN + 40)
+#define STR_LINE_WIDTH (RC_ATTR_BEGIN + 41)
+#define STR_MAX_FTN_HEIGHT (RC_ATTR_BEGIN + 42)
+#define STR_SURROUND_IDEAL (RC_ATTR_BEGIN + 43)
+#define STR_LINE_TOP (RC_ATTR_BEGIN + 44)
+#define STR_LINE_CENTER (RC_ATTR_BEGIN + 45)
+#define STR_LINE_BOTTOM (RC_ATTR_BEGIN + 46)
+#define STR_REGISTER_ON (RC_ATTR_BEGIN + 47)
+#define STR_REGISTER_OFF (RC_ATTR_BEGIN + 48)
+#define STR_SURROUND_ANCHORONLY (RC_ATTR_BEGIN + 49)
+#define STR_EDIT_IN_READONLY (RC_ATTR_BEGIN + 50)
+#define STR_LAYOUT_SPLIT (RC_ATTR_BEGIN + 51)
+#define STR_NUMRULE_ON (RC_ATTR_BEGIN + 52)
+#define STR_NUMRULE_OFF (RC_ATTR_BEGIN + 53)
+#define STR_CONNECT1 (RC_ATTR_BEGIN + 54)
+#define STR_CONNECT2 (RC_ATTR_BEGIN + 55)
+#define STR_MIRROR_TOGGLE (RC_ATTR_BEGIN + 56)
+#define STR_LINECOUNT (RC_ATTR_BEGIN + 57)
+#define STR_DONTLINECOUNT (RC_ATTR_BEGIN + 58)
+#define STR_LINCOUNT_START (RC_ATTR_BEGIN + 59)
+#define STR_LUMINANCE (RC_ATTR_BEGIN + 60)
+#define STR_CHANNELR (RC_ATTR_BEGIN + 61)
+#define STR_CHANNELG (RC_ATTR_BEGIN + 62)
+#define STR_CHANNELB (RC_ATTR_BEGIN + 63)
+#define STR_CONTRAST (RC_ATTR_BEGIN + 64)
+#define STR_GAMMA (RC_ATTR_BEGIN + 65)
+#define STR_TRANSPARENCY (RC_ATTR_BEGIN + 66)
+#define STR_INVERT (RC_ATTR_BEGIN + 67)
+#define STR_INVERT_NOT (RC_ATTR_BEGIN + 68)
+#define STR_DRAWMODE (RC_ATTR_BEGIN + 69)
+#define STR_DRAWMODE_STD (RC_ATTR_BEGIN + 70)
+#define STR_DRAWMODE_GREY (RC_ATTR_BEGIN + 71)
+#define STR_DRAWMODE_BLACKWHITE (RC_ATTR_BEGIN + 72)
+#define STR_DRAWMODE_WATERMARK (RC_ATTR_BEGIN + 73)
+#define STR_ROTATION (RC_ATTR_BEGIN + 74)
+#define STR_GRID_NONE (RC_ATTR_BEGIN + 75)
+#define STR_GRID_LINES_ONLY (RC_ATTR_BEGIN + 76)
+#define STR_GRID_LINES_CHARS (RC_ATTR_BEGIN + 77)
+#define STR_FOLLOW_TEXT_FLOW (RC_ATTR_BEGIN + 78)
+#define STR_DONT_FOLLOW_TEXT_FLOW (RC_ATTR_BEGIN + 79)
+#define STR_CONNECT_BORDER_ON (RC_ATTR_BEGIN + 80)
+#define STR_CONNECT_BORDER_OFF (RC_ATTR_BEGIN + 81)
+
+#define ATTR_ACT_END STR_CONNECT_BORDER_OFF
+
+#if ATTR_ACT_END > RC_ATTR_END
+#error Resource-Id overflow in #file, #line
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/utlui/attrdesc.src b/sw/source/core/uibase/utlui/attrdesc.src
new file mode 100644
index 000000000000..cd14d9e6add0
--- /dev/null
+++ b/sw/source/core/uibase/utlui/attrdesc.src
@@ -0,0 +1,363 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "globals.hrc"
+#include "attrdesc.hrc"
+
+// Strings for textual attributes.
+
+String STR_DROP_OVER
+{
+ Text [ en-US ] = "Drop Caps over" ;
+};
+String STR_DROP_LINES
+{
+ Text [ en-US ] = "rows" ;
+};
+String STR_NO_DROP_LINES
+{
+ Text [ en-US ] = "No Drop Caps" ;
+};
+String STR_NO_PAGEDESC
+{
+ Text [ en-US ] = "No page break" ;
+};
+String STR_NO_MIRROR
+{
+ Text [ en-US ] = "Don't mirror" ;
+};
+String STR_VERT_MIRROR
+{
+ Text [ en-US ] = "Flip vertically" ;
+};
+String STR_HORI_MIRROR
+{
+ Text [ en-US ] = "Flip horizontal" ;
+};
+String STR_BOTH_MIRROR
+{
+ Text [ en-US ] = "Horizontal and Vertical Flip" ;
+};
+String STR_MIRROR_TOGGLE
+{
+ Text [ en-US ] = "+ mirror horizontal on even pages" ;
+};
+String STR_CHARFMT
+{
+ Text [ en-US ] = "Character Style" ;
+};
+String STR_NO_CHARFMT
+{
+ Text [ en-US ] = "No Character Style" ;
+};
+String STR_FOOTER
+{
+ Text [ en-US ] = "Footer" ;
+};
+String STR_NO_FOOTER
+{
+ Text [ en-US ] = "No footer" ;
+};
+String STR_HEADER
+{
+ Text [ en-US ] = "Header" ;
+};
+String STR_NO_HEADER
+{
+ Text [ en-US ] = "No header" ;
+};
+String STR_SURROUND_IDEAL
+{
+ Text [ en-US ] = "Optimal wrap" ;
+};
+String STR_SURROUND_NONE
+{
+ Text [ en-US ] = "No wrap" ;
+};
+String STR_SURROUND_THROUGHT
+{
+ Text [ en-US ] = "Through" ;
+};
+String STR_SURROUND_PARALLEL
+{
+ Text [ en-US ] = "Parallel wrap" ;
+};
+String STR_SURROUND_COLUMN
+{
+ Text [ en-US ] = "Column Wrap" ;
+};
+String STR_SURROUND_LEFT
+{
+ Text [ en-US ] = "Left wrap" ;
+};
+String STR_SURROUND_RIGHT
+{
+ Text [ en-US ] = "Right wrap" ;
+};
+String STR_SURROUND_INSIDE
+{
+ Text [ en-US ] = "Inner wrap" ;
+};
+String STR_SURROUND_OUTSIDE
+{
+ Text [ en-US ] = "Outer wrap" ;
+};
+String STR_SURROUND_ANCHORONLY
+{
+ Text [ en-US ] = "(Anchor only)" ;
+};
+String STR_FRM_WIDTH
+{
+ Text [ en-US ] = "Width:" ;
+};
+String STR_FRM_FIXEDHEIGHT
+{
+ Text [ en-US ] = "Fixed height:" ;
+};
+String STR_FRM_MINHEIGHT
+{
+ Text [ en-US ] = "Min. height:" ;
+};
+String STR_FLY_AT_PARA
+{
+ Text [ en-US ] = "to paragraph" ;
+};
+String STR_FLY_AS_CHAR
+{
+ Text [ en-US ] = "to character" ;
+};
+String STR_FLY_AT_PAGE
+{
+ Text [ en-US ] = "to page" ;
+};
+String STR_POS_X
+{
+ Text [ en-US ] = "X Coordinate:" ;
+};
+String STR_POS_Y
+{
+ Text [ en-US ] = "Y Coordinate:" ;
+};
+String STR_VERT_TOP
+{
+ Text [ en-US ] = "at top" ;
+};
+String STR_VERT_CENTER
+{
+ Text [ en-US ] = "Centered vertically" ;
+};
+String STR_VERT_BOTTOM
+{
+ Text [ en-US ] = "at bottom" ;
+};
+String STR_LINE_TOP
+{
+ Text [ en-US ] = "Top of line" ;
+};
+String STR_LINE_CENTER
+{
+ Text [ en-US ] = "Line centered" ;
+};
+String STR_LINE_BOTTOM
+{
+ Text [ en-US ] = "Bottom of line" ;
+};
+String STR_REGISTER_ON
+{
+ Text [ en-US ] = "Register-true" ;
+};
+String STR_REGISTER_OFF
+{
+ Text [ en-US ] = "Not register-true" ;
+};
+String STR_HORI_RIGHT
+{
+ Text [ en-US ] = "at the right" ;
+};
+String STR_HORI_CENTER
+{
+ Text [ en-US ] = "Centered horizontally" ;
+};
+String STR_HORI_LEFT
+{
+ Text [ en-US ] = "at the left" ;
+};
+String STR_HORI_INSIDE
+{
+ Text [ en-US ] = "inside" ;
+};
+String STR_HORI_OUTSIDE
+{
+ Text [ en-US ] = "outside" ;
+};
+String STR_HORI_FULL
+{
+ Text [ en-US ] = "Full width" ;
+};
+String STR_COLUMNS
+{
+ Text [ en-US ] = "Columns" ;
+};
+String STR_LINE_WIDTH
+{
+ Text [ en-US ] = "Separator Width:" ;
+};
+String STR_MAX_FTN_HEIGHT
+{
+ Text [ en-US ] = "Max. footnote area:" ;
+};
+String STR_EDIT_IN_READONLY
+{
+ Text [ en-US ] = "Editable in read-only document" ;
+};
+String STR_LAYOUT_SPLIT
+{
+ Text [ en-US ] = "Split" ;
+};
+String STR_NUMRULE_ON
+{
+ Text [ en-US ] = "Numbering" ;
+};
+String STR_NUMRULE_OFF
+{
+ Text [ en-US ] = "no numbering" ;
+};
+String STR_CONNECT1
+{
+ Text [ en-US ] = "linked to " ;
+};
+String STR_CONNECT2
+{
+ Text [ en-US ] = "and " ;
+};
+String STR_LINECOUNT
+{
+ Text [ en-US ] = "Count lines" ;
+};
+String STR_DONTLINECOUNT
+{
+ Text [ en-US ] = "don't count lines" ;
+};
+String STR_LINCOUNT_START
+{
+ Text [ en-US ] = "restart line count with: " ;
+};
+
+String STR_LUMINANCE
+{
+ Text [ en-US ] = "Brightness: ";
+};
+
+String STR_CHANNELR
+{
+ Text [ en-US ] = "Red: ";
+};
+
+String STR_CHANNELG
+{
+ Text [ en-US ] = "Green: ";
+};
+
+String STR_CHANNELB
+{
+ Text [ en-US ] = "Blue: ";
+};
+
+String STR_CONTRAST
+{
+ Text [ en-US ] = "Contrast: ";
+};
+
+String STR_GAMMA
+{
+ Text [ en-US ] = "Gamma: ";
+};
+
+String STR_TRANSPARENCY
+{
+ Text [ en-US ] = "Transparency: ";
+};
+
+String STR_INVERT
+{
+ Text [ en-US ] = "Invert";
+};
+String STR_INVERT_NOT
+{
+ Text [ en-US ] = "do not invert";
+};
+
+String STR_DRAWMODE
+{
+ Text [ en-US ] = "Graphics mode: ";
+};
+
+String STR_DRAWMODE_STD
+{
+ Text [ en-US ] = "Standard";
+};
+String STR_DRAWMODE_GREY
+{
+ Text [ en-US ] = "Grayscales";
+};
+String STR_DRAWMODE_BLACKWHITE
+{
+ Text [ en-US ] = "Black & White";
+};
+String STR_DRAWMODE_WATERMARK
+{
+ Text [ en-US ] = "Watermark";
+};
+String STR_ROTATION
+{
+ Text [ en-US ] = "Rotation";
+};
+
+String STR_GRID_NONE
+{
+ Text [ en-US ] = "No grid";
+};
+
+String STR_GRID_LINES_ONLY
+{
+ Text [ en-US ] = "Grid (lines only)";
+};
+
+String STR_GRID_LINES_CHARS
+{
+ Text [ en-US ] = "Grid (lines and characters)";
+};
+String STR_FOLLOW_TEXT_FLOW
+{
+ Text [ en-US ] = "Follow text flow";
+};
+String STR_DONT_FOLLOW_TEXT_FLOW
+{
+ Text [ en-US ] = "Do not follow text flow";
+};
+String STR_CONNECT_BORDER_ON
+{
+ Text [ en-US ] = "Merge borders";
+};
+String STR_CONNECT_BORDER_OFF
+{
+ Text [ en-US ] = "Do not merge borders";
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/utlui/bookctrl.cxx b/sw/source/core/uibase/utlui/bookctrl.cxx
new file mode 100644
index 000000000000..1e5770f62f1a
--- /dev/null
+++ b/sw/source/core/uibase/utlui/bookctrl.cxx
@@ -0,0 +1,128 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "hintids.hxx"
+
+#include <svl/intitem.hxx>
+#include <svl/stritem.hxx>
+#include <sfx2/dispatch.hxx>
+#include <vcl/event.hxx>
+#include <vcl/status.hxx>
+#include <vcl/menu.hxx>
+#include "cmdid.h"
+#include "swmodule.hxx"
+#include "wrtsh.hxx"
+#include "IMark.hxx"
+#include "bookctrl.hxx"
+#include <map>
+
+SFX_IMPL_STATUSBAR_CONTROL( SwBookmarkControl, SfxStringItem );
+
+class BookmarkPopup_Impl : public PopupMenu
+{
+public:
+ BookmarkPopup_Impl();
+
+ sal_uInt16 GetCurId() const { return nCurId; }
+
+private:
+ sal_uInt16 nCurId;
+
+ virtual void Select();
+};
+
+BookmarkPopup_Impl::BookmarkPopup_Impl() :
+ PopupMenu(),
+ nCurId(USHRT_MAX)
+{
+}
+
+void BookmarkPopup_Impl::Select()
+{
+ nCurId = GetCurItemId();
+}
+
+SwBookmarkControl::SwBookmarkControl( sal_uInt16 _nSlotId,
+ sal_uInt16 _nId,
+ StatusBar& rStb ) :
+ SfxStatusBarControl( _nSlotId, _nId, rStb )
+{
+}
+
+SwBookmarkControl::~SwBookmarkControl()
+{
+}
+
+void SwBookmarkControl::StateChanged(
+ sal_uInt16 /*nSID*/, SfxItemState eState, const SfxPoolItem* pState )
+{
+ if( eState != SFX_ITEM_AVAILABLE || pState->ISA( SfxVoidItem ) )
+ GetStatusBar().SetItemText( GetId(), OUString() );
+ else if ( pState->ISA( SfxStringItem ) )
+ {
+ sPageNumber = ((SfxStringItem*)pState)->GetValue();
+ GetStatusBar().SetItemText( GetId(), sPageNumber );
+ }
+}
+
+void SwBookmarkControl::Paint( const UserDrawEvent& )
+{
+ GetStatusBar().SetItemText( GetId(), sPageNumber );
+}
+
+void SwBookmarkControl::Command( const CommandEvent& rCEvt )
+{
+ if ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU &&
+ !GetStatusBar().GetItemText( GetId() ).isEmpty() )
+ {
+ CaptureMouse();
+ BookmarkPopup_Impl aPop;
+ SwWrtShell* pWrtShell = ::GetActiveWrtShell();
+ if( pWrtShell && pWrtShell->getIDocumentMarkAccess()->getAllMarksCount() > 0 )
+ {
+ IDocumentMarkAccess* const pMarkAccess = pWrtShell->getIDocumentMarkAccess();
+ IDocumentMarkAccess::const_iterator_t ppBookmarkStart = pMarkAccess->getBookmarksBegin();
+ sal_uInt16 nPopupId = 1;
+ ::std::map<sal_Int32, sal_uInt16> aBookmarkIdx;
+ for(IDocumentMarkAccess::const_iterator_t ppBookmark = ppBookmarkStart;
+ ppBookmark != pMarkAccess->getBookmarksEnd();
+ ++ppBookmark)
+ {
+ if(IDocumentMarkAccess::BOOKMARK == IDocumentMarkAccess::GetType(**ppBookmark))
+ {
+ aPop.InsertItem( nPopupId, ppBookmark->get()->GetName() );
+ aBookmarkIdx[nPopupId] = static_cast<sal_uInt16>(ppBookmark - ppBookmarkStart);
+ nPopupId++;
+ }
+ }
+ aPop.Execute( &GetStatusBar(), rCEvt.GetMousePosPixel());
+ sal_uInt16 nCurrId = aPop.GetCurId();
+ if( nCurrId != USHRT_MAX)
+ {
+ SfxUInt16Item aBookmark( FN_STAT_BOOKMARK, aBookmarkIdx[nCurrId] );
+ SfxViewFrame::Current()->GetDispatcher()->Execute( FN_STAT_BOOKMARK,
+ SFX_CALLMODE_ASYNCHRON|SFX_CALLMODE_RECORD,
+ &aBookmark, 0L );
+ }
+ }
+ ReleaseMouse();
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/utlui/condedit.cxx b/sw/source/core/uibase/utlui/condedit.cxx
new file mode 100644
index 000000000000..5aa7ff1abb0b
--- /dev/null
+++ b/sw/source/core/uibase/utlui/condedit.cxx
@@ -0,0 +1,90 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <sot/formats.hxx>
+
+#include <condedit.hxx>
+#include <svx/dbaexchange.hxx>
+#include <vcl/builder.hxx>
+
+using namespace ::svx;
+using namespace ::com::sun::star::uno;
+
+ConditionEdit::ConditionEdit(Window* pParent, WinBits nStyle)
+ : Edit(pParent, nStyle)
+ , DropTargetHelper(this)
+ , bBrackets(true)
+ , bEnableDrop(true)
+{
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeConditionEdit(Window *pParent, VclBuilder::stringmap &rMap)
+{
+ VclBuilder::ensureDefaultWidthChars(rMap);
+ return new ConditionEdit(pParent, WB_LEFT|WB_VCENTER|WB_BORDER|WB_3DLOOK);
+}
+
+// Drop possible, respectively format known?
+
+sal_Int8 ConditionEdit::AcceptDrop( const AcceptDropEvent& /*rEvt*/ )
+{
+ return OColumnTransferable::canExtractColumnDescriptor
+ ( GetDataFlavorExVector(),
+ CTF_COLUMN_DESCRIPTOR )
+ ? DND_ACTION_COPY
+ : DND_ACTION_NONE;
+}
+
+sal_Int8 ConditionEdit::ExecuteDrop( const ExecuteDropEvent& rEvt )
+{
+ sal_Int8 nRet = DND_ACTION_NONE;
+ if( bEnableDrop )
+ {
+ TransferableDataHelper aData( rEvt.maDropEvent.Transferable );
+
+ DataFlavorExVector& rVector = aData.GetDataFlavorExVector();
+ if(OColumnTransferable::canExtractColumnDescriptor(rVector, CTF_COLUMN_DESCRIPTOR))
+ {
+ ODataAccessDescriptor aColDesc = OColumnTransferable::extractColumnDescriptor(
+ aData);
+ OUString sDBName;
+ if (bBrackets)
+ sDBName += "[";
+ OUString sTmp;
+ sTmp = aColDesc.getDataSource();
+ sDBName += sTmp;
+ sDBName += ".";
+
+ aColDesc[daCommand] >>= sTmp;
+ sDBName += sTmp;
+ sDBName += ".";
+
+ aColDesc[daColumnName] >>= sTmp;
+ sDBName += sTmp;
+ if (bBrackets)
+ sDBName += "]";
+
+ SetText( sDBName );
+ nRet = DND_ACTION_COPY;
+ }
+ }
+ return nRet;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/utlui/content.cxx b/sw/source/core/uibase/utlui/content.cxx
new file mode 100644
index 000000000000..60ac680ffd66
--- /dev/null
+++ b/sw/source/core/uibase/utlui/content.cxx
@@ -0,0 +1,3517 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <comphelper/string.hxx>
+#include <svl/urlbmk.hxx>
+#include <osl/thread.h>
+#include <tools/urlobj.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/dispatch.hxx>
+#include <vcl/help.hxx>
+#include <vcl/settings.hxx>
+#include <sot/formats.hxx>
+#include <uiitems.hxx>
+#include <fmtinfmt.hxx>
+#include <txtinet.hxx>
+#include <fmtfld.hxx>
+#include <swmodule.hxx>
+#include <wrtsh.hxx>
+#include <view.hxx>
+#include <docsh.hxx>
+#include <content.hxx>
+#include <frmfmt.hxx>
+#include <fldbas.hxx>
+#include <txtatr.hxx>
+#include <IMark.hxx>
+#include <section.hxx>
+#include <tox.hxx>
+#include <navipi.hxx>
+#include <navicont.hxx>
+#include <navicfg.hxx>
+#include <edtwin.hxx>
+#include <doc.hxx>
+#include <unotools.hxx>
+#include <crsskip.hxx>
+#include <cmdid.h>
+#include <helpid.h>
+#include <navipi.hrc>
+#include <utlui.hrc>
+#include <misc.hrc>
+#include <comcore.hrc>
+#include <com/sun/star/text/XTextSectionsSupplier.hpp>
+#include <com/sun/star/text/XTextGraphicObjectsSupplier.hpp>
+#include <com/sun/star/text/XTextTablesSupplier.hpp>
+#include <com/sun/star/text/XDocumentIndexesSupplier.hpp>
+#include <com/sun/star/text/XDocumentIndex.hpp>
+#include <com/sun/star/text/XBookmarksSupplier.hpp>
+#include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp>
+#include <com/sun/star/text/XTextFramesSupplier.hpp>
+#include <dcontact.hxx>
+#include <svx/svdogrp.hxx>
+#include <svx/svdmodel.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdview.hxx>
+#include <vcl/scrbar.hxx>
+#include <SwRewriter.hxx>
+#include <hints.hxx>
+#include <numrule.hxx>
+#include <swundo.hxx>
+#include <ndtxt.hxx>
+#include <fmtcntnt.hxx>
+#include <PostItMgr.hxx>
+#include <postithelper.hxx>
+#include <redline.hxx>
+#include <docary.hxx>
+#include <o3tl/sorted_vector.hxx>
+#include "svtools/treelistentry.hxx"
+
+#include "swabstdlg.hxx"
+#include "globals.hrc"
+#include <unomid.h>
+
+#include "navmgr.hxx"
+
+#define CTYPE_CNT 0
+#define CTYPE_CTT 1
+
+using namespace ::std;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::text;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::container;
+
+#define NAVI_BOOKMARK_DELIM (sal_Unicode)1
+
+class SwContentArr
+ : public o3tl::sorted_vector<SwContent*, o3tl::less_ptr_to<SwContent>,
+ o3tl::find_partialorder_ptrequals>
+{
+public:
+ ~SwContentArr() { DeleteAndDestroyAll(); }
+};
+
+bool SwContentTree::bIsInDrag = false;
+
+namespace
+{
+ static bool lcl_IsContent(const SvTreeListEntry* pEntry)
+ {
+ return ((const SwTypeNumber*)pEntry->GetUserData())->GetTypeId() == CTYPE_CNT;
+ }
+
+ static bool lcl_IsContentType(const SvTreeListEntry* pEntry)
+ {
+ return ((const SwTypeNumber*)pEntry->GetUserData())->GetTypeId() == CTYPE_CTT;
+ }
+
+ static bool lcl_FindShell(SwWrtShell* pShell)
+ {
+ bool bFound = false;
+ SwView *pView = SwModule::GetFirstView();
+ while (pView)
+ {
+ if(pShell == &pView->GetWrtShell())
+ {
+ bFound = true;
+ break;
+ }
+ pView = SwModule::GetNextView(pView);
+ }
+ return bFound;
+ }
+
+ static bool lcl_IsUiVisibleBookmark(const IDocumentMarkAccess::pMark_t& rpMark)
+ {
+ return IDocumentMarkAccess::GetType(*rpMark) == IDocumentMarkAccess::BOOKMARK;
+ }
+}
+
+// Content, contains names and reference at the content type.
+
+SwContent::SwContent(const SwContentType* pCnt, const OUString& rName, long nYPos) :
+ SwTypeNumber(CTYPE_CNT),
+ pParent(pCnt),
+ sContentName(rName),
+ nYPosition(nYPos),
+ bInvisible(sal_False)
+{
+}
+
+sal_uInt8 SwTypeNumber::GetTypeId() const
+{
+ return nTypeId;
+}
+
+SwTypeNumber::~SwTypeNumber()
+{
+}
+
+sal_Bool SwContent::IsProtect() const
+{
+ return sal_False;
+}
+
+sal_Bool SwPostItContent::IsProtect() const
+{
+ if (mbPostIt)
+ return pFld->IsProtect();
+ else
+ return false;
+}
+
+sal_Bool SwURLFieldContent::IsProtect() const
+{
+ return pINetAttr->IsProtect();
+}
+
+SwGraphicContent::~SwGraphicContent()
+{
+}
+
+SwTOXBaseContent::~SwTOXBaseContent()
+{
+}
+
+// Content type, knows it's contents and the WrtShell.
+
+SwContentType::SwContentType(SwWrtShell* pShell, sal_uInt16 nType, sal_uInt8 nLevel) :
+ SwTypeNumber(CTYPE_CTT),
+ pWrtShell(pShell),
+ pMember(0),
+ sContentTypeName(SW_RES(STR_CONTENT_TYPE_FIRST + nType)),
+ sSingleContentTypeName(SW_RES(STR_CONTENT_TYPE_SINGLE_FIRST + nType)),
+ nMemberCount(0),
+ nContentType(nType),
+ nOutlineLevel(nLevel),
+ bDataValid(false),
+ bEdit(false),
+ bDelete(true)
+{
+ Init();
+}
+
+// Init
+
+void SwContentType::Init(sal_Bool* pbInvalidateWindow)
+{
+ // if the MemberCount is changing ...
+ sal_uInt16 nOldMemberCount = nMemberCount;
+ nMemberCount = 0;
+ switch(nContentType)
+ {
+ case CONTENT_TYPE_OUTLINE :
+ {
+ sTypeToken = "outline";
+ sal_uInt16 nOutlineCount = nMemberCount =
+ static_cast<sal_uInt16>(pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineNodesCount());
+ if(nOutlineLevel < MAXLEVEL)
+ {
+ for(sal_uInt16 j = 0; j < nOutlineCount; j++)
+ {
+ if(pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineLevel(j) > nOutlineLevel )
+ nMemberCount --;
+ }
+ }
+ bDelete = false;
+ }
+ break;
+
+ case CONTENT_TYPE_TABLE :
+ sTypeToken = "table";
+ nMemberCount = pWrtShell->GetTblFrmFmtCount(true);
+ bEdit = true;
+ break;
+
+ case CONTENT_TYPE_FRAME :
+ case CONTENT_TYPE_GRAPHIC :
+ case CONTENT_TYPE_OLE :
+ {
+ FlyCntType eType = FLYCNTTYPE_FRM;
+ sTypeToken = "frame";
+ if(nContentType == CONTENT_TYPE_OLE)
+ {
+ eType = FLYCNTTYPE_OLE;
+ sTypeToken = "ole";
+ }
+ else if(nContentType == CONTENT_TYPE_GRAPHIC)
+ {
+ eType = FLYCNTTYPE_GRF;
+ sTypeToken = "graphic";
+ }
+ nMemberCount = pWrtShell->GetFlyCount(eType);
+ bEdit = true;
+ }
+ break;
+ case CONTENT_TYPE_BOOKMARK:
+ {
+ IDocumentMarkAccess* const pMarkAccess = pWrtShell->getIDocumentMarkAccess();
+ nMemberCount = static_cast<sal_uInt16>(count_if(
+ pMarkAccess->getBookmarksBegin(),
+ pMarkAccess->getBookmarksEnd(),
+ &lcl_IsUiVisibleBookmark));
+ sTypeToken = OUString();
+ bEdit = true;
+ }
+ break;
+ case CONTENT_TYPE_REGION :
+ {
+ SwContentArr* pOldMember = 0;
+ sal_uInt16 nOldRegionCount = 0;
+ bool bInvalidate = false;
+ if(!pMember)
+ pMember = new SwContentArr;
+ else if(!pMember->empty())
+ {
+ pOldMember = pMember;
+ nOldRegionCount = pOldMember->size();
+ pMember = new SwContentArr;
+ }
+ const Point aNullPt;
+ nMemberCount = pWrtShell->GetSectionFmtCount();
+ for(sal_uInt16 i = 0; i < nMemberCount; i++)
+ {
+ const SwSectionFmt* pFmt;
+ SectionType eTmpType;
+ if( (pFmt = &pWrtShell->GetSectionFmt(i))->IsInNodesArr() &&
+ (eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION
+ && TOX_HEADER_SECTION != eTmpType )
+ {
+ const OUString& rSectionName =
+ pFmt->GetSection()->GetSectionName();
+ sal_uInt8 nLevel = 0;
+ SwSectionFmt* pParentFmt = pFmt->GetParent();
+ while(pParentFmt)
+ {
+ nLevel++;
+ pParentFmt = pParentFmt->GetParent();
+ }
+
+ SwContent* pCnt = new SwRegionContent(this, rSectionName,
+ nLevel,
+ pFmt->FindLayoutRect( sal_False, &aNullPt ).Top());
+
+ SwPtrMsgPoolItem aAskItem( RES_CONTENT_VISIBLE, 0 );
+ if( !pFmt->GetInfo( aAskItem ) &&
+ !aAskItem.pObject ) // not visible
+ pCnt->SetInvisible();
+ pMember->insert(pCnt);
+
+ sal_uInt16 nPos = pMember->size() - 1;
+ if(nOldRegionCount > nPos &&
+ ((*pOldMember)[nPos])->IsInvisible()
+ != pCnt->IsInvisible())
+ bInvalidate = true;
+ }
+ }
+ nMemberCount = pMember->size();
+ sTypeToken = "region";
+ bEdit = true;
+ bDelete = false;
+ if(pOldMember)
+ {
+ pOldMember->DeleteAndDestroyAll();
+ delete pOldMember;
+ if(pbInvalidateWindow && bInvalidate)
+ *pbInvalidateWindow = sal_True;
+ }
+ }
+ break;
+ case CONTENT_TYPE_INDEX:
+ {
+ nMemberCount = pWrtShell->GetTOXCount();
+ bEdit = true;
+ bDelete = false;
+ }
+ break;
+ case CONTENT_TYPE_REFERENCE:
+ {
+ nMemberCount = pWrtShell->GetRefMarks( 0 );
+ bDelete = false;
+ }
+ break;
+ case CONTENT_TYPE_URLFIELD:
+ {
+ nMemberCount = 0;
+ if(!pMember)
+ pMember = new SwContentArr;
+ else if(!pMember->empty())
+ pMember->DeleteAndDestroyAll();
+
+ SwGetINetAttrs aArr;
+ nMemberCount = pWrtShell->GetINetAttrs( aArr );
+ for( sal_uInt16 n = 0; n < nMemberCount; ++n )
+ {
+ SwGetINetAttr* p = &aArr[ n ];
+ SwURLFieldContent* pCnt = new SwURLFieldContent(
+ this,
+ p->sText,
+ INetURLObject::decode(
+ p->rINetAttr.GetINetFmt().GetValue(),
+ INET_HEX_ESCAPE,
+ INetURLObject::DECODE_UNAMBIGUOUS,
+ RTL_TEXTENCODING_UTF8 ),
+ &p->rINetAttr,
+ n );
+ pMember->insert( pCnt );
+ }
+ bEdit = true;
+ nOldMemberCount = nMemberCount;
+ bDelete = false;
+ }
+ break;
+ case CONTENT_TYPE_POSTIT:
+ {
+ nMemberCount = 0;
+ if(!pMember)
+ pMember = new SwContentArr;
+ else if(!pMember->empty())
+ pMember->DeleteAndDestroyAll();
+
+ SwPostItMgr* aMgr = pWrtShell->GetView().GetPostItMgr();
+ if (aMgr)
+ {
+ for(SwPostItMgr::const_iterator i = aMgr->begin(); i != aMgr->end(); ++i)
+ {
+ if ( (*i)->GetBroadCaster()->ISA(SwFmtFld)) // SwPostit
+ {
+ const SwFmtFld* aFmtFld = static_cast<const SwFmtFld*>((*i)->GetBroadCaster());
+ if (aFmtFld->GetTxtFld() && aFmtFld->IsFldInDoc() &&
+ (*i)->mLayoutStatus!=SwPostItHelper::INVISIBLE )
+ {
+ OUString sEntry = aFmtFld->GetField()->GetPar2();
+ sEntry = RemoveNewline(sEntry);
+ SwPostItContent* pCnt = new SwPostItContent(
+ this,
+ sEntry,
+ aFmtFld,
+ nMemberCount);
+ pMember->insert(pCnt);
+ nMemberCount++;
+ }
+ }
+ }
+ }
+ sTypeToken = OUString();
+ bEdit = true;
+ nOldMemberCount = nMemberCount;
+ }
+ break;
+ case CONTENT_TYPE_DRAWOBJECT:
+ {
+ sTypeToken = OUString();
+ nMemberCount = 0;
+ SdrModel* pModel = pWrtShell->getIDocumentDrawModelAccess()->GetDrawModel();
+ if(pModel)
+ {
+ SdrPage* pPage = pModel->GetPage(0);
+ sal_uInt32 nCount = pPage->GetObjCount();
+ for( sal_uInt32 i=0; i< nCount; i++ )
+ {
+ SdrObject* pTemp = pPage->GetObj(i);
+ // #i51726# - all drawing objects can be named now
+ if (!pTemp->GetName().isEmpty())
+ nMemberCount++;
+ }
+ }
+ }
+ break;
+ }
+ // ... then, the data can also no longer be valid,
+ // apart from those which have already been corrected,
+ // then nOldMemberCount is nevertheless not so old.
+ if( nOldMemberCount != nMemberCount )
+ bDataValid = false;
+}
+
+SwContentType::~SwContentType()
+{
+ delete pMember;
+}
+
+// Deliver content, for that if necessary fill the list
+
+const SwContent* SwContentType::GetMember(sal_uInt16 nIndex)
+{
+ if(!bDataValid || !pMember)
+ {
+ FillMemberList();
+ }
+ if(nIndex < pMember->size())
+ return (*pMember)[nIndex];
+ else
+ return 0;
+
+}
+
+void SwContentType::Invalidate()
+{
+ bDataValid = false;
+}
+
+// Fill the List of contents
+
+void SwContentType::FillMemberList(sal_Bool* pbLevelOrVisibilityChanged)
+{
+ SwContentArr* pOldMember = 0;
+ int nOldMemberCount = -1;
+ SwPtrMsgPoolItem aAskItem( RES_CONTENT_VISIBLE, 0 );
+ if(pMember && pbLevelOrVisibilityChanged)
+ {
+ pOldMember = pMember;
+ nOldMemberCount = pOldMember->size();
+ pMember = new SwContentArr;
+ *pbLevelOrVisibilityChanged = sal_False;
+ }
+ else if(!pMember)
+ pMember = new SwContentArr;
+ else if(!pMember->empty())
+ pMember->DeleteAndDestroyAll();
+ switch(nContentType)
+ {
+ case CONTENT_TYPE_OUTLINE :
+ {
+ sal_uInt16 nOutlineCount = nMemberCount =
+ static_cast<sal_uInt16>(pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineNodesCount());
+
+ sal_uInt16 nPos = 0;
+ for (sal_uInt16 i = 0; i < nOutlineCount; ++i)
+ {
+ const sal_Int8 nLevel = (sal_Int8)pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineLevel(i);
+ if(nLevel >= nOutlineLevel )
+ nMemberCount--;
+ else
+ {
+ OUString aEntry(comphelper::string::stripStart(
+ pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineText(i), ' '));
+ aEntry = SwNavigationPI::CleanEntry(aEntry);
+ SwOutlineContent* pCnt = new SwOutlineContent(this, aEntry, i, nLevel,
+ pWrtShell->IsOutlineMovable( i ), nPos );
+ pMember->insert(pCnt);//, nPos);
+ // with the same number and existing "pOldMember" the
+ // old one is compared with the new OutlinePos.
+ // cast for Win16
+ if(nOldMemberCount > (int)nPos &&
+ ((SwOutlineContent*)(*pOldMember)[nPos])->GetOutlineLevel() != nLevel)
+ *pbLevelOrVisibilityChanged = sal_True;
+
+ nPos++;
+ }
+ }
+
+ }
+ break;
+
+ case CONTENT_TYPE_TABLE :
+ {
+ OSL_ENSURE(nMemberCount == pWrtShell->GetTblFrmFmtCount(true),
+ "MemberCount differs");
+ Point aNullPt;
+ nMemberCount = pWrtShell->GetTblFrmFmtCount(true);
+ for(sal_uInt16 i = 0; i < nMemberCount; i++)
+ {
+ const SwFrmFmt& rTblFmt = pWrtShell->GetTblFrmFmt(i, true);
+ const OUString sTblName( rTblFmt.GetName() );
+
+ SwContent* pCnt = new SwContent(this, sTblName,
+ rTblFmt.FindLayoutRect(sal_False, &aNullPt).Top() );
+ if( !rTblFmt.GetInfo( aAskItem ) &&
+ !aAskItem.pObject ) // not visible
+ pCnt->SetInvisible();
+
+ pMember->insert(pCnt);
+
+ if(nOldMemberCount > (int)i &&
+ (*pOldMember)[i]->IsInvisible() != pCnt->IsInvisible())
+ *pbLevelOrVisibilityChanged = sal_True;
+ }
+ }
+ break;
+ case CONTENT_TYPE_OLE :
+ case CONTENT_TYPE_FRAME :
+ case CONTENT_TYPE_GRAPHIC :
+ {
+ FlyCntType eType = FLYCNTTYPE_FRM;
+ if(nContentType == CONTENT_TYPE_OLE)
+ eType = FLYCNTTYPE_OLE;
+ else if(nContentType == CONTENT_TYPE_GRAPHIC)
+ eType = FLYCNTTYPE_GRF;
+ OSL_ENSURE(nMemberCount == pWrtShell->GetFlyCount(eType),
+ "MemberCount differs");
+ Point aNullPt;
+ nMemberCount = pWrtShell->GetFlyCount(eType);
+ for(sal_uInt16 i = 0; i < nMemberCount; i++)
+ {
+ const SwFrmFmt* pFrmFmt = pWrtShell->GetFlyNum(i,eType);
+ const OUString sFrmName = pFrmFmt->GetName();
+
+ SwContent* pCnt;
+ if(CONTENT_TYPE_GRAPHIC == nContentType)
+ {
+ OUString sLink;
+ pWrtShell->GetGrfNms( &sLink, 0, (SwFlyFrmFmt*) pFrmFmt);
+ pCnt = new SwGraphicContent(this, sFrmName,
+ INetURLObject::decode( sLink, INET_HEX_ESCAPE,
+ INetURLObject::DECODE_UNAMBIGUOUS,
+ RTL_TEXTENCODING_UTF8 ),
+ pFrmFmt->FindLayoutRect(sal_False, &aNullPt).Top());
+ }
+ else
+ {
+ pCnt = new SwContent(this, sFrmName,
+ pFrmFmt->FindLayoutRect(sal_False, &aNullPt).Top() );
+ }
+ if( !pFrmFmt->GetInfo( aAskItem ) &&
+ !aAskItem.pObject ) // not visible
+ pCnt->SetInvisible();
+ pMember->insert(pCnt);
+ if(nOldMemberCount > (int)i &&
+ (*pOldMember)[i]->IsInvisible() != pCnt->IsInvisible())
+ *pbLevelOrVisibilityChanged = sal_True;
+ }
+ }
+ break;
+ case CONTENT_TYPE_BOOKMARK:
+ {
+ IDocumentMarkAccess* const pMarkAccess = pWrtShell->getIDocumentMarkAccess();
+ for(IDocumentMarkAccess::const_iterator_t ppBookmark = pMarkAccess->getBookmarksBegin();
+ ppBookmark != pMarkAccess->getBookmarksEnd();
+ ++ppBookmark)
+ {
+ if(lcl_IsUiVisibleBookmark(*ppBookmark))
+ {
+ const OUString& rBkmName = ppBookmark->get()->GetName();
+ //nYPos from 0 -> text::Bookmarks will be sorted alphabetically
+ SwContent* pCnt = new SwContent(this, rBkmName, 0);
+ pMember->insert(pCnt);
+ }
+ }
+ }
+ break;
+ case CONTENT_TYPE_REGION :
+ {
+ const Point aNullPt;
+ nMemberCount = pWrtShell->GetSectionFmtCount();
+ for(sal_uInt16 i = 0; i < nMemberCount; i++)
+ {
+ const SwSectionFmt* pFmt;
+ SectionType eTmpType;
+ if( (pFmt = &pWrtShell->GetSectionFmt(i))->IsInNodesArr() &&
+ (eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION
+ && TOX_HEADER_SECTION != eTmpType )
+ {
+ OUString sSectionName = pFmt->GetSection()->GetSectionName();
+
+ sal_uInt8 nLevel = 0;
+ SwSectionFmt* pParentFmt = pFmt->GetParent();
+ while(pParentFmt)
+ {
+ nLevel++;
+ pParentFmt = pParentFmt->GetParent();
+ }
+
+ SwContent* pCnt = new SwRegionContent(this, sSectionName,
+ nLevel,
+ pFmt->FindLayoutRect( sal_False, &aNullPt ).Top());
+ if( !pFmt->GetInfo( aAskItem ) &&
+ !aAskItem.pObject ) // not visible
+ pCnt->SetInvisible();
+ pMember->insert(pCnt);
+
+ sal_uInt16 nPos = pMember->size() - 1;
+ if(nOldMemberCount > nPos &&
+ (*pOldMember)[nPos]->IsInvisible()
+ != pCnt->IsInvisible())
+ *pbLevelOrVisibilityChanged = sal_True;
+ }
+ }
+ nMemberCount = pMember->size();
+ }
+ break;
+ case CONTENT_TYPE_REFERENCE:
+ {
+ std::vector<OUString> aRefMarks;
+ nMemberCount = pWrtShell->GetRefMarks( &aRefMarks );
+
+ for(std::vector<OUString>::const_iterator i = aRefMarks.begin(); i != aRefMarks.end(); ++i)
+ {
+ // References sorted alphabetically
+ SwContent* pCnt = new SwContent(this, *i, 0);
+ pMember->insert(pCnt);
+ }
+ }
+ break;
+ case CONTENT_TYPE_URLFIELD:
+ {
+ SwGetINetAttrs aArr;
+ nMemberCount = pWrtShell->GetINetAttrs( aArr );
+ for( sal_uInt16 n = 0; n < nMemberCount; ++n )
+ {
+ SwGetINetAttr* p = &aArr[ n ];
+ SwURLFieldContent* pCnt = new SwURLFieldContent(
+ this,
+ p->sText,
+ INetURLObject::decode(
+ p->rINetAttr.GetINetFmt().GetValue(),
+ INET_HEX_ESCAPE,
+ INetURLObject::DECODE_UNAMBIGUOUS,
+ RTL_TEXTENCODING_UTF8 ),
+ &p->rINetAttr,
+ n );
+ pMember->insert( pCnt );
+ }
+ }
+ break;
+ case CONTENT_TYPE_INDEX:
+ {
+
+ sal_uInt16 nCount = nMemberCount = pWrtShell->GetTOXCount();
+ for ( sal_uInt16 nTox = 0; nTox < nCount; nTox++ )
+ {
+ const SwTOXBase* pBase = pWrtShell->GetTOX( nTox );
+ OUString sTOXNm( pBase->GetTOXName() );
+
+ SwContent* pCnt = new SwTOXBaseContent(
+ this, sTOXNm, nTox, *pBase);
+
+ if( !pBase->GetInfo( aAskItem ) &&
+ !aAskItem.pObject ) // not visible
+ pCnt->SetInvisible();
+
+ pMember->insert( pCnt );
+ sal_uInt16 nPos = pMember->size() - 1;
+ if(nOldMemberCount > nPos &&
+ (*pOldMember)[nPos]->IsInvisible()
+ != pCnt->IsInvisible())
+ *pbLevelOrVisibilityChanged = sal_True;
+ }
+ }
+ break;
+ case CONTENT_TYPE_POSTIT:
+ {
+ nMemberCount = 0;
+ if(!pMember)
+ pMember = new SwContentArr;
+ else if(!pMember->empty())
+ pMember->DeleteAndDestroyAll();
+ SwPostItMgr* aMgr = pWrtShell->GetView().GetPostItMgr();
+ if (aMgr)
+ {
+ for(SwPostItMgr::const_iterator i = aMgr->begin(); i != aMgr->end(); ++i)
+ {
+ if ( (*i)->GetBroadCaster()->ISA(SwFmtFld)) // SwPostit
+ {
+ const SwFmtFld* aFmtFld = static_cast<const SwFmtFld*>((*i)->GetBroadCaster());
+ if (aFmtFld->GetTxtFld() && aFmtFld->IsFldInDoc() &&
+ (*i)->mLayoutStatus!=SwPostItHelper::INVISIBLE )
+ {
+ OUString sEntry = aFmtFld->GetField()->GetPar2();
+ sEntry = RemoveNewline(sEntry);
+ SwPostItContent* pCnt = new SwPostItContent(
+ this,
+ sEntry,
+ aFmtFld,
+ nMemberCount);
+ pMember->insert(pCnt);
+ nMemberCount++;
+ }
+ }
+ }
+ }
+ }
+ break;
+ case CONTENT_TYPE_DRAWOBJECT:
+ {
+ nMemberCount = 0;
+ if(!pMember)
+ pMember = new SwContentArr;
+ else if(!pMember->empty())
+ pMember->DeleteAndDestroyAll();
+
+ IDocumentDrawModelAccess* pIDDMA = pWrtShell->getIDocumentDrawModelAccess();
+ SdrModel* pModel = pIDDMA->GetDrawModel();
+ if(pModel)
+ {
+ SdrPage* pPage = pModel->GetPage(0);
+ sal_uInt32 nCount = pPage->GetObjCount();
+ for( sal_uInt32 i=0; i< nCount; i++ )
+ {
+ SdrObject* pTemp = pPage->GetObj(i);
+ // #i51726# - all drawing objects can be named now
+ if (!pTemp->GetName().isEmpty())
+ {
+ SwContact* pContact = (SwContact*)pTemp->GetUserCall();
+ long nYPos = 0;
+ const Point aNullPt;
+ if(pContact && pContact->GetFmt())
+ nYPos = pContact->GetFmt()->FindLayoutRect(sal_False, &aNullPt).Top();
+ SwContent* pCnt = new SwContent(
+ this,
+ pTemp->GetName(),
+ nYPos);
+ if(!pIDDMA->IsVisibleLayerId(pTemp->GetLayer()))
+ pCnt->SetInvisible();
+ pMember->insert(pCnt);
+ nMemberCount++;
+ if(nOldMemberCount > (int)i &&
+ (*pOldMember)[i]->IsInvisible() != pCnt->IsInvisible() )
+ *pbLevelOrVisibilityChanged = sal_True;
+ }
+ }
+ }
+ }
+ break;
+ }
+ bDataValid = true;
+ if(pOldMember)
+ pOldMember->DeleteAndDestroyAll();
+
+}
+
+// TreeListBox for content indicator
+
+SwContentTree::SwContentTree(Window* pParent, const ResId& rResId) :
+ SvTreeListBox( pParent, rResId ),
+
+ sSpace(OUString(" ")),
+
+ sRemoveIdx(SW_RES(ST_REMOVE_INDEX)),
+ sUpdateIdx(SW_RES(ST_UPDATE)),
+ sUnprotTbl(SW_RES(ST_REMOVE_TBL_PROTECTION)),
+ sRename(SW_RES(ST_RENAME)),
+ sReadonlyIdx(SW_RES(ST_READONLY_IDX)),
+ sInvisible(SW_RES(ST_INVISIBLE)),
+
+ sPostItShow(SW_RES(ST_POSTIT_SHOW)),
+ sPostItHide(SW_RES(ST_POSTIT_HIDE)),
+ sPostItDelete(SW_RES(ST_POSTIT_DELETE)),
+
+ pHiddenShell(0),
+ pActiveShell(0),
+ pConfig(SW_MOD()->GetNavigationConfig()),
+
+ nActiveBlock(0),
+ nHiddenBlock(0),
+
+ nRootType(USHRT_MAX),
+ nLastSelType(USHRT_MAX),
+ nOutlineLevel(MAXLEVEL),
+
+ bIsActive(true),
+ bIsConstant(false),
+ bIsHidden(false),
+ bDocChgdInDragging(false),
+ bIsInternalDrag(false),
+ bIsRoot(false),
+ bIsIdleClear(false),
+ bIsLastReadOnly(sal_False),
+ bIsOutlineMoveable(true),
+ bViewHasChanged(false),
+ bIsImageListInitialized(false),
+ bIsKeySpace(false)
+{
+ sal_uInt16 i;
+
+ SetHelpId(HID_NAVIGATOR_TREELIST);
+
+ SetNodeDefaultImages();
+ SetDoubleClickHdl(LINK(this, SwContentTree, ContentDoubleClickHdl));
+ SetDragDropMode(SV_DRAGDROP_APP_COPY);
+ for( i = 0; i < CONTENT_TYPE_MAX; i++)
+ {
+ aActiveContentArr[i] = 0;
+ aHiddenContentArr[i] = 0;
+ }
+ for( i = 0; i < CONTEXT_COUNT; i++ )
+ {
+ aContextStrings[i] = SW_RESSTR(i+ST_CONTEXT_FIRST);
+ }
+ nActiveBlock = pConfig->GetActiveBlock();
+ aUpdTimer.SetTimeoutHdl(LINK(this, SwContentTree, TimerUpdate));
+ aUpdTimer.SetTimeout(1000);
+ Clear();
+ EnableContextMenuHandling();
+ SetStyle( GetStyle() | WB_QUICK_SEARCH );
+}
+
+SwContentTree::~SwContentTree()
+{
+ Clear(); // If applicable erase content types previously.
+ bIsInDrag = false;
+}
+
+OUString SwContentTree::GetEntryAltText( SvTreeListEntry* pEntry ) const
+{
+ if( pEntry == NULL)
+ return OUString();
+
+ SwContent* pCnt = (SwContent*)pEntry->GetUserData();
+ if( pCnt == NULL || pCnt->GetParent() == NULL)
+ return OUString();
+
+ sal_uInt16 nJumpType = pCnt->GetParent()->GetType();
+ SdrObject* pTemp;
+
+ switch(nJumpType)
+ {
+ case CONTENT_TYPE_DRAWOBJECT:
+ {
+ SdrView* pDrawView = pActiveShell->GetDrawView();
+ if (pDrawView)
+ {
+ SdrModel* pDrawModel = pActiveShell->GetDoc()->GetDrawModel();
+ SdrPage* pPage = pDrawModel->GetPage(0);
+ const sal_uInt32 nCount = pPage->GetObjCount();
+ for( sal_uInt32 i=0; i< nCount; i++ )
+ {
+ pTemp = pPage->GetObj(i);
+ sal_uInt16 nCmpId;
+ switch( pTemp->GetObjIdentifier() )
+ {
+ case OBJ_GRUP:
+ case OBJ_TEXT:
+ case OBJ_TEXTEXT:
+ case OBJ_wegFITTEXT:
+ case OBJ_LINE:
+ case OBJ_RECT:
+ //caoxueqin added custom shape
+ case OBJ_CUSTOMSHAPE:
+ //end 2005/08/05
+ case OBJ_CIRC:
+ case OBJ_SECT:
+ case OBJ_CARC:
+ case OBJ_CCUT:
+ case OBJ_POLY:
+ case OBJ_PLIN:
+ case OBJ_PATHLINE:
+ case OBJ_PATHFILL:
+ case OBJ_FREELINE:
+ case OBJ_FREEFILL:
+ case OBJ_PATHPOLY:
+ case OBJ_PATHPLIN:
+ case OBJ_CAPTION:
+ nCmpId = OBJ_GRUP;
+ break;
+ default:
+ nCmpId = pTemp->GetObjIdentifier();
+ }
+ if(nCmpId == OBJ_GRUP /*pTemp->ISA(SdrObjGroup)*/ && pTemp->GetName() == pCnt->GetName())
+ {
+ return pTemp->GetTitle();
+ }
+ //Commented End
+ }
+ }
+ }
+ break;
+ case CONTENT_TYPE_GRAPHIC :
+ {
+ if( pActiveShell && pActiveShell->GetDoc() )
+ {
+ const SwFlyFrmFmt* pFrmFmt = pActiveShell->GetDoc()->FindFlyByName( pCnt->GetName(), 0);
+ if( pFrmFmt )
+ {
+// SwNodeIndex aIdx( *(pFrmFmt->GetCntnt().GetCntntIdx()), 1 );
+// const SwGrfNode* pGrfNd = aIdx.GetNode().GetGrfNode();
+// if( pGrfNd )
+// return pGrfNd->GetAlternateText();
+ return pFrmFmt->GetObjTitle();
+ }
+ }
+ }
+ break;
+ case CONTENT_TYPE_OLE :
+ case CONTENT_TYPE_FRAME :
+ {
+ //Can't find the GetAlternateText function. Need to verify again.
+ const SwFlyFrmFmt* pFlyFmt = pActiveShell->GetDoc()->FindFlyByName( pCnt->GetName(), 0);
+ if( pFlyFmt )
+ return pFlyFmt->/*GetAlternateText*/GetName();
+ }
+ break;
+ }
+ return OUString();
+}
+
+OUString SwContentTree::GetEntryLongDescription( SvTreeListEntry* pEntry ) const
+{
+ if( pEntry == NULL)
+ return OUString();
+
+ SwContent* pCnt = (SwContent*)pEntry->GetUserData();
+ if( pCnt == NULL || pCnt->GetParent() == NULL)
+ return OUString();
+
+ sal_uInt16 nJumpType = pCnt->GetParent()->GetType();
+ SdrObject* pTemp;
+
+ switch(nJumpType)
+ {
+ case CONTENT_TYPE_DRAWOBJECT:
+ {
+ SdrView* pDrawView = pActiveShell->GetDrawView();
+ if (pDrawView)
+ {
+ SdrModel* pDrawModel = pActiveShell->GetDoc()->GetDrawModel();
+ SdrPage* pPage = pDrawModel->GetPage(0);
+ sal_uInt32 nCount = pPage->GetObjCount();
+ for( sal_uInt32 i=0; i< nCount; i++ )
+ {
+ pTemp = pPage->GetObj(i);
+ sal_uInt16 nCmpId;
+ switch( pTemp->GetObjIdentifier() )
+ {
+ case OBJ_GRUP:
+ case OBJ_TEXT:
+ case OBJ_TEXTEXT:
+ case OBJ_wegFITTEXT:
+ case OBJ_LINE:
+ case OBJ_RECT:
+ //caoxueqin added custom shape
+ case OBJ_CUSTOMSHAPE:
+ //end 2005/08/05
+ case OBJ_CIRC:
+ case OBJ_SECT:
+ case OBJ_CARC:
+ case OBJ_CCUT:
+ case OBJ_POLY:
+ case OBJ_PLIN:
+ case OBJ_PATHLINE:
+ case OBJ_PATHFILL:
+ case OBJ_FREELINE:
+ case OBJ_FREEFILL:
+ case OBJ_PATHPOLY:
+ case OBJ_PATHPLIN:
+ case OBJ_CAPTION:
+ nCmpId = OBJ_GRUP;
+ break;
+ default:
+ nCmpId = pTemp->GetObjIdentifier();
+ }
+ if(nCmpId == OBJ_GRUP /*pTemp->ISA(SdrObjGroup)*/ && pTemp->GetName() == pCnt->GetName())
+ {
+ return pTemp->GetDescription();
+ }
+ //Commented End
+ }
+ }
+ }
+ break;
+ case CONTENT_TYPE_GRAPHIC :
+ case CONTENT_TYPE_OLE :
+ case CONTENT_TYPE_FRAME :
+ {
+ //Can't find the function "GetLongDescription". Need to verify again.
+ const SwFlyFrmFmt* pFlyFmt = pActiveShell->GetDoc()->FindFlyByName( pCnt->GetName(), 0);
+ if( pFlyFmt )
+ return pFlyFmt->GetDescription();
+ }
+ break;
+ }
+ return OUString();
+}
+
+// Drag&Drop methods
+
+void SwContentTree::StartDrag( sal_Int8 nAction, const Point& rPosPixel )
+{
+ if( !bIsRoot || nRootType != CONTENT_TYPE_OUTLINE )
+ {
+ ReleaseMouse();
+
+ TransferDataContainer* pContainer = new TransferDataContainer;
+ uno::Reference<
+ datatransfer::XTransferable > xRef( pContainer );
+
+ sal_Int8 nDragMode = DND_ACTION_COPYMOVE | DND_ACTION_LINK;
+ if( FillTransferData( *pContainer, nDragMode ))
+ {
+ SwContentTree::SetInDrag(true);
+ pContainer->StartDrag( this, nDragMode, GetDragFinishedHdl() );
+ }
+ }
+ else
+ SvTreeListBox::StartDrag( nAction, rPosPixel );
+}
+
+void SwContentTree::DragFinished( sal_Int8 nAction )
+{
+ // To prevent the removing of the selected entry in external drag and drop
+ // the drag action mustn't be MOVE.
+ SvTreeListBox::DragFinished( bIsInternalDrag ? nAction : DND_ACTION_COPY );
+ SwContentTree::SetInDrag(false);
+ bIsInternalDrag = false;
+}
+
+// QueryDrop will be executed in the navigator
+
+sal_Int8 SwContentTree::AcceptDrop( const AcceptDropEvent& rEvt )
+{
+ sal_Int8 nRet = DND_ACTION_NONE;
+ if( bIsRoot )
+ {
+ if( bIsOutlineMoveable )
+ nRet = SvTreeListBox::AcceptDrop( rEvt );
+ }
+ else if( !bIsInDrag )
+ nRet = GetParentWindow()->AcceptDrop( rEvt );
+ return nRet;
+}
+
+// Drop will be executed in the navigator
+
+static void* lcl_GetOutlineKey( SwContentTree* pTree, SwOutlineContent* pContent)
+{
+ void* key = 0;
+ if( pTree && pContent )
+ {
+ SwWrtShell* pShell = pTree->GetWrtShell();
+ sal_Int32 nPos = pContent->GetYPos();
+ if( nPos )
+ {
+ key = (void*)pShell->getIDocumentOutlineNodesAccess()->getOutlineNode( nPos );
+ }
+ }
+ return key;
+}
+
+sal_Int8 SwContentTree::ExecuteDrop( const ExecuteDropEvent& rEvt )
+{
+ SvTreeListEntry* pEntry = pTargetEntry;
+ if( pEntry && ( nRootType == CONTENT_TYPE_OUTLINE ) && lcl_IsContent( pEntry ) )
+ {
+ SwOutlineContent* pOutlineContent = ( SwOutlineContent* )( pEntry->GetUserData() );
+ if( pOutlineContent )
+ {
+ void* key = lcl_GetOutlineKey(this, pOutlineContent);
+ if( !mOutLineNodeMap[key] )
+ {
+ while( pEntry->HasChildren() )
+ {
+ SvTreeListEntry* pChildEntry = FirstChild( pEntry );
+ while( pChildEntry )
+ {
+ pEntry = pChildEntry;
+ pChildEntry = NextSibling( pChildEntry );
+ }
+ }
+ pTargetEntry = pEntry;
+ }
+ }
+ }
+ if( bIsRoot )
+ return SvTreeListBox::ExecuteDrop( rEvt );
+ return bIsInDrag ? DND_ACTION_NONE : GetParentWindow()->ExecuteDrop(rEvt);
+}
+
+// Handler for Dragging and ContextMenu
+
+PopupMenu* SwContentTree::CreateContextMenu( void )
+{
+ PopupMenu* pPop = new PopupMenu;
+ PopupMenu* pSubPop1 = new PopupMenu;
+ PopupMenu* pSubPop2 = new PopupMenu;
+ PopupMenu* pSubPop3 = new PopupMenu;
+ PopupMenu* pSubPop4 = new PopupMenu; // Edit
+
+ sal_uInt16 i;
+ for(i = 1; i <= MAXLEVEL; i++ )
+ {
+ pSubPop1->InsertItem( i + 100, OUString::number(i));
+ }
+ pSubPop1->CheckItem(100 + nOutlineLevel);
+ for(i=0; i < 3; i++ )
+ {
+ pSubPop2->InsertItem( i + 201, aContextStrings[
+ ST_HYPERLINK - ST_CONTEXT_FIRST + i]);
+ }
+ pSubPop2->CheckItem( 201 +
+ GetParentWindow()->GetRegionDropMode());
+ // Insert the list of the open files
+ sal_uInt16 nId = 301;
+ const SwView* pActiveView = ::GetActiveView();
+ SwView *pView = SwModule::GetFirstView();
+ while (pView)
+ {
+ OUString sInsert = pView->GetDocShell()->GetTitle();
+ if(pView == pActiveView)
+ {
+ sInsert += "(";
+ sInsert += aContextStrings[ ST_ACTIVE - ST_CONTEXT_FIRST];
+ sInsert += ")";
+ }
+ pSubPop3->InsertItem(nId, sInsert);
+ if(bIsConstant && pActiveShell == &pView->GetWrtShell())
+ pSubPop3->CheckItem(nId);
+ pView = SwModule::GetNextView(pView);
+ nId++;
+ }
+ pSubPop3->InsertItem(nId++, aContextStrings[ST_ACTIVE_VIEW - ST_CONTEXT_FIRST]);
+ if(pHiddenShell)
+ {
+ OUString sHiddenEntry = pHiddenShell->GetView().GetDocShell()->GetTitle();
+ sHiddenEntry += " ( ";
+ sHiddenEntry += aContextStrings[ ST_HIDDEN - ST_CONTEXT_FIRST];
+ sHiddenEntry += " )";
+ pSubPop3->InsertItem(nId, sHiddenEntry);
+ }
+
+ if(bIsActive)
+ pSubPop3->CheckItem( --nId );
+ else if(bIsHidden)
+ pSubPop3->CheckItem( nId );
+
+ pPop->InsertItem( 1, aContextStrings[ST_OUTLINE_LEVEL - ST_CONTEXT_FIRST]);
+ pPop->InsertItem(2, aContextStrings[ST_DRAGMODE - ST_CONTEXT_FIRST]);
+ pPop->InsertItem(3, aContextStrings[ST_DISPLAY - ST_CONTEXT_FIRST]);
+ // Now edit
+ SvTreeListEntry* pEntry = 0;
+ // Edit only if the shown content is coming from the current view.
+ if((bIsActive || pActiveShell == pActiveView->GetWrtShellPtr())
+ && 0 != (pEntry = FirstSelected()) && lcl_IsContent(pEntry))
+ {
+ const SwContentType* pContType = ((SwContent*)pEntry->GetUserData())->GetParent();
+ const sal_uInt16 nContentType = pContType->GetType();
+ sal_Bool bReadonly = pActiveShell->GetView().GetDocShell()->IsReadOnly();
+ bool bVisible = !((SwContent*)pEntry->GetUserData())->IsInvisible();
+ sal_Bool bProtected = ((SwContent*)pEntry->GetUserData())->IsProtect();
+ bool bEditable = pContType->IsEditable() &&
+ ((bVisible && !bProtected) ||CONTENT_TYPE_REGION == nContentType);
+ bool bDeletable = pContType->IsDeletable() &&
+ ((bVisible && !bProtected) ||CONTENT_TYPE_REGION == nContentType);
+ bool bRenamable = bEditable && !bReadonly &&
+ (CONTENT_TYPE_TABLE == nContentType ||
+ CONTENT_TYPE_FRAME == nContentType ||
+ CONTENT_TYPE_GRAPHIC == nContentType ||
+ CONTENT_TYPE_OLE == nContentType ||
+ CONTENT_TYPE_BOOKMARK == nContentType ||
+ CONTENT_TYPE_REGION == nContentType||
+ CONTENT_TYPE_INDEX == nContentType);
+
+ if(!bReadonly && (bEditable || bDeletable))
+ {
+ bool bSubPop4 = false;
+ if(CONTENT_TYPE_INDEX == nContentType)
+ {
+ bSubPop4 = true;
+ pSubPop4->InsertItem(401, sRemoveIdx);
+ pSubPop4->InsertItem(402, sUpdateIdx);
+
+ const SwTOXBase* pBase = ((SwTOXBaseContent*)pEntry->GetUserData())->GetTOXBase();
+ if(!pBase->IsTOXBaseInReadonly())
+ pSubPop4->InsertItem(403, aContextStrings[ST_EDIT_ENTRY - ST_CONTEXT_FIRST]);
+ pSubPop4->InsertItem(405, sReadonlyIdx);
+
+ pSubPop4->CheckItem( 405, pActiveShell->IsTOXBaseReadonly(*pBase));
+ pSubPop4->InsertItem(501, aContextStrings[ST_DELETE_ENTRY - ST_CONTEXT_FIRST]);
+ }
+ else if(CONTENT_TYPE_TABLE == nContentType && !bReadonly)
+ {
+ bSubPop4 = true;
+ pSubPop4->InsertItem(403, aContextStrings[ST_EDIT_ENTRY - ST_CONTEXT_FIRST]);
+ pSubPop4->InsertItem(404, sUnprotTbl);
+ sal_Bool bFull = sal_False;
+ OUString sTblName = ((SwContent*)pEntry->GetUserData())->GetName();
+ sal_Bool bProt =pActiveShell->HasTblAnyProtection( &sTblName, &bFull );
+ pSubPop4->EnableItem(403, !bFull );
+ pSubPop4->EnableItem(404, bProt );
+ pSubPop4->InsertItem(501, aContextStrings[ST_DELETE_ENTRY - ST_CONTEXT_FIRST]);
+ }
+ else if(bEditable || bDeletable)
+ {
+
+ if(bEditable && bDeletable)
+ {
+ pSubPop4->InsertItem(403, aContextStrings[ST_EDIT_ENTRY - ST_CONTEXT_FIRST]);
+ pSubPop4->InsertItem(501, aContextStrings[ST_DELETE_ENTRY - ST_CONTEXT_FIRST]);
+ bSubPop4 = true;
+ }
+ else if(bEditable)
+ pPop->InsertItem(403, aContextStrings[ST_EDIT_ENTRY - ST_CONTEXT_FIRST]);
+ else if(bDeletable)
+ {
+ pSubPop4->InsertItem(501, aContextStrings[ST_DELETE_ENTRY - ST_CONTEXT_FIRST]);
+ }
+ }
+ //Rename object
+ if(bRenamable)
+ {
+ if(bSubPop4)
+ pSubPop4->InsertItem(502, sRename);
+ else
+ pPop->InsertItem(502, sRename);
+ }
+
+ if(bSubPop4)
+ {
+ pPop->InsertItem(4, pContType->GetSingleName());
+ pPop->SetPopupMenu(4, pSubPop4);
+ }
+ }
+ }
+ else if( pEntry )
+ {
+ SwContentType* pType = (SwContentType*)pEntry->GetUserData();
+ if ( (pType->GetType() == CONTENT_TYPE_POSTIT) && (!pActiveShell->GetView().GetDocShell()->IsReadOnly()) && ( pType->GetMemberCount() > 0) )
+ {
+ pSubPop4->InsertItem(600, sPostItShow );
+ pSubPop4->InsertItem(601, sPostItHide );
+ pSubPop4->InsertItem(602, sPostItDelete );
+ pPop->InsertItem(4, pType->GetSingleName());
+ pPop->SetPopupMenu(4, pSubPop4);
+ }
+ }
+
+ pPop->SetPopupMenu( 1, pSubPop1 );
+ pPop->SetPopupMenu( 2, pSubPop2 );
+ pPop->SetPopupMenu( 3, pSubPop3 );
+ return pPop;
+
+}
+
+// Indentation for outlines (and sections)
+
+sal_IntPtr SwContentTree::GetTabPos( SvTreeListEntry* pEntry, SvLBoxTab* pTab)
+{
+ sal_uInt16 nLevel = 0;
+ if(lcl_IsContent(pEntry))
+ {
+ nLevel++;
+ SwContent* pCnt = (SwContent *) pEntry->GetUserData();
+ const SwContentType* pParent;
+ if(pCnt && 0 != (pParent = pCnt->GetParent()))
+ {
+ if(pParent->GetType() == CONTENT_TYPE_OUTLINE)
+ nLevel = nLevel + ((SwOutlineContent*)pCnt)->GetOutlineLevel();
+ else if(pParent->GetType() == CONTENT_TYPE_REGION)
+ nLevel = nLevel + ((SwRegionContent*)pCnt)->GetRegionLevel();
+ }
+ }
+ sal_uInt16 nBasis = bIsRoot ? 0 : 5;
+ return nLevel * 10 + nBasis + pTab->GetPos(); //determined empirically
+}
+
+// Content will be integrated into the Box only on demand.
+
+void SwContentTree::RequestingChildren( SvTreeListEntry* pParent )
+{
+ // Is this a content type?
+ if(lcl_IsContentType(pParent))
+ {
+ if(!pParent->HasChildren())
+ {
+ OSL_ENSURE(pParent->GetUserData(), "no UserData?");
+ SwContentType* pCntType = (SwContentType*)pParent->GetUserData();
+
+ sal_uInt16 nCount = pCntType->GetMemberCount();
+ // Add for outline plus/minus
+ if(pCntType->GetType() == CONTENT_TYPE_OUTLINE)
+ {
+ SvTreeListEntry* pChild = 0;
+ for(sal_uInt16 i = 0; i < nCount; i++)
+ {
+ const SwContent* pCnt = pCntType->GetMember(i);
+ if(pCnt)
+ {
+ sal_uInt16 nLevel = ((SwOutlineContent*)pCnt)->GetOutlineLevel();
+ OUString sEntry = pCnt->GetName();
+ if(sEntry.isEmpty())
+ sEntry = sSpace;
+ if(!pChild || (nLevel == 0))
+ pChild = InsertEntry(sEntry, pParent,
+ sal_False, TREELIST_APPEND,(void*)pCnt);
+ else
+ {
+ //back search parent.
+ if(((SwOutlineContent*)pCntType->GetMember(i-1))->GetOutlineLevel() < nLevel)
+ pChild = InsertEntry(sEntry, pChild,
+ sal_False, TREELIST_APPEND, (void*)pCnt);
+ else
+ {
+ pChild = Prev(pChild);
+ while(pChild &&
+ lcl_IsContent(pChild) &&
+ !(((SwOutlineContent*)pChild->GetUserData())->GetOutlineLevel() < nLevel)
+ )
+ {
+ pChild = Prev(pChild);
+ }
+ if(pChild)
+ pChild = InsertEntry(sEntry, pChild,
+ sal_False, TREELIST_APPEND, (void*)pCnt);
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ for(sal_uInt16 i = 0; i < nCount; i++)
+ {
+ const SwContent* pCnt = pCntType->GetMember(i);
+ if(pCnt)
+ {
+ OUString sEntry = pCnt->GetName();
+ if (sEntry.isEmpty())
+ sEntry = sSpace;
+ SvTreeListEntry* pChild = InsertEntry(sEntry, pParent,
+ sal_False, TREELIST_APPEND, (void*)pCnt);
+
+ //If object is marked , the corresponding entry is set true,
+ //else the corresponding entry is set false .
+ SdrObject * pObj = GetDrawingObjectsByContent(pCnt);
+ if(pChild)
+ pChild->SetMarked(sal_False);
+ if(pObj)
+ {
+ SdrView* pDrawView = pActiveShell->GetDrawView();
+ SdrPageView* pPV = pDrawView->/*GetPageViewPvNum*/GetSdrPageView(/*0*/);
+ if( pPV )
+ {
+ sal_Bool Marked = pDrawView->IsObjMarked(pObj);
+ if(Marked)
+ {
+ //sEntry += String::CreateFromAscii(" *");
+ pChild->SetMarked(sal_True);
+ }
+
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+//Get drawing Objects by content .
+SdrObject* SwContentTree::GetDrawingObjectsByContent(const SwContent *pCnt)
+{
+ SdrObject *pRetObj = NULL;
+ sal_uInt16 nJumpType = pCnt->GetParent()->GetType();
+ switch(nJumpType)
+ {
+ case CONTENT_TYPE_DRAWOBJECT:
+ {
+ SdrView* pDrawView = pActiveShell->GetDrawView();
+ if (pDrawView)
+ {
+ SdrModel* pDrawModel = pActiveShell->GetDoc()->GetDrawModel();
+ SdrPage* pPage = pDrawModel->GetPage(0);
+ sal_uInt32 nCount = pPage->GetObjCount();
+
+ for( sal_uInt32 i=0; i< nCount; i++ )
+ {
+ SdrObject* pTemp = pPage->GetObj(i);
+ if( pTemp->GetName() == pCnt->GetName())
+ {
+ pRetObj = pTemp;
+ break;
+ }
+ }
+ }
+ break;
+ }
+ default:
+ pRetObj = NULL;
+ }
+ return pRetObj;
+}
+
+// Expand - Remember the state for content types.
+
+sal_Bool SwContentTree::Expand( SvTreeListEntry* pParent )
+{
+ if(!bIsRoot || (((SwContentType*)pParent->GetUserData())->GetType() == CONTENT_TYPE_OUTLINE) ||
+ (nRootType == CONTENT_TYPE_OUTLINE))
+ {
+ if(lcl_IsContentType(pParent))
+ {
+ SwContentType* pCntType = (SwContentType*)pParent->GetUserData();
+ sal_uInt16 nOr = 1 << pCntType->GetType(); //linear -> Bitposition
+ if(bIsActive || bIsConstant)
+ {
+ nActiveBlock |= nOr;
+ pConfig->SetActiveBlock(nActiveBlock);
+ }
+ else
+ nHiddenBlock |= nOr;
+ if((pCntType->GetType() == CONTENT_TYPE_OUTLINE))
+ {
+ std::map< void*, bool > mCurrOutLineNodeMap;
+
+ SwWrtShell* pShell = GetWrtShell();
+ sal_Bool bBool = SvTreeListBox::Expand(pParent);
+ SvTreeListEntry* pChild = Next(pParent);
+ while(pChild && lcl_IsContent(pChild) && pParent->HasChildren())
+ {
+ if(pChild->HasChildren())
+ {
+ sal_Int32 nPos = ((SwContent*)pChild->GetUserData())->GetYPos();
+ void* key = (void*)pShell->getIDocumentOutlineNodesAccess()->getOutlineNode( nPos );
+ mCurrOutLineNodeMap.insert(std::map<void*, bool>::value_type( key, false ) );
+ std::map<void*, bool>::iterator iter = mOutLineNodeMap.find( key );
+ if( iter != mOutLineNodeMap.end() && mOutLineNodeMap[key])
+ {
+ mCurrOutLineNodeMap[key] = true;
+ SvTreeListBox::Expand(pChild);
+ }
+ }
+ pChild = Next(pChild);
+ }
+ mOutLineNodeMap = mCurrOutLineNodeMap;
+ return bBool;
+ }
+
+ }
+ else if( lcl_IsContent(pParent) )
+ {
+ SwWrtShell* pShell = GetWrtShell();
+ sal_Int32 nPos = ((SwContent*)pParent->GetUserData())->GetYPos();
+ void* key = (void*)pShell->getIDocumentOutlineNodesAccess()->getOutlineNode( nPos );
+ mOutLineNodeMap[key] = true;
+ }
+ }
+ return SvTreeListBox::Expand(pParent);
+}
+
+// Collapse - Remember the state for content types.
+
+sal_Bool SwContentTree::Collapse( SvTreeListEntry* pParent )
+{
+ sal_Bool bRet;
+ if(!bIsRoot || (((SwContentType*)pParent->GetUserData())->GetType() == CONTENT_TYPE_OUTLINE) ||
+ (nRootType == CONTENT_TYPE_OUTLINE))
+ {
+ if(lcl_IsContentType(pParent))
+ {
+ if(bIsRoot)
+ return bRet = sal_False;
+ SwContentType* pCntType = (SwContentType*)pParent->GetUserData();
+ sal_uInt16 nAnd = 1 << pCntType->GetType();
+ nAnd = ~nAnd;
+ if(bIsActive || bIsConstant)
+ {
+ nActiveBlock &= nAnd;
+ pConfig->SetActiveBlock(nActiveBlock);
+ }
+ else
+ nHiddenBlock &= nAnd;
+ }
+ else if( lcl_IsContent(pParent) )
+ {
+ SwWrtShell* pShell = GetWrtShell();
+ sal_Int32 nPos = ((SwContent*)pParent->GetUserData())->GetYPos();
+ void* key = (void*)pShell->getIDocumentOutlineNodesAccess()->getOutlineNode( nPos );
+ mOutLineNodeMap[key] = false;
+ }
+ bRet = SvTreeListBox::Collapse(pParent);
+ }
+ else
+ bRet = SvTreeListBox::Collapse(pParent);
+ return bRet;
+}
+
+// Also on double click will be initially opened only.
+
+IMPL_LINK_NOARG(SwContentTree, ContentDoubleClickHdl)
+{
+ SvTreeListEntry* pEntry = GetCurEntry();
+ // Is it a content type?
+ OSL_ENSURE(pEntry, "no current entry!");
+ if(pEntry)
+ {
+ if(lcl_IsContentType(pEntry) && !pEntry->HasChildren())
+ RequestingChildren(pEntry);
+ else if(!lcl_IsContentType(pEntry) && (bIsActive || bIsConstant))
+ {
+ if(bIsConstant)
+ {
+ pActiveShell->GetView().GetViewFrame()->GetWindow().ToTop();
+ }
+ //Jump to content type:
+ SwContent* pCnt = (SwContent*)pEntry->GetUserData();
+ OSL_ENSURE( pCnt, "no UserData");
+ GotoContent(pCnt);
+ if(pCnt->GetParent()->GetType() == CONTENT_TYPE_FRAME)
+ pActiveShell->EnterStdMode();
+ }
+ }
+ return 0;
+}
+
+// Show the file
+
+void SwContentTree::Display( bool bActive )
+{
+ if(!bIsImageListInitialized)
+ {
+ aEntryImages = ImageList(SW_RES(IMG_NAVI_ENTRYBMP));
+
+#ifndef MACSOX
+ if ( GetDPIScaleFactor() > 1 )
+ {
+ for (short i = 0; i < aEntryImages.GetImageCount(); i++)
+ {
+ OUString rImageName = aEntryImages.GetImageName(i);
+ BitmapEx b = aEntryImages.GetImage(rImageName).GetBitmapEx();
+ //Use Lanczos because it looks better with circles / diagonals
+ b.Scale(GetDPIScaleFactor(), GetDPIScaleFactor(), BMP_SCALE_LANCZOS);
+ aEntryImages.ReplaceImage(rImageName, Image(b));
+ }
+ }
+#endif
+ bIsImageListInitialized = true;
+ }
+ // First read the selected entry to select it later again if necessary
+ // -> the user data here are no longer valid!
+ SvTreeListEntry* pOldSelEntry = FirstSelected();
+ OUString sEntryName; // Name of the entry
+ sal_uInt16 nEntryRelPos = 0; // relative position to their parent
+ sal_uInt32 nOldEntryCount = GetEntryCount();
+ sal_Int32 nOldScrollPos = 0;
+ if(pOldSelEntry)
+ {
+ ScrollBar* pVScroll = GetVScroll();
+ if(pVScroll && pVScroll->IsVisible())
+ nOldScrollPos = pVScroll->GetThumbPos();
+
+ sEntryName = GetEntryText(pOldSelEntry);
+ SvTreeListEntry* pParantEntry = pOldSelEntry;
+ while( GetParent(pParantEntry))
+ {
+ pParantEntry = GetParent(pParantEntry);
+ }
+ if(GetParent(pOldSelEntry))
+ {
+ nEntryRelPos = (sal_uInt16)(GetModel()->GetAbsPos(pOldSelEntry) - GetModel()->GetAbsPos(pParantEntry));
+ }
+ }
+ Clear();
+ SetUpdateMode( sal_False );
+ if(bActive && !bIsConstant && !bIsActive)
+ bIsActive = bActive;
+ bIsHidden = !bActive;
+ SwWrtShell* pShell = GetWrtShell();
+ sal_Bool bReadOnly = pShell ? pShell->GetView().GetDocShell()->IsReadOnly() : sal_True;
+ if(bReadOnly != bIsLastReadOnly)
+ {
+ bIsLastReadOnly = bReadOnly;
+ bool bDisable = pShell == 0 || bReadOnly;
+ SwNavigationPI* pNavi = GetParentWindow();
+ pNavi->aContentToolBox.EnableItem(FN_ITEM_UP , !bDisable);
+ pNavi->aContentToolBox.EnableItem(FN_ITEM_DOWN, !bDisable);
+ pNavi->aContentToolBox.EnableItem(FN_ITEM_LEFT, !bDisable);
+ pNavi->aContentToolBox.EnableItem(FN_ITEM_RIGHT, !bDisable);
+ pNavi->aContentToolBox.EnableItem(FN_SELECT_SET_AUTO_BOOKMARK, !bDisable);
+ }
+ if(pShell)
+ {
+ SvTreeListEntry* pSelEntry = 0;
+ if(nRootType == USHRT_MAX)
+ {
+ for(sal_uInt16 nCntType = CONTENT_TYPE_OUTLINE;
+ nCntType <= CONTENT_TYPE_DRAWOBJECT; nCntType++ )
+ {
+ SwContentType** ppContentT = bActive ?
+ &aActiveContentArr[nCntType] :
+ &aHiddenContentArr[nCntType];
+ if(!*ppContentT)
+ (*ppContentT) = new SwContentType(pShell, nCntType, nOutlineLevel );
+
+ OUString sEntry = (*ppContentT)->GetName();
+ SvTreeListEntry* pEntry;
+ const Image& rImage = aEntryImages.GetImage(SID_SW_START + nCntType);
+ sal_Bool bChOnDemand = 0 != (*ppContentT)->GetMemberCount();
+ pEntry = InsertEntry(sEntry, rImage, rImage,
+ 0, bChOnDemand, TREELIST_APPEND, (*ppContentT));
+ if(nCntType == nLastSelType)
+ pSelEntry = pEntry;
+ sal_Int32 nExpandOptions = bIsActive || bIsConstant ?
+ nActiveBlock :
+ nHiddenBlock;
+ if(nExpandOptions & (1 << nCntType))
+ {
+ Expand(pEntry);
+ if(nEntryRelPos && nCntType == nLastSelType)
+ {
+ // Now maybe select a additional child
+ SvTreeListEntry* pChild = pEntry;
+ SvTreeListEntry* pTemp = 0;
+ sal_uInt16 nPos = 1;
+ while(0 != (pChild = Next(pChild)))
+ {
+ // The old text will be slightly favored
+ if(sEntryName == GetEntryText(pChild) ||
+ nPos == nEntryRelPos )
+ {
+ pSelEntry = pChild;
+ break;
+ }
+ pTemp = pChild;
+ nPos++;
+ }
+ if(!pSelEntry || lcl_IsContentType(pSelEntry))
+ pSelEntry = pTemp;
+ }
+
+ }
+ }
+ if(pSelEntry)
+ {
+ MakeVisible(pSelEntry);
+ Select(pSelEntry);
+ }
+ else
+ nOldScrollPos = 0;
+ }
+ else
+ {
+ SwContentType** ppRootContentT = bActive ?
+ &aActiveContentArr[nRootType] :
+ &aHiddenContentArr[nRootType];
+ if(!(*ppRootContentT))
+ (*ppRootContentT) = new SwContentType(pShell, nRootType, nOutlineLevel );
+ const Image& rImage = aEntryImages.GetImage(20000 + nRootType);
+ SvTreeListEntry* pParent = InsertEntry(
+ (*ppRootContentT)->GetName(), rImage, rImage,
+ 0, sal_False, TREELIST_APPEND, *ppRootContentT);
+
+ if(nRootType != CONTENT_TYPE_OUTLINE)
+ {
+ for(sal_uInt16 i = 0; i < (*ppRootContentT)->GetMemberCount(); i++ )
+ {
+ const SwContent* pCnt = (*ppRootContentT)->GetMember(i);
+ if(pCnt)
+ {
+ OUString sEntry = pCnt->GetName();
+ if(sEntry.isEmpty())
+ sEntry = sSpace;
+ InsertEntry( sEntry, pParent,
+ sal_False, TREELIST_APPEND, (void*)pCnt);
+ }
+ }
+ }
+ else
+ RequestingChildren(pParent);
+ Expand(pParent);
+ if( nRootType == CONTENT_TYPE_OUTLINE && bIsActive )
+ {
+ // find out where the cursor is
+ const sal_uInt16 nActPos = pShell->GetOutlinePos(MAXLEVEL);
+ SvTreeListEntry* pEntry = First();
+
+ while( 0 != (pEntry = Next(pEntry)) )
+ {
+ if(((SwOutlineContent*)pEntry->GetUserData())->GetPos() == nActPos)
+ {
+ MakeVisible(pEntry);
+ Select(pEntry);
+ }
+ }
+
+ }
+ else
+ {
+ // Now maybe select a additional child
+ SvTreeListEntry* pChild = pParent;
+ SvTreeListEntry* pTemp = 0;
+ sal_uInt16 nPos = 1;
+ while(0 != (pChild = Next(pChild)))
+ {
+ // The old text will be slightly favored
+ if(sEntryName == GetEntryText(pChild) ||
+ nPos == nEntryRelPos )
+ {
+ pSelEntry = pChild;
+ break;
+ }
+ pTemp = pChild;
+ nPos++;
+ }
+ if(!pSelEntry)
+ pSelEntry = pTemp;
+ if(pSelEntry)
+ {
+ MakeVisible(pSelEntry);
+ Select(pSelEntry);
+ }
+ }
+ }
+ }
+ SetUpdateMode( sal_True );
+ ScrollBar* pVScroll = GetVScroll();
+ if(GetEntryCount() == nOldEntryCount &&
+ nOldScrollPos && pVScroll && pVScroll->IsVisible()
+ && pVScroll->GetThumbPos() != nOldScrollPos)
+ {
+ sal_Int32 nDelta = pVScroll->GetThumbPos() - nOldScrollPos;
+ ScrollOutputArea( (short)nDelta );
+ }
+
+}
+
+// In the Clear the content types have to be deleted, also.
+
+void SwContentTree::Clear()
+{
+ SetUpdateMode(sal_False);
+ SvTreeListBox::Clear();
+ SetUpdateMode(sal_True);
+}
+
+bool SwContentTree::FillTransferData( TransferDataContainer& rTransfer,
+ sal_Int8& rDragMode )
+{
+ SwWrtShell* pWrtShell = GetWrtShell();
+ OSL_ENSURE(pWrtShell, "no Shell!");
+ SvTreeListEntry* pEntry = GetCurEntry();
+ if(!pEntry || lcl_IsContentType(pEntry) || !pWrtShell)
+ return false;
+ OUString sEntry;
+ SwContent* pCnt = ((SwContent*)pEntry->GetUserData());
+
+ sal_uInt16 nActType = pCnt->GetParent()->GetType();
+ OUString sUrl;
+ bool bOutline = false;
+ OUString sOutlineText;
+ switch( nActType )
+ {
+ case CONTENT_TYPE_OUTLINE:
+ {
+ sal_uInt16 nPos = ((SwOutlineContent*)pCnt)->GetPos();
+ OSL_ENSURE(nPos < pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineNodesCount(),
+ "outlinecnt changed");
+
+ // make sure outline may actually be copied
+ if( pWrtShell->IsOutlineCopyable( nPos ) )
+ {
+ const SwNumRule* pOutlRule = pWrtShell->GetOutlineNumRule();
+ const SwTxtNode* pTxtNd =
+ pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineNode(nPos);
+ if( pTxtNd && pOutlRule && pTxtNd->IsNumbered())
+ {
+ SwNumberTree::tNumberVector aNumVector =
+ pTxtNd->GetNumberVector();
+ for( sal_Int8 nLevel = 0;
+ nLevel <= pTxtNd->GetActualListLevel();
+ nLevel++ )
+ {
+ sal_uInt16 nVal = (sal_uInt16)aNumVector[nLevel];
+ nVal ++;
+ nVal = nVal - pOutlRule->Get(nLevel).GetStart();
+ sEntry += OUString::number( nVal );
+ sEntry += ".";
+ }
+ }
+ sEntry += pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineText(nPos, false);
+ sOutlineText = pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineText(nPos, true);
+ bIsOutlineMoveable = ((SwOutlineContent*)pCnt)->IsMoveable();
+ bOutline = true;
+ }
+ }
+ break;
+ case CONTENT_TYPE_POSTIT:
+ case CONTENT_TYPE_INDEX:
+ case CONTENT_TYPE_REFERENCE :
+ // cannot inserted as URL or as koennen weder als URL noch als region
+ break;
+ case CONTENT_TYPE_URLFIELD:
+ sUrl = ((SwURLFieldContent*)pCnt)->GetURL();
+ // no break;
+ case CONTENT_TYPE_OLE:
+ case CONTENT_TYPE_GRAPHIC:
+ if(GetParentWindow()->GetRegionDropMode() != REGION_MODE_NONE)
+ break;
+ else
+ rDragMode &= ~( DND_ACTION_MOVE | DND_ACTION_LINK );
+ default:
+ sEntry = GetEntryText(pEntry);
+ }
+
+ bool bRet = false;
+ if(!sEntry.isEmpty())
+ {
+ const SwDocShell* pDocShell = pWrtShell->GetView().GetDocShell();
+ if(sUrl.isEmpty())
+ {
+ if(pDocShell->HasName())
+ {
+ SfxMedium* pMedium = pDocShell->GetMedium();
+ sUrl = pMedium->GetURLObject().GetURLNoMark();
+ // only if a primarily link shall be integrated.
+ bRet = true;
+ }
+ else if( nActType == CONTENT_TYPE_REGION ||
+ nActType == CONTENT_TYPE_BOOKMARK )
+ {
+ // For field and bookmarks a link is also allowed
+ // without a filename into its own document.
+ bRet = true;
+ }
+ else if(bIsConstant &&
+ ( !::GetActiveView() ||
+ pActiveShell != ::GetActiveView()->GetWrtShellPtr()))
+ {
+ // Urls of inactive views cannot dragged without
+ // file names, also.
+ bRet = false;
+ }
+ else
+ {
+ bRet = GetParentWindow()->GetRegionDropMode() == REGION_MODE_NONE;
+ rDragMode = DND_ACTION_MOVE;
+ }
+
+ const OUString& rToken = pCnt->GetParent()->GetTypeToken();
+ sUrl += "#";
+ sUrl += sEntry;
+ if(!rToken.isEmpty())
+ {
+ sUrl += OUString(cMarkSeparator);
+ sUrl += rToken;
+ }
+ }
+ else
+ bRet = true;
+
+ if( bRet )
+ {
+ // In Outlines of heading text must match
+ // the real number into the description.
+ if(bOutline)
+ sEntry = sOutlineText;
+
+ {
+ NaviContentBookmark aBmk( sUrl, sEntry,
+ GetParentWindow()->GetRegionDropMode(),
+ pDocShell);
+ aBmk.Copy( rTransfer );
+ }
+
+ // An INetBookmark must a be delivered to foreign DocShells
+ if( pDocShell->HasName() )
+ {
+ INetBookmark aBkmk( sUrl, sEntry );
+ rTransfer.CopyINetBookmark( aBkmk );
+ }
+ }
+ }
+ return bRet;
+}
+
+// Switch the display to Root
+
+bool SwContentTree::ToggleToRoot()
+{
+ if(!bIsRoot)
+ {
+ SvTreeListEntry* pEntry = GetCurEntry();
+ const SwContentType* pCntType;
+ if(pEntry)
+ {
+ if(lcl_IsContentType(pEntry))
+ pCntType = (SwContentType*)pEntry->GetUserData();
+ else
+ pCntType = ((SwContent*)pEntry->GetUserData())->GetParent();
+ nRootType = pCntType->GetType();
+ bIsRoot = true;
+ Display(bIsActive || bIsConstant);
+ }
+ }
+ else
+ {
+ nRootType = USHRT_MAX;
+ bIsRoot = false;
+ FindActiveTypeAndRemoveUserData();
+ Display(bIsActive || bIsConstant);
+ if( bIsKeySpace )
+ {
+ HideFocus();
+ ShowFocus( oldRectangle);
+ bIsKeySpace = false;
+ }
+ }
+ pConfig->SetRootType( nRootType );
+ GetParentWindow()->aContentToolBox.CheckItem(FN_SHOW_ROOT, bIsRoot ? sal_True : sal_False);
+ return bIsRoot;
+}
+
+// Check if the displayed content is valid.
+
+bool SwContentTree::HasContentChanged()
+{
+
+// - Run through the local array and the Treelistbox in parallel.
+// - Are the records not expanded, they are discarded only in the array
+// and the content type will be set as the new UserData.
+// - Is the root mode is active only this will be updated.
+
+// Valid for the displayed content types is:
+// the Memberlist will be erased and the membercount will be updated
+// If content will be checked, the memberlists will be replenished
+// at the same time. Once a difference occurs it will be only replenished
+// no longer checked. Finally, the box is filled again.
+
+ bool bRepaint = false;
+ sal_Bool bInvalidate = sal_False;
+
+ if(!bIsActive && ! bIsConstant)
+ {
+ for(sal_uInt16 i=0; i < CONTENT_TYPE_MAX; i++)
+ {
+ if(aActiveContentArr[i])
+ aActiveContentArr[i]->Invalidate();
+ }
+ }
+ else if(bIsRoot)
+ {
+ bool bOutline = false;
+ SvTreeListEntry* pEntry = First();
+ if(!pEntry)
+ bRepaint = true;
+ else
+ {
+ sal_uInt16 nType = ((SwContentType*)pEntry->GetUserData())->GetType();
+ bOutline = nRootType == CONTENT_TYPE_OUTLINE;
+ SwContentType* pArrType = aActiveContentArr[nType];
+ if(!pArrType)
+ bRepaint = true;
+ else
+ {
+ sal_uInt16 nSelLevel = USHRT_MAX;
+
+ SvTreeListEntry* pFirstSel;
+ if(bOutline &&
+ 0 != ( pFirstSel = FirstSelected()) &&
+ lcl_IsContent(pFirstSel))
+ {
+ nSelLevel = ((SwOutlineContent*)pFirstSel->GetUserData())->GetOutlineLevel();
+ SwWrtShell* pSh = GetWrtShell();
+ sal_uInt16 nOutlinePos = pSh->GetOutlinePos(MAXLEVEL);
+ if (nOutlinePos != USHRT_MAX &&
+ pSh->getIDocumentOutlineNodesAccess()->getOutlineLevel(nOutlinePos) != nSelLevel)
+ bRepaint = true;
+ }
+
+ pArrType->Init(&bInvalidate);
+ pArrType->FillMemberList();
+ pEntry->SetUserData((void*)pArrType);
+ if(!bRepaint)
+ {
+ if(GetChildCount(pEntry) != pArrType->GetMemberCount())
+ bRepaint = true;
+ else
+ {
+ sal_uInt16 nChildCount = (sal_uInt16)GetChildCount(pEntry);
+ for(sal_uInt16 j = 0; j < nChildCount; j++)
+ {
+ pEntry = Next(pEntry);
+ const SwContent* pCnt = pArrType->GetMember(j);
+ pEntry->SetUserData((void*)pCnt);
+ OUString sEntryText = GetEntryText(pEntry);
+ if( sEntryText != pCnt->GetName() &&
+ !(sEntryText == sSpace && pCnt->GetName().isEmpty()))
+ bRepaint = true;
+ }
+ }
+ }
+ }
+ }
+ if( !bRepaint && bOutline )
+ {
+ // find out where the cursor is
+ const sal_uInt16 nActPos = GetWrtShell()->GetOutlinePos(MAXLEVEL);
+ SvTreeListEntry* pFirstEntry = First();
+
+ while( 0 != (pFirstEntry = Next(pFirstEntry)) )
+ {
+ if(((SwOutlineContent*)pFirstEntry->GetUserData())->GetPos() == nActPos)
+ {
+ if(FirstSelected() != pFirstEntry)
+ {
+ Select(pFirstEntry);
+ MakeVisible(pFirstEntry);
+ }
+ }
+ }
+
+ }
+
+ }
+ else
+ {
+ SvTreeListEntry* pEntry = First();
+ while ( pEntry )
+ {
+ bool bNext = true; // at least a next must be
+ SwContentType* pTreeType = (SwContentType*)pEntry->GetUserData();
+ sal_uInt16 nType = pTreeType->GetType();
+ sal_uInt16 nTreeCount = pTreeType->GetMemberCount();
+ SwContentType* pArrType = aActiveContentArr[nType];
+ if(!pArrType)
+ bRepaint = true;
+ else
+ {
+ pArrType->Init(&bInvalidate);
+ pEntry->SetUserData((void*)pArrType);
+ if(IsExpanded(pEntry))
+ {
+ sal_Bool bLevelOrVisibiblityChanged = sal_False;
+ // bLevelOrVisibiblityChanged is set if outlines have changed their level
+ // or if the visibility of objects (frames, sections, tables) has changed
+ // i.e. in header/footer
+ pArrType->FillMemberList(&bLevelOrVisibiblityChanged);
+ sal_uInt16 nChildCount = (sal_uInt16)GetChildCount(pEntry);
+ if((nType == CONTENT_TYPE_OUTLINE) && bLevelOrVisibiblityChanged)
+ bRepaint = true;
+ if(bLevelOrVisibiblityChanged)
+ bInvalidate = sal_True;
+
+ if(nChildCount != pArrType->GetMemberCount())
+ bRepaint = true;
+ else
+ {
+ for(sal_uInt16 j = 0; j < nChildCount; j++)
+ {
+ pEntry = Next(pEntry);
+ bNext = false;
+ const SwContent* pCnt = pArrType->GetMember(j);
+ pEntry->SetUserData((void*)pCnt);
+ OUString sEntryText = GetEntryText(pEntry);
+ if( sEntryText != pCnt->GetName() &&
+ !(sEntryText == sSpace && pCnt->GetName().isEmpty()))
+ bRepaint = true;
+ }
+ }
+
+ }
+ else if(pEntry->HasChildren())
+ {
+ // was the entry once opened, then must also the
+ // invisible records be examined.
+ // At least the user data must be updated.
+ sal_Bool bLevelOrVisibiblityChanged = sal_False;
+ // bLevelOrVisibiblityChanged is set if outlines have changed their level
+ // or if the visibility of objects (frames, sections, tables) has changed
+ // i.e. in header/footer
+ pArrType->FillMemberList(&bLevelOrVisibiblityChanged);
+ sal_Bool bRemoveChildren = sal_False;
+ sal_uInt16 nChildCount = (sal_uInt16)GetChildCount(pEntry);
+ if( nChildCount != pArrType->GetMemberCount() )
+ {
+ bRemoveChildren = sal_True;
+ }
+ else
+ {
+ SvTreeListEntry* pChild = FirstChild(pEntry);
+ for(sal_uInt16 j = 0; j < nChildCount; j++)
+ {
+ const SwContent* pCnt = pArrType->GetMember(j);
+ pChild->SetUserData((void*)pCnt);
+ OUString sEntryText = GetEntryText(pChild);
+ if( sEntryText != pCnt->GetName() &&
+ !(sEntryText == sSpace && pCnt->GetName().isEmpty()))
+ bRemoveChildren = sal_True;
+ pChild = Next(pChild);
+ }
+ }
+ if(bRemoveChildren)
+ {
+ SvTreeListEntry* pChild = FirstChild(pEntry);
+ SvTreeListEntry* pRemove = pChild;
+ for(sal_uInt16 j = 0; j < nChildCount; j++)
+ {
+ pChild = Next(pRemove);
+ GetModel()->Remove(pRemove);
+ pRemove = pChild;
+ }
+ }
+ if(!nChildCount)
+ {
+ pEntry->EnableChildrenOnDemand(false);
+ InvalidateEntry(pEntry);
+ }
+
+ }
+ else if((nTreeCount != 0)
+ != (pArrType->GetMemberCount()!=0))
+ {
+ bRepaint = true;
+ }
+ }
+ // The Root-Entry has to be found now
+ while( pEntry && (bNext || GetParent(pEntry ) ))
+ {
+ pEntry = Next(pEntry);
+ bNext = false;
+ }
+ }
+ }
+ if(!bRepaint && bInvalidate)
+ Invalidate();
+ return bRepaint;
+}
+
+// Before any data will be deleted, the last active entry has to be found.
+// After this the UserData will be deleted
+
+void SwContentTree::FindActiveTypeAndRemoveUserData()
+{
+ SvTreeListEntry* pEntry = FirstSelected();
+ if(pEntry)
+ {
+ // If clear is called by TimerUpdate:
+ // Only for root can the validity of the UserData be guaranteed.
+ SvTreeListEntry* pParent;
+ while(0 != (pParent = GetParent(pEntry)))
+ pEntry = pParent;
+ if(pEntry->GetUserData() && lcl_IsContentType(pEntry))
+ nLastSelType = ((SwContentType*)pEntry->GetUserData())->GetType();
+ }
+ pEntry = First();
+ while(pEntry)
+ {
+ pEntry->SetUserData(0);
+ pEntry = Next(pEntry);
+ }
+}
+
+// After a file is dropped on the Navigator,
+// the new shell will be set.
+
+void SwContentTree::SetHiddenShell(SwWrtShell* pSh)
+{
+ pHiddenShell = pSh;
+ bIsHidden = true;
+ bIsActive = bIsConstant = false;
+ FindActiveTypeAndRemoveUserData();
+ for(sal_uInt16 i=0; i < CONTENT_TYPE_MAX; i++)
+ {
+ DELETEZ(aHiddenContentArr[i]);
+ }
+ Display(bIsActive);
+
+ GetParentWindow()->UpdateListBox();
+}
+
+// Document change - set new Shell
+
+void SwContentTree::SetActiveShell(SwWrtShell* pSh)
+{
+ if(bIsInternalDrag)
+ bDocChgdInDragging = true;
+ bool bClear = pActiveShell != pSh;
+ if(bIsActive && bClear)
+ {
+ pActiveShell = pSh;
+ FindActiveTypeAndRemoveUserData();
+ Clear();
+ }
+ else if(bIsConstant)
+ {
+ if(!lcl_FindShell(pActiveShell))
+ {
+ pActiveShell = pSh;
+ bIsActive = true;
+ bIsConstant = false;
+ bClear = true;
+ }
+ }
+ // Only if it is the active view, the array will be deleted and
+ // the screen filled new.
+ if(bIsActive && bClear)
+ {
+ FindActiveTypeAndRemoveUserData();
+ for(sal_uInt16 i=0; i < CONTENT_TYPE_MAX; i++)
+ {
+ DELETEZ(aActiveContentArr[i]);
+ }
+ Display(true);
+ }
+}
+
+// Set an open view as active.
+
+void SwContentTree::SetConstantShell(SwWrtShell* pSh)
+{
+ pActiveShell = pSh;
+ bIsActive = false;
+ bIsConstant = true;
+ FindActiveTypeAndRemoveUserData();
+ for(sal_uInt16 i=0; i < CONTENT_TYPE_MAX; i++)
+ {
+ DELETEZ(aActiveContentArr[i]);
+ }
+ Display(true);
+}
+
+// Execute commands of the Navigator
+
+void SwContentTree::ExecCommand(sal_uInt16 nCmd, sal_Bool bModifier)
+{
+ bool nMove = false;
+ switch( nCmd )
+ {
+ case FN_ITEM_DOWN:
+ case FN_ITEM_UP: nMove = true;
+ case FN_ITEM_LEFT:
+ case FN_ITEM_RIGHT:
+ if( !GetWrtShell()->GetView().GetDocShell()->IsReadOnly() &&
+ (bIsActive ||
+ (bIsConstant && pActiveShell == GetParentWindow()->GetCreateView()->GetWrtShellPtr())))
+ {
+ SwWrtShell* pShell = GetWrtShell();
+ sal_Int8 nActOutlineLevel = nOutlineLevel;
+ sal_uInt16 nActPos = pShell->GetOutlinePos(nActOutlineLevel);
+ SvTreeListEntry* pFirstEntry = FirstSelected();
+ if (pFirstEntry && lcl_IsContent(pFirstEntry))
+ {
+ if ( (bIsRoot && nRootType == CONTENT_TYPE_OUTLINE) ||
+ ((SwContent*)pFirstEntry->GetUserData())->GetParent()->GetType()
+ == CONTENT_TYPE_OUTLINE)
+ {
+ nActPos = ((SwOutlineContent*)pFirstEntry->GetUserData())->GetPos();
+ }
+ }
+ if ( nActPos < USHRT_MAX &&
+ ( !nMove || pShell->IsOutlineMovable( nActPos )) )
+ {
+ pShell->StartAllAction();
+ pShell->GotoOutline( nActPos); // If text selection != box selection
+ pShell->Push();
+ pShell->MakeOutlineSel( nActPos, nActPos,
+ bModifier);
+ if( nMove )
+ {
+ short nDir = nCmd == FN_ITEM_UP ? -1 : 1;
+ if( !bModifier && ( (nDir == -1 && nActPos > 0) ||
+ (nDir == 1 && nActPos < GetEntryCount() - 2) ) )
+ {
+ pShell->MoveOutlinePara( nDir );
+ // Set cursor back to the current position
+ pShell->GotoOutline( nActPos + nDir);
+ }
+ else if(bModifier)
+ {
+ sal_uInt16 nActEndPos = nActPos;
+ SvTreeListEntry* pEntry = pFirstEntry;
+ sal_uInt16 nActLevel = ((SwOutlineContent*)
+ pFirstEntry->GetUserData())->GetOutlineLevel();
+ pEntry = Next(pEntry);
+ while( pEntry && CONTENT_TYPE_OUTLINE ==
+ ((SwTypeNumber*)pEntry->GetUserData())->GetTypeId() )
+ {
+ if(nActLevel >= ((SwOutlineContent*)
+ pEntry->GetUserData())->GetOutlineLevel())
+ break;
+ pEntry = Next(pEntry);
+ nActEndPos++;
+ }
+ sal_uInt16 nDest;
+ if(nDir == 1)
+ {
+ // If the last entry is to be moved it is over!
+ if(pEntry && CONTENT_TYPE_OUTLINE ==
+ ((SwTypeNumber*)pEntry->GetUserData())->GetTypeId())
+ {
+ // pEntry now points to the following entry of the last
+ // selected entry.
+ nDest = nActEndPos;
+ nDest++;
+ // here needs to found the next record after next.
+ // The selection must be inserted in front of.
+ while(pEntry )
+ {
+ pEntry = Next(pEntry);
+ // nDest++ may only executed if pEntry != 0
+ if(pEntry && nDest++ &&
+ ( nActLevel >= ((SwOutlineContent*)pEntry->GetUserData())->GetOutlineLevel()||
+ CONTENT_TYPE_OUTLINE != ((SwTypeNumber*)pEntry->GetUserData())->GetTypeId()))
+ {
+ nDest--;
+ break;
+ }
+ }
+ nDir = nDest - nActEndPos;
+ // If no entry was found which corresponds the condition
+ // of the previously paste, it needs to be pushed slightly less.
+ }
+ else
+ nDir = 0;
+ }
+ else
+ {
+ nDest = nActPos;
+ pEntry = pFirstEntry;
+ while(pEntry && nDest )
+ {
+ nDest--;
+ pEntry = Prev(pEntry);
+ if(pEntry &&
+ (nActLevel >= ((SwOutlineContent*)pEntry->GetUserData())->GetOutlineLevel()||
+ CONTENT_TYPE_OUTLINE !=
+ ((SwTypeNumber*)pEntry->GetUserData())->GetTypeId()))
+ {
+ break;
+ }
+ }
+ nDir = nDest - nActPos;
+ }
+ if(nDir)
+ {
+ pShell->MoveOutlinePara( nDir );
+ //Set cursor back to the current position
+ pShell->GotoOutline( nActPos + nDir);
+ }
+ }
+ }
+ else
+ {
+ if( !pShell->IsProtectedOutlinePara() )
+ pShell->OutlineUpDown( nCmd == FN_ITEM_LEFT ? -1 : 1 );
+ }
+
+ pShell->ClearMark();
+ pShell->Pop(sal_False); // Cursor is now back at the current superscription.
+ pShell->EndAllAction();
+ if(aActiveContentArr[CONTENT_TYPE_OUTLINE])
+ aActiveContentArr[CONTENT_TYPE_OUTLINE]->Invalidate();
+ Display(true);
+ if(!bIsRoot)
+ {
+ const sal_uInt16 nCurrPos = pShell->GetOutlinePos(MAXLEVEL);
+ SvTreeListEntry* pFirst = First();
+
+ while( 0 != (pFirst = Next(pFirst)) && lcl_IsContent(pFirst))
+ {
+ if(((SwOutlineContent*)pFirst->GetUserData())->GetPos() == nCurrPos)
+ {
+ Select(pFirst);
+ MakeVisible(pFirst);
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+void SwContentTree::ShowTree()
+{
+ aUpdTimer.Start();
+ SvTreeListBox::Show();
+}
+
+// folded together will not be geidled
+
+void SwContentTree::HideTree()
+{
+ aUpdTimer.Stop();
+ SvTreeListBox::Hide();
+}
+
+// No idle with focus or while dragging.
+
+IMPL_LINK_NOARG(SwContentTree, TimerUpdate)
+{
+ // No update while drag and drop.
+ // Query view because the Navigator is cleared too late.
+ SwView* pView = GetParentWindow()->GetCreateView();
+ if( (!HasFocus() || bViewHasChanged) &&
+ !bIsInDrag && !bIsInternalDrag && pView &&
+ pView->GetWrtShellPtr() && !pView->GetWrtShellPtr()->ActionPend() )
+ {
+ bViewHasChanged = false;
+ bIsIdleClear = false;
+ SwWrtShell* pActShell = pView->GetWrtShellPtr();
+ if( bIsConstant && !lcl_FindShell( pActiveShell ) )
+ {
+ SetActiveShell(pActShell);
+ GetParentWindow()->UpdateListBox();
+ }
+
+ if(bIsActive && pActShell != GetWrtShell())
+ SetActiveShell(pActShell);
+ else if( (bIsActive || (bIsConstant && pActShell == GetWrtShell())) &&
+ HasContentChanged())
+ {
+ FindActiveTypeAndRemoveUserData();
+ Display(true);
+ }
+ }
+ else if(!pView && bIsActive && !bIsIdleClear)
+ {
+ if(pActiveShell)
+ SetActiveShell(0);
+ Clear();
+ bIsIdleClear = true;
+ }
+ return 0;
+}
+
+DragDropMode SwContentTree::NotifyStartDrag(
+ TransferDataContainer& rContainer,
+ SvTreeListEntry* pEntry )
+{
+ DragDropMode eMode = (DragDropMode)0;
+ if( bIsActive && nRootType == CONTENT_TYPE_OUTLINE &&
+ GetModel()->GetAbsPos( pEntry ) > 0
+ && !GetWrtShell()->GetView().GetDocShell()->IsReadOnly())
+ eMode = GetDragDropMode();
+ else if(!bIsActive && GetWrtShell()->GetView().GetDocShell()->HasName())
+ eMode = SV_DRAGDROP_APP_COPY;
+
+ sal_Int8 nDragMode;
+ FillTransferData( rContainer, nDragMode );
+ bDocChgdInDragging = false;
+ bIsInternalDrag = true;
+ return eMode;
+}
+// After the drag the current paragraph will be moved w i t h the children.
+
+sal_Bool SwContentTree::NotifyMoving( SvTreeListEntry* pTarget,
+ SvTreeListEntry* pEntry, SvTreeListEntry*& , sal_uLong& )
+{
+ if(!bDocChgdInDragging)
+ {
+ sal_uInt16 nTargetPos = 0;
+ sal_uInt16 nSourcePos = (( SwOutlineContent* )pEntry->GetUserData())->GetPos();
+ if(!lcl_IsContent(pTarget))
+ nTargetPos = USHRT_MAX;
+ else
+ nTargetPos = (( SwOutlineContent* )pTarget->GetUserData())->GetPos();
+ if( MAXLEVEL > nOutlineLevel && // Not all layers are displayed.
+ nTargetPos != USHRT_MAX)
+ {
+ SvTreeListEntry* pNext = Next(pTarget);
+ if(pNext)
+ nTargetPos = (( SwOutlineContent* )pNext->GetUserData())->GetPos() -1;
+ else
+ nTargetPos = static_cast<sal_uInt16>(GetWrtShell()->getIDocumentOutlineNodesAccess()->getOutlineNodesCount())- 1;
+
+ }
+
+ OSL_ENSURE( pEntry &&
+ lcl_IsContent(pEntry),"Source == 0 or Source has no Content" );
+ GetParentWindow()->MoveOutline( nSourcePos,
+ nTargetPos,
+ true);
+
+ aActiveContentArr[CONTENT_TYPE_OUTLINE]->Invalidate();
+ Display(true);
+ }
+ //TreeListBox will be reloaded from the document
+ return sal_False;
+}
+
+// After the drag the current paragraph will be moved w i t h o u t the children.
+
+sal_Bool SwContentTree::NotifyCopying( SvTreeListEntry* pTarget,
+ SvTreeListEntry* pEntry, SvTreeListEntry*& , sal_uLong& )
+{
+ if(!bDocChgdInDragging)
+ {
+ sal_uInt16 nTargetPos = 0;
+ sal_uInt16 nSourcePos = (( SwOutlineContent* )pEntry->GetUserData())->GetPos();
+ if(!lcl_IsContent(pTarget))
+ nTargetPos = USHRT_MAX;
+ else
+ nTargetPos = (( SwOutlineContent* )pTarget->GetUserData())->GetPos();
+
+ if( MAXLEVEL > nOutlineLevel && // Not all layers are displayed.
+ nTargetPos != USHRT_MAX)
+ {
+ SvTreeListEntry* pNext = Next(pTarget);
+ if(pNext)
+ nTargetPos = (( SwOutlineContent* )pNext->GetUserData())->GetPos() - 1;
+ else
+ nTargetPos = static_cast<sal_uInt16>(GetWrtShell()->getIDocumentOutlineNodesAccess()->getOutlineNodesCount()) - 1;
+
+ }
+
+ OSL_ENSURE( pEntry &&
+ lcl_IsContent(pEntry),"Source == 0 or Source has no Content" );
+ GetParentWindow()->MoveOutline( nSourcePos, nTargetPos, false);
+
+ //TreeListBox will be reloaded from the document
+ aActiveContentArr[CONTENT_TYPE_OUTLINE]->Invalidate();
+ Display(true);
+ }
+ return sal_False;
+}
+
+// No drop before the first entry - it's a SwContentType
+
+sal_Bool SwContentTree::NotifyAcceptDrop( SvTreeListEntry* pEntry)
+{
+ return pEntry != 0;
+}
+
+// If a Ctrl + DoubleClick are executed in an open area,
+// then the base function of the control is to be called.
+
+void SwContentTree::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ Point aPos( rMEvt.GetPosPixel());
+ SvTreeListEntry* pEntry = GetEntry( aPos, sal_True );
+ if( !pEntry && rMEvt.IsLeft() && rMEvt.IsMod1() && (rMEvt.GetClicks() % 2) == 0)
+ Control::MouseButtonDown( rMEvt );
+ else
+ SvTreeListBox::MouseButtonDown( rMEvt );
+}
+
+// Update immediately
+
+void SwContentTree::GetFocus()
+{
+ SwView* pActView = GetParentWindow()->GetCreateView();
+ if(pActView)
+ {
+ SwWrtShell* pActShell = pActView->GetWrtShellPtr();
+ if(bIsConstant && !lcl_FindShell(pActiveShell))
+ {
+ SetActiveShell(pActShell);
+ }
+
+ if(bIsActive && pActShell != GetWrtShell())
+ SetActiveShell(pActShell);
+ else if( (bIsActive || (bIsConstant && pActShell == GetWrtShell())) &&
+ HasContentChanged())
+ {
+ Display(true);
+ }
+ }
+ else if(bIsActive)
+ Clear();
+ SvTreeListBox::GetFocus();
+}
+
+void SwContentTree::KeyInput(const KeyEvent& rEvent)
+{
+ const KeyCode aCode = rEvent.GetKeyCode();
+ if(aCode.GetCode() == KEY_RETURN)
+ {
+ SvTreeListEntry* pEntry = FirstSelected();
+ if ( pEntry )
+ {
+ switch(aCode.GetModifier())
+ {
+ case KEY_MOD2:
+ // Switch boxes
+ GetParentWindow()->ToggleTree();
+ break;
+ case KEY_MOD1:
+ // Switch RootMode
+ ToggleToRoot();
+ break;
+ case 0:
+ if(lcl_IsContentType(pEntry))
+ {
+ IsExpanded(pEntry) ?
+ Collapse(pEntry) :
+ Expand(pEntry);
+ }
+ else
+ ContentDoubleClickHdl(0);
+ break;
+ }
+ }
+ }
+ else if(aCode.GetCode() == KEY_DELETE && 0 == aCode.GetModifier())
+ {
+ SvTreeListEntry* pEntry = FirstSelected();
+ if(pEntry &&
+ lcl_IsContent(pEntry) &&
+ ((SwContent*)pEntry->GetUserData())->GetParent()->IsDeletable() &&
+ !pActiveShell->GetView().GetDocShell()->IsReadOnly())
+ {
+ EditEntry(pEntry, EDIT_MODE_DELETE);
+ bViewHasChanged = true;
+ GetParentWindow()->UpdateListBox();
+ TimerUpdate(&aUpdTimer);
+ GrabFocus();
+ }
+ }
+ //Make KEY_SPACE has same function as DoubleClick ,
+ //and realize multi-selection .
+ else if(aCode.GetCode() == KEY_SPACE && 0 == aCode.GetModifier())
+ {
+
+ SvTreeListEntry* pEntry = GetCurEntry();
+ if( GetChildCount( pEntry ) == 0 )
+ bIsKeySpace = true;
+ Point tempPoint = GetEntryPosition( pEntry );//Change from "GetEntryPos" to "GetEntryPosition" for acc migration
+ oldRectangle = GetFocusRect( pEntry,tempPoint.Y() );
+
+ if(pEntry)
+ {
+ if(bIsActive || bIsConstant)
+ {
+ if(bIsConstant)
+ {
+ pActiveShell->GetView().GetViewFrame()->GetWindow().ToTop();
+ }
+
+ SwContent* pCnt = (SwContent*)pEntry->GetUserData();
+
+ sal_uInt16 nJumpType = pCnt->GetParent()->GetType();
+ switch(nJumpType)
+ {
+ case CONTENT_TYPE_DRAWOBJECT:
+ {
+ SdrView* pDrawView = pActiveShell->GetDrawView();
+ if (pDrawView)
+ {
+ pDrawView->SdrEndTextEdit();//Change from "EndTextEdit" to "SdrEndTextEdit" for acc migration
+
+ SdrModel* pDrawModel = pActiveShell->GetDoc()->GetDrawModel();
+ SdrPage* pPage = pDrawModel->GetPage(0);
+ sal_uInt32 nCount = pPage->GetObjCount();
+ sal_Bool hasObjectMarked = sal_False;
+
+ SdrObject* pObject = NULL;
+ pObject = GetDrawingObjectsByContent( pCnt );
+ if( pObject )
+ {
+ SdrPageView* pPV = pDrawView->GetSdrPageView/*GetPageViewPvNum*/(/*0*/);
+ if( pPV )
+ {
+ sal_Bool bUnMark = pDrawView->IsObjMarked(pObject);
+ pDrawView->MarkObj( pObject, pPV, bUnMark);
+
+ }
+ }
+ for( sal_uInt32 i=0; i< nCount; i++ )
+ {
+ SdrObject* pTemp = pPage->GetObj(i);
+ sal_Bool bMark = pDrawView->IsObjMarked(pTemp);
+ switch( pTemp->GetObjIdentifier() )
+ {
+ case OBJ_GRUP:
+ case OBJ_TEXT:
+ case OBJ_TEXTEXT:
+ case OBJ_wegFITTEXT:
+ case OBJ_LINE:
+ case OBJ_RECT:
+ case OBJ_CIRC:
+ case OBJ_SECT:
+ case OBJ_CARC:
+ case OBJ_CCUT:
+ case OBJ_POLY:
+ case OBJ_PLIN:
+ case OBJ_PATHLINE:
+ case OBJ_PATHFILL:
+ case OBJ_FREELINE:
+ case OBJ_FREEFILL:
+ case OBJ_PATHPOLY:
+ case OBJ_PATHPLIN:
+ case OBJ_CAPTION:
+ case OBJ_CUSTOMSHAPE:
+ if( bMark )
+ hasObjectMarked = sal_True;
+ break;
+ default:
+ if ( bMark )
+ {
+ SdrPageView* pPV = pDrawView->GetSdrPageView/*GetPageViewPvNum*/(/*0*/);
+ if (pPV)
+ {
+ pDrawView->MarkObj(pTemp, pPV, sal_True);
+ }
+ }
+ }
+ //mod end
+ }
+ if ( !hasObjectMarked )
+ {
+ SwEditWin& pEditWindow =
+ pActiveShell->GetView().GetEditWin();
+ if( &pEditWindow )
+ {
+ KeyCode tempKeycode( KEY_ESCAPE );
+ KeyEvent rKEvt( 0 , tempKeycode );
+ ((Window*)&pEditWindow)->KeyInput( rKEvt );
+
+ }
+ //rView.GetEditWin().GrabFocus();
+ }
+ }
+ }
+ break;
+ }
+
+ bViewHasChanged = true;
+ }
+ }
+
+ }
+ else
+ SvTreeListBox::KeyInput(rEvent);
+
+}
+
+void SwContentTree::RequestHelp( const HelpEvent& rHEvt )
+{
+ bool bCallBase = true;
+ if( rHEvt.GetMode() & HELPMODE_QUICK )
+ {
+ Point aPos( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ));
+ SvTreeListEntry* pEntry = GetEntry( aPos );
+ if( pEntry )
+ {
+ sal_uInt16 nType;
+ bool bBalloon = false;
+ bool bContent = false;
+ void* pUserData = pEntry->GetUserData();
+ if(lcl_IsContentType(pEntry))
+ nType = ((SwContentType*)pUserData)->GetType();
+ else
+ {
+ nType = ((SwContent*)pUserData)->GetParent()->GetType();
+ bContent = true;
+ }
+ OUString sEntry;
+ bool bRet = false;
+ if(bContent)
+ {
+ switch( nType )
+ {
+ case CONTENT_TYPE_URLFIELD:
+ sEntry = ((SwURLFieldContent*)pUserData)->GetURL();
+ bRet = true;
+ break;
+
+ case CONTENT_TYPE_POSTIT:
+ sEntry = ((SwPostItContent*)pUserData)->GetName();
+ bRet = true;
+ if(Help::IsBalloonHelpEnabled())
+ bBalloon = true;
+ break;
+ case CONTENT_TYPE_OUTLINE:
+ sEntry = ((SwOutlineContent*)pUserData)->GetName();
+ bRet = true;
+ break;
+ case CONTENT_TYPE_GRAPHIC:
+ sEntry = ((SwGraphicContent*)pUserData)->GetLink();
+#if OSL_DEBUG_LEVEL > 1
+ sEntry += " ";
+ sEntry += OUString::number(
+ ((SwGraphicContent*)pUserData)->GetYPos());
+#endif
+ bRet = true;
+ break;
+#if OSL_DEBUG_LEVEL > 1
+ case CONTENT_TYPE_TABLE:
+ case CONTENT_TYPE_FRAME:
+ sEntry = OUString::number(
+ ((SwContent*)pUserData)->GetYPos() );
+ bRet = true;
+ break;
+#endif
+ }
+ if(((SwContent*)pUserData)->IsInvisible())
+ {
+ if(!sEntry.isEmpty())
+ sEntry += ", ";
+ sEntry += sInvisible;
+ bRet = true;
+ }
+ }
+ else
+ {
+ sal_uInt16 nMemberCount = ((SwContentType*)pUserData)->GetMemberCount();
+ sEntry = OUString::number(nMemberCount);
+ sEntry += " ";
+ sEntry += nMemberCount == 1
+ ? ((SwContentType*)pUserData)->GetSingleName()
+ : ((SwContentType*)pUserData)->GetName();
+ bRet = true;
+ }
+ if(bRet)
+ {
+ SvLBoxTab* pTab;
+ SvLBoxItem* pItem = GetItem( pEntry, aPos.X(), &pTab );
+ if (pItem && SV_ITEM_ID_LBOXSTRING == pItem->GetType())
+ {
+ aPos = GetEntryPosition( pEntry );
+
+ aPos.X() = GetTabPos( pEntry, pTab );
+ Size aSize( pItem->GetSize( this, pEntry ) );
+
+ if((aPos.X() + aSize.Width()) > GetSizePixel().Width())
+ aSize.Width() = GetSizePixel().Width() - aPos.X();
+
+ aPos = OutputToScreenPixel(aPos);
+ Rectangle aItemRect( aPos, aSize );
+ if(bBalloon)
+ {
+ aPos.X() += aSize.Width();
+ Help::ShowBalloon( this, aPos, aItemRect, sEntry );
+ }
+ else
+ Help::ShowQuickHelp( this, aItemRect, sEntry,
+ QUICKHELP_LEFT|QUICKHELP_VCENTER );
+ bCallBase = false;
+ }
+ }
+ else
+ {
+ Help::ShowQuickHelp( this, Rectangle(), OUString(), 0 );
+ bCallBase = false;
+ }
+ }
+ }
+ if( bCallBase )
+ Window::RequestHelp( rHEvt );
+}
+
+void SwContentTree::ExcecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry )
+{
+ SvTreeListEntry* pFirst = FirstSelected();
+ switch( nSelectedPopupEntry )
+ {
+ //Outlinelevel
+ case 101:
+ case 102:
+ case 103:
+ case 104:
+ case 105:
+ case 106:
+ case 107:
+ case 108:
+ case 109:
+ case 110:
+ nSelectedPopupEntry -= 100;
+ if(nOutlineLevel != nSelectedPopupEntry )
+ SetOutlineLevel((sal_Int8)nSelectedPopupEntry);
+ break;
+ case 201:
+ case 202:
+ case 203:
+ GetParentWindow()->SetRegionDropMode(nSelectedPopupEntry - 201);
+ break;
+ case 401:
+ case 402:
+ EditEntry(pFirst, nSelectedPopupEntry == 401 ? EDIT_MODE_RMV_IDX : EDIT_MODE_UPD_IDX);
+ break;
+ // Edit entry
+ case 403:
+ EditEntry(pFirst, EDIT_MODE_EDIT);
+ break;
+ case 404:
+ EditEntry(pFirst, EDIT_UNPROTECT_TABLE);
+ break;
+ case 405 :
+ {
+ const SwTOXBase* pBase = ((SwTOXBaseContent*)pFirst->GetUserData())
+ ->GetTOXBase();
+ pActiveShell->SetTOXBaseReadonly(*pBase, !pActiveShell->IsTOXBaseReadonly(*pBase));
+ }
+ break;
+ case 4:
+ break;
+ case 501:
+ EditEntry(pFirst, EDIT_MODE_DELETE);
+ break;
+ case 502 :
+ EditEntry(pFirst, EDIT_MODE_RENAME);
+ break;
+ case 600:
+ pActiveShell->GetView().GetPostItMgr()->Show();
+ break;
+ case 601:
+ pActiveShell->GetView().GetPostItMgr()->Hide();
+ break;
+ case 602:
+ {
+ pActiveShell->GetView().GetPostItMgr()->SetActiveSidebarWin(0);
+ pActiveShell->GetView().GetPostItMgr()->Delete();
+ break;
+ }
+ //Display
+ default:
+ if(nSelectedPopupEntry > 300 && nSelectedPopupEntry < 400)
+ {
+ nSelectedPopupEntry -= 300;
+ SwView *pView = SwModule::GetFirstView();
+ while (pView)
+ {
+ nSelectedPopupEntry --;
+ if(nSelectedPopupEntry == 0)
+ {
+ SetConstantShell(&pView->GetWrtShell());
+ break;
+ }
+ pView = SwModule::GetNextView(pView);
+ }
+ if(nSelectedPopupEntry)
+ {
+ bViewHasChanged = bIsActive = nSelectedPopupEntry == 1;
+ bIsConstant = false;
+ Display(nSelectedPopupEntry == 1);
+ }
+ }
+ }
+ GetParentWindow()->UpdateListBox();
+}
+
+void SwContentTree::SetOutlineLevel(sal_uInt8 nSet)
+{
+ nOutlineLevel = nSet;
+ pConfig->SetOutlineLevel( nOutlineLevel );
+ SwContentType** ppContentT = bIsActive ?
+ &aActiveContentArr[CONTENT_TYPE_OUTLINE] :
+ &aHiddenContentArr[CONTENT_TYPE_OUTLINE];
+ if(*ppContentT)
+ {
+ (*ppContentT)->SetOutlineLevel(nOutlineLevel);
+ (*ppContentT)->Init();
+ }
+ Display(bIsActive);
+}
+
+// Mode Change: Show dropped Doc
+
+void SwContentTree::ShowHiddenShell()
+{
+ if(pHiddenShell)
+ {
+ bIsConstant = false;
+ bIsActive = false;
+ Display(false);
+ }
+}
+
+// Mode Change: Show active view
+
+void SwContentTree::ShowActualView()
+{
+ bIsActive = true;
+ bIsConstant = false;
+ Display(true);
+ GetParentWindow()->UpdateListBox();
+}
+
+// Here are the buttons for moving outlines are en-/disabled.
+
+sal_Bool SwContentTree::Select( SvTreeListEntry* pEntry, sal_Bool bSelect )
+{
+ if(!pEntry)
+ return sal_False;
+ sal_Bool bEnable = sal_False;
+ SvTreeListEntry* pParentEntry = GetParent(pEntry);
+ while(pParentEntry && (!lcl_IsContentType(pParentEntry)))
+ {
+ pParentEntry = GetParent(pParentEntry);
+ }
+ if(!bIsLastReadOnly && (!IsVisible() ||
+ ( (bIsRoot && nRootType == CONTENT_TYPE_OUTLINE && pParentEntry) ||
+ (lcl_IsContent(pEntry) && ((SwContentType*)pParentEntry->GetUserData())->GetType() == CONTENT_TYPE_OUTLINE)) ))
+ bEnable = sal_True;
+ SwNavigationPI* pNavi = GetParentWindow();
+ pNavi->aContentToolBox.EnableItem(FN_ITEM_UP , bEnable);
+ pNavi->aContentToolBox.EnableItem(FN_ITEM_DOWN, bEnable);
+ pNavi->aContentToolBox.EnableItem(FN_ITEM_LEFT, bEnable);
+ pNavi->aContentToolBox.EnableItem(FN_ITEM_RIGHT,bEnable);
+
+ return SvTreeListBox::Select(pEntry, bSelect);
+}
+
+void SwContentTree::SetRootType(sal_uInt16 nType)
+{
+ nRootType = nType;
+ bIsRoot = true;
+ pConfig->SetRootType( nRootType );
+}
+
+OUString SwContentType::RemoveNewline(const OUString& rEntry)
+{
+ if (rEntry.isEmpty())
+ return rEntry;
+
+ OUStringBuffer aEntry(rEntry);
+ for (sal_Int32 i = 0; i < rEntry.getLength(); ++i)
+ if(aEntry[i] == 10 || aEntry[i] == 13)
+ aEntry[i] = 0x20;
+
+ return aEntry.makeStringAndClear();
+}
+
+void SwContentTree::EditEntry(SvTreeListEntry* pEntry, sal_uInt8 nMode)
+{
+ SwContent* pCnt = (SwContent*)pEntry->GetUserData();
+ GotoContent(pCnt);
+ sal_uInt16 nType = pCnt->GetParent()->GetType();
+ sal_uInt16 nSlot = 0;
+
+ uno::Reference< container::XNameAccess > xNameAccess, xSecond, xThird;
+ switch(nType)
+ {
+ case CONTENT_TYPE_TABLE :
+ if(nMode == EDIT_UNPROTECT_TABLE)
+ {
+ pActiveShell->GetView().GetDocShell()->
+ GetDoc()->UnProtectCells( pCnt->GetName());
+ }
+ else if(nMode == EDIT_MODE_DELETE)
+ {
+ pActiveShell->StartAction();
+ OUString sTable = SW_RES(STR_TABLE_NAME);
+ SwRewriter aRewriterTableName;
+ aRewriterTableName.AddRule(UndoArg1, SW_RES(STR_START_QUOTE));
+ aRewriterTableName.AddRule(UndoArg2, pCnt->GetName());
+ aRewriterTableName.AddRule(UndoArg3, SW_RES(STR_END_QUOTE));
+ sTable = aRewriterTableName.Apply(sTable);
+
+ SwRewriter aRewriter;
+ aRewriter.AddRule(UndoArg1, sTable);
+ pActiveShell->StartUndo(UNDO_DELETE, &aRewriter);
+ pActiveShell->GetView().GetViewFrame()->GetDispatcher()->Execute(FN_TABLE_SELECT_ALL);
+ pActiveShell->DeleteRow();
+ pActiveShell->EndUndo();
+ pActiveShell->EndAction();
+ }
+ else if(nMode == EDIT_MODE_RENAME)
+ {
+ uno::Reference< frame::XModel > xModel = pActiveShell->GetView().GetDocShell()->GetBaseModel();
+ uno::Reference< text::XTextTablesSupplier > xTables(xModel, uno::UNO_QUERY);
+ xNameAccess = xTables->getTextTables();
+ }
+ else
+ nSlot = FN_FORMAT_TABLE_DLG;
+ break;
+
+ case CONTENT_TYPE_GRAPHIC :
+ if(nMode == EDIT_MODE_DELETE)
+ {
+ pActiveShell->DelRight();
+ }
+ else if(nMode == EDIT_MODE_RENAME)
+ {
+ uno::Reference< frame::XModel > xModel = pActiveShell->GetView().GetDocShell()->GetBaseModel();
+ uno::Reference< text::XTextGraphicObjectsSupplier > xGraphics(xModel, uno::UNO_QUERY);
+ xNameAccess = xGraphics->getGraphicObjects();
+ uno::Reference< text::XTextFramesSupplier > xFrms(xModel, uno::UNO_QUERY);
+ xSecond = xFrms->getTextFrames();
+ uno::Reference< text::XTextEmbeddedObjectsSupplier > xObjs(xModel, uno::UNO_QUERY);
+ xThird = xObjs->getEmbeddedObjects();
+ }
+ else
+ nSlot = FN_FORMAT_GRAFIC_DLG;
+ break;
+
+ case CONTENT_TYPE_FRAME :
+ case CONTENT_TYPE_OLE :
+ if(nMode == EDIT_MODE_DELETE)
+ {
+ pActiveShell->DelRight();
+ }
+ else if(nMode == EDIT_MODE_RENAME)
+ {
+ uno::Reference< frame::XModel > xModel = pActiveShell->GetView().GetDocShell()->GetBaseModel();
+ uno::Reference< text::XTextFramesSupplier > xFrms(xModel, uno::UNO_QUERY);
+ uno::Reference< text::XTextEmbeddedObjectsSupplier > xObjs(xModel, uno::UNO_QUERY);
+ if(CONTENT_TYPE_FRAME == nType)
+ {
+ xNameAccess = xFrms->getTextFrames();
+ xSecond = xObjs->getEmbeddedObjects();
+ }
+ else
+ {
+ xNameAccess = xObjs->getEmbeddedObjects();
+ xSecond = xFrms->getTextFrames();
+ }
+ uno::Reference< text::XTextGraphicObjectsSupplier > xGraphics(xModel, uno::UNO_QUERY);
+ xThird = xGraphics->getGraphicObjects();
+ }
+ else
+ nSlot = FN_FORMAT_FRAME_DLG;
+ break;
+ case CONTENT_TYPE_BOOKMARK :
+ if(nMode == EDIT_MODE_DELETE)
+ {
+ IDocumentMarkAccess* const pMarkAccess = pActiveShell->getIDocumentMarkAccess();
+ pMarkAccess->deleteMark( pMarkAccess->findMark(pCnt->GetName()) );
+ }
+ else if(nMode == EDIT_MODE_RENAME)
+ {
+ uno::Reference< frame::XModel > xModel = pActiveShell->GetView().GetDocShell()->GetBaseModel();
+ uno::Reference< text::XBookmarksSupplier > xBkms(xModel, uno::UNO_QUERY);
+ xNameAccess = xBkms->getBookmarks();
+ }
+ else
+ nSlot = FN_INSERT_BOOKMARK;
+ break;
+
+ case CONTENT_TYPE_REGION :
+ if(nMode == EDIT_MODE_RENAME)
+ {
+ uno::Reference< frame::XModel > xModel = pActiveShell->GetView().GetDocShell()->GetBaseModel();
+ uno::Reference< text::XTextSectionsSupplier > xSects(xModel, uno::UNO_QUERY);
+ xNameAccess = xSects->getTextSections();
+ }
+ else
+ nSlot = FN_EDIT_REGION;
+ break;
+
+ case CONTENT_TYPE_URLFIELD:
+ nSlot = FN_EDIT_HYPERLINK;
+ break;
+ case CONTENT_TYPE_REFERENCE:
+ nSlot = FN_EDIT_FIELD;
+ break;
+
+ case CONTENT_TYPE_POSTIT:
+ pActiveShell->GetView().GetPostItMgr()->AssureStdModeAtShell();
+ if(nMode == EDIT_MODE_DELETE)
+ {
+ if (((SwPostItContent*)pCnt)->IsPostIt())
+ {
+ pActiveShell->GetView().GetPostItMgr()->SetActiveSidebarWin(0);
+ pActiveShell->DelRight();
+ }
+ }
+ else
+ {
+ if (((SwPostItContent*)pCnt)->IsPostIt())
+ nSlot = FN_POSTIT;
+ else
+ nSlot = FN_REDLINE_COMMENT;
+ }
+ break;
+ case CONTENT_TYPE_INDEX:
+ {
+ const SwTOXBase* pBase = ((SwTOXBaseContent*)pCnt)->GetTOXBase();
+ switch(nMode)
+ {
+ case EDIT_MODE_EDIT:
+ if(pBase)
+ {
+ SwPtrItem aPtrItem( FN_INSERT_MULTI_TOX, (void*)pBase);
+ pActiveShell->GetView().GetViewFrame()->
+ GetDispatcher()->Execute(FN_INSERT_MULTI_TOX,
+ SFX_CALLMODE_ASYNCHRON, &aPtrItem, 0L);
+
+ }
+ break;
+ case EDIT_MODE_RMV_IDX:
+ case EDIT_MODE_DELETE:
+ {
+ if( pBase )
+ pActiveShell->DeleteTOX(*pBase, EDIT_MODE_DELETE == nMode);
+ }
+ break;
+ case EDIT_MODE_UPD_IDX:
+ case EDIT_MODE_RENAME:
+ {
+ Reference< frame::XModel > xModel = pActiveShell->GetView().GetDocShell()->GetBaseModel();
+ Reference< XDocumentIndexesSupplier > xIndexes(xModel, UNO_QUERY);
+ Reference< XIndexAccess> xIdxAcc(xIndexes->getDocumentIndexes());
+ Reference< XNameAccess >xLocalNameAccess(xIdxAcc, UNO_QUERY);
+ if(EDIT_MODE_RENAME == nMode)
+ xNameAccess = xLocalNameAccess;
+ else if(xLocalNameAccess.is() && xLocalNameAccess->hasByName(pBase->GetTOXName()))
+ {
+ Any aIdx = xLocalNameAccess->getByName(pBase->GetTOXName());
+ Reference< XDocumentIndex> xIdx;
+ if(aIdx >>= xIdx)
+ xIdx->update();
+ }
+ }
+ break;
+ }
+ }
+ break;
+ case CONTENT_TYPE_DRAWOBJECT :
+ if(EDIT_MODE_DELETE == nMode)
+ nSlot = SID_DELETE;
+ break;
+ }
+ if(nSlot)
+ pActiveShell->GetView().GetViewFrame()->
+ GetDispatcher()->Execute(nSlot, SFX_CALLMODE_ASYNCHRON);
+ else if(xNameAccess.is())
+ {
+ uno::Any aObj = xNameAccess->getByName(pCnt->GetName());
+ uno::Reference< uno::XInterface > xTmp;
+ aObj >>= xTmp;
+ uno::Reference< container::XNamed > xNamed(xTmp, uno::UNO_QUERY);
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+
+ AbstractSwRenameXNamedDlg* pDlg = pFact->CreateSwRenameXNamedDlg(this, xNamed, xNameAccess);
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ if(xSecond.is())
+ pDlg->SetAlternativeAccess( xSecond, xThird);
+
+ OUString sForbiddenChars;
+ if(CONTENT_TYPE_BOOKMARK == nType)
+ {
+ sForbiddenChars = "/\\@:*?\";,.#";
+ }
+ else if(CONTENT_TYPE_TABLE == nType)
+ {
+ sForbiddenChars = " .<>";
+ }
+ pDlg->SetForbiddenChars(sForbiddenChars);
+ pDlg->Execute();
+ delete pDlg;
+ }
+}
+
+void SwContentTree::GotoContent(SwContent* pCnt)
+{
+ pActiveShell->EnterStdMode();
+
+ bool bSel = false;
+ sal_uInt16 nJumpType = pCnt->GetParent()->GetType();
+ switch(nJumpType)
+ {
+ case CONTENT_TYPE_OUTLINE :
+ {
+ pActiveShell->GotoOutline(((SwOutlineContent*)pCnt)->GetPos());
+ }
+ break;
+ case CONTENT_TYPE_TABLE :
+ {
+ pActiveShell->GotoTable(pCnt->GetName());
+ }
+ break;
+ case CONTENT_TYPE_FRAME :
+ case CONTENT_TYPE_GRAPHIC :
+ case CONTENT_TYPE_OLE :
+ {
+ if(pActiveShell->GotoFly(pCnt->GetName()))
+ bSel = true;
+ }
+ break;
+ case CONTENT_TYPE_BOOKMARK:
+ {
+ pActiveShell->GotoMark(pCnt->GetName());
+ }
+ break;
+ case CONTENT_TYPE_REGION :
+ {
+ pActiveShell->GotoRegion(pCnt->GetName());
+ }
+ break;
+ case CONTENT_TYPE_URLFIELD:
+ {
+ if(pActiveShell->GotoINetAttr(
+ *((SwURLFieldContent*)pCnt)->GetINetAttr() ))
+ {
+ pActiveShell->Right( CRSR_SKIP_CHARS, sal_True, 1, sal_False);
+ pActiveShell->SwCrsrShell::SelectTxtAttr( RES_TXTATR_INETFMT, sal_True );
+ }
+
+ }
+ break;
+ case CONTENT_TYPE_REFERENCE:
+ {
+ pActiveShell->GotoRefMark(pCnt->GetName());
+ }
+ break;
+ case CONTENT_TYPE_INDEX:
+ {
+ const OUString sName(pCnt->GetName());
+ if (!pActiveShell->GotoNextTOXBase(&sName))
+ pActiveShell->GotoPrevTOXBase(&sName);
+ }
+ break;
+ case CONTENT_TYPE_POSTIT:
+ pActiveShell->GetView().GetPostItMgr()->AssureStdModeAtShell();
+ if (((SwPostItContent*)pCnt)->IsPostIt())
+ pActiveShell->GotoFld(*((SwPostItContent*)pCnt)->GetPostIt());
+ else
+ pActiveShell->GetView().GetDocShell()->GetWrtShell()->GotoRedline(
+ pActiveShell->GetView().GetDocShell()->GetWrtShell()->FindRedlineOfData(((SwPostItContent*)pCnt)->GetRedline()->GetRedlineData()));
+
+ break;
+ case CONTENT_TYPE_DRAWOBJECT:
+ {
+ SwPosition aPos = *pActiveShell->GetCrsr()->GetPoint();
+ SdrView* pDrawView = pActiveShell->GetDrawView();
+ if (pDrawView)
+ {
+ pDrawView->SdrEndTextEdit();
+ pDrawView->UnmarkAll();
+ SdrModel* _pModel = pActiveShell->getIDocumentDrawModelAccess()->GetDrawModel();
+ SdrPage* pPage = _pModel->GetPage(0);
+ sal_uInt32 nCount = pPage->GetObjCount();
+ for( sal_uInt32 i=0; i< nCount; i++ )
+ {
+ SdrObject* pTemp = pPage->GetObj(i);
+ // #i51726# - all drawing objects can be named now
+ if (pTemp->GetName().equals(pCnt->GetName()))
+ {
+ SdrPageView* pPV = pDrawView->GetSdrPageView();
+ if( pPV )
+ {
+ pDrawView->MarkObj( pTemp, pPV );
+ }
+ }
+ }
+ pActiveShell->GetNavigationMgr().addEntry(aPos);
+ }
+ }
+ break;
+ }
+ if(bSel)
+ {
+ pActiveShell->HideCrsr();
+ pActiveShell->EnterSelFrmMode();
+ }
+ SwView& rView = pActiveShell->GetView();
+ rView.StopShellTimer();
+ rView.GetPostItMgr()->SetActiveSidebarWin(0);
+ rView.GetEditWin().GrabFocus();
+}
+
+// Now even the matching text::Bookmark
+NaviContentBookmark::NaviContentBookmark()
+ :
+ nDocSh(0),
+ nDefDrag( REGION_MODE_NONE )
+{
+}
+
+NaviContentBookmark::NaviContentBookmark( const OUString &rUrl,
+ const OUString& rDesc,
+ sal_uInt16 nDragType,
+ const SwDocShell* pDocSh ) :
+ aUrl( rUrl ),
+ aDescr(rDesc),
+ nDocSh((sal_IntPtr)pDocSh),
+ nDefDrag( nDragType )
+{
+}
+
+void NaviContentBookmark::Copy( TransferDataContainer& rData ) const
+{
+ rtl_TextEncoding eSysCSet = osl_getThreadTextEncoding();
+
+ OString sStrBuf(OUStringToOString(aUrl, eSysCSet) + OString(NAVI_BOOKMARK_DELIM) +
+ OUStringToOString(aDescr, eSysCSet) + OString(NAVI_BOOKMARK_DELIM) +
+ OString::number(nDefDrag) + OString(NAVI_BOOKMARK_DELIM) +
+ OString::number(nDocSh));
+ rData.CopyByteString(SOT_FORMATSTR_ID_SONLK, sStrBuf);
+}
+
+sal_Bool NaviContentBookmark::Paste( TransferableDataHelper& rData )
+{
+ OUString sStr;
+ sal_Bool bRet = rData.GetString( SOT_FORMATSTR_ID_SONLK, sStr );
+ if( bRet )
+ {
+ sal_Int32 nPos = 0;
+ aUrl = sStr.getToken(0, NAVI_BOOKMARK_DELIM, nPos );
+ aDescr = sStr.getToken(0, NAVI_BOOKMARK_DELIM, nPos );
+ nDefDrag= (sal_uInt16)sStr.getToken(0, NAVI_BOOKMARK_DELIM, nPos ).toInt32();
+ nDocSh = sStr.getToken(0, NAVI_BOOKMARK_DELIM, nPos ).toInt32();
+ }
+ return bRet;
+}
+
+class SwContentLBoxString : public SvLBoxString
+{
+public:
+ SwContentLBoxString( SvTreeListEntry* pEntry, sal_uInt16 nFlags,
+ const OUString& rStr ) : SvLBoxString(pEntry,nFlags,rStr) {}
+
+ virtual void Paint(
+ const Point& rPos, SvTreeListBox& rDev, const SvViewDataEntry* pView,
+ const SvTreeListEntry* pEntry);
+};
+
+void SwContentTree::InitEntry(SvTreeListEntry* pEntry,
+ const OUString& rStr ,const Image& rImg1,const Image& rImg2,
+ SvLBoxButtonKind eButtonKind)
+{
+ sal_uInt16 nColToHilite = 1; //0==Bitmap;1=="Column1";2=="Column2"
+ SvTreeListBox::InitEntry( pEntry, rStr, rImg1, rImg2, eButtonKind );
+ SvLBoxString* pCol = (SvLBoxString*)pEntry->GetItem( nColToHilite );
+ SwContentLBoxString* pStr = new SwContentLBoxString( pEntry, 0, pCol->GetText() );
+ pEntry->ReplaceItem( pStr, nColToHilite );
+}
+
+void SwContentLBoxString::Paint(
+ const Point& rPos, SvTreeListBox& rDev, const SvViewDataEntry* pView,
+ const SvTreeListEntry* pEntry)
+{
+ if(lcl_IsContent(pEntry) &&
+ ((SwContent *)pEntry->GetUserData())->IsInvisible())
+ {
+ Font aOldFont( rDev.GetFont());
+ Font aFont(aOldFont);
+ Color aCol( COL_LIGHTGRAY );
+ aFont.SetColor( aCol );
+ rDev.SetFont( aFont );
+ rDev.DrawText( rPos, GetText() );
+ rDev.SetFont( aOldFont );
+ }
+ // IA2 CWS. MT: Removed for now (also in SvLBoxEntry) - only used in Sw/Sd/ScContentLBoxString, they should decide if they need this
+ /*
+ else if (pEntry->IsMarked())
+ {
+ rDev.DrawText( rPos, GetText() );
+ XubString str;
+ str = XubString::CreateFromAscii("*");
+ Point rPosStar(rPos.X()-6,rPos.Y());
+ Font aOldFont( rDev.GetFont());
+ Font aFont(aOldFont);
+ Color aCol( aOldFont.GetColor() );
+ aCol.DecreaseLuminance( 200 );
+ aFont.SetColor( aCol );
+ rDev.SetFont( aFont );
+ rDev.DrawText( rPosStar, str);
+ rDev.SetFont( aOldFont );
+ }
+ */
+ else
+ SvLBoxString::Paint( rPos, rDev, pView, pEntry);
+}
+
+void SwContentTree::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
+ (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ {
+ FindActiveTypeAndRemoveUserData();
+
+ bIsImageListInitialized = false;
+ Display(true);
+ }
+ SvTreeListBox::DataChanged( rDCEvt );
+}
+
+sal_Int32 SwContentTree::GetEntryRealChildrenNum( SvTreeListEntry* pParent ) const
+{
+ // ist es ein Inhaltstyp?
+ if(lcl_IsContentType(pParent))
+ {
+ if(!pParent->HasChildren())
+ {
+ SwContentType* pCntType = (SwContentType*)pParent->GetUserData();
+ return pCntType->GetMemberCount();
+ }
+ }
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/utlui/glbltree.cxx b/sw/source/core/uibase/utlui/glbltree.cxx
new file mode 100644
index 000000000000..9cdcf71b7e4b
--- /dev/null
+++ b/sw/source/core/uibase/utlui/glbltree.cxx
@@ -0,0 +1,1374 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <vcl/msgbox.hxx>
+#include <svl/stritem.hxx>
+#include <sfx2/fcontnr.hxx>
+#include <sfx2/linkmgr.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svl/urihelper.hxx>
+#include <sfx2/docfile.hxx>
+#include <vcl/help.hxx>
+#include <sot/filelist.hxx>
+#include <svl/eitem.hxx>
+#include <svl/urlbmk.hxx>
+#include <vcl/graphicfilter.hxx>
+#include <vcl/settings.hxx>
+
+#include "svtools/treelistentry.hxx"
+#include <sfx2/docinsert.hxx>
+#include <sfx2/filedlghelper.hxx>
+
+#include <sfx2/app.hxx>
+#include <swmodule.hxx>
+#include <wrtsh.hxx>
+#include <view.hxx>
+#include <docsh.hxx>
+#include <content.hxx>
+#include <edglbldc.hxx>
+#include <section.hxx>
+#include <tox.hxx>
+#include <cnttab.hxx>
+#include <navipi.hxx>
+#include <navicont.hxx>
+#include <edtwin.hxx>
+#include <uitool.hxx>
+
+#include <cmdid.h>
+#include <helpid.h>
+#include <navipi.hrc>
+#include <utlui.hrc>
+#include <comcore.hrc>
+#include <globals.hrc>
+#include "swabstdlg.hxx"
+
+using namespace ::com::sun::star::uno;
+
+// Context menu for GlobalTree
+#define CTX_INSERT_ANY_INDEX 10
+#define CTX_INSERT_FILE 11
+#define CTX_INSERT_NEW_FILE 12
+#define CTX_INSERT_TEXT 13
+
+#define CTX_UPDATE_SEL 20
+#define CTX_UPDATE_INDEX 21
+#define CTX_UPDATE_LINK 22
+#define CTX_UPDATE_ALL 23
+
+#define CTX_UPDATE 1
+#define CTX_INSERT 2
+#define CTX_EDIT 3
+#define CTX_DELETE 4
+#define CTX_EDIT_LINK 5
+
+#define GLOBAL_UPDATE_TIMEOUT 2000
+
+// Flags for PopupMenu-enable/disable
+#define ENABLE_INSERT_IDX 0x0001
+#define ENABLE_INSERT_FILE 0x0002
+#define ENABLE_INSERT_TEXT 0x0004
+#define ENABLE_EDIT 0x0008
+#define ENABLE_DELETE 0x0010
+#define ENABLE_UPDATE 0x0020
+#define ENABLE_UPDATE_SEL 0x0040
+#define ENABLE_EDIT_LINK 0x0080
+
+// TabPos: push to left
+#define GLBL_TABPOS_SUB 5
+
+const SfxObjectShell* SwGlobalTree::pShowShell = 0;
+static const char* aHelpForMenu[] =
+{
+ 0,
+ HID_GLBLTREE_UPDATE, //CTX_UPDATE
+ HID_GLBLTREE_INSERT, //CTX_INSERT
+ HID_GLBLTREE_EDIT, //CTX_EDIT
+ HID_GLBLTREE_DEL, //CTX_DELETE
+ HID_GLBLTREE_EDIT_LINK, //CTX_EDIT_LINK
+ 0,
+ 0,
+ 0,
+ 0,
+ HID_GLBLTREE_INS_IDX, //CTX_INSERT_ANY_INDEX
+ HID_GLBLTREE_INS_FILE, //CTX_INSERT_FILE
+ HID_GLBLTREE_INS_NEW_FILE, //CTX_INSERT_NEW_FILE
+ HID_GLBLTREE_INS_TEXT, //CTX_INSERT_TEXT
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ HID_GLBLTREE_UPD_SEL, //CTX_UPDATE_SEL
+ HID_GLBLTREE_UPD_IDX, //CTX_UPDATE_INDEX
+ HID_GLBLTREE_UPD_LINK, //CTX_UPDATE_LINK
+ HID_GLBLTREEUPD_ALL //CTX_UPDATE_ALL
+};
+
+class SwGlobalFrameListener_Impl : public SfxListener
+{
+ bool bValid;
+public:
+ SwGlobalFrameListener_Impl(SfxViewFrame& rFrame) :
+ bValid(true)
+ {
+ StartListening(rFrame);
+ }
+
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+
+ bool IsValid() const {return bValid;}
+};
+
+void SwGlobalFrameListener_Impl::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
+{
+ if( rHint.ISA(SfxSimpleHint) &&
+ (((SfxSimpleHint&) rHint).GetId() == SFX_HINT_DYING))
+ bValid = false;
+}
+
+SwGlobalTree::SwGlobalTree(Window* pParent, const ResId& rResId) :
+
+ SvTreeListBox(pParent, rResId),
+
+ pActiveShell ( NULL ),
+ pEmphasisEntry ( NULL ),
+ pDDSource ( NULL ),
+ pSwGlblDocContents ( NULL ),
+ pDefParentWin ( NULL ),
+ pDocContent ( NULL ),
+ pDocInserter ( NULL ),
+
+ bIsInternalDrag ( false ),
+ bLastEntryEmphasis ( false ),
+ bIsImageListInitialized ( false )
+
+{
+ SetDragDropMode(SV_DRAGDROP_APP_COPY |
+ SV_DRAGDROP_CTRL_MOVE |
+ SV_DRAGDROP_ENABLE_TOP );
+
+ aUpdateTimer.SetTimeout(GLOBAL_UPDATE_TIMEOUT);
+ aUpdateTimer.SetTimeoutHdl(LINK(this, SwGlobalTree, Timeout));
+ aUpdateTimer.Start();
+ for(sal_uInt16 i = 0; i < GLOBAL_CONTEXT_COUNT; i++)
+ {
+ aContextStrings[i] = SW_RESSTR(i+ ST_GLOBAL_CONTEXT_FIRST);
+ }
+ SetHelpId(HID_NAVIGATOR_GLOB_TREELIST);
+ SelectHdl();
+ SetDoubleClickHdl(LINK(this, SwGlobalTree, DoubleClickHdl));
+ EnableContextMenuHandling();
+}
+
+SwGlobalTree::~SwGlobalTree()
+{
+ delete pSwGlblDocContents;
+ delete pDocInserter;
+}
+
+sal_Int8 SwGlobalTree::ExecuteDrop( const ExecuteDropEvent& rEvt )
+{
+ sal_Int8 nRet = DND_ACTION_NONE;
+ SvTreeListEntry* pLast = (SvTreeListEntry*)LastVisible();
+ if(pEmphasisEntry)
+ {
+ ImplShowTargetEmphasis( Prev(pEmphasisEntry), sal_False );
+ pEmphasisEntry = 0;
+ }
+ else if(bLastEntryEmphasis && pLast)
+ {
+ ImplShowTargetEmphasis( pLast, sal_False);
+ }
+
+ SvTreeListEntry* pDropEntry = bLastEntryEmphasis ? 0 : GetEntry(rEvt.maPosPixel);
+ if( bIsInternalDrag )
+ {
+ SvTreeListEntry* pDummy = 0;
+ sal_uLong nInsertionPos = TREELIST_APPEND;
+ NotifyMoving( pDropEntry, pDDSource, pDummy, nInsertionPos );
+ }
+ else
+ {
+ TransferableDataHelper aData( rEvt.maDropEvent.Transferable );
+
+ OUString sFileName;
+ const SwGlblDocContent* pCnt = pDropEntry ?
+ (const SwGlblDocContent*)pDropEntry->GetUserData() :
+ 0;
+ if( aData.HasFormat( FORMAT_FILE_LIST ))
+ {
+ nRet = rEvt.mnAction;
+ SwGlblDocContents* pTempContents = new SwGlblDocContents;
+ int nAbsContPos = pDropEntry ?
+ (int) GetModel()->GetAbsPos(pDropEntry):
+ - 1;
+ sal_uLong nEntryCount = GetEntryCount();
+
+ // Get data
+ FileList aFileList;
+ aData.GetFileList( FORMAT_FILE_LIST, aFileList );
+ for ( sal_uInt16 n = (sal_uInt16)aFileList.Count(); n--; )
+ {
+ sFileName = aFileList.GetFile(n);
+ InsertRegion(pCnt, &sFileName);
+ // The list of contents must be newly fetched after inserting,
+ // to not work on an old content.
+ if(n)
+ {
+ pActiveShell->GetGlobalDocContent(*pTempContents);
+ // If the file was successfully inserted,
+ // then the next content must also be fetched.
+ if(nEntryCount < pTempContents->size())
+ {
+ nEntryCount++;
+ nAbsContPos++;
+ pCnt = (*pTempContents)[ nAbsContPos ];
+ }
+ }
+ }
+ delete pTempContents;
+ }
+ else if( !(sFileName =
+ SwNavigationPI::CreateDropFileName( aData )).isEmpty())
+ {
+ INetURLObject aTemp(sFileName);
+ GraphicDescriptor aDesc(aTemp);
+ if( !aDesc.Detect() ) // accept no graphics
+ {
+ nRet = rEvt.mnAction;
+ InsertRegion(pCnt, &sFileName);
+ }
+ }
+ }
+ bLastEntryEmphasis = false;
+ return nRet;
+
+}
+
+sal_Int8 SwGlobalTree::AcceptDrop( const AcceptDropEvent& rEvt )
+{
+ sal_Int8 nRet = rEvt.mnAction;
+
+ //initiate scrolling
+ GetDropTarget( rEvt.maPosPixel );
+ SvTreeListEntry* pLast = (SvTreeListEntry*)LastVisible();
+ if( rEvt.mbLeaving )
+ {
+ if( pEmphasisEntry )
+ {
+ ImplShowTargetEmphasis( Prev(pEmphasisEntry), sal_False );
+ pEmphasisEntry = 0;
+ }
+ else if(bLastEntryEmphasis && pLast)
+ {
+ ImplShowTargetEmphasis( pLast, sal_False);
+ }
+ bLastEntryEmphasis = false;
+ }
+ else
+ {
+ SvTreeListEntry* pDropEntry = GetEntry( rEvt.maPosPixel );
+ if(bIsInternalDrag)
+ {
+ if( pDDSource != pDropEntry )
+ nRet = rEvt.mnAction;
+ }
+ else if( IsDropFormatSupported( FORMAT_FILE ) ||
+ IsDropFormatSupported( FORMAT_STRING ) ||
+ IsDropFormatSupported( FORMAT_FILE_LIST ) ||
+ IsDropFormatSupported( SOT_FORMATSTR_ID_SOLK ) ||
+ IsDropFormatSupported( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK )||
+ IsDropFormatSupported( SOT_FORMATSTR_ID_FILECONTENT ) ||
+ IsDropFormatSupported( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) ||
+ IsDropFormatSupported( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ) ||
+ IsDropFormatSupported( SOT_FORMATSTR_ID_FILENAME ))
+ nRet = DND_ACTION_LINK;
+
+ if(pEmphasisEntry && pEmphasisEntry != pDropEntry)
+ ImplShowTargetEmphasis( Prev(pEmphasisEntry), sal_False );
+ else if(pLast && bLastEntryEmphasis && pDropEntry)
+ {
+ ImplShowTargetEmphasis( pLast, sal_False);
+ bLastEntryEmphasis = false;
+ }
+
+ if(pDropEntry)
+ ImplShowTargetEmphasis( Prev(pDropEntry), DND_ACTION_NONE != nRet );
+ else if(pLast)
+ {
+ ImplShowTargetEmphasis( pLast, DND_ACTION_NONE != nRet );
+ bLastEntryEmphasis = true;
+ }
+ pEmphasisEntry = pDropEntry;
+ }
+ return nRet;
+}
+
+PopupMenu* SwGlobalTree::CreateContextMenu()
+{
+ PopupMenu* pPop = 0;
+ if(pActiveShell &&
+ !pActiveShell->GetView().GetDocShell()->IsReadOnly())
+ {
+ sal_uInt16 nEnableFlags = GetEnableFlags();
+ pPop = new PopupMenu;
+ PopupMenu* pSubPop1 = new PopupMenu;
+ PopupMenu* pSubPop2 = new PopupMenu;
+
+ for (sal_uInt16 i = CTX_UPDATE_SEL; i <= CTX_UPDATE_ALL; i++)
+ {
+ pSubPop2->InsertItem( i, aContextStrings[ST_UPDATE_SEL - ST_GLOBAL_CONTEXT_FIRST - CTX_UPDATE_SEL+ i] );
+ pSubPop2->SetHelpId(i, aHelpForMenu[i]);
+ }
+ pSubPop2->EnableItem(CTX_UPDATE_SEL, 0 != (nEnableFlags & ENABLE_UPDATE_SEL));
+
+ pSubPop1->InsertItem(CTX_INSERT_ANY_INDEX, aContextStrings[ST_INDEX - ST_GLOBAL_CONTEXT_FIRST]);
+ pSubPop1->SetHelpId(CTX_INSERT_ANY_INDEX, aHelpForMenu[CTX_INSERT_ANY_INDEX]);
+ pSubPop1->InsertItem(CTX_INSERT_FILE, aContextStrings[ST_FILE - ST_GLOBAL_CONTEXT_FIRST]);
+ pSubPop1->SetHelpId(CTX_INSERT_FILE, aHelpForMenu[CTX_INSERT_FILE]);
+ pSubPop1->InsertItem(CTX_INSERT_NEW_FILE, aContextStrings[ST_NEW_FILE - ST_GLOBAL_CONTEXT_FIRST]);
+ pSubPop1->SetHelpId(CTX_INSERT_NEW_FILE, aHelpForMenu[CTX_INSERT_NEW_FILE]);
+ pSubPop1->InsertItem(CTX_INSERT_TEXT, aContextStrings[ST_TEXT - ST_GLOBAL_CONTEXT_FIRST]);
+ pSubPop1->SetHelpId(CTX_INSERT_TEXT, aHelpForMenu[CTX_INSERT_TEXT]);
+
+ pPop->InsertItem(CTX_UPDATE, aContextStrings[ST_UPDATE - ST_GLOBAL_CONTEXT_FIRST]);
+ pPop->SetHelpId(CTX_UPDATE, aHelpForMenu[CTX_UPDATE]);
+ pPop->InsertItem(CTX_EDIT, aContextStrings[ST_EDIT_CONTENT - ST_GLOBAL_CONTEXT_FIRST]);
+ pPop->SetHelpId(CTX_EDIT, aHelpForMenu[CTX_EDIT]);
+ if(nEnableFlags&ENABLE_EDIT_LINK)
+ {
+ pPop->InsertItem(CTX_EDIT_LINK, aContextStrings[ST_EDIT_LINK - ST_GLOBAL_CONTEXT_FIRST]);
+ pPop->SetHelpId(CTX_EDIT_LINK, aHelpForMenu[CTX_EDIT_LINK]);
+ }
+ pPop->InsertItem(CTX_INSERT, aContextStrings[ST_INSERT - ST_GLOBAL_CONTEXT_FIRST]);
+ pPop->SetHelpId(CTX_INSERT, aHelpForMenu[CTX_INSERT]);
+ pPop->InsertSeparator() ;
+ pPop->InsertItem(CTX_DELETE, aContextStrings[ST_DELETE - ST_GLOBAL_CONTEXT_FIRST]);
+ pPop->SetHelpId(CTX_DELETE, aHelpForMenu[CTX_DELETE]);
+
+ //disabling if applicable
+ pSubPop1->EnableItem(CTX_INSERT_ANY_INDEX, 0 != (nEnableFlags & ENABLE_INSERT_IDX ));
+ pSubPop1->EnableItem(CTX_INSERT_TEXT, 0 != (nEnableFlags & ENABLE_INSERT_TEXT));
+ pSubPop1->EnableItem(CTX_INSERT_FILE, 0 != (nEnableFlags & ENABLE_INSERT_FILE));
+ pSubPop1->EnableItem(CTX_INSERT_NEW_FILE, 0 != (nEnableFlags & ENABLE_INSERT_FILE));
+
+ pPop->EnableItem(CTX_UPDATE, 0 != (nEnableFlags & ENABLE_UPDATE));
+ pPop->EnableItem(CTX_INSERT, 0 != (nEnableFlags & ENABLE_INSERT_IDX));
+ pPop->EnableItem(CTX_EDIT, 0 != (nEnableFlags & ENABLE_EDIT));
+ pPop->EnableItem(CTX_DELETE, 0 != (nEnableFlags & ENABLE_DELETE));
+
+ pPop->SetPopupMenu( CTX_INSERT, pSubPop1 );
+ pPop->SetPopupMenu( CTX_UPDATE, pSubPop2 );
+ }
+ return pPop;
+}
+
+void SwGlobalTree::TbxMenuHdl(sal_uInt16 nTbxId, ToolBox* pBox)
+{
+ sal_uInt16 nEnableFlags = GetEnableFlags();
+ if(FN_GLOBAL_OPEN == nTbxId)
+ {
+ PopupMenu *pMenu = new PopupMenu;
+ for (sal_uInt16 i = CTX_INSERT_ANY_INDEX; i <= CTX_INSERT_TEXT; i++)
+ {
+ pMenu->InsertItem( i, aContextStrings[ST_INDEX - ST_GLOBAL_CONTEXT_FIRST - CTX_INSERT_ANY_INDEX + i] );
+ pMenu->SetHelpId(i, aHelpForMenu[i] );
+ }
+ pMenu->EnableItem(CTX_INSERT_ANY_INDEX, 0 != (nEnableFlags & ENABLE_INSERT_IDX ));
+ pMenu->EnableItem(CTX_INSERT_TEXT, 0 != (nEnableFlags & ENABLE_INSERT_TEXT));
+ pMenu->EnableItem(CTX_INSERT_FILE, 0 != (nEnableFlags & ENABLE_INSERT_FILE));
+ pMenu->EnableItem(CTX_INSERT_NEW_FILE, 0 != (nEnableFlags & ENABLE_INSERT_FILE));
+ pMenu->SetSelectHdl(LINK(this, SwGlobalTree, PopupHdl));
+ pMenu->Execute( pBox, pBox->GetItemRect(nTbxId).BottomLeft());
+ delete pMenu;
+ pBox->EndSelection();
+ pBox->Invalidate();
+ }
+ else if(FN_GLOBAL_UPDATE == nTbxId)
+ {
+ PopupMenu *pMenu = new PopupMenu;
+ for (sal_uInt16 i = CTX_UPDATE_SEL; i <= CTX_UPDATE_ALL; i++)
+ {
+ pMenu->InsertItem( i, aContextStrings[ST_UPDATE_SEL - ST_GLOBAL_CONTEXT_FIRST - CTX_UPDATE_SEL+ i] );
+ pMenu->SetHelpId(i, aHelpForMenu[i] );
+ }
+ pMenu->EnableItem(CTX_UPDATE_SEL, 0 != (nEnableFlags & ENABLE_UPDATE_SEL));
+ pMenu->SetSelectHdl(LINK(this, SwGlobalTree, PopupHdl));
+ pMenu->Execute( pBox, pBox->GetItemRect(nTbxId).BottomLeft());
+ delete pMenu;
+ pBox->EndSelection();
+ pBox->Invalidate();
+ }
+}
+
+sal_uInt16 SwGlobalTree::GetEnableFlags() const
+{
+ SvTreeListEntry* pEntry = FirstSelected();
+ sal_uLong nSelCount = GetSelectionCount();
+ sal_uLong nEntryCount = GetEntryCount();
+ SvTreeListEntry* pPrevEntry = pEntry ? Prev(pEntry) : 0;
+
+ sal_uInt16 nRet = 0;
+ if(nSelCount == 1 || !nEntryCount)
+ nRet |= ENABLE_INSERT_IDX|ENABLE_INSERT_FILE;
+ if(nSelCount == 1)
+ {
+ nRet |= ENABLE_EDIT;
+ if( ((SwGlblDocContent*)pEntry->GetUserData())->GetType() != GLBLDOC_UNKNOWN &&
+ (!pPrevEntry || ((SwGlblDocContent*)pPrevEntry->GetUserData())->GetType() != GLBLDOC_UNKNOWN))
+ nRet |= ENABLE_INSERT_TEXT;
+ if( GLBLDOC_SECTION == ((SwGlblDocContent*)pEntry->GetUserData())->GetType() )
+ nRet |= ENABLE_EDIT_LINK;
+ }
+ else if(!nEntryCount)
+ {
+ nRet |= ENABLE_INSERT_TEXT;
+ }
+ if(nEntryCount)
+ nRet |= ENABLE_UPDATE|ENABLE_DELETE;
+ if(nSelCount)
+ nRet |= ENABLE_UPDATE_SEL;
+ return nRet;
+}
+
+void SwGlobalTree::RequestHelp( const HelpEvent& rHEvt )
+{
+ bool bParent = true;
+ Update(sal_True);
+ Display(true);
+ if( rHEvt.GetMode() & HELPMODE_QUICK )
+ {
+ Point aPos( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ));
+ SvTreeListEntry* pEntry = GetEntry( aPos );
+ const SwGlblDocContent* pCont = pEntry ?
+ (const SwGlblDocContent*)pEntry->GetUserData() : 0;
+ if( pCont && GLBLDOC_SECTION == pCont->GetType())
+ {
+ bParent = false;
+ SvLBoxTab* pTab;
+ SvLBoxItem* pItem = GetItem( pEntry, aPos.X(), &pTab );
+ if (pItem && SV_ITEM_ID_LBOXSTRING == pItem->GetType())
+ {
+ const SwSection* pSect = pCont->GetSection();
+ OUString sEntry = pSect->GetLinkFileName().getToken(0, sfx2::cTokenSeparator);
+ if(!pSect->IsConnectFlag())
+ sEntry = aContextStrings[ST_BROKEN_LINK - ST_GLOBAL_CONTEXT_FIRST] + sEntry;
+ Point aEntryPos = GetEntryPosition( pEntry );
+
+ aEntryPos.X() = GetTabPos( pEntry, pTab );
+ Size aSize( pItem->GetSize( this, pEntry ) );
+
+ if((aEntryPos.X() + aSize.Width()) > GetSizePixel().Width())
+ aSize.Width() = GetSizePixel().Width() - aEntryPos.X();
+
+ aEntryPos = OutputToScreenPixel(aEntryPos);
+ Rectangle aItemRect( aEntryPos, aSize );
+ if(Help::IsBalloonHelpEnabled())
+ {
+ aEntryPos.X() += aSize.Width();
+ Help::ShowBalloon( this, aEntryPos, aItemRect, sEntry );
+ }
+ else
+ Help::ShowQuickHelp( this, aItemRect, sEntry,
+ QUICKHELP_LEFT|QUICKHELP_VCENTER );
+ }
+ }
+ }
+
+ if(bParent)
+ SvTreeListBox::RequestHelp(rHEvt);
+}
+
+void SwGlobalTree::SelectHdl()
+{
+
+ sal_uLong nSelCount = GetSelectionCount();
+ SvTreeListEntry* pSel = FirstSelected();
+ sal_uLong nAbsPos = pSel ? GetModel()->GetAbsPos(pSel) : 0;
+ SwNavigationPI* pNavi = GetParentWindow();
+ bool bReadonly = !pActiveShell ||
+ pActiveShell->GetView().GetDocShell()->IsReadOnly();
+ pNavi->aGlobalToolBox.EnableItem(FN_GLOBAL_EDIT, nSelCount == 1 && !bReadonly);
+ pNavi->aGlobalToolBox.EnableItem(FN_GLOBAL_OPEN, nSelCount <= 1 && !bReadonly);
+ pNavi->aGlobalToolBox.EnableItem(FN_GLOBAL_UPDATE, GetEntryCount() > 0 && !bReadonly);
+ pNavi->aGlobalToolBox.EnableItem(FN_ITEM_UP,
+ nSelCount == 1 && nAbsPos && !bReadonly);
+ pNavi->aGlobalToolBox.EnableItem(FN_ITEM_DOWN,
+ nSelCount == 1 && nAbsPos < GetEntryCount() - 1 && !bReadonly);
+
+}
+
+void SwGlobalTree::DeselectHdl()
+{
+ SelectHdl();
+}
+
+DragDropMode SwGlobalTree::NotifyStartDrag( TransferDataContainer& ,
+ SvTreeListEntry* pEntry )
+{
+ bIsInternalDrag = true;
+ pDDSource = pEntry;
+ return SV_DRAGDROP_CTRL_MOVE;
+}
+
+sal_IntPtr SwGlobalTree::GetTabPos( SvTreeListEntry*, SvLBoxTab* pTab)
+{
+ return pTab->GetPos() - GLBL_TABPOS_SUB;
+}
+
+sal_Bool SwGlobalTree::NotifyMoving( SvTreeListEntry* pTarget,
+ SvTreeListEntry* pSource,
+ SvTreeListEntry*&,
+ sal_uLong&
+ )
+{
+ SvTreeList* _pModel = GetModel();
+ sal_uLong nSource = _pModel->GetAbsPos(pSource);
+ sal_uLong nDest = pTarget ? _pModel->GetAbsPos(pTarget) : pSwGlblDocContents->size();
+
+ if( pActiveShell->MoveGlobalDocContent(
+ *pSwGlblDocContents, nSource, nSource + 1, nDest ) &&
+ Update( sal_False ))
+ Display();
+ return sal_False;
+}
+
+sal_Bool SwGlobalTree::NotifyCopying( SvTreeListEntry* /*pTarget*/,
+ SvTreeListEntry* /*pEntry*/,
+ SvTreeListEntry*& /*rpNewParent*/,
+ sal_uLong& /*rNewChildPos*/
+ )
+{
+ return sal_False;
+}
+
+sal_Bool SwGlobalTree::NotifyAcceptDrop( SvTreeListEntry* pEntry)
+{
+ return pEntry != 0;
+}
+
+void SwGlobalTree::StartDrag( sal_Int8 nAction, const Point& rPt )
+{
+ if( 1 == GetSelectionCount() )
+ SvTreeListBox::StartDrag( nAction, rPt );
+}
+
+void SwGlobalTree::DragFinished( sal_Int8 nAction )
+{
+ SvTreeListBox::DragFinished( nAction );
+ bIsInternalDrag = false;
+}
+
+// If a Ctrl+DoubleClick is executed in an empty area,
+// then the base function of the control should be called.
+
+void SwGlobalTree::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ Point aPos( rMEvt.GetPosPixel());
+ SvTreeListEntry* pEntry = GetEntry( aPos, sal_True );
+ if( !pEntry && rMEvt.IsLeft() && rMEvt.IsMod1() && (rMEvt.GetClicks() % 2) == 0)
+ Control::MouseButtonDown( rMEvt );
+ else
+ SvTreeListBox::MouseButtonDown( rMEvt );
+}
+
+void SwGlobalTree::GetFocus()
+{
+ if(Update( sal_False ))
+ Display();
+ SvTreeListBox::GetFocus();
+}
+
+void SwGlobalTree::KeyInput(const KeyEvent& rKEvt)
+{
+ const KeyCode aCode = rKEvt.GetKeyCode();
+ if(aCode.GetCode() == KEY_RETURN)
+ {
+ switch(aCode.GetModifier())
+ {
+ case KEY_MOD2:
+ // Switch boxes
+ GetParentWindow()->ToggleTree();
+ break;
+ }
+ }
+ else
+ SvTreeListBox::KeyInput(rKEvt);
+}
+
+void SwGlobalTree::Clear()
+{
+ pEmphasisEntry = 0;
+ SvTreeListBox::Clear();
+}
+
+void SwGlobalTree::Display(bool bOnlyUpdateUserData)
+{
+ if(!bIsImageListInitialized)
+ {
+ aEntryImages = ImageList(SW_RES(IMG_NAVI_ENTRYBMP));
+ bIsImageListInitialized = true;
+ }
+ size_t nCount = pSwGlblDocContents->size();
+ if(bOnlyUpdateUserData && GetEntryCount() == pSwGlblDocContents->size())
+ {
+ SvTreeListEntry* pEntry = First();
+ for( size_t i = 0; i < nCount; i++)
+ {
+ SwGlblDocContent* pCont = (*pSwGlblDocContents)[i];
+ pEntry->SetUserData(pCont);
+ pEntry = Next(pEntry);
+ }
+ }
+ else
+ {
+ SetUpdateMode( sal_False );
+ SvTreeListEntry* pOldSelEntry = FirstSelected();
+ OUString sEntryName; // Name of the entry
+ sal_uLong nSelPos = TREELIST_ENTRY_NOTFOUND;
+ if(pOldSelEntry)
+ {
+ sEntryName = GetEntryText(pOldSelEntry);
+ nSelPos = GetModel()->GetAbsPos(pOldSelEntry);
+ }
+ Clear();
+ if(!pSwGlblDocContents)
+ Update( sal_False );
+
+ SvTreeListEntry* pSelEntry = 0;
+ for( size_t i = 0; i < nCount; i++)
+ {
+ SwGlblDocContent* pCont = (*pSwGlblDocContents)[i];
+ OUString sEntry;
+ Image aImage;
+ switch( pCont->GetType() )
+ {
+ case GLBLDOC_UNKNOWN:
+ {
+ sEntry = aContextStrings[ST_TEXT - ST_GLOBAL_CONTEXT_FIRST];
+ aImage = aEntryImages.GetImage(SID_SW_START + GLOBAL_CONTENT_TEXT);
+ }
+ break;
+ case GLBLDOC_TOXBASE:
+ {
+ const SwTOXBase* pBase = pCont->GetTOX();
+ sEntry = pBase->GetTitle();
+ aImage = aEntryImages.GetImage(SID_SW_START + CONTENT_TYPE_INDEX);
+ }
+ break;
+ case GLBLDOC_SECTION:
+ {
+ const SwSection* pSect = pCont->GetSection();
+ sEntry = pSect->GetSectionName();
+ aImage = aEntryImages.GetImage(SID_SW_START + CONTENT_TYPE_REGION);
+ }
+ break;
+ }
+ SvTreeListEntry* pEntry = InsertEntry(sEntry, aImage, aImage,
+ 0, sal_False, TREELIST_APPEND, pCont);
+ if(sEntry == sEntryName)
+ {
+ pSelEntry = pEntry;
+ }
+ }
+ if(pSelEntry)
+ {
+ Select(pSelEntry);
+ }
+ else if(nSelPos != TREELIST_ENTRY_NOTFOUND && nSelPos < nCount)
+ {
+ Select(GetEntry(nSelPos));
+ }
+ else if(nCount)
+ Select(First());
+ else
+ SelectHdl();
+ SetUpdateMode( sal_True );
+ }
+}
+
+void SwGlobalTree::InsertRegion( const SwGlblDocContent* pCont, const OUString* pFileName )
+{
+ Sequence< OUString > aFileNames;
+ if ( !pFileName )
+ {
+ pDefParentWin = Application::GetDefDialogParent();
+ Application::SetDefDialogParent( this );
+ delete pDocInserter;
+ pDocInserter = new ::sfx2::DocumentInserter(
+ OUString("swriter"), true );
+ pDocInserter->StartExecuteModal( LINK( this, SwGlobalTree, DialogClosedHdl ) );
+ }
+ else if ( !pFileName->isEmpty() )
+ {
+ aFileNames.realloc(1);
+ INetURLObject aFileName;
+ aFileName.SetSmartURL( *pFileName );
+ aFileNames.getArray()[0] = aFileName.GetMainURL( INetURLObject::NO_DECODE );
+ InsertRegion( pCont, aFileNames );
+ }
+}
+
+void SwGlobalTree::EditContent(const SwGlblDocContent* pCont )
+{
+ sal_uInt16 nSlot = 0;
+ switch( pCont->GetType() )
+ {
+ case GLBLDOC_UNKNOWN:
+ pActiveShell->GetView().GetEditWin().GrabFocus();
+ break;
+ case GLBLDOC_TOXBASE:
+ {
+ const SwTOXBase* pBase = pCont->GetTOX();
+ if(pBase)
+ nSlot = FN_INSERT_MULTI_TOX;
+ }
+ break;
+ case GLBLDOC_SECTION:
+ {
+ OpenDoc(pCont);
+
+ nSlot = 0;
+ pCont = 0;
+ }
+ break;
+ }
+ if(pCont)
+ GotoContent(pCont);
+ if(nSlot)
+ {
+ pActiveShell->GetView().GetViewFrame()->GetDispatcher()->Execute(nSlot);
+ if(Update( sal_False ))
+ Display();
+ }
+}
+
+IMPL_LINK( SwGlobalTree, PopupHdl, Menu* , pMenu)
+{
+ ExcecuteContextMenuAction( pMenu->GetCurItemId());
+ return sal_True;
+}
+
+void SwGlobalTree::ExcecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry )
+{
+ SvTreeListEntry* pEntry = FirstSelected();
+ SwGlblDocContent* pCont = pEntry ? (SwGlblDocContent*)pEntry->GetUserData() : 0;
+ // If a RequestHelp is called during the dialogue,
+ // then the content gets lost. Because of that a copy
+ // is created in which only the DocPos is set correctly.
+ SwGlblDocContent* pContCopy = 0;
+ if(pCont)
+ pContCopy = new SwGlblDocContent(pCont->GetDocPos());
+ SfxDispatcher& rDispatch = *pActiveShell->GetView().GetViewFrame()->GetDispatcher();
+ sal_uInt16 nSlot = 0;
+ bool bDeleteContentCopy = true;
+ switch( nSelectedPopupEntry )
+ {
+ case CTX_UPDATE_SEL:
+ {
+ // Two passes: first update the areas, then the directories.
+ SvTreeListEntry* pSelEntry = FirstSelected();
+ while( pSelEntry )
+ {
+ SwGlblDocContent* pContent = (SwGlblDocContent*)pSelEntry->GetUserData();
+ if(GLBLDOC_SECTION == pContent->GetType() &&
+ pContent->GetSection()->IsConnected())
+ {
+ ((SwSection*)pContent->GetSection())->UpdateNow();
+ }
+
+ pSelEntry = NextSelected(pSelEntry);
+ }
+ pSelEntry = FirstSelected();
+ while( pSelEntry )
+ {
+ SwGlblDocContent* pContent = (SwGlblDocContent*)pSelEntry->GetUserData();
+ if(GLBLDOC_TOXBASE == pContent->GetType())
+ pActiveShell->UpdateTableOf(*pContent->GetTOX());
+ pSelEntry = NextSelected(pSelEntry);
+ }
+
+ }
+ break;
+ case CTX_UPDATE_INDEX:
+ {
+ nSlot = FN_UPDATE_TOX;
+ }
+ break;
+ case CTX_UPDATE_LINK:
+ case CTX_UPDATE_ALL:
+ {
+ pActiveShell->GetLinkManager().UpdateAllLinks(true);
+ if(CTX_UPDATE_ALL == nSelectedPopupEntry)
+ nSlot = FN_UPDATE_TOX;
+ pCont = 0;
+ }
+ break;
+ case CTX_EDIT:
+ {
+ OSL_ENSURE(pCont, "edit without entry ? " );
+ EditContent(pCont);
+ }
+ break;
+ case CTX_EDIT_LINK:
+ {
+ OSL_ENSURE(pCont, "edit without entry ? " );
+ SfxStringItem aName(FN_EDIT_REGION,
+ pCont->GetSection()->GetSectionName());
+ rDispatch.Execute(FN_EDIT_REGION, SFX_CALLMODE_ASYNCHRON, &aName, 0L);
+ }
+ break;
+ case CTX_DELETE:
+ {
+ // If several entries selected, then after each delete the array
+ // must be refilled. So you do not have to remember anything,
+ // deleting begins at the end.
+ SvTreeListEntry* pSelEntry = LastSelected();
+ SwGlblDocContents* pTempContents = 0;
+ pActiveShell->StartAction();
+ while(pSelEntry)
+ {
+ pActiveShell->DeleteGlobalDocContent(
+ pTempContents ? *pTempContents : *pSwGlblDocContents,
+ GetModel()->GetAbsPos(pSelEntry));
+ pSelEntry = PrevSelected(pSelEntry);
+ if(pSelEntry)
+ {
+ delete pTempContents;
+ pTempContents = new SwGlblDocContents;
+ pActiveShell->GetGlobalDocContent(*pTempContents);
+ }
+ }
+ delete pTempContents;
+ pActiveShell->EndAction();
+ pCont = 0;
+ }
+ break;
+ case CTX_INSERT_ANY_INDEX:
+ {
+ if(pContCopy)
+ {
+ SfxItemSet aSet(pActiveShell->GetView().GetPool(),
+ RES_COL, RES_COL,
+ RES_BACKGROUND, RES_BACKGROUND,
+ RES_FRM_SIZE, RES_FRM_SIZE,
+ SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE,
+ RES_LR_SPACE, RES_LR_SPACE,
+ FN_PARAM_TOX_TYPE, FN_PARAM_TOX_TYPE,
+ 0);
+
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "Dialogdiet fail!");
+ AbstractMultiTOXTabDialog* pDlg = pFact->CreateMultiTOXTabDialog(
+ this, aSet,
+ *pActiveShell,
+ 0,
+ USHRT_MAX,
+ sal_True);
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ if(RET_OK == pDlg->Execute())
+ {
+ SwTOXDescription& rDesc = pDlg->GetTOXDescription(
+ pDlg->GetCurrentTOXType());
+ SwTOXMgr aMgr(pActiveShell);
+ SwTOXBase* pToInsert = 0;
+ if(aMgr.UpdateOrInsertTOX(rDesc, &pToInsert, pDlg->GetOutputItemSet()))
+ pActiveShell->InsertGlobalDocContent( *pContCopy, *pToInsert );
+ }
+ pCont = 0;
+ delete pDlg;
+ }
+ }
+ break;
+ case CTX_INSERT_FILE:
+ {
+ bDeleteContentCopy = false;
+ pDocContent = pContCopy;
+ InsertRegion( pContCopy );
+ pCont = NULL;
+ }
+ break;
+ case CTX_INSERT_NEW_FILE:
+ {
+ SfxViewFrame* pGlobFrm = pActiveShell->GetView().GetViewFrame();
+ SwGlobalFrameListener_Impl aFrmListener(*pGlobFrm);
+
+ sal_uLong nEntryPos = pEntry ? GetModel()->GetAbsPos(pEntry) : (sal_uLong)-1;
+ // Creating a new doc
+ SfxStringItem aFactory(SID_NEWDOCDIRECT,
+ SwDocShell::Factory().GetFilterContainer()->GetName());
+
+ const SfxFrameItem* pItem = (SfxFrameItem*)
+ rDispatch.Execute(SID_NEWDOCDIRECT,
+ SFX_CALLMODE_SYNCHRON, &aFactory, 0L);
+
+ // save at
+ SfxFrame* pFrm = pItem ? pItem->GetFrame() : 0;
+ SfxViewFrame* pFrame = pFrm ? pFrm->GetCurrentViewFrame() : 0;
+ if( pFrame )
+ {
+ const SfxBoolItem* pBool = (const SfxBoolItem*)
+ pFrame->GetDispatcher()->Execute(
+ SID_SAVEASDOC, SFX_CALLMODE_SYNCHRON );
+ SfxObjectShell& rObj = *pFrame->GetObjectShell();
+ const SfxMedium* pMedium = rObj.GetMedium();
+ OUString sNewFile(pMedium->GetURLObject().GetMainURL(INetURLObject::DECODE_TO_IURI));
+ // Insert the area with the Doc-Name
+ // Bring the own Doc in the foreground
+ if(aFrmListener.IsValid() && !sNewFile.isEmpty())
+ {
+ pGlobFrm->ToTop();
+ // Due to the update the entries are invalid
+ if(nEntryPos != (sal_uLong)-1)
+ {
+ Update( sal_False );
+ Display();
+ Select(GetModel()->GetEntryAtAbsPos(nEntryPos));
+ pEntry = FirstSelected();
+ pCont = pEntry ? (SwGlblDocContent*)pEntry->GetUserData() : 0;
+ }
+ else
+ {
+ pEntry = 0;
+ pCont = 0;
+ }
+ if(pBool->GetValue())
+ {
+ InsertRegion(pCont, &sNewFile);
+ pFrame->ToTop();
+ }
+ else
+ pFrame->GetDispatcher()->Execute(SID_CLOSEWIN,
+ SFX_CALLMODE_SYNCHRON);
+ }
+ else
+ {
+ pFrame->ToTop();
+ return;
+ }
+ }
+ }
+ break;
+ case CTX_INSERT_TEXT:
+ {
+ if(pCont)
+ pActiveShell->InsertGlobalDocContent(*pCont);
+ else
+ {
+ pActiveShell->SplitNode(); // Empty document
+ pActiveShell->Up( sal_False, 1 );
+ }
+ pActiveShell->GetView().GetEditWin().GrabFocus();
+ }
+ break;
+ case CTX_UPDATE:
+ pCont = 0;
+ break;
+ default:;
+ // here nothing happens
+ }
+ if(pCont)
+ GotoContent(pCont);
+ if(nSlot)
+ rDispatch.Execute(nSlot);
+ if(Update( sal_False ))
+ Display();
+ if ( bDeleteContentCopy )
+ delete pContCopy;
+ else
+ bDeleteContentCopy = true;
+}
+
+IMPL_LINK_NOARG(SwGlobalTree, Timeout)
+{
+ if(!HasFocus() && Update( sal_False ))
+ Display();
+ return 0;
+}
+
+void SwGlobalTree::GotoContent(const SwGlblDocContent* pCont)
+{
+ pActiveShell->EnterStdMode();
+
+ switch( pCont->GetType() )
+ {
+ case GLBLDOC_UNKNOWN:
+ pActiveShell->GotoGlobalDocContent(*pCont);
+ break;
+ case GLBLDOC_TOXBASE:
+ {
+ const OUString sName = pCont->GetTOX()->GetTOXName();
+ if (!pActiveShell->GotoNextTOXBase(&sName))
+ pActiveShell->GotoPrevTOXBase(&sName);
+ }
+ break;
+ case GLBLDOC_SECTION:
+ break;
+ }
+
+}
+
+void SwGlobalTree::ShowTree()
+{
+ aUpdateTimer.Start();
+ SvTreeListBox::Show();
+}
+
+void SwGlobalTree::HideTree()
+{
+ aUpdateTimer.Stop();
+ SvTreeListBox::Hide();
+}
+
+void SwGlobalTree::ExecCommand(sal_uInt16 nCmd)
+{
+ SvTreeListEntry* pEntry = FirstSelected();
+ OSL_ENSURE(pEntry, "It explodes in the next moment");
+ if(FN_GLOBAL_EDIT == nCmd)
+ {
+ const SwGlblDocContent* pCont = (const SwGlblDocContent*)
+ pEntry->GetUserData();
+ EditContent(pCont);
+ }
+ else
+ {
+ if(GetSelectionCount() == 1)
+ {
+ bool bMove = false;
+ sal_uLong nSource = GetModel()->GetAbsPos(pEntry);
+ sal_uLong nDest = nSource;
+ switch(nCmd)
+ {
+ case FN_ITEM_DOWN:
+ {
+ sal_uLong nEntryCount = GetEntryCount();
+ bMove = nEntryCount > nSource + 1;
+ nDest+= 2;
+ }
+ break;
+ case FN_ITEM_UP:
+ {
+ if(nSource)
+ bMove = 0 != nSource;
+ nDest--;
+ }
+ break;
+ }
+ if( bMove && pActiveShell->MoveGlobalDocContent(
+ *pSwGlblDocContents, nSource, nSource + 1, nDest ) &&
+ Update( sal_False ))
+ Display();
+ }
+ }
+}
+
+sal_Bool SwGlobalTree::Update(sal_Bool bHard)
+{
+ SwView* pActView = GetParentWindow()->GetCreateView();
+ sal_Bool bRet = sal_False;
+ if(pActView && pActView->GetWrtShellPtr())
+ {
+ const SwWrtShell* pOldShell = pActiveShell;
+ pActiveShell = pActView->GetWrtShellPtr();
+ if(pActiveShell != pOldShell)
+ {
+ delete pSwGlblDocContents;
+ pSwGlblDocContents = 0;
+ }
+ if(!pSwGlblDocContents)
+ {
+ pSwGlblDocContents = new SwGlblDocContents;
+ bRet = sal_True;
+ pActiveShell->GetGlobalDocContent(*pSwGlblDocContents);
+ }
+ else
+ {
+ sal_Bool bCopy = sal_False;
+ SwGlblDocContents* pTempContents = new SwGlblDocContents;
+ pActiveShell->GetGlobalDocContent(*pTempContents);
+ if(pTempContents->size() != pSwGlblDocContents->size() ||
+ pTempContents->size() != GetEntryCount())
+ {
+ bRet = sal_True;
+ bCopy = sal_True;
+ }
+ else
+ {
+ for(size_t i = 0; i < pTempContents->size() && !bCopy; i++)
+ {
+ SwGlblDocContent* pLeft = (*pTempContents)[i];
+ SwGlblDocContent* pRight = (*pSwGlblDocContents)[i];
+ GlobalDocContentType eType = pLeft->GetType();
+ SvTreeListEntry* pEntry = GetEntry(i);
+ OUString sTemp = GetEntryText(pEntry);
+ if (
+ eType != pRight->GetType() ||
+ (
+ eType == GLBLDOC_SECTION &&
+ pLeft->GetSection()->GetSectionName() != sTemp
+ ) ||
+ (
+ eType == GLBLDOC_TOXBASE &&
+ pLeft->GetTOX()->GetTitle() != sTemp
+ )
+ )
+ {
+ bCopy = bRet = sal_True;
+ }
+ }
+ }
+ if(bCopy || bHard)
+ {
+ pSwGlblDocContents->DeleteAndDestroyAll();
+ pSwGlblDocContents->insert( *pTempContents );
+ pTempContents->clear();
+
+ }
+ delete pTempContents;
+ }
+
+ }
+ else
+ {
+ Clear();
+ if(pSwGlblDocContents)
+ pSwGlblDocContents->DeleteAndDestroyAll();
+ }
+ // FIXME: Implement a test for changes!
+ return bRet;
+}
+
+void SwGlobalTree::OpenDoc(const SwGlblDocContent* pCont)
+{
+ const OUString sFileName(pCont->GetSection()->GetLinkFileName().getToken(0,
+ sfx2::cTokenSeparator));
+ bool bFound = false;
+ const SfxObjectShell* pCurr = SfxObjectShell::GetFirst();
+ while( !bFound && pCurr )
+ {
+ if(pCurr->GetMedium() &&
+ pCurr->GetMedium()->GetURLObject().GetMainURL(INetURLObject::DECODE_TO_IURI) == sFileName)
+ {
+ bFound = true;
+ SwGlobalTree::SetShowShell(pCurr);
+ Application::PostUserEvent( STATIC_LINK(
+ this, SwGlobalTree, ShowFrameHdl ) );
+ pCurr = 0;
+ }
+ else
+ pCurr = SfxObjectShell::GetNext(*pCurr);
+ }
+ if(!bFound)
+ {
+ SfxStringItem aURL(SID_FILE_NAME, sFileName);
+ SfxBoolItem aReadOnly(SID_DOC_READONLY, false);
+ SfxStringItem aTargetFrameName( SID_TARGETNAME, "_blank" );
+ SfxStringItem aReferer(SID_REFERER, pActiveShell->GetView().GetDocShell()->GetTitle());
+ pActiveShell->GetView().GetViewFrame()->GetDispatcher()->
+ Execute(SID_OPENDOC, SFX_CALLMODE_ASYNCHRON,
+ &aURL, &aReadOnly, &aReferer, &aTargetFrameName, 0L);
+ }
+}
+
+IMPL_LINK_NOARG( SwGlobalTree, DoubleClickHdl)
+{
+ SvTreeListEntry* pEntry = GetCurEntry();
+ SwGlblDocContent* pCont = (SwGlblDocContent*)pEntry->GetUserData();
+ if(pCont->GetType() == GLBLDOC_SECTION)
+ OpenDoc(pCont);
+ else
+ {
+ GotoContent(pCont);
+ pActiveShell->GetView().GetEditWin().GrabFocus();
+ }
+ return 0;
+}
+
+IMPL_STATIC_LINK_NOINSTANCE(SwGlobalTree, ShowFrameHdl, SwGlobalTree*, EMPTYARG)
+{
+ if(SwGlobalTree::GetShowShell())
+ SfxViewFrame::GetFirst(SwGlobalTree::GetShowShell())->ToTop();
+ SwGlobalTree::SetShowShell(0);
+ return 0;
+}
+
+void SwGlobalTree::InitEntry(SvTreeListEntry* pEntry,
+ const OUString& rStr ,const Image& rImg1,const Image& rImg2,
+ SvLBoxButtonKind eButtonKind)
+{
+ sal_uInt16 nColToHilite = 1; //0==Bitmap;1=="Column1";2=="Column2"
+ SvTreeListBox::InitEntry( pEntry, rStr, rImg1, rImg2, eButtonKind );
+ SvLBoxString* pCol = (SvLBoxString*)pEntry->GetItem( nColToHilite );
+ SwLBoxString* pStr = new SwLBoxString( pEntry, 0, pCol->GetText() );
+ pEntry->ReplaceItem( pStr, nColToHilite );
+}
+
+void SwLBoxString::Paint(
+ const Point& rPos, SvTreeListBox& rDev, const SvViewDataEntry* pView,
+ const SvTreeListEntry* pEntry)
+{
+ SwGlblDocContent* pCont = (SwGlblDocContent*)pEntry->GetUserData();
+ if(pCont->GetType() == GLBLDOC_SECTION &&
+ !(pCont->GetSection())->IsConnectFlag() )
+ {
+ Font aOldFont( rDev.GetFont());
+ Font aFont(aOldFont);
+ Color aCol( COL_LIGHTRED );
+ aFont.SetColor( aCol );
+ rDev.SetFont( aFont );
+ rDev.DrawText( rPos, GetText() );
+ rDev.SetFont( aOldFont );
+ }
+ else
+ SvLBoxString::Paint( rPos, rDev, pView, pEntry);
+}
+
+void SwGlobalTree::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
+ (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ {
+ aEntryImages = ImageList(SW_RES(IMG_NAVI_ENTRYBMP));
+ Update(sal_True);
+ }
+ SvTreeListBox::DataChanged( rDCEvt );
+}
+
+void SwGlobalTree::InsertRegion( const SwGlblDocContent* _pContent, const Sequence< OUString >& _rFiles )
+{
+ sal_Int32 nFiles = _rFiles.getLength();
+ if ( nFiles )
+ {
+ bool bMove = false;
+ if ( !_pContent )
+ {
+ SvTreeListEntry* pLast = (SvTreeListEntry*)LastVisible();
+ _pContent = (SwGlblDocContent*)pLast->GetUserData();
+ bMove = true;
+ }
+ OUString sFilePassword;
+ sal_uLong nEntryCount = GetEntryCount();
+ const OUString* pFileNames = _rFiles.getConstArray();
+ SwWrtShell& rSh = GetParentWindow()->GetCreateView()->GetWrtShell();
+ rSh.StartAction();
+ // after insertion of the first new content the 'pCont' parameter becomes invalid
+ // find the index of the 'anchor' content to always use a current anchor content
+ size_t nAnchorContent = pSwGlblDocContents->size() - 1;
+ if ( !bMove )
+ {
+ for (size_t nContent = 0; nContent < pSwGlblDocContents->size();
+ ++nContent)
+ {
+ if( *_pContent == *(*pSwGlblDocContents)[ nContent ] )
+ {
+ nAnchorContent = nContent;
+ break;
+ }
+ }
+ }
+ SwGlblDocContents aTempContents;
+ for ( sal_Int32 nFile = 0; nFile < nFiles; ++nFile )
+ {
+ //update the global document content after each inserted document
+ rSh.GetGlobalDocContent(aTempContents);
+ SwGlblDocContent* pAnchorContent = 0;
+ OSL_ENSURE(aTempContents.size() > (nAnchorContent + nFile), "invalid anchor content -> last insertion failed");
+ if ( aTempContents.size() > (nAnchorContent + nFile) )
+ pAnchorContent = aTempContents[nAnchorContent + nFile];
+ else
+ pAnchorContent = aTempContents.back();
+ OUString sFileName(pFileNames[nFile]);
+ INetURLObject aFileUrl;
+ aFileUrl.SetSmartURL( sFileName );
+ OUString sSectionName(aFileUrl.GetLastName(
+ INetURLObject::DECODE_UNAMBIGUOUS).getToken(0, sfx2::cTokenSeparator));
+ sal_uInt16 nSectCount = rSh.GetSectionFmtCount();
+ OUString sTempSectionName(sSectionName);
+ sal_uInt16 nAddNumber = 0;
+ sal_uInt16 nCount = 0;
+ // if applicable: add index if the range name is already in use.
+ while ( nCount < nSectCount )
+ {
+ const SwSectionFmt& rFmt = rSh.GetSectionFmt(nCount);
+ if ((rFmt.GetSection()->GetSectionName() == sTempSectionName)
+ && rFmt.IsInNodesArr())
+ {
+ nCount = 0;
+ nAddNumber++;
+ sTempSectionName = sSectionName + ":" + OUString::number( nAddNumber );
+ }
+ else
+ nCount++;
+ }
+
+ if ( nAddNumber )
+ sSectionName = sTempSectionName;
+
+ SwSectionData aSectionData(CONTENT_SECTION, sSectionName);
+ aSectionData.SetProtectFlag(true);
+ aSectionData.SetHidden(false);
+
+ aSectionData.SetLinkFileName(sFileName);
+ aSectionData.SetType(FILE_LINK_SECTION);
+ aSectionData.SetLinkFilePassword( sFilePassword );
+
+ rSh.InsertGlobalDocContent( *pAnchorContent, aSectionData );
+ }
+ if ( bMove )
+ {
+ Update( sal_False );
+ rSh.MoveGlobalDocContent(
+ *pSwGlblDocContents, nEntryCount, nEntryCount + nFiles, nEntryCount - nFiles );
+ }
+ rSh.EndAction();
+ Update( sal_False );
+ Display();
+ }
+}
+
+IMPL_LINK( SwGlobalTree, DialogClosedHdl, sfx2::FileDialogHelper*, _pFileDlg )
+{
+ Application::SetDefDialogParent( pDefParentWin );
+ if ( ERRCODE_NONE == _pFileDlg->GetError() )
+ {
+ SfxMediumList* pMedList = pDocInserter->CreateMediumList();
+ if ( pMedList )
+ {
+ Sequence< OUString >aFileNames( pMedList->size() );
+ OUString* pFileNames = aFileNames.getArray();
+ sal_Int32 nPos = 0;
+ for ( size_t i = 0, n = pMedList->size(); i < n; ++i )
+ {
+ SfxMedium* pMed = pMedList->at( i );
+ OUString sFileName = pMed->GetURLObject().GetMainURL( INetURLObject::NO_DECODE );
+ sFileName += OUString(sfx2::cTokenSeparator);
+ sFileName += pMed->GetFilter()->GetFilterName();
+ sFileName += OUString(sfx2::cTokenSeparator);
+ pFileNames[nPos++] = sFileName;
+ }
+ delete pMedList;
+ InsertRegion( pDocContent, aFileNames );
+ DELETEZ( pDocContent );
+ }
+ }
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/utlui/gloslst.cxx b/sw/source/core/uibase/utlui/gloslst.cxx
new file mode 100644
index 000000000000..518a1ed02b5d
--- /dev/null
+++ b/sw/source/core/uibase/utlui/gloslst.cxx
@@ -0,0 +1,418 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <tools/urlobj.hxx>
+#include <vcl/dialog.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/button.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/lstbox.hxx>
+#include <svl/fstathelper.hxx>
+#include <unotools/pathoptions.hxx>
+#include <unotools/transliterationwrapper.hxx>
+#include <swtypes.hxx>
+#include <swmodule.hxx>
+#include <shellio.hxx>
+#include <initui.hxx>
+#include <glosdoc.hxx>
+#include <gloslst.hxx>
+#include <swunohelper.hxx>
+
+#include <vector>
+
+#include <utlui.hrc>
+
+#define STRING_DELIM (char)0x0A
+#define GLOS_TIMEOUT 30000 // update every 30 seconds
+#define FIND_MAX_GLOS 20
+
+struct TripleString
+{
+ OUString sGroup;
+ OUString sBlock;
+ OUString sShort;
+};
+
+class SwGlossDecideDlg : public ModalDialog
+{
+ OKButton* m_pOk;
+ ListBox* m_pListLB;
+
+ DECL_LINK(DoubleClickHdl, void*);
+ DECL_LINK(SelectHdl, void*);
+
+ public:
+ SwGlossDecideDlg(Window* pParent);
+ ListBox& GetListBox() {return *m_pListLB;}
+};
+
+SwGlossDecideDlg::SwGlossDecideDlg(Window* pParent)
+ : ModalDialog(pParent, "SelectAutoTextDialog",
+ "modules/swriter/ui/selectautotextdialog.ui")
+{
+ get(m_pOk, "ok");
+ get(m_pListLB, "treeview");
+ m_pListLB->set_height_request(m_pListLB->GetTextHeight() * 10);
+ m_pListLB->SetDoubleClickHdl(LINK(this, SwGlossDecideDlg, DoubleClickHdl));
+ m_pListLB->SetSelectHdl(LINK(this, SwGlossDecideDlg, SelectHdl));
+}
+
+IMPL_LINK_NOARG(SwGlossDecideDlg, DoubleClickHdl)
+{
+ EndDialog(RET_OK);
+ return 0;
+}
+
+IMPL_LINK_NOARG(SwGlossDecideDlg, SelectHdl)
+{
+ m_pOk->Enable(LISTBOX_ENTRY_NOTFOUND != m_pListLB->GetSelectEntryPos());
+ return 0;
+}
+
+SwGlossaryList::SwGlossaryList() :
+ bFilled(false)
+{
+ SvtPathOptions aPathOpt;
+ sPath = aPathOpt.GetAutoTextPath();
+ SetTimeout(GLOS_TIMEOUT);
+}
+
+SwGlossaryList::~SwGlossaryList()
+{
+ ClearGroups();
+}
+
+// If the GroupName is already known, then only rShortName
+// will be filled. Otherwise also rGroupName will be set and
+// on demand asked for the right group.
+
+sal_Bool SwGlossaryList::GetShortName(const OUString& rLongName,
+ OUString& rShortName, OUString& rGroupName )
+{
+ if(!bFilled)
+ Update();
+
+ std::vector<TripleString> aTripleStrings;
+
+ sal_uInt16 nCount = aGroupArr.size();
+ sal_uInt16 nFound = 0;
+ for(sal_uInt16 i = 0; i < nCount; i++ )
+ {
+ AutoTextGroup* pGroup = aGroupArr[i];
+ if(!rGroupName.isEmpty() && rGroupName != pGroup->sName)
+ continue;
+
+ for(sal_uInt16 j = 0; j < pGroup->nCount; j++)
+ {
+ OUString sLong = pGroup->sLongNames.getToken(j, STRING_DELIM);
+ if(rLongName != sLong)
+ continue;
+
+ TripleString pTriple;
+ pTriple.sGroup = pGroup->sName;
+ pTriple.sBlock = sLong;
+ pTriple.sShort = pGroup->sShortNames.getToken(j, STRING_DELIM);
+ aTripleStrings.push_back(pTriple);
+ ++nFound;
+ }
+ }
+
+ sal_Bool bRet = sal_False;
+ nCount = aTripleStrings.size();
+ if(1 == nCount)
+ {
+ const TripleString& pTriple(aTripleStrings.front());
+ rShortName = pTriple.sShort;
+ rGroupName = pTriple.sGroup;
+ bRet = sal_True;
+ }
+ else if(1 < nCount)
+ {
+ SwGlossDecideDlg aDlg(0);
+ OUString sTitle = aDlg.GetText() + " " + aTripleStrings.front().sBlock;
+ aDlg.SetText(sTitle);
+
+ ListBox& rLB = aDlg.GetListBox();
+ for(std::vector<TripleString>::const_iterator i = aTripleStrings.begin(); i != aTripleStrings.end(); ++i)
+ rLB.InsertEntry(i->sGroup.getToken(0, GLOS_DELIM));
+
+ rLB.SelectEntryPos(0);
+ if(RET_OK == aDlg.Execute() &&
+ LISTBOX_ENTRY_NOTFOUND != rLB.GetSelectEntryPos())
+ {
+ const TripleString& pTriple(aTripleStrings[rLB.GetSelectEntryPos()]);
+ rShortName = pTriple.sShort;
+ rGroupName = pTriple.sGroup;
+ bRet = sal_True;
+ }
+ else
+ bRet = sal_False;
+ }
+ return bRet;
+}
+
+sal_uInt16 SwGlossaryList::GetGroupCount()
+{
+ if(!bFilled)
+ Update();
+ return aGroupArr.size();
+}
+
+OUString SwGlossaryList::GetGroupName(sal_uInt16 nPos, bool bNoPath)
+{
+ OSL_ENSURE(aGroupArr.size() > nPos, "group not available");
+ if(nPos < aGroupArr.size())
+ {
+ AutoTextGroup* pGroup = aGroupArr[nPos];
+ OUString sRet = pGroup->sName;
+ if(bNoPath)
+ sRet = sRet.getToken(0, GLOS_DELIM);
+ return sRet;
+ }
+ return OUString();
+}
+
+OUString SwGlossaryList::GetGroupTitle(sal_uInt16 nPos)
+{
+ OSL_ENSURE(aGroupArr.size() > nPos, "group not available");
+ if(nPos < aGroupArr.size())
+ {
+ AutoTextGroup* pGroup = aGroupArr[nPos];
+ return pGroup->sTitle;
+ }
+ return OUString();
+}
+
+sal_uInt16 SwGlossaryList::GetBlockCount(sal_uInt16 nGroup)
+{
+ OSL_ENSURE(aGroupArr.size() > nGroup, "group not available");
+ if(nGroup < aGroupArr.size())
+ {
+ AutoTextGroup* pGroup = aGroupArr[nGroup];
+ return pGroup->nCount;
+ }
+ return 0;
+}
+
+OUString SwGlossaryList::GetBlockLongName(sal_uInt16 nGroup, sal_uInt16 nBlock)
+{
+ OSL_ENSURE(aGroupArr.size() > nGroup, "group not available");
+ if(nGroup < aGroupArr.size())
+ {
+ AutoTextGroup* pGroup = aGroupArr[nGroup];
+ return pGroup->sLongNames.getToken(nBlock, STRING_DELIM);
+ }
+ return OUString();
+}
+
+OUString SwGlossaryList::GetBlockShortName(sal_uInt16 nGroup, sal_uInt16 nBlock)
+{
+ OSL_ENSURE(aGroupArr.size() > nGroup, "group not available");
+ if(nGroup < aGroupArr.size())
+ {
+ AutoTextGroup* pGroup = aGroupArr[nGroup];
+ return pGroup->sShortNames.getToken(nBlock, STRING_DELIM);
+ }
+ return OUString();
+}
+
+void SwGlossaryList::Update()
+{
+ if(!IsActive())
+ Start();
+
+ SvtPathOptions aPathOpt;
+ OUString sTemp( aPathOpt.GetAutoTextPath() );
+ if(sTemp != sPath)
+ {
+ sPath = sTemp;
+ bFilled = false;
+ ClearGroups();
+ }
+ SwGlossaries* pGlossaries = ::GetGlossaries();
+ const std::vector<OUString> & rPathArr = pGlossaries->GetPathArray();
+ const OUString sExt( SwGlossaries::GetExtension() );
+ if(!bFilled)
+ {
+ sal_uInt16 nGroupCount = pGlossaries->GetGroupCnt();
+ for(sal_uInt16 i = 0; i < nGroupCount; i++)
+ {
+ OUString sGrpName = pGlossaries->GetGroupName(i);
+ sal_uInt16 nPath = (sal_uInt16)sGrpName.getToken(1, GLOS_DELIM).toInt32();
+ if( static_cast<size_t>(nPath) < rPathArr.size() )
+ {
+ AutoTextGroup* pGroup = new AutoTextGroup;
+ pGroup->sName = sGrpName;
+
+ FillGroup(pGroup, pGlossaries);
+ OUString sName = rPathArr[nPath] + OUString(INET_PATH_TOKEN) +
+ pGroup->sName.getToken(0, GLOS_DELIM) + sExt;
+ FStatHelper::GetModifiedDateTimeOfFile( sName,
+ &pGroup->aDateModified,
+ &pGroup->aDateModified );
+
+ aGroupArr.insert( aGroupArr.begin(), pGroup );
+ }
+ }
+ bFilled = true;
+ }
+ else
+ {
+ for( size_t nPath = 0; nPath < rPathArr.size(); nPath++ )
+ {
+ std::vector<OUString> aFoundGroupNames;
+ std::vector<OUString> aFiles;
+ std::vector<DateTime*> aDateTimeArr;
+
+ SWUnoHelper::UCB_GetFileListOfFolder( rPathArr[nPath], aFiles,
+ &sExt, &aDateTimeArr );
+ for( size_t nFiles = 0; nFiles < aFiles.size(); ++nFiles )
+ {
+ const OUString aTitle = aFiles[ nFiles ];
+ ::DateTime* pDT = (::DateTime*) aDateTimeArr[ static_cast<sal_uInt16>(nFiles) ];
+
+ OUString sName( aTitle.copy( 0, aTitle.getLength() - sExt.getLength() ));
+
+ aFoundGroupNames.push_back(sName);
+ sName += OUString(GLOS_DELIM) + OUString::number( static_cast<sal_uInt16>(nPath) );
+ AutoTextGroup* pFound = FindGroup( sName );
+ if( !pFound )
+ {
+ pFound = new AutoTextGroup;
+ pFound->sName = sName;
+ FillGroup( pFound, pGlossaries );
+ pFound->aDateModified = *pDT;
+
+ aGroupArr.push_back(pFound);
+ }
+ else if( pFound->aDateModified < *pDT )
+ {
+ FillGroup(pFound, pGlossaries);
+ pFound->aDateModified = *pDT;
+ }
+
+ // don't need any more these pointers
+ delete pDT;
+ }
+
+ sal_uInt16 nArrCount = aGroupArr.size();
+ for( sal_uInt16 i = nArrCount; i; --i)
+ {
+ // maybe remove deleted groups
+ AutoTextGroup* pGroup = aGroupArr[i - 1];
+ sal_uInt16 nGroupPath = (sal_uInt16)pGroup->sName.getToken( 1,
+ GLOS_DELIM).toInt32();
+ // Only the groups will be checked which are registered
+ // for the current subpath.
+ if( nGroupPath == static_cast<sal_uInt16>(nPath) )
+ {
+ bool bFound = false;
+ OUString sCompareGroup = pGroup->sName.getToken(0, GLOS_DELIM);
+ for(std::vector<OUString>::const_iterator j = aFoundGroupNames.begin(); j != aFoundGroupNames.end() && !bFound; ++j)
+ bFound = (sCompareGroup == *j);
+
+ if(!bFound)
+ {
+ aGroupArr.erase(aGroupArr.begin() + i - 1);
+ delete pGroup;
+ }
+ }
+ }
+ }
+ }
+}
+
+void SwGlossaryList::Timeout()
+{
+ // Only update automatically if a SwView has the focus.
+ if(::GetActiveView())
+ Update();
+}
+
+AutoTextGroup* SwGlossaryList::FindGroup(const OUString& rGroupName)
+{
+ for(sal_uInt16 i = 0; i < aGroupArr.size(); i++)
+ {
+ AutoTextGroup* pRet = aGroupArr[i];
+ if(pRet->sName == rGroupName)
+ return pRet;
+ }
+ return 0;
+}
+
+void SwGlossaryList::FillGroup(AutoTextGroup* pGroup, SwGlossaries* pGlossaries)
+{
+ SwTextBlocks* pBlock = pGlossaries->GetGroupDoc(pGroup->sName);
+ pGroup->nCount = pBlock ? pBlock->GetCount() : 0;
+ pGroup->sLongNames = pGroup->sShortNames = OUString();
+ if(pBlock)
+ pGroup->sTitle = pBlock->GetName();
+
+ for(sal_uInt16 j = 0; j < pGroup->nCount; j++)
+ {
+ pGroup->sLongNames += pBlock->GetLongName(j);
+ pGroup->sLongNames += OUString(STRING_DELIM);
+ pGroup->sShortNames += pBlock->GetShortName(j);
+ pGroup->sShortNames += OUString(STRING_DELIM);
+ }
+ pGlossaries->PutGroupDoc(pBlock);
+}
+
+// Give back all (not exceeding FIND_MAX_GLOS) found modules
+// with matching beginning.
+
+bool SwGlossaryList::HasLongName(const OUString& rBegin, std::vector<OUString> *pLongNames)
+{
+ if(!bFilled)
+ Update();
+ sal_uInt16 nFound = 0;
+ sal_uInt16 nCount = aGroupArr.size();
+ sal_Int32 nBeginLen = rBegin.getLength();
+ const ::utl::TransliterationWrapper& rSCmp = GetAppCmpStrIgnore();
+
+ for(sal_uInt16 i = 0; i < nCount; i++ )
+ {
+ AutoTextGroup* pGroup = aGroupArr[i];
+ for(sal_uInt16 j = 0; j < pGroup->nCount; j++)
+ {
+ OUString sBlock = pGroup->sLongNames.getToken(j, STRING_DELIM);
+ if( nBeginLen + 1 < sBlock.getLength() &&
+ rSCmp.isEqual( sBlock.copy(0, nBeginLen), rBegin ))
+ {
+ pLongNames->push_back( sBlock );
+ nFound++;
+ if(FIND_MAX_GLOS == nFound)
+ break;
+ }
+ }
+ }
+ return nFound > 0;
+}
+
+void SwGlossaryList::ClearGroups()
+{
+ sal_uInt16 nCount = aGroupArr.size();
+ for( sal_uInt16 i = 0; i < nCount; ++i )
+ delete aGroupArr[ i ];
+
+ aGroupArr.clear();
+ bFilled = false;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/utlui/initui.cxx b/sw/source/core/uibase/utlui/initui.cxx
new file mode 100644
index 000000000000..1a745a735392
--- /dev/null
+++ b/sw/source/core/uibase/utlui/initui.cxx
@@ -0,0 +1,337 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <unotools/localedatawrapper.hxx>
+#include <viewsh.hxx>
+#include <initui.hxx>
+#include <edtwin.hxx>
+#include <shellres.hxx>
+#include <fldbas.hxx>
+#include <glosdoc.hxx>
+#include <gloslst.hxx>
+
+#include <utlui.hrc>
+#include <initui.hrc>
+#include <comcore.hrc>
+#include <authfld.hxx>
+#include <dbmgr.hxx>
+#include <unotools/syslocale.hxx>
+
+#include <unomid.h>
+
+// Global Pointer
+
+SwGlossaries* pGlossaries = 0;
+
+// Provides all needed paths. Is initialized by UI.
+SwGlossaryList* pGlossaryList = 0;
+
+namespace
+{
+
+enum CachedStringID
+{
+ OldGrfCat,
+ OldTabCat,
+ OldFrmCat,
+ OldDrwCat,
+ CurrGlosGroup,
+ CachedStrings
+};
+
+OUString *StringCache[CachedStrings] = {0};
+
+inline OUString GetCachedString(CachedStringID id)
+{
+ return StringCache[id] ? *StringCache[id] : OUString();
+}
+
+inline void SetCachedString(CachedStringID id, OUString sStr)
+{
+ if (StringCache[id])
+ {
+ *StringCache[id] = sStr;
+ }
+ else
+ {
+ StringCache[id] = new OUString(sStr);
+ }
+}
+
+void ClearStringCache()
+{
+ for (int i=0; i<CachedStrings; ++i)
+ {
+ delete StringCache[i];
+ }
+}
+
+}
+
+OUString GetOldGrfCat()
+{
+ return GetCachedString(OldGrfCat);
+}
+
+void SetOldGrfCat(OUString sStr)
+{
+ SetCachedString(OldGrfCat, sStr);
+}
+
+OUString GetOldTabCat()
+{
+ return GetCachedString(OldTabCat);
+}
+
+void SetOldTabCat(OUString sStr)
+{
+ SetCachedString(OldTabCat, sStr);
+}
+
+OUString GetOldFrmCat()
+{
+ return GetCachedString(OldFrmCat);
+}
+
+void SetOldFrmCat(OUString sStr)
+{
+ SetCachedString(OldFrmCat, sStr);
+}
+
+OUString GetOldDrwCat()
+{
+ return GetCachedString(OldDrwCat);
+}
+
+void SetOldDrwCat(OUString sStr)
+{
+ SetCachedString(OldDrwCat, sStr);
+}
+
+OUString GetCurrGlosGroup()
+{
+ return GetCachedString(CurrGlosGroup);
+}
+
+void SetCurrGlosGroup(OUString sStr)
+{
+ SetCachedString(CurrGlosGroup, sStr);
+}
+
+namespace
+{
+
+std::vector<OUString>* pAuthFieldNameList = 0;
+std::vector<OUString>* pAuthFieldTypeList = 0;
+
+}
+
+// Finish UI
+
+void _FinitUI()
+{
+ SwNewDBMgr::RemoveDbtoolsClient();
+ delete SwViewShell::GetShellRes();
+ SwViewShell::SetShellRes( 0 );
+
+ SwEditWin::_FinitStaticData();
+
+ DELETEZ(pGlossaries);
+
+ delete SwFieldType::pFldNames;
+
+ ClearStringCache();
+ delete pGlossaryList;
+ delete pAuthFieldNameList;
+ delete pAuthFieldTypeList;
+
+}
+
+// Initialise
+
+void _InitUI()
+{
+ // ShellResource gives the CORE the possibility to work with resources.
+ SwViewShell::SetShellRes( new ShellResource );
+ SwEditWin::_InitStaticData();
+}
+
+ShellResource::ShellResource()
+ : Resource( SW_RES(RID_SW_SHELLRES) ),
+ aPostItAuthor( SW_RES( STR_POSTIT_AUTHOR ) ),
+ aPostItPage( SW_RES( STR_POSTIT_PAGE ) ),
+ aPostItLine( SW_RES( STR_POSTIT_LINE ) ),
+
+ aCalc_Syntax( SW_RES( STR_CALC_SYNTAX ) ),
+ aCalc_ZeroDiv( SW_RES( STR_CALC_ZERODIV ) ),
+ aCalc_Brack( SW_RES( STR_CALC_BRACK ) ),
+ aCalc_Pow( SW_RES( STR_CALC_POW ) ),
+ aCalc_VarNFnd( SW_RES( STR_CALC_VARNFND ) ),
+ aCalc_Overflow( SW_RES( STR_CALC_OVERFLOW ) ),
+ aCalc_WrongTime( SW_RES( STR_CALC_WRONGTIME ) ),
+ aCalc_Default( SW_RES( STR_CALC_DEFAULT ) ),
+ aCalc_Error( SW_RES( STR_CALC_ERROR ) ),
+
+ aGetRefFld_Up( SW_RES( STR_GETREFFLD_UP ) ),
+ aGetRefFld_Down( SW_RES( STR_GETREFFLD_DOWN ) ),
+ // #i81002#
+ aGetRefFld_RefItemNotFound( SW_RES( STR_GETREFFLD_REFITEMNOTFOUND ) ),
+ aStrAllPageHeadFoot( SW_RES( STR_ALLPAGE_HEADFOOT ) ),
+ aStrNone( SW_RES( STR_TEMPLATE_NONE )),
+ aFixedStr( SW_RES( STR_FIELD_FIXED )),
+ sDurationFormat( SW_RES( STR_DURATION_FORMAT )),
+
+ aTOXIndexName( SW_RES(STR_TOI)),
+ aTOXUserName( SW_RES(STR_TOU)),
+ aTOXContentName( SW_RES(STR_TOC)),
+ aTOXIllustrationsName( SW_RES(STR_TOX_ILL)),
+ aTOXObjectsName( SW_RES(STR_TOX_OBJ)),
+ aTOXTablesName( SW_RES(STR_TOX_TBL)),
+ aTOXAuthoritiesName( SW_RES(STR_TOX_AUTH)),
+ aLinkCtrlClick(SW_RESSTR(STR_LINK_CTRL_CLICK)),
+ aLinkClick(SW_RESSTR(STR_LINK_CLICK)),
+ pAutoFmtNameLst(0),
+ sPageDescFirstName( SW_RES(STR_PAGEDESC_FIRSTNAME)),
+ sPageDescFollowName( SW_RES(STR_PAGEDESC_FOLLOWNAME)),
+ sPageDescName( SW_RES(STR_PAGEDESC_NAME))
+{
+ const sal_uInt16 nCount = FLD_DOCINFO_END - FLD_DOCINFO_BEGIN;
+
+ KeyCode aCode( KEY_SPACE );
+ KeyCode aModifiedCode( KEY_SPACE, KEY_MOD1 );
+ OUString aModStr( aModifiedCode.GetName() );
+ aModStr = aModStr.replaceFirst(aCode.GetName(), OUString());
+ aModStr = aModStr.replaceAll("+", OUString());
+ aLinkCtrlClick = aLinkCtrlClick.replaceAll("%s", aModStr);
+
+ for(sal_uInt16 i = 0; i < nCount; ++i)
+ aDocInfoLst.push_back(OUString(SW_RESSTR(FLD_DOCINFO_BEGIN + i)));
+
+ FreeResource();
+}
+
+ShellResource::~ShellResource()
+{
+ delete pAutoFmtNameLst;
+}
+
+OUString ShellResource::GetPageDescName(sal_uInt16 nNo, PageNameMode eMode)
+{
+ OUString sRet;
+
+ switch (eMode)
+ {
+ case NORMAL_PAGE:
+ sRet = sPageDescName;
+ break;
+ case FIRST_PAGE:
+ sRet = sPageDescFirstName;
+ break;
+ case FOLLOW_PAGE:
+ sRet = sPageDescFollowName;
+ break;
+ }
+
+ return sRet.replaceFirst( "$(ARG1)", OUString::number( nNo ));
+}
+
+SwGlossaries* GetGlossaries()
+{
+ if (!pGlossaries)
+ pGlossaries = new SwGlossaries;
+ return (pGlossaries);
+}
+
+bool HasGlossaryList()
+{
+ return pGlossaryList != 0;
+}
+
+SwGlossaryList* GetGlossaryList()
+{
+ if(!pGlossaryList)
+ pGlossaryList = new SwGlossaryList();
+
+ return pGlossaryList;
+}
+
+struct ImpAutoFmtNameListLoader : public Resource
+{
+ ImpAutoFmtNameListLoader( std::vector<OUString>& rLst );
+};
+
+void ShellResource::_GetAutoFmtNameLst() const
+{
+ assert(!pAutoFmtNameLst);
+ pAutoFmtNameLst = new std::vector<OUString>;
+ pAutoFmtNameLst->reserve(STR_AUTOFMTREDL_END);
+ ImpAutoFmtNameListLoader aTmp(*pAutoFmtNameLst);
+}
+
+ImpAutoFmtNameListLoader::ImpAutoFmtNameListLoader( std::vector<OUString>& rLst )
+ : Resource( ResId(RID_SHELLRES_AUTOFMTSTRS, *pSwResMgr) )
+{
+ for( sal_uInt16 n = 0; n < STR_AUTOFMTREDL_END; ++n )
+ {
+ OUString p(ResId(n + 1, *pSwResMgr));
+ if(STR_AUTOFMTREDL_TYPO == n)
+ {
+#ifdef WNT
+ // For Windows, a special treatment is necessary because MS has
+ // forgotten some characters in the dialog font here.
+ p = p.replaceFirst("%1", ",,");
+ p = p.replaceFirst("%2", "''");
+#else
+ const SvtSysLocale aSysLocale;
+ const LocaleDataWrapper& rLclD = aSysLocale.GetLocaleData();
+ // With real operating systems it also works without special handling.
+ p = p.replaceFirst("%1", rLclD.getDoubleQuotationMarkStart());
+ p = p.replaceFirst("%2", rLclD.getDoubleQuotationMarkEnd());
+#endif
+ }
+ rLst.insert(rLst.begin() + n, p);
+ }
+ FreeResource();
+}
+
+OUString SwAuthorityFieldType::GetAuthFieldName(ToxAuthorityField eType)
+{
+ if(!pAuthFieldNameList)
+ {
+ pAuthFieldNameList = new std::vector<OUString>;
+ pAuthFieldNameList->reserve(AUTH_FIELD_END);
+ for(sal_uInt16 i = 0; i < AUTH_FIELD_END; ++i)
+ pAuthFieldNameList->push_back(SW_RES(STR_AUTH_FIELD_START + i));
+ }
+ return (*pAuthFieldNameList)[static_cast< sal_uInt16 >(eType)];
+}
+
+OUString SwAuthorityFieldType::GetAuthTypeName(ToxAuthorityType eType)
+{
+ if(!pAuthFieldTypeList)
+ {
+ pAuthFieldTypeList = new std::vector<OUString>;
+ pAuthFieldTypeList->reserve(AUTH_TYPE_END);
+ for(sal_uInt16 i = 0; i < AUTH_TYPE_END; ++i)
+ pAuthFieldTypeList->push_back(SW_RES(STR_AUTH_TYPE_START + i));
+ }
+ return (*pAuthFieldTypeList)[static_cast< sal_uInt16 >(eType)];
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/utlui/initui.hrc b/sw/source/core/uibase/utlui/initui.hrc
new file mode 100644
index 000000000000..6df29075cf65
--- /dev/null
+++ b/sw/source/core/uibase/utlui/initui.hrc
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef _INITUI_HRC
+#define _INITUI_HRC
+
+// Local Resources for the shells:
+#define STR_POSTIT_PAGE 1
+#define STR_POSTIT_AUTHOR 2
+#define STR_CALC_SYNTAX 3
+#define STR_CALC_ZERODIV 4
+#define STR_CALC_BRACK 5
+#define STR_CALC_POW 6
+#define STR_CALC_VARNFND 7
+#define STR_CALC_OVERFLOW 8
+#define STR_CALC_WRONGTIME 9
+#define STR_CALC_DEFAULT 10
+#define STR_CALC_ERROR 11
+#define STR_GETREFFLD_UP 12
+#define STR_GETREFFLD_DOWN 13
+#define STR_ALLPAGE_HEADFOOT 14
+#define STR_TEMPLATE_NONE 15
+#define STR_POSTIT_LINE 16
+#define STR_FIELD_FIXED 17
+#define STR_TOI 18
+#define STR_TOU 19
+#define STR_TOC 20
+#define STR_TOX_ILL 21
+#define STR_TOX_OBJ 22
+#define STR_TOX_TBL 23
+#define STR_TOX_AUTH 24
+#define STR_PAGEDESC_NAME 25
+#define STR_PAGEDESC_FIRSTNAME 26
+#define STR_PAGEDESC_FOLLOWNAME 27
+#define STR_LINK_CTRL_CLICK 28
+#define STR_LINK_CLICK 29
+#define STR_GETREFFLD_REFITEMNOTFOUND 30
+#define STR_DURATION_FORMAT 31
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/utlui/initui.src b/sw/source/core/uibase/utlui/initui.src
new file mode 100644
index 000000000000..81e47ff75eaa
--- /dev/null
+++ b/sw/source/core/uibase/utlui/initui.src
@@ -0,0 +1,412 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "globals.hrc"
+#include "utlui.hrc"
+#include "helpid.h"
+#include "initui.hrc"
+
+// Error calculator
+
+Resource RID_SW_SHELLRES
+{
+ String STR_POSTIT_PAGE
+ {
+ Text [ en-US ] = "Page" ;
+ };
+ String STR_POSTIT_LINE
+ {
+ Text [ en-US ] = "Line" ;
+ };
+ String STR_POSTIT_AUTHOR
+ {
+ Text [ en-US ] = "Author" ;
+ };
+ String STR_CALC_SYNTAX
+ {
+ Text [ en-US ] = "** Syntax Error **" ;
+ };
+ String STR_CALC_ZERODIV
+ {
+ Text [ en-US ] = "** Division by zero **" ;
+ };
+ String STR_CALC_BRACK
+ {
+ Text [ en-US ] = "** Wrong use of brackets **" ;
+ };
+ String STR_CALC_POW
+ {
+ Text [ en-US ] = "** Square function overflow **" ;
+ };
+ String STR_CALC_VARNFND
+ {
+ Text [ en-US ] = "** Variable not found **" ;
+ };
+ String STR_CALC_OVERFLOW
+ {
+ Text [ en-US ] = "** Overflow **" ;
+ };
+ String STR_CALC_WRONGTIME
+ {
+ Text [ en-US ] = "** Wrong time format **" ;
+ };
+ String STR_CALC_DEFAULT
+ {
+ Text [ en-US ] = "** Error **" ;
+ };
+ String STR_CALC_ERROR
+ {
+ Text [ en-US ] = "** Expression is faulty **" ;
+ };
+ String STR_GETREFFLD_UP
+ {
+ Text [ en-US ] = "above" ;
+ };
+ String STR_GETREFFLD_DOWN
+ {
+ Text [ en-US ] = "below" ;
+ };
+ String STR_GETREFFLD_REFITEMNOTFOUND
+ {
+ Text [ en-US ] = "Error: Reference source not found" ;
+ };
+ String STR_ALLPAGE_HEADFOOT
+ {
+ Text [ en-US ] = "All" ;
+ };
+ String STR_TEMPLATE_NONE
+ {
+ Text [ en-US ] = "None" ;
+ };
+ String STR_FIELD_FIXED
+ {
+ Text [ en-US ] = "(fixed)" ;
+ };
+ String STR_DURATION_FORMAT
+ {
+ Text [en-US] = " Y: %1 M: %2 D: %3 H: %4 M: %5 S: %6";
+ };
+ String STR_TOI
+ {
+ Text [ en-US ] = "Alphabetical Index" ;
+ };
+
+ String STR_TOU
+ {
+ Text [ en-US ] = "User-Defined" ;
+ };
+
+ String STR_TOC
+ {
+ Text [ en-US ] = "Table of Contents" ;
+ };
+
+ String STR_TOX_AUTH
+ {
+ Text [ en-US ] = "Bibliography";
+ };
+ String STR_TOX_TBL
+ {
+ Text [ en-US ] = "Index of Tables";
+ };
+ String STR_TOX_OBJ
+ {
+ Text [ en-US ] = "Table of Objects";
+ };
+ String STR_TOX_ILL
+ {
+ Text [ en-US ] = "Illustration Index";
+ };
+ String STR_LINK_CTRL_CLICK
+ {
+ Text [ en-US ] = "%s-Click to follow link";
+ };
+ String STR_LINK_CLICK
+ {
+ Text [ en-US ] = "Click to follow link";
+ };
+
+ // SubType DocInfo
+
+ String FLD_DOCINFO_TITEL
+ {
+ Text [ en-US ] = "Title" ;
+ };
+ String FLD_DOCINFO_THEMA
+ {
+ Text [ en-US ] = "Subject" ;
+ };
+ String FLD_DOCINFO_KEYS
+ {
+ Text [ en-US ] = "Keywords" ;
+ };
+ String FLD_DOCINFO_COMMENT
+ {
+ Text [ en-US ] = "Comments" ;
+ };
+ String FLD_DOCINFO_CREATE
+ {
+ Text [ en-US ] = "Created" ;
+ };
+ String FLD_DOCINFO_CHANGE
+ {
+ Text [ en-US ] = "Modified" ;
+ };
+ String FLD_DOCINFO_PRINT
+ {
+ Text [ en-US ] = "Last printed" ;
+ };
+ String FLD_DOCINFO_DOCNO
+ {
+ Text [ en-US ] = "Revision number" ;
+ };
+ String FLD_DOCINFO_EDIT
+ {
+ Text [ en-US ] = "Total editing time" ;
+ };
+
+ String STR_PAGEDESC_NAME
+ {
+ Text [ en-US ] = "Convert $(ARG1)";
+ };
+ String STR_PAGEDESC_FIRSTNAME
+ {
+ Text [ en-US ] = "First convert $(ARG1)";
+ };
+ String STR_PAGEDESC_FOLLOWNAME
+ {
+ Text [ en-US ] = "Next convert $(ARG1)";
+ };
+};
+
+String STR_AUTH_TYPE_ARTICLE
+{
+ Text [ en-US ] = "Article";
+};
+String STR_AUTH_TYPE_BOOK
+{
+ Text [ en-US ] = "Book";
+};
+String STR_AUTH_TYPE_BOOKLET
+{
+ Text [ en-US ] = "Brochures";
+};
+String STR_AUTH_TYPE_CONFERENCE
+{
+ Text [ en-US ] = "Conference proceedings";
+};
+String STR_AUTH_TYPE_INBOOK
+{
+ Text [ en-US ] = "Book excerpt";
+};
+String STR_AUTH_TYPE_INCOLLECTION
+{
+ Text [ en-US ] = "Book excerpt with title";
+};
+String STR_AUTH_TYPE_INPROCEEDINGS
+{
+ Text [ en-US ] = "Conference proceedings";
+};
+String STR_AUTH_TYPE_JOURNAL
+{
+ Text [ en-US ] = "Journal";
+};
+String STR_AUTH_TYPE_MANUAL
+{
+ Text [ en-US ] = "Techn. documentation";
+};
+String STR_AUTH_TYPE_MASTERSTHESIS
+{
+ Text [ en-US ] = "Thesis";
+};
+String STR_AUTH_TYPE_MISC
+{
+ Text [ en-US ] = "Miscellaneous";
+};
+String STR_AUTH_TYPE_PHDTHESIS
+{
+ Text [ en-US ] = "Dissertation";
+};
+String STR_AUTH_TYPE_PROCEEDINGS
+{
+ Text [ en-US ] = "Conference proceedings";
+};
+String STR_AUTH_TYPE_TECHREPORT
+{
+ Text [ en-US ] = "Research report";
+};
+String STR_AUTH_TYPE_UNPUBLISHED
+{
+ Text [ en-US ] = "Unpublished";
+};
+String STR_AUTH_TYPE_EMAIL
+{
+ Text [ en-US ] = "e-mail";
+};
+String STR_AUTH_TYPE_WWW
+{
+ Text [ en-US ] = "WWW document";
+};
+String STR_AUTH_TYPE_CUSTOM1
+{
+ Text [ en-US ] = "User-defined1";
+};
+String STR_AUTH_TYPE_CUSTOM2
+{
+ Text [ en-US ] = "User-defined2";
+};
+String STR_AUTH_TYPE_CUSTOM3
+{
+ Text [ en-US ] = "User-defined3";
+};
+String STR_AUTH_TYPE_CUSTOM4
+{
+ Text [ en-US ] = "User-defined4";
+};
+String STR_AUTH_TYPE_CUSTOM5
+{
+ Text [ en-US ] = "User-defined5";
+};
+
+String STR_AUTH_FIELD_IDENTIFIER
+{
+ Text [ en-US ] = "Short name";
+};
+String STR_AUTH_FIELD_AUTHORITY_TYPE
+{
+ Text [ en-US ] = "Type";
+};
+String STR_AUTH_FIELD_ADDRESS
+{
+ Text [ en-US ] = "Address";
+};
+String STR_AUTH_FIELD_ANNOTE
+{
+ Text [ en-US ] = "Annotation";
+};
+String STR_AUTH_FIELD_AUTHOR
+{
+ Text [ en-US ] = "Author(s)";
+};
+String STR_AUTH_FIELD_BOOKTITLE
+{
+ Text [ en-US ] = "Book title";
+};
+String STR_AUTH_FIELD_CHAPTER
+{
+ Text [ en-US ] = "Chapter";
+};
+String STR_AUTH_FIELD_EDITION
+{
+ Text [ en-US ] = "Edition";
+};
+String STR_AUTH_FIELD_EDITOR
+{
+ Text [ en-US ] = "Editor";
+};
+String STR_AUTH_FIELD_HOWPUBLISHED
+{
+ Text [ en-US ] = "Publication type";
+};
+String STR_AUTH_FIELD_INSTITUTION
+{
+ Text [ en-US ] = "Institution";
+};
+String STR_AUTH_FIELD_JOURNAL
+{
+ Text [ en-US ] = "Journal";
+};
+String STR_AUTH_FIELD_MONTH
+{
+ Text [ en-US ] = "Month";
+};
+String STR_AUTH_FIELD_NOTE
+{
+ Text [ en-US ] = "Note";
+};
+String STR_AUTH_FIELD_NUMBER
+{
+ Text [ en-US ] = "Number";
+};
+String STR_AUTH_FIELD_ORGANIZATIONS
+{
+ Text [ en-US ] = "Organization";
+};
+String STR_AUTH_FIELD_PAGES
+{
+ Text [ en-US ] = "Page(s)";
+};
+String STR_AUTH_FIELD_PUBLISHER
+{
+ Text [ en-US ] = "Publisher";
+};
+String STR_AUTH_FIELD_SCHOOL
+{
+ Text [ en-US ] = "University";
+};
+String STR_AUTH_FIELD_SERIES
+{
+ Text [ en-US ] = "Series";
+};
+String STR_AUTH_FIELD_TITLE
+{
+ Text [ en-US ] = "Title";
+};
+String STR_AUTH_FIELD_TYPE
+{
+ Text [ en-US ] = "Type of report";
+};
+String STR_AUTH_FIELD_VOLUME
+{
+ Text [ en-US ] = "Volume";
+};
+String STR_AUTH_FIELD_YEAR
+{
+ Text [ en-US ] = "Year";
+};
+String STR_AUTH_FIELD_URL
+{
+ Text [ en-US ] = "URL";
+};
+String STR_AUTH_FIELD_CUSTOM1
+{
+ Text [ en-US ] = "User-defined1";
+};
+String STR_AUTH_FIELD_CUSTOM2
+{
+ Text [ en-US ] = "User-defined2";
+};
+String STR_AUTH_FIELD_CUSTOM3
+{
+ Text [ en-US ] = "User-defined3";
+};
+String STR_AUTH_FIELD_CUSTOM4
+{
+ Text [ en-US ] = "User-defined4";
+};
+String STR_AUTH_FIELD_CUSTOM5
+{
+ Text [ en-US ] = "User-defined5";
+};
+String STR_AUTH_FIELD_ISBN
+{
+ Text [ en-US ] = "ISBN";
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/utlui/navicfg.cxx b/sw/source/core/uibase/utlui/navicfg.cxx
new file mode 100644
index 000000000000..975a08876fb9
--- /dev/null
+++ b/sw/source/core/uibase/utlui/navicfg.cxx
@@ -0,0 +1,119 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <swtypes.hxx>
+#include <navicfg.hxx>
+#include <swcont.hxx>
+#include <osl/diagnose.h>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <unomid.h>
+
+using namespace ::utl;
+using namespace ::rtl;
+using namespace ::com::sun::star::uno;
+
+Sequence<OUString> SwNavigationConfig::GetPropertyNames()
+{
+ static const char* aPropNames[] =
+ {
+ "RootType", //0
+ "SelectedPosition", //1
+ "OutlineLevel", //2
+ "InsertMode", //3
+ "ActiveBlock", //4
+ "ShowListBox", //5
+ "GlobalDocMode" //6
+ };
+ const int nCount = 7;
+ Sequence<OUString> aNames(nCount);
+ OUString* pNames = aNames.getArray();
+ for(int i = 0; i < nCount; i++)
+ {
+ pNames[i] = OUString::createFromAscii(aPropNames[i]);
+ }
+ return aNames;
+}
+
+SwNavigationConfig::SwNavigationConfig() :
+ utl::ConfigItem("Office.Writer/Navigator"),
+ nRootType(0xffff),
+ nSelectedPos(0),
+ nOutlineLevel(MAXLEVEL),
+ nRegionMode(REGION_MODE_NONE),
+ nActiveBlock(0),
+ bIsSmall(sal_False),
+ bIsGlobalActive(sal_True)
+{
+ Sequence<OUString> aNames = GetPropertyNames();
+ Sequence<Any> aValues = GetProperties(aNames);
+ const Any* pValues = aValues.getConstArray();
+ OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
+ if(aValues.getLength() == aNames.getLength())
+ {
+ for(int nProp = 0; nProp < aNames.getLength(); nProp++)
+ {
+ if(pValues[nProp].hasValue())
+ {
+ switch(nProp)
+ {
+ case 0: pValues[nProp] >>= nRootType; break;
+ case 1: pValues[nProp] >>= nSelectedPos; break;
+ case 2: pValues[nProp] >>= nOutlineLevel; break;
+ case 3: pValues[nProp] >>= nRegionMode; break;
+ case 4: pValues[nProp] >>= nActiveBlock; break;
+ case 5: bIsSmall = *(sal_Bool*)pValues[nProp].getValue(); break;
+ case 6: bIsGlobalActive = *(sal_Bool*)pValues[nProp].getValue(); break;
+ }
+ }
+ }
+ }
+}
+
+SwNavigationConfig::~SwNavigationConfig()
+{
+}
+
+void SwNavigationConfig::Commit()
+{
+ Sequence<OUString> aNames = GetPropertyNames();
+ Sequence<Any> aValues(aNames.getLength());
+ Any* pValues = aValues.getArray();
+ const Type& rType = ::getBooleanCppuType();
+
+ for(int nProp = 0; nProp < aNames.getLength(); nProp++)
+ {
+ switch(nProp)
+ {
+ case 0: pValues[nProp] <<= nRootType; break;
+ case 1: pValues[nProp] <<= nSelectedPos; break;
+ case 2: pValues[nProp] <<= nOutlineLevel; break;
+ case 3: pValues[nProp] <<= nRegionMode; break;
+ case 4: pValues[nProp] <<= nActiveBlock; break;
+ case 5: pValues[nProp].setValue(&bIsSmall, rType); break;
+ case 6: pValues[nProp].setValue(&bIsGlobalActive, rType); break;
+ }
+ }
+ PutProperties(aNames, aValues);
+}
+
+void SwNavigationConfig::Notify( const ::com::sun::star::uno::Sequence< OUString >& ) {}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/utlui/navipi.cxx b/sw/source/core/uibase/utlui/navipi.cxx
new file mode 100644
index 000000000000..9dbb33e41893
--- /dev/null
+++ b/sw/source/core/uibase/utlui/navipi.cxx
@@ -0,0 +1,1384 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <string>
+#include <comphelper/string.hxx>
+#include <svl/urlbmk.hxx>
+#include <svl/stritem.hxx>
+#include <vcl/graphicfilter.hxx>
+#include <svl/urihelper.hxx>
+#include <sot/formats.hxx>
+#include <sot/filelist.hxx>
+#include <sfx2/event.hxx>
+#include <sfx2/imgmgr.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/dockwin.hxx>
+#include <vcl/toolbox.hxx>
+#include <vcl/settings.hxx>
+#include <swtypes.hxx>
+#include <swmodule.hxx>
+#include <view.hxx>
+#include <navicfg.hxx>
+#include <wrtsh.hxx>
+#include <docsh.hxx>
+#include <actctrl.hxx>
+#include <IMark.hxx>
+#include <navipi.hxx>
+#include <content.hxx>
+#include <workctrl.hxx>
+#include <section.hxx>
+#include <edtwin.hxx>
+#include <sfx2/app.hxx>
+#include <cmdid.h>
+#include <helpid.h>
+#include <ribbar.hrc>
+#include <navipi.hrc>
+#include <utlui.hrc>
+
+#include "access.hrc"
+
+#include <unomid.h>
+
+#define PAGE_CHANGE_TIMEOUT 1000
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::frame;
+
+SFX_IMPL_CHILDWINDOW_CONTEXT( SwNavigationChild, SID_NAVIGATOR, SwView )
+
+// Filter the control characters out of the Outline-Entry
+
+OUString SwNavigationPI::CleanEntry(const OUString& rEntry)
+{
+ if (rEntry.isEmpty())
+ return rEntry;
+
+ OUStringBuffer aEntry(rEntry);
+ for (sal_Int32 i = 0; i < rEntry.getLength(); ++i)
+ if(aEntry[i] == 10 || aEntry[i] == 9)
+ aEntry[i] = 0x20;
+
+ return aEntry.makeStringAndClear();
+}
+
+// Execution of the drag operation with and without the children.
+
+void SwNavigationPI::MoveOutline(sal_uInt16 nSource, sal_uInt16 nTarget,
+ bool bWithChildren)
+{
+ SwView *pView = GetCreateView();
+ SwWrtShell &rSh = pView->GetWrtShell();
+ if(nTarget < nSource || nTarget == USHRT_MAX)
+ nTarget ++;
+ if ( rSh.IsOutlineMovable( nSource ))
+ {
+
+ short nMove = nTarget-nSource; //( nDir<0 ) ? 1 : 0 ;
+ rSh.GotoOutline(nSource);
+ if (bWithChildren)
+ rSh.MakeOutlineSel(nSource, nSource, sal_True);
+ // While moving, the selected children does not counting.
+ sal_uInt16 nLastOutlinePos = rSh.GetOutlinePos(MAXLEVEL);
+ if(bWithChildren && nMove > 1 &&
+ nLastOutlinePos < nTarget)
+ {
+ if(!rSh.IsCrsrPtAtEnd())
+ rSh.SwapPam();
+ nMove -= nLastOutlinePos - nSource;
+ }
+ if(!bWithChildren || nMove < 1 || nLastOutlinePos < nTarget )
+ rSh.MoveOutlinePara( nMove );
+ rSh.ClearMark();
+ rSh.GotoOutline( nSource + nMove);
+ FillBox();
+ }
+
+}
+
+// After goto cancel the status frame selection
+
+static void lcl_UnSelectFrm(SwWrtShell *pSh)
+{
+ if (pSh->IsFrmSelected())
+ {
+ pSh->UnSelectFrm();
+ pSh->LeaveSelFrmMode();
+ }
+}
+
+// Select the document view
+
+IMPL_LINK( SwNavigationPI, DocListBoxSelectHdl, ListBox *, pBox )
+{
+ int nEntryIdx = pBox->GetSelectEntryPos();
+ SwView *pView ;
+ pView = SwModule::GetFirstView();
+ while (nEntryIdx-- && pView)
+ {
+ pView = SwModule::GetNextView(pView);
+ }
+ if(!pView)
+ {
+ nEntryIdx == 0 ?
+ aContentTree.ShowHiddenShell():
+ aContentTree.ShowActualView();
+
+ }
+ else
+ {
+ aContentTree.SetConstantShell(pView->GetWrtShellPtr());
+ }
+ return 0;
+}
+
+// Filling of the list box for outline view or documents
+// The PI will be set to full size
+
+void SwNavigationPI::FillBox()
+{
+ if(pContentWrtShell)
+ {
+ aContentTree.SetHiddenShell( pContentWrtShell );
+ aContentTree.Display( false );
+ }
+ else
+ {
+ SwView *pView = GetCreateView();
+ if(!pView)
+ {
+ aContentTree.SetActiveShell(0);
+ }
+ else if( pView != pActContView)
+ {
+ SwWrtShell* pWrtShell = pView->GetWrtShellPtr();
+ aContentTree.SetActiveShell(pWrtShell);
+ }
+ else
+ aContentTree.Display( true );
+ pActContView = pView;
+ }
+}
+
+void SwNavigationPI::UsePage(SwWrtShell *pSh)
+{
+ if (!pSh)
+ {
+ SwView *pView = GetCreateView();
+ pSh = pView ? &pView->GetWrtShell() : 0;
+ GetPageEdit().SetValue(1);
+ }
+ if (pSh)
+ {
+ const sal_uInt16 nPageCnt = pSh->GetPageCnt();
+ sal_uInt16 nPhyPage, nVirPage;
+ pSh->GetPageNum(nPhyPage, nVirPage);
+
+ GetPageEdit().SetMax(nPageCnt);
+ GetPageEdit().SetLast(nPageCnt);
+ GetPageEdit().SetValue(nPhyPage);
+ }
+}
+
+// Select handler of the toolboxes
+
+IMPL_LINK( SwNavigationPI, ToolBoxSelectHdl, ToolBox *, pBox )
+{
+ const sal_uInt16 nCurrItemId = pBox->GetCurItemId();
+ SwView *pView = GetCreateView();
+ if (!pView)
+ return 1;
+ SwWrtShell &rSh = pView->GetWrtShell();
+ // Get MouseModifier for Outline-Move
+
+ // Standard: sublevels are taken
+ // do not take sublevels with Ctrl
+ sal_Bool bOutlineWithChildren = ( KEY_MOD1 != pBox->GetModifier());
+ int nFuncId = 0;
+ bool bFocusToDoc = false;
+ switch (nCurrItemId)
+ {
+ case FN_UP:
+ case FN_DOWN:
+ {
+ // #i75416# move the execution of the search to an asynchronously called static link
+ bool* pbNext = new bool( FN_DOWN == nCurrItemId );
+ Application::PostUserEvent( STATIC_LINK(pView, SwView, MoveNavigationHdl), pbNext );
+ }
+ break;
+ case FN_SHOW_ROOT:
+ {
+ aContentTree.ToggleToRoot();
+ }
+ break;
+ case FN_SHOW_CONTENT_BOX:
+ case FN_SELECT_CONTENT:
+ if(pContextWin!=NULL && pContextWin->GetFloatingWindow()!=NULL)
+ {
+ if(_IsZoomedIn() )
+ {
+ _ZoomOut();
+ }
+ else
+ {
+ _ZoomIn();
+ }
+ }
+ return sal_True;
+ // Functions that will trigger a direct action.
+
+ case FN_SELECT_FOOTER:
+ {
+ rSh.MoveCrsr();
+ const sal_uInt16 eType = rSh.GetFrmType(0,sal_False);
+ if (eType & FRMTYPE_FOOTER)
+ {
+ if (rSh.EndPg())
+ nFuncId = FN_END_OF_PAGE;
+ }
+ else if (rSh.GotoFooterTxt())
+ nFuncId = FN_TO_FOOTER;
+ bFocusToDoc = true;
+ }
+ break;
+ case FN_SELECT_HEADER:
+ {
+ rSh.MoveCrsr();
+ const sal_uInt16 eType = rSh.GetFrmType(0,sal_False);
+ if (eType & FRMTYPE_HEADER)
+ {
+ if (rSh.SttPg())
+ nFuncId = FN_START_OF_PAGE;
+ }
+ else if (rSh.GotoHeaderTxt())
+ nFuncId = FN_TO_HEADER;
+ bFocusToDoc = true;
+ }
+ break;
+ case FN_SELECT_FOOTNOTE:
+ {
+ rSh.MoveCrsr();
+ const sal_uInt16 eFrmType = rSh.GetFrmType(0,sal_False);
+ // Jump from the footnote to the anchor.
+ if (eFrmType & FRMTYPE_FOOTNOTE)
+ {
+ if (rSh.GotoFtnAnchor())
+ nFuncId = FN_FOOTNOTE_TO_ANCHOR;
+ }
+ // Otherwise, jump to the first footnote text;
+ // go to the next footnote if this is not possible;
+ // if this is also not possible got to the footnote before.
+ else
+ {
+ if (rSh.GotoFtnTxt())
+ nFuncId = FN_FOOTNOTE_TO_ANCHOR;
+ else if (rSh.GotoNextFtnAnchor())
+ nFuncId = FN_NEXT_FOOTNOTE;
+ else if (rSh.GotoPrevFtnAnchor())
+ nFuncId = FN_PREV_FOOTNOTE;
+ }
+ bFocusToDoc = true;
+ }
+ break;
+
+ case FN_SELECT_SET_AUTO_BOOKMARK:
+ MakeMark();
+ break;
+ case FN_ITEM_DOWN:
+ case FN_ITEM_UP:
+ case FN_ITEM_LEFT:
+ case FN_ITEM_RIGHT:
+ case FN_GLOBAL_EDIT:
+ {
+ if(IsGlobalMode())
+ aGlobalTree.ExecCommand(nCurrItemId);
+ else
+ aContentTree.ExecCommand(nCurrItemId, bOutlineWithChildren);
+ }
+ break;
+ case FN_GLOBAL_SWITCH:
+ {
+ ToggleTree();
+ pConfig->SetGlobalActive(IsGlobalMode());
+ }
+ break;
+ case FN_GLOBAL_SAVE_CONTENT:
+ {
+ sal_Bool bSave = rSh.IsGlblDocSaveLinks();
+ rSh.SetGlblDocSaveLinks( !bSave );
+ pBox->CheckItem(FN_GLOBAL_SAVE_CONTENT, !bSave );
+ }
+ break;
+ }
+ if (nFuncId)
+ {
+ lcl_UnSelectFrm(&rSh);
+ }
+ if(bFocusToDoc)
+ pView->GetEditWin().GrabFocus();
+ return sal_True;
+}
+
+// Click handler of the toolboxes
+
+IMPL_LINK( SwNavigationPI, ToolBoxClickHdl, ToolBox *, pBox )
+{
+ const sal_uInt16 nCurrItemId = pBox->GetCurItemId();
+ switch (nCurrItemId)
+ {
+ case FN_GLOBAL_UPDATE:
+ case FN_GLOBAL_OPEN:
+ {
+ aGlobalTree.TbxMenuHdl(nCurrItemId, pBox);
+ }
+ break;
+ }
+
+ return sal_True;
+}
+
+IMPL_LINK( SwNavigationPI, ToolBoxDropdownClickHdl, ToolBox*, pBox )
+{
+ const sal_uInt16 nCurrItemId = pBox->GetCurItemId();
+ switch (nCurrItemId)
+ {
+ case FN_CREATE_NAVIGATION:
+ {
+ CreateNavigationTool(pBox->GetItemRect(FN_CREATE_NAVIGATION), true, this);
+ }
+ break;
+
+ case FN_DROP_REGION:
+ {
+ static const char* aHIDs[] =
+ {
+ HID_NAVI_DRAG_HYP,
+ HID_NAVI_DRAG_LINK,
+ HID_NAVI_DRAG_COPY,
+ };
+ PopupMenu *pMenu = new PopupMenu;
+ for (sal_uInt16 i = 0; i <= REGION_MODE_EMBEDDED; i++)
+ {
+ pMenu->InsertItem( i + 1, aContextArr[i] );
+ pMenu->SetHelpId(i + 1, aHIDs[i]);
+ }
+ pMenu->CheckItem( nRegionMode + 1 );
+ pMenu->SetSelectHdl(LINK(this, SwNavigationPI, MenuSelectHdl));
+ pBox->SetItemDown( nCurrItemId, true );
+ pMenu->Execute( pBox,
+ pBox->GetItemRect(FN_DROP_REGION),
+ POPUPMENU_EXECUTE_DOWN );
+ pBox->SetItemDown( nCurrItemId, false );
+ pBox->EndSelection();
+ delete pMenu;
+ pBox->Invalidate();
+ }
+ break;
+ case FN_OUTLINE_LEVEL:
+ {
+ PopupMenu *pMenu = new PopupMenu;
+ for (sal_uInt16 i = 101; i <= 100 + MAXLEVEL; i++)
+ {
+ pMenu->InsertItem( i, OUString::number(i - 100) );
+ pMenu->SetHelpId( i, HID_NAVI_OUTLINES );
+ }
+ pMenu->CheckItem( aContentTree.GetOutlineLevel() + 100 );
+ pMenu->SetSelectHdl(LINK(this, SwNavigationPI, MenuSelectHdl));
+ pBox->SetItemDown( nCurrItemId, true );
+ pMenu->Execute( pBox,
+ pBox->GetItemRect(FN_OUTLINE_LEVEL),
+ POPUPMENU_EXECUTE_DOWN );
+ pBox->SetItemDown( nCurrItemId, false );
+ delete pMenu;
+ pBox->EndSelection();
+ pBox->Invalidate();
+ }
+ break;
+ }
+ return sal_True;
+}
+
+SwNavHelpToolBox::SwNavHelpToolBox(SwNavigationPI* pParent, const ResId &rResId) :
+ SwHelpToolBox(pParent, rResId)
+{}
+
+void SwNavHelpToolBox::MouseButtonDown(const MouseEvent &rEvt)
+{
+ if(rEvt.GetButtons() == MOUSE_LEFT &&
+ FN_CREATE_NAVIGATION == GetItemId(rEvt.GetPosPixel()))
+ {
+ ((SwNavigationPI*)GetParent())->CreateNavigationTool(GetItemRect(FN_CREATE_NAVIGATION), false, this);
+ }
+ else
+ SwHelpToolBox::MouseButtonDown(rEvt);
+}
+
+void SwNavigationPI::CreateNavigationTool(const Rectangle& rRect, bool bSetFocus, Window *pParent)
+{
+ Reference< XFrame > xFrame = GetCreateView()->GetViewFrame()->GetFrame().GetFrameInterface();
+ SwScrollNaviPopup* pPopup = new
+ SwScrollNaviPopup(FN_SCROLL_NAVIGATION, xFrame, pParent);
+
+ Rectangle aRect(rRect);
+ Point aT1 = aRect.TopLeft();
+ aT1 = pPopup->GetParent()->OutputToScreenPixel(pPopup->GetParent()->AbsoluteScreenToOutputPixel(aContentToolBox.OutputToAbsoluteScreenPixel(aT1)));
+ aRect.SetPos(aT1);
+ pPopup->StartPopupMode(aRect, FLOATWIN_POPUPMODE_RIGHT|FLOATWIN_POPUPMODE_ALLOWTEAROFF);
+ SetPopupWindow( pPopup );
+ if(bSetFocus)
+ {
+ pPopup->EndPopupMode(FLOATWIN_POPUPMODEEND_TEAROFF);
+ pPopup->GrabFocus();
+ }
+}
+
+void SwNavHelpToolBox::RequestHelp( const HelpEvent& rHEvt )
+{
+ sal_uInt16 nItemId = GetItemId(ScreenToOutputPixel(rHEvt.GetMousePosPixel()));
+ if( FN_UP == nItemId || FN_DOWN == nItemId )
+ {
+ SetItemText(nItemId, SwScrollNaviPopup::GetQuickHelpText((FN_DOWN == nItemId)));
+ }
+ SwHelpToolBox::RequestHelp(rHEvt);
+}
+
+// Action-Handler Edit:
+// Switches to the page if the structure view is not turned on.
+
+IMPL_LINK( SwNavigationPI, EditAction, NumEditAction *, pEdit )
+{
+ SwView *pView = GetCreateView();
+ if (pView)
+ {
+ if(aPageChgTimer.IsActive())
+ aPageChgTimer.Stop();
+ pCreateView->GetWrtShell().GotoPage((sal_uInt16)pEdit->GetValue(), sal_True);
+ pCreateView->GetEditWin().GrabFocus();
+ pCreateView->GetViewFrame()->GetBindings().Invalidate(FN_STAT_PAGE);
+ }
+ return 0;
+}
+
+// If the page can be set here, the maximum is set.
+
+IMPL_LINK( SwNavigationPI, EditGetFocus, NumEditAction *, pEdit )
+{
+ SwView *pView = GetCreateView();
+ if (!pView)
+ return 0;
+ SwWrtShell &rSh = pView->GetWrtShell();
+
+ const sal_uInt16 nPageCnt = rSh.GetPageCnt();
+ pEdit->SetMax(nPageCnt);
+ pEdit->SetLast(nPageCnt);
+ return 0;
+}
+
+sal_Bool SwNavigationPI::Close()
+{
+ SfxViewFrame* pVFrame = pCreateView->GetViewFrame();
+ pVFrame->GetBindings().Invalidate(SID_NAVIGATOR);
+ pVFrame->GetDispatcher()->Execute(SID_NAVIGATOR);
+ return sal_True;
+}
+
+// Setting of an automatic mark
+
+void SwNavigationPI::MakeMark()
+{
+ SwView *pView = GetCreateView();
+ if (!pView) return;
+ SwWrtShell &rSh = pView->GetWrtShell();
+ IDocumentMarkAccess* const pMarkAccess = rSh.getIDocumentMarkAccess();
+
+ // collect and sort navigator reminder names
+ ::std::vector< ::rtl::OUString > vNavMarkNames;
+ for(IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getAllMarksBegin();
+ ppMark != pMarkAccess->getAllMarksEnd();
+ ++ppMark)
+ if( IDocumentMarkAccess::GetType(**ppMark) == IDocumentMarkAccess::NAVIGATOR_REMINDER )
+ vNavMarkNames.push_back(ppMark->get()->GetName());
+ ::std::sort(vNavMarkNames.begin(), vNavMarkNames.end());
+
+ // we are maxed out and delete one
+ // nAutoMarkIdx rotates through the available MarkNames
+ // this assumes that IDocumentMarkAccess generates Names in ascending order
+ if(vNavMarkNames.size() == MAX_MARKS)
+ pMarkAccess->deleteMark(pMarkAccess->findMark(vNavMarkNames[nAutoMarkIdx]));
+
+ rSh.SetBookmark(KeyCode(), OUString(), OUString(), IDocumentMarkAccess::NAVIGATOR_REMINDER);
+ SwView::SetActMark( nAutoMarkIdx );
+
+ if(++nAutoMarkIdx == MAX_MARKS)
+ nAutoMarkIdx = 0;
+}
+
+void SwNavigationPI::GotoPage()
+{
+ if (pContextWin && pContextWin->GetFloatingWindow() && pContextWin->GetFloatingWindow()->IsRollUp())
+ _ZoomIn();
+ if(IsGlobalMode())
+ ToggleTree();
+ UsePage(0);
+ GetPageEdit().GrabFocus();
+}
+
+void SwNavigationPI::_ZoomOut()
+{
+ if (_IsZoomedIn())
+ {
+ FloatingWindow* pFloat = pContextWin!=NULL ? pContextWin->GetFloatingWindow() : NULL;
+ bIsZoomedIn = sal_False;
+ Size aSz(GetOutputSizePixel());
+ aSz.Height() = nZoomOut;
+ Size aMinOutSizePixel = ((SfxDockingWindow*)GetParent())->GetMinOutputSizePixel();
+ ((SfxDockingWindow*)GetParent())->SetMinOutputSizePixel(Size(
+ aMinOutSizePixel.Width(),nZoomOutInit));
+ if (pFloat != NULL)
+ pFloat->SetOutputSizePixel(aSz);
+ FillBox();
+ if(IsGlobalMode())
+ {
+ aGlobalTree.ShowTree();
+ }
+ else
+ {
+ aContentTree.ShowTree();
+ aDocListBox.Show();
+ }
+ SvTreeListEntry* pFirst = aContentTree.FirstSelected();
+ if(pFirst)
+ aContentTree.Select(pFirst, sal_True); // Enable toolbox
+ pConfig->SetSmall( sal_False );
+ aContentToolBox.CheckItem(FN_SHOW_CONTENT_BOX);
+ }
+}
+
+void SwNavigationPI::_ZoomIn()
+{
+ if (pContextWin != NULL)
+ {
+ FloatingWindow* pFloat = pContextWin->GetFloatingWindow();
+ if (pFloat &&
+ (!_IsZoomedIn() || ( pContextWin->GetFloatingWindow()->IsRollUp())))
+ {
+ aContentTree.HideTree();
+ aDocListBox.Hide();
+ aGlobalTree.HideTree();
+ bIsZoomedIn = sal_True;
+ Size aSz(GetOutputSizePixel());
+ if( aSz.Height() > nZoomIn )
+ nZoomOut = ( short ) aSz.Height();
+
+ aSz.Height() = nZoomIn;
+ Size aMinOutSizePixel = ((SfxDockingWindow*)GetParent())->GetMinOutputSizePixel();
+ ((SfxDockingWindow*)GetParent())->SetMinOutputSizePixel(Size(
+ aMinOutSizePixel.Width(), aSz.Height()));
+ pFloat->SetOutputSizePixel(aSz);
+ SvTreeListEntry* pFirst = aContentTree.FirstSelected();
+ if(pFirst)
+ aContentTree.Select(pFirst, sal_True); // Enable toolbox
+ pConfig->SetSmall( sal_True );
+ aContentToolBox.CheckItem(FN_SHOW_CONTENT_BOX, false);
+ }
+ }
+}
+
+void SwNavigationPI::Resize()
+{
+ Window* pParent = GetParent();
+ if( !_IsZoomedIn() )
+ {
+ Size aNewSize (pParent->GetOutputSizePixel());
+
+ SfxDockingWindow* pDockingParent = dynamic_cast<SfxDockingWindow*>(pParent);
+ if (pDockingParent != NULL)
+ {
+ FloatingWindow* pFloat = pDockingParent->GetFloatingWindow();
+ //change the minimum width depending on the dock status
+ Size aMinOutSizePixel = pDockingParent->GetMinOutputSizePixel();
+ if( pFloat)
+ {
+ aNewSize = pFloat->GetOutputSizePixel();
+ aMinOutSizePixel.Width() = nWishWidth;
+ aMinOutSizePixel.Height() = _IsZoomedIn() ? nZoomIn : nZoomOutInit;
+ }
+ else
+ {
+ aMinOutSizePixel.Width() = 0;
+ aMinOutSizePixel.Height() = 0;
+ }
+ pDockingParent->SetMinOutputSizePixel(aMinOutSizePixel);
+ }
+
+ const Point aPos = aContentTree.GetPosPixel();
+ Point aLBPos = aDocListBox.GetPosPixel();
+ long nDist = aPos.X();
+ aNewSize.Height() -= (aPos.Y() + aPos.X() + nDocLBIniHeight + nDist);
+ aNewSize.Width() -= 2 * nDist;
+ aLBPos.Y() = aPos.Y() + aNewSize.Height() + nDist;
+ aDocListBox.Show(!aGlobalTree.IsVisible() && aLBPos.Y() > aPos.Y() );
+
+ Size aDocLBSz = aDocListBox.GetSizePixel();
+ aDocLBSz.Width() = aNewSize.Width();
+ if(aNewSize.Height() < 0)
+ aDocLBSz.Height() = 0;
+ else
+ aDocLBSz.Height() = nDocLBIniHeight;
+ aContentTree.SetSizePixel(aNewSize);
+ // GlobalTree starts on to the top and goes all the way down.
+ aNewSize.Height() += (nDist + nDocLBIniHeight + aPos.Y() - aGlobalTree.GetPosPixel().Y());
+ aGlobalTree.SetSizePixel(aNewSize);
+ aDocListBox.setPosSizePixel( aLBPos.X(), aLBPos.Y(),
+ aDocLBSz.Width(), aDocLBSz.Height(),
+ WINDOW_POSSIZE_X|WINDOW_POSSIZE_Y|WINDOW_POSSIZE_WIDTH);
+ }
+}
+
+SwNavigationPI::SwNavigationPI( SfxBindings* _pBindings,
+ SfxChildWindowContext* pCw,
+ Window* pParent) :
+
+ Window( pParent, SW_RES(DLG_NAVIGATION_PI)),
+ SfxControllerItem( SID_DOCFULLNAME, *_pBindings ),
+
+ aContentToolBox(this, SW_RES(TB_CONTENT)),
+ aGlobalToolBox(this, SW_RES(TB_GLOBAL)),
+ aContentImageList(SW_RES(IL_CONTENT)),
+ aContentTree(this, SW_RES(TL_CONTENT)),
+ aGlobalTree(this, SW_RES(TL_GLOBAL)),
+ aDocListBox(this, SW_RES(LB_DOCS)),
+
+ pxObjectShell(0),
+ pContentView(0),
+ pContentWrtShell(0),
+ pActContView(0),
+ pCreateView(0),
+ pPopupWindow(0),
+ pFloatingWindow(0),
+
+ pContextWin(pCw),
+
+ pConfig(SW_MOD()->GetNavigationConfig()),
+ rBindings(*_pBindings),
+
+ nWishWidth(0),
+ nAutoMarkIdx(1),
+ nRegionMode(REGION_MODE_NONE),
+
+ bSmallMode(sal_False),
+ bIsZoomedIn(sal_False),
+ bPageCtrlsVisible(sal_False),
+ bGlobalMode(sal_False)
+{
+ GetCreateView();
+ InitImageList();
+
+ aContentToolBox.SetHelpId(HID_NAVIGATOR_TOOLBOX );
+ aGlobalToolBox.SetHelpId(HID_NAVIGATOR_GLOBAL_TOOLBOX);
+ aDocListBox.SetHelpId(HID_NAVIGATOR_LISTBOX );
+
+ nDocLBIniHeight = aDocListBox.GetSizePixel().Height();
+ nZoomOutInit = nZoomOut = Resource::ReadShortRes();
+
+ // Insert the numeric field in the toolbox.
+ NumEditAction* pEdit = new NumEditAction(
+ &aContentToolBox, SW_RES(NF_PAGE ));
+ pEdit->SetActionHdl(LINK(this, SwNavigationPI, EditAction));
+ pEdit->SetGetFocusHdl(LINK(this, SwNavigationPI, EditGetFocus));
+ pEdit->SetAccessibleName(pEdit->GetQuickHelpText());
+ pEdit->SetUpHdl(LINK(this, SwNavigationPI, PageEditModifyHdl));
+ pEdit->SetDownHdl(LINK(this, SwNavigationPI, PageEditModifyHdl));
+
+ bPageCtrlsVisible = sal_True;
+
+ // Double separators are not allowed, so you have to
+ // determine the suitable size differently.
+ Rectangle aFirstRect = aContentToolBox.GetItemRect(FN_SELECT_FOOTNOTE);
+ Rectangle aSecondRect = aContentToolBox.GetItemRect(FN_SELECT_HEADER);
+ sal_uInt16 nWidth = sal_uInt16(aFirstRect.Left() - aSecondRect.Left());
+
+ Size aItemWinSize( nWidth , aFirstRect.Bottom() - aFirstRect.Top() );
+ pEdit->SetSizePixel(aItemWinSize);
+ aContentToolBox.InsertSeparator(4);
+ aContentToolBox.InsertWindow( FN_PAGENUMBER, pEdit, 0, 4);
+ aContentToolBox.InsertSeparator(4);
+ aContentToolBox.SetHelpId(FN_PAGENUMBER, HID_NAVI_TBX16);
+ aContentToolBox.ShowItem( FN_PAGENUMBER );
+
+ for( sal_uInt16 i = 0; i <= REGION_MODE_EMBEDDED; i++ )
+ {
+ aContextArr[i] = SW_RESSTR(ST_HYPERLINK + i);
+ aStatusArr[i] = SW_RESSTR(ST_STATUS_FIRST + i);
+ }
+ aStatusArr[3] = SW_RESSTR(ST_ACTIVE_VIEW);
+ FreeResource();
+
+ const Size& rOutSize = GetOutputSizePixel();
+
+ nZoomIn = (short)rOutSize.Height();
+
+ // Make sure the toolbox has a size that fits all its contents
+ Size aContentToolboxSize( aContentToolBox.CalcWindowSizePixel() );
+ aContentToolBox.SetOutputSizePixel( aContentToolboxSize );
+
+ // position listbox below toolbar and add some space
+ long nListboxYPos = aContentToolBox.GetPosPixel().Y() + aContentToolboxSize.Height() + 4;
+
+ // The left and right margins around the toolboxes should be equal.
+ nWishWidth = aContentToolboxSize.Width();
+ nWishWidth += 2 * aContentToolBox.GetPosPixel().X();
+
+ DockingWindow* pDockingParent = dynamic_cast<DockingWindow*>(pParent);
+ if (pDockingParent != NULL)
+ {
+ FloatingWindow* pFloat = pDockingParent->GetFloatingWindow();
+ Size aMinSize(pFloat ? nWishWidth : 0, pFloat ? nZoomOutInit : 0);
+ pDockingParent->SetMinOutputSizePixel(aMinSize);
+ SetOutputSizePixel( Size( nWishWidth, nZoomOutInit));
+
+ SfxDockingWindow* pSfxDockingParent = dynamic_cast<SfxDockingWindow*>(pParent);
+ if (pSfxDockingParent != NULL)
+ {
+ Size aTmpParentSize(pSfxDockingParent->GetSizePixel());
+ if (aTmpParentSize.Width() < aMinSize.Width()
+ || aTmpParentSize.Height() < aMinSize.Height())
+ {
+ if (pSfxDockingParent->GetFloatingWindow()
+ && ! pSfxDockingParent->GetFloatingWindow()->IsRollUp())
+ {
+ pSfxDockingParent->SetOutputSizePixel(aMinSize);
+ }
+ }
+ }
+ }
+
+ aContentTree.setPosSizePixel( 0, nListboxYPos, 0, 0, WINDOW_POSSIZE_Y );
+ aContentTree.SetStyle( aContentTree.GetStyle()|WB_HASBUTTONS|WB_HASBUTTONSATROOT|
+ WB_CLIPCHILDREN|WB_HSCROLL|WB_FORCE_MAKEVISIBLE );
+ aContentTree.SetSpaceBetweenEntries(3);
+ aContentTree.SetSelectionMode( SINGLE_SELECTION );
+ aContentTree.SetDragDropMode( SV_DRAGDROP_CTRL_MOVE |
+ SV_DRAGDROP_CTRL_COPY |
+ SV_DRAGDROP_ENABLE_TOP );
+ aContentTree.EnableAsyncDrag(sal_True);
+ aContentTree.ShowTree();
+ aContentToolBox.CheckItem(FN_SHOW_CONTENT_BOX, true);
+
+// TreeListBox for global document
+ aGlobalTree.setPosSizePixel( 0, nListboxYPos, 0, 0, WINDOW_POSSIZE_Y );
+ aGlobalTree.SetSelectionMode( MULTIPLE_SELECTION );
+ aGlobalTree.SetStyle( aGlobalTree.GetStyle()|WB_HASBUTTONS|WB_HASBUTTONSATROOT|
+ WB_CLIPCHILDREN|WB_HSCROLL );
+ Size aGlblSize(aGlobalToolBox.CalcWindowSizePixel());
+ aGlobalToolBox.SetSizePixel(aGlblSize);
+
+// Handler
+
+ Link aLk = LINK(this, SwNavigationPI, ToolBoxSelectHdl);
+ aContentToolBox.SetSelectHdl( aLk );
+ aGlobalToolBox.SetSelectHdl( aLk );
+ aDocListBox.SetSelectHdl(LINK(this, SwNavigationPI,
+ DocListBoxSelectHdl));
+ aContentToolBox.SetClickHdl( LINK(this, SwNavigationPI, ToolBoxClickHdl) );
+ aContentToolBox.SetDropdownClickHdl( LINK(this, SwNavigationPI, ToolBoxDropdownClickHdl) );
+ aGlobalToolBox.SetClickHdl( LINK(this, SwNavigationPI, ToolBoxClickHdl) );
+ aGlobalToolBox.SetDropdownClickHdl( LINK(this, SwNavigationPI, ToolBoxDropdownClickHdl) );
+ aGlobalToolBox.CheckItem(FN_GLOBAL_SWITCH, true);
+
+ Font aFont(GetFont());
+ aFont.SetWeight(WEIGHT_NORMAL);
+ GetPageEdit().SetFont(aFont);
+ aFont = aContentTree.GetFont();
+ aFont.SetWeight(WEIGHT_NORMAL);
+ aContentTree.SetFont(aFont);
+ aGlobalTree.SetFont(aFont);
+
+ StartListening(*SFX_APP());
+ if ( pCreateView )
+ StartListening(*pCreateView);
+ SfxImageManager* pImgMan = SfxImageManager::GetImageManager( SW_MOD() );
+ pImgMan->RegisterToolBox(&aContentToolBox, SFX_TOOLBOX_CHANGEOUTSTYLE);
+ pImgMan->RegisterToolBox(&aGlobalToolBox, SFX_TOOLBOX_CHANGEOUTSTYLE);
+
+ aContentToolBox.SetItemBits( FN_CREATE_NAVIGATION, aContentToolBox.GetItemBits( FN_CREATE_NAVIGATION ) | TIB_DROPDOWNONLY );
+ aContentToolBox.SetItemBits( FN_DROP_REGION, aContentToolBox.GetItemBits( FN_DROP_REGION ) | TIB_DROPDOWNONLY );
+ aContentToolBox.SetItemBits( FN_OUTLINE_LEVEL, aContentToolBox.GetItemBits( FN_OUTLINE_LEVEL ) | TIB_DROPDOWNONLY );
+
+ if(IsGlobalDoc())
+ {
+ SwView *pActView = GetCreateView();
+ aGlobalToolBox.CheckItem(FN_GLOBAL_SAVE_CONTENT,
+ pActView->GetWrtShellPtr()->IsGlblDocSaveLinks());
+ if(pConfig->IsGlobalActive())
+ ToggleTree();
+ aGlobalTree.GrabFocus();
+ }
+ else
+ aContentTree.GrabFocus();
+ UsePage(0);
+ aPageChgTimer.SetTimeoutHdl(LINK(this, SwNavigationPI, ChangePageHdl));
+ aPageChgTimer.SetTimeout(PAGE_CHANGE_TIMEOUT);
+
+ aContentTree.SetAccessibleName(SW_RESSTR(STR_ACCESS_TL_CONTENT));
+ aGlobalTree.SetAccessibleName(SW_RESSTR(STR_ACCESS_TL_GLOBAL));
+ aDocListBox.SetAccessibleName(aStatusArr[3]);
+
+ if (pContextWin == NULL)
+ {
+ // When the context window is missing then the navigator is
+ // displayed in the sidebar. While the navigator could change
+ // its size, the sidebar can not, and the navigator would just
+ // waste space. Therefore hide this button.
+ aContentToolBox.RemoveItem(aContentToolBox.GetItemPos(FN_SHOW_CONTENT_BOX));
+ }
+}
+
+SwNavigationPI::~SwNavigationPI()
+{
+ if(IsGlobalDoc() && !IsGlobalMode())
+ {
+ SwView *pView = GetCreateView();
+ SwWrtShell &rSh = pView->GetWrtShell();
+ if( !rSh.IsAllProtect() )
+ pView->GetDocShell()->SetReadOnlyUI(sal_False);
+ }
+
+ EndListening(*SFX_APP());
+
+ SfxImageManager* pImgMan = SfxImageManager::GetImageManager( SW_MOD() );
+ pImgMan->ReleaseToolBox(&aContentToolBox);
+ pImgMan->ReleaseToolBox(&aGlobalToolBox);
+ delete aContentToolBox.GetItemWindow(FN_PAGENUMBER);
+ aContentToolBox.Clear();
+ if(pxObjectShell)
+ {
+ if(pxObjectShell->Is())
+ (*pxObjectShell)->DoClose();
+ delete pxObjectShell;
+ }
+ delete pPopupWindow;
+ delete pFloatingWindow;
+
+ if ( IsBound() )
+ rBindings.Release(*this);
+}
+
+void SwNavigationPI::SetPopupWindow( SfxPopupWindow* pWindow )
+{
+ pPopupWindow = pWindow;
+ pPopupWindow->SetPopupModeEndHdl( LINK( this, SwNavigationPI, PopupModeEndHdl ));
+ pPopupWindow->SetDeleteLink_Impl( LINK( this, SwNavigationPI, ClosePopupWindow ));
+}
+
+IMPL_LINK_NOARG(SwNavigationPI, PopupModeEndHdl)
+{
+ if ( pPopupWindow->IsVisible() )
+ {
+ // Replace floating window with popup window and destroy
+ // floating window instance.
+ delete pFloatingWindow;
+ pFloatingWindow = pPopupWindow;
+ pPopupWindow = 0;
+ }
+ else
+ {
+ // Popup window has been closed by the user. No replacement, instance
+ // will destroy itself.
+ pPopupWindow = 0;
+ }
+
+ return 1;
+}
+
+IMPL_LINK( SwNavigationPI, ClosePopupWindow, SfxPopupWindow *, pWindow )
+{
+ if ( pWindow == pFloatingWindow )
+ pFloatingWindow = 0;
+ else
+ pPopupWindow = 0;
+
+ return 1;
+}
+
+void SwNavigationPI::StateChanged( sal_uInt16 nSID, SfxItemState /*eState*/,
+ const SfxPoolItem* /*pState*/ )
+{
+ if(nSID == SID_DOCFULLNAME)
+ {
+ SwView *pActView = GetCreateView();
+ if(pActView)
+ {
+ SwWrtShell* pWrtShell = pActView->GetWrtShellPtr();
+ aContentTree.SetActiveShell(pWrtShell);
+ sal_Bool bGlobal = IsGlobalDoc();
+ aContentToolBox.EnableItem(FN_GLOBAL_SWITCH, bGlobal);
+ if( (!bGlobal && IsGlobalMode()) ||
+ (!IsGlobalMode() && pConfig->IsGlobalActive()) )
+ {
+ ToggleTree();
+ }
+ if(bGlobal)
+ {
+ aGlobalToolBox.CheckItem(FN_GLOBAL_SAVE_CONTENT, pWrtShell->IsGlblDocSaveLinks());
+ }
+ }
+ else
+ {
+ aContentTree.SetActiveShell(0);
+ }
+ UpdateListBox();
+ }
+}
+
+// Get the numeric field from the toolbox.
+
+NumEditAction& SwNavigationPI::GetPageEdit()
+{
+ return *(NumEditAction*)aContentToolBox.GetItemWindow(FN_PAGENUMBER);
+}
+
+SfxChildAlignment SwNavigationPI::CheckAlignment
+ (
+ SfxChildAlignment eActAlign,
+ SfxChildAlignment eAlign
+ )
+{
+SfxChildAlignment eRetAlign;
+
+ if(_IsZoomedIn())
+ eRetAlign = SFX_ALIGN_NOALIGNMENT;
+ else
+ switch (eAlign)
+ {
+ case SFX_ALIGN_BOTTOM:
+ case SFX_ALIGN_LOWESTBOTTOM:
+ case SFX_ALIGN_HIGHESTBOTTOM:
+ eRetAlign = eActAlign;
+ break;
+
+ case SFX_ALIGN_TOP:
+ case SFX_ALIGN_HIGHESTTOP:
+ case SFX_ALIGN_LOWESTTOP:
+ 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;
+ break;
+
+ default:
+ eRetAlign = eAlign;
+ break;
+ }
+ return eRetAlign;
+
+}
+
+// Notification on modified DocInfo
+
+void SwNavigationPI::Notify( SfxBroadcaster& rBrdc, const SfxHint& rHint )
+{
+ if(&rBrdc == pCreateView)
+ {
+ if(rHint.ISA(SfxSimpleHint) && ((SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING)
+ {
+ pCreateView = 0;
+ }
+ }
+ else
+ {
+ if(rHint.ISA(SfxEventHint))
+ {
+ if( pxObjectShell &&
+ ((SfxEventHint&) rHint).GetEventId() == SFX_EVENT_CLOSEAPP)
+ {
+ DELETEZ(pxObjectShell);
+ }
+ else if(((SfxEventHint&) rHint).GetEventId() == SFX_EVENT_OPENDOC)
+ {
+
+ SwView *pActView = GetCreateView();
+ if(pActView)
+ {
+ SwWrtShell* pWrtShell = pActView->GetWrtShellPtr();
+ aContentTree.SetActiveShell(pWrtShell);
+ if(aGlobalTree.IsVisible())
+ {
+ if(aGlobalTree.Update( sal_False ))
+ aGlobalTree.Display();
+ else
+ // If no update is needed, then paint at least,
+ // because of the red entries for the broken links.
+ aGlobalTree.Invalidate();
+ }
+ }
+ }
+ }
+ }
+}
+
+IMPL_LINK( SwNavigationPI, MenuSelectHdl, Menu *, pMenu )
+{
+ sal_uInt16 nMenuId = pMenu->GetCurItemId();
+ if(nMenuId != USHRT_MAX)
+ {
+ if(nMenuId < 100)
+ SetRegionDropMode( --nMenuId);
+ else
+ aContentTree.SetOutlineLevel( static_cast< sal_uInt8 >(nMenuId - 100) );
+ }
+ return 0;
+}
+
+void SwNavigationPI::UpdateListBox()
+{
+ aDocListBox.SetUpdateMode(false);
+ aDocListBox.Clear();
+ SwView *pActView = GetCreateView();
+ bool bDisable = pActView == 0;
+ SwView *pView = SwModule::GetFirstView();
+ sal_uInt16 nCount = 0;
+ sal_uInt16 nAct = 0;
+ sal_uInt16 nConstPos = 0;
+ const SwView* pConstView = aContentTree.IsConstantView() &&
+ aContentTree.GetActiveWrtShell() ?
+ &aContentTree.GetActiveWrtShell()->GetView():
+ 0;
+ while (pView)
+ {
+ SfxObjectShell* pDoc = pView->GetDocShell();
+ // #i53333# don't show help pages here
+ if ( !pDoc->IsHelpDocument() )
+ {
+ OUString sEntry = pDoc->GetTitle();
+ sEntry += " (";
+ if (pView == pActView)
+ {
+ nAct = nCount;
+ sEntry += aStatusArr[ST_ACTIVE - ST_STATUS_FIRST];
+ }
+ else
+ sEntry += aStatusArr[ST_INACTIVE - ST_STATUS_FIRST];
+ sEntry += ")";
+ aDocListBox.InsertEntry(sEntry);
+
+ if (pConstView && pView == pConstView)
+ nConstPos = nCount;
+
+ nCount++;
+ }
+ pView = SwModule::GetNextView(pView);
+ }
+ aDocListBox.InsertEntry(aStatusArr[3]); // "Active Window"
+ nCount++;
+
+ if(aContentTree.GetHiddenWrtShell())
+ {
+ OUString sEntry = aContentTree.GetHiddenWrtShell()->GetView().
+ GetDocShell()->GetTitle();
+ sEntry += " (";
+ sEntry += aStatusArr[ST_HIDDEN - ST_STATUS_FIRST];
+ sEntry += ")";
+ aDocListBox.InsertEntry(sEntry);
+ bDisable = false;
+ }
+ if(aContentTree.IsActiveView())
+ {
+ //Either the name of the current Document or "Active Document".
+ sal_uInt16 nTmp = pActView ? nAct : --nCount;
+ aDocListBox.SelectEntryPos( nTmp );
+ }
+ else if(aContentTree.IsHiddenView())
+ {
+ aDocListBox.SelectEntryPos(nCount);
+ }
+ else
+ aDocListBox.SelectEntryPos(nConstPos);
+
+ aDocListBox.Enable( !bDisable );
+ aDocListBox.SetUpdateMode(true);
+}
+
+IMPL_LINK(SwNavigationPI, DoneLink, SfxPoolItem *, pItem)
+{
+ const SfxViewFrameItem* pFrameItem = PTR_CAST(SfxViewFrameItem, pItem );
+ if( pFrameItem )
+ {
+ SfxViewFrame* pFrame = pFrameItem->GetFrame();
+ if(pFrame)
+ {
+ aContentTree.Clear();
+ pContentView = PTR_CAST(SwView, pFrame->GetViewShell());
+ OSL_ENSURE(pContentView, "no SwView");
+ if(pContentView)
+ pContentWrtShell = pContentView->GetWrtShellPtr();
+ else
+ pContentWrtShell = 0;
+ pxObjectShell = new SfxObjectShellLock(pFrame->GetObjectShell());
+ FillBox();
+ aContentTree.Update();
+ }
+ }
+ return 0;
+}
+
+OUString SwNavigationPI::CreateDropFileName( TransferableDataHelper& rData )
+{
+ OUString sFileName;
+ sal_uLong nFmt;
+ if( rData.HasFormat( nFmt = FORMAT_FILE_LIST ))
+ {
+ FileList aFileList;
+ rData.GetFileList( nFmt, aFileList );
+ sFileName = aFileList.GetFile( 0 );
+ }
+ else if( rData.HasFormat( nFmt = FORMAT_STRING ) ||
+ rData.HasFormat( nFmt = FORMAT_FILE ) ||
+ rData.HasFormat( nFmt = SOT_FORMATSTR_ID_FILENAME ))
+ rData.GetString( nFmt, sFileName );
+ else if( rData.HasFormat( nFmt = SOT_FORMATSTR_ID_SOLK ) ||
+ rData.HasFormat( nFmt = SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK )||
+ rData.HasFormat( nFmt = SOT_FORMATSTR_ID_FILECONTENT ) ||
+ rData.HasFormat( nFmt = SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) ||
+ rData.HasFormat( nFmt = SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ))
+ {
+ INetBookmark aBkmk( aEmptyOUStr, aEmptyOUStr );
+ rData.GetINetBookmark( nFmt, aBkmk );
+ sFileName = aBkmk.GetURL();
+ }
+ if( !sFileName.isEmpty() )
+ {
+ sFileName = INetURLObject( sFileName ).GetMainURL( INetURLObject::NO_DECODE );
+ }
+ return sFileName;
+}
+
+sal_Int8 SwNavigationPI::AcceptDrop( const AcceptDropEvent& /*rEvt*/ )
+{
+ return ( !aContentTree.IsInDrag() &&
+ ( aContentTree.IsDropFormatSupported( FORMAT_FILE ) ||
+ aContentTree.IsDropFormatSupported( FORMAT_STRING ) ||
+ aContentTree.IsDropFormatSupported( SOT_FORMATSTR_ID_SOLK ) ||
+ aContentTree.IsDropFormatSupported( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK )||
+ aContentTree.IsDropFormatSupported( SOT_FORMATSTR_ID_FILECONTENT ) ||
+ aContentTree.IsDropFormatSupported( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) ||
+ aContentTree.IsDropFormatSupported( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ) ||
+ aContentTree.IsDropFormatSupported( SOT_FORMATSTR_ID_FILENAME )))
+ ? DND_ACTION_COPY
+ : DND_ACTION_NONE;
+}
+
+sal_Int8 SwNavigationPI::ExecuteDrop( const ExecuteDropEvent& rEvt )
+{
+ TransferableDataHelper aData( rEvt.maDropEvent.Transferable );
+ sal_Int8 nRet = DND_ACTION_NONE;
+ OUString sFileName;
+ if( !aContentTree.IsInDrag() &&
+ !(sFileName = SwNavigationPI::CreateDropFileName( aData )).isEmpty() )
+ {
+ INetURLObject aTemp( sFileName );
+ GraphicDescriptor aDesc( aTemp );
+ if( !aDesc.Detect() ) // accept no graphics
+ {
+ if( -1 == sFileName.indexOf('#')
+ && (sContentFileName.isEmpty() || sContentFileName != sFileName ))
+ {
+ nRet = rEvt.mnAction;
+ sFileName = comphelper::string::stripEnd(sFileName, 0);
+ sContentFileName = sFileName;
+ if(pxObjectShell)
+ {
+ aContentTree.SetHiddenShell( 0 );
+ (*pxObjectShell)->DoClose();
+ DELETEZ( pxObjectShell);
+ }
+ SfxStringItem aFileItem(SID_FILE_NAME, sFileName );
+ SfxStringItem aOptionsItem( SID_OPTIONS, OUString("HRC") );
+ SfxLinkItem aLink( SID_DONELINK,
+ LINK( this, SwNavigationPI, DoneLink ) );
+ GetActiveView()->GetViewFrame()->GetDispatcher()->Execute(
+ SID_OPENDOC, SFX_CALLMODE_ASYNCHRON,
+ &aFileItem, &aOptionsItem, &aLink, 0L );
+ }
+ }
+ }
+ return nRet;
+}
+
+void SwNavigationPI::SetRegionDropMode(sal_uInt16 nNewMode)
+{
+ nRegionMode = nNewMode;
+ pConfig->SetRegionMode( nRegionMode );
+
+ sal_uInt16 nDropId = FN_DROP_REGION;
+ if(nRegionMode == REGION_MODE_LINK)
+ nDropId = FN_DROP_REGION_LINK;
+ else if(nRegionMode == REGION_MODE_EMBEDDED)
+ nDropId = FN_DROP_REGION_COPY;
+
+ ImageList& rImgLst = aContentImageList;
+
+ aContentToolBox.SetItemImage( FN_DROP_REGION, rImgLst.GetImage(nDropId));
+}
+
+sal_Bool SwNavigationPI::ToggleTree()
+{
+ sal_Bool bRet = sal_True;
+ sal_Bool bGlobalDoc = IsGlobalDoc();
+ if(!IsGlobalMode() && bGlobalDoc)
+ {
+ SetUpdateMode(false);
+ if(_IsZoomedIn())
+ _ZoomOut();
+ aGlobalTree.ShowTree();
+ aGlobalToolBox.Show();
+ aContentTree.HideTree();
+ aContentToolBox.Hide();
+ aDocListBox.Hide();
+ SetGlobalMode(sal_True);
+ SetUpdateMode(true);
+ }
+ else
+ {
+ aGlobalTree.HideTree();
+ aGlobalToolBox.Hide();
+ if(!_IsZoomedIn())
+ {
+ aContentTree.ShowTree();
+ aContentToolBox.Show();
+ aDocListBox.Show();
+ }
+ bRet = sal_False;
+ SetGlobalMode(sal_False);
+ }
+ return bRet;
+}
+
+sal_Bool SwNavigationPI::IsGlobalDoc() const
+{
+ sal_Bool bRet = sal_False;
+ SwView *pView = GetCreateView();
+ if(pView)
+ {
+ SwWrtShell &rSh = pView->GetWrtShell();
+ bRet = rSh.IsGlobalDoc();
+ }
+ return bRet;
+}
+
+IMPL_LINK_NOARG(SwNavigationPI, ChangePageHdl)
+{
+ EditAction(&GetPageEdit());
+ GetPageEdit().GrabFocus();
+ return 0;
+}
+
+IMPL_LINK_NOARG(SwNavigationPI, PageEditModifyHdl)
+{
+ if(aPageChgTimer.IsActive())
+ aPageChgTimer.Stop();
+ aPageChgTimer.Start();
+ return 0;
+}
+
+SwView* SwNavigationPI::GetCreateView() const
+{
+ if(!pCreateView)
+ {
+ SwView* pView = SwModule::GetFirstView();
+ while(pView)
+ {
+ if(&pView->GetViewFrame()->GetBindings() == &rBindings)
+ {
+ ((SwNavigationPI*)this)->pCreateView = pView;
+ ((SwNavigationPI*)this)->StartListening(*pCreateView);
+ break;
+ }
+ pView = SwModule::GetNextView(pView);
+ }
+ }
+ return pCreateView;
+}
+
+SwNavigationChild::SwNavigationChild( Window* pParent,
+ sal_uInt16 nId,
+ SfxBindings* _pBindings,
+ SfxChildWinInfo* )
+ : SfxChildWindowContext( nId )
+{
+ SwNavigationPI* pNavi = new SwNavigationPI( _pBindings, this, pParent );
+ SetWindow( pNavi );
+ _pBindings->Invalidate(SID_NAVIGATOR);
+
+ SwNavigationConfig* pNaviConfig = SW_MOD()->GetNavigationConfig();
+
+ sal_uInt16 nRootType = static_cast< sal_uInt16 >( pNaviConfig->GetRootType() );
+ if( nRootType < CONTENT_TYPE_MAX )
+ {
+ pNavi->aContentTree.SetRootType(nRootType);
+ pNavi->aContentToolBox.CheckItem(FN_SHOW_ROOT, true);
+ }
+ pNavi->aContentTree.SetOutlineLevel( static_cast< sal_uInt8 >( pNaviConfig->GetOutlineLevel() ) );
+ pNavi->SetRegionDropMode( static_cast< sal_uInt16 >( pNaviConfig->GetRegionMode() ) );
+
+ if(GetFloatingWindow() && pNaviConfig->IsSmall())
+ {
+ pNavi->_ZoomIn();
+ }
+}
+
+void SwNavigationPI::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ Window::DataChanged( rDCEvt );
+ if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
+ (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ {
+ InitImageList();
+ const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
+ Color aBgColor = rStyleSettings.GetFaceColor();
+ Wallpaper aBack( aBgColor );
+ SetBackground( aBack );
+ }
+}
+
+void SwNavigationPI::InitImageList()
+{
+ sal_uInt16 k;
+
+ ImageList& rImgLst = aContentImageList;
+ for( k = 0; k < aContentToolBox.GetItemCount(); k++)
+ aContentToolBox.SetItemImage(aContentToolBox.GetItemId(k),
+ rImgLst.GetImage(aContentToolBox.GetItemId(k)));
+
+ for( k = 0; k < aGlobalToolBox.GetItemCount(); k++)
+ aGlobalToolBox.SetItemImage(aGlobalToolBox.GetItemId(k),
+ rImgLst.GetImage(aGlobalToolBox.GetItemId(k)));
+
+ sal_uInt16 nDropId = FN_DROP_REGION;
+ if(nRegionMode == REGION_MODE_LINK)
+ nDropId = FN_DROP_REGION_LINK;
+ else if(nRegionMode == REGION_MODE_EMBEDDED)
+ nDropId = FN_DROP_REGION_COPY;
+ aContentToolBox.SetItemImage( FN_DROP_REGION,
+ rImgLst.GetImage(nDropId));
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/utlui/navipi.hrc b/sw/source/core/uibase/utlui/navipi.hrc
new file mode 100644
index 000000000000..daed23f3d77a
--- /dev/null
+++ b/sw/source/core/uibase/utlui/navipi.hrc
@@ -0,0 +1,74 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#define IL_CONTENT 7
+#define FT_PAGE 10
+#define TB_CONTENT 50
+#define TL_CONTENT 51
+#define LB_DOCS 53
+#define NF_PAGE 54
+#define TL_GLOBAL 55
+#define TB_GLOBAL 56
+
+// Strings for the context menu of the content tree
+#define ST_CONTEXT_FIRST 60
+#define ST_OUTLINE_LEVEL ST_CONTEXT_FIRST
+#define ST_DRAGMODE (ST_CONTEXT_FIRST + 1)
+#define ST_HYPERLINK (ST_CONTEXT_FIRST + 2)
+#define ST_LINK_REGION (ST_CONTEXT_FIRST + 3)
+#define ST_COPY_REGION (ST_CONTEXT_FIRST + 4)
+#define ST_DISPLAY (ST_CONTEXT_FIRST + 5)
+#define ST_ACTIVE_VIEW (ST_CONTEXT_FIRST + 6)
+#define ST_STATUS_FIRST 67
+#define ST_HIDDEN (ST_STATUS_FIRST )
+#define ST_ACTIVE (ST_STATUS_FIRST + 1)
+#define ST_INACTIVE (ST_STATUS_FIRST + 2)
+#define ST_MISC 70
+#define ST_EDIT_ENTRY ST_MISC
+#define ST_DELETE_ENTRY (ST_MISC + 1)
+
+#define ST_GLOBAL_CONTEXT_FIRST (ST_DELETE_ENTRY + 1)
+#define ST_UPDATE (ST_GLOBAL_CONTEXT_FIRST )
+#define ST_EDIT_CONTENT (ST_GLOBAL_CONTEXT_FIRST + 1)
+#define ST_INSERT (ST_GLOBAL_CONTEXT_FIRST + 2)
+#define ST_INDEX (ST_GLOBAL_CONTEXT_FIRST + 3)
+#define ST_FILE (ST_GLOBAL_CONTEXT_FIRST + 4)
+#define ST_NEW_FILE (ST_GLOBAL_CONTEXT_FIRST + 5)
+#define ST_TEXT (ST_GLOBAL_CONTEXT_FIRST + 6)
+#define ST_DELETE (ST_GLOBAL_CONTEXT_FIRST + 7)
+#define ST_UPDATE_SEL (ST_GLOBAL_CONTEXT_FIRST + 8)
+#define ST_UPDATE_INDEX (ST_GLOBAL_CONTEXT_FIRST + 9)
+#define ST_UPDATE_LINK (ST_GLOBAL_CONTEXT_FIRST +10)
+#define ST_UPDATE_ALL (ST_GLOBAL_CONTEXT_FIRST +11)
+#define ST_BROKEN_LINK (ST_GLOBAL_CONTEXT_FIRST +12)
+#define ST_EDIT_LINK (ST_GLOBAL_CONTEXT_FIRST +13)
+
+#define ST_REMOVE_INDEX (ST_GLOBAL_CONTEXT_FIRST +30)
+#define ST_REMOVE_TBL_PROTECTION (ST_GLOBAL_CONTEXT_FIRST +31)
+#define ST_RENAME (ST_GLOBAL_CONTEXT_FIRST +32)
+#define ST_READONLY_IDX (ST_GLOBAL_CONTEXT_FIRST +33)
+#define ST_INVISIBLE (ST_GLOBAL_CONTEXT_FIRST +34)
+
+#define ST_POSTIT_SHOW (ST_GLOBAL_CONTEXT_FIRST +35)
+#define ST_POSTIT_HIDE (ST_GLOBAL_CONTEXT_FIRST +36)
+#define ST_POSTIT_DELETE (ST_GLOBAL_CONTEXT_FIRST +37)
+
+#define ST_TL_GLOBAL (ST_GLOBAL_CONTEXT_FIRST +38)
+#define ST_TL_CONTENT (ST_GLOBAL_CONTEXT_FIRST +39)
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/utlui/navipi.src b/sw/source/core/uibase/utlui/navipi.src
new file mode 100644
index 000000000000..66bda96428c8
--- /dev/null
+++ b/sw/source/core/uibase/utlui/navipi.src
@@ -0,0 +1,508 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "cmdid.h"
+#include "utlui.hrc"
+#include "navipi.hrc"
+#include "helpid.h"
+#include "access.hrc"
+
+Window DLG_NAVIGATION_PI
+{
+ HelpID = HID_NAVIGATION_PI ;
+ OutputSize = TRUE ;
+ DialogControl = TRUE ;
+ SVLook = TRUE ;
+ // Size = MAP_PIXEL( 235, 195 );
+ // ZoomInOutputSize = MAP_PIXEL(235, 56);
+ Size = MAP_PIXEL ( 282 , 59 ) ;
+ // Closeable = TRUE ;
+ // Zoomable = TRUE ;
+ // Moveable = TRUE ;
+ // ZoomIn = FALSE;
+ Hide = TRUE ;
+ // HideWhenDeactivate = TRUE ;
+ // Sizeable = TRUE ;
+ // EnableResizing = TRUE ;
+ // Dockable = TRUE ;
+ // Sizeable = TRUE ;
+ Text [ en-US ] = "Navigator" ;
+ ExtraData =
+ {
+ 198;
+ };
+ // Toolbox from 323 x
+#define NAVI_IDLIST \
+ IdList = \
+ { \
+ FN_UP ; \
+ FN_DOWN ; \
+ FN_SELECT_HEADER ; \
+ FN_SELECT_FOOTER ; \
+ FN_SELECT_FOOTNOTE ; \
+ FN_SHOW_CONTENT_BOX ; \
+ FN_SHOW_ROOT ; \
+ FN_ITEM_UP ; \
+ FN_ITEM_DOWN ; \
+ FN_ITEM_LEFT ; \
+ FN_ITEM_RIGHT ; \
+ FN_DROP_REGION ; \
+ FN_OUTLINE_LEVEL ; \
+ FN_SELECT_SET_AUTO_BOOKMARK ; \
+ FN_DROP_REGION_LINK ; \
+ FN_DROP_REGION_COPY ; \
+ FN_GLOBAL_SWITCH ; \
+ FN_GLOBAL_EDIT ; \
+ FN_GLOBAL_UPDATE ; \
+ FN_GLOBAL_OPEN ; \
+ FN_GLOBAL_SAVE_CONTENT ; \
+ FN_CREATE_NAVIGATION ; \
+ }; \
+ IdCount = { 21 ; };
+
+ ImageList IL_CONTENT
+ {
+ Prefix = "sc";
+ MaskColor = IMAGE_MASK_COLOR ;
+ NAVI_IDLIST
+ };
+ Toolbox TB_CONTENT
+ {
+ Pos = MAP_PIXEL ( 5 , 5 ) ;
+ Size = MAP_PIXEL ( 300 , 47 ) ;
+ LineCount = 2 ;
+ ItemList =
+ {
+ ToolBoxItem
+ {
+ Identifier = FN_GLOBAL_SWITCH ;
+ HelpID = HID_NAVI_TBX17 ;
+ Text [ en-US ] = "Toggle" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = FN_CREATE_NAVIGATION ;
+ HelpID = HID_NAVI_TBX24 ;
+ Text [ en-US ] = "Navigation" ;
+ DropDown = TRUE ;
+ };
+ ToolBoxItem
+ {
+ Identifier = FN_UP ;
+ // ItemBitmap = Bitmap { File = "navup.bmp"; };
+ HelpID = HID_NAVI_TBX2 ;
+ Text [ en-US ] = "Back" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = FN_DOWN ;
+ // ItemBitmap = Bitmap { File = "navdn.bmp"; };
+ HelpID = HID_NAVI_TBX3 ;
+ Text [ en-US ] = "Forward" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = FN_DROP_REGION ;
+ HelpID = HID_NAVI_TBX4 ;
+ DropDown = TRUE ;
+ Text [ en-US ] = "Drag Mode" ;
+ };
+ ToolBoxItem
+ {
+ Type = TOOLBOXITEM_SEPARATOR ;
+ };
+ ToolBoxItem
+ {
+ Identifier = FN_ITEM_UP ;
+ // ItemBitmap = Bitmap { File = "navchup.bmp"; };
+ HelpID = HID_NAVI_TBX5 ;
+ Text [ en-US ] = "Promote Chapter" ;
+ //HelpText[english_us-wrong] = "Move chapter down";//"Move chapter up"
+ };
+ ToolBoxItem
+ {
+ Identifier = FN_ITEM_DOWN ;
+ // ItemBitmap = Bitmap { File = "navchdn.bmp"; };
+ HelpID = HID_NAVI_TBX6 ;
+ Text [ en-US ] = "Demote Chapter" ;
+ };
+ ToolBoxItem
+ {
+ Type = TOOLBOXITEM_BREAK ;
+ };
+ ToolBoxItem
+ {
+ Identifier = FN_SHOW_CONTENT_BOX ;
+ HelpID = HID_NAVI_TBX7 ;
+ Text [ en-US ] = "List Box On/Off" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = FN_SHOW_ROOT ;
+ HelpID = HID_NAVI_TBX8 ;
+ Text [ en-US ] = "Content View" ;
+ };
+ ToolBoxItem
+ {
+ Type = TOOLBOXITEM_SEPARATOR ;
+ };
+ ToolBoxItem
+ {
+ Identifier = FN_SELECT_SET_AUTO_BOOKMARK ;
+ HelpID = HID_NAVI_TBX9 ;
+ // ItemBitmap = Bitmap { File = "navstmp.bmp"; };
+ Text [ en-US ] = "Set Reminder" ;
+ };
+ ToolBoxItem
+ {
+ Type = TOOLBOXITEM_SEPARATOR ;
+ };
+ ToolBoxItem
+ {
+ Identifier = FN_SELECT_HEADER ;
+ // ItemBitmap = Bitmap { File = "navhead.bmp"; };
+ HelpID = HID_NAVI_TBX10 ;
+ Text [ en-US ] = "Header" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = FN_SELECT_FOOTER ;
+ // ItemBitmap = Bitmap { File = "navfoot.bmp"; };
+ HelpID = HID_NAVI_TBX11 ;
+ Text [ en-US ] = "Footer" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = FN_SELECT_FOOTNOTE ;
+ // ItemBitmap = Bitmap { File = "navnote.bmp"; };
+ HelpID = HID_NAVI_TBX12 ;
+ Text [ en-US ] = "Anchor<->Text" ;
+ };
+ ToolBoxItem
+ {
+ Type = TOOLBOXITEM_SEPARATOR ;
+ };
+ ToolBoxItem
+ {
+ Identifier = FN_OUTLINE_LEVEL ;
+ HelpID = HID_NAVI_TBX13 ;
+ Text [ en-US ] = "Heading Levels Shown" ;
+ DropDown = TRUE ;
+ };
+ ToolBoxItem
+ {
+ Type = TOOLBOXITEM_SEPARATOR ;
+ };
+ ToolBoxItem
+ {
+ Identifier = FN_ITEM_LEFT ;
+ HelpID = HID_NAVI_TBX14 ;
+ // ItemBitmap = Bitmap { File = "navchlf.bmp"; };
+ Text [ en-US ] = "Promote Level" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = FN_ITEM_RIGHT ;
+ // ItemBitmap = Bitmap { File = "navchrg.bmp"; };
+ HelpID = HID_NAVI_TBX15 ;
+ Text [ en-US ] = "Demote Level" ;
+ };
+ };
+ };
+ ToolBox TB_GLOBAL
+ {
+ Pos = MAP_PIXEL ( 5 , 5 ) ;
+ Size = MAP_PIXEL ( 300 , 47 ) ;
+ LineCount = 1 ;
+ Hide = TRUE ;
+ ItemList =
+ {
+ ToolBoxItem
+ {
+ Identifier = FN_GLOBAL_SWITCH ;
+ HelpID = HID_NAVI_TBX17 ;
+ Text [ en-US ] = "Toggle" ;
+ };
+ ToolBoxItem
+ {
+ Type = TOOLBOXITEM_SEPARATOR ;
+ };
+ ToolBoxItem
+ {
+ Identifier = FN_GLOBAL_EDIT ;
+ HelpID = HID_NAVI_TBX18 ;
+ Text [ en-US ] = "Edit" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = FN_GLOBAL_UPDATE ;
+ HelpID = HID_NAVI_TBX19 ;
+ Text [ en-US ] = "Update" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = FN_GLOBAL_OPEN ;
+ HelpID = HID_NAVI_TBX20 ;
+ Text [ en-US ] = "Insert" ;
+ };
+ ToolBoxItem
+ {
+ Type = TOOLBOXITEM_SEPARATOR ;
+ };
+ ToolBoxItem
+ {
+ Identifier = FN_GLOBAL_SAVE_CONTENT ;
+ HelpID = HID_NAVI_TBX21 ;
+ Text [ en-US ] = "Save Contents as well" ;
+ };
+ ToolBoxItem
+ {
+ Type = TOOLBOXITEM_SEPARATOR ;
+ };
+ ToolBoxItem
+ {
+ Identifier = FN_ITEM_UP ;
+ HelpID = HID_NAVI_TBX22 ;
+ Text [ en-US ] = "Move Up" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = FN_ITEM_DOWN ;
+ HelpID = HID_NAVI_TBX23 ;
+ Text [ en-US ] = "Move Down" ;
+ };
+ };
+ };
+ /* TreeListBox */
+ Control TL_CONTENT
+ {
+ HelpID = HID_NAVI_CONTENT ;
+ Border = TRUE ;
+ Pos = MAP_PIXEL ( 5 , 62 ) ;
+ Size = MAP_PIXEL ( 274 , 112 ) ;
+ TabStop = TRUE ;
+ ClipChildren = TRUE ;
+ Hide = TRUE ;
+ };
+ Control TL_GLOBAL
+ {
+ HelpID = HID_NAVI_GLOBAL ;
+ Border = TRUE ;
+ Pos = MAP_PIXEL ( 5 , 34 ) ;
+ Size = MAP_PIXEL ( 274 , 112 ) ;
+ TabStop = TRUE ;
+ ClipChildren = TRUE ;
+ Hide = TRUE ;
+ };
+ ListBox LB_DOCS
+ {
+ Border = TRUE ;
+ Pos = MAP_PIXEL ( 5 , 115 ) ;
+ Size = MAP_APPFONT ( 150 , 50 ) ;
+ DropDown = TRUE ;
+ };
+ NumericField NF_PAGE
+ {
+ Border = TRUE ;
+ Pos = MAP_PIXEL ( 50 , 29 ) ;
+ Size = MAP_PIXEL ( 34 , 20 ) ;
+ TabStop = TRUE ;
+ Left = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Minimum = 1 ;
+ First = 1 ;
+ // Outline as default
+ Maximum = 5 ;
+ Last = 5 ;
+ Value = 5 ;
+ };
+ String ST_OUTLINE_LEVEL
+ {
+ Text [ en-US ] = "Outline Level" ;
+ };
+ String ST_DRAGMODE
+ {
+ Text [ en-US ] = "Drag Mode" ;
+ };
+ String ST_HYPERLINK
+ {
+ Text [ en-US ] = "Insert as Hyperlink" ;
+ };
+ String ST_LINK_REGION
+ {
+ Text [ en-US ] = "Insert as Link" ;
+ };
+ String ST_COPY_REGION
+ {
+ Text [ en-US ] = "Insert as Copy" ;
+ };
+ String ST_DISPLAY
+ {
+ Text [ en-US ] = "Display" ;
+ };
+ String ST_ACTIVE_VIEW
+ {
+ Text [ en-US ] = "Active Window" ;
+ };
+ String ST_HIDDEN
+ {
+ Text [ en-US ] = "hidden" ;
+ };
+ String ST_ACTIVE
+ {
+ Text [ en-US ] = "active" ;
+ };
+ String ST_INACTIVE
+ {
+ Text [ en-US ] = "inactive" ;
+ };
+ String ST_EDIT_ENTRY
+ {
+ Text [ en-US ] = "Edit..." ;
+ };
+ String ST_UPDATE
+ {
+ Text [ en-US ] = "~Update" ;
+ };
+ String ST_EDIT_CONTENT
+ {
+ Text [ en-US ] = "Edit" ;
+ };
+ String ST_EDIT_LINK
+ {
+ Text [ en-US ] = "Edit link";
+ };
+ String ST_INSERT
+ {
+ Text [ en-US ] = "Insert" ;
+ };
+ String ST_INDEX
+ {
+ Text [ en-US ] = "~Index";
+ };
+ String ST_FILE
+ {
+ Text [ en-US ] = "File" ;
+ };
+ String ST_NEW_FILE
+ {
+ Text [ en-US ] = "New Document" ;
+ };
+ String ST_TEXT
+ {
+ Text [ en-US ] = "Text" ;
+ };
+ String ST_DELETE
+ {
+ Text [ en-US ] = "Delete" ;
+ };
+ String ST_DELETE_ENTRY
+ {
+ Text [ en-US ] = "~Delete" ;
+ };
+ String ST_UPDATE_SEL
+ {
+ Text [ en-US ] = "Selection" ;
+ };
+ String ST_UPDATE_INDEX
+ {
+ Text [ en-US ] = "Indexes" ;
+ };
+ String ST_UPDATE_LINK
+ {
+ Text [ en-US ] = "Links" ;
+ };
+ String ST_UPDATE_ALL
+ {
+ Text [ en-US ] = "All" ;
+ };
+ String ST_REMOVE_INDEX
+ {
+ Text [ en-US ] = "~Remove Index" ;
+ };
+ String ST_REMOVE_TBL_PROTECTION
+ {
+ Text [ en-US ] = "~Unprotect" ;
+ };
+ String ST_INVISIBLE
+ {
+ Text [ en-US ] = "hidden";
+ };
+ String ST_BROKEN_LINK
+ {
+ Text [ en-US ] = "File not found: ";
+ };
+ String ST_RENAME
+ {
+ Text [ en-US ] = "~Rename";
+ };
+ String ST_READONLY_IDX
+ {
+ Text [ en-US ] = "Read-~only";
+ };
+ String ST_POSTIT_SHOW
+ {
+ Text [ en-US ] = "Show All";
+ };
+ String ST_POSTIT_HIDE
+ {
+ Text [ en-US ] = "Hide All";
+ };
+ String ST_POSTIT_DELETE
+ {
+ Text [ en-US ] = "Delete All";
+ };
+};
+#define NAVI_ENTRY_IDS \
+ IdList = \
+ { \
+ 20000 ; \
+ 20001 ; \
+ 20002 ; \
+ 20003 ; \
+ 20004 ; \
+ 20005 ; \
+ 20006 ; \
+ 20007 ; \
+ 20008 ; \
+ 20009 ; \
+ 20010 ; \
+ 20011 ; \
+ }; \
+ IdCount = { 12 ; };
+
+ImageList IMG_NAVI_ENTRYBMP
+{
+ Prefix = "nc";
+ MaskColor = IMAGE_MASK_COLOR ;
+ NAVI_ENTRY_IDS
+};
+
+
+String STR_ACCESS_TL_GLOBAL
+{
+ Text [ en-US ] = "Global View";
+};
+String STR_ACCESS_TL_CONTENT
+{
+ Text [ en-US ] = "Content View";
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/utlui/numfmtlb.cxx b/sw/source/core/uibase/utlui/numfmtlb.cxx
new file mode 100644
index 000000000000..ecd4dee197d5
--- /dev/null
+++ b/sw/source/core/uibase/utlui/numfmtlb.cxx
@@ -0,0 +1,488 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <hintids.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <comphelper/processfactory.hxx>
+#include <editeng/unolingu.hxx>
+#include <unotools/localedatawrapper.hxx>
+#include <i18nlangtag/lang.h>
+#include <svl/zformat.hxx>
+#include <svl/eitem.hxx>
+#include <svx/svxids.hrc>
+#include <svx/numinf.hxx>
+#include <vcl/msgbox.hxx>
+#include <svx/flagsdef.hxx>
+#include <svl/itemset.hxx>
+#include <docsh.hxx>
+#include <swtypes.hxx>
+#include <swmodule.hxx>
+#include <view.hxx>
+#include <wrtsh.hxx>
+#include <numfmtlb.hxx>
+#include <utlui.hrc>
+#include "swabstdlg.hxx"
+#include "dialog.hrc"
+#include <unomid.h>
+#include <sfx2/viewfrm.hxx>
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+
+// STATIC DATA
+
+/**
+ * Description:
+ * nFormatType: Display the formats of this Type
+ * nDefFmt: Select this format and possibly insert it
+ */
+
+NumFormatListBox::NumFormatListBox(Window* pWin, WinBits nStyle) :
+ ListBox ( pWin, nStyle ),
+ nCurrFormatType (-1),
+ nStdEntry (0),
+ bOneArea (sal_False),
+ nDefFormat (0),
+ pVw (0),
+ pOwnFormatter (0),
+ bShowLanguageControl(sal_False),
+ bUseAutomaticLanguage(sal_True)
+{
+ Init(NUMBERFORMAT_NUMBER, true);
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeNumFormatListBox(Window *pParent, VclBuilder::stringmap &rMap)
+{
+ WinBits nBits = WB_LEFT|WB_VCENTER|WB_3DLOOK;
+
+ bool bDropdown = VclBuilder::extractDropdown(rMap);
+
+ if (bDropdown)
+ nBits |= WB_DROPDOWN;
+ else
+ nBits |= WB_BORDER;
+
+ NumFormatListBox* pListBox = new NumFormatListBox(pParent, nBits|WB_SIMPLEMODE);
+
+ if (bDropdown)
+ pListBox->EnableAutoSize(true);
+
+ return pListBox;
+}
+
+void NumFormatListBox::Init(short nFormatType, sal_Bool bUsrFmts)
+{
+ SwView *pView = GetView();
+
+ if (pView)
+ eCurLanguage = pView->GetWrtShell().GetCurLang();
+ else
+ eCurLanguage = SvtSysLocale().GetLanguageTag().getLanguageType();
+
+ if (bUsrFmts == sal_False)
+ {
+ pOwnFormatter = new SvNumberFormatter(comphelper::getProcessComponentContext(), eCurLanguage);
+ }
+
+ SetFormatType(nFormatType);
+ SetDefFormat(nDefFormat);
+
+ SetSelectHdl(LINK(this, NumFormatListBox, SelectHdl));
+}
+
+NumFormatListBox::~NumFormatListBox()
+{
+ delete pOwnFormatter;
+}
+
+SwView* NumFormatListBox::GetView()
+{
+ if( pVw )
+ return pVw;
+ return ::GetActiveView();
+}
+
+void NumFormatListBox::SetFormatType(const short nFormatType)
+{
+ if (nCurrFormatType == -1 ||
+ (nCurrFormatType & nFormatType) == 0) // there are mixed formats, like for example DateTime
+ {
+ SvNumberFormatter* pFormatter;
+
+ if( pOwnFormatter )
+ pFormatter = pOwnFormatter;
+ else
+ {
+ SwView *pView = GetView();
+ OSL_ENSURE(pView, "no view found");
+ if(!pView)
+ return;
+ SwWrtShell &rSh = pView->GetWrtShell();
+ pFormatter = rSh.GetNumberFormatter();
+ }
+
+ Clear(); // Remove all entries from the Listbox
+
+ NfIndexTableOffset eOffsetStart = NF_NUMBER_START;
+ NfIndexTableOffset eOffsetEnd = NF_NUMBER_START;
+
+ switch( nFormatType )
+ {
+ case NUMBERFORMAT_NUMBER:
+ eOffsetStart=NF_NUMBER_START;
+ eOffsetEnd=NF_NUMBER_END;
+ break;
+
+ case NUMBERFORMAT_PERCENT:
+ eOffsetStart=NF_PERCENT_START;
+ eOffsetEnd=NF_PERCENT_END;
+ break;
+
+ case NUMBERFORMAT_CURRENCY:
+ eOffsetStart=NF_CURRENCY_START;
+ eOffsetEnd=NF_CURRENCY_END;
+ break;
+
+ case NUMBERFORMAT_DATETIME:
+ eOffsetStart=NF_DATE_START;
+ eOffsetEnd=NF_TIME_END;
+ break;
+
+ case NUMBERFORMAT_DATE:
+ eOffsetStart=NF_DATE_START;
+ eOffsetEnd=NF_DATE_END;
+ break;
+
+ case NUMBERFORMAT_TIME:
+ eOffsetStart=NF_TIME_START;
+ eOffsetEnd=NF_TIME_END;
+ break;
+
+ case NUMBERFORMAT_SCIENTIFIC:
+ eOffsetStart=NF_SCIENTIFIC_START;
+ eOffsetEnd=NF_SCIENTIFIC_END;
+ break;
+
+ case NUMBERFORMAT_FRACTION:
+ eOffsetStart=NF_FRACTION_START;
+ eOffsetEnd=NF_FRACTION_END;
+ break;
+
+ case NUMBERFORMAT_LOGICAL:
+ eOffsetStart=NF_BOOLEAN;
+ eOffsetEnd=NF_BOOLEAN;
+ break;
+
+ case NUMBERFORMAT_TEXT:
+ eOffsetStart=NF_TEXT;
+ eOffsetEnd=NF_TEXT;
+ break;
+
+ case NUMBERFORMAT_ALL:
+ eOffsetStart=NF_NUMERIC_START;
+ eOffsetEnd = NfIndexTableOffset( NF_INDEX_TABLE_ENTRIES - 1 );
+ break;
+
+ default:
+ OSL_FAIL("what a format?");
+ break;
+ }
+
+ const SvNumberformat* pFmt;
+ sal_uInt16 nPos, i = 0;
+ sal_uLong nFormat;
+ Color* pCol;
+ double fVal = GetDefValue( nFormatType );
+ OUString sValue;
+
+ sal_uLong nSysNumFmt = pFormatter->GetFormatIndex(
+ NF_NUMBER_SYSTEM, eCurLanguage );
+ sal_uLong nSysShortDateFmt = pFormatter->GetFormatIndex(
+ NF_DATE_SYSTEM_SHORT, eCurLanguage );
+ sal_uLong nSysLongDateFmt = pFormatter->GetFormatIndex(
+ NF_DATE_SYSTEM_LONG, eCurLanguage );
+
+ for( long nIndex = eOffsetStart; nIndex <= eOffsetEnd; ++nIndex )
+ {
+ nFormat = pFormatter->GetFormatIndex(
+ (NfIndexTableOffset)nIndex, eCurLanguage );
+ pFmt = pFormatter->GetEntry( nFormat );
+
+ if( nFormat == pFormatter->GetFormatIndex( NF_NUMBER_STANDARD,
+ eCurLanguage )
+ || ((SvNumberformat*)pFmt)->GetOutputString( fVal, sValue, &pCol )
+ || nFormatType == NUMBERFORMAT_UNDEFINED )
+ {
+ sValue = pFmt->GetFormatstring();
+ }
+ else if( nFormatType == NUMBERFORMAT_TEXT )
+ {
+ pFormatter->GetOutputString( "\"ABC\"", nFormat, sValue, &pCol);
+ }
+
+ if (nFormat != nSysNumFmt &&
+ nFormat != nSysShortDateFmt &&
+ nFormat != nSysLongDateFmt)
+ {
+ nPos = InsertEntry( sValue );
+ SetEntryData( nPos, (void*)nFormat );
+
+ if( nFormat == pFormatter->GetStandardFormat(
+ nFormatType, eCurLanguage ) )
+ nStdEntry = i;
+ ++i;
+ }
+ }
+
+ if (!pOwnFormatter)
+ {
+ nPos = InsertEntry(SW_RESSTR( STR_DEFINE_NUMBERFORMAT ));
+ SetEntryData( nPos, NULL );
+ }
+
+ SelectEntryPos( nStdEntry );
+
+ nCurrFormatType = nFormatType;
+ }
+}
+
+void NumFormatListBox::SetDefFormat(const sal_uLong nDefFmt)
+{
+ if (nDefFmt == ULONG_MAX)
+ {
+ nDefFormat = nDefFmt;
+ return;
+ }
+
+ SvNumberFormatter* pFormatter;
+ if (pOwnFormatter)
+ pFormatter = pOwnFormatter;
+ else
+ {
+ SwView *pView = GetView();
+ OSL_ENSURE(pView, "no view found");
+ if(!pView)
+ return;
+ SwWrtShell &rSh = pView->GetWrtShell();
+ pFormatter = rSh.GetNumberFormatter();
+ }
+
+ short nType = pFormatter->GetType(nDefFmt);
+
+ SetFormatType(nType);
+
+ sal_uLong nFormat = pFormatter->GetFormatForLanguageIfBuiltIn(nDefFmt, eCurLanguage);
+
+ for (sal_uInt16 i = 0; i < GetEntryCount(); i++)
+ {
+ if (nFormat == (sal_uLong)GetEntryData(i))
+ {
+ SelectEntryPos(i);
+ nStdEntry = i;
+ nDefFormat = GetFormat();
+ return;
+ }
+ }
+
+ // No entry found:
+ double fValue = GetDefValue(nType);
+ OUString sValue;
+ Color* pCol = 0;
+
+ if (nType == NUMBERFORMAT_TEXT)
+ {
+ pFormatter->GetOutputString("\"ABC\"", nDefFmt, sValue, &pCol);
+ }
+ else
+ {
+ pFormatter->GetOutputString(fValue, nDefFmt, sValue, &pCol);
+ }
+
+ sal_uInt16 nPos = 0;
+ while ((sal_uLong)GetEntryData(nPos) == ULONG_MAX)
+ nPos++;
+
+ sal_uLong nSysNumFmt = pFormatter->GetFormatIndex( NF_NUMBER_SYSTEM, eCurLanguage);
+ sal_uLong nSysShortDateFmt = pFormatter->GetFormatIndex( NF_DATE_SYSTEM_SHORT, eCurLanguage);
+ sal_uLong nSysLongDateFmt = pFormatter->GetFormatIndex( NF_DATE_SYSTEM_LONG, eCurLanguage);
+ bool bSysLang = false;
+ if( eCurLanguage == GetAppLanguage() )
+ bSysLang = true;
+ sal_uLong nNumFormatForLanguage = pFormatter->GetFormatForLanguageIfBuiltIn(nSysNumFmt, LANGUAGE_SYSTEM );
+ sal_uLong nShortDateFormatForLanguage = pFormatter->GetFormatForLanguageIfBuiltIn(nSysShortDateFmt, LANGUAGE_SYSTEM );
+ sal_uLong nLongDateFormatForLanguage = pFormatter->GetFormatForLanguageIfBuiltIn(nSysLongDateFmt, LANGUAGE_SYSTEM );
+
+ if (
+ nDefFmt == nSysNumFmt ||
+ nDefFmt == nSysShortDateFmt ||
+ nDefFmt == nSysLongDateFmt ||
+ (
+ bSysLang &&
+ (
+ nDefFmt == nNumFormatForLanguage ||
+ nDefFmt == nShortDateFormatForLanguage ||
+ nDefFmt == nLongDateFormatForLanguage
+ )
+ )
+ )
+ {
+ sValue += SW_RES(RID_STR_SYSTEM);
+ }
+
+ nPos = InsertEntry(sValue, nPos); // Insert as first numeric entry
+ SetEntryData(nPos, (void*)nDefFmt);
+ SelectEntryPos(nPos);
+ nDefFormat = GetFormat();
+}
+
+sal_uLong NumFormatListBox::GetFormat() const
+{
+ sal_uInt16 nPos = GetSelectEntryPos();
+
+ return (sal_uLong)GetEntryData(nPos);
+}
+
+IMPL_LINK( NumFormatListBox, SelectHdl, ListBox *, pBox )
+{
+ sal_uInt16 nPos = pBox->GetSelectEntryPos();
+ OUString sDefine(SW_RES( STR_DEFINE_NUMBERFORMAT ));
+ SwView *pView = GetView();
+
+ if( pView && nPos == pBox->GetEntryCount() - 1 &&
+ pBox->GetEntry( nPos ) == sDefine )
+ {
+ SwWrtShell &rSh = pView->GetWrtShell();
+ SvNumberFormatter* pFormatter = rSh.GetNumberFormatter();
+
+ SfxItemSet aCoreSet( rSh.GetAttrPool(),
+ SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_VALUE,
+ SID_ATTR_NUMBERFORMAT_INFO, SID_ATTR_NUMBERFORMAT_INFO,
+ SID_ATTR_NUMBERFORMAT_ONE_AREA, SID_ATTR_NUMBERFORMAT_ONE_AREA,
+ SID_ATTR_NUMBERFORMAT_NOLANGUAGE, SID_ATTR_NUMBERFORMAT_NOLANGUAGE,
+ SID_ATTR_NUMBERFORMAT_ADD_AUTO, SID_ATTR_NUMBERFORMAT_ADD_AUTO,
+ 0 );
+
+ double fValue = GetDefValue( nCurrFormatType);
+
+ sal_uLong nFormat = pFormatter->GetStandardFormat( nCurrFormatType, eCurLanguage);
+ aCoreSet.Put( SfxUInt32Item( SID_ATTR_NUMBERFORMAT_VALUE, nFormat ));
+
+ aCoreSet.Put( SvxNumberInfoItem( pFormatter, fValue,
+ SID_ATTR_NUMBERFORMAT_INFO ) );
+
+ if( (NUMBERFORMAT_DATE | NUMBERFORMAT_TIME) & nCurrFormatType )
+ aCoreSet.Put(SfxBoolItem(SID_ATTR_NUMBERFORMAT_ONE_AREA, bOneArea));
+
+ aCoreSet.Put(SfxBoolItem(SID_ATTR_NUMBERFORMAT_NOLANGUAGE, !bShowLanguageControl));
+ aCoreSet.Put(SfxBoolItem(SID_ATTR_NUMBERFORMAT_ADD_AUTO, bUseAutomaticLanguage));
+
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+
+ SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( this, aCoreSet,
+ GetView()->GetViewFrame()->GetFrame().GetFrameInterface(),
+ RC_DLG_SWNUMFMTDLG );
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+
+ if (RET_OK == pDlg->Execute())
+ {
+ const SfxPoolItem* pItem = pView->GetDocShell()->
+ GetItem( SID_ATTR_NUMBERFORMAT_INFO );
+
+ if( pItem && 0 != ((SvxNumberInfoItem*)pItem)->GetDelCount() )
+ {
+ const sal_uInt32* pDelArr = ((SvxNumberInfoItem*)pItem)->GetDelArray();
+
+ for ( sal_uInt16 i = 0; i < ((SvxNumberInfoItem*)pItem)->GetDelCount(); i++ )
+ pFormatter->DeleteEntry( pDelArr[i] );
+ }
+
+ const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
+ if( SFX_ITEM_SET == pOutSet->GetItemState(
+ SID_ATTR_NUMBERFORMAT_VALUE, false, &pItem ))
+ {
+ sal_uInt32 nNumberFormat = ((SfxUInt32Item*)pItem)->GetValue();
+ // oj #105473# change order of calls
+ const SvNumberformat* pFmt = pFormatter->GetEntry(nNumberFormat);
+ if( pFmt )
+ eCurLanguage = pFmt->GetLanguage();
+ // SetDefFormat uses eCurLanguage to look for if this format already in the list
+ SetDefFormat(nNumberFormat);
+ }
+ if( bShowLanguageControl && SFX_ITEM_SET == pOutSet->GetItemState(
+ SID_ATTR_NUMBERFORMAT_ADD_AUTO, false, &pItem ))
+ {
+ bUseAutomaticLanguage = ((const SfxBoolItem*)pItem)->GetValue();
+ }
+ }
+ else
+ SetDefFormat(nFormat);
+
+ delete pDlg;
+ }
+ return 0;
+}
+
+double NumFormatListBox::GetDefValue(const short nFormatType) const
+{
+ double fDefValue = 0.0;
+
+ switch (nFormatType)
+ {
+ case NUMBERFORMAT_DATE:
+ case NUMBERFORMAT_DATE|NUMBERFORMAT_TIME:
+ fDefValue = SVX_NUMVAL_DATE;
+ break;
+
+ case NUMBERFORMAT_TIME:
+ fDefValue = SVX_NUMVAL_TIME;
+ break;
+
+ case NUMBERFORMAT_TEXT:
+ case NUMBERFORMAT_UNDEFINED:
+ fDefValue = 0;
+ break;
+
+ case NUMBERFORMAT_CURRENCY:
+ fDefValue = SVX_NUMVAL_CURRENCY;
+ break;
+
+ case NUMBERFORMAT_PERCENT:
+ fDefValue = SVX_NUMVAL_PERCENT;
+ break;
+
+ case NUMBERFORMAT_LOGICAL:
+ fDefValue = SVX_NUMVAL_BOOLEAN;
+ break;
+
+ default:
+ fDefValue = SVX_NUMVAL_STANDARD;
+ break;
+ }
+
+ return fDefValue;
+}
+
+void NumFormatListBox::Clear()
+{
+ ListBox::Clear();
+ nCurrFormatType = -1;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/utlui/prcntfld.cxx b/sw/source/core/uibase/utlui/prcntfld.cxx
new file mode 100644
index 000000000000..cd4863753d10
--- /dev/null
+++ b/sw/source/core/uibase/utlui/prcntfld.cxx
@@ -0,0 +1,287 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "prcntfld.hxx"
+
+PercentField::PercentField()
+ : m_pField(NULL)
+ , nRefValue(0)
+ , nOldMax(0)
+ , nOldMin(0)
+ , nOldSpinSize(0)
+ , nOldBaseValue(0)
+ , nLastPercent(-1)
+ , nLastValue(-1)
+ , nOldDigits(0)
+ , eOldUnit(FUNIT_NONE)
+ , bLockAutoCalculation(false)
+{
+}
+
+void PercentField::set(MetricField *pField)
+{
+ m_pField = pField;
+ nOldSpinSize = m_pField->GetSpinSize();
+ nRefValue = DenormalizePercent(m_pField->GetMax(FUNIT_TWIP));
+ nOldDigits = m_pField->GetDecimalDigits();
+ m_pField->SetCustomUnitText(OUString('%'));
+}
+
+void PercentField::SetRefValue(sal_Int64 nValue)
+{
+ sal_Int64 nRealValue = GetRealValue(eOldUnit);
+
+ nRefValue = nValue;
+
+ if (!bLockAutoCalculation && (m_pField->GetUnit() == FUNIT_CUSTOM))
+ SetPrcntValue(nRealValue, eOldUnit);
+}
+
+void PercentField::ShowPercent(bool bPercent)
+{
+ if ((bPercent && m_pField->GetUnit() == FUNIT_CUSTOM) ||
+ (!bPercent && m_pField->GetUnit() != FUNIT_CUSTOM))
+ return;
+
+ sal_Int64 nOldValue;
+
+ if (bPercent)
+ {
+ sal_Int64 nAktWidth, nPercent;
+
+ nOldValue = GetValue();
+
+ eOldUnit = m_pField->GetUnit();
+ nOldDigits = m_pField->GetDecimalDigits();
+ nOldMin = m_pField->GetMin();
+ nOldMax = m_pField->GetMax();
+ nOldSpinSize = m_pField->GetSpinSize();
+ nOldBaseValue = m_pField->GetBaseValue();
+ m_pField->SetUnit(FUNIT_CUSTOM);
+ m_pField->SetDecimalDigits( 0 );
+
+ nAktWidth = m_pField->ConvertValue(nOldMin, 0, nOldDigits, eOldUnit, FUNIT_TWIP);
+ // round to 0.5 percent
+ nPercent = ((nAktWidth * 10) / nRefValue + 5) / 10;
+
+ m_pField->SetMin(std::max(static_cast< sal_Int64 >(1), nPercent));
+ m_pField->SetMax(100);
+ m_pField->SetSpinSize(5);
+ m_pField->SetBaseValue(0);
+ if (nOldValue != nLastValue)
+ {
+ nAktWidth = m_pField->ConvertValue(nOldValue, 0, nOldDigits, eOldUnit, FUNIT_TWIP);
+ nPercent = ((nAktWidth * 10) / nRefValue + 5) / 10;
+ m_pField->SetValue(nPercent);
+ nLastPercent = nPercent;
+ nLastValue = nOldValue;
+ }
+ else
+ m_pField->SetValue(nLastPercent);
+ }
+ else
+ {
+ sal_Int64 nOldPercent = GetValue(FUNIT_CUSTOM);
+
+ nOldValue = Convert(GetValue(), m_pField->GetUnit(), eOldUnit);
+
+ m_pField->SetUnit(eOldUnit);
+ m_pField->SetDecimalDigits(nOldDigits);
+ m_pField->SetMin(nOldMin);
+ m_pField->SetMax(nOldMax);
+ m_pField->SetSpinSize(nOldSpinSize);
+ m_pField->SetBaseValue(nOldBaseValue);
+
+ if (nOldPercent != nLastPercent)
+ {
+ SetPrcntValue(nOldValue, eOldUnit);
+ nLastPercent = nOldPercent;
+ nLastValue = nOldValue;
+ }
+ else
+ SetPrcntValue(nLastValue, eOldUnit);
+ }
+}
+
+void PercentField::SetPrcntValue(sal_Int64 nNewValue, FieldUnit eInUnit)
+{
+ if (m_pField->GetUnit() != FUNIT_CUSTOM || eInUnit == FUNIT_CUSTOM)
+ m_pField->SetValue(Convert(nNewValue, eInUnit, m_pField->GetUnit()));
+ else
+ {
+ // Overwrite output value, do not restore later
+ sal_Int64 nPercent, nAktWidth;
+ if(eInUnit == FUNIT_TWIP)
+ {
+ nAktWidth = m_pField->ConvertValue(nNewValue, 0, nOldDigits, FUNIT_TWIP, FUNIT_TWIP);
+ }
+ else
+ {
+ sal_Int64 nValue = Convert(nNewValue, eInUnit, eOldUnit);
+ nAktWidth = m_pField->ConvertValue(nValue, 0, nOldDigits, eOldUnit, FUNIT_TWIP);
+ }
+ nPercent = ((nAktWidth * 10) / nRefValue + 5) / 10;
+ m_pField->SetValue(nPercent);
+ }
+}
+
+void PercentField::SetBaseValue(sal_Int64 nNewValue, FieldUnit eInUnit)
+{
+ if (m_pField->GetUnit() == FUNIT_CUSTOM)
+ nOldBaseValue = m_pField->ConvertValue(nNewValue, 0, nOldDigits, eInUnit, eOldUnit);
+ else
+ m_pField->SetBaseValue(nNewValue, eInUnit);
+}
+
+sal_Int64 PercentField::GetValue(FieldUnit eOutUnit)
+{
+ return Convert(m_pField->GetValue(), m_pField->GetUnit(), eOutUnit);
+}
+
+void PercentField::SetMin(sal_Int64 nNewMin, FieldUnit eInUnit)
+{
+ if (m_pField->GetUnit() != FUNIT_CUSTOM)
+ m_pField->SetMin(nNewMin, eInUnit);
+ else
+ {
+ if (eInUnit == FUNIT_NONE)
+ eInUnit = eOldUnit;
+ nOldMin = Convert(nNewMin, eInUnit, eOldUnit);
+
+ sal_Int64 nPercent = Convert(nNewMin, eInUnit, FUNIT_CUSTOM);
+ m_pField->SetMin(std::max( static_cast< sal_Int64 >(1), nPercent));
+ }
+}
+
+void PercentField::SetMax(sal_Int64 nNewMax, FieldUnit eInUnit)
+{
+ if (m_pField->GetUnit() != FUNIT_CUSTOM)
+ m_pField->SetMax(nNewMax, eInUnit);
+ else
+ {
+ if (eInUnit == FUNIT_NONE)
+ eInUnit = eOldUnit;
+ }
+}
+
+sal_Int64 PercentField::NormalizePercent(sal_Int64 nValue)
+{
+ if (m_pField->GetUnit() != FUNIT_CUSTOM)
+ nValue = m_pField->Normalize(nValue);
+ else
+ nValue = nValue * ImpPower10(nOldDigits);
+ return nValue;
+}
+
+sal_Int64 PercentField::DenormalizePercent(sal_Int64 nValue)
+{
+ if (m_pField->GetUnit() != FUNIT_CUSTOM)
+ nValue = m_pField->Denormalize(nValue);
+ else
+ {
+ sal_Int64 nFactor = ImpPower10(nOldDigits);
+ nValue = ((nValue+(nFactor/2)) / nFactor);
+ }
+ return nValue;
+}
+
+bool PercentField::IsValueModified()
+{
+ if (m_pField->GetUnit() == FUNIT_CUSTOM)
+ return true;
+ else
+ return m_pField->IsValueModified();
+}
+
+void PercentField::SetUserValue(sal_Int64 nNewValue, FieldUnit eInUnit)
+{
+ if (m_pField->GetUnit() != FUNIT_CUSTOM || eInUnit == FUNIT_CUSTOM)
+ m_pField->SetUserValue(Convert(nNewValue, eInUnit, m_pField->GetUnit()),FUNIT_NONE);
+ else
+ {
+ // Overwrite output value, do not restore later
+ sal_Int64 nPercent, nAktWidth;
+ if (eInUnit == FUNIT_TWIP)
+ {
+ nAktWidth = m_pField->ConvertValue(nNewValue, 0, nOldDigits, FUNIT_TWIP, FUNIT_TWIP);
+ }
+ else
+ {
+ sal_Int64 nValue = Convert(nNewValue, eInUnit, eOldUnit);
+ nAktWidth = m_pField->ConvertValue(nValue, 0, nOldDigits, eOldUnit, FUNIT_TWIP);
+ }
+ nPercent = ((nAktWidth * 10) / nRefValue + 5) / 10;
+ m_pField->SetUserValue(nPercent,FUNIT_NONE);
+ }
+}
+
+sal_Int64 PercentField::ImpPower10(sal_uInt16 n)
+{
+ sal_Int64 nValue = 1;
+
+ for (sal_uInt16 i=0; i < n; ++i)
+ nValue *= 10;
+
+ return nValue;
+}
+
+sal_Int64 PercentField::GetRealValue(FieldUnit eOutUnit)
+{
+ if (m_pField->GetUnit() != FUNIT_CUSTOM)
+ return GetValue(eOutUnit);
+ else
+ return Convert(GetValue(), m_pField->GetUnit(), eOutUnit);
+}
+
+sal_Int64 PercentField::Convert(sal_Int64 nValue, FieldUnit eInUnit, FieldUnit eOutUnit)
+{
+ if (eInUnit == eOutUnit ||
+ (eInUnit == FUNIT_NONE && eOutUnit == m_pField->GetUnit()) ||
+ (eOutUnit == FUNIT_NONE && eInUnit == m_pField->GetUnit()))
+ return nValue;
+
+ if (eInUnit == FUNIT_CUSTOM)
+ {
+ // Convert to metric
+ sal_Int64 nTwipValue = (nRefValue * nValue + 50) / 100;
+
+ if (eOutUnit == FUNIT_TWIP) // Only convert if necessary
+ return NormalizePercent(nTwipValue);
+ else
+ return m_pField->ConvertValue(NormalizePercent(nTwipValue), 0, nOldDigits, FUNIT_TWIP, eOutUnit);
+ }
+
+ if (eOutUnit == FUNIT_CUSTOM)
+ {
+ // Convert to percent
+ sal_Int64 nAktWidth;
+ nValue = DenormalizePercent(nValue);
+
+ if (eInUnit == FUNIT_TWIP) // Only convert if necessary
+ nAktWidth = nValue;
+ else
+ nAktWidth = m_pField->ConvertValue(nValue, 0, nOldDigits, eInUnit, FUNIT_TWIP);
+ // Round to 0.5 percent
+ return ((nAktWidth * 1000) / nRefValue + 5) / 10;
+ }
+
+ return m_pField->ConvertValue(nValue, 0, nOldDigits, eInUnit, eOutUnit);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/utlui/shdwcrsr.cxx b/sw/source/core/uibase/utlui/shdwcrsr.cxx
new file mode 100644
index 000000000000..6e30e2ff21f5
--- /dev/null
+++ b/sw/source/core/uibase/utlui/shdwcrsr.cxx
@@ -0,0 +1,120 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <com/sun/star/text/HoriOrientation.hpp>
+#include <vcl/window.hxx>
+
+#include "swtypes.hxx"
+#include "shdwcrsr.hxx"
+
+using namespace ::com::sun::star;
+
+SwShadowCursor::~SwShadowCursor()
+{
+ if( USHRT_MAX != nOldMode )
+ DrawCrsr( aOldPt, nOldHeight, nOldMode );
+}
+
+void SwShadowCursor::SetPos( const Point& rPt, long nHeight, sal_uInt16 nMode )
+{
+ Point aPt( pWin->LogicToPixel( rPt ));
+ nHeight = pWin->LogicToPixel( Size( 0, nHeight )).Height();
+ if( aOldPt != aPt || nOldHeight != nHeight || nOldMode != nMode )
+ {
+ if( USHRT_MAX != nOldMode )
+ DrawCrsr( aOldPt, nOldHeight, nOldMode );
+
+ DrawCrsr( aPt, nHeight, nMode );
+ nOldMode = nMode;
+ nOldHeight = nHeight;
+ aOldPt = aPt;
+ }
+}
+
+void SwShadowCursor::DrawTri( const Point& rPt, long nHeight, bool bLeft )
+{
+ long nLineDiff = ( nHeight / 2 );
+ long nLineDiffHalf = nLineDiff / 2;
+
+ // Dot above
+ Point aPt1( (bLeft ? rPt.X() - 3 : rPt.X() + 3),
+ rPt.Y() + nLineDiffHalf );
+ // Dot below
+ Point aPt2( aPt1.X(), aPt1.Y() + nHeight - nLineDiff - 1 );
+ long nDiff = bLeft ? -1 : 1;
+ while( aPt1.Y() <= aPt2.Y() )
+ {
+ pWin->DrawLine( aPt1, aPt2 );
+ aPt1.Y()++, aPt2.Y()--;
+ aPt2.X() = aPt1.X() += nDiff;
+ }
+}
+
+void SwShadowCursor::DrawCrsr( const Point& rPt, long nHeight, sal_uInt16 nMode )
+{
+ nHeight = (((nHeight / 4)+1) * 4) + 1;
+
+ pWin->Push();
+
+ pWin->SetMapMode( MAP_PIXEL );
+ pWin->SetRasterOp( ROP_XOR );
+
+ pWin->SetLineColor( Color( aCol.GetColor() ^ COL_WHITE ) );
+
+ // 1. The Line:
+ pWin->DrawLine( Point( rPt.X(), rPt.Y() + 1),
+ Point( rPt.X(), rPt.Y() - 2 + nHeight ));
+
+ // 2. The Triangle
+ if( text::HoriOrientation::LEFT == nMode || text::HoriOrientation::CENTER == nMode ) // Arrow to the right
+ DrawTri( rPt, nHeight, false );
+ if( text::HoriOrientation::RIGHT == nMode || text::HoriOrientation::CENTER == nMode ) // Arrow to the left
+ DrawTri( rPt, nHeight, true );
+
+ pWin->Pop();
+}
+
+void SwShadowCursor::Paint()
+{
+ if( USHRT_MAX != nOldMode )
+ DrawCrsr( aOldPt, nOldHeight, nOldMode );
+}
+
+Rectangle SwShadowCursor::GetRect() const
+{
+ long nH = nOldHeight;
+ Point aPt( aOldPt );
+
+ nH = (((nH / 4)+1) * 4) + 1;
+ long nWidth = nH / 4 + 3 + 1;
+
+ Size aSz( nWidth, nH );
+
+ if( text::HoriOrientation::RIGHT == nOldMode )
+ aPt.X() -= aSz.Width();
+ else if( text::HoriOrientation::CENTER == nOldMode )
+ {
+ aPt.X() -= aSz.Width();
+ aSz.Width() *= 2;
+ }
+
+ return pWin->PixelToLogic( Rectangle( aPt, aSz ) );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/utlui/tmplctrl.cxx b/sw/source/core/uibase/utlui/tmplctrl.cxx
new file mode 100644
index 000000000000..a4a59ffc5370
--- /dev/null
+++ b/sw/source/core/uibase/utlui/tmplctrl.cxx
@@ -0,0 +1,137 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <svl/style.hxx>
+#include <vcl/menu.hxx>
+#include <svl/stritem.hxx>
+#include <sfx2/dispatch.hxx>
+#include <vcl/status.hxx>
+
+#include "wrtsh.hxx"
+#include "view.hxx"
+#include "swmodule.hxx"
+#include "cmdid.h"
+#include "docsh.hxx"
+#include "tmplctrl.hxx"
+
+SFX_IMPL_STATUSBAR_CONTROL( SwTemplateControl, SfxStringItem );
+
+class SwTemplatePopup_Impl : public PopupMenu
+{
+public:
+ SwTemplatePopup_Impl();
+
+ sal_uInt16 GetCurId() const { return nCurId; }
+
+private:
+ sal_uInt16 nCurId;
+
+ virtual void Select();
+};
+
+SwTemplatePopup_Impl::SwTemplatePopup_Impl() :
+ PopupMenu(),
+ nCurId(USHRT_MAX)
+{
+}
+
+void SwTemplatePopup_Impl::Select()
+{
+ nCurId = GetCurItemId();
+}
+
+// class SvxZoomStatusBarControl
+
+SwTemplateControl::SwTemplateControl( sal_uInt16 _nSlotId,
+ sal_uInt16 _nId,
+ StatusBar& rStb ) :
+ SfxStatusBarControl( _nSlotId, _nId, rStb )
+{
+}
+
+SwTemplateControl::~SwTemplateControl()
+{
+}
+
+void SwTemplateControl::StateChanged(
+ sal_uInt16 /*nSID*/, SfxItemState eState, const SfxPoolItem* pState )
+{
+ if( eState != SFX_ITEM_AVAILABLE || pState->ISA( SfxVoidItem ) )
+ GetStatusBar().SetItemText( GetId(), OUString() );
+ else if ( pState->ISA( SfxStringItem ) )
+ {
+ sTemplate = ((SfxStringItem*)pState)->GetValue();
+ GetStatusBar().SetItemText( GetId(), sTemplate );
+ }
+}
+
+void SwTemplateControl::Paint( const UserDrawEvent& )
+{
+ GetStatusBar().SetItemText( GetId(), sTemplate );
+}
+
+void SwTemplateControl::Command( const CommandEvent& rCEvt )
+{
+ if ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU &&
+ !GetStatusBar().GetItemText( GetId() ).isEmpty() )
+ {
+ CaptureMouse();
+ SwTemplatePopup_Impl aPop;
+ {
+ SwView* pView = ::GetActiveView();
+ SwWrtShell* pWrtShell;
+ if( pView && 0 != (pWrtShell = pView->GetWrtShellPtr()) &&
+ !pWrtShell->SwCrsrShell::HasSelection()&&
+ !pWrtShell->IsSelFrmMode() &&
+ !pWrtShell->IsObjSelected())
+ {
+ SfxStyleSheetBasePool* pPool = pView->GetDocShell()->
+ GetStyleSheetPool();
+ pPool->SetSearchMask(SFX_STYLE_FAMILY_PAGE, SFXSTYLEBIT_ALL);
+ if( pPool->Count() > 1 )
+ {
+ sal_uInt16 nCount = 0;
+ SfxStyleSheetBase* pStyle = pPool->First();
+ while( pStyle )
+ {
+ nCount++;
+ aPop.InsertItem( nCount, pStyle->GetName() );
+ pStyle = pPool->Next();
+ }
+
+ aPop.Execute( &GetStatusBar(), rCEvt.GetMousePosPixel());
+ sal_uInt16 nCurrId = aPop.GetCurId();
+ if( nCurrId != USHRT_MAX)
+ {
+ // looks a bit awkward, but another way is not possible
+ pStyle = pPool->operator[]( nCurrId - 1 );
+ SfxStringItem aStyle( FN_SET_PAGE_STYLE, pStyle->GetName() );
+ pWrtShell->GetView().GetViewFrame()->GetDispatcher()->Execute(
+ FN_SET_PAGE_STYLE,
+ SFX_CALLMODE_SLOT|SFX_CALLMODE_RECORD,
+ &aStyle, 0L );
+ }
+ }
+ }
+ }
+ ReleaseMouse();
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/utlui/uiitems.cxx b/sw/source/core/uibase/utlui/uiitems.cxx
new file mode 100644
index 000000000000..a3dc8d4b2b3c
--- /dev/null
+++ b/sw/source/core/uibase/utlui/uiitems.cxx
@@ -0,0 +1,317 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <editeng/itemtype.hxx>
+#include <unosett.hxx>
+
+#include "swtypes.hxx"
+#include "cmdid.h"
+#include "uiitems.hxx"
+
+#include "utlui.hrc"
+#include "attrdesc.hrc"
+#include <unomid.h>
+#include <numrule.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+SwPageFtnInfoItem::SwPageFtnInfoItem( const sal_uInt16 nId, SwPageFtnInfo& rInfo) :
+ SfxPoolItem( nId ),
+ aFtnInfo(rInfo)
+{
+}
+
+SwPageFtnInfoItem::SwPageFtnInfoItem( const SwPageFtnInfoItem& rItem ) :
+ SfxPoolItem( rItem ),
+ aFtnInfo(rItem.GetPageFtnInfo())
+{
+}
+
+ SwPageFtnInfoItem::~SwPageFtnInfoItem()
+{
+}
+
+SfxPoolItem* SwPageFtnInfoItem::Clone( SfxItemPool * /*pPool*/ ) const
+{
+ return new SwPageFtnInfoItem( *this );
+}
+
+bool SwPageFtnInfoItem::operator==( const SfxPoolItem& rAttr ) const
+{
+ OSL_ENSURE( Which() == rAttr.Which(), "no equal attributes" );
+ return ( aFtnInfo == ((SwPageFtnInfoItem&)rAttr).GetPageFtnInfo());
+}
+
+SfxItemPresentation SwPageFtnInfoItem::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit eCoreUnit,
+ SfxMapUnit ePresUnit,
+ OUString& rText,
+ const IntlWrapper* pIntl
+) const
+{
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ rText = OUString();
+ return SFX_ITEM_PRESENTATION_NONE;
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ {
+ sal_uInt16 nHght = (sal_uInt16) GetPageFtnInfo().GetHeight();
+ if ( nHght )
+ {
+ rText = SW_RESSTR( STR_MAX_FTN_HEIGHT ) + " " +
+ ::GetMetricText( nHght, eCoreUnit, ePresUnit, pIntl ) + " " +
+ ::GetSvxString( ::GetMetricId( ePresUnit ) );
+ }
+ return ePres;
+ }
+ default:; //prevent warning
+ }
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+bool SwPageFtnInfoItem::QueryValue( Any& rVal, sal_uInt8 nMemberId ) const
+{
+ bool bRet = true;
+ switch(nMemberId & ~CONVERT_TWIPS)
+ {
+ case MID_FTN_HEIGHT : rVal <<= (sal_Int32)TWIP_TO_MM100(aFtnInfo.GetHeight());break;
+ case MID_LINE_WEIGHT : rVal <<= (sal_Int16)TWIP_TO_MM100_UNSIGNED(aFtnInfo.GetLineWidth());break;
+ case MID_LINE_COLOR : rVal <<= (sal_Int32)aFtnInfo.GetLineColor().GetColor();break;
+ case MID_LINE_RELWIDTH :
+ {
+ Fraction aTmp( 100, 1 );
+ aTmp *= aFtnInfo.GetWidth();
+ rVal <<= (sal_Int8)(long)aTmp;
+ }
+ break;
+ case MID_LINE_ADJUST : rVal <<= (sal_Int16)aFtnInfo.GetAdj();break;//text::HorizontalAdjust
+ case MID_LINE_TEXT_DIST : rVal <<= (sal_Int32)TWIP_TO_MM100(aFtnInfo.GetTopDist());break;
+ case MID_LINE_FOOTNOTE_DIST: rVal <<= (sal_Int32)TWIP_TO_MM100(aFtnInfo.GetBottomDist());break;
+ case MID_FTN_LINE_STYLE :
+ {
+ switch ( aFtnInfo.GetLineStyle( ) )
+ {
+ default:
+ case table::BorderLineStyle::NONE : rVal <<= sal_Int8(0); break;
+ case table::BorderLineStyle::SOLID: rVal <<= sal_Int8(1); break;
+ case table::BorderLineStyle::DOTTED: rVal <<= sal_Int8(2); break;
+ case table::BorderLineStyle::DASHED: rVal <<= sal_Int8(3); break;
+ }
+ break;
+ }
+ default:
+ bRet = false;
+ }
+ return bRet;
+}
+
+bool SwPageFtnInfoItem::PutValue(const Any& rVal, sal_uInt8 nMemberId)
+{
+ sal_Int32 nSet32 = 0;
+ bool bRet = true;
+ switch(nMemberId & ~CONVERT_TWIPS)
+ {
+ case MID_LINE_COLOR :
+ rVal >>= nSet32;
+ aFtnInfo.SetLineColor(nSet32);
+ break;
+ case MID_FTN_HEIGHT:
+ case MID_LINE_TEXT_DIST :
+ case MID_LINE_FOOTNOTE_DIST:
+ rVal >>= nSet32;
+ if(nSet32 < 0)
+ bRet = false;
+ else
+ {
+ nSet32 = MM100_TO_TWIP(nSet32);
+ switch(nMemberId & ~CONVERT_TWIPS)
+ {
+ case MID_FTN_HEIGHT: aFtnInfo.SetHeight(nSet32); break;
+ case MID_LINE_TEXT_DIST: aFtnInfo.SetTopDist(nSet32);break;
+ case MID_LINE_FOOTNOTE_DIST: aFtnInfo.SetBottomDist(nSet32);break;
+ }
+ }
+ break;
+ case MID_LINE_WEIGHT :
+ {
+ sal_Int16 nSet = 0;
+ rVal >>= nSet;
+ if(nSet >= 0)
+ aFtnInfo.SetLineWidth(MM100_TO_TWIP(nSet));
+ else
+ bRet = false;
+ }
+ break;
+ case MID_LINE_RELWIDTH :
+ {
+ sal_Int8 nSet = 0;
+ rVal >>= nSet;
+ if(nSet < 0)
+ bRet = false;
+ else
+ aFtnInfo.SetWidth(Fraction(nSet, 100));
+ }
+ break;
+ case MID_LINE_ADJUST :
+ {
+ sal_Int16 nSet = 0;
+ rVal >>= nSet;
+ if(nSet >= 0 && nSet < 3) //text::HorizontalAdjust
+ aFtnInfo.SetAdj((SwFtnAdj)nSet);
+ else
+ bRet = false;
+ }
+ case MID_FTN_LINE_STYLE:
+ {
+ ::editeng::SvxBorderStyle eStyle = table::BorderLineStyle::NONE;
+ sal_Int8 nSet = 0;
+ rVal >>= nSet;
+ switch ( nSet )
+ {
+ case 1: eStyle = table::BorderLineStyle::SOLID; break;
+ case 2: eStyle = table::BorderLineStyle::DOTTED; break;
+ case 3: eStyle = table::BorderLineStyle::DASHED; break;
+ default: break;
+ }
+ aFtnInfo.SetLineStyle( eStyle );
+ }
+ break;
+ default:
+ bRet = false;
+ }
+ return bRet;
+}
+
+SwPtrItem::SwPtrItem( const sal_uInt16 nId, void* pPtr ) :
+ SfxPoolItem( nId ),
+ pMisc(pPtr)
+{
+}
+
+// Copy constructor
+
+SwPtrItem::SwPtrItem( const SwPtrItem& rItem ) : SfxPoolItem( rItem )
+{
+ pMisc = rItem.pMisc;
+}
+
+// Cloning
+
+SfxPoolItem* SwPtrItem::Clone( SfxItemPool * /*pPool*/ ) const
+{
+ return new SwPtrItem( *this );
+}
+
+bool SwPtrItem::operator==( const SfxPoolItem& rAttr ) const
+{
+ OSL_ENSURE( SfxPoolItem::operator==(rAttr), "unequal types" );
+ const SwPtrItem& rItem = (SwPtrItem&)rAttr;
+ return ( pMisc == rItem.pMisc );
+}
+
+// SwUINumRuleItem for the NumTabPages of the FormatNumRule/Styleists
+
+SwUINumRuleItem::SwUINumRuleItem( const SwNumRule& rRul, const sal_uInt16 nId )
+ : SfxPoolItem( nId ), pRule( new SwNumRule( rRul ) )
+{
+}
+
+SwUINumRuleItem::SwUINumRuleItem( const SwUINumRuleItem& rItem )
+ : SfxPoolItem( rItem ),
+ pRule( new SwNumRule( *rItem.pRule ))
+{
+}
+
+ SwUINumRuleItem::~SwUINumRuleItem()
+{
+ delete pRule;
+}
+
+SfxPoolItem* SwUINumRuleItem::Clone( SfxItemPool * /*pPool*/ ) const
+{
+ return new SwUINumRuleItem( *this );
+}
+
+bool SwUINumRuleItem::operator==( const SfxPoolItem& rAttr ) const
+{
+ OSL_ENSURE( SfxPoolItem::operator==(rAttr), "unequal types" );
+ return *pRule == *((SwUINumRuleItem&)rAttr).pRule;
+}
+
+bool SwUINumRuleItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
+{
+ uno::Reference< container::XIndexReplace >xRules = new SwXNumberingRules(*pRule);
+ rVal.setValue(&xRules, ::getCppuType((uno::Reference< container::XIndexReplace>*)0));
+ return true;
+}
+bool SwUINumRuleItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
+{
+ uno::Reference< container::XIndexReplace> xRulesRef;
+ if(rVal >>= xRulesRef)
+ {
+ uno::Reference< lang::XUnoTunnel > xTunnel(xRulesRef, uno::UNO_QUERY);
+ SwXNumberingRules* pSwXRules = xTunnel.is() ? reinterpret_cast<SwXNumberingRules*>(
+ xTunnel->getSomething(SwXNumberingRules::getUnoTunnelId())) : 0;
+ if(pSwXRules)
+ {
+ *pRule = *pSwXRules->GetNumRule();
+ }
+ }
+ return true;
+}
+
+SwBackgroundDestinationItem::SwBackgroundDestinationItem(sal_uInt16 _nWhich, sal_uInt16 nValue) :
+ SfxUInt16Item(_nWhich, nValue)
+{
+}
+
+SfxPoolItem* SwBackgroundDestinationItem::Clone( SfxItemPool * /*pPool*/ ) const
+{
+ return new SwBackgroundDestinationItem(Which(), GetValue());
+}
+
+SwPaMItem::SwPaMItem( const sal_uInt16 nId, SwPaM* pPaM ) :
+ SfxPoolItem( nId ),
+ m_pPaM(pPaM)
+{
+}
+
+SwPaMItem::SwPaMItem( const SwPaMItem& rItem ) : SfxPoolItem( rItem )
+{
+ m_pPaM = rItem.m_pPaM;
+}
+
+SfxPoolItem* SwPaMItem::Clone( SfxItemPool * /*pPool*/ ) const
+{
+ return new SwPaMItem( *this );
+}
+
+bool SwPaMItem::operator==( const SfxPoolItem& rAttr ) const
+{
+ OSL_ENSURE( SfxPoolItem::operator==(rAttr), "unequal types" );
+ const SwPaMItem& rItem = (SwPaMItem&)rAttr;
+ return ( m_pPaM == rItem.m_pPaM );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/utlui/uitool.cxx b/sw/source/core/uibase/utlui/uitool.cxx
new file mode 100644
index 000000000000..206b86451a63
--- /dev/null
+++ b/sw/source/core/uibase/utlui/uitool.cxx
@@ -0,0 +1,818 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <hintids.hxx>
+
+#include <osl/diagnose.h>
+#include <tools/datetime.hxx>
+#include <vcl/svapp.hxx>
+#include <unotools/collatorwrapper.hxx>
+#include <svl/urihelper.hxx>
+#include <svl/stritem.hxx>
+#include <unotools/syslocale.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/docfilt.hxx>
+#include <editeng/pmdlitem.hxx>
+#include <editeng/tstpitem.hxx>
+#include <editeng/boxitem.hxx>
+#include <editeng/shaditem.hxx>
+#include <editeng/sizeitem.hxx>
+#include <editeng/brushitem.hxx>
+#include <svx/pageitem.hxx>
+#include <editeng/lrspitem.hxx>
+#include <svl/style.hxx>
+#include <vcl/lstbox.hxx>
+#include <unotools/localedatawrapper.hxx>
+#include <com/sun/star/frame/XDispatch.hpp>
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#include <com/sun/star/util/URLTransformer.hpp>
+#include <com/sun/star/util/XURLTransformer.hpp>
+#include <comphelper/processfactory.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <fmtornt.hxx>
+#include <tabcol.hxx>
+#include <edtwin.hxx>
+#include <fmtfsize.hxx>
+#include <fmthdft.hxx>
+#include <fmtpdsc.hxx>
+#include <wview.hxx>
+#include <uiitems.hxx>
+#include <docsh.hxx>
+#include <wrtsh.hxx>
+#include <swmodule.hxx>
+#include <view.hxx>
+#include <uitool.hxx>
+#include <frmatr.hxx>
+#include <paratr.hxx>
+#include <fmtcol.hxx>
+#include <poolfmt.hxx>
+#include "usrpref.hxx"
+
+#include <cmdid.h>
+#include <globals.hrc>
+#include <utlui.hrc>
+#include <doc.hxx>
+#include <docary.hxx>
+#include <charfmt.hxx>
+#include <SwStyleNameMapper.hxx>
+// 50 cm 28350
+
+#define MAXHEIGHT 28350
+#define MAXWIDTH 28350
+
+using namespace ::com::sun::star;
+
+// General list of string pointer
+
+// Switch metric
+
+void SetMetric(MetricFormatter& rCtrl, FieldUnit eUnit)
+{
+ SwTwips nMin = static_cast< SwTwips >(rCtrl.GetMin(FUNIT_TWIP));
+ SwTwips nMax = static_cast< SwTwips >(rCtrl.GetMax(FUNIT_TWIP));
+
+ rCtrl.SetUnit(eUnit);
+
+ rCtrl.SetMin(nMin, FUNIT_TWIP);
+ rCtrl.SetMax(nMax, FUNIT_TWIP);
+}
+
+// Set boxinfo attribute
+
+void PrepareBoxInfo(SfxItemSet& rSet, const SwWrtShell& rSh)
+{
+ SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
+ const SfxPoolItem *pBoxInfo;
+ if ( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_BORDER_INNER,
+ true, &pBoxInfo))
+ aBoxInfo = *(SvxBoxInfoItem*)pBoxInfo;
+
+ // Table variant: If more than one table cells are selected
+ rSh.GetCrsr(); //So that GetCrsrCnt() returns the right thing
+ aBoxInfo.SetTable (rSh.IsTableMode() && rSh.GetCrsrCnt() > 1);
+ // Always show the distance field
+ aBoxInfo.SetDist (true);
+ // Set minimal size in tables and paragraphs
+ aBoxInfo.SetMinDist (rSh.IsTableMode() || rSh.GetSelectionType() & (nsSelectionType::SEL_TXT | nsSelectionType::SEL_TBL));
+ // Set always the default distance
+ aBoxInfo.SetDefDist (MIN_BORDER_DIST);
+ // Single lines can have only in tables DontCare-Status
+ aBoxInfo.SetValid(VALID_DISABLE, !rSh.IsTableMode());
+
+ rSet.Put(aBoxInfo);
+}
+
+void ConvertAttrCharToGen(SfxItemSet& rSet, const sal_uInt8 nMode)
+{
+ // Background
+ {
+ const SfxPoolItem *pTmpBrush;
+ if( SFX_ITEM_SET == rSet.GetItemState( RES_CHRATR_BACKGROUND, true, &pTmpBrush ) )
+ {
+ SvxBrushItem aTmpBrush( *((SvxBrushItem*)pTmpBrush) );
+ aTmpBrush.SetWhich( RES_BACKGROUND );
+ rSet.Put( aTmpBrush );
+ }
+ else
+ rSet.ClearItem(RES_BACKGROUND);
+ }
+
+ if( nMode == CONV_ATTR_STD )
+ {
+ // Border
+ const SfxPoolItem *pTmpItem;
+ if( SFX_ITEM_SET == rSet.GetItemState( RES_CHRATR_BOX, true, &pTmpItem ) )
+ {
+ SvxBoxItem aTmpBox( *((SvxBoxItem*)pTmpItem) );
+ aTmpBox.SetWhich( RES_BOX );
+ rSet.Put( aTmpBox );
+ }
+ else
+ rSet.ClearItem(RES_BOX);
+
+ // Border shadow
+ if( SFX_ITEM_SET == rSet.GetItemState( RES_CHRATR_SHADOW, false, &pTmpItem ) )
+ {
+ SvxShadowItem aTmpShadow( *((SvxShadowItem*)pTmpItem) );
+ aTmpShadow.SetWhich( RES_SHADOW );
+ rSet.Put( aTmpShadow );
+ }
+ else
+ rSet.ClearItem( RES_SHADOW );
+ }
+}
+
+void ConvertAttrGenToChar(SfxItemSet& rSet, const sal_uInt8 nMode)
+{
+ // Background
+ {
+ const SfxPoolItem *pTmpBrush;
+ if( SFX_ITEM_SET == rSet.GetItemState( RES_BACKGROUND, false, &pTmpBrush ) )
+ {
+ SvxBrushItem aTmpBrush( *((SvxBrushItem*)pTmpBrush) );
+ aTmpBrush.SetWhich( RES_CHRATR_BACKGROUND );
+ rSet.Put( aTmpBrush );
+ }
+ rSet.ClearItem( RES_BACKGROUND );
+ }
+
+ if( nMode == CONV_ATTR_STD )
+ {
+ // Border
+ const SfxPoolItem *pTmpItem;
+ if( SFX_ITEM_SET == rSet.GetItemState( RES_BOX, false, &pTmpItem ) )
+ {
+ SvxBoxItem aTmpBox( *((SvxBoxItem*)pTmpItem) );
+ aTmpBox.SetWhich( RES_CHRATR_BOX );
+ rSet.Put( aTmpBox );
+ }
+ rSet.ClearItem( RES_BOX );
+
+ // Border shadow
+ if( SFX_ITEM_SET == rSet.GetItemState( RES_SHADOW, false, &pTmpItem ) )
+ {
+ SvxShadowItem aTmpShadow( *((SvxShadowItem*)pTmpItem) );
+ aTmpShadow.SetWhich( RES_CHRATR_SHADOW );
+ rSet.Put( aTmpShadow );
+ }
+ rSet.ClearItem( RES_SHADOW );
+ }
+}
+
+// Fill header footer
+
+void FillHdFt(SwFrmFmt* pFmt, const SfxItemSet& rSet)
+{
+ SwAttrSet aSet(pFmt->GetAttrSet());
+ aSet.Put(rSet);
+
+ const SvxSizeItem& rSize = (const SvxSizeItem&)rSet.Get(SID_ATTR_PAGE_SIZE);
+ const SfxBoolItem& rDynamic = (const SfxBoolItem&)rSet.Get(SID_ATTR_PAGE_DYNAMIC);
+
+ // Convert size
+ SwFmtFrmSize aFrmSize(rDynamic.GetValue() ? ATT_MIN_SIZE : ATT_FIX_SIZE,
+ rSize.GetSize().Width(),
+ rSize.GetSize().Height());
+ aSet.Put(aFrmSize);
+ pFmt->SetFmtAttr(aSet);
+}
+
+/// Convert from UseOnPage to SvxPageUsage.
+UseOnPage lcl_convertUseToSvx(UseOnPage nUse)
+{
+ UseOnPage nRet = nsUseOnPage::PD_NONE;
+ if ((nUse & nsUseOnPage::PD_LEFT) == nsUseOnPage::PD_LEFT)
+ nRet |= SVX_PAGE_LEFT;
+ if ((nUse & nsUseOnPage::PD_RIGHT) == nsUseOnPage::PD_RIGHT)
+ nRet |= SVX_PAGE_RIGHT;
+ if ((nUse & nsUseOnPage::PD_ALL) == nsUseOnPage::PD_ALL)
+ nRet |= SVX_PAGE_ALL;
+ if ((nUse & nsUseOnPage::PD_MIRROR) == nsUseOnPage::PD_MIRROR)
+ nRet |= SVX_PAGE_MIRROR;
+ return nRet;
+}
+
+/// Convert from SvxPageUsage to UseOnPage.
+UseOnPage lcl_convertUseFromSvx(UseOnPage nUse)
+{
+ UseOnPage nRet = nsUseOnPage::PD_NONE;
+ if ((nUse & SVX_PAGE_LEFT) == SVX_PAGE_LEFT)
+ nRet |= nsUseOnPage::PD_LEFT;
+ if ((nUse & SVX_PAGE_RIGHT) == SVX_PAGE_RIGHT)
+ nRet |= nsUseOnPage::PD_RIGHT;
+ if ((nUse & SVX_PAGE_ALL) == SVX_PAGE_ALL)
+ nRet |= nsUseOnPage::PD_ALL;
+ if ((nUse & SVX_PAGE_MIRROR) == SVX_PAGE_MIRROR)
+ nRet |= nsUseOnPage::PD_MIRROR;
+ return nRet;
+}
+
+// PageDesc <-> convert into sets and back
+
+void ItemSetToPageDesc( const SfxItemSet& rSet, SwPageDesc& rPageDesc )
+{
+ SwFrmFmt& rMaster = rPageDesc.GetMaster();
+ int nFirstShare = -1;
+
+ // Transfer all general frame attributes
+ rMaster.SetFmtAttr(rSet);
+
+ // PageData
+ if(rSet.GetItemState(SID_ATTR_PAGE) == SFX_ITEM_SET)
+ {
+ const SvxPageItem& rPageItem = (const SvxPageItem&)rSet.Get(SID_ATTR_PAGE);
+
+ sal_uInt16 nUse = (sal_uInt16)rPageItem.GetPageUsage();
+ if(nUse)
+ rPageDesc.SetUseOn( lcl_convertUseFromSvx((UseOnPage) nUse) );
+ rPageDesc.SetLandscape(rPageItem.IsLandscape());
+ SvxNumberType aNumType;
+ aNumType.SetNumberingType( static_cast< sal_Int16 >(rPageItem.GetNumType()) );
+ rPageDesc.SetNumType(aNumType);
+ }
+ // Size
+ if(rSet.GetItemState(SID_ATTR_PAGE_SIZE) == SFX_ITEM_SET)
+ {
+ const SvxSizeItem& rSizeItem = (const SvxSizeItem&)rSet.Get(SID_ATTR_PAGE_SIZE);
+ SwFmtFrmSize aSize(ATT_FIX_SIZE);
+ aSize.SetSize(rSizeItem.GetSize());
+ rMaster.SetFmtAttr(aSize);
+ }
+ // Evaluate header attributes
+ const SfxPoolItem* pItem;
+ if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_PAGE_HEADERSET,
+ false, &pItem ) )
+ {
+ const SfxItemSet& rHeaderSet = ((SvxSetItem*)pItem)->GetItemSet();
+ const SfxBoolItem& rHeaderOn = (const SfxBoolItem&)rHeaderSet.Get(SID_ATTR_PAGE_ON);
+
+ if(rHeaderOn.GetValue())
+ {
+ // Take over values
+ if(!rMaster.GetHeader().IsActive())
+ rMaster.SetFmtAttr(SwFmtHeader(sal_True));
+
+ // Pick out everything and adapt the header format
+ SwFmtHeader aHeaderFmt(rMaster.GetHeader());
+ SwFrmFmt *pHeaderFmt = aHeaderFmt.GetHeaderFmt();
+ OSL_ENSURE(pHeaderFmt != 0, "no header format");
+
+ ::FillHdFt(pHeaderFmt, rHeaderSet);
+
+ rPageDesc.ChgHeaderShare(((const SfxBoolItem&)
+ rHeaderSet.Get(SID_ATTR_PAGE_SHARED)).GetValue());
+ if (nFirstShare < 0)
+ {
+ rPageDesc.ChgFirstShare(((const SfxBoolItem&)
+ rHeaderSet.Get(SID_ATTR_PAGE_SHARED_FIRST)).GetValue());
+ nFirstShare = rPageDesc.IsFirstShared();
+ }
+ }
+ else
+ {
+ // Disable header
+ if(rMaster.GetHeader().IsActive())
+ {
+ rMaster.SetFmtAttr(SwFmtHeader(sal_Bool(sal_False)));
+ rPageDesc.ChgHeaderShare(sal_False);
+ }
+ }
+ }
+
+ // Evaluate footer attributes
+ if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_PAGE_FOOTERSET,
+ false, &pItem ) )
+ {
+ const SfxItemSet& rFooterSet = ((SvxSetItem*)pItem)->GetItemSet();
+ const SfxBoolItem& rFooterOn = (const SfxBoolItem&)rFooterSet.Get(SID_ATTR_PAGE_ON);
+
+ if(rFooterOn.GetValue())
+ {
+ // Take over values
+ if(!rMaster.GetFooter().IsActive())
+ rMaster.SetFmtAttr(SwFmtFooter(sal_True));
+
+ // Pick out everything and adapt the footer format
+ SwFmtFooter aFooterFmt(rMaster.GetFooter());
+ SwFrmFmt *pFooterFmt = aFooterFmt.GetFooterFmt();
+ OSL_ENSURE(pFooterFmt != 0, "no footer format");
+
+ ::FillHdFt(pFooterFmt, rFooterSet);
+
+ rPageDesc.ChgFooterShare(((const SfxBoolItem&)
+ rFooterSet.Get(SID_ATTR_PAGE_SHARED)).GetValue());
+ if (nFirstShare < 0)
+ {
+ rPageDesc.ChgFirstShare(((const SfxBoolItem&)
+ rFooterSet.Get(SID_ATTR_PAGE_SHARED_FIRST)).GetValue());
+ nFirstShare = rPageDesc.IsFirstShared();
+ }
+ }
+ else
+ {
+ // Disable footer
+ if(rMaster.GetFooter().IsActive())
+ {
+ rMaster.SetFmtAttr(SwFmtFooter(sal_Bool(sal_False)));
+ rPageDesc.ChgFooterShare(sal_False);
+ }
+ }
+ }
+
+ // Footnotes
+
+ if( SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_FTN_INFO,
+ false, &pItem ) )
+ rPageDesc.SetFtnInfo( ((SwPageFtnInfoItem*)pItem)->GetPageFtnInfo() );
+
+ // Columns
+
+ // Register compliant
+
+ if(SFX_ITEM_SET == rSet.GetItemState(
+ SID_SWREGISTER_MODE, false, &pItem))
+ {
+ sal_Bool bSet = ((const SfxBoolItem*)pItem)->GetValue();
+ if(!bSet)
+ rPageDesc.SetRegisterFmtColl(0);
+ else if(SFX_ITEM_SET == rSet.GetItemState(
+ SID_SWREGISTER_COLLECTION, false, &pItem))
+ {
+ const OUString& rColl = ((const SfxStringItem*)pItem)->GetValue();
+ SwDoc& rDoc = *rMaster.GetDoc();
+ SwTxtFmtColl* pColl = rDoc.FindTxtFmtCollByName( rColl );
+ if( !pColl )
+ {
+ sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( rColl, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
+ if( USHRT_MAX != nId )
+ pColl = rDoc.GetTxtCollFromPool( nId );
+ else
+ pColl = rDoc.MakeTxtFmtColl( rColl,
+ (SwTxtFmtColl*)rDoc.GetDfltTxtFmtColl() );
+ }
+ if( pColl )
+ pColl->SetFmtAttr( SwRegisterItem ( sal_True ));
+ rPageDesc.SetRegisterFmtColl( pColl );
+ }
+ }
+}
+
+void PageDescToItemSet( const SwPageDesc& rPageDesc, SfxItemSet& rSet)
+{
+ const SwFrmFmt& rMaster = rPageDesc.GetMaster();
+
+ // Page data
+ SvxPageItem aPageItem(SID_ATTR_PAGE);
+ aPageItem.SetDescName(rPageDesc.GetName());
+ aPageItem.SetPageUsage(lcl_convertUseToSvx(rPageDesc.GetUseOn()));
+ aPageItem.SetLandscape(rPageDesc.GetLandscape());
+ aPageItem.SetNumType((SvxNumType)rPageDesc.GetNumType().GetNumberingType());
+ rSet.Put(aPageItem);
+
+ // Size
+ SvxSizeItem aSizeItem(SID_ATTR_PAGE_SIZE, rMaster.GetFrmSize().GetSize());
+ rSet.Put(aSizeItem);
+
+ // Maximum size
+ SvxSizeItem aMaxSizeItem(SID_ATTR_PAGE_MAXSIZE, Size(MAXWIDTH, MAXHEIGHT));
+ rSet.Put(aMaxSizeItem);
+
+ // Margins, border and the other stuff.
+ rSet.Put(rMaster.GetAttrSet());
+
+ SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
+ const SfxPoolItem *pBoxInfo;
+ if ( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_BORDER_INNER,
+ true, &pBoxInfo) )
+ aBoxInfo = *(SvxBoxInfoItem*)pBoxInfo;
+
+ aBoxInfo.SetTable( false );
+ // Show always the distance field
+ aBoxInfo.SetDist( true);
+ // Set minimal size in tables and paragraphs
+ aBoxInfo.SetMinDist( false );
+ // Set always the default distance
+ aBoxInfo.SetDefDist( MIN_BORDER_DIST );
+ // Single lines can have only in tables DontCare-Status
+ aBoxInfo.SetValid( VALID_DISABLE );
+ rSet.Put( aBoxInfo );
+
+ SfxStringItem aFollow(SID_ATTR_PAGE_EXT1, OUString());
+ if(rPageDesc.GetFollow())
+ aFollow.SetValue(rPageDesc.GetFollow()->GetName());
+ rSet.Put(aFollow);
+
+ // Header
+ if(rMaster.GetHeader().IsActive())
+ {
+ const SwFmtHeader &rHeaderFmt = rMaster.GetHeader();
+ const SwFrmFmt *pHeaderFmt = rHeaderFmt.GetHeaderFmt();
+ OSL_ENSURE(pHeaderFmt != 0, "no header format");
+
+ // HeaderInfo, margins, background, border
+ SfxItemSet aHeaderSet( *rSet.GetPool(),
+ SID_ATTR_PAGE_ON, SID_ATTR_PAGE_SHARED,
+ SID_ATTR_PAGE_SHARED_FIRST, SID_ATTR_PAGE_SHARED_FIRST,
+ SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE,
+ SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
+ RES_FRMATR_BEGIN, RES_FRMATR_END-1,
+ 0);
+
+ // Dynamic or fixed height
+ SfxBoolItem aOn(SID_ATTR_PAGE_ON, true);
+ aHeaderSet.Put(aOn);
+
+ const SwFmtFrmSize &rFrmSize = pHeaderFmt->GetFrmSize();
+ const SwFrmSize eSizeType = rFrmSize.GetHeightSizeType();
+ SfxBoolItem aDynamic(SID_ATTR_PAGE_DYNAMIC, eSizeType != ATT_FIX_SIZE);
+ aHeaderSet.Put(aDynamic);
+
+ // Left equal right
+ SfxBoolItem aShared(SID_ATTR_PAGE_SHARED, rPageDesc.IsHeaderShared());
+ aHeaderSet.Put(aShared);
+ SfxBoolItem aFirstShared(SID_ATTR_PAGE_SHARED_FIRST, rPageDesc.IsFirstShared());
+ aHeaderSet.Put(aFirstShared);
+
+ // Size
+ SvxSizeItem aSize(SID_ATTR_PAGE_SIZE, Size(rFrmSize.GetSize()));
+ aHeaderSet.Put(aSize);
+
+ // Shifting frame attributes
+ aHeaderSet.Put(pHeaderFmt->GetAttrSet());
+ aHeaderSet.Put( aBoxInfo );
+
+ // Create SetItem
+ SvxSetItem aSetItem(SID_ATTR_PAGE_HEADERSET, aHeaderSet);
+ rSet.Put(aSetItem);
+ }
+
+ // Footer
+ if(rMaster.GetFooter().IsActive())
+ {
+ const SwFmtFooter &rFooterFmt = rMaster.GetFooter();
+ const SwFrmFmt *pFooterFmt = rFooterFmt.GetFooterFmt();
+ OSL_ENSURE(pFooterFmt != 0, "no footer format");
+
+ // FooterInfo, margins, background, border
+ SfxItemSet aFooterSet( *rSet.GetPool(),
+ SID_ATTR_PAGE_ON, SID_ATTR_PAGE_SHARED,
+ SID_ATTR_PAGE_SHARED_FIRST, SID_ATTR_PAGE_SHARED_FIRST,
+ SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE,
+ SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
+ RES_FRMATR_BEGIN, RES_FRMATR_END-1,
+ 0);
+
+ // Dynamic or fixed height
+ SfxBoolItem aOn(SID_ATTR_PAGE_ON, true);
+ aFooterSet.Put(aOn);
+
+ const SwFmtFrmSize &rFrmSize = pFooterFmt->GetFrmSize();
+ const SwFrmSize eSizeType = rFrmSize.GetHeightSizeType();
+ SfxBoolItem aDynamic(SID_ATTR_PAGE_DYNAMIC, eSizeType != ATT_FIX_SIZE);
+ aFooterSet.Put(aDynamic);
+
+ // Left equal right
+ SfxBoolItem aShared(SID_ATTR_PAGE_SHARED, rPageDesc.IsFooterShared());
+ aFooterSet.Put(aShared);
+ SfxBoolItem aFirstShared(SID_ATTR_PAGE_SHARED_FIRST, rPageDesc.IsFirstShared());
+ aFooterSet.Put(aFirstShared);
+
+ // Size
+ SvxSizeItem aSize(SID_ATTR_PAGE_SIZE, Size(rFrmSize.GetSize()));
+ aFooterSet.Put(aSize);
+
+ // Shifting Frame attributes
+ aFooterSet.Put(pFooterFmt->GetAttrSet());
+ aFooterSet.Put( aBoxInfo );
+
+ // Create SetItem
+ SvxSetItem aSetItem(SID_ATTR_PAGE_FOOTERSET, aFooterSet);
+ rSet.Put(aSetItem);
+ }
+
+ // Integrate footnotes
+ SwPageFtnInfo& rInfo = (SwPageFtnInfo&)rPageDesc.GetFtnInfo();
+ SwPageFtnInfoItem aFtnItem(FN_PARAM_FTN_INFO, rInfo);
+ rSet.Put(aFtnItem);
+
+ // Register compliant
+ const SwTxtFmtColl* pCol = rPageDesc.GetRegisterFmtColl();
+ SwRegisterItem aReg(pCol != 0);
+ aReg.SetWhich(SID_SWREGISTER_MODE);
+ rSet.Put(aReg);
+ if(pCol)
+ rSet.Put(SfxStringItem(SID_SWREGISTER_COLLECTION, pCol->GetName()));
+
+}
+
+// Set DefaultTabs
+
+void MakeDefTabs(SwTwips nDefDist, SvxTabStopItem& rTabs)
+{
+ if( rTabs.Count() )
+ return;
+ {
+ SvxTabStop aSwTabStop( nDefDist, SVX_TAB_ADJUST_DEFAULT );
+ rTabs.Insert( aSwTabStop );
+ }
+}
+
+// Distance between two tabs
+
+sal_uInt16 GetTabDist(const SvxTabStopItem& rTabs)
+{
+ sal_uInt16 nDefDist;
+ if( rTabs.Count() )
+ nDefDist = (sal_uInt16)( rTabs[0].GetTabPos() );
+ else
+ nDefDist = 1134; // 2cm
+ return nDefDist;
+}
+
+// Inquire if in the set is a Sfx-PageDesc combination present and return it.
+void SfxToSwPageDescAttr( const SwWrtShell& rShell, SfxItemSet& rSet )
+{
+ const SfxPoolItem* pItem;
+ SwFmtPageDesc aPgDesc;
+
+ bool bChanged = false;
+ // Page number
+ if(SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_PARA_PAGENUM, false, &pItem))
+ {
+ aPgDesc.SetNumOffset(((SfxUInt16Item*)pItem)->GetValue());
+ bChanged = true;
+ }
+ if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_PARA_MODEL, false, &pItem ))
+ {
+ const OUString& rDescName = ((SvxPageModelItem*)pItem)->GetValue();
+ if( !rDescName.isEmpty() ) // No name -> disable PageDesc!
+ {
+ // Delete only, if PageDesc will be enabled!
+ rSet.ClearItem( RES_BREAK );
+ SwPageDesc* pDesc = ((SwWrtShell&)rShell).FindPageDescByName(
+ rDescName, sal_True );
+ if( pDesc )
+ aPgDesc.RegisterToPageDesc( *pDesc );
+ }
+ rSet.ClearItem( SID_ATTR_PARA_MODEL );
+ bChanged = true;
+ }
+ else
+ {
+ SfxItemSet aCoreSet(rShell.GetView().GetPool(), RES_PAGEDESC, RES_PAGEDESC );
+ rShell.GetCurAttr( aCoreSet );
+ if(SFX_ITEM_SET == aCoreSet.GetItemState( RES_PAGEDESC, true, &pItem ) )
+ {
+ if( ((SwFmtPageDesc*)pItem)->GetPageDesc() )
+ {
+ aPgDesc.RegisterToPageDesc( *((SwFmtPageDesc*)pItem)->GetPageDesc() );
+ }
+ }
+ }
+
+ if(bChanged)
+ rSet.Put( aPgDesc );
+}
+
+// Inquire if in the set is a Sfx-PageDesc combination present and return it.
+void SwToSfxPageDescAttr( SfxItemSet& rCoreSet )
+{
+ const SfxPoolItem* pItem = 0;
+ OUString aName;
+ ::boost::optional<sal_uInt16> oNumOffset;
+ bool bPut = true;
+ switch( rCoreSet.GetItemState( RES_PAGEDESC, true, &pItem ) )
+ {
+ case SFX_ITEM_SET:
+ {
+ if( ((SwFmtPageDesc*)pItem)->GetPageDesc() )
+ {
+ aName = ((SwFmtPageDesc*)pItem)->GetPageDesc()->GetName();
+ oNumOffset = ((SwFmtPageDesc*)pItem)->GetNumOffset();
+ }
+ rCoreSet.ClearItem( RES_PAGEDESC );
+ // Page number
+ }
+ break;
+
+ case SFX_ITEM_AVAILABLE:
+ break;
+
+ default:
+ bPut = false;
+ }
+
+ // TODO for now always pass a page number to cui, it can't make a
+ // difference between 0 and no page number at the moment.
+ {
+ SfxUInt16Item aPageNum( SID_ATTR_PARA_PAGENUM, oNumOffset ? oNumOffset.get() : 0 );
+ rCoreSet.Put( aPageNum );
+ }
+
+ if(bPut)
+ rCoreSet.Put( SvxPageModelItem( aName, true, SID_ATTR_PARA_MODEL ) );
+}
+
+// Determine metric
+
+FieldUnit GetDfltMetric(sal_Bool bWeb)
+{
+ return SW_MOD()->GetUsrPref(bWeb)->GetMetric();
+}
+
+// Determine metric
+
+void SetDfltMetric( FieldUnit eMetric, sal_Bool bWeb )
+{
+ SW_MOD()->ApplyUserMetric(eMetric, bWeb);
+}
+
+sal_uInt16 InsertStringSorted(const OUString& rEntry, ListBox& rToFill, sal_uInt16 nOffset )
+{
+ sal_uInt16 i = nOffset;
+ CollatorWrapper& rCaseColl = ::GetAppCaseCollator();
+
+ for( ; i < rToFill.GetEntryCount(); i++ )
+ {
+ if( 0 < rCaseColl.compareString( rToFill.GetEntry(i), rEntry ))
+ break;
+ }
+ return rToFill.InsertEntry(rEntry, i);
+}
+void FillCharStyleListBox(ListBox& rToFill, SwDocShell* pDocSh, bool bSorted, bool bWithDefault)
+{
+ sal_Bool bHasOffset = rToFill.GetEntryCount() > 0;
+ SfxStyleSheetBasePool* pPool = pDocSh->GetStyleSheetPool();
+ pPool->SetSearchMask(SFX_STYLE_FAMILY_CHAR, SFXSTYLEBIT_ALL);
+ SwDoc* pDoc = pDocSh->GetDoc();
+ const SfxStyleSheetBase* pBase = pPool->First();
+ OUString sStandard;
+ SwStyleNameMapper::FillUIName( RES_POOLCOLL_STANDARD, sStandard );
+ while(pBase)
+ {
+ if(bWithDefault || pBase->GetName() != sStandard)
+ {
+ sal_uInt16 nPos;
+ if(bSorted)
+ nPos = InsertStringSorted(pBase->GetName(), rToFill, bHasOffset );
+ else
+ nPos = rToFill.InsertEntry(pBase->GetName());
+ sal_IntPtr nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( pBase->GetName(), nsSwGetPoolIdFromName::GET_POOLID_CHRFMT );
+ rToFill.SetEntryData( nPos, (void*) (nPoolId));
+ }
+ pBase = pPool->Next();
+ }
+ // non-pool styles
+ const SwCharFmts* pFmts = pDoc->GetCharFmts();
+ for(sal_uInt16 i = 0; i < pFmts->size(); i++)
+ {
+ const SwCharFmt* pFmt = (*pFmts)[i];
+ if(pFmt->IsDefault())
+ continue;
+ const OUString& rName = pFmt->GetName();
+ if(rToFill.GetEntryPos(rName) == LISTBOX_ENTRY_NOTFOUND)
+ {
+ sal_uInt16 nPos;
+ if(bSorted)
+ nPos = InsertStringSorted(rName, rToFill, bHasOffset );
+ else
+ nPos = rToFill.InsertEntry(rName);
+ sal_IntPtr nPoolId = USHRT_MAX;
+ rToFill.SetEntryData( nPos, (void*) (nPoolId));
+ }
+ }
+};
+
+SwTwips GetTableWidth( SwFrmFmt* pFmt, SwTabCols& rCols, sal_uInt16 *pPercent,
+ SwWrtShell* pSh )
+{
+ // To get the width is slightly more complicated.
+ SwTwips nWidth = 0;
+ const sal_Int16 eOri = pFmt->GetHoriOrient().GetHoriOrient();
+ switch(eOri)
+ {
+ case text::HoriOrientation::FULL: nWidth = rCols.GetRight(); break;
+ case text::HoriOrientation::LEFT_AND_WIDTH:
+ case text::HoriOrientation::LEFT:
+ case text::HoriOrientation::RIGHT:
+ case text::HoriOrientation::CENTER:
+ nWidth = pFmt->GetFrmSize().GetWidth();
+ break;
+ default:
+ {
+ if(pSh)
+ {
+ if ( 0 == pSh->GetFlyFrmFmt() )
+ {
+ nWidth = pSh->GetAnyCurRect(RECT_PAGE_PRT).Width();
+ }
+ else
+ {
+ nWidth = pSh->GetAnyCurRect(RECT_FLY_PRT_EMBEDDED).Width();
+ }
+ }
+ else
+ {
+ OSL_FAIL("where to get the actual width from?");
+ }
+ const SvxLRSpaceItem& rLRSpace = pFmt->GetLRSpace();
+ nWidth -= (rLRSpace.GetRight() + rLRSpace.GetLeft());
+ }
+ }
+ if (pPercent)
+ *pPercent = pFmt->GetFrmSize().GetWidthPercent();
+ return nWidth;
+}
+
+OUString GetAppLangDateTimeString( const DateTime& rDT )
+{
+ const SvtSysLocale aSysLocale;
+ const LocaleDataWrapper& rAppLclData = aSysLocale.GetLocaleData();
+ OUString sRet = rAppLclData.getDate( rDT ) + " " + rAppLclData.getTime( rDT, false, false );
+ return sRet;
+}
+
+// Add a new function which can get and set the current "SID_ATTR_APPLYCHARUNIT" value
+
+sal_Bool HasCharUnit( sal_Bool bWeb)
+{
+ return SW_MOD()->GetUsrPref(bWeb)->IsApplyCharUnit();
+}
+
+void SetApplyCharUnit(sal_Bool bApplyChar, sal_Bool bWeb)
+{
+ SW_MOD()->ApplyUserCharUnit(bApplyChar, bWeb);
+}
+
+bool ExecuteMenuCommand( PopupMenu& rMenu, SfxViewFrame& rViewFrame, sal_uInt16 nId )
+{
+ bool bRet = false;
+ sal_uInt16 nItemCount = rMenu.GetItemCount();
+ OUString sCommand;
+ for( sal_uInt16 nItem = 0; nItem < nItemCount; ++nItem)
+ {
+ PopupMenu* pPopup = rMenu.GetPopupMenu( rMenu.GetItemId( nItem ) );
+ if(pPopup)
+ {
+ sCommand = pPopup->GetItemCommand(nId);
+ if(!sCommand.isEmpty())
+ break;
+ }
+ }
+ if(!sCommand.isEmpty())
+ {
+ uno::Reference< frame::XFrame > xFrame = rViewFrame.GetFrame().GetFrameInterface();
+ uno::Reference < frame::XDispatchProvider > xProv( xFrame, uno::UNO_QUERY );
+ util::URL aURL;
+ aURL.Complete = sCommand;
+ uno::Reference < util::XURLTransformer > xTrans( util::URLTransformer::create(::comphelper::getProcessComponentContext() ) );
+ xTrans->parseStrict( aURL );
+ uno::Reference< frame::XDispatch > xDisp = xProv->queryDispatch( aURL, OUString(), 0 );
+ if( xDisp.is() )
+ {
+ uno::Sequence< beans::PropertyValue > aSeq;
+ xDisp->dispatch( aURL, aSeq );
+ bRet = true;
+ }
+ }
+ return bRet;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/utlui/unotools.cxx b/sw/source/core/uibase/utlui/unotools.cxx
new file mode 100644
index 000000000000..6d9b90cc88b6
--- /dev/null
+++ b/sw/source/core/uibase/utlui/unotools.cxx
@@ -0,0 +1,562 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <swtypes.hxx>
+#include <globals.hrc>
+#include <misc.hrc>
+
+#include <utlui.hrc>
+#include <unotools.hrc>
+#include <unotools.hxx>
+#include <unoprnms.hxx>
+#include <i18nutil/unicode.hxx>
+#include <osl/diagnose.h>
+#include <vcl/msgbox.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/settings.hxx>
+#include <com/sun/star/text/XTextViewCursorSupplier.hpp>
+#include <com/sun/star/view/XScreenCursor.hpp>
+#include <com/sun/star/view/DocumentZoomType.hpp>
+#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
+#include <com/sun/star/style/XStyle.hpp>
+#include <com/sun/star/text/XTextDocument.hpp>
+#include <com/sun/star/awt/Toolkit.hpp>
+#include <com/sun/star/awt/PosSize.hpp>
+#include <com/sun/star/view/XViewSettingsSupplier.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/frame/XLayoutManager.hpp>
+#include <comphelper/processfactory.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svl/stritem.hxx>
+#include <shellio.hxx>
+#include <docsh.hxx>
+#include <view.hxx>
+#include <wrtsh.hxx>
+#include <swmodule.hxx>
+#include <TextCursorHelper.hxx>
+#include <unocrsr.hxx>
+#include <doc.hxx>
+
+#include <unomid.h>
+
+using namespace ::com::sun::star;
+
+const sal_Char cFrameControl[] = "com.sun.star.frame.FrameControl";
+const sal_Char cFactory[] = "private:factory/swriter";
+
+bool SwOneExampleFrame::bShowServiceNotAvailableMessage = true;
+
+SwOneExampleFrame::SwOneExampleFrame( Window& rWin,
+ sal_uInt32 nFlags,
+ const Link* pInitializedLink,
+ OUString* pURL ) :
+ aTopWindow(&rWin, this),
+ aMenuRes(SW_RES(RES_FRMEX_MENU)),
+ pModuleView(SW_MOD()->GetView()),
+ nStyleFlags(nFlags),
+ bIsInitialized(sal_False),
+ bServiceAvailable(sal_False)
+{
+ if (pURL && !pURL->isEmpty())
+ sArgumentURL = *pURL;
+
+ aTopWindow.SetPosSizePixel(Point(0, 0), rWin.GetSizePixel());
+
+ if( pInitializedLink )
+ aInitializedLink = *pInitializedLink;
+
+ // the controller is asynchronously set
+ aLoadedTimer.SetTimeoutHdl(LINK(this, SwOneExampleFrame, TimeoutHdl));
+ aLoadedTimer.SetTimeout(200);
+
+ CreateControl();
+
+ aTopWindow.Show();
+}
+
+void SwOneExampleFrame::CreateErrorMessage(Window* pParent)
+{
+ if(SwOneExampleFrame::bShowServiceNotAvailableMessage)
+ {
+ OUString sInfo(SW_RES(STR_SERVICE_UNAVAILABLE));
+ sInfo += OUString(cFrameControl);
+ InfoBox(pParent, sInfo).Execute();
+ SwOneExampleFrame::bShowServiceNotAvailableMessage = false;
+ }
+}
+
+SwOneExampleFrame::~SwOneExampleFrame()
+{
+ DisposeControl();
+}
+
+void SwOneExampleFrame::CreateControl()
+{
+ if(_xControl.is())
+ return ;
+ uno::Reference< lang::XMultiServiceFactory >
+ xMgr = comphelper::getProcessServiceFactory();
+ uno::Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext();
+ uno::Reference< uno::XInterface > xInst = xMgr->createInstance( "com.sun.star.frame.FrameControl" );
+ _xControl = uno::Reference< awt::XControl >(xInst, uno::UNO_QUERY);
+ if(_xControl.is())
+ {
+ uno::Reference< awt::XWindowPeer > xParent( aTopWindow.GetComponentInterface() );
+
+ uno::Reference< awt::XToolkit > xToolkit( awt::Toolkit::create(xContext), uno::UNO_QUERY_THROW );
+
+ _xControl->createPeer( xToolkit, xParent );
+
+ uno::Reference< awt::XWindow > xWin( _xControl, uno::UNO_QUERY );
+ xWin->setVisible(sal_False);
+ Size aWinSize(aTopWindow.GetOutputSizePixel());
+ xWin->setPosSize( 0, 0, aWinSize.Width(), aWinSize.Height(), awt::PosSize::SIZE );
+
+ uno::Reference< beans::XPropertySet > xPrSet(xInst, uno::UNO_QUERY);
+ uno::Any aURL;
+ // create new doc
+ OUString sTempURL(cFactory);
+ if(!sArgumentURL.isEmpty())
+ sTempURL = sArgumentURL;
+ aURL <<= sTempURL;
+
+ uno::Sequence<beans::PropertyValue> aSeq(3);
+ beans::PropertyValue* pValues = aSeq.getArray();
+ pValues[0].Name = "ReadOnly";
+ sal_Bool bTrue = sal_True;
+ pValues[0].Value.setValue(&bTrue, ::getBooleanCppuType());
+ pValues[1].Name = "OpenFlags";
+ pValues[1].Value <<= OUString("-RB");
+ pValues[2].Name = "Referer";
+ pValues[2].Value <<= OUString("private:user");
+ uno::Any aArgs;
+ aArgs.setValue(&aSeq, ::getCppuType((uno::Sequence<beans::PropertyValue>*)0));
+
+ xPrSet->setPropertyValue( "LoaderArguments", aArgs );
+ //save and set readonly???
+
+ xPrSet->setPropertyValue("ComponentURL", aURL);
+
+ aLoadedTimer.Start();
+ bServiceAvailable = sal_True;
+ }
+}
+
+void SwOneExampleFrame::DisposeControl()
+{
+ _xCursor = 0;
+ if(_xControl.is())
+ _xControl->dispose();
+ _xControl = 0;
+ _xModel = 0;
+ _xController = 0;
+}
+
+static void disableScrollBars(uno::Reference< beans::XPropertySet > xViewProps,
+ bool bEnableOnlineMode)
+{
+ //the scrollbar logic is kind of busted looking in writer, when the hori scrollbar
+ //property is changed then the hori scrollbar is enabled if the property is
+ //true or browse (online) mode is enabled. So...
+ //disable online mode
+ //turn off scrollbars
+ //turn back on online mode if that's what we want
+ //which subverts the (dodgy/buggy) scrollbar setting
+
+ //To reproduce this problem, in edit->autotext and click through
+ //the examples and see if the preview gets a horizontal scrollbar
+ uno::Any aFalseSet(uno::makeAny(sal_False));
+ xViewProps->setPropertyValue(UNO_NAME_SHOW_ONLINE_LAYOUT, aFalseSet);
+
+ xViewProps->setPropertyValue(UNO_NAME_SHOW_HORI_SCROLL_BAR, aFalseSet);
+ xViewProps->setPropertyValue(UNO_NAME_SHOW_VERT_SCROLL_BAR, aFalseSet);
+
+ if (bEnableOnlineMode)
+ {
+ xViewProps->setPropertyValue(UNO_NAME_SHOW_ONLINE_LAYOUT, uno::makeAny(sal_True));
+ }
+}
+
+IMPL_LINK( SwOneExampleFrame, TimeoutHdl, Timer*, pTimer )
+{
+ if(!_xControl.is())
+ return 0;
+
+ // now get the model
+ uno::Reference< beans::XPropertySet > xPrSet(_xControl, uno::UNO_QUERY);
+ uno::Any aFrame = xPrSet->getPropertyValue("Frame");
+ uno::Reference< frame::XFrame > xFrm;
+ aFrame >>= xFrm;
+
+ uno::Reference< beans::XPropertySet > xPropSet( xFrm, uno::UNO_QUERY );
+ if ( xPropSet.is() )
+ {
+ try
+ {
+ uno::Reference< frame::XLayoutManager > xLayoutManager;
+ uno::Any aValue = xPropSet->getPropertyValue("LayoutManager");
+ aValue >>= xLayoutManager;
+ if ( xLayoutManager.is() )
+ xLayoutManager->setVisible( sal_False );
+ }
+ catch (const uno::Exception&)
+ {
+ }
+ }
+
+ _xController = xFrm->getController();
+ if(_xController.is())
+ {
+ _xModel = _xController->getModel();
+ //now the ViewOptions should be set properly
+ uno::Reference< view::XViewSettingsSupplier > xSettings(_xController, uno::UNO_QUERY);
+ uno::Reference< beans::XPropertySet > xViewProps = xSettings->getViewSettings();
+
+ sal_Bool bTrue = sal_True;
+ sal_Bool bFalse = sal_False;
+ uno::Any aTrueSet( &bTrue, ::getBooleanCppuType() );
+ uno::Any aFalseSet( &bFalse, ::getBooleanCppuType() );
+
+ if( !bIsInitialized )
+ {
+ xViewProps->setPropertyValue(UNO_NAME_SHOW_BREAKS, aFalseSet);
+ xViewProps->setPropertyValue(UNO_NAME_SHOW_DRAWINGS, aTrueSet);
+ xViewProps->setPropertyValue(UNO_NAME_SHOW_FIELD_COMMANDS, aFalseSet);
+ xViewProps->setPropertyValue(UNO_NAME_SHOW_GRAPHICS, aTrueSet);
+ xViewProps->setPropertyValue(UNO_NAME_SHOW_HIDDEN_PARAGRAPHS, aFalseSet);
+ xViewProps->setPropertyValue(UNO_NAME_SHOW_HIDDEN_TEXT, aFalseSet);
+ xViewProps->setPropertyValue(UNO_NAME_SHOW_HORI_RULER, aFalseSet);
+ xViewProps->setPropertyValue(UNO_NAME_SHOW_PARA_BREAKS, aFalseSet);
+ xViewProps->setPropertyValue(UNO_NAME_SHOW_PROTECTED_SPACES, aFalseSet);
+ xViewProps->setPropertyValue(UNO_NAME_SHOW_SOFT_HYPHENS, aFalseSet);
+ xViewProps->setPropertyValue(UNO_NAME_SHOW_SPACES, aFalseSet);
+ xViewProps->setPropertyValue(UNO_NAME_SHOW_TABLES, aTrueSet);
+ xViewProps->setPropertyValue(UNO_NAME_SHOW_TABSTOPS, aFalseSet);
+ xViewProps->setPropertyValue(UNO_NAME_SHOW_VERT_RULER, aFalseSet);
+
+ if(0 ==(nStyleFlags&EX_SHOW_ONLINE_LAYOUT))
+ {
+ uno::Any aZoom;
+ aZoom <<= (sal_Int16)view::DocumentZoomType::PAGE_WIDTH_EXACT;
+ xViewProps->setPropertyValue(UNO_NAME_ZOOM_TYPE, aZoom);
+ }
+ else
+ {
+ uno::Any aZoom;
+ aZoom <<= (sal_Int16)view::DocumentZoomType::BY_VALUE;
+ xViewProps->setPropertyValue(UNO_NAME_ZOOM_TYPE, aZoom);
+
+ sal_Int16 nZoomValue = 50;
+ if(EX_SHOW_BUSINESS_CARDS == nStyleFlags)
+ {
+ nZoomValue = 80;
+ }
+ aZoom <<= nZoomValue;
+ xViewProps->setPropertyValue(UNO_NAME_ZOOM_VALUE, aZoom);
+ }
+
+ // set onlinelayout property after setting the zoom
+ disableScrollBars(xViewProps, (nStyleFlags&EX_SHOW_ONLINE_LAYOUT) != 0);
+ bIsInitialized = sal_True;
+ }
+
+ uno::Reference< text::XTextDocument > xDoc(_xModel, uno::UNO_QUERY);
+ uno::Reference< text::XText > xText = xDoc->getText();
+ _xCursor = xText->createTextCursor();
+
+ //From here, a cursor is defined, which goes through the template,
+ //and overwrites the template words where it is necessary.
+
+ uno::Reference< lang::XUnoTunnel> xTunnel( _xCursor, uno::UNO_QUERY);
+ if( xTunnel.is() )
+ {
+ OTextCursorHelper* pCrsr = reinterpret_cast<OTextCursorHelper*>( xTunnel->getSomething(
+ OTextCursorHelper::getUnoTunnelId() ));
+ if( pCrsr )
+ {
+ SwEditShell* pSh = pCrsr->GetDoc()->GetEditShell();
+
+ do
+ {
+ if (pSh->GetCurWord() == "HEADING1")
+ {
+ pSh->Overwrite(SW_RESSTR(STR_IDXEXAMPLE_IDXTXT_HEADING1));
+ }
+ else if (pSh->GetCurWord() == "ENTRY1")
+ {
+ pSh->Overwrite(SW_RESSTR(STR_IDXEXAMPLE_IDXTXT_ENTRY1));
+ }
+ else if (pSh->GetCurWord() == "HEADING11")
+ {
+ pSh->Overwrite(SW_RESSTR(STR_IDXEXAMPLE_IDXTXT_HEADING11));
+ }
+ else if (pSh->GetCurWord() == "ENTRY11")
+ {
+ pSh->Overwrite(SW_RESSTR(STR_IDXEXAMPLE_IDXTXT_ENTRY11));
+ }
+ else if (pSh->GetCurWord() == "HEADING12")
+ {
+ pSh->Overwrite(SW_RESSTR(STR_IDXEXAMPLE_IDXTXT_HEADING12));
+ }
+ else if (pSh->GetCurWord() == "ENTRY12")
+ {
+ pSh->Overwrite(SW_RESSTR(STR_IDXEXAMPLE_IDXTXT_ENTRY12));
+ }
+ else if (pSh->GetCurWord() == "TABLE1")
+ {
+ pSh->Overwrite(SW_RESSTR(STR_IDXEXAMPLE_IDXTXT_TABLE1));
+ }
+ else if (pSh->GetCurWord() == "IMAGE1")
+ {
+ pSh->Overwrite(SW_RESSTR(STR_IDXEXAMPLE_IDXTXT_IMAGE1));
+ }
+ else
+ {;}
+ }
+ while(pSh->Right(sal_uInt16(1), sal_uInt16(1), sal_True) == sal_True);
+ }
+ }
+
+ uno::Reference< beans::XPropertySet > xCrsrProp(_xCursor, uno::UNO_QUERY);
+ uno::Any aPageStyle = xCrsrProp->getPropertyValue(UNO_NAME_PAGE_STYLE_NAME);
+ OUString sPageStyle;
+ aPageStyle >>= sPageStyle;
+
+ uno::Reference< style::XStyleFamiliesSupplier > xSSupp( xDoc, uno::UNO_QUERY);
+ uno::Reference< container::XNameAccess > xStyles = xSSupp->getStyleFamilies();
+ uno::Any aPFamily = xStyles->getByName( "PageStyles" );
+ uno::Reference< container::XNameContainer > xPFamily;
+
+ if( EX_SHOW_DEFAULT_PAGE != nStyleFlags
+ && (aPFamily >>= xPFamily) && !sPageStyle.isEmpty() )
+ {
+ uno::Any aPStyle = xPFamily->getByName( sPageStyle );
+ uno::Reference< style::XStyle > xPStyle;
+ aPStyle >>= xPStyle;
+ uno::Reference< beans::XPropertySet > xPProp(xPStyle, uno::UNO_QUERY);
+ uno::Any aSize = xPProp->getPropertyValue(UNO_NAME_SIZE);
+ awt::Size aPSize;
+ aSize >>= aPSize;
+ //TODO: set page width to card width
+ aPSize.Width = 10000;
+ aSize.setValue(&aPSize, ::getCppuType((awt::Size*)0));
+ xPProp->setPropertyValue(UNO_NAME_SIZE, aSize);
+
+ uno::Any aZero; aZero <<= (sal_Int32)0;
+ xPProp->setPropertyValue(UNO_NAME_LEFT_MARGIN, aZero);
+ xPProp->setPropertyValue(UNO_NAME_RIGHT_MARGIN, aZero);
+ }
+
+ uno::Reference< awt::XWindow > xWin( _xControl, uno::UNO_QUERY );
+ Size aWinSize(aTopWindow.GetOutputSizePixel());
+ xWin->setPosSize( 0, 0, aWinSize.Width(), aWinSize.Height(), awt::PosSize::SIZE );
+
+ // can only be done here - the SFX changes the ScrollBar values
+ disableScrollBars(xViewProps, (nStyleFlags&EX_SHOW_ONLINE_LAYOUT) != 0);
+
+ if (aInitializedLink.IsSet())
+ aInitializedLink.Call(this);
+
+ uno::Reference< text::XTextViewCursorSupplier > xCrsrSupp(_xController, uno::UNO_QUERY);
+ uno::Reference< view::XScreenCursor > xScrCrsr(xCrsrSupp->getViewCursor(), uno::UNO_QUERY);
+ if(xScrCrsr.is())
+ xScrCrsr->screenUp();
+
+ xWin->setVisible( sal_True );
+ aTopWindow.Show();
+
+ if( xTunnel.is() )
+ {
+ OTextCursorHelper* pCrsr = reinterpret_cast<OTextCursorHelper*>( xTunnel->getSomething(
+ OTextCursorHelper::getUnoTunnelId() ));
+ if( pCrsr )
+ {
+ SwEditShell* pSh = pCrsr->GetDoc()->GetEditShell();
+ if( pSh->ActionCount() )
+ {
+ pSh->EndAllAction();
+ pSh->UnlockPaint();
+ }
+ }
+ }
+
+ SW_MOD()->SetView(pModuleView);
+ }
+ else
+ pTimer->Start();
+ return 0;
+}
+
+void SwOneExampleFrame::ClearDocument( sal_Bool bStartUpdateTimer )
+{
+ uno::Reference< lang::XUnoTunnel> xTunnel( _xCursor, uno::UNO_QUERY);
+ if( xTunnel.is() )
+ {
+ OTextCursorHelper* pCrsr = reinterpret_cast<OTextCursorHelper*>(xTunnel->getSomething(
+ OTextCursorHelper::getUnoTunnelId()) );
+ if( pCrsr )
+ {
+ SwDoc* pDoc = pCrsr->GetDoc();
+ SwEditShell* pSh = pDoc->GetEditShell();
+ pSh->LockPaint();
+ pSh->StartAllAction();
+ pDoc->ClearDoc();
+
+ if( aLoadedTimer.IsActive() || !bStartUpdateTimer )
+ {
+ pSh->EndAllAction();
+ pSh->UnlockPaint();
+ }
+ if( bStartUpdateTimer )
+ aLoadedTimer.Start();
+ }
+ else
+ {
+ _xCursor->gotoStart(sal_False);
+ _xCursor->gotoEnd(sal_True);
+ _xCursor->setString(OUString());
+ }
+ }
+}
+
+static const sal_Int16 nZoomValues[] =
+{
+ 20,
+ 40,
+ 50,
+ 75,
+ 100
+};
+
+#define ITEM_UP 100
+#define ITEM_DOWN 200
+#define ITEM_ZOOM 300
+
+void SwOneExampleFrame::CreatePopup(const Point& rPt)
+{
+ PopupMenu aPop;
+ PopupMenu aSubPop1;
+ ResStringArray& rArr = aMenuRes.GetMenuArray();
+
+ aPop.InsertItem(ITEM_UP, rArr.GetString(rArr.FindIndex(ST_MENU_UP )));
+ aPop.InsertItem(ITEM_DOWN, rArr.GetString(rArr.FindIndex(ST_MENU_DOWN )));
+
+ Link aSelLk = LINK(this, SwOneExampleFrame, PopupHdl );
+ aPop.SetSelectHdl(aSelLk);
+ if(EX_SHOW_ONLINE_LAYOUT == nStyleFlags)
+ {
+ aPop.InsertItem(ITEM_ZOOM, rArr.GetString(rArr.FindIndex(ST_MENU_ZOOM )));
+
+ uno::Reference< view::XViewSettingsSupplier > xSettings(_xController, uno::UNO_QUERY);
+ uno::Reference< beans::XPropertySet > xViewProps = xSettings->getViewSettings();
+
+ uno::Any aZoom = xViewProps->getPropertyValue(UNO_NAME_ZOOM_VALUE);
+ sal_Int16 nZoom = 0;
+ aZoom >>= nZoom;
+
+ for (sal_uInt16 i = 0;
+ i < (sizeof(nZoomValues)/sizeof(nZoomValues[0])); ++i)
+ {
+ OUString sTemp = unicode::formatPercent(nZoomValues[i],
+ Application::GetSettings().GetUILanguageTag());
+ aSubPop1.InsertItem( ITEM_ZOOM + i + 1, sTemp);
+ if(nZoom == nZoomValues[i])
+ aSubPop1.CheckItem(ITEM_ZOOM + i + 1);
+ }
+ aPop.SetPopupMenu( ITEM_ZOOM, &aSubPop1 );
+ aSubPop1.SetSelectHdl(aSelLk);
+ }
+ aPop.Execute( &aTopWindow, rPt );
+
+}
+
+IMPL_LINK(SwOneExampleFrame, PopupHdl, Menu*, pMenu )
+{
+ sal_uInt16 nId = pMenu->GetCurItemId();
+ if ((nId > ITEM_ZOOM) &&
+ (nId <= (ITEM_ZOOM + (sizeof(nZoomValues)/sizeof(nZoomValues[0])))))
+ {
+ sal_Int16 nZoom = nZoomValues[nId - ITEM_ZOOM - 1];
+ uno::Reference< view::XViewSettingsSupplier > xSettings(_xController, uno::UNO_QUERY);
+ uno::Reference< beans::XPropertySet > xViewProps = xSettings->getViewSettings();
+
+ uno::Any aZoom;
+ aZoom <<= nZoom;
+ xViewProps->setPropertyValue(UNO_NAME_ZOOM_VALUE, aZoom);
+ aZoom <<= (sal_Int16)view::DocumentZoomType::BY_VALUE;
+ xViewProps->setPropertyValue(UNO_NAME_ZOOM_TYPE, aZoom);
+ }
+ else if(ITEM_UP == nId || ITEM_DOWN == nId)
+ {
+ uno::Reference< text::XTextViewCursorSupplier > xCrsrSupp(_xController, uno::UNO_QUERY);
+ uno::Reference< view::XScreenCursor > xScrCrsr(xCrsrSupp->getViewCursor(), uno::UNO_QUERY);
+ if(ITEM_UP == nId)
+ xScrCrsr->screenUp();
+ else
+ xScrCrsr->screenDown();
+ }
+ return 0;
+};
+
+SwFrmCtrlWindow::SwFrmCtrlWindow(Window* pParent, SwOneExampleFrame* pFrame)
+ : VclEventBox(pParent)
+ , pExampleFrame(pFrame)
+{
+ set_expand(true);
+ set_fill(true);
+}
+
+void SwFrmCtrlWindow::Command( const CommandEvent& rCEvt )
+{
+ switch ( rCEvt.GetCommand() )
+ {
+ case COMMAND_CONTEXTMENU:
+ {
+ //#125881# quickly clicking crashes because the control is not fully initialized
+ if(pExampleFrame->GetController().is())
+ pExampleFrame->CreatePopup(rCEvt.GetMousePosPixel());
+ }
+ break;
+ case COMMAND_WHEEL:
+ case COMMAND_STARTAUTOSCROLL:
+ case COMMAND_AUTOSCROLL:
+ break;
+ default:;
+ }
+}
+
+Size SwFrmCtrlWindow::GetOptimalSize() const
+{
+ return LogicToPixel(Size(82, 124), MapMode(MAP_APPFONT));
+}
+
+void SwFrmCtrlWindow::Resize()
+{
+ VclEventBox::Resize();
+ pExampleFrame->ClearDocument(true);
+}
+
+MenuResource::MenuResource(const ResId& rResId) :
+ Resource(rResId),
+ aMenuArray(ResId(1,*rResId.GetResMgr()))
+{
+ FreeResource();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/utlui/unotools.hrc b/sw/source/core/uibase/utlui/unotools.hrc
new file mode 100644
index 000000000000..db3d7805f821
--- /dev/null
+++ b/sw/source/core/uibase/utlui/unotools.hrc
@@ -0,0 +1,35 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef _UNOTOOLS_HRC
+#define _UNOTOOLS_HRC
+
+#define FT_NEW_NAME 1
+#define ED_NEW_NAME 2
+#define FL_NAME 3
+#define PB_OK 4
+#define PB_HELP 5
+#define PB_CANCEL 6
+
+#define ST_MENU_ZOOM 1
+#define ST_MENU_UP 2
+#define ST_MENU_DOWN 3
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/utlui/unotools.src b/sw/source/core/uibase/utlui/unotools.src
new file mode 100644
index 000000000000..7ee442ed1589
--- /dev/null
+++ b/sw/source/core/uibase/utlui/unotools.src
@@ -0,0 +1,42 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#include <unotools.hrc>
+#include <utlui.hrc>
+#include <globals.hrc>
+#include <helpid.h>
+
+String STR_SERVICE_UNAVAILABLE
+{
+ Text [ en-US ] = "The following service is not available: ";
+};
+
+Resource RES_FRMEX_MENU
+{
+ StringArray 1
+ {
+ ItemList [ en-US ] =
+ {
+ < "~Zoom" ; ST_MENU_ZOOM; > ;
+ < "~Upwards" ; ST_MENU_UP; > ;
+ < "Do~wnwards" ; ST_MENU_DOWN; > ;
+ };
+ };
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/utlui/viewlayoutctrl.cxx b/sw/source/core/uibase/utlui/viewlayoutctrl.cxx
new file mode 100644
index 000000000000..18a92123d1d0
--- /dev/null
+++ b/sw/source/core/uibase/utlui/viewlayoutctrl.cxx
@@ -0,0 +1,195 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <viewlayoutctrl.hxx>
+
+#include <vcl/status.hxx>
+#include <vcl/image.hxx>
+#include <svl/eitem.hxx>
+#include <svx/viewlayoutitem.hxx>
+#include <utlui.hrc>
+#include <swtypes.hxx>
+
+SFX_IMPL_STATUSBAR_CONTROL( SwViewLayoutControl, SvxViewLayoutItem );
+
+struct SwViewLayoutControl::SwViewLayoutControl_Impl
+{
+ sal_uInt16 mnState; // 0 = single, 1 = auto, 2 = book, 3 = none
+ Image maImageSingleColumn;
+ Image maImageSingleColumn_Active;
+ Image maImageAutomatic;
+ Image maImageAutomatic_Active;
+ Image maImageBookMode;
+ Image maImageBookMode_Active;
+};
+
+SwViewLayoutControl::SwViewLayoutControl( sal_uInt16 _nSlotId, sal_uInt16 _nId, StatusBar& rStb ) :
+ SfxStatusBarControl( _nSlotId, _nId, rStb ),
+ mpImpl( new SwViewLayoutControl_Impl )
+{
+ mpImpl->mnState = 0;
+
+ mpImpl->maImageSingleColumn = Image( SW_RES(IMG_VIEWLAYOUT_SINGLECOLUMN) );
+ mpImpl->maImageSingleColumn_Active = Image( SW_RES(IMG_VIEWLAYOUT_SINGLECOLUMN_ACTIVE) );
+ mpImpl->maImageAutomatic = Image( SW_RES(IMG_VIEWLAYOUT_AUTOMATIC) );
+ mpImpl->maImageAutomatic_Active = Image( SW_RES(IMG_VIEWLAYOUT_AUTOMATIC_ACTIVE) );
+ mpImpl->maImageBookMode = Image( SW_RES(IMG_VIEWLAYOUT_BOOKMODE) );
+ mpImpl->maImageBookMode_Active = Image( SW_RES(IMG_VIEWLAYOUT_BOOKMODE_ACTIVE) );
+
+#ifndef MACOSX
+ if ( rStb.GetDPIScaleFactor() > 1)
+ {
+ Image arr[6] = {mpImpl->maImageSingleColumn, mpImpl->maImageSingleColumn_Active,
+ mpImpl->maImageAutomatic, mpImpl->maImageAutomatic_Active,
+ mpImpl->maImageBookMode, mpImpl->maImageBookMode_Active};
+
+ for (int i = 0; i < 6; i++)
+ {
+ BitmapEx b = arr[i].GetBitmapEx();
+ //Don't scale width, no space.
+ b.Scale(1.0, rStb.GetDPIScaleFactor(), BMP_SCALE_FAST);
+ arr[i] = Image(b);
+ }
+
+ mpImpl->maImageSingleColumn = arr[0];
+ mpImpl->maImageSingleColumn_Active = arr[1];
+
+ mpImpl->maImageAutomatic = arr[2];
+ mpImpl->maImageAutomatic_Active = arr[3];
+
+ mpImpl->maImageBookMode = arr[4];
+ mpImpl->maImageBookMode_Active = arr[5];
+ }
+#endif
+}
+
+SwViewLayoutControl::~SwViewLayoutControl()
+{
+ delete mpImpl;
+}
+
+void SwViewLayoutControl::StateChanged( sal_uInt16 /*nSID*/, SfxItemState eState, const SfxPoolItem* pState )
+{
+ if ( SFX_ITEM_AVAILABLE != eState || pState->ISA( SfxVoidItem ) )
+ GetStatusBar().SetItemText( GetId(), OUString() );
+ else
+ {
+ OSL_ENSURE( pState->ISA( SvxViewLayoutItem ), "invalid item type" );
+ const sal_uInt16 nColumns = static_cast<const SvxViewLayoutItem*>( pState )->GetValue();
+ const bool bBookMode = static_cast<const SvxViewLayoutItem*>( pState )->IsBookMode();
+
+ // SingleColumn Mode
+ if ( 1 == nColumns )
+ mpImpl->mnState = 0;
+ // Automatic Mode
+ else if ( 0 == nColumns )
+ mpImpl->mnState = 1;
+ // Book Mode
+ else if ( bBookMode && 2 == nColumns )
+ mpImpl->mnState = 2;
+ else
+ mpImpl->mnState = 3;
+ }
+
+ if ( GetStatusBar().AreItemsVisible() )
+ GetStatusBar().SetItemData( GetId(), 0 ); // force repaint
+}
+
+void SwViewLayoutControl::Paint( const UserDrawEvent& rUsrEvt )
+{
+ OutputDevice* pDev = rUsrEvt.GetDevice();
+ Rectangle aRect = rUsrEvt.GetRect();
+
+ const Rectangle aControlRect = getControlRect();
+
+ const bool bSingleColumn = 0 == mpImpl->mnState;
+ const bool bAutomatic = 1 == mpImpl->mnState;
+ const bool bBookMode = 2 == mpImpl->mnState;
+
+ const long nImageWidthSum = mpImpl->maImageSingleColumn.GetSizePixel().Width() +
+ mpImpl->maImageAutomatic.GetSizePixel().Width() +
+ mpImpl->maImageBookMode.GetSizePixel().Width();
+
+ const long nXOffset = (aRect.GetWidth() - nImageWidthSum)/2;
+ const long nYOffset = (aControlRect.GetHeight() - mpImpl->maImageSingleColumn.GetSizePixel().Height())/2;
+
+ aRect.Left() = aRect.Left() + nXOffset;
+ aRect.Top() = aRect.Top() + nYOffset;
+
+ // draw single column image:
+ pDev->DrawImage( aRect.TopLeft(), bSingleColumn ? mpImpl->maImageSingleColumn_Active : mpImpl->maImageSingleColumn );
+
+ // draw automatic image:
+ aRect.Left() += mpImpl->maImageSingleColumn.GetSizePixel().Width();
+ pDev->DrawImage( aRect.TopLeft(), bAutomatic ? mpImpl->maImageAutomatic_Active : mpImpl->maImageAutomatic );
+
+ // draw bookmode image:
+ aRect.Left() += mpImpl->maImageAutomatic.GetSizePixel().Width();
+ pDev->DrawImage( aRect.TopLeft(), bBookMode ? mpImpl->maImageBookMode_Active : mpImpl->maImageBookMode );
+}
+
+sal_Bool SwViewLayoutControl::MouseButtonDown( const MouseEvent & rEvt )
+{
+ const Rectangle aRect = getControlRect();
+ const Point aPoint = rEvt.GetPosPixel();
+ const long nXDiff = aPoint.X() - aRect.Left();
+
+ sal_uInt16 nColumns = 1;
+ bool bBookMode = false;
+
+ const long nImageWidthSingle = mpImpl->maImageSingleColumn.GetSizePixel().Width();
+ const long nImageWidthAuto = mpImpl->maImageAutomatic.GetSizePixel().Width();
+ const long nImageWidthBook = mpImpl->maImageBookMode.GetSizePixel().Width();
+ const long nImageWidthSum = nImageWidthSingle + nImageWidthAuto + nImageWidthBook;
+
+ const long nXOffset = (aRect.GetWidth() - nImageWidthSum)/2;
+
+ if ( nXDiff < nXOffset + nImageWidthSingle )
+ {
+ mpImpl->mnState = 0; // single
+ nColumns = 1;
+ }
+ else if ( nXDiff < nXOffset + nImageWidthSingle + nImageWidthAuto )
+ {
+ mpImpl->mnState = 1; // auto
+ nColumns = 0;
+ }
+ else
+ {
+ mpImpl->mnState = 2; // book
+ nColumns = 2;
+ bBookMode = true;
+ }
+
+ // commit state change
+ SvxViewLayoutItem aViewLayout( nColumns, bBookMode );
+
+ ::com::sun::star::uno::Any a;
+ aViewLayout.QueryValue( a );
+
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgs( 1 );
+ aArgs[0].Name = "ViewLayout";
+ aArgs[0].Value = a;
+
+ execute( aArgs );
+
+ return sal_True;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/utlui/wordcountctrl.cxx b/sw/source/core/uibase/utlui/wordcountctrl.cxx
new file mode 100644
index 000000000000..498de51ceb3c
--- /dev/null
+++ b/sw/source/core/uibase/utlui/wordcountctrl.cxx
@@ -0,0 +1,27 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "wordcountctrl.hxx"
+#include <svl/stritem.hxx>
+
+SFX_IMPL_STATUSBAR_CONTROL(SwWordCountStatusBarControl, SfxStringItem);
+
+SwWordCountStatusBarControl::SwWordCountStatusBarControl(
+ sal_uInt16 _nSlotId,
+ sal_uInt16 _nId,
+ StatusBar& rStb) :
+ SfxStatusBarControl(_nSlotId, _nId, rStb)
+{
+}
+
+SwWordCountStatusBarControl::~SwWordCountStatusBarControl()
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/utlui/zoomctrl.cxx b/sw/source/core/uibase/utlui/zoomctrl.cxx
new file mode 100644
index 000000000000..ac592474eb80
--- /dev/null
+++ b/sw/source/core/uibase/utlui/zoomctrl.cxx
@@ -0,0 +1,72 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "hintids.hxx"
+
+#include <vcl/status.hxx>
+#include <sfx2/app.hxx>
+#include <svl/stritem.hxx>
+#include <sfx2/zoomitem.hxx>
+
+#include "swtypes.hxx"
+#include "zoomctrl.hxx"
+
+SFX_IMPL_STATUSBAR_CONTROL( SwZoomControl, SvxZoomItem );
+
+SwZoomControl::SwZoomControl( sal_uInt16 _nSlotId,
+ sal_uInt16 _nId,
+ StatusBar& rStb ) :
+ SvxZoomStatusBarControl( _nSlotId, _nId, rStb )
+{
+}
+
+SwZoomControl::~SwZoomControl()
+{
+}
+
+void SwZoomControl::StateChanged( sal_uInt16 nSID, SfxItemState eState,
+ const SfxPoolItem* pState )
+{
+ if(SFX_ITEM_AVAILABLE == eState && pState->ISA( SfxStringItem ))
+ {
+ sPreviewZoom = ((const SfxStringItem*)pState)->GetValue();
+ GetStatusBar().SetItemText( GetId(), sPreviewZoom );
+ }
+ else
+ {
+ sPreviewZoom = OUString();
+ SvxZoomStatusBarControl::StateChanged(nSID, eState, pState);
+ }
+}
+
+void SwZoomControl::Paint( const UserDrawEvent& rUsrEvt )
+{
+ if(sPreviewZoom.isEmpty())
+ SvxZoomStatusBarControl::Paint(rUsrEvt);
+ else
+ GetStatusBar().SetItemText( GetId(), sPreviewZoom );
+}
+
+void SwZoomControl::Command( const CommandEvent& rCEvt )
+{
+ if(sPreviewZoom.isEmpty())
+ SvxZoomStatusBarControl::Command(rCEvt);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/web/wdocsh.cxx b/sw/source/core/uibase/web/wdocsh.cxx
new file mode 100644
index 000000000000..ac44c7d16c4a
--- /dev/null
+++ b/sw/source/core/uibase/web/wdocsh.cxx
@@ -0,0 +1,86 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <svl/srchitem.hxx>
+#include <sfx2/app.hxx>
+#include <svx/svxids.hrc>
+
+#include <comphelper/classids.hxx>
+#include <sfx2/objface.hxx>
+
+#include <sfx2/msg.hxx>
+#include "cfgid.h"
+#include "cmdid.h"
+#include "swtypes.hxx"
+
+#include "shellio.hxx"
+// just because of the itemtypes
+#include "wdocsh.hxx"
+#include "web.hrc"
+
+#define SwWebDocShell
+#include "swslots.hxx"
+
+#include <unomid.h>
+
+SFX_IMPL_INTERFACE( SwWebDocShell, SfxObjectShell, SW_RES(0) )
+{
+}
+
+TYPEINIT1(SwWebDocShell, SwDocShell);
+
+SFX_IMPL_OBJECTFACTORY(SwWebDocShell, SvGlobalName(SO3_SWWEB_CLASSID), SFXOBJECTSHELL_STD_NORMAL|SFXOBJECTSHELL_HASMENU, "swriter/web" )
+
+SwWebDocShell::SwWebDocShell(SfxObjectCreateMode eMode ) :
+ SwDocShell(eMode),
+ nSourcePara(0)
+{
+}
+
+SwWebDocShell::~SwWebDocShell()
+{
+}
+
+void SwWebDocShell::FillClass( SvGlobalName * pClassName,
+ sal_uInt32 * pClipFormat,
+ OUString * /*pAppName*/,
+ OUString * pLongUserName,
+ OUString * pUserName,
+ sal_Int32 nVersion,
+ sal_Bool bTemplate /* = sal_False */) const
+{
+ (void)bTemplate;
+ OSL_ENSURE( bTemplate == sal_False, "No template for Writer Web" );
+
+ if (nVersion == SOFFICE_FILEFORMAT_60)
+ {
+ *pClassName = SvGlobalName( SO3_SWWEB_CLASSID_60 );
+ *pClipFormat = SOT_FORMATSTR_ID_STARWRITERWEB_60;
+ *pLongUserName = SW_RESSTR(STR_WRITER_WEBDOC_FULLTYPE);
+ }
+ else if (nVersion == SOFFICE_FILEFORMAT_8)
+ {
+ *pClassName = SvGlobalName( SO3_SWWEB_CLASSID_60 );
+ *pClipFormat = SOT_FORMATSTR_ID_STARWRITERWEB_8;
+ *pLongUserName = SW_RESSTR(STR_WRITER_WEBDOC_FULLTYPE);
+ }
+ *pUserName = SW_RESSTR(STR_HUMAN_SWWEBDOC_NAME);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/web/wformsh.cxx b/sw/source/core/uibase/web/wformsh.cxx
new file mode 100644
index 000000000000..9911d0be198a
--- /dev/null
+++ b/sw/source/core/uibase/web/wformsh.cxx
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <sfx2/msg.hxx>
+
+#include <svx/svxids.hrc>
+#include <svl/srchitem.hxx>
+#include <sfx2/objface.hxx>
+#include <tools/globname.hxx>
+#include <sfx2/app.hxx>
+
+#include "swtypes.hxx"
+#include "cmdid.h"
+#include "wformsh.hxx"
+#include "globals.hrc"
+#include "web.hrc"
+#include "popup.hrc"
+#include "shells.hrc"
+
+#define SwWebDrawFormShell
+#include "swslots.hxx"
+
+SFX_IMPL_INTERFACE(SwWebDrawFormShell, SwDrawFormShell, SW_RES(0))
+{
+ SFX_POPUPMENU_REGISTRATION(SW_RES(MN_DRAWFORM_POPUPMENU));
+ SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_TEXT_TOOLBOX));
+}
+
+TYPEINIT1(SwWebDrawFormShell, SwDrawFormShell)
+
+SwWebDrawFormShell::SwWebDrawFormShell(SwView& rVw) :
+ SwDrawFormShell(rVw)
+{
+}
+
+SwWebDrawFormShell::~SwWebDrawFormShell()
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/web/wfrmsh.cxx b/sw/source/core/uibase/web/wfrmsh.cxx
new file mode 100644
index 000000000000..d2697400f983
--- /dev/null
+++ b/sw/source/core/uibase/web/wfrmsh.cxx
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "hintids.hxx"
+#include <sfx2/app.hxx>
+#include <sfx2/objface.hxx>
+#include <svl/srchitem.hxx>
+#include "swtypes.hxx"
+#include "cmdid.h"
+#include "view.hxx"
+#include "wfrmsh.hxx"
+#include "globals.hrc"
+#include "popup.hrc"
+#include "shells.hrc"
+#include "web.hrc"
+
+// STATIC DATA
+#define SwWebFrameShell
+#include <sfx2/msg.hxx>
+#include "swslots.hxx"
+
+SFX_IMPL_INTERFACE(SwWebFrameShell, SwFrameShell, SW_RES(STR_SHELLNAME_WEBFRAME))
+{
+ SFX_POPUPMENU_REGISTRATION(SW_RES(MN_FRM_POPUPMENU));
+ SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_WEBFRAME_TOOLBOX));
+}
+
+TYPEINIT1(SwWebFrameShell, SwFrameShell)
+
+SwWebFrameShell::SwWebFrameShell(SwView &_rView) :
+ SwFrameShell(_rView)
+{
+ SetHelpId(SW_WEBFRAMESHELL);
+}
+
+SwWebFrameShell::~SwWebFrameShell()
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/web/wgrfsh.cxx b/sw/source/core/uibase/web/wgrfsh.cxx
new file mode 100644
index 000000000000..042b4ddbbefd
--- /dev/null
+++ b/sw/source/core/uibase/web/wgrfsh.cxx
@@ -0,0 +1,61 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <sfx2/msg.hxx>
+#include <svl/srchitem.hxx>
+#include <sfx2/app.hxx>
+
+#include <sfx2/objface.hxx>
+
+#include "cmdid.h"
+#include "view.hxx"
+#include "wrtsh.hxx"
+#include "swmodule.hxx"
+#include "uitool.hxx"
+#include "docsh.hxx"
+#include "shells.hrc"
+#include "popup.hrc"
+#include "globals.hrc"
+#include "web.hrc"
+#include "wgrfsh.hxx"
+
+#define SwWebGrfShell
+#include "swslots.hxx"
+
+SFX_IMPL_INTERFACE(SwWebGrfShell, SwGrfShell, SW_RES(STR_SHELLNAME_GRAPHIC))
+{
+ SFX_POPUPMENU_REGISTRATION(SW_RES(MN_GRF_POPUPMENU));
+ SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_WEBGRAPHIC_TOOLBOX));
+}
+
+TYPEINIT1(SwWebGrfShell,SwGrfShell)
+
+SwWebGrfShell::SwWebGrfShell(SwView &_rView) :
+ SwGrfShell(_rView)
+
+{
+ SetName(OUString("Graphic"));
+ SetHelpId(SW_GRFSHELL);
+}
+
+SwWebGrfShell::~SwWebGrfShell()
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/web/wlistsh.cxx b/sw/source/core/uibase/web/wlistsh.cxx
new file mode 100644
index 000000000000..7bca24fcf64e
--- /dev/null
+++ b/sw/source/core/uibase/web/wlistsh.cxx
@@ -0,0 +1,55 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <sfx2/msg.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/objface.hxx>
+#include <svl/srchitem.hxx>
+#include <svx/imapdlg.hxx>
+
+#include "cmdid.h"
+#include "wrtsh.hxx"
+#include "swmodule.hxx"
+#include "globals.hrc"
+#include "shells.hrc"
+#include "uinums.hxx"
+#include "wlistsh.hxx"
+
+#define SwWebListShell
+#include "swslots.hxx"
+
+SFX_IMPL_INTERFACE(SwWebListShell, SwListShell, SW_RES(STR_SHELLNAME_LIST))
+{
+ SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_NUM_TOOLBOX));
+}
+
+TYPEINIT1(SwWebListShell,SwListShell)
+
+SwWebListShell::SwWebListShell(SwView &_rView) :
+ SwListShell(_rView)
+{
+ SetName(OUString("List"));
+ SetHelpId(SW_LISTSHELL);
+}
+
+SwWebListShell::~SwWebListShell()
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/web/wolesh.cxx b/sw/source/core/uibase/web/wolesh.cxx
new file mode 100644
index 000000000000..bf8359c8ef47
--- /dev/null
+++ b/sw/source/core/uibase/web/wolesh.cxx
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <sfx2/msg.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/objface.hxx>
+#include <svl/srchitem.hxx>
+
+#include "wrtsh.hxx"
+#include "view.hxx"
+#include "helpid.h"
+#include "globals.hrc"
+#include "web.hrc"
+#include "popup.hrc"
+#include "shells.hrc"
+#include "wolesh.hxx"
+#include "cmdid.h"
+
+#define SwWebOleShell
+#include "swslots.hxx"
+
+SFX_IMPL_INTERFACE(SwWebOleShell, SwOleShell, SW_RES(STR_SHELLNAME_OBJECT))
+{
+ SFX_POPUPMENU_REGISTRATION(SW_RES(MN_OLE_POPUPMENU));
+ SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_WEBOLE_TOOLBOX));
+}
+
+SwWebOleShell::SwWebOleShell(SwView &_rView) :
+ SwOleShell(_rView)
+
+{
+ SetName(OUString("Object"));
+ SetHelpId(SW_OLESHELL);
+}
+
+SwWebOleShell::~SwWebOleShell()
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/web/wtabsh.cxx b/sw/source/core/uibase/web/wtabsh.cxx
new file mode 100644
index 000000000000..ca24430380fd
--- /dev/null
+++ b/sw/source/core/uibase/web/wtabsh.cxx
@@ -0,0 +1,61 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "hintids.hxx"
+#include <sfx2/app.hxx>
+#include <tools/globname.hxx>
+#include <sfx2/objface.hxx>
+#include <svl/srchitem.hxx>
+
+#include "cmdid.h"
+#include "globals.hrc"
+#include "uitool.hxx"
+#include "helpid.h"
+#include "popup.hrc"
+#include "shells.hrc"
+#include "table.hrc"
+#include "wrtsh.hxx"
+#include "wtabsh.hxx"
+
+#define SwWebTableShell
+#include <sfx2/msg.hxx>
+#include "svx/svxids.hrc"
+#include "swslots.hxx"
+
+SFX_IMPL_INTERFACE(SwWebTableShell, SwTableShell, SW_RES(STR_SHELLNAME_TABLE))
+{
+ SFX_POPUPMENU_REGISTRATION(SW_RES(MN_TAB_POPUPMENU));
+ SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_TABLE_TOOLBOX));
+}
+
+TYPEINIT1(SwWebTableShell,SwTableShell)
+
+SwWebTableShell::SwWebTableShell(SwView &_rView) :
+ SwTableShell(_rView)
+{
+ GetShell().UpdateTable();
+ SetName(OUString("Table"));
+ SetHelpId(SW_TABSHELL);
+}
+
+SwWebTableShell::~SwWebTableShell()
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/web/wtextsh.cxx b/sw/source/core/uibase/web/wtextsh.cxx
new file mode 100644
index 000000000000..16299b4f2e68
--- /dev/null
+++ b/sw/source/core/uibase/web/wtextsh.cxx
@@ -0,0 +1,64 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "hintids.hxx"
+#include <sfx2/objface.hxx>
+#include <sfx2/app.hxx>
+#include <svl/srchitem.hxx>
+#include <basic/sbxvar.hxx>
+#include <svx/svxids.hrc>
+
+#include "swtypes.hxx"
+#include "cmdid.h"
+#include "view.hxx"
+#include "wtextsh.hxx"
+#include "basesh.hxx"
+#include "globals.hrc"
+#include "popup.hrc"
+#include "shells.hrc"
+#include "web.hrc"
+
+#include <unomid.h>
+
+// STATIC DATA
+#define SwWebTextShell
+#include <sfx2/msg.hxx>
+#include "swslots.hxx"
+
+SFX_IMPL_INTERFACE(SwWebTextShell, SwBaseShell, SW_RES(STR_SHELLNAME_WEBTEXT))
+{
+ SFX_POPUPMENU_REGISTRATION(SW_RES(MN_TEXT_POPUPMENU));
+ SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_TEXT_TOOLBOX));
+ SFX_CHILDWINDOW_REGISTRATION(FN_EDIT_FORMULA);
+ SFX_CHILDWINDOW_REGISTRATION(FN_INSERT_FIELD);
+}
+
+TYPEINIT1(SwWebTextShell, SwTextShell)
+
+SwWebTextShell::SwWebTextShell(SwView &_rView) :
+ SwTextShell(_rView)
+{
+ SetHelpId(SW_WEBTEXTSHELL);
+}
+
+SwWebTextShell::~SwWebTextShell()
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/web/wview.cxx b/sw/source/core/uibase/web/wview.cxx
new file mode 100644
index 000000000000..5e733721c280
--- /dev/null
+++ b/sw/source/core/uibase/web/wview.cxx
@@ -0,0 +1,288 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <sfx2/msg.hxx>
+#include <svl/srchitem.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/infobar.hxx>
+#include <sfx2/templdlg.hxx>
+#include <svx/srchdlg.hxx>
+#include <basic/sbxobj.hxx>
+#include <uivwimp.hxx>
+#include <svx/fmshell.hxx>
+#include <svx/extrusionbar.hxx>
+#include <svx/fontworkbar.hxx>
+
+#include <sfx2/objface.hxx>
+#include <swmodule.hxx>
+#include <unotxvw.hxx>
+#include <swtypes.hxx>
+#include <cmdid.h>
+#include <globals.hrc>
+#include <wrtsh.hxx>
+#include <edtwin.hxx>
+#include <wgrfsh.hxx>
+#include <wfrmsh.hxx>
+#include <wolesh.hxx>
+#include <wtabsh.hxx>
+#include <wlistsh.hxx>
+#include <wformsh.hxx>
+#include <wtextsh.hxx>
+#include <barcfg.hxx>
+#include <doc.hxx>
+
+// TECHNICALLY not possible !!
+#include <beziersh.hxx>
+#include <drawsh.hxx>
+#include <drwtxtsh.hxx>
+#include <annotsh.hxx>
+
+#include <wview.hxx>
+#include <wdocsh.hxx>
+#include <web.hrc>
+#include <shells.hrc>
+
+#define SwWebView
+#define Text
+#define TextInTable
+#define ListInText
+#define ListInTable
+#include <swslots.hxx>
+
+SFX_IMPL_NAMED_VIEWFACTORY(SwWebView, "Default")
+{
+ SFX_VIEW_REGISTRATION(SwWebDocShell);
+}
+
+SFX_IMPL_INTERFACE( SwWebView, SwView, SW_RES(RID_WEBTOOLS_TOOLBOX) )
+{
+ SFX_CHILDWINDOW_REGISTRATION(SfxTemplateDialogWrapper::GetChildWindowId());
+ SFX_CHILDWINDOW_REGISTRATION(SvxSearchDialogWrapper::GetChildWindowId());
+ SFX_CHILDWINDOW_REGISTRATION(SfxInfoBarContainerChild::GetChildWindowId());
+ SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_TOOLS|
+ SFX_VISIBILITY_STANDARD|SFX_VISIBILITY_SERVER,
+ SW_RES(RID_WEBTOOLS_TOOLBOX) );
+}
+
+TYPEINIT1(SwWebView,SwView)
+
+SwWebView::SwWebView(SfxViewFrame* _pFrame, SfxViewShell* _pShell) :
+ SwView(_pFrame, _pShell)
+{
+}
+
+SwWebView::~SwWebView()
+{
+}
+
+void SwWebView::SelectShell()
+{
+ // Decision whether UpdateTable must be called
+ bool bUpdateTable = false;
+ const SwFrmFmt* pCurTableFmt = GetWrtShell().GetTableFmt();
+ if(pCurTableFmt && pCurTableFmt != GetLastTblFrmFmt())
+ {
+ bUpdateTable = true; // can only be executed later
+ }
+ SetLastTblFrmFmt(pCurTableFmt);
+ //SEL_TBL and SEL_TBL_CELLS can be ored!
+ int nNewSelectionType = (GetWrtShell().GetSelectionType()
+ & ~nsSelectionType::SEL_TBL_CELLS);
+
+ int _nSelectionType = GetSelectionType();
+ if ( nNewSelectionType == _nSelectionType )
+ {
+ GetViewFrame()->GetBindings().InvalidateAll( sal_False );
+ if ( _nSelectionType & nsSelectionType::SEL_OLE ||
+ _nSelectionType & nsSelectionType::SEL_GRF )
+ //The verb may of course change for graphics and OLE!
+ ImpSetVerb( nNewSelectionType );
+ }
+ else
+ {
+ SfxDispatcher &rDispatcher = *GetViewFrame()->GetDispatcher();
+ SwToolbarConfigItem *pBarCfg = SW_MOD()->GetWebToolbarConfig();
+
+ if( GetCurShell() )
+ {
+ rDispatcher.Flush(); // really delete all cached shells
+
+ //Additional to the old selection remember which toolbar was visible.
+ sal_Int32 nId = rDispatcher.GetObjectBarId( SFX_OBJECTBAR_OBJECT );
+ if ( nId )
+ pBarCfg->SetTopToolbar( _nSelectionType, nId );
+
+ SfxShell *pSfxShell;
+ sal_uInt16 i;
+ for ( i = 0; true; ++i )
+ {
+ pSfxShell = rDispatcher.GetShell( i );
+ if ( !( pSfxShell->ISA( SwBaseShell ) ||
+ pSfxShell->ISA( SwDrawTextShell ) || pSfxShell->ISA( SwAnnotationShell ) ) )
+ break;
+ }
+ pSfxShell = rDispatcher.GetShell( --i );
+ OSL_ENSURE( pSfxShell, "My Shell ist lost in space" );
+ rDispatcher.Pop( *pSfxShell, SFX_SHELL_POP_UNTIL | SFX_SHELL_POP_DELETE);
+ }
+
+ bool bInitFormShell = false;
+ if( !GetFormShell() )
+ {
+ bInitFormShell = true;
+ SetFormShell( new FmFormShell( this ) );
+ rDispatcher.Push( *GetFormShell() );
+ }
+
+ bool bSetExtInpCntxt = false;
+ _nSelectionType = nNewSelectionType;
+ SetSelectionType( _nSelectionType );
+ ShellModes eShellMode;
+
+ if ( _nSelectionType & nsSelectionType::SEL_OLE )
+ {
+ eShellMode = SHELL_MODE_OBJECT;
+ SetShell( new SwWebOleShell( *this ));
+ rDispatcher.Push( *GetCurShell() );
+ }
+ else if ( _nSelectionType & nsSelectionType::SEL_FRM
+ || _nSelectionType & nsSelectionType::SEL_GRF)
+ {
+ eShellMode = SHELL_MODE_FRAME;
+ SetShell( new SwWebFrameShell( *this ));
+ rDispatcher.Push( *GetCurShell() );
+ if(_nSelectionType & nsSelectionType::SEL_GRF )
+ {
+ eShellMode = SHELL_MODE_GRAPHIC;
+ SetShell( new SwWebGrfShell( *this ));
+ rDispatcher.Push( *GetCurShell() );
+ }
+ }
+ else if ( _nSelectionType & nsSelectionType::SEL_FRM )
+ {
+ eShellMode = SHELL_MODE_FRAME;
+ SetShell( new SwWebFrameShell( *this ));
+ rDispatcher.Push( *GetCurShell() );
+ }
+ else if ( _nSelectionType & nsSelectionType::SEL_DRW )
+ {
+ eShellMode = SHELL_MODE_DRAW;
+ SetShell( new svx::ExtrusionBar( this ) );
+ rDispatcher.Push( *GetCurShell() );
+
+ SetShell( new svx::FontworkBar( this ) );
+ rDispatcher.Push( *GetCurShell() );
+
+ SetShell( new SwDrawShell( *this ));
+ rDispatcher.Push( *GetCurShell() );
+ if ( _nSelectionType & nsSelectionType::SEL_BEZ )
+ {
+ eShellMode = SHELL_MODE_BEZIER;
+ SetShell( new SwBezierShell( *this ));
+ rDispatcher.Push( *GetCurShell() );
+ }
+
+ }
+ else if ( _nSelectionType & nsSelectionType::SEL_DRW_FORM )
+ {
+ eShellMode = SHELL_MODE_DRAW_FORM;
+ SetShell( new SwWebDrawFormShell( *this ));
+
+ rDispatcher.Push( *GetCurShell() );
+ }
+ else if ( _nSelectionType & nsSelectionType::SEL_DRW_TXT )
+ {
+ eShellMode = SHELL_MODE_DRAWTEXT;
+ rDispatcher.Push( *(new SwBaseShell( *this )) );
+ SetShell( new SwDrawTextShell( *this ));
+ rDispatcher.Push( *GetCurShell() );
+ }
+ else if ( _nSelectionType & nsSelectionType::SEL_POSTIT )
+ {
+ eShellMode = SHELL_MODE_POSTIT;
+ SetShell( new SwAnnotationShell( *this ) );
+ rDispatcher.Push( *GetCurShell() );
+ }
+ else
+ {
+ bSetExtInpCntxt = true;
+ eShellMode = SHELL_MODE_TEXT;
+ if ( _nSelectionType & nsSelectionType::SEL_NUM )
+ {
+ eShellMode = SHELL_MODE_LIST_TEXT;
+ SetShell( new SwWebListShell( *this ));
+ rDispatcher.Push( *GetCurShell() );
+ }
+ SetShell( new SwWebTextShell(*this));
+ rDispatcher.Push( *GetCurShell() );
+ if ( _nSelectionType & nsSelectionType::SEL_TBL )
+ {
+ eShellMode = eShellMode == SHELL_MODE_LIST_TEXT ? SHELL_MODE_TABLE_LIST_TEXT
+ : SHELL_MODE_TABLE_TEXT;
+ SetShell( new SwWebTableShell( *this ));
+ rDispatcher.Push( *GetCurShell() );
+ }
+ }
+ ImpSetVerb( _nSelectionType );
+ GetViewImpl()->SetShellMode(eShellMode);
+
+ if( !GetDocShell()->IsReadOnly() )
+ {
+ if( bSetExtInpCntxt && GetWrtShell().HasReadonlySel() )
+ bSetExtInpCntxt = false;
+
+ InputContext aCntxt( GetEditWin().GetInputContext() );
+ aCntxt.SetOptions( bSetExtInpCntxt
+ ? (aCntxt.GetOptions() |
+ ( INPUTCONTEXT_TEXT |
+ INPUTCONTEXT_EXTTEXTINPUT ))
+ : (aCntxt.GetOptions() & ~
+ ( INPUTCONTEXT_TEXT |
+ INPUTCONTEXT_EXTTEXTINPUT )) );
+ GetEditWin().SetInputContext( aCntxt );
+ }
+
+ //Additional to the selection enable the toolbar, which was
+ //activated last time
+ //Before must be a Flush(), but concerns according to MBA not the
+ //user interface and is not a performance issue.
+ // TODO/LATER: maybe now the Flush() command is superfluous?!
+ rDispatcher.Flush();
+
+ Point aPnt = GetEditWin().GetPointerPosPixel();
+ aPnt = GetEditWin().PixelToLogic(aPnt);
+ GetEditWin().UpdatePointer(aPnt);
+
+ if ( bInitFormShell && GetWrtShell().GetDrawView() )
+ GetFormShell()->SetView( PTR_CAST( FmFormView,
+ GetWrtShell().GetDrawView()));
+
+ }
+ GetViewImpl()->GetUNOObject_Impl()->NotifySelChanged();
+
+ //Opportune time for the communication with OLE objects?
+ if ( GetDocShell()->GetDoc()->IsOLEPrtNotifyPending() )
+ GetDocShell()->GetDoc()->PrtOLENotify( sal_False );
+
+ //now the table update
+ if(bUpdateTable)
+ GetWrtShell().UpdateTable();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/wrtsh/delete.cxx b/sw/source/core/uibase/wrtsh/delete.cxx
new file mode 100644
index 000000000000..7d95390ce8e9
--- /dev/null
+++ b/sw/source/core/uibase/wrtsh/delete.cxx
@@ -0,0 +1,543 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <wrtsh.hxx>
+#include <crsskip.hxx>
+#include <swcrsr.hxx>
+#include <editeng/lrspitem.hxx>
+// #134369#
+#include <view.hxx>
+#include <drawbase.hxx>
+
+inline void SwWrtShell::OpenMark()
+{
+ StartAllAction();
+ ResetCursorStack();
+ KillPams();
+ SetMark();
+}
+
+inline void SwWrtShell::CloseMark( bool bOkFlag )
+{
+ if( bOkFlag )
+ UpdateAttr();
+ else
+ SwapPam();
+
+ ClearMark();
+ EndAllAction();
+}
+
+// #i23725#
+bool SwWrtShell::TryRemoveIndent()
+{
+ bool bResult = false;
+
+ SfxItemSet aAttrSet(GetAttrPool(), RES_LR_SPACE, RES_LR_SPACE);
+ GetCurAttr(aAttrSet);
+
+ SvxLRSpaceItem aItem = (const SvxLRSpaceItem &)aAttrSet.Get(RES_LR_SPACE);
+ short aOldFirstLineOfst = aItem.GetTxtFirstLineOfst();
+
+ if (aOldFirstLineOfst > 0)
+ {
+ aItem.SetTxtFirstLineOfst(0);
+ bResult = true;
+ }
+ else if (aOldFirstLineOfst < 0)
+ {
+ aItem.SetTxtFirstLineOfst(0);
+ aItem.SetLeft(aItem.GetLeft() + aOldFirstLineOfst);
+
+ bResult = true;
+ }
+ else if (aItem.GetLeft() != 0)
+ {
+ aItem.SetLeft(0);
+ bResult = true;
+ }
+
+ if (bResult)
+ {
+ aAttrSet.Put(aItem);
+ SetAttrSet(aAttrSet);
+ }
+
+ return bResult;
+}
+
+/** Description: Erase the line. */
+
+long SwWrtShell::DelLine()
+{
+ SwActContext aActContext(this);
+ ResetCursorStack();
+ // remember the old cursor
+ Push();
+ ClearMark();
+ SwCrsrShell::LeftMargin();
+ SetMark();
+ SwCrsrShell::RightMargin();
+
+ long nRet = Delete();
+ Pop(sal_False);
+ if( nRet )
+ UpdateAttr();
+ return nRet;
+}
+
+long SwWrtShell::DelToStartOfLine()
+{
+ OpenMark();
+ SwCrsrShell::LeftMargin();
+ long nRet = Delete();
+ CloseMark( 0 != nRet );
+ return nRet;
+}
+
+long SwWrtShell::DelToEndOfLine()
+{
+ OpenMark();
+ SwCrsrShell::RightMargin();
+ long nRet = Delete();
+ CloseMark( 0 != nRet );
+ return 1;
+}
+
+long SwWrtShell::DelLeft()
+{
+ // If it's a Fly, throw it away
+ int nSelType = GetSelectionType();
+ const int nCmp = nsSelectionType::SEL_FRM | nsSelectionType::SEL_GRF | nsSelectionType::SEL_OLE | nsSelectionType::SEL_DRW;
+ if( nCmp & nSelType )
+ {
+ // #108205# Remember object's position.
+ Point aTmpPt = GetObjRect().TopLeft();
+
+ DelSelectedObj();
+
+ // #108205# Set cursor to remembered position.
+ SetCrsr(&aTmpPt);
+
+ LeaveSelFrmMode();
+ UnSelectFrm();
+
+ nSelType = GetSelectionType();
+ if ( nCmp & nSelType )
+ {
+ EnterSelFrmMode();
+ GotoNextFly();
+ }
+
+ return 1L;
+ }
+
+ // If a selection exists, erase this
+ if ( IsSelection() )
+ {
+ if( !IsBlockMode() || HasSelection() )
+ {
+ //OS: Once again Basic: SwActContext must be leaved
+ //before EnterStdMode!
+ {
+ SwActContext aActContext(this);
+ ResetCursorStack();
+ Delete();
+ UpdateAttr();
+ }
+ if( IsBlockMode() )
+ {
+ NormalizePam();
+ ClearMark();
+ EnterBlockMode();
+ }
+ else
+ EnterStdMode();
+ return 1L;
+ }
+ else
+ EnterStdMode();
+ }
+
+ // JP 29.06.95: never erase a table standing in front of it.
+ bool bSwap = false;
+ const SwTableNode * pWasInTblNd = SwCrsrShell::IsCrsrInTbl();
+
+ if( SwCrsrShell::IsSttPara())
+ {
+ // #i4032# Don't actually call a 'delete' if we
+ // changed the table cell, compare DelRight().
+ const SwStartNode * pSNdOld = pWasInTblNd ?
+ GetSwCrsr()->GetNode()->FindTableBoxStartNode() :
+ 0;
+
+ // If the cursor is at the beginning of a paragraph, try to step
+ // backwards. On failure we are done.
+ if( !SwCrsrShell::Left(1,CRSR_SKIP_CHARS) )
+ return 0;
+
+ // If the cursor entered or left a table (or both) we are done. No step
+ // back.
+ const SwTableNode* pIsInTblNd = SwCrsrShell::IsCrsrInTbl();
+ if( pIsInTblNd != pWasInTblNd )
+ return 0;
+
+ const SwStartNode* pSNdNew = pIsInTblNd ?
+ GetSwCrsr()->GetNode()->FindTableBoxStartNode() :
+ 0;
+
+ // #i4032# Don't actually call a 'delete' if we
+ // changed the table cell, compare DelRight().
+ if ( pSNdOld != pSNdNew )
+ return 0;
+
+ OpenMark();
+ SwCrsrShell::Right(1,CRSR_SKIP_CHARS);
+ SwCrsrShell::SwapPam();
+ bSwap = true;
+ }
+ else
+ {
+ OpenMark();
+ SwCrsrShell::Left(1,CRSR_SKIP_CHARS);
+ }
+ long nRet = Delete();
+ if( !nRet && bSwap )
+ SwCrsrShell::SwapPam();
+ CloseMark( 0 != nRet );
+ return nRet;
+}
+
+long SwWrtShell::DelRight()
+{
+ // Will be or'ed, if a tableselection exists;
+ // will here be implemented on nsSelectionType::SEL_TBL
+ long nRet = 0;
+ int nSelection = GetSelectionType();
+ if(nSelection & nsSelectionType::SEL_TBL_CELLS)
+ nSelection = nsSelectionType::SEL_TBL;
+ if(nSelection & nsSelectionType::SEL_TXT)
+ nSelection = nsSelectionType::SEL_TXT;
+
+ const SwTableNode * pWasInTblNd = NULL;
+
+ switch( nSelection & ~(nsSelectionType::SEL_BEZ) )
+ {
+ case nsSelectionType::SEL_POSTIT:
+ case nsSelectionType::SEL_TXT:
+ case nsSelectionType::SEL_TBL:
+ case nsSelectionType::SEL_NUM:
+ // If a selection exists, erase it.
+ if( IsSelection() )
+ {
+ if( !IsBlockMode() || HasSelection() )
+ {
+ //OS: And once again Basic: SwActContext must be
+ //leaved before EnterStdMode !
+ {
+ SwActContext aActContext(this);
+ ResetCursorStack();
+ Delete();
+ UpdateAttr();
+ }
+ if( IsBlockMode() )
+ {
+ NormalizePam();
+ ClearMark();
+ EnterBlockMode();
+ }
+ else
+ EnterStdMode();
+ nRet = 1L;
+ break;
+ }
+ else
+ EnterStdMode();
+ }
+
+ pWasInTblNd = IsCrsrInTbl();
+
+ if( nsSelectionType::SEL_TXT & nSelection && SwCrsrShell::IsSttPara() &&
+ SwCrsrShell::IsEndPara() )
+ {
+ // save cursor
+ SwCrsrShell::Push();
+
+ bool bDelFull = false;
+ if ( SwCrsrShell::Right(1,CRSR_SKIP_CHARS) )
+ {
+ const SwTableNode * pCurrTblNd = IsCrsrInTbl();
+ bDelFull = pCurrTblNd && pCurrTblNd != pWasInTblNd;
+ }
+
+ // restore cursor
+ SwCrsrShell::Pop( sal_False );
+
+ if( bDelFull )
+ {
+ DelFullPara();
+ UpdateAttr();
+ break;
+ }
+ }
+
+ {
+ // #108049# Save the startnode of the current cell
+ const SwStartNode * pSNdOld;
+ pSNdOld = GetSwCrsr()->GetNode()->
+ FindTableBoxStartNode();
+
+ if ( SwCrsrShell::IsEndPara() )
+ {
+ // #i41424# Introduced a couple of
+ // Push()-Pop() pairs here. The reason for this is that a
+ // Right()-Left() combination does not make sure, that
+ // the cursor will be in its initial state, because there
+ // may be a numbering in front of the next paragraph.
+ SwCrsrShell::Push();
+
+ if ( SwCrsrShell::Right(1, CRSR_SKIP_CHARS) )
+ {
+ if (IsCrsrInTbl() || (pWasInTblNd != IsCrsrInTbl()))
+ {
+ /** #108049# Save the startnode of the current
+ cell. May be different to pSNdOld as we have
+ moved. */
+ const SwStartNode * pSNdNew = GetSwCrsr()
+ ->GetNode()->FindTableBoxStartNode();
+
+ /** #108049# Only move instead of deleting if we
+ have moved to a different cell */
+ if (pSNdOld != pSNdNew)
+ {
+ SwCrsrShell::Pop( sal_True );
+ break;
+ }
+ }
+ }
+
+ // restore cursor
+ SwCrsrShell::Pop( sal_False );
+ }
+ }
+
+ OpenMark();
+ SwCrsrShell::Right(1,CRSR_SKIP_CELLS);
+ nRet = Delete();
+ CloseMark( 0 != nRet );
+ break;
+
+ case nsSelectionType::SEL_FRM:
+ case nsSelectionType::SEL_GRF:
+ case nsSelectionType::SEL_OLE:
+ case nsSelectionType::SEL_DRW:
+ case nsSelectionType::SEL_DRW_TXT:
+ case nsSelectionType::SEL_DRW_FORM:
+ {
+ // #108205# Remember object's position.
+ Point aTmpPt = GetObjRect().TopLeft();
+
+ DelSelectedObj();
+
+ // #108205# Set cursor to remembered position.
+ SetCrsr(&aTmpPt);
+
+ LeaveSelFrmMode();
+ UnSelectFrm();
+ // #134369#
+ OSL_ENSURE( !IsFrmSelected(),
+ "<SwWrtShell::DelRight(..)> - <SwWrtShell::UnSelectFrm()> should unmark all objects" );
+ // #134369#
+ // leave draw mode, if necessary.
+ {
+ if (GetView().GetDrawFuncPtr())
+ {
+ GetView().GetDrawFuncPtr()->Deactivate();
+ GetView().SetDrawFuncPtr(NULL);
+ }
+ if ( GetView().IsDrawMode() )
+ {
+ GetView().LeaveDrawCreate();
+ }
+ }
+ }
+
+ // #134369#
+ // <IsFrmSelected()> can't be true - see above.
+ {
+ nSelection = GetSelectionType();
+ if ( nsSelectionType::SEL_FRM & nSelection ||
+ nsSelectionType::SEL_GRF & nSelection ||
+ nsSelectionType::SEL_OLE & nSelection ||
+ nsSelectionType::SEL_DRW & nSelection )
+ {
+ EnterSelFrmMode();
+ GotoNextFly();
+ }
+ }
+ nRet = 1;
+ break;
+ }
+ return nRet;
+}
+
+long SwWrtShell::DelToEndOfPara()
+{
+ SwActContext aActContext(this);
+ ResetCursorStack();
+ Push();
+ SetMark();
+ if( !MovePara(fnParaCurr,fnParaEnd))
+ {
+ Pop(sal_False);
+ return 0;
+ }
+ long nRet = Delete();
+ Pop(sal_False);
+ if( nRet )
+ UpdateAttr();
+ return nRet;
+}
+
+long SwWrtShell::DelToStartOfPara()
+{
+ SwActContext aActContext(this);
+ ResetCursorStack();
+ Push();
+ SetMark();
+ if( !MovePara(fnParaCurr,fnParaStart))
+ {
+ Pop(sal_False);
+ return 0;
+ }
+ long nRet = Delete();
+ Pop(sal_False);
+ if( nRet )
+ UpdateAttr();
+ return nRet;
+}
+
+// All erase operations should work with Find instead with
+// Nxt-/PrvDelim, because the latter works with Wrap Around
+// -- that's probably not wished.
+
+long SwWrtShell::DelToStartOfSentence()
+{
+ if(IsStartOfDoc())
+ return 0;
+ OpenMark();
+ long nRet = _BwdSentence() ? Delete() : 0;
+ CloseMark( 0 != nRet );
+ return nRet;
+}
+
+long SwWrtShell::DelToEndOfSentence()
+{
+ if(IsEndOfDoc())
+ return 0;
+ OpenMark();
+ long nRet(0);
+ // fdo#60967: special case that is documented in help: delete
+ // paragraph following table if cursor is at end of last cell in table
+ if (IsEndOfTable())
+ {
+ Push();
+ ClearMark();
+ if (SwCrsrShell::Right(1,CRSR_SKIP_CHARS))
+ {
+ SetMark();
+ SwCrsrShell::MovePara(fnParaCurr, fnParaEnd);
+ if (!IsEndOfDoc()) // do not delete last paragraph in body text
+ {
+ nRet = DelFullPara() ? 1 : 0;
+ }
+ }
+ Pop(false);
+ }
+ else
+ {
+ nRet = _FwdSentence() ? Delete() : 0;
+ }
+ CloseMark( 0 != nRet );
+ return nRet;
+}
+
+long SwWrtShell::DelNxtWord()
+{
+ if(IsEndOfDoc())
+ return 0;
+ SwActContext aActContext(this);
+ ResetCursorStack();
+ EnterStdMode();
+ SetMark();
+ if(IsEndWrd() && !IsSttWrd())
+ _NxtWrdForDelete(); // #i92468#
+ if(IsSttWrd() || IsEndPara())
+ _NxtWrdForDelete(); // #i92468#
+ else
+ _EndWrd();
+
+ long nRet = Delete();
+ if( nRet )
+ UpdateAttr();
+ else
+ SwapPam();
+ ClearMark();
+ return nRet;
+}
+
+long SwWrtShell::DelPrvWord()
+{
+ if(IsStartOfDoc())
+ return 0;
+ SwActContext aActContext(this);
+ ResetCursorStack();
+ EnterStdMode();
+ SetMark();
+ if ( !IsSttWrd() ||
+ !_PrvWrdForDelete() ) // #i92468#
+ {
+ if( IsEndWrd() )
+ {
+ if ( _PrvWrdForDelete() ) // #i92468#
+ {
+ // skip over all spaces
+ short n = 0;
+ while( ' ' == GetChar( sal_False, n ))
+ --n;
+
+ if( ++n )
+ ExtendSelection( sal_False, -n );
+ }
+ }
+ else if( IsSttPara())
+ _PrvWrdForDelete(); // #i92468#
+ else
+ _SttWrd();
+ }
+ long nRet = Delete();
+ if( nRet )
+ UpdateAttr();
+ else
+ SwapPam();
+ ClearMark();
+ return nRet;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/wrtsh/move.cxx b/sw/source/core/uibase/wrtsh/move.cxx
new file mode 100644
index 000000000000..fdd75dfbbe14
--- /dev/null
+++ b/sw/source/core/uibase/wrtsh/move.cxx
@@ -0,0 +1,693 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <sfx2/bindings.hxx>
+#include <wrtsh.hxx>
+#include <view.hxx>
+#include <viewopt.hxx>
+#include <crsskip.hxx>
+
+/**
+ Always:
+ - Reset of the cursor stack
+ - retrigger timer
+ - if applicable: GCAttr
+
+ on selection
+ - SttSelect()
+
+ else
+ - EndSelect()
+ */
+
+const long nReadOnlyScrollOfst = 10;
+
+class ShellMoveCrsr
+{
+ SwWrtShell* pSh;
+ bool bAct;
+public:
+ inline ShellMoveCrsr( SwWrtShell* pWrtSh, sal_Bool bSel )
+ {
+ bAct = !pWrtSh->ActionPend() && (pWrtSh->GetFrmType(0,sal_False) & FRMTYPE_FLY_ANY);
+ ( pSh = pWrtSh )->MoveCrsr( sal_Bool(bSel) );
+ pWrtSh->GetView().GetViewFrame()->GetBindings().Invalidate(SID_HYPERLINK_GETLINK);
+ }
+ inline ~ShellMoveCrsr()
+ {
+ if( bAct )
+ {
+ // The action is used for scrolling in "single paragraph"
+ // frames with fixed height.
+ pSh->StartAllAction();
+ pSh->EndAllAction();
+ }
+ }
+};
+
+void SwWrtShell::MoveCrsr( sal_Bool bWithSelect )
+{
+ ResetCursorStack();
+ if ( IsGCAttr() )
+ {
+ GCAttr();
+ ClearGCAttr();
+ }
+ if ( bWithSelect )
+ SttSelect();
+ else
+ {
+ EndSelect();
+ (this->*fnKillSel)( 0, sal_False );
+ }
+}
+
+sal_Bool SwWrtShell::SimpleMove( FNSimpleMove FnSimpleMove, sal_Bool bSelect )
+{
+ sal_Bool nRet;
+ if( bSelect )
+ {
+ SttCrsrMove();
+ MoveCrsr( sal_True );
+ nRet = (this->*FnSimpleMove)();
+ EndCrsrMove();
+ }
+ else if( 0 != ( nRet = (this->*FnSimpleMove)() ) )
+ MoveCrsr( sal_False );
+ return nRet;
+}
+
+sal_Bool SwWrtShell::Left( sal_uInt16 nMode, sal_Bool bSelect,
+ sal_uInt16 nCount, sal_Bool bBasicCall, sal_Bool bVisual )
+{
+ if ( !bSelect && !bBasicCall && IsCrsrReadonly() && !GetViewOptions()->IsSelectionInReadonly())
+ {
+ Point aTmp( VisArea().Pos() );
+ aTmp.X() -= VisArea().Width() * nReadOnlyScrollOfst / 100;
+ rView.SetVisArea( aTmp );
+ return sal_True;
+ }
+ else
+ {
+ ShellMoveCrsr aTmp( this, bSelect );
+ return SwCrsrShell::Left( nCount, nMode, bVisual );
+ }
+}
+
+sal_Bool SwWrtShell::Right( sal_uInt16 nMode, sal_Bool bSelect,
+ sal_uInt16 nCount, sal_Bool bBasicCall, sal_Bool bVisual )
+{
+ if ( !bSelect && !bBasicCall && IsCrsrReadonly() && !GetViewOptions()->IsSelectionInReadonly() )
+ {
+ Point aTmp( VisArea().Pos() );
+ aTmp.X() += VisArea().Width() * nReadOnlyScrollOfst / 100;
+ aTmp.X() = rView.SetHScrollMax( aTmp.X() );
+ rView.SetVisArea( aTmp );
+ return sal_True;
+ }
+ else
+ {
+ ShellMoveCrsr aTmp( this, bSelect );
+ return SwCrsrShell::Right( nCount, nMode, bVisual );
+ }
+}
+
+sal_Bool SwWrtShell::Up( sal_Bool bSelect, sal_uInt16 nCount, sal_Bool bBasicCall )
+{
+ if ( !bSelect && !bBasicCall && IsCrsrReadonly() && !GetViewOptions()->IsSelectionInReadonly())
+ {
+ Point aTmp( VisArea().Pos() );
+ aTmp.Y() -= VisArea().Height() * nReadOnlyScrollOfst / 100;
+ rView.SetVisArea( aTmp );
+ return sal_True;
+ }
+ else
+ {
+ ShellMoveCrsr aTmp( this, bSelect );
+ return SwCrsrShell::Up( nCount );
+ }
+}
+
+sal_Bool SwWrtShell::Down( sal_Bool bSelect, sal_uInt16 nCount, sal_Bool bBasicCall )
+{
+ if ( !bSelect && !bBasicCall && IsCrsrReadonly() && !GetViewOptions()->IsSelectionInReadonly())
+ {
+ Point aTmp( VisArea().Pos() );
+ aTmp.Y() += VisArea().Height() * nReadOnlyScrollOfst / 100;
+ aTmp.Y() = rView.SetVScrollMax( aTmp.Y() );
+ rView.SetVisArea( aTmp );
+ return sal_True;
+ }
+ else
+ {
+ ShellMoveCrsr aTmp( this, bSelect );
+ return SwCrsrShell::Down( nCount );
+ }
+}
+
+sal_Bool SwWrtShell::LeftMargin( sal_Bool bSelect, sal_Bool bBasicCall )
+{
+ if ( !bSelect && !bBasicCall && IsCrsrReadonly() )
+ {
+ Point aTmp( VisArea().Pos() );
+ aTmp.X() = DOCUMENTBORDER;
+ rView.SetVisArea( aTmp );
+ return sal_True;
+ }
+ else
+ {
+ ShellMoveCrsr aTmp( this, bSelect );
+ return SwCrsrShell::LeftMargin();
+ }
+}
+
+sal_Bool SwWrtShell::RightMargin( sal_Bool bSelect, sal_Bool bBasicCall )
+{
+ if ( !bSelect && !bBasicCall && IsCrsrReadonly() )
+ {
+ Point aTmp( VisArea().Pos() );
+ aTmp.X() = GetDocSize().Width() - VisArea().Width() + DOCUMENTBORDER;
+ if( DOCUMENTBORDER > aTmp.X() )
+ aTmp.X() = DOCUMENTBORDER;
+ rView.SetVisArea( aTmp );
+ return sal_True;
+ }
+ else
+ {
+ ShellMoveCrsr aTmp( this, bSelect );
+ return SwCrsrShell::RightMargin(bBasicCall);
+ }
+}
+
+sal_Bool SwWrtShell::GoStart( sal_Bool bKeepArea, sal_Bool *pMoveTable,
+ sal_Bool bSelect, sal_Bool bDontMoveRegion )
+{
+ if ( IsCrsrInTbl() )
+ {
+ const sal_Bool bBoxSelection = HasBoxSelection();
+ if( !bBlockMode )
+ {
+ if ( !bSelect )
+ EnterStdMode();
+ else
+ SttSelect();
+ }
+ // Table cell ?
+ if ( !bBoxSelection && (MoveSection( fnSectionCurr, fnSectionStart)
+ || bDontMoveRegion))
+ {
+ if ( pMoveTable )
+ *pMoveTable = sal_False;
+ return sal_True;
+ }
+ if( MoveTable( fnTableCurr, fnTableStart ) || bDontMoveRegion )
+ {
+ if ( pMoveTable )
+ *pMoveTable = sal_True;
+ return sal_True;
+ }
+ else if( bBoxSelection && pMoveTable )
+ {
+ // JP 09.01.96: We have a box selection (or a empty cell)
+ // and we want select (pMoveTable will be
+ // set in SelAll). Then the table must not
+ // be left, otherwise there is no selection
+ // of the entire table possible!
+ *pMoveTable = sal_True;
+ return sal_True;
+ }
+ }
+
+ if( !bBlockMode )
+ {
+ if ( !bSelect )
+ EnterStdMode();
+ else
+ SttSelect();
+ }
+ const sal_uInt16 nFrmType = GetFrmType(0,sal_False);
+ if ( FRMTYPE_FLY_ANY & nFrmType )
+ {
+ if( MoveSection( fnSectionCurr, fnSectionStart ) )
+ return sal_True;
+ else if ( FRMTYPE_FLY_FREE & nFrmType || bDontMoveRegion )
+ return sal_False;
+ }
+ if(( FRMTYPE_HEADER | FRMTYPE_FOOTER | FRMTYPE_FOOTNOTE ) & nFrmType )
+ {
+ if ( MoveSection( fnSectionCurr, fnSectionStart ) )
+ return sal_True;
+ else if ( bKeepArea )
+ return sal_True;
+ }
+ // Regions ???
+ return SwCrsrShell::MoveRegion( fnRegionCurrAndSkip, fnRegionStart ) ||
+ SwCrsrShell::SttEndDoc(sal_True);
+}
+
+sal_Bool SwWrtShell::GoEnd(sal_Bool bKeepArea, sal_Bool *pMoveTable)
+{
+ if ( pMoveTable && *pMoveTable )
+ return MoveTable( fnTableCurr, fnTableEnd );
+
+ if ( IsCrsrInTbl() )
+ {
+ if ( MoveSection( fnSectionCurr, fnSectionEnd ) ||
+ MoveTable( fnTableCurr, fnTableEnd ) )
+ return sal_True;
+ }
+ else
+ {
+ const sal_uInt16 nFrmType = GetFrmType(0,sal_False);
+ if ( FRMTYPE_FLY_ANY & nFrmType )
+ {
+ if ( MoveSection( fnSectionCurr, fnSectionEnd ) )
+ return sal_True;
+ else if ( FRMTYPE_FLY_FREE & nFrmType )
+ return sal_False;
+ }
+ if(( FRMTYPE_HEADER | FRMTYPE_FOOTER | FRMTYPE_FOOTNOTE ) & nFrmType )
+ {
+ if ( MoveSection( fnSectionCurr, fnSectionEnd) )
+ return sal_True;
+ else if ( bKeepArea )
+ return sal_True;
+ }
+ }
+ // Regions ???
+ return SwCrsrShell::MoveRegion( fnRegionCurrAndSkip, fnRegionEnd ) ||
+ SwCrsrShell::SttEndDoc(sal_False);
+}
+
+sal_Bool SwWrtShell::SttDoc( sal_Bool bSelect )
+{
+ ShellMoveCrsr aTmp( this, bSelect );
+ return GoStart(sal_False, 0, bSelect );
+}
+
+sal_Bool SwWrtShell::EndDoc( sal_Bool bSelect)
+{
+ ShellMoveCrsr aTmp( this, bSelect );
+ return GoEnd();
+}
+
+sal_Bool SwWrtShell::SttNxtPg( sal_Bool bSelect )
+{
+ ShellMoveCrsr aTmp( this, bSelect );
+ return MovePage( fnPageNext, fnPageStart );
+}
+
+sal_Bool SwWrtShell::SttPrvPg( sal_Bool bSelect )
+{
+ ShellMoveCrsr aTmp( this, bSelect );
+ return MovePage( fnPagePrev, fnPageStart );
+}
+
+sal_Bool SwWrtShell::EndNxtPg( sal_Bool bSelect )
+{
+ ShellMoveCrsr aTmp( this, bSelect );
+ return MovePage( fnPageNext, fnPageEnd );
+}
+
+sal_Bool SwWrtShell::EndPrvPg( sal_Bool bSelect )
+{
+ ShellMoveCrsr aTmp( this, bSelect );
+ return MovePage( fnPagePrev, fnPageEnd );
+}
+
+sal_Bool SwWrtShell::SttPg( sal_Bool bSelect )
+{
+ ShellMoveCrsr aTmp( this, bSelect );
+ return MovePage( fnPageCurr, fnPageStart );
+}
+
+sal_Bool SwWrtShell::EndPg( sal_Bool bSelect )
+{
+ ShellMoveCrsr aTmp( this, bSelect );
+ return MovePage( fnPageCurr, fnPageEnd );
+}
+
+sal_Bool SwWrtShell::SttPara( sal_Bool bSelect )
+{
+ ShellMoveCrsr aTmp( this, bSelect );
+ return MovePara( fnParaCurr, fnParaStart );
+}
+
+sal_Bool SwWrtShell::EndPara( sal_Bool bSelect )
+{
+ ShellMoveCrsr aTmp( this, bSelect );
+ return MovePara(fnParaCurr,fnParaEnd);
+}
+
+// Column-by-jumping.
+// SSelection with or without
+// returns success or failure
+
+sal_Bool SwWrtShell::StartOfColumn( sal_Bool bSelect )
+{
+ ShellMoveCrsr aTmp( this, bSelect);
+ return MoveColumn(fnColumnCurr, fnColumnStart);
+}
+
+sal_Bool SwWrtShell::EndOfColumn( sal_Bool bSelect )
+{
+ ShellMoveCrsr aTmp( this, bSelect);
+ return MoveColumn(fnColumnCurr, fnColumnEnd);
+}
+
+sal_Bool SwWrtShell::StartOfNextColumn( sal_Bool bSelect )
+{
+ ShellMoveCrsr aTmp( this, bSelect);
+ return MoveColumn( fnColumnNext, fnColumnStart);
+}
+
+sal_Bool SwWrtShell::EndOfNextColumn( sal_Bool bSelect )
+{
+ ShellMoveCrsr aTmp( this, bSelect);
+ return MoveColumn(fnColumnNext, fnColumnEnd);
+}
+
+sal_Bool SwWrtShell::StartOfPrevColumn( sal_Bool bSelect )
+{
+ ShellMoveCrsr aTmp( this, bSelect);
+ return MoveColumn(fnColumnPrev, fnColumnStart);
+}
+
+sal_Bool SwWrtShell::EndOfPrevColumn( sal_Bool bSelect )
+{
+ ShellMoveCrsr aTmp( this, bSelect);
+ return MoveColumn(fnColumnPrev, fnColumnEnd);
+}
+
+sal_Bool SwWrtShell::PushCrsr(SwTwips lOffset, sal_Bool bSelect)
+{
+ sal_Bool bDiff = sal_False;
+ SwRect aOldRect( GetCharRect() ), aTmpArea( VisArea() );
+
+ // bDestOnStack indicates if I could not set the coursor at the current
+ // position, because in this region is no content.
+ if( !bDestOnStack )
+ {
+ Point aPt( aOldRect.Center() );
+
+ if( !IsCrsrVisible() )
+ // set CrsrPos to top-/bottom left pos. So the pagescroll is not
+ // be dependent on the current cursor, but on the visarea.
+ aPt.Y() = aTmpArea.Top() + aTmpArea.Height() / 2;
+
+ aPt.Y() += lOffset;
+ aDest = GetCntntPos(aPt,lOffset > 0);
+ aDest.X() = aPt.X();
+ bDestOnStack = true;
+ }
+
+ // If we had a frame selection, it must be removed after the fnSetCrsr
+ // and we have to remember the position on the stack to return to it later.
+ sal_Bool bIsFrmSel = sal_False;
+
+ //Target position is now within the viewable region -->
+ //Place the cursor at the target position; remember that no target
+ //position is longer on the stack.
+ //The new visible region is to be determined beforehand.
+ aTmpArea.Pos().Y() += lOffset;
+ if( aTmpArea.IsInside(aDest) )
+ {
+ if( bSelect )
+ SttSelect();
+ else
+ EndSelect();
+
+ bIsFrmSel = IsFrmSelected();
+ bool bIsObjSel = 0 != IsObjSelected();
+
+ // unselect frame
+ if( bIsFrmSel || bIsObjSel )
+ {
+ UnSelectFrm();
+ LeaveSelFrmMode();
+ if ( bIsObjSel )
+ {
+ GetView().SetDrawFuncPtr( NULL );
+ GetView().LeaveDrawCreate();
+ }
+
+ CallChgLnk();
+ }
+
+ (this->*fnSetCrsr)( &aDest, sal_True );
+
+ bDiff = aOldRect != GetCharRect();
+
+ if( bIsFrmSel )
+ {
+ // In frames take only the upper corner
+ // so that it can be re-selected.
+ aOldRect.SSize( 5, 5 );
+ }
+
+ // reset Dest. SPoint Flags
+ bDestOnStack = false;
+ }
+
+ // Position into the stack; bDiff indicates if there is a
+ // difference between the old and the new cursor position.
+ pCrsrStack = new CrsrStack( bDiff, bIsFrmSel, aOldRect.Center(),
+ lOffset, pCrsrStack );
+ return !bDestOnStack && bDiff;
+}
+
+sal_Bool SwWrtShell::PopCrsr(sal_Bool bUpdate, sal_Bool bSelect)
+{
+ if( 0 == pCrsrStack)
+ return sal_False;
+
+ const sal_Bool bValidPos = pCrsrStack->bValidCurPos;
+ if( bUpdate && bValidPos )
+ {
+ // If a predecessor is on the stack,
+ // use the flag for a valid position.
+ SwRect aTmpArea(VisArea());
+ aTmpArea.Pos().Y() -= pCrsrStack->lOffset;
+ if( aTmpArea.IsInside( pCrsrStack->aDocPos ) )
+ {
+ if( bSelect )
+ SttSelect();
+ else
+ EndSelect();
+
+ (this->*fnSetCrsr)(&pCrsrStack->aDocPos, !pCrsrStack->bIsFrmSel);
+ if( pCrsrStack->bIsFrmSel && IsObjSelectable(pCrsrStack->aDocPos))
+ {
+ HideCrsr();
+ SelectObj( pCrsrStack->aDocPos );
+ EnterSelFrmMode( &pCrsrStack->aDocPos );
+ }
+ }
+ // If a discrepancy between the visible range and the
+ // remembered cursor position occurs, all of the remembered
+ // positions are thrown away.
+ else
+ {
+ _ResetCursorStack();
+ return sal_False;
+ }
+ }
+ CrsrStack *pTmp = pCrsrStack;
+ pCrsrStack = pCrsrStack->pNext;
+ delete pTmp;
+ if( 0 == pCrsrStack )
+ {
+ ePageMove = MV_NO;
+ bDestOnStack = false;
+ }
+ return bValidPos;
+}
+
+// Reset of all pushed cursor positions; these will
+// not be displayed ( --> No Start-/EndAction!!)
+
+void SwWrtShell::_ResetCursorStack()
+{
+ CrsrStack *pTmp = pCrsrStack;
+ while(pCrsrStack)
+ {
+ pTmp = pCrsrStack->pNext;
+ delete pCrsrStack;
+ pCrsrStack = pTmp;
+ }
+ ePageMove = MV_NO;
+ bDestOnStack = false;
+}
+/**
+ if no stack exists --> cancel selection
+ if stack && change of direction
+ --> pop cursor and return
+ else
+ --> push cursor
+ transpose cursor
+*/
+
+sal_Bool SwWrtShell::PageCrsr(SwTwips lOffset, sal_Bool bSelect)
+{
+ // Do nothing if an offset of 0 was indicated
+ if(!lOffset) return sal_False;
+ // Was once used to force a reformat of the layout.
+ // This has not work that way, because the cursor was not set
+ // because this does not happen within a
+ // Start-/EndActionParentheses.
+ // Because only SwViewShell::EndAction() is called at the end,
+ // no updating of the display of the cursor position takes place.
+ // The CrsrShell-Actionparentheses cannot be used, because it
+ // always leads to displaying the cursor, thus also,
+ // if after the scroll scrolled in a region without a valid postition.
+ // SwViewShell::StartAction();
+ PageMove eDir = lOffset > 0? MV_PAGE_DOWN: MV_PAGE_UP;
+ // Change of direction and stack present
+ if( eDir != ePageMove && ePageMove != MV_NO && PopCrsr( sal_True, bSelect ))
+ return sal_True;
+
+ const sal_Bool bRet = PushCrsr(lOffset, bSelect);
+ ePageMove = eDir;
+ return bRet;
+}
+
+sal_Bool SwWrtShell::GotoPage(sal_uInt16 nPage, sal_Bool bRecord)
+{
+ ShellMoveCrsr aTmp( this, sal_False);
+ if( SwCrsrShell::GotoPage(nPage) && bRecord)
+ {
+ if(IsSelFrmMode())
+ {
+ UnSelectFrm();
+ LeaveSelFrmMode();
+ }
+ return sal_True;
+ }
+ return sal_False;
+}
+
+sal_Bool SwWrtShell::GotoMark( const ::sw::mark::IMark* const pMark, sal_Bool bSelect, sal_Bool bStart )
+{
+ ShellMoveCrsr aTmp( this, bSelect );
+ SwPosition aPos = *GetCrsr()->GetPoint();
+ bool bRet = SwCrsrShell::GotoMark( pMark, bStart );
+ if (bRet)
+ aNavigationMgr.addEntry(aPos);
+ return bRet;
+}
+
+sal_Bool SwWrtShell::GotoFly( const OUString& rName, FlyCntType eType, sal_Bool bSelFrame )
+{
+ SwPosition aPos = *GetCrsr()->GetPoint();
+ bool bRet = SwFEShell::GotoFly(rName, eType, bSelFrame);
+ if (bRet)
+ aNavigationMgr.addEntry(aPos);
+ return bRet;
+}
+
+bool SwWrtShell::GotoINetAttr( const SwTxtINetFmt& rAttr )
+{
+ SwPosition aPos = *GetCrsr()->GetPoint();
+ bool bRet = SwCrsrShell::GotoINetAttr(rAttr);
+ if (bRet)
+ aNavigationMgr.addEntry(aPos);
+ return bRet;
+}
+
+void SwWrtShell::GotoOutline( sal_uInt16 nIdx )
+{
+ addCurrentPosition();
+ SwCrsrShell::GotoOutline (nIdx);
+}
+
+bool SwWrtShell::GotoOutline( const OUString& rName )
+{
+ SwPosition aPos = *GetCrsr()->GetPoint();
+ bool bRet = SwCrsrShell::GotoOutline (rName);
+ if (bRet)
+ aNavigationMgr.addEntry(aPos);
+ return bRet;
+}
+
+bool SwWrtShell::GotoRegion( const OUString& rName )
+{
+ SwPosition aPos = *GetCrsr()->GetPoint();
+ bool bRet = SwCrsrShell::GotoRegion (rName);
+ if (bRet)
+ aNavigationMgr.addEntry(aPos);
+ return bRet;
+ }
+
+sal_Bool SwWrtShell::GotoRefMark( const OUString& rRefMark, sal_uInt16 nSubType,
+ sal_uInt16 nSeqNo )
+{
+ SwPosition aPos = *GetCrsr()->GetPoint();
+ bool bRet = SwCrsrShell::GotoRefMark(rRefMark, nSubType, nSeqNo);
+ if (bRet)
+ aNavigationMgr.addEntry(aPos);
+ return bRet;
+}
+
+sal_Bool SwWrtShell::GotoNextTOXBase( const OUString* pName )
+{
+ SwPosition aPos = *GetCrsr()->GetPoint();
+ bool bRet = SwCrsrShell::GotoNextTOXBase(pName);
+ if (bRet)
+ aNavigationMgr.addEntry(aPos);
+ return bRet;
+}
+
+bool SwWrtShell::GotoTable( const OUString& rName )
+{
+ SwPosition aPos = *GetCrsr()->GetPoint();
+ bool bRet = SwCrsrShell::GotoTable(rName);
+ if (bRet)
+ aNavigationMgr.addEntry(aPos);
+ return bRet;
+}
+
+sal_Bool SwWrtShell::GotoFld( const SwFmtFld& rFld ) {
+ SwPosition aPos = *GetCrsr()->GetPoint();
+ bool bRet = SwCrsrShell::GotoFld(rFld);
+ if (bRet)
+ aNavigationMgr.addEntry(aPos);
+ return bRet;
+}
+
+const SwRangeRedline* SwWrtShell::GotoRedline( sal_uInt16 nArrPos, sal_Bool bSelect ) {
+ SwPosition aPos = *GetCrsr()->GetPoint();
+ const SwRangeRedline *pRedline = SwCrsrShell::GotoRedline(nArrPos, bSelect);
+ if (pRedline)
+ aNavigationMgr.addEntry(aPos);
+ return pRedline;
+}
+
+sal_Bool SwWrtShell::SelectTxtAttr( sal_uInt16 nWhich, const SwTxtAttr* pAttr )
+{
+ sal_Bool bRet;
+ {
+ SwMvContext aMvContext(this);
+ SttSelect();
+ bRet = SwCrsrShell::SelectTxtAttr( nWhich, sal_False, pAttr );
+ }
+ EndSelect();
+ return bRet;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/wrtsh/navmgr.cxx b/sw/source/core/uibase/wrtsh/navmgr.cxx
new file mode 100644
index 000000000000..cb4fc1b6cd07
--- /dev/null
+++ b/sw/source/core/uibase/wrtsh/navmgr.cxx
@@ -0,0 +1,228 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "navmgr.hxx"
+#include "wrtsh.hxx"
+#include <sfx2/bindings.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <cmdid.h>
+#include <view.hxx>
+#include <doc.hxx>
+#include <unocrsr.hxx>
+
+#include <com/sun/star/frame/XLayoutManager.hpp>
+
+/**
+ * If SMART is defined, the navigation history has recency with temporal ordering enhancement,
+ * as described on http://zing.ncsl.nist.gov/hfweb/proceedings/greenberg/
+ */
+
+#define SMART 1
+
+// This method positions the cursor to the position rPos.
+
+void SwNavigationMgr::GotoSwPosition(const SwPosition &rPos) {
+ // EnterStdMode() prevents the cursor to 'block' the current
+ // shell when it should move from the image back to the normal shell
+ m_rMyShell.EnterStdMode();
+ m_rMyShell.StartAllAction();
+ // cursor consists of two SwPositions: Point and Mark.
+ // Such a pair is called a PaM. SwPaM is derived from SwRing.
+ // The Ring contains the single regions of a multi-selection.
+ SwPaM* pPaM = m_rMyShell.GetCrsr();
+
+ if(pPaM->HasMark())
+ pPaM->DeleteMark(); // If there was a selection, get rid of it
+ *pPaM->GetPoint() = rPos; // Position Cursor
+
+ m_rMyShell.EndAllAction();
+}
+
+// Ctor for the SwNavigationMgr class
+// Sets the shell to the current shell
+// and the index of the current position to 0
+
+SwNavigationMgr::SwNavigationMgr(SwWrtShell & rShell)
+ : m_nCurrent(0), m_rMyShell(rShell)
+{
+}
+
+// This method is used by the navigation shell - defined in sw/source/ui/inc/navsh.hxx
+// and implemented in sw/source/ui/shells/navsh.cxx
+// It is called when we want to check if the back button should be enabled or not.
+// The back button should be enabled only if there are some entries in the navigation history
+
+bool SwNavigationMgr::backEnabled() {
+ return (m_nCurrent > 0);
+}
+
+// Similar to backEnabled() method.
+// The forward button should be enabled if we ever clicked back
+// Due to the implementation of the navigation class, this is when the
+// current position within the navigation history entries in not the last one
+// i.e. when the m_nCurrent index is not at the end of the m_entries vector
+
+bool SwNavigationMgr::forwardEnabled() {
+ return m_nCurrent+1 < m_entries.size();
+}
+
+// The goBack() method positions the cursor to the previous entry in the navigation history
+// If there was no history to go forward to, it adds the current position of the cursor
+// to the history so we could go forward to where we came from
+
+void SwNavigationMgr::goBack() {
+
+ // Although the button should be disabled whenever the backEnabled() returns false,
+ // the UI is sometimes not as responsive as we would like it to be :)
+ // this check prevents segmentation faults and in this way the class is not relying on the UI
+
+ if (backEnabled()) {
+ /* Trying to get the current cursor */
+ SwPaM* pPaM = m_rMyShell.GetCrsr();
+ if (!pPaM) {
+ return;
+ }
+ // This flag will be used to manually refresh the buttons
+
+ bool bForwardWasDisabled = !forwardEnabled();
+
+ // If we're going backwards in our history, but the current location is not
+ // in the history then we need to add *here* to it so that we can "go
+ // forward" to here again.
+
+ if (bForwardWasDisabled) {
+
+ // the cursor consists of two SwPositions: Point and Mark.
+ // We are adding the current Point to the navigation history
+ // so we could later navigate forward to it
+
+ // The addEntry() method returns true iff we should decrement
+ // the index before navigating back
+
+ if (addEntry(*pPaM->GetPoint()) ) {
+ m_nCurrent--;
+ }
+ }
+ m_nCurrent--;
+ // Position cursor to appropriate navigation history entry
+ GotoSwPosition(*m_entries[m_nCurrent]->GetPoint());
+ // Refresh the buttons
+ if (bForwardWasDisabled)
+ m_rMyShell.GetView().GetViewFrame()->GetBindings().Invalidate(FN_NAVIGATION_FORWARD);
+ if (!backEnabled())
+ m_rMyShell.GetView().GetViewFrame()->GetBindings().Invalidate(FN_NAVIGATION_BACK);
+ }
+}
+
+// The goForward() method positions the cursor to the next entry in the navigation history
+
+void SwNavigationMgr::goForward() {
+
+ // Although the button should be disabled whenever the backForward() returns false,
+ // the UI is sometimes not as responsive as we would like it to be :)
+ // this check prevents segmentation faults and in this way the class is not relying on the UI
+
+ if (forwardEnabled()) {
+ // This flag will be used to manually refresh the buttons
+ bool bBackWasDisabled = !backEnabled();
+ // The current index is positioned at the current entry in the navigation history
+ // We have to increment it to go to the next entry
+ m_nCurrent++;
+ GotoSwPosition(*m_entries[m_nCurrent]->GetPoint());
+ // Refresh the buttons
+ if (bBackWasDisabled)
+ m_rMyShell.GetView().GetViewFrame()->GetBindings().Invalidate(FN_NAVIGATION_BACK);
+ if (!forwardEnabled())
+ m_rMyShell.GetView().GetViewFrame()->GetBindings().Invalidate(FN_NAVIGATION_FORWARD);
+ }
+}
+
+// This method adds the SwPosition rPos to the navigation history
+// rPos is usually the current position of the cursor in the document
+
+bool SwNavigationMgr::addEntry(const SwPosition& rPos) {
+ // Flags that will be used for refreshing the buttons
+ bool bBackWasDisabled = !backEnabled();
+ bool bForwardWasEnabled = forwardEnabled();
+
+ bool bRet = false; // return value of the function.
+ // Indicates whether the index should be decremented before
+ // jumping back or not
+#if SMART
+ // If any forward history exists, twist the tail of the
+ // list from the current position to the end
+ if (bForwardWasEnabled) {
+
+ size_t number_ofm_entries = m_entries.size(); // To avoid calling m_entries.size() multiple times
+ int curr = m_nCurrent; // Index from which we'll twist the tail.
+ int n = (number_ofm_entries - curr) / 2; // Number of entries that will swap places
+ for (int i = 0; i < n; i++) {
+ ::std::swap(m_entries[curr + i], m_entries[number_ofm_entries -1 - i]);
+ }
+
+ if (*m_entries.back()->GetPoint() != rPos)
+ {
+ SwUnoCrsr *const pCursor = m_rMyShell.GetDoc()->CreateUnoCrsr(rPos);
+ m_entries.push_back(::boost::shared_ptr<SwUnoCrsr>(pCursor));
+ }
+ bRet = true;
+ }
+ else {
+ if ( (!m_entries.empty() && *m_entries.back()->GetPoint() != rPos) || m_entries.empty() ) {
+ SwUnoCrsr *const pCursor = m_rMyShell.GetDoc()->CreateUnoCrsr(rPos);
+ m_entries.push_back(::boost::shared_ptr<SwUnoCrsr>(pCursor));
+ bRet = true;
+ }
+ if (m_entries.size() > 1 && *m_entries.back()->GetPoint() == rPos)
+ bRet = true;
+ if (m_entries.size() == 1 && *m_entries.back()->GetPoint() == rPos)
+ bRet = false;
+ }
+#else
+ m_entries.erase(m_entries.begin() + m_nCurrent, m_entries.end());
+ SwUnoCrsr *const pCursor = m_rMyShell.GetDoc()->CreateUnoCrsr(rPos);
+ m_entries.push_back(::boost::shared_ptr<SwUnoCrsr>(pCursor));
+ bRet = true;
+#endif
+ m_nCurrent = m_entries.size();
+
+ // Refresh buttons
+ if (bBackWasDisabled)
+ m_rMyShell.GetView().GetViewFrame()->GetBindings().Invalidate(FN_NAVIGATION_BACK);
+ if (bForwardWasEnabled)
+ m_rMyShell.GetView().GetViewFrame()->GetBindings().Invalidate(FN_NAVIGATION_FORWARD);
+
+ // show the Navigation toolbar
+ css::uno::Reference< css::frame::XFrame > xFrame =
+ m_rMyShell.GetView().GetViewFrame()->GetFrame().GetFrameInterface();
+ if (xFrame.is())
+ {
+ css::uno::Reference< css::beans::XPropertySet > xPropSet(xFrame, css::uno::UNO_QUERY);
+ if (xPropSet.is())
+ {
+ css::uno::Reference< css::frame::XLayoutManager > xLayoutManager;
+ css::uno::Any aValue = xPropSet->getPropertyValue("LayoutManager");
+
+ aValue >>= xLayoutManager;
+ if (xLayoutManager.is())
+ {
+ const OUString sResourceURL( "private:resource/toolbar/navigationobjectbar" );
+ css::uno::Reference< css::ui::XUIElement > xUIElement = xLayoutManager->getElement(sResourceURL);
+ if (!xUIElement.is())
+ {
+ xLayoutManager->createElement( sResourceURL );
+ xLayoutManager->showElement( sResourceURL );
+ }
+ }
+ }
+ }
+
+ return bRet;
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/wrtsh/select.cxx b/sw/source/core/uibase/wrtsh/select.cxx
new file mode 100644
index 000000000000..5b8eee1f367f
--- /dev/null
+++ b/sw/source/core/uibase/wrtsh/select.cxx
@@ -0,0 +1,973 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <limits.h>
+#include <hintids.hxx>
+#include <sfx2/bindings.hxx>
+#include <svl/eitem.hxx>
+#include <svl/macitem.hxx>
+#include <unotools/charclass.hxx>
+#include <editeng/scripttypeitem.hxx>
+#include <cmdid.h>
+#include <view.hxx>
+#include <basesh.hxx>
+#include <wrtsh.hxx>
+#include <frmatr.hxx>
+#include <initui.hxx>
+#include <mdiexp.hxx>
+#include <fmtcol.hxx>
+#include <frmfmt.hxx>
+#include <swundo.hxx>
+#include <swevent.hxx>
+#include <swdtflvr.hxx>
+#include <crsskip.hxx>
+#include <doc.hxx>
+#include <wordcountdialog.hxx>
+
+namespace com { namespace sun { namespace star { namespace util {
+ struct SearchOptions;
+} } } }
+
+using namespace ::com::sun::star::util;
+
+static long nStartDragX = 0, nStartDragY = 0;
+static bool bStartDrag = false;
+
+void SwWrtShell::Invalidate()
+{
+ // to avoid making the slot volatile, invalidate it everytime if something could have been changed
+ // this is still much cheaper than asking for the state every 200 ms (and avoid background processing)
+ GetView().GetViewFrame()->GetBindings().Invalidate( FN_STAT_SELMODE );
+ SwWordCountWrapper *pWrdCnt = (SwWordCountWrapper*)GetView().GetViewFrame()->GetChildWindow(SwWordCountWrapper::GetChildWindowId());
+ if (pWrdCnt)
+ pWrdCnt->UpdateCounts();
+}
+
+sal_Bool SwWrtShell::SelNearestWrd()
+{
+ SwMvContext aMvContext(this);
+ if( !IsInWrd() && !IsEndWrd() && !IsSttWrd() )
+ PrvWrd();
+ if( IsEndWrd() )
+ Left(CRSR_SKIP_CELLS, sal_False, 1, sal_False );
+ return SelWrd();
+}
+
+sal_Bool SwWrtShell::SelWrd(const Point *pPt, sal_Bool )
+{
+ sal_Bool bRet;
+ {
+ SwMvContext aMvContext(this);
+ SttSelect();
+ bRet = SwCrsrShell::SelectWord( pPt );
+ }
+ EndSelect();
+ if( bRet )
+ {
+ bSelWrd = sal_True;
+ if(pPt)
+ aStart = *pPt;
+ }
+ return bRet;
+}
+
+void SwWrtShell::SelSentence(const Point *pPt, sal_Bool )
+{
+ {
+ SwMvContext aMvContext(this);
+ ClearMark();
+ SwCrsrShell::GoStartSentence();
+ SttSelect();
+ SwCrsrShell::GoEndSentence();
+ }
+ EndSelect();
+ if(pPt)
+ aStart = *pPt;
+ bSelLn = sal_True;
+ bSelWrd = sal_False; // disable SelWord, otherwise no SelLine goes on
+}
+
+void SwWrtShell::SelPara(const Point *pPt, sal_Bool )
+{
+ {
+ SwMvContext aMvContext(this);
+ ClearMark();
+ SwCrsrShell::MovePara( fnParaCurr, fnParaStart );
+ SttSelect();
+ SwCrsrShell::MovePara( fnParaCurr, fnParaEnd );
+ }
+ EndSelect();
+ if(pPt)
+ aStart = *pPt;
+ bSelLn = sal_False;
+ bSelWrd = sal_False; // disable SelWord, otherwise no SelLine goes on
+}
+
+long SwWrtShell::SelAll()
+{
+ const sal_Bool bLockedView = IsViewLocked();
+ LockView( sal_True );
+ {
+ if(bBlockMode)
+ LeaveBlockMode();
+ SwMvContext aMvContext(this);
+ sal_Bool bMoveTable = sal_False;
+ SwPosition *pStartPos = 0;
+ SwPosition *pEndPos = 0;
+ SwShellCrsr* pTmpCrsr = 0;
+ if( !HasWholeTabSelection() )
+ {
+ if ( IsSelection() && IsCrsrPtAtEnd() )
+ SwapPam();
+ pTmpCrsr = getShellCrsr( false );
+ if( pTmpCrsr )
+ {
+ pStartPos = new SwPosition( *pTmpCrsr->GetPoint() );
+ pEndPos = new SwPosition( *pTmpCrsr->GetMark() );
+ }
+ Push();
+ bool bIsFullSel = !MoveSection( fnSectionCurr, fnSectionStart);
+ SwapPam();
+ bIsFullSel &= !MoveSection( fnSectionCurr, fnSectionEnd);
+ Pop(sal_False);
+ GoStart(sal_True, &bMoveTable, sal_False, !bIsFullSel);
+ }
+ else
+ {
+ EnterStdMode();
+ SttEndDoc(sal_True);
+ }
+ SttSelect();
+ GoEnd(sal_True, &bMoveTable);
+
+ bool bStartsWithTable = StartsWithTable();
+ if (bStartsWithTable)
+ {
+ // Disable table cursor to make sure getShellCrsr() returns m_pCurCrsr, not m_pTblCrsr.
+ if (IsTableMode())
+ TblCrsrToCursor();
+ // Do the extended select all on m_pCurCrsr.
+ ExtendedSelectAll(/*bFootnotes =*/ false);
+ }
+
+ SwDoc *pDoc = GetDoc();
+ if ( pDoc )
+ {
+ pDoc->SetPrepareSelAll();
+ }
+
+ if( pStartPos )
+ {
+ pTmpCrsr = getShellCrsr( false );
+ if( pTmpCrsr )
+ {
+ // Some special handling for sections (e.g. TOC) at the beginning of the document body
+ // to avoid the selection of the first section
+ // if the last selection was behind the first section or
+ // if the last selection was already the first section
+ // In this both cases we select to the end of document
+ if( ( *pTmpCrsr->GetPoint() < *pEndPos ||
+ ( *pStartPos == *pTmpCrsr->GetMark() &&
+ *pEndPos == *pTmpCrsr->GetPoint() ) ) && !bStartsWithTable)
+ SwCrsrShell::SttEndDoc(sal_False);
+ }
+ delete pStartPos;
+ delete pEndPos;
+ }
+ }
+ EndSelect();
+ LockView( bLockedView );
+ return 1;
+}
+
+// Desciption: Text search
+
+sal_uLong SwWrtShell::SearchPattern( const SearchOptions& rSearchOpt, sal_Bool bSearchInNotes,
+ SwDocPositions eStt, SwDocPositions eEnd,
+ FindRanges eFlags, int bReplace )
+{
+ // no enhancement of existing selections
+ if(!(eFlags & FND_IN_SEL))
+ ClearMark();
+ sal_Bool bCancel = sal_False;
+ sal_uLong nRet = Find( rSearchOpt, bSearchInNotes, eStt, eEnd, bCancel, eFlags, bReplace );
+ if(bCancel)
+ {
+ Undo(1);
+ nRet = ULONG_MAX;
+ }
+ return nRet;
+}
+
+// Description: search for templates
+
+sal_uLong SwWrtShell::SearchTempl( const OUString &rTempl,
+ SwDocPositions eStt, SwDocPositions eEnd,
+ FindRanges eFlags, const OUString* pReplTempl )
+{
+ // no enhancement of existing selections
+ if(!(eFlags & FND_IN_SEL))
+ ClearMark();
+ SwTxtFmtColl *pColl = GetParaStyle(rTempl, SwWrtShell::GETSTYLE_CREATESOME);
+ SwTxtFmtColl *pReplaceColl = 0;
+ if( pReplTempl )
+ pReplaceColl = GetParaStyle(*pReplTempl, SwWrtShell::GETSTYLE_CREATESOME );
+
+ sal_Bool bCancel = sal_False;
+ sal_uLong nRet = Find(pColl? *pColl: GetDfltTxtFmtColl(),
+ eStt,eEnd, bCancel, eFlags, pReplaceColl);
+ if(bCancel)
+ {
+ Undo(1);
+ nRet = ULONG_MAX;
+ }
+ return nRet;
+}
+
+// search for attributes
+
+sal_uLong SwWrtShell::SearchAttr( const SfxItemSet& rFindSet, sal_Bool bNoColls,
+ SwDocPositions eStart, SwDocPositions eEnde,
+ FindRanges eFlags, const SearchOptions* pSearchOpt,
+ const SfxItemSet* pReplaceSet )
+{
+ // no enhancement of existing selections
+ if (!(eFlags & FND_IN_SEL))
+ ClearMark();
+
+ // Searching
+ sal_Bool bCancel = sal_False;
+ sal_uLong nRet = Find( rFindSet, bNoColls, eStart, eEnde, bCancel, eFlags, pSearchOpt, pReplaceSet);
+
+ if(bCancel)
+ {
+ Undo(1);
+ nRet = ULONG_MAX;
+ }
+ return nRet;
+}
+
+// Selection modes
+
+void SwWrtShell::PushMode()
+{
+ pModeStack = new ModeStack( pModeStack, bIns, bExtMode, bAddMode, bBlockMode );
+}
+
+void SwWrtShell::PopMode()
+{
+ if ( 0 == pModeStack )
+ return;
+
+ if ( bExtMode && !pModeStack->bExt )
+ LeaveExtMode();
+ if ( bAddMode && !pModeStack->bAdd )
+ LeaveAddMode();
+ if ( bBlockMode && !pModeStack->bBlock )
+ LeaveBlockMode();
+ bIns = pModeStack->bIns;
+
+ ModeStack *pTmp = pModeStack->pNext;
+ delete pModeStack;
+ pModeStack = pTmp;
+}
+
+// Two methodes for setting cursors: the first maps at the
+// eponymous methodes in the CursorShell, the second removes
+// all selections at first.
+
+long SwWrtShell::SetCrsr(const Point *pPt, sal_Bool bTextOnly)
+{
+ // Remove a possibly present selection at the position
+ // of the mouseclick
+
+ if(!IsInSelect() && ChgCurrPam(*pPt)) {
+ ClearMark();
+ }
+
+ return SwCrsrShell::SetCrsr(*pPt, bTextOnly);
+}
+
+long SwWrtShell::SetCrsrKillSel(const Point *pPt, sal_Bool bTextOnly )
+{
+ SwActContext aActContext(this);
+ ResetSelect(pPt,sal_False);
+ return SwCrsrShell::SetCrsr(*pPt, bTextOnly);
+}
+
+void SwWrtShell::UnSelectFrm()
+{
+ // Remove Frame selection with guaranteed invalid position
+ Point aPt(LONG_MIN, LONG_MIN);
+ SelectObj(aPt, 0);
+ SwTransferable::ClearSelection( *this );
+}
+
+// Remove of all selections
+
+long SwWrtShell::ResetSelect(const Point *,sal_Bool)
+{
+ if(IsSelFrmMode())
+ {
+ UnSelectFrm();
+ LeaveSelFrmMode();
+ }
+ else
+ {
+ // SwActContext opens an Action -
+ // to avoid problems in the basic process with the
+ // shell switching, GetChgLnk().Call() may be called
+ // after EndAction().
+ {
+ SwActContext aActContext(this);
+ bSelWrd = bSelLn = sal_False;
+ KillPams();
+ ClearMark();
+ fnKillSel = &SwWrtShell::Ignore;
+ fnSetCrsr = &SwWrtShell::SetCrsr;
+ }
+
+ // After canceling of all selections an update of Attr-Controls
+ // could be necessary.
+ GetChgLnk().Call(this);
+ }
+ Invalidate();
+ SwTransferable::ClearSelection( *this );
+ return 1;
+}
+
+// Do nothing
+
+long SwWrtShell::Ignore(const Point *, sal_Bool ) {
+ return 1;
+}
+
+// Begin of a selection process.
+
+void SwWrtShell::SttSelect()
+{
+ if(bInSelect)
+ return;
+ if(!HasMark())
+ SetMark();
+ if( bBlockMode )
+ {
+ SwShellCrsr* pTmp = getShellCrsr( true );
+ if( !pTmp->HasMark() )
+ pTmp->SetMark();
+ }
+ fnKillSel = &SwWrtShell::Ignore;
+ fnSetCrsr = &SwWrtShell::SetCrsr;
+ bInSelect = sal_True;
+ Invalidate();
+ SwTransferable::CreateSelection( *this );
+}
+
+// End of a selection process.
+
+void SwWrtShell::EndSelect()
+{
+ if(bInSelect && !bExtMode)
+ {
+ bInSelect = sal_False;
+ if (bAddMode)
+ {
+ AddLeaveSelect(0, sal_False);
+ }
+ else
+ {
+ SttLeaveSelect(0, sal_False);
+ fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
+ fnKillSel = &SwWrtShell::ResetSelect;
+ }
+ }
+ SwWordCountWrapper *pWrdCnt = (SwWordCountWrapper*)GetView().GetViewFrame()->GetChildWindow(SwWordCountWrapper::GetChildWindowId());
+ if (pWrdCnt)
+ pWrdCnt->UpdateCounts();
+}
+
+// Methode to enhance a selecton word by word or line by line.
+
+inline bool operator<(const Point &rP1,const Point &rP2)
+{
+ return rP1.Y() < rP2.Y() || (rP1.Y() == rP2.Y() && rP1.X() < rP2.X());
+}
+
+long SwWrtShell::ExtSelWrd(const Point *pPt, sal_Bool )
+{
+ SwMvContext aMvContext(this);
+ if( IsTableMode() )
+ return 1;
+
+ // Bug 66823: actual crsr has in additional mode no selection?
+ // Then destroy the actual an go to prev, this will be expand
+ if( !HasMark() && GoPrevCrsr() )
+ {
+ sal_Bool bHasMark = HasMark(); // thats wrong!
+ GoNextCrsr();
+ if( bHasMark )
+ {
+ DestroyCrsr();
+ GoPrevCrsr();
+ }
+ }
+
+ // check the direction of the selection with the new point
+ sal_Bool bRet = sal_False, bMoveCrsr = sal_True, bToTop = sal_False;
+ SwCrsrShell::SelectWord( &aStart ); // select the startword
+ SwCrsrShell::Push(); // save the cursor
+ SwCrsrShell::SetCrsr( *pPt ); // and check the direction
+
+ switch( SwCrsrShell::CompareCursor( StackMkCurrPt ))
+ {
+ case -1: bToTop = sal_False; break;
+ case 1: bToTop = sal_True; break;
+ default: bMoveCrsr = sal_False; break;
+ }
+
+ SwCrsrShell::Pop( sal_False ); // retore the saved cursor
+
+ if( bMoveCrsr )
+ {
+ // select to Top but cursor select to Bottom? or
+ // select to Bottom but cursor select to Top? --> swap the cursor
+ if( bToTop )
+ SwapPam();
+
+ SwCrsrShell::Push(); // save cur cursor
+ if( SwCrsrShell::SelectWord( pPt )) // select the current word
+ {
+ if( bToTop )
+ SwapPam();
+ Combine();
+ bRet = sal_True;
+ }
+ else
+ {
+ SwCrsrShell::Pop( sal_False );
+ if( bToTop )
+ SwapPam();
+ }
+ }
+ else
+ bRet = sal_True;
+ return bRet;
+}
+
+long SwWrtShell::ExtSelLn(const Point *pPt, sal_Bool )
+{
+ SwMvContext aMvContext(this);
+ SwCrsrShell::SetCrsr(*pPt);
+ if( IsTableMode() )
+ return 1;
+
+ // Bug 66823: actual crsr has in additional mode no selection?
+ // Then destroy the actual an go to prev, this will be expand
+ if( !HasMark() && GoPrevCrsr() )
+ {
+ sal_Bool bHasMark = HasMark(); // thats wrong!
+ GoNextCrsr();
+ if( bHasMark )
+ {
+ DestroyCrsr();
+ GoPrevCrsr();
+ }
+ }
+
+ // if applicable fit the selection to the "Mark"
+ sal_Bool bToTop = !IsCrsrPtAtEnd();
+ SwapPam();
+
+ // The "Mark" has to be at the end or the beginning of the line.
+ if( bToTop ? !IsEndSentence() : !IsStartSentence() )
+ {
+ if( bToTop )
+ {
+ if( !IsEndPara() )
+ SwCrsrShell::Right(1,CRSR_SKIP_CHARS);
+ SwCrsrShell::GoEndSentence();
+ }
+ else
+ SwCrsrShell::GoStartSentence();
+ }
+ SwapPam();
+
+ return bToTop ? SwCrsrShell::GoStartSentence() : SwCrsrShell::GoEndSentence();
+}
+
+// Back into the standard mode: no mode, no selections.
+
+void SwWrtShell::EnterStdMode()
+{
+ if(bAddMode)
+ LeaveAddMode();
+ if(bBlockMode)
+ LeaveBlockMode();
+ bBlockMode = sal_False;
+ bExtMode = sal_False;
+ bInSelect = sal_False;
+ if(IsSelFrmMode())
+ {
+ UnSelectFrm();
+ LeaveSelFrmMode();
+ }
+ else
+ {
+ // SwActContext opens and action which has to be
+ // closed prior to the call of
+ // GetChgLnk().Call()
+ {
+ SwActContext aActContext(this);
+ bSelWrd = bSelLn = sal_False;
+ if( !IsRetainSelection() )
+ KillPams();
+ ClearMark();
+ fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
+ fnKillSel = &SwWrtShell::ResetSelect;
+ }
+ }
+ Invalidate();
+ SwTransferable::ClearSelection( *this );
+}
+
+// Extended Mode
+
+void SwWrtShell::EnterExtMode()
+{
+ if(bBlockMode)
+ {
+ LeaveBlockMode();
+ KillPams();
+ ClearMark();
+ }
+ bExtMode = sal_True;
+ bAddMode = sal_False;
+ bBlockMode = sal_False;
+ SttSelect();
+}
+
+void SwWrtShell::LeaveExtMode()
+{
+ bExtMode = sal_False;
+ EndSelect();
+}
+
+// End of a selection; if the selection is empty,
+// ClearMark().
+
+long SwWrtShell::SttLeaveSelect(const Point *, sal_Bool )
+{
+ if(SwCrsrShell::HasSelection() && !IsSelTblCells() && bClearMark) {
+ return 0;
+ }
+ ClearMark();
+ return 1;
+}
+
+// Leaving of the selection mode in additional mode
+
+long SwWrtShell::AddLeaveSelect(const Point *, sal_Bool )
+{
+ if(IsTableMode()) LeaveAddMode();
+ else if(SwCrsrShell::HasSelection())
+ CreateCrsr();
+ return 1;
+}
+
+// Additional Mode
+
+void SwWrtShell::EnterAddMode()
+{
+ if(IsTableMode()) return;
+ if(bBlockMode)
+ LeaveBlockMode();
+ fnKillSel = &SwWrtShell::Ignore;
+ fnSetCrsr = &SwWrtShell::SetCrsr;
+ bAddMode = sal_True;
+ bBlockMode = sal_False;
+ bExtMode = sal_False;
+ if(SwCrsrShell::HasSelection())
+ CreateCrsr();
+ Invalidate();
+}
+
+void SwWrtShell::LeaveAddMode()
+{
+ fnKillSel = &SwWrtShell::ResetSelect;
+ fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
+ bAddMode = sal_False;
+ Invalidate();
+}
+
+// Block Mode
+
+void SwWrtShell::EnterBlockMode()
+{
+ bBlockMode = sal_False;
+ EnterStdMode();
+ bBlockMode = sal_True;
+ CrsrToBlockCrsr();
+ Invalidate();
+}
+
+void SwWrtShell::LeaveBlockMode()
+{
+ bBlockMode = sal_False;
+ BlockCrsrToCrsr();
+ EndSelect();
+ Invalidate();
+}
+
+// Insert mode
+
+void SwWrtShell::SetInsMode( sal_Bool bOn )
+{
+ bIns = bOn;
+ SwCrsrShell::SetOverwriteCrsr( !bIns );
+ const SfxBoolItem aTmp( SID_ATTR_INSERT, bIns );
+ GetView().GetViewFrame()->GetBindings().SetState( aTmp );
+ StartAction();
+ EndAction();
+ Invalidate();
+}
+//Overwrite mode is incompatible with red-lining
+void SwWrtShell::SetRedlineModeAndCheckInsMode( sal_uInt16 eMode )
+{
+ SetRedlineMode( eMode );
+ if (IsRedlineOn())
+ SetInsMode( true );
+}
+
+// Edit frame
+
+long SwWrtShell::BeginFrmDrag(const Point *pPt, sal_Bool)
+{
+ fnDrag = &SwFEShell::Drag;
+ if(bStartDrag)
+ {
+ Point aTmp( nStartDragX, nStartDragY );
+ SwFEShell::BeginDrag( &aTmp, sal_False );
+ }
+ else
+ SwFEShell::BeginDrag( pPt, sal_False );
+ return 1;
+}
+
+void SwWrtShell::EnterSelFrmMode(const Point *pPos)
+{
+ if(pPos)
+ {
+ nStartDragX = pPos->X();
+ nStartDragY = pPos->Y();
+ bStartDrag = true;
+ }
+ bLayoutMode = sal_True;
+ HideCrsr();
+
+ // equal call of BeginDrag in the SwFEShell
+ fnDrag = &SwWrtShell::BeginFrmDrag;
+ fnEndDrag = &SwWrtShell::UpdateLayoutFrm;
+ SwBaseShell::SetFrmMode( FLY_DRAG_START, this );
+ Invalidate();
+}
+
+void SwWrtShell::LeaveSelFrmMode()
+{
+ fnDrag = &SwWrtShell::BeginDrag;
+ fnEndDrag = &SwWrtShell::EndDrag;
+ bLayoutMode = sal_False;
+ bStartDrag = false;
+ Edit();
+ SwBaseShell::SetFrmMode( FLY_DRAG_END, this );
+ Invalidate();
+}
+
+// Description: execute framebound macro
+
+IMPL_LINK( SwWrtShell, ExecFlyMac, void *, pFlyFmt )
+{
+ const SwFrmFmt *pFmt = pFlyFmt ? (SwFrmFmt*)pFlyFmt : GetFlyFrmFmt();
+ OSL_ENSURE(pFmt, "no frame format");
+ const SvxMacroItem &rFmtMac = pFmt->GetMacro();
+
+ if(rFmtMac.HasMacro(SW_EVENT_OBJECT_SELECT))
+ {
+ const SvxMacro &rMac = rFmtMac.GetMacro(SW_EVENT_OBJECT_SELECT);
+ if( IsFrmSelected() )
+ bLayoutMode = sal_True;
+ CallChgLnk();
+ ExecMacro( rMac );
+ }
+ return 0;
+}
+
+long SwWrtShell::UpdateLayoutFrm(const Point *pPt, sal_Bool )
+{
+ // still a dummy
+ SwFEShell::EndDrag( pPt, sal_False );
+ fnDrag = &SwWrtShell::BeginFrmDrag;
+ return 1;
+}
+
+// Handler for toggling the modes. Returns back the old mode.
+
+bool SwWrtShell::ToggleAddMode()
+{
+ bAddMode ? LeaveAddMode(): EnterAddMode();
+ Invalidate();
+ return !bAddMode;
+}
+
+bool SwWrtShell::ToggleBlockMode()
+{
+ bBlockMode ? LeaveBlockMode(): EnterBlockMode();
+ Invalidate();
+ return !bBlockMode;
+}
+
+bool SwWrtShell::ToggleExtMode()
+{
+ bExtMode ? LeaveExtMode() : EnterExtMode();
+ Invalidate();
+ return !bExtMode;
+}
+
+// Dragging in standard mode (Selecting of content)
+
+long SwWrtShell::BeginDrag(const Point * /*pPt*/, sal_Bool )
+{
+ if(bSelWrd)
+ {
+ bInSelect = sal_True;
+ if( !IsCrsrPtAtEnd() )
+ SwapPam();
+
+ fnDrag = &SwWrtShell::ExtSelWrd;
+ fnSetCrsr = &SwWrtShell::Ignore;
+ }
+ else if(bSelLn)
+ {
+ bInSelect = sal_True;
+ fnDrag = &SwWrtShell::ExtSelLn;
+ fnSetCrsr = &SwWrtShell::Ignore;
+ }
+ else
+ {
+ fnDrag = &SwWrtShell::Drag;
+ SttSelect();
+ }
+
+ return 1;
+}
+
+long SwWrtShell::Drag(const Point *, sal_Bool )
+{
+ if( IsSelTblCells() )
+ aSelTblLink.Call(this);
+
+ return 1;
+}
+
+long SwWrtShell::EndDrag(const Point * /*pPt*/, sal_Bool )
+{
+ fnDrag = &SwWrtShell::BeginDrag;
+ if( IsExtSel() )
+ LeaveExtSel();
+
+ if( IsSelTblCells() )
+ aSelTblLink.Call(this);
+ EndSelect();
+ return 1;
+}
+
+// #i32329# Enhanced table selection
+sal_Bool SwWrtShell::SelectTableRowCol( const Point& rPt, const Point* pEnd, bool bRowDrag )
+{
+ SwMvContext aMvContext(this);
+ SttSelect();
+ if(SelTblRowCol( rPt, pEnd, bRowDrag ))
+ {
+ fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
+ fnKillSel = &SwWrtShell::ResetSelect;
+ return sal_True;
+ }
+ return sal_False;
+}
+
+// Description: Selection of a table line or column
+
+sal_Bool SwWrtShell::SelectTableRow()
+{
+ if ( SelTblRow() )
+ {
+ fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
+ fnKillSel = &SwWrtShell::ResetSelect;
+ return sal_True;
+ }
+ return sal_False;
+}
+
+sal_Bool SwWrtShell::SelectTableCol()
+{
+ if ( SelTblCol() )
+ {
+ fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
+ fnKillSel = &SwWrtShell::ResetSelect;
+ return sal_True;
+ }
+ return sal_False;
+}
+
+sal_Bool SwWrtShell::SelectTableCell()
+{
+ if ( SelTblBox() )
+ {
+ fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
+ fnKillSel = &SwWrtShell::ResetSelect;
+ return sal_True;
+ }
+ return sal_False;
+}
+
+// Description: Check if a word selection is present.
+// According to the rules for intelligent cut / paste
+// surrounding spaces are cut out.
+// Return: Delivers the type of the word selection.
+
+int SwWrtShell::IntelligentCut(int nSelection, sal_Bool bCut)
+{
+ // On multiple selection no intelligent drag and drop
+ // there are multiple cursors, since a second was placed
+ // already at the target postion.
+ if( IsAddMode() || !(nSelection & nsSelectionType::SEL_TXT) )
+ return sal_False;
+
+ OUString sTxt;
+ CharClass& rCC = GetAppCharClass();
+
+ // If the first character is no word character,
+ // no word selected.
+ sal_Unicode cPrev = GetChar(sal_False);
+ sal_Unicode cNext = GetChar(sal_True, -1);
+ if( !cPrev || !cNext ||
+ !rCC.isLetterNumeric( ( sTxt = OUString(cPrev) ), 0 ) ||
+ !rCC.isLetterNumeric( ( sTxt = OUString(cNext) ), 0 ) )
+ return NO_WORD;
+
+ cPrev = GetChar(sal_False, -1);
+ cNext = GetChar(sal_True);
+
+ int cWord = NO_WORD;
+ // is a word seleced?
+ if(!cWord && cPrev && cNext &&
+ CH_TXTATR_BREAKWORD != cPrev && CH_TXTATR_INWORD != cPrev &&
+ CH_TXTATR_BREAKWORD != cNext && CH_TXTATR_INWORD != cNext &&
+ !rCC.isLetterNumeric( ( sTxt = OUString(cPrev) ), 0 ) &&
+ !rCC.isLetterNumeric( ( sTxt = OUString(cNext) ), 0 ) )
+ cWord = WORD_NO_SPACE;
+
+ if(cWord == WORD_NO_SPACE && ' ' == cPrev )
+ {
+ cWord = WORD_SPACE_BEFORE;
+ // delete the space before
+ if(bCut)
+ {
+ Push();
+ if(IsCrsrPtAtEnd())
+ SwapPam();
+ ClearMark();
+ SetMark();
+ SwCrsrShell::Left(1,CRSR_SKIP_CHARS);
+ SwFEShell::Delete();
+ Pop( sal_False );
+ }
+ }
+ else if(cWord == WORD_NO_SPACE && cNext == ' ')
+ {
+ cWord = WORD_SPACE_AFTER;
+ // delete the space behind
+ if(bCut) {
+ Push();
+ if(!IsCrsrPtAtEnd()) SwapPam();
+ ClearMark();
+ SetMark();
+ SwCrsrShell::Right(1,CRSR_SKIP_CHARS);
+ SwFEShell::Delete();
+ Pop( sal_False );
+ }
+ }
+ return cWord;
+}
+
+ // jump to the next / previous hyperlink - inside text and also
+ // on graphics
+bool SwWrtShell::SelectNextPrevHyperlink( bool bNext )
+{
+ StartAction();
+ bool bRet = SwCrsrShell::SelectNxtPrvHyperlink( bNext );
+ if( !bRet )
+ {
+ // will we have this feature?
+ EnterStdMode();
+ if( bNext )
+ SttEndDoc(sal_True);
+ else
+ SttEndDoc(sal_False);
+ bRet = SwCrsrShell::SelectNxtPrvHyperlink( bNext );
+ }
+ EndAction();
+
+ bool bCreateXSelection = false;
+ const bool bFrmSelected = IsFrmSelected() || IsObjSelected();
+ if( IsSelection() )
+ {
+ if ( bFrmSelected )
+ UnSelectFrm();
+
+ // Set the function pointer for the canceling of the selection
+ // set at cursor
+ fnKillSel = &SwWrtShell::ResetSelect;
+ fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
+ bCreateXSelection = true;
+ }
+ else if( bFrmSelected )
+ {
+ EnterSelFrmMode();
+ bCreateXSelection = true;
+ }
+ else if( (CNT_GRF | CNT_OLE ) & GetCntType() )
+ {
+ SelectObj( GetCharRect().Pos() );
+ EnterSelFrmMode();
+ bCreateXSelection = true;
+ }
+
+ if( bCreateXSelection )
+ SwTransferable::CreateSelection( *this );
+
+ return bRet;
+}
+
+// For the preservation of the selection the cursor will be moved left
+// after SetMark(), so that the cursor is not moved by inserting text.
+// Because a present selection at the CORE page is cleared at the
+// current cursor position, the cursor will be pushed on the stack.
+// After moving, they will again resummarized.
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/wrtsh/wrtsh.hrc b/sw/source/core/uibase/wrtsh/wrtsh.hrc
new file mode 100644
index 000000000000..87435e1bce99
--- /dev/null
+++ b/sw/source/core/uibase/wrtsh/wrtsh.hrc
@@ -0,0 +1,41 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef _WRTSH_HRC
+#define _WRTSH_HRC
+
+#include "rcid.hrc"
+
+
+
+#define STR_DDEERROR_APP1 (RC_WRTSH_BEGIN + 2)
+#define STR_DDEERROR_APP2 (RC_WRTSH_BEGIN + 3)
+#define STR_DDEERROR_DATA1 (RC_WRTSH_BEGIN + 4)
+#define STR_DDEERROR_DATA2 (RC_WRTSH_BEGIN + 5)
+#define STR_DDEERROR_LINK1 (RC_WRTSH_BEGIN + 6)
+#define STR_DDEERROR_LINK2 (RC_WRTSH_BEGIN + 7)
+
+#define WRTSH_ACT_END STR_DDEERROR_LINK2
+
+#if WRTSH_ACT_END > RC_WRTSH_END
+#error Resource-Id Ueberlauf
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/wrtsh/wrtsh.src b/sw/source/core/uibase/wrtsh/wrtsh.src
new file mode 100644
index 000000000000..5d6e3bff3f9b
--- /dev/null
+++ b/sw/source/core/uibase/wrtsh/wrtsh.src
@@ -0,0 +1,46 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+#include "wrtsh.hrc"
+
+String STR_DDEERROR_APP1
+{
+ Text[ en-US ] = "Application [" ;
+};
+String STR_DDEERROR_APP2
+{
+ Text[ en-US ] = "] is not responding." ;
+};
+String STR_DDEERROR_DATA1
+{
+ Text[ en-US ] = "Data for [" ;
+};
+String STR_DDEERROR_DATA2
+{
+ Text[ en-US ] = "] cannot be obtained" ;
+};
+String STR_DDEERROR_LINK1
+{
+ Text[ en-US ] = "Link to [" ;
+};
+String STR_DDEERROR_LINK2
+{
+ Text[ en-US ] = "] cannot be established" ;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/wrtsh/wrtsh1.cxx b/sw/source/core/uibase/wrtsh/wrtsh1.cxx
new file mode 100644
index 000000000000..ad6648d9078e
--- /dev/null
+++ b/sw/source/core/uibase/wrtsh/wrtsh1.cxx
@@ -0,0 +1,1801 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/embed/XVisualObject.hpp>
+#include <com/sun/star/embed/EmbedMisc.hpp>
+#include <com/sun/star/embed/EmbedStates.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
+#include <com/sun/star/chart2/XChartDocument.hpp>
+#include <com/sun/star/util/XModifiable.hpp>
+
+#include <svx/dialogs.hrc>
+
+#include <math.h>
+#include <hintids.hxx>
+#include <svx/hdft.hxx>
+#include <svx/svdview.hxx>
+#include <sot/factory.hxx>
+#include <svl/itemiter.hxx>
+#include <tools/bigint.hxx>
+#include <sot/storage.hxx>
+#include <svtools/insdlg.hxx>
+#include <sfx2/frmdescr.hxx>
+#include <sfx2/ipclient.hxx>
+#include <svtools/ehdl.hxx>
+#include <svtools/soerr.hxx>
+#include <unotools/moduleoptions.hxx>
+#include <editeng/sizeitem.hxx>
+#include <editeng/formatbreakitem.hxx>
+#include <editeng/svxacorr.hxx>
+#include <editeng/ulspitem.hxx>
+#include <vcl/graph.hxx>
+#include <vcl/msgbox.hxx>
+#include <sfx2/printer.hxx>
+#include <unotools/charclass.hxx>
+#include <comphelper/storagehelper.hxx>
+#include <svx/svxdlg.hxx>
+#include <svx/extrusionbar.hxx>
+#include <svx/fontworkbar.hxx>
+#include <frmfmt.hxx>
+#include <fmtftn.hxx>
+#include <fmthdft.hxx>
+#include <fmtpdsc.hxx>
+#include <wdocsh.hxx>
+#include <basesh.hxx>
+#include <swmodule.hxx>
+#include <wrtsh.hxx>
+#include <view.hxx>
+#include <uitool.hxx>
+#include <cmdid.h>
+#include <cfgitems.hxx>
+#include <pagedesc.hxx>
+#include <frmmgr.hxx>
+#include <shellio.hxx>
+#include <uinums.hxx>
+#include <swundo.hxx>
+#include <swcli.hxx>
+#include <poolfmt.hxx>
+#include <wview.hxx>
+#include <edtwin.hxx>
+#include <fmtcol.hxx>
+#include <swtable.hxx>
+#include <caption.hxx>
+#include <viscrs.hxx>
+#include <swdtflvr.hxx>
+#include <crsskip.hxx>
+#include <doc.hxx>
+#include <wrtsh.hrc>
+#include <SwStyleNameMapper.hxx>
+#include <sfx2/request.hxx>
+#include <paratr.hxx>
+#include <ndtxt.hxx>
+#include <editeng/acorrcfg.hxx>
+#include <IMark.hxx>
+#include <sfx2/bindings.hxx>
+#include <svx/dialmgr.hxx>
+
+// -> #111827#
+#include <SwRewriter.hxx>
+#include <comcore.hrc>
+// <- #111827#
+
+#include <toolkit/helper/vclunohelper.hxx>
+#include <sfx2/viewfrm.hxx>
+
+#include "PostItMgr.hxx"
+#include <sfx2/msgpool.hxx>
+
+using namespace sw::mark;
+using namespace com::sun::star;
+
+#define COMMON_INI_LIST \
+ fnDrag(&SwWrtShell::BeginDrag),\
+ fnSetCrsr(&SwWrtShell::SetCrsr),\
+ fnEndDrag(&SwWrtShell::EndDrag),\
+ fnKillSel(&SwWrtShell::Ignore),\
+ pModeStack(0), \
+ ePageMove(MV_NO),\
+ pCrsrStack(0), \
+ rView(rShell),\
+ aNavigationMgr(*this), \
+ bDestOnStack(false)
+
+#define BITFLD_INI_LIST \
+ bClearMark = \
+ bIns = sal_True;\
+ bAddMode = \
+ bBlockMode = \
+ bExtMode = \
+ bInSelect = \
+ bCopy = \
+ bLayoutMode = \
+ bSelWrd = \
+ bSelLn = \
+ mbRetainSelection = sal_False; \
+ bIsInClickToEdit = false;
+
+static SvxAutoCorrect* lcl_IsAutoCorr()
+{
+ SvxAutoCorrect* pACorr = SvxAutoCorrCfg::Get().GetAutoCorrect();
+ if( pACorr && !pACorr->IsAutoCorrFlag( CptlSttSntnc | CptlSttWrd |
+ AddNonBrkSpace | ChgOrdinalNumber |
+ ChgToEnEmDash | SetINetAttr | Autocorrect ))
+ pACorr = 0;
+ return pACorr;
+}
+
+void SwWrtShell::NoEdit(bool bHideCrsr)
+{
+ if(bHideCrsr)
+ HideCrsr();
+}
+
+void SwWrtShell::Edit()
+{
+ if (CanInsert())
+ {
+ ShowCrsr();
+ }
+}
+
+sal_Bool SwWrtShell::IsEndWrd()
+{
+ SwMvContext aMvContext(this);
+ if(IsEndPara() && !IsSttPara())
+ return sal_True;
+
+ return IsEndWord();
+}
+
+// Insert string
+void SwWrtShell::InsertByWord( const OUString & rStr)
+{
+ if( !rStr.isEmpty() )
+ {
+ sal_Bool bDelim = GetAppCharClass().isLetterNumeric( rStr, 0 );
+ sal_Int32 nPos = 0, nStt = 0;
+ for( ; nPos < rStr.getLength(); nPos++ )
+ {
+ sal_Bool bTmpDelim = GetAppCharClass().isLetterNumeric( rStr, nPos );
+ if( bTmpDelim != bDelim )
+ {
+ Insert( rStr.copy( nStt, nPos - nStt ));
+ nStt = nPos;
+ }
+ }
+ if( nStt != nPos )
+ Insert( rStr.copy( nStt, nPos - nStt ));
+ }
+}
+
+void SwWrtShell::Insert( const OUString &rStr )
+{
+ ResetCursorStack();
+ if( !CanInsert() )
+ return;
+
+ bool bStarted = false;
+ sal_Bool bHasSel = HasSelection(),
+ bCallIns = bIns /*|| bHasSel*/;
+ bool bDeleted = false;
+
+ if( bHasSel || ( !bIns && SelectHiddenRange() ) )
+ {
+ // Only here parenthesizing, because the normal
+ // insert is already in parentheses at Editshell.
+ StartAllAction();
+
+ // #111827#
+ SwRewriter aRewriter;
+
+ aRewriter.AddRule(UndoArg1, GetCrsrDescr());
+ aRewriter.AddRule(UndoArg2, OUString(SW_RES(STR_YIELDS)));
+ {
+ OUString aTmpStr;
+ aTmpStr += SW_RES(STR_START_QUOTE);
+ aTmpStr += rStr;
+ aTmpStr += SW_RES(STR_END_QUOTE);
+
+ aRewriter.AddRule(UndoArg3, rStr);
+ }
+
+ StartUndo(UNDO_REPLACE, &aRewriter);
+ bStarted = true;
+ bDeleted = DelRight() != 0;
+ }
+
+ bCallIns ?
+ SwEditShell::Insert2( rStr, bDeleted ) : SwEditShell::Overwrite( rStr );
+
+ if( bStarted )
+ {
+ EndAllAction();
+ EndUndo();
+ }
+}
+
+// Maximum height limit not possible, because the maximum height
+// of the current frame can not be obtained.
+
+void SwWrtShell::Insert( const OUString &rPath, const OUString &rFilter,
+ const Graphic &rGrf, SwFlyFrmAttrMgr *pFrmMgr,
+ sal_Bool bRule )
+{
+ ResetCursorStack();
+ if ( !CanInsert() )
+ return;
+
+ StartAllAction();
+
+ SwRewriter aRewriter;
+ aRewriter.AddRule(UndoArg1, SW_RES(STR_GRAPHIC));
+
+ StartUndo(UNDO_INSERT, &aRewriter);
+
+ if ( HasSelection() )
+ DelRight();
+ // Inserted graphics in its own paragraph,
+ // if at the end of a non-empty paragraph.
+ //For i120928,avoid to split node
+
+ EnterSelFrmMode();
+
+ bool bSetGrfSize = true;
+ bool bOwnMgr = false;
+
+ if ( !pFrmMgr )
+ {
+ bOwnMgr = true;
+ pFrmMgr = new SwFlyFrmAttrMgr( sal_True, this, FRMMGR_TYPE_GRF );
+
+ // CAUTION
+ // GetAttrSet makes an adjustment
+ // While pasting is a SwFrmSize present
+ // because of the DEF-Framesize
+ // These must be removed explicitly for the optimal size.
+ pFrmMgr->DelAttr(RES_FRM_SIZE);
+ }
+ else
+ {
+ Size aSz( pFrmMgr->GetSize() );
+ if ( !aSz.Width() || !aSz.Height() )
+ {
+ aSz.Width() = aSz.Height() = 567;
+ pFrmMgr->SetSize( aSz );
+ }
+ else if ( aSz.Width() != DFLT_WIDTH && aSz.Height() != DFLT_HEIGHT )
+ bSetGrfSize = false;
+
+ pFrmMgr->SetHeightSizeType(ATT_FIX_SIZE);
+ }
+
+ // Insert the graphic
+ SwFEShell::Insert(rPath, rFilter, &rGrf, &pFrmMgr->GetAttrSet());
+ if ( bOwnMgr )
+ pFrmMgr->UpdateAttrMgr();
+
+ if( bSetGrfSize && !bRule )
+ {
+ Size aGrfSize, aBound = GetGraphicDefaultSize();
+ GetGrfSize( aGrfSize );
+
+ // Add the margin attributes to GrfSize,
+ // because these counts at the margin additionally
+ aGrfSize.Width() += pFrmMgr->CalcWidthBorder();
+ aGrfSize.Height()+= pFrmMgr->CalcHeightBorder();
+
+ const BigInt aTempWidth( aGrfSize.Width() );
+ const BigInt aTempHeight( aGrfSize.Height());
+
+ // Fit width if necessary, scale down the height proportional thereafter.
+ if( aGrfSize.Width() > aBound.Width() )
+ {
+ aGrfSize.Width() = aBound.Width();
+ aGrfSize.Height() = ((BigInt)aBound.Width()) * aTempHeight / aTempWidth;
+ }
+ // Fit hight if necessary, scale down the width proportional thereafter.
+ if( aGrfSize.Height() > aBound.Height() )
+ {
+ aGrfSize.Height() = aBound.Height();
+ aGrfSize.Width() = ((BigInt)aBound.Height()) * aTempWidth / aTempHeight;
+ }
+ pFrmMgr->SetSize( aGrfSize );
+ pFrmMgr->UpdateFlyFrm();
+ }
+ if ( bOwnMgr )
+ delete pFrmMgr;
+
+ EndUndo();
+ EndAllAction();
+}
+
+// Insert an OLE-Objekt into the CORE.
+// if no object is transfered, then one will be created.
+
+void SwWrtShell::InsertObject( const svt::EmbeddedObjectRef& xRef, SvGlobalName *pName,
+ sal_Bool bActivate, sal_uInt16 nSlotId )
+{
+ ResetCursorStack();
+ if( !CanInsert() )
+ return;
+
+ if( !xRef.is() )
+ {
+ // temporary storage
+ svt::EmbeddedObjectRef xObj;
+ uno::Reference < embed::XStorage > xStor = comphelper::OStorageHelper::GetTemporaryStorage();
+ sal_Bool bDoVerb = sal_True;
+ if ( pName )
+ {
+ comphelper::EmbeddedObjectContainer aCnt( xStor );
+ OUString aName;
+ // TODO/LATER: get aspect?
+ xObj.Assign( aCnt.CreateEmbeddedObject( pName->GetByteSequence(), aName ), embed::Aspects::MSOLE_CONTENT );
+ }
+ else
+ {
+ SvObjectServerList aServerList;
+ switch (nSlotId)
+ {
+ case SID_INSERT_OBJECT:
+ {
+ aServerList.FillInsertObjects();
+ aServerList.Remove( SwDocShell::Factory().GetClassId() );
+ // Intentionally no break!
+ }
+
+ // TODO/LATER: recording! Convert properties to items
+ case SID_INSERT_PLUGIN:
+ case SID_INSERT_FLOATINGFRAME:
+ {
+ SfxSlotPool* pSlotPool = SW_MOD()->GetSlotPool();
+ const SfxSlot* pSlot = pSlotPool->GetSlot(nSlotId);
+ OString aCmd(".uno:");
+ aCmd += pSlot->GetUnoName();
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ SfxAbstractInsertObjectDialog* pDlg =
+ pFact->CreateInsertObjectDialog( GetWin(), OStringToOUString( aCmd, RTL_TEXTENCODING_UTF8 ), xStor, &aServerList );
+ if ( pDlg )
+ {
+ pDlg->Execute();
+ bDoVerb = pDlg->IsCreateNew();
+ OUString aIconMediaType;
+ uno::Reference< io::XInputStream > xIconMetaFile = pDlg->GetIconIfIconified( &aIconMediaType );
+ xObj.Assign( pDlg->GetObject(),
+ xIconMetaFile.is() ? embed::Aspects::MSOLE_ICON : embed::Aspects::MSOLE_CONTENT );
+ if ( xIconMetaFile.is() )
+ xObj.SetGraphicStream( xIconMetaFile, aIconMediaType );
+
+ DELETEZ( pDlg );
+ }
+
+ break;
+ }
+
+ default:
+ break;
+ }
+ }
+
+ if ( xObj.is() )
+ {
+ if( InsertOleObject( xObj ) && bActivate && bDoVerb )
+ {
+ SfxInPlaceClient* pClient = GetView().FindIPClient( xObj.GetObject(), &GetView().GetEditWin() );
+ if ( !pClient )
+ {
+ pClient = new SwOleClient( &GetView(), &GetView().GetEditWin(), xObj );
+ SetCheckForOLEInCaption( sal_True );
+ }
+
+ if ( xObj.GetViewAspect() == embed::Aspects::MSOLE_ICON )
+ {
+ SwRect aArea = GetAnyCurRect( RECT_FLY_PRT_EMBEDDED, 0, xObj.GetObject() );
+ aArea.Pos() += GetAnyCurRect( RECT_FLY_EMBEDDED, 0, xObj.GetObject() ).Pos();
+ MapMode aMapMode( MAP_TWIP );
+ Size aSize = xObj.GetSize( &aMapMode );
+ aArea.Width( aSize.Width() );
+ aArea.Height( aSize.Height() );
+ RequestObjectResize( aArea, xObj.GetObject() );
+ }
+ else
+ CalcAndSetScale( xObj );
+
+ //#50270# We don't need to handle error, this is handled by the
+ //DoVerb in the SfxViewShell
+ pClient->DoVerb( SVVERB_SHOW );
+
+ // TODO/LATER: set document name - should be done in Client
+ }
+ }
+ }
+ else
+ {
+ if( HasSelection() )
+ DelRight();
+ InsertOleObject( xRef );
+ }
+}
+
+// Insert object into the Core.
+// From ClipBoard or Insert
+
+sal_Bool SwWrtShell::InsertOleObject( const svt::EmbeddedObjectRef& xRef, SwFlyFrmFmt **pFlyFrmFmt )
+{
+ ResetCursorStack();
+ StartAllAction();
+
+ StartUndo(UNDO_INSERT);
+
+ //Some differences between StarMath and any other objects:
+ //1. Selections should be deleted. For StarMath the Text should be
+ // passed to the Object
+ //2. If the cursor is at the end of an non empty paragraph a paragraph
+ // break should be insertet. StarMath objects are character bound and
+ // no break should be inserted.
+ //3. If an selektion is passed to a StarMath object, this object should
+ // not be activated. sal_False should be returned then.
+ bool bStarMath = true;
+ sal_Bool bActivate = sal_True;
+
+ // set parent to get correct VisArea(in case of object needing parent printer)
+ uno::Reference < container::XChild > xChild( xRef.GetObject(), uno::UNO_QUERY );
+ if ( xChild.is() )
+ xChild->setParent( mpDoc->GetDocShell()->GetModel() );
+
+ SvGlobalName aCLSID( xRef->getClassID() );
+ bStarMath = ( SotExchange::IsMath( aCLSID ) != 0 );
+ if( IsSelection() )
+ {
+ if( bStarMath )
+ {
+ OUString aMathData;
+ GetSelectedText( aMathData, GETSELTXT_PARABRK_TO_ONLYCR );
+
+ if( !aMathData.isEmpty() && svt::EmbeddedObjectRef::TryRunningState( xRef.GetObject() ) )
+ {
+ uno::Reference < beans::XPropertySet > xSet( xRef->getComponent(), uno::UNO_QUERY );
+ if ( xSet.is() )
+ {
+ try
+ {
+ xSet->setPropertyValue("Formula", uno::makeAny( OUString( aMathData ) ) );
+ bActivate = sal_False;
+ }
+ catch (const uno::Exception&)
+ {
+ }
+ }
+ }
+ }
+ DelRight();
+ }
+
+ if ( !bStarMath )
+ SwFEShell::SplitNode( sal_False, sal_False );
+
+ EnterSelFrmMode();
+
+ SwFlyFrmAttrMgr aFrmMgr( sal_True, this, FRMMGR_TYPE_OLE );
+ aFrmMgr.SetHeightSizeType(ATT_FIX_SIZE);
+
+ SwRect aBound;
+ CalcBoundRect( aBound, aFrmMgr.GetAnchor() );
+
+ //The Size should be suggested by the OLE server
+ MapMode aMapMode( MAP_TWIP );
+ Size aSz = xRef.GetSize( &aMapMode );
+
+ //Object size can be limited
+ if ( aSz.Width() > aBound.Width() )
+ {
+ //Always limit proportional.
+ aSz.Height() = aSz.Height() * aBound.Width() / aSz.Width();
+ aSz.Width() = aBound.Width();
+ }
+ aFrmMgr.SetSize( aSz );
+ SwFlyFrmFmt *pFmt = SwFEShell::InsertObject( xRef, &aFrmMgr.GetAttrSet() );
+
+ // --> #i972#
+ if ( bStarMath && mpDoc->get( IDocumentSettingAccess::MATH_BASELINE_ALIGNMENT ) )
+ AlignFormulaToBaseline( xRef.GetObject() );
+
+ if (pFlyFrmFmt)
+ *pFlyFrmFmt = pFmt;
+
+ if ( SotExchange::IsChart( aCLSID ) )
+ {
+ uno::Reference< embed::XEmbeddedObject > xEmbeddedObj( xRef.GetObject(), uno::UNO_QUERY );
+ if ( xEmbeddedObj.is() )
+ {
+ bool bDisableDataTableDialog = false;
+ svt::EmbeddedObjectRef::TryRunningState( xEmbeddedObj );
+ uno::Reference< beans::XPropertySet > xProps( xEmbeddedObj->getComponent(), uno::UNO_QUERY );
+ if ( xProps.is() &&
+ ( xProps->getPropertyValue("DisableDataTableDialog") >>= bDisableDataTableDialog ) &&
+ bDisableDataTableDialog )
+ {
+ xProps->setPropertyValue("DisableDataTableDialog",
+ uno::makeAny( sal_False ) );
+ xProps->setPropertyValue("DisableComplexChartTypes",
+ uno::makeAny( sal_False ) );
+ uno::Reference< util::XModifiable > xModifiable( xProps, uno::UNO_QUERY );
+ if ( xModifiable.is() )
+ {
+ xModifiable->setModified( sal_True );
+ }
+ }
+ }
+ }
+
+ EndAllAction();
+ GetView().AutoCaption(OLE_CAP, &aCLSID);
+
+ SwRewriter aRewriter;
+
+ if ( bStarMath )
+ aRewriter.AddRule(UndoArg1, SW_RES(STR_MATH_FORMULA));
+ else if ( SotExchange::IsChart( aCLSID ) )
+ aRewriter.AddRule(UndoArg1, SW_RES(STR_CHART));
+ else
+ aRewriter.AddRule(UndoArg1, SW_RES(STR_OLE));
+
+ EndUndo(UNDO_INSERT, &aRewriter);
+
+ return bActivate;
+}
+
+// The current selected OLE object will be loaded with the
+// verb into the server.
+
+void SwWrtShell::LaunchOLEObj( long nVerb )
+{
+ if ( GetCntType() == CNT_OLE &&
+ !GetView().GetViewFrame()->GetFrame().IsInPlace() )
+ {
+ svt::EmbeddedObjectRef& xRef = GetOLEObject();
+ OSL_ENSURE( xRef.is(), "OLE not found" );
+ SfxInPlaceClient* pCli=0;
+
+ pCli = GetView().FindIPClient( xRef.GetObject(), &GetView().GetEditWin() );
+ if ( !pCli )
+ pCli = new SwOleClient( &GetView(), &GetView().GetEditWin(), xRef );
+
+ ((SwOleClient*)pCli)->SetInDoVerb( sal_True );
+
+ CalcAndSetScale( xRef );
+ pCli->DoVerb( nVerb );
+
+ ((SwOleClient*)pCli)->SetInDoVerb( sal_False );
+ CalcAndSetScale( xRef );
+ }
+}
+
+void SwWrtShell::MoveObjectIfActive( svt::EmbeddedObjectRef& xObj, const Point& rOffset )
+{
+ try
+ {
+ sal_Int32 nState = xObj->getCurrentState();
+ if ( nState == ::com::sun::star::embed::EmbedStates::INPLACE_ACTIVE
+ || nState == ::com::sun::star::embed::EmbedStates::UI_ACTIVE )
+ {
+ SfxInPlaceClient* pCli =
+ GetView().FindIPClient( xObj.GetObject(), &(GetView().GetEditWin()) );
+ if ( pCli )
+ {
+ Rectangle aArea = pCli->GetObjArea();
+ aArea += rOffset;
+ pCli->SetObjArea( aArea );
+ }
+ }
+ }
+ catch (const uno::Exception&)
+ {
+ }
+}
+
+void SwWrtShell::CalcAndSetScale( svt::EmbeddedObjectRef& xObj,
+ const SwRect *pFlyPrtRect,
+ const SwRect *pFlyFrmRect,
+ const bool bNoTxtFrmPrtAreaChanged )
+{
+ // Setting the scale of the client. This arises from the difference
+ // between the VisArea of the object and the ObjArea.
+ OSL_ENSURE( xObj.is(), "ObjectRef not valid" );
+
+ sal_Int64 nAspect = xObj.GetViewAspect();
+ if ( nAspect == embed::Aspects::MSOLE_ICON )
+ return; // the replacement image is completely controlled by container in this case
+
+ sal_Int64 nMisc = 0;
+ bool bLinkingChart = false;
+
+ try
+ {
+ nMisc = xObj->getStatus( nAspect );
+
+ // This can surely only be a non-active object, if desired they
+ // get the new size set as VisArea (StarChart).
+ if( embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE & nMisc )
+ {
+ // TODO/MBA: testing
+ SwRect aRect( pFlyPrtRect ? *pFlyPrtRect
+ : GetAnyCurRect( RECT_FLY_PRT_EMBEDDED, 0, xObj.GetObject() ));
+ if( !aRect.IsEmpty() )
+ {
+ // TODO/LEAN: getMapUnit can switch object to running state
+ // xObj.TryRunningState();
+
+ MapUnit aUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( nAspect ) );
+
+ // TODO/LATER: needs complete VisArea?!
+ Size aSize( OutputDevice::LogicToLogic( aRect.SVRect(), MAP_TWIP, aUnit ).GetSize() );
+ awt::Size aSz;
+ aSz.Width = aSize.Width();
+ aSz.Height = aSize.Height();
+ xObj->setVisualAreaSize( nAspect, aSz );
+ // #i48419# - action 'UpdateReplacement' doesn't
+ // have to change the modified state of the document.
+ // This is only a workaround for the defect, that this action
+ // modifies a document after load, because unnecessarily the
+ // replacement graphic is updated, in spite of the fact that
+ // nothing has been changed.
+ // If the replacement graphic changes by this action, the document
+ // will be already modified via other mechanisms.
+ {
+ bool bResetEnableSetModified(false);
+ if ( GetDoc()->GetDocShell()->IsEnableSetModified() )
+ {
+ GetDoc()->GetDocShell()->EnableSetModified( sal_False );
+ bResetEnableSetModified = true;
+ }
+
+ //#i79576# don't destroy chart replacement images on load
+ //#i79578# don't request a new replacement image for charts to often
+ //a chart sends a modified call to the framework if it was changed
+ //thus the replacement update is already handled elsewhere
+ if ( !SotExchange::IsChart( xObj->getClassID() ) )
+ xObj.UpdateReplacement();
+
+ if ( bResetEnableSetModified )
+ {
+ GetDoc()->GetDocShell()->EnableSetModified( sal_True );
+ }
+ }
+ }
+
+ // TODO/LATER: this is only a workaround,
+ uno::Reference< chart2::XChartDocument > xChartDocument( xObj->getComponent(), uno::UNO_QUERY );
+ bLinkingChart = ( xChartDocument.is() && !xChartDocument->hasInternalDataProvider() );
+ }
+ }
+ catch (const uno::Exception&)
+ {
+ // TODO/LATER: handle the error
+ return;
+ }
+
+ SfxInPlaceClient* pCli = GetView().FindIPClient( xObj.GetObject(), &GetView().GetEditWin() );
+ if ( !pCli )
+ {
+ if ( (embed::EmbedMisc::EMBED_ACTIVATEIMMEDIATELY & nMisc)
+ || bLinkingChart
+ // TODO/LATER: ResizeOnPrinterChange
+ //|| SVOBJ_MISCSTATUS_RESIZEONPRINTERCHANGE & xObj->GetMiscStatus()
+ // --> OD #i117189# - refine condition for non-resizable objects
+ // non-resizable objects need to be set the size back by this method
+ || ( bNoTxtFrmPrtAreaChanged && nMisc & embed::EmbedMisc::EMBED_NEVERRESIZE ) )
+ {
+ pCli = new SwOleClient( &GetView(), &GetView().GetEditWin(), xObj );
+ }
+ else
+ return;
+ }
+
+ // TODO/LEAN: getMapUnit can switch object to running state
+ // xObj.TryRunningState();
+
+ awt::Size aSize;
+ try
+ {
+ aSize = xObj->getVisualAreaSize( nAspect );
+ }
+ catch (const embed::NoVisualAreaSizeException&)
+ {
+ OSL_FAIL("Can't get visual area size!\n" );
+ // the scaling will not be done
+ }
+ catch (const uno::Exception&)
+ {
+ // TODO/LATER: handle the error
+ OSL_FAIL("Can't get visual area size!\n" );
+ return;
+ }
+
+ Size _aVisArea( aSize.Width, aSize.Height );
+
+ Fraction aScaleWidth( 1, 1 );
+ Fraction aScaleHeight( 1, 1 );
+
+ bool bUseObjectSize = false;
+
+ // As long as there comes no reasonable size from the object,
+ // nothing can be scaled.
+ if( _aVisArea.Width() && _aVisArea.Height() )
+ {
+ const MapMode aTmp( MAP_TWIP );
+ MapUnit aUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( nAspect ) );
+ _aVisArea = OutputDevice::LogicToLogic( _aVisArea, aUnit, aTmp);
+ Size aObjArea;
+ if ( pFlyPrtRect )
+ aObjArea = pFlyPrtRect->SSize();
+ else
+ aObjArea = GetAnyCurRect( RECT_FLY_PRT_EMBEDDED, 0, xObj.GetObject() ).SSize();
+
+ // differ the aObjArea and _aVisArea by 1 Pixel then set new VisArea
+ long nX, nY;
+ SwSelPaintRects::Get1PixelInLogic( *this, &nX, &nY );
+ if( !( _aVisArea.Width() - nX <= aObjArea.Width() &&
+ _aVisArea.Width() + nX >= aObjArea.Width() &&
+ _aVisArea.Height()- nY <= aObjArea.Height()&&
+ _aVisArea.Height()+ nY >= aObjArea.Height() ))
+ {
+ if ( nMisc & embed::EmbedMisc::EMBED_NEVERRESIZE )
+ {
+ // the object must not be scaled,
+ // the size stored in object must be used for restoring
+ bUseObjectSize = true;
+ }
+ else
+ {
+ aScaleWidth = Fraction( aObjArea.Width(), _aVisArea.Width() );
+ aScaleHeight = Fraction( aObjArea.Height(), _aVisArea.Height());
+ }
+ }
+ }
+
+ // Now is the favorable time to set the ObjArea.
+ // The Scaling must be considered.
+ SwRect aArea;
+ if ( pFlyPrtRect )
+ {
+ aArea = *pFlyPrtRect;
+ aArea += pFlyFrmRect->Pos();
+ }
+ else
+ {
+ aArea = GetAnyCurRect( RECT_FLY_PRT_EMBEDDED, 0, xObj.GetObject() );
+ aArea.Pos() += GetAnyCurRect( RECT_FLY_EMBEDDED, 0, xObj.GetObject() ).Pos();
+ }
+
+ if ( bUseObjectSize )
+ {
+ // --> this moves non-resizable object so that when adding borders the baseline remains the same
+ const SwFlyFrmFmt *pFlyFrmFmt = dynamic_cast< const SwFlyFrmFmt * >( GetFlyFrmFmt() );
+ OSL_ENSURE( pFlyFrmFmt, "Could not find fly frame." );
+ if ( pFlyFrmFmt )
+ {
+ const Point &rPoint = pFlyFrmFmt->GetLastFlyFrmPrtRectPos();
+ SwRect aRect( pFlyPrtRect ? *pFlyPrtRect
+ : GetAnyCurRect( RECT_FLY_PRT_EMBEDDED, 0, xObj.GetObject() ));
+ aArea += rPoint - aRect.Pos(); // adjust area by diff of printing area position in order to keep baseline alignment correct.
+ }
+ aArea.Width ( _aVisArea.Width() );
+ aArea.Height( _aVisArea.Height() );
+ RequestObjectResize( aArea, xObj.GetObject() );
+ }
+ else
+ {
+ aArea.Width ( Fraction( aArea.Width() ) / pCli->GetScaleWidth() );
+ aArea.Height( Fraction( aArea.Height() ) / pCli->GetScaleHeight());
+ }
+
+ pCli->SetObjAreaAndScale( aArea.SVRect(), aScaleWidth, aScaleHeight );
+}
+
+void SwWrtShell::ConnectObj( svt::EmbeddedObjectRef& xObj, const SwRect &rPrt,
+ const SwRect &rFrm )
+{
+ SfxInPlaceClient* pCli = GetView().FindIPClient( xObj.GetObject(), &GetView().GetEditWin());
+ if ( !pCli )
+ pCli = new SwOleClient( &GetView(), &GetView().GetEditWin(), xObj );
+ CalcAndSetScale( xObj, &rPrt, &rFrm );
+}
+
+// Insert hard page break;
+// Selections will be overwritten
+
+void SwWrtShell::InsertPageBreak(const OUString *pPageDesc, ::boost::optional<sal_uInt16> oPgNum )
+{
+ ResetCursorStack();
+ if( CanInsert() )
+ {
+ SwActContext aActContext(this);
+ StartUndo(UNDO_UI_INSERT_PAGE_BREAK);
+
+ if ( !IsCrsrInTbl() )
+ {
+ if(HasSelection())
+ DelRight();
+ SwFEShell::SplitNode();
+ // delete the numbered attribute of the last line if the last line is empty
+ GetDoc()->ClearLineNumAttrs( *GetCrsr()->GetPoint() );
+ }
+
+ const SwPageDesc *pDesc = pPageDesc
+ ? FindPageDescByName( *pPageDesc, sal_True ) : 0;
+ if( pDesc )
+ {
+ SwFmtPageDesc aDesc( pDesc );
+ aDesc.SetNumOffset( oPgNum );
+ SetAttrItem( aDesc );
+ }
+ else
+ SetAttrItem( SvxFmtBreakItem(SVX_BREAK_PAGE_BEFORE, RES_BREAK) );
+ EndUndo(UNDO_UI_INSERT_PAGE_BREAK);
+ }
+}
+
+// Insert hard page break;
+// Selections will be overwritten
+
+void SwWrtShell::InsertLineBreak()
+{
+ ResetCursorStack();
+ if( CanInsert() )
+ {
+ if(HasSelection())
+ DelRight();
+
+ const sal_Unicode cIns = 0x0A;
+ SvxAutoCorrect* pACorr = lcl_IsAutoCorr();
+ if( pACorr )
+ AutoCorrect( *pACorr, cIns );
+ else
+ SwWrtShell::Insert( OUString( cIns ) );
+ }
+}
+
+// Insert hard column break;
+// Selections will be overwritten
+
+void SwWrtShell::InsertColumnBreak()
+{
+ SwActContext aActContext(this);
+ ResetCursorStack();
+ if( CanInsert() )
+ {
+ StartUndo(UNDO_UI_INSERT_COLUMN_BREAK);
+
+ if ( !IsCrsrInTbl() )
+ {
+ if(HasSelection())
+ DelRight();
+ SwFEShell::SplitNode( sal_False, sal_False );
+ }
+ SetAttrItem(SvxFmtBreakItem(SVX_BREAK_COLUMN_BEFORE, RES_BREAK));
+
+ EndUndo(UNDO_UI_INSERT_COLUMN_BREAK);
+ }
+}
+
+// Insert footnote
+// rStr - optional footnote mark
+
+void SwWrtShell::InsertFootnote(const OUString &rStr, sal_Bool bEndNote, sal_Bool bEdit )
+{
+ ResetCursorStack();
+ if( CanInsert() )
+ {
+ if(HasSelection())
+ {
+ //collapse cursor to the end
+ if(!IsCrsrPtAtEnd())
+ SwapPam();
+ ClearMark();
+ }
+ SwPosition aPos = *GetCrsr()->GetPoint();
+ SwFmtFtn aFootNote( bEndNote );
+ if(!rStr.isEmpty())
+ aFootNote.SetNumStr( rStr );
+
+ SetAttrItem(aFootNote);
+
+ if( bEdit )
+ {
+ // For editing the footnote text.
+ Left(CRSR_SKIP_CHARS, sal_False, 1, sal_False );
+ GotoFtnTxt();
+ }
+ aNavigationMgr.addEntry(aPos);
+ }
+}
+
+// SplitNode; also, because
+// - of deleting selected content;
+// - of reset of the Cursorstack if necessary.
+
+void SwWrtShell::SplitNode( sal_Bool bAutoFmt, sal_Bool bCheckTableStart )
+{
+ ResetCursorStack();
+ if( CanInsert() )
+ {
+ SwActContext aActContext(this);
+
+ rView.GetEditWin().FlushInBuffer();
+ sal_Bool bHasSel = HasSelection();
+ if( bHasSel )
+ {
+ StartUndo( UNDO_INSERT );
+ DelRight();
+ }
+
+ SwFEShell::SplitNode( bAutoFmt, bCheckTableStart );
+ if( bHasSel )
+ EndUndo( UNDO_INSERT );
+ }
+}
+
+// Turn on numbering
+// Parameter: Optional specification of a name for the named list;
+// this indicates a position if it is possible to convert them
+// into a number and less than nMaxRules.
+
+// To test the CharFormats at the numbering
+// external void SetNumChrFmt( SwWrtShell*, SwNumRules& );
+
+// -> #i40041#
+// Preconditions (as far as OD has figured out):
+// - <SwEditShell::HasNumber()> is sal_False, if <bNum> is sal_True
+// - <SwEditShell::HasBullet()> is sal_False, if <bNum> is sal_False
+// Behavior of method is determined by the current situation at the current
+// cursor position in the document.
+void SwWrtShell::NumOrBulletOn(sal_Bool bNum)
+{
+ // determine numbering rule found at current cursor position in the document.
+ const SwNumRule* pCurRule = GetCurNumRule();
+
+ StartUndo(UNDO_NUMORNONUM);
+
+ const SwNumRule * pNumRule = pCurRule;
+
+ // - activate outline rule respectively turning on outline rule for
+ // current text node. But, only for turning on a numbering (<bNum> == sal_True).
+ // - overwrite found numbering rule at current cursor position, if
+ // no numbering rule can be retrieved from the paragraph style.
+ bool bContinueFoundNumRule( false );
+ bool bActivateOutlineRule( false );
+ int nActivateOutlineLvl( MAXLEVEL ); // only relevant, if <bActivateOutlineRule> == sal_True
+ SwTxtFmtColl * pColl = GetCurTxtFmtColl();
+ if ( pColl )
+ {
+ // retrieve numbering rule at paragraph
+ // style, which is found at current cursor position in the document.
+ SwNumRule* pCollRule = mpDoc->FindNumRulePtr(pColl->GetNumRule().GetValue());
+ // #125993# - The outline numbering rule isn't allowed
+ // to be derived from a parent paragraph style to a derived one.
+ // Thus check, if the found outline numbering rule is directly
+ // set at the paragraph style <pColl>. If not, set <pCollRule> to NULL
+ if ( pCollRule && pCollRule == GetDoc()->GetOutlineNumRule() )
+ {
+ const SwNumRule* pDirectCollRule =
+ mpDoc->FindNumRulePtr(pColl->GetNumRule( sal_False ).GetValue());
+ if ( !pDirectCollRule )
+ {
+ pCollRule = 0;
+ }
+ }
+
+ if ( !pCollRule )
+ {
+ pNumRule = pCollRule;
+ }
+ // no activation or continuation of outline numbering in Writer/Web document
+ else if ( bNum &&
+ !dynamic_cast<SwWebDocShell*>(GetDoc()->GetDocShell()) &&
+ pCollRule == GetDoc()->GetOutlineNumRule() )
+ {
+ if ( pNumRule == pCollRule )
+ {
+ // check, if text node at current cursor positioned is counted.
+ // If not, let it been counted. Then it has to be checked,
+ // of the outline numbering has to be activated or continued.
+ SwTxtNode* pTxtNode =
+ GetCrsr()->GetPoint()->nNode.GetNode().GetTxtNode();
+ if ( pTxtNode && !pTxtNode->IsCountedInList() )
+ {
+ // check, if numbering of the outline level of the paragraph
+ // style is active. If not, activate this outline level.
+ nActivateOutlineLvl = pColl->GetAssignedOutlineStyleLevel();
+ OSL_ENSURE( pColl->IsAssignedToListLevelOfOutlineStyle(),
+ "<SwWrtShell::NumOrBulletOn(..)> - paragraph style with outline rule, but no outline level" );
+ if ( pColl->IsAssignedToListLevelOfOutlineStyle() &&
+ pCollRule->Get( static_cast<sal_uInt16>(nActivateOutlineLvl) ).GetNumberingType()
+ == SVX_NUM_NUMBER_NONE )
+ {
+ // activate outline numbering
+ bActivateOutlineRule = true;
+ }
+ else
+ {
+ // turning on outline numbering at current cursor position
+ bContinueFoundNumRule = true;
+ }
+ }
+ else
+ {
+ // #i101234#
+ // activate outline numbering, because from the precondition
+ // it's known, that <SwEdit::HasNumber()> == sal_False
+ bActivateOutlineRule = true;
+ nActivateOutlineLvl = pColl->GetAssignedOutlineStyleLevel();
+ }
+ }
+ else if ( !pNumRule )
+ {
+ // #i101234#
+ // Check, if corresponding list level of the outline numbering
+ // has already a numbering format set.
+ nActivateOutlineLvl = pColl->GetAssignedOutlineStyleLevel();
+ if ( pCollRule->Get( static_cast<sal_uInt16>(nActivateOutlineLvl) ).GetNumberingType()
+ == SVX_NUM_NUMBER_NONE )
+ {
+ // activate outline numbering, because from the precondition
+ // it's known, that <SwEdit::HasNumber()> == sal_False
+ bActivateOutlineRule = true;
+ }
+ else
+ {
+ // turning on outline numbering at current cursor position
+ bContinueFoundNumRule = true;
+ }
+ }
+ else
+ {
+ // check, if numbering of the outline level of the paragraph
+ // style is active. If not, activate this outline level.
+ nActivateOutlineLvl = pColl->GetAssignedOutlineStyleLevel();
+ OSL_ENSURE( pColl->IsAssignedToListLevelOfOutlineStyle(),
+ "<SwWrtShell::NumOrBulletOn(..)> - paragraph style with outline rule, but no outline level" );
+ if ( pColl->IsAssignedToListLevelOfOutlineStyle() &&
+ pCollRule->Get( static_cast<sal_uInt16>(nActivateOutlineLvl) ).GetNumberingType()
+ == SVX_NUM_NUMBER_NONE )
+ {
+ // activate outline numbering
+ bActivateOutlineRule = true;
+ }
+ else
+ {
+ // turning on outline numbering at current cursor position
+ bContinueFoundNumRule = true;
+ }
+ }
+ pNumRule = pCollRule;
+ }
+ }
+
+ // Only automatic numbering/bullet rules should be changed.
+ // Note: The outline numbering rule is also an automatic one. It's only
+ // changed, if it has to be activated.
+ if ( pNumRule )
+ {
+ if ( !pNumRule->IsAutoRule() )
+ {
+ pNumRule = 0;
+ }
+ else if ( pNumRule == GetDoc()->GetOutlineNumRule() &&
+ !bActivateOutlineRule && !bContinueFoundNumRule )
+ {
+ pNumRule = 0;
+ }
+ }
+
+ // Search for a previous numbering/bullet rule to continue it.
+ OUString sContinuedListId;
+ if ( !pNumRule )
+ {
+ pNumRule = GetDoc()->SearchNumRule( *GetCrsr()->GetPoint(),
+ false, bNum, false, 0,
+ sContinuedListId );
+ bContinueFoundNumRule = pNumRule != 0;
+ }
+
+ if (pNumRule)
+ {
+ SwNumRule aNumRule(*pNumRule);
+
+ // do not change found numbering/bullet rule, if it should only be continued.
+ if ( !bContinueFoundNumRule )
+ {
+ SwTxtNode * pTxtNode = GetCrsr()->GetPoint()->nNode.GetNode().GetTxtNode();
+
+ if (pTxtNode)
+ {
+ // use above retrieve outline level, if outline numbering has to be activated.
+ int nLevel = bActivateOutlineRule
+ ? nActivateOutlineLvl
+ : pTxtNode->GetActualListLevel();
+
+ if (nLevel < 0)
+ nLevel = 0;
+
+ if (nLevel >= MAXLEVEL)
+ nLevel = MAXLEVEL - 1;
+
+ SwNumFmt aFmt(aNumRule.Get(static_cast<sal_uInt16>(nLevel)));
+
+ if (bNum)
+ aFmt.SetNumberingType(SVX_NUM_ARABIC);
+ else
+ {
+ // #i63395# Only apply user defined default bullet font
+ if ( numfunc::IsDefBulletFontUserDefined() )
+ {
+ const Font* pFnt = &numfunc::GetDefBulletFont();
+ aFmt.SetBulletFont( pFnt );
+ }
+ aFmt.SetBulletChar( numfunc::GetBulletChar(static_cast<sal_uInt8>(nLevel)));
+ aFmt.SetNumberingType(SVX_NUM_CHAR_SPECIAL);
+ // #i93908# clear suffix for bullet lists
+ aFmt.SetPrefix(OUString());
+ aFmt.SetSuffix(OUString());
+ }
+ aNumRule.Set(static_cast<sal_uInt16>(nLevel), aFmt);
+ }
+ }
+
+ // reset indent attribute on applying list style
+ SetCurNumRule( aNumRule, false, sContinuedListId, true );
+ }
+ else
+ {
+ // #i95907#
+ const SvxNumberFormat::SvxNumPositionAndSpaceMode ePosAndSpaceMode(
+ numfunc::GetDefaultPositionAndSpaceMode() );
+ SwNumRule aNumRule( GetUniqueNumRuleName(), ePosAndSpaceMode );
+ // Append the character template at the numbering.
+ SwCharFmt* pChrFmt;
+ SwDocShell* pDocSh = GetView().GetDocShell();
+ // #i63395#
+ // Only apply user defined default bullet font
+ const Font* pFnt = numfunc::IsDefBulletFontUserDefined()
+ ? &numfunc::GetDefBulletFont()
+ : 0;
+
+ if (bNum)
+ {
+ pChrFmt = GetCharFmtFromPool( RES_POOLCHR_NUM_LEVEL );
+ }
+ else
+ {
+ pChrFmt = GetCharFmtFromPool( RES_POOLCHR_BUL_LEVEL );
+ }
+
+ const SwTxtNode* pTxtNode = GetCrsr()->GetPoint()->nNode.GetNode().GetTxtNode();
+ const SwTwips nWidthOfTabs = pTxtNode
+ ? pTxtNode->GetWidthOfLeadingTabs()
+ : 0;
+ GetDoc()->RemoveLeadingWhiteSpace( *GetCrsr()->GetPoint() );
+
+ const bool bHtml = 0 != PTR_CAST(SwWebDocShell, pDocSh);
+ const bool bRightToLeft = IsInRightToLeftText();
+ for( sal_uInt8 nLvl = 0; nLvl < MAXLEVEL; ++nLvl )
+ {
+ SwNumFmt aFmt( aNumRule.Get( nLvl ) );
+ aFmt.SetCharFmt( pChrFmt );
+
+ if (! bNum)
+ {
+ // #i63395#
+ // Only apply user defined default bullet font
+ if ( pFnt )
+ {
+ aFmt.SetBulletFont( pFnt );
+ }
+ aFmt.SetBulletChar( numfunc::GetBulletChar(nLvl) );
+ aFmt.SetNumberingType(SVX_NUM_CHAR_SPECIAL);
+ // #i93908# clear suffix for bullet lists
+ aFmt.SetPrefix(OUString());
+ aFmt.SetSuffix(OUString());
+ }
+
+ // #i95907#
+ if ( ePosAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
+ {
+ if(bHtml && nLvl)
+ {
+ // 1/2" for HTML
+ aFmt.SetLSpace(720);
+ aFmt.SetAbsLSpace(nLvl * 720);
+ }
+ else if ( nWidthOfTabs > 0 )
+ {
+ aFmt.SetAbsLSpace(nWidthOfTabs + nLvl * 720);
+ }
+ }
+
+ // #i38904# Default alignment for
+ // numbering/bullet should be rtl in rtl paragraph:
+ if ( bRightToLeft )
+ {
+ aFmt.SetNumAdjust( SVX_ADJUST_RIGHT );
+ }
+
+ aNumRule.Set( nLvl, aFmt );
+ }
+
+ // #i95907#
+ if ( pTxtNode &&
+ ePosAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
+ {
+
+ const SwTwips nTxtNodeIndent = pTxtNode->GetAdditionalIndentForStartingNewList();
+ if ( ( nTxtNodeIndent + nWidthOfTabs ) != 0 )
+ {
+ // #i111172#
+ // If text node is already inside a list, assure that the indents
+ // are the same. Thus, adjust the indent change value by subtracting
+ // indents of to be applied list style.
+ SwTwips nIndentChange = nTxtNodeIndent + nWidthOfTabs;
+ if ( pTxtNode->GetNumRule() )
+ {
+ const SwNumFmt aFmt( aNumRule.Get( 0 ) );
+ if ( aFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
+ {
+ nIndentChange -= aFmt.GetIndentAt() + aFmt.GetFirstLineIndent();
+ }
+ }
+ aNumRule.ChangeIndent( nIndentChange );
+ }
+ }
+ // reset indent attribute on applying list style
+ // start new list
+ SetCurNumRule( aNumRule, true, OUString(), true );
+ }
+
+ EndUndo(UNDO_NUMORNONUM);
+}
+// <- #i40041#
+
+void SwWrtShell::NumOn()
+{
+ NumOrBulletOn(sal_True);
+}
+
+void SwWrtShell::NumOrBulletOff()
+{
+ const SwNumRule * pCurNumRule = GetCurNumRule();
+
+ if (pCurNumRule)
+ {
+ if (pCurNumRule->IsOutlineRule())
+ {
+ SwNumRule aNumRule(*pCurNumRule);
+
+ SwTxtNode * pTxtNode =
+ GetCrsr()->GetPoint()->nNode.GetNode().GetTxtNode();
+
+ if (pTxtNode)
+ {
+ int nLevel = pTxtNode->GetActualListLevel();
+
+ if (nLevel < 0)
+ nLevel = 0;
+
+ if (nLevel >= MAXLEVEL)
+ nLevel = MAXLEVEL - 1;
+
+ SwNumFmt aFmt(aNumRule.Get(static_cast<sal_uInt16>(nLevel)));
+
+ aFmt.SetNumberingType(SVX_NUM_NUMBER_NONE);
+ aNumRule.Set(nLevel, aFmt);
+
+ // no start or continuation of a list - the outline style is only changed.
+ SetCurNumRule( aNumRule, false );
+ }
+ }
+ else
+ {
+ DelNumRules();
+ }
+
+ // #126346# - Cursor can not be anymore in front of
+ // a label, because numbering/bullet is switched off.
+ SetInFrontOfLabel( false );
+ }
+}
+// <- #i29560#
+
+// Request Default-Bulletlist
+
+void SwWrtShell::BulletOn()
+{
+ NumOrBulletOn(sal_False);
+}
+
+SelectionType SwWrtShell::GetSelectionType() const
+{
+ // ContentType cannot be determined within a
+ // Start-/Endaction parentheses.
+ // Because there is no invalid value TEXT will be returned.
+ // The value does not matter, it may be updated in endaction anyway.
+
+ if ( BasicActionPend() )
+ return IsSelFrmMode() ? nsSelectionType::SEL_FRM : nsSelectionType::SEL_TXT;
+
+ SwView &_rView = ((SwView&)GetView());
+ if (_rView.GetPostItMgr() && _rView.GetPostItMgr()->HasActiveSidebarWin() )
+ return nsSelectionType::SEL_POSTIT;
+
+ // Inserting a frame is not a DrawMode
+ int nCnt;
+ if ( !_rView.GetEditWin().IsFrmAction() &&
+ (IsObjSelected() || (_rView.IsDrawMode() && !IsFrmSelected()) ))
+ {
+ if (GetDrawView()->IsTextEdit())
+ nCnt = nsSelectionType::SEL_DRW_TXT;
+ else
+ {
+ if (GetView().IsFormMode()) // Only Form selected
+ nCnt = nsSelectionType::SEL_DRW_FORM;
+ else
+ nCnt = nsSelectionType::SEL_DRW; // Any draw object
+
+ if (_rView.IsBezierEditMode())
+ nCnt |= nsSelectionType::SEL_BEZ;
+ else if( GetDrawView()->GetContext() == SDRCONTEXT_MEDIA )
+ nCnt |= nsSelectionType::SEL_MEDIA;
+
+ if (svx::checkForSelectedCustomShapes(
+ const_cast<SdrView *>(GetDrawView()),
+ true /* bOnlyExtruded */ ))
+ {
+ nCnt |= nsSelectionType::SEL_EXTRUDED_CUSTOMSHAPE;
+ }
+ sal_uInt32 nCheckStatus = 0;
+ if (svx::checkForSelectedFontWork(
+ const_cast<SdrView *>(GetDrawView()), nCheckStatus ))
+ {
+ nCnt |= nsSelectionType::SEL_FONTWORK;
+ }
+ }
+
+ return nCnt;
+ }
+
+ nCnt = GetCntType();
+
+ if ( IsFrmSelected() )
+ {
+ if (_rView.IsDrawMode())
+ _rView.LeaveDrawCreate(); // clean up (Bug #45639)
+ if ( !(nCnt & (CNT_GRF | CNT_OLE)) )
+ return nsSelectionType::SEL_FRM;
+ }
+
+ if ( IsCrsrInTbl() )
+ nCnt |= nsSelectionType::SEL_TBL;
+
+ if ( IsTableMode() )
+ nCnt |= (nsSelectionType::SEL_TBL | nsSelectionType::SEL_TBL_CELLS);
+
+ // Do not pop up numbering toolbar, if the text node has a numbering of type SVX_NUM_NUMBER_NONE.
+ const SwNumRule* pNumRule = GetCurNumRule();
+ if ( pNumRule )
+ {
+ const SwTxtNode* pTxtNd =
+ GetCrsr()->GetPoint()->nNode.GetNode().GetTxtNode();
+
+ if ( pTxtNd && pTxtNd->IsInList() )
+ {
+ const SwNumFmt& rFmt = pNumRule->Get(sal::static_int_cast< sal_uInt8, sal_Int32>(pTxtNd->GetActualListLevel()));
+ if ( SVX_NUM_NUMBER_NONE != rFmt.GetNumberingType() )
+ nCnt |= nsSelectionType::SEL_NUM;
+ }
+ }
+
+ return nCnt;
+}
+
+// Find the text collection with the name rCollname
+// Returns: Pointer at the collection or 0, if no
+// text collection with this name exists, or
+// this is a default template.
+
+SwTxtFmtColl *SwWrtShell::GetParaStyle(const OUString &rCollName, GetStyle eCreate )
+{
+ SwTxtFmtColl* pColl = FindTxtFmtCollByName( rCollName );
+ if( !pColl && GETSTYLE_NOCREATE != eCreate )
+ {
+ sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( rCollName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
+ if( USHRT_MAX != nId || GETSTYLE_CREATEANY == eCreate )
+ pColl = GetTxtCollFromPool( nId );
+ }
+ return pColl;
+}
+
+// Find the text collection with the name rCollname
+// Returns: Pointer at the collection or 0, if no
+// character template with this name exists, or
+// this is a default template or template is automatic.
+
+SwCharFmt *SwWrtShell::GetCharStyle(const OUString &rFmtName, GetStyle eCreate )
+{
+ SwCharFmt* pFmt = FindCharFmtByName( rFmtName );
+ if( !pFmt && GETSTYLE_NOCREATE != eCreate )
+ {
+ sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( rFmtName, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT );
+ if( USHRT_MAX != nId || GETSTYLE_CREATEANY == eCreate )
+ pFmt = (SwCharFmt*)GetFmtFromPool( nId );
+ }
+ return pFmt;
+}
+
+// Find the table format with the name rFmtname
+// Returns: Pointer at the collection or 0, if no
+// frame format with this name exists or
+// this is a default format or the format is automatic.
+
+SwFrmFmt *SwWrtShell::GetTblStyle(const OUString &rFmtName)
+{
+ SwFrmFmt *pFmt = 0;
+ for( sal_uInt16 i = GetTblFrmFmtCount(); i; )
+ if( !( pFmt = &GetTblFrmFmt( --i ) )->IsDefault() &&
+ pFmt->GetName() == rFmtName && IsUsed( *pFmt ) )
+ return pFmt;
+ return 0;
+}
+
+SwNavigationMgr& SwWrtShell::GetNavigationMgr() {
+ return aNavigationMgr;
+}
+
+void SwWrtShell::addCurrentPosition() {
+ SwPaM* pPaM = GetCrsr();
+ aNavigationMgr.addEntry(*pPaM->GetPoint());
+}
+
+// Applying templates
+
+void SwWrtShell::SetPageStyle(const OUString &rCollName)
+{
+ if( !SwCrsrShell::HasSelection() && !IsSelFrmMode() && !IsObjSelected() )
+ {
+ SwPageDesc* pDesc = FindPageDescByName( rCollName, sal_True );
+ if( pDesc )
+ ChgCurPageDesc( *pDesc );
+ }
+}
+
+// Access templates
+
+OUString SwWrtShell::GetCurPageStyle( const sal_Bool bCalcFrm ) const
+{
+ return GetPageDesc(GetCurPageDesc( bCalcFrm )).GetName();
+}
+
+// Change the current template referring to the existing change.
+
+void SwWrtShell::QuickUpdateStyle()
+{
+ SwTxtFmtColl *pColl = GetCurTxtFmtColl();
+
+ // Default cannot be changed
+ if(pColl && !pColl->IsDefault())
+ {
+ FillByEx(pColl);
+ // Also apply the template to remove hard attribute assignment.
+ SetTxtFmtColl(pColl);
+ }
+}
+
+void SwWrtShell::AutoUpdatePara(SwTxtFmtColl* pColl, const SfxItemSet& rStyleSet, SwPaM* pPaM )
+{
+ SwPaM* pCrsr = pPaM ? pPaM : GetCrsr( );
+ SfxItemSet aCoreSet( GetAttrPool(),
+ RES_CHRATR_BEGIN, RES_CHRATR_END - 1,
+ RES_PARATR_BEGIN, RES_PARATR_END - 1,
+ RES_FRMATR_BEGIN, RES_FRMATR_END - 1,
+ SID_ATTR_TABSTOP_POS, SID_ATTR_TABSTOP_POS,
+ SID_ATTR_TABSTOP_DEFAULTS, SID_ATTR_TABSTOP_DEFAULTS,
+ SID_ATTR_TABSTOP_OFFSET, SID_ATTR_TABSTOP_OFFSET,
+ SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
+ SID_ATTR_PARA_MODEL, SID_ATTR_PARA_KEEP,
+ SID_ATTR_PARA_PAGENUM, SID_ATTR_PARA_PAGENUM,
+ 0 );
+ GetPaMAttr( pCrsr, aCoreSet );
+ bool bReset = false;
+ SfxItemIter aParaIter( aCoreSet );
+ const SfxPoolItem* pParaItem = aParaIter.FirstItem();
+ while( pParaItem )
+ {
+ if(!IsInvalidItem(pParaItem))
+ {
+ sal_uInt16 nWhich = pParaItem->Which();
+ if(SFX_ITEM_SET == aCoreSet.GetItemState(nWhich) &&
+ SFX_ITEM_SET == rStyleSet.GetItemState(nWhich))
+ {
+ aCoreSet.ClearItem(nWhich);
+ bReset = true;
+ }
+ }
+ pParaItem = aParaIter.NextItem();
+ }
+ StartAction();
+ if(bReset)
+ {
+ ResetAttr( std::set<sal_uInt16>(), pCrsr );
+ SetAttrSet(aCoreSet, 0, pCrsr);
+ }
+ mpDoc->ChgFmt(*pColl, rStyleSet );
+ EndAction();
+}
+
+void SwWrtShell::AutoUpdateFrame( SwFrmFmt* pFmt, const SfxItemSet& rStyleSet )
+{
+ StartAction();
+
+ ResetFlyFrmAttr( 0, &rStyleSet );
+ pFmt->SetFmtAttr( rStyleSet );
+
+ EndAction();
+}
+
+void SwWrtShell::AutoCorrect( SvxAutoCorrect& rACorr, sal_Unicode cChar )
+{
+ ResetCursorStack();
+ if(CanInsert())
+ {
+ bool bStarted = false;
+ if(HasSelection())
+ {
+ // Only parenthese here, because the regular insert
+ // is already clipped to the editshell
+ StartAllAction();
+ StartUndo(UNDO_INSERT);
+ bStarted = true;
+ DelRight();
+ }
+ SwEditShell::AutoCorrect( rACorr, IsInsMode(), cChar );
+
+ if(bStarted)
+ {
+ EndAllAction();
+ EndUndo(UNDO_INSERT);
+ }
+ }
+}
+
+// Some kind of controlled copy ctor
+
+SwWrtShell::SwWrtShell( SwWrtShell& rSh, Window *_pWin, SwView &rShell )
+ : SwFEShell( rSh, _pWin ),
+ COMMON_INI_LIST
+{
+ BITFLD_INI_LIST
+ SET_CURR_SHELL( this );
+
+ SetSfxViewShell( (SfxViewShell *)&rShell );
+ SetFlyMacroLnk( LINK(this, SwWrtShell, ExecFlyMac) );
+
+ // place the cursor on the first field...
+ IFieldmark *pBM = NULL;
+ if ( IsFormProtected() && ( pBM = GetFieldmarkAfter( ) ) !=NULL ) {
+ GotoFieldmark(pBM);
+ }
+}
+
+SwWrtShell::SwWrtShell( SwDoc& rDoc, Window *_pWin, SwView &rShell,
+ const SwViewOption *pViewOpt )
+ : SwFEShell( rDoc, _pWin, pViewOpt),
+ COMMON_INI_LIST
+{
+ BITFLD_INI_LIST
+ SET_CURR_SHELL( this );
+ SetSfxViewShell( (SfxViewShell *)&rShell );
+ SetFlyMacroLnk( LINK(this, SwWrtShell, ExecFlyMac) );
+
+ // place the cursor on the first field...
+ IFieldmark *pBM = NULL;
+ if ( IsFormProtected() && ( pBM = GetFieldmarkAfter( ) ) !=NULL ) {
+ GotoFieldmark(pBM);
+ }
+}
+
+SwWrtShell::~SwWrtShell()
+{
+ SET_CURR_SHELL( this );
+ while(IsModePushed())
+ PopMode();
+ while(PopCrsr(sal_False))
+ ;
+ SwTransferable::ClearSelection( *this );
+}
+
+sal_Bool SwWrtShell::Pop( sal_Bool bOldCrsr )
+{
+ sal_Bool bRet = SwCrsrShell::Pop( bOldCrsr );
+ if( bRet && IsSelection() )
+ {
+ fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
+ fnKillSel = &SwWrtShell::ResetSelect;
+ }
+ return bRet;
+}
+
+bool SwWrtShell::CanInsert()
+{
+ if(IsSelFrmMode())
+ {
+ return false;
+ }
+
+ if(IsObjSelected())
+ {
+ return false;
+ }
+
+ if(GetView().GetDrawFuncPtr())
+ {
+ return false;
+ }
+
+ if(GetView().GetPostItMgr()->GetActiveSidebarWin())
+ {
+ return false;
+ }
+
+ return true;
+}
+
+void SwWrtShell::ChgDBData(const SwDBData& aDBData)
+{
+ SwEditShell::ChgDBData(aDBData);
+ //notify the db-beamer if available
+ GetView().NotifyDBChanged();
+}
+
+OUString SwWrtShell::GetSelDescr() const
+{
+ OUString aResult;
+
+ int nSelType = GetSelectionType();
+ switch (nSelType)
+ {
+ case nsSelectionType::SEL_GRF:
+ aResult = SW_RESSTR(STR_GRAPHIC);
+
+ break;
+ case nsSelectionType::SEL_FRM:
+ {
+ const SwFrmFmt * pFrmFmt = GetCurFrmFmt();
+
+ if (pFrmFmt)
+ aResult = pFrmFmt->GetDescription();
+ }
+ break;
+ case nsSelectionType::SEL_DRW:
+ {
+ aResult = SW_RESSTR(STR_DRAWING_OBJECTS);
+ }
+ break;
+ default:
+ if (0 != mpDoc)
+ aResult = GetCrsrDescr();
+ }
+
+ return aResult;
+}
+
+void SwWrtShell::ApplyViewOptions( const SwViewOption &rOpt )
+{
+ SwFEShell::ApplyViewOptions( rOpt );
+ //#i115062# invalidate meta character slot
+ GetView().GetViewFrame()->GetBindings().Invalidate( FN_VIEW_META_CHARS );
+}
+
+void SwWrtShell::SetReadonlyOption(sal_Bool bSet)
+{
+ GetView().GetEditWin().GetFrameControlsManager().SetReadonlyControls( bSet );
+ SwViewShell::SetReadonlyOption( bSet );
+}
+
+// Switch on/off header or footer of a page style - if an empty name is
+// given all styles are changed
+
+void SwWrtShell::ChangeHeaderOrFooter(
+ const OUString& rStyleName, sal_Bool bHeader, sal_Bool bOn, sal_Bool bShowWarning)
+{
+ addCurrentPosition();
+ StartAllAction();
+ StartUndo( UNDO_HEADER_FOOTER ); // #i7983#
+ bool bExecute = true;
+ sal_Bool bCrsrSet = sal_False;
+ for( sal_uInt16 nFrom = 0, nTo = GetPageDescCnt();
+ nFrom < nTo; ++nFrom )
+ {
+ int bChgd = sal_False;
+ SwPageDesc aDesc( GetPageDesc( nFrom ));
+ OUString sTmp(aDesc.GetName());
+ if( rStyleName.isEmpty() || rStyleName == sTmp )
+ {
+ if( bShowWarning && !bOn && GetActiveView() && GetActiveView() == &GetView() &&
+ ( (bHeader && aDesc.GetMaster().GetHeader().IsActive()) ||
+ (!bHeader && aDesc.GetMaster().GetFooter().IsActive()) ) )
+ {
+ bShowWarning = sal_False;
+ //Actions have to be closed while the dialog is showing
+ EndAllAction();
+
+ Window* pParent = &GetView().GetViewFrame()->GetWindow();
+ short nResult;
+ if (bHeader)
+ nResult = DeleteHeaderDialog(pParent).Execute();
+ else
+ nResult = DeleteFooterDialog(pParent).Execute();
+ bExecute = nResult == RET_YES;
+
+ StartAllAction();
+ }
+ if( bExecute )
+ {
+ bChgd = sal_True;
+ SwFrmFmt &rMaster = aDesc.GetMaster();
+ if(bHeader)
+ rMaster.SetFmtAttr( SwFmtHeader( bOn ));
+ else
+ rMaster.SetFmtAttr( SwFmtFooter( bOn ));
+ if( bOn )
+ {
+ SvxULSpaceItem aUL(bHeader ? 0 : MM50, bHeader ? MM50 : 0, RES_UL_SPACE );
+ SwFrmFmt* pFmt = bHeader ?
+ (SwFrmFmt*)rMaster.GetHeader().GetHeaderFmt() :
+ (SwFrmFmt*)rMaster.GetFooter().GetFooterFmt();
+ pFmt->SetFmtAttr( aUL );
+ }
+ }
+ if( bChgd )
+ {
+ ChgPageDesc( nFrom, aDesc );
+
+ if( !bCrsrSet && bOn )
+ {
+ if ( !IsHeaderFooterEdit() )
+ ToggleHeaderFooterEdit();
+ bCrsrSet = SetCrsrInHdFt(
+ rStyleName.isEmpty() ? (sal_uInt16)0xFFFF : nFrom,
+ bHeader );
+ }
+ }
+ }
+ }
+ EndUndo( UNDO_HEADER_FOOTER ); // #i7983#
+ EndAllAction();
+}
+
+void SwWrtShell::SetShowHeaderFooterSeparator( FrameControlType eControl, bool bShow )
+{
+ SwViewShell::SetShowHeaderFooterSeparator( eControl, bShow );
+ if ( !bShow )
+ GetView().GetEditWin().GetFrameControlsManager().HideControls( eControl );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/wrtsh/wrtsh2.cxx b/sw/source/core/uibase/wrtsh/wrtsh2.cxx
new file mode 100644
index 000000000000..1634d1dae0b6
--- /dev/null
+++ b/sw/source/core/uibase/wrtsh/wrtsh2.cxx
@@ -0,0 +1,542 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <hintids.hxx>
+#include <svl/macitem.hxx>
+#include <sfx2/frame.hxx>
+#include <vcl/msgbox.hxx>
+#include <svl/urihelper.hxx>
+#include <svl/eitem.hxx>
+#include <svl/stritem.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/fcontnr.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/linkmgr.hxx>
+#include <fmtinfmt.hxx>
+#include <frmatr.hxx>
+#include <swtypes.hxx>
+#include <wrtsh.hxx>
+#include <docsh.hxx>
+#include <fldbas.hxx>
+#include <expfld.hxx>
+#include <ddefld.hxx>
+#include <docufld.hxx>
+#include <reffld.hxx>
+#include <swundo.hxx>
+#include <doc.hxx>
+#include <IDocumentUndoRedo.hxx>
+#include <viewopt.hxx>
+#include <frmfmt.hxx>
+#include <swtable.hxx>
+#include <mdiexp.hxx>
+#include <view.hxx>
+#include <swevent.hxx>
+#include <poolfmt.hxx>
+#include <section.hxx>
+#include <navicont.hxx>
+#include <navipi.hxx>
+#include <crsskip.hxx>
+#include <txtinet.hxx>
+#include <cmdid.h>
+#include <wrtsh.hrc>
+#include "swabstdlg.hxx"
+#include "fldui.hrc"
+#include <SwRewriter.hxx>
+
+#include <com/sun/star/document/XDocumentProperties.hpp>
+#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
+
+#include <xmloff/odffields.hxx>
+
+void SwWrtShell::Insert(SwField &rFld)
+{
+ ResetCursorStack();
+ if(!CanInsert())
+ return;
+ StartAllAction();
+
+ SwRewriter aRewriter;
+ aRewriter.AddRule(UndoArg1, rFld.GetDescription());
+
+ StartUndo(UNDO_INSERT, &aRewriter);
+
+ bool bDeleted = false;
+ const SwPaM* pAnnotationTextRange = NULL;
+ if ( HasSelection() )
+ {
+ if ( rFld.GetTyp()->Which() == RES_POSTITFLD )
+ {
+ // for annotation fields:
+ // - keep the current selection in order to create a corresponding annotation mark
+ // - collapse cursor to its end
+ if ( IsTableMode() )
+ {
+ GetTblCrs()->Normalize( false );
+ const SwPosition rStartPos( *(GetTblCrs()->GetMark()->nNode.GetNode().GetCntntNode()), 0 );
+ KillPams();
+ EndPara();
+ const SwPosition rEndPos( *GetCurrentShellCursor().GetPoint() );
+ pAnnotationTextRange = new SwPaM( rStartPos, rEndPos );
+ }
+ else
+ {
+ NormalizePam( sal_False );
+ const SwPaM& rCurrPaM = GetCurrentShellCursor();
+ pAnnotationTextRange = new SwPaM( *rCurrPaM.GetPoint(), *rCurrPaM.GetMark() );
+ ClearMark();
+ }
+ }
+ else
+ {
+ bDeleted = DelRight() != 0;
+ }
+ }
+
+ SwEditShell::Insert2(rFld, bDeleted);
+
+ if ( pAnnotationTextRange != NULL )
+ {
+ if ( GetDoc() != NULL )
+ {
+ IDocumentMarkAccess* pMarksAccess = GetDoc()->getIDocumentMarkAccess();
+ pMarksAccess->makeAnnotationMark( *pAnnotationTextRange, ::rtl::OUString() );
+ }
+ delete pAnnotationTextRange;
+ }
+
+ EndUndo();
+ EndAllAction();
+}
+
+// Start the field update
+
+void SwWrtShell::UpdateInputFlds( SwInputFieldList* pLst )
+{
+ // Go through the list of fields and updating
+ SwInputFieldList* pTmp = pLst;
+ if( !pTmp )
+ pTmp = new SwInputFieldList( this );
+
+ const sal_uInt16 nCnt = pTmp->Count();
+ if(nCnt)
+ {
+ pTmp->PushCrsr();
+
+ sal_Bool bCancel = sal_False;
+ OString aDlgPos;
+ for( sal_uInt16 i = 0; i < nCnt && !bCancel; ++i )
+ {
+ pTmp->GotoFieldPos( i );
+ SwField* pField = pTmp->GetField( i );
+ if(pField->GetTyp()->Which() == RES_DROPDOWN)
+ bCancel = StartDropDownFldDlg( pField, sal_True, &aDlgPos );
+ else
+ bCancel = StartInputFldDlg( pField, sal_True, 0, &aDlgPos);
+
+ if (!bCancel)
+ {
+ // Otherwise update error at multi-selection:
+ pTmp->GetField( i )->GetTyp()->UpdateFlds();
+ }
+ }
+ pTmp->PopCrsr();
+ }
+
+ if( !pLst )
+ delete pTmp;
+}
+
+// Listener class: will close InputField dialog if input field(s)
+// is(are) deleted (for instance, by an extension) after the dialog shows up.
+// Otherwise, the for loop in SwWrtShell::UpdateInputFlds will crash when doing:
+// 'pTmp->GetField( i )->GetTyp()->UpdateFlds();'
+// on a deleted field.
+class FieldDeletionModify : public SwModify
+{
+ public:
+ FieldDeletionModify(AbstractFldInputDlg* pInputFieldDlg) : mpInputFieldDlg(pInputFieldDlg) {}
+
+ void Modify( const SfxPoolItem* pOld, const SfxPoolItem *)
+ {
+ // Input fields have been deleted: better to close the dialog
+ if (pOld->Which() == RES_FIELD_DELETED)
+ {
+ mpInputFieldDlg->EndDialog(RET_CANCEL);
+ }
+ }
+ private:
+ AbstractFldInputDlg* mpInputFieldDlg;
+};
+
+// Start input dialog for a specific field
+
+sal_Bool SwWrtShell::StartInputFldDlg( SwField* pFld, sal_Bool bNextButton,
+ Window* pParentWin, OString* pWindowState )
+{
+
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "Dialogdiet fail!");
+ AbstractFldInputDlg* pDlg = pFact->CreateFldInputDlg(pParentWin, *this, pFld, bNextButton);
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ if(pWindowState && !pWindowState->isEmpty())
+ pDlg->SetWindowState(*pWindowState);
+
+ // Register for possible input field deletion while dialog is open
+ FieldDeletionModify aModify(pDlg);
+ GetDoc()->GetUnoCallBack()->Add(&aModify);
+
+ sal_Bool bRet = RET_CANCEL == pDlg->Execute();
+
+ // Dialog closed, remove modification listener
+ GetDoc()->GetUnoCallBack()->Remove(&aModify);
+
+ if(pWindowState)
+ *pWindowState = pDlg->GetWindowState();
+
+ delete pDlg;
+ GetWin()->Update();
+ return bRet;
+}
+
+sal_Bool SwWrtShell::StartDropDownFldDlg(SwField* pFld, sal_Bool bNextButton, OString* pWindowState)
+{
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+
+ AbstractDropDownFieldDialog* pDlg = pFact->CreateDropDownFieldDialog(NULL, *this, pFld, bNextButton);
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+ if(pWindowState && !pWindowState->isEmpty())
+ pDlg->SetWindowState(*pWindowState);
+ sal_uInt16 nRet = pDlg->Execute();
+ if(pWindowState)
+ *pWindowState = pDlg->GetWindowState();
+ delete pDlg;
+ sal_Bool bRet = RET_CANCEL == nRet;
+ GetWin()->Update();
+ if(RET_YES == nRet)
+ {
+ GetView().GetViewFrame()->GetDispatcher()->Execute(FN_EDIT_FIELD, SFX_CALLMODE_SYNCHRON);
+ }
+ return bRet;
+}
+
+// Insert directory - remove selection
+
+void SwWrtShell::InsertTableOf(const SwTOXBase& rTOX, const SfxItemSet* pSet)
+{
+ if(!CanInsert())
+ return;
+
+ if(HasSelection())
+ DelRight();
+
+ SwEditShell::InsertTableOf(rTOX, pSet);
+}
+
+// Update directory - remove selection
+
+sal_Bool SwWrtShell::UpdateTableOf(const SwTOXBase& rTOX, const SfxItemSet* pSet)
+{
+ sal_Bool bResult = sal_False;
+
+ if(CanInsert())
+ {
+ bResult = SwEditShell::UpdateTableOf(rTOX, pSet);
+
+ if (pSet == NULL)
+ {
+ SwDoc *const pDoc_ = GetDoc();
+ if (pDoc_)
+ {
+ pDoc_->GetIDocumentUndoRedo().DelAllUndoObj();
+ }
+ }
+ }
+
+ return bResult;
+}
+
+// handler for click on the field given as parameter.
+// the cursor is positioned on the field.
+
+void SwWrtShell::ClickToField( const SwField& rFld )
+{
+ // cross reference field must not be selected because it moves the cursor
+ if (RES_GETREFFLD != rFld.GetTyp()->Which())
+ {
+ StartAllAction();
+ Right( CRSR_SKIP_CHARS, true, 1, false ); // Select the field.
+ NormalizePam();
+ EndAllAction();
+ }
+
+ bIsInClickToEdit = true;
+ switch( rFld.GetTyp()->Which() )
+ {
+ case RES_JUMPEDITFLD:
+ {
+ sal_uInt16 nSlotId = 0;
+ switch( rFld.GetFormat() )
+ {
+ case JE_FMT_TABLE:
+ nSlotId = FN_INSERT_TABLE;
+ break;
+
+ case JE_FMT_FRAME:
+ nSlotId = FN_INSERT_FRAME;
+ break;
+
+ case JE_FMT_GRAPHIC: nSlotId = SID_INSERT_GRAPHIC; break;
+ case JE_FMT_OLE: nSlotId = SID_INSERT_OBJECT; break;
+
+ }
+
+ if( nSlotId )
+ {
+ StartUndo( UNDO_START );
+ //#97295# immediately select the right shell
+ GetView().StopShellTimer();
+ GetView().GetViewFrame()->GetDispatcher()->Execute( nSlotId,
+ SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD );
+ EndUndo( UNDO_END );
+ }
+ }
+ break;
+
+ case RES_MACROFLD:
+ {
+ const SwMacroField *pFld = (const SwMacroField*)&rFld;
+ const OUString sText( rFld.GetPar2() );
+ OUString sRet( sText );
+ ExecMacro( pFld->GetSvxMacro(), &sRet );
+
+ // return value changed?
+ if( sRet != sText )
+ {
+ StartAllAction();
+ ((SwField&)rFld).SetPar2( sRet );
+ ((SwField&)rFld).GetTyp()->UpdateFlds();
+ EndAllAction();
+ }
+ }
+ break;
+
+ case RES_GETREFFLD:
+ StartAllAction();
+ SwCrsrShell::GotoRefMark( ((SwGetRefField&)rFld).GetSetRefName(),
+ ((SwGetRefField&)rFld).GetSubType(),
+ ((SwGetRefField&)rFld).GetSeqNo() );
+ EndAllAction();
+ break;
+
+ case RES_INPUTFLD:
+ {
+ const SwInputField* pInputField = dynamic_cast<const SwInputField*>(&rFld);
+ if ( pInputField == NULL )
+ {
+ StartInputFldDlg( (SwField*)&rFld, sal_False );
+ }
+ }
+ break;
+
+ case RES_SETEXPFLD:
+ if( ((SwSetExpField&)rFld).GetInputFlag() )
+ StartInputFldDlg( (SwField*)&rFld, sal_False );
+ break;
+ case RES_DROPDOWN :
+ StartDropDownFldDlg( (SwField*)&rFld, sal_False );
+ break;
+ default:
+ SAL_WARN_IF(rFld.IsClickable(), "sw", "unhandled clickable field!");
+ }
+
+ bIsInClickToEdit = false;
+}
+
+void SwWrtShell::ClickToINetAttr( const SwFmtINetFmt& rItem, sal_uInt16 nFilter )
+{
+ if( rItem.GetValue().isEmpty() )
+ return ;
+
+ bIsInClickToEdit = true;
+
+ // At first run the possibly set ObjectSelect Macro
+ const SvxMacro* pMac = rItem.GetMacro( SFX_EVENT_MOUSECLICK_OBJECT );
+ if( pMac )
+ {
+ SwCallMouseEvent aCallEvent;
+ aCallEvent.Set( &rItem );
+ GetDoc()->CallEvent( SFX_EVENT_MOUSECLICK_OBJECT, aCallEvent, false );
+ }
+
+ // So that the implementation of templates is displayed immediately
+ ::LoadURL( *this, rItem.GetValue(), nFilter, rItem.GetTargetFrame() );
+ const SwTxtINetFmt* pTxtAttr = rItem.GetTxtINetFmt();
+ if( pTxtAttr )
+ {
+ const_cast<SwTxtINetFmt*>(pTxtAttr)->SetVisited( true );
+ const_cast<SwTxtINetFmt*>(pTxtAttr)->SetVisitedValid( true );
+ }
+
+ bIsInClickToEdit = false;
+}
+
+bool SwWrtShell::ClickToINetGrf( const Point& rDocPt, sal_uInt16 nFilter )
+{
+ bool bRet = false;
+ OUString sURL;
+ OUString sTargetFrameName;
+ const SwFrmFmt* pFnd = IsURLGrfAtPos( rDocPt, &sURL, &sTargetFrameName );
+ if( pFnd && !sURL.isEmpty() )
+ {
+ bRet = true;
+ // At first run the possibly set ObjectSelect Macro
+ const SvxMacro* pMac = &pFnd->GetMacro().GetMacro( SFX_EVENT_MOUSECLICK_OBJECT );
+ if( pMac )
+ {
+ SwCallMouseEvent aCallEvent;
+ aCallEvent.Set( EVENT_OBJECT_URLITEM, pFnd );
+ GetDoc()->CallEvent( SFX_EVENT_MOUSECLICK_OBJECT, aCallEvent, false );
+ }
+
+ ::LoadURL(*this, sURL, nFilter, sTargetFrameName);
+ }
+ return bRet;
+}
+
+void LoadURL( SwViewShell& rVSh, const OUString& rURL, sal_uInt16 nFilter,
+ const OUString& rTargetFrameName )
+{
+ OSL_ENSURE( !rURL.isEmpty(), "what should be loaded here?" );
+ if( rURL.isEmpty() )
+ return ;
+
+ // The shell could be 0 also!!!!!
+ if ( !rVSh.ISA(SwCrsrShell) )
+ return;
+
+ //A CrsrShell is always a WrtShell
+ SwWrtShell &rSh = (SwWrtShell&)rVSh;
+
+ SwDocShell* pDShell = rSh.GetView().GetDocShell();
+ OSL_ENSURE( pDShell, "No DocShell?!");
+ OUString sTargetFrame(rTargetFrameName);
+ if (sTargetFrame.isEmpty() && pDShell)
+ {
+ using namespace ::com::sun::star;
+ uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
+ pDShell->GetModel(), uno::UNO_QUERY_THROW);
+ uno::Reference<document::XDocumentProperties> xDocProps
+ = xDPS->getDocumentProperties();
+ sTargetFrame = xDocProps->getDefaultTarget();
+ }
+
+ OUString sReferer;
+ if( pDShell && pDShell->GetMedium() )
+ sReferer = pDShell->GetMedium()->GetName();
+ SfxViewFrame* pViewFrm = rSh.GetView().GetViewFrame();
+ SfxFrameItem aView( SID_DOCFRAME, pViewFrm );
+ SfxStringItem aName( SID_FILE_NAME, rURL );
+ SfxStringItem aTargetFrameName( SID_TARGETNAME, sTargetFrame );
+ SfxStringItem aReferer( SID_REFERER, sReferer );
+
+ SfxBoolItem aNewView( SID_OPEN_NEW_VIEW, false );
+ //#39076# Silent can be removed accordingly to SFX.
+ SfxBoolItem aBrowse( SID_BROWSE, true );
+
+ if( nFilter & URLLOAD_NEWVIEW )
+ aTargetFrameName.SetValue( OUString("_blank") );
+
+ const SfxPoolItem* aArr[] = {
+ &aName,
+ &aNewView, /*&aSilent,*/
+ &aReferer,
+ &aView, &aTargetFrameName,
+ &aBrowse,
+ 0L
+ };
+
+ pViewFrm->GetDispatcher()->GetBindings()->Execute( SID_OPENDOC, aArr,
+ SFX_CALLMODE_ASYNCHRON|SFX_CALLMODE_RECORD );
+}
+
+void SwWrtShell::NavigatorPaste( const NaviContentBookmark& rBkmk,
+ const sal_uInt16 nAction )
+{
+ if( EXCHG_IN_ACTION_COPY == nAction )
+ {
+ // Insert
+ OUString sURL = rBkmk.GetURL();
+ // Is this is a jump within the current Doc?
+ const SwDocShell* pDocShell = GetView().GetDocShell();
+ if(pDocShell->HasName())
+ {
+ const OUString rName = pDocShell->GetMedium()->GetURLObject().GetURLNoMark();
+
+ if (sURL.startsWith(rName))
+ {
+ if (sURL.getLength()>rName.getLength())
+ {
+ sURL = sURL.copy(rName.getLength());
+ }
+ else
+ {
+ sURL = OUString();
+ }
+ }
+ }
+ SwFmtINetFmt aFmt( sURL, OUString() );
+ InsertURL( aFmt, rBkmk.GetDescription() );
+ }
+ else
+ {
+ SwSectionData aSection( FILE_LINK_SECTION, GetUniqueSectionName() );
+ OUString aLinkFile( rBkmk.GetURL().getToken(0, '#') );
+ aLinkFile += OUString(sfx2::cTokenSeparator);
+ aLinkFile += OUString(sfx2::cTokenSeparator);
+ aLinkFile += rBkmk.GetURL().getToken(1, '#');
+ aSection.SetLinkFileName( aLinkFile );
+ aSection.SetProtectFlag( true );
+ const SwSection* pIns = InsertSection( aSection );
+ if( EXCHG_IN_ACTION_MOVE == nAction && pIns )
+ {
+ aSection = SwSectionData(*pIns);
+ aSection.SetLinkFileName( OUString() );
+ aSection.SetType( CONTENT_SECTION );
+ aSection.SetProtectFlag( false );
+
+ // the update of content from linked section at time delete
+ // the undostack. Then the change of the section dont create
+ // any undoobject. - BUG 69145
+ sal_Bool bDoesUndo = DoesUndo();
+ SwUndoId nLastUndoId(UNDO_EMPTY);
+ if (GetLastUndoInfo(0, & nLastUndoId))
+ {
+ if (UNDO_INSSECTION != nLastUndoId)
+ {
+ DoUndo(false);
+ }
+ }
+ UpdateSection( GetSectionFmtPos( *pIns->GetFmt() ), aSection );
+ DoUndo( bDoesUndo );
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/wrtsh/wrtsh3.cxx b/sw/source/core/uibase/wrtsh/wrtsh3.cxx
new file mode 100644
index 000000000000..bc35ef16b8e3
--- /dev/null
+++ b/sw/source/core/uibase/wrtsh/wrtsh3.cxx
@@ -0,0 +1,227 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <svx/svxids.hrc>
+#include <sfx2/app.hxx>
+#include <sfx2/childwin.hxx>
+#include <sfx2/bindings.hxx>
+#include <svx/svdmark.hxx>
+#include <svx/svdview.hxx>
+#include <svx/fmglob.hxx>
+#include <svx/svdouno.hxx>
+#include <com/sun/star/form/FormButtonType.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <sfx2/htmlmode.hxx>
+#include "wrtsh.hxx"
+#include "view.hxx"
+#include "IMark.hxx"
+#include "doc.hxx"
+#include "wrtsh.hrc"
+
+#include <unomid.h>
+
+using namespace ::com::sun::star;
+
+extern bool bNoInterrupt; // in mainwn.cxx
+
+sal_Bool SwWrtShell::MoveBookMark( BookMarkMove eFuncId, const ::sw::mark::IMark* const pMark)
+{
+ addCurrentPosition();
+ (this->*fnKillSel)( 0, sal_False );
+
+ sal_Bool bRet = sal_True;
+ switch(eFuncId)
+ {
+ case BOOKMARK_INDEX:bRet = SwCrsrShell::GotoMark( pMark );break;
+ case BOOKMARK_NEXT: bRet = SwCrsrShell::GoNextBookmark();break;
+ case BOOKMARK_PREV: bRet = SwCrsrShell::GoPrevBookmark();break;
+ default:;//prevent warning
+ }
+
+ if( bRet && IsSelFrmMode() )
+ {
+ UnSelectFrm();
+ LeaveSelFrmMode();
+ }
+ if( IsSelection() )
+ {
+ fnKillSel = &SwWrtShell::ResetSelect;
+ fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
+ }
+ return bRet;
+}
+
+sal_Bool SwWrtShell::GotoField( const SwFmtFld& rFld )
+{
+ (this->*fnKillSel)( 0, sal_False );
+
+ sal_Bool bRet = SwCrsrShell::GotoFld( rFld );
+ if( bRet && IsSelFrmMode() )
+ {
+ UnSelectFrm();
+ LeaveSelFrmMode();
+ }
+
+ if( IsSelection() )
+ {
+ fnKillSel = &SwWrtShell::ResetSelect;
+ fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
+ }
+
+ return bRet;
+}
+
+bool SwWrtShell::GotoFieldmark(::sw::mark::IFieldmark const * const pMark)
+{
+ (this->*fnKillSel)( 0, sal_False );
+ bool bRet = SwCrsrShell::GotoFieldmark(pMark);
+ if( bRet && IsSelFrmMode() )
+ {
+ UnSelectFrm();
+ LeaveSelFrmMode();
+ }
+ if( IsSelection() )
+ {
+ fnKillSel = &SwWrtShell::ResetSelect;
+ fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
+ }
+ return bRet;
+}
+
+// Invalidate FontWork-Slots
+
+void SwWrtShell::DrawSelChanged( )
+{
+ static sal_uInt16 const aInval[] =
+ {
+ SID_ATTR_FILL_STYLE, SID_ATTR_FILL_COLOR, SID_ATTR_LINE_STYLE,
+ SID_ATTR_LINE_WIDTH, SID_ATTR_LINE_COLOR,
+ /*AF: these may be needed for the sidebar.
+ SID_SVX_AREA_TRANSPARENCY, SID_SVX_AREA_TRANSP_GRADIENT,
+ SID_SVX_AREA_TRANS_TYPE,
+ */
+ 0
+ };
+
+ GetView().GetViewFrame()->GetBindings().Invalidate(aInval);
+
+ bool bOldVal = bNoInterrupt;
+ bNoInterrupt = true; // Trick to run AttrChangedNotify by timer.
+ GetView().AttrChangedNotify(this);
+ bNoInterrupt = bOldVal;
+}
+
+sal_Bool SwWrtShell::GotoMark( const OUString& rName )
+{
+ IDocumentMarkAccess::const_iterator_t ppMark = getIDocumentMarkAccess()->findMark( rName );
+ if(ppMark == getIDocumentMarkAccess()->getAllMarksEnd()) return false;
+ return MoveBookMark( BOOKMARK_INDEX, ppMark->get() );
+}
+
+sal_Bool SwWrtShell::GotoMark( const ::sw::mark::IMark* const pMark )
+{
+ return MoveBookMark( BOOKMARK_INDEX, pMark );
+}
+
+sal_Bool SwWrtShell::GoNextBookmark()
+{
+ return MoveBookMark( BOOKMARK_NEXT );
+}
+
+sal_Bool SwWrtShell::GoPrevBookmark()
+{
+ return MoveBookMark( BOOKMARK_PREV );
+}
+
+void SwWrtShell::ExecMacro( const SvxMacro& rMacro, OUString* pRet, SbxArray* pArgs )
+{
+ // OD 11.02.2003 #100556# - execute macro, if it is allowed.
+ if ( IsMacroExecAllowed() )
+ {
+ GetDoc()->ExecMacro( rMacro, pRet, pArgs );
+ }
+}
+
+sal_uInt16 SwWrtShell::CallEvent( sal_uInt16 nEvent, const SwCallMouseEvent& rCallEvent,
+ bool bChkPtr, SbxArray* pArgs,
+ const Link* pCallBack )
+{
+ return GetDoc()->CallEvent( nEvent, rCallEvent, bChkPtr, pArgs, pCallBack );
+}
+
+ // If a util::URL-Button is selected, return its util::URL
+ // otherwise an emtpy string.
+bool SwWrtShell::GetURLFromButton( OUString& rURL, OUString& rDescr ) const
+{
+ bool bRet = false;
+ const SdrView *pDView = GetDrawView();
+ if( pDView )
+ {
+ // A fly is precisely achievable if it is selected.
+ const SdrMarkList &rMarkList = pDView->GetMarkedObjectList();
+
+ if (rMarkList.GetMark(0))
+ {
+ SdrUnoObj* pUnoCtrl = PTR_CAST(SdrUnoObj, rMarkList.GetMark(0)->GetMarkedSdrObj());
+ if (pUnoCtrl && FmFormInventor == pUnoCtrl->GetObjInventor())
+ {
+ uno::Reference< awt::XControlModel > xControlModel = pUnoCtrl->GetUnoControlModel();
+
+ OSL_ENSURE( xControlModel.is(), "UNO-Control without Model" );
+ if( !xControlModel.is() )
+ return bRet;
+
+ uno::Reference< beans::XPropertySet > xPropSet(xControlModel, uno::UNO_QUERY);
+
+ uno::Any aTmp;
+
+ form::FormButtonType eButtonType = form::FormButtonType_URL;
+ uno::Reference< beans::XPropertySetInfo > xInfo = xPropSet->getPropertySetInfo();
+ if(xInfo->hasPropertyByName( "ButtonType" ))
+ {
+ aTmp = xPropSet->getPropertyValue( "ButtonType" );
+ form::FormButtonType eTmpButtonType;
+ aTmp >>= eTmpButtonType;
+ if( eButtonType == eTmpButtonType)
+ {
+ // Label
+ aTmp = xPropSet->getPropertyValue( "Label" );
+ OUString uTmp;
+ if( (aTmp >>= uTmp) && !uTmp.isEmpty())
+ {
+ rDescr = uTmp;
+ }
+
+ // util::URL
+ aTmp = xPropSet->getPropertyValue( "TargetURL" );
+ if( (aTmp >>= uTmp) && !uTmp.isEmpty())
+ {
+ rURL = uTmp;
+ }
+ bRet = true;
+ }
+ }
+ }
+ }
+ }
+
+ return bRet;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/wrtsh/wrtsh4.cxx b/sw/source/core/uibase/wrtsh/wrtsh4.cxx
new file mode 100644
index 000000000000..6966e45c4fda
--- /dev/null
+++ b/sw/source/core/uibase/wrtsh/wrtsh4.cxx
@@ -0,0 +1,238 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <wrtsh.hxx>
+#include <crsskip.hxx>
+
+// Private methods, which move the cursor over search.
+// The removal of the selection must be made on the level above.
+
+// The beginning of a word is the follow of a
+// non-delimiter to delimiter. Furthermore, the follow of
+// non-sentence separators on sentence separator.
+// The begin of paragraph is also the word beginning.
+
+bool SwWrtShell::_SttWrd()
+{
+ if ( IsSttPara() )
+ return true;
+ // Create temporary cursor without selection.
+ Push();
+ ClearMark();
+ if( !GoStartWord() )
+ // not found --> go to the beginning of the paragraph.
+ SwCrsrShell::MovePara( fnParaCurr, fnParaStart );
+ ClearMark();
+ // If Mark was previously set, summarize.
+ Combine();
+ return true;
+}
+
+// The end of a word is the follow of separator to nonseparator.
+// The end of a word is also the sequence of wordseparators to
+// punctuation marks.
+// The end of a paragraph is also the end of a word.
+
+bool SwWrtShell::_EndWrd()
+{
+ if ( IsEndWrd() )
+ return true;
+ // Create temporary cursor without selection.
+ Push();
+ ClearMark();
+ if( !GoEndWord() )
+ // not found --> go to the end of the paragraph.
+ SwCrsrShell::MovePara(fnParaCurr, fnParaEnd);
+ ClearMark();
+ // If Mark was previously set, summarize.
+ Combine();
+ return true;
+}
+
+sal_Bool SwWrtShell::_NxtWrd()
+{
+ sal_Bool bRet = sal_False;
+ while( IsEndPara() ) // If already at the end, then the next???
+ {
+ if(!SwCrsrShell::Right(1,CRSR_SKIP_CHARS)) // Document - end ??
+ {
+ Pop( sal_False );
+ return bRet;
+ }
+ bRet = IsStartWord();
+ }
+ Push();
+ ClearMark();
+ while( !bRet )
+ {
+ if( !GoNextWord() )
+ {
+ if( (!IsEndPara() && !SwCrsrShell::MovePara( fnParaCurr, fnParaEnd ) )
+ || !SwCrsrShell::Right(1,CRSR_SKIP_CHARS) )
+ break;
+ bRet = IsStartWord();
+ }
+ else
+ bRet = sal_True;
+ }
+ ClearMark();
+ Combine();
+ return bRet;
+}
+
+sal_Bool SwWrtShell::_PrvWrd()
+{
+ sal_Bool bRet = sal_False;
+ while( IsSttPara() )
+ { // if already at the beginning, then the next???
+ if(!SwCrsrShell::Left(1,CRSR_SKIP_CHARS))
+ { // Document - beginning ??
+ Pop( sal_False );
+ return bRet;
+ }
+ bRet = IsStartWord();
+ }
+ Push();
+ ClearMark();
+ while( !bRet )
+ {
+ if( !GoPrevWord() )
+ {
+ if( (!IsSttPara() && !SwCrsrShell::MovePara( fnParaCurr, fnParaStart ) )
+ || !SwCrsrShell::Left(1,CRSR_SKIP_CHARS) )
+ break;
+ bRet = IsStartWord();
+ }
+ else
+ bRet = sal_True;
+ }
+ ClearMark();
+ Combine();
+ return bRet;
+}
+
+// #i92468#
+// method code of <SwWrtShell::_NxtWrd()> before fix for issue i72162
+sal_Bool SwWrtShell::_NxtWrdForDelete()
+{
+ if ( IsEndPara() )
+ {
+ if ( !SwCrsrShell::Right(1,CRSR_SKIP_CHARS) )
+ {
+ Pop( sal_False );
+ return sal_False;
+ }
+ return sal_True;
+ }
+ Push();
+ ClearMark();
+ if ( !GoNextWord() )
+ {
+ SwCrsrShell::MovePara( fnParaCurr, fnParaEnd );
+ }
+ ClearMark();
+ Combine();
+ return sal_True;
+}
+
+// method code of <SwWrtShell::_PrvWrd()> before fix for issue i72162
+sal_Bool SwWrtShell::_PrvWrdForDelete()
+{
+ if ( IsSttPara() )
+ {
+ if ( !SwCrsrShell::Left(1,CRSR_SKIP_CHARS) )
+ {
+ Pop( sal_False );
+ return sal_False;
+ }
+ return sal_True;
+ }
+ Push();
+ ClearMark();
+ if( !GoPrevWord() )
+ {
+ SwCrsrShell::MovePara( fnParaCurr, fnParaStart );
+ }
+ ClearMark();
+ Combine();
+ return sal_True;
+}
+
+sal_Bool SwWrtShell::_FwdSentence()
+{
+ Push();
+ ClearMark();
+ if(!SwCrsrShell::Right(1,CRSR_SKIP_CHARS))
+ {
+ Pop(sal_False);
+ return 0;
+ }
+ if( !GoNextSentence() && !IsEndPara() )
+ SwCrsrShell::MovePara(fnParaCurr, fnParaEnd);
+
+ ClearMark();
+ Combine();
+ return 1;
+}
+
+sal_Bool SwWrtShell::_BwdSentence()
+{
+ Push();
+ ClearMark();
+ if(!SwCrsrShell::Left(1,CRSR_SKIP_CHARS))
+ {
+ Pop(sal_False);
+ return 0;
+ }
+ if( !GoStartSentence() && !IsSttPara() )
+ // not found --> go to the beginning of the paragraph
+ SwCrsrShell::MovePara( fnParaCurr, fnParaStart );
+ ClearMark();
+ Combine();
+ return 1;
+}
+
+sal_Bool SwWrtShell::_FwdPara()
+{
+ Push();
+ ClearMark();
+ sal_Bool bRet = SwCrsrShell::MovePara(fnParaNext, fnParaStart);
+
+ ClearMark();
+ Combine();
+ return bRet;
+}
+
+sal_Bool SwWrtShell::_BwdPara()
+{
+ Push();
+ ClearMark();
+
+ sal_Bool bRet = SwCrsrShell::MovePara(fnParaPrev, fnParaStart);
+ if ( !bRet && !IsSttOfPara() )
+ {
+ SttPara();
+ }
+
+ ClearMark();
+ Combine();
+ return bRet;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/wrtsh/wrtundo.cxx b/sw/source/core/uibase/wrtsh/wrtundo.cxx
new file mode 100644
index 000000000000..6290b5e7f5ce
--- /dev/null
+++ b/sw/source/core/uibase/wrtsh/wrtundo.cxx
@@ -0,0 +1,154 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <tools/resid.hxx>
+#include <sfx2/app.hxx>
+#include <svl/slstitm.hxx>
+#include <wrtsh.hxx>
+#include <swundo.hxx>
+#include <IDocumentUndoRedo.hxx>
+#include <swdtflvr.hxx>
+#include <svtools/svtresid.hxx>
+#include <svtools/svtools.hrc>
+#include <wrtsh.hrc>
+#include <sfx2/sfx.hrc>
+
+// Undo ends all modes. If a selection is emerged by the Undo,
+// this must be considered for further action.
+
+void SwWrtShell::Do( DoType eDoType, sal_uInt16 nCnt )
+{
+ // #105332# save current state of DoesUndo()
+ sal_Bool bSaveDoesUndo = DoesUndo();
+
+ StartAllAction();
+ switch (eDoType)
+ {
+ case UNDO:
+ DoUndo(sal_False); // #i21739#
+ // Reset modes
+ EnterStdMode();
+ SwEditShell::Undo(nCnt);
+ break;
+ case REDO:
+ DoUndo(sal_False); // #i21739#
+ // Reset modes
+ EnterStdMode();
+ SwEditShell::Redo( nCnt );
+ break;
+ case REPEAT:
+ // #i21739# do not touch undo flag here !!!
+ SwEditShell::Repeat( nCnt );
+ break;
+ }
+ EndAllAction();
+ // #105332# restore undo state
+ DoUndo(bSaveDoesUndo);
+
+ bool bCreateXSelection = false;
+ const bool bFrmSelected = IsFrmSelected() || IsObjSelected();
+ if ( IsSelection() )
+ {
+ if ( bFrmSelected )
+ UnSelectFrm();
+
+ // Set the function pointer for canceling the selection at the
+ // cursor position.
+ fnKillSel = &SwWrtShell::ResetSelect;
+ fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
+ bCreateXSelection = true;
+ }
+ else if ( bFrmSelected )
+ {
+ EnterSelFrmMode();
+ bCreateXSelection = true;
+ }
+ else if( (CNT_GRF | CNT_OLE ) & GetCntType() )
+ {
+ SelectObj( GetCharRect().Pos() );
+ EnterSelFrmMode();
+ bCreateXSelection = true;
+ }
+
+ if( bCreateXSelection )
+ SwTransferable::CreateSelection( *this );
+
+ // Bug 32918: After deleting of the numbering the object panel remains.
+ // Why is not here always a CallChgLink called?
+ CallChgLnk();
+}
+
+OUString SwWrtShell::GetDoString( DoType eDoType ) const
+{
+ OUString aUndoStr;
+ sal_uInt16 nResStr = STR_UNDO;
+ switch( eDoType )
+ {
+ case UNDO:
+ nResStr = STR_UNDO;
+ GetLastUndoInfo(& aUndoStr, 0);
+ break;
+ case REDO:
+ nResStr = STR_REDO;
+ GetFirstRedoInfo(& aUndoStr);
+ break;
+ default:;//prevent warning
+ }
+
+ return SvtResId( nResStr ).toString() + aUndoStr;
+}
+
+sal_uInt16 SwWrtShell::GetDoStrings( DoType eDoType, SfxStringListItem& rStrs ) const
+{
+ SwUndoComments_t comments;
+ switch( eDoType )
+ {
+ case UNDO:
+ comments = GetIDocumentUndoRedo().GetUndoComments();
+ break;
+ case REDO:
+ comments = GetIDocumentUndoRedo().GetRedoComments();
+ break;
+ default:;//prevent warning
+ }
+
+ OUString buf;
+ for (size_t i = 0; i < comments.size(); ++i)
+ {
+ OSL_ENSURE(!comments[i].isEmpty(), "no Undo/Redo Text set");
+ buf += comments[i] + "\n";
+ }
+ rStrs.SetString(buf);
+ return static_cast<sal_uInt16>(comments.size());
+}
+
+OUString SwWrtShell::GetRepeatString() const
+{
+ OUString str;
+ GetRepeatInfo(& str);
+
+ if (str.isEmpty())
+ {
+ return str;
+ }
+
+ return SvtResId(STR_REPEAT).toString() + str;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index 973576cdc7e2..72ed52243c80 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -64,7 +64,7 @@
#include <anchoredobject.hxx>
#include <wrtsh.hxx>
-#include "../../ui/inc/view.hxx"
+#include "../uibase/inc/view.hxx"
#include <PostItMgr.hxx>
#include <vcl/dibtools.hxx>
#include <vcl/sysdata.hxx>