From 8362bf63dea22bbf6736609b0f49c152f975eb63 Mon Sep 17 00:00:00 2001 From: tpearson Date: Wed, 20 Jan 2010 01:29:50 +0000 Subject: Added old abandoned KDE3 version of koffice git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1077364 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kpresenter/AUTHORS | 9 + kpresenter/CHANGES | 282 + kpresenter/KPrAboutData.h | 49 + kpresenter/KPrAutoFormObjectIface.cpp | 54 + kpresenter/KPrAutoFormObjectIface.h | 48 + kpresenter/KPrAutoformObject.cpp | 378 ++ kpresenter/KPrAutoformObject.h | 82 + kpresenter/KPrBackDia.cpp | 420 ++ kpresenter/KPrBackDia.h | 134 + kpresenter/KPrBackground.cpp | 653 ++ kpresenter/KPrBackground.h | 188 + kpresenter/KPrBezierCurveObject.cpp | 302 + kpresenter/KPrBezierCurveObject.h | 90 + kpresenter/KPrBgSpellCheck.cpp | 60 + kpresenter/KPrBgSpellCheck.h | 42 + kpresenter/KPrBrush.cpp | 247 + kpresenter/KPrBrush.h | 50 + kpresenter/KPrBrushProperty.cpp | 498 ++ kpresenter/KPrBrushProperty.h | 88 + kpresenter/KPrCanvas.cpp | 5704 +++++++++++++++++ kpresenter/KPrCanvas.h | 938 +++ kpresenter/KPrClosedLineObject.cpp | 339 + kpresenter/KPrClosedLineObject.h | 84 + kpresenter/KPrCommand.cpp | 2827 +++++++++ kpresenter/KPrCommand.h | 1094 ++++ kpresenter/KPrConfig.cpp | 1128 ++++ kpresenter/KPrConfig.h | 228 + kpresenter/KPrCubicBezierCurveObjectIface.cpp | 65 + kpresenter/KPrCubicBezierCurveObjectIface.h | 50 + kpresenter/KPrCustomSlideShowDia.cpp | 461 ++ kpresenter/KPrCustomSlideShowDia.h | 117 + kpresenter/KPrDocument.cpp | 4857 +++++++++++++++ kpresenter/KPrDocument.h | 714 +++ kpresenter/KPrDocumentIface.cpp | 571 ++ kpresenter/KPrDocumentIface.h | 188 + kpresenter/KPrDuplicateObjDia.cpp | 125 + kpresenter/KPrDuplicateObjDia.h | 54 + kpresenter/KPrEffectDia.cpp | 528 ++ kpresenter/KPrEffectDia.h | 94 + kpresenter/KPrEffectHandler.cpp | 1055 ++++ kpresenter/KPrEffectHandler.h | 345 ++ kpresenter/KPrEllipseObject.cpp | 128 + kpresenter/KPrEllipseObject.h | 64 + kpresenter/KPrFactory.cpp | 84 + kpresenter/KPrFactory.h | 48 + kpresenter/KPrFactoryInit.cpp | 24 + kpresenter/KPrFindReplace.cpp | 64 + kpresenter/KPrFindReplace.h | 63 + kpresenter/KPrFreehandObject.cpp | 106 + kpresenter/KPrFreehandObject.h | 54 + kpresenter/KPrFreehandObjectIface.cpp | 67 + kpresenter/KPrFreehandObjectIface.h | 50 + kpresenter/KPrGeneralProperty.cpp | 254 + kpresenter/KPrGeneralProperty.h | 82 + kpresenter/KPrGotoPage.cpp | 91 + kpresenter/KPrGotoPage.h | 53 + kpresenter/KPrGradient.cpp | 136 + kpresenter/KPrGradient.h | 97 + kpresenter/KPrGradientCollection.cpp | 73 + kpresenter/KPrGradientCollection.h | 63 + kpresenter/KPrGroupObject.cpp | 642 ++ kpresenter/KPrGroupObject.h | 116 + kpresenter/KPrImageEffectDia.cpp | 412 ++ kpresenter/KPrImageEffectDia.h | 83 + kpresenter/KPrImportStyleDia.cpp | 157 + kpresenter/KPrImportStyleDia.h | 47 + kpresenter/KPrLineObject.cpp | 499 ++ kpresenter/KPrLineObject.h | 84 + kpresenter/KPrLineObjectIface.cpp | 66 + kpresenter/KPrLineObjectIface.h | 49 + kpresenter/KPrLoadingInfo.h | 87 + kpresenter/KPrMSPresentationSetup.cpp | 619 ++ kpresenter/KPrMSPresentationSetup.h | 159 + kpresenter/KPrMarginWidget.cpp | 129 + kpresenter/KPrMarginWidget.h | 57 + kpresenter/KPrMoveHelpLineDia.cpp | 154 + kpresenter/KPrMoveHelpLineDia.h | 95 + kpresenter/KPrNoteBar.cpp | 197 + kpresenter/KPrNoteBar.h | 65 + kpresenter/KPrObject.cpp | 2172 +++++++ kpresenter/KPrObject.h | 557 ++ kpresenter/KPrObject2DIface.cpp | 124 + kpresenter/KPrObject2DIface.h | 59 + kpresenter/KPrObjectIface.cpp | 288 + kpresenter/KPrObjectIface.h | 101 + kpresenter/KPrObjectProperties.cpp | 310 + kpresenter/KPrObjectProperties.h | 98 + kpresenter/KPrPBPreview.cpp | 125 + kpresenter/KPrPBPreview.h | 82 + kpresenter/KPrPage.cpp | 2614 ++++++++ kpresenter/KPrPage.h | 607 ++ kpresenter/KPrPageEffects.cpp | 1590 +++++ kpresenter/KPrPageEffects.h | 121 + kpresenter/KPrPageIface.cpp | 699 +++ kpresenter/KPrPageIface.h | 137 + kpresenter/KPrPartObject.cpp | 203 + kpresenter/KPrPartObject.h | 69 + kpresenter/KPrPenStyleWidget.cpp | 279 + kpresenter/KPrPenStyleWidget.h | 67 + kpresenter/KPrPgConfDia.cpp | 324 + kpresenter/KPrPgConfDia.h | 90 + kpresenter/KPrPicturePreview.cpp | 307 + kpresenter/KPrPicturePreview.h | 74 + kpresenter/KPrPictureProperty.cpp | 132 + kpresenter/KPrPictureProperty.h | 53 + kpresenter/KPrPieObject.cpp | 607 ++ kpresenter/KPrPieObject.h | 109 + kpresenter/KPrPieObjectIface.cpp | 83 + kpresenter/KPrPieObjectIface.h | 52 + kpresenter/KPrPiePreview.cpp | 66 + kpresenter/KPrPiePreview.h | 58 + kpresenter/KPrPieProperty.cpp | 141 + kpresenter/KPrPieProperty.h | 55 + kpresenter/KPrPixmapObject.cpp | 958 +++ kpresenter/KPrPixmapObject.h | 153 + kpresenter/KPrPixmapObjectIface.cpp | 101 + kpresenter/KPrPixmapObjectIface.h | 56 + kpresenter/KPrPointObject.cpp | 276 + kpresenter/KPrPointObject.h | 74 + kpresenter/KPrPolyLineObjectIface.cpp | 45 + kpresenter/KPrPolyLineObjectIface.h | 43 + kpresenter/KPrPolygonObject.cpp | 377 ++ kpresenter/KPrPolygonObject.h | 88 + kpresenter/KPrPolygonObjectIface.cpp | 62 + kpresenter/KPrPolygonObjectIface.h | 49 + kpresenter/KPrPolygonPreview.cpp | 120 + kpresenter/KPrPolygonPreview.h | 61 + kpresenter/KPrPolygonProperty.cpp | 134 + kpresenter/KPrPolygonProperty.h | 55 + kpresenter/KPrPolylineObject.cpp | 91 + kpresenter/KPrPolylineObject.h | 56 + kpresenter/KPrPresDurationDia.cpp | 81 + kpresenter/KPrPresDurationDia.h | 59 + kpresenter/KPrPrinterDlg.cpp | 114 + kpresenter/KPrPrinterDlg.h | 56 + kpresenter/KPrPropertyEditor.cpp | 499 ++ kpresenter/KPrPropertyEditor.h | 84 + kpresenter/KPrQuadricBezierCurveObjectIface.cpp | 66 + kpresenter/KPrQuadricBezierCurveObjectIface.h | 50 + kpresenter/KPrRectObject.cpp | 219 + kpresenter/KPrRectObject.h | 75 + kpresenter/KPrRectObjectIface.cpp | 52 + kpresenter/KPrRectObjectIface.h | 44 + kpresenter/KPrRectPreview.cpp | 50 + kpresenter/KPrRectPreview.h | 51 + kpresenter/KPrRectProperty.cpp | 147 + kpresenter/KPrRectProperty.h | 60 + kpresenter/KPrRotationDialogImpl.cpp | 174 + kpresenter/KPrRotationDialogImpl.h | 136 + kpresenter/KPrSVGPathParser.cpp | 179 + kpresenter/KPrSVGPathParser.h | 92 + kpresenter/KPrShadowDialogImpl.cpp | 91 + kpresenter/KPrShadowDialogImpl.h | 41 + kpresenter/KPrSideBar.cpp | 1111 ++++ kpresenter/KPrSideBar.h | 182 + kpresenter/KPrSlideTransitionDia.cpp | 413 ++ kpresenter/KPrSlideTransitionDia.h | 79 + kpresenter/KPrSoundPlayer.cpp | 111 + kpresenter/KPrSoundPlayer.h | 63 + kpresenter/KPrStyleManager.cpp | 61 + kpresenter/KPrStyleManager.h | 49 + kpresenter/KPrTextDocument.cpp | 103 + kpresenter/KPrTextDocument.h | 55 + kpresenter/KPrTextObject.cpp | 2586 ++++++++ kpresenter/KPrTextObject.h | 312 + kpresenter/KPrTextObjectIface.cpp | 366 ++ kpresenter/KPrTextObjectIface.h | 110 + kpresenter/KPrTextPreview.cpp | 101 + kpresenter/KPrTextPreview.h | 30 + kpresenter/KPrTextProperty.cpp | 139 + kpresenter/KPrTextProperty.h | 67 + kpresenter/KPrTextViewIface.cpp | 122 + kpresenter/KPrTextViewIface.h | 56 + kpresenter/KPrTransEffectDia.cpp | 466 ++ kpresenter/KPrTransEffectDia.h | 138 + kpresenter/KPrUtils.cpp | 448 ++ kpresenter/KPrUtils.h | 62 + kpresenter/KPrVariableCollection.cpp | 200 + kpresenter/KPrVariableCollection.h | 71 + kpresenter/KPrView.cpp | 6480 ++++++++++++++++++++ kpresenter/KPrView.h | 1228 ++++ kpresenter/KPrViewIface.cpp | 719 +++ kpresenter/KPrViewIface.h | 238 + kpresenter/KPrWebPresentation.cpp | 1305 ++++ kpresenter/KPrWebPresentation.h | 227 + kpresenter/KoPointArray.cpp | 320 + kpresenter/KoPointArray.h | 65 + kpresenter/Makefile.am | 104 + kpresenter/TODO | 117 + kpresenter/autoformEdit/AFChoose.cpp | 202 + kpresenter/autoformEdit/AFChoose.h | 89 + kpresenter/autoformEdit/ATFInterpreter.cpp | 453 ++ kpresenter/autoformEdit/ATFInterpreter.h | 175 + kpresenter/autoformEdit/Makefile.am | 12 + kpresenter/autoforms/.autoforms | 2 + kpresenter/autoforms/Arrows/.directory | 41 + kpresenter/autoforms/Arrows/ArrowDown.atf | 255 + kpresenter/autoforms/Arrows/ArrowDown.desktop | 49 + kpresenter/autoforms/Arrows/ArrowDown.png | Bin 0 -> 309 bytes kpresenter/autoforms/Arrows/ArrowLeft.atf | 255 + kpresenter/autoforms/Arrows/ArrowLeft.desktop | 49 + kpresenter/autoforms/Arrows/ArrowLeft.png | Bin 0 -> 311 bytes kpresenter/autoforms/Arrows/ArrowLeftDown.atf | 255 + kpresenter/autoforms/Arrows/ArrowLeftDown.desktop | 49 + kpresenter/autoforms/Arrows/ArrowLeftDown.png | Bin 0 -> 337 bytes kpresenter/autoforms/Arrows/ArrowLeftUp.atf | 255 + kpresenter/autoforms/Arrows/ArrowLeftUp.desktop | 49 + kpresenter/autoforms/Arrows/ArrowLeftUp.png | Bin 0 -> 340 bytes kpresenter/autoforms/Arrows/ArrowRight.atf | 255 + kpresenter/autoforms/Arrows/ArrowRight.desktop | 49 + kpresenter/autoforms/Arrows/ArrowRight.png | Bin 0 -> 320 bytes kpresenter/autoforms/Arrows/ArrowRightDown.atf | 255 + kpresenter/autoforms/Arrows/ArrowRightDown.desktop | 49 + kpresenter/autoforms/Arrows/ArrowRightDown.png | Bin 0 -> 338 bytes kpresenter/autoforms/Arrows/ArrowRightUp.atf | 255 + kpresenter/autoforms/Arrows/ArrowRightUp.desktop | 49 + kpresenter/autoforms/Arrows/ArrowRightUp.png | Bin 0 -> 333 bytes kpresenter/autoforms/Arrows/ArrowUp.atf | 255 + kpresenter/autoforms/Arrows/ArrowUp.desktop | 49 + kpresenter/autoforms/Arrows/ArrowUp.png | Bin 0 -> 309 bytes kpresenter/autoforms/Arrows/Makefile.am | 18 + kpresenter/autoforms/Connections/.directory | 42 + kpresenter/autoforms/Connections/Connection1.atf | 131 + .../autoforms/Connections/Connection1.desktop | 71 + kpresenter/autoforms/Connections/Connection1.png | Bin 0 -> 259 bytes kpresenter/autoforms/Connections/Connection10.atf | 131 + .../autoforms/Connections/Connection10.desktop | 71 + kpresenter/autoforms/Connections/Connection10.png | Bin 0 -> 246 bytes kpresenter/autoforms/Connections/Connection11.atf | 131 + .../autoforms/Connections/Connection11.desktop | 71 + kpresenter/autoforms/Connections/Connection11.png | Bin 0 -> 246 bytes kpresenter/autoforms/Connections/Connection12.atf | 131 + .../autoforms/Connections/Connection12.desktop | 71 + kpresenter/autoforms/Connections/Connection12.png | Bin 0 -> 245 bytes kpresenter/autoforms/Connections/Connection2.atf | 131 + .../autoforms/Connections/Connection2.desktop | 71 + kpresenter/autoforms/Connections/Connection2.png | Bin 0 -> 262 bytes kpresenter/autoforms/Connections/Connection3.atf | 131 + .../autoforms/Connections/Connection3.desktop | 71 + kpresenter/autoforms/Connections/Connection3.png | Bin 0 -> 262 bytes kpresenter/autoforms/Connections/Connection4.atf | 131 + .../autoforms/Connections/Connection4.desktop | 71 + kpresenter/autoforms/Connections/Connection4.png | Bin 0 -> 264 bytes kpresenter/autoforms/Connections/Connection5.atf | 224 + .../autoforms/Connections/Connection5.desktop | 71 + kpresenter/autoforms/Connections/Connection5.png | Bin 0 -> 254 bytes kpresenter/autoforms/Connections/Connection6.atf | 224 + .../autoforms/Connections/Connection6.desktop | 71 + kpresenter/autoforms/Connections/Connection6.png | Bin 0 -> 251 bytes kpresenter/autoforms/Connections/Connection7.atf | 224 + .../autoforms/Connections/Connection7.desktop | 71 + kpresenter/autoforms/Connections/Connection7.png | Bin 0 -> 250 bytes kpresenter/autoforms/Connections/Connection8.atf | 224 + .../autoforms/Connections/Connection8.desktop | 71 + kpresenter/autoforms/Connections/Connection8.png | Bin 0 -> 250 bytes kpresenter/autoforms/Connections/Connection9.atf | 131 + .../autoforms/Connections/Connection9.desktop | 71 + kpresenter/autoforms/Connections/Connection9.png | Bin 0 -> 244 bytes kpresenter/autoforms/Connections/Makefile.am | 24 + kpresenter/autoforms/Makefile.am | 6 + kpresenter/brushpropertyui.ui | 86 + kpresenter/configure.in.in | 1 + kpresenter/dtd/Makefile.am | 4 + kpresenter/dtd/kpresenter.dtd | 777 +++ kpresenter/generalpropertyui.ui | 193 + kpresenter/global.h | 299 + kpresenter/gradientpropertyui.ui | 178 + kpresenter/imageEffectBase.ui | 1480 +++++ kpresenter/insertpagedia.ui | 185 + kpresenter/kprconverter.pl | 174 + kpresenter/kpresenter.desktop | 85 + kpresenter/kpresenter.rc | 682 ++ kpresenter/kpresenter_readonly.rc | 82 + kpresenter/kpresenterpart.desktop | 83 + kpresenter/main.cpp | 46 + kpresenter/marginui.ui | 167 + kpresenter/penstyle.ui | 199 + kpresenter/pics/Makefile.am | 6 + kpresenter/pics/hi16-app-kpresenter.png | Bin 0 -> 989 bytes kpresenter/pics/hi22-app-kpresenter.png | Bin 0 -> 1258 bytes kpresenter/pics/hi32-app-kpresenter.png | Bin 0 -> 1809 bytes kpresenter/pics/hi48-app-kpresenter.png | Bin 0 -> 2657 bytes kpresenter/pics/rotate/Makefile.am | 4 + kpresenter/pics/rotate/bl.png | Bin 0 -> 576 bytes kpresenter/pics/rotate/bldn.png | Bin 0 -> 557 bytes kpresenter/pics/rotate/bm.png | Bin 0 -> 538 bytes kpresenter/pics/rotate/bmdn.png | Bin 0 -> 509 bytes kpresenter/pics/rotate/br.png | Bin 0 -> 602 bytes kpresenter/pics/rotate/brdn.png | Bin 0 -> 562 bytes kpresenter/pics/rotate/ml.png | Bin 0 -> 520 bytes kpresenter/pics/rotate/mldn.png | Bin 0 -> 505 bytes kpresenter/pics/rotate/mr.png | Bin 0 -> 525 bytes kpresenter/pics/rotate/mrdn.png | Bin 0 -> 502 bytes kpresenter/pics/rotate/tl.png | Bin 0 -> 553 bytes kpresenter/pics/rotate/tldn.png | Bin 0 -> 534 bytes kpresenter/pics/rotate/tm.png | Bin 0 -> 525 bytes kpresenter/pics/rotate/tmdn.png | Bin 0 -> 497 bytes kpresenter/pics/rotate/tr.png | Bin 0 -> 575 bytes kpresenter/pics/rotate/trdn.png | Bin 0 -> 554 bytes kpresenter/pics/webslideshow-sidebar.png | Bin 0 -> 11299 bytes kpresenter/picturepropertyui.ui | 180 + kpresenter/piepropertyui.ui | 146 + kpresenter/polygonpropertyui.ui | 151 + kpresenter/presstep.h | 52 + kpresenter/rectpropertyui.ui | 181 + kpresenter/rotationpropertyui.ui | 166 + kpresenter/scripts/automate_presentation.sh | 25 + kpresenter/scripts/mkstandalone.sh | 91 + kpresenter/shadowdialog.ui | 499 ++ kpresenter/slideshow/Makefile.am | 5 + kpresenter/slideshow/first.bmp | Bin 0 -> 3126 bytes kpresenter/slideshow/first.jpeg | Bin 0 -> 1110 bytes kpresenter/slideshow/first.png | Bin 0 -> 2452 bytes kpresenter/slideshow/home.bmp | Bin 0 -> 4194 bytes kpresenter/slideshow/home.jpeg | Bin 0 -> 1402 bytes kpresenter/slideshow/home.png | Bin 0 -> 951 bytes kpresenter/slideshow/last.bmp | Bin 0 -> 3126 bytes kpresenter/slideshow/last.jpeg | Bin 0 -> 1130 bytes kpresenter/slideshow/last.png | Bin 0 -> 2483 bytes kpresenter/slideshow/next.bmp | Bin 0 -> 3126 bytes kpresenter/slideshow/next.jpeg | Bin 0 -> 1120 bytes kpresenter/slideshow/next.png | Bin 0 -> 2478 bytes kpresenter/slideshow/prev.bmp | Bin 0 -> 3126 bytes kpresenter/slideshow/prev.jpeg | Bin 0 -> 1116 bytes kpresenter/slideshow/prev.png | Bin 0 -> 2519 bytes kpresenter/slidetransitionwidget.ui | 308 + kpresenter/templates/A4/.directory | 7 + kpresenter/templates/A4/Makefile.am | 20 + kpresenter/templates/A4/OneColumnLandscape.kpt | Bin 0 -> 1140 bytes kpresenter/templates/A4/OneColumnPortrait.kpt | Bin 0 -> 1141 bytes kpresenter/templates/A4/TitleLandscape.kpt | Bin 0 -> 1111 bytes kpresenter/templates/A4/TitlePortrait.kpt | Bin 0 -> 1113 bytes kpresenter/templates/A4/TwoColumnLandscape.kpt | Bin 0 -> 1153 bytes kpresenter/templates/A4/TwoColumnPortrait.kpt | Bin 0 -> 1151 bytes kpresenter/templates/A4/emptyLandscape.kpt | Bin 0 -> 999 bytes kpresenter/templates/A4/emptyPortrait.kpt | Bin 0 -> 996 bytes kpresenter/templates/Makefile.am | 1 + kpresenter/templates/README | 9 + kpresenter/templates/Screen/.directory | 59 + kpresenter/templates/Screen/Makefile.am | 16 + kpresenter/templates/Screen/OneColumnLandscape.kpt | 101 + kpresenter/templates/Screen/TitleLandscape.kpt | 83 + kpresenter/templates/Screen/TwoColumnLandscape.kpt | 119 + kpresenter/templates/Screen/emptyLandscape.kpt | 64 + .../templates/Screenpresentations/.directory | 49 + .../Screenpresentations/BlueBreezeDouble.desktop | 90 + .../Screenpresentations/BlueBreezeDouble.kpt | Bin 0 -> 3490 bytes .../Screenpresentations/BlueBreezePicture.desktop | 92 + .../Screenpresentations/BlueBreezePicture.kpt | Bin 0 -> 93363 bytes .../Screenpresentations/BlueBreezeSingle.desktop | 90 + .../Screenpresentations/BlueBreezeSingle.kpt | Bin 0 -> 3425 bytes .../Screenpresentations/CopperPlain.desktop | 85 + .../templates/Screenpresentations/CopperPlain.kpt | Bin 0 -> 3922 bytes .../Screenpresentations/GradientBlueRed.desktop | 101 + .../Screenpresentations/GradientBlueRed.kpt | Bin 0 -> 1227 bytes .../templates/Screenpresentations/Makefile.am | 18 + .../Screenpresentations/SnowyMountains.desktop | 100 + .../Screenpresentations/SnowyMountains.kpt | Bin 0 -> 61271 bytes .../Screenpresentations/TotallyNewProduct.desktop | 100 + .../Screenpresentations/TotallyNewProduct.kpt | Bin 0 -> 75755 bytes .../Screenpresentations/classroom.desktop | 78 + .../templates/Screenpresentations/classroom.kpt | Bin 0 -> 104924 bytes .../hi48-action-template_bluebreezedouble.png | Bin 0 -> 995 bytes .../hi48-action-template_bluebreezepicture.png | Bin 0 -> 2718 bytes .../hi48-action-template_bluebreezesingle.png | Bin 0 -> 748 bytes .../hi48-action-template_classroom.png | Bin 0 -> 1779 bytes .../hi48-action-template_copperplain.png | Bin 0 -> 294 bytes .../hi48-action-template_gradientbluered.png | Bin 0 -> 252 bytes .../hi48-action-template_kde.png | Bin 0 -> 310 bytes .../hi48-action-template_kde2.png | Bin 0 -> 353 bytes .../hi48-action-template_kde3.png | Bin 0 -> 601 bytes .../hi48-action-template_savannah.png | Bin 0 -> 1390 bytes .../hi48-action-template_screenplain.png | Bin 0 -> 182 bytes .../hi48-action-template_snowymountains.png | Bin 0 -> 2785 bytes .../hi48-action-template_totallynewproduct.png | Bin 0 -> 2458 bytes .../templates/Screenpresentations/kde.desktop | 45 + kpresenter/templates/Screenpresentations/kde.kpt | Bin 0 -> 4382 bytes .../templates/Screenpresentations/kde2.desktop | 47 + kpresenter/templates/Screenpresentations/kde2.kpt | Bin 0 -> 4314 bytes .../templates/Screenpresentations/kde3.desktop | 45 + kpresenter/templates/Screenpresentations/kde3.kpt | Bin 0 -> 46091 bytes .../templates/Screenpresentations/savannah.desktop | 64 + .../templates/Screenpresentations/savannah.kpt | Bin 0 -> 71306 bytes .../common_desktop/OneColumnLandscape.desktop | 107 + .../common_desktop/OneColumnPortrait.desktop | 102 + .../common_desktop/TitleLandscape.desktop | 109 + .../templates/common_desktop/TitlePortrait.desktop | 102 + .../common_desktop/TwoColumnLandscape.desktop | 106 + .../common_desktop/TwoColumnPortrait.desktop | 102 + .../common_desktop/emptyLandscape.desktop | 100 + .../templates/common_desktop/emptyPortrait.desktop | 91 + kpresenter/templates/common_icon/Makefile.am | 3 + .../cr48-action-template_emptylandscape.png | Bin 0 -> 443 bytes .../cr48-action-template_emptyportrait.png | Bin 0 -> 469 bytes .../cr48-action-template_onecolumnlandscape.png | Bin 0 -> 812 bytes .../cr48-action-template_onecolumnportrait.png | Bin 0 -> 892 bytes .../cr48-action-template_titlelandscape.png | Bin 0 -> 529 bytes .../cr48-action-template_titleportrait.png | Bin 0 -> 584 bytes .../cr48-action-template_twocolumnlandscape.png | Bin 0 -> 918 bytes .../cr48-action-template_twocolumnportrait.png | Bin 0 -> 1155 bytes .../crsc-action-template_emptylandscape.svgz | Bin 0 -> 1415 bytes .../crsc-action-template_emptyportrait.svgz | Bin 0 -> 1432 bytes .../crsc-action-template_onecolumnlandscape.svgz | Bin 0 -> 1816 bytes .../crsc-action-template_onecolumnportrait.svgz | Bin 0 -> 1830 bytes .../crsc-action-template_titlelandscape.svgz | Bin 0 -> 1581 bytes .../crsc-action-template_titleportrait.svgz | Bin 0 -> 1595 bytes .../crsc-action-template_twocolumnlandscape.svgz | Bin 0 -> 1889 bytes .../crsc-action-template_twocolumnportrait.svgz | Bin 0 -> 1910 bytes kpresenter/templates/legal/.directory | 24 + kpresenter/templates/legal/Makefile.am | 20 + kpresenter/templates/legal/OneColumnLandscape.kpt | Bin 0 -> 1148 bytes kpresenter/templates/legal/OneColumnPortrait.kpt | Bin 0 -> 1175 bytes kpresenter/templates/legal/TitleLandscape.kpt | Bin 0 -> 1119 bytes kpresenter/templates/legal/TitlePortrait.kpt | Bin 0 -> 1113 bytes kpresenter/templates/legal/TwoColumnLandscape.kpt | Bin 0 -> 1167 bytes kpresenter/templates/legal/TwoColumnPortrait.kpt | Bin 0 -> 1158 bytes kpresenter/templates/legal/emptyLandscape.kpt | Bin 0 -> 1008 bytes kpresenter/templates/legal/emptyPortrait.kpt | Bin 0 -> 1008 bytes kpresenter/templates/letter/.directory | 43 + kpresenter/templates/letter/Makefile.am | 20 + kpresenter/templates/letter/OneColumnLandscape.kpt | Bin 0 -> 1141 bytes kpresenter/templates/letter/OneColumnPortrait.kpt | Bin 0 -> 1142 bytes kpresenter/templates/letter/TitleLandscape.kpt | Bin 0 -> 1113 bytes kpresenter/templates/letter/TitlePortrait.kpt | Bin 0 -> 1113 bytes kpresenter/templates/letter/TwoColumnLandscape.kpt | Bin 0 -> 1152 bytes kpresenter/templates/letter/TwoColumnPortrait.kpt | Bin 0 -> 1151 bytes kpresenter/templates/letter/emptyLandscape.kpt | Bin 0 -> 999 bytes kpresenter/templates/letter/emptyPortrait.kpt | Bin 0 -> 999 bytes kpresenter/tests/oasis-kpresenter.sh | 87 + kpresenter/textpropertyui.ui | 61 + kpresenter/toolbar/Makefile.am | 2 + kpresenter/toolbar/action-alignobjs.svg | 886 +++ kpresenter/toolbar/action-autoform.svg | 151 + kpresenter/toolbar/action-circle.svg | 152 + .../toolbar/action-closed_cubicbeziercurve.svg | 444 ++ kpresenter/toolbar/action-closed_freehand.svg | 482 ++ kpresenter/toolbar/action-closed_polyline.svg | 482 ++ .../toolbar/action-closed_quadricbeziercurve.svg | 402 ++ kpresenter/toolbar/action-cubicbeziercurve.svg | 432 ++ kpresenter/toolbar/action-effect.png.svg | 973 +++ kpresenter/toolbar/action-effect.svg | 879 +++ kpresenter/toolbar/action-freehand.svg | 481 ++ kpresenter/toolbar/action-line.svg | 539 ++ kpresenter/toolbar/action-penbrush.svg | 3337 ++++++++++ kpresenter/toolbar/action-pie.svg | 603 ++ kpresenter/toolbar/action-polygon.svg | 147 + kpresenter/toolbar/action-polyline.svg | 327 + kpresenter/toolbar/action-quadricbeziercurve.svg | 393 ++ kpresenter/toolbar/action-rectangle.svg | 150 + kpresenter/toolbar/action-slide_effect.svg | 680 ++ kpresenter/toolbar/cr16-action-alignobjs.png | Bin 0 -> 444 bytes kpresenter/toolbar/cr16-action-alignobjs.svg | 1066 ++++ kpresenter/toolbar/cr16-action-autoform.png | Bin 0 -> 536 bytes kpresenter/toolbar/cr16-action-circle.png | Bin 0 -> 626 bytes .../cr16-action-closed_cubicbeziercurve.png | Bin 0 -> 429 bytes kpresenter/toolbar/cr16-action-closed_freehand.png | Bin 0 -> 589 bytes kpresenter/toolbar/cr16-action-closed_polyline.png | Bin 0 -> 487 bytes .../cr16-action-closed_quadricbeziercurve.png | Bin 0 -> 495 bytes .../toolbar/cr16-action-cubicbeziercurve.png | Bin 0 -> 288 bytes kpresenter/toolbar/cr16-action-effect.png | Bin 0 -> 997 bytes kpresenter/toolbar/cr16-action-freehand.png | Bin 0 -> 416 bytes kpresenter/toolbar/cr16-action-line.png | Bin 0 -> 240 bytes kpresenter/toolbar/cr16-action-penbrush.png | Bin 0 -> 946 bytes kpresenter/toolbar/cr16-action-pie.png | Bin 0 -> 625 bytes kpresenter/toolbar/cr16-action-polygon.png | Bin 0 -> 598 bytes kpresenter/toolbar/cr16-action-polyline.png | Bin 0 -> 273 bytes .../toolbar/cr16-action-quadricbeziercurve.png | Bin 0 -> 303 bytes kpresenter/toolbar/cr16-action-rectangle.png | Bin 0 -> 410 bytes kpresenter/toolbar/cr16-action-slide_effect.png | Bin 0 -> 824 bytes kpresenter/toolbar/cr22-action-alignobjs.png | Bin 0 -> 485 bytes kpresenter/toolbar/cr22-action-alignobjs.svg | 1061 ++++ kpresenter/toolbar/cr22-action-arrange.png | Bin 0 -> 429 bytes kpresenter/toolbar/cr22-action-autoform.png | Bin 0 -> 663 bytes kpresenter/toolbar/cr22-action-cakes.png | Bin 0 -> 330 bytes kpresenter/toolbar/cr22-action-cakes3d.png | Bin 0 -> 332 bytes kpresenter/toolbar/cr22-action-circle.png | Bin 0 -> 861 bytes .../cr22-action-closed_cubicbeziercurve.png | Bin 0 -> 624 bytes kpresenter/toolbar/cr22-action-closed_freehand.png | Bin 0 -> 880 bytes kpresenter/toolbar/cr22-action-closed_polyline.png | Bin 0 -> 691 bytes .../cr22-action-closed_quadricbeziercurve.png | Bin 0 -> 758 bytes .../toolbar/cr22-action-cubicbeziercurve.png | Bin 0 -> 373 bytes kpresenter/toolbar/cr22-action-edit_picture.png | Bin 0 -> 930 bytes kpresenter/toolbar/cr22-action-edit_pie.png | Bin 0 -> 435 bytes kpresenter/toolbar/cr22-action-edit_polygon.png | Bin 0 -> 268 bytes kpresenter/toolbar/cr22-action-effect.png | Bin 0 -> 1592 bytes kpresenter/toolbar/cr22-action-freehand.png | Bin 0 -> 579 bytes kpresenter/toolbar/cr22-action-line.png | Bin 0 -> 306 bytes .../toolbar/cr22-action-line_arrow_begin.png | Bin 0 -> 135 bytes kpresenter/toolbar/cr22-action-line_arrow_end.png | Bin 0 -> 137 bytes kpresenter/toolbar/cr22-action-line_begin.png | Bin 0 -> 419 bytes .../toolbar/cr22-action-line_circle_begin.png | Bin 0 -> 137 bytes kpresenter/toolbar/cr22-action-line_circle_end.png | Bin 0 -> 136 bytes .../cr22-action-line_dimension_line_begin.png | Bin 0 -> 144 bytes .../cr22-action-line_dimension_line_end.png | Bin 0 -> 134 bytes .../cr22-action-line_double_arrow_begin.png | Bin 0 -> 190 bytes .../toolbar/cr22-action-line_double_arrow_end.png | Bin 0 -> 193 bytes .../cr22-action-line_double_line_arrow_begin.png | Bin 0 -> 184 bytes .../cr22-action-line_double_line_arrow_end.png | Bin 0 -> 185 bytes kpresenter/toolbar/cr22-action-line_end.png | Bin 0 -> 368 bytes .../toolbar/cr22-action-line_line_arrow_begin.png | Bin 0 -> 168 bytes .../toolbar/cr22-action-line_line_arrow_end.png | Bin 0 -> 193 bytes .../toolbar/cr22-action-line_normal_begin.png | Bin 0 -> 90 bytes kpresenter/toolbar/cr22-action-line_normal_end.png | Bin 0 -> 90 bytes kpresenter/toolbar/cr22-action-line_rect_begin.png | Bin 0 -> 103 bytes kpresenter/toolbar/cr22-action-line_rect_end.png | Bin 0 -> 109 bytes kpresenter/toolbar/cr22-action-mini_autoform.png | Bin 0 -> 274 bytes kpresenter/toolbar/cr22-action-mini_circle.png | Bin 0 -> 282 bytes kpresenter/toolbar/cr22-action-mini_clipart.png | Bin 0 -> 336 bytes kpresenter/toolbar/cr22-action-mini_line.png | Bin 0 -> 240 bytes kpresenter/toolbar/cr22-action-mini_pie.png | Bin 0 -> 319 bytes kpresenter/toolbar/cr22-action-mini_polygon.png | Bin 0 -> 138 bytes kpresenter/toolbar/cr22-action-mini_rect.png | Bin 0 -> 259 bytes kpresenter/toolbar/cr22-action-pen_style.png | Bin 0 -> 237 bytes kpresenter/toolbar/cr22-action-pen_style_dash.png | Bin 0 -> 107 bytes .../toolbar/cr22-action-pen_style_dashdot.png | Bin 0 -> 115 bytes .../toolbar/cr22-action-pen_style_dashdotdot.png | Bin 0 -> 110 bytes kpresenter/toolbar/cr22-action-pen_style_dot.png | Bin 0 -> 101 bytes kpresenter/toolbar/cr22-action-pen_style_nopen.png | Bin 0 -> 88 bytes kpresenter/toolbar/cr22-action-pen_style_solid.png | Bin 0 -> 106 bytes kpresenter/toolbar/cr22-action-pen_width.png | Bin 0 -> 218 bytes kpresenter/toolbar/cr22-action-pen_width1.png | Bin 0 -> 106 bytes kpresenter/toolbar/cr22-action-pen_width10.png | Bin 0 -> 108 bytes kpresenter/toolbar/cr22-action-pen_width2.png | Bin 0 -> 108 bytes kpresenter/toolbar/cr22-action-pen_width3.png | Bin 0 -> 107 bytes kpresenter/toolbar/cr22-action-pen_width4.png | Bin 0 -> 110 bytes kpresenter/toolbar/cr22-action-pen_width5.png | Bin 0 -> 109 bytes kpresenter/toolbar/cr22-action-pen_width6.png | Bin 0 -> 108 bytes kpresenter/toolbar/cr22-action-pen_width7.png | Bin 0 -> 108 bytes kpresenter/toolbar/cr22-action-pen_width8.png | Bin 0 -> 109 bytes kpresenter/toolbar/cr22-action-pen_width9.png | Bin 0 -> 108 bytes kpresenter/toolbar/cr22-action-penbrush.png | Bin 0 -> 1487 bytes kpresenter/toolbar/cr22-action-pgnum.png | Bin 0 -> 299 bytes kpresenter/toolbar/cr22-action-pie.png | Bin 0 -> 851 bytes kpresenter/toolbar/cr22-action-polygon.png | Bin 0 -> 791 bytes kpresenter/toolbar/cr22-action-polyline.png | Bin 0 -> 341 bytes .../toolbar/cr22-action-quadricbeziercurve.png | Bin 0 -> 389 bytes kpresenter/toolbar/cr22-action-rectangle.png | Bin 0 -> 562 bytes kpresenter/toolbar/cr22-action-slide_effect.png | Bin 0 -> 1253 bytes kpresenter/toolbar/cr22-action-webpres.png | Bin 0 -> 420 bytes kpresenter/toolbar/cr32-action-alignobjs.png | Bin 0 -> 946 bytes kpresenter/toolbar/cr32-action-autoform.png | Bin 0 -> 1006 bytes kpresenter/toolbar/cr32-action-circle.png | Bin 0 -> 1214 bytes .../cr32-action-closed_cubicbeziercurve.png | Bin 0 -> 972 bytes kpresenter/toolbar/cr32-action-closed_freehand.png | Bin 0 -> 1288 bytes kpresenter/toolbar/cr32-action-closed_polyline.png | Bin 0 -> 1090 bytes .../cr32-action-closed_quadricbeziercurve.png | Bin 0 -> 1166 bytes .../toolbar/cr32-action-cubicbeziercurve.png | Bin 0 -> 480 bytes kpresenter/toolbar/cr32-action-effect.png | Bin 0 -> 2753 bytes kpresenter/toolbar/cr32-action-freehand.png | Bin 0 -> 814 bytes kpresenter/toolbar/cr32-action-line.png | Bin 0 -> 406 bytes kpresenter/toolbar/cr32-action-penbrush.png | Bin 0 -> 2552 bytes kpresenter/toolbar/cr32-action-pie.png | Bin 0 -> 1256 bytes kpresenter/toolbar/cr32-action-polygon.png | Bin 0 -> 1195 bytes kpresenter/toolbar/cr32-action-polyline.png | Bin 0 -> 507 bytes .../toolbar/cr32-action-quadricbeziercurve.png | Bin 0 -> 552 bytes kpresenter/toolbar/cr32-action-rectangle.png | Bin 0 -> 750 bytes kpresenter/toolbar/cr32-action-slide_effect.png | Bin 0 -> 1911 bytes kpresenter/toolbar/cr48-action-alignobjs.png | Bin 0 -> 1616 bytes kpresenter/toolbar/cr48-action-autoform.png | Bin 0 -> 1490 bytes kpresenter/toolbar/cr48-action-circle.png | Bin 0 -> 1882 bytes .../cr48-action-closed_cubicbeziercurve.png | Bin 0 -> 1480 bytes kpresenter/toolbar/cr48-action-closed_freehand.png | Bin 0 -> 2062 bytes kpresenter/toolbar/cr48-action-closed_polyline.png | Bin 0 -> 1620 bytes .../cr48-action-closed_quadricbeziercurve.png | Bin 0 -> 1730 bytes .../toolbar/cr48-action-cubicbeziercurve.png | Bin 0 -> 706 bytes kpresenter/toolbar/cr48-action-effect.png | Bin 0 -> 4817 bytes kpresenter/toolbar/cr48-action-freehand.png | Bin 0 -> 1310 bytes kpresenter/toolbar/cr48-action-line.png | Bin 0 -> 670 bytes kpresenter/toolbar/cr48-action-penbrush.png | Bin 0 -> 4571 bytes kpresenter/toolbar/cr48-action-pie.png | Bin 0 -> 1981 bytes kpresenter/toolbar/cr48-action-polygon.png | Bin 0 -> 1866 bytes kpresenter/toolbar/cr48-action-polyline.png | Bin 0 -> 816 bytes .../toolbar/cr48-action-quadricbeziercurve.png | Bin 0 -> 837 bytes kpresenter/toolbar/cr48-action-rectangle.png | Bin 0 -> 1189 bytes kpresenter/toolbar/cr48-action-slide_effect.png | Bin 0 -> 3328 bytes 575 files changed, 95990 insertions(+) create mode 100644 kpresenter/AUTHORS create mode 100644 kpresenter/CHANGES create mode 100644 kpresenter/KPrAboutData.h create mode 100644 kpresenter/KPrAutoFormObjectIface.cpp create mode 100644 kpresenter/KPrAutoFormObjectIface.h create mode 100644 kpresenter/KPrAutoformObject.cpp create mode 100644 kpresenter/KPrAutoformObject.h create mode 100644 kpresenter/KPrBackDia.cpp create mode 100644 kpresenter/KPrBackDia.h create mode 100644 kpresenter/KPrBackground.cpp create mode 100644 kpresenter/KPrBackground.h create mode 100644 kpresenter/KPrBezierCurveObject.cpp create mode 100644 kpresenter/KPrBezierCurveObject.h create mode 100644 kpresenter/KPrBgSpellCheck.cpp create mode 100644 kpresenter/KPrBgSpellCheck.h create mode 100644 kpresenter/KPrBrush.cpp create mode 100644 kpresenter/KPrBrush.h create mode 100644 kpresenter/KPrBrushProperty.cpp create mode 100644 kpresenter/KPrBrushProperty.h create mode 100644 kpresenter/KPrCanvas.cpp create mode 100644 kpresenter/KPrCanvas.h create mode 100644 kpresenter/KPrClosedLineObject.cpp create mode 100644 kpresenter/KPrClosedLineObject.h create mode 100644 kpresenter/KPrCommand.cpp create mode 100644 kpresenter/KPrCommand.h create mode 100644 kpresenter/KPrConfig.cpp create mode 100644 kpresenter/KPrConfig.h create mode 100644 kpresenter/KPrCubicBezierCurveObjectIface.cpp create mode 100644 kpresenter/KPrCubicBezierCurveObjectIface.h create mode 100644 kpresenter/KPrCustomSlideShowDia.cpp create mode 100644 kpresenter/KPrCustomSlideShowDia.h create mode 100644 kpresenter/KPrDocument.cpp create mode 100644 kpresenter/KPrDocument.h create mode 100644 kpresenter/KPrDocumentIface.cpp create mode 100644 kpresenter/KPrDocumentIface.h create mode 100644 kpresenter/KPrDuplicateObjDia.cpp create mode 100644 kpresenter/KPrDuplicateObjDia.h create mode 100644 kpresenter/KPrEffectDia.cpp create mode 100644 kpresenter/KPrEffectDia.h create mode 100644 kpresenter/KPrEffectHandler.cpp create mode 100644 kpresenter/KPrEffectHandler.h create mode 100644 kpresenter/KPrEllipseObject.cpp create mode 100644 kpresenter/KPrEllipseObject.h create mode 100644 kpresenter/KPrFactory.cpp create mode 100644 kpresenter/KPrFactory.h create mode 100644 kpresenter/KPrFactoryInit.cpp create mode 100644 kpresenter/KPrFindReplace.cpp create mode 100644 kpresenter/KPrFindReplace.h create mode 100644 kpresenter/KPrFreehandObject.cpp create mode 100644 kpresenter/KPrFreehandObject.h create mode 100644 kpresenter/KPrFreehandObjectIface.cpp create mode 100644 kpresenter/KPrFreehandObjectIface.h create mode 100644 kpresenter/KPrGeneralProperty.cpp create mode 100644 kpresenter/KPrGeneralProperty.h create mode 100644 kpresenter/KPrGotoPage.cpp create mode 100644 kpresenter/KPrGotoPage.h create mode 100644 kpresenter/KPrGradient.cpp create mode 100644 kpresenter/KPrGradient.h create mode 100644 kpresenter/KPrGradientCollection.cpp create mode 100644 kpresenter/KPrGradientCollection.h create mode 100644 kpresenter/KPrGroupObject.cpp create mode 100644 kpresenter/KPrGroupObject.h create mode 100644 kpresenter/KPrImageEffectDia.cpp create mode 100644 kpresenter/KPrImageEffectDia.h create mode 100644 kpresenter/KPrImportStyleDia.cpp create mode 100644 kpresenter/KPrImportStyleDia.h create mode 100644 kpresenter/KPrLineObject.cpp create mode 100644 kpresenter/KPrLineObject.h create mode 100644 kpresenter/KPrLineObjectIface.cpp create mode 100644 kpresenter/KPrLineObjectIface.h create mode 100644 kpresenter/KPrLoadingInfo.h create mode 100644 kpresenter/KPrMSPresentationSetup.cpp create mode 100644 kpresenter/KPrMSPresentationSetup.h create mode 100644 kpresenter/KPrMarginWidget.cpp create mode 100644 kpresenter/KPrMarginWidget.h create mode 100644 kpresenter/KPrMoveHelpLineDia.cpp create mode 100644 kpresenter/KPrMoveHelpLineDia.h create mode 100644 kpresenter/KPrNoteBar.cpp create mode 100644 kpresenter/KPrNoteBar.h create mode 100644 kpresenter/KPrObject.cpp create mode 100644 kpresenter/KPrObject.h create mode 100644 kpresenter/KPrObject2DIface.cpp create mode 100644 kpresenter/KPrObject2DIface.h create mode 100644 kpresenter/KPrObjectIface.cpp create mode 100644 kpresenter/KPrObjectIface.h create mode 100644 kpresenter/KPrObjectProperties.cpp create mode 100644 kpresenter/KPrObjectProperties.h create mode 100644 kpresenter/KPrPBPreview.cpp create mode 100644 kpresenter/KPrPBPreview.h create mode 100644 kpresenter/KPrPage.cpp create mode 100644 kpresenter/KPrPage.h create mode 100644 kpresenter/KPrPageEffects.cpp create mode 100644 kpresenter/KPrPageEffects.h create mode 100644 kpresenter/KPrPageIface.cpp create mode 100644 kpresenter/KPrPageIface.h create mode 100644 kpresenter/KPrPartObject.cpp create mode 100644 kpresenter/KPrPartObject.h create mode 100644 kpresenter/KPrPenStyleWidget.cpp create mode 100644 kpresenter/KPrPenStyleWidget.h create mode 100644 kpresenter/KPrPgConfDia.cpp create mode 100644 kpresenter/KPrPgConfDia.h create mode 100644 kpresenter/KPrPicturePreview.cpp create mode 100644 kpresenter/KPrPicturePreview.h create mode 100644 kpresenter/KPrPictureProperty.cpp create mode 100644 kpresenter/KPrPictureProperty.h create mode 100644 kpresenter/KPrPieObject.cpp create mode 100644 kpresenter/KPrPieObject.h create mode 100644 kpresenter/KPrPieObjectIface.cpp create mode 100644 kpresenter/KPrPieObjectIface.h create mode 100644 kpresenter/KPrPiePreview.cpp create mode 100644 kpresenter/KPrPiePreview.h create mode 100644 kpresenter/KPrPieProperty.cpp create mode 100644 kpresenter/KPrPieProperty.h create mode 100644 kpresenter/KPrPixmapObject.cpp create mode 100644 kpresenter/KPrPixmapObject.h create mode 100644 kpresenter/KPrPixmapObjectIface.cpp create mode 100644 kpresenter/KPrPixmapObjectIface.h create mode 100644 kpresenter/KPrPointObject.cpp create mode 100644 kpresenter/KPrPointObject.h create mode 100644 kpresenter/KPrPolyLineObjectIface.cpp create mode 100644 kpresenter/KPrPolyLineObjectIface.h create mode 100644 kpresenter/KPrPolygonObject.cpp create mode 100644 kpresenter/KPrPolygonObject.h create mode 100644 kpresenter/KPrPolygonObjectIface.cpp create mode 100644 kpresenter/KPrPolygonObjectIface.h create mode 100644 kpresenter/KPrPolygonPreview.cpp create mode 100644 kpresenter/KPrPolygonPreview.h create mode 100644 kpresenter/KPrPolygonProperty.cpp create mode 100644 kpresenter/KPrPolygonProperty.h create mode 100644 kpresenter/KPrPolylineObject.cpp create mode 100644 kpresenter/KPrPolylineObject.h create mode 100644 kpresenter/KPrPresDurationDia.cpp create mode 100644 kpresenter/KPrPresDurationDia.h create mode 100644 kpresenter/KPrPrinterDlg.cpp create mode 100644 kpresenter/KPrPrinterDlg.h create mode 100644 kpresenter/KPrPropertyEditor.cpp create mode 100644 kpresenter/KPrPropertyEditor.h create mode 100644 kpresenter/KPrQuadricBezierCurveObjectIface.cpp create mode 100644 kpresenter/KPrQuadricBezierCurveObjectIface.h create mode 100644 kpresenter/KPrRectObject.cpp create mode 100644 kpresenter/KPrRectObject.h create mode 100644 kpresenter/KPrRectObjectIface.cpp create mode 100644 kpresenter/KPrRectObjectIface.h create mode 100644 kpresenter/KPrRectPreview.cpp create mode 100644 kpresenter/KPrRectPreview.h create mode 100644 kpresenter/KPrRectProperty.cpp create mode 100644 kpresenter/KPrRectProperty.h create mode 100644 kpresenter/KPrRotationDialogImpl.cpp create mode 100644 kpresenter/KPrRotationDialogImpl.h create mode 100644 kpresenter/KPrSVGPathParser.cpp create mode 100644 kpresenter/KPrSVGPathParser.h create mode 100644 kpresenter/KPrShadowDialogImpl.cpp create mode 100644 kpresenter/KPrShadowDialogImpl.h create mode 100644 kpresenter/KPrSideBar.cpp create mode 100644 kpresenter/KPrSideBar.h create mode 100644 kpresenter/KPrSlideTransitionDia.cpp create mode 100644 kpresenter/KPrSlideTransitionDia.h create mode 100644 kpresenter/KPrSoundPlayer.cpp create mode 100644 kpresenter/KPrSoundPlayer.h create mode 100644 kpresenter/KPrStyleManager.cpp create mode 100644 kpresenter/KPrStyleManager.h create mode 100644 kpresenter/KPrTextDocument.cpp create mode 100644 kpresenter/KPrTextDocument.h create mode 100644 kpresenter/KPrTextObject.cpp create mode 100644 kpresenter/KPrTextObject.h create mode 100644 kpresenter/KPrTextObjectIface.cpp create mode 100644 kpresenter/KPrTextObjectIface.h create mode 100644 kpresenter/KPrTextPreview.cpp create mode 100644 kpresenter/KPrTextPreview.h create mode 100644 kpresenter/KPrTextProperty.cpp create mode 100644 kpresenter/KPrTextProperty.h create mode 100644 kpresenter/KPrTextViewIface.cpp create mode 100644 kpresenter/KPrTextViewIface.h create mode 100644 kpresenter/KPrTransEffectDia.cpp create mode 100644 kpresenter/KPrTransEffectDia.h create mode 100644 kpresenter/KPrUtils.cpp create mode 100644 kpresenter/KPrUtils.h create mode 100644 kpresenter/KPrVariableCollection.cpp create mode 100644 kpresenter/KPrVariableCollection.h create mode 100644 kpresenter/KPrView.cpp create mode 100644 kpresenter/KPrView.h create mode 100644 kpresenter/KPrViewIface.cpp create mode 100644 kpresenter/KPrViewIface.h create mode 100644 kpresenter/KPrWebPresentation.cpp create mode 100644 kpresenter/KPrWebPresentation.h create mode 100644 kpresenter/KoPointArray.cpp create mode 100644 kpresenter/KoPointArray.h create mode 100644 kpresenter/Makefile.am create mode 100644 kpresenter/TODO create mode 100644 kpresenter/autoformEdit/AFChoose.cpp create mode 100644 kpresenter/autoformEdit/AFChoose.h create mode 100644 kpresenter/autoformEdit/ATFInterpreter.cpp create mode 100644 kpresenter/autoformEdit/ATFInterpreter.h create mode 100644 kpresenter/autoformEdit/Makefile.am create mode 100644 kpresenter/autoforms/.autoforms create mode 100644 kpresenter/autoforms/Arrows/.directory create mode 100644 kpresenter/autoforms/Arrows/ArrowDown.atf create mode 100644 kpresenter/autoforms/Arrows/ArrowDown.desktop create mode 100644 kpresenter/autoforms/Arrows/ArrowDown.png create mode 100644 kpresenter/autoforms/Arrows/ArrowLeft.atf create mode 100644 kpresenter/autoforms/Arrows/ArrowLeft.desktop create mode 100644 kpresenter/autoforms/Arrows/ArrowLeft.png create mode 100644 kpresenter/autoforms/Arrows/ArrowLeftDown.atf create mode 100644 kpresenter/autoforms/Arrows/ArrowLeftDown.desktop create mode 100644 kpresenter/autoforms/Arrows/ArrowLeftDown.png create mode 100644 kpresenter/autoforms/Arrows/ArrowLeftUp.atf create mode 100644 kpresenter/autoforms/Arrows/ArrowLeftUp.desktop create mode 100644 kpresenter/autoforms/Arrows/ArrowLeftUp.png create mode 100644 kpresenter/autoforms/Arrows/ArrowRight.atf create mode 100644 kpresenter/autoforms/Arrows/ArrowRight.desktop create mode 100644 kpresenter/autoforms/Arrows/ArrowRight.png create mode 100644 kpresenter/autoforms/Arrows/ArrowRightDown.atf create mode 100644 kpresenter/autoforms/Arrows/ArrowRightDown.desktop create mode 100644 kpresenter/autoforms/Arrows/ArrowRightDown.png create mode 100644 kpresenter/autoforms/Arrows/ArrowRightUp.atf create mode 100644 kpresenter/autoforms/Arrows/ArrowRightUp.desktop create mode 100644 kpresenter/autoforms/Arrows/ArrowRightUp.png create mode 100644 kpresenter/autoforms/Arrows/ArrowUp.atf create mode 100644 kpresenter/autoforms/Arrows/ArrowUp.desktop create mode 100644 kpresenter/autoforms/Arrows/ArrowUp.png create mode 100644 kpresenter/autoforms/Arrows/Makefile.am create mode 100644 kpresenter/autoforms/Connections/.directory create mode 100644 kpresenter/autoforms/Connections/Connection1.atf create mode 100644 kpresenter/autoforms/Connections/Connection1.desktop create mode 100644 kpresenter/autoforms/Connections/Connection1.png create mode 100644 kpresenter/autoforms/Connections/Connection10.atf create mode 100644 kpresenter/autoforms/Connections/Connection10.desktop create mode 100644 kpresenter/autoforms/Connections/Connection10.png create mode 100644 kpresenter/autoforms/Connections/Connection11.atf create mode 100644 kpresenter/autoforms/Connections/Connection11.desktop create mode 100644 kpresenter/autoforms/Connections/Connection11.png create mode 100644 kpresenter/autoforms/Connections/Connection12.atf create mode 100644 kpresenter/autoforms/Connections/Connection12.desktop create mode 100644 kpresenter/autoforms/Connections/Connection12.png create mode 100644 kpresenter/autoforms/Connections/Connection2.atf create mode 100644 kpresenter/autoforms/Connections/Connection2.desktop create mode 100644 kpresenter/autoforms/Connections/Connection2.png create mode 100644 kpresenter/autoforms/Connections/Connection3.atf create mode 100644 kpresenter/autoforms/Connections/Connection3.desktop create mode 100644 kpresenter/autoforms/Connections/Connection3.png create mode 100644 kpresenter/autoforms/Connections/Connection4.atf create mode 100644 kpresenter/autoforms/Connections/Connection4.desktop create mode 100644 kpresenter/autoforms/Connections/Connection4.png create mode 100644 kpresenter/autoforms/Connections/Connection5.atf create mode 100644 kpresenter/autoforms/Connections/Connection5.desktop create mode 100644 kpresenter/autoforms/Connections/Connection5.png create mode 100644 kpresenter/autoforms/Connections/Connection6.atf create mode 100644 kpresenter/autoforms/Connections/Connection6.desktop create mode 100644 kpresenter/autoforms/Connections/Connection6.png create mode 100644 kpresenter/autoforms/Connections/Connection7.atf create mode 100644 kpresenter/autoforms/Connections/Connection7.desktop create mode 100644 kpresenter/autoforms/Connections/Connection7.png create mode 100644 kpresenter/autoforms/Connections/Connection8.atf create mode 100644 kpresenter/autoforms/Connections/Connection8.desktop create mode 100644 kpresenter/autoforms/Connections/Connection8.png create mode 100644 kpresenter/autoforms/Connections/Connection9.atf create mode 100644 kpresenter/autoforms/Connections/Connection9.desktop create mode 100644 kpresenter/autoforms/Connections/Connection9.png create mode 100644 kpresenter/autoforms/Connections/Makefile.am create mode 100644 kpresenter/autoforms/Makefile.am create mode 100644 kpresenter/brushpropertyui.ui create mode 100644 kpresenter/configure.in.in create mode 100644 kpresenter/dtd/Makefile.am create mode 100644 kpresenter/dtd/kpresenter.dtd create mode 100644 kpresenter/generalpropertyui.ui create mode 100644 kpresenter/global.h create mode 100644 kpresenter/gradientpropertyui.ui create mode 100644 kpresenter/imageEffectBase.ui create mode 100644 kpresenter/insertpagedia.ui create mode 100644 kpresenter/kprconverter.pl create mode 100644 kpresenter/kpresenter.desktop create mode 100644 kpresenter/kpresenter.rc create mode 100644 kpresenter/kpresenter_readonly.rc create mode 100644 kpresenter/kpresenterpart.desktop create mode 100644 kpresenter/main.cpp create mode 100644 kpresenter/marginui.ui create mode 100644 kpresenter/penstyle.ui create mode 100644 kpresenter/pics/Makefile.am create mode 100644 kpresenter/pics/hi16-app-kpresenter.png create mode 100644 kpresenter/pics/hi22-app-kpresenter.png create mode 100644 kpresenter/pics/hi32-app-kpresenter.png create mode 100644 kpresenter/pics/hi48-app-kpresenter.png create mode 100644 kpresenter/pics/rotate/Makefile.am create mode 100644 kpresenter/pics/rotate/bl.png create mode 100644 kpresenter/pics/rotate/bldn.png create mode 100644 kpresenter/pics/rotate/bm.png create mode 100644 kpresenter/pics/rotate/bmdn.png create mode 100644 kpresenter/pics/rotate/br.png create mode 100644 kpresenter/pics/rotate/brdn.png create mode 100644 kpresenter/pics/rotate/ml.png create mode 100644 kpresenter/pics/rotate/mldn.png create mode 100644 kpresenter/pics/rotate/mr.png create mode 100644 kpresenter/pics/rotate/mrdn.png create mode 100644 kpresenter/pics/rotate/tl.png create mode 100644 kpresenter/pics/rotate/tldn.png create mode 100644 kpresenter/pics/rotate/tm.png create mode 100644 kpresenter/pics/rotate/tmdn.png create mode 100644 kpresenter/pics/rotate/tr.png create mode 100644 kpresenter/pics/rotate/trdn.png create mode 100644 kpresenter/pics/webslideshow-sidebar.png create mode 100644 kpresenter/picturepropertyui.ui create mode 100644 kpresenter/piepropertyui.ui create mode 100644 kpresenter/polygonpropertyui.ui create mode 100644 kpresenter/presstep.h create mode 100644 kpresenter/rectpropertyui.ui create mode 100644 kpresenter/rotationpropertyui.ui create mode 100755 kpresenter/scripts/automate_presentation.sh create mode 100755 kpresenter/scripts/mkstandalone.sh create mode 100644 kpresenter/shadowdialog.ui create mode 100644 kpresenter/slideshow/Makefile.am create mode 100644 kpresenter/slideshow/first.bmp create mode 100644 kpresenter/slideshow/first.jpeg create mode 100644 kpresenter/slideshow/first.png create mode 100644 kpresenter/slideshow/home.bmp create mode 100644 kpresenter/slideshow/home.jpeg create mode 100644 kpresenter/slideshow/home.png create mode 100644 kpresenter/slideshow/last.bmp create mode 100644 kpresenter/slideshow/last.jpeg create mode 100644 kpresenter/slideshow/last.png create mode 100644 kpresenter/slideshow/next.bmp create mode 100644 kpresenter/slideshow/next.jpeg create mode 100644 kpresenter/slideshow/next.png create mode 100644 kpresenter/slideshow/prev.bmp create mode 100644 kpresenter/slideshow/prev.jpeg create mode 100644 kpresenter/slideshow/prev.png create mode 100644 kpresenter/slidetransitionwidget.ui create mode 100644 kpresenter/templates/A4/.directory create mode 100644 kpresenter/templates/A4/Makefile.am create mode 100644 kpresenter/templates/A4/OneColumnLandscape.kpt create mode 100644 kpresenter/templates/A4/OneColumnPortrait.kpt create mode 100644 kpresenter/templates/A4/TitleLandscape.kpt create mode 100644 kpresenter/templates/A4/TitlePortrait.kpt create mode 100644 kpresenter/templates/A4/TwoColumnLandscape.kpt create mode 100644 kpresenter/templates/A4/TwoColumnPortrait.kpt create mode 100644 kpresenter/templates/A4/emptyLandscape.kpt create mode 100644 kpresenter/templates/A4/emptyPortrait.kpt create mode 100644 kpresenter/templates/Makefile.am create mode 100644 kpresenter/templates/README create mode 100644 kpresenter/templates/Screen/.directory create mode 100644 kpresenter/templates/Screen/Makefile.am create mode 100644 kpresenter/templates/Screen/OneColumnLandscape.kpt create mode 100644 kpresenter/templates/Screen/TitleLandscape.kpt create mode 100644 kpresenter/templates/Screen/TwoColumnLandscape.kpt create mode 100644 kpresenter/templates/Screen/emptyLandscape.kpt create mode 100644 kpresenter/templates/Screenpresentations/.directory create mode 100644 kpresenter/templates/Screenpresentations/BlueBreezeDouble.desktop create mode 100644 kpresenter/templates/Screenpresentations/BlueBreezeDouble.kpt create mode 100644 kpresenter/templates/Screenpresentations/BlueBreezePicture.desktop create mode 100644 kpresenter/templates/Screenpresentations/BlueBreezePicture.kpt create mode 100644 kpresenter/templates/Screenpresentations/BlueBreezeSingle.desktop create mode 100644 kpresenter/templates/Screenpresentations/BlueBreezeSingle.kpt create mode 100644 kpresenter/templates/Screenpresentations/CopperPlain.desktop create mode 100644 kpresenter/templates/Screenpresentations/CopperPlain.kpt create mode 100644 kpresenter/templates/Screenpresentations/GradientBlueRed.desktop create mode 100644 kpresenter/templates/Screenpresentations/GradientBlueRed.kpt create mode 100644 kpresenter/templates/Screenpresentations/Makefile.am create mode 100644 kpresenter/templates/Screenpresentations/SnowyMountains.desktop create mode 100644 kpresenter/templates/Screenpresentations/SnowyMountains.kpt create mode 100644 kpresenter/templates/Screenpresentations/TotallyNewProduct.desktop create mode 100644 kpresenter/templates/Screenpresentations/TotallyNewProduct.kpt create mode 100644 kpresenter/templates/Screenpresentations/classroom.desktop create mode 100644 kpresenter/templates/Screenpresentations/classroom.kpt create mode 100644 kpresenter/templates/Screenpresentations/hi48-action-template_bluebreezedouble.png create mode 100644 kpresenter/templates/Screenpresentations/hi48-action-template_bluebreezepicture.png create mode 100644 kpresenter/templates/Screenpresentations/hi48-action-template_bluebreezesingle.png create mode 100644 kpresenter/templates/Screenpresentations/hi48-action-template_classroom.png create mode 100644 kpresenter/templates/Screenpresentations/hi48-action-template_copperplain.png create mode 100644 kpresenter/templates/Screenpresentations/hi48-action-template_gradientbluered.png create mode 100644 kpresenter/templates/Screenpresentations/hi48-action-template_kde.png create mode 100644 kpresenter/templates/Screenpresentations/hi48-action-template_kde2.png create mode 100644 kpresenter/templates/Screenpresentations/hi48-action-template_kde3.png create mode 100644 kpresenter/templates/Screenpresentations/hi48-action-template_savannah.png create mode 100644 kpresenter/templates/Screenpresentations/hi48-action-template_screenplain.png create mode 100644 kpresenter/templates/Screenpresentations/hi48-action-template_snowymountains.png create mode 100644 kpresenter/templates/Screenpresentations/hi48-action-template_totallynewproduct.png create mode 100644 kpresenter/templates/Screenpresentations/kde.desktop create mode 100644 kpresenter/templates/Screenpresentations/kde.kpt create mode 100644 kpresenter/templates/Screenpresentations/kde2.desktop create mode 100644 kpresenter/templates/Screenpresentations/kde2.kpt create mode 100644 kpresenter/templates/Screenpresentations/kde3.desktop create mode 100644 kpresenter/templates/Screenpresentations/kde3.kpt create mode 100644 kpresenter/templates/Screenpresentations/savannah.desktop create mode 100644 kpresenter/templates/Screenpresentations/savannah.kpt create mode 100644 kpresenter/templates/common_desktop/OneColumnLandscape.desktop create mode 100644 kpresenter/templates/common_desktop/OneColumnPortrait.desktop create mode 100644 kpresenter/templates/common_desktop/TitleLandscape.desktop create mode 100644 kpresenter/templates/common_desktop/TitlePortrait.desktop create mode 100644 kpresenter/templates/common_desktop/TwoColumnLandscape.desktop create mode 100644 kpresenter/templates/common_desktop/TwoColumnPortrait.desktop create mode 100644 kpresenter/templates/common_desktop/emptyLandscape.desktop create mode 100644 kpresenter/templates/common_desktop/emptyPortrait.desktop create mode 100644 kpresenter/templates/common_icon/Makefile.am create mode 100644 kpresenter/templates/common_icon/cr48-action-template_emptylandscape.png create mode 100644 kpresenter/templates/common_icon/cr48-action-template_emptyportrait.png create mode 100644 kpresenter/templates/common_icon/cr48-action-template_onecolumnlandscape.png create mode 100644 kpresenter/templates/common_icon/cr48-action-template_onecolumnportrait.png create mode 100644 kpresenter/templates/common_icon/cr48-action-template_titlelandscape.png create mode 100644 kpresenter/templates/common_icon/cr48-action-template_titleportrait.png create mode 100644 kpresenter/templates/common_icon/cr48-action-template_twocolumnlandscape.png create mode 100644 kpresenter/templates/common_icon/cr48-action-template_twocolumnportrait.png create mode 100644 kpresenter/templates/common_icon/crsc-action-template_emptylandscape.svgz create mode 100644 kpresenter/templates/common_icon/crsc-action-template_emptyportrait.svgz create mode 100644 kpresenter/templates/common_icon/crsc-action-template_onecolumnlandscape.svgz create mode 100644 kpresenter/templates/common_icon/crsc-action-template_onecolumnportrait.svgz create mode 100644 kpresenter/templates/common_icon/crsc-action-template_titlelandscape.svgz create mode 100644 kpresenter/templates/common_icon/crsc-action-template_titleportrait.svgz create mode 100644 kpresenter/templates/common_icon/crsc-action-template_twocolumnlandscape.svgz create mode 100644 kpresenter/templates/common_icon/crsc-action-template_twocolumnportrait.svgz create mode 100644 kpresenter/templates/legal/.directory create mode 100644 kpresenter/templates/legal/Makefile.am create mode 100644 kpresenter/templates/legal/OneColumnLandscape.kpt create mode 100644 kpresenter/templates/legal/OneColumnPortrait.kpt create mode 100644 kpresenter/templates/legal/TitleLandscape.kpt create mode 100644 kpresenter/templates/legal/TitlePortrait.kpt create mode 100644 kpresenter/templates/legal/TwoColumnLandscape.kpt create mode 100644 kpresenter/templates/legal/TwoColumnPortrait.kpt create mode 100644 kpresenter/templates/legal/emptyLandscape.kpt create mode 100644 kpresenter/templates/legal/emptyPortrait.kpt create mode 100644 kpresenter/templates/letter/.directory create mode 100644 kpresenter/templates/letter/Makefile.am create mode 100644 kpresenter/templates/letter/OneColumnLandscape.kpt create mode 100644 kpresenter/templates/letter/OneColumnPortrait.kpt create mode 100644 kpresenter/templates/letter/TitleLandscape.kpt create mode 100644 kpresenter/templates/letter/TitlePortrait.kpt create mode 100644 kpresenter/templates/letter/TwoColumnLandscape.kpt create mode 100644 kpresenter/templates/letter/TwoColumnPortrait.kpt create mode 100644 kpresenter/templates/letter/emptyLandscape.kpt create mode 100644 kpresenter/templates/letter/emptyPortrait.kpt create mode 100755 kpresenter/tests/oasis-kpresenter.sh create mode 100644 kpresenter/textpropertyui.ui create mode 100644 kpresenter/toolbar/Makefile.am create mode 100644 kpresenter/toolbar/action-alignobjs.svg create mode 100644 kpresenter/toolbar/action-autoform.svg create mode 100644 kpresenter/toolbar/action-circle.svg create mode 100644 kpresenter/toolbar/action-closed_cubicbeziercurve.svg create mode 100644 kpresenter/toolbar/action-closed_freehand.svg create mode 100644 kpresenter/toolbar/action-closed_polyline.svg create mode 100644 kpresenter/toolbar/action-closed_quadricbeziercurve.svg create mode 100644 kpresenter/toolbar/action-cubicbeziercurve.svg create mode 100644 kpresenter/toolbar/action-effect.png.svg create mode 100644 kpresenter/toolbar/action-effect.svg create mode 100644 kpresenter/toolbar/action-freehand.svg create mode 100644 kpresenter/toolbar/action-line.svg create mode 100644 kpresenter/toolbar/action-penbrush.svg create mode 100644 kpresenter/toolbar/action-pie.svg create mode 100644 kpresenter/toolbar/action-polygon.svg create mode 100644 kpresenter/toolbar/action-polyline.svg create mode 100644 kpresenter/toolbar/action-quadricbeziercurve.svg create mode 100644 kpresenter/toolbar/action-rectangle.svg create mode 100644 kpresenter/toolbar/action-slide_effect.svg create mode 100644 kpresenter/toolbar/cr16-action-alignobjs.png create mode 100644 kpresenter/toolbar/cr16-action-alignobjs.svg create mode 100644 kpresenter/toolbar/cr16-action-autoform.png create mode 100644 kpresenter/toolbar/cr16-action-circle.png create mode 100644 kpresenter/toolbar/cr16-action-closed_cubicbeziercurve.png create mode 100644 kpresenter/toolbar/cr16-action-closed_freehand.png create mode 100644 kpresenter/toolbar/cr16-action-closed_polyline.png create mode 100644 kpresenter/toolbar/cr16-action-closed_quadricbeziercurve.png create mode 100644 kpresenter/toolbar/cr16-action-cubicbeziercurve.png create mode 100644 kpresenter/toolbar/cr16-action-effect.png create mode 100644 kpresenter/toolbar/cr16-action-freehand.png create mode 100644 kpresenter/toolbar/cr16-action-line.png create mode 100644 kpresenter/toolbar/cr16-action-penbrush.png create mode 100644 kpresenter/toolbar/cr16-action-pie.png create mode 100644 kpresenter/toolbar/cr16-action-polygon.png create mode 100644 kpresenter/toolbar/cr16-action-polyline.png create mode 100644 kpresenter/toolbar/cr16-action-quadricbeziercurve.png create mode 100644 kpresenter/toolbar/cr16-action-rectangle.png create mode 100644 kpresenter/toolbar/cr16-action-slide_effect.png create mode 100644 kpresenter/toolbar/cr22-action-alignobjs.png create mode 100644 kpresenter/toolbar/cr22-action-alignobjs.svg create mode 100644 kpresenter/toolbar/cr22-action-arrange.png create mode 100644 kpresenter/toolbar/cr22-action-autoform.png create mode 100644 kpresenter/toolbar/cr22-action-cakes.png create mode 100644 kpresenter/toolbar/cr22-action-cakes3d.png create mode 100644 kpresenter/toolbar/cr22-action-circle.png create mode 100644 kpresenter/toolbar/cr22-action-closed_cubicbeziercurve.png create mode 100644 kpresenter/toolbar/cr22-action-closed_freehand.png create mode 100644 kpresenter/toolbar/cr22-action-closed_polyline.png create mode 100644 kpresenter/toolbar/cr22-action-closed_quadricbeziercurve.png create mode 100644 kpresenter/toolbar/cr22-action-cubicbeziercurve.png create mode 100644 kpresenter/toolbar/cr22-action-edit_picture.png create mode 100644 kpresenter/toolbar/cr22-action-edit_pie.png create mode 100644 kpresenter/toolbar/cr22-action-edit_polygon.png create mode 100644 kpresenter/toolbar/cr22-action-effect.png create mode 100644 kpresenter/toolbar/cr22-action-freehand.png create mode 100644 kpresenter/toolbar/cr22-action-line.png create mode 100644 kpresenter/toolbar/cr22-action-line_arrow_begin.png create mode 100644 kpresenter/toolbar/cr22-action-line_arrow_end.png create mode 100644 kpresenter/toolbar/cr22-action-line_begin.png create mode 100644 kpresenter/toolbar/cr22-action-line_circle_begin.png create mode 100644 kpresenter/toolbar/cr22-action-line_circle_end.png create mode 100644 kpresenter/toolbar/cr22-action-line_dimension_line_begin.png create mode 100644 kpresenter/toolbar/cr22-action-line_dimension_line_end.png create mode 100644 kpresenter/toolbar/cr22-action-line_double_arrow_begin.png create mode 100644 kpresenter/toolbar/cr22-action-line_double_arrow_end.png create mode 100644 kpresenter/toolbar/cr22-action-line_double_line_arrow_begin.png create mode 100644 kpresenter/toolbar/cr22-action-line_double_line_arrow_end.png create mode 100644 kpresenter/toolbar/cr22-action-line_end.png create mode 100644 kpresenter/toolbar/cr22-action-line_line_arrow_begin.png create mode 100644 kpresenter/toolbar/cr22-action-line_line_arrow_end.png create mode 100644 kpresenter/toolbar/cr22-action-line_normal_begin.png create mode 100644 kpresenter/toolbar/cr22-action-line_normal_end.png create mode 100644 kpresenter/toolbar/cr22-action-line_rect_begin.png create mode 100644 kpresenter/toolbar/cr22-action-line_rect_end.png create mode 100644 kpresenter/toolbar/cr22-action-mini_autoform.png create mode 100644 kpresenter/toolbar/cr22-action-mini_circle.png create mode 100644 kpresenter/toolbar/cr22-action-mini_clipart.png create mode 100644 kpresenter/toolbar/cr22-action-mini_line.png create mode 100644 kpresenter/toolbar/cr22-action-mini_pie.png create mode 100644 kpresenter/toolbar/cr22-action-mini_polygon.png create mode 100644 kpresenter/toolbar/cr22-action-mini_rect.png create mode 100644 kpresenter/toolbar/cr22-action-pen_style.png create mode 100644 kpresenter/toolbar/cr22-action-pen_style_dash.png create mode 100644 kpresenter/toolbar/cr22-action-pen_style_dashdot.png create mode 100644 kpresenter/toolbar/cr22-action-pen_style_dashdotdot.png create mode 100644 kpresenter/toolbar/cr22-action-pen_style_dot.png create mode 100644 kpresenter/toolbar/cr22-action-pen_style_nopen.png create mode 100644 kpresenter/toolbar/cr22-action-pen_style_solid.png create mode 100644 kpresenter/toolbar/cr22-action-pen_width.png create mode 100644 kpresenter/toolbar/cr22-action-pen_width1.png create mode 100644 kpresenter/toolbar/cr22-action-pen_width10.png create mode 100644 kpresenter/toolbar/cr22-action-pen_width2.png create mode 100644 kpresenter/toolbar/cr22-action-pen_width3.png create mode 100644 kpresenter/toolbar/cr22-action-pen_width4.png create mode 100644 kpresenter/toolbar/cr22-action-pen_width5.png create mode 100644 kpresenter/toolbar/cr22-action-pen_width6.png create mode 100644 kpresenter/toolbar/cr22-action-pen_width7.png create mode 100644 kpresenter/toolbar/cr22-action-pen_width8.png create mode 100644 kpresenter/toolbar/cr22-action-pen_width9.png create mode 100644 kpresenter/toolbar/cr22-action-penbrush.png create mode 100644 kpresenter/toolbar/cr22-action-pgnum.png create mode 100644 kpresenter/toolbar/cr22-action-pie.png create mode 100644 kpresenter/toolbar/cr22-action-polygon.png create mode 100644 kpresenter/toolbar/cr22-action-polyline.png create mode 100644 kpresenter/toolbar/cr22-action-quadricbeziercurve.png create mode 100644 kpresenter/toolbar/cr22-action-rectangle.png create mode 100644 kpresenter/toolbar/cr22-action-slide_effect.png create mode 100644 kpresenter/toolbar/cr22-action-webpres.png create mode 100644 kpresenter/toolbar/cr32-action-alignobjs.png create mode 100644 kpresenter/toolbar/cr32-action-autoform.png create mode 100644 kpresenter/toolbar/cr32-action-circle.png create mode 100644 kpresenter/toolbar/cr32-action-closed_cubicbeziercurve.png create mode 100644 kpresenter/toolbar/cr32-action-closed_freehand.png create mode 100644 kpresenter/toolbar/cr32-action-closed_polyline.png create mode 100644 kpresenter/toolbar/cr32-action-closed_quadricbeziercurve.png create mode 100644 kpresenter/toolbar/cr32-action-cubicbeziercurve.png create mode 100644 kpresenter/toolbar/cr32-action-effect.png create mode 100644 kpresenter/toolbar/cr32-action-freehand.png create mode 100644 kpresenter/toolbar/cr32-action-line.png create mode 100644 kpresenter/toolbar/cr32-action-penbrush.png create mode 100644 kpresenter/toolbar/cr32-action-pie.png create mode 100644 kpresenter/toolbar/cr32-action-polygon.png create mode 100644 kpresenter/toolbar/cr32-action-polyline.png create mode 100644 kpresenter/toolbar/cr32-action-quadricbeziercurve.png create mode 100644 kpresenter/toolbar/cr32-action-rectangle.png create mode 100644 kpresenter/toolbar/cr32-action-slide_effect.png create mode 100644 kpresenter/toolbar/cr48-action-alignobjs.png create mode 100644 kpresenter/toolbar/cr48-action-autoform.png create mode 100644 kpresenter/toolbar/cr48-action-circle.png create mode 100644 kpresenter/toolbar/cr48-action-closed_cubicbeziercurve.png create mode 100644 kpresenter/toolbar/cr48-action-closed_freehand.png create mode 100644 kpresenter/toolbar/cr48-action-closed_polyline.png create mode 100644 kpresenter/toolbar/cr48-action-closed_quadricbeziercurve.png create mode 100644 kpresenter/toolbar/cr48-action-cubicbeziercurve.png create mode 100644 kpresenter/toolbar/cr48-action-effect.png create mode 100644 kpresenter/toolbar/cr48-action-freehand.png create mode 100644 kpresenter/toolbar/cr48-action-line.png create mode 100644 kpresenter/toolbar/cr48-action-penbrush.png create mode 100644 kpresenter/toolbar/cr48-action-pie.png create mode 100644 kpresenter/toolbar/cr48-action-polygon.png create mode 100644 kpresenter/toolbar/cr48-action-polyline.png create mode 100644 kpresenter/toolbar/cr48-action-quadricbeziercurve.png create mode 100644 kpresenter/toolbar/cr48-action-rectangle.png create mode 100644 kpresenter/toolbar/cr48-action-slide_effect.png (limited to 'kpresenter') diff --git a/kpresenter/AUTHORS b/kpresenter/AUTHORS new file mode 100644 index 00000000..f7e6b75d --- /dev/null +++ b/kpresenter/AUTHORS @@ -0,0 +1,9 @@ +Laurent Montel (official maintainer) +Werner Trobin +David Faure +Toshitaka Fujioka +Lukáš Tinkl +Thorsten Zachmann +Ariya Hidayat +Percy Leonhardt +Thomas Zander diff --git a/kpresenter/CHANGES b/kpresenter/CHANGES new file mode 100644 index 00000000..651081cf --- /dev/null +++ b/kpresenter/CHANGES @@ -0,0 +1,282 @@ +Changes after KPresenter 1.4 +============================ +Fixes: +- Fixed Bug 47825 object appeared on the wrong page after save/open in kpr format +- Fixed Bug 118825: Property altering actions are not enabled correctly + +Changes: +- Added auto guidelines +- Now we can or not display object from master page +- Draw objects of the master slide behind the objects of the current slide. + +Changes after KPresenter 1.3 +============================ +Fixes: +- Fixed undo of delete and group command +- Fixed possible crash in presentation mode if not all slides are shown +- Fixed take tmp objects for redrawing in effect from the correct page +- Fixed show the duration for the correct page if not all slides are shown +- Fixed crash in infinite loop presentation mode when first slide is not shown +- Fixed redrawing of lines in drawing mode in case of a repaint event +- Fixed aligning of rotated lines and line with pen.width() > 1 +- Fixed that the width/height of an rotated object could be negative +- Fixed copy and paste when one pic is in the copied objects +- Fixed crash in history of group/ungroup commands +- Ignore sticky objects when duplicating a page +- Fixed Object Effects are not correctly done (#64384) +- Fixed drawing of rect with round corners when zoomed and gradient filling +- Fixed no alpha channel set on mirrored pictures +- Fixed objects placed on wrong page after saving and loading in kpr file format +- Fixed picture not updated when only depth is changed +- Fixed saving of document type for webpresentations + +Changes: +- Flip now works as in Gimp. Horizontal flip flips on y-axis + vertical filp on x-axis +- Group objects: The grouped object is now in the z-order of the upperst + object grouped and no longer on the top. +- Ungroup object: The objects are now in the z-order where the group object + was and no longer on top. +- If a page is shown more than once during a presentation add the time for + the duration instead of showing only the last duration. +- Use kspell2 +- Now PresSpeed is into each page +- Now PageUp/PageDown during presentation go to beginning of the next/previous slide +- Each object effect can have it's own speed now +- Copy between kword/kpresenter +- Now we can configure header/footer by page +- Configure Custom Slide Show +- Add statistic variable + +Changes after KPresenter 1.3 RC1 +================================ +- during a presentation variables on the sticky page were not updated (#67515) + + +Changes after KPresenter 1.3 beta 4 +=================================== +Fixes: +- Fixed When resizing a frame it does not snap to the grid (#63032) +- Fixed after resize/undo size of object is not the same +- Fixed after move/undo position of object is not the same +- Fixed resizing of poly line objects +- Fixed after reload of some objects moved up a little bit +- Fixed moving with key left used y grid +- Fixed header/footer moved in undo + +Changes after KPresenter 1.3 beta 3 +=================================== +Fixes: +- Fixed cursor not blinking in some cases +- Fixed "blinking cursor erases formatting characters" bug +- "Adjust object to contents" works as intended now +- Purpose of the 'Notebar' is unknown (#63037) +- kpresenter crashed when I tried to insert the variable + "section title" (#61735) +- large footer from kpresenter 1.2.1 will crash kpresenter + (#61449) +- embedded spreadsheet (table button) appears at wrong size + (#58498) +- embedded kspread object displayed with wrong size (#33233) +- KPresenter hangs when inserted text wraps to newline + (#56946) +- layer lowering is incorrect (#53277) +- resize handles deceptive when zoomed out (#61602) +- fixed painting garbage at a side of the screen in the presentation mode (on + weird DPIs) + +Changes after KPresenter 1.3 beta 2 +=================================== +Fixes: +- KPR 'forgets' solid line attribute of text frames (#61343) +- fix pasting text objects screwing UTF-8 text +- snap to Grid function aligns relatively, not absolutely (#56181) +- when cutting&pasting a vertically centred text frame, + the vertical position changes (#61330) + +Changes: +- grid, snap to grid are on now by default, with a finer step of 5mm + (#60011 and #60013) + +Changes after KPresenter 1.3 beta 1 +=================================== +Fixes: +- fixed loading of old documents with invalid paragraph indents +- paste image gives tiny initial object (#59058) +- setting the font size in the toolbar doesn't work (#39786) +- objects disappears on the rightside of a dinA0 presentation (#37370) +- large unwanted offset in print preview and printing (#56123) + +New features: +- flip groups horizontally/vertically (#45561) + + +Changes after KPresenter 1.2 +============================ +- Add "add to bookmark" feature +- Add font properties : change relative font size when we sub/super script font +- Add support to add offset from baseline +- Now koinsertlink use 'recent document' +- Add support to insert cursor directly +- Add autocorrection : "Capitalize name of days" +- Added support for global language +- Use new kospell API +- Added support for naming objects +- Added flipping support for most objects (not yet for text autoform and kpart) + +Visual stuff: +- objects use "forbidden" cursor when they're protected (new) +- display an "End of presentation"-slide at end of presentation; configurable + (new) +- transition effect dialog with preview (new) + +Text boxes: +- can spellcheck in selection only (new) +- shadow is a text property now (bugfix) +- link manipulation (add/copy/remove) (new) +- access to spellcheck result via context menu +- text formats now include language information (new) +- new line spacing types: at least / exactly / multiple of (new) +- new font attributes: small caps, uppercase, lowercase (new) +- new underline and strikethru type: word by word + +Images: +- properly draw images with alpha channels (bugfix) +- better loading of background pictures; especially for remote files (new) + +Variables: +- created/modified/printed document date (bug #24242) +- added time/date variable offset (new) +- added new variables: Next page number, Previous page number (new) + +Configurability: +- whether and where to create backup files (new) +- path to pictures (new) +- personal dictionary (new) +- list of ignored words when spellchecking (new) +- go with a per-slide default when inserting a new one (wish #22629) +- printing of slide notes (wish #56120) + +Misc: +- web presentation: better HTML generation, usability improvement of the wizard (new) +- copy/paste image/embedded objects between different instances (bugfix) +- comment text can be copied now (bugfix) +- undo/redo shows history of commands (new) + + +Changes between KPresenter-1.2-RC1 and KPresenter-1.2 +===================================================== +Bugfixes: +- Fix undo/redo move object. +- Fix #45966 kpresenter refuses to update image with same name +- Fix #45991: problems w.r.t. font color and bullets +- Fix mouse move event + vertical alignment +- Fix resize to height : Don't create command when it's not necessary. +- Fix availableHeight + vertical alignment +- Fix save variable. +- Fix recalc page number + sticky object +- Fix draw gradient + rectangle object +- Fix presentation mode : Don't draw grid and helpline in this mode +- Fix update ruler tabs when we switch between two text object +- Fix move up/down style +- Fix restore style shortcut when we remove/rename/add style + + +Changes between KPresenter-1.2-beta2 and KPresenter-1.2-RC1 +=========================================================== +New: +- Like all of KOffice: a readonly GUI for embedding into Konqueror +- More DCOP calls + +Bugfixes: +- Fix resize text object +- Fix webpresentation => display real variable value +- Fix autocorrection (crash/change language etc...) +- Fix update sidebar +- Fix key event when text object is protect content. +- Fix group object : allow to change text object attribute, fix load close object etc... +- Width and height spin boxes in the style dialog are now coupled when + keep aspect ratio is in effect. +- Fix unselect object : use right button + shift +- Fixed rounded rectangle + gradient +- Fixed saving shadowed objects (when only their color differed from + the defaults) +- Restored a lot of backwards compatibility (formatting, bullets, numbers, + whitespace handling etc.) +- Speedup in displaying of the pixmap objects +- Fixed the drawing of the background (no gradient when background is + an image or a clipart) + +Crashes: +- Fixed crash when we close kword and "special char dialogbox" is not closed +- Fixed several memory leaks +- Fixed crash when we cancel insert time/date variable. +- Fixed crash when we duplicate page and there was an embedded document. +- Fixed crash when we split view and we try to open menu when factory() is null +- Fixed crash when we didn't select a slide and try to launch presentation + + +KPresenter 1.2beta1 -> 1.2 beta 2 +--------------------------------- +- Add support for flip polyline object +- Add support for "protect size and postion" +- When we create a line object and we press shift we draw horizontal/vertical +- Added support for dnd between text objects +- Added support for keeping ratio of objects +- Added dialog for duplicatiing objects +- Add "Apply AutoFormat" +- Add new type of begin/end line (line arrow, Dimension line... ) +- Add support for find/replace with format +- Now we can create directly a style from a selection +- Add support for protect content of text object +- Now we can close polyline object +- Fix save/load variable +- Use tripleState in styledia +- Removed settings-toolbar and corresponding menu-entries +- Added tab to properties-dialog according to selected object +- Moved default-settings for rectangles, pies and polygons to + 'Settings' -> 'Configure KPresenter' +- Now we can change grid color +- Add option to "Snap to grid" +- Add support for text object margins +- Improve font style +- New transition effects: Strips +- Add support for vertical alignment +- Now we can change tab stop value +- Now we can save picture from file to disk +- Add Closed Line Object (freehand, polyline, quadric bezier curve, cubic bezier curve) +- Add New Cursor for rotate tool and freehand tool +- Merged actions for lines, shapes and arrangement of objects into + an appropriate drop-down menu +- Add support for autocorrect with format +- Add option "Allow cursor in text object protected content" +- Add import text style support +- Add save page background image on disk +- Add display field code (for variable) +- We can change autoformat language + + +Changes after KPresenter 1.1 +============================ +- Port to kotext +- New effect : kpresenter can play sounds +- Thumbnail mode for the sidebar +- Add notebar +- Add a real statusbar +- Add New Tool : freehand, polyline, quadric bezier curve, cubic bezier curve, convex/concave polygon +- Add zoom support +- Improve undo/redo (now we can undo/redo "insert new page"/"delete page"/"paste page"/"Duplicate page") +- Now kpresenter has real page +- Limit position/size object to page +- spell checking/search/find works on all page +- Add "Show Presentation Duration" +- Add dcop interface : now we can insert text, change text format, etc... +- Add support for style +- Add support for background spell checking +- Add support for manual completion (use CTRL + E ) +- Add Help line +- New transition effect: Blinds, Box In/Out, Checkboard, Cover, Uncover, Dissolve, Random,... +- Add grid support +- Add Help Point +- Add support to change zoom with mouse (zoom selected area) +- Add Configure Picture Dialog diff --git a/kpresenter/KPrAboutData.h b/kpresenter/KPrAboutData.h new file mode 100644 index 00000000..c576b9d5 --- /dev/null +++ b/kpresenter/KPrAboutData.h @@ -0,0 +1,49 @@ +/* This file is part of the KDE project + Copyright (C) 1998, 1999 Reginald Stadlbauer + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#ifndef KPRESENTER_ABOUTDATA +#define KPRESENTER_ABOUTDATA + +#include +#include +#include + +static const char* description=I18N_NOOP("KOffice Presentation Tool"); +static const char* version=KOFFICE_VERSION_STRING; + +KAboutData * newKPresenterAboutData() +{ + KAboutData * aboutData=new KAboutData( "kpresenter", I18N_NOOP("KPresenter"), + version, description, KAboutData::License_LGPL, + I18N_NOOP("(c) 1998-2006, The KPresenter Team"), 0, + "http://www.koffice.org/kpresenter/"); + aboutData->addAuthor("Laurent Montel", I18N_NOOP("current maintainer"), "montel@kde.org"); + aboutData->addAuthor("Werner Trobin", 0, "trobin@kde.org"); + aboutData->addAuthor("David Faure", 0, "faure@kde.org"); + aboutData->addAuthor("Toshitaka Fujioka", 0, "fujioka@kde.org"); + aboutData->addAuthor("Lukáš Tinkl", 0, "lukas@kde.org"); + aboutData->addAuthor("Thorsten Zachmann", 0, "t.zachmann@zagge.de"); + aboutData->addAuthor("Ariya Hidayat", 0, "ariya@kde.org"); + aboutData->addAuthor("Percy Leonhardt", 0, "percy@eris23.de"); + aboutData->addAuthor("Thomas Zander", 0, ""); + aboutData->addAuthor("Reginald Stadlbauer",I18N_NOOP("original author"), "reggie@kde.org"); + return aboutData; +} + +#endif diff --git a/kpresenter/KPrAutoFormObjectIface.cpp b/kpresenter/KPrAutoFormObjectIface.cpp new file mode 100644 index 00000000..ee9500b0 --- /dev/null +++ b/kpresenter/KPrAutoFormObjectIface.cpp @@ -0,0 +1,54 @@ +// -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*- +/* This file is part of the KDE project + Copyright (C) 2002 Laurent MONTEL + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#include "KPrAutoFormObjectIface.h" +#include "KPrAutoformObject.h" +#include "KPrUtils.h" +#include "KPrObject.h" +#include + +#include +#include + +KPrAutoFormObjectIface::KPrAutoFormObjectIface( KPrAutoformObject *_obj ) + : KPrObject2DIface(_obj) +{ + obj = _obj; +} + +QString KPrAutoFormObjectIface::fileName() const +{ + return obj->getFileName(); +} + +void KPrAutoFormObjectIface::setFileName( const QString &_filename ) +{ + obj->setFileName(_filename); +} + +void KPrAutoFormObjectIface::setLineBegin( const QString & type) +{ + obj->setLineBegin(lineEndBeginFromString( type )); +} + +void KPrAutoFormObjectIface::setLineEnd( const QString & type) +{ + obj->setLineEnd(lineEndBeginFromString( type )); +} diff --git a/kpresenter/KPrAutoFormObjectIface.h b/kpresenter/KPrAutoFormObjectIface.h new file mode 100644 index 00000000..685b0c5f --- /dev/null +++ b/kpresenter/KPrAutoFormObjectIface.h @@ -0,0 +1,48 @@ +// -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*- +/* This file is part of the KDE project + Copyright (C) 2002 Laurent MONTEL + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#ifndef KPAUTOFORM_OBJECT_IFACE_H +#define KPAUTOFORM_OBJECT_IFACE_H + +#include +#include +#include "KPrObject2DIface.h" +#include + +class KPrAutoformObject; + +class KPrAutoFormObjectIface : public KPrObject2DIface +{ + K_DCOP +public: + KPrAutoFormObjectIface( KPrAutoformObject *obj_ ); + +k_dcop: + QString fileName() const; + void setFileName( const QString &_filename ); + + virtual void setLineBegin( const QString & ); + virtual void setLineEnd( const QString & ); + +private: + KPrAutoformObject *obj; +}; + +#endif diff --git a/kpresenter/KPrAutoformObject.cpp b/kpresenter/KPrAutoformObject.cpp new file mode 100644 index 00000000..c5d7028d --- /dev/null +++ b/kpresenter/KPrAutoformObject.cpp @@ -0,0 +1,378 @@ +// -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*- +/* This file is part of the KDE project + Copyright (C) 1998, 1999 Reginald Stadlbauer + Copyright (C) 2005-2006 Thorsten Zachmann + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#include "KPrAutoformObject.h" +#include "KPrAutoFormObjectIface.h" +#include "KPrUtils.h" +#include "KPrGradient.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +using namespace std; + +KPrAutoformObject::KPrAutoformObject() +: KPr2DObject() +, KPrStartEndLine( L_NORMAL, L_NORMAL ) +, atfInterp() +{ +} + +KPrAutoformObject::KPrAutoformObject( const KoPen & _pen, const QBrush &_brush, const QString & _filename, + LineEnd _lineBegin, LineEnd _lineEnd, + FillType _fillType, const QColor &_gColor1, + const QColor &_gColor2, BCType _gType, + bool _unbalanced, int _xfactor, int _yfactor) +: KPr2DObject( _pen, _brush, _fillType, _gColor1, _gColor2, _gType, _unbalanced, _xfactor, _yfactor ) +, KPrStartEndLine( _lineBegin, _lineEnd ) +, filename( _filename ), atfInterp() +{ + atfInterp.load( filename ); +} + +KPrAutoformObject &KPrAutoformObject::operator=( const KPrAutoformObject & ) +{ + return *this; +} + +DCOPObject* KPrAutoformObject::dcopObject() +{ + if ( !dcop ) + dcop = new KPrAutoFormObjectIface( this ); + return dcop; +} + +void KPrAutoformObject::setFileName( const QString & _filename ) +{ + filename = _filename; + atfInterp.load( filename ); +} + + +bool KPrAutoformObject::saveOasisObjectAttributes( KPOasisSaveContext &sc ) const +{ + kdDebug(33001) << "bool KPrAutoformObject::saveOasisObjectAttributes()" << endl; + QSize size( int( ext.width() * 100 ), int( ext.height() * 100 ) ); + + sc.xmlWriter.addAttribute( "svg:viewBox", QString( "0 0 %1 %2" ).arg( size.width() ) + .arg( size.height() ) ); + + QPointArray points = const_cast( atfInterp ).getPointArray( size.width(), size.height() ); + + unsigned int pointCount = points.size(); + unsigned int pos = 0; + bool closed = points.at( 0 ) == points.at( pointCount - 1 ); + + if ( closed ) + --pointCount; + + QString d; + d += QString( "M%1 %2" ).arg( points.at(pos).x() ) + .arg( points.at(pos).y() ); + ++pos; + + while ( pos < pointCount ) + { + d += QString( "L%1 %2" ).arg( points.at( pos ).x() ) + .arg( points.at( pos ).y() ); + ++pos; + } + + if ( closed ) + d += "Z"; + + sc.xmlWriter.addAttribute( "svg:d", d ); + + return true; +} + +void KPrAutoformObject::fillStyle( KoGenStyle& styleObjectAuto, KoGenStyles& mainStyles ) const +{ + kdDebug(33001) << "KPr2DObject::fillStyle" << endl; + KPrShadowObject::fillStyle( styleObjectAuto, mainStyles ); + + QPointArray points = const_cast( atfInterp ).getPointArray( int( ext.width() * 100 ), + int( ext.height() * 100 ) ); + + // if it is a closed object save the background + if ( points.at( 0 ) == points.at( points.size() - 1 ) ) + { + m_brush.saveOasisFillStyle( styleObjectAuto, mainStyles ); + } + else + { + saveOasisMarkerElement( mainStyles, styleObjectAuto ); + } +} + +const char * KPrAutoformObject::getOasisElementName() const +{ + return "draw:path"; +} + +QDomDocumentFragment KPrAutoformObject::save( QDomDocument& doc, double offset ) +{ + QDomDocumentFragment fragment=KPr2DObject::save(doc, offset); + KPrStartEndLine::save( fragment, doc ); + + // The filename contains the absolute path to the autoform. This is + // bad, so we simply remove everything but the last dir and the name. + // e.g. /my/local/path/to/kpresenter/Arrow/.source/Arrow1.atf -> Arrow/.source/Arrow1.atf + QStringList afDirs = KPrFactory::global()->dirs()->resourceDirs("autoforms"); + QValueList::ConstIterator it=afDirs.begin(); + QString str; + for( ; it!=afDirs.end(); ++it) { + if(filename.startsWith(*it)) { + str=filename.mid((*it).length()); + break; + } + } + QDomElement elem=doc.createElement("FILENAME"); + elem.setAttribute("value", str); + fragment.appendChild(elem); + return fragment; +} + +double KPrAutoformObject::load(const QDomElement &element) +{ + double offset=KPr2DObject::load(element); + KPrStartEndLine::load( element ); + QDomElement e=element.namedItem("FILENAME").toElement(); + if(!e.isNull()) { + if(e.hasAttribute("value")) + filename=e.attribute("value"); + // don't crash on invalid files, better insert something + if(filename.isEmpty()) + filename="Connections/.source/Connection1.atf"; + // workaround for a bug in the (very) old file format + if(filename[0]=='/') { + kdDebug(33001) << "rubbish ahead! cleaning up..." << endl; + // remove the leading absolute path (i.e. to create Arrow/Arrow1.atf) + filename=filename.mid(filename.findRev('/', filename.findRev('/')-1)+1); + } + // okay... we changed the file format again and now the autoforms + // are stored in .../kpresenter/autoforms/.source/foo.atf (note: we didn't have .source + // before. Therefore we have to add this dir if it's not already there to make it + // work with old files + if(filename.find(".source")==-1) { + // okay, old file -- add the .source dir + filename=filename.insert(filename.find('/'), "/.source"); + } + filename = locate("autoforms", filename, KPrFactory::global()); + atfInterp.load( filename ); + } + return offset; +} + +void KPrAutoformObject::paint( QPainter* _painter, KoTextZoomHandler *_zoomHandler, + int /* pageNum */, bool drawingShadow, bool drawContour ) +{ + unsigned int pw = 0, pwOrig = 0, px, py; + QPen pen2; + QSize size( _zoomHandler->zoomSize( ext ) ); + + if ( drawContour ) + pen2 = QPen( Qt::black, 1, Qt::DotLine ); + else { + pen2 = pen.zoomedPen( _zoomHandler ); + } + + _painter->setPen( pen2 ); + pwOrig = ( pen2.style() == Qt::NoPen ) ? 1 : pen2.width(); + if ( !drawContour ) + _painter->setBrush( getBrush() ); + + QPointArray pntArray = atfInterp.getPointArray( _zoomHandler->zoomItX( ext.width()), + _zoomHandler->zoomItY( ext.height() ) ); + QPtrList atrLs = atfInterp.getAttribList(); + QPointArray pntArray2( pntArray.size() ); + int ex = _zoomHandler->zoomItX(ext.width()); + int ey = _zoomHandler->zoomItY(ext.height()); + for ( unsigned int i = 0; i < pntArray.size(); i++ ) + { + px = pntArray.at( i ).x(); + py = pntArray.at( i ).y(); + if ( atrLs.at( i )->pwDiv > 0 ) + { + pw = pwOrig / atrLs.at( i )->pwDiv; + px = (int)((double)(ex - pw) / (double)ex * px + pw / 2); + py = (int)((double)(ey - pw) / (double)ey * py + pw / 2); + } + pntArray2.setPoint( i, px, py ); + } + + if ( pntArray2.size() > 0 ) + { + if ( pntArray2.at( 0 ) == pntArray2.at( pntArray2.size() - 1 ) ) + { + if ( drawContour || (drawingShadow || getFillType() == FT_BRUSH || !gradient) ) + _painter->drawPolygon( pntArray2 ); + else + { + if ( angle == 0 || angle==360 ) + { + //int ox = _painter->viewport().x() + static_cast( _painter->worldMatrix().dx() ); + //int oy = _painter->viewport().y() + static_cast( _painter->worldMatrix().dy() ); + + QPointArray pntArray3 = pntArray2.copy(); + _painter->save(); + + QRegion clipregion( pntArray3 ); + + // Intersect with current clipregion (whereas setupClipRegion unites) + if ( _painter->hasClipping() ) + clipregion = _painter->clipRegion(QPainter::CoordPainter).intersect( clipregion ); + + _painter->setClipRegion( clipregion, QPainter::CoordPainter ); + + gradient->setSize( size ); + _painter->drawPixmap( 0, 0, gradient->pixmap() ); + + _painter->restore(); + } + else + { + if ( m_redrawGradientPix || gradient->size() != size ) + { + kdDebug(33001) << "KPrAutoformObject::draw redrawPix" << endl; + gradient->setSize( size ); + m_redrawGradientPix = false; + QRegion clipregion( pntArray2 ); + m_gradientPix.resize ( _zoomHandler->zoomItX(ext.width()),_zoomHandler->zoomItY(ext.height()) ); + m_gradientPix.fill( Qt::white ); + + + QPainter p; + p.begin( &m_gradientPix ); + p.setClipRegion( clipregion , QPainter::CoordPainter); + p.drawPixmap( 0, 0, gradient->pixmap() ); + p.end(); + + m_gradientPix.setMask( m_gradientPix.createHeuristicMask() ); + } + + _painter->drawPixmap( 0, 0, m_gradientPix ); + } + + _painter->setPen( pen2 ); + _painter->setBrush( Qt::NoBrush ); + _painter->drawPolygon( pntArray2 ); + } + } + else + { + KoSize diff1( 0, 0 ), diff2( 0, 0 ); + int _w = int( pen.pointWidth() ); + + if ( lineBegin != L_NORMAL ) + diff1 = getBoundingSize( lineBegin, _w, _zoomHandler ); + + if ( lineEnd != L_NORMAL ) + diff2 = getBoundingSize( lineEnd, _w, _zoomHandler ); + + if ( pntArray.size() > 1 ) + { + if ( lineBegin != L_NORMAL && !drawContour ) + { + QPoint pnt1( pntArray2.at( 0 ) ), pnt2( pntArray2.at( 1 ) ); + QPoint pnt3, pnt4( pntArray.at( 0 ) ); + float _angle = KoPoint::getAngle( KoPoint( pnt1 ), KoPoint( pnt2 ) ); + + switch ( static_cast( _angle ) ) + { + case 0: + { + pnt3.setX( pnt4.x() - (int)diff1.width() / 2 ); + pnt3.setY( pnt1.y() ); + } break; + case 180: + { + pnt3.setX( pnt4.x() + (int)diff1.width() / 2 ); + pnt3.setY( pnt1.y() ); + } break; + case 90: + { + pnt3.setX( pnt1.x() ); + pnt3.setY( pnt4.y() - (int)diff1.width() / 2 ); + } break; + case 270: + { + pnt3.setX( pnt1.x() ); + pnt3.setY( pnt4.y() + (int)diff1.width() / 2 ); + } break; + default: + pnt3 = pnt1; + break; + } + + drawFigure( lineBegin, _painter, _zoomHandler->unzoomPoint( pnt3 ), pen2.color(), _w, _angle, _zoomHandler ); + } + + if ( lineEnd != L_NORMAL && !drawContour ) + { + QPoint pnt1( pntArray2.at( pntArray2.size() - 1 ) ), pnt2( pntArray2.at( pntArray2.size() - 2 ) ); + QPoint pnt3, pnt4( pntArray.at( pntArray.size() - 1 ) ); + float _angle = KoPoint::getAngle( KoPoint( pnt1 ), KoPoint( pnt2 ) ); + + switch ( ( int )_angle ) + { + case 0: + { + pnt3.setX( pnt4.x() - (int)diff2.width() / 2 ); + pnt3.setY( pnt1.y() ); + } break; + case 180: + { + pnt3.setX( pnt4.x() + (int)diff2.width() / 2 ); + pnt3.setY( pnt1.y() ); + } break; + case 90: + { + pnt3.setX( pnt1.x() ); + pnt3.setY( pnt4.y() - (int)diff2.width() / 2 ); + } break; + case 270: + { + pnt3.setX( pnt1.x() ); + pnt3.setY( pnt4.y() + (int)diff2.width() / 2 ); + } break; + default: + pnt3 = pnt1; + break; + } + + drawFigure( lineEnd, _painter, _zoomHandler->unzoomPoint( pnt3 ), pen2.color(), _w, _angle,_zoomHandler ); + } + } + + _painter->setPen( pen2 ); + _painter->drawPolyline( pntArray2 ); + } + } +} diff --git a/kpresenter/KPrAutoformObject.h b/kpresenter/KPrAutoformObject.h new file mode 100644 index 00000000..9963769d --- /dev/null +++ b/kpresenter/KPrAutoformObject.h @@ -0,0 +1,82 @@ +// -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*- +/* This file is part of the KDE project + Copyright (C) 1998, 1999 Reginald Stadlbauer + Copyright (C) 2005 Thorsten Zachmann + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#ifndef kpautoformobject_h +#define kpautoformobject_h + +#include +#include + +#include "KPrObject.h" +#include "global.h" +#include "autoformEdit/ATFInterpreter.h" + +class KPrGradient; +class DCOPObject; + +class KPrAutoformObject : public KPr2DObject, public KPrStartEndLine +{ +public: + KPrAutoformObject(); + KPrAutoformObject( const KoPen & _pen, const QBrush &_brush, const QString &_filename, LineEnd _lineBegin, LineEnd _lineEnd, + FillType _fillType, const QColor &_gColor1, const QColor &_gColor2, BCType _gType, + bool _unbalanced, int _xfactor, int _yfactor); + virtual ~KPrAutoformObject() {} + + KPrAutoformObject &operator=( const KPrAutoformObject & ); + + virtual DCOPObject* dcopObject(); + + virtual void setFileName( const QString &_filename ); + virtual void setLineBegin( LineEnd _lineBegin ) + { lineBegin = _lineBegin; } + virtual void setLineEnd( LineEnd _lineEnd ) + { lineEnd = _lineEnd; } + + virtual ObjType getType() const + { return OT_AUTOFORM; } + virtual QString getTypeString() const + { return i18n("Autoform"); } + + QString getFileName() const + { return filename; } + virtual LineEnd getLineBegin() const + { return lineBegin; } + virtual LineEnd getLineEnd() const + { return lineEnd; } + + virtual QDomDocumentFragment save( QDomDocument& doc,double offset ); + + virtual double load(const QDomElement &element); +protected: + virtual const char * getOasisElementName() const; + virtual bool saveOasisObjectAttributes( KPOasisSaveContext &sc ) const; + virtual void fillStyle( KoGenStyle& styleObjectAuto, KoGenStyles& mainStyles ) const; + + virtual void paint( QPainter *_painter, KoTextZoomHandler *_zoomHandler, + int /* pageNum */, bool drawingShadow, bool drawContour = FALSE ); + + QString filename; + + ATFInterpreter atfInterp; +}; + +#endif diff --git a/kpresenter/KPrBackDia.cpp b/kpresenter/KPrBackDia.cpp new file mode 100644 index 00000000..ebee4263 --- /dev/null +++ b/kpresenter/KPrBackDia.cpp @@ -0,0 +1,420 @@ +// -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*- +/* This file is part of the KDE project + Copyright (C) 1998, 1999 Reginald Stadlbauer + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#include +#include "KPrBackDia.h" +#include "KPrBackground.h" +#include "KPrDocument.h" +#include "KPrPage.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include + +KPrBackPreview::KPrBackPreview( QWidget *parent, KPrPage *page ) + : QFrame( parent ) +{ + setFrameStyle( WinPanel | Sunken ); + back = new KPrBackGround( page ); + setMinimumSize( 300, 200 ); +} + +KPrBackPreview::~KPrBackPreview() +{ + delete back; +} + +void KPrBackPreview::drawContents( QPainter *p ) +{ + QFrame::drawContents( p ); + p->save(); + p->translate( contentsRect().x(), contentsRect().y() ); + back->drawBackground( p, contentsRect().size(), contentsRect(), false ); + p->restore(); +} + +KPrBackDialog::KPrBackDialog( QWidget* parent, const char* name, + BackType backType, const QColor &backColor1, + const QColor &backColor2, BCType _bcType, + const KoPicture &backPic, + BackView backPicView, bool _unbalanced, + int _xfactor, int _yfactor, KPrPage *_page ) + : KDialogBase( parent, name, true, "",KDialogBase::Ok|KDialogBase::Apply|KDialogBase::Cancel| + KDialogBase::User1|KDialogBase::User2 ), + m_useMasterBackground( 0 ), m_picture(backPic),m_oldpicture(backPic), m_page( _page ) +{ + lockUpdate = true; + + oldUseMasterBackground=m_page->useMasterBackground(); + oldBackType=backType; + oldBackColor1=backColor1; + oldBackColor2 = backColor2; + oldBcType= _bcType; + oldBackPicView=backPicView; + oldUnbalanced=_unbalanced; + oldXFactor=_xfactor; + oldYFactor=_yfactor; + + QWidget *page = new QWidget( this ); + setMainWidget(page); + QVBoxLayout *layout = new QVBoxLayout( page, 0, spacingHint() ); + + + QHBoxLayout *hbox = new QHBoxLayout( layout ); + hbox->setSpacing( KDialog::spacingHint() ); + QVBoxLayout *vbox = new QVBoxLayout( hbox ); + vbox->setSpacing( KDialog::spacingHint() ); + + if ( !m_page->isMasterPage() ) + { + m_useMasterBackground = new QCheckBox( i18n( "Use slide master background" ), page ); + connect( m_useMasterBackground, SIGNAL( clicked() ), + this, SLOT( updateConfiguration() ) ); + m_useMasterBackground->setChecked( m_page->useMasterBackground() ); + vbox->addWidget( m_useMasterBackground ); + } + vbox->addWidget( new QLabel( i18n( "Background type:" ), page ) ); + + backCombo = new QComboBox( false, page ); + backCombo->insertItem( i18n( "Color/Gradient" ) ); + backCombo->insertItem( i18n( "Picture" ) ); + backCombo->setCurrentItem( (int)backType ); + connect( backCombo, SIGNAL( activated( int ) ), + this, SLOT( changeComboText(int) ) ); + + vbox->addWidget( backCombo ); + + tabWidget = new QTabWidget( page ); + vbox->addWidget( tabWidget ); + + // color/gradient tab --------------- + + QVBox *colorTab = new QVBox( tabWidget ); + colorTab->setSpacing( KDialog::spacingHint() ); + colorTab->setMargin( 5 ); + + cType = new QComboBox( false, colorTab ); + cType->insertItem( i18n( "Plain" ) ); + cType->insertItem( i18n( "Vertical Gradient" ) ); + cType->insertItem( i18n( "Horizontal Gradient" ) ); + cType->insertItem( i18n( "Diagonal Gradient 1" ) ); + cType->insertItem( i18n( "Diagonal Gradient 2" ) ); + cType->insertItem( i18n( "Circle Gradient" ) ); + cType->insertItem( i18n( "Rectangle Gradient" ) ); + cType->insertItem( i18n( "PipeCross Gradient" ) ); + cType->insertItem( i18n( "Pyramid Gradient" ) ); + cType->setCurrentItem( _bcType ); + connect( cType, SIGNAL( activated( int ) ), + this, SLOT( updateConfiguration() ) ); + + color1Choose = new KColorButton( backColor1, colorTab ); + connect( color1Choose, SIGNAL( changed( const QColor& ) ), + this, SLOT( updateConfiguration() ) ); + + color2Choose = new KColorButton( backColor2, colorTab ); + connect( color2Choose, SIGNAL( changed( const QColor& ) ), + this, SLOT( updateConfiguration() ) ); + + unbalanced = new QCheckBox( i18n( "Unbalanced" ), colorTab ); + connect( unbalanced, SIGNAL( clicked() ), + this, SLOT( updateConfiguration() ) ); + unbalanced->setChecked( _unbalanced ); + + labXFactor =new QLabel( i18n( "X-factor:" ), colorTab ); + + xfactor = new QSlider( -200, 200, 1, 100, QSlider::Horizontal, colorTab ); + connect( xfactor, SIGNAL( valueChanged( int ) ), + this, SLOT( updateConfiguration() ) ); + xfactor->setValue( _xfactor ); + + labYFactor=new QLabel( i18n( "Y-factor:" ), colorTab ); + + yfactor = new QSlider( -200, 200, 1, 100, QSlider::Horizontal, colorTab ); + connect( yfactor, SIGNAL( valueChanged( int ) ), + this, SLOT( updateConfiguration() ) ); + yfactor->setValue( _yfactor ); + + tabWidget->addTab( colorTab, i18n( "Color/Gradient" ) ); + + // picture tab --------------------- + + QVBox *picTab = new QVBox( tabWidget ); + picTab->setSpacing( KDialog::spacingHint() ); + picTab->setMargin( 5 ); + + QLabel *l = new QLabel( i18n( "View mode:" ), picTab ); + l->setFixedHeight( l->sizeHint().height() ); + + picView = new QComboBox( false, picTab ); + picView->insertItem( i18n( "Scaled" ) ); + picView->insertItem( i18n( "Centered" ) ); + picView->insertItem( i18n( "Tiled" ) ); + picView->setCurrentItem( (int)backPicView ); + connect( picView, SIGNAL( activated( int ) ), + this, SLOT( updateConfiguration() ) ); + + picChooseLabel = new QLabel( i18n("&Location:"), picTab ); + picChooseLabel->setFixedHeight( picChooseLabel->sizeHint().height() ); + + picChoose = new KURLRequester( picTab, "picChoose" ); + picChoose->setFixedHeight( picChoose->sizeHint().height() ); + picChoose->setMode( KFile::ExistingOnly ); + connect( picChoose, SIGNAL( openFileDialog( KURLRequester * ) ), + SLOT( aboutToSelectPic() ) ); + connect( picChoose, SIGNAL( urlSelected( const QString & ) ), + SLOT( afterSelectPic( const QString & ) ) ); + + picChooseLabel->setBuddy( picChoose ); + + (void)new QWidget( picTab ); + + tabWidget->addTab( picTab, i18n( "Picture" ) ); + + // ------------------------ preview + + preview = new KPrBackPreview( page, m_page ); + hbox->addWidget( preview ); + + // ------------------------ buttons + + connect( this, SIGNAL( okClicked() ), + this, SLOT( Ok() ) ); + connect( this, SIGNAL( applyClicked() ), + this, SLOT( Apply() ) ); + connect( this, SIGNAL( user1Clicked() ), + this, SLOT( ApplyGlobal() ) ); + + connect( this, SIGNAL( user2Clicked() ), + this, SLOT( slotReset() ) ); + + connect( this, SIGNAL( okClicked() ), + this, SLOT( accept() ) ); + setButtonText(KDialogBase::User1,i18n( "Apply &Global" )); + setButtonText(KDialogBase::User2,i18n( "&Reset" )); + picChanged = true; + lockUpdate = false; + updateConfiguration(); +} + +void KPrBackDialog::slotReset() +{ + if ( m_useMasterBackground ) + m_useMasterBackground->setChecked( oldUseMasterBackground ); + backCombo->setCurrentItem( (int)oldBackType ); + color1Choose->setColor( oldBackColor1 ); + color2Choose->setColor( oldBackColor2 ); + cType->setCurrentItem( oldBcType ); + + m_picture=m_oldpicture; + + if ( !m_picture.isNull() ) + picChoose->setURL( m_picture.getKey().filename() ); + else + picChoose->setURL( QString::null ); + + picView->setCurrentItem( (int)oldBackPicView ); + unbalanced->setChecked( oldUnbalanced ); + xfactor->setValue( oldXFactor ); + yfactor->setValue( oldYFactor ); + updateConfiguration(); +} + +void KPrBackDialog::changeComboText(int _p) +{ + if(_p!=tabWidget->currentPageIndex ()) + tabWidget->setCurrentPage(_p); + updateConfiguration(); +} + +void KPrBackDialog::showEvent( QShowEvent *e ) +{ + QDialog::showEvent( e ); + lockUpdate = false; + updateConfiguration(); +} + +void KPrBackDialog::updateConfiguration() +{ + if ( lockUpdate ) + return; + + if ( m_useMasterBackground ) + { + tabWidget->setEnabled( !m_useMasterBackground->isChecked() ); + backCombo->setEnabled( !m_useMasterBackground->isChecked() ); + } + else + { + tabWidget->setEnabled( true ); + backCombo->setEnabled( true ); + } + if ( getBackColorType() == BCT_PLAIN ) + { + unbalanced->setEnabled( false ); + xfactor->setEnabled( false ); + yfactor->setEnabled( false ); + labXFactor->setEnabled(false); + labYFactor->setEnabled(false); + color2Choose->setEnabled( false ); + } + else + { + unbalanced->setEnabled( true ); + if ( unbalanced->isChecked() ) + { + xfactor->setEnabled( true ); + yfactor->setEnabled( true ); + labXFactor->setEnabled(true); + labYFactor->setEnabled(true); + } + else + { + xfactor->setEnabled( false ); + yfactor->setEnabled( false ); + labXFactor->setEnabled(false); + labYFactor->setEnabled(false); + } + color2Choose->setEnabled( true ); + } + + if ( m_useMasterBackground && m_useMasterBackground->isChecked() ) + { + kdDebug(33001) << "set backgound to master" << endl; + preview->backGround()->setBackGround( m_page->masterPage()->background()->getBackGround() ); + preview->repaint( true ); + } + else + { + picChanged = (getBackType() == BT_PICTURE); + preview->backGround()->setBackType( getBackType() ); + preview->backGround()->setBackView( getBackView() ); + preview->backGround()->setBackColor1( getBackColor1() ); + preview->backGround()->setBackColor2( getBackColor2() ); + preview->backGround()->setBackColorType( getBackColorType() ); + preview->backGround()->setBackUnbalanced( getBackUnbalanced() ); + preview->backGround()->setBackXFactor( getBackXFactor() ); + preview->backGround()->setBackYFactor( getBackYFactor() ); + if ( !m_picture.isNull() && picChanged ) + preview->backGround()->setBackPicture( m_picture ); + preview->backGround()->setBackType( getBackType() ); + if ( preview->isVisible() && isVisible() ) { + preview->backGround()->reload(); // ### TODO: instead of reloading, load or remove the picture correctly. + preview->repaint( true ); + } + + picChanged = false; + } +} + +BackType KPrBackDialog::getBackType() const +{ + return (BackType)backCombo->currentItem(); +} + +BackView KPrBackDialog::getBackView() const +{ + return (BackView)picView->currentItem(); +} + +QColor KPrBackDialog::getBackColor1() const +{ + return color1Choose->color(); +} + +QColor KPrBackDialog::getBackColor2() const +{ + return color2Choose->color(); +} + +BCType KPrBackDialog::getBackColorType() const +{ + return (BCType)cType->currentItem(); +} + +bool KPrBackDialog::getBackUnbalanced() const +{ + return unbalanced->isChecked(); +} + +int KPrBackDialog::getBackXFactor() const +{ + return xfactor->value(); +} + +int KPrBackDialog::getBackYFactor() const +{ + return yfactor->value(); +} + +KPrBackGround::Settings KPrBackDialog::getBackGround() const +{ + return KPrBackGround::Settings( getBackType(), getBackColor1(), + getBackColor2(), getBackColorType(), + getBackUnbalanced(), getBackXFactor(), + getBackYFactor(), getBackPicture().getKey(), + getBackView() ); +} + +bool KPrBackDialog::useMasterBackground() const +{ + return m_useMasterBackground ? m_useMasterBackground->isChecked():false; +} + +void KPrBackDialog::aboutToSelectPic() +{ + QStringList mimetypes; + mimetypes += KImageIO::mimeTypes( KImageIO::Reading ); + mimetypes += KoPictureFilePreview::clipartMimeTypes(); + + picChoose->fileDialog()->setMimeFilter( mimetypes ); + picChoose->fileDialog()->setPreviewWidget( new KoPictureFilePreview( picChoose->fileDialog() ) ); +} + +void KPrBackDialog::afterSelectPic( const QString &url ) +{ + KoPicture picture; + picture.setKeyAndDownloadPicture(url, tabWidget); + + if ( picture.isNull() ) + return; + + backCombo->setCurrentItem( 1 ); + m_picture=picture; + picChanged = true; + updateConfiguration(); +} + +#include "KPrGradient.h" +#include "KPrBackDia.moc" diff --git a/kpresenter/KPrBackDia.h b/kpresenter/KPrBackDia.h new file mode 100644 index 00000000..433edb5e --- /dev/null +++ b/kpresenter/KPrBackDia.h @@ -0,0 +1,134 @@ +// -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*- +/* This file is part of the KDE project + Copyright (C) 1998, 1999 Reginald Stadlbauer + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#ifndef BACKDIA_H +#define BACKDIA_H + +#include +#include +#include + +#include "global.h" +#include "KPrBackground.h" + +#include +#include + +class QLabel; +class QComboBox; +class KColorButton; +class QSlider; +class KPrBackGround; +class QCheckBox; +class QTabWidget; +class KPrPage; +class KURLRequester; + + +class KPrBackPreview : public QFrame +{ + Q_OBJECT + +public: + KPrBackPreview( QWidget *parent, KPrPage *page ); + virtual ~KPrBackPreview(); + + KPrBackGround *backGround() const { + return back; + } + +protected: + virtual void drawContents( QPainter *p ); + +private: + KPrBackGround *back; + +}; + +class KPrBackDialog : public KDialogBase +{ + Q_OBJECT + +public: + KPrBackDialog( QWidget* parent, const char* name, + BackType backType, const QColor &backColor1, + const QColor &backColor2, BCType _bcType, + const KoPicture &backPic, + BackView backPicView, bool _unbalanced, + int _xfactor, int _yfactor, KPrPage *_page ); + + KPrBackGround::Settings getBackGround() const; + bool useMasterBackground() const; + +protected: + void showEvent( QShowEvent *e ); + QColor getBackColor1() const; + QColor getBackColor2() const; + BCType getBackColorType() const; + BackType getBackType() const; + KoPicture getBackPicture() const { return m_picture; } + BackView getBackView() const; + bool getBackUnbalanced() const; + int getBackXFactor() const; + int getBackYFactor() const; +private: + QLabel *picPreview; + QCheckBox *unbalanced; + QComboBox *cType, *backCombo, *picView; + QLabel *picChooseLabel; + KURLRequester *picChoose; + KColorButton *color1Choose, *color2Choose; + QSlider *xfactor, *yfactor; + KPrBackPreview *preview; + bool picChanged, lockUpdate; + QLabel *labXFactor, *labYFactor; + QTabWidget *tabWidget; + QCheckBox *m_useMasterBackground; + + bool oldUseMasterBackground; + BackType oldBackType; + QColor oldBackColor1; + QColor oldBackColor2; + BCType oldBcType; + BackView oldBackPicView; + bool oldUnbalanced; + int oldXFactor; + int oldYFactor; + + KoPicture m_picture, m_oldpicture; + KPrPage *m_page; + +private slots: + void aboutToSelectPic(); + void afterSelectPic( const QString & ); + void updateConfiguration(); + + void Ok() { emit backOk( this, false ); } + void Apply() { emit backOk( this, false ); } + void ApplyGlobal() { emit backOk( this, true ); } + + void changeComboText(int _p); + void slotReset(); + +signals: + void backOk( KPrBackDialog*, bool ); + +}; +#endif //BACKDIA_H diff --git a/kpresenter/KPrBackground.cpp b/kpresenter/KPrBackground.cpp new file mode 100644 index 00000000..e8e7586d --- /dev/null +++ b/kpresenter/KPrBackground.cpp @@ -0,0 +1,653 @@ +// -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*- +/* This file is part of the KDE project + Copyright (C) 1998, 1999 Reginald Stadlbauer + Copyright (C) 2004-2006 Thorsten Zachmann + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#include "KPrBackground.h" +#include "KPrDocument.h" +#include +#include "KPrGradientCollection.h" +#include "KPrTextObject.h" +#include "KPrPage.h" +#include "KPrUtils.h" +#include "KPrBrush.h" + +#include +#include +#include + +#include +#include +// for getenv () +#include +using namespace std; +#include +#include +#include +#include +#include +#include + +KPrBackGround::KPrBackGround( KPrPage *_page ) + // : footerHeight( 0 ) +{ + backType = BT_COLOR; + backView = BV_CENTER; + backColor1 = Qt::white; + backColor2 = Qt::white; + bcType = BCT_PLAIN; + unbalanced = false; + xfactor = 100; + yfactor = 100; + + gradientPixmap = 0L; + m_page=_page; +} + +void KPrBackGround::setBackPicture( const KoPicture& picture ) +{ + if ( backType != BT_PICTURE ) + return; + backPicture = pictureCollection()->insertPicture(picture); +} + +void KPrBackGround::setBackPicture ( const KoPictureKey& key ) +{ + if ( backType != BT_PICTURE ) + return; + backPicture = pictureCollection()->findOrLoad(key.filename(), key.lastModified() ); +} + +void KPrBackGround::drawBackground( QPainter *_painter, const KoTextZoomHandler* zoomHandler, + const QRect& _crect, bool _drawBorders ) +{ + QRect pageRect = zoomHandler->zoomRect( m_page->getPageRect() ); + QRect crect = pageRect.intersect( _crect ); + if ( crect.isEmpty() ) + return; + QSize ext = pageRect.size(); + drawBackground( _painter, ext, crect, _drawBorders ); +} + +void KPrBackGround::drawBackground( QPainter *_painter, const QSize& ext, const QRect& crect, bool _drawBorders ) +{ + if ( m_page->displayBackground() ) + { + _painter->save(); + switch ( backType ) + { + case BT_COLOR: + drawBackColor( _painter, ext, crect ); + break; + case BT_CLIPART: + case BT_PICTURE: + { + if ( backView == BV_CENTER ) + drawBackColor( _painter, ext, crect ); + drawBackPix( _painter, ext, crect ); + break; + } + default: + break; + } + + if ( _drawBorders ) + drawBorders( _painter, ext, crect ); + + _painter->restore(); + } +} + +void KPrBackGround::reload() +{ + if ( backType == BT_PICTURE || backType == BT_CLIPART ) + backPicture = pictureCollection()->insertPicture(backPicture); + else + backPicture.clear(); +} + + +QDomElement KPrBackGround::save( QDomDocument &doc ) +{ + QString tag = m_page->masterPage() == 0 ? "MASTERPAGE" : "PAGE"; + QDomElement page=doc.createElement( tag ); + QDomElement element; + + element=doc.createElement("BACKMASTER"); + element.setAttribute( "useMasterBackground", static_cast(m_page->useMasterBackground() ) ); + element.setAttribute( "displayMasterPageObject", static_cast( m_page->displayObjectFromMasterPage() )); + element.setAttribute( "displayBackground", static_cast( m_page->displayBackground() )); + page.appendChild(element); + if ( !m_page->useMasterBackground() ) + { + + if (backType!=BT_COLOR) { + element=doc.createElement("BACKTYPE"); + element.setAttribute("value", static_cast( backType )); + page.appendChild(element); + } + + if (backView!=BV_CENTER) { + element=doc.createElement("BACKVIEW"); + element.setAttribute("value", static_cast( backView )); + page.appendChild(element); + } + + if (backColor1!=Qt::white) { + element=doc.createElement("BACKCOLOR1"); + element.setAttribute("color", backColor1.name()); + page.appendChild(element); + } + + if (backColor2!=Qt::white) { + element=doc.createElement("BACKCOLOR2"); + element.setAttribute("color", backColor2.name()); + page.appendChild(element); + } + + if (bcType!=BCT_PLAIN) { + element=doc.createElement("BCTYPE"); + element.setAttribute("value", static_cast( bcType )); + page.appendChild(element); + } + + if (xfactor!=100 || yfactor!=100 || unbalanced) { + element=doc.createElement("BGRADIENT"); + element.setAttribute("unbalanced", static_cast( unbalanced )); + element.setAttribute("xfactor", xfactor); + element.setAttribute("yfactor", yfactor); + page.appendChild(element); + } + + if ( !backPicture.isNull() && ( ( backType == BT_PICTURE ) || ( backType == BT_CLIPART ) ) ) + { + element = doc.createElement( "BACKPICTUREKEY" ); + + backPicture.getKey().saveAttributes( element ); + page.appendChild( element ); + } + } + + return page; +} + + +void KPrBackGround::saveOasisBackgroundPageStyle( KoGenStyle& stylepageauto, KoGenStyles& mainStyles ) +{ + switch ( backType ) + { + case BT_COLOR: + { + QBrush qbrush( backColor1 ); + KPrBrush brush( qbrush, backColor1, backColor2, bcType, + bcType == BCT_PLAIN ? FT_BRUSH : FT_GRADIENT, + unbalanced, xfactor, yfactor ); + brush.saveOasisFillStyle( stylepageauto, mainStyles ); + } break; + case BT_BRUSH: + case BT_CLIPART: + case BT_PICTURE: + { + stylepageauto.addProperty("draw:fill", "bitmap" ); + stylepageauto.addProperty("draw:fill-image-name", saveOasisPictureStyle( mainStyles ) ); + QString repeat = "repeat"; + switch ( backView ) + { + case BV_ZOOM: + repeat = "stretch"; + break; + case BV_CENTER: + repeat = "no-repeat"; + break; + case BV_TILED: + repeat = "repeat"; + break; + } + stylepageauto.addProperty( "style:repeat", repeat ); + } break; + } +} + + +QString KPrBackGround::saveOasisPictureStyle( KoGenStyles& mainStyles ) +{ + // + KoGenStyle pictureStyle( KPrDocument::STYLE_PICTURE /*no family name*/ ); + pictureStyle.addAttribute( "xlink:show", "embed" ); + pictureStyle.addAttribute( "xlink:actuate", "onLoad" ); + pictureStyle.addAttribute( "xlink:type", "simple" ); + pictureStyle.addAttribute( "xlink:href", pictureCollection()->getOasisFileName(backPicture ) ); + return mainStyles.lookup( pictureStyle, "picture" ); +} + + +void KPrBackGround::loadOasis(KoOasisContext & context ) +{ + KoStyleStack& styleStack = context.styleStack(); + kdDebug()<<"KPrBackGround::loadOasis()\n"; + styleStack.setTypeProperties( "drawing-page" ); + if ( styleStack.hasAttributeNS( KoXmlNS::draw, "fill" ) ) + { + const QString fill = styleStack.attributeNS( KoXmlNS::draw, "fill" ); + kdDebug(33001) <<"fill page type :" << fill << endl; + if ( fill == "solid" || fill == "gradient" ) + { + KPrBrush brush; + brush.loadOasisFillStyle( context, "drawing-page" ); + if ( brush.getFillType() == FT_BRUSH ) + { + setBackColor1( brush.getBrush().color() ); + setBackColorType( BCT_PLAIN ); + } + else + { + setBackColor1( brush.getGColor1() ); + setBackColor2( brush.getGColor2() ); + setBackColorType( brush.getGType() ); + setBackUnbalanced( brush.getGUnbalanced() ); + setBackXFactor( brush.getGXFactor() ); + setBackYFactor( brush.getGYFactor() ); + } + setBackType( BT_COLOR ); + } + else if ( fill == "bitmap" ) + { + QString style = styleStack.attributeNS( KoXmlNS::draw, "fill-image-name" ); + QDomElement* draw =context.oasisStyles().drawStyles()[style]; + + const QString href( draw->attributeNS( KoXmlNS::xlink, "href", QString::null) ); + kdDebug()<<" href: "<=0) + { + strExtension=href.mid(result+1); // As we are using KoPicture, the extension should be without the dot. + } + QString filename(href); + const KoPictureKey key(filename, QDateTime::currentDateTime(Qt::UTC)); + backPicture.setKey(key); + + KoStore* store = context.store(); + if ( store->open( filename ) ) + { + KoStoreDevice dev(store); + if ( !backPicture.load( &dev, strExtension ) ) + kdWarning() << "Cannot load picture: " << filename << " " << href << endl; + store->close(); + } + pictureCollection()->insertPicture( key, backPicture ); + } + + if ( styleStack.hasAttributeNS( KoXmlNS::style, "repeat" ) ) + { + QString repeat = styleStack.attributeNS( KoXmlNS::style, "repeat" ); + if ( repeat == "stretch" ) + setBackView( BV_ZOOM ); + else if ( repeat == "no-repeat" ) + setBackView( BV_CENTER ); + else + setBackView( BV_TILED ); + } + else + setBackView( BV_TILED );; // use tiled as default + + setBackType(BT_PICTURE); + } + } +} + +void KPrBackGround::load( const QDomElement &element ) +{ + //compatible with old file format kpresenter-1.4 + QDomElement e=element.namedItem("BACKMASTER").toElement(); + if ( !e.isNull() ) + { + if ( e.hasAttribute( "useMasterBackground" ) ) + { + m_page->setUseMasterBackground( (bool)e.attribute("useMasterBackground").toInt()); + } + else //for kpresenter-1.4 + m_page->setUseMasterBackground( true ); + + if(e.hasAttribute("displayMasterPageObject")) + { + m_page->setDisplayObjectFromMasterPage( (bool)e.attribute("displayMasterPageObject").toInt()); + } + if(e.hasAttribute("displayBackground")) + { + m_page->setDisplayBackground( (bool)e.attribute("displayBackground").toInt()); + } + } + else + m_page->setUseMasterBackground( false ); + + e=element.namedItem("BACKTYPE").toElement(); + if(!e.isNull()) { + int tmp=0; + if(e.hasAttribute("value")) + tmp=e.attribute("value").toInt(); + setBackType(static_cast(tmp)); + } + e=element.namedItem("BACKVIEW").toElement(); + if(!e.isNull()) { + int tmp=0; + if(e.hasAttribute("value")) + tmp=e.attribute("value").toInt(); + setBackView(static_cast(tmp)); + } + e=element.namedItem("BACKCOLOR1").toElement(); + if(!e.isNull()) { + int red=0, green=0, blue=0; + if(e.hasAttribute("red")) + red=e.attribute("red").toInt(); + if(e.hasAttribute("green")) + green=e.attribute("green").toInt(); + if(e.hasAttribute("blue")) + blue=e.attribute("blue").toInt(); + if(e.hasAttribute("color")) + setBackColor1(QColor(e.attribute("color"))); + else + setBackColor1(QColor(red, green, blue)); + } + e=element.namedItem("BACKCOLOR2").toElement(); + if(!e.isNull()) { + int red=0, green=0, blue=0; + if(e.hasAttribute("red")) + red=e.attribute("red").toInt(); + if(e.hasAttribute("green")) + green=e.attribute("green").toInt(); + if(e.hasAttribute("blue")) + blue=e.attribute("blue").toInt(); + if(e.hasAttribute("color")) + setBackColor2(QColor(e.attribute("color"))); + else + setBackColor2(QColor(red, green, blue)); + } + e=element.namedItem("BGRADIENT").toElement(); + if(!e.isNull()) { + int xf=0, yf=0, unbalanced=0; + if(e.hasAttribute("xfactor")) + xf=e.attribute("xfactor").toInt(); + setBackXFactor(xf); + if(e.hasAttribute("yfactor")) + yf=e.attribute("yfactor").toInt(); + setBackYFactor(yf); + if(e.hasAttribute("unbalanced")) + unbalanced=e.attribute("unbalanced").toInt(); + setBackUnbalanced(static_cast(unbalanced)); + } + e=element.namedItem("BCTYPE").toElement(); + if(!e.isNull()) { + int tmp=0; + if(e.hasAttribute("value")) + tmp=e.attribute("value").toInt(); + setBackColorType(static_cast(tmp)); + } + e=element.namedItem("BACKPICTUREKEY").toElement(); + if(!e.isNull()) { + KoPictureKey key; + key.loadAttributes( e ); + backPicture.clear(); + backPicture.setKey( key ); + // Image will be set by reload(), called by completeLoading() + } + e=element.namedItem("BACKPIXKEY").toElement(); + if(!e.isNull()) { + KoPictureKey key; + key.loadAttributes( e ); + backPicture.clear(); + backPicture.setKey( key ); + // Image will be set by reload(), called by completeLoading() + } + else { + // try to find a BACKPIX tag if the BACKPIXKEY is not available... + KoPictureKey key; + e=element.namedItem("BACKPIX").toElement(); + if(!e.isNull()) { + bool openPic = true; + QString _data; + QString _fileName; + if(e.hasAttribute("data")) + _data=e.attribute("data"); + if ( _data.isEmpty() ) + openPic = true; + else + openPic = false; + if(e.hasAttribute("filename")) + _fileName=e.attribute("filename"); + if ( !_fileName.isEmpty() ) + { + if ( int _envVarB = _fileName.find( '$' ) >= 0 ) + { + int _envVarE = _fileName.find( '/', _envVarB ); + QString path = getenv( QFile::encodeName(_fileName.mid( _envVarB, _envVarE-_envVarB )) ); + _fileName.replace( _envVarB-1, _envVarE-_envVarB+1, path ); + } + } + if ( openPic ) + // !! this loads it from the disk (unless it's in the image collection already) + backPicture = pictureCollection()->loadPicture( _fileName ); + else + { + KoPictureKey key( _fileName ); + backPicture.clear(); + backPicture.setKey(key); + QByteArray rawData=_data.utf8(); // XPM is normally ASCII, therefore UTF-8 + rawData[rawData.size()-1]=char(10); // Replace the NULL character by a LINE FEED + QBuffer buffer(rawData); + backPicture.loadXpm(&buffer); + } + +#if 0 + if ( ext == orig_size.toQSize() ) + ext = backPicture.size(); + + backPicture = backPicture.scale( ext ); +#endif + } + } + e=element.namedItem("BACKCLIPKEY").toElement(); + if(!e.isNull()) { + KoPictureKey clipKey; + clipKey.loadAttributes( e ); + backPicture.clear(); + backPicture.setKey(clipKey); + // Picture will be set by reload(), called by completeLoading() + } + else { + // try to find a BACKCLIP tag if the BACKCLIPKEY is not available... + e=element.namedItem("BACKCLIP").toElement(); + if(!e.isNull()) { + QString _fileName; + if(e.hasAttribute("filename")) + _fileName=e.attribute("filename"); + if ( !_fileName.isEmpty() ) + { + if ( int _envVarB = _fileName.find( '$' ) >= 0 ) + { + int _envVarE = _fileName.find( '/', _envVarB ); + QString path = getenv( QFile::encodeName(_fileName.mid( _envVarB, _envVarE-_envVarB )) ); + _fileName.replace( _envVarB-1, _envVarE-_envVarB+1, path ); + } + } + //KPClipartKey clipKey( _fileName, QDateTime( pictureCollection()->tmpDate(), + // pictureCollection()->tmpTime() ) ); + backPicture = pictureCollection()->loadPicture( _fileName ); // load from disk ! + } + } +} + +void KPrBackGround::drawBackColor( QPainter *_painter, const QSize& ext, const QRect& crect ) +{ + if ( (backType == BT_COLOR && bcType == BCT_PLAIN) || backColor1 == backColor2 ) //plain color + { + //kdDebug(33001) << "KPrBackGround::drawBackColor (filling " << DEBUGRECT(crect) << ")" << endl; + _painter->fillRect( crect, QBrush( getBackColor1() ) ); + } + else if (backType == BT_COLOR && bcType != BCT_PLAIN) { //gradient + if ( !gradientPixmap || gradientPixmap->size() != ext ) + generateGradient( ext ); + _painter->drawPixmap( crect.topLeft(), *gradientPixmap, crect ); + } + else /*if ( backType == BT_CLIPART || backType == BT_PICTURE )*/ //no gradient or bg color + _painter->fillRect( crect, QBrush( Qt::white ) ); + return; +} + +void KPrBackGround::drawBackPix( QPainter *_painter, const QSize& ext, const QRect& /*crect*/ ) +{ + /*kdDebug(33001) << "KPrBackGround::drawBackPix ext=" << ext.width() << "," << ext.height() << endl; + kdDebug(33001) << "mode=" << (backView==BV_ZOOM?"ZOOM":backView==BV_TILED?"TILED":backView==BV_CENTER?"CENTER":"OTHER") + << " crect=" << DEBUGRECT(crect) << endl;*/ + if ( !backPicture.isNull() ) + { + // depend on page size and desktop size + const QSize _origSize = backPicture.getOriginalSize(); + // NOTE: make all multiplications before any division + double w = _origSize.width(); + w *= ext.width(); +#if KDE_IS_VERSION(3,1,90) + QRect desk = KGlobalSettings::desktopGeometry(kapp->activeWindow()); +#else + QRect desk = QApplication::desktop()->screenGeometry(); +#endif + w /= desk.width(); + double h = _origSize.height(); + h *= ext.height(); + h /= desk.height(); + const QSize _pixSize = QSize( (int)w, (int)h ); + QPixmap backPix; + + switch ( backView ) + { + case BV_ZOOM: + backPix=backPicture.generatePixmap( ext, true ); + _painter->drawPixmap( QRect( 0, 0, ext.width(), ext.height() ), backPix ); + break; + case BV_TILED: + backPix=backPicture.generatePixmap( _pixSize, true ); + _painter->drawTiledPixmap( 0, 0, ext.width(), ext.height(), backPix ); + break; + case BV_CENTER: + { + backPix=backPicture.generatePixmap( _pixSize, true ); + + QPixmap *pix = new QPixmap( ext.width(), ext.height() ); + bool delPix = true; + int _x = 0, _y = 0; + + if ( backPix.width() > pix->width() && backPix.height() > pix->height() ) + bitBlt( pix, 0, 0, &backPix, backPix.width() - pix->width(), backPix.height() - pix->height(), + pix->width(), pix->height() ); + else if ( backPix.width() > pix->width() ) + { + bitBlt( pix, 0, 0, &backPix, backPix.width() - pix->width(), 0, + pix->width(), backPix.height() ); + _y = ( pix->height() - backPix.height() ) / 2; + } + else if ( backPix.height() > pix->height() ) + { + bitBlt( pix, 0, 0, &backPix, 0, backPix.height() - pix->height(), + backPix.width(), pix->height() ); + _x = ( pix->width() - backPix.width() ) / 2; + } + else + { + _x = ( pix->width() - backPix.width() ) / 2; + _y = ( pix->height() - backPix.height() ) / 2; + delPix = false; + delete pix; + pix = &backPix; + } + + if ( pix && !pix->isNull() ) + _painter->drawPixmap( _x, _y, *pix ); + if ( delPix ) delete pix; + } + break; + } + } +} + +void KPrBackGround::drawBorders( QPainter *_painter, const QSize& /*ext*/, const QRect& /*crect*/ ) +{ + _painter->setPen( QApplication::palette().active().color( QColorGroup::Dark ) ); + _painter->setBrush( Qt::NoBrush ); + + QRect rect = m_page->getZoomPageRect(); + + _painter->drawRect( rect.x()-1,rect.y()-1,rect.width()+1,rect.height()+1 ); +} + +void KPrBackGround::generateGradient( const QSize& size ) +{ + if ( backType == BT_COLOR || backType == BT_CLIPART || + backType == BT_PICTURE && backView == BV_CENTER ) { + removeGradient(); + gradientPixmap = &gradientCollection()->getGradient( backColor1, backColor2, bcType, size, + unbalanced, xfactor, yfactor ); + } + + // Avoid keeping an unused gradient around + if ( (backType == BT_PICTURE || backType==BT_CLIPART) && gradientPixmap ) + removeGradient(); +} + +void KPrBackGround::removeGradient() +{ + if ( gradientPixmap ) { + gradientCollection()->removeRef( backColor1, backColor2, bcType, gradientPixmap->size(), + unbalanced, xfactor, yfactor); + gradientPixmap = 0; + } +} + +KoPictureCollection * KPrBackGround::pictureCollection() const +{ + return m_page->kPresenterDoc()->pictureCollection(); +} + +KPrGradientCollection * KPrBackGround::gradientCollection() const +{ + return m_page->kPresenterDoc()->gradientCollection(); +} + +void KPrBackGround::setBackGround( const struct Settings &settings ) +{ + backType = settings.m_backType; + backColor1 = settings.m_backColor1; + backColor2 = settings.m_backColor2; + bcType = settings.m_bcType; + unbalanced = settings.m_unbalanced; + xfactor = settings.m_xfactor; + yfactor = settings.m_yfactor; + removeGradient(); + setBackPicture( settings.m_backPictureKey ); + backView = settings.m_backView; + +} + +struct KPrBackGround::Settings KPrBackGround::getBackGround() const +{ + return Settings( backType, backColor1, backColor2, + bcType, unbalanced, xfactor, yfactor, + backPicture.getKey(), backView); +} diff --git a/kpresenter/KPrBackground.h b/kpresenter/KPrBackground.h new file mode 100644 index 00000000..b0326634 --- /dev/null +++ b/kpresenter/KPrBackground.h @@ -0,0 +1,188 @@ +// -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*- +/* This file is part of the KDE project + Copyright (C) 1998, 1999 Reginald Stadlbauer + Copyright (C) 2004,2006 Thorsten Zachmann + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#ifndef kpbackground_h +#define kpbackground_h + +#include +#include +#include +#include +#include +#include + +#include + +#include "global.h" + +class KPrDocument; +class QPainter; +class QPixmap; +class KPrGradientCollection; +class QDomDocument; +class QDomElement; +class KoTextZoomHandler; +class KPrPage; +class KoXmlWriter; +class KoGenStyles; +class KoGenStyle; + + +class KPrBackGround +{ +public: + struct Settings + { + Settings( const BackType backType, const QColor backColor1, const QColor backColor2, + const BCType bcType, const bool unbalanced, const int xfactor, const int yfactor, + const KoPictureKey &key, const BackView backView ) + : m_backType( backType ) + , m_backColor1( backColor1 ) + , m_backColor2( backColor2 ) + , m_bcType( bcType ) + , m_unbalanced( unbalanced ) + , m_xfactor( xfactor ) + , m_yfactor( yfactor ) + , m_backPictureKey( key ) + , m_backView( backView ) + {} + + BackType m_backType; + QColor m_backColor1; + QColor m_backColor2; + // Gradient setting + BCType m_bcType; + bool m_unbalanced; + // Gradient factors + int m_xfactor, m_yfactor; + + KoPictureKey m_backPictureKey; + BackView m_backView; + }; + + KPrBackGround( KPrPage *_page ); + ~KPrBackGround() {} + + void setBackType( BackType _backType ) + { + backType = _backType; + if (backType==BT_PICTURE || backType==BT_CLIPART) + removeGradient(); + } + void setBackView( BackView _backView ) + { backView = _backView; } + void setBackColor1( const QColor &_color ) + { removeGradient(); backColor1 = _color; } + void setBackColor2( const QColor &_color ) + { removeGradient(); backColor2 = _color; } + void setBackColorType( BCType _bcType ) + { removeGradient(); bcType = _bcType; } + void setBackUnbalanced( bool _unbalanced ) + { removeGradient(); unbalanced = _unbalanced; } + void setBackXFactor( int _xfactor ) + { removeGradient(); xfactor = _xfactor; } + void setBackYFactor( int _yfactor ) + { removeGradient(); yfactor = _yfactor; } + /// set the back picture to a new KoPicture + void setBackPicture( const KoPicture& picture ); + void setBackPicture ( const KoPictureKey& key ); + void setBackGround( const struct Settings &settings ); + struct Settings getBackGround() const; + + KoPicture picture() const { return backPicture;} + + BackType getBackType() const + { return backType; } + BackView getBackView() const + { return backView; } + QColor getBackColor1() const + { return backColor1; } + QColor getBackColor2() const + { return backColor2; } + BCType getBackColorType() const + { return bcType; } + KoPictureKey getBackPictureKey() const + { return backPicture.getKey(); } + KoPicture getBackPicture() const + { return backPicture;} + + bool getBackUnbalanced() const + { return unbalanced; } + int getBackXFactor() const + { return xfactor; } + int getBackYFactor() const + { return yfactor; } + + // Draw the background. + // Uses the @p zoomHandler to determine the size of the background + void drawBackground( QPainter *_painter, const KoTextZoomHandler* zoomHandler, + const QRect& crect, bool _drawBorders ); + // Draw the background. The size of the background is passed explicitly + void drawBackground( QPainter *_painter, const QSize& ext, + const QRect& crect, bool _drawBorders ); + + void reload(); + + QDomElement save( QDomDocument &doc ); + void load( const QDomElement &element ); + void loadOasis( KoOasisContext & context ); + void saveOasisBackgroundPageStyle( KoGenStyle &stylepageauto, KoGenStyles &mainStyles ); + +protected: + void drawBackColor( QPainter *_painter, const QSize& ext, const QRect& crect ); + void drawBackPix( QPainter *_painter, const QSize& ext, const QRect& crect ); + void drawBorders( QPainter *_painter, const QSize& ext, const QRect& crect ); + // The current gradient isn't valid anymore (e.g. size or settings changed) -> discard it + void removeGradient(); + // Generate a new gradient pixmap, for the given size + void generateGradient( const QSize& size ); + + KoPictureCollection *pictureCollection() const; + KPrGradientCollection *gradientCollection() const; + + QString saveOasisPictureStyle( KoGenStyles& mainStyles ); + +private: + BackType backType; + BackView backView; + QColor backColor1; + QColor backColor2; + BCType bcType; + + // Background picture + KoPicture backPicture; + + // Pixmap used to cache the drawing of the gradient, at the current size + const QPixmap *gradientPixmap; + + // The page for which this background exists + KPrPage *m_page; + + //int footerHeight; + + // Gradient factors + int xfactor, yfactor; + + // Gradient setting + bool unbalanced; +}; + +#endif diff --git a/kpresenter/KPrBezierCurveObject.cpp b/kpresenter/KPrBezierCurveObject.cpp new file mode 100644 index 00000000..152d466d --- /dev/null +++ b/kpresenter/KPrBezierCurveObject.cpp @@ -0,0 +1,302 @@ +// -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*- +/* This file is part of the KDE project + Copyright (C) 2001 Toshitaka Fujioka + Copyright (C) 2005-2006 Thorsten Zachmann + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#include "KPrBezierCurveObject.h" +#include "KPrCubicBezierCurveObjectIface.h" +#include "KPrQuadricBezierCurveObjectIface.h" +#include "KPrUtils.h" +#include +#include +#include +#include +#include "KoPointArray.h" +#include + +#include +using namespace std; + +KPrBezierCurveObject::KPrBezierCurveObject() +: KPrPointObject() +{ +} + +KPrBezierCurveObject::KPrBezierCurveObject( const KoPointArray &_controlPoints, + const KoPointArray &_allPoints, + const KoSize &_size, const KoPen &_pen, + LineEnd _lineBegin, LineEnd _lineEnd ) +: KPrPointObject( _pen, _lineBegin, _lineEnd ) +{ + points = KoPointArray( _controlPoints ); + allPoints = KoPointArray( _allPoints ); + + ext = _size; +} + + +KPrBezierCurveObject &KPrBezierCurveObject::operator=( const KPrBezierCurveObject & ) +{ + return *this; +} + + +bool KPrBezierCurveObject::saveOasisObjectAttributes( KPOasisSaveContext &sc ) const +{ + KoRect rect( getRect() ); + sc.xmlWriter.addAttribute("svg:viewBox", QString( "0 0 %1 %2" ).arg( int( rect.width() * 100 ) ) + .arg( int( rect.height() * 100 ) ) ); + + unsigned int pointCount = points.count(); + unsigned int pos = 0; + + QString d; + d += QString( "M%1 %2" ).arg( int( points.at(pos).x() * 100 ) ) + .arg( int( points.at(pos).y() * 100 ) ); + + while ( pos + 4 <= pointCount ) + { + d += QString( "C%1 %2 %3 %4 %5 %6" ).arg( int( points.at( pos + 2 ).x() * 100 ) ) + .arg( int( points.at( pos + 2 ).y() * 100 ) ) + .arg( int( points.at( pos + 3 ).x() * 100 ) ) + .arg( int( points.at( pos + 3 ).y() * 100 ) ) + .arg( int( points.at( pos + 1 ).x() * 100 ) ) + .arg( int( points.at( pos + 1 ).y() * 100 ) ); + pos += 4; + } + + if ( pos < pointCount ) + { + d += QString( "L%1 %2" ).arg( int( points.at( pos + 1 ).x() * 100 ) ) + .arg( int( points.at( pos + 1 ).y() * 100 ) ); + } + + sc.xmlWriter.addAttribute( "svg:d", d ); + + return true; +} + + +const char * KPrBezierCurveObject::getOasisElementName() const +{ + return "draw:path"; +} + + +void KPrBezierCurveObject::loadOasis( const QDomElement &element, KoOasisContext & context, KPrLoadingInfo* info ) +{ + kdDebug(33001) << "KPrBezierCurveObject::loadOasis" << endl; + KPrPointObject::loadOasis( element, context, info ); + + allPoints = bezier2polyline( points ); + + //load marker + loadOasisMarker( context ); +} + +QDomDocumentFragment KPrBezierCurveObject::save( QDomDocument& doc, double offset ) +{ + return KPrPointObject::save( doc,offset ); +} + +double KPrBezierCurveObject::load(const QDomElement &element) +{ + double offset = KPrPointObject::load( element ); + + allPoints = bezier2polyline( points ); + + return offset; +} + +void KPrBezierCurveObject::updatePoints( double _fx, double _fy ) +{ + KPrPointObject::updatePoints( _fx, _fy ); + + int index = 0; + KoPointArray tmpPoints; + KoPointArray::ConstIterator it; + for ( it = allPoints.begin(); it != allPoints.end(); ++it ) { + KoPoint point = (*it); + double tmpX = point.x() * _fx; + double tmpY = point.y() * _fy; + + tmpPoints.putPoints( index, 1, tmpX,tmpY ); + ++index; + } + allPoints = tmpPoints; +} + +KoPointArray KPrBezierCurveObject::bezier2polyline( const KoPointArray &bezierPoints ) +{ + if ( bezierPoints.isNull() ) + return bezierPoints; + + KoPointArray _points( bezierPoints ); + KoPointArray _allPoints; + unsigned int pointCount = _points.count(); + + if ( pointCount == 2 ) // line + { + _allPoints = _points; + } + else // cubic bezier curve + { + KoPointArray tmpPointArray; + unsigned int _tmpIndex = 0; + unsigned int count = 0; + while ( count < pointCount ) + { + if ( pointCount >= ( count + 4 ) ) // for cubic bezier curve + { + double _firstX = _points.at( count ).x(); + double _firstY = _points.at( count ).y(); + + double _fourthX = _points.at( count + 1 ).x(); + double _fourthY = _points.at( count + 1 ).y(); + + double _secondX = _points.at( count + 2 ).x(); + double _secondY = _points.at( count + 2 ).y(); + + double _thirdX = _points.at( count + 3 ).x(); + double _thirdY = _points.at( count + 3 ).y(); + + KoPointArray bezierPoint; + bezierPoint.putPoints( 0, 4, _firstX,_firstY, _secondX,_secondY, + _thirdX,_thirdY, _fourthX,_fourthY ); + bezierPoint = bezierPoint.cubicBezier(); + + KoPointArray::ConstIterator it; + for ( it = bezierPoint.begin(); it != bezierPoint.end(); ++it ) + { + KoPoint _point = (*it); + tmpPointArray.putPoints( _tmpIndex, 1, _point.x(), _point.y() ); + ++_tmpIndex; + } + + count += 4; + } + else // for line + { + double _x1 = _points.at( count ).x(); + double _y1 = _points.at( count ).y(); + + double _x2 = _points.at( count + 1 ).x(); + double _y2 = _points.at( count + 1 ).y(); + + tmpPointArray.putPoints( _tmpIndex, 2, _x1,_y1, _x2,_y2 ); + _tmpIndex += 2; + count += 2; + } + } + + _allPoints = tmpPointArray; + } + + return _allPoints; +} + +void KPrBezierCurveObject::flip(bool horizontal ) +{ + KPrPointObject::flip( horizontal ); + + KoPointArray tmpPoints; + int index = 0; + if ( ! horizontal ) + { + KoPointArray::ConstIterator it; + double horiz = getSize().height()/2; + for ( it = allPoints.begin(); it != allPoints.end(); ++it ) + { + KoPoint point = (*it); + if ( point.y()> horiz ) + tmpPoints.putPoints( index, 1, point.x(),point.y()- 2*(point.y()-horiz) ); + else + tmpPoints.putPoints( index, 1, point.x(),point.y()+ 2*(horiz - point.y()) ); + ++index; + } + } + else + { + KoPointArray::ConstIterator it; + double vert = getSize().width()/2; + for ( it = allPoints.begin(); it != allPoints.end(); ++it ) + { + KoPoint point = (*it); + if ( point.y()> vert ) + tmpPoints.putPoints( index, 1, point.x()- 2*(point.x()-vert), point.y() ); + else + tmpPoints.putPoints( index, 1, point.x()+ 2*(vert - point.x()),point.y() ); + ++index; + } + } + + allPoints = tmpPoints; +} + + +KoPointArray KPrBezierCurveObject::getDrawingPoints() const +{ + return allPoints; +} + + +KPrCubicBezierCurveObject::KPrCubicBezierCurveObject() +: KPrBezierCurveObject() +{ +} + + +KPrCubicBezierCurveObject::KPrCubicBezierCurveObject( const KoPointArray &_controlPoints, + const KoPointArray &_allPoints, + const KoSize & _size, const KoPen &_pen, + LineEnd _lineBegin, LineEnd _lineEnd ) +: KPrBezierCurveObject( _controlPoints, _allPoints, _size, _pen, _lineBegin, _lineEnd ) +{ +} + + +DCOPObject* KPrCubicBezierCurveObject::dcopObject() +{ + if ( !dcop ) + dcop = new KPrCubicBezierCurveObjectIface( this ); + return dcop; +} + + +KPrQuadricBezierCurveObject::KPrQuadricBezierCurveObject() +: KPrBezierCurveObject() +{ +} + + +KPrQuadricBezierCurveObject::KPrQuadricBezierCurveObject( const KoPointArray &_controlPoints, + const KoPointArray &_allPoints, + const KoSize & _size, const KoPen &_pen, + LineEnd _lineBegin, LineEnd _lineEnd ) +: KPrBezierCurveObject( _controlPoints, _allPoints, _size, _pen, _lineBegin, _lineEnd ) +{ +} + + +DCOPObject* KPrQuadricBezierCurveObject::dcopObject() +{ + if ( !dcop ) + dcop = new KPrQuadricBezierCurveObjectIface( this ); + return dcop; +} diff --git a/kpresenter/KPrBezierCurveObject.h b/kpresenter/KPrBezierCurveObject.h new file mode 100644 index 00000000..db12f8d8 --- /dev/null +++ b/kpresenter/KPrBezierCurveObject.h @@ -0,0 +1,90 @@ +// -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*- +/* This file is part of the KDE project + Copyright (C) 2001 Toshitaka Fujioka + Copyright (C) 2005 Thorsten Zachmann + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#ifndef kpcubicbeziercurveobject_h +#define kpcubicbeziercurveobject_h + +#include "KPrPointObject.h" + +class QPainter; +class DCOPObject; + +class KPrBezierCurveObject : public KPrPointObject +{ +public: + KPrBezierCurveObject(); + KPrBezierCurveObject( const KoPointArray &_controlPoints, const KoPointArray &_allPoints, const KoSize & _size, + const KoPen &_pen, LineEnd _lineBegin, LineEnd _lineEnd ); + virtual ~KPrBezierCurveObject() {} + + virtual QDomDocumentFragment save( QDomDocument& doc,double offset ); + + virtual double load( const QDomElement &element ); + virtual void loadOasis( const QDomElement &element, KoOasisContext & context, KPrLoadingInfo* info ); + + virtual void flip(bool horizontal ); + + static KoPointArray bezier2polyline( const KoPointArray &bezierPoints ); + +protected: + virtual const char * getOasisElementName() const; + virtual bool saveOasisObjectAttributes( KPOasisSaveContext &sc ) const; + + virtual void updatePoints( double _fx, double _fy ); + virtual KoPointArray getDrawingPoints() const; + + KoPointArray allPoints; + +private: + // Don't assign it + KPrBezierCurveObject &operator=( const KPrBezierCurveObject & ); +}; + + +class KPrCubicBezierCurveObject : public KPrBezierCurveObject +{ +public: + KPrCubicBezierCurveObject(); + KPrCubicBezierCurveObject( const KoPointArray &_controlPoints, const KoPointArray &_allPoints, const KoSize & _size, + const KoPen &_pen, LineEnd _lineBegin, LineEnd _lineEnd ); + virtual ~KPrCubicBezierCurveObject() {} + + virtual DCOPObject* dcopObject(); + + virtual ObjType getType() const { return OT_CUBICBEZIERCURVE; } + virtual QString getTypeString() const { return i18n( "Cubic Bezier Curve" ); } +}; + +class KPrQuadricBezierCurveObject : public KPrBezierCurveObject +{ +public: + KPrQuadricBezierCurveObject(); + KPrQuadricBezierCurveObject( const KoPointArray &_controlPoints, const KoPointArray &_allPoints, const KoSize & _size, + const KoPen &_pen, LineEnd _lineBegin, LineEnd _lineEnd ); + virtual ~KPrQuadricBezierCurveObject() {} + + virtual DCOPObject* dcopObject(); + + virtual ObjType getType() const { return OT_CUBICBEZIERCURVE; } + virtual QString getTypeString() const { return i18n( "Quadric Bezier Curve" ); } +}; + +#endif diff --git a/kpresenter/KPrBgSpellCheck.cpp b/kpresenter/KPrBgSpellCheck.cpp new file mode 100644 index 00000000..efd84234 --- /dev/null +++ b/kpresenter/KPrBgSpellCheck.cpp @@ -0,0 +1,60 @@ +// -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*- +/* This file is part of the KDE project + Copyright (C) 2002 David Faure + 2002 Laurent Montel + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + + +#include "KPrBgSpellCheck.h" +#include "KPrDocument.h" +#include "KPrTextObject.h" + +#include "KoTextIterator.h" +#include "KoTextObject.h" + +#include +using namespace KSpell2; + +#include +#include +#include + +KPrBgSpellCheck::KPrBgSpellCheck(KPrDocument *_doc) + : KoBgSpellCheck(Broker::openBroker( KSharedConfig::openConfig( "kpresenterrc" ) ), _doc ) +{ + m_doc=_doc; + m_currentObj=0L; +} + +KPrBgSpellCheck::~KPrBgSpellCheck() +{ +} + + +KoTextIterator *KPrBgSpellCheck::createWholeDocIterator() const +{ + QValueList objects = m_doc->visibleTextObjects( ); + + kdDebug()<<"Number of visible text objects = "<< objects.count() << endl; + + if ( objects.isEmpty() ) + return 0; + + return new KoTextIterator( objects, 0, 0 ); +} + diff --git a/kpresenter/KPrBgSpellCheck.h b/kpresenter/KPrBgSpellCheck.h new file mode 100644 index 00000000..d2d8edea --- /dev/null +++ b/kpresenter/KPrBgSpellCheck.h @@ -0,0 +1,42 @@ +// -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*- +/* This file is part of the KDE project + Copyright (C) 2002 David Faure + 2002 Laurent Montel + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#ifndef kprbgspellcheck_h +#define kprbgspellcheck_h + +class KPrDocument; +class KPrTextObject; +#include "KoBgSpellCheck.h" + + +class KPrBgSpellCheck : public KoBgSpellCheck +{ +public: + KPrBgSpellCheck(KPrDocument *_doc); + virtual ~KPrBgSpellCheck(); + virtual KoTextIterator *createWholeDocIterator() const; + + +private: + KPrDocument *m_doc; + KPrTextObject *m_currentObj; +}; +#endif diff --git a/kpresenter/KPrBrush.cpp b/kpresenter/KPrBrush.cpp new file mode 100644 index 00000000..6d4d1699 --- /dev/null +++ b/kpresenter/KPrBrush.cpp @@ -0,0 +1,247 @@ +// -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*- +/* This file is part of the KDE project + Copyright (C) 2005-2006 Thorsten Zachmann + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#include "KPrBrush.h" + +#include +#include +#include +#include +#include "KPrDocument.h" + +KPrBrush::KPrBrush() + : KoBrush() +{ +} + +KPrBrush::KPrBrush( const QBrush &brush, const QColor &gColor1, const QColor &gColor2, + BCType gType, FillType fillType, bool unbalanced, + int xfactor, int yfactor ) + : KoBrush( brush, gColor1,gColor2, gType, fillType, unbalanced, xfactor, yfactor ) +{ +} + +void KPrBrush::saveOasisFillStyle( KoGenStyle &styleObjectAuto, KoGenStyles& mainStyles ) const +{ + switch ( getFillType() ) + { + case FT_BRUSH: + { + if( getBrush().style() != Qt::NoBrush ) + { + KoOasisStyles::saveOasisFillStyle( styleObjectAuto, mainStyles, getBrush() ); + } + else + { + styleObjectAuto.addProperty( "draw:fill","none" ); + } + break; + } + case FT_GRADIENT: + styleObjectAuto.addProperty( "draw:fill","gradient" ); + styleObjectAuto.addProperty( "draw:fill-gradient-name", saveOasisGradientStyle( mainStyles ) ); + break; + } +} + + +QString KPrBrush::saveOasisGradientStyle( KoGenStyles& mainStyles ) const +{ + KoGenStyle gradientStyle( KPrDocument::STYLE_GRADIENT /*no family name*/); + gradientStyle.addAttribute( "draw:start-color", getGColor1().name() ); + gradientStyle.addAttribute( "draw:end-color", getGColor2().name() ); + + QString unbalancedx( "50%" ); + QString unbalancedy( "50%" ); + + if ( getGUnbalanced() ) + { + unbalancedx = QString( "%1%" ).arg( getGXFactor() / 4 + 50 ); + unbalancedy = QString( "%1%" ).arg( getGYFactor() / 4 + 50 ); + } + gradientStyle.addAttribute( "draw:cx", unbalancedx ); + gradientStyle.addAttribute( "draw:cy", unbalancedy ); + + switch( getGType() ) + { + case BCT_PLAIN: + gradientStyle.addAttribute( "draw:angle", 0 ); + gradientStyle.addAttribute( "draw:style", "linear" ); + break; + case BCT_GHORZ: + gradientStyle.addAttribute( "draw:angle", 0 ); + gradientStyle.addAttribute( "draw:style", "linear" ); + break; + case BCT_GVERT: + gradientStyle.addAttribute( "draw:angle", 900 ); + gradientStyle.addAttribute( "draw:style", "linear" ); + break; + case BCT_GDIAGONAL1: + gradientStyle.addAttribute( "draw:angle", 450 ); + gradientStyle.addAttribute( "draw:style", "linear" ); + break; + case BCT_GDIAGONAL2: + gradientStyle.addAttribute( "draw:angle", 135 ); + gradientStyle.addAttribute( "draw:style", "linear" ); + break; + case BCT_GCIRCLE: + gradientStyle.addAttribute( "draw:angle", 0 ); + gradientStyle.addAttribute( "draw:style", "radial" ); + break; + case BCT_GRECT: + gradientStyle.addAttribute( "draw:angle", 0 ); + gradientStyle.addAttribute( "draw:style", "square" ); + break; + case BCT_GPIPECROSS: + gradientStyle.addAttribute( "draw:angle", 0 ); + gradientStyle.addAttribute( "draw:style", "axial" ); + break; + case BCT_GPYRAMID: //todo fixme ! it doesn't work ! + gradientStyle.addAttribute( "draw:angle", 0 ); + gradientStyle.addAttribute( "draw:style", 0 ); + break; + } + + return mainStyles.lookup( gradientStyle, "gradient" ); +} + + +void KPrBrush::loadOasisFillStyle( KoOasisContext &context, const char * propertyType ) +{ + KoStyleStack &styleStack = context.styleStack(); + styleStack.setTypeProperties( propertyType ); + + if ( styleStack.hasAttributeNS( KoXmlNS::draw, "fill" ) ) + { + const QString fill = styleStack.attributeNS( KoXmlNS::draw, "fill" ); + kdDebug(33001) << " load object gradient fill type :" << fill << endl; + + if ( fill == "solid" || fill == "hatch" ) + { + setBrush( KoOasisStyles::loadOasisFillStyle( styleStack, fill, context.oasisStyles() ) ); + } + else if ( fill == "gradient" ) + { + QString style = styleStack.attributeNS( KoXmlNS::draw, "fill-gradient-name" ); + QDomElement* draw = context.oasisStyles().drawStyles()[style]; + + if ( draw ) + { + setGColor1( draw->attributeNS( KoXmlNS::draw, "start-color", QString::null ) ); + setGColor2( draw->attributeNS( KoXmlNS::draw, "end-color", QString::null ) ); + + QString type = draw->attributeNS( KoXmlNS::draw, "style", QString::null ); + kdDebug()<<" type :"<attributeNS( KoXmlNS::draw, "angle", QString::null ).toInt() / 10; + + // make sure the angle is between 0 and 359 + angle = abs( angle ); + angle -= ( (int) ( angle / 360 ) ) * 360; + + // What we are trying to do here is to find out if the given + // angle belongs to a horizontal, vertical or diagonal gradient. + int lower, upper, nearAngle = 0; + for ( lower = 0, upper = 45; upper < 360; lower += 45, upper += 45 ) + { + if ( upper >= angle ) + { + int distanceToUpper = abs( angle - upper ); + int distanceToLower = abs( angle - lower ); + nearAngle = distanceToUpper > distanceToLower ? lower : upper; + break; + } + } + // nearAngle should now be one of: 0, 45, 90, 135, 180... + if ( nearAngle == 0 || nearAngle == 180 ) + setGType( BCT_GHORZ ); // horizontal + else if ( nearAngle == 90 || nearAngle == 270 ) + setGType( BCT_GVERT ); // vertical + else if ( nearAngle == 45 || nearAngle == 225 ) + setGType( BCT_GDIAGONAL1 ); // diagonal 1 + else if ( nearAngle == 135 || nearAngle == 315 ) + setGType( BCT_GDIAGONAL2 ); // diagonal 2 + + if ( nearAngle == 180 || nearAngle == 270 || nearAngle == 225 || nearAngle == 315 ) + { + setGColor1( draw->attributeNS( KoXmlNS::draw, "end-color", QString::null ) ); + setGColor2( draw->attributeNS( KoXmlNS::draw, "start-color", QString::null ) ); + } + } + else if ( type == "radial" || type == "ellipsoid" ) + setGType( BCT_GCIRCLE ); // circle + else if ( type == "square" || type == "rectangular" ) + setGType( BCT_GRECT ); // rectangle + else if ( type == "axial" ) + setGType( BCT_GPIPECROSS ); // pipecross + else //safe + setGType( BCT_PLAIN ); // plain + + // Hard to map between x- and y-center settings of ooimpress + // and (un-)balanced settings of kpresenter. Let's try it. + int x, y; + if ( draw->hasAttributeNS( KoXmlNS::draw, "cx" ) ) + x = draw->attributeNS( KoXmlNS::draw, "cx", QString::null ).remove( '%' ).toInt(); + else + x = 50; + + if ( draw->hasAttributeNS( KoXmlNS::draw, "cy" ) ) + y = draw->attributeNS( KoXmlNS::draw, "cy", QString::null ).remove( '%' ).toInt(); + else + y = 50; + + if ( x == 50 && y == 50 ) + { + setGUnbalanced( false ); + setGXFactor( 100 ); + setGYFactor( 100 ); + } + else + { + setGUnbalanced( true ); + // map 0 - 100% to -200 - 200 + setGXFactor( 4 * x - 200 ); + setGYFactor( 4 * y - 200 ); + } + } + + // We have to set a brush with brushstyle != no background fill + // otherwise the properties dialog for the object won't + // display the preview for the gradient. + QBrush tmpBrush; + tmpBrush.setStyle( static_cast( 1 ) ); + setBrush( tmpBrush ); + setFillType( FT_GRADIENT ); + } + else if ( fill == "none" ) + { + //nothing + } + else if ( fill == "bitmap" ) + { + //todo + //not implementer in kpresenter... + //the drawing object is filled with the bitmap specified by the draw:fill-image-name attribute. + //QBrush implement setPixmap + //easy just add pixmap and store it. + } + } +} diff --git a/kpresenter/KPrBrush.h b/kpresenter/KPrBrush.h new file mode 100644 index 00000000..f96f6627 --- /dev/null +++ b/kpresenter/KPrBrush.h @@ -0,0 +1,50 @@ +// -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*- +/* This file is part of the KDE project + Copyright (C) 2005-2006 Thorsten Zachmann + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#ifndef KPRBRUSH_H +#define KPRBRUSH_H + +#include +#include + +#include "global.h" + +class KoGenStyle; +class KoGenStyles; +class KoOasisContext; +class QDomElement; + +class KPrBrush : public KoBrush +{ +public: + KPrBrush(); + KPrBrush( const QBrush &brush, const QColor &gColor1, const QColor &gColor2, + BCType gType, FillType fillType, bool unbalanced, + int xfactor, int yfactor ); + + void saveOasisFillStyle( KoGenStyle &styleObjectAuto, KoGenStyles& mainStyles ) const; + void loadOasisFillStyle( KoOasisContext &context, const char * propertyType ); + +private: + QString saveOasisGradientStyle( KoGenStyles& mainStyles ) const; +}; + +#endif /* KPRBRUSH_H */ + diff --git a/kpresenter/KPrBrushProperty.cpp b/kpresenter/KPrBrushProperty.cpp new file mode 100644 index 00000000..6e27e118 --- /dev/null +++ b/kpresenter/KPrBrushProperty.cpp @@ -0,0 +1,498 @@ +/* This file is part of the KDE project + Copyright (C) 2005 Thorsten Zachmann + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ +#include "KPrBrushProperty.h" + +#include "brushpropertyui.h" +#include "gradientpropertyui.h" +#include "KPrPBPreview.h" + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +KPrBrushProperty::KPrBrushProperty( QWidget *parent, const char *name, const KPrBrushCmd::Brush &brush ) + : QWidget( parent, name ) + , m_brush( brush ) +{ + QGridLayout *layout = new QGridLayout( this, 1, 1, KDialog::marginHint(), KDialog::spacingHint() ); + + m_typeCombo = new KComboBox( this ); + layout->addWidget( m_typeCombo, 0, 1 ); + m_typeCombo->insertItem( i18n( "Single Color" ) ); + m_typeCombo->insertItem( i18n( "Gradient" ) ); + m_typeCombo->insertItem( i18n( "Transparent" ) ); + QWhatsThis::add(m_typeCombo, i18n( "You can choose between Single Color, Gradient or Transparent as the type." ) ); + + QLabel *typeLabel = new QLabel( i18n( "&Type:" ), this ); + layout->addWidget( typeLabel, 0, 0 ); + typeLabel->setBuddy( m_typeCombo ); + + m_stack = new QWidgetStack( this ); + layout->addMultiCellWidget( m_stack, 1, 1, 0, 1 ); + connect( m_typeCombo, SIGNAL( activated( int ) ), + this, SLOT( slotTypeChanged( int ) ) ); + + m_brushUI = new BrushPropertyUI( m_stack ); + + m_brushUI->styleCombo->insertItem( i18n( "%1% Fill Pattern" ).arg( 100 ) ); + m_brushUI->styleCombo->insertItem( i18n( "%1% Fill Pattern" ).arg( 94 ) ); + m_brushUI->styleCombo->insertItem( i18n( "%1% Fill Pattern" ).arg( 88 ) ); + m_brushUI->styleCombo->insertItem( i18n( "%1% Fill Pattern" ).arg( 63 ) ); + m_brushUI->styleCombo->insertItem( i18n( "%1% Fill Pattern" ).arg( 50 ) ); + m_brushUI->styleCombo->insertItem( i18n( "%1% Fill Pattern" ).arg( 37 ) ); + m_brushUI->styleCombo->insertItem( i18n( "%1% Fill Pattern" ).arg( 12 ) ); + m_brushUI->styleCombo->insertItem( i18n( "%1% Fill Pattern" ).arg( 6 ) ); + m_brushUI->styleCombo->insertItem( i18n( "Horizontal Lines" ) ); + m_brushUI->styleCombo->insertItem( i18n( "Vertical Lines" ) ); + m_brushUI->styleCombo->insertItem( i18n( "Crossing Lines" ) ); + m_brushUI->styleCombo->insertItem( i18n( "Diagonal Lines ( / )" ) ); + m_brushUI->styleCombo->insertItem( i18n( "Diagonal Lines ( \\ )" ) ); + m_brushUI->styleCombo->insertItem( i18n( "Diagonal Crossing Lines" ) ); + + m_preview_color = new KPrPBPreview( m_brushUI->previewPanel, 0, KPrPBPreview::Brush ); + QHBoxLayout *hbox = new QHBoxLayout( m_brushUI->previewPanel ); + QWhatsThis::add(m_preview_color, i18n( "This displays a preview of your choices." ) ); + hbox->addWidget(m_preview_color); + + connect( m_brushUI->styleCombo, SIGNAL( activated( int ) ), + this, SLOT( slotBrushChanged() ) ); + connect( m_brushUI->colorChooser, SIGNAL( changed( const QColor& ) ), + this, SLOT( slotBrushChanged() ) ); + + m_stack->addWidget( m_brushUI, 0 ); + + m_gradientUI = new GradientPropertyUI( m_stack ); + m_gradientUI->styleCombo->insertItem( i18n( "Horizontal" ) ); + m_gradientUI->styleCombo->insertItem( i18n( "Vertical" ) ); + m_gradientUI->styleCombo->insertItem( i18n( "Diagonal 1" ) ); + m_gradientUI->styleCombo->insertItem( i18n( "Diagonal 2" ) ); + m_gradientUI->styleCombo->insertItem( i18n( "Circle" ) ); + m_gradientUI->styleCombo->insertItem( i18n( "Rectangle" ) ); + m_gradientUI->styleCombo->insertItem( i18n( "PipeCross" ) ); + m_gradientUI->styleCombo->insertItem( i18n( "Pyramid" ) ); + + m_preview_gradient = new KPrPBPreview( m_gradientUI->previewPanel, 0, KPrPBPreview::Gradient ); + hbox = new QHBoxLayout( m_gradientUI->previewPanel ); + hbox->addWidget(m_preview_gradient); + + connect( m_gradientUI->styleCombo, SIGNAL( activated( int ) ), + this, SLOT( slotBackColorTypeChanged() ) ); + connect( m_gradientUI->color1Chooser, SIGNAL( changed( const QColor& ) ), + this, SLOT( slotColor1Changed() ) ); + connect( m_gradientUI->color2Chooser, SIGNAL( changed( const QColor& ) ), + this, SLOT( slotColor2Changed() ) ); + connect( m_gradientUI->unbalancedCheckBox, SIGNAL( clicked() ), + this, SLOT( slotUnbalancedChanged() ) ); + connect( m_gradientUI->xSlider, SIGNAL( valueChanged( int ) ), + this, SLOT( slotXFactorChanged() ) ); + connect( m_gradientUI->ySlider, SIGNAL( valueChanged( int ) ), + this, SLOT( slotYFactorChanged() ) ); + + m_stack->addWidget( m_gradientUI, 1 ); + m_stack->addWidget( new QFrame(), 2 ); // the transparent case + + slotReset(); +} + + +KPrBrushProperty::~KPrBrushProperty() +{ +} + + +FillType KPrBrushProperty::getFillType() const +{ + int selected = m_typeCombo->currentItem(); + if(selected == 2) + selected = 0; + return (FillType) selected; +} + + +QBrush KPrBrushProperty::getQBrush() const +{ + QBrush brush; + + switch ( m_brushUI->styleCombo->currentItem() ) + { + case 0: + brush.setStyle( SolidPattern ); + break; + case 1: + brush.setStyle( Dense1Pattern ); + break; + case 2: + brush.setStyle( Dense2Pattern ); + break; + case 3: + brush.setStyle( Dense3Pattern ); + break; + case 4: + brush.setStyle( Dense4Pattern ); + break; + case 5: + brush.setStyle( Dense5Pattern ); + break; + case 6: + brush.setStyle( Dense6Pattern ); + break; + case 7: + brush.setStyle( Dense7Pattern ); + break; + case 8: + brush.setStyle( HorPattern ); + break; + case 9: + brush.setStyle( VerPattern ); + break; + case 10: + brush.setStyle( CrossPattern ); + break; + case 11: + brush.setStyle( BDiagPattern ); + break; + case 12: + brush.setStyle( FDiagPattern ); + break; + case 13: + brush.setStyle( DiagCrossPattern ); + break; + } + if( m_typeCombo->currentItem() == 2) + brush.setStyle( QBrush::NoBrush ); + + brush.setColor( m_brushUI->colorChooser->color() ); + + return brush; +} + + +QColor KPrBrushProperty::getGColor1()const +{ + return m_gradientUI->color1Chooser->color(); +} + + +QColor KPrBrushProperty::getGColor2()const +{ + return m_gradientUI->color2Chooser->color(); +} + + +BCType KPrBrushProperty::getGType()const +{ + return (BCType)( m_gradientUI->styleCombo->currentItem() +1 ); +} + + +bool KPrBrushProperty::getGUnbalanced()const +{ + return m_gradientUI->unbalancedCheckBox->isChecked(); +} + + +int KPrBrushProperty::getGXFactor() const +{ + return m_gradientUI->xSlider->value(); +} + + +int KPrBrushProperty::getGYFactor() const +{ + return m_gradientUI->ySlider->value(); +} + + +int KPrBrushProperty::getBrushPropertyChange() const +{ + int flags = 0; + bool fillTypeChanged = getFillType() != m_brush.fillType; + + if ( getFillType() == FT_BRUSH ) + { + QBrush brush = getQBrush(); + if ( fillTypeChanged || brush.color() != m_brush.brush.color() ) + { + flags |= KPrBrushCmd::BrushColor; + } + if ( fillTypeChanged || brush.style() != m_brush.brush.style() ) + { + flags |= KPrBrushCmd::BrushStyle; + } + if ( fillTypeChanged ) + { + flags |= KPrBrushCmd::BrushGradientSelect; + } + } + else + { + if ( fillTypeChanged || getGColor1() != m_brush.gColor1 ) + { + flags |= KPrBrushCmd::GradientColor1; + } + if ( fillTypeChanged || getGColor2() != m_brush.gColor2 ) + { + flags |= KPrBrushCmd::GradientColor2; + } + if ( fillTypeChanged || getGType() != m_brush.gType ) + { + flags |= KPrBrushCmd::GradientType; + } + if ( fillTypeChanged || getGUnbalanced() != m_brush.unbalanced ) + { + flags |= KPrBrushCmd::GradientBalanced; + } + if ( fillTypeChanged || getGXFactor() != m_brush.xfactor ) + { + flags |= KPrBrushCmd::GradientXFactor; + } + if ( fillTypeChanged || getGYFactor() != m_brush.yfactor ) + { + flags |= KPrBrushCmd::GradientYFactor; + } + if ( fillTypeChanged ) + { + flags |= KPrBrushCmd::BrushGradientSelect; + } + } + return flags; +} + + +KPrBrushCmd::Brush KPrBrushProperty::getBrush() const +{ + KPrBrushCmd::Brush brush( getQBrush(), + getGColor1(), + getGColor2(), + getGType(), + getFillType(), + getGUnbalanced(), + getGXFactor(), + getGYFactor() ); + return brush; +} + + +void KPrBrushProperty::setBrush( KPrBrushCmd::Brush &brush ) +{ + m_brush = brush; + slotReset(); +} + + +void KPrBrushProperty::apply() +{ + int flags = getBrushPropertyChange(); + + if ( flags & KPrBrushCmd::BrushGradientSelect ) + m_brush.fillType = getFillType(); + + if ( flags & KPrBrushCmd::BrushColor ) + m_brush.brush.setColor( getQBrush().color() ); + + if ( flags & KPrBrushCmd::BrushStyle ) + m_brush.brush.setStyle( getQBrush().style() ); + + if ( flags & KPrBrushCmd::GradientColor1 ) + m_brush.gColor1 = getGColor1(); + + if ( flags & KPrBrushCmd::GradientColor2 ) + m_brush.gColor2 = getGColor2(); + + if ( flags & KPrBrushCmd::GradientType ) + m_brush.gType = getGType() ; + + if ( flags & KPrBrushCmd::GradientBalanced ) + m_brush.unbalanced = getGUnbalanced() ; + + if ( flags & KPrBrushCmd::GradientXFactor ) + m_brush.xfactor = getGXFactor() ; + + if ( flags & KPrBrushCmd::GradientYFactor ) + m_brush.yfactor = getGYFactor() ; +} + + +void KPrBrushProperty::setQBrush( const QBrush &brush ) +{ + switch ( brush.style() ) + { + case NoBrush: + // TODO + break; + case SolidPattern: + m_brushUI->styleCombo->setCurrentItem( 0 ); + break; + case Dense1Pattern: + m_brushUI->styleCombo->setCurrentItem( 1 ); + break; + case Dense2Pattern: + m_brushUI->styleCombo->setCurrentItem( 2 ); + break; + case Dense3Pattern: + m_brushUI->styleCombo->setCurrentItem( 3 ); + break; + case Dense4Pattern: + m_brushUI->styleCombo->setCurrentItem( 4 ); + break; + case Dense5Pattern: + m_brushUI->styleCombo->setCurrentItem( 5 ); + break; + case Dense6Pattern: + m_brushUI->styleCombo->setCurrentItem( 6 ); + break; + case Dense7Pattern: + m_brushUI->styleCombo->setCurrentItem( 7 ); + break; + case HorPattern: + m_brushUI->styleCombo->setCurrentItem( 8 ); + break; + case VerPattern: + m_brushUI->styleCombo->setCurrentItem( 9 ); + break; + case CrossPattern: + m_brushUI->styleCombo->setCurrentItem( 10 ); + break; + case BDiagPattern: + m_brushUI->styleCombo->setCurrentItem( 11 ); + break; + case FDiagPattern: + m_brushUI->styleCombo->setCurrentItem( 12 ); + break; + case DiagCrossPattern: + m_brushUI->styleCombo->setCurrentItem( 13 ); + break; + case CustomPattern: + break; + } + + m_brushUI->colorChooser->setColor( brush.color() ); + m_preview_color->setBrush( brush ); +} + + +void KPrBrushProperty::setGradient( const QColor &_c1, const QColor &_c2, BCType _t, + bool _unbalanced, int _xfactor, int _yfactor ) +{ + m_gradientUI->styleCombo->setCurrentItem( (int) _t - 1 ); + m_gradientUI->color1Chooser->setColor( _c1 ); + m_gradientUI->color2Chooser->setColor( _c2 ); + m_gradientUI->unbalancedCheckBox->setChecked( _unbalanced ); + setUnbalancedEnabled( _unbalanced ); + m_gradientUI->xSlider->setValue( _xfactor ); + m_gradientUI->ySlider->setValue( _yfactor ); + m_preview_gradient->setGradient( _c1, _c2, _t, _unbalanced, _xfactor, _yfactor ); +} + + +void KPrBrushProperty::setUnbalancedEnabled( bool state ) +{ + m_gradientUI->xFactorLabel->setEnabled( state ); + m_gradientUI->xSlider->setEnabled( state ); + m_gradientUI->yFactorLabel->setEnabled( state ); + m_gradientUI->ySlider->setEnabled( state ); +} + + +void KPrBrushProperty::slotReset() +{ + if ( m_brush.gType == BCT_PLAIN ) + m_brush.gType = BCT_GHORZ; + setQBrush( m_brush.brush ); + setGradient( m_brush.gColor1, + m_brush.gColor2, + m_brush.gType, + m_brush.unbalanced, + m_brush.xfactor, + m_brush.yfactor ); + + int panelIndex; + if( m_brush.fillType == FT_BRUSH && m_brush.brush.style() == QBrush::NoBrush ) + panelIndex = 2; + else + panelIndex = (int)m_brush.fillType; + + m_typeCombo->setCurrentItem( panelIndex ); + slotTypeChanged( panelIndex ); +} + + +void KPrBrushProperty::slotTypeChanged( int pos ) +{ + m_stack->raiseWidget( pos ); + slotBrushChanged(); +} + + +void KPrBrushProperty::slotBrushChanged() +{ + m_preview_color->setBrush( getQBrush() ); +} + + +void KPrBrushProperty::slotColor1Changed() +{ + m_preview_gradient->setColor1( getGColor1() ); +} + + +void KPrBrushProperty::slotColor2Changed() +{ + m_preview_gradient->setColor2( getGColor2() ); +} + + +void KPrBrushProperty::slotBackColorTypeChanged() +{ + BCType type = getGType(); + m_preview_gradient->setBackColorType( type ); + m_gradientUI->xSlider->setEnabled( type != 1 ); + m_gradientUI->ySlider->setEnabled( type != 2 ); +} + + +void KPrBrushProperty::slotUnbalancedChanged() +{ + bool state = getGUnbalanced(); + setUnbalancedEnabled( state ); + m_preview_gradient->setUnbalanced( state ); + + slotBackColorTypeChanged(); // make sure the sliders enabled-ness is up-to-date +} + + +void KPrBrushProperty::slotXFactorChanged() +{ + m_preview_gradient->setXFactor( getGXFactor() ); +} + + +void KPrBrushProperty::slotYFactorChanged() +{ + m_preview_gradient->setYFactor( getGYFactor() ); +} + +#include "KPrBrushProperty.moc" diff --git a/kpresenter/KPrBrushProperty.h b/kpresenter/KPrBrushProperty.h new file mode 100644 index 00000000..1a49c685 --- /dev/null +++ b/kpresenter/KPrBrushProperty.h @@ -0,0 +1,88 @@ +/* This file is part of the KDE project + Copyright (C) 2005 Thorsten Zachmann + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ +#ifndef BRUSHSTYLEWIDGET_H +#define BRUSHSTYLEWIDGET_H + +#include +#include + +#include "KPrCommand.h" + +class BrushPropertyUI; +class GradientPropertyUI; +class KPrPBPreview; + +class QWidgetStack; + +class KComboBox; + + +class KPrBrushProperty : public QWidget +{ + Q_OBJECT +public: + KPrBrushProperty( QWidget *parent, const char *name, const KPrBrushCmd::Brush &brush ); + ~KPrBrushProperty(); + + int getBrushPropertyChange() const; + KPrBrushCmd::Brush getBrush() const; + + void setBrush( KPrBrushCmd::Brush &brush ); + + void apply(); + +protected: + FillType getFillType() const; + QBrush getQBrush() const; + + QColor getGColor1() const; + QColor getGColor2() const; + BCType getGType() const; + bool getGUnbalanced() const; + int getGXFactor() const; + int getGYFactor() const; + + void setQBrush( const QBrush &brush ); + void setGradient( const QColor &_c1, const QColor &_c2, BCType _t, + bool _unbalanced, int _xfactor, int _yfactor ); + void setUnbalancedEnabled( bool state ); + + KComboBox *m_typeCombo; + QWidgetStack *m_stack; + BrushPropertyUI *m_brushUI; + GradientPropertyUI *m_gradientUI; + KPrPBPreview *m_preview_color; + KPrPBPreview *m_preview_gradient; + + KPrBrushCmd::Brush m_brush; + +protected slots: + void slotReset(); + void slotTypeChanged( int pos ); + void slotBrushChanged(); + + void slotColor1Changed(); + void slotColor2Changed(); + void slotBackColorTypeChanged(); + void slotUnbalancedChanged(); + void slotXFactorChanged(); + void slotYFactorChanged(); +}; + +#endif /* BRUSHSTYLEWIDGET_H */ diff --git a/kpresenter/KPrCanvas.cpp b/kpresenter/KPrCanvas.cpp new file mode 100644 index 00000000..965a3fd4 --- /dev/null +++ b/kpresenter/KPrCanvas.cpp @@ -0,0 +1,5704 @@ +/* This file is part of the KDE project + Copyright (C) 1998, 1999 Reginald Stadlbauer + Copyright (C) 2002-2005 Thorsten Zachmann + Copyright (C) 2005 Casper Boemann Rasmussen + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include "KoPointArray.h" +#include + +#include "KPrView.h" +#include "KPrBackground.h" +#include "KPrPixmapObject.h" +#include "KPrFreehandObject.h" +#include "KPrBezierCurveObject.h" +#include "KPrGotoPage.h" +#include "KPrTextObject.h" +#include "KPrSoundPlayer.h" +#include "KPrNoteBar.h" +#include "KPrPartObject.h" +#include "KPrUtils.h" +#include "KPrCommand.h" +#include "KPrPolylineObject.h" +#include "KPrClosedLineObject.h" +#include "KPrPage.h" +#include "KPrVariableCollection.h" +#include "KPrGroupObject.h" +#include "KPrDocument.h" + +#include "KPrCanvas.h" +#include "KPrCanvas.moc" + +#include "KPrEffectHandler.h" +#include "KPrPageEffects.h" +#include + +const int KPrCanvas::MOUSE_SNAP_DISTANCE = 4; +const int KPrCanvas::KEY_SNAP_DISTANCE = 2; + +KPrCanvas::KPrCanvas( QWidget *parent, const char *name, KPrView *_view ) +: QWidget( parent, name, WStaticContents|WResizeNoErase|WRepaintNoErase ) +, buffer( size() ) +, m_gl( _view, _view->zoomHandler() ) +, m_paintGuides( false ) +, m_objectDisplayAbove( 0 ) +{ + m_presMenu = 0; + m_currentTextObjectView=0L; + m_activePage=0L; + m_xOffset = 0; + m_yOffset = 0; + m_prevSpokenTO = 0; + + m_keyPressEvent = false; + m_drawSymetricObject = false; + if ( parent ) { + showingLastSlide = false; + mousePressed = false; + drawContour = false; + modType = MT_NONE; + m_resizeObject = 0; + m_editObject = 0; + m_rotateObject = 0; + setBackgroundMode( Qt::NoBackground ); + m_view = _view; + setupMenus(); + setMouseTracking( true ); + show(); + editMode = true; + m_step.m_pageNumber = 0; + m_step.m_step = 0; + m_step.m_subStep = 0; + goingBack = false; + m_drawMode = false; + fillBlack = true; + drawRubber = false; + m_zoomRubberDraw = false; + toolEditMode = TEM_MOUSE; + setAcceptDrops( true ); + m_ratio = 0.0; + m_isMoving = false; + m_isResizing = false; + mouseSelectedObject = false; + m_setPageTimer = true; + m_drawLineInDrawMode = false; + soundPlayer = 0; + m_disableSnapping = false; + m_drawPolyline = false; + m_drawCubicBezierCurve = false; + m_drawLineWithCubicBezierCurve = true; + m_oldCubicBezierPointArray.putPoints( 0, 4, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0 ); + m_effectHandler = 0; + m_pageEffect = 0; + } else { + m_view = 0; + hide(); + } + + setFocusPolicy( QWidget::StrongFocus ); + setFocus(); + setKeyCompression( true ); + setInputMethodEnabled( true ); // ensure using the InputMethod + installEventFilter( this ); + KCursor::setAutoHideCursor( this, true, true ); + m_zoomBeforePresentation=100; + + if( m_view) + { + m_activePage=m_view->kPresenterDoc()->pageList().getFirst(); + connect( m_view->kPresenterDoc(), SIGNAL( sig_terminateEditing( KPrTextObject * ) ), + this, SLOT( terminateEditing( KPrTextObject * ) ) ); + connect( m_view, SIGNAL( autoScroll( const QPoint & )), this, SLOT( slotAutoScroll( const QPoint &))); + } + + if ( kospeaker ) + connect( kospeaker, SIGNAL( customSpeakWidget(QWidget*, const QPoint&, uint) ), + this, SLOT( speakTextUnderMouse(QWidget*, const QPoint&, uint) ) ); +} + +KPrCanvas::~KPrCanvas() +{ + // block all signals (save for destroyed()) to avoid crashes on exit + // (exitEditMode) emits signals + blockSignals(true); + + exitEditMode( false ); + + delete m_presMenu; + + stopSound(); + delete soundPlayer; + blockSignals(false); +} + +void KPrCanvas::scrollX( int x ) +{ + // Relative movement + int dx = m_xOffset - x; + // new position + m_xOffset = x; + bitBlt( &buffer, dx, 0, &buffer ); + scroll( dx, 0 ); +} + +void KPrCanvas::scrollY( int y ) +{ + // Relative movement + int dy = m_yOffset - y; + // new position + m_yOffset = y; + bitBlt( &buffer, 0, dy, &buffer ); + scroll( 0, dy ); +} + +bool KPrCanvas::eventFilter( QObject *o, QEvent *e ) +{ + if ( !o || !e ) + return TRUE; + if ( m_currentTextObjectView ) + KCursor::autoHideEventFilter( o, e ); + switch ( e->type() ) + { + case QEvent::FocusIn: + if ( m_currentTextObjectView ) + m_currentTextObjectView->focusInEvent(); + return TRUE; + case QEvent::FocusOut: + if ( m_currentTextObjectView ) + m_currentTextObjectView->focusOutEvent(); + return TRUE; + case QEvent::KeyPress: + { + QKeyEvent * keyev = static_cast(e); + if ( keyev->key() == KGlobalSettings::contextMenuKey() ) { + popupContextMenu(); + return true; + } + if ( m_currentTextObjectView && + (keyev->key()==Qt::Key_Home ||keyev->key()==Key_End + || keyev->key()==Qt::Key_Tab || keyev->key()==Key_Prior + || keyev->key()==Qt::Key_Next || keyev->key() == Key_Backtab) ) + { + m_currentTextObjectView->keyPressEvent( keyev ); + return true; + } + else if ( !m_currentTextObjectView && keyev->key()==Qt::Key_Tab ) + { + keyPressEvent(keyev); + return true; + } + break; + } + case QEvent::AccelOverride: + { +#ifndef NDEBUG + QKeyEvent * keyev = static_cast(e); + // Debug keys + if ( ( keyev->state() & ControlButton ) && ( keyev->state() & ShiftButton ) ) + { + switch ( keyev->key() ) { + case Qt::Key_P: // 'P' -> paragraph debug + printRTDebug( 0 ); + keyev->accept(); + break; + case Qt::Key_V: // 'V' -> verbose parag debug + printRTDebug( 1 ); + keyev->accept(); + break; + default: + break; + } + } +#endif + break; + } + default: + break; + } + return QWidget::eventFilter(o,e); +} + +bool KPrCanvas::focusNextPrevChild( bool ) +{ + return TRUE; // Don't allow to go out of the canvas widget by pressing "Tab" +} + +void KPrCanvas::paintEvent( QPaintEvent* paintEvent ) +{ + if ( isUpdatesEnabled() ) + { + //kdDebug(33001) << "KPrCanvas::paintEvent m_paintGuides = " << m_paintGuides << endl; //<< " " << kdBacktrace( 10 ) << endl; + KPrDocument *doc =m_view->kPresenterDoc(); + + if ( ! m_paintGuides ) + { + //kdDebug(33001) << "KPrCanvas::paintEvent" << endl; + QPainter bufPainter; + bufPainter.begin( &buffer, this ); // double-buffering - (the buffer is as big as the widget) + bufPainter.translate( -diffx(), -diffy() ); + bufPainter.setBrushOrigin( -diffx(), -diffy() ); + + QRect crect( paintEvent->rect() ); // the rectangle that needs to be repainted, in widget coordinates + bufPainter.setClipRect( crect ); + + //kdDebug(33001) << "KPrCanvas::paintEvent " << DEBUGRECT( crect ) << ", " << size() << endl; + + crect.moveBy( diffx(), diffy() ); // now in contents coordinates + //kdDebug(33001) << "KPrCanvas::paintEvent after applying diffx/diffy: " << DEBUGRECT( crect ) << endl; + + if ( editMode || !fillBlack ) + bufPainter.fillRect( crect, white ); + else + bufPainter.fillRect( crect, black ); + + KPrPage * page = editMode ? m_activePage : doc->pageList().at( m_step.m_pageNumber ); + drawBackground( &bufPainter, crect, page, editMode ); + + if ( editMode ) + { + SelectionMode selectionMode; + + if ( toolEditMode == TEM_MOUSE || toolEditMode == TEM_ZOOM ) + selectionMode = SM_MOVERESIZE; + else if ( toolEditMode == TEM_ROTATE ) + selectionMode = SM_ROTATE; + else + selectionMode = SM_NONE; + + if ( doc->showGrid() ) + drawGrid( &bufPainter, crect ); + + drawEditPage( &bufPainter, crect, page, selectionMode ); + } + else + { + // Center the slide in the screen, if it's smaller... +#if 0 // this works but isn't enough - e.g. object effects need the same offsets + // so we should store them, but they don't work like diffx/diffy... + // (e.g. the painter mustn't be translated when painting the background) + QRect desk = KGlobalSettings::desktopGeometry(this); + QRect pgRect = m_view->kPresenterDoc()->pageList().at(0)->getZoomPageRect(); + int offx = 0, offy = 0; + if ( desk.width() > pgRect.width() ) + offx = ( desk.width() - pgRect.width() ) / 2; + if ( desk.height() > pgRect.height() ) + offy = ( desk.height() - pgRect.height() ) / 2; + bufPainter.translate( offx, offy ); +#endif + + PresStep step( m_step.m_pageNumber, m_step.m_step, m_step.m_subStep, m_effectTimer.isActive(), !goingBack ); + drawPresPage( &bufPainter, crect, step ); + if ( m_drawMode && m_drawModeLines.count() ) + { + bufPainter.save(); + bufPainter.setPen( m_view->kPresenterDoc()->presPen() ); + for ( unsigned int i = 0; i < m_drawModeLines.count(); ++i ) + { + bufPainter.drawPolyline( m_drawModeLines[i] ); + } + bufPainter.restore(); + } + } + + bufPainter.end(); + } + + + QPixmap topBuffer( buffer ); + QPainter topPainter( &topBuffer, &buffer ); + topPainter.translate( -diffx(), -diffy() ); + topPainter.setBrushOrigin( -diffx(), -diffy() ); + + if ( editMode && doc->showGuideLines() ) + { + m_gl.paintGuides( topPainter ); + } + + topPainter.setPen( QPen( Qt::black, 1, Qt::SolidLine ) ); + topPainter.setRasterOp( NotROP ); + switch ( toolEditMode ) + { + case MT_NONE: + if ( drawRubber ) + { + topPainter.setPen( QPen( black, 0, DotLine ) ); + topPainter.drawRect( m_view->zoomHandler()->zoomRect( m_rubber ) ); + } + break; + case INS_RECT: + if ( !m_insertRect.isNull() ) + { + topPainter.drawRoundRect( m_view->zoomHandler()->zoomRect( m_insertRect.normalize() ), + m_view->getRndX(), m_view->getRndY() ); + } + break; + case INS_ELLIPSE: + if ( !m_insertRect.isNull() ) + { + topPainter.drawEllipse( m_view->zoomHandler()->zoomRect( m_insertRect.normalize() ) ); + } + break; + case INS_AUTOFORM: + case INS_DIAGRAMM: + case INS_FORMULA: + case INS_CLIPART: + case INS_PICTURE: + case INS_OBJECT: + case INS_TABLE: + case INS_TEXT: + if ( !m_insertRect.isNull() ) + { + topPainter.drawRect( m_view->zoomHandler()->zoomRect( m_insertRect.normalize() ) ); + } + break; + case INS_PIE: + if ( !m_insertRect.isNull() ) + { + drawPieObject( &topPainter, m_insertRect ); + } + break; + case INS_LINE: + topPainter.drawLine( m_view->zoomHandler()->zoomPoint( m_startPoint ), + m_view->zoomHandler()->zoomPoint( m_endPoint ) ); + break; + case INS_FREEHAND: + case INS_CLOSED_FREEHAND: + case INS_POLYLINE: + case INS_CLOSED_POLYLINE: + { + QPointArray pointArray = m_pointArray.zoomPointArray( m_view->zoomHandler() ); + topPainter.drawPolyline( pointArray ); + topPainter.drawLine( m_view->zoomHandler()->zoomPoint( m_startPoint ), + m_view->zoomHandler()->zoomPoint( m_endPoint ) ); + } break; + case INS_QUADRICBEZIERCURVE: + case INS_CUBICBEZIERCURVE: + case INS_CLOSED_QUADRICBEZIERCURVE: + case INS_CLOSED_CUBICBEZIERCURVE: + if ( m_drawCubicBezierCurve ) + { + if ( m_indexPointArray > 0 ) + { + redrawCubicBezierCurve( topPainter ); + drawCubicBezierCurve( topPainter, m_oldCubicBezierPointArray ); + } + } + break; + case INS_POLYGON: + drawPolygon( topPainter, m_insertRect ); + break; + default: + break; + } + topPainter.end(); + bitBlt( this, paintEvent->rect().topLeft(), &topBuffer, paintEvent->rect() ); + } + //else kdDebug(33001) << "KPrCanvas::paintEvent with updates disabled" << endl; +} + + +void KPrCanvas::drawBackground( QPainter *painter, const QRect& rect, KPrPage * page, bool edit ) const +{ + if ( edit ) + { + QRect pageRect = page->getZoomPageRect(); + + if ( rect.intersects( pageRect ) ) + { + if ( page->displayBackground() ) + { + if ( page->masterPage() && page->useMasterBackground() ) + page->masterPage()->background()->drawBackground( painter, m_view->zoomHandler(), rect, true ); + else + page->background()->drawBackground( painter, m_view->zoomHandler(), rect, true ); + } + } + // Include the border + pageRect.rLeft() -= 1; + pageRect.rTop() -= 1; + pageRect.rRight() += 1; + pageRect.rBottom() += 1; + + QRegion grayRegion( rect ); + grayRegion -= pageRect; + + // In edit mode we also want to draw the gray area out of the pages + if ( !grayRegion.isEmpty() ) + eraseEmptySpace( painter, grayRegion, QApplication::palette().active().brush( QColorGroup::Mid ) ); + } + else + { + // Old code, left a black area if zoomX != zoomY + //page->background()->draw( painter, m_view->zoomHandler(), rect, false ); + + QRect desk = KGlobalSettings::desktopGeometry(getView()); + QRect crect = desk.intersect( rect ); + if ( crect.isEmpty() || !page->displayBackground()) + return; + + if ( page->masterPage() && page->useMasterBackground() ) + page->masterPage()->background()->drawBackground( painter, desk.size(), crect, false ); + else + page->background()->drawBackground( painter, desk.size(), crect, false ); + } +} + + +// 100% stolen from KWord +void KPrCanvas::eraseEmptySpace( QPainter * painter, const QRegion & emptySpaceRegion, const QBrush & brush ) const +{ + painter->save(); + painter->setClipRegion( emptySpaceRegion, QPainter::CoordPainter ); + painter->setPen( Qt::NoPen ); + + //kdDebug(33001) << "KWDocument::eraseEmptySpace emptySpaceRegion: " << DEBUGRECT( emptySpaceRegion.boundingRect() ) << endl; + painter->fillRect( emptySpaceRegion.boundingRect(), brush ); + painter->restore(); +} + + +void KPrCanvas::drawObjects( QPainter *painter, const QPtrList &objects, SelectionMode selectionMode, + bool contour, KPrTextView * textView, int pageNum ) const +{ + QPtrListIterator it( objects ); + for ( ; it.current(); ++it ) + { + SelectionMode selMode = selectionMode; + if ( selectionMode != SM_NONE + && it.current()->isSelected() + && ( m_view->kPresenterDoc()->isHeaderFooter(it.current()) + || it.current()->isProtect() ) ) + selMode = SM_PROTECT; + + it.current()->draw( painter, m_view->zoomHandler(), pageNum, selMode, (it.current()->isSelected()) && contour ); + + it.current()->setSubPresStep( 0 ); + it.current()->doSpecificEffects( false ); + } + + if ( textView ) + { + textView->kpTextObject()->paintEdited( painter, m_view->zoomHandler(), false /*onlyChanged. Pass as param ?*/, + textView->cursor(), true /* idem */ ); + } +} + + +void KPrCanvas::drawObjectsPres( QPainter *painter, const QPtrList &_objects, PresStep step ) const +{ + QPtrList objects; + + QPtrListIterator it( _objects ); + for ( ; it.current(); ++it ) + { + if ( objectIsAHeaderFooterHidden(it.current()) ) + continue; + if ( it.current()->getAppearStep() <= step.m_step + && ( ! it.current()->getDisappear() + || it.current()->getDisappear() + && it.current()->getDisappearStep() > step.m_step ) ) + { + if ( step.m_animate && it.current()->getAppearStep() == step.m_step && it.current()->getEffect() != EF_NONE ) + continue; + + if ( step.m_animateSub && it.current()->getAppearStep() == step.m_step ) + { + it.current()->setSubPresStep( step.m_subStep ); + it.current()->doSpecificEffects( true, false ); + } + + objects.append( it.current() ); + } + } + drawObjects( painter, objects, SM_NONE, false, NULL, step.m_pageNumber ); +} + + +void KPrCanvas::drawObjectsEdit( QPainter *painter, const KoRect &rect, const QPtrList &_objects, + SelectionMode selectionMode, int pageNum ) const +{ + QPtrList objects; + + KPrTextView * textView = NULL; + QPtrListIterator it( _objects ); + for ( ; it.current(); ++it ) + { + if ( objectIsAHeaderFooterHidden(it.current()) ) + continue; + + if ( rect.intersects( it.current()->getRepaintRect() ) ) + { + if ( m_currentTextObjectView && m_currentTextObjectView->kpTextObject() == it.current() ) + { + textView = m_currentTextObjectView; + } + + objects.append( it.current() ); + } + } + drawObjects( painter, objects, selectionMode, drawContour, textView, pageNum ); +} + + +void KPrCanvas::drawEditPage( QPainter *painter, const QRect &_rect, + KPrPage *page, SelectionMode selectionMode ) const +{ + KoRect rect = m_view->zoomHandler()->unzoomRect(_rect); + + int pageNum = m_view->kPresenterDoc()->pageList().findRef( page ); + //objects on master page + if ( page->masterPage() && page->displayObjectFromMasterPage() ) + drawObjectsEdit( painter, rect, page->masterPage()->objectList(), selectionMode, pageNum ); + //objects on current page + drawObjectsEdit( painter, rect, displayObjectList(), selectionMode, pageNum ); +} + + +void KPrCanvas::drawPresPage( QPainter *painter, const QRect &_rect, PresStep step ) const +{ + KoRect rect = m_view->zoomHandler()->unzoomRect(_rect); + + KPrPage * page = m_view->kPresenterDoc()->pageList().at(step.m_pageNumber); + //objects on master page + if ( page->masterPage() && page->displayObjectFromMasterPage() ) + drawObjectsPres( painter, page->masterPage()->objectList(), step ); + //objects on current page + drawObjectsPres( painter, page->objectList(), step ); +} + + +void KPrCanvas::drawGrid(QPainter *painter, const QRect &rect2) const +{ + KPrDocument *doc=m_view->kPresenterDoc(); + + if(!doc->isReadWrite()) + return; + QPen _pen = QPen( doc->gridColor(), 6, Qt::DotLine ); + painter->save(); + painter->setPen( _pen ); + QRect pageRect = m_activePage->getZoomPageRect(); + + int zoomedX, zoomedY; + double offsetX = doc->getGridX(); + double offsetY = doc->getGridY(); + + for ( double i = offsetX; ( zoomedX = m_view->zoomHandler()->zoomItX( i )+pageRect.left() ) < pageRect.right(); i += offsetX ) + for ( double j = offsetY; ( zoomedY = m_view->zoomHandler()->zoomItY( j )+pageRect.top() ) < pageRect.bottom(); j += offsetY ) + if( rect2.contains( zoomedX, zoomedY ) ) + painter->drawPoint( zoomedX, zoomedY ); + + painter->restore(); +} + + +// This one is used to generate the pixmaps for the HTML presentation, +// for the pres-structure-dialog, for the sidebar previews, for template icons. +void KPrCanvas::drawAllObjectsInPage( QPainter *painter, const QPtrList & obj, int pageNum ) const +{ + QPtrListIterator it( obj ); + for ( ; it.current(); ++it ) { + if ( objectIsAHeaderFooterHidden( it.current() ) ) + continue; + it.current()->draw( painter, m_view->zoomHandler(), pageNum, SM_NONE, false ); + } +} + +void KPrCanvas::recalcAutoGuides( ) +{ + QValueList horizontalPos; + QValueList verticalPos; + QPtrListIterator it( m_activePage->objectList() ); + for ( ; it.current(); ++it ) + { + if( ! it.current()->isSelected() ) + it.current()->addSelfToGuides( horizontalPos, verticalPos); + } + + m_gl.setAutoGuideLines( horizontalPos, verticalPos ); +} + +void KPrCanvas::mousePressEvent( QMouseEvent *e ) +{ + QPoint contentsPoint( e->pos().x()+diffx(), e->pos().y()+diffy() ); + KoPoint docPoint = m_view->zoomHandler()->unzoomPoint( contentsPoint ); + m_insertRect = KoRect(); + + if(!m_view->koDocument()->isReadWrite()) + return; + + if ( editMode && m_view->kPresenterDoc()->showGuideLines() && toolEditMode == TEM_MOUSE && m_gl.mousePressEvent( e ) ) + return; + + m_moveStartPosMouse = objectRect( false ).topLeft(); + if(m_currentTextObjectView) + { + KPrTextObject *txtObj=m_currentTextObjectView->kpTextObject(); + Q_ASSERT(txtObj); + if(txtObj->contains( docPoint )) + { + KoPoint pos = docPoint - txtObj->innerRect().topLeft(); // in pt, but now translated into the object's coordinate system + // This is common to all mouse buttons, so that RMB and MMB place the cursor too + m_currentTextObjectView->mousePressEvent(e, m_view->zoomHandler()->ptToLayoutUnitPix( pos ) ); // in LU pixels + mousePressed = true; + m_view->enableAutoScroll(); + if(e->button() == RightButton) + { + m_currentTextObjectView->showPopup( m_view, QCursor::pos(), m_view->actionList() ); + m_view->disableAutoScroll(); + mousePressed=false; + } + else if( e->button() == MidButton ) + { + QApplication::clipboard()->setSelectionMode( true ); + m_currentTextObjectView->paste(); + QApplication::clipboard()->setSelectionMode( false ); + } + return; + } + } + + + KPrObject *kpobject = 0; + + m_disableSnapping = e->state() & ShiftButton; + + exitEditMode(); + + if ( editMode ) { + if ( e->button() == LeftButton ) { + mousePressed = true; + m_view->enableAutoScroll(); + + if ( m_drawPolyline && ( toolEditMode == INS_POLYLINE || toolEditMode == INS_CLOSED_POLYLINE ) ) + { + m_startPoint = snapPoint( docPoint ); + m_pointArray.putPoints( m_indexPointArray, 1, m_startPoint.x(), m_startPoint.y() ); + + ++m_indexPointArray; + return; + } + + if ( m_drawCubicBezierCurve && ( toolEditMode == INS_CUBICBEZIERCURVE + || toolEditMode == INS_QUADRICBEZIERCURVE + || toolEditMode == INS_CLOSED_CUBICBEZIERCURVE + || toolEditMode == INS_CLOSED_QUADRICBEZIERCURVE ) ) { + if ( m_drawLineWithCubicBezierCurve ) { + QPainter p( this ); + p.setPen( QPen( Qt::black, 1, Qt::SolidLine ) ); + p.setBrush( Qt::NoBrush ); + p.setRasterOp( Qt::NotROP ); + + p.translate( -diffx(), -diffy() ); + KoPoint newStartPoint = snapPoint( docPoint ); + + p.drawLine( m_view->zoomHandler()->zoomPoint( m_startPoint ), + m_view->zoomHandler()->zoomPoint( newStartPoint ) ); + + m_startPoint = newStartPoint; + p.end(); + + m_pointArray.putPoints( m_indexPointArray, 1, m_startPoint.x(), m_startPoint.y() ); + + ++m_indexPointArray; + m_drawLineWithCubicBezierCurve = false; + } + else { + QPainter p( this ); + QPen _pen = QPen( Qt::black, 1, Qt::DashLine ); + p.setPen( _pen ); + p.setBrush( Qt::NoBrush ); + p.setRasterOp( Qt::NotROP ); + + p.translate( -diffx(), -diffy() ); + p.save(); + + KoPoint endPoint = snapPoint( docPoint ); + + double angle = KoPoint::getAngle( endPoint, m_startPoint ); + + drawFigure( L_SQUARE, &p, endPoint, _pen.color(), _pen.width(), angle, m_view->zoomHandler() ); // erase old figure + + p.restore(); + + p.drawLine( m_view->zoomHandler()->zoomPoint( m_startPoint ), + m_view->zoomHandler()->zoomPoint( endPoint ) );// erase old line + + m_symmetricEndPoint = m_startPoint * 2 - endPoint; + + p.save(); + angle = KoPoint::getAngle( m_symmetricEndPoint, m_startPoint ); + + drawFigure( L_SQUARE, &p, m_symmetricEndPoint, _pen.color(), _pen.width(), angle, m_view->zoomHandler() ); // erase old figure + + p.restore(); + + p.drawLine( m_view->zoomHandler()->zoomPoint( m_startPoint ), + m_view->zoomHandler()->zoomPoint( m_symmetricEndPoint ) );// erase old line + + m_pointArray.putPoints( m_indexPointArray, 3, m_CubicBezierSecondPoint.x(), m_CubicBezierSecondPoint.y(), + m_CubicBezierThirdPoint.x(), m_CubicBezierThirdPoint.y(), + m_startPoint.x(), m_startPoint.y() ); + m_indexPointArray += 3; + m_drawLineWithCubicBezierCurve = true; + m_oldCubicBezierPointArray = KoPointArray(); + m_oldCubicBezierPointArray.putPoints( 0, 4, (double)0,(double)0, (double)0,(double)0, + (double)0,(double)0, (double)0,(double)0 ); + m_endPoint = m_startPoint; + } + + return; + } + + switch ( toolEditMode ) { + case TEM_MOUSE: { + KPrObject *kpobject = getObjectAt( docPoint, true ); + + if ( kpobject ) { + // use ctrl + Button to select / deselect object + if ( e->state() & ControlButton && kpobject->isSelected() ) + deSelectObj( kpobject ); + else if ( e->state() & ControlButton ) + { + selectObj( kpobject ); + raiseObject( kpobject ); + m_moveStartPosMouse = objectRect( false ).topLeft(); + } + else + { + if ( modType != MT_MOVE || !kpobject->isSelected() ) + deSelectAllObj(); + + selectObj( kpobject ); + raiseObject( kpobject ); + m_moveStartPosMouse = objectRect( false ).topLeft(); + } + + // start resizing + if ( modType != MT_MOVE && modType != MT_NONE ) + { + deSelectAllObj(); + selectObj( kpobject ); + raiseObject( kpobject ); + + m_resizeObject = kpobject; + + m_ratio = static_cast( kpobject->getSize().width() ) / + static_cast( kpobject->getSize().height() ); + m_rectBeforeResize = kpobject->getRect(); + } + recalcAutoGuides(); + if ( m_view->kPresenterDoc()->showGuideLines() && !m_disableSnapping ) + { + m_gl.repaintSnapping( objectRect( false ) ); + } + } + else + { + KPrPage *masterPage = m_activePage->masterPage(); + if ( masterPage && m_activePage->displayObjectFromMasterPage() ) + { + kpobject = masterPage->getObjectAt( docPoint, true ); + + if ( kpobject && objectIsAHeaderFooterHidden( kpobject ) ) + { + kpobject = 0; + } + } + + if ( kpobject ) + { + mousePressed = false; + QString msg( i18n( "The object you are trying to select belongs to the master slide. " + "Editing the object can only be done on the master slide.\n" + "Go there now?" ) ); + m_view->disableAutoScroll(); // needed because the messagebox 'eats' the mouseRelease + if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) + { + getView()->setEditMaster( true ); + selectObj( kpobject ); + raiseObject( kpobject ); + m_moveStartPosMouse = objectRect( false ).topLeft(); + } + else + { + deSelectAllObj(); + modType = MT_NONE; + } + } + else { + modType = MT_NONE; + if ( !( e->state() & ShiftButton ) && !( e->state() & ControlButton ) ) + deSelectAllObj(); + + drawRubber = true; + m_rubber = KoRect( docPoint.x(), docPoint.y(), 0, 0 ); + } + } + m_origMousePos = docPoint; + } break; + case TEM_ZOOM: { + modType = MT_NONE; + drawRubber = true; + m_zoomRubberDraw = false; + m_rubber = KoRect( docPoint.x(), docPoint.y(), 0, 0 ); + }break; + case TEM_ROTATE: + { + KPrObject *kpobject = getObjectAt( docPoint ); + + // clear old selections even if shift or control are pressed + // we don't support rotating multiple objects yet + deSelectAllObj(); + + if ( kpobject && !kpobject->isProtect()) + { + m_rotateObject = kpobject; + m_rotateStart = docPoint; + m_angleBeforeRotate = kpobject->getAngle(); + selectObj( kpobject ); + raiseObject( kpobject ); + + // set center of selected object bounding rect + m_rotateCenter = kpobject->getRealRect().center(); + } + } break; + case INS_LINE: + deSelectAllObj(); + recalcAutoGuides(); + mousePressed = true; + + m_startPoint = snapPoint( docPoint ); + m_endPoint = m_startPoint; + break; + case INS_FREEHAND: case INS_CLOSED_FREEHAND: { + deSelectAllObj(); + recalcAutoGuides(); + mousePressed = true; + + m_indexPointArray = 0; + m_startPoint = snapPoint( docPoint ); + m_endPoint = m_startPoint; + m_pointArray.putPoints( m_indexPointArray, 1, m_startPoint.x(), m_startPoint.y() ); + ++m_indexPointArray; + } break; + case INS_POLYLINE: case INS_CLOSED_POLYLINE: { + deSelectAllObj(); + recalcAutoGuides(); + mousePressed = true; + + m_drawPolyline = true; + m_indexPointArray = 0; + m_startPoint = snapPoint( docPoint ); + m_endPoint = m_startPoint; + m_pointArray.putPoints( m_indexPointArray, 1, m_startPoint.x(), m_startPoint.y() ); + ++m_indexPointArray; + } break; + case INS_CUBICBEZIERCURVE: case INS_QUADRICBEZIERCURVE: + case INS_CLOSED_CUBICBEZIERCURVE: case INS_CLOSED_QUADRICBEZIERCURVE: { + deSelectAllObj(); + recalcAutoGuides(); + mousePressed = true; + + m_drawCubicBezierCurve = true; + m_drawLineWithCubicBezierCurve = true; + m_indexPointArray = 0; + + m_oldCubicBezierPointArray.putPoints( 0, 4, (double)0,(double)0, (double)0,(double)0, + (double)0,(double)0, (double)0,(double)0 ); + m_startPoint = snapPoint( docPoint ); + m_endPoint = m_startPoint; + m_pointArray.putPoints( m_indexPointArray, 1, m_startPoint.x(), m_startPoint.y() ); + + ++m_indexPointArray; + } break; + default: { + deSelectAllObj(); + recalcAutoGuides(); + mousePressed = true; + KoPoint sp( snapPoint( docPoint ) ); + m_insertRect = KoRect( sp.x(), sp.y(),0 ,0 ); + } break; + } + } + + if ( e->button() == RightButton && ( toolEditMode == INS_POLYLINE || toolEditMode == INS_CLOSED_POLYLINE ) + && !m_pointArray.isNull() && m_drawPolyline ) { + if( m_indexPointArray > 1) + { + QPainter p( this ); + p.setPen( QPen( black, 1, SolidLine ) ); + p.setBrush( NoBrush ); + p.translate( -diffx(), -diffy() ); + p.save(); + p.setRasterOp( NotROP ); + + // remove old line + p.drawLine( m_view->zoomHandler()->zoomPoint( m_startPoint ), + m_view->zoomHandler()->zoomPoint( m_endPoint ) ); + + p.drawLine( m_view->zoomHandler()->zoomPoint( m_startPoint ), + m_view->zoomHandler()->zoomPoint( m_pointArray.at( m_indexPointArray - 2 ) ) ); + p.restore(); + + m_indexPointArray = QMAX( 1, m_indexPointArray - 1 ); + m_pointArray.resize( m_indexPointArray ); + m_startPoint = m_pointArray.at( m_indexPointArray - 1 ); + + p.drawLine( m_view->zoomHandler()->zoomPoint( m_startPoint ), + m_view->zoomHandler()->zoomPoint( m_endPoint ) ); + + p.end(); + } + else if( m_indexPointArray == 1) + { + QPainter p( this ); + p.setPen( QPen( black, 1, SolidLine ) ); + p.setBrush( NoBrush ); + p.setRasterOp( NotROP ); + p.translate( -diffx(), -diffy() ); + p.drawLine( m_view->zoomHandler()->zoomPoint( m_startPoint ), + m_view->zoomHandler()->zoomPoint( m_endPoint ) ); + p.end(); + m_pointArray = KoPointArray(); + m_indexPointArray = 0; + + m_drawPolyline = false; + m_view->disableAutoScroll(); + mousePressed = false; + } + return; + } + + if ( e->button() == RightButton && ( toolEditMode == INS_CUBICBEZIERCURVE || toolEditMode == INS_QUADRICBEZIERCURVE + || toolEditMode == INS_CLOSED_CUBICBEZIERCURVE || toolEditMode == INS_CLOSED_QUADRICBEZIERCURVE ) + && !m_pointArray.isNull() && m_drawCubicBezierCurve ) { + if ( m_drawLineWithCubicBezierCurve ) { + KoPoint point = snapPoint( docPoint ); + m_pointArray.putPoints( m_indexPointArray, 1, point.x(), point.y() ); + ++m_indexPointArray; + } + else { + m_pointArray.putPoints( m_indexPointArray, 2, m_CubicBezierSecondPoint.x(), m_CubicBezierSecondPoint.y(), + m_CubicBezierThirdPoint.x(), m_CubicBezierThirdPoint.y() ); + m_indexPointArray += 2; + } + + endDrawCubicBezierCurve(); + + m_gl.repaintAfterSnapping(); + + return; + } + + if ( e->button() == RightButton && toolEditMode == TEM_MOUSE ) { + KPrObject * obj = getObjectAt( docPoint ); + if ( obj ) + { + kpobject = obj; + QPoint pnt = QCursor::pos(); + mousePressed = false; + m_view->disableAutoScroll(); + bool state=!( e->state() & ShiftButton ) && !( e->state() & ControlButton ) && !kpobject->isSelected(); + + if ( state ) + deSelectAllObj(); + selectObj( kpobject ); + objectPopup( kpobject, pnt ); + } else { + QPoint pnt = QCursor::pos(); + m_view->openPopupMenuMenuPage( pnt ); + m_view->disableAutoScroll(); + mousePressed = false; + } + modType = MT_NONE; + + } + else if( e->button() == RightButton && toolEditMode == TEM_ZOOM ) { + QPoint pnt = QCursor::pos(); + mousePressed = false; + m_view->disableAutoScroll(); + m_view->openPopupMenuZoom( pnt ); + } + else if( e->button() == RightButton && toolEditMode != TEM_MOUSE ) { + //deactivate tools when you click on right button + setToolEditMode( TEM_MOUSE ); + } + } else { + if ( e->button() == LeftButton ) { + if ( m_drawMode ) { + setCursor( KPrUtils::penCursor() ); + m_drawLineInDrawMode = true; + m_drawModeLineIndex = 0; + m_drawModeLines.append( QPointArray() ); + m_drawModeLines[m_drawModeLines.count() - 1].putPoints( m_drawModeLineIndex++, 1, e->x(), e->y() ); + } + else + m_view->screenNext(); + } else if ( e->button() == MidButton ) + m_view->screenPrev(); + else if ( e->button() == RightButton ) { + if ( !m_drawMode && !spManualSwitch() ) + { + finishObjectEffects(); + finishPageEffect(); + m_view->stopAutoPresTimer(); + } + + setCursor( arrowCursor ); + QPoint pnt = QCursor::pos(); + int ret = m_presMenu->exec( pnt ); + // we have to continue the timer if the menu was canceled and we draw mode is not active + if ( ret == -1 && !m_presMenu->isItemChecked( PM_DM ) && !spManualSwitch() ) + m_view->continueAutoPresTimer(); + } + } + + +#if 0 // Where do you need this ? (toshitaka) + // ME: I have no idea why this is needed at all + if ( toolEditMode == TEM_MOUSE ) + mouseMoveEvent( e ); +#endif +} + +KoRect KPrCanvas::getAlignBoundingRect() const +{ + KoRect boundingRect; + + QPtrListIterator it( m_activePage->objectList() ); + for ( ; it.current() ; ++it ) + { + if ( it.current() == m_view->kPresenterDoc()->header() || + it.current() == m_view->kPresenterDoc()->footer() ) + continue; + + if( it.current()->isSelected() && !it.current()->isProtect() ) { + boundingRect |= it.current()->getRealRect(); + } + } + return boundingRect; +} + +void KPrCanvas::mouseReleaseEvent( QMouseEvent *e ) +{ + if ( editMode && m_view->kPresenterDoc()->showGuideLines() && toolEditMode == TEM_MOUSE && m_gl.mouseReleaseEvent( e ) ) + return; + + QPoint contentsPoint( e->pos().x()+diffx(), e->pos().y()+diffy() ); + if(m_currentTextObjectView) + { + m_currentTextObjectView->mouseReleaseEvent( e, contentsPoint ); + emit objectSelectedChanged(); + m_view->disableAutoScroll(); + mousePressed=false; + return; + } + + if ( e->button() != LeftButton ) + return; + + if ( m_drawMode ) { + m_drawLineInDrawMode = false; + m_drawModeLines[m_drawModeLines.count() - 1].putPoints( m_drawModeLineIndex++, 1, contentsPoint.x(), contentsPoint.y() ); + return; + } + + QPtrList _objects; + _objects.setAutoDelete( false ); + + if ( ( m_drawPolyline && ( toolEditMode == INS_POLYLINE || toolEditMode == INS_CLOSED_POLYLINE ) ) + || ( m_drawCubicBezierCurve && ( toolEditMode == INS_CUBICBEZIERCURVE || toolEditMode == INS_QUADRICBEZIERCURVE + || toolEditMode == INS_CLOSED_CUBICBEZIERCURVE || toolEditMode == INS_CLOSED_QUADRICBEZIERCURVE ) ) ) { + return; + } + + m_insertRect = m_insertRect.normalize(); + + switch ( toolEditMode ) { + case TEM_MOUSE: { + drawContour = FALSE; + switch ( modType ) { + case MT_NONE: { + if ( drawRubber ) { + // used for selecting multiple object in with the mouse + QPainter p; + p.begin( this ); + p.setRasterOp( NotROP ); + p.setPen( QPen( black, 0, DotLine ) ); + p.translate( -diffx(), -diffy() ); + p.drawRect( m_view->zoomHandler()->zoomRect( m_rubber ) ); + p.end(); + drawRubber = false; + + m_rubber = m_rubber.normalize(); + + QPtrListIterator it( getObjectList() ); + for ( ; it.current() ; ++it ) + { + if ( it.current()->intersects( m_rubber ) ) + { + if( objectIsAHeaderFooterHidden(it.current())) + continue; + it.current()->setSelected( true ); + mouseSelectedObject = true; + } + } + + if ( mouseSelectedObject ) + _repaint( false ); + emit objectSelectedChanged(); + } + } break; + case MT_MOVE: { + KoPoint move( objectRect( false ).topLeft() - m_moveStartPosMouse ); + if ( move != KoPoint( 0, 0 ) ) + { + KCommand *cmd=m_activePage->moveObject(m_view, move.x(), move.y()); + if(cmd) + m_view->kPresenterDoc()->addCommand( cmd ); + } else + { + m_activePage->repaintObj(); + } + m_isMoving = false; + } + break; + case MT_RESIZE_UP: + finishResizeObject( i18n( "Resize Object Up" ) ); + break; + case MT_RESIZE_DN: + finishResizeObject( i18n( "Resize Object Down" ), false ); + break; + case MT_RESIZE_LF: + finishResizeObject( i18n( "Resize Object Left" ) ); + break; + case MT_RESIZE_RT: + finishResizeObject( i18n( "Resize Object Right" ) ); + break; + case MT_RESIZE_LU: + finishResizeObject( i18n( "Resize Object Left && Up" ) ); + break; + case MT_RESIZE_LD: + finishResizeObject( i18n( "Resize Object Left && Down" ) ); + break; + case MT_RESIZE_RU: + finishResizeObject( i18n( "Resize Object Right && Up" ) ); + break; + case MT_RESIZE_RD: + finishResizeObject( i18n( "Resize Object Right && Down" ) ); + break; + } + } break; + case INS_TEXT: + if ( !m_insertRect.isNull() ) + { + KPrTextObject* kptextobject = insertTextObject( m_insertRect ); + setToolEditMode( TEM_MOUSE ); + + // User-friendlyness: automatically start editing this textobject + createEditing( kptextobject ); + //setTextBackground( kptextobject ); + //setCursor( arrowCursor ); + } + break; + case TEM_ZOOM:{ + drawContour = FALSE; + if( modType == MT_NONE && drawRubber ) + { + QPainter p; + p.begin( this ); + p.setRasterOp( NotROP ); + p.setPen( QPen( black, 0, DotLine ) ); + p.translate( -diffx(), -diffy() ); + p.drawRect( m_view->zoomHandler()->zoomRect( m_rubber ) ); + p.end(); + drawRubber = false; + m_rubber = m_rubber.normalize(); + if ( m_zoomRubberDraw ) + { + m_view->setZoomRect( m_rubber ); + } + else + { + m_view->zoomPlus(); + } + m_zoomRubberDraw = false; + } + }break; + case TEM_ROTATE: { + drawContour = FALSE; + if ( !m_rotateObject ) + break; + if ( m_angleBeforeRotate != m_rotateObject->getAngle() ) { + QPtrList objects; + objects.append( m_rotateObject ); + + /* As the object is allready rotated set the angle to + * the m_angleBeforeRotate for the creation of the command, and + * back afterwards. No need for executing the command */ + float newAngle = m_rotateObject->getAngle(); + m_rotateObject->rotate( m_angleBeforeRotate ); + + KPrRotateCmd *rotateCmd = new KPrRotateCmd( i18n( "Change Rotation" ), newAngle, + objects, m_view->kPresenterDoc() ); + m_view->kPresenterDoc()->addCommand( rotateCmd ); + + m_rotateObject->rotate( newAngle ); + m_rotateObject = NULL; + } + }break; + case INS_LINE: + if ( m_startPoint != m_endPoint ) + { + insertLine( m_startPoint, m_endPoint ); + m_endPoint = m_startPoint; + } + break; + case INS_RECT: + if ( !m_insertRect.isNull() ) + { + insertRect( m_insertRect ); + } + break; + case INS_ELLIPSE: + if ( !m_insertRect.isNull() ) + { + insertEllipse( m_insertRect ); + } + break; + case INS_PIE: + if ( !m_insertRect.isNull() ) + { + insertPie( m_insertRect ); + } + break; + case INS_OBJECT: + case INS_DIAGRAMM: + case INS_TABLE: + case INS_FORMULA: + if ( !m_insertRect.isNull() ) + { + KPrPartObject *kpPartObject = insertObject( m_insertRect ); + setToolEditMode( TEM_MOUSE ); + + if ( kpPartObject ) + { + kpPartObject->activate( m_view ); + m_editObject = kpPartObject; + } + } + break; + case INS_AUTOFORM: + if ( !m_insertRect.isNull() ) + { + insertAutoform( m_insertRect ); + } + setToolEditMode( TEM_MOUSE ); + break; + case INS_FREEHAND: + if ( !m_pointArray.isNull() ) + { + insertFreehand( m_pointArray ); + } + break; + case INS_POLYGON: + if ( !m_pointArray.isNull() ) + insertPolygon( m_pointArray ); + break; + case INS_PICTURE: + case INS_CLIPART: + insertPicture( m_insertRect ); + setToolEditMode( TEM_MOUSE ); + break; + case INS_CLOSED_FREEHAND: { + if ( !m_pointArray.isNull() ) + insertClosedLine( m_pointArray ); + }break; + default: break; + } + + m_gl.repaintAfterSnapping(); + + emit objectSelectedChanged(); + + if ( toolEditMode != TEM_MOUSE && editMode ) + repaint( false ); + + m_view->disableAutoScroll(); + mousePressed = false; + modType = MT_NONE; + m_insertRect = KoRect(); + mouseMoveEvent( e ); +} + +void KPrCanvas::mouseMoveEvent( QMouseEvent *e ) +{ + if ( editMode && m_view->kPresenterDoc()->showGuideLines() && toolEditMode == TEM_MOUSE && m_gl.mouseMoveEvent( e ) ) + return; + + QPoint contentsPoint( e->pos().x()+diffx(), e->pos().y()+diffy() ); + KoPoint docPoint = m_view->zoomHandler()->unzoomPoint( contentsPoint ); + if(m_currentTextObjectView) + { + if (m_currentTextObjectView->isLinkVariable(e->pos()) ) + { + setCursor(Qt::PointingHandCursor); + return; + } + setCursor( arrowCursor ); + + KPrTextObject *txtObj=m_currentTextObjectView->kpTextObject(); + Q_ASSERT(txtObj); + if(txtObj->contains( docPoint )&&mousePressed) + { + KoPoint pos = docPoint - txtObj->innerRect().topLeft(); + m_currentTextObjectView->mouseMoveEvent( e, m_view->zoomHandler()->ptToLayoutUnitPix( pos ) ); // in LU pixels + } + return; + } + + if (m_view->kPresenterDoc()->getVariableCollection()->variableSetting()->displayLink()) + { + KPrObject *tmp_kpobject = getObjectAt( docPoint ); + if(tmp_kpobject && tmp_kpobject->getType() == OT_TEXT) + { + KPrTextObject *kptextobject = static_cast( tmp_kpobject ); + QPoint iPoint = kptextobject->viewToInternal( e->pos(), this ); + KoLinkVariable* linkVar = dynamic_cast( kptextobject->textObject()->variableAtPoint( iPoint ) ); + + if ( linkVar ) + { + setCursor(Qt::PointingHandCursor); + return; + } + } + } + + m_disableSnapping = e->state() & ShiftButton; + + if ( editMode ) { + m_view->setRulerMousePos( e->x(), e->y() ); + + if ( toolEditMode == TEM_ROTATE ) + { + setCursor( KPrUtils::rotateCursor() ); + if ( !mousePressed ) + return; + } + KPrObject *kpobject; + if ( ( !mousePressed || ( !drawRubber && modType == MT_NONE ) ) && + toolEditMode == TEM_MOUSE ) + { + bool cursorAlreadySet = false; + if ( (int)objectList().count() > 0 ) + { + kpobject = m_activePage->getCursor( docPoint ); + if( kpobject) + { + setCursor( kpobject->getCursor( docPoint, modType, m_view->kPresenterDoc() ) ); + + cursorAlreadySet = true; + } + } + + if ( !cursorAlreadySet ) + setCursor( arrowCursor ); + else + return; + } else if ( mousePressed ) { + switch ( toolEditMode ) { + case TEM_MOUSE: { + drawContour = TRUE; + if ( modType == MT_NONE ) { + if ( drawRubber ) + { + QPainter p; + p.begin( this ); + p.setRasterOp( NotROP ); + p.setPen( QPen( black, 0, DotLine ) ); + p.translate( -diffx(), -diffy() ); + p.drawRect( m_view->zoomHandler()->zoomRect( m_rubber ) ); + m_rubber.setRight( docPoint.x() ); + m_rubber.setBottom( docPoint.y() ); + p.drawRect( m_view->zoomHandler()->zoomRect( m_rubber ) ); + p.end(); + } + } else if ( modType == MT_MOVE ) { + if ( !m_isMoving ) + { + m_moveSnapDiff= KoPoint(0,0); + m_moveStartPoint = objectRect( false ).topLeft(); + m_isMoving = true; + } + moveObjectsByMouse( docPoint, e->state() & AltButton || e->state() & ControlButton ); + } else if ( modType != MT_NONE && m_resizeObject ) { + if ( !m_isResizing ) + { + m_isResizing = true; + } + + KoPoint sp( snapPoint( docPoint, false ) ); + + bool keepRatio = m_resizeObject->isKeepRatio(); + if ( e->state() & AltButton ) + { + keepRatio = true; + } + bool scaleAroundCenter = false; + if ( e->state() & ControlButton ) + { + scaleAroundCenter = true; + } + + resizeObject( modType, sp, keepRatio, scaleAroundCenter ); + } + } break; + case TEM_ZOOM : { + if ( drawRubber ) { + QPainter p; + p.begin( this ); + p.setRasterOp( NotROP ); + p.setPen( QPen( black, 0, DotLine ) ); + p.translate( -diffx(), -diffy() ); + p.drawRect( m_view->zoomHandler()->zoomRect( m_rubber ) ); + m_rubber.setRight( docPoint.x() ); + m_rubber.setBottom( docPoint.y() ); + p.drawRect( m_view->zoomHandler()->zoomRect( m_rubber ) ); + p.end(); + m_zoomRubberDraw = true; + } + }break; + case TEM_ROTATE: { + if ( m_rotateObject ) + { + drawContour = TRUE; + // angle to mouse pos + double angle = KoPoint::getAngle( m_rotateCenter, docPoint ); + // angle to start of mouse pos + double angle1 = KoPoint::getAngle( m_rotateCenter, m_rotateStart ); + + angle -= angle1; + angle += m_angleBeforeRotate; + if ( angle < 0 ) + angle += 360; + else if ( angle > 360 ) + angle -= 360; + + m_rotateObject->rotate( angle ); + _repaint( m_rotateObject ); + } + }break; + case INS_AUTOFORM: + case INS_DIAGRAMM: + case INS_FORMULA: + case INS_CLIPART: + case INS_PICTURE: + case INS_OBJECT: + case INS_TABLE: + case INS_TEXT: + { + QPainter p( this ); + p.setPen( QPen( black, 1, SolidLine ) ); + p.setBrush( NoBrush ); + p.setRasterOp( NotROP ); + p.translate( -diffx(), -diffy() ); + + KoPoint sp( snapPoint( docPoint ) ); + p.drawRect( m_view->zoomHandler()->zoomRect( m_insertRect.normalize() ) ); + updateInsertRect( sp, e->state() ); + p.drawRect( m_view->zoomHandler()->zoomRect( m_insertRect.normalize() ) ); + + p.end(); + + mouseSelectedObject = true; + } break; + case INS_ELLIPSE: { + QPainter p( this ); + p.setPen( QPen( black, 1, SolidLine ) ); + p.setBrush( NoBrush ); + p.setRasterOp( NotROP ); + p.translate( -diffx(), -diffy() ); + + KoPoint sp( snapPoint( docPoint ) ); + p.drawEllipse( m_view->zoomHandler()->zoomRect( m_insertRect.normalize() ) ); + updateInsertRect( sp, e->state() ); + p.drawEllipse( m_view->zoomHandler()->zoomRect( m_insertRect.normalize() ) ); + + p.end(); + + mouseSelectedObject = true; + } break; + case INS_RECT: { + QPainter p( this ); + p.setPen( QPen( black, 1, SolidLine ) ); + p.setBrush( NoBrush ); + p.setRasterOp( NotROP ); + p.translate( -diffx(), -diffy() ); + + KoPoint sp( snapPoint( docPoint ) ); + p.drawRoundRect( m_view->zoomHandler()->zoomRect( m_insertRect.normalize() ), m_view->getRndX(), m_view->getRndY() ); + updateInsertRect( sp, e->state() ); + p.drawRoundRect( m_view->zoomHandler()->zoomRect( m_insertRect.normalize() ), m_view->getRndX(), m_view->getRndY() ); + + p.end(); + + mouseSelectedObject = true; + } break; + case INS_LINE: { + QPainter p( this ); + p.setPen( QPen( black, 1, SolidLine ) ); + p.setBrush( NoBrush ); + p.setRasterOp( NotROP ); + p.translate( -diffx(), -diffy() ); + + KoPoint oldEndPoint( m_endPoint ); + m_endPoint = snapPoint( docPoint ); + //remove the old line + p.drawLine( m_view->zoomHandler()->zoomPoint( m_startPoint ), + m_view->zoomHandler()->zoomPoint( oldEndPoint ) ); + + if ( e->state() & AltButton ) + { + m_startPoint += m_endPoint - oldEndPoint; + } + + // print the new line + p.drawLine( m_view->zoomHandler()->zoomPoint( m_startPoint ), + m_view->zoomHandler()->zoomPoint( m_endPoint ) ); + p.end(); + + mouseSelectedObject = true; + } break; + case INS_PIE: { + QPainter p( this ); + p.setPen( QPen( black, 1, SolidLine ) ); + p.setBrush( NoBrush ); + p.setRasterOp( NotROP ); + p.translate( -diffx(), -diffy() ); + + KoPoint sp( snapPoint( docPoint ) ); + drawPieObject( &p, m_insertRect ); + updateInsertRect( sp, e->state() ); + drawPieObject( &p, m_insertRect ); + + p.end(); + + mouseSelectedObject = true; + } break; + case INS_FREEHAND: + case INS_CLOSED_FREEHAND: + { + m_endPoint = snapPoint( docPoint ); + if ( m_endPoint != m_startPoint ) + { + QPainter p( this ); + p.setPen( QPen( black, 1, SolidLine ) ); + p.setBrush( NoBrush ); + p.setRasterOp( NotROP ); + p.translate( -diffx(), -diffy() ); + + if ( e->state() & AltButton ) + { + QPointArray pointArray = m_pointArray.zoomPointArray( m_view->zoomHandler() ); + // erase + p.drawPolyline( pointArray ); + m_pointArray.translate( m_endPoint.x() - m_startPoint.x(), + m_endPoint.y() - m_startPoint.y() ); + pointArray = m_pointArray.zoomPointArray( m_view->zoomHandler() ); + // draw + p.drawPolyline( pointArray ); + } + else + { + p.drawLine( m_view->zoomHandler()->zoomPoint( m_startPoint ), + m_view->zoomHandler()->zoomPoint( m_endPoint ) ); + } + p.end(); + + m_pointArray.putPoints( m_indexPointArray, 1, m_endPoint.x(), m_endPoint.y() ); + ++m_indexPointArray; + m_startPoint = m_endPoint; + } + + mouseSelectedObject = true; + } break; + case INS_POLYLINE: case INS_CLOSED_POLYLINE: { + QPainter p( this ); + p.setPen( QPen( black, 1, SolidLine ) ); + p.setBrush( NoBrush ); + p.setRasterOp( NotROP ); + p.translate( -diffx(), -diffy() ); + + KoPoint oldEndPoint( m_endPoint ); + m_endPoint = snapPoint( docPoint ); + //remove the old line + p.drawLine( m_view->zoomHandler()->zoomPoint( m_startPoint ), + m_view->zoomHandler()->zoomPoint( oldEndPoint ) ); + + if ( e->state() & AltButton ) + { + QPointArray pointArray = m_pointArray.zoomPointArray( m_view->zoomHandler() ); + // erase + p.drawPolyline( pointArray ); + m_pointArray.translate( m_endPoint.x() - oldEndPoint.x(), + m_endPoint.y() - oldEndPoint.y() ); + pointArray = m_pointArray.zoomPointArray( m_view->zoomHandler() ); + // draw + p.drawPolyline( pointArray ); + m_startPoint += m_endPoint - oldEndPoint; + } + + // print the new line + p.drawLine( m_view->zoomHandler()->zoomPoint( m_startPoint ), + m_view->zoomHandler()->zoomPoint( m_endPoint ) ); + p.end(); + + mouseSelectedObject = true; + } break; + case INS_CUBICBEZIERCURVE: case INS_QUADRICBEZIERCURVE: + case INS_CLOSED_CUBICBEZIERCURVE: case INS_CLOSED_QUADRICBEZIERCURVE:{ + QPainter p( this ); + p.setPen( QPen( black, 1, SolidLine ) ); + p.setBrush( NoBrush ); + p.setRasterOp( NotROP ); + p.translate( -diffx(), -diffy() ); + + KoPoint newEndPoint( snapPoint( docPoint ) ); + + drawCubicBezierCurve( p, m_oldCubicBezierPointArray ); + + if ( e->state() & AltButton ) + { + // erase + redrawCubicBezierCurve( p ); + + KoPoint diff( newEndPoint - m_endPoint ); + m_pointArray.translate( diff.x(), diff.y() ); + m_endPoint = newEndPoint; + m_startPoint += diff; + + // draw + redrawCubicBezierCurve( p ); + } + else + { + m_endPoint = newEndPoint; + } + + KoPointArray points; + if ( !m_drawLineWithCubicBezierCurve ) + { + double _firstX = m_pointArray.at( m_indexPointArray - 2 ).x(); + double _firstY = m_pointArray.at( m_indexPointArray - 2 ).y(); + + double _fourthX = m_pointArray.at( m_indexPointArray - 1 ).x(); + double _fourthY = m_pointArray.at( m_indexPointArray - 1 ).y(); + + double _midpointX = (_firstX + _fourthX ) / 2; + double _midpointY = (_firstY + _fourthY ) / 2; + double _diffX = _fourthX - _midpointX; + double _diffY = _fourthY - _midpointY; + + double _secondX = m_endPoint.x() - _diffX; + double _secondY = m_endPoint.y() - _diffY; + m_CubicBezierSecondPoint = KoPoint( _secondX, _secondY ); + + m_symmetricEndPoint = m_startPoint * 2 - m_endPoint; + + double _thirdX = m_symmetricEndPoint.x() - _diffX; + double _thirdY = m_symmetricEndPoint.y() - _diffY; + m_CubicBezierThirdPoint = KoPoint( _thirdX, _thirdY ); + + if ( toolEditMode == INS_QUADRICBEZIERCURVE || toolEditMode == INS_CLOSED_QUADRICBEZIERCURVE ) { + _secondX = _thirdX; + _secondY = _thirdY; + m_CubicBezierSecondPoint = KoPoint( _secondX, _secondY ); + } + points.putPoints( 0, 4, _firstX,_firstY, _secondX,_secondY, _thirdX,_thirdY, _fourthX,_fourthY ); + } + + drawCubicBezierCurve( p, points ); + if ( points.size() > 0 ) + { + m_oldCubicBezierPointArray = points; + } + + mouseSelectedObject = true; + } break; + case INS_POLYGON: { + QPainter p( this ); + p.setPen( QPen( black, 1, SolidLine ) ); + p.setBrush( NoBrush ); + p.setRasterOp( NotROP ); + p.translate( -diffx(), -diffy() ); + + KoPoint sp( snapPoint( docPoint ) ); + // erase old + drawPolygon( p, m_insertRect ); + updateInsertRect( sp, e->state() ); + // print new + drawPolygon( p, m_insertRect ); + + mouseSelectedObject = true; + } break; + default: break; + } + } + } else if ( !editMode && m_drawMode && m_drawLineInDrawMode ) { + QPainter p; + p.begin( this ); + p.setPen( m_view->kPresenterDoc()->presPen() ); + p.drawLine( m_drawModeLines[m_drawModeLines.count() - 1].point( m_drawModeLineIndex - 1 ), e->pos() ); + p.end(); + m_drawModeLines[m_drawModeLines.count() - 1].putPoints( m_drawModeLineIndex++, 1, e->x(), e->y() ); + } + + if ( !editMode && !m_drawMode && !m_presMenu->isVisible() && fillBlack ) + setCursor( blankCursor ); +} + +void KPrCanvas::mouseDoubleClickEvent( QMouseEvent *e ) +{ + if(!m_view->koDocument()->isReadWrite()) + return; + QPoint contentsPoint( e->pos().x()+diffx(), e->pos().y()+diffy() ); + KoPoint docPoint = m_view->zoomHandler()->unzoomPoint( contentsPoint ); + if(m_currentTextObjectView) + { + KPrTextObject *txtObj=m_currentTextObjectView->kpTextObject(); + Q_ASSERT(txtObj); + if(txtObj->contains( docPoint )) + { + KoPoint pos = docPoint - txtObj->getOrig(); + //pos=m_view->zoomHandler()->pixelToLayoutUnit(QPoint(pos.x(),pos.y())); + m_currentTextObjectView->mouseDoubleClickEvent( e, m_view->zoomHandler()->ptToLayoutUnitPix( pos ) ); + return; + } + } + + //disallow activating objects outside the "page" + if ( !m_activePage->getPageRect().contains(docPoint)) + return; + + + if ( ( toolEditMode == INS_POLYLINE || toolEditMode == INS_CLOSED_POLYLINE ) && !m_pointArray.isNull() && m_drawPolyline ) + { + m_startPoint = snapPoint( docPoint ); + + m_pointArray.putPoints( m_indexPointArray, 1, m_startPoint.x(), m_startPoint.y() ); + ++m_indexPointArray; + endDrawPolyline(); + + mouseMoveEvent( e ); + return; + } + + + if ( toolEditMode != TEM_MOUSE || !editMode ) return; + + KPrObject *kpobject = getObjectAt( docPoint ); + if(kpobject) + { + if ( kpobject->getType() == OT_TEXT ) + { + deSelectAllObj(); + KPrTextObject *kptextobject = dynamic_cast( kpobject ); + if(kptextobject && (!kptextobject->isProtectContent() || kptextobject->isProtectContent() + && m_view->kPresenterDoc()->cursorInProtectedArea())) + { + if(m_currentTextObjectView) + { + m_currentTextObjectView->terminate(); + delete m_currentTextObjectView; + } + m_currentTextObjectView=kptextobject->createKPTextView(this); + + //setTextBackground( kptextobject ); + setCursor( arrowCursor ); + m_editObject = kpobject; + } + } + else if ( kpobject->getType() == OT_PART ) + { + deSelectAllObj(); + KPrPartObject * obj=dynamic_cast(kpobject); + if(obj) + { + obj->activate( m_view ); + m_editObject = obj; + } + } + else + getView()->extraProperties(); + } +} + +void KPrCanvas::drawPieObject( QPainter *p, const KoRect & rect ) +{ + QRect pRect( m_view->zoomHandler()->zoomRect( rect ) ); + switch ( m_view->getPieType() ) { + case PT_PIE: + p->drawPie( pRect.x(), pRect.y(), pRect.width() - 2, + pRect.height() - 2, m_view->getPieAngle(), m_view->getPieLength() ); + break; + case PT_ARC: + p->drawArc( pRect.x(), pRect.y(), pRect.width() - 2, + pRect.height() - 2, m_view->getPieAngle(), m_view->getPieLength() ); + break; + case PT_CHORD: + p->drawChord( pRect.x(), pRect.y(), pRect.width() - 2, + pRect.height() - 2, m_view->getPieAngle(), m_view->getPieLength() ); + break; + default: break; + } + +} + +void KPrCanvas::wheelEvent( QWheelEvent *e ) +{ + if ( !editMode && !m_drawMode ) { + if ( e->delta() == -120 ) // wheel down + m_view->screenNext(); + else if ( e->delta() == 120 ) // wheel up + m_view->screenPrev(); + e->accept(); + } + else if ( editMode ) + emit sigMouseWheelEvent( e ); +} + +void KPrCanvas::keyPressEvent( QKeyEvent *e ) +{ + if ( editMode && m_view->kPresenterDoc()->showGuideLines() && m_gl.keyPressEvent( e ) ) + return; + if ( !editMode ) { + switch ( e->key() ) { + case Qt::Key_Space: case Key_Right: case Key_Down: + setSwitchingMode( false ); + m_view->screenNext(); + break; + case Qt::Key_Next: + setSwitchingMode( false ); + m_view->screenNext( true ); + break; + case Qt::Key_Backspace: case Key_Left: case Key_Up: + setSwitchingMode( false ); + finishObjectEffects(); + finishPageEffect( true ); + m_view->screenPrev(); + break; + case Qt::Key_Prior: + setSwitchingMode( false ); + finishObjectEffects(); + finishPageEffect( true ); + m_view->screenPrev( true ); + break; + case Qt::Key_Escape: case Key_Q: case Key_X: + setSwitchingMode( false ); + finishObjectEffects(); + finishPageEffect( true ); + m_view->screenStop(); + break; + case Qt::Key_G: + // setSwitchingMode( false ) not needed as it is allready done in slotGotoPage; + if ( !spManualSwitch() ) + m_view->stopAutoPresTimer(); + slotGotoPage(); + break; + case Qt::Key_Home: // go to first page + setSwitchingMode( false ); + presGotoFirstPage(); + if ( !spManualSwitch() ) { + m_view->setAutoPresTimer( 1 ); + m_setPageTimer = true; + } + break; + case Qt::Key_End: // go to last page + setSwitchingMode( false ); + if ( m_presentationSlidesIterator != m_presentationSlides.end() ) { + gotoPage( *(--m_presentationSlides.end()) ); + if ( !spManualSwitch() ) { + m_view->setAutoPresTimer( 1 ); + m_setPageTimer = true; + } + } + break; + default: break; + } + } else if ( m_editObject ) { + if ( e->key() == Qt::Key_Escape ) { + exitEditMode(); + } + else if ( m_currentTextObjectView ) + { + if ( !m_currentTextObjectView->kpTextObject()->isProtectContent() || (e->text().length() == 0)) + m_currentTextObjectView->keyPressEvent( e ); + else + KMessageBox::information(this, i18n("Read-only content cannot be changed. No modifications will be accepted.")); + } + } + else + { + switch ( e->key() ) + { + case Qt::Key_Next: + m_view->nextPage(); + break; + case Qt::Key_Prior: + m_view->prevPage(); + break; + case Qt::Key_Home: // go to first page + m_view->screenFirst(); + break; + case Qt::Key_End: // go to first page + m_view->screenLast(); + break; + default: + break; + } + + if ( mouseSelectedObject ) + { + m_disableSnapping = e->state() & ShiftButton; + + int offsetx = 1; + int offsety = 1; + + if ( e->state() & ControlButton ) + { + offsetx = QMAX(1,m_view->zoomHandler()->zoomItX(10)); + offsety = QMAX(1,m_view->zoomHandler()->zoomItY(10)); + } + + if ( !m_keyPressEvent ) + { + m_moveStartPosKey = objectRect( false ).topLeft(); + } + switch ( e->key() ) + { + case Qt::Key_Up: + m_keyPressEvent = true; + moveObjectsByKey( 0, -offsety ); + break; + case Qt::Key_Down: + m_keyPressEvent = true; + moveObjectsByKey( 0, offsety ); + break; + case Qt::Key_Right: + m_keyPressEvent = true; + moveObjectsByKey( offsetx, 0 ); + break; + case Qt::Key_Left: + m_keyPressEvent = true; + moveObjectsByKey( -offsetx, 0 ); + break; + case Qt::Key_Delete: + case Key_Backspace: + m_view->editDelete(); + break; + case Qt::Key_Escape: + { + if ( mousePressed && toolEditMode == TEM_MOUSE ) + { + switch (modType) + { + case MT_RESIZE_UP: + case MT_RESIZE_DN: + case MT_RESIZE_LF: + case MT_RESIZE_RT: + case MT_RESIZE_LU: + case MT_RESIZE_LD: + case MT_RESIZE_RU: + case MT_RESIZE_RD: + { + QRect oldBoundingRect = m_view->zoomHandler()->zoomRect( m_resizeObject->getRepaintRect() ); + m_resizeObject->setOrig( m_rectBeforeResize.topLeft() ); + m_resizeObject->setSize( m_rectBeforeResize.size() ); + drawContour = false; + m_view->kPresenterDoc()->repaint( oldBoundingRect ); + m_view->kPresenterDoc()->repaint( m_resizeObject ); + m_ratio = 0.0; + m_resizeObject = 0; + m_isResizing = false; + m_view->disableAutoScroll(); + mousePressed = false; + modType = MT_NONE; + return; + } + case MT_MOVE: + { + if ( m_isMoving ) + { + drawContour = false; + KoPoint move( m_moveStartPoint - objectRect( false ).topLeft() ); + m_activePage->moveObject( m_view, move, false ); + m_view->disableAutoScroll(); + mousePressed = false; + modType = MT_NONE; + m_isMoving = false; + return; + } + break; + } + default: + break; + } + } + setToolEditMode( TEM_MOUSE ); + break; + } + case Qt::Key_Shift: + { + bool oldChangeSnap = m_disableSnapping; + m_disableSnapping = e->key() == Qt::Key_Shift; + if ( !oldChangeSnap && m_disableSnapping ) + { + m_gl.repaintAfterSnapping(); + } + // undo snapping for move by mouse + if ( e->state() & Qt::LeftButton && m_isMoving ) + { + moveObjectsByMouse( m_origMousePos, e->state() & AltButton || e->state() & ControlButton ); + } + break; + } + default: break; + } + } + else + { + switch ( e->key() ) { + case Qt::Key_Down: + m_view->getVScrollBar()->addLine(); + break; + case Qt::Key_Up: + m_view->getVScrollBar()->subtractLine(); + break; + case Qt::Key_Right: + m_view->getHScrollBar()->addLine(); + break; + case Qt::Key_Left: + m_view->getHScrollBar()->subtractLine(); + break; + case Qt::Key_Tab: + selectNext(); + break; + case Qt::Key_Backtab: + selectPrev(); + break; + case Qt::Key_Escape: + if ( toolEditMode == TEM_ZOOM ) + setToolEditMode( TEM_MOUSE ); + break; + default: break; + } + } + } +} + +void KPrCanvas::keyReleaseEvent( QKeyEvent *e ) +{ + if ( editMode && m_currentTextObjectView ) + m_currentTextObjectView->keyReleaseEvent( e ); + else + { + if ( mouseSelectedObject ) + { + if(e->key()==Qt::Key_Up || e->key()==Key_Down || e->key()==Key_Right || e->key()==Key_Left) + { + if ( !e->isAutoRepeat() ) + { + KoPoint move( objectRect( false ).topLeft() - m_moveStartPosKey); + KCommand *cmd=m_activePage->moveObject(m_view, move.x(), move.y()); + if(cmd) + m_view->kPresenterDoc()->addCommand( cmd ); + m_keyPressEvent = false; + } + emit objectSelectedChanged(); + } + } + } +} + +void KPrCanvas::imStartEvent( QIMEvent * e ) +{ + if ( m_editObject && m_currentTextObjectView ) + { + if ( !m_currentTextObjectView->kpTextObject()->isProtectContent() ) + m_currentTextObjectView->imStartEvent( e ); + else + KMessageBox::information(this, i18n("Read-only content cannot be changed. No modifications will be accepted.")); + } +} + +void KPrCanvas::imComposeEvent( QIMEvent * e ) +{ + if ( m_editObject && m_currentTextObjectView ) + { + if ( !m_currentTextObjectView->kpTextObject()->isProtectContent() ) + m_currentTextObjectView->imComposeEvent( e ); + } +} + +void KPrCanvas::imEndEvent( QIMEvent * e ) +{ + if ( m_editObject && m_currentTextObjectView ) + { + if ( !m_currentTextObjectView->kpTextObject()->isProtectContent() ) + m_currentTextObjectView->imEndEvent( e ); + } +} + +void KPrCanvas::resizeEvent( QResizeEvent *e ) +{ + if ( editMode ) + { + QWidget::resizeEvent( e ); + } + else + QWidget::resizeEvent( new QResizeEvent( KGlobalSettings::desktopGeometry(this).size(), + e->oldSize() ) ); + buffer.resize( size() ); +} + +bool KPrCanvas::close( bool alsoDelete ) +{ + if ( editMode ) + { + return QWidget::close(alsoDelete); + } + else + { + m_view->screenStop(); + return false; + } +} + +KPrObject * KPrCanvas::getObjectAt( const KoPoint &pos, bool withoutProtected ) +{ + KPrObject *object = m_activePage->getObjectAt( pos, withoutProtected ); + if ( objectIsAHeaderFooterHidden( object ) ) + object = 0; + + return object; +} + +void KPrCanvas::selectObj( KPrObject *kpobject ) +{ + kpobject->setSelected( true ); + _repaint( kpobject ); + emit objectSelectedChanged(); + + mouseSelectedObject = true; +} + +void KPrCanvas::deSelectObj( KPrObject *kpobject ) +{ + kpobject->setSelected( false ); + _repaint( kpobject ); + + if ( !m_activePage->isOneObjectSelected() ) + { + mouseSelectedObject = false; + } + emit objectSelectedChanged(); +} + +void KPrCanvas::selectAllObj() +{ + QPtrListIterator it( m_activePage->objectList() ); + for ( ; it.current() ; ++it ) + { + if ( !objectIsAHeaderFooterHidden(it.current()) ) + it.current()->setSelected( true ); + } + + mouseSelectedObject = true; + _repaint( false ); + emit objectSelectedChanged(); +} + + +void KPrCanvas::deSelectAllObj() +{ + if( m_activePage->numSelected() == 0 ) + return; + + lowerObject(); + + m_activePage->deSelectAllObj(); + + //desactivate kptextview when we switch of page + if(m_currentTextObjectView) + { + m_currentTextObjectView->terminate(); + m_currentTextObjectView->kpTextObject()->setEditingTextObj( false ); + delete m_currentTextObjectView; + m_currentTextObjectView=0L; + } + mouseSelectedObject = false; + emit objectSelectedChanged(); +} + +void KPrCanvas::setMouseSelectedObject(bool b) +{ + mouseSelectedObject = b; + emit objectSelectedChanged(); +} + +void KPrCanvas::setupMenus() +{ + // create right button presentation menu + m_presMenu = new KPopupMenu(); + Q_CHECK_PTR( m_presMenu ); + m_presMenu->setCheckable( true ); + m_presMenu->insertTitle( i18n( "Slide Show" ) ); + m_presMenu->insertItem( i18n( "&Continue" ), this, SLOT( setSwitchingMode() ) ); + PM_DM = m_presMenu->insertItem( i18n( "&Drawing Mode" ), this, SLOT( setDrawingMode() ) ); + m_presMenu->insertSeparator(); + m_presMenu->insertItem( SmallIcon("goto"), i18n( "&Goto Slide..." ), this, SLOT( slotGotoPage() ) ); + m_presMenu->insertSeparator(); + m_presMenu->insertItem( i18n( "&End" ), this, SLOT( slotExitPres() ) ); + m_presMenu->setItemChecked( PM_DM, false ); + m_presMenu->setMouseTracking( true ); +} + +void KPrCanvas::clipCut() +{ + if ( m_currentTextObjectView ) + m_currentTextObjectView->cut(); + m_view->editCut(); +} + +void KPrCanvas::clipCopy() +{ + if ( m_currentTextObjectView ) + m_currentTextObjectView->copy(); + m_view->editCopy(); +} + +void KPrCanvas::clipPaste() +{ + if ( m_currentTextObjectView ) + m_currentTextObjectView->paste(); + m_view->editPaste(); +} + +void KPrCanvas::chPic() +{ + m_activePage->chPic( m_view ); +} + +bool KPrCanvas::exportPage( int nPage, + int nWidth, + int nHeight, + const KURL& _fileURL, + const char* format, + int quality ) +{ + bool res = false; + const QCursor oldCursor( cursor() ); + setCursor( waitCursor ); + QPixmap pix( nWidth, nHeight ); + drawPageInPix( pix, nPage, 0, true, nWidth, nHeight ); + if( !pix.isNull() ){ + // Depending on the desired target size due to rounding + // errors during zoom the resulting pixmap *might* be + // 1 pixel or 2 pixels wider/higher than desired: we just + // remove the additional columns/rows. This can be done + // since KPresenter is leaving a minimal border below/at + // the right of the image anyway. + const QSize desiredSize(nWidth, nHeight); + if( desiredSize != pix.size() ) + pix.resize( desiredSize ); + // save the pixmap to the desired file + KURL fileURL(_fileURL); + if( fileURL.protocol().isEmpty() ) + fileURL.setProtocol( "file" ); + const bool bLocalFile = fileURL.isLocalFile(); + KTempFile* tmpFile = bLocalFile ? NULL : new KTempFile(); + if( !bLocalFile ) + tmpFile->setAutoDelete( true ); + if( bLocalFile || 0 == tmpFile->status() ){ + QFile file( bLocalFile ? fileURL.path(0) : tmpFile->name() ); + if ( file.open( IO_ReadWrite ) ) { + res = pix.save( &file, format, quality ); + file.close(); + } + if( !bLocalFile ){ + if( res ){ + res = KIO::NetAccess::upload( tmpFile->name(), fileURL, this ); + } + } + } + if( !bLocalFile ){ + delete tmpFile; + } + } + setCursor( oldCursor ); + return res; +} + +void KPrCanvas::savePicture() +{ + m_activePage->savePicture( m_view ); +} + +void KPrCanvas::setTextFormat(const KoTextFormat &format, int flags) +{ + QPtrList lst = applicableTextInterfaces(); + if ( lst.isEmpty() ) return; + KMacroCommand* macroCmd = new KMacroCommand( i18n("Change Text Font") ); + QPtrListIterator it( lst ); + for ( ; it.current() ; ++it ) { + KCommand *cmd = it.current()->setFormatCommand(&format, flags, true); + + if (cmd) + macroCmd->addCommand( cmd ); + } + m_view->kPresenterDoc()->addCommand( macroCmd ); +} + +void KPrCanvas::setTextColor( const QColor &color ) +{ + QPtrList lst = applicableTextInterfaces(); + if ( lst.isEmpty() ) return; + QPtrListIterator it( lst ); + KMacroCommand* macroCmd = new KMacroCommand( i18n("Set Text Color") ); + for ( ; it.current() ; ++it ) { + KCommand* cmd = it.current()->setTextColorCommand( color ); + if (cmd) + macroCmd->addCommand( cmd ); + } + m_view->kPresenterDoc()->addCommand( macroCmd ); +} + +void KPrCanvas::setTextBackgroundColor( const QColor &color ) +{ + QPtrList lst = applicableTextInterfaces(); + if ( lst.isEmpty() ) return; + QPtrListIterator it( lst ); + KMacroCommand* macroCmd = 0L; + for ( ; it.current() ; ++it ) { + KCommand* cmd = it.current()->setTextBackgroundColorCommand( color ); + if ( cmd ) + { + if ( !macroCmd ) + macroCmd = new KMacroCommand( i18n("Set Text Background Color") ); + macroCmd->addCommand( cmd ); + } + } + if (macroCmd ) + m_view->kPresenterDoc()->addCommand( macroCmd ); +} + +void KPrCanvas::setTextBold( bool b ) +{ + QPtrList lst = applicableTextInterfaces(); + if ( lst.isEmpty() ) return; + QPtrListIterator it( lst ); + KMacroCommand* macroCmd = 0L; + for ( ; it.current() ; ++it ) { + KCommand* cmd = it.current()->setBoldCommand( b ); + if ( cmd ) + { + if ( !macroCmd ) + macroCmd = new KMacroCommand( i18n("Make Text Bold") ); + macroCmd->addCommand( cmd ); + } + } + if ( macroCmd ) + m_view->kPresenterDoc()->addCommand( macroCmd ); +} + +void KPrCanvas::setTextItalic( bool b ) +{ + QPtrList lst = applicableTextInterfaces(); + if ( lst.isEmpty() ) return; + QPtrListIterator it( lst ); + KMacroCommand* macroCmd = 0L; + for ( ; it.current() ; ++it ) { + KCommand* cmd = it.current()->setItalicCommand( b ); + if ( cmd ) + { + if ( !macroCmd ) + macroCmd = new KMacroCommand( i18n("Make Text Italic") ); + macroCmd->addCommand( cmd ); + } + } + if (macroCmd ) + m_view->kPresenterDoc()->addCommand( macroCmd ); +} + +void KPrCanvas::setTextUnderline( bool b ) +{ + QPtrList lst = applicableTextInterfaces(); + if ( lst.isEmpty() ) return; + QPtrListIterator it( lst ); + KMacroCommand* macroCmd = 0L; + for ( ; it.current() ; ++it ) { + KCommand* cmd = it.current()->setUnderlineCommand( b ); + if ( cmd ) + { + if ( !macroCmd ) + macroCmd = new KMacroCommand( i18n("Underline Text") ); + macroCmd->addCommand( cmd ); + } + } + if ( macroCmd ) + m_view->kPresenterDoc()->addCommand( macroCmd ); +} + +void KPrCanvas::setTextStrikeOut( bool b ) +{ + QPtrList lst = applicableTextInterfaces(); + if ( lst.isEmpty() ) return; + KMacroCommand* macroCmd = 0L; + QPtrListIterator it( lst ); + for ( ; it.current() ; ++it ) { + KCommand *cmd = it.current()->setStrikeOutCommand( b ); + if ( cmd ) + { + if ( !macroCmd ) + macroCmd = new KMacroCommand( i18n("Make Text Italic") ); + macroCmd->addCommand( cmd ); + } + } + if ( macroCmd ) + m_view->kPresenterDoc()->addCommand( macroCmd ); +} + +void KPrCanvas::setTextFamily( const QString &f ) +{ + QPtrList lst = applicableTextInterfaces(); + if ( lst.isEmpty() ) return; + KMacroCommand* macroCmd = 0L; + QPtrListIterator it( lst ); + for ( ; it.current() ; ++it ) { + KCommand* cmd = it.current()->setFamilyCommand( f ); + if ( cmd ) + { + if ( !macroCmd ) + macroCmd = new KMacroCommand( i18n("Set Text Font") ); + macroCmd->addCommand( cmd ); + } + } + if ( macroCmd) + m_view->kPresenterDoc()->addCommand( macroCmd ); +} + +void KPrCanvas::setTextPointSize( int s ) +{ + QPtrList lst = applicableTextInterfaces(); + if ( lst.isEmpty() ) return; + KMacroCommand* macroCmd = 0L; + QPtrListIterator it( lst ); + for ( ; it.current() ; ++it ) { + KCommand* cmd = it.current()->setPointSizeCommand( s ); + if ( cmd ) + { + if ( !macroCmd ) + macroCmd = new KMacroCommand( i18n("Change Text Size") ); + macroCmd->addCommand( cmd ); + } + + } + if (macroCmd) + m_view->kPresenterDoc()->addCommand( macroCmd ); +} + +void KPrCanvas::setTextSubScript( bool b ) +{ + QPtrList lst = applicableTextInterfaces(); + if ( lst.isEmpty() ) return; + QPtrListIterator it( lst ); + KMacroCommand* macroCmd = 0L; + for ( ; it.current() ; ++it ) { + KCommand* cmd = it.current()->setTextSubScriptCommand( b ); + if ( cmd ) + { + if ( !macroCmd ) + macroCmd = new KMacroCommand( i18n("Set Text Subscript") ); + macroCmd->addCommand( cmd ); + } + } + if ( macroCmd ) + m_view->kPresenterDoc()->addCommand( macroCmd ); +} + +void KPrCanvas::setTextSuperScript( bool b ) +{ + QPtrList lst = applicableTextInterfaces(); + if ( lst.isEmpty() ) return; + QPtrListIterator it( lst ); + KMacroCommand* macroCmd = 0L; + for ( ; it.current() ; ++it ) { + KCommand* cmd = it.current()->setTextSuperScriptCommand( b ); + if ( cmd ) + { + if ( !macroCmd ) + macroCmd = new KMacroCommand( i18n("Set Text Superscript") ); + macroCmd->addCommand( cmd ); + } + } + if ( macroCmd ) + m_view->kPresenterDoc()->addCommand( macroCmd ); +} + +void KPrCanvas::setTextDefaultFormat( ) +{ + QPtrList lst = applicableTextInterfaces(); + if ( lst.isEmpty() ) return; + QPtrListIterator it( lst ); + KMacroCommand* macroCmd = 0L; + for ( ; it.current() ; ++it ) { + KCommand* cmd = it.current()->setDefaultFormatCommand( ); + if ( cmd ) + { + if ( !macroCmd ) + macroCmd = new KMacroCommand( i18n("Apply Default Format") ); + macroCmd->addCommand( cmd ); + } + } + if (macroCmd) + m_view->kPresenterDoc()->addCommand( macroCmd ); +} + +void KPrCanvas::setIncreaseFontSize() +{ + QPtrList lst = applicableTextInterfaces(); + if ( lst.isEmpty() ) return; + QPtrListIterator it( lst ); + int size = it.current()->currentFormat()->pointSize(); + KMacroCommand* macroCmd =0L; + for ( ; it.current() ; ++it ) { + KCommand* cmd = it.current()->setPointSizeCommand( size+1 ); + if ( cmd ) + { + if ( !macroCmd ) + macroCmd = new KMacroCommand( i18n("Increase Font Size") ); + macroCmd->addCommand( cmd ); + } + } + if ( macroCmd) + m_view->kPresenterDoc()->addCommand( macroCmd ); +} + +void KPrCanvas::setDecreaseFontSize() +{ + QPtrList lst = applicableTextInterfaces(); + if ( lst.isEmpty() ) return; + QPtrListIterator it( lst ); + int size = it.current()->currentFormat()->pointSize(); + KMacroCommand* macroCmd = 0L; + for ( ; it.current() ; ++it ) { + KCommand* cmd = it.current()->setPointSizeCommand( size-1 ); + if ( cmd ) + { + if ( !macroCmd ) + macroCmd = new KMacroCommand( i18n("Decrease Font Size") ); + macroCmd->addCommand( cmd ); + } + } + if ( macroCmd ) + m_view->kPresenterDoc()->addCommand( macroCmd ); +} + +void KPrCanvas::setTextAlign( int align ) +{ + QPtrList lst = applicableTextInterfaces(); + if ( lst.isEmpty() ) return; + QPtrListIterator it( lst ); + KMacroCommand* macroCmd = 0L; + for ( ; it.current() ; ++it ) { + KCommand* cmd = it.current()->setAlignCommand(align); + if ( cmd ) + { + if ( !macroCmd) + macroCmd = new KMacroCommand( i18n("Set Text Align") ); + macroCmd->addCommand( cmd ); + } + } + if ( macroCmd ) + m_view->kPresenterDoc()->addCommand( macroCmd ); +} + +void KPrCanvas::setTabList( const KoTabulatorList & tabList ) +{ + QPtrList lst = applicableTextInterfaces(); + if ( lst.isEmpty() ) return; + QPtrListIterator it( lst ); + KMacroCommand* macroCmd = 0L; + for ( ; it.current() ; ++it ) { + KCommand* cmd = it.current()->setTabListCommand(tabList ); + if ( cmd ) + { + if ( !macroCmd ) + macroCmd = new KMacroCommand( i18n("Change Tabulators") ); + macroCmd->addCommand( cmd ); + } + } + if ( macroCmd) + m_view->kPresenterDoc()->addCommand( macroCmd ); +} + +void KPrCanvas::setTextDepthPlus() +{ + QPtrList lst = applicableTextInterfaces(); + if ( lst.isEmpty() ) return; + double leftMargin=0.0; + if(!lst.isEmpty()) + leftMargin=lst.first()->currentParagLayoutFormat()->margins[QStyleSheetItem::MarginLeft]; + double indent = m_view->kPresenterDoc()->getIndentValue(); + double newVal = leftMargin + indent; + QPtrListIterator it( lst ); + KMacroCommand* macroCmd = 0L; + for ( ; it.current() ; ++it ) { + KCommand* cmd = it.current()->setMarginCommand(QStyleSheetItem::MarginLeft, newVal); + if ( cmd ) + { + if ( !macroCmd ) + macroCmd = new KMacroCommand( i18n("Increase Paragraph Depth") ); + macroCmd->addCommand( cmd ); + } + } + if ( macroCmd ) + m_view->kPresenterDoc()->addCommand( macroCmd ); + if(!lst.isEmpty()) + { + const KoParagLayout *layout=lst.first()->currentParagLayoutFormat(); + m_view->showRulerIndent( layout->margins[QStyleSheetItem::MarginLeft], layout->margins[QStyleSheetItem::MarginFirstLine], + layout->margins[QStyleSheetItem::MarginRight], lst.first()->rtl()); + } +} + +void KPrCanvas::setTextDepthMinus() +{ + QPtrList lst = applicableTextInterfaces(); + if ( lst.isEmpty() ) return; + double leftMargin=0.0; + if(!lst.isEmpty()) + leftMargin=lst.first()->currentParagLayoutFormat()->margins[QStyleSheetItem::MarginLeft]; + double indent = m_view->kPresenterDoc()->getIndentValue(); + QPtrListIterator it( lst ); + double newVal = leftMargin - indent; + KMacroCommand* macroCmd = 0L; + for ( ; it.current() ; ++it ) { + KCommand* cmd = it.current()->setMarginCommand(QStyleSheetItem::MarginLeft, QMAX( newVal, 0 )); + if ( cmd ) + { + if ( !macroCmd ) + macroCmd = new KMacroCommand( i18n("Decrease Paragraph Depth") ); + macroCmd->addCommand( cmd ); + } + } + if (macroCmd ) + m_view->kPresenterDoc()->addCommand( macroCmd ); + if(!lst.isEmpty()) + { + const KoParagLayout *layout=lst.first()->currentParagLayoutFormat(); + m_view->showRulerIndent( layout->margins[QStyleSheetItem::MarginLeft], layout->margins[QStyleSheetItem::MarginFirstLine], + layout->margins[QStyleSheetItem::MarginRight], lst.first()->rtl()); + } +} + +void KPrCanvas::setNewFirstIndent(double _firstIndent) +{ + QPtrList lst = applicableTextInterfaces(); + if ( lst.isEmpty() ) return; + QPtrListIterator it( lst ); + KMacroCommand* macroCmd = 0L; + for ( ; it.current() ; ++it ) { + KCommand* cmd = it.current()->setMarginCommand(QStyleSheetItem::MarginFirstLine, _firstIndent); + if ( cmd ) + { + if ( !macroCmd ) + macroCmd = new KMacroCommand( i18n("Change First Line Indent") ); + macroCmd->addCommand( cmd ); + } + } + if ( macroCmd ) + m_view->kPresenterDoc()->addCommand( macroCmd ); +} + +void KPrCanvas::setNewLeftIndent(double _leftIndent) +{ + QPtrList lst = applicableTextInterfaces(); + if ( lst.isEmpty() ) return; + QPtrListIterator it( lst ); + KMacroCommand* macroCmd = 0L; + for ( ; it.current() ; ++it ) { + KCommand* cmd = it.current()->setMarginCommand(QStyleSheetItem::MarginLeft, _leftIndent); + if ( cmd ) + { + if ( !macroCmd ) + macroCmd = new KMacroCommand( i18n("Change Left Indent") ); + macroCmd->addCommand( cmd ); + } + } + if ( macroCmd ) + m_view->kPresenterDoc()->addCommand( macroCmd ); +} + +void KPrCanvas::setNewRightIndent(double _rightIndent) +{ + QPtrList lst = applicableTextInterfaces(); + if ( lst.isEmpty() ) return; + QPtrListIterator it( lst ); + KMacroCommand* macroCmd = 0L; + for ( ; it.current() ; ++it ) { + KCommand* cmd = it.current()->setMarginCommand(QStyleSheetItem::MarginRight, _rightIndent); + if ( cmd ) + { + if ( !macroCmd ) + macroCmd = new KMacroCommand( i18n("Change Right Indent") ); + macroCmd->addCommand( cmd ); + } + } + if ( macroCmd ) + m_view->kPresenterDoc()->addCommand( macroCmd ); +} + +/*void KPrCanvas::setTextCounter(KoParagCounter counter) +{ + QPtrList lst = applicableTextInterfaces(); + if ( lst.isEmpty() ) return; + QPtrListIterator it( lst ); + KMacroCommand* macroCmd = 0L; + for ( ; it.current() ; ++it ) { + KCommand* cmd = it.current()->setCounterCommand(counter ); + if ( cmd ) + { + if ( !macroCmd ) + macroCmd = new KMacroCommand( i18n("Change Paragraph Type") ); + macroCmd->addCommand( cmd ); + } + } + if ( macroCmd ) + m_view->kPresenterDoc()->addCommand( macroCmd ); +}*/ + +#ifndef NDEBUG +void KPrCanvas::printRTDebug( int info ) +{ + KPrTextObject *kpTxtObj = 0; + if ( m_currentTextObjectView ) + kpTxtObj = m_currentTextObjectView->kpTextObject(); + else + kpTxtObj = selectedTextObjs().first(); + if ( kpTxtObj ) + kpTxtObj->textObject()->printRTDebug( info ); +} +#endif + +bool KPrCanvas::haveASelectedPartObj() const +{ + return m_activePage->haveASelectedPartObj(); +} + +bool KPrCanvas::haveASelectedGroupObj() const +{ + return m_activePage->haveASelectedGroupObj(); +} + +bool KPrCanvas::haveASelectedPixmapObj() const +{ + return m_activePage->haveASelectedPixmapObj(); +} + +QPtrList KPrCanvas::applicableTextObjects() const +{ + QPtrList lst; + // If we're editing a text object, then that's the one we return + if ( m_currentTextObjectView ) + lst.append( m_currentTextObjectView->kpTextObject() ); + else + lst = selectedTextObjs(); + return lst; +} + +QPtrList KPrCanvas::applicableTextInterfaces() const +{ + QPtrList lst; + QPtrList lstObj; + // If we're editing a text object, then that's the one we return + if ( m_currentTextObjectView ) + { + if ( !m_currentTextObjectView->kpTextObject()->isProtectContent()) + lst.append( m_currentTextObjectView ); + } + else + { + m_activePage->getAllObjectSelectedList(lstObj); + QPtrListIterator it(lstObj); + for ( ; it.current(); ++it ) { + if ( it.current()->getType() == OT_TEXT ) + { + KPrTextObject * obj = static_cast( it.current() ); + if ( !obj->isProtectContent() ) + lst.append( obj->textObject() ); + } + } + } + return lst; +} + +QPtrList KPrCanvas::selectedTextObjs() const +{ + QPtrList lst; + QPtrListIterator it(getObjectList()); + for ( ; it.current(); ++it ) { + if ( it.current()->isSelected() && it.current()->getType() == OT_TEXT ) + lst.append( static_cast( it.current() ) ); + } + return lst; +} + +void KPrCanvas::startScreenPresentation( double zoomX, double zoomY, int curPgNum /* 1-based */) +{ + //kdDebug(33001) << "KPrCanvas::startScreenPresentation curPgNum=" << curPgNum << endl; + + //setup presentation menu + m_presMenu->setItemChecked( PM_DM, false ); + + setCursor( waitCursor ); + + exitEditMode(); + + KPrDocument * doc = m_view->kPresenterDoc(); + + // Text can't zoom with a different x and y factor, yet. + // So we have to choose the smallest zoom (but still paint background everywhere) + double zoom = kMin( zoomX, zoomY ); + + kdDebug() << "zoomX=" << zoomX << " zoomY=" << zoomY << " zoom=" << zoom << endl; + + m_zoomBeforePresentation = doc->zoomHandler()->zoom(); + kdDebug() << "old zoomed resolutions =" << doc->zoomHandler()->zoomedResolutionX() << "," << doc->zoomHandler()->zoomedResolutionY() << endl; + // Seems to fail (Qt uses the wrong font sizes...) + //doc->zoomHandler()->setZoomedResolution( zoomX * doc->zoomHandler()->zoomedResolutionX(), + // zoomY * doc->zoomHandler()->zoomedResolutionY() ); + // Apply the new zooming to the existing one + doc->zoomHandler()->setZoomAndResolution( qRound( zoom * m_zoomBeforePresentation ), + KoGlobal::dpiX(), KoGlobal::dpiY() ); + + doc->newZoomAndResolution( false, false ); + + // add all selected slides + m_presentationSlides.clear(); + QValueList selected = doc->displaySelectedSlides(); + for ( QValueList::Iterator it = selected.begin() ; it != selected.end(); ++ it ) + { + // ARGLLLRGLRLGRLG selectedSlides gets us 0-based numbers, + // and here we want 1-based numbers ! + int slideno = *it + 1; + m_presentationSlides.append( slideno ); + } + + // no slide selected ? end the slide show immediately... + if( !m_presentationSlides.count() ) + { + //kdDebug(33001) << "No slide: end the slide show" << endl; + stopScreenPresentation(); + return; + } + + // find first selected slide after curPgNum + unsigned slide = 0; + for( unsigned i = 0; i= curPgNum ) + { + slide = m_presentationSlides[i]; + break; + } + + setCursor( blankCursor ); + + m_step.m_pageNumber = (unsigned int) -1; // force gotoPage to do something + gotoPage( slide ); + //kdDebug(33001) << "Page::startScreenPresentation - done" << endl; +} + +void KPrCanvas::stopScreenPresentation() +{ + //kdDebug(33001) << "KPrCanvas::stopScreenPresentation m_showOnlyPage=" << m_showOnlyPage << endl; + setCursor( waitCursor ); + + KPrDocument * doc = m_view->kPresenterDoc(); + doc->zoomHandler()->setZoomAndResolution( m_zoomBeforePresentation, + KoGlobal::dpiX(), KoGlobal::dpiY() ); + doc->newZoomAndResolution(false,false); + goingBack = false; + m_step.m_pageNumber = 0; + editMode = true; + m_drawMode = false; + repaint( false ); + setToolEditMode( toolEditMode ); + setWFlags( WResizeNoErase ); +} + +bool KPrCanvas::pNext( bool gotoNextPage ) +{ + goingBack = false; + + bool objectEffectFinished = finishObjectEffects(); + + KPrDocument * doc = m_view->kPresenterDoc(); + + if ( !gotoNextPage ) + { + if ( finishPageEffect() ) + return false; + + // clear drawed lines + m_drawModeLines.clear(); + + //kdDebug(33001) << "\n-------\nKPrCanvas::pNext m_step =" << m_step.m_step << " m_subStep =" << m_step.m_subStep << endl; + + // First try to go one sub-step further, if any object requires it + // ### should we also objects on the sticky page be checked for sub steps? + QPtrListIterator oit( doc->pageList().at( m_step.m_pageNumber )->objectList() ); + for ( int i = 0 ; oit.current(); ++oit, ++i ) + { + KPrObject *kpobject = oit.current(); + if ( kpobject->getAppearStep() == static_cast( m_step.m_step ) + && kpobject->getType() == OT_TEXT && kpobject->getEffect2() != EF2_NONE ) + { + if ( static_cast( m_step.m_subStep + 1 ) < kpobject->getSubPresSteps() ) + { + m_step.m_subStep++; + //kdDebug(33001) << "Page::pNext addSubPres m_subStep is now " << m_subStep << endl; + doObjEffects(); + return false; + } + } + } + + // Then try to see if there is still one step to do in the current page + if ( m_step.m_step < *( --m_pageEffectSteps.end() ) ) + { + QValueList::ConstIterator it = m_pageEffectSteps.find( m_step.m_step ); + m_step.m_step = *( ++it ); + m_step.m_subStep = 0; + //kdDebug(33001) << "Page::pNext setting currentEffectStep to " << m_step.m_step << endl; + + // if first step on page, draw background + if ( m_step.m_step == 0 ) + { + QPainter p; + p.begin( this ); + drawBackground( &p, + QRect( 0, 0, kapp->desktop()->width(), kapp->desktop()->height() ), + doc->pageList().at( m_step.m_pageNumber ) ); + p.end(); + } + + doObjEffects(); + return false; + } + + /* + * don't go to next slide if we have finished an object effect + * so that we can see the hole slide before going to the next + */ + if ( objectEffectFinished ) + return false; + } + + // No more steps in this page, try to go to the next page + QValueList::ConstIterator test( m_presentationSlidesIterator ); + if ( ++test != m_presentationSlides.end() ) + { + if ( !spManualSwitch() && m_setPageTimer ) + { + //TODO add global presentation speed + m_view->setAutoPresTimer( doc->pageList().at( (*m_presentationSlidesIterator) - 1 )->getPageTimer() / 1 ); + m_setPageTimer = false; + return false; + } + m_setPageTimer = true; + + QRect desk = KGlobalSettings::desktopGeometry(this); + QPixmap _pix1( desk.width(), desk.height() ); + drawCurrentPageInPix( _pix1 ); + + m_view->setPageDuration( m_step.m_pageNumber ); + + m_step.m_pageNumber = *( ++m_presentationSlidesIterator ) - 1; + m_step.m_subStep = 0; + + m_pageEffectSteps = doc->getPageEffectSteps( m_step.m_pageNumber ); + m_step.m_step = *m_pageEffectSteps.begin(); + + QPixmap _pix2( desk.width(), desk.height() ); + drawCurrentPageInPix( _pix2 ); + + QValueList::ConstIterator it( m_presentationSlidesIterator ); + --it; + + KPrPage * page = doc->pageList().at( ( *it ) - 1 ); + PageEffect _pageEffect = page->getPageEffect(); + + bool _soundEffect = page->getPageSoundEffect(); + QString _soundFileName = page->getPageSoundFileName(); + + if ( _soundEffect && !_soundFileName.isEmpty() ) { + stopSound(); + playSound( _soundFileName ); + } + + if ( m_pageEffect ) + finishPageEffect(); + + m_pageEffect = new KPrPageEffects( this, _pix2, _pageEffect, page->getPageEffectSpeed() ); + if ( m_pageEffect->doEffect() ) + { + delete m_pageEffect; + m_pageEffect = 0; + + doObjEffects( true ); + } + else + { + connect( &m_pageEffectTimer, SIGNAL( timeout() ), SLOT( slotDoPageEffect() ) ); + m_pageEffectTimer.start( 50, true ); + } + + return true; + } + + //kdDebug(33001) << "Page::pNext last slide -> End of presentation" << endl; + + // When we are in manual mode or in automatic mode with no infinite loop + // we display the 'End of presentation' slide, unles told explicitly by showEndOfPresentationSlide + if ( ( spManualSwitch() || !spInfiniteLoop() ) && !showingLastSlide && spShowEndOfPresentationSlide() ) + { + m_view->setPageDuration( m_step.m_pageNumber ); + + QRect desk = KGlobalSettings::desktopGeometry(this); + QPixmap lastSlide( desk.width(), desk.height() ); + QFont font( m_view->kPresenterDoc()->defaultFont().family() ); + QPainter p( &lastSlide ); + + p.setFont( font ); + p.setPen( white ); + p.fillRect( p.viewport(), black ); + p.drawText( 50, 50, i18n( "End of presentation. Click to exit." ) ); + bitBlt( this, 0, 0, &lastSlide, 0, 0, lastSlide.width(), lastSlide.height() ); + showingLastSlide = true; + emit stopAutomaticPresentation(); // no automatic mode for last slide + } + else if ( showingLastSlide || !spShowEndOfPresentationSlide() ) // after last slide stop presentation + { + showingLastSlide = false; + m_view->screenStop(); + } + else + { + m_view->setPageDuration( m_step.m_pageNumber ); + emit restartPresentation(); // tells automatic mode to restart + m_view->setAutoPresTimer( 1 ); + } + + return false; +} + +bool KPrCanvas::pPrev( bool gotoPreviousPage ) +{ + goingBack = true; + m_step.m_subStep = 0; + + // clear drawed lines + m_drawModeLines.clear(); + + if ( !gotoPreviousPage && m_step.m_step > *m_pageEffectSteps.begin() ) { + QValueList::ConstIterator it = m_pageEffectSteps.find( m_step.m_step ); + m_step.m_step = *( --it ); + //hopefully there are never more than 1000 sub steps :-) + m_step.m_subStep = 1000; + repaint( false ); + return false; + } else { + // when we go back on the first slide, thats like starting the presentation again + if ( m_presentationSlidesIterator == m_presentationSlides.begin() ) { + m_pageEffectSteps = m_view->kPresenterDoc()->getPageEffectSteps( m_step.m_pageNumber ); + m_step.m_step = *m_pageEffectSteps.begin(); + goingBack = false; + doObjEffects(); + return false; + } + m_view->setPageDuration( m_step.m_pageNumber ); + + m_step.m_pageNumber = *( --m_presentationSlidesIterator ) - 1; + + KPrDocument * doc = m_view->kPresenterDoc(); + + m_pageEffectSteps = doc->getPageEffectSteps( m_step.m_pageNumber ); + + if ( gotoPreviousPage ) + { + m_step.m_step = *( m_pageEffectSteps.begin() ); + goingBack = false; + doObjEffects(); + } + else + { + m_step.m_step = *( --m_pageEffectSteps.end() ); + repaint( false ); + } + + return true; + } + + return false; +} + +bool KPrCanvas::canAssignEffect( QPtrList &objs ) const +{ + QPtrListIterator oIt( m_activePage->objectList() ); + for (; oIt.current(); ++oIt ) + { + //can't assign a effect to header/footer + if(m_view->kPresenterDoc()->isHeaderFooter(oIt.current())) + continue; + if ( oIt.current()->isSelected() ) + objs.append( oIt.current() ); + } + return !objs.isEmpty(); +} + +bool KPrCanvas::isOneObjectSelected() const +{ + return m_activePage->isOneObjectSelected(); +} + +// This one is used to generate the pixmaps for the HTML presentation, +// for the pres-structure-dialog, for the sidebar previews, for template icons. +// Set forceWidth and/or forceHeight to override the zoom factor +// and obtain a pixmap of the specified width and/or height. +// By omitting one of them you make sure that the aspect ratio +// of your page is used for the resulting image. +void KPrCanvas::drawPageInPix( QPixmap &_pix, int pgnum, int zoom, + bool forceRealVariableValue, + int forceWidth, + int forceHeight ) +{ + //kdDebug(33001) << "Page::drawPageInPix" << endl; + + KPrDocument *doc = m_view->kPresenterDoc(); + int oldZoom = doc->zoomHandler()->zoom(); + bool oldDisplayFieldValue = false; + + if( 0 < forceWidth || 0 < forceHeight ) + { + const QRect rect( doc->getPageRect( true ) ); + const double dRectHeight = static_cast(rect.height()); + const double dRectWidth = static_cast(rect.width()); + double dForceHeight = static_cast(forceHeight); + double dForceWidth = static_cast(forceWidth); + + // adjust width or height, in case one of them is missing + if( 0 >= forceWidth ) + dForceWidth = dForceHeight * dRectWidth / dRectHeight; + else if( 0 >= forceHeight ) + dForceHeight = dForceWidth * dRectHeight / dRectWidth; + + // set the stretching values + // ### TODO: this should probably be setZoomedResolution, please test + doc->zoomHandler()->setResolution( dForceWidth / dRectWidth, + dForceHeight / dRectHeight ); + // As of yet (Feb. 2004) the following call results + // in a NOP but be prepared for the future... + doc->newZoomAndResolution( false, false ); + }else{ + m_view->zoomDocument(zoom); + } + + if ( forceRealVariableValue ) + { + oldDisplayFieldValue = m_view->kPresenterDoc()->getVariableCollection()->variableSetting()->displayFieldCode(); + if ( oldDisplayFieldValue ) + { + m_view->kPresenterDoc()->getVariableCollection()->variableSetting()->setDisplayFieldCode(false); + m_view->kPresenterDoc()->recalcVariables( VT_ALL ); + } + } + + KPrPage * page = m_view->kPresenterDoc()->pageList().at(pgnum); + QRect rect = page->getZoomPageRect( ); + _pix.resize( rect.size() ); + _pix.fill( Qt::white ); + + QPainter p; + p.begin( &_pix ); + + bool _editMode = editMode; + editMode = false; + + drawBackground( &p, _pix.rect(), page, true ); + + // draw objects on master slide + if ( page->masterPage() && page->displayObjectFromMasterPage() ) + drawAllObjectsInPage( &p, page->masterPage()->objectList(), pgnum ); + + //objects in current page + drawAllObjectsInPage( &p, page->objectList(), pgnum ); + + editMode = _editMode; + p.end(); + + if ( forceRealVariableValue ) + { + if ( oldDisplayFieldValue ) + { + m_view->kPresenterDoc()->getVariableCollection()->variableSetting()->setDisplayFieldCode(true); + m_view->kPresenterDoc()->recalcVariables( VT_ALL ); + } + } + + m_view->zoomDocument(oldZoom); +} + +// This one is used in fullscreenmode, to generate the pixmaps used for the +// page effects. +void KPrCanvas::drawCurrentPageInPix( QPixmap &_pix ) const +{ + //kdDebug(33001) << "Page::drawCurrentPageInPix" << endl; + + // avoid garbage on "weird" DPIs + _pix.fill(Qt::black); + + QPainter p; + p.begin( &_pix ); + + drawBackground( &p, _pix.rect(), m_view->kPresenterDoc()->pageList().at( m_step.m_pageNumber ) ); + PresStep step( m_step.m_pageNumber, m_step.m_step, m_step.m_subStep, true, true ); + drawPresPage( &p, _pix.rect(), step ); + + p.end(); +} + +void KPrCanvas::printPage( QPainter* painter, PresStep step, KPrinter *printer, int rows, int cols ) +{ + //kdDebug(33001) << "KPrCanvas::printPage" << endl; + KPrDocument *doc = m_view->kPresenterDoc(); + KPrPage* page = doc->pageList().at( step.m_pageNumber ); + QRect const rect = page->getZoomPageRect(); + bool const drawBorder = printer->option("kde-kpresenter-printslideborders").toInt() && rows>1 && cols>1; + + int height = rect.height(); + int width = rect.width(); + + QPaintDeviceMetrics metrics( printer ); + int begin_left = ( metrics.width() - rect.width() ); + int begin_top = ( metrics.height() - rect.height() ); + + rows = cols = QMAX( rows, cols ); // all slides have the same size + + if ( rows > 1 ) + { + height = ( ( height - 80 ) / rows ) - 20; + begin_top = 40; + } + if ( cols > 1 ) + { + width = (width -5) / cols; + begin_left = 5; + } + int top = begin_top; + int left = begin_left; + for (int r = 0; r < rows; r++ ) + { + for (int c = 0; c < cols; c++ ) + { + page = doc->pageList().at( step.m_pageNumber ); + if ( !page ) + return; + painter->setViewport( QRect(left, top, width, height) ); + drawBackground( painter, rect, page, true ); + drawPresPage( painter, rect, step ); + if ( drawBorder ) + painter->drawRect( rect ); + step.m_pageNumber++; + left += width; + } + top += height + 20; // some y-space between the slides + left = begin_left; + } + +} + +void KPrCanvas::doObjEffects( bool isAllreadyPainted ) +{ + if ( m_effectHandler ) + { + m_effectTimer.stop(); + QObject::disconnect( &m_effectTimer, SIGNAL( timeout() ), this, SLOT( slotDoEffect() ) ); + + m_effectHandler->finish(); + delete m_effectHandler; + m_effectHandler = 0; + } + + QPixmap screen_orig( kapp->desktop()->width(), kapp->desktop()->height() ); + + KPrPage *page = m_view->kPresenterDoc()->pageList().at( m_step.m_pageNumber ); + // YABADABADOOOOOOO.... That's a hack :-) + if ( m_step.m_subStep == 0 && !isAllreadyPainted && isUpdatesEnabled() ) + { + //kdDebug(33001) << "Page::doObjEffects - in the strange hack" << endl; + QPainter p; + p.begin( &screen_orig ); + QRect desktopRect = QRect( 0, 0, kapp->desktop()->width(), kapp->desktop()->height() ); + drawBackground( &p, desktopRect, page ); + PresStep step( m_step.m_pageNumber, m_step.m_step, m_step.m_subStep, true, true ); + drawPresPage( &p, desktopRect ,step ); + p.end(); + bitBlt( this, 0, 0, &screen_orig ); + } + else + { + bitBlt( &screen_orig, 0, 0, this ); + } + + QPtrList allObjects; + // master slide objects are below the objects of the normal slide + if ( page->displayObjectFromMasterPage() ) + { + QPtrListIterator it( page->masterPage()->objectList() ); + for ( ; it.current(); ++it ) { + if ( objectIsAHeaderFooterHidden( it.current() ) ) + continue; + else + allObjects.append( it.current() ); + } + } + + QPtrListIterator it( page->objectList() ); + for ( ; it.current(); ++it ) + { + allObjects.append( it.current() ); + } + + //TODO add global presentation speed + m_effectHandler = new KPrEffectHandler( m_step, goingBack, this, &screen_orig, allObjects, m_view, 1 ); + if ( m_effectHandler->doEffect() ) + { + delete m_effectHandler; + m_effectHandler = 0; + } + else + { + connect( &m_effectTimer, SIGNAL( timeout() ), SLOT( slotDoEffect() ) ); + m_effectTimer.start( 50, true ); + } + +} + +void KPrCanvas::slotDoEffect() +{ + if ( m_effectHandler->doEffect() ) + { + m_effectTimer.stop(); + QObject::disconnect( &m_effectTimer, SIGNAL( timeout() ), this, SLOT( slotDoEffect() ) ); + delete m_effectHandler; + m_effectHandler = 0; + } + else + { + m_effectTimer.start( 50, true ); + } +} + + +void KPrCanvas::slotDoPageEffect() +{ + if ( m_pageEffect->doEffect() ) + { + m_pageEffectTimer.stop(); + QObject::disconnect( &m_pageEffectTimer, SIGNAL( timeout() ), this, SLOT( slotDoPageEffect() ) ); + delete m_pageEffect; + m_pageEffect = 0; + + doObjEffects( true ); + } + else + { + m_pageEffectTimer.start( 50, true ); + } +} + +void KPrCanvas::slotAutoScroll(const QPoint &scrollDistance) +{ + //QPoint d = m_view->zoomHandler()->zoomPoint( scrollDistance ); + QPoint d = scrollDistance; + m_view->getHScrollBar()->setValue( m_view->getHScrollBar()->value() + d.x() ); + m_view->getVScrollBar()->setValue( m_view->getVScrollBar()->value() + d.y() ); +} + + +bool KPrCanvas::finishObjectEffects() +{ + bool finished = false; + if ( m_effectHandler ) + { + m_effectTimer.stop(); + QObject::disconnect( &m_effectTimer, SIGNAL( timeout() ), this, SLOT( slotDoEffect() ) ); + m_effectHandler->finish(); + delete m_effectHandler; + m_effectHandler = 0; + finished = true; + } + return finished; +} + + +bool KPrCanvas::finishPageEffect( bool cancel ) +{ + bool finished = false; + if ( m_pageEffect ) + { + m_pageEffectTimer.stop(); + QObject::disconnect( &m_pageEffectTimer, SIGNAL( timeout() ), this, SLOT( slotDoPageEffect() ) ); + if ( !cancel ) + m_pageEffect->finish(); + delete m_pageEffect; + m_pageEffect = 0; + + if ( !cancel ) + { + doObjEffects( true ); + } + else if ( !spManualSwitch() ) + { + m_view->setAutoPresTimer( 1 ); + m_setPageTimer = true; + } + + finished = true; + } + return finished; +} + + +void KPrCanvas::print( QPainter *painter, KPrinter *printer, float /*left_margin*/, float /*top_margin*/ ) +{ + PresStep step( 0, 1000, 1000 ); + //deSelectAllObj(); // already done in KPrView::setupPrinter + int i = 0; + + repaint( false ); + kapp->processEvents(); + + editMode = false; + fillBlack = false; + + //int _xOffset = diffx(); + //int _yOffset = diffy(); + + //m_view->setDiffX( -static_cast( MM_TO_POINT( left_margin ) ) ); + //m_view->setDiffY( -static_cast( MM_TO_POINT( top_margin ) ) ); + + QProgressDialog progress( i18n( "Printing..." ), i18n( "Cancel" ), + printer->pageList().count() + 2, this ); + + int j = 0; + progress.setProgress( 0 ); + + + int rows = 1; + int cols = 1; + if ( !printer->previewOnly() ) + { + rows = printer->option("kde-kpresenter-printrows").toInt(); + cols = printer->option("kde-kpresenter-printcolumns").toInt(); + } + int const slides_per_page = rows * cols; + + /*if ( printer->fromPage() > 1 ) + m_view->setDiffY( ( printer->fromPage() - 1 ) * ( getPageRect( 1, 1.0, false ).height() ) - + (int)MM_TO_POINT( top_margin ) );*/ + int current_slide = 0; + QValueList list=printer->pageList(); // 1-based + QValueList::iterator it; + for( it=list.begin();it!=list.end();++it) + { + i=(*it); + progress.setProgress( ++j ); + kapp->processEvents(); + + if ( progress.wasCancelled() ) + break; + + step.m_pageNumber = i - 1; + + if ( step.m_pageNumber != current_slide ) + continue; + + if ( !list.isEmpty() && i > list.first() ) + printer->newPage(); + + painter->resetXForm(); + painter->fillRect( m_view->kPresenterDoc()->pageList().at( m_step.m_pageNumber )->getZoomPageRect(), white ); + + printPage( painter, step, printer, rows, cols ); + kapp->processEvents(); + + painter->resetXForm(); + kapp->processEvents(); + + current_slide += slides_per_page; + + /*m_view->setDiffY( i * ( getPageRect( 1, 1.0, false ).height() ) + - static_cast( MM_TO_POINT( top_margin ) ) );*/ + } + + KConfig *config=KPrFactory::global()->config(); + config->setGroup("Misc"); + bool printNotes = config->readBoolEntry("PrintNotes", true); + + KPrNoteBar *noteBar = m_view->getNoteBar(); + //don't print notes when there is no note to print or it's disabled + if ( noteBar && !noteBar->getNotesTextForPrinting(list).isEmpty() + && !progress.wasCancelled() && printNotes ) + { + printer->newPage(); + painter->resetXForm(); + noteBar->printNotes( painter, printer, list ); + painter->resetXForm(); + } + + setToolEditMode( toolEditMode ); + //m_view->setDiffX( _xOffset ); + //m_view->setDiffY( _yOffset ); + + progress.setProgress( printer->pageList().count() + 2 ); + + fillBlack = true; + editMode = true; + repaint( false ); +} + + +void KPrCanvas::updateInsertRect( const KoPoint &point, Qt::ButtonState state ) +{ + if ( state & AltButton ) + { + m_insertRect.moveBottomRight( point ); + } + else + { + m_insertRect.setRight( point.x() ); + m_insertRect.setBottom( point.y() ); + } +} + + +KPrTextObject* KPrCanvas::insertTextObject( const KoRect &rect ) +{ + KPrTextObject* obj = m_activePage->insertTextObject( rect ); + selectObj( obj ); + return obj; +} + +void KPrCanvas::insertLine( const KoPoint &startPoint, const KoPoint &endPoint ) +{ + KoRect rect( startPoint, endPoint ); + bool rev = rect.width() < 0 || rect.height() < 0; + rect = rect.normalize(); + LineType lt = LT_LU_RD; + if ( startPoint.x() == endPoint.x() ) + { + lt = LT_VERT; + rect.setLeft( rect.left() - 5.0 ); + rect.setRight( rect.right() + 5.0 ); + } + else if ( startPoint.y() == endPoint.y() ) + { + lt = LT_HORZ; + rect.setTop( startPoint.y() - 5.0 ); + rect.setBottom( startPoint.y() + 5.0 ); + } + else if ( ( startPoint.x() < endPoint.x() && startPoint.y() > endPoint.y() ) || + ( startPoint.x() > endPoint.x() && startPoint.y() < endPoint.y() ) ) + { + lt = LT_LD_RU; + } + m_activePage->insertLine( rect, m_view->getPen(), + !rev ? m_view->getLineBegin() : m_view->getLineEnd(), !rev ? m_view->getLineEnd() : m_view->getLineBegin(), + lt ); +} + + +void KPrCanvas::insertRect( const KoRect &rect ) +{ + m_activePage->insertRectangle( rect, m_view->getPen(), m_view->getBrush(), m_view->getFillType(), + m_view->getGColor1(), m_view->getGColor2(), m_view->getGType(), m_view->getRndX(), m_view->getRndY(), + m_view->getGUnbalanced(), m_view->getGXFactor(), m_view->getGYFactor() ); +} + +void KPrCanvas::insertEllipse( const KoRect &rect ) +{ + m_activePage->insertCircleOrEllipse( rect, m_view->getPen(), m_view->getBrush(), m_view->getFillType(), + m_view->getGColor1(), m_view->getGColor2(), + m_view->getGType(), m_view->getGUnbalanced(), m_view->getGXFactor(), m_view->getGYFactor() ); +} + +void KPrCanvas::insertPie( const KoRect &rect ) +{ + m_activePage->insertPie( rect, m_view->getPen(), m_view->getBrush(), m_view->getFillType(), + m_view->getGColor1(), m_view->getGColor2(), m_view->getGType(), + m_view->getPieType(), m_view->getPieAngle(), m_view->getPieLength(), + m_view->getLineBegin(), m_view->getLineEnd(), m_view->getGUnbalanced(), m_view->getGXFactor(), + m_view->getGYFactor() ); +} + +void KPrCanvas::insertAutoform( const KoRect &rect ) +{ + m_activePage->insertAutoform( rect, m_view->getPen(), m_view->getBrush(), + m_view->getLineBegin(), m_view->getLineEnd(), + m_view->getFillType(), m_view->getGColor1(), m_view->getGColor2(), m_view->getGType(), + autoform, m_view->getGUnbalanced(), m_view->getGXFactor(), m_view->getGYFactor() ); +} + +KPrPartObject* KPrCanvas::insertObject( const KoRect &rect ) +{ + KPrPartObject *kpPartObject = m_activePage->insertObject( rect, partEntry ); + return kpPartObject; +} + +void KPrCanvas::insertFreehand( const KoPointArray &_pointArray ) +{ + KoRect rect = _pointArray.boundingRect(); + + m_activePage->insertFreehand( getObjectPoints( _pointArray ), rect, m_view->getPen(), m_view->getLineBegin(), + m_view->getLineEnd() ); + + m_pointArray = KoPointArray(); + m_indexPointArray = 0; +} + +void KPrCanvas::insertPolyline( const KoPointArray &_pointArray ) +{ + if( _pointArray.count()> 1) + { + KoRect rect = _pointArray.boundingRect(); + m_activePage->insertPolyline( getObjectPoints( _pointArray ), rect, m_view->getPen(), m_view->getLineBegin(), + m_view->getLineEnd() ); + } + m_pointArray = KoPointArray(); + m_indexPointArray = 0; +} + +void KPrCanvas::insertCubicBezierCurve( const KoPointArray &_pointArray ) +{ + if ( _pointArray.count() > 1 ) + { + KoPointArray points( _pointArray ); + KoPointArray bezierPoints( KPrBezierCurveObject::bezier2polyline( _pointArray ) ); + KoRect rect = bezierPoints.boundingRect(); + points = getObjectPoints( points ); + bezierPoints = getObjectPoints( bezierPoints ); + + if ( toolEditMode == INS_CUBICBEZIERCURVE ) + { + m_activePage->insertCubicBezierCurve( points, bezierPoints, rect, m_view->getPen(), + m_view->getLineBegin(), m_view->getLineEnd() ); + } + else if ( toolEditMode == INS_QUADRICBEZIERCURVE ) + { + m_activePage->insertQuadricBezierCurve( points, bezierPoints, rect, m_view->getPen(), + m_view->getLineBegin(), m_view->getLineEnd() ); + } + else if ( toolEditMode == INS_CLOSED_CUBICBEZIERCURVE || + toolEditMode == INS_CLOSED_QUADRICBEZIERCURVE ) + { + m_activePage->insertClosedLine( bezierPoints, rect, m_view->getPen(), m_view->getBrush(), + m_view->getFillType(), m_view->getGColor1(), m_view->getGColor2(), + m_view->getGType(), m_view->getGUnbalanced(), + m_view->getGXFactor(), m_view->getGYFactor(), toolEditMode ); + } + } + m_pointArray = KoPointArray(); + m_indexPointArray = 0; +} + +void KPrCanvas::insertPolygon( const KoPointArray &_pointArray ) +{ + KoRect rect = _pointArray.boundingRect(); + + m_activePage->insertPolygon( getObjectPoints( _pointArray ), rect, m_view->getPen(), m_view->getBrush(), m_view->getFillType(), + m_view->getGColor1(), m_view->getGColor2(), m_view->getGType(), m_view->getGUnbalanced(), + m_view->getGXFactor(), m_view->getGYFactor(), + m_view->getCheckConcavePolygon(), m_view->getCornersValue(), m_view->getSharpnessValue() ); + + m_pointArray = KoPointArray(); + m_indexPointArray = 0; +} + +void KPrCanvas::insertPicture( const KoRect &rect ) +{ + QString file = m_activePage->insPictureFile(); + + QCursor c = cursor(); + setCursor( waitCursor ); + if ( !file.isEmpty() ) { + if ( rect.width() > 10 && rect.height() > 10 ) + { + m_activePage->insertPicture( file, rect ); + } + else + { + KoPoint tl( rect.topLeft() ); + m_activePage->insertPicture( file, tl ); + } + m_activePage->setInsPictureFile( QString::null ); + } + setCursor( c ); +} + +void KPrCanvas::insertClosedLine( const KoPointArray &_pointArray ) +{ + KoRect rect = _pointArray.boundingRect(); + + m_activePage->insertClosedLine( getObjectPoints( _pointArray ), rect, m_view->getPen(), m_view->getBrush(), m_view->getFillType(), + m_view->getGColor1(), m_view->getGColor2(), m_view->getGType(), m_view->getGUnbalanced(), + m_view->getGXFactor(), m_view->getGYFactor(), toolEditMode ); + + m_pointArray = KoPointArray(); + m_indexPointArray = 0; +} + +void KPrCanvas::setToolEditMode( ToolEditMode _m, bool updateView ) +{ + //store m_pointArray if !m_pointArray.isNull() + if ( ( toolEditMode == INS_POLYLINE || toolEditMode == INS_CLOSED_POLYLINE ) && !m_pointArray.isNull()) + endDrawPolyline(); + + if ( ( toolEditMode == INS_CUBICBEZIERCURVE || toolEditMode == INS_QUADRICBEZIERCURVE + || toolEditMode == INS_CLOSED_CUBICBEZIERCURVE || toolEditMode == INS_CLOSED_QUADRICBEZIERCURVE ) && !m_pointArray.isNull() ) + endDrawCubicBezierCurve(); + + exitEditMode(); + toolEditMode = _m; + + if ( toolEditMode == TEM_MOUSE ) + { + setCursor( arrowCursor ); + QPoint pos = QCursor::pos(); + // ### missing some coord transformation here? + KoPoint docPoint( m_view->zoomHandler()->unzoomPoint( pos ) ); + KPrObject *obj=m_activePage->getCursor( pos); + if(obj) + setCursor( obj->getCursor( docPoint, modType, m_view->kPresenterDoc() ) ); + } + else if ( toolEditMode == INS_FREEHAND || toolEditMode == INS_CLOSED_FREEHAND ) + setCursor( KPrUtils::penCursor() ); + else if ( toolEditMode == TEM_ROTATE ) + setCursor( KPrUtils::rotateCursor() ); + else + setCursor( crossCursor ); + + if ( updateView ) + m_view->setTool( toolEditMode ); +} + + +void KPrCanvas::endDrawPolyline() +{ + m_drawPolyline = false; + + if ( toolEditMode == INS_POLYLINE ) + insertPolyline( m_pointArray ); + else if ( toolEditMode == INS_CLOSED_POLYLINE ) + insertClosedLine( m_pointArray ); + + emit objectSelectedChanged(); + if ( toolEditMode != TEM_MOUSE && editMode ) + repaint( false ); + m_view->disableAutoScroll(); + mousePressed = false; + modType = MT_NONE; +} + +void KPrCanvas::endDrawCubicBezierCurve() +{ + m_drawCubicBezierCurve = false; + m_oldCubicBezierPointArray = KoPointArray(); + insertCubicBezierCurve( m_pointArray ); + emit objectSelectedChanged(); + if ( toolEditMode != TEM_MOUSE && editMode ) + repaint( false ); + m_view->disableAutoScroll(); + mousePressed = false; + modType = MT_NONE; +} + +void KPrCanvas::selectNext() +{ + if ( objectList().count() == 0 ) return; + + if ( m_activePage->numSelected() == 0 ) + objectList().at( 0 )->setSelected( true ); + else { + int i = objectList().findRef( m_activePage->getSelectedObj() ); + if ( i < static_cast( objectList().count() ) - 1 ) { + m_view->kPresenterDoc()->deSelectAllObj(); + objectList().at( ++i )->setSelected( true ); + } else { + m_view->kPresenterDoc()->deSelectAllObj(); + objectList().at( 0 )->setSelected( true ); + } + } + m_view->showObjectRect( m_activePage->getSelectedObj() ); + _repaint( false ); +} + +void KPrCanvas::selectPrev() +{ + if ( objectList().count() == 0 ) return; + if ( m_activePage->numSelected() == 0 ) + objectList().at( objectList().count() - 1 )->setSelected( true ); + else { + int i = objectList().findRef( m_activePage->getSelectedObj() ); + if ( i > 0 ) { + m_view->kPresenterDoc()->deSelectAllObj(); + objectList().at( --i )->setSelected( true ); + } else { + m_view->kPresenterDoc()->deSelectAllObj(); + objectList().at( objectList().count() - 1 )->setSelected( true ); + } + } + m_view->showObjectRect( m_activePage->getSelectedObj() ); + _repaint( false ); +} + +void KPrCanvas::dragEnterEvent( QDragEnterEvent *e ) +{ + if ( m_currentTextObjectView ) + m_currentTextObjectView->dragEnterEvent( e ); + else if ( QTextDrag::canDecode( e ) + || QImageDrag::canDecode( e ) + || KURLDrag::canDecode(e)) { + e->accept(); + } + else + e->ignore(); +} + +void KPrCanvas::dragMoveEvent( QDragMoveEvent *e ) +{ + if( m_currentTextObjectView) + { + KPrTextObject * obj = textUnderMouse( e->pos()); + bool emitChanged = false; + if ( obj ) + emitChanged = checkCurrentTextEdit( obj ); + if ( m_currentTextObjectView ) + { + m_currentTextObjectView->dragMoveEvent( e, QPoint() ); + if ( emitChanged ) + emit currentObjectEditChanged(); + } + } + else if ( QTextDrag::canDecode( e ) + || QImageDrag::canDecode( e ) + || KURLDrag::canDecode(e)) { + e->accept(); + } + else + e->ignore(); +} + +void KPrCanvas::dropImage( QMimeSource * data, bool resizeImageToOriginalSize, int posX, int posY ) +{ + setToolEditMode( TEM_MOUSE ); + deSelectAllObj(); + + QImage pix; + QImageDrag::decode( data, pix ); + + KTempFile tmpFile; + tmpFile.setAutoDelete(true); + + if( tmpFile.status() != 0 ) + return; + + pix.save( tmpFile.name(), "PNG" ); + QCursor c = cursor(); + setCursor( waitCursor ); + + QPoint pos( posX + diffx(), posY + diffy() ); + KoPoint docPoint( m_view->zoomHandler()->unzoomPoint( pos ) ); + + m_activePage->insertPicture( tmpFile.name(), docPoint ); + + tmpFile.close(); + + if ( resizeImageToOriginalSize ) + picViewOriginalSize(); + setCursor( c ); +} + +void KPrCanvas::dropEvent( QDropEvent *e ) +{ + //disallow dropping objects outside the "page" + KoPoint docPoint = m_view->zoomHandler()->unzoomPoint( e->pos()+QPoint(diffx(),diffy()) ); + if ( !m_activePage->getZoomPageRect().contains(e->pos())) + return; + + if ( QImageDrag::canDecode( e ) ) { + dropImage( e, true, e->pos().x(), e->pos().y() ); + e->accept(); + } else if ( KURLDrag::canDecode( e ) ) { + setToolEditMode( TEM_MOUSE ); + deSelectAllObj(); + + KURL::List lst; + KURLDrag::decode( e, lst ); + + KURL::List::ConstIterator it = lst.begin(); + for ( ; it != lst.end(); ++it ) { + const KURL &url( *it ); + + QString filename; + if ( !url.isLocalFile() ) { + if ( !KIO::NetAccess::download( url, filename, this ) ) + continue; + } else { + filename = url.path(); + } + + KMimeMagicResult *res = KMimeMagic::self()->findFileType( filename ); + + if ( res && res->isValid() ) { + QString mimetype = res->mimeType(); + if ( mimetype.contains( "image" ) ) { + QCursor c = cursor(); + setCursor( waitCursor ); + m_activePage->insertPicture( filename, docPoint ); + setCursor( c ); + } else if ( mimetype.contains( "text" ) ) { + QCursor c = cursor(); + setCursor( waitCursor ); + QFile f( filename ); + QTextStream t( &f ); + QString text = QString::null, tmp; + kdDebug()<<" filename :"<insertTextObject( m_view->zoomHandler()->unzoomRect(QRect( e->pos().x(), e->pos().y(), 250, 250 )), + text, m_view ); + + setCursor( c ); + } + } + KIO::NetAccess::removeTempFile( filename ); + } + } + else if (m_currentTextObjectView) + { + m_currentTextObjectView->dropEvent( e ); + } + else if ( QTextDrag::canDecode( e ) ) { + setToolEditMode( TEM_MOUSE ); + deSelectAllObj(); + + QString text; + QTextDrag::decode( e, text ); + //kdDebug()<<" QTextDrag::decode( e, text ); :"<insertTextObject( m_view->zoomHandler()->unzoomRect( QRect( e->pos().x(), e->pos().y(), 250, 250 )), + text, m_view ); + e->accept(); + } else + e->ignore(); + +} + +void KPrCanvas::slotGotoPage() +{ + setSwitchingMode( false ); + //setCursor( blankCursor ); + int pg = m_step.m_pageNumber + 1; + + m_view->setPageDuration( m_step.m_pageNumber ); + + pg = KPrGotoPage::gotoPage( m_view->kPresenterDoc(), m_presentationSlides, pg, this ); + gotoPage( pg ); + + if ( !spManualSwitch() ) { + m_view->setAutoPresTimer( 1 ); + m_setPageTimer = true; + } +} + +void KPrCanvas::gotoPage( int pg ) +{ + int page = pg - 1; + if ( page != m_step.m_pageNumber || m_step.m_step != *m_pageEffectSteps.begin() || m_step.m_subStep != 0 ) { + // clear drawed lines + m_drawModeLines.clear(); + goingBack = false; + + m_step.m_pageNumber = page; + kdDebug(33001) << "Page::gotoPage m_step.m_pageNumber =" << m_step.m_pageNumber << endl; + m_presentationSlidesIterator = m_presentationSlides.find( m_step.m_pageNumber + 1 ); + editMode = false; + m_drawMode = false; + m_pageEffectSteps = m_view->kPresenterDoc()->getPageEffectSteps( m_step.m_pageNumber ); + m_step.m_step = *m_pageEffectSteps.begin(); + m_step.m_subStep = 0; +#if 0 + QRect desk = KGlobalSettings::desktopGeometry(this); + resize( desk.width(), desk.height() ); +#endif + doObjEffects(); + setFocus(); + m_view->refreshPageButton(); + } +} + +void KPrCanvas::presGotoFirstPage() +{ + gotoPage( *m_presentationSlides.begin() ); +} + +KPrTextObject* KPrCanvas::kpTxtObj() const +{ + return ( ( m_editObject && m_editObject->getType() == OT_TEXT ) ? + dynamic_cast( m_editObject ) : 0 ); + // ### return m_currentTextObjectView->kpTextObject() +} + +void KPrCanvas::copyOasisObjs() +{ + //todo copy object from selected object + KoStoreDrag *kd = new KoStoreDrag( "application/vnd.oasis.opendocument.presentation", 0L ); + QDragObject* dragObject = kd; + QByteArray arr; + QBuffer buffer(arr); + KoStore* store = KoStore::createStore( &buffer, KoStore::Write, "application/vnd.oasis.opendocument.presentation" ); + + delete store; + kd->setEncodedData( arr ); + QApplication::clipboard()->setData( dragObject, QClipboard::Clipboard ); +} + +void KPrCanvas::copyObjs() +{ + QDomDocument doc("DOC"); + QDomElement presenter=doc.createElement("DOC"); + presenter.setAttribute("editor", "KPresenter"); + presenter.setAttribute("mime", "application/x-kpresenter"); + + doc.appendChild(presenter); + + QPtrList embeddedObjectsActivePage; + + KoStoreDrag *kd = new KoStoreDrag( "application/x-kpresenter", 0L ); + QDragObject* dragObject = kd; + QByteArray arr; + QBuffer buffer(arr); + KoStore* store = KoStore::createStore( &buffer, KoStore::Write, "application/x-kpresenter" ); + + m_activePage->getAllEmbeddedObjectSelected(embeddedObjectsActivePage ); + + // Save internal embedded objects first, since it might change their URL + int i = 0; + QValueList savePictures; + QPtrListIterator chl( embeddedObjectsActivePage ); + for( ; chl.current(); ++chl ) { + KoDocument* childDoc = chl.current()->document(); + if ( childDoc && !childDoc->isStoredExtern() ) + (void) childDoc->saveToStore( store, QString::number( i++ ) ); + } + + m_activePage->copyObjs(doc, presenter, savePictures); + + KPrDocument* kprdoc = m_view->kPresenterDoc(); + if ( !embeddedObjectsActivePage.isEmpty()) + { + kprdoc->saveEmbeddedObject(m_activePage, embeddedObjectsActivePage,doc,presenter); + } + + if ( !savePictures.isEmpty() ) { + // Save picture list at the end of the main XML + presenter.appendChild( kprdoc->pictureCollection()->saveXML( KoPictureCollection::CollectionPicture, doc, savePictures ) ); + // Save the actual picture data into the store + kprdoc->pictureCollection()->saveToStore( KoPictureCollection::CollectionPicture, store, savePictures ); + // Single image -> put it in dragobject too + if ( savePictures.count() == 1 ) + { + KoPicture pic = kprdoc->pictureCollection()->findPicture( savePictures.first() ); + QDragObject* picDrag = pic.dragObject( 0L ); + if ( picDrag ) { + KMultipleDrag* multipleDrag = new KMultipleDrag( 0L ); + multipleDrag->addDragObject( kd ); + multipleDrag->addDragObject( picDrag ); + dragObject = multipleDrag; + } + } + } + + if ( store->open( "root" ) ) + { + QCString s = doc.toCString(); // this is already Utf8! + //kdDebug(33001) << "KPrCanvas::copyObject: " << s << endl; + (void)store->write( s.data(), s.size()-1 ); + store->close(); + } + + delete store; + kd->setEncodedData( arr ); + QApplication::clipboard()->setData( dragObject, QClipboard::Clipboard ); +} + +void KPrCanvas::deleteObjs() +{ + lowerObject(); + KCommand *cmd=m_activePage->deleteSelectedObjects(); + m_view->kPresenterDoc()->deSelectAllObj(); + if( cmd ) + m_view->kPresenterDoc()->addCommand( cmd ); + emit objectSelectedChanged(); + setToolEditMode( toolEditMode ); +} + + +void KPrCanvas::enterEvent( QEvent *e ) +{ + m_view->setRulerMousePos( ( ( QMouseEvent* )e )->x(), ( ( QMouseEvent* )e )->y() ); + m_view->setRulerMouseShow( true ); +} + +void KPrCanvas::leaveEvent( QEvent * /*e*/ ) +{ + m_view->setRulerMouseShow( false ); +} + +QPtrList KPrCanvas::objectList() const +{ + return m_activePage->objectList(); +} + +const QPtrList &KPrCanvas::getObjectList() const +{ + return m_activePage->objectList(); +} + +unsigned int KPrCanvas::currPgNum() const +{ + return m_view->getCurrPgNum(); +} + +QColor KPrCanvas::txtBackCol() const +{ + return m_view->kPresenterDoc()->txtBackCol(); +} + +bool KPrCanvas::spInfiniteLoop() const +{ + return m_view->kPresenterDoc()->spInfiniteLoop(); +} + +bool KPrCanvas::spShowEndOfPresentationSlide() const +{ + return m_view->kPresenterDoc()->spShowEndOfPresentationSlide(); +} + +bool KPrCanvas::spManualSwitch() const +{ + return m_view->kPresenterDoc()->spManualSwitch(); +} + +QRect KPrCanvas::getPageRect( bool decBorders ) const +{ + return m_view->kPresenterDoc()->getPageRect( decBorders ); +} + +unsigned int KPrCanvas::pageNums() const +{ + return m_view->kPresenterDoc()->getPageNums(); +} + +void KPrCanvas::_repaint( bool /*erase*/ ) +{ + m_view->kPresenterDoc()->repaint( false ); +} + +void KPrCanvas::_repaint( const QRect &r ) +{ + m_view->kPresenterDoc()->repaint( r ); +} + +void KPrCanvas::_repaint( KPrObject *o ) +{ + m_view->kPresenterDoc()->repaint( o ); +} + +void KPrCanvas::slotExitPres() +{ + m_view->screenStop(); +} + +void KPrCanvas::setDrawingMode() +{ + m_presMenu->setItemChecked( PM_DM, true ); + m_drawMode = true; + + setCursor( KPrUtils::penCursor() ); +} + +void KPrCanvas::setSwitchingMode( bool continueTimer ) +{ + m_presMenu->setItemChecked( PM_DM, false ); + + // the following have to be done even when nothing changed + // we don't want to see the cursor nor the automatic pesentation stopped + m_drawMode = false; + m_drawLineInDrawMode = false; + setCursor( blankCursor ); + + if ( continueTimer && !spManualSwitch() ) + m_view->continueAutoPresTimer(); +} + +void KPrCanvas::exitEditMode( bool repaint ) +{ + if ( m_editObject ) + { + if ( m_editObject->getType() == OT_TEXT ) + { + if(m_currentTextObjectView) + { + m_currentTextObjectView->clearSelection(); + //hide cursor when we desactivate textObjectView + if ( repaint ) + { + m_currentTextObjectView->drawCursor( false ); + m_currentTextObjectView->terminate(); + } + KPrTextObject *kpTextObj = m_currentTextObjectView->kpTextObject(); + kpTextObj->setEditingTextObj( false ); + delete m_currentTextObjectView; + m_currentTextObjectView = 0; + + if ( repaint ) + _repaint( static_cast( kpTextObj ) ); + } + // Title of slide may have changed + m_view->kPresenterDoc()->updateSideBarItem( m_activePage ); + emit objectSelectedChanged(); + m_editObject = 0; + } + else if (m_editObject->getType() == OT_PART ) + { + static_cast(m_editObject)->deactivate(); + _repaint( m_editObject ); + m_editObject = 0; + return; + } + } + //modType = MT_NONE; +} + +bool KPrCanvas::getPixmapOrigAndCurrentSize( KPrPixmapObject *&obj, KoSize *origSize, KoSize *currentSize ) +{ + *origSize = KoSize(obj->originalSize().width(),obj->originalSize().height()); + *currentSize = obj->getSize(); + return true; +} + +void KPrCanvas::picViewOriginalSize() +{ + KPrDocument *doc = m_view->kPresenterDoc(); + KPrPixmapObject *object = m_activePage->picViewOrigHelper(); + + KoSize newSize( doc->zoomHandler()->pixelXToPt( object->originalSize().width() ), + doc->zoomHandler()->pixelYToPt( object->originalSize().height() ) ); + + KoRect pageRect = m_activePage->getPageRect(); + double fakt = 1.0; + + if ( newSize.width() > pageRect.width() ) + fakt = pageRect.width() / newSize.width(); + if ( newSize.height() > pageRect.height() ) + fakt = QMIN( fakt, pageRect.height() / newSize.height() ); + + KoSize diff( newSize.width() * fakt - object->getSize().width(), + newSize.height() * fakt - object->getSize().height() ); + + KPrResizeCmd *resizeCmd = new KPrResizeCmd( i18n( "Scale to Original Size" ), + KoPoint( 0, 0 ), diff, object, doc ); + resizeCmd->execute(); + doc->addCommand( resizeCmd ); +} + +void KPrCanvas::picViewOrig640x480() +{ + picViewOrigHelper(640, 480); +} + +void KPrCanvas::picViewOrig800x600() +{ + picViewOrigHelper(800, 600); +} + +void KPrCanvas::picViewOrig1024x768() +{ + picViewOrigHelper(1024, 768); +} + +void KPrCanvas::picViewOrig1280x1024() +{ + picViewOrigHelper(1280, 1024); +} + +void KPrCanvas::picViewOrig1600x1200() +{ + picViewOrigHelper(1600, 1200); +} + +void KPrCanvas::picViewOrigHelper(int x, int y) +{ + KPrPixmapObject *obj = 0; + KoSize origSize; + KoSize currentSize; + + obj=m_activePage->picViewOrigHelper(); + + if ( obj && !getPixmapOrigAndCurrentSize( obj, &origSize, ¤tSize ) ) + return; + KoSize pgSize = m_activePage->getPageRect().size(); + + if ( x == -1 && y == -1 ) { + x = (int)origSize.width(); + y = (int)origSize.height(); + } + + QSize presSize( x, y ); + + scalePixmapToBeOrigIn( currentSize, pgSize, presSize, obj ); +} + +void KPrCanvas::picViewOrigFactor() +{ +} + +void KPrCanvas::scalePixmapToBeOrigIn( const KoSize ¤tSize, const KoSize &pgSize, + const QSize &presSize, KPrPixmapObject *obj ) +{ + QRect desk = KGlobalSettings::desktopGeometry(this); + double faktX = (double)presSize.width() / (double)desk.width(); + double faktY = (double)presSize.height() / (double)desk.height(); + double w = pgSize.width() * faktX; + double h = pgSize.height() * faktY; + + KPrResizeCmd *resizeCmd = new KPrResizeCmd( i18n( "Scale Picture to Be Shown 1:1 in Presentation Mode" ), + KoPoint( 0, 0 ), KoSize( w - currentSize.width(), h - currentSize.height() ), + obj, m_view->kPresenterDoc() ); + resizeCmd->execute(); + m_view->kPresenterDoc()->addCommand( resizeCmd ); +} + +void KPrCanvas::setTextBackground( KPrTextObject */*obj*/ ) +{ + // This is called when double-clicking on a text object. + // What should happen exactly ? (DF) +#if 0 + QPixmap pix( m_activePage->getZoomPageRect().size() ); + QPainter painter( &pix ); + m_activePage->background()->drawBackground( &painter, FALSE ); + QPixmap bpix( obj->getSize().toQSize() ); // ## zoom it ! + bitBlt( &bpix, 0, 0, &pix, obj->getOrig().x(), obj->getOrig().y() - + m_activePage->getZoomPageRect().height() * ( m_view->getCurrPgNum() - 1 ), bpix.width(), bpix.height() ); + QBrush b( white, bpix ); + QPalette pal( obj->textObjectView()->palette() ); + pal.setBrush( QColorGroup::Base, b ); + obj->textObjectView()->setPalette( pal ); +#endif +} + + +KoPoint KPrCanvas::diffGrid( KoRect &rect, double diffx, double diffy ) +{ + KPrDocument * doc( m_view->kPresenterDoc() ); + KoPoint move( 0, 0 ); + + double tempx = ( int( rect.topLeft().x() / doc->getGridX() ) * doc->getGridX() ) - rect.topLeft().x(); + if ( diffx > 0 ) + { + tempx += doc->getGridX(); + while ( diffx > tempx ) + { + move.setX( tempx ); + tempx += doc->getGridX(); + } + } + else + { + while ( diffx < tempx ) + { + move.setX( tempx ); + tempx -= doc->getGridX(); + } + } + double tempy = ( int( rect.topLeft().y() / doc->getGridY() ) * doc->getGridY() ) - rect.topLeft().y(); + if ( diffy > 0 ) + { + tempy += doc->getGridY(); + while ( diffy > tempy ) + { + move.setY( tempy ); + tempy += doc->getGridY(); + } + } + else + { + while ( diffy < tempy ) + { + move.setY( tempy ); + tempy -= doc->getGridY(); + } + } + + return move; +} + + +void KPrCanvas::moveObjectsByKey( int x, int y ) +{ + KPrDocument *doc( m_view->kPresenterDoc() ); + + KoRect rect( objectRect( false ) ); + double diffx = m_view->zoomHandler()->unzoomItX( x ); + double diffy = m_view->zoomHandler()->unzoomItY( y ); + KoPoint move( diffx, diffy ); + + bool snapToGrid = doc->snapToGrid() && !m_disableSnapping; + bool snapToGuideLines = doc->showGuideLines() && !m_disableSnapping; + + if ( snapToGrid ) + { + /* + * Find the distance to the next grid pos. + * The 1E-10 is needed when the object is on the grid when finding the next one, as + * calcualtion with doubles is tricky. + */ + double tempx = int( rect.x() / doc->getGridX() ) * doc->getGridX(); + if ( diffx > 0 ) + { + move.setX( tempx - rect.x() ); + while ( rect.x() - tempx >= -1E-10 ) + { + tempx += doc->getGridX(); + move.setX( tempx - rect.x() ); + } + } + else if ( diffx < 0 ) + { + move.setX( tempx - rect.x() ); + while ( rect.x() - tempx <= 1E-10 ) + { + tempx -= doc->getGridX(); + move.setX( tempx - rect.x() ); + } + } + + double tempy = int( rect.y() / doc->getGridY() ) * doc->getGridY(); + if ( diffy > 0 ) + { + move.setY( tempy - rect.y() ); + while ( rect.y() - tempy >= -1E-10 ) + { + tempy += doc->getGridY(); + move.setY( tempy - rect.y() ); + } + } + else if ( diffy < 0 ) + { + move.setY( tempy - rect.y() ); + while ( rect.y() - tempy <= 1E-10 ) + { + tempy -= doc->getGridY(); + move.setY( tempy - rect.y() ); + } + } + } + + if ( snapToGuideLines ) + { + if ( !snapToGrid ) + { + // unwind last snapping + KoRect movedRect( rect ); + movedRect.moveBy( diffx, diffy ); + movedRect.moveBy( -m_moveSnapDiff.x(), -m_moveSnapDiff.y() ); + move -= m_moveSnapDiff; + + m_moveSnapDiff = KoPoint( 0, 0 ); + + KoGuides::SnapStatus snapStatus = KoGuides::SNAP_NONE; + m_gl.snapToGuideLines( movedRect, KEY_SNAP_DISTANCE, snapStatus, m_moveSnapDiff ); + + move += m_moveSnapDiff; + } + else + { + m_gl.diffNextGuide( rect, move ); + } + } + + // don't move object from canvas + KoRect pageRect( m_activePage->getPageRect() ); + if ( rect.left() + move.x() < pageRect.left() ) + { + move.setX( pageRect.left() - rect.left() ); + } + else if ( rect.right() + move.x() > pageRect.right() ) + { + move.setX( pageRect.right() - rect.right() ); + } + if ( rect.top() + move.y() < pageRect.top() ) + { + move.setY( pageRect.top() - rect.top() ); + } + else if ( rect.bottom() + move.y() > pageRect.bottom() ) + { + move.setY( pageRect.bottom() - rect.bottom() ); + } + + // we only want a repaint if we have guide lines + if ( snapToGuideLines ) + { + // redraw guidelines (intentionally always) + KoRect movedRect( rect ); + movedRect.moveBy( move.x(), move.y() ); + m_gl.repaintSnapping( movedRect ); + } + + if ( move != KoPoint( 0, 0 ) ) + { + //kdDebug(33001) << "moveObjectsByKey move = " << move << endl; + m_activePage->moveObject( m_view, move, false ); + m_view->updateObjectStatusBarItem(); + } +} + + +void KPrCanvas::moveObjectsByMouse( KoPoint &pos, bool keepXorYunchanged ) +{ + KPrDocument *doc( m_view->kPresenterDoc() ); + + KoRect rect( objectRect( false ) ); + KoPoint move( 0, 0 ); + double diffx = pos.x() - m_origMousePos.x(); + double diffy = pos.y() - m_origMousePos.y(); + + bool snapToGrid = doc->snapToGrid() && !m_disableSnapping; + bool snapToGuideLines = doc->showGuideLines() && !m_disableSnapping; + + move = KoPoint( diffx, diffy ); + m_origMousePos = pos; + + // unwind last snapping + KoRect movedRect( rect ); + movedRect.moveBy( diffx, diffy ); + movedRect.moveBy( -m_moveSnapDiff.x(), -m_moveSnapDiff.y() ); + move -= m_moveSnapDiff; + + m_moveSnapDiff = KoPoint( 0, 0 ); // needed if all snapping is off + KoGuides::SnapStatus snapStatus = KoGuides::SNAP_NONE; + + if ( snapToGrid ) + { + m_moveSnapDiff.setX( qRound( movedRect.topLeft().x() / doc->getGridX()) * doc->getGridX() + - movedRect.topLeft().x() ); + m_moveSnapDiff.setY( qRound( movedRect.topLeft().y() / doc->getGridY()) * doc->getGridY() + - movedRect.topLeft().y() ); + snapStatus = KoGuides::SNAP_BOTH; + } + + if ( snapToGuideLines ) + { + m_gl.snapToGuideLines( movedRect, MOUSE_SNAP_DISTANCE, snapStatus, m_moveSnapDiff ); + } + + move += m_moveSnapDiff; + + // don't move object off canvas + KoPoint diffDueToBorders(0,0); + KoRect pageRect( m_activePage->getPageRect() ); + if ( rect.left() + move.x() < pageRect.left() ) + diffDueToBorders.setX( pageRect.left() - (rect.left() + move.x()) ); + else if ( rect.right() + move.x() > pageRect.right() ) + diffDueToBorders.setX( pageRect.right() - (rect.right() + move.x()) ); + + if ( rect.top() + move.y() < pageRect.top() ) + diffDueToBorders.setY( pageRect.top() - (rect.top() + move.y()) ); + else if ( rect.bottom() + move.y() > pageRect.bottom() ) + diffDueToBorders.setY( pageRect.bottom() - (rect.bottom() + move.y()) ); + + m_moveSnapDiff += diffDueToBorders; + move += diffDueToBorders; + + movedRect.moveBy( m_moveSnapDiff.x(), m_moveSnapDiff.y() ); + if ( keepXorYunchanged ) + { + KoPoint diff( m_moveStartPosMouse - movedRect.topLeft() ); + if ( fabs( diff.x() ) > fabs( diff.y() ) ) + { + m_moveSnapDiff.setY( m_moveSnapDiff.y() + m_moveStartPosMouse.y() - movedRect.y() ); + movedRect.moveTopLeft( KoPoint( movedRect.x(), m_moveStartPosMouse.y() ) ); + move.setY( movedRect.y() - rect.y() ); + } + else + { + m_moveSnapDiff.setX( m_moveSnapDiff.x() + m_moveStartPosMouse.x() - movedRect.x() ); + movedRect.moveTopLeft( KoPoint( m_moveStartPosMouse.x(), movedRect.y() ) ); + move.setX( movedRect.x() - rect.x() ); + } + } + + if ( snapToGuideLines ) + { + // redraw guidelines (intentionally always) + m_gl.repaintSnapping( movedRect ); + } + + if ( move != KoPoint( 0, 0 ) ) + { + //kdDebug(33001) << "moveObjectsByMouse move = " << move << endl; + m_activePage->moveObject( m_view, move, false ); + } +} + + +void KPrCanvas::resizeObject( ModifyType _modType, const KoPoint & point, bool keepRatio, bool scaleAroundCenter ) +{ + KPrObject *kpobject = m_resizeObject; + + QRect oldBoundingRect( m_view->zoomHandler()->zoomRect( kpobject->getRepaintRect() ) ); + + KoRect objRect = kpobject->getRealRect(); + KoGuides::SnapStatus snapStatus( KoGuides::SNAP_NONE ); + + bool left = false; + bool right = false; + bool top = false; + bool bottom = false; + if ( _modType == MT_RESIZE_UP || _modType == MT_RESIZE_LU || _modType == MT_RESIZE_RU ) + { + top = true; + snapStatus |= KoGuides::SNAP_HORIZ; + } + if ( _modType == MT_RESIZE_DN || _modType == MT_RESIZE_LD || _modType == MT_RESIZE_RD ) + { + bottom = true; + snapStatus |= KoGuides::SNAP_HORIZ; + } + if ( _modType == MT_RESIZE_LF || _modType == MT_RESIZE_LU || _modType == MT_RESIZE_LD ) + { + left = true; + snapStatus |= KoGuides::SNAP_VERT; + } + if ( _modType == MT_RESIZE_RT || _modType == MT_RESIZE_RU || _modType == MT_RESIZE_RD ) + { + right = true; + snapStatus |= KoGuides::SNAP_VERT; + } + + double newLeft = objRect.left(); + double newRight = objRect.right(); + double newTop = objRect.top(); + double newBottom = objRect.bottom(); + if ( top ) + { + if ( point.y() < objRect.bottom() - MIN_SIZE ) + { + newTop = point.y(); + } + else + { + newTop = objRect.bottom() - MIN_SIZE; + } + } + if ( bottom ) + { + if ( point.y() > objRect.top() + MIN_SIZE ) + { + newBottom = point.y(); + } + else + { + newBottom = objRect.top() + MIN_SIZE; + } + } + if ( left ) + { + if ( point.x() < objRect.right() - MIN_SIZE ) + { + newLeft = point.x(); + } + else + { + newLeft = objRect.right() - MIN_SIZE; + } + } + if ( right ) + { + if ( point.x() > objRect.left() + MIN_SIZE ) + { + newRight = point.x(); + } + else + { + newRight = objRect.left() + MIN_SIZE; + } + } + + double width = newRight - newLeft; + double height = newBottom - newTop; + + if ( keepRatio && m_ratio != 0 ) + { + if ( ( top || bottom ) && ( right || left ) ) + { + if ( height * height * m_ratio > width * width / m_ratio ) + { + width = height * m_ratio; + } + else + { + height = width / m_ratio; + } + } + else if ( top || bottom ) + { + width = height * m_ratio; + } + else + { + height = width / m_ratio; + } + + if ( top ) + { + newTop = objRect.bottom() - height; + } + else + { + newBottom = objRect.top() + height; + } + if ( left ) + { + newLeft = objRect.right() - width; + } + else + { + newRight = objRect.left() + width; + } + } + + if ( scaleAroundCenter ) + { + KoPoint center( m_rectBeforeResize.center() ); + + if ( newLeft != objRect.left() ) + { + width = 2 * ( center.x() - newLeft ); + } + else if ( newRight != objRect.right() ) + { + width = 2 * ( newRight - center.x() ); + } + + // if keep ratio is set caluclate witdh by ratio + if ( keepRatio ) + { + height = width / m_ratio; + } + else + { + if ( newTop != objRect.top() ) + { + height = 2 * ( center.y() - newTop ); + } + else if ( newBottom != objRect.bottom() ) + { + height = 2 * ( newBottom - center.y() ); + } + } + + if ( width < MIN_SIZE ) + { + width = MIN_SIZE; + } + if ( height < MIN_SIZE ) + { + height = MIN_SIZE; + } + + newLeft = center.x() - width / 2; + newRight = newLeft + width; + newTop = center.y() - height / 2; + newBottom = newTop + height; + } + + if ( newLeft != objRect.left() || newRight != objRect.right() || newTop != objRect.top() || newBottom != objRect.bottom() ) + { + // resizeBy and moveBy have to been used to make it work with rotated objects + kpobject->resizeBy( width - objRect.width(), height - objRect.height() ); + + if ( objRect.left() != newLeft || objRect.top() != newTop ) + { + kpobject->moveBy( KoPoint( newLeft - objRect.left(), newTop - objRect.top() ) ); + } + + if ( m_view->kPresenterDoc()->showGuideLines() && !m_disableSnapping ) + { + KoRect rect( kpobject->getRealRect() ); + KoPoint sp( rect.topLeft() ); + if ( right ) + { + sp.setX( rect.right() ); + } + if ( bottom ) + { + sp.setY( rect.bottom() ); + } + m_gl.repaintSnapping( sp, snapStatus ); + } + + _repaint( oldBoundingRect ); + _repaint( kpobject ); + emit objectSizeChanged(); + } +} + + +void KPrCanvas::finishResizeObject( const QString &name, bool layout ) +{ + if ( m_resizeObject ) + { + KoPoint move = KoPoint( m_resizeObject->getOrig().x() - m_rectBeforeResize.x(), + m_resizeObject->getOrig().y() - m_rectBeforeResize.y() ); + KoSize size = KoSize( m_resizeObject->getSize().width() - m_rectBeforeResize.width(), + m_resizeObject->getSize().height() - m_rectBeforeResize.height() ); + + if ( ( m_resizeObject->getRect() ) != m_rectBeforeResize ) + { + KPrResizeCmd *resizeCmd = new KPrResizeCmd( name, move, size, m_resizeObject, + m_view->kPresenterDoc() ); + // the command is not executed as the object is allready resized. + m_view->kPresenterDoc()->addCommand( resizeCmd ); + } + + if ( layout ) + m_view->kPresenterDoc()->layout( m_resizeObject ); + + m_ratio = 0.0; + m_isResizing = false; + _repaint( m_resizeObject ); + m_resizeObject = NULL; + } +} + +void KPrCanvas::raiseObject( KPrObject *object ) +{ + if ( objectList().count() <= 1 ) + return; + + if ( m_objectDisplayAbove == 0 ) + { + if ( m_activePage->numSelected() == 1 ) + { + m_objectDisplayAbove = object; + } + } +} + +void KPrCanvas::lowerObject() +{ + m_objectDisplayAbove = 0; +} + +const QPtrList KPrCanvas::displayObjectList() const +{ + QPtrList list = objectList(); + list.setAutoDelete( false ); + + if ( m_objectDisplayAbove ) + { + // it can happen that the object is no longer there e.g. when + // the insert of the object is undone + int pos = objectList().findRef( m_objectDisplayAbove ); + if ( pos != -1 && m_objectDisplayAbove->isSelected() ) + { + list.take( pos ); + list.append( m_objectDisplayAbove ); + } + else + { + //tz not possible due to const. should const be removed? + //m_objectDisplayAbove = 0; + } + } + return list; +} + +void KPrCanvas::playSound( const QString &soundFileName ) +{ + if(soundPlayer) + delete soundPlayer; + soundPlayer = new KPrSoundPlayer( soundFileName ); + soundPlayer->play(); +} + +void KPrCanvas::stopSound() +{ + if ( soundPlayer ) { + soundPlayer->stop(); + delete soundPlayer; + soundPlayer = 0; + } +} + +void KPrCanvas::setXimPosition( int x, int y, int w, int h, QFont *f ) +{ + QWidget::setMicroFocusHint( x - diffx(), y - diffy(), w, h, true, f ); +} + +void KPrCanvas::createEditing( KPrTextObject *textObj ) +{ + if( m_currentTextObjectView) + { + m_currentTextObjectView->terminate(); + delete m_currentTextObjectView; + m_currentTextObjectView = 0; + m_editObject = 0; + } + m_currentTextObjectView = textObj->createKPTextView( this ); + m_editObject = textObj; +} + +void KPrCanvas::terminateEditing( KPrTextObject *textObj ) +{ + if ( m_currentTextObjectView && m_currentTextObjectView->kpTextObject() == textObj ) + { + m_currentTextObjectView->terminate(); + delete m_currentTextObjectView; + m_currentTextObjectView = 0; + m_editObject = 0; + } +} + +void KPrCanvas::drawCubicBezierCurve( QPainter &p, KoPointArray &points ) +{ + p.save(); + if ( !m_drawLineWithCubicBezierCurve ) + { + QPen pen = QPen( Qt::black, 1, Qt::DashLine ); + p.setPen( pen ); + double angle = KoPoint::getAngle( m_endPoint, m_startPoint ); + drawFigure( L_SQUARE, &p, m_endPoint, pen.color(), pen.width(), angle,m_view->zoomHandler() ); + + p.drawLine( m_view->zoomHandler()->zoomPoint( m_startPoint ), + m_view->zoomHandler()->zoomPoint( m_endPoint ) ); + + KoPoint symmetricEndPoint = m_startPoint * 2 - m_endPoint; + + angle = KoPoint::getAngle( symmetricEndPoint, m_startPoint ); + drawFigure( L_SQUARE, &p, symmetricEndPoint, pen.color(), pen.width(), angle,m_view->zoomHandler() ); + + // TODO only 1 draw line + p.drawLine( m_view->zoomHandler()->zoomPoint( m_startPoint ), + m_view->zoomHandler()->zoomPoint( symmetricEndPoint ) ); + + p.save(); + p.setPen( QPen( Qt::black, 1, Qt::SolidLine ) ); + p.drawCubicBezier( points.zoomPointArray( m_view->zoomHandler() ) ); + p.restore(); + } + else + { + KoPoint startPoint( m_pointArray.at( m_indexPointArray - 1 ) ); + + p.drawLine( m_view->zoomHandler()->zoomPoint( startPoint ), + m_view->zoomHandler()->zoomPoint( m_endPoint ) ); + } + p.restore(); +} + + +void KPrCanvas::redrawCubicBezierCurve( QPainter &p ) +{ + if ( m_indexPointArray > 0 ) + { + for ( int count = 0; count < m_indexPointArray - 4; count += 4 ) + { + double _firstX = m_pointArray.at( count ).x(); + double _firstY = m_pointArray.at( count ).y(); + + double _fourthX = m_pointArray.at( count + 1 ).x(); + double _fourthY = m_pointArray.at( count + 1 ).y(); + + double _secondX = m_pointArray.at( count + 2 ).x(); + double _secondY = m_pointArray.at( count + 2 ).y(); + + double _thirdX = m_pointArray.at( count + 3 ).x(); + double _thirdY = m_pointArray.at( count + 3 ).y(); + + KoPointArray points; + points.putPoints( 0, 4, _firstX,_firstY, _secondX,_secondY, _thirdX,_thirdY, _fourthX,_fourthY ); + + p.drawCubicBezier( points.zoomPointArray( m_view->zoomHandler() ) ); + } + } +} + + +void KPrCanvas::drawPolygon( QPainter &p, const KoRect &rect ) +{ + KoRect nRect = rect.normalize(); + bool checkConcavePolygon = m_view->getCheckConcavePolygon(); + int cornersValue = m_view->getCornersValue(); + int sharpnessValue = m_view->getSharpnessValue(); + + KoRect _rect( 0, 0, nRect.width(), nRect.height() ); + double angle = 2 * M_PI / cornersValue; + double diameter = static_cast( QMAX( _rect.width(), _rect.height() ) ); + double radius = diameter * 0.5; + + KoPointArray _points( checkConcavePolygon ? cornersValue * 2 : cornersValue ); + _points.setPoint( 0, 0, qRound( -radius ) ); + + double xmin = 0; + double ymin = qRound( -radius ); + + if ( checkConcavePolygon ) { + angle = angle / 2.0; + double a = angle; + double r = radius - ( sharpnessValue / 100.0 * radius ); + for ( int i = 1; i < cornersValue * 2; ++i ) { + double xp, yp; + if ( i % 2 ) { + xp = r * sin( a ); + yp = -r * cos( a ); + } + else { + xp = radius * sin( a ); + yp = -radius * cos( a ); + } + a += angle; + _points.setPoint( i, xp, yp ); + if (xp < xmin) + xmin = xp; + if (yp < ymin) + ymin = yp; + } + } + else { + double a = angle; + for ( int i = 1; i < cornersValue; ++i ) { + double xp = radius * sin( a ); + double yp = -radius * cos( a ); + a += angle; + _points.setPoint( i, xp, yp ); + if (xp < xmin) + xmin = xp; + if (yp < ymin) + ymin = yp; + } + } + + // calculate the points as offsets to 0,0 + KoRect _changRect = _points.boundingRect(); + double fx = _rect.width() / _changRect.width(); + double fy = _rect.height() / _changRect.height(); + + int _index = 0; + KoPointArray tmpPoints; + KoPointArray::ConstIterator it; + for ( it = _points.begin(); it != _points.end(); ++it ) { + KoPoint point = (*it); + double tmpX = ( point.x() - xmin) * fx + nRect.x(); + double tmpY = ( point.y() - ymin) * fy + nRect.y(); + + tmpPoints.putPoints( _index, 1, tmpX,tmpY ); + ++_index; + } + p.drawPolygon( tmpPoints.zoomPointArray( m_view->zoomHandler() ) ); + m_pointArray = tmpPoints; +} + + +bool KPrCanvas::oneObjectTextSelected() const +{ + return m_activePage->oneObjectTextSelected(); +} + +bool KPrCanvas::oneObjectTextExist() const +{ + return m_activePage->oneObjectTextExist(); +} + +KPrPage* KPrCanvas::activePage() const +{ + return m_activePage; +} + +void KPrCanvas::setActivePage( KPrPage* active ) +{ + Q_ASSERT(active); + //kdDebug(33001)<<"KPrCanvas::setActivePage( KPrPage* active) :"<kPresenterDoc()->isHeader(obj) && !m_activePage->hasHeader() ) + || ( m_view->kPresenterDoc()->isFooter(obj) && !m_activePage->hasFooter() ) ) + return true; + return false; +} + +int KPrCanvas::numberOfObjectSelected() const +{ + int nb = m_activePage->numSelected(); + return nb; +} + +KPrObject *KPrCanvas::getSelectedObj() const +{ + KPrObject *obj = m_activePage->getSelectedObj(); + return obj; +} + +void KPrCanvas::ungroupObjects() +{ + KMacroCommand *macro = 0; + m_activePage->ungroupObjects( ¯o ); + if ( macro ) + m_view->kPresenterDoc()->addCommand( macro ); +} + +void KPrCanvas::groupObjects() +{ + m_activePage->groupObjects(); +} + +KoRect KPrCanvas::objectRect( bool all ) const +{ + return m_activePage->getRealRect( all ); +} + +void KPrCanvas::scrollTopLeftPoint( const QPoint & pos ) +{ + m_view->getHScrollBar()->setValue( pos.x() ); + m_view->getVScrollBar()->setValue( pos.y() ); +} + +void KPrCanvas::changePicture( const KURL & url, QWidget *window ) +{ + m_activePage->changePicture( url, window ); +} + +unsigned int KPrCanvas::objNums() const +{ + return m_activePage->objNums(); +} + + +void KPrCanvas::ensureVisible( int x, int y, int xmargin, int ymargin ) +{ + + int newy= (y+ymargin)-(visibleRect().bottom()+diffy()); + + if( newy > 0) + m_view->getVScrollBar()->setValue(m_view->getVScrollBar()->value()+newy); + else + { + newy= (y )-(visibleRect().top()+diffy()); + if( newy < 0) + m_view->getVScrollBar()->setValue(m_view->getVScrollBar()->value()+newy - ymargin); + } + + int newx= (x+xmargin)-(visibleRect().right()+diffx()); + if( newx > 0) + m_view->getHScrollBar()->setValue(m_view->getHScrollBar()->value()+newx); + else + { + newx= x -(visibleRect().left()+diffx()); + if( newx < 0) + m_view->getHScrollBar()->setValue(m_view->getHScrollBar()->value()+newx - xmargin ); + } +} + +// "Extend Contents to Object Height" +void KPrCanvas::textContentsToHeight() +{ + QPtrList lst = applicableTextObjects(); + if ( lst.isEmpty() ) + return; + QPtrListIterator it( lst ); + KMacroCommand * macro = 0L; + for ( ; it.current() ; ++it ) { + KCommand *cmd= it.current()->textContentsToHeight(); + if( cmd ) + { + if ( !macro ) + macro = new KMacroCommand(i18n("Extend Text Contents to Height")); + macro->addCommand( cmd); + _repaint( it.current() ); + } + } + if( macro ) + { + macro->execute(); + m_view->kPresenterDoc()->addCommand( macro ); + m_view->kPresenterDoc()->repaint(this); + } +} + +// "Resize Object to fit Contents" +void KPrCanvas::textObjectToContents() +{ + QPtrList lst = applicableTextObjects(); + if ( lst.isEmpty() ) + return; + QPtrListIterator it( lst ); + KMacroCommand * macro = 0L; + for ( ; it.current() ; ++it ) { + KCommand *cmd= it.current()->textObjectToContents(); + if( cmd ) + { + if (!macro ) + macro = new KMacroCommand(i18n("Extend Text to Contents")); + macro->addCommand( cmd); + } + } + + if( macro) + { + macro->execute(); + m_view->kPresenterDoc()->addCommand( macro ); + m_view->kPresenterDoc()->repaint(this); + } + +} + +void KPrCanvas::flipObject( bool _horizontal ) +{ + QPtrList lst; + QPtrListIterator it(getObjectList()); + for ( ; it.current(); ++it ) { + if ( it.current()->isSelected() && + it.current()->getType() != OT_AUTOFORM && + it.current()->getType() != OT_PART && + it.current()->getType() != OT_TEXT ) + { + lst.append( it.current() ); + } + } + if ( lst.isEmpty() ) + return; + + KPrFlipObjectCommand *flipCmd = new KPrFlipObjectCommand( i18n("Flip Objects"), + m_view->kPresenterDoc(), + _horizontal, lst ); + flipCmd->execute(); + m_view->kPresenterDoc()->addCommand( flipCmd ); +} + +void KPrCanvas::lowerObjs( bool backward ) +{ + lowerObject(); + m_activePage->lowerObjs( backward ); +} + +void KPrCanvas::raiseObjs( bool forward ) +{ + lowerObject(); + m_activePage->raiseObjs( forward ); +} + +QPtrList KPrCanvas::listOfTextObjs() const +{ + QPtrList lst; + QPtrListIterator it(getObjectList()); + for ( ; it.current(); ++it ) { + if ( it.current()->getType() == OT_TEXT ) + { + if ( objectIsAHeaderFooterHidden(it.current())) + continue; + else + lst.append( static_cast( it.current() )); + } + } + return lst; +} + +KPrTextObject* KPrCanvas::textUnderMouse( const QPoint & point ) +{ + QPtrList obj = listOfTextObjs(); + QPtrListIterator it2(obj ); + for ( ; it2.current() ; ++it2 ) { + QRect outerRect( m_view->kPresenterDoc()->zoomHandler()->zoomRect( it2.current()->getRect()) ); + if ( !it2.current()->isProtectContent() && outerRect.contains( point) ) + return it2.current(); + } + return 0L; +} + +void KPrCanvas::speakTextUnderMouse(QWidget* w, const QPoint& p, uint flags) +{ + Q_UNUSED( flags ); + if ( w != this ) return; + // Since text objects can't get focus without clicking with the mouse, + // no point in supporting focus speaking. + if ( p == QPoint() ) return; + KPrTextObject *to = textUnderMouse( w->mapFromGlobal( p ) ); + if ( to == m_prevSpokenTO ) return; + m_prevSpokenTO = to; + if ( to ) { + QString text = to->textObject()->textDocument()->plainText(); + if ( !text.isEmpty() ) kospeaker->sayWidget( text ); + } +} + +bool KPrCanvas::checkCurrentTextEdit( KPrTextObject * textObj ) +{ + bool emitChanged = false; + if ( textObj && m_currentTextObjectView && m_currentTextObjectView->kpTextObject() != textObj ) + { + m_currentTextObjectView->kpTextObject()->setEditingTextObj( false ); + _repaint( m_currentTextObjectView->kpTextObject() ); + //don't remove selection otherwise break dnd. + m_currentTextObjectView->terminate(false); + delete m_currentTextObjectView; + m_currentTextObjectView = 0L; + emitChanged = true; + } + + // Edit the frameset under the mouse, if any + if ( textObj && !m_currentTextObjectView ) + { + m_currentTextObjectView = textObj->createKPTextView( this ); + emitChanged = true; + } + return emitChanged; +} + +void KPrCanvas::alignObjects( AlignType at ) +{ + KPrDocument * doc = m_view->kPresenterDoc(); + + QString name; + + switch ( at ) + { + case AT_LEFT: + name = i18n( "Align Objects Left" ); + break; + case AT_TOP: + name = i18n( "Align Objects Top" ); + break; + case AT_RIGHT: + name = i18n( "Align Objects Right" ); + break; + case AT_BOTTOM: + name = i18n( "Align Objects Bottom" ); + break; + case AT_HCENTER: + name = i18n( "Align Objects Centered (horizontal)" ); + break; + case AT_VCENTER: + name = i18n( "Align Objects Center/Vertical" ); + break; + } + + QPtrList objects; + + QPtrListIterator it( m_activePage->objectList() ); + for ( ; it.current() ; ++it ) + { + if ( it.current() == m_view->kPresenterDoc()->header() || + it.current() == m_view->kPresenterDoc()->footer() ) + continue; + + if( it.current()->isSelected() && !it.current()->isProtect() ) { + objects.append( it.current() ); + } + } + + if ( objects.count() ) + { + KCommand * cmd = new KPrAlignCmd( name, objects, at, doc ); + cmd->execute(); + doc->addCommand( cmd ); + } +} + +bool KPrCanvas::canMoveOneObject() const +{ + return m_activePage->canMoveOneObject(); +} + +void KPrCanvas::closeObject(bool /*close*/) +{ + QPtrList lst; + QPtrListIterator it(getObjectList()); + for ( ; it.current(); ++it ) { + if ( it.current()->isSelected() + && (it.current()->getType() == OT_POLYLINE || it.current()->getType() == OT_FREEHAND + || it.current()->getType() == OT_QUADRICBEZIERCURVE + || it.current()->getType() == OT_CUBICBEZIERCURVE )) + lst.append( it.current() ); + } + if ( lst.isEmpty()) + return; + + KCommand * cmd= new KPrCloseObjectCommand( i18n("Close Object"), lst, m_view->kPresenterDoc() ); + cmd->execute(); + m_view->kPresenterDoc()->addCommand( cmd ); +} + +void KPrCanvas::layout() +{ + QPtrListIterator it(getObjectList()); + for ( ; it.current(); ++it ) { + if ( it.current()->getType() == OT_TEXT ) + static_cast( it.current() )->layout(); + } +} + +KoPoint KPrCanvas::snapPoint( KoPoint &pos, bool repaintSnapping ) +{ + KoPoint sp( pos ); + KPrDocument * doc( m_view->kPresenterDoc() ); + + bool snapToGrid = doc->snapToGrid() && !m_disableSnapping; + bool snapToGuideLines = doc->showGuideLines() && !m_disableSnapping; + + KoPoint snapDiff = KoPoint( 0, 0 ); // needed if all snapping is off + KoGuides::SnapStatus snapStatus = KoGuides::SNAP_NONE; + + if ( snapToGrid ) + { + snapDiff.setX( qRound( sp.x() / doc->getGridX()) * doc->getGridX() - sp.x() ); + snapDiff.setY( qRound( sp.y() / doc->getGridY()) * doc->getGridY() - sp.y() ); + snapStatus = KoGuides::SNAP_BOTH; + } + + if ( snapToGuideLines ) + { + m_gl.snapToGuideLines( sp, MOUSE_SNAP_DISTANCE, snapStatus, snapDiff ); + } + + sp += snapDiff; + + // don't snap out of canvas + KoRect pageRect( m_activePage->getPageRect() ); + if ( sp.x() < pageRect.left() ) + sp.setX( pageRect.left() ); + else if ( sp.x() > pageRect.right() ) + sp.setX( pageRect.right() ); + + if ( sp.y() < pageRect.top() ) + sp.setY( pageRect.top() ); + else if ( sp.y() > pageRect.bottom() ) + sp.setY( pageRect.bottom() ); + + // redraw guidelines (intentionally always) + if ( repaintSnapping && snapToGuideLines ) + { + m_gl.repaintSnapping( sp, KoGuides::SNAP_BOTH ); + } + + return sp; +} + + +void KPrCanvas::alignVertical( VerticalAlignmentType _type ) +{ + KCommand *cmd = m_activePage->alignVertical( _type ); + if ( cmd ) + m_view->kPresenterDoc()->addCommand( cmd ); +} + +KPrPixmapObject * KPrCanvas::getSelectedImage() const +{ + return m_activePage->getSelectedImage(); +} + + +KoPointArray KPrCanvas::getObjectPoints( const KoPointArray &pointArray ) +{ + KoRect rect = pointArray.boundingRect(); + + KoPointArray points( pointArray ); + points.translate( -rect.x(), -rect.y() ); + + return points; +} + +void KPrCanvas::objectPopup( KPrObject *object, const QPoint &point ) +{ + switch ( object->getType() ) + { + case OT_PICTURE: + case OT_CLIPART: + m_view->openPopupMenuObject( "picmenu_popup", point ); + break; + case OT_TEXT: + { + KPrTextObject *obj=dynamic_cast(object); + if ( obj ) + m_view->changeVerticalAlignmentStatus( obj->verticalAlignment() ); + m_view->openPopupMenuObject( "textobject_popup", point ); + } break; + case OT_PIE: + m_view->openPopupMenuObject( "piemenu_popup", point ); + break; + case OT_RECT: + case OT_ELLIPSE: + m_view->openPopupMenuObject( "rectangleobject_popup", point ); + break; + case OT_PART: + m_view->openPopupMenuObject( "partobject_popup", point ); + break; + case OT_POLYGON: + m_view->openPopupMenuObject( "polygonobject_popup", point ); + break; + case OT_POLYLINE: + case OT_CUBICBEZIERCURVE: + case OT_QUADRICBEZIERCURVE: + case OT_FREEHAND: + m_view->openPopupMenuObject( "closed_popup", point ); + break; + case OT_LINE: + case OT_CLOSED_LINE: + m_view->openPopupMenuObject( "flip_popup", point ); + break; + case OT_GROUP: + if ( oneObjectTextSelected()) + m_view->openPopupMenuObject( "textobject_popup", point ); + else + m_view->openPopupMenuObject( "flip_popup", point ); + break; + default: + m_view->openPopupMenuObject( "graphmenu_popup", point ); + break; + } +} + +void KPrCanvas::popupContextMenu() +{ + if ( !editMode ) { + if ( !m_drawMode && !spManualSwitch() ) + { + finishObjectEffects(); + finishPageEffect(); + m_view->stopAutoPresTimer(); + } + setCursor( arrowCursor ); + QPoint p( width()/2, height()/2 ); + int ret = m_presMenu->exec( p ); + // we have to continue the timer if the menu was canceled and draw mode is not active + if ( ret == -1 && !m_presMenu->isItemChecked( PM_DM ) && !spManualSwitch() ) + m_view->continueAutoPresTimer(); + return; + } + if ( m_currentTextObjectView ) { + // TODO: Better to popup at caret position. + // KoTextCursor* cursor = m_currentTextObjectView->cursor(); + KoPoint kop = m_currentTextObjectView->kpTextObject()->getOrig(); + QPoint p = m_view->zoomHandler()->zoomPoint( kop ); + p = mapToGlobal( p ); + m_currentTextObjectView->showPopup( m_view, p, m_view->actionList() ); + return; + } + if (!m_activePage) return; + KPrObject* obj = m_activePage->getSelectedObj(); + if (obj) { + KoPoint kop = obj->getOrig(); + QPoint p = m_view->zoomHandler()->zoomPoint( kop ); + p = mapToGlobal( p ); + objectPopup( obj, p ); + } else { + QPoint p = mapToGlobal( QPoint() ); + m_view->openPopupMenuMenuPage( p ); + } +} diff --git a/kpresenter/KPrCanvas.h b/kpresenter/KPrCanvas.h new file mode 100644 index 00000000..ca81fdfc --- /dev/null +++ b/kpresenter/KPrCanvas.h @@ -0,0 +1,938 @@ +// -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*- +/* This file is part of the KDE project + Copyright (C) 1998, 1999 Reginald Stadlbauer + Copyright (C) 2002-2005 Thorsten Zachmann + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + + +#ifndef __KPRCANVAS__ +#define __KPRCANVAS__ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include "KoPointArray.h" +#include "global.h" +#include +#include +#include "presstep.h" + +class KURL; +class KoTextFormatInterface; +class KPrView; +class KPrDocument; +class QPainter; +class KTextEdit; +class KPrTextObject; +class KPrObject; +class KPopupMenu; +class QResizeEvent; +class QPaintEvent; +class QDragEnterEvent; +class QDragMoveEvent; +class QDropEvent; +class QFocusEvent; +class QMouseEvent; +class QWheelEvent; +class QKeyEvent; +class KPrPixmapObject; +class KPrBackGround; +class QRect; +class QSize; +class QPoint; +class KPrSoundPlayer; +class KoTextObject; +class KoParagCounter; +class KPrPage; +class KPrinter; +class KPrTextView; +class KPrPartObject; +class KCommand; +class KPrEffectHandler; +class KPrPageEffects; +/** + * Class KPCanvas - There is a single instance of this class for a given view. + * + * It manages the graphical representation of all the objects. + */ +class KPrCanvas : public QWidget +{ + Q_OBJECT + +public: + + /// constructor + KPrCanvas( QWidget *parent=0,const char *name=0,KPrView *_view=0 ); + /// destructor + ~KPrCanvas(); + + KPrView * getView()const { return m_view; } + + // The equivalent of contentsX() and contentsY() for a QScrollView + // The Canvas is a widget, not a scrollview (because we handle the scrollbars ourselves, + // to have the "goto page" buttons at the bottom of the scrollbars etc.) + int diffx() const { return m_xOffset; } + int diffy() const { return m_yOffset; } + void setDiffX( int _diffX ) { m_xOffset = _diffX; } + void setDiffY( int _diffY ) { m_yOffset = _diffY; } + void scrollX( int x ); + void scrollY( int y ); + + // public functions + void selectAllObj(); + void deSelectAllObj(); + void selectObj( KPrObject* ); + void deSelectObj( KPrObject* ); + void setTextFormat(const KoTextFormat &format, int flags); + + void setTextColor( const QColor & ); + void setTextBackgroundColor( const QColor & ); + void setTextAlign( int ); + void setTextDepthPlus(); + void setTextDepthMinus(); + void setNewRightIndent(double _rightIndent); + void setNewLeftIndent(double _leftIndent); + void setNewFirstIndent(double _firstIndent); + //void setTextCounter(KoParagCounter counter); + void setTabList( const KoTabulatorList & tabList ); + void setTextBold( bool b ); + void setTextItalic( bool b ); + void setTextUnderline( bool b ); + void setTextStrikeOut( bool b ); + void setTextFamily( const QString &f ); + void setTextPointSize( int s ); + void setTextSubScript( bool b ); + void setTextSuperScript( bool b ); + void setTextDefaultFormat( ); + void setIncreaseFontSize(); + void setDecreaseFontSize(); + KPrTextObject* kpTxtObj() const; + + /** + * Start a screen presentation + * All pages if @p curPgNum is -1, otherwise just @p curPgNum (1-based) + */ + void startScreenPresentation( double zoomX, double zoomY, int curPgNum = -1); + void stopScreenPresentation(); + + /** + * Go to the next step in the presentation. + * gotoNextPage: if is set to true go to beginning of the + * next page. + */ + bool pNext( bool gotoNextPage = false ); + + /** + * Go to previous step of the presentation. + * gotoPreviousPage: if is set to true go to beginning of the + * previous page. + */ + bool pPrev( bool gotoPreviousPage = false ); + + /// returns the current page of the presentation 1 based + unsigned int presPage() const { return m_step.m_pageNumber + 1; } + /// returns the current step of the presentation + int presStep() const { return m_step.m_step; } + int numPresSteps() const { return m_pageEffectSteps.count(); } + int numPresPages() const { return m_presentationSlides.count(); } + + bool canAssignEffect( QPtrList &objs ) const; + + void print( QPainter*, KPrinter*, float, float ); + + + void setPartEntry( KoDocumentEntry& _e ) + { partEntry = _e; } + void setToolEditMode( ToolEditMode _m, bool updateView = true ); + void setAutoForm( const QString &_autoform ) + { autoform = _autoform; } + + /** + \brief Draw page into QPixmap. + + Draws page pgnum of the currently open presentation into a QPixmap + using the specified zoom factor (or fixed width/height dimensions, resp.) + + Set forceWidth and/or forceHeight to override the zoom factor + and obtain a pixmap of the specified width and/or height. + By omitting one of them you make sure that the aspect ratio + of your page is used for the resulting image. + + \sa exportPage + */ + void drawPageInPix( QPixmap&, int pgnum, int zoom, + bool forceRealVariableValue = false, + int forceWidth = 0, + int forceHeight = 0 ); + + /** + \brief Save page to bitmap file. + + Export a page of the currently open presentation to disk + using a bitmap format like e.g. PNG. + This method uses a QPixmap::save() call. + + \param nPage the internally used 0-based page number + \param nWidth the desired image width in px + \param nHeight the desired image height in px + \param fileURL the URL of the image file to be created: if this + does not point to a local file a KTempFile is created by QPixmap::save() + which is then copied over to the desired location. + \param format the format of the image file (see QPixmap::save()) + \param quality the quality of the image (see QPixmap::save()) + + example: +\verbatim +exportPage( 0, s, 800, 600, "/home/khz/page0.png", "PNG", 100 ); +\endverbatim + \returns True if the file was written successfully. + + \sa drawPageInPix, KPrViewIface::exportPage + */ + bool exportPage( int nPage, int nWidth, int nHeight, + const KURL& fileURL, + const char* format, + int quality = -1 ); + + void gotoPage( int pg ); + + /** + * Go to first slide of presentation. + * Used in presentation mode. + */ + void presGotoFirstPage(); + + KPrPage* activePage() const; + + bool oneObjectTextExist() const; + bool oneObjectTextSelected() const; + bool isOneObjectSelected() const; + /** Returns the list of selected text objects */ + QPtrList selectedTextObjs() const; + /** + * Returns the list of interfaces to use for changing the text format. + * This can be either the currently edited text object, + * or the list of text objects currently selected + */ + QPtrList applicableTextInterfaces() const; + /** + * Returns the list of text objects, either selected or activated. + */ + QPtrList applicableTextObjects() const; + + void setMouseSelectedObject(bool b); + + bool haveASelectedPartObj() const; + bool haveASelectedGroupObj() const; + bool haveASelectedPixmapObj() const; + + KPrTextView *currentTextObjectView() const { return m_currentTextObjectView; } + + QPtrList objectList() const; + + // get - set data + const QPtrList & getObjectList() const; + + void playSound( const QString &soundFileName ); + void stopSound(); + + ///for KPrTextView + void dragStarted() { mousePressed = false; } + + void setXimPosition( int x, int y, int w, int h, QFont *f ); + void createEditing( KPrTextObject *textObj ); + + + /** + * @brief Add a line + * + * @param startPoint the start point of the line + * @param endPoint the end point of the line + */ + void insertLine( const KoPoint &startPoint, const KoPoint &endPoint ); + + /** + * @brief Add a rectangle + * + * @param rect the size and position of the rectangle + */ + void insertRect( const KoRect &rect); + + /** + * @brief Add a ellipse + * + * @param rect the size and position of the ellipse + */ + void insertEllipse( const KoRect &rect ); + + /** + * @brief Add a pie/arc/chord + * + * @param rect the size and position of the pie/arc/chord + */ + void insertPie( const KoRect &rect ); + + /** + * @brief Add a text object + * + * @param rect the size and position of the text object + */ + KPrTextObject* insertTextObject( const KoRect &rect ); + + /** + * @brief Add a picture + * + * @param rect the size and position of the picture + */ + void insertPicture( const KoRect &rect ); + void changePicture( const KURL & url, QWidget *window ); + + int numberOfObjectSelected() const; + KPrObject *getSelectedObj() const; + KPrPixmapObject *getSelectedImage() const; + + bool getEditMode() const { return editMode; } + + void ungroupObjects(); + void groupObjects(); + + unsigned int objNums() const; + + void ensureVisible( int x, int y, int xmargin, int ymargin ); + + /** + * @brief get the rect for the objects + * + * @param all true if the rect for all objects shoud be returned + * false if only the rect for selected objects sould be returned + * + * @return rect of the objects + */ + KoRect objectRect( bool all ) const; + + void scrollTopLeftPoint( const QPoint & pos ); + + void textContentsToHeight(); + void textObjectToContents(); + + void flipObject( bool _horizontal ); + + void lowerObjs( bool backward ); + void raiseObjs( bool forward ); + + /** + * @brief Align objects + * + * This will align all selected non protected objects according to the + * align type at. + * + * @param at the align type + */ + void alignObjects( AlignType at ); + + bool canMoveOneObject()const; + QPtrList listOfTextObjs() const; + + QPixmap getPicturePixmap() const; + void closeObject(bool _close); + void layout(); + void alignVertical( VerticalAlignmentType _type ); + void savePicture(); + + void dropImage( QMimeSource * data, bool resizeImageToOriginalSize = false , int posX = 10, int posY=10 ); + KoGuides & guideLines() { return m_gl; } + + /** + * @brief Open the object popup + * + * @param object the selected object + * @param point where the popup should be displayed + */ + void objectPopup( KPrObject *object, const QPoint &point ); + +public slots: + // use repaint = false when the KPrCanvas is destroyed to avaid a possible crash + void exitEditMode( bool repaint = true ); + + void clipCut(); + void clipCopy(); + void clipPaste(); + void deleteObjs(); + void copyObjs(); + void copyOasisObjs(); + + void chPic(); + void picViewOriginalSize(); + void picViewOrig640x480(); + void picViewOrig800x600(); + void picViewOrig1024x768(); + void picViewOrig1280x1024(); + void picViewOrig1600x1200(); + void picViewOrigFactor(); + void setActivePage( KPrPage* active ); + + /** + * @brief Set the guide move state + * + * @param state true set guide move state + * false unset guide move state + */ + void setPaintGuides( bool state ); + +signals: + + // signals to notify of changes + void fontChanged( const QFont & ); + void colorChanged( const QColor & ); + void alignChanged( int ); + /** + * Emmitted when presentation should be restarted + * This is used in automatic screen and infinite loop mode. + */ + void stopAutomaticPresentation(); + /** + * Emmitted when presentation should be restarted + * This is used in automatic screen and infinite loop mode. + */ + void restartPresentation(); + void objectSelectedChanged(); + void objectSizeChanged(); + /// Emitted when the current frameset edit changes + void currentObjectEditChanged(); + + void selectionChanged( bool hasSelection ); + void sigMouseWheelEvent( QWheelEvent * ); + +protected: + struct PicCache + { + QPicture pic; + int num; + int subPresStep; + }; + + // functions for displaying + /** + * This method is used for repainting the canvas. + */ + virtual void paintEvent( QPaintEvent* ); + + /** + * Draws the background of page to painter. + * Set edit to true if in edit mode, false in presentation mode. + */ + void drawBackground( QPainter* painter, const QRect& rect, KPrPage * page, bool edit = false ) const; + + /** + * Draw obj to painter. + */ + void drawAllObjectsInPage( QPainter *painter, const QPtrList & obj, int pageNum ) const; + + /** + * Draw _objects shown at step to painter. + * This method is used for presentation mode, printing. + */ + void drawObjectsPres( QPainter *painter, const QPtrList &_objects, PresStep step ) const; + + /** + * Draw _objects to painter. + * Only rect is painted. + * This method is used for edit mode. + */ + void drawObjectsEdit( QPainter *painter, const KoRect &rect, const QPtrList &_objects, + SelectionMode selectionMode, int page ) const; + + /** + * Draw _objects to painter. + * contour if true only countor of selected objects is drawn + * selectionMode selected objects use this selection mode + * textView if set print editable textobject (used by drawObjectsEdit) + * This method is used by drawObjectsPres and drawObjectsEdit. + */ + void drawObjects( QPainter *painter, const QPtrList &objects, SelectionMode selectionMode, + bool contour, KPrTextView * textView, int pageNum ) const; + + /** + * Draw _objects of page to painter. + * This method is used for edit mode. + */ + void drawEditPage( QPainter *painter, const QRect &_rect, + KPrPage *page, SelectionMode selectionMode ) const; + + /** + * Draw _objects of page shown at step to painter. + * This method is used for presentation mode, printing. + */ + void drawPresPage( QPainter *painter, const QRect &_rect, PresStep step ) const; + + /// draw grid + void drawGrid(QPainter *painter, const QRect &rect2) const; + + /** + * Finish the object effects. + * This shown the last step of the effect. It stops the effect timer and + * disconnect it and the effect handler deleted. + */ + bool finishObjectEffects(); + + bool finishPageEffect( bool cancel = false ); + + void drawCurrentPageInPix( QPixmap& ) const; + virtual void mousePressEvent( QMouseEvent *e ); + virtual void mouseReleaseEvent( QMouseEvent *e ); + virtual void mouseMoveEvent( QMouseEvent *e ); + virtual void mouseDoubleClickEvent( QMouseEvent *e ); + virtual void wheelEvent( QWheelEvent *e ); + virtual void resizeEvent( QResizeEvent *e ); + virtual bool close( bool alsoDelete ); + /** + * Returns the object at position pos + * @param pos the position in the document on which to look + * @param withoutProtected if set to true only unprotecred objects are returned + * @return the object at position pos + */ + KPrObject *getObjectAt( const KoPoint &pos, bool withoutProtected = false ); + virtual void focusInEvent( QFocusEvent* ) {} + virtual void focusOutEvent( QFocusEvent* ) {} + virtual void enterEvent( QEvent *e ); + virtual void leaveEvent( QEvent *e ); + virtual void dragEnterEvent( QDragEnterEvent *e ); + virtual void dragMoveEvent( QDragMoveEvent *e ); + virtual void dropEvent( QDropEvent *e ); + virtual void keyPressEvent( QKeyEvent *e ); + virtual void keyReleaseEvent( QKeyEvent *e ); + virtual void imStartEvent( QIMEvent * e ); + virtual void imComposeEvent( QIMEvent * e ); + virtual void imEndEvent( QIMEvent * e ); + + void eraseEmptySpace( QPainter * painter, const QRegion & emptySpaceRegion, const QBrush & brush ) const; + + /// setup popupmenus + void setupMenus(); + + unsigned int currPgNum() const; + QColor txtBackCol() const; + bool spInfiniteLoop() const; + bool spShowEndOfPresentationSlide() const; + bool spManualSwitch() const; + QRect getPageRect( bool decBorders = true ) const; + unsigned int pageNums() const; + + void _repaint( bool erase=true ); + void _repaint( const QRect &r ); + void _repaint( KPrObject *o ); + + /** + * Draw page defined in step to painter. + * This method is used for printing a presentation. + */ + void printPage( QPainter*, PresStep step, KPrinter *printer, int rows, int cols ); + + /** + * This method animates the objects in the presentation. + */ + void doObjEffects( bool isAllreadyPainted = false ); + + /** + * @brief Add a object + * + * @param rect the size and position of the object + */ + KPrPartObject *insertObject( const KoRect &rect ); + + /** + * @brief Add a autoform object + * + * @param rect the size and position of the autoform object + */ + void insertAutoform( const KoRect &rect ); + void insertFreehand( const KoPointArray &_pointArray ); + void insertPolyline( const KoPointArray &_pointArray ); + void insertCubicBezierCurve( const KoPointArray &_pointArray ); + void insertPolygon( const KoPointArray &_pointArray ); + void insertClosedLine( const KoPointArray &_pointArray ); + + void selectNext(); + void selectPrev(); + + void scalePixmapToBeOrigIn( const KoSize ¤tSize, const KoSize &pgSize, + const QSize &presSize, KPrPixmapObject *obj ); + bool getPixmapOrigAndCurrentSize( KPrPixmapObject *&obj, KoSize *origSize, KoSize *currentSize ); + void setTextBackground( KPrTextObject *obj ); + virtual bool eventFilter( QObject *o, QEvent *e ); + virtual bool focusNextPrevChild( bool ); + + void endDrawPolyline(); + + /** + * @brief Draw a cubic bezier curve. + */ + void drawCubicBezierCurve( QPainter &p, KoPointArray &points ); + //void drawCubicBezierCurve( int _dx, int _dy ); + void endDrawCubicBezierCurve(); + + /** + * @brief Redraw the curve defined in m_pointArray + * + * @param p painter used for drawing + */ + void redrawCubicBezierCurve( QPainter &p ); + + +#ifndef NDEBUG + void printRTDebug( int info ); +#endif + + KoRect getAlignBoundingRect() const; + +private: + void picViewOrigHelper(int x, int y); + + /** + * @brief Move object by key + * + * @param x The distance to move the objects in x direction + * @param y The distance to move the objects in y direction + */ + void moveObjectsByKey( int x, int y ); + + /** + * @brief Move object by mouse + * + * @param pos The position of the mouse + * @param keepXorYunchanged if true keep x or y position unchanged + */ + void moveObjectsByMouse( KoPoint &pos, bool keepXorYunchanged ); + + //---- stuff needed for resizing ---- + /// resize the m_resizeObject + void resizeObject( ModifyType _modType, const KoPoint & point, bool keepRatio, bool scaleAroundCenter ); + /// create KPrResizeCmd + void finishResizeObject( const QString &name, bool layout = true ); + + /** + * @brief Display object above the other objects in editiong mode + * + * This is used to bring a single slected object to front, so it is easier + * to modify. + * + * @param object which should be displayed above the other objects + */ + void raiseObject( KPrObject *object ); + /** + * @brief Don't display an object above the others + */ + void lowerObject(); + /** + * @brief Get the list of objects in the order they should be displayed. + * + * This takes into acount the object set in raiseObject so that it is + * the last one in the list returned (the one that is displayed above all + * the others). + * + * @return List of objects + */ + const QPtrList displayObjectList() const; + + /** + * This is used in automatic presentation mode. + * If it is set to true and we are in automatic presentation + * mode the timer of the page will be activated after the last + * effect has been shown. + */ + bool m_setPageTimer; + + /// Helper function to draw a polygon + void drawPolygon( QPainter &p, const KoRect &rect ); + + /// Helper function to draw a pie/arc/chord + void drawPieObject( QPainter *p, const KoRect &rect ); + + QPoint limitOfPoint(const QPoint& _point) const; + + /** + * Return true if object is a header/footer which is hidden. + */ + bool objectIsAHeaderFooterHidden(KPrObject *obj) const; + + KPrTextObject* textUnderMouse( const QPoint & point ); + bool checkCurrentTextEdit( KPrTextObject * textObj ); + + /** + * @brief Snap @p pos to grid and guide lines. + * + * This method looks if the @p pos has to be snapped to a guide or grid or both. + * If so it returns the position it has snapped to. + * + * @param pos the point which should be snapped + * @param repaintSnapping true if the guides should be repainted. + * @param repaintSnapping false when the guides should not be repainted. + * You have to call repaint by yourself. + * + * @return the position of the snapped point + */ + KoPoint snapPoint( KoPoint &pos, bool repaintSnapping = true ); + + /** + * @brief Find the next grid in distance + * + * Allways the top left corner is snapped to the grid. + * + * @param rect The rect which should be snapped to the grid. + * @param diffx The range in x distance in which the grid has to be. + * @param diffy The range in y distance in which the grid has to be. + * + * @return the distance to the guide or ( 0, 0 ) if there is no guide to snap to. + */ + KoPoint diffGrid( KoRect &rect, double diffx, double diffy ); + + void recalcAutoGuides( ); + + /** + * @brief Calculate the points in distance to the top left corner + * + * @param pointArray the points in coordinate position + */ + KoPointArray getObjectPoints( const KoPointArray &pointArray ); + + + /** + * @brief Update m_insertRect + * + * This will set the bottom right corner of the insert rect to + * the given point. If the AltButton is pressed the insert rect + * is moved with its bottom right to the given point. + * + * @param point the bottom right point of the inserted object + * @param The state of the mouse and modifier buttons + * + */ + void updateInsertRect( const KoPoint &point, Qt::ButtonState state ); + + /** + * @brief Popup context menu + * + * Popup context menu for current active or selected object, + * otherwise popup context menu for page. + */ + void popupContextMenu(); + +private slots: + void toFontChanged( const QFont &font ) { emit fontChanged( font ); } + void toColorChanged( const QColor &color ) { emit colorChanged( color ); } + void toAlignChanged( int a ) { emit alignChanged( a ); } + /** + * Switch to drawing mode. In drawing mode it is possible to draw on the + * current slide. + * Only to be used in presentation mode. + */ + void setDrawingMode(); + /** + * Set switching mode. This ends drawing mode and goes back to + * stepping between the pages. + * If continueTimer is true the autoPres timer is continued + * Only to be used in presentation mode. + */ + void setSwitchingMode( bool continueTimer = true ); + void slotGotoPage(); + void slotExitPres(); + void terminateEditing( KPrTextObject * ); + + /** + * Do the next step of the object effect. + * This restarts the effect tmer. If the effects are + * completed the timer is disconnected and the effect handler + * deleted. + */ + void slotDoEffect(); + + void slotDoPageEffect(); + + /** + * Scroll canvas when receiving this signal + */ + void slotAutoScroll(const QPoint &scrollDist); + + /** + * Speak the text object under the mouse. This slot is normally + * connected to the kospeaker customSpeakWidget signal. + */ + void speakTextUnderMouse(QWidget* w, const QPoint& p, uint flags); + +private: + /// Distance for snapping to guide line with mouse + static const int MOUSE_SNAP_DISTANCE; + /// Distance for snapping to guide line with key + static const int KEY_SNAP_DISTANCE; + // variables + /// Popup menu used in presentation mode. + KPopupMenu *m_presMenu; + bool showingLastSlide; + bool mousePressed; + bool drawContour; + ModifyType modType; + + /// text or part object when it is edited + KPrObject * m_editObject; + + bool fillBlack; + KPrView *m_view; + bool editMode, goingBack; + /** + * True when we are in drawing mode. + * False when we are in switching mode. + */ + bool m_drawMode; + /** + * True if the a line should be drawn. + * Used in drawing mode. + */ + bool m_drawLineInDrawMode; + + /** + * Save the lines drawed in drawMode. + * This is used for paint events. + * Used in drawing mode. + */ + QValueVector m_drawModeLines; + + /** + * Index into the QPointArray for the next point of the line in draw mode. + * Used in drawing mode. + */ + int m_drawModeLineIndex; + + bool mouseSelectedObject; + /// information about current step of the presentation + PresStep m_step; + float _presFakt; + int m_showOnlyPage; // 1-based (-1 = all) + /// list of all effect steps occuring on the active page + QValueList m_pageEffectSteps; + /// List of the slides used in the presentation + QValueList m_presentationSlides; + /// Iterator over the slides of a presentation + QValueList::Iterator m_presentationSlidesIterator; + /// KPrEffectHandler for object effects + KPrEffectHandler *m_effectHandler; + + KPrPageEffects *m_pageEffect; + + /// EffectTimer + QTimer m_effectTimer; + + QTimer m_pageEffectTimer; + + /// menu identifier for draw mode + int PM_DM; + int delPageId; + bool drawRubber; + /// rect for drawing rubber + KoRect m_rubber; + + //---- stuff needed for resizing ---- + /// object which gets resized + KPrObject *m_resizeObject; + /// size of the object at when resizing is started + KoRect m_rectBeforeResize; + /// ratio of the object ( width / height ) + double m_ratio; + bool m_isResizing; + + //---- stuff needed for moving ---- + bool m_isMoving; + KoPoint m_moveStartPoint; + + //---- stuff needed for rotating ---- + /// object which gets rotated + KPrObject *m_rotateObject; + /// center of the rotated object + KoPoint m_rotateCenter; + /// start point for rotation + KoPoint m_rotateStart; + /// angle of the object at start of rotate + double m_angleBeforeRotate; + + ToolEditMode toolEditMode; + /// The rect of the object during insert. + KoRect m_insertRect; + KoDocumentEntry partEntry; + QString autoform; + QPixmap buffer; + + KPrTextView *m_currentTextObjectView; + + KPrSoundPlayer *soundPlayer; + + KoPointArray m_pointArray, m_oldCubicBezierPointArray; + QPoint m_dragStartPoint, m_dragEndPoint, m_dragSymmetricEndPoint; + /// The start position of an insert for line objects + KoPoint m_startPoint; + /// The end position of an insert for line objects + KoPoint m_endPoint; + KoPoint m_symmetricEndPoint; + KoPoint m_CubicBezierSecondPoint, m_CubicBezierThirdPoint; + int m_indexPointArray; + bool m_drawPolyline; + bool m_drawCubicBezierCurve; + bool m_drawLineWithCubicBezierCurve; + bool m_zoomRubberDraw; + + KPrPage *m_activePage; + int m_xOffset, m_yOffset; + int m_xOffsetSaved, m_yOffsetSaved; // saved when going fullscreen + + /// Start position for move with mouse + KoPoint m_moveStartPosMouse; + /// This holds the distance it an object was snapped to a guide + KoPoint m_moveSnapDiff; + /// Set to true if snapping should be disabled (by pressing shift during move) + bool m_disableSnapping; + /// The last position of the mouse during moving + KoPoint m_origMousePos; + /// start position for move with key + KoPoint m_moveStartPosKey; + + KPrPage * m_activePageBeforePresentation; + int m_zoomBeforePresentation; + + bool m_keyPressEvent; + bool m_drawSymetricObject; + + /// guides + KoGuides m_gl; + /// true if we are in guide move state, false otherwise + bool m_paintGuides; + + /// object which is selected and should be shown above all the other objects + KPrObject * m_objectDisplayAbove; + + /// Previously spoken text object. + KPrTextObject *m_prevSpokenTO; +}; + +#endif // __KPRCANVAS__ diff --git a/kpresenter/KPrClosedLineObject.cpp b/kpresenter/KPrClosedLineObject.cpp new file mode 100644 index 00000000..4e11006a --- /dev/null +++ b/kpresenter/KPrClosedLineObject.cpp @@ -0,0 +1,339 @@ +// -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*- +/* This file is part of the KDE project + Copyright (C) 2002 Toshitaka Fujioka + Copyright (C) 2005 Thorsten Zachmann + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#include "KPrClosedLineObject.h" +#include "KPrPointObject.h" +#include "KPrGradient.h" +#include "KPrSVGPathParser.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +KPrClosedLineObject::KPrClosedLineObject() + : KPr2DObject() +{ +} + +KPrClosedLineObject::KPrClosedLineObject( const KoPointArray &_points, const KoSize &_size, const KoPen &_pen, const QBrush &_brush, + FillType _fillType, const QColor &_gColor1, const QColor &_gColor2, BCType _gType, + bool _unbalanced, int _xfactor, int _yfactor, const QString _typeString ) + : KPr2DObject( _pen, _brush, _fillType, _gColor1, _gColor2, _gType, _unbalanced, _xfactor, _yfactor ) +{ + points = KoPointArray( _points ); + ext = _size; + typeString = _typeString; +} + +KPrClosedLineObject::KPrClosedLineObject( const KPrPointObject &object ) +: KPr2DObject( object.getPen(), QBrush::NoBrush, FT_BRUSH, QColor(), QColor(), BCT_PLAIN, false, 0, 0 ) +{ + ext = object.getSize(); + orig = object.getOrig(); + objectName = object.getObjectName(); + points = object.getPoints().copy(); + points.putPoints( points.count(), 1, points.at( 0 ).x(), points.at( 0 ).y() ); + switch ( object.getType() ) + { + case OT_FREEHAND: + typeString = i18n( "Closed Freehand" ); + break; + case OT_POLYLINE: + typeString = i18n( "Closed Polyline" ); + break; + case OT_CUBICBEZIERCURVE: + typeString = i18n( "Closed Cubic Bezier Curve" ); + break; + case OT_QUADRICBEZIERCURVE: + typeString = i18n( "Closed Quadric Bezier Curve" ); + break; + default: + break; + } + +} + +KPrClosedLineObject &KPrClosedLineObject::operator=( const KPrClosedLineObject & ) +{ + return *this; +} + +#if 0 +DCOPObject* KPrClosedLineObject::dcopObject() +{ + if ( !dcop ) + dcop = new KPClosedLineObjectIface( this ); + return dcop; +} +#endif + +QDomDocumentFragment KPrClosedLineObject::save( QDomDocument& doc, double offset ) +{ + QDomDocumentFragment fragment = KPr2DObject::save( doc, offset ); + + QDomElement elemObjectsName = doc.createElement( "OBJECTSNAME" ); + + elemObjectsName.setAttribute( "NAME", typeString ); + + fragment.appendChild( elemObjectsName ); + + if ( !points.isNull() ) { + QDomElement elemPoints = doc.createElement( "POINTS" ); + KoPointArray::ConstIterator it; + for ( it = points.begin(); it != points.end(); ++it ) { + QDomElement elemPoint = doc.createElement( "Point" ); + KoPoint point = (*it); + elemPoint.setAttribute( "point_x", point.x() ); + elemPoint.setAttribute( "point_y", point.y() ); + + elemPoints.appendChild( elemPoint ); + } + fragment.appendChild( elemPoints ); + } + + return fragment; +} + +bool KPrClosedLineObject::saveOasisObjectAttributes( KPOasisSaveContext &sc ) const +{ + KPrShadowObject::saveOasisDrawPoints( points, sc ); + return true; +} + +const char * KPrClosedLineObject::getOasisElementName() const +{ + return "draw:polygon"; +} + + +double KPrClosedLineObject::load( const QDomElement &element ) +{ + double offset = KPr2DObject::load( element ); + + QDomElement e = element.namedItem( "OBJECTSNAME" ).toElement(); + if ( !e.isNull() ) { + if ( e.hasAttribute( "NAME" ) ) + typeString = e.attribute( "NAME" ); + } + + e = element.namedItem( "POINTS" ).toElement(); + if ( !e.isNull() ) { + QDomElement elemPoint = e.firstChild().toElement(); + unsigned int index = 0; + while ( !elemPoint.isNull() ) { + if ( elemPoint.tagName() == "Point" ) { + double tmpX = 0; + double tmpY = 0; + if( elemPoint.hasAttribute( "point_x" ) ) + tmpX = elemPoint.attribute( "point_x" ).toDouble(); + if( elemPoint.hasAttribute( "point_y" ) ) + tmpY = elemPoint.attribute( "point_y" ).toDouble(); + + points.putPoints( index, 1, tmpX,tmpY ); + } + elemPoint = elemPoint.nextSibling().toElement(); + ++index; + } + } + return offset; +} + +void KPrClosedLineObject::setSize( double _width, double _height ) +{ + KoSize origSize( ext ); + KPrObject::setSize( _width, _height ); + + double fx = ext.width() / origSize.width(); + double fy = ext.height() / origSize.height(); + + updatePoints( fx, fy ); +} + +void KPrClosedLineObject::updatePoints( double _fx, double _fy ) +{ + int index = 0; + KoPointArray tmpPoints; + KoPointArray::ConstIterator it; + for ( it = points.begin(); it != points.end(); ++it ) { + KoPoint point = (*it); + double tmpX = point.x() * _fx; + double tmpY = point.y() * _fy; + + tmpPoints.putPoints( index, 1, tmpX,tmpY ); + ++index; + } + points = tmpPoints; +} + +void KPrClosedLineObject::paint( QPainter* _painter,KoTextZoomHandler*_zoomHandler, + int /* pageNum */, bool drawingShadow, bool drawContour ) +{ + int _w = ( pen.style() == Qt::NoPen ) ? 1 : int( pen.pointWidth() ); + + if ( drawContour ) { + QPointArray pointArray2 = points.zoomPointArray( _zoomHandler ); + QPen pen3( Qt::black, 1, Qt::DotLine ); + _painter->setPen( pen3 ); + _painter->setRasterOp( Qt::NotXorROP ); + _painter->drawPolygon( pointArray2 ); + return; + } + + QPointArray pointArray = points.zoomPointArray( _zoomHandler, _w ); + QPen pen2 = pen.zoomedPen( _zoomHandler ); + + if ( drawingShadow || getFillType() == FT_BRUSH || !gradient ) { + _painter->setPen( pen2 ); + _painter->setBrush( getBrush() ); + _painter->drawPolygon( pointArray ); + } + else { + QSize size( _zoomHandler->zoomSize( ext ) ); + if ( m_redrawGradientPix || gradient->size() != size ) + { + m_redrawGradientPix = false; + gradient->setSize( size ); + QRegion clipregion( pointArray ); + m_gradientPix.resize( size ); + m_gradientPix.fill( Qt::white ); + + QPainter p; + p.begin( &m_gradientPix ); + p.setClipRegion( clipregion ); + p.drawPixmap( 0, 0, gradient->pixmap() ); + p.end(); + + m_gradientPix.setMask( m_gradientPix.createHeuristicMask() ); + } + + QRect _rect = pointArray.boundingRect(); + _painter->drawPixmap( 0, 0, m_gradientPix, 0, 0, _rect.width(), _rect.height() ); + + _painter->setPen( pen2 ); + _painter->setBrush( Qt::NoBrush ); + _painter->drawPolygon( pointArray ); + } +} + +void KPrClosedLineObject::flip( bool horizontal ) +{ + KPr2DObject::flip( horizontal ); + // flip the points + KoPointArray tmpPoints; + int index = 0; + if ( ! horizontal ) + { + KoPointArray::ConstIterator it; + double horiz = getSize().height()/2; + for ( it = points.begin(); it != points.end(); ++it ) { + KoPoint point = (*it); + if ( point.y()> horiz ) + tmpPoints.putPoints( index, 1, point.x(),point.y()- 2*(point.y()-horiz) ); + else + tmpPoints.putPoints( index, 1, point.x(),point.y()+ 2*(horiz - point.y()) ); + ++index; + } + } + else + { + KoPointArray::ConstIterator it; + double vert = getSize().width()/2; + for ( it = points.begin(); it != points.end(); ++it ) { + KoPoint point = (*it); + if ( point.x()> vert ) + tmpPoints.putPoints( index, 1, point.x()- 2*(point.x()-vert), point.y() ); + else + tmpPoints.putPoints( index, 1, point.x()+ 2*(vert - point.x()),point.y() ); + ++index; + } + } + points = tmpPoints; +} + +void KPrClosedLineObject::loadOasis( const QDomElement &element, KoOasisContext & context, KPrLoadingInfo *info ) +{ + kdDebug()<<"void KPrClosedLineObject::loadOasis( const QDomElement &element )***********\n"; + KPr2DObject::loadOasis( element,context, info ); + QString tag( element.tagName() ); + if ( tag == "polygon" ) + { + KPrShadowObject::loadOasisDrawPoints( points, element, context, info ); + } + else if ( tag == "path" ) // this is used to load closed draw:path objects + { + QString d = element.attributeNS( KoXmlNS::svg, "d", QString::null); + kdDebug(33001) << "path d: " << d << endl; + + KPrSVGPathParser parser; + points = parser.getPoints( d, true ); + loadOasisApplyViewBox( element, points ); + } + else if ( tag == "custom-shape" ) + { + QDomElement enhancedGeometry = KoDom::namedItemNS( element, KoXmlNS::draw, "enhanced-geometry" ); + + if ( !enhancedGeometry.isNull() ) + { + QString d = enhancedGeometry.attributeNS( KoXmlNS::draw, "enhanced-path", QString::null ); + QRegExp rx( "^([0-9 MLZ]+)N$" ); + if ( rx.search( d ) != -1 ) + { + d = rx.cap( 1 ); + kdDebug(33001) << "enhanced-path d: " << d << endl; + + KPrSVGPathParser parser; + points = parser.getPoints( d, true ); + loadOasisApplyViewBox( enhancedGeometry, points ); + } + } + } + else + { + kdDebug(33001) << "KPrClosedLineObject::loadOasis unsupported tag" << endl; + } +} + +KoSize KPrClosedLineObject::getRealSize() const { + KoSize size( ext ); + KoPoint realOrig( orig ); + KoPointArray p( points ); + getRealSizeAndOrigFromPoints( p, angle, size, realOrig ); + return size; +} + +KoPoint KPrClosedLineObject::getRealOrig() const { + KoSize size( ext ); + KoPoint realOrig( orig ); + KoPointArray p( points ); + getRealSizeAndOrigFromPoints( p, angle, size, realOrig ); + return realOrig; +} diff --git a/kpresenter/KPrClosedLineObject.h b/kpresenter/KPrClosedLineObject.h new file mode 100644 index 00000000..60c07ea6 --- /dev/null +++ b/kpresenter/KPrClosedLineObject.h @@ -0,0 +1,84 @@ +// -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*- +/* This file is part of the KDE project + Copyright (C) 2002 Toshitaka Fujioka + Copyright (C) 2005 Thorsten Zachmann + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#ifndef kpclosedlineoject_h +#define kpclosedlineoject_h + +#include +#include "KoPointArray.h" +#include "KPrObject.h" + +class KPrGradient; +class QPainter; +class DCOPObject; +class KPrPointObject; + +class KPrClosedLineObject : public KPr2DObject +{ +public: + KPrClosedLineObject(); + KPrClosedLineObject( const KoPointArray &_points, const KoSize &_size, const KoPen &_pen, const QBrush &_brush, + FillType _fillType, const QColor &_gColor1, const QColor &_gColor2, BCType _gType, + bool _unbalanced, int _xfactor, int _yfactor, const QString _type ); + /** + * @brief Construct object form a KPrPointObject. + * + * This constructor is used when a KPrPointObject objects gets closed. + * It is then changed into a KPrClosedLineObject. + * + * @param object form which the KPrClosedLineObject is constructed + */ + KPrClosedLineObject( const KPrPointObject &object ); + + virtual ~KPrClosedLineObject() {} + //virtual DCOPObject* dcopObject(); + + KPrClosedLineObject &operator=( const KPrClosedLineObject & ); + + virtual void setSize( double _width, double _height ); + virtual void setSize( const KoSize & _size ) { setSize( _size.width(), _size.height() ); } + + virtual ObjType getType() const { return OT_CLOSED_LINE; } + virtual QString getTypeString() const { return typeString; } + + + virtual QDomDocumentFragment save( QDomDocument& doc, double offset ); + virtual double load( const QDomElement &element ); + virtual void loadOasis( const QDomElement &element, KoOasisContext & context, KPrLoadingInfo *info ); + + virtual void flip(bool horizontal ); + virtual KoSize getRealSize() const; + virtual KoPoint getRealOrig() const; + +protected: + virtual const char * getOasisElementName() const; + virtual bool saveOasisObjectAttributes( KPOasisSaveContext &sc ) const; + virtual void paint( QPainter *_painter,KoTextZoomHandler*_zoomHandler, + int /* pageNum */, bool drawingShadow, bool drawContour ); + + void updatePoints( double _fx, double _fy ); + + KoPointArray points; + + QString typeString; +}; + +#endif diff --git a/kpresenter/KPrCommand.cpp b/kpresenter/KPrCommand.cpp new file mode 100644 index 00000000..62119e9f --- /dev/null +++ b/kpresenter/KPrCommand.cpp @@ -0,0 +1,2827 @@ +// -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*- +/* This file is part of the KDE project + Copyright (C) 2001 Laurent Montel + Copyright (C) 2005-2006 Thorsten Zachmann + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#include "KPrDocument.h" +#include "KPrPage.h" +#include "KPrCommand.h" +#include "KPrBackground.h" +#include "KPrGroupObject.h" + + +#include "KPrLineObject.h" +#include "KPrEllipseObject.h" +#include "KPrAutoformObject.h" +#include "KPrFreehandObject.h" +#include "KPrPolylineObject.h" +#include "KPrBezierCurveObject.h" +#include "KPrPolygonObject.h" +#include "KPrClosedLineObject.h" + +#include "KPrTextObject.h" +#include "KPrPixmapObject.h" + +#include "KPrPartObject.h" +#include +#include "KPrPieObject.h" +#include "KPrRectObject.h" +#include "KPrView.h" +#include "KoTextObject.h" +#include "KPrTextDocument.h" +#include +#include "KPrVariableCollection.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + +KPrShadowCmd::KPrShadowCmd( const QString &_name, QPtrList &_oldShadow, ShadowValues _newShadow, + QPtrList &_objects, KPrDocument *_doc ) + : KNamedCommand( _name ), oldShadow( _oldShadow ), objects( _objects ) +{ + objects.setAutoDelete( false ); + oldShadow.setAutoDelete( false ); + doc = _doc; + newShadow = _newShadow; + + m_page = doc->findPage( objects ); + + QPtrListIterator it( objects ); + for ( ; it.current() ; ++it ) + it.current()->incCmdRef(); +} + +KPrShadowCmd::~KPrShadowCmd() +{ + QPtrListIterator it( objects ); + for ( ; it.current() ; ++it ) + it.current()->decCmdRef(); + oldShadow.setAutoDelete( true ); + oldShadow.clear(); +} + +void KPrShadowCmd::execute() +{ + QPtrListIterator it( objects ); + for ( ; it.current() ; ++it ) + it.current()->setShadowParameter(newShadow.shadowDistance, + newShadow.shadowDirection, + newShadow.shadowColor); + doc->repaint( false ); + + doc->updateSideBarItem( m_page ); +} + +void KPrShadowCmd::unexecute() +{ + for ( unsigned int i = 0; i < objects.count(); i++ ) + objects.at( i )->setShadowParameter(oldShadow.at(i)->shadowDistance, + oldShadow.at(i)->shadowDirection, + oldShadow.at(i)->shadowColor); + doc->repaint( false ); + + doc->updateSideBarItem( m_page ); +} + + +KPrSetOptionsCmd::KPrSetOptionsCmd( const QString &_name, QValueList &_diffs, QPtrList &_objects, + double _gridX, double _gridY, double _oldGridX, double _oldGridY, + const QColor &_txtBackCol, const QColor &_otxtBackCol, KPrDocument *_doc ) + : KNamedCommand( _name ), + diffs( _diffs ), + objects( _objects ), + txtBackCol( _txtBackCol ), + otxtBackCol( _otxtBackCol ) +{ + gridX = _gridX; + gridY = _gridY; + oldGridX = _oldGridX; + oldGridY = _oldGridY; + doc = _doc; + QPtrListIterator it( objects ); + for ( ; it.current() ; ++it ) + it.current()->incCmdRef(); +} + +KPrSetOptionsCmd::~KPrSetOptionsCmd() +{ + QPtrListIterator it( objects ); + for ( ; it.current() ; ++it ) + it.current()->decCmdRef(); +} + +void KPrSetOptionsCmd::execute() +{ + // ## use iterator + for ( unsigned int i = 0; i < objects.count(); i++ ) + objects.at( i )->moveBy( *diffs.at( i ) ); + doc->setGridValue( gridX, gridY, false ); + doc->updateRuler(); + doc->setTxtBackCol( txtBackCol ); + doc->repaint( false ); +} + +void KPrSetOptionsCmd::unexecute() +{ + for ( unsigned int i = 0; i < objects.count(); i++ ) + objects.at( i )->moveBy( -(*diffs.at( i )).x(), -(*diffs.at( i )).y() ); + doc->setGridValue( oldGridX, oldGridY, false ); + doc->updateRuler(); + doc->setTxtBackCol( otxtBackCol ); + doc->repaint( false ); +} + +KPrSetBackCmd::KPrSetBackCmd( const QString &name, const KPrBackGround::Settings &settings, + const KPrBackGround::Settings &oldSettings, + bool useMasterBackground, + bool takeGlobal, KPrDocument *doc, KPrPage *page ) +: KNamedCommand( name ) +, m_settings( settings ) +, m_oldSettings( oldSettings ) +, m_useMasterBackground( useMasterBackground ) +, m_oldUseMasterBackground( page->useMasterBackground() ) +, m_takeGlobal( takeGlobal ) +, m_doc( doc ) +, m_page( page ) +{ +} + +void KPrSetBackCmd::execute() +{ + if ( !m_takeGlobal ) { + m_page->background()->setBackGround( m_settings ); + m_page->setUseMasterBackground( m_useMasterBackground ); + m_doc->restoreBackground( m_page ); + } else { + QPtrListIterator it( m_doc->getPageList() ); + for ( ; it.current() ; ++it ) + { + it.current()->background()->setBackGround( m_settings ); + it.current()->setUseMasterBackground( m_useMasterBackground ); + m_doc->restoreBackground(it.current()); + } + + } + m_doc->repaint( false ); + + if ( m_takeGlobal ) { + QPtrListIterator it( m_doc->getPageList() ); + for ( int pos = 0; it.current(); ++it, ++pos ) { + m_doc->updateSideBarItem( it.current() ); + } + } + else { + m_doc->updateSideBarItem( m_page ); + } +} + +void KPrSetBackCmd::unexecute() +{ + if ( !m_takeGlobal ) { + m_page->background()->setBackGround( m_oldSettings ); + m_page->setUseMasterBackground( m_oldUseMasterBackground ); + m_doc->restoreBackground( m_page ); + } else { + QPtrListIterator it( m_doc->getPageList() ); + for ( ; it.current() ; ++it ) + { + it.current()->background()->setBackGround( m_oldSettings ); + it.current()->setUseMasterBackground( m_oldUseMasterBackground ); + m_doc->restoreBackground(it.current()); + } + } + m_doc->repaint( false ); + + if ( m_takeGlobal ) { + QPtrListIterator it( m_doc->getPageList() ); + for ( int pos = 0; it.current(); ++it, ++pos ) { + m_doc->updateSideBarItem( it.current() ); + } + } + else { + m_doc->updateSideBarItem( m_page ); + } +} + +KPrRotateCmd::KPrRotateCmd( const QString &_name, float newAngle, QPtrList &objects, + KPrDocument *doc, bool addAngle ) + : KNamedCommand( _name ), m_doc( doc ), m_newAngle( newAngle ), m_addAngle( addAngle ) +{ + m_objects.setAutoDelete( false ); + m_oldAngles.setAutoDelete( false ); + + QPtrListIterator it( objects ); + for ( ; it.current() ; ++it ) + { + m_objects.append( it.current() ); + + RotateValues *old = new RotateValues; + old->angle = it.current()->getAngle(); + m_oldAngles.append( old ); + + it.current()->incCmdRef(); + } + + m_page = m_doc->findPage( m_objects ); +} + +KPrRotateCmd::~KPrRotateCmd() +{ + QPtrListIterator it( m_objects ); + for ( ; it.current() ; ++it ) + it.current()->decCmdRef(); + m_oldAngles.setAutoDelete( true ); + m_oldAngles.clear(); +} + +void KPrRotateCmd::execute() +{ + QPtrListIterator it( m_objects ); + for ( ; it.current() ; ++it ) + { + if ( m_addAngle ) + it.current()->rotate( it.current()->getAngle() + m_newAngle ); + else + it.current()->rotate( m_newAngle ); + } + m_doc->updateRuler(); + m_doc->repaint( false ); + + m_doc->updateSideBarItem( m_page ); +} + +void KPrRotateCmd::unexecute() +{ + for ( unsigned int i = 0; i < m_objects.count(); i++ ) + m_objects.at(i)->rotate( m_oldAngles.at( i )->angle ); + m_doc->updateRuler(); + m_doc->repaint( false ); + + m_doc->updateSideBarItem( m_page ); +} + + +KPrChgPixCmd::KPrChgPixCmd( const QString &_name, KPrPixmapObject *_oldObject, KPrPixmapObject *_newObject, + KPrDocument *_doc, KPrPage *_page) + : KNamedCommand( _name ) +{ + oldObject = _oldObject; + newObject = _newObject; + m_page=_page; + doc = _doc; + oldObject->incCmdRef(); + newObject->incCmdRef(); + newObject->setSize( oldObject->getSize() ); + newObject->setOrig( oldObject->getOrig() ); +} + +KPrChgPixCmd::~KPrChgPixCmd() +{ + oldObject->decCmdRef(); + newObject->decCmdRef(); +} + +void KPrChgPixCmd::execute() +{ + m_page->replaceObject( oldObject, newObject ); + doc->repaint( newObject ); + + doc->updateSideBarItem( m_page ); +} + +void KPrChgPixCmd::unexecute() +{ + m_page->replaceObject( newObject, oldObject ); + doc->repaint( oldObject ); + + doc->updateSideBarItem( m_page ); +} + +KPrDeleteCmd::KPrDeleteCmd( const QString &_name, QPtrList &_objects, + KPrDocument *_doc, KPrPage *_page ) +: KNamedCommand( _name ) +, m_oldObjectList( _page->objectList() ) +, m_objectsToDelete( _objects ) +, m_doc( _doc ) +, m_page( _page ) +{ + QPtrListIterator it( m_oldObjectList ); + for ( ; it.current() ; ++it ) + it.current()->incCmdRef(); +} + +KPrDeleteCmd::~KPrDeleteCmd() +{ + QPtrListIterator it( m_oldObjectList ); + for ( ; it.current() ; ++it ) + it.current()->decCmdRef(); +} + +void KPrDeleteCmd::execute() +{ + bool textObj=false; + + QPtrListIterator it( m_oldObjectList ); + QPtrListIterator itDelete( m_objectsToDelete ); + QPtrList newObjectList; + for ( ; it.current(); ++it ) + { + if ( it.current() == itDelete.current() ) + { + it.current()->setSelected( false ); + it.current()->removeFromObjList(); + + if ( !textObj && it.current()->getType() == OT_TEXT ) + { + KPrTextObject * tmp = dynamic_cast( it.current() ); + if ( tmp ) + tmp->setEditingTextObj( false ); + textObj=true; + } + ++itDelete; + } + else + { + newObjectList.append( it.current() ); + } + } + + m_page->setObjectList( newObjectList ); + + for ( itDelete.toFirst(); itDelete.current(); ++itDelete ) + { + QRect oldRect = m_doc->zoomHandler()->zoomRect( itDelete.current()->getRepaintRect() ); + m_doc->repaint( oldRect ); + } + if(textObj) + m_doc->updateRuler(); + + m_doc->updateSideBarItem( m_page ); +} + +void KPrDeleteCmd::unexecute() +{ + m_page->setObjectList( m_oldObjectList ); + QPtrListIterator it( m_objectsToDelete ); + for ( ; it.current(); ++it ) + { + it.current()->addToObjList(); + m_doc->repaint( it.current() ); + } + + m_doc->updateSideBarItem( m_page ); +} + + +KPrEffectCmd::KPrEffectCmd( const QString &_name, const QPtrList &_objs, + const QValueList &_oldEffects, EffectStruct _newEffect ) + : KNamedCommand( _name ), oldEffects( _oldEffects ), + newEffect( _newEffect ), objs( _objs ) +{ + QPtrListIterator it( objs ); + for ( ; it.current() ; ++it ) + it.current()->incCmdRef(); +} + +KPrEffectCmd::~KPrEffectCmd() +{ + QPtrListIterator it( objs ); + for ( ; it.current() ; ++it ) + it.current()->decCmdRef(); +} + +void KPrEffectCmd::execute() +{ + QPtrListIterator it( objs ); + for ( ; it.current() ; ++it ) + { + it.current()->setAppearStep( newEffect.appearStep ); + it.current()->setEffect( newEffect.effect ); + it.current()->setEffect2( newEffect.effect2 ); + it.current()->setDisappear( newEffect.disappear ); + it.current()->setEffect3( newEffect.effect3 ); + it.current()->setDisappearStep( newEffect.disappearStep ); + it.current()->setAppearSpeed( newEffect.m_appearSpeed ); + it.current()->setDisappearSpeed( newEffect.m_disappearSpeed ); + it.current()->setAppearTimer( newEffect.appearTimer ); + it.current()->setDisappearTimer( newEffect.disappearTimer ); + it.current()->setAppearSoundEffect( newEffect.appearSoundEffect ); + it.current()->setDisappearSoundEffect( newEffect.disappearSoundEffect ); + it.current()->setAppearSoundEffectFileName( newEffect.a_fileName ); + it.current()->setDisappearSoundEffectFileName( newEffect.d_fileName ); + } +} + +void KPrEffectCmd::unexecute() +{ + KPrObject *object = 0; + for ( unsigned int i = 0; i < objs.count(); ++i ) { + object = objs.at( i ); + + object->setAppearStep( oldEffects[ i ].appearStep ); + object->setEffect( oldEffects[ i ].effect ); + object->setEffect2( oldEffects[ i ].effect2 ); + object->setDisappear( oldEffects[ i ].disappear ); + object->setEffect3( oldEffects[ i ].effect3 ); + object->setDisappearStep( oldEffects[ i ].disappearStep ); + object->setAppearSpeed( oldEffects[ i ].m_appearSpeed ); + object->setDisappearSpeed( oldEffects[ i ].m_disappearSpeed ); + object->setAppearTimer( oldEffects[ i ].appearTimer ); + object->setDisappearTimer( oldEffects[ i ].disappearTimer ); + object->setAppearSoundEffect( oldEffects[ i ].appearSoundEffect ); + object->setDisappearSoundEffect( oldEffects[ i ].disappearSoundEffect ); + object->setAppearSoundEffectFileName( oldEffects[ i ].a_fileName ); + object->setDisappearSoundEffectFileName( oldEffects[ i ].d_fileName ); + } +} + +KPrGroupObjCmd::KPrGroupObjCmd( const QString &_name, + const QPtrList &_objects, + KPrDocument *_doc, KPrPage *_page ) +: KNamedCommand( _name ) +, m_objectsToGroup( _objects ) +, m_oldObjectList( _page->objectList() ) +, m_doc( _doc ) +, m_page( _page ) +{ + m_groupObject = new KPrGroupObject( m_objectsToGroup ); + m_groupObject->incCmdRef(); +} + +KPrGroupObjCmd::~KPrGroupObjCmd() +{ + m_groupObject->decCmdRef(); +} + +void KPrGroupObjCmd::execute() +{ + KoRect r; + int position = 0; + QPtrListIterator it( m_objectsToGroup ); + for ( ; it.current() ; ++it ) + { + it.current()->setSelected( false ); + position = m_page->takeObject(it.current() ); + r |= it.current()->getRealRect(); + } + + m_groupObject->setUpdateObjects( false ); + m_groupObject->setOrig( r.x(), r.y() ); + m_groupObject->setSize( r.width(), r.height() ); + m_page->insertObject( m_groupObject, position ); + m_groupObject->addToObjList(); + m_groupObject->setUpdateObjects( true ); + m_groupObject->setSelected( true ); + m_doc->refreshGroupButton(); + + m_doc->repaint( false ); + + m_doc->updateSideBarItem( m_page ); +} + +void KPrGroupObjCmd::unexecute() +{ + m_groupObject->setUpdateObjects( false ); + + m_page->setObjectList( m_oldObjectList ); + m_groupObject->removeFromObjList(); + + QPtrListIterator it( m_objectsToGroup ); + for ( ; it.current() ; ++it ) + { + it.current()->addToObjList(); + it.current()->setSelected( true ); + } + + m_doc->refreshGroupButton(); + + m_doc->repaint( false ); + + m_doc->updateSideBarItem( m_page ); +} + +UnGroupObjCmd::UnGroupObjCmd( const QString &_name, + KPrGroupObject *grpObj_, + KPrDocument *_doc, KPrPage *_page ) +: KNamedCommand( _name ) +, m_groupedObjects( grpObj_->getObjects() ) +, m_groupObject( grpObj_ ) +, m_doc( _doc ) +, m_page( _page ) +{ + m_groupObject->incCmdRef(); +} + +UnGroupObjCmd::~UnGroupObjCmd() +{ + m_groupObject->decCmdRef(); +} + +void UnGroupObjCmd::execute() +{ + m_groupObject->setUpdateObjects( false ); + + int position = m_page->takeObject( m_groupObject ); + m_groupObject->removeFromObjList(); + + QPtrListIterator it( m_groupedObjects ); + for ( it.toLast(); it.current() ; --it ) + { + m_page->insertObject( it.current(), position ); + it.current()->addToObjList(); + it.current()->setSelected( true ); + } + + m_doc->refreshGroupButton(); + + m_doc->repaint( false ); + + m_doc->updateSideBarItem( m_page ); +} + +void UnGroupObjCmd::unexecute() +{ + KoRect r=KoRect(); + int position = 0; + QPtrListIterator it( m_groupedObjects ); + for ( ; it.current() ; ++it ) + { + it.current()->setSelected( false ); + position = m_page->takeObject( it.current() ); + r |= it.current()->getRealRect(); + } + + m_groupObject->setUpdateObjects( false ); + m_groupObject->setOrig( r.x(), r.y() ); + m_groupObject->setSize( r.width(), r.height() ); + m_page->insertObject( m_groupObject, position ); + m_groupObject->addToObjList(); + m_groupObject->setUpdateObjects( true ); + m_groupObject->setSelected( true ); + m_doc->refreshGroupButton(); + + m_doc->repaint( false ); + + m_doc->updateSideBarItem( m_page ); +} + +KPrInsertCmd::KPrInsertCmd( const QString &name, const QValueList objects, + KPrDocument *doc, KPrPage *page ) +: KNamedCommand( name ) +, m_objects( objects ) +, m_object( 0 ) +, m_doc( doc ) +, m_page( page ) +{ + QValueListConstIterator it( m_objects.begin() ); + for ( ; it != m_objects.end(); ++it ) + { + ( *it )->incCmdRef(); + } +} + +KPrInsertCmd::KPrInsertCmd( const QString &name, KPrObject *object, + KPrDocument *doc, KPrPage *page ) +: KNamedCommand( name ) +, m_object( object ) +, m_doc( doc ) +, m_page( page ) +{ + m_object->incCmdRef(); +} + +KPrInsertCmd::~KPrInsertCmd() +{ + if ( m_object ) + { + m_object->decCmdRef(); + } + else + { + QValueListConstIterator it( m_objects.begin() ); + for ( ; it != m_objects.end(); ++it ) + { + ( *it )->decCmdRef(); + } + } +} + +void KPrInsertCmd::execute() +{ + if ( m_object ) + { + m_page->appendObject( m_object ); + m_object->addToObjList(); + if ( m_object->getType() == OT_TEXT ) + m_doc->updateRuler(); + m_doc->repaint( m_object ); + } + else + { + m_page->appendObjects( m_objects ); + QValueListConstIterator it( m_objects.begin() ); + bool updateRuler = false; + for ( ; it != m_objects.end(); ++it ) + { + ( *it )->addToObjList(); + if ( ( *it )->getType() == OT_TEXT ) + updateRuler = true; + m_doc->repaint( *it ); + } + if ( updateRuler ) + m_doc->updateRuler(); + } + + m_doc->updateSideBarItem( m_page ); +} + +void KPrInsertCmd::unexecute() +{ + if ( m_object ) + { + QRect oldRect = m_doc->zoomHandler()->zoomRect( m_object->getRepaintRect() ); + QPtrList list(m_page->objectList()); + if ( list.findRef( m_object ) != -1 ) { + m_page->takeObject( m_object ); + m_object->removeFromObjList(); + if ( m_object->getType() == OT_TEXT ) + { + m_doc->terminateEditing( (KPrTextObject*)m_object ); + ((KPrTextObject*)m_object)->setEditingTextObj( false ); + m_doc->updateRuler(); + } + } + m_doc->repaint( oldRect ); + } + else + { + QPtrList list(m_page->objectList()); + bool updateRuler = false; + + QValueListConstIterator it( m_objects.begin() ); + for ( ; it != m_objects.end(); ++it ) + { + if ( list.findRef( *it ) != -1 ) + { + m_page->takeObject( *it ); + ( *it )->removeFromObjList(); + if ( ( *it )->getType() == OT_TEXT ) + { + m_doc->terminateEditing( (KPrTextObject*)( *it ) ); + ( (KPrTextObject*) *it )->setEditingTextObj( false ); + updateRuler = true; + } + } + } + if ( updateRuler ) + m_doc->updateRuler(); + + m_doc->repaint( false ); + } + + m_doc->updateSideBarItem( m_page ); +} + +KPrLowerRaiseCmd::KPrLowerRaiseCmd( const QString &_name, const QPtrList& _oldList, + const QPtrList& _newList, KPrDocument *_doc, + KPrPage *_page ) + : KNamedCommand( _name ) +{ + oldList = _oldList; + newList = _newList; + m_page=_page; + oldList.setAutoDelete( false ); + newList.setAutoDelete( false ); + doc = _doc; + + QPtrListIterator it( oldList ); + for ( ; it.current() ; ++it ) + it.current()->incCmdRef(); +} + +KPrLowerRaiseCmd::~KPrLowerRaiseCmd() +{ + QPtrListIterator it( oldList ); + for ( ; it.current() ; ++it ) + it.current()->decCmdRef(); +} + +void KPrLowerRaiseCmd::execute() +{ + m_page->setObjectList( newList ); + doc->repaint( false ); + + doc->updateSideBarItem( m_page ); +} + +void KPrLowerRaiseCmd::unexecute() +{ + m_page->setObjectList( oldList ); + doc->repaint( false ); + + doc->updateSideBarItem( m_page ); +} + + +KPrMoveByCmd::KPrMoveByCmd( const QString &_name, const KoPoint &_diff, QPtrList &_objects, + KPrDocument *_doc,KPrPage *_page ) + : KNamedCommand( _name ), diff( _diff ), objects( _objects ) +{ + objects.setAutoDelete( false ); + doc = _doc; + m_page=_page; + QPtrListIterator it( objects ); + for ( ; it.current() ; ++it ) + { + it.current()->incCmdRef(); + } +} + +KPrMoveByCmd::~KPrMoveByCmd() +{ + QPtrListIterator it( objects ); + for ( ; it.current() ; ++it ) + it.current()->decCmdRef(); +} + +void KPrMoveByCmd::execute() +{ + QRect oldRect; + + for ( unsigned int i = 0; i < objects.count(); i++ ) { + oldRect = doc->zoomHandler()->zoomRect( objects.at( i )->getRepaintRect() ); + objects.at( i )->moveBy( diff ); + if ( objects.at( i )->getType() == OT_TEXT ) + { + if(objects.at(i)->isSelected()) + doc->updateRuler(); + } + doc->repaint( oldRect ); + doc->repaint( objects.at( i ) ); + } + + doc->updateSideBarItem( m_page ); + doc->updateObjectStatusBarItem(); +} + +void KPrMoveByCmd::unexecute() +{ + QRect oldRect; + + for ( unsigned int i = 0; i < objects.count(); i++ ) { + oldRect = doc->zoomHandler()->zoomRect( objects.at( i )->getRepaintRect() ); + objects.at( i )->moveBy( -diff.x(), -diff.y() ); + if ( objects.at( i )->getType() == OT_TEXT ) + { + if(objects.at(i)->isSelected()) + doc->updateRuler(); + } + doc->repaint( oldRect ); + doc->repaint( objects.at( i ) ); + } + + doc->updateSideBarItem( m_page ); + doc->updateObjectStatusBarItem(); +} + +KPrAlignCmd::KPrAlignCmd( const QString &_name, QPtrList &_objects, AlignType _at, KPrDocument *_doc ) + : KNamedCommand( _name ), doc(_doc) +{ + objects.setAutoDelete( false ); + diffs.setAutoDelete( true ); + m_page = doc->findPage( _objects ); + + QPtrListIterator it( _objects ); + KoRect boundingRect; + for ( ; it.current() ; ++it ) + { + boundingRect |= it.current()->getRealRect(); + } + + if ( _objects.count() == 1 ) + boundingRect = m_page->getPageRect(); + + it.toFirst(); + for ( ; it.current() ; ++it ) + { + KoPoint * diff = NULL; + switch ( _at ) + { + case AT_LEFT: + diff = new KoPoint( boundingRect.x() - it.current()->getRealOrig().x(), 0 ); + break; + case AT_TOP: + diff = new KoPoint( 0, boundingRect.y() - it.current()->getRealOrig().y() ); + break; + case AT_RIGHT: + diff = new KoPoint( boundingRect.x() + boundingRect.width() - + it.current()->getRealOrig().x() - it.current()->getRealSize().width(), 0 ); + break; + case AT_BOTTOM: + diff = new KoPoint( 0, boundingRect.y() + boundingRect.height() - + it.current()->getRealOrig().y() - it.current()->getRealSize().height() ); + break; + case AT_HCENTER: + diff = new KoPoint( ( boundingRect.width() - it.current()->getRealSize().width() ) / 2 - + it.current()->getRealOrig().x() + boundingRect.x(), 0 ); + break; + case AT_VCENTER: + diff = new KoPoint( 0, ( boundingRect.height() - it.current()->getRealSize().height() ) / 2 - + it.current()->getRealOrig().y() + boundingRect.y() ); + break; + } + if ( diff ) + { + objects.append( it.current() ); + diffs.append( diff ); + it.current()->incCmdRef(); + } + } +} + +KPrAlignCmd::~KPrAlignCmd() +{ + QPtrListIterator it( objects ); + for ( ; it.current() ; ++it ) + it.current()->decCmdRef(); + + diffs.clear(); +} + +void KPrAlignCmd::execute() +{ + QRect oldRect; + + for ( unsigned int i = 0; i < objects.count(); i++ ) { + oldRect = doc->zoomHandler()->zoomRect( objects.at( i )->getRepaintRect() ); + objects.at( i )->moveBy( *diffs.at( i ) ); + if ( objects.at( i )->getType() == OT_TEXT ) + { + if(objects.at(i)->isSelected()) + doc->updateRuler(); + } + + doc->repaint( oldRect ); + doc->repaint( objects.at( i ) ); + } + + doc->updateSideBarItem( m_page ); +} + +void KPrAlignCmd::unexecute() +{ + QRect oldRect; + + for ( unsigned int i = 0; i < objects.count(); i++ ) { + oldRect = doc->zoomHandler()->zoomRect(objects.at( i )->getRepaintRect() ); + objects.at( i )->moveBy( -diffs.at( i )->x(), -diffs.at( i )->y() ); + if ( objects.at( i )->getType() == OT_TEXT ) + { + if(objects.at(i)->isSelected()) + doc->updateRuler(); + } + doc->repaint( oldRect ); + doc->repaint( objects.at( i ) ); + doc->updateRuler(); + } + + doc->updateSideBarItem( m_page ); +} + +KoPenCmd::KoPenCmd( const QString &_name, QPtrList &_objects, Pen _newPen, + KPrDocument *_doc, KPrPage *_page, int _flags ) +: KNamedCommand(_name), doc(_doc), m_page( _page ), newPen(_newPen), flags(_flags) +{ + objects.setAutoDelete( false ); + oldPen.setAutoDelete( false ); + + addObjects( _objects ); +} + +KoPenCmd::~KoPenCmd() +{ + QPtrListIterator it( objects ); + for ( ; it.current() ; ++it ) + it.current()->decCmdRef(); + + oldPen.setAutoDelete( true ); + oldPen.clear(); +} + +void KoPenCmd::execute() +{ + for ( int i = 0; i < static_cast( objects.count() ); i++ ) + { + Pen tmpPen = *oldPen.at( i ); + + if ( flags & LineBegin ) + tmpPen.lineBegin = newPen.lineBegin; + + if ( flags & LineEnd ) + tmpPen.lineEnd = newPen.lineEnd; + + if ( flags & Color ) + tmpPen.pen.setColor( newPen.pen.color() ); + + if ( flags & Width ) + tmpPen.pen.setPointWidth( newPen.pen.pointWidth() ); + + if ( flags & Style ) + tmpPen.pen.setStyle( newPen.pen.style() ); + + applyPen( objects.at( i ), &tmpPen ); + } + + // this has to be called as the outline could have been changed so + // that the toolbar is updated correctly + doc->updateObjectSelected(); + doc->updateSideBarItem( m_page ); +} + +void KoPenCmd::applyPen( KPrObject *object, Pen *tmpPen ) +{ + switch (object->getType()) { + case OT_LINE: + { + KPrLineObject* obj=dynamic_cast( object ); + if( obj ) + { + //obj->setPen( tmpPen->pen ); + obj->setLineBegin( tmpPen->lineBegin ); + obj->setLineEnd( tmpPen->lineEnd ); + //doc->repaint( obj ); + } + } break; + case OT_FREEHAND: + case OT_POLYLINE: + case OT_QUADRICBEZIERCURVE: + case OT_CUBICBEZIERCURVE: + { + KPrPointObject *obj = dynamic_cast( object ); + if ( obj ) + { + //obj->setPen( tmpPen->pen ); + obj->setLineBegin( tmpPen->lineBegin ); + obj->setLineEnd( tmpPen->lineEnd ); + //doc->repaint( obj ); + } + } break; + case OT_PIE: + { + KPrPieObject *obj = dynamic_cast( object ); + if ( obj ) + { + obj->setLineBegin( tmpPen->lineBegin ); + obj->setLineEnd( tmpPen->lineEnd ); + } + } break; + case OT_AUTOFORM: + { + KPrAutoformObject *obj = dynamic_cast( object ); + if ( obj ) + { + obj->setLineBegin( tmpPen->lineBegin ); + obj->setLineEnd( tmpPen->lineEnd ); + } + } break; + default: + break; + } + + KPrShadowObject *obj = dynamic_cast( object ); + if ( obj ) + { + obj->setPen( tmpPen->pen ); + doc->repaint( obj ); + } +} + +void KoPenCmd::unexecute() +{ + for ( unsigned int i = 0; i < objects.count(); ++i ) { + if( oldPen.count() > i ) + applyPen( objects.at( i ), oldPen.at( i ) ); + } + + // this has to be called as the outline could have been changed so + // that the toolbar is updated correctly + doc->updateObjectSelected(); + doc->updateSideBarItem( m_page ); +} + +void KoPenCmd::addObjects( const QPtrList &_objects ) +{ + QPtrListIterator it( _objects ); + for ( ; it.current(); ++it ) + { + KPrObject * object( it.current() ); + if ( object->getType() == OT_GROUP ) + { + KPrGroupObject * obj=dynamic_cast( object ); + if ( obj ) + { + addObjects( obj->objectList() ); + } + } + else + { + // tz TODO fix name + ::LineEnd lineBegin = L_NORMAL; + ::LineEnd lineEnd = L_NORMAL; + switch ( it.current()->getType() ) { + case OT_LINE: + { + KPrLineObject *obj=dynamic_cast( object ); + if ( obj ) + { + lineBegin = obj->getLineBegin(); + lineEnd = obj->getLineEnd(); + } + } break; + case OT_FREEHAND: + case OT_POLYLINE: + case OT_QUADRICBEZIERCURVE: + case OT_CUBICBEZIERCURVE: + { + KPrPointObject *obj = dynamic_cast( object ); + if ( obj ) + { + lineBegin = obj->getLineBegin(); + lineEnd = obj->getLineEnd(); + } + } break; + case OT_PIE: + { + KPrPieObject *obj = dynamic_cast( object ); + if ( obj ) + { + lineBegin = obj->getLineBegin(); + lineEnd = obj->getLineEnd(); + } + } break; + case OT_AUTOFORM: + { + KPrAutoformObject *obj = dynamic_cast( object ); + if ( obj ) + { + lineBegin = obj->getLineBegin(); + lineEnd = obj->getLineEnd(); + } + } break; + default: + break; + } + + KPrShadowObject *obj = dynamic_cast( object ); + if ( obj ) + { + objects.append( obj ); + obj->incCmdRef(); + + Pen * pen = new KoPenCmd::Pen( obj->getPen(), lineBegin, lineEnd ); + + oldPen.append( pen ); + } + } + } +} + + +KPrBrushCmd::KPrBrushCmd( const QString &_name, QPtrList &_objects, Brush _newBrush, + KPrDocument *_doc, KPrPage *_page, int _flags ) +: KNamedCommand(_name), doc(_doc), newBrush(_newBrush), m_page(_page), flags(_flags) +{ + objects.setAutoDelete( false ); + oldBrush.setAutoDelete( false ); + + addObjects( _objects ); +} + +void KPrBrushCmd::addObjects( const QPtrList &_objects ) +{ + QPtrListIterator it( _objects ); + for ( ; it.current(); ++it ) + { + if ( it.current()->getType() == OT_GROUP ) + { + KPrGroupObject * obj=dynamic_cast( it.current() ); + if ( obj ) + { + addObjects( obj->objectList() ); + } + } + else + { + KPr2DObject * obj = dynamic_cast( it.current() ); + if( obj ) + { + objects.append( obj ); + obj->incCmdRef(); + + Brush * brush = new KPrBrushCmd::Brush; + brush->brush = obj->getBrush(); + brush->fillType = obj->getFillType(); + brush->gColor1 = obj->getGColor1(); + brush->gColor2 = obj->getGColor2(); + brush->gType = obj->getGType(); + brush->unbalanced = obj->getGUnbalanced(); + brush->xfactor = obj->getGXFactor(); + brush->yfactor = obj->getGYFactor(); + + oldBrush.append( brush ); + } + } + } +} + +KPrBrushCmd::~KPrBrushCmd() +{ + QPtrListIterator it( objects ); + for ( ; it.current() ; ++it ) + it.current()->decCmdRef(); + + oldBrush.setAutoDelete( true ); + oldBrush.clear(); +} + +void KPrBrushCmd::execute() +{ + for ( int i = 0; i < static_cast( objects.count() ); i++ ) + { + Brush tmpBrush = *oldBrush.at( i ); + + if ( flags & BrushColor ) + tmpBrush.brush.setColor( newBrush.brush.color() ); + + if ( flags & BrushStyle ) + tmpBrush.brush.setStyle( newBrush.brush.style() ); + + if ( flags & BrushGradientSelect ) + tmpBrush.fillType = newBrush.fillType; + + if ( flags & GradientColor1 ) + tmpBrush.gColor1 = newBrush.gColor1; + + if ( flags & GradientColor2 ) + tmpBrush.gColor2 = newBrush.gColor2; + + if ( flags & GradientType ) + tmpBrush.gType = newBrush.gType; + + if ( flags & GradientBalanced ) + tmpBrush.unbalanced = newBrush.unbalanced; + + if ( flags & GradientXFactor ) + tmpBrush.xfactor = newBrush.xfactor; + + if ( flags & GradientYFactor ) + tmpBrush.yfactor = newBrush.yfactor; + + applyBrush( objects.at( i ), &tmpBrush ); + } + + doc->updateSideBarItem( m_page ); +} + +void KPrBrushCmd::applyBrush( KPr2DObject *object, Brush *tmpBrush ) +{ + object->setBrush( tmpBrush->brush ); + object->setFillType( tmpBrush->fillType ); + object->setGColor1( tmpBrush->gColor1 ); + object->setGColor2( tmpBrush->gColor2 ); + object->setGType( tmpBrush->gType ); + object->setGUnbalanced( tmpBrush->unbalanced ); + object->setGXFactor( tmpBrush->xfactor ); + object->setGYFactor( tmpBrush->yfactor ); + doc->repaint( object ); +} + +void KPrBrushCmd::unexecute() +{ + for ( unsigned int i = 0; i < objects.count(); i++ ) { + applyBrush( objects.at( i ), oldBrush.at( i ) ); + } + + doc->updateSideBarItem( m_page ); +} + + +KPrPgConfCmd::KPrPgConfCmd( const QString &_name, bool _manualSwitch, bool _infiniteLoop, + bool _showEndOfPresentationSlide, bool _showPresentationDuration, QPen _pen, + QValueList _selectedSlides, const QString & _presentationName, + bool _oldManualSwitch, bool _oldInfiniteLoop, + bool _oldShowEndOfPresentationSlide, bool _oldShowPresentationDuration, QPen _oldPen, + QValueList _oldSelectedSlides, const QString & _oldPresentationName, + KPrDocument *_doc ) + : KNamedCommand( _name ) +{ + manualSwitch = _manualSwitch; + infiniteLoop = _infiniteLoop; + showEndOfPresentationSlide = _showEndOfPresentationSlide; + showPresentationDuration = _showPresentationDuration; + pen = _pen; + selectedSlides = _selectedSlides; + oldManualSwitch = _oldManualSwitch; + oldInfiniteLoop = _oldInfiniteLoop; + oldShowEndOfPresentationSlide = _oldShowEndOfPresentationSlide; + oldShowPresentationDuration = _oldShowPresentationDuration; + oldPen = _oldPen; + oldSelectedSlides = _oldSelectedSlides; + oldPresentationName = _oldPresentationName; + presentationName = _presentationName; + doc = _doc; +} + +void KPrPgConfCmd::execute() +{ + doc->setManualSwitch( manualSwitch ); + doc->setInfiniteLoop( infiniteLoop ); + doc->setShowEndOfPresentationSlide ( showEndOfPresentationSlide ); + doc->setPresentationDuration( showPresentationDuration ); + doc->setPresPen( pen ); + doc->setPresentationName( presentationName ); + QPtrList pages = doc->pageList(); + unsigned count = selectedSlides.count(); + if( count > pages.count() ) count = pages.count(); + for( unsigned i = 0; i < selectedSlides.count(); i++ ) + pages.at( i )->slideSelected( selectedSlides[ i ] ); +} + +void KPrPgConfCmd::unexecute() +{ + doc->setManualSwitch( oldManualSwitch ); + doc->setInfiniteLoop( oldInfiniteLoop ); + doc->setShowEndOfPresentationSlide( oldShowEndOfPresentationSlide ); + doc->setPresentationDuration( oldShowPresentationDuration ); + doc->setPresPen( oldPen ); + doc->setPresentationName( oldPresentationName ); + + QPtrList pages = doc->pageList(); + unsigned count = oldSelectedSlides.count(); + if( count > pages.count() ) count = pages.count(); + for( unsigned i = 0; i < oldSelectedSlides.count(); i++ ) + pages.at( i )->slideSelected( oldSelectedSlides[ i ] ); +} + + +KPrTransEffectCmd::KPrTransEffectCmd( QValueVector oldSettings, + PageEffectSettings newSettings, + KPrPage* page, KPrDocument* doc ) +{ + m_newSettings = newSettings; + m_oldSettings = oldSettings; + Q_ASSERT( !m_oldSettings.isEmpty() ); + m_page = page; + m_doc = doc; +} + +void KPrTransEffectCmd::PageEffectSettings::applyTo( KPrPage *page ) +{ + page->setPageEffect( pageEffect ); + page->setPageEffectSpeed( effectSpeed ); + page->setPageSoundEffect( soundEffect ); + page->setPageSoundFileName( soundFileName ); + // TODO page->setAutoAdvance( autoAdvance ); + page->setPageTimer( slideTime ); +} + +void KPrTransEffectCmd::execute() +{ + if ( m_page ) + m_newSettings.applyTo( m_page ); + else + for( QPtrListIterator it( m_doc->getPageList() ); *it; ++it ) + m_newSettings.applyTo( it.current() ); +} + +void KPrTransEffectCmd::unexecute() +{ + if ( m_page ) + m_oldSettings[0].applyTo( m_page ); + else { + int i = 0; + for( QPtrListIterator it( m_doc->getPageList() ); *it; ++it, ++i ) + m_oldSettings[i].applyTo( it.current() ); + } +} + +QString KPrTransEffectCmd::name() const +{ + if ( m_page ) + return i18n( "Modify Slide Transition" ); + else + return i18n( "Modify Slide Transition For All Pages" ); +} + +KPrPgLayoutCmd::KPrPgLayoutCmd( const QString &_name, KoPageLayout _layout, KoPageLayout _oldLayout, + KoUnit::Unit _oldUnit, KoUnit::Unit _unit,KPrDocument *_doc ) + : KNamedCommand( _name ) +{ + m_doc=_doc; + layout = _layout; + oldLayout = _oldLayout; + oldUnit = _oldUnit; + unit = _unit; +} + +void KPrPgLayoutCmd::execute() +{ + m_doc->setUnit( unit ); + m_doc->setPageLayout( layout ); + m_doc->updateHeaderFooterPosition(); + m_doc->updateRuler(); + m_doc->updateRulerPageLayout(); +} + +void KPrPgLayoutCmd::unexecute() +{ + m_doc->setUnit( oldUnit ); + m_doc->setPageLayout( oldLayout ); + m_doc->updateHeaderFooterPosition(); + m_doc->updateRuler(); + m_doc->updateRulerPageLayout(); +} + + +KPrPieValueCmd::KPrPieValueCmd( const QString &name, PieValues newValues, + QPtrList &objects, KPrDocument *doc, + KPrPage *page, int flags ) +: KNamedCommand( name ) +, m_doc( doc ) +, m_page( page ) +, m_newValues( newValues ) +, m_flags( flags ) +{ + m_objects.setAutoDelete( false ); + m_oldValues.setAutoDelete( false ); + + addObjects( objects ); +} + +KPrPieValueCmd::KPrPieValueCmd( const QString &_name, QPtrList &_oldValues, PieValues _newValues, + QPtrList &_objects, KPrDocument *_doc, KPrPage *_page, int _flags ) + : KNamedCommand( _name ), m_oldValues( _oldValues ), m_objects( _objects ), m_flags(_flags) +{ + m_objects.setAutoDelete( false ); + m_oldValues.setAutoDelete( false ); + m_doc = _doc; + m_page = _page; + m_newValues = _newValues; + + QPtrListIterator it( m_objects ); + for ( ; it.current() ; ++it ) + it.current()->incCmdRef(); +} + +KPrPieValueCmd::~KPrPieValueCmd() +{ + QPtrListIterator it( m_objects ); + for ( ; it.current() ; ++it ) + it.current()->decCmdRef(); + m_oldValues.setAutoDelete( true ); + m_oldValues.clear(); +} + +void KPrPieValueCmd::addObjects( const QPtrList &objects ) +{ + QPtrListIterator it( objects ); + for ( ; it.current(); ++it ) + { + if ( it.current()->getType() == OT_GROUP ) + { + KPrGroupObject * obj = dynamic_cast( it.current() ); + if ( obj ) + { + addObjects( obj->objectList() ); + } + } + else + { + KPrPieObject *obj = dynamic_cast( it.current() ); + if( obj ) + { + m_objects.append( obj ); + obj->incCmdRef(); + + PieValues * pieValues = new PieValues; + pieValues->pieType = obj->getPieType(); + pieValues->pieAngle = obj->getPieAngle(); + pieValues->pieLength = obj->getPieLength(); + m_oldValues.append( pieValues ); + } + } + } +} + +void KPrPieValueCmd::execute() +{ + QPtrListIterator it( m_objects ); + for ( ; it.current() ; ++it ) + { + KPrPieObject* obj=dynamic_cast( it.current() ); + if(obj) + { + if (m_flags & Type) + obj->setPieType( m_newValues.pieType ); + if (m_flags & Angle) + obj->setPieAngle( m_newValues.pieAngle ); + if (m_flags & Length) + obj->setPieLength( m_newValues.pieLength ); + } + } + m_doc->repaint( false ); + + m_doc->updateSideBarItem( m_page ); +} + +void KPrPieValueCmd::unexecute() +{ + for ( unsigned int i = 0; i < m_objects.count(); i++ ) + { + KPrPieObject* obj=dynamic_cast( m_objects.at( i ) ); + if(obj) + { + obj->setPieType( m_oldValues.at( i )->pieType ); + obj->setPieAngle( m_oldValues.at( i )->pieAngle ); + obj->setPieLength( m_oldValues.at( i )->pieLength ); + } + } + m_doc->repaint( false ); + + m_doc->updateSideBarItem( m_page ); +} + + +KPrPolygonSettingCmd::KPrPolygonSettingCmd( const QString &name, PolygonSettings newSettings, + QPtrList &objects, KPrDocument *doc, + KPrPage *page, int flags ) +: KNamedCommand( name ) +, m_doc( doc ) +, m_page( page ) +, m_newSettings( newSettings ) +, m_flags( flags ) +{ + m_objects.setAutoDelete( false ); + m_oldSettings.setAutoDelete( false ); + + addObjects( objects ); +} + + +KPrPolygonSettingCmd::~KPrPolygonSettingCmd() +{ + QPtrListIterator it( m_objects ); + for ( ; it.current() ; ++it ) + it.current()->decCmdRef(); + m_oldSettings.setAutoDelete( true ); + m_oldSettings.clear(); +} + +void KPrPolygonSettingCmd::addObjects( const QPtrList &objects ) +{ + QPtrListIterator it( objects ); + for ( ; it.current(); ++it ) + { + if ( it.current()->getType() == OT_GROUP ) + { + KPrGroupObject * obj = dynamic_cast( it.current() ); + if ( obj ) + { + addObjects( obj->objectList() ); + } + } + else + { + KPrPolygonObject *obj = dynamic_cast( it.current() ); + if( obj ) + { + m_objects.append( obj ); + obj->incCmdRef(); + + PolygonSettings * polygonSettings = new PolygonSettings; + + polygonSettings->checkConcavePolygon = obj->getCheckConcavePolygon(); + polygonSettings->cornersValue = obj->getCornersValue(); + polygonSettings->sharpnessValue = obj->getSharpnessValue(); + + m_oldSettings.append( polygonSettings ); + } + } + } +} + +void KPrPolygonSettingCmd::execute() +{ + QPtrListIterator it( m_objects ); + for ( ; it.current() ; ++it ) + { + KPrPolygonObject * obj=dynamic_cast( it.current() ); + if(obj) + { + if (m_flags & ConcaveConvex) + obj->setCheckConcavePolygon(m_newSettings.checkConcavePolygon); + if (m_flags & Corners) + obj->setCornersValue(m_newSettings.cornersValue); + if (m_flags & Sharpness) + obj->setSharpnessValue(m_newSettings.sharpnessValue ); + } + } + m_doc->repaint( false ); + + m_doc->updateSideBarItem( m_page ); +} + +void KPrPolygonSettingCmd::unexecute() +{ + for ( unsigned int i = 0; i < m_objects.count(); ++i ) + { + KPrPolygonObject * obj=dynamic_cast( m_objects.at(i) ); + if(obj) + { + obj->setCheckConcavePolygon(m_oldSettings.at( i )->checkConcavePolygon); + obj->setCornersValue(m_oldSettings.at( i )->cornersValue); + obj->setSharpnessValue(m_oldSettings.at( i )->sharpnessValue); + } + } + m_doc->repaint( false ); + + m_doc->updateSideBarItem( m_page ); +} + + +KPrPictureSettingCmd::KPrPictureSettingCmd( const QString &name, PictureSettings newSettings, + QPtrList &objects, KPrDocument *doc, + KPrPage *page, int flags ) +: KNamedCommand( name ) +, m_doc( doc ) +, m_newSettings( newSettings ) +, m_page( page ) +, m_flags( flags ) +{ + m_objects.setAutoDelete( false ); + m_oldValues.setAutoDelete( false ); + + addObjects( objects ); +} + +KPrPictureSettingCmd::KPrPictureSettingCmd( const QString &_name, QPtrList &_oldSettings, + PictureSettings _newSettings, QPtrList &_objects, + KPrDocument *_doc, int flags ) + : KNamedCommand( _name ), m_oldValues( _oldSettings ), m_objects( _objects ), m_flags( flags ) +{ + m_objects.setAutoDelete( false ); + m_oldValues.setAutoDelete( false ); + m_doc = _doc; + m_newSettings = _newSettings; + + m_page = m_doc->findPage( m_objects ); + + QPtrListIterator it( m_objects ); + for ( ; it.current() ; ++it ) + it.current()->incCmdRef(); +} + +KPrPictureSettingCmd::~KPrPictureSettingCmd() +{ + QPtrListIterator it( m_objects ); + for ( ; it.current() ; ++it ) + it.current()->decCmdRef(); + m_oldValues.setAutoDelete( true ); + m_oldValues.clear(); +} + +void KPrPictureSettingCmd::addObjects( const QPtrList &objects ) +{ + QPtrListIterator it( objects ); + for ( ; it.current(); ++it ) + { + if ( it.current()->getType() == OT_GROUP ) + { + KPrGroupObject * obj = dynamic_cast( it.current() ); + if ( obj ) + { + addObjects( obj->objectList() ); + } + } + else + { + KPrPixmapObject *obj = dynamic_cast( it.current() ); + if( obj ) + { + m_objects.append( obj ); + obj->incCmdRef(); + + PictureSettings * pictureSettings = new PictureSettings; + + pictureSettings->mirrorType = obj->getPictureMirrorType(); + pictureSettings->depth = obj->getPictureDepth(); + pictureSettings->swapRGB = obj->getPictureSwapRGB(); + pictureSettings->grayscal = obj->getPictureGrayscal(); + pictureSettings->bright = obj->getPictureBright(); + + m_oldValues.append( pictureSettings ); + } + } + } +} + +void KPrPictureSettingCmd::execute() +{ + QPtrListIterator it( m_objects ); + for ( ; it.current() ; ++it ) { + KPrPixmapObject * obj = dynamic_cast( it.current() ); + if ( obj ) { + if ( m_flags & MirrorType ) + obj->setPictureMirrorType( m_newSettings.mirrorType ); + if ( m_flags & Depth ) + obj->setPictureDepth( m_newSettings.depth ); + if ( m_flags & SwapRGB ) + obj->setPictureSwapRGB( m_newSettings.swapRGB ); + if ( m_flags & Grayscal ) + obj->setPictureGrayscal( m_newSettings.grayscal ); + if ( m_flags & Bright ) + obj->setPictureBright( m_newSettings.bright ); + } + } + m_doc->repaint( false ); + + m_doc->updateSideBarItem( m_page ); +} + +void KPrPictureSettingCmd::unexecute() +{ + for ( unsigned int i = 0; i < m_objects.count(); ++i ) { + KPrPixmapObject * obj = dynamic_cast( m_objects.at(i) ); + if ( obj ) { + PictureSettings *pictureSettings = m_oldValues.at( i ); + obj->setPictureMirrorType( pictureSettings->mirrorType ); + obj->setPictureDepth( pictureSettings->depth ); + obj->setPictureSwapRGB( pictureSettings->swapRGB ); + obj->setPictureGrayscal( pictureSettings->grayscal ); + obj->setPictureBright( pictureSettings->bright ); + } + } + m_doc->repaint( false ); + + m_doc->updateSideBarItem( m_page ); +} + + +KPrRectValueCmd::KPrRectValueCmd( const QString &_name, QPtrList &_oldValues, RectValues _newValues, + QPtrList &_objects, KPrDocument *_doc, KPrPage *_page, int _flags ) + : KNamedCommand( _name ), m_oldValues( _oldValues ), m_objects( _objects ), m_flags(_flags) +{ + m_objects.setAutoDelete( false ); + m_oldValues.setAutoDelete( false ); + m_doc = _doc; + m_page = _page; + m_newValues = _newValues; + + QPtrListIterator it( m_objects ); + for ( ; it.current() ; ++it ) + it.current()->incCmdRef(); +} + + +KPrRectValueCmd::KPrRectValueCmd( const QString &name, QPtrList &objects, RectValues newValues, + KPrDocument *doc, KPrPage *page, int flags ) +: KNamedCommand( name ) +, m_doc( doc ) +, m_page( page ) +, m_newValues( newValues ) +, m_flags( flags ) +{ + m_objects.setAutoDelete( false ); + m_oldValues.setAutoDelete( false ); + + addObjects( objects ); +} + + +KPrRectValueCmd::~KPrRectValueCmd() +{ + QPtrListIterator it( m_objects ); + for ( ; it.current() ; ++it ) + it.current()->decCmdRef(); + + m_oldValues.setAutoDelete( true ); + m_oldValues.clear(); +} + + +void KPrRectValueCmd::addObjects( const QPtrList &objects ) +{ + QPtrListIterator it( objects ); + for ( ; it.current(); ++it ) + { + if ( it.current()->getType() == OT_GROUP ) + { + KPrGroupObject * obj = dynamic_cast( it.current() ); + if ( obj ) + { + addObjects( obj->objectList() ); + } + } + else + { + KPrRectObject *obj = dynamic_cast( it.current() ); + if( obj ) + { + m_objects.append( obj ); + obj->incCmdRef(); + + RectValues * rectValue = new RectValues; + + int xtmp, ytmp; + obj->getRnds( xtmp, ytmp ); + rectValue->xRnd = xtmp; + rectValue->yRnd = ytmp; + + m_oldValues.append( rectValue ); + } + } + } +} + + +void KPrRectValueCmd::execute() +{ + QPtrListIterator it( m_objects ); + for ( ; it.current() ; ++it ) + { + KPrRectObject *obj = dynamic_cast( it.current() ); + if( obj ) + { + int xtmp, ytmp; + obj->getRnds( xtmp, ytmp ); + + if ( m_flags & XRnd ) + { + xtmp = m_newValues.xRnd; + } + + if ( m_flags & YRnd ) + { + ytmp = m_newValues.yRnd; + } + + obj->setRnds( xtmp, ytmp ); + } + } + m_doc->repaint( false ); + + m_doc->updateSideBarItem( m_page ); +} + +void KPrRectValueCmd::unexecute() +{ + for ( unsigned int i = 0; i < m_objects.count(); i++ ) + { + KPrRectObject *obj = dynamic_cast( m_objects.at( i ) ); + + if( obj ) + obj->setRnds( m_oldValues.at( i )->xRnd, m_oldValues.at( i )->yRnd ); + } + m_doc->repaint( false ); + + m_doc->updateSideBarItem( m_page ); +} + + +KPrResizeCmd::KPrResizeCmd( const QString &_name, const KoPoint &_m_diff, const KoSize &_r_diff, + KPrObject *_object, KPrDocument *_doc ) + : KNamedCommand( _name ), m_diff( _m_diff ), r_diff( _r_diff ) +{ + object = _object; + doc = _doc; + m_page = doc->findPage( object ); + + object->incCmdRef(); +} + +KPrResizeCmd::~KPrResizeCmd() +{ + object->decCmdRef(); +} + +void KPrResizeCmd::execute() +{ + QRect oldRect; + + oldRect = doc->zoomHandler()->zoomRect( object->getRepaintRect() ); + object->moveBy( m_diff ); + object->resizeBy( r_diff ); + if ( object->getType() == OT_TEXT ) + { + if(object->isSelected()) + doc->updateRuler(); + doc->layout( object ); + } + if ( object->isSelected()) + doc->updateObjectStatusBarItem(); + doc->repaint( oldRect ); + doc->repaint( object ); + + doc->updateSideBarItem( m_page ); +} + +void KPrResizeCmd::unexecute() +{ + QRect oldRect; + + oldRect = doc->zoomHandler()->zoomRect( object->getRepaintRect() ); + object->moveBy( -m_diff.x(), -m_diff.y() ); + object->resizeBy( -r_diff.width(), -r_diff.height() ); + if ( object->getType() == OT_TEXT ) + { + if(object->isSelected()) + doc->updateRuler(); + doc->layout( object ); + } + if ( object->isSelected()) + doc->updateObjectStatusBarItem(); + + doc->repaint( oldRect ); + doc->repaint( object ); + + doc->updateSideBarItem( m_page ); +} + + +KPrOasisPasteTextCommand::KPrOasisPasteTextCommand( KoTextDocument *d, int parag, int idx, + const QByteArray &data ) + : KoTextDocCommand( d ), m_parag( parag ), m_idx( idx ), m_data( data ), m_oldParagLayout( 0 ) +{ +} + +KoTextCursor * KPrOasisPasteTextCommand::execute( KoTextCursor *c ) +{ + KoTextParag *firstParag = doc->paragAt( m_parag ); + if ( !firstParag ) { + qWarning( "can't locate parag at %d, last parag: %d", m_parag, doc->lastParag()->paragId() ); + return 0; + } + //kdDebug() << "KWOasisPasteCommand::execute m_parag=" << m_parag << " m_idx=" << m_idx + // << " firstParag=" << firstParag << " " << firstParag->paragId() << endl; + cursor.setParag( firstParag ); + cursor.setIndex( m_idx ); + c->setParag( firstParag ); + c->setIndex( m_idx ); + + QBuffer buffer( m_data ); + KoStore * store = KoStore::createStore( &buffer, KoStore::Read ); + + if ( store->bad() || !store->hasFile( "content.xml" ) ) + { + kdError(33001) << "Invalid ZIP store in memory" << endl; + if ( !store->hasFile( "content.xml" ) ) + kdError(33001) << "No content.xml file" << endl; + return c; + } + store->disallowNameExpansion(); + + KoOasisStore oasisStore( store ); + QDomDocument contentDoc; + QString errorMessage; + bool ok = oasisStore.loadAndParse( "content.xml", contentDoc, errorMessage ); + if ( !ok ) { + kdError(33001) << "Error parsing content.xml: " << errorMessage << endl; + return c; + } + + KoOasisStyles oasisStyles; + QDomDocument stylesDoc; + (void)oasisStore.loadAndParse( "styles.xml", stylesDoc, errorMessage ); + // Load styles from style.xml + oasisStyles.createStyleMap( stylesDoc, true ); + // Also load styles from content.xml + oasisStyles.createStyleMap( contentDoc, false ); + + QDomElement content = contentDoc.documentElement(); + + QDomElement body ( KoDom::namedItemNS( content, KoXmlNS::office, "body" ) ); + + // We then want to use whichever element is the child of , + // whether that's or or whatever. + QDomElement iter, realBody; + forEachElement( iter, body ) { + realBody = iter; + } + if ( realBody.isNull() ) { + kdError(33001) << "No element found inside office:body!" << endl; + return c; + } + + KPrTextDocument * textdoc = static_cast(c->parag()->document()); + KPrDocument *doc = textdoc->textObject()->kPresenterDocument(); + KoOasisContext context( doc, *doc->getVariableCollection(), oasisStyles, store ); + + *c = textdoc->textObject()->textObject()->pasteOasisText( realBody, context, cursor, doc->styleCollection() ); + textdoc->textObject()->textObject()->setNeedSpellCheck( true ); + + m_lastParag = c->parag()->paragId(); + m_lastIndex = c->index(); + return c; +} + +KoTextCursor * KPrOasisPasteTextCommand::unexecute( KoTextCursor *c ) +{ + KoTextParag *firstParag = doc->paragAt( m_parag ); + if ( !firstParag ) { + qWarning( "can't locate parag at %d, last parag: %d", m_parag, doc->lastParag()->paragId() ); + return 0; + } + cursor.setParag( firstParag ); + cursor.setIndex( m_idx ); + doc->setSelectionStart( KoTextDocument::Temp, &cursor ); + + KoTextParag *lastParag = doc->paragAt( m_lastParag ); + if ( !lastParag ) { + qWarning( "can't locate parag at %d, last parag: %d", m_lastParag, doc->lastParag()->paragId() ); + return 0; + } + //Q_ASSERT( lastParag->document() ); + // Get hold of the document before deleting the parag + //KoTextDocument* textdoc = lastParag->document(); + + //kdDebug() << "Undoing paste: deleting from (" << firstParag->paragId() << "," << m_idx << ")" + // << " to (" << lastParag->paragId() << "," << m_lastIndex << ")" << endl; + + cursor.setParag( lastParag ); + cursor.setIndex( m_lastIndex ); + doc->setSelectionEnd( KoTextDocument::Temp, &cursor ); + doc->removeSelectedText( KoTextDocument::Temp, c /* sets c to the correct position */ ); + + if ( m_idx == 0 ) { + Q_ASSERT( m_oldParagLayout ); + if ( m_oldParagLayout ) + firstParag->setParagLayout( *m_oldParagLayout ); + } + return c; +} + + +KPrChangeStartingPageCommand::KPrChangeStartingPageCommand( const QString &name, KPrDocument *_doc, + int _oldStartingPage, int _newStartingPage): + KNamedCommand(name), + m_doc(_doc), + oldStartingPage(_oldStartingPage), + newStartingPage(_newStartingPage) +{ +} + +void KPrChangeStartingPageCommand::execute() +{ + m_doc->getVariableCollection()->variableSetting()->setStartingPageNumber(newStartingPage); + m_doc->recalcVariables( VT_PGNUM ); +} + +void KPrChangeStartingPageCommand::unexecute() +{ + m_doc->getVariableCollection()->variableSetting()->setStartingPageNumber(oldStartingPage); + m_doc->recalcVariables( VT_PGNUM ); +} + + +KPrChangeVariableSettingsCommand::KPrChangeVariableSettingsCommand( const QString &name, KPrDocument *_doc, + bool _oldValue, bool _newValue, + VariableProperties _type): + KNamedCommand(name), + m_doc(_doc), + type(_type), + m_bOldValue(_oldValue), + m_bNewValue(_newValue) +{ +} + +void KPrChangeVariableSettingsCommand::changeValue( bool b ) +{ + switch(type) + { + case VS_DISPLAYLINK: + m_doc->getVariableCollection()->variableSetting()->setDisplayLink(b); + m_doc->recalcVariables( VT_LINK ); + break; + case VS_UNDERLINELINK: + m_doc->getVariableCollection()->variableSetting()->setUnderlineLink(b); + m_doc->recalcVariables( VT_LINK ); + break; + case VS_DISPLAYCOMMENT: + m_doc->getVariableCollection()->variableSetting()->setDisplayComment(b); + m_doc->recalcVariables( VT_NOTE ); + break; + case VS_DISPLAYFIELDCODE: + m_doc->getVariableCollection()->variableSetting()->setDisplayFieldCode(b); + m_doc->recalcVariables( VT_ALL ); + break; + } +} + +void KPrChangeVariableSettingsCommand::execute() +{ + changeValue(m_bNewValue); +} + +void KPrChangeVariableSettingsCommand::unexecute() +{ + changeValue(m_bOldValue); +} + +KPrDeletePageCmd::KPrDeletePageCmd( const QString &name, int pageNum, KPrDocument *doc ) +: KNamedCommand( name ) +, m_doc( doc ) +, m_pageNum( pageNum ) +{ + m_page = m_doc->pageList().at( m_pageNum ); +} + +KPrDeletePageCmd::~KPrDeletePageCmd() +{ +} + +void KPrDeletePageCmd::execute() +{ + m_doc->deSelectAllObj(); + m_doc->takePage( m_page, QMAX( m_pageNum - 1, 0 ) ); + m_doc->updatePresentationButton(); +} + +void KPrDeletePageCmd::unexecute() +{ + m_doc->deSelectAllObj(); + m_doc->insertPage( m_page, QMAX( m_pageNum - 1, 0 ), m_pageNum ); + m_doc->updatePresentationButton(); +} + +KPrInsertPageCmd::KPrInsertPageCmd( const QString &name, int pageNum, InsertPos pos, + KPrPage *page, KPrDocument *doc ) +: KNamedCommand(name) +, m_doc( doc ) +, m_page( page ) +, m_currentPageNum( pageNum ) +, m_insertPageNum( 0 ) +{ + switch( pos ) + { + case IP_BEFORE: + m_insertPageNum = m_currentPageNum; + break; + case IP_AFTER: + m_insertPageNum = m_currentPageNum + 1; + break; + } +} + +KPrInsertPageCmd::~KPrInsertPageCmd() +{ +} + +void KPrInsertPageCmd::execute() +{ + m_doc->deSelectAllObj(); + m_doc->insertPage( m_page, m_currentPageNum, m_insertPageNum ); + m_page->completeLoading( false, -1 ); + m_doc->updatePresentationButton(); +} + +void KPrInsertPageCmd::unexecute() +{ + m_doc->deSelectAllObj(); + m_doc->takePage( m_page, m_currentPageNum ); + m_doc->updatePresentationButton(); +} + +KPrMovePageCmd::KPrMovePageCmd( const QString &_name,int from, int to, KPrDocument *_doc ) : + KNamedCommand( _name ), + m_doc( _doc ), + m_oldPosition( from ), + m_newPosition( to ) +{ +} + +KPrMovePageCmd::~KPrMovePageCmd() +{ +} + +void KPrMovePageCmd::execute() +{ + m_doc->deSelectAllObj(); + m_doc->movePageTo( m_oldPosition, m_newPosition ); +} + +void KPrMovePageCmd::unexecute() +{ + m_doc->deSelectAllObj(); + m_doc->movePageTo( m_newPosition, m_oldPosition ); +} + + +KPrChangeTitlePageNameCommand::KPrChangeTitlePageNameCommand( const QString &_name,KPrDocument *_doc, + const QString &_oldPageName, + const QString &_newPageName, KPrPage *_page ) : + KNamedCommand(_name), + m_doc(_doc), + oldPageName(_oldPageName), + newPageName(_newPageName), + m_page(_page) +{ +} + +void KPrChangeTitlePageNameCommand::execute() +{ + m_page->insertManualTitle(newPageName); + m_doc->updateSideBarItem( m_page ); + m_doc->recalcVariables( VT_PGNUM ); +} + +void KPrChangeTitlePageNameCommand::unexecute() +{ + m_page->insertManualTitle(oldPageName); + m_doc->updateSideBarItem( m_page ); + m_doc->recalcVariables( VT_PGNUM ); +} + +KPrChangeCustomVariableValue::KPrChangeCustomVariableValue( const QString &name, KPrDocument *_doc, + const QString & _oldValue, const QString & _newValue, + KoCustomVariable *var): + KNamedCommand(name), + m_doc(_doc), + newValue(_newValue), + oldValue(_oldValue), + m_var(var) +{ +} + +void KPrChangeCustomVariableValue::execute() +{ + Q_ASSERT(m_var); + m_var->setValue(newValue); + m_doc->recalcVariables( VT_CUSTOM ); +} + +void KPrChangeCustomVariableValue::unexecute() +{ + Q_ASSERT(m_var); + m_var->setValue(oldValue); + m_doc->recalcVariables( VT_CUSTOM ); +} + +KPrChangeLinkVariable::KPrChangeLinkVariable( const QString &name, KPrDocument *_doc, + const QString & _oldHref, const QString & _newHref, + const QString & _oldLink,const QString &_newLink, + KoLinkVariable *var): + KNamedCommand(name), + m_doc(_doc), + oldHref(_oldHref), + newHref(_newHref), + oldLink(_oldLink), + newLink(_newLink), + m_var(var) +{ +} + + +void KPrChangeLinkVariable::execute() +{ + m_var->setLink(newLink,newHref); + m_doc->recalcVariables(VT_LINK); +} + +void KPrChangeLinkVariable::unexecute() +{ + m_var->setLink(oldLink,oldHref); + m_doc->recalcVariables(VT_LINK); +} + + +KPrNameObjectCommand::KPrNameObjectCommand( const QString &_name, const QString &_objectName, + KPrObject *_obj, KPrDocument *_doc ): + KNamedCommand( _name ), + newObjectName( _objectName ), + object( _obj ), + doc( _doc ) +{ + oldObjectName = object->getObjectName(); + + m_page = doc->findPage( object ); +} + +KPrNameObjectCommand::~KPrNameObjectCommand() +{ +} + +void KPrNameObjectCommand::execute() +{ + object->setObjectName( newObjectName ); + m_page->unifyObjectName( object ); + + doc->updateSideBarItem( m_page ); +} + +void KPrNameObjectCommand::unexecute() +{ + object->setObjectName( oldObjectName ); + + doc->updateSideBarItem( m_page ); +} + +KPrDisplayObjectFromMasterPage::KPrDisplayObjectFromMasterPage(const QString &name, KPrDocument *_doc, KPrPage *_page, bool _newValue) + :KNamedCommand(name), + m_doc( _doc ), + m_page(_page), + newValue(_newValue) +{ +} + +void KPrDisplayObjectFromMasterPage::execute() +{ + m_page->setDisplayObjectFromMasterPage( newValue ); + m_doc->updateSideBarItem( m_doc->masterPage() ); +} + +void KPrDisplayObjectFromMasterPage::unexecute() +{ + m_page->setDisplayObjectFromMasterPage( !newValue ); + m_doc->updateSideBarItem( m_doc->masterPage() ); +} + + +KPrDisplayBackgroundPage::KPrDisplayBackgroundPage(const QString &name, KPrDocument *_doc, KPrPage *_page, bool _newValue) + :KNamedCommand(name), + m_doc( _doc ), + m_page(_page), + newValue(_newValue) +{ +} + +void KPrDisplayBackgroundPage::execute() +{ + m_page->setDisplayBackground( newValue ); + m_doc->updateSideBarItem( m_doc->masterPage() ); +} + +void KPrDisplayBackgroundPage::unexecute() +{ + m_page->setDisplayBackground( !newValue ); + m_doc->updateSideBarItem( m_doc->masterPage() ); +} + + +KPrHideShowHeaderFooter::KPrHideShowHeaderFooter( const QString &name, KPrDocument *_doc, KPrPage *_page, + bool _newValue, KPrTextObject *_textObject): + KNamedCommand(name), + m_doc( _doc ), + m_page(_page), + m_textObject(_textObject), + newValue(_newValue) +{ +} + + +void KPrHideShowHeaderFooter::execute() +{ + if( m_textObject==m_doc->footer()) + m_page->setFooter( newValue ); + else if( m_textObject==m_doc->header()) + m_page->setHeader( newValue ); + else + kdDebug(33001)<<"Error in void KPrHideShowHeaderFooter::execute()\n"; + + m_doc->updateSideBarItem( m_doc->masterPage() ); +} + +void KPrHideShowHeaderFooter::unexecute() +{ + if( m_textObject==m_doc->footer()) + m_page->setFooter( !newValue ); + else if( m_textObject==m_doc->header()) + m_page->setHeader( !newValue ); + else + kdDebug(33001)<<"Error in void KPrHideShowHeaderFooter::unexecute()\n"; + + m_doc->updateSideBarItem( m_doc->masterPage() ); +} + +KPrFlipObjectCommand::KPrFlipObjectCommand( const QString &name, KPrDocument *_doc, + bool _horizontal, QPtrList &_objects ): + KNamedCommand( name ), + m_doc( _doc ), + objects( _objects ), + horizontal( _horizontal ) +{ + objects.setAutoDelete( false ); + + m_page = m_doc->findPage( objects ); + + QPtrListIterator it( objects ); + for ( ; it.current() ; ++it ) + it.current()->incCmdRef(); +} + +KPrFlipObjectCommand::~KPrFlipObjectCommand() +{ + QPtrListIterator it( objects ); + for ( ; it.current() ; ++it ) + it.current()->decCmdRef(); +} + +void KPrFlipObjectCommand::execute() +{ + flipObjects(); +} + +void KPrFlipObjectCommand::unexecute() +{ + flipObjects(); +} + +void KPrFlipObjectCommand::flipObjects() +{ + QPtrListIterator it( objects ); + for ( ; it.current() ; ++it ) + { + it.current()->flip( horizontal ); + m_doc->repaint( it.current() ); + } + + m_doc->updateSideBarItem( m_page ); +} + + +KPrGeometryPropertiesCommand::KPrGeometryPropertiesCommand( const QString &name, QPtrList &objects, + bool newValue, KgpType type,KPrDocument *_doc ) +: KNamedCommand( name ) +, m_objects( objects ) +, m_newValue( newValue ) +, m_type( type ) + , m_doc( _doc ) +{ + QPtrListIterator it( m_objects ); + for ( ; it.current() ; ++it ) + { + it.current()->incCmdRef(); + if ( m_type == ProtectSize ) + m_oldValue.append( it.current()->isProtect() ); + else if ( m_type == KeepRatio) + m_oldValue.append( it.current()->isKeepRatio() ); + } +} + +KPrGeometryPropertiesCommand::KPrGeometryPropertiesCommand( const QString &name, QValueList &lst, + QPtrList &objects, bool newValue, + KgpType type, KPrDocument *_doc) +: KNamedCommand( name ) +, m_oldValue( lst ) +, m_objects( objects ) +, m_newValue( newValue ) +, m_type( type ) +, m_doc ( _doc ) +{ + QPtrListIterator it( m_objects ); + for ( ; it.current() ; ++it ) + it.current()->incCmdRef(); +} + +KPrGeometryPropertiesCommand::~KPrGeometryPropertiesCommand() +{ + QPtrListIterator it( m_objects ); + for ( ; it.current() ; ++it ) + it.current()->decCmdRef(); +} + +void KPrGeometryPropertiesCommand::execute() +{ + QPtrListIterator it( m_objects ); + for ( ; it.current() ; ++it ) + { + if ( m_type == ProtectSize ) + { + it.current()->setProtect( m_newValue ); + if ( it.current()->isSelected() ) + m_doc->repaint( it.current() ); + } + else if ( m_type == KeepRatio) + it.current()->setKeepRatio( m_newValue ); + } +} + +void KPrGeometryPropertiesCommand::unexecute() +{ + KPrObject *obj = 0; + for ( unsigned int i = 0; i < m_objects.count(); ++i ) { + obj = m_objects.at( i ); + if ( m_type == ProtectSize ) + { + obj->setProtect( *m_oldValue.at(i) ); + if ( obj->isSelected() ) + m_doc->repaint( obj ); + } + else if ( m_type == KeepRatio) + obj->setKeepRatio( *m_oldValue.at(i) ); + } +} + +KPrProtectContentCommand::KPrProtectContentCommand( const QString &name, QPtrList &objects, + bool protectContent, KPrDocument *doc ) +: KNamedCommand( name ) +, m_protectContent( protectContent ) +, m_doc( doc ) +{ + m_objects.setAutoDelete( false ); + + addObjects( objects ); +} + +KPrProtectContentCommand::KPrProtectContentCommand( const QString &name, bool protectContent, + KPrTextObject *obj, KPrDocument *doc ) +: KNamedCommand( name ) +, m_protectContent( protectContent ) +, m_doc( doc ) +{ + obj->incCmdRef(); + m_objects.append( obj ); + m_oldValues.append( obj->isProtectContent() ); +} + +KPrProtectContentCommand::~KPrProtectContentCommand() +{ + QPtrListIterator it( m_objects ); + for ( ; it.current() ; ++it ) + it.current()->decCmdRef(); +} + +void KPrProtectContentCommand::addObjects( const QPtrList &objects ) +{ + QPtrListIterator it( objects ); + for ( ; it.current(); ++it ) + { + if ( it.current()->getType() == OT_GROUP ) + { + KPrGroupObject * obj = dynamic_cast( it.current() ); + if ( obj ) + { + addObjects( obj->objectList() ); + } + } + else + { + KPrTextObject *obj = dynamic_cast( it.current() ); + if( obj ) + { + m_objects.append( obj ); + obj->incCmdRef(); + + m_oldValues.append( obj->isProtectContent() ); + } + } + } +} + +void KPrProtectContentCommand::execute() +{ + QPtrListIterator it( m_objects ); + for ( ; it.current() ; ++it ) + { + it.current()->setProtectContent( m_protectContent ); + } + m_doc->updateObjectSelected(); + m_doc->updateRulerInProtectContentMode(); + +} + +void KPrProtectContentCommand::unexecute() +{ + for ( unsigned int i = 0; i < m_objects.count(); i++ ) + { + m_objects.at( i )->setProtectContent( m_oldValues[i] ); + } + m_doc->updateObjectSelected(); + m_doc->updateRulerInProtectContentMode(); +} + +KPrCloseObjectCommand::KPrCloseObjectCommand( const QString &name, QPtrList objects, KPrDocument *doc ) +: KNamedCommand( name ) +, m_doc( doc ) +, m_page( doc->findPage( objects.at( 0 ) ) ) +{ + QPtrListIterator it( objects ); + for ( ; it.current(); ++it ) + { + KPrPointObject * pointObject = dynamic_cast( *it ); + if ( pointObject ) + { + m_openObjects.append( *it ); + ( *it )->incCmdRef(); + KPrClosedLineObject * closedObject = new KPrClosedLineObject( *pointObject ); + closedObject->incCmdRef(); + m_closedObjects.append( closedObject ); + } + } +} + +KPrCloseObjectCommand::~KPrCloseObjectCommand() +{ + QPtrListIterator it( m_openObjects ); + for ( ; it.current() ; ++it ) + it.current()->decCmdRef(); + QPtrListIterator it2( m_closedObjects ); + for ( ; it2.current() ; ++it2 ) + it2.current()->decCmdRef(); +} + +void KPrCloseObjectCommand::execute() +{ + QPtrListIterator openIt( m_openObjects ); + QPtrListIterator closeIt( m_closedObjects ); + for ( ; openIt.current() ; ++openIt, ++closeIt ) + { + m_page->replaceObject( *openIt, *closeIt ); + bool selected = ( *openIt )->isSelected(); + ( *openIt )->removeFromObjList(); + ( *closeIt )->addToObjList(); + ( *openIt )->setSelected( false ); + ( *closeIt )->setSelected( selected ); + m_doc->repaint( *closeIt ); + } + m_doc->updateSideBarItem( m_page ); +} + +void KPrCloseObjectCommand::unexecute() +{ + QPtrListIterator openIt( m_openObjects ); + QPtrListIterator closeIt( m_closedObjects ); + for ( ; openIt.current() ; ++openIt, ++closeIt ) + { + m_page->replaceObject( *closeIt, *openIt ); + bool selected = ( *closeIt )->isSelected(); + ( *closeIt )->removeFromObjList(); + ( *openIt )->addToObjList(); + ( *closeIt )->setSelected( false ); + ( *openIt )->setSelected( selected ); + m_doc->repaint( *openIt ); + } + m_doc->updateSideBarItem( m_page ); +} + +MarginsStruct::MarginsStruct( KPrTextObject *obj ) +{ + topMargin = obj->bTop(); + bottomMargin= obj->bBottom(); + leftMargin = obj->bLeft(); + rightMargin= obj->bRight(); +} + +MarginsStruct::MarginsStruct( double _left, double _top, double _right, double _bottom ): + topMargin(_top), + bottomMargin(_bottom), + leftMargin(_left), + rightMargin(_right) +{ +} + + +KPrChangeMarginCommand::KPrChangeMarginCommand( const QString &name, QPtrList &objects, + MarginsStruct newMargins, KPrDocument *doc, + KPrPage *page ) +: KNamedCommand( name ) +, m_newMargins( newMargins ) +, m_page( page ) +, m_doc( doc ) +{ + m_objects.setAutoDelete( false ); + m_oldMargins.setAutoDelete( false ); + + addObjects( objects ); +} + + +KPrChangeMarginCommand::~KPrChangeMarginCommand() +{ + QPtrListIterator it( m_objects ); + for ( ; it.current() ; ++it ) + it.current()->decCmdRef(); + m_oldMargins.setAutoDelete( true ); + m_oldMargins.clear(); +} + + +void KPrChangeMarginCommand::addObjects( const QPtrList &objects ) +{ + QPtrListIterator it( objects ); + for ( ; it.current(); ++it ) + { + if ( it.current()->getType() == OT_GROUP ) + { + KPrGroupObject * obj = dynamic_cast( it.current() ); + if ( obj ) + { + addObjects( obj->objectList() ); + } + } + else + { + KPrTextObject *obj = dynamic_cast( it.current() ); + if( obj ) + { + m_objects.append( obj ); + obj->incCmdRef(); + + m_oldMargins.append( new MarginsStruct( obj ) ); + } + } + } +} + + +void KPrChangeMarginCommand::execute() +{ + QPtrListIterator it( m_objects ); + for ( ; it.current() ; ++it ) + { + it.current()->setTextMargins( m_newMargins.leftMargin, m_newMargins.topMargin, + m_newMargins.rightMargin, m_newMargins.bottomMargin); + it.current()->resizeTextDocument(); + it.current()->layout(); + } + m_doc->repaint( false ); + + m_doc->updateSideBarItem( m_page ); +} + +void KPrChangeMarginCommand::unexecute() +{ + for ( unsigned int i = 0; i < m_objects.count(); i++ ) + { + KPrTextObject *object = m_objects.at( i ); + MarginsStruct *marginsStruct = m_oldMargins.at( i ); + object->setTextMargins( marginsStruct->leftMargin, marginsStruct->topMargin, + marginsStruct->rightMargin, marginsStruct->bottomMargin); + object->resizeTextDocument(); + object->layout(); + } + m_doc->repaint( false ); + + m_doc->updateSideBarItem( m_page ); +} + + +KPrChangeVerticalAlignmentCommand::KPrChangeVerticalAlignmentCommand( const QString &name, KPrTextObject *_obj, + VerticalAlignmentType _oldAlign, + VerticalAlignmentType _newAlign, + KPrDocument *_doc) : + KNamedCommand(name), + m_obj( _obj ), + m_oldAlign(_oldAlign), + m_newAlign(_newAlign), + m_doc( _doc ) +{ + m_page = m_doc->findPage( _obj ); +} + +void KPrChangeVerticalAlignmentCommand::execute() +{ + m_obj->setVerticalAligment( m_newAlign ); + m_obj->kPresenterDocument()->layout(m_obj); + m_obj->kPresenterDocument()->repaint(m_obj); + + m_doc->updateSideBarItem( m_page ); +} + +void KPrChangeVerticalAlignmentCommand::unexecute() +{ + m_obj->setVerticalAligment( m_oldAlign ); + m_obj->kPresenterDocument()->layout(m_obj); + m_obj->kPresenterDocument()->repaint(m_obj); + + m_doc->updateSideBarItem( m_page ); +} + + +KPrChangeTabStopValueCommand::KPrChangeTabStopValueCommand( const QString &name, double _oldValue, double _newValue, + KPrDocument *_doc): + KNamedCommand(name), + m_doc( _doc ), + m_oldValue(_oldValue), + m_newValue(_newValue) +{ +} + +void KPrChangeTabStopValueCommand::execute() +{ + m_doc->setTabStopValue ( m_newValue ); +} + +void KPrChangeTabStopValueCommand::unexecute() +{ + m_doc->setTabStopValue ( m_oldValue ); +} + +KPrImageEffectCmd::KPrImageEffectCmd(const QString &_name, QPtrList &_oldSettings, + ImageEffectSettings _newSettings, QPtrList &_objects, + KPrDocument *_doc ) + :KNamedCommand( _name ), oldSettings( _oldSettings ), objects( _objects ) +{ + objects.setAutoDelete( false ); + oldSettings.setAutoDelete( false ); + doc = _doc; + newSettings = _newSettings; + + m_page = doc->findPage( objects ); + + QPtrListIterator it( objects ); + for ( ; it.current() ; ++it ) + it.current()->incCmdRef(); +} + +KPrImageEffectCmd::~KPrImageEffectCmd() +{ + QPtrListIterator it( objects ); + for ( ; it.current() ; ++it ) + it.current()->decCmdRef(); + oldSettings.setAutoDelete( true ); + oldSettings.clear(); +} + +void KPrImageEffectCmd::execute() +{ + QPtrListIterator it( objects ); + for ( ; it.current() ; ++it ) { + KPrPixmapObject * obj = dynamic_cast( it.current() ); + if ( obj ) { + obj->setImageEffect(newSettings.effect); + obj->setIEParams(newSettings.param1, newSettings.param2, newSettings.param3); + } + } + doc->repaint( false ); + + doc->updateSideBarItem( m_page ); +} + +void KPrImageEffectCmd::unexecute() +{ + for ( unsigned int i = 0; i < objects.count(); ++i ) { + KPrPixmapObject * obj = dynamic_cast( objects.at(i) ); + if ( obj ) { + obj->setImageEffect(oldSettings.at( i )->effect); + obj->setIEParams(oldSettings.at( i )->param1, oldSettings.at( i )->param2, + oldSettings.at( i )->param3); + } + } + doc->repaint( false ); + + doc->updateSideBarItem( m_page ); +} + +KPrChangeVariableNoteText::KPrChangeVariableNoteText( const QString &name, KPrDocument *_doc, + const QString &_oldValue,const QString &_newValue, + KoNoteVariable *var): + KNamedCommand(name), + m_doc(_doc), + newValue(_newValue), + oldValue(_oldValue), + m_var(var) +{ +} + +KPrChangeVariableNoteText::~KPrChangeVariableNoteText() +{ +} + +void KPrChangeVariableNoteText::execute() +{ + Q_ASSERT(m_var); + m_var->setNote(newValue); +} + +void KPrChangeVariableNoteText::unexecute() +{ + Q_ASSERT(m_var); + m_var->setNote(oldValue); +} diff --git a/kpresenter/KPrCommand.h b/kpresenter/KPrCommand.h new file mode 100644 index 00000000..a3e06e3e --- /dev/null +++ b/kpresenter/KPrCommand.h @@ -0,0 +1,1094 @@ +// -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*- +/* This file is part of the KDE project + Copyright (C) 2001 Laurent Montel + Copyright (C) 2005 Thorsten Zachmann + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#ifndef kprcommand_h +#define kprcommand_h + +#include +#include +#include +#include +#include +#include "global.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "KPrBackground.h" +#include "KPrVariableCollection.h" +#include + +class KPrDocument; +class KPrTextObject; +class KPrObject; +class KPr2DObject; +class KPrPixmapObject; +class KPrGroupObject; +class KPrView; +class KoParagLayout; +class KPrPage; +class KoCustomVariable; +class KoLinkVariable; +class KPrPolylineObject; +class KPrFieldVariable; +class KPrTimeVariable; +class KPrDateVariable; +class KPrPgNumVariable; + +class KPrShadowCmd : public KNamedCommand +{ +public: + struct ShadowValues + { + int shadowDistance; + ShadowDirection shadowDirection; + QColor shadowColor; + }; + + KPrShadowCmd( const QString &_name, QPtrList &_oldShadow, ShadowValues _newShadow, + QPtrList &_objects, KPrDocument *_doc ); + ~KPrShadowCmd(); + + virtual void execute(); + virtual void unexecute(); + +protected: + KPrDocument *doc; + QPtrList oldShadow; + QPtrList objects; + ShadowValues newShadow; + KPrPage *m_page; +}; + +class KPrSetOptionsCmd : public KNamedCommand +{ +public: + KPrSetOptionsCmd( const QString &_name, QValueList &_diffs, QPtrList &_objects, + double _rastX, double _rastY, double _orastX, double _orastY, + const QColor &_txtBackCol, const QColor &_otxtBackCol, KPrDocument *_doc ); + ~KPrSetOptionsCmd(); + + virtual void execute(); + virtual void unexecute(); + +protected: + + QValueList diffs; + QPtrList objects; + double gridX; + double gridY; + double oldGridX; + double oldGridY; + KPrDocument *doc; + QColor txtBackCol; + QColor otxtBackCol; +}; + +class KPrSetBackCmd : public KNamedCommand +{ +public: + KPrSetBackCmd( const QString &name, const KPrBackGround::Settings &settings, + const KPrBackGround::Settings &oldSettings, + bool useMasterBackground, + bool takeGlobal, KPrDocument *doc, KPrPage *page ); + + virtual void execute(); + virtual void unexecute(); + +protected: + + KPrBackGround::Settings m_settings; + KPrBackGround::Settings m_oldSettings; + bool m_useMasterBackground; + bool m_oldUseMasterBackground; + bool m_takeGlobal; + KPrDocument *m_doc; + KPrPage *m_page; +}; + +class KPrRotateCmd : public KNamedCommand +{ +public: + struct RotateValues + { + float angle; + }; + + KPrRotateCmd( const QString &_name, float newAngle, QPtrList &objects, + KPrDocument *doc, bool addAngle = false ); + ~KPrRotateCmd(); + + virtual void execute(); + virtual void unexecute(); + +protected: + KPrDocument *m_doc; + QPtrList m_oldAngles; + QPtrList m_objects; + float m_newAngle; + //necessary for duplicate object, we can duplicated and add angle. + bool m_addAngle; + KPrPage *m_page; +}; + +class KPrResizeCmd : public KNamedCommand +{ +public: + KPrResizeCmd( const QString &_name, const KoPoint &_m_diff, const KoSize &_r_diff, + KPrObject *_object, KPrDocument *_doc ); + ~KPrResizeCmd(); + + virtual void execute(); + virtual void unexecute(); + +protected: + + KoPoint m_diff; + KoSize r_diff; + KPrObject *object; + KPrDocument *doc; + KPrPage *m_page; +}; + +class KPrChgPixCmd : public KNamedCommand +{ +public: + KPrChgPixCmd( const QString &_name, KPrPixmapObject *_oldObject, KPrPixmapObject *_newObject, + KPrDocument *_doc, KPrPage *_page ); + ~KPrChgPixCmd(); + + virtual void execute(); + virtual void unexecute(); + +protected: + + KPrPixmapObject *oldObject, *newObject; + KPrDocument *doc; + KPrPage *m_page; +}; + +class KPrDeleteCmd : public KNamedCommand +{ +public: + KPrDeleteCmd( const QString &_name, QPtrList &_objects, KPrDocument *_doc, + KPrPage *_page); + ~KPrDeleteCmd(); + + virtual void execute(); + virtual void unexecute(); + +protected: + QPtrList m_oldObjectList; + QPtrList m_objectsToDelete; + KPrDocument *m_doc; + KPrPage *m_page; +}; + +class KPrEffectCmd : public KNamedCommand +{ +public: + struct EffectStruct { + int appearStep, disappearStep; + Effect effect; + Effect2 effect2; + Effect3 effect3; + EffectSpeed m_appearSpeed; + EffectSpeed m_disappearSpeed; + bool disappear; + int appearTimer, disappearTimer; + bool appearSoundEffect, disappearSoundEffect; + QString a_fileName, d_fileName; + }; + + KPrEffectCmd( const QString &_name, const QPtrList &_objs, + const QValueList &_oldEffects, EffectStruct _newEffect ); + ~KPrEffectCmd(); + + virtual void execute(); + virtual void unexecute(); + +protected: + + QValueList oldEffects; + EffectStruct newEffect; + QPtrList objs; +}; + +class KPrGroupObjCmd : public KNamedCommand +{ +public: + KPrGroupObjCmd( const QString &_name, + const QPtrList &_objects, + KPrDocument *_doc, KPrPage *_page ); + ~KPrGroupObjCmd(); + + virtual void execute(); + virtual void unexecute(); + +protected: + + QPtrList m_objectsToGroup; + QPtrList m_oldObjectList; + KPrDocument *m_doc; + KPrGroupObject *m_groupObject; + KPrPage *m_page; + +}; + +class UnGroupObjCmd : public KNamedCommand +{ +public: + UnGroupObjCmd( const QString &_name, + KPrGroupObject *grpObj_, + KPrDocument *_doc, KPrPage *_page ); + ~UnGroupObjCmd(); + + virtual void execute(); + virtual void unexecute(); + +protected: + + QPtrList m_groupedObjects; + KPrGroupObject *m_groupObject; + KPrDocument *m_doc; + KPrPage *m_page; +}; + + +class KPrInsertCmd : public KNamedCommand +{ +public: + KPrInsertCmd( const QString &name, const QValueList objects, KPrDocument *doc, KPrPage *page ); + KPrInsertCmd( const QString &name, KPrObject *object, KPrDocument *doc, KPrPage *page ); + ~KPrInsertCmd(); + + virtual void execute(); + virtual void unexecute(); + +protected: + QValueList m_objects; + KPrObject *m_object; + KPrDocument *m_doc; + KPrPage *m_page; +}; + + +class KPrLowerRaiseCmd : public KNamedCommand +{ +public: + KPrLowerRaiseCmd( const QString &_name, const QPtrList& _oldList, + const QPtrList& _newList, + KPrDocument *_doc, KPrPage *_page ); + ~KPrLowerRaiseCmd(); + + virtual void execute(); + virtual void unexecute(); + +protected: + + QPtrList oldList, newList; + KPrDocument *doc; + KPrPage *m_page; +}; + +class KPrMoveByCmd : public KNamedCommand +{ +public: + KPrMoveByCmd( const QString &_name, const KoPoint &_diff, QPtrList &_objects, + KPrDocument *_doc, KPrPage *_page ); + ~KPrMoveByCmd(); + + virtual void execute(); + virtual void unexecute(); + +protected: + + KoPoint diff; + QPtrList objects; + KPrDocument *doc; + KPrPage *m_page; +}; + +/** + * Command to align objects + */ +class KPrAlignCmd : public KNamedCommand +{ +public: + KPrAlignCmd( const QString &_name, QPtrList &_objects, AlignType _at, KPrDocument *_doc ); + ~KPrAlignCmd(); + + virtual void execute(); + virtual void unexecute(); + +protected: + QPtrList diffs; + QPtrList objects; + KPrDocument *doc; + KPrPage *m_page; +}; + +class KoPenCmd : public KNamedCommand +{ +public: + struct Pen { + Pen( KoPen p, LineEnd lb, LineEnd le ) + : pen( p ) + , lineBegin( lb ) + , lineEnd( le ) + {} + + KoPen pen; + LineEnd lineBegin, lineEnd; + + Pen &operator=( const Pen &_pen ) { + pen = _pen.pen; + lineBegin = _pen.lineBegin; + lineEnd = _pen.lineEnd; + return *this; + } + }; + + // the flags indicate what has changed + enum PenConfigChange { + LineBegin = 1, + LineEnd = 2, + Color = 4, + Width = 8, + Style = 16, + All = LineBegin | LineEnd | Color | Width | Style + }; + + KoPenCmd( const QString &_name, QPtrList &_objects, Pen _newPen, + KPrDocument *_doc, KPrPage *_page, int _flags = All); + ~KoPenCmd(); + + virtual void execute(); + virtual void unexecute(); + +protected: + void addObjects( const QPtrList &_objects ); + void applyPen( KPrObject *object, Pen *tmpPen ); + + KPrDocument *doc; + KPrPage *m_page; + QPtrList oldPen; + QPtrList objects; + Pen newPen; + int flags; +}; + +class KPrBrushCmd : public KNamedCommand +{ +public: + struct Brush { + Brush() {} + Brush( QBrush _brush, QColor _gColor1, QColor _gColor2, + BCType _gType, FillType _fillType, bool _unbalanced, + int _xfactor, int _yfactor ) + : brush( _brush ) + , gColor1( _gColor1 ) + , gColor2( _gColor2 ) + , gType( _gType ) + , fillType( _fillType ) + , unbalanced( _unbalanced ) + , xfactor( _xfactor ) + , yfactor( _yfactor ) + {} + + QBrush brush; + QColor gColor1; + QColor gColor2; + BCType gType; + FillType fillType; + bool unbalanced; + int xfactor, yfactor; + + Brush &operator=( const Brush &_brush ) { + brush = _brush.brush; + gColor1 = _brush.gColor1; + gColor2 = _brush.gColor2; + gType = _brush.gType; + fillType = _brush.fillType; + unbalanced = _brush.unbalanced; + xfactor = _brush.xfactor; + yfactor = _brush.yfactor; + return *this; + } + }; + + // the flags indicate what has changed + enum BrushConfigChange { + BrushColor = 1, + BrushStyle = 2, + BrushGradientSelect = 4, + GradientColor1 = 8, + GradientColor2 = 16, + GradientType = 32, + GradientBalanced = 64, + GradientXFactor = 128, + GradientYFactor = 256, + All = BrushColor | BrushStyle | BrushGradientSelect | GradientColor1 | GradientColor2 | GradientType | GradientBalanced | GradientXFactor | GradientYFactor + }; + + KPrBrushCmd( const QString &_name, QPtrList &_objects, Brush _newBrush, + KPrDocument *_doc, KPrPage *_page, int _flags = All ); + ~KPrBrushCmd(); + + virtual void execute(); + virtual void unexecute(); + +protected: + void addObjects( const QPtrList &_objects ); + void applyBrush( KPr2DObject *object, Brush *tmpBrush ); + + KPrDocument *doc; + QPtrList oldBrush; + QPtrList objects; + Brush newBrush; + KPrPage *m_page; + int flags; +}; + +class KPrPgConfCmd : public KNamedCommand +{ +public: + KPrPgConfCmd( const QString &_name, bool _manualSwitch, bool _infiniteLoop, + bool _showEndOfPresentationSlide, bool _showPresentationDuration, QPen _pen, + QValueList _selectedSlides, const QString & _presentationName, + bool _oldManualSwitch, bool _oldInfiniteLoop, + bool _oldShowEndOfPresentationSlide, bool _oldShowPresentationDuration, QPen _oldPen, + QValueList _oldSelectedSlides, const QString & _oldPresentationName, + KPrDocument *_doc ); + + virtual void execute(); + virtual void unexecute(); + +protected: + bool manualSwitch, oldManualSwitch; + bool infiniteLoop, oldInfiniteLoop; + bool showEndOfPresentationSlide, oldShowEndOfPresentationSlide; + bool showPresentationDuration, oldShowPresentationDuration; + QPen pen, oldPen; + QValueList selectedSlides, oldSelectedSlides; + QString oldPresentationName, presentationName; + + KPrDocument *doc; +}; + +class KPrTransEffectCmd : public KCommand +{ +public: + struct PageEffectSettings { + PageEffect pageEffect; + EffectSpeed effectSpeed; + bool soundEffect; + QString soundFileName; + bool autoAdvance; + int slideTime; + void applyTo( KPrPage * ); + }; + // TODO also pass a flag to know which settings need to be applied (especially for "all pages") + KPrTransEffectCmd( QValueVector oldSettings, + PageEffectSettings newSettings, + KPrPage* page, KPrDocument* doc ); + + virtual void execute(); + virtual void unexecute(); + virtual QString name() const; + +private: + void exec( KPrPage* page ); + void unexec( KPrPage* page ); + + QValueVector m_oldSettings; + PageEffectSettings m_newSettings; + KPrPage *m_page; + KPrDocument *m_doc; +}; + +class KPrPgLayoutCmd : public KNamedCommand +{ +public: + KPrPgLayoutCmd( const QString &_name, KoPageLayout _layout, KoPageLayout _oldLayout, + KoUnit::Unit _oldUnit, KoUnit::Unit _unit,KPrDocument *_doc ); + + virtual void execute(); + virtual void unexecute(); + +protected: + KPrDocument *m_doc; + KoPageLayout layout, oldLayout; + KoUnit::Unit unit, oldUnit; +}; + +class KPrPieValueCmd : public KNamedCommand +{ +public: + struct PieValues + { + PieType pieType; + int pieAngle, pieLength; + }; + + // the flags indicate what has changed + enum PieConfigChange { + Type = 1, + Angle = 2, + Length = 4, + All = Type | Angle | Length + }; + + KPrPieValueCmd( const QString &name, PieValues newValues, + QPtrList &objects, KPrDocument *doc, + KPrPage *page, int flags = All ); + KPrPieValueCmd( const QString &_name, QPtrList &_oldValues, PieValues _newValues, + QPtrList &_objects, KPrDocument *_doc, KPrPage *_page, int _flags = All ); + ~KPrPieValueCmd(); + + virtual void execute(); + virtual void unexecute(); + +protected: + void addObjects( const QPtrList &objects ); + + KPrDocument *m_doc; + KPrPage *m_page; + QPtrList m_oldValues; + QPtrList m_objects; + PieValues m_newValues; + int m_flags; +}; + +class KPrPolygonSettingCmd : public KNamedCommand +{ +public: + struct PolygonSettings + { + bool checkConcavePolygon; + int cornersValue; + int sharpnessValue; + }; + + // the flags indicate what has changed + enum PolygonConfigChange { + ConcaveConvex = 1, + Corners = 2, + Sharpness = 4, + All = ConcaveConvex | Corners | Sharpness + }; + + KPrPolygonSettingCmd( const QString &name, PolygonSettings newSettings, + QPtrList &objects, KPrDocument *doc, + KPrPage *page, int flags = All ); + ~KPrPolygonSettingCmd(); + + virtual void execute(); + virtual void unexecute(); + +protected: + void addObjects( const QPtrList &objects ); + + KPrDocument *m_doc; + KPrPage *m_page; + QPtrList m_oldSettings; + QPtrList m_objects; + PolygonSettings m_newSettings; + int m_flags; +}; + +class KPrPictureSettingCmd : public KNamedCommand +{ +public: + struct PictureSettings + { + PictureMirrorType mirrorType; + int depth; + bool swapRGB; + bool grayscal; + int bright; + }; + + enum PictureConfigChange { + MirrorType = 1, + Depth = 2, + SwapRGB = 4, + Grayscal = 8, + Bright = 16, + All = MirrorType | Depth | SwapRGB | Grayscal | Bright + }; + + KPrPictureSettingCmd( const QString &name, PictureSettings newSettings, + QPtrList &objects, KPrDocument *doc, + KPrPage *page, int flags = All ); + KPrPictureSettingCmd( const QString &_name, QPtrList &_oldSettings, + PictureSettings _newSettings, QPtrList &_objects, + KPrDocument *_doc, int flags = All ); + ~KPrPictureSettingCmd(); + + virtual void execute(); + virtual void unexecute(); + +protected: + void addObjects( const QPtrList &_objects ); + + KPrDocument *m_doc; + QPtrList m_oldValues; + QPtrList m_objects; + PictureSettings m_newSettings; + KPrPage *m_page; + int m_flags; +}; + +class KPrImageEffectCmd : public KNamedCommand +{ +public: + struct ImageEffectSettings + { + ImageEffect effect; + QVariant param1; + QVariant param2; + QVariant param3; + }; + + KPrImageEffectCmd(const QString &_name, QPtrList &_oldSettings, + ImageEffectSettings _newSettings, QPtrList &_objects, + KPrDocument *_doc ); + ~KPrImageEffectCmd(); + + virtual void execute(); + virtual void unexecute(); + +protected: + KPrDocument *doc; + QPtrList oldSettings; + QPtrList objects; + ImageEffectSettings newSettings; + KPrPage *m_page; + +}; + +class KPrRectValueCmd : public KNamedCommand +{ +public: + struct RectValues + { + int xRnd, yRnd; + }; + + // the flags indicate what has changed + enum RectangleConfigChange { + XRnd = 1, + YRnd = 2, + All = XRnd | YRnd + }; + + KPrRectValueCmd( const QString &_name, QPtrList &_oldValues, RectValues _newValues, + QPtrList &_objects, KPrDocument *_doc, KPrPage *_page, int _flags = All ); + KPrRectValueCmd( const QString &_name, QPtrList &_objects, RectValues _newValues, + KPrDocument *_doc, KPrPage *_page, int _flags = All ); + ~KPrRectValueCmd(); + + virtual void execute(); + virtual void unexecute(); + +protected: + void addObjects( const QPtrList &_objects ); + + KPrDocument *m_doc; + KPrPage *m_page; + QPtrList m_oldValues; + QPtrList m_objects; + RectValues m_newValues; + int m_flags; +}; + +class KPrDeletePageCmd : public KNamedCommand +{ +public: + KPrDeletePageCmd( const QString &name, int pageNum, KPrDocument *doc ); + ~KPrDeletePageCmd(); + + virtual void execute(); + virtual void unexecute(); + +protected: + KPrDocument *m_doc; + KPrPage *m_page; + int m_pageNum; +}; + +class KPrInsertPageCmd : public KNamedCommand +{ +public: + KPrInsertPageCmd( const QString &name, int currentPageNum, InsertPos pos, + KPrPage *page, KPrDocument *doc ); + ~KPrInsertPageCmd(); + + virtual void execute(); + virtual void unexecute(); +protected: + KPrDocument *m_doc; + KPrPage *m_page; + int m_currentPageNum; + int m_insertPageNum; +}; + +class KPrMovePageCmd : public KNamedCommand +{ +public: + KPrMovePageCmd( const QString &_name, int from,int to, KPrDocument *_doc ); + ~KPrMovePageCmd(); + + virtual void execute(); + virtual void unexecute(); +protected: + KPrDocument *m_doc; + int m_oldPosition; + int m_newPosition; +}; + +/** + * Command created when pasting oasis-formatted text + */ +class KPrOasisPasteTextCommand : public KoTextDocCommand +{ +public: + KPrOasisPasteTextCommand( KoTextDocument *d, int parag, int idx, + const QByteArray &data ); + KoTextCursor *execute( KoTextCursor *c ); + KoTextCursor *unexecute( KoTextCursor *c ); +protected: + int m_parag; + int m_idx; + QByteArray m_data; + // filled in by execute(), for unexecute() + int m_lastParag; + int m_lastIndex; + KoParagLayout* m_oldParagLayout; +}; + +/** + * Command to change variable setting + */ +class KPrChangeStartingPageCommand : public KNamedCommand +{ +public: + KPrChangeStartingPageCommand( const QString &name, KPrDocument *_doc, + int _oldStartingPage, int _newStartingPage); + ~KPrChangeStartingPageCommand(){} + + void execute(); + void unexecute(); +protected: + KPrDocument *m_doc; + int oldStartingPage; + int newStartingPage; +}; + +/** + * Command to display link setting + */ +class KPrChangeVariableSettingsCommand : public KNamedCommand +{ +public: + enum VariableProperties { VS_DISPLAYLINK, VS_UNDERLINELINK, VS_DISPLAYCOMMENT, VS_DISPLAYFIELDCODE}; + KPrChangeVariableSettingsCommand( const QString &name, KPrDocument *_doc, bool _oldValue, + bool _newValue, VariableProperties _type); + ~KPrChangeVariableSettingsCommand(){} + + void execute(); + void unexecute(); +protected: + void changeValue( bool b ); + KPrDocument *m_doc; + VariableProperties type; + bool m_bOldValue; + bool m_bNewValue; +}; + +/** + * Command to change title page name + */ +class KPrChangeTitlePageNameCommand : public KNamedCommand +{ +public: + KPrChangeTitlePageNameCommand( const QString &name, KPrDocument *_doc, const QString &_oldPageName, + const QString &_newPageName, KPrPage *_page); + ~KPrChangeTitlePageNameCommand(){} + + void execute(); + void unexecute(); +protected: + KPrDocument *m_doc; + QString oldPageName; + QString newPageName; + KPrPage *m_page; +}; + +class KPrChangeCustomVariableValue : public KNamedCommand +{ +public: + KPrChangeCustomVariableValue( const QString &name, KPrDocument *_doc,const QString & _oldValue, + const QString & _newValue, KoCustomVariable *var); + + void execute(); + void unexecute(); +protected: + KPrDocument *m_doc; + QString newValue; + QString oldValue; + KoCustomVariable *m_var; +}; + +class KPrChangeLinkVariable : public KNamedCommand +{ +public: + KPrChangeLinkVariable( const QString &name, KPrDocument *_doc,const QString & _oldHref, + const QString & _newHref, const QString & _oldLink,const QString &_newLink, KoLinkVariable *var); + ~KPrChangeLinkVariable(){}; + void execute(); + void unexecute(); +protected: + KPrDocument *m_doc; + QString oldHref; + QString newHref; + QString oldLink; + QString newLink; + KoLinkVariable *m_var; +}; + + +class KPrNameObjectCommand : public KNamedCommand +{ +public: + KPrNameObjectCommand( const QString &_name, const QString &_objectName, KPrObject *_obj, KPrDocument *_doc ); + ~KPrNameObjectCommand(); + void execute(); + void unexecute(); +protected: + QString oldObjectName, newObjectName; + KPrObject *object; + KPrDocument *doc; + KPrPage *m_page; +}; + +class KPrDisplayObjectFromMasterPage : public KNamedCommand +{ +public: + KPrDisplayObjectFromMasterPage( const QString &name, KPrDocument *_doc, KPrPage *_page, bool _newValue); + ~KPrDisplayObjectFromMasterPage(){}; + void execute(); + void unexecute(); +protected: + KPrDocument *m_doc; + KPrPage *m_page; + bool newValue; +}; + +class KPrDisplayBackgroundPage : public KNamedCommand +{ +public: + KPrDisplayBackgroundPage( const QString &name, KPrDocument *_doc, KPrPage *_page, bool _newValue); + ~KPrDisplayBackgroundPage(){}; + void execute(); + void unexecute(); +protected: + KPrDocument *m_doc; + KPrPage *m_page; + bool newValue; +}; + +class KPrHideShowHeaderFooter : public KNamedCommand +{ +public: + KPrHideShowHeaderFooter( const QString &name, KPrDocument *_doc, KPrPage *_page, bool _newValue,KPrTextObject *_textObject); + ~KPrHideShowHeaderFooter(){}; + void execute(); + void unexecute(); +protected: + KPrDocument *m_doc; + KPrPage *m_page; + KPrTextObject *m_textObject; + bool newValue; +}; + +class KPrFlipObjectCommand : public KNamedCommand +{ +public: + KPrFlipObjectCommand( const QString &name, KPrDocument *_doc, bool _horizontal , + QPtrList &_objects ); + ~KPrFlipObjectCommand(); + void execute(); + void unexecute(); +protected: + void flipObjects(); + KPrDocument *m_doc; + QPtrList objects; + bool horizontal; + KPrPage *m_page; +}; + +class KPrGeometryPropertiesCommand : public KNamedCommand +{ +public: + enum KgpType { ProtectSize, KeepRatio}; + KPrGeometryPropertiesCommand( const QString &name, QPtrList &objects, + bool newValue, KgpType type, KPrDocument *_doc ); + KPrGeometryPropertiesCommand( const QString &name, QValueList &lst, QPtrList &objects, + bool newValue, KgpType type, KPrDocument *_doc ); + ~KPrGeometryPropertiesCommand(); + + virtual void execute(); + virtual void unexecute(); + +protected: + QValueList m_oldValue; + QPtrList m_objects; + bool m_newValue; + KgpType m_type; + KPrDocument *m_doc; +}; + +class KPrProtectContentCommand : public KNamedCommand +{ +public: + KPrProtectContentCommand( const QString &name, QPtrList &objects, + bool protectContent, KPrDocument *doc ); + KPrProtectContentCommand( const QString &name, bool protectContent, + KPrTextObject *obj, KPrDocument *doc ); + + ~KPrProtectContentCommand(); + virtual void execute(); + virtual void unexecute(); + +protected: + void addObjects( const QPtrList &objects ); + + QPtrList m_objects; + bool m_protectContent; + QValueList m_oldValues; + KPrDocument *m_doc; +}; + +class KPrCloseObjectCommand : public KNamedCommand +{ +public: + KPrCloseObjectCommand( const QString &name, QPtrList objects, KPrDocument *doc ); + + ~KPrCloseObjectCommand(); + virtual void execute(); + virtual void unexecute(); + +protected: + void closeObject(bool close); + + QPtrList m_openObjects; + QPtrList m_closedObjects; + KPrDocument * m_doc; + KPrPage *m_page; +}; + +struct MarginsStruct { + MarginsStruct() {} + MarginsStruct( KPrTextObject *obj ); + MarginsStruct( double _left, double top, double right, double bottom ); + double topMargin; + double bottomMargin; + double leftMargin; + double rightMargin; +}; + +class KPrChangeMarginCommand : public KNamedCommand +{ +public: + KPrChangeMarginCommand( const QString &name, QPtrList &objects, MarginsStruct newMargins, + KPrDocument *doc, KPrPage *page ); + ~KPrChangeMarginCommand(); + + virtual void execute(); + virtual void unexecute(); +protected: + void addObjects( const QPtrList &objects ); + QPtrList m_oldMargins; + QPtrList m_objects; + MarginsStruct m_newMargins; + KPrPage *m_page; + KPrDocument *m_doc; +}; + + +class KPrChangeVerticalAlignmentCommand : public KNamedCommand +{ +public: + KPrChangeVerticalAlignmentCommand( const QString &name, KPrTextObject *_obj, VerticalAlignmentType _oldAlign, + VerticalAlignmentType _newAlign, KPrDocument *_doc); + ~KPrChangeVerticalAlignmentCommand() {} + + virtual void execute(); + virtual void unexecute(); +protected: + KPrTextObject *m_obj; + VerticalAlignmentType m_oldAlign; + VerticalAlignmentType m_newAlign; + KPrPage *m_page; + KPrDocument *m_doc; +}; + + +class KPrChangeTabStopValueCommand : public KNamedCommand +{ +public: + KPrChangeTabStopValueCommand( const QString &name, double _oldValue, double _newValue, KPrDocument *_doc); + + ~KPrChangeTabStopValueCommand() {} + + virtual void execute(); + virtual void unexecute(); +protected: + KPrDocument *m_doc; + double m_oldValue; + double m_newValue; +}; + +class KPrChangeVariableNoteText : public KNamedCommand +{ + public: + KPrChangeVariableNoteText( const QString &name, KPrDocument *_doc, const QString &_oldValue,const QString &_newValue, KoNoteVariable *var); + ~KPrChangeVariableNoteText(); + void execute(); + void unexecute(); + protected: + KPrDocument *m_doc; + QString newValue; + QString oldValue; + KoNoteVariable *m_var; +}; + + +#endif diff --git a/kpresenter/KPrConfig.cpp b/kpresenter/KPrConfig.cpp new file mode 100644 index 00000000..6722edd2 --- /dev/null +++ b/kpresenter/KPrConfig.cpp @@ -0,0 +1,1128 @@ +/* This file is part of the KDE project + Copyright (C) 1998, 1999 Reginald Stadlbauer + Copyright (C) 2005 Thorsten Zachmann + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + + +#include +#include +#include +#include +#include +#include +#include +#include +#include "KPrVariableCollection.h" +#include "KPrCanvas.h" +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "KPrPenStyleWidget.h" +#include "KPrBrushProperty.h" +#include "KPrPieProperty.h" +#include "KPrRectProperty.h" +#include "KPrPolygonProperty.h" + +#include "KPrConfig.h" +#include "KPrView.h" +#include "KPrDocument.h" +#include "KPrPage.h" +#include + +#include +#include +#include +#include "KPrCommand.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +using namespace KSpell2; + +KPrConfig::KPrConfig( KPrView* parent ) + : KDialogBase(KDialogBase::IconList,i18n("Configure KPresenter") , + KDialogBase::Ok | KDialogBase::Apply | KDialogBase::Cancel| KDialogBase::Default, + KDialogBase::Ok, parent) + +{ + m_doc = parent->kPresenterDoc(); + QVBox *page = addVBoxPage( i18n("Interface"), i18n("Interface"), + BarIcon("misc", KIcon::SizeMedium) ); + _interfacePage=new KPrConfigureInterfacePage( parent, page ); + page = addVBoxPage( i18n("Color"), i18n("Color"), + BarIcon("colorize", KIcon::SizeMedium) ); + _colorBackground = new KPrConfigureColorBackground( parent, page ); + + page = addVBoxPage( i18n("Spelling"), i18n("Spellchecker Behavior"), + BarIcon("spellcheck", KIcon::SizeMedium) ); + _spellPage=new KPrConfigureSpellPage(parent, page); + + page = addVBoxPage( i18n("Misc"), i18n("Misc"), + BarIcon("misc", KIcon::SizeMedium) ); + _miscPage=new KPrConfigureMiscPage(parent, page); + + page = addVBoxPage( i18n("Document"), i18n("Document Settings"), + BarIcon("kpresenter_kpr", KIcon::SizeMedium) ); + + _defaultDocPage=new KPrConfigureDefaultDocPage(parent, page); + + page = addVBoxPage( i18n("Tools"), i18n("Default Tools Settings"), + BarIcon("configure", KIcon::SizeMedium) ); + + _toolsPage=new KPrConfigureToolsPage(parent, page); + + page = addVBoxPage( i18n("Paths"), i18n("Path Settings"), + BarIcon("path") ); + + m_pathPage=new KPrConfigurePathPage(parent, page); + + if (KoSpeaker::isKttsdInstalled()) { + page = addVBoxPage( i18n("Abbreviation for Text-to-Speech", "TTS"), i18n("Text-to-Speech Settings"), + BarIcon("access", KIcon::SizeMedium) ); + m_ttsPage=new KPrConfigureTTSPage(parent, page); + } else m_ttsPage = 0; + + connect( this, SIGNAL( okClicked() ),this, SLOT( slotApply() ) ); +} + +void KPrConfig::openPage(int flags) +{ + if(flags & KP_INTERFACE) + showPage( 0 ); + else if(flags & KP_COLOR) + showPage(1 ); + else if(flags & KP_KSPELL) + showPage(2); + else if(flags & KP_MISC) + showPage(3 ); + else if(flags & KP_DOC) + showPage(4 ); + else if(flags & KP_TOOLS) + showPage(5); + else if(flags & KP_PATH) + showPage(6); +} + +void KPrConfig::slotApply() +{ + KMacroCommand *macro = 0L; + _interfacePage->apply(); + _colorBackground->apply(); + if (_spellPage) _spellPage->apply(); + m_pathPage->apply(); + KCommand *cmd = _miscPage->apply(); + if ( cmd ) + { + if ( !macro ) + macro = new KMacroCommand(i18n("Change Config") ); + macro->addCommand( cmd ); + } + cmd = _defaultDocPage->apply(); + if ( cmd ) + { + if ( !macro ) + macro = new KMacroCommand(i18n("Change Config") ); + + macro->addCommand( cmd ); + } + + _toolsPage->apply(); + if (m_ttsPage) m_ttsPage->apply(); + if ( macro ) + m_doc->addCommand( macro); +} + +void KPrConfig::slotDefault() +{ + switch( activePageIndex() ) { + case 0: + _interfacePage->slotDefault(); + break; + case 1: + _colorBackground->slotDefault(); + break; + case 2: + if (_spellPage) _spellPage->slotDefault(); + break; + case 3: + _miscPage->slotDefault(); + break; + case 4: + _defaultDocPage->slotDefault(); + break; + case 5: + _toolsPage->slotDefault(); + break; + case 6: + m_pathPage->slotDefault(); + break; + case 7: + m_ttsPage->slotDefault(); + default: + break; + } +} + +KPrConfigureInterfacePage::KPrConfigureInterfacePage( KPrView *_view, QWidget *parent , char *name ) + :QWidget ( parent,name ) +{ + QVBoxLayout *box = new QVBoxLayout( this, 0, 0 ); + + m_pView=_view; + config = KPrFactory::global()->config(); + + KoUnit::Unit unit = m_pView->kPresenterDoc()->unit(); + + oldNbRecentFiles=10; + double ptIndent = MM_TO_POINT(10.0); + bool bShowRuler=true; + bool oldShowStatusBar = true; + + if( config->hasGroup("Interface") ) { + config->setGroup( "Interface" ); + oldNbRecentFiles=config->readNumEntry("NbRecentFile",oldNbRecentFiles); + ptIndent = config->readDoubleNumEntry("Indent", ptIndent); + bShowRuler=config->readBoolEntry("Rulers",true); + oldShowStatusBar = config->readBoolEntry( "ShowStatusBar" , true ); + + } + + showRuler= new QCheckBox(i18n("Show rulers"),this); + QWhatsThis::add(showRuler, i18n( "When checked, both vertical and horizontal rulers are shown on the KPresenter slide (this is the default). When unchecked, the rulers are not shown on any slide." ) ); + showRuler->setChecked(bShowRuler); + box->addWidget(showRuler); + + showStatusBar = new QCheckBox(i18n("Show status bar"),this); + QWhatsThis::add(showStatusBar, i18n( "Toggle the statusbar, which is shown by default." ) ); + showStatusBar->setChecked(oldShowStatusBar); + box->addWidget(showStatusBar); + + + recentFiles=new KIntNumInput( oldNbRecentFiles, this); + recentFiles->setRange(1, 20, 1); + recentFiles->setLabel(i18n("Number of recent files:")); + QWhatsThis::add(recentFiles, i18n( "Set the number of recent files which will be opened using the File->Open Recent menu. Default is to remember 10 filenames. The maximum you can set is 20 and the minimum is 1." ) ); + + box->addWidget(recentFiles); + + QString suffix = KoUnit::unitName( unit ).prepend(' '); + indent = new KDoubleNumInput( this ); + indent->setValue( KoUnit::toUserValue( ptIndent, unit ) ); + indent->setRange(KoUnit::toUserValue( 0.1, unit ), KoUnit::toUserValue( 50, unit ), KoUnit::toUserValue( 0.1, unit )); + + + indent->setSuffix( suffix ); + indent->setLabel(i18n("Text indentation depth:")); + QWhatsThis::add(indent, i18n( "This setting is used by Increase Depth and Decrease Depth menu items (in the Text menu) to change the indentation depth. The Default is 1 centimeter." ) ); + + box->addWidget(indent); + + QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); + box->addItem( spacer); +} + +void KPrConfigureInterfacePage::apply() +{ + bool ruler=showRuler->isChecked(); + bool statusBar=showStatusBar->isChecked(); + + KPrDocument * doc = m_pView->kPresenterDoc(); + + config->setGroup( "Interface" ); + + double newIndent = KoUnit::fromUserValue( indent->value(), doc->unit() ); + if( newIndent != doc->getIndentValue() ) + { + config->writeEntry( "Indent", newIndent, true, false, 'g', DBL_DIG /* 6 is not enough */ ); + doc->setIndentValue( newIndent ); + } + int nbRecent=recentFiles->value(); + if(nbRecent!=oldNbRecentFiles) + { + config->writeEntry( "NbRecentFile", nbRecent); + m_pView->changeNbOfRecentFiles(nbRecent); + oldNbRecentFiles=nbRecent; + } + bool refreshGUI=false; + if(ruler != doc->showRuler()) + { + config->writeEntry( "Rulers", ruler ); + doc->setShowRuler( ruler ); + refreshGUI=true; + + } + if( statusBar != doc->showStatusBar() ) + { + config->writeEntry( "ShowStatusBar", statusBar ); + doc->setShowStatusBar( statusBar ); + refreshGUI=true; + } + + if( refreshGUI ) + doc->reorganizeGUI(); + +} + +void KPrConfigureInterfacePage::slotDefault() +{ + double newIndent = KoUnit::toUserValue( MM_TO_POINT( 10 ), m_pView->kPresenterDoc()->unit() ); + indent->setValue( newIndent ); + recentFiles->setValue(10); + showRuler->setChecked(true); + showStatusBar->setChecked(true); +} + +KPrConfigureColorBackground::KPrConfigureColorBackground( KPrView* _view, QWidget *parent , char *name ) + :QWidget ( parent,name ) +{ + m_pView = _view; + config = KPrFactory::global()->config(); + + oldBgColor = m_pView->kPresenterDoc()->txtBackCol(); + oldGridColor = m_pView->kPresenterDoc()->gridColor(); + QVBoxLayout *box = new QVBoxLayout( this, 0, 0 ); + + QLabel *lab = new QLabel( this, "label20" ); + lab->setText( i18n( "Background object color:" ) ); + QWhatsThis::add(lab, i18n( "Change the background color of the text box. The background is white by default. If you have a dark background color and you want to put some white text on it, you can change the color of the text box so that you can see what you are typing. When you have finished, the area around the text will revert to the background color. The Defaults button restores the original settings." ) ); + box->addWidget(lab); + + bgColor = new KColorButton( oldBgColor, + oldBgColor, + this ); + bgColor->setColor( oldBgColor ); + box->addWidget(bgColor); + + + lab = new QLabel( this, "label20" ); + lab->setText( i18n( "Grid color:" ) ); + QWhatsThis::add(lab, i18n( "Here you can change the grid color, which is black by default." ) ); + box->addWidget(lab); + + gridColor = new KColorButton( oldGridColor, + oldGridColor, + this ); + box->addWidget(gridColor); + QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); + box->addItem( spacer); + +} + +void KPrConfigureColorBackground::apply() +{ + KPrDocument * doc = m_pView->kPresenterDoc(); + bool repaintNeeded = false; + QColor _col = bgColor->color(); + if( oldBgColor != _col ) { + config->setGroup( "KPresenter Color" ); + config->writeEntry( "BackgroundColor", _col ); + doc->setTxtBackCol( _col ); + doc->replaceObjs(); + oldBgColor=_col; + repaintNeeded = true; + } + _col = gridColor->color(); + if( oldGridColor != _col ) { + config->setGroup( "KPresenter Color" ); + config->writeEntry( "GridColor", _col ); + doc->repaint( false ); + doc->setGridColor( _col ); + oldGridColor=_col; + repaintNeeded = true; + } + if (repaintNeeded) + doc->repaint( false ); +} + +void KPrConfigureColorBackground::slotDefault() +{ + bgColor->setColor( Qt::white ); + gridColor->setColor( Qt::black ); +} + + + +KPrConfigureSpellPage::KPrConfigureSpellPage( KPrView *_view, QWidget *parent, char *name ) + : QWidget( parent, name ) +{ + m_pView=_view; + config = KPrFactory::global()->config(); + m_spellConfigWidget = new ConfigWidget( _view->broker(), parent ); + m_spellConfigWidget->setBackgroundCheckingButtonShown( true ); +} + +void KPrConfigureSpellPage::apply() +{ + + KPrDocument* doc = m_pView->kPresenterDoc(); + m_spellConfigWidget->save(); + + + m_pView->kPresenterDoc()->setSpellCheckIgnoreList( + m_pView->broker()->settings()->currentIgnoreList() ); + //FIXME reactivate just if there are changes. + doc->enableBackgroundSpellCheck( m_pView->broker()->settings()->backgroundCheckerEnabled() ); + doc->reactivateBgSpellChecking(); +} + +void KPrConfigureSpellPage::slotDefault() +{ + m_spellConfigWidget->slotDefault(); +} + +KPrConfigureMiscPage::KPrConfigureMiscPage( KPrView *_view, QWidget *parent, char *name ) + : QWidget( parent, name ) +{ + QVBoxLayout *box = new QVBoxLayout( this, 0, 0 ); + + m_pView=_view; + config = KPrFactory::global()->config(); + + QGroupBox* tmpQGroupBox = new QGroupBox( 0, Qt::Vertical, i18n("Misc"), this, "GroupBox" ); + tmpQGroupBox->layout()->setSpacing(KDialog::spacingHint()); + tmpQGroupBox->layout()->setMargin(KDialog::marginHint()); + QGridLayout *grid = new QGridLayout( tmpQGroupBox->layout(), 8, 1 ); + + m_oldNbRedo=30; + m_printNotes=true; + if( config->hasGroup("Misc") ) + { + config->setGroup( "Misc" ); + m_oldNbRedo=config->readNumEntry("UndoRedo",m_oldNbRedo); + m_printNotes = config->readBoolEntry("PrintNotes", true); + } + + m_undoRedoLimit=new KIntNumInput( m_oldNbRedo, tmpQGroupBox ); + m_undoRedoLimit->setLabel(i18n("Undo/redo limit:")); + m_undoRedoLimit->setRange(10, 60, 1); + QWhatsThis::add(m_undoRedoLimit, i18n( "Set the number of actions you can undo and redo (how many actions KPresenter keeps in its Undo buffer). This ranges from a minimum of 10 to a maximum of 60 (the default is 30). Once the number of actions reaches the number set here, earlier actions will be forgotten." ) ); + grid->addWidget(m_undoRedoLimit,0,0); + + KPrDocument* doc = m_pView->kPresenterDoc(); + + m_displayLink=new QCheckBox(i18n("Display links"),tmpQGroupBox); + QWhatsThis::add(m_displayLink, i18n( "When you want to include a link in your slide, you can use the Insert->Link... menu, which allows you to insert URL, mail or file links. If the option Display links is checked, all links will be active and displayed in a different color (this is the default behavior). If the option is unchecked, the links will be inactive and the same color as the text. This affects both the edited slides and the slide show." ) ); + grid->addWidget(m_displayLink,3,0); + m_displayLink->setChecked(doc->getVariableCollection()->variableSetting()->displayLink()); + + m_underlineLink=new QCheckBox(i18n("&Underline all links"),tmpQGroupBox); + m_underlineLink->setChecked(doc->getVariableCollection()->variableSetting()->underlineLink()); + QWhatsThis::add(m_underlineLink, i18n( "If this is checked, all links will be underlined (this is the default). If it is not checked, the links will not be underlined." ) ); + grid->addWidget(m_underlineLink,4,0); + + + m_displayComment=new QCheckBox(i18n("Display comments"),tmpQGroupBox); + m_displayComment->setChecked(doc->getVariableCollection()->variableSetting()->displayComment()); + QWhatsThis::add(m_displayComment, i18n( "Comments are inserted in the text at the cursor using the Insert->Comment... menu. Comments can only be viewed in edit mode and not in the slide show. If this option is checked (default) then each comment will be shown as a small yellow rectangle. You can then right-click on them to edit them, remove them or copy the text." ) ); + grid->addWidget(m_displayComment,5,0); + + m_displayFieldCode=new QCheckBox(i18n("Display field code"),tmpQGroupBox); + m_displayFieldCode->setChecked(doc->getVariableCollection()->variableSetting()->displayFieldCode()); + QWhatsThis::add(m_displayFieldCode, i18n( "In editor mode (not in slide show) this option will display all the variable codes as well as Link at links location. This is very useful to see what variable is displayed. Variables are inserted using the Insert -> Variable menu." ) ); + grid->addWidget(m_displayFieldCode,6,0); + + m_cbPrintNotes=new QCheckBox(i18n("Print slide notes"),tmpQGroupBox); + m_cbPrintNotes->setChecked(m_printNotes); + QWhatsThis::add(m_cbPrintNotes, i18n( "If checked, all notes will be printed on paper. The notes will all be printed separately on the last page, from the first slide to the last and finally the Master Page Note. You can see the notes for each slide using the View->Show notebar menu." ) ); + grid->addWidget(m_cbPrintNotes,7,0); + + box->addWidget(tmpQGroupBox); + + tmpQGroupBox = new QGroupBox( 0, Qt::Vertical, i18n("Grid"), this, "GroupBox" ); + tmpQGroupBox->layout()->setSpacing(KDialog::spacingHint()); + tmpQGroupBox->layout()->setMargin(KDialog::marginHint()); + grid = new QGridLayout( tmpQGroupBox->layout(), 8, 1 ); + + KoRect rect = doc->masterPage()->getPageRect(); + QLabel *lab=new QLabel(i18n("Horizontal grid size:"), tmpQGroupBox); + QWhatsThis::add(lab, i18n( "Set the space in millimeters between two horizontal points on the grid. Default is 5 millimeters." ) ); + grid->addWidget(lab,0,0); + KoUnit::Unit unit = doc->unit(); + resolutionX = new KoUnitDoubleSpinBox(tmpQGroupBox, 5.0,rect.width(),1,doc->getGridX() ); + resolutionX->setUnit( unit ); + + grid->addWidget(resolutionX,1,0); + + lab=new QLabel(i18n("Vertical grid size:"), tmpQGroupBox); + QWhatsThis::add(lab, i18n( "Set the space in millimeters between two vertical points on the grid. Default is 5 millimeters." ) ); + grid->addWidget(lab,2,0); + + resolutionY = new KoUnitDoubleSpinBox(tmpQGroupBox, 5.0,rect.height(),1,doc->getGridY() ); + resolutionY->setUnit( unit ); + + grid->addWidget(resolutionY, 3, 0); + box->addWidget(tmpQGroupBox); + + QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); + box->addItem( spacer); + + +} + +KCommand * KPrConfigureMiscPage::apply() +{ + config->setGroup( "Misc" ); + int newUndo=m_undoRedoLimit->value(); + KPrDocument* doc = m_pView->kPresenterDoc(); + if(newUndo!=m_oldNbRedo) + { + config->writeEntry("UndoRedo",newUndo); + doc->setUndoRedoLimit(newUndo); + m_oldNbRedo=newUndo; + } + config->writeEntry("PrintNotes", m_cbPrintNotes->isChecked()); + + KMacroCommand * macroCmd=0L; + bool b=m_displayLink->isChecked(); + bool b_new=doc->getVariableCollection()->variableSetting()->displayLink(); + if(b_new!=b) + { + if(!macroCmd) + macroCmd=new KMacroCommand(i18n("Change Display Link Command")); + + KPrChangeVariableSettingsCommand *cmd=new KPrChangeVariableSettingsCommand( + i18n("Change Display Link Command"), doc, b_new, b, KPrChangeVariableSettingsCommand::VS_DISPLAYLINK); + cmd->execute(); + macroCmd->addCommand(cmd); + } + + b=m_underlineLink->isChecked(); + if(doc->getVariableCollection()->variableSetting()->underlineLink()!=b) + { + if(!macroCmd) + macroCmd=new KMacroCommand(i18n("Change Display Link Command")); + + KPrChangeVariableSettingsCommand *cmd=new KPrChangeVariableSettingsCommand( + i18n("Change Display Link Command"), doc, doc->getVariableCollection()->variableSetting()->underlineLink(), + b, KPrChangeVariableSettingsCommand::VS_UNDERLINELINK); + cmd->execute(); + macroCmd->addCommand(cmd); + } + + b=m_displayComment->isChecked(); + if(doc->getVariableCollection()->variableSetting()->displayComment()!=b) + { + if(!macroCmd) + macroCmd=new KMacroCommand(i18n("Change Display Link Command")); + + KPrChangeVariableSettingsCommand *cmd=new KPrChangeVariableSettingsCommand( + i18n("Change Display Link Command"), doc, doc->getVariableCollection()->variableSetting()->displayComment(), + b, KPrChangeVariableSettingsCommand::VS_DISPLAYCOMMENT); + cmd->execute(); + macroCmd->addCommand(cmd); + } + + b=m_displayFieldCode->isChecked(); + if(doc->getVariableCollection()->variableSetting()->displayFieldCode()!=b) + { + if(!macroCmd) + macroCmd=new KMacroCommand(i18n("Change Display Field Code Command")); + + KPrChangeVariableSettingsCommand *cmd=new KPrChangeVariableSettingsCommand( + i18n("Change Display Field Code Command"), doc, doc->getVariableCollection()->variableSetting()->displayComment(), + b, KPrChangeVariableSettingsCommand::VS_DISPLAYFIELDCODE); + cmd->execute(); + macroCmd->addCommand(cmd); + } + + doc->setGridValue( resolutionX->value(), + resolutionY->value(), true); + doc->repaint( false ); + + config->sync(); + + return macroCmd; +} + +void KPrConfigureMiscPage::slotDefault() +{ + m_undoRedoLimit->setValue(30); + m_displayLink->setChecked(true); + m_displayComment->setChecked(true); + m_underlineLink->setChecked(true); + m_displayFieldCode->setChecked( false ); + m_cbPrintNotes->setChecked(true); + //KPrDocument* doc = m_pView->kPresenterDoc(); + + resolutionY->setValue( MM_TO_POINT( 5.0 )); + resolutionX->setValue( MM_TO_POINT( 5.0 )); +} + +KPrConfigureDefaultDocPage::KPrConfigureDefaultDocPage(KPrView *_view, QWidget *parent, char *name ) + : QWidget( parent, name ) +{ + QVBoxLayout *box = new QVBoxLayout( this, 0, 0 ); + + m_pView=_view; + config = KPrFactory::global()->config(); + KPrDocument *doc = m_pView->kPresenterDoc(); + oldAutoSaveValue = doc->defaultAutoSave()/60; + m_oldBackupFile = true; + m_oldLanguage = doc->globalLanguage(); + m_oldHyphenation = doc->globalHyphenation(); + if( config->hasGroup("Interface") ) { + config->setGroup( "Interface" ); + oldAutoSaveValue = config->readNumEntry( "AutoSave", oldAutoSaveValue ); + m_oldBackupFile=config->readBoolEntry("BackupFile",m_oldBackupFile); + m_oldLanguage = config->readEntry( "language", m_oldLanguage ); + m_oldHyphenation = config->readBoolEntry( "hyphenation", m_oldHyphenation); + } + + QVGroupBox* gbDocumentDefaults = new QVGroupBox( i18n("Document Defaults"), this, "GroupBox" ); + gbDocumentDefaults->setMargin( KDialog::marginHint() ); + gbDocumentDefaults->setInsideSpacing( 5 ); + + QWidget *fontContainer = new QWidget(gbDocumentDefaults); + QGridLayout * fontLayout = new QGridLayout(fontContainer, 1, 3); + + fontLayout->setColStretch(0, 0); + fontLayout->setColStretch(1, 1); + fontLayout->setColStretch(2, 0); + + QLabel *fontTitle = new QLabel(i18n("Default font:"), fontContainer); + + font= new QFont( doc->defaultFont() ); + + QString labelName = font->family() + ' ' + QString::number(font->pointSize()); + fontName = new QLabel(labelName, fontContainer); + fontName->setFont(*font); + fontName->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); + + QPushButton *chooseButton = new QPushButton(i18n("Choose..."), fontContainer); + QWhatsThis::add(chooseButton, i18n( "Click here if you want to set a new font. The KDE default Select Font dialog will then be displayed." ) ); + connect(chooseButton, SIGNAL(clicked()), this, SLOT(selectNewDefaultFont())); + + fontLayout->addWidget(fontTitle, 0, 0); + fontLayout->addWidget(fontName, 0, 1); + fontLayout->addWidget(chooseButton, 0, 2); + + QWidget *languageContainer = new QWidget(gbDocumentDefaults); + QGridLayout * languageLayout = new QGridLayout(languageContainer, 1, 3); + + languageLayout->setColStretch(0, 0); + languageLayout->setColStretch(1, 1); + + QLabel *languageTitle = new QLabel(i18n("Global language:"), languageContainer); + QWhatsThis::add(languageTitle, i18n( "Use this drop down box to determine the default language for the document. This setting is used by the hyphenation and spelling tools." ) ); + + m_globalLanguage = new QComboBox( languageContainer ); + m_globalLanguage->insertStringList( KoGlobal::listOfLanguages() ); + m_globalLanguage->setCurrentText( KoGlobal::languageFromTag( doc->globalLanguage() ) ); + + languageLayout->addWidget(languageTitle, 0, 0); + languageLayout->addWidget(m_globalLanguage, 0, 1); + + m_autoHyphenation = new QCheckBox( i18n("Automatic hyphenation"), gbDocumentDefaults); + QWhatsThis::add(m_autoHyphenation, i18n( "Check this box if you want KPresenter to automatically hyphenate long words when it determines the word wrap in text frames. This is not set by default." ) ); + m_autoHyphenation->setChecked( m_oldHyphenation ); + + box->addWidget(gbDocumentDefaults); + + QVGroupBox* gbDocumentSettings = new QVGroupBox( i18n("Document Settings"), this ); + gbDocumentSettings->setMargin( KDialog::marginHint() ); + gbDocumentSettings->setInsideSpacing( KDialog::spacingHint() ); + + m_createBackupFile = new QCheckBox( i18n("Create backup file"), gbDocumentSettings); + QWhatsThis::add(m_createBackupFile, i18n( "If checked, this will create a ..kpr.autosave.kpr in the folder where your file is. This backup file can then be used in case of a problem.\nThe backup file is updated every time you save your document or every time there is an autosave." ) ); + m_createBackupFile->setChecked( m_oldBackupFile ); + + + autoSave = new KIntNumInput( oldAutoSaveValue, gbDocumentSettings ); + autoSave->setRange( 0, 60, 1 ); + autoSave->setLabel( i18n("Autosave (min):") ); + autoSave->setSpecialValueText( i18n("No autosave") ); + autoSave->setSuffix( i18n("min") ); + QWhatsThis::add(autoSave, i18n( "You can use this to adjust how often KPresenter saves a temporary file. If you set this value to No autosave, KPresenter will not autosave. You can adjust the autosave from 1 to 60 minutes." ) ); + + new QLabel(i18n("Starting page number:"), gbDocumentSettings); + m_oldStartingPage=doc->getVariableCollection()->variableSetting()->startingPageNumber(); + m_variableNumberOffset=new KIntNumInput(gbDocumentSettings); + m_variableNumberOffset->setRange(1, 9999, 1, false); + m_variableNumberOffset->setValue(m_oldStartingPage); + QWhatsThis::add(m_variableNumberOffset, i18n( "Here you can change the number for the first page. It is set to 1 by default.\nTip: this is helpful if you have split a single document into multiple files." ) ); + + new QLabel(i18n("Tab stop:"), gbDocumentSettings); + m_oldTabStopWidth = doc->tabStopValue(); + KoRect rect = doc->masterPage()->getPageRect(); + m_tabStopWidth = new KoUnitDoubleSpinBox( gbDocumentSettings , MM_TO_POINT(2), rect.width() ,0.1, m_oldTabStopWidth ); + + m_tabStopWidth->setUnit( doc->unit() ); + + QWhatsThis::add(m_tabStopWidth, i18n( "Each KPresenter document has a default set of tab stops. If you add tab stops to your document, the newly added tab stops override the default ones. You can use this text box to define the spacing between default tab stops. As an example, if you enter 1.5 in this text box, and the unit of measurement is in centimeters, the first default tab stop will be located 1.5 cm to the right of the frame's left-hand margin. The second default tab stop will be located at 3 cm from the left-hand margin, and so on." ) ); + + box->addWidget(gbDocumentSettings); + QVGroupBox* gbDocumentCursor = new QVGroupBox( i18n("Cursor"), this ); + gbDocumentCursor->setMargin( KDialog::marginHint() ); + gbDocumentCursor->setInsideSpacing( KDialog::spacingHint() ); + + m_cursorInProtectedArea= new QCheckBox(i18n("Cursor in protected area"),gbDocumentCursor); + m_cursorInProtectedArea->setChecked(doc->cursorInProtectedArea()); + QWhatsThis::add(m_cursorInProtectedArea, i18n( "When this box is checked and you click in a protected frame within your document, a cursor will appear. When this box is unchecked, and you click in a protected frame, no cursor will be visible." ) ); + + m_directInsertCursor= new QCheckBox(i18n("Direct insert cursor"),gbDocumentCursor); + m_directInsertCursor->setChecked(doc->insertDirectCursor()); + QWhatsThis::add(m_directInsertCursor, i18n( "When this box is checked, you can select a section of text using your mouse. Move the mouse to a new area in your document and click once with the middle mouse button and a copy of the selected text will be copied and pasted to the new location in the document.\nWhen this box is unchecked, in order to copy text from one section to another, you must select the text, manually copy the text to the clipboard, then manually paste the text in the new location." ) ); + box->addWidget(gbDocumentCursor); + + QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); + box->addItem(spacer); + +} + +KPrConfigureDefaultDocPage::~KPrConfigureDefaultDocPage() +{ + delete font; +} + +KCommand *KPrConfigureDefaultDocPage::apply() +{ + config->setGroup( "Document defaults" ); + KPrDocument* doc = m_pView->kPresenterDoc(); + config->writeEntry("DefaultFont",font->toString()); + + config->setGroup( "Interface" ); + int autoSaveVal = autoSave->value(); + if( autoSaveVal != oldAutoSaveValue ) { + config->writeEntry( "AutoSave", autoSaveVal ); + m_pView->kPresenterDoc()->setAutoSave( autoSaveVal*60 ); + oldAutoSaveValue=autoSaveVal; + } + bool state =m_createBackupFile->isChecked(); + + if(state!=m_oldBackupFile) + { + config->writeEntry( "BackupFile", state ); + doc->setBackupFile( state); + m_oldBackupFile=state; + } + + state = m_cursorInProtectedArea->isChecked(); + if ( state != doc->cursorInProtectedArea() ) + { + config->writeEntry( "cursorInProtectArea", state ); + m_pView->kPresenterDoc()->setCursorInProtectedArea( state ); + } + + state = m_directInsertCursor->isChecked(); + if ( state != doc->insertDirectCursor() ) + doc->setInsertDirectCursor( state ); + + //Laurent Todo add a message box to inform user that + //global language will change after re-launch kword + const QString lang = KoGlobal::tagOfLanguage( m_globalLanguage->currentText() ); + config->writeEntry( "language" , lang); + m_oldLanguage = lang; + //don't call this function otherwise we can have a textobject with + // a default language and other textobject with other default language. + //doc->setGlobalLanguage( lang ); + + + state = m_autoHyphenation->isChecked(); + config->writeEntry( "hyphenation", state ); + m_oldHyphenation = state; + + KMacroCommand *macro = 0L; + int newStartingPage=m_variableNumberOffset->value(); + if(newStartingPage!=m_oldStartingPage) + { + macro = new KMacroCommand( i18n("Change Starting Page Number") ); + KPrChangeStartingPageCommand *cmd = new KPrChangeStartingPageCommand( i18n("Change Starting Page Number"), doc, m_oldStartingPage,newStartingPage ); + cmd->execute(); + macro->addCommand( cmd); + m_oldStartingPage=newStartingPage; + } + double newTabStop = m_tabStopWidth->value(); + if ( newTabStop != m_oldTabStopWidth) + { + if ( !macro ) + macro = new KMacroCommand( i18n("Change Tab Stop Value") ); + KPrChangeTabStopValueCommand *cmd = new KPrChangeTabStopValueCommand( i18n("Change Tab Stop Value"), m_oldTabStopWidth, newTabStop, doc); + cmd->execute(); + macro->addCommand( cmd ); + m_oldTabStopWidth = newTabStop; + } + return macro; +} + +void KPrConfigureDefaultDocPage::slotDefault() +{ + autoSave->setValue( m_pView->kPresenterDoc()->defaultAutoSave()/60 ); + m_variableNumberOffset->setValue(1); + m_cursorInProtectedArea->setChecked(true); + m_tabStopWidth->setValue( MM_TO_POINT(15)); + m_createBackupFile->setChecked( true ); + m_directInsertCursor->setChecked( false ); + m_globalLanguage->setCurrentText( KoGlobal::languageFromTag( KGlobal::locale()->language() ) ); + m_autoHyphenation->setChecked( false ); +} + +void KPrConfigureDefaultDocPage::selectNewDefaultFont() { + QStringList list; + KFontChooser::getFontList(list, KFontChooser::SmoothScalableFonts); + KFontDialog dlg( this, "Font Selector", false, true, list, true ); + dlg.setFont(*font); + int result = dlg.exec(); + if (KDialog::Accepted == result) { + delete font; + font = new QFont(dlg.font()); + fontName->setText(font->family() + ' ' + QString::number(font->pointSize())); + fontName->setFont(*font); + m_pView->kPresenterDoc()->setDefaultFont( *font ); + } +} + +KPrConfigureToolsPage::KPrConfigureToolsPage( KPrView *_view, QWidget *parent, char *name ) + : QWidget( parent, name ) +{ + QVBoxLayout *box = new QVBoxLayout( this, 0, 0 ); + + m_pView = _view; + config = KPrFactory::global()->config(); + m_pView->getCanvas()->deSelectAllObj(); + + QTabWidget *tab = new QTabWidget(this); + + KoPenCmd::Pen pen( m_pView->getPen(), m_pView->getLineBegin(), m_pView->getLineEnd() ); + m_confPenDia = new KPrPenStyleWidget(tab, 0, pen, true ); + tab->addTab( m_confPenDia, i18n( "Outl&ine" ) ); + + KPrBrushCmd::Brush brush( m_pView->getBrush(), + m_pView->getGColor1(), + m_pView->getGColor2(), + m_pView->getGType(), + m_pView->getFillType(), + m_pView->getGUnbalanced(), + m_pView->getGXFactor(), + m_pView->getGYFactor() ); + m_brushProperty = new KPrBrushProperty( this, 0, brush ); + tab->addTab( m_brushProperty, i18n( "&Fill" ) ); + + KPrRectValueCmd::RectValues rectValues; + rectValues.xRnd = m_pView->getRndX(); + rectValues.yRnd = m_pView->getRndY(); + m_rectProperty = new KPrRectProperty( this, 0, rectValues ); + tab->addTab( m_rectProperty, i18n( "&Rectangle" ) ); + + KPrPolygonSettingCmd::PolygonSettings polygonSettings; + polygonSettings.checkConcavePolygon = m_pView->getCheckConcavePolygon(); + polygonSettings.cornersValue = m_pView->getCornersValue(); + polygonSettings.sharpnessValue = m_pView->getSharpnessValue(); + m_polygonProperty = new KPrPolygonProperty( this, 0, polygonSettings ); + tab->addTab( m_polygonProperty, i18n( "Polygo&n" ) ); + + KPrPieValueCmd::PieValues pieValues; + pieValues.pieType = m_pView->getPieType(); + pieValues.pieAngle = m_pView->getPieAngle(); + pieValues.pieLength = m_pView->getPieLength(); + m_pieProperty = new KPrPieProperty( this, 0, pieValues ); + tab->addTab( m_pieProperty, i18n( "&Pie" ) ); + + box->addWidget(tab); +} + +KPrConfigureToolsPage::~KPrConfigureToolsPage() +{ +} + +void KPrConfigureToolsPage::apply() +{ + KoPenCmd::Pen pen = m_confPenDia->getPen(); + m_pView->setPen( pen.pen ); + m_pView->setLineBegin( pen.lineBegin ); + m_pView->setLineEnd( pen.lineEnd ); + m_pView->getActionPenColor()->setCurrentColor( pen.pen.color() ); + + KPrBrushCmd::Brush brush = m_brushProperty->getBrush(); + m_pView->setBrush( brush.brush ); + m_pView->setFillType( brush.fillType ); + m_pView->setGColor1( brush.gColor1 ); + m_pView->setGColor2( brush.gColor2 ); + m_pView->setGType( brush.gType ); + m_pView->setGUnbalanced( brush.unbalanced ); + m_pView->setGXFactor( brush.xfactor ); + m_pView->setGYFactor( brush.yfactor ); + m_pView->getActionBrushColor()->setCurrentColor( brush.brush.color() ); + + KPrRectValueCmd::RectValues rectValues = m_rectProperty->getRectValues(); + m_pView->setRndX( rectValues.xRnd ); + m_pView->setRndY( rectValues.yRnd ); + + KPrPolygonSettingCmd::PolygonSettings polygonSettings = m_polygonProperty->getPolygonSettings(); + m_pView->setCheckConcavePolygon( polygonSettings.checkConcavePolygon ); + m_pView->setCornersValue( polygonSettings.cornersValue ); + m_pView->setSharpnessValue( polygonSettings.sharpnessValue ); + + KPrPieValueCmd::PieValues pieValues = m_pieProperty->getPieValues(); + m_pView->setPieType( pieValues.pieType ); + m_pView->setPieAngle( pieValues.pieAngle ); + m_pView->setPieLength( pieValues.pieLength ); + + //TODO set pen brush in m_rectProperty + //TODO set pen brush in m_polygonProperty + //TODO set pen brush in m_pieProperty +} + +void KPrConfigureToolsPage::slotDefault() +{ + KoPenCmd::Pen pen( KoPen(black, 1.0, SolidLine), L_NORMAL, L_NORMAL ); + m_confPenDia->setPen( pen ); + m_pView->getActionPenColor()->setCurrentColor( pen.pen.color() ); + + KPrBrushCmd::Brush brush( QBrush( white, SolidPattern ), red, green, + BCT_GHORZ, FT_BRUSH, false, 100, 100 ); + m_brushProperty->setBrush( brush ); + m_pView->getActionBrushColor()->setCurrentColor( brush.brush.color() ); + + KPrRectValueCmd::RectValues rectValues; + rectValues.xRnd = 0; + rectValues.yRnd = 0; + m_rectProperty->setRectValues( rectValues ); + + KPrPolygonSettingCmd::PolygonSettings polygonSettings; + polygonSettings.checkConcavePolygon = false; + polygonSettings.cornersValue = 3; + polygonSettings.sharpnessValue = 0; + m_polygonProperty->setPolygonSettings( polygonSettings ); + + KPrPieValueCmd::PieValues pieValues; + pieValues.pieType = PT_PIE; + pieValues.pieAngle = 45 * 16; + pieValues.pieLength = 270 * 16; +} + +KPrConfigurePathPage::KPrConfigurePathPage( KPrView *_view, QWidget *parent, char *name ) + : QWidget( parent, name ) +{ + QVBoxLayout *box = new QVBoxLayout( this, 0, 0 ); + + m_pView=_view; + KPrDocument* doc = m_pView->kPresenterDoc(); + config = KPrFactory::global()->config(); + + m_pPathView = new KListView( this ); + m_pPathView->setResizeMode(QListView::NoColumn); + m_pPathView->addColumn( i18n( "Type" ) ); + m_pPathView->addColumn( i18n( "Path" ) ); + (void) new QListViewItem( m_pPathView, i18n("Picture Path"),doc->picturePath() ); + (void) new QListViewItem( m_pPathView, i18n("Backup Path"),doc->backupPath() ); + QWhatsThis::add(m_pPathView, i18n( "There are two paths that are set here: the Backup Path and the Picture Path. The Backup path is the folder where your backup files are saved and the Picture Path is the folder where your pictures are saved." ) ); + box->addWidget(m_pPathView); + + m_modifyPath = new QPushButton( i18n("Modify Path..."), this); + connect( m_modifyPath, SIGNAL( clicked ()), this, SLOT( slotModifyPath())); + connect( m_pPathView, SIGNAL( doubleClicked (QListViewItem *, const QPoint &, int )), + this, SLOT( slotModifyPath())); + connect( m_pPathView, SIGNAL( selectionChanged ( QListViewItem * )), + this, SLOT( slotSelectionChanged(QListViewItem * ))); + slotSelectionChanged(m_pPathView->currentItem()); + QWhatsThis::add(m_modifyPath, i18n( "When you click this button, a small dialog will appear and, if Default path is unchecked, you can either enter a path yourself or choose one using the standard KDE file dialog." ) ); + box->addWidget(m_modifyPath); + +} + +void KPrConfigurePathPage::slotSelectionChanged(QListViewItem * item) +{ + m_modifyPath->setEnabled( item ); +} + +void KPrConfigurePathPage::slotModifyPath() +{ + QListViewItem *item = m_pPathView->currentItem (); + if ( item ) + { + if ( item->text(0)==i18n("Picture Path")) + { + KURLRequesterDlg * dlg = new KURLRequesterDlg( item->text(1), 0L, + "picture path dlg"); + dlg->fileDialog()->setMode(KFile::Directory | KFile::LocalOnly); + if ( dlg->exec() ) + item->setText( 1, dlg->selectedURL().path()); + delete dlg; + } + else if ( item->text(0)==i18n("Backup Path")) + { + KoChangePathDia *dlg = new KoChangePathDia( item->text(1), 0L, + "backup path" ); + if (dlg->exec() ) + item->setText(1, dlg->newPath()); + delete dlg; + } + } +} + +void KPrConfigurePathPage::slotDefault() +{ + QListViewItem * item = m_pPathView->findItem(i18n("Picture Path"), 0); + if ( item ) + item->setText(1, KGlobalSettings::documentPath()); + item = m_pPathView->findItem(i18n("Backup Path"), 0); + if ( item ) + item->setText(1, QString::null ); +} + +void KPrConfigurePathPage::apply() +{ + QListViewItem *item = m_pPathView->findItem(i18n("Backup Path"), 0); + if ( item ) + { + QString res = item->text(1 ); + if ( res != m_pView->kPresenterDoc()->backupPath()) + { + config->setGroup( "Kpresenter Path" ); + m_pView->kPresenterDoc()->setBackupPath( res ); +#if KDE_IS_VERSION(3,1,3) + config->writePathEntry( "backup path",res ); +#else + config->writeEntry( "backup path",res ); +#endif + } + } + item = m_pPathView->findItem(i18n("Picture Path"), 0); + if ( item ) + { + QString res = item->text(1 ); + if ( res != m_pView->kPresenterDoc()->picturePath()) + { + config->setGroup( "Kpresenter Path" ); + m_pView->kPresenterDoc()->setPicturePath( res ); +#if KDE_IS_VERSION(3,1,3) + config->writePathEntry( "picture path",res ); +#else + config->writeEntry( "picture path",res ); +#endif + } + } +} + +//// + +KPrConfigureTTSPage::KPrConfigureTTSPage( KPrView *_view, QWidget *parent, char *name ) + : QWidget( parent, name ) +{ + Q_UNUSED(_view); + + QVBoxLayout *box = new QVBoxLayout( this, 0, 0 ); + + m_cbSpeakPointerWidget = new QCheckBox(i18n("Speak widget under &mouse pointer"), this); + m_cbSpeakFocusWidget = new QCheckBox(i18n("Speak widget with &focus"), this); + m_gbScreenReaderOptions = new QVGroupBox("", this); + box->add(m_cbSpeakPointerWidget); + box->add(m_cbSpeakFocusWidget); + box->add(m_gbScreenReaderOptions); + m_gbScreenReaderOptions->setMargin( KDialog::marginHint() ); + m_gbScreenReaderOptions->setInsideSpacing( KDialog::spacingHint() ); + m_cbSpeakTooltips = new QCheckBox(i18n("Speak &tool tips"), m_gbScreenReaderOptions); + m_cbSpeakWhatsThis = new QCheckBox(i18n("Speak &What's This?"), m_gbScreenReaderOptions); + m_cbSpeakDisabled = new QCheckBox(i18n("Verbal indication if widget is disabled (grayed)", + "&Say whether disabled"), m_gbScreenReaderOptions); + m_cbSpeakAccelerators = new QCheckBox(i18n("Spea&k accelerators"), m_gbScreenReaderOptions); + QHBox* hbAcceleratorPrefix = new QHBox(m_gbScreenReaderOptions); + QWidget* spacer = new QWidget(hbAcceleratorPrefix); + spacer->setMinimumWidth(2 * KDialog::marginHint()); + m_lblAcceleratorPrefix = + new QLabel(i18n("A word spoken before another word", "Pr&efaced by the word:"), + hbAcceleratorPrefix); + m_leAcceleratorPrefixWord = new QLineEdit(i18n("Keyboard accelerator, such as Alt+F", "Accelerator"), + hbAcceleratorPrefix); + m_lblAcceleratorPrefix->setBuddy(m_leAcceleratorPrefixWord); + QHBox* hbPollingInterval = new QHBox(m_gbScreenReaderOptions); + hbPollingInterval->setMargin( 0 ); + QLabel* lblPollingInterval = new QLabel(i18n("&Polling interval:"), hbPollingInterval); + m_iniPollingInterval = new KIntNumInput(hbPollingInterval); + m_iniPollingInterval->setSuffix(" ms"); + m_iniPollingInterval->setRange(100, 5000, 100, true); + lblPollingInterval->setBuddy(m_iniPollingInterval); + + config = KPrFactory::global()->config(); + config->setGroup("TTS"); + m_cbSpeakPointerWidget->setChecked(config->readBoolEntry("SpeakPointerWidget", false)); + m_cbSpeakFocusWidget->setChecked(config->readBoolEntry("SpeakFocusWidget", false)); + m_cbSpeakTooltips->setChecked(config->readBoolEntry("SpeakTooltips", true)); + m_cbSpeakWhatsThis->setChecked(config->readBoolEntry("SpeakWhatsThis", false)); + m_cbSpeakDisabled->setChecked(config->readBoolEntry("SpeakDisabled", true)); + m_cbSpeakAccelerators->setChecked(config->readBoolEntry("SpeakAccelerators", true)); + m_leAcceleratorPrefixWord->setText(config->readEntry("AcceleratorPrefixWord", + i18n("Keyboard accelerator, such as Alt+F", "Accelerator"))); + m_iniPollingInterval->setValue(config->readNumEntry("PollingInterval", 600)); + + screenReaderOptionChanged(); + connect(m_cbSpeakPointerWidget, SIGNAL(toggled(bool)), this, SLOT(screenReaderOptionChanged())); + connect(m_cbSpeakFocusWidget, SIGNAL(toggled(bool)), this, SLOT(screenReaderOptionChanged())); + connect(m_cbSpeakAccelerators, SIGNAL(toggled(bool)), this, SLOT(screenReaderOptionChanged())); +} + +void KPrConfigureTTSPage::slotDefault() +{ + m_cbSpeakPointerWidget->setChecked(false); + m_cbSpeakFocusWidget->setChecked(false); + m_cbSpeakTooltips->setChecked(true); + m_cbSpeakWhatsThis->setChecked(false); + m_cbSpeakDisabled->setChecked(true); + m_cbSpeakAccelerators->setChecked(true); + m_leAcceleratorPrefixWord->setText(i18n("Keyboard accelerator, such as Alt+F", "Accelerator")); + m_iniPollingInterval->setValue(600); +} + +void KPrConfigureTTSPage::apply() +{ + config->setGroup("TTS"); + config->writeEntry("SpeakPointerWidget", m_cbSpeakPointerWidget->isChecked()); + config->writeEntry("SpeakFocusWidget", m_cbSpeakFocusWidget->isChecked()); + config->writeEntry("SpeakTooltips", m_cbSpeakTooltips->isChecked()); + config->writeEntry("SpeakWhatsThis", m_cbSpeakWhatsThis->isChecked()); + config->writeEntry("SpeakDisabled", m_cbSpeakDisabled->isChecked()); + config->writeEntry("SpeakAccelerators", m_cbSpeakAccelerators->isChecked()); + config->writeEntry("AcceleratorPrefixWord", m_leAcceleratorPrefixWord->text()); + config->writeEntry("PollingInterval", m_iniPollingInterval->value()); + if (kospeaker) kospeaker->readConfig(config); +} + +void KPrConfigureTTSPage::screenReaderOptionChanged() +{ + m_gbScreenReaderOptions->setEnabled( + m_cbSpeakPointerWidget->isChecked() | m_cbSpeakFocusWidget->isChecked()); + m_leAcceleratorPrefixWord->setEnabled(m_cbSpeakAccelerators->isChecked()); + m_lblAcceleratorPrefix->setEnabled(m_cbSpeakAccelerators->isChecked()); +} + +#include "KPrConfig.moc" diff --git a/kpresenter/KPrConfig.h b/kpresenter/KPrConfig.h new file mode 100644 index 00000000..da99cf44 --- /dev/null +++ b/kpresenter/KPrConfig.h @@ -0,0 +1,228 @@ +// -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*- +/* This file is part of the KDE project + Copyright (C) 1998, 1999 Reginald Stadlbauer + Copyright (C) 2005 Thorsten Zachmann + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#ifndef __kpresenter_dlg_config__ +#define __kpresenter_dlg_config__ + +#include + +class KPrView; +class KPrDocument; +class KIntNumInput; +class KColorButton; +class KConfig; +class QCheckBox; +class KLineEdit; +class KDoubleNumInput; +class KoSpellConfigWidget; +class KPrPenStyleWidget; +class KPrBrushProperty; +class KPrRectProperty; +class KPrPolygonProperty; +class KPrPieProperty; +class KoUnitDoubleSpinBox; +class QVGroupBox; + +namespace KSpell2 { + class ConfigWidget; +} + + +class KPrConfigureInterfacePage : public QWidget +{ + Q_OBJECT +public: + KPrConfigureInterfacePage( KPrView *_view, QWidget *parent = 0, char *name = 0 ); + void apply(); + void slotDefault(); +private: + KPrView* m_pView; + KConfig* config; + int oldNbRecentFiles; + KDoubleNumInput* indent; + KIntNumInput* recentFiles; + QCheckBox *showRuler, *showStatusBar; +}; + +class KPrConfigureColorBackground : public QWidget +{ + Q_OBJECT +public: + KPrConfigureColorBackground( KPrView* _view, QWidget *parent = 0, char *name = 0 ); + void apply(); + void slotDefault(); +protected: + KPrView* m_pView; + KColorButton* bgColor; + KColorButton* gridColor; + KConfig* config; + QColor oldBgColor; + QColor oldGridColor; +} ; + +class KPrConfigureSpellPage : public QWidget +{ + Q_OBJECT +public: + KPrConfigureSpellPage( KPrView *_view, QWidget *parent, char *name = 0 ); + void apply(); + void slotDefault(); +private: + KPrView* m_pView; + KSpell2::ConfigWidget *m_spellConfigWidget; + KConfig* config; +}; + +class KPrConfigureMiscPage : public QWidget +{ + Q_OBJECT +public: + KPrConfigureMiscPage( KPrView *_view, QWidget *parent, char *name = 0 ); + KCommand *apply(); + void slotDefault(); +private: + KPrView* m_pView; + KConfig* config; + KIntNumInput* m_undoRedoLimit; + int m_oldNbRedo; + bool m_printNotes; + QCheckBox* m_displayLink, *m_displayComment, *m_underlineLink, *m_displayFieldCode, *m_cbPrintNotes; + KoUnitDoubleSpinBox * resolutionY, * resolutionX; + KDoubleNumInput *m_rotation; +}; + +class KPrConfigureDefaultDocPage : public QWidget +{ + Q_OBJECT +public: + KPrConfigureDefaultDocPage( KPrView *_view, QWidget *parent, char *name = 0 ); + ~KPrConfigureDefaultDocPage(); + KCommand *apply(); + void slotDefault(); +public slots: + void selectNewDefaultFont(); +private: + int oldAutoSaveValue; + int m_oldStartingPage; + double m_oldTabStopWidth; + bool m_oldBackupFile; + QString m_oldLanguage; + KPrView* m_pView; + KConfig* config; + QFont *font; + QLabel *fontName; + KIntNumInput* autoSave; + KIntNumInput* m_variableNumberOffset; + KoUnitDoubleSpinBox *m_tabStopWidth; + QCheckBox *m_cursorInProtectedArea; + QCheckBox *m_createBackupFile; + QCheckBox *m_directInsertCursor; + QComboBox *m_globalLanguage; + QCheckBox *m_autoHyphenation; + bool m_oldHyphenation; +}; + +class KPrConfigureToolsPage : public QWidget +{ + Q_OBJECT +public: + KPrConfigureToolsPage( KPrView *_view, QWidget *parent, char *name = 0 ); + ~KPrConfigureToolsPage(); + void apply(); + void slotDefault(); +public slots: + +private: + KPrView* m_pView; + KConfig* config; + + KPrPenStyleWidget *m_confPenDia; + KPrBrushProperty *m_brushProperty; + KPrRectProperty *m_rectProperty; + KPrPolygonProperty *m_polygonProperty; + KPrPieProperty *m_pieProperty; +}; + +class KPrConfigurePathPage : public QWidget +{ + Q_OBJECT +public: + KPrConfigurePathPage( KPrView *_view, QWidget *parent, char *name = 0 ); + void slotDefault(); + void apply(); +private slots: + void slotModifyPath(); + void slotSelectionChanged(QListViewItem *); +private: + KPrView* m_pView; + KConfig* config; + KListView* m_pPathView; + QPushButton *m_modifyPath; +}; + +class KPrConfigureTTSPage : public QWidget +{ + Q_OBJECT +public: + KPrConfigureTTSPage( KPrView *_view, QWidget *parent, char *name = 0 ); + void slotDefault(); + void apply(); +private slots: + void screenReaderOptionChanged(); +private: + KConfig* config; + QCheckBox* m_cbSpeakPointerWidget; + QCheckBox* m_cbSpeakFocusWidget; + QVGroupBox* m_gbScreenReaderOptions; + QCheckBox* m_cbSpeakTooltips; + QCheckBox* m_cbSpeakWhatsThis; + QCheckBox* m_cbSpeakDisabled; + QCheckBox* m_cbSpeakAccelerators; + QLabel* m_lblAcceleratorPrefix; + QLineEdit* m_leAcceleratorPrefixWord; + KIntNumInput* m_iniPollingInterval; +}; + + +class KPrConfig : public KDialogBase +{ + Q_OBJECT +public: + enum { KP_INTERFACE = 1, KP_COLOR=2, KP_KSPELL=4,KP_MISC=8, KP_DOC=16, KP_TOOLS=32,KP_PATH = 64 }; + KPrConfig( KPrView* parent ); +public slots: + void slotApply(); + void slotDefault(); + void openPage(int flags); +private: + KPrConfigureInterfacePage *_interfacePage; + KPrConfigureColorBackground *_colorBackground; + KPrConfigureSpellPage *_spellPage; + KPrConfigureMiscPage *_miscPage; + KPrConfigureDefaultDocPage *_defaultDocPage; + KPrConfigureToolsPage *_toolsPage; + KPrConfigurePathPage *m_pathPage; + KPrConfigureTTSPage *m_ttsPage; + KPrDocument* m_doc; + +}; + +#endif diff --git a/kpresenter/KPrCubicBezierCurveObjectIface.cpp b/kpresenter/KPrCubicBezierCurveObjectIface.cpp new file mode 100644 index 00000000..169cce6f --- /dev/null +++ b/kpresenter/KPrCubicBezierCurveObjectIface.cpp @@ -0,0 +1,65 @@ +// -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*- +/* This file is part of the KDE project + Copyright (C) 2002 Laurent MONTEL + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#include "KPrCubicBezierCurveObjectIface.h" +#include "KPrBezierCurveObject.h" +#include "KPrUtils.h" +#include + +#include +#include + +KPrCubicBezierCurveObjectIface::KPrCubicBezierCurveObjectIface( KPrCubicBezierCurveObject *_obj ) + : KPrObjectIface(_obj) +{ + obj = _obj; +} + +void KPrCubicBezierCurveObjectIface::setLineBegin( const QString & type) +{ + obj->setLineBegin(lineEndBeginFromString( type )); +} + +void KPrCubicBezierCurveObjectIface::setLineEnd( const QString & type) +{ + obj->setLineEnd(lineEndBeginFromString( type )); +} + +QString KPrCubicBezierCurveObjectIface::lineBegin()const +{ + LineEnd type=obj->getLineBegin(); + return lineEndBeginName( type ); +} + +QString KPrCubicBezierCurveObjectIface::lineEnd() const +{ + LineEnd type=obj->getLineEnd(); + return lineEndBeginName( type ); +} + +void KPrCubicBezierCurveObjectIface::horizontalFlip() +{ + obj->flip( true ); +} + +void KPrCubicBezierCurveObjectIface::verticalFlip() +{ + obj->flip( false ); +} diff --git a/kpresenter/KPrCubicBezierCurveObjectIface.h b/kpresenter/KPrCubicBezierCurveObjectIface.h new file mode 100644 index 00000000..771e3d1f --- /dev/null +++ b/kpresenter/KPrCubicBezierCurveObjectIface.h @@ -0,0 +1,50 @@ +// -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*- +/* This file is part of the KDE project + Copyright (C) 2002 Laurent MONTEL + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#ifndef KPCUBIC_OBJECT_IFACE_H +#define KPCUBIC_OBJECT_IFACE_H + +#include +#include +#include "KPrObjectIface.h" +#include + +class KPrCubicBezierCurveObject; + +class KPrCubicBezierCurveObjectIface : public KPrObjectIface +{ + K_DCOP +public: + KPrCubicBezierCurveObjectIface( KPrCubicBezierCurveObject *obj_ ); + +k_dcop: + + void setLineBegin( const QString & ); + void setLineEnd( const QString & ); + QString lineBegin()const; + QString lineEnd() const; + void horizontalFlip(); + void verticalFlip(); + +private: + KPrCubicBezierCurveObject *obj; +}; + +#endif diff --git a/kpresenter/KPrCustomSlideShowDia.cpp b/kpresenter/KPrCustomSlideShowDia.cpp new file mode 100644 index 00000000..004652b9 --- /dev/null +++ b/kpresenter/KPrCustomSlideShowDia.cpp @@ -0,0 +1,461 @@ +/* This file is part of the KDE project + Copyright (C) 2004 Laurent Montel + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "KPrPage.h" +#include "KPrDocument.h" +#include "KPrView.h" + +#include "KPrCustomSlideShowDia.h" + + +KPrCustomSlideShowDia::KPrCustomSlideShowDia( KPrView* _view, KPrDocument *_doc, const char* name ) + : KDialogBase( _view, name, true, i18n("Custom Slide Show"), Ok|Cancel ), m_doc( _doc ), m_view( _view ) + , m_customSlideShowMap( m_doc->customSlideShows() ) +{ + QWidget* page = new QWidget( this ); + setMainWidget( page ); + + QGridLayout *grid1 = new QGridLayout( page,10,3,KDialog::marginHint(), KDialog::spacingHint()); + + list=new QListBox(page); + grid1->addMultiCellWidget(list,0,8,0,0); + + m_pAdd=new QPushButton(i18n("&Add..."),page); + grid1->addWidget(m_pAdd,1,2); + + m_pModify=new QPushButton(i18n("&Modify..."),page); + grid1->addWidget(m_pModify,2,2); + + m_pRemove=new QPushButton(i18n("&Remove"),page); + grid1->addWidget(m_pRemove,3,2); + + m_pCopy=new QPushButton(i18n("Co&py"),page); + grid1->addWidget(m_pCopy,4,2); + + m_pTest=new QPushButton(i18n("Test"),page); + grid1->addWidget(m_pTest,5,2); + + + connect( m_pRemove, SIGNAL( clicked() ), this, SLOT( slotRemove() ) ); + connect( m_pAdd, SIGNAL( clicked() ), this, SLOT( slotAdd() ) ); + connect( m_pModify, SIGNAL( clicked() ), this, SLOT( slotModify() ) ); + connect( m_pCopy, SIGNAL( clicked() ), this, SLOT( slotCopy() ) ); + connect( m_pTest, SIGNAL( clicked() ), this, SLOT( slotTest() ) ); + + connect( list, SIGNAL(doubleClicked(QListBoxItem *)),this,SLOT(slotDoubleClicked(QListBoxItem *))); + connect( list, SIGNAL(clicked ( QListBoxItem * )),this,SLOT(slotTextClicked(QListBoxItem * ))); + + connect( m_view, SIGNAL( presentationFinished() ), this, SLOT( slotPresentationFinished() ) ); + + init(); + updateButton(); + + resize( 600, 250 ); + + m_bChanged=false; +} + + +KPrCustomSlideShowDia::~KPrCustomSlideShowDia() +{ + kdDebug()<<"KPrCustomSlideShowDia::~KPrCustomSlideShowDia()********************\n"; +} + +void KPrCustomSlideShowDia::init() +{ + CustomSlideShowMap::ConstIterator it( m_customSlideShowMap.begin() ); + for ( ; it != m_customSlideShowMap.end(); ++it ) + { + list->insertItem( it.key() ); + } +} + +void KPrCustomSlideShowDia::updateButton() +{ + bool state = ( list->currentItem() >= 0 ); + m_pRemove->setEnabled( state ); + m_pModify->setEnabled( state ); + m_pCopy->setEnabled( state ); + m_pTest->setEnabled( state ); +} + +void KPrCustomSlideShowDia::slotTextClicked(QListBoxItem*) +{ + updateButton(); +} + +void KPrCustomSlideShowDia::slotDoubleClicked(QListBoxItem *) +{ + updateButton(); + slotModify(); +} + +void KPrCustomSlideShowDia::slotPresentationFinished() +{ + kdDebug()<<"void KPrCustomSlideShowDia::slotPresentationFinished()*************************\n"; + show(); +} + + +void KPrCustomSlideShowDia::hideEvent( QHideEvent* ) +{ +} + +void KPrCustomSlideShowDia::slotTest() +{ + QListBoxItem *item = list->selectedItem(); + if ( item ) + { + m_doc->testCustomSlideShow( m_customSlideShowMap[item->text()], m_view ); + hide(); + } +} + +void KPrCustomSlideShowDia::slotAdd() +{ + QStringList listCustomName; + CustomSlideShowMap::Iterator it( m_customSlideShowMap.begin() ) ; + for ( ; it != m_customSlideShowMap.end(); ++it ) + { + listCustomName.append( it.key() ); + } + + KPrDefineCustomSlideShow * dlg = new KPrDefineCustomSlideShow( this, listCustomName, m_doc->getPageList() ); + if ( dlg->exec() ) + { + //insert new element + m_customSlideShowMap.insert( dlg->customSlideShowName(), dlg->customSlides() ); + list->insertItem( dlg->customSlideShowName() ); + updateButton(); + } + delete dlg; + +} + +void KPrCustomSlideShowDia::slotRemove() +{ + if (list->selectedItem() ) + { + m_customSlideShowMap.remove( list->selectedItem()->text() ); + list->removeItem( list->currentItem() ); + updateButton(); + } +} + +void KPrCustomSlideShowDia::slotOk() +{ + m_doc->setCustomSlideShows( m_customSlideShowMap ); + accept(); +} + +void KPrCustomSlideShowDia::slotModify() +{ + QListBoxItem *item = list->selectedItem(); + if ( item ) + { + QStringList listCustomName; + CustomSlideShowMap::ConstIterator it( m_customSlideShowMap.begin() ); + for ( ; it != m_customSlideShowMap.end(); ++it ) + { + if ( it.key() !=item->text() ) + listCustomName.append( it.key() ); + } + + KPrDefineCustomSlideShow * dlg = new KPrDefineCustomSlideShow( this, item->text(), listCustomName, + m_doc->getPageList(), m_customSlideShowMap[item->text()]); + if ( dlg->exec() ) + { + //insert new element + m_customSlideShowMap.remove( list->selectedItem()->text() ); + m_customSlideShowMap.insert( dlg->customSlideShowName(), dlg->customSlides() ); + list->changeItem( dlg->customSlideShowName(), list->currentItem() ); + } + delete dlg; + } + +} + +void KPrCustomSlideShowDia::slotCopy() +{ + QListBoxItem *item = list->selectedItem(); + if ( item ) + { + QString str( list->selectedItem()->text() ); + str+=i18n( "(Copy %1)" ); + for ( int i =1;; ++i ) + { + if ( !uniqueName( i, str ) ) + { + str = str.arg( i ); + m_customSlideShowMap.insert( str, m_customSlideShowMap[item->text()] ); + list->insertItem( str ); + break; + } + } + } +} + +bool KPrCustomSlideShowDia::uniqueName( int val, const QString & name ) const +{ + QString str = name.arg( val ); + for ( int i= 0; i < ( int )list->count(); ++i ) + { + if ( list->text ( i ) == str ) + return true; + } + return false; +} + + +KPrCustomSlideShowItem::KPrCustomSlideShowItem( QListBox * listbox, KPrPage * page ) +: QListBoxText( listbox, page->pageTitle() ) +, m_page( page ) +{ +} + +KPrCustomSlideShowItem::KPrCustomSlideShowItem( KPrPage * page ) +: QListBoxText( page->pageTitle() ) +, m_page( page ) +{ +} + +KPrCustomSlideShowItem::KPrCustomSlideShowItem( QListBox * listbox, KPrPage * page, QListBoxItem * after ) +: QListBoxText( listbox, page->pageTitle(), after ) +, m_page( page ) +{ +} + +KPrDefineCustomSlideShow::KPrDefineCustomSlideShow( QWidget* parent, QStringList &_listNameSlideShow, + const QPtrList &pages, const char *name ) +: KDialogBase( parent, name, true, i18n("Define Custom Slide Show"), Ok|Cancel ) +, listNameCustomSlideShow( _listNameSlideShow ) +{ + init(); + for ( QPtrList::ConstIterator it = pages.begin(); it != pages.end(); ++it ) + { + listSlide->insertItem( new KPrCustomSlideShowItem( *it ) ); + } +} + +KPrDefineCustomSlideShow::KPrDefineCustomSlideShow( QWidget* parent, const QString &_customName, QStringList &_listNameSlideShow, + const QPtrList &pages, QValueList &customPages, const char* name ) +: KDialogBase( parent, name, true, i18n("Define Custom Slide Show"), Ok|Cancel ) +, listNameCustomSlideShow( _listNameSlideShow ) +{ + init(); + m_name->setText( _customName ); + for ( QPtrList::ConstIterator it = pages.begin(); it != pages.end(); ++it ) + { + listSlide->insertItem( new KPrCustomSlideShowItem( *it ) ); + } + for ( QValueList::ConstIterator it = customPages.begin(); it != customPages.end(); ++it ) + { + listSlideShow->insertItem( new KPrCustomSlideShowItem( *it ) ); + } +} + +void KPrDefineCustomSlideShow::init() +{ + QWidget* page = new QWidget( this ); + setMainWidget( page ); + + QVBoxLayout *lov = new QVBoxLayout( page ); + lov->setSpacing( KDialog::spacingHint() ); + QHBoxLayout *loh = new QHBoxLayout( lov ); + + QLabel *lab = new QLabel( i18n( "Name:" ), page ); + loh->addWidget( lab ); + m_name = new QLineEdit( page ); + loh->addWidget( m_name ); + + QHBoxLayout *lo = new QHBoxLayout( lov ); + lo->setSpacing( KDialog::spacingHint() ); + + QVBoxLayout *loAv = new QVBoxLayout( lo ); + lab = new QLabel( i18n("Existing slides:"), page ); + loAv->addWidget( lab ); + listSlide = new QListBox( page ); + loAv->addWidget( listSlide ); + lab->setBuddy( listSlide ); + + QVBoxLayout *loHBtns = new QVBoxLayout( lo ); + loHBtns->addStretch( 1 ); + m_insertSlide = new QToolButton( page ); + loHBtns->addWidget( m_insertSlide ); + m_removeSlide = new QToolButton( page ); + loHBtns->addWidget( m_removeSlide ); + loHBtns->addStretch( 1 ); + + QVBoxLayout *loS = new QVBoxLayout( lo ); + lab = new QLabel( i18n("Selected slides:"), page ); + loS->addWidget( lab ); + listSlideShow = new QListBox( page ); + loS->addWidget( listSlideShow ); + lab->setBuddy( listSlideShow ); + + QVBoxLayout *loVBtns = new QVBoxLayout( lo ); + loVBtns->addStretch( 1 ); + m_moveUpSlide = new QToolButton( page ); + m_moveUpSlide->setAutoRepeat( true ); + loVBtns->addWidget( m_moveUpSlide ); + m_moveDownSlide = new QToolButton( page ); + m_moveDownSlide->setAutoRepeat( true ); + loVBtns->addWidget( m_moveDownSlide ); + loVBtns->addStretch( 1 ); + + + m_name->setFocus(); + + connect( m_insertSlide, SIGNAL(clicked()), this, SLOT(slotMoveInsertSlide() ) ); + connect( m_removeSlide, SIGNAL(clicked()), this, SLOT(slotMoveRemoveSlide()) ); + connect( m_moveUpSlide, SIGNAL(clicked()), this, SLOT( slotMoveUpSlide() ) ); + connect( m_moveDownSlide, SIGNAL(clicked()), this, SLOT(slotMoveDownSlide()) ); + connect( m_name, SIGNAL( textChanged ( const QString & ) ), this, SLOT( slideNameChanged( const QString & ) ) ); + connect( listSlideShow, SIGNAL( clicked ( QListBoxItem * ) ), this, SLOT( updateButton() ) ); + connect( listSlide, SIGNAL( clicked ( QListBoxItem * ) ), this, SLOT( updateButton() ) ); + connect( listSlide, SIGNAL( doubleClicked ( QListBoxItem * ) ), this, SLOT( slotMoveInsertSlide() ) ); + connect( listSlideShow, SIGNAL( doubleClicked( QListBoxItem * ) ), this, SLOT( slotMoveRemoveSlide() ) ); + m_insertSlide->setIconSet( SmallIconSet( ( QApplication::reverseLayout() ? "back" : "forward" ) ) ); + m_removeSlide->setIconSet( SmallIconSet( ( QApplication::reverseLayout() ? "forward" : "back") ) ); + m_moveUpSlide->setIconSet( SmallIconSet( "up" ) ); + m_moveDownSlide->setIconSet( SmallIconSet( "down" ) ); + + slideNameChanged( m_name->text() ); + updateButton(); + resize( 600, 250 ); + +} + +void KPrDefineCustomSlideShow::slideNameChanged( const QString & _name) +{ + enableButtonOK( !_name.isEmpty() ); +} + +void KPrDefineCustomSlideShow::updateButton() +{ + int pos = listSlideShow->currentItem(); + m_moveUpSlide->setEnabled( pos>0 ); + m_moveDownSlide->setEnabled( pos< (( int ) listSlideShow->count()-1 ) ); + m_removeSlide->setEnabled( listSlideShow->count()>0 ); + m_insertSlide->setEnabled( listSlide->currentItem()>-1 ); +} + +void KPrDefineCustomSlideShow::slotMoveUpSlide() +{ + int c = listSlideShow->currentItem(); + if ( c < 1 ) return; + QListBoxItem *item = listSlideShow->item( c ); + listSlideShow->takeItem( item ); + listSlideShow->insertItem( item, c-1 ); + listSlideShow->setCurrentItem( item ); + + updateButton(); +} + +void KPrDefineCustomSlideShow::slotMoveDownSlide() +{ + int c = listSlideShow->currentItem(); + if ( c < 0 || c == int( listSlideShow->count() ) - 1 ) return; + QListBoxItem *item = listSlideShow->item( c ); + listSlideShow->takeItem( item ); + listSlideShow->insertItem( item, c+1 ); + listSlideShow->setCurrentItem( item ); + updateButton(); +} + +void KPrDefineCustomSlideShow::slotMoveRemoveSlide() +{ + // move all selected items from selected to available listbox + QListBoxItem *item = listSlideShow->firstItem(); + while ( item ) { + if ( item->isSelected() ) { + listSlideShow->takeItem( item ); + } + item = item->next(); + } + updateButton(); +} + +void KPrDefineCustomSlideShow::slotMoveInsertSlide() +{ + QListBoxItem *item = listSlide->firstItem(); + while ( item ) { + if ( item->isSelected() ) { + KPrCustomSlideShowItem * i = dynamic_cast( item ); + if ( i ) + { + listSlideShow->insertItem( new KPrCustomSlideShowItem( i->getPage() ), ( listSlideShow->count() ) ); + } + } + item = item->next(); + } + listSlideShow->setFocus(); + updateButton(); +} + +QValueList KPrDefineCustomSlideShow::customSlides() +{ + QValueList pages; + QListBoxItem *item = listSlideShow->firstItem(); + while ( item ) + { + KPrCustomSlideShowItem * i = dynamic_cast( item ); + if ( i ) + { + pages.push_back( i->getPage() ); + } + item = item->next(); + } + return pages; +} + +QString KPrDefineCustomSlideShow::customSlideShowName() const +{ + return m_name->text(); +} + + +void KPrDefineCustomSlideShow::slotOk() +{ + if ( listNameCustomSlideShow.contains( m_name->text() ) ) + { + KMessageBox::error(this, i18n("Custom Slide Show name is already used."), i18n("Define Custom Slide Show")); + } + else + { + if ( listSlideShow->count() == 0 ) + KMessageBox::error(this, i18n("You did not select any slides. Please select some slides."), i18n("Define Custom Slide Show")); + else + accept(); + } +} + +#include "KPrCustomSlideShowDia.moc" diff --git a/kpresenter/KPrCustomSlideShowDia.h b/kpresenter/KPrCustomSlideShowDia.h new file mode 100644 index 00000000..203405bd --- /dev/null +++ b/kpresenter/KPrCustomSlideShowDia.h @@ -0,0 +1,117 @@ +/* This file is part of the KDE project + Copyright (C) 2004 Laurent Montel + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#ifndef __CUSTOM_SLIDE_SHOW__ +#define __CUSTOM_SLIDE_SHOW__ + +#include +#include +#include "global.h" + +class QLineEdit; +class QPushButton; +class KPrDocument; +class QToolButton; +class KPrView; +class KPrPage; + +class KPrCustomSlideShowDia : public KDialogBase +{ + Q_OBJECT + +public: + KPrCustomSlideShowDia( KPrView* _view, KPrDocument *_doc, const char* name ); + ~KPrCustomSlideShowDia(); +public slots: + virtual void slotOk(); + void slotDoubleClicked(QListBoxItem *); + void slotTextClicked(QListBoxItem*); + void slotRemove(); + void slotAdd(); + void slotModify(); + void slotCopy(); + void slotTest(); + void slotPresentationFinished(); + +protected: + void hideEvent( QHideEvent* ); + + void init(); + void updateButton(); + bool uniqueName( int val, const QString & name ) const; + + QListBox * list; + QPushButton* m_pRemove; + QPushButton* m_pAdd; + QPushButton* m_pModify; + QPushButton* m_pCopy; + QPushButton* m_pTest; + bool m_bChanged; + KPrDocument *m_doc; + KPrView *m_view; + CustomSlideShowMap m_customSlideShowMap; + QStringList listPageName; +}; + +class KPrCustomSlideShowItem : public QListBoxText +{ +public: + KPrCustomSlideShowItem( QListBox * listbox, KPrPage * page ); + KPrCustomSlideShowItem( KPrPage * page ); + KPrCustomSlideShowItem( QListBox * listbox, KPrPage * page, QListBoxItem * after ); + + KPrPage * getPage() { return m_page; } +private: + KPrPage * m_page; +}; + +class KPrDefineCustomSlideShow : public KDialogBase +{ + Q_OBJECT +public: + KPrDefineCustomSlideShow( QWidget* parent, QStringList &_listNameSlideShow, const QPtrList &pages, const char *name = 0L); + KPrDefineCustomSlideShow( QWidget* parent, const QString &_customName, QStringList &_listNameSlideShow, + const QPtrList &pages, QValueList &customPages, const char* name = 0L ); + + QString customSlideShowName() const; + QValueList customSlides(); + +protected slots: + void slotMoveUpSlide(); + void slotMoveDownSlide(); + void slotMoveRemoveSlide(); + void slotMoveInsertSlide(); + void slideNameChanged( const QString & _name); + void updateButton(); + virtual void slotOk(); + +protected: + void init(); + QStringList listNameCustomSlideShow; + QListBox *listSlide; + QListBox *listSlideShow; + QToolButton *m_insertSlide; + QToolButton *m_removeSlide; + QToolButton *m_moveUpSlide; + QToolButton *m_moveDownSlide; + QLineEdit *m_name; + +}; + +#endif diff --git a/kpresenter/KPrDocument.cpp b/kpresenter/KPrDocument.cpp new file mode 100644 index 00000000..595f4981 --- /dev/null +++ b/kpresenter/KPrDocument.cpp @@ -0,0 +1,4857 @@ +/* This file is part of the KDE project + Copyright (C) 1998, 1999 Reginald Stadlbauer + Copyright (C) 2005-2006 Thorsten Zachmann + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#include "KPrDocument.h" +#include "KPrView.h" +#include "KPrCanvas.h" +#include "KPrPage.h" +#include "KPrObject.h" +#include "KPrLineObject.h" +#include "KPrRectObject.h" +#include "KPrEllipseObject.h" +#include "KPrAutoformObject.h" +#include "KPrTextObject.h" +#include "KPrTextDocument.h" +#include "KPrPixmapObject.h" +#include "KPrPieObject.h" +#include "KPrPartObject.h" +#include "KPrGroupObject.h" +#include "KPrCommand.h" +#include "insertpagedia.h" +#include "KPrFreehandObject.h" +#include "KPrPolylineObject.h" +#include "KPrBezierCurveObject.h" +#include "KPrPolygonObject.h" +#include "KPrClosedLineObject.h" +#include "KPrSVGPathParser.h" + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include "KPrDocumentIface.h" + +#include + +#include +#include +#include +#include "KPrVariableCollection.h" +#include "KPrBackground.h" +#include "KPrNoteBar.h" +#include "KPrBgSpellCheck.h" +#include +#include +#include "KoApplication.h" +#include +#include + +#include "KPrLoadingInfo.h" + +using namespace std; + +static const int CURRENT_SYNTAX_VERSION = 2; +// Make sure an appropriate DTD is available in www/koffice/DTD if changing this value +static const char * CURRENT_DTD_VERSION = "1.2"; + +KPrChild::KPrChild( KPrDocument *_kpr, KoDocument* _doc, const QRect& _rect ) + : KoDocumentChild( _kpr, _doc, _rect ) +{ + m_parent = _kpr; +} + +KPrChild::KPrChild( KPrDocument *_kpr ) : + KoDocumentChild( _kpr ) +{ + m_parent = _kpr; +} + +KPrChild::~KPrChild() +{ +} + +KoDocument *KPrChild::hitTest( const QPoint &, const QWMatrix & ) +{ + // hitTest functionality is disabled because kpresenter handles activation + // of embedded parts by itself. See KPrPartObject::activate(). + return 0; +} + +KPrDocument::KPrDocument( QWidget *parentWidget, const char *widgetName, QObject* parent, const char* name, + bool singleViewMode ) + : KoDocument( parentWidget,widgetName, parent, name, singleViewMode ), + _gradientCollection(), m_customListTest( 0L ), + m_childCountBeforeInsert( 0 ) +{ + setInstance( KPrFactory::global() ); + setTemplateType( "kpresenter_template" ); + //Necessary to define page where we load object otherwise copy-duplicate page doesn't work. + m_pageWhereLoadObject=0L; + m_loadingInfo=0L; + m_tabStop = MM_TO_POINT( 15.0 ); + m_styleColl=new KoStyleCollection(); + m_insertFilePage = 0; + m_picturePath= KGlobalSettings::documentPath(); + m_globalLanguage = KGlobal::locale()->language(); + m_bGlobalHyphenation = false; + _duplicatePage=false; + + KoParagStyle* m_standardStyle = new KoParagStyle( "Standard" ); + m_styleColl->addStyle( m_standardStyle ); + + KConfig *config = KPrFactory::global()->config(); + config->setGroup("Document defaults" ); + QString defaultFontname=config->readEntry("DefaultFont"); + if ( !defaultFontname.isEmpty() ) + m_defaultFont.fromString( defaultFontname ); + // If not found, we automatically fallback to the application font (the one from KControl's font module) + + // Try to force a scalable font. + m_defaultFont.setStyleStrategy( QFont::ForceOutline ); + //kdDebug(33001) << "Default font: requested family: " << m_defaultFont.family() << endl; + //kdDebug(33001) << "Default font: real family: " << QFontInfo(m_defaultFont).family() << endl; + + int ptSize = m_defaultFont.pointSize(); + if ( ptSize == -1 ) // specified with a pixel size ? + ptSize = QFontInfo(m_defaultFont).pointSize(); + //kdDebug(33001) << "KPrDocument::KPrDocument[2] ptSize=" << ptSize << endl; + // Ok, this is KPresenter. A default font of 10 makes no sense. Let's go for 20. + ptSize = QMAX( 20, ptSize ); + + m_standardStyle->format().setFont( m_defaultFont ); + + /// KPresenter isn't color-scheme aware, it defaults to black on white. + m_standardStyle->format().setColor( Qt::black ); + + if( config->hasGroup("Interface") ) { + config->setGroup( "Interface" ); + m_globalLanguage=config->readEntry("language", KGlobal::locale()->language()); + m_bGlobalHyphenation=config->readBoolEntry("hyphenation", false); + } + + m_standardStyle->format().setLanguage( m_globalLanguage); + + m_zoomHandler = new KoTextZoomHandler; + + m_varFormatCollection = new KoVariableFormatCollection; + m_varColl = new KPrVariableCollection( new KoVariableSettings(), m_varFormatCollection ); + m_bgSpellCheck = new KPrBgSpellCheck(this); + dcop = 0; + m_initialActivePage=0; + m_bShowStatusBar = true; + m_autoFormat = new KoAutoFormat(this,m_varColl,m_varFormatCollection); + _clean = true; + _spInfiniteLoop = false; + _spShowEndOfPresentationSlide = true; + _spManualSwitch = true; + _showPresentationDuration = false; + tmpSoundFileList = QPtrList(); + _xRnd = 20; + _yRnd = 20; + _txtBackCol = lightGray; + _otxtBackCol = lightGray; + + m_bShowRuler=true; + m_bAllowAutoFormat = true; + + m_bViewFormattingChars = false; + m_bShowGuideLines = true; + + m_bShowGrid = true; + + m_bSnapToGrid = true; + + m_cursorInProtectectedArea=true; + + usedSoundFile = QStringList(); + haveNotOwnDiskSoundFile = QStringList(); + + m_zoomHandler->setZoomAndResolution( 100, KoGlobal::dpiX(), KoGlobal::dpiY() ); + newZoomAndResolution(false,false); + + // _pageLayout.format = PG_SCREEN; + // _pageLayout.orientation = PG_PORTRAIT; + // _pageLayout.width = PG_SCREEN_WIDTH; + // _pageLayout.height = PG_SCREEN_HEIGHT; + // _pageLayout.left = 0; + // _pageLayout.right = 0; + // _pageLayout.top = 0; + // _pageLayout.bottom = 0; + // _pageLayout.ptWidth = cMM_TO_POINT( PG_SCREEN_WIDTH ); + // _pageLayout.ptHeight = cMM_TO_POINT( PG_SCREEN_HEIGHT ); + // _pageLayout.ptLeft = 0; + // _pageLayout.ptRight = 0; + // _pageLayout.ptTop = 0; + // _pageLayout.ptBottom = 0; + + m_indent = MM_TO_POINT( 10.0 ); + m_gridX = MM_TO_POINT( 5.0 ); + m_gridY = MM_TO_POINT( 5.0 ); + + oldGridX = m_gridX; + oldGridY = m_gridY; + + m_masterPage=new KPrPage(this); + KPrPage *newpage = new KPrPage( this, m_masterPage ); + m_pageList.insert( 0,newpage); + m_bInsertDirectCursor = false; + + objStartY = 0; + _presPen = QPen( red, 3, SolidLine ); + ignoreSticky = TRUE; + + m_gridColor=Qt::black; + + _header = new KPrTextObject( this ); + _header->setDrawEditRect( false ); + _header->setDrawEmpty( false ); + + _footer = new KPrTextObject( this ); + _footer->setDrawEditRect( false ); + _footer->setDrawEmpty( false ); + + saveOnlyPage = -1; + m_maxRecentFiles = 10; + + connect( QApplication::clipboard(), SIGNAL( dataChanged() ), + this, SLOT( clipboardDataChanged() ) ); + + m_commandHistory = new KoCommandHistory( actionCollection(), true ) ; + initConfig(); + + connect( m_commandHistory, SIGNAL( documentRestored() ), this, SLOT( slotDocumentRestored() ) ); + connect( m_commandHistory, SIGNAL( commandExecuted() ), this, SLOT( slotCommandExecuted() ) ); + + dcopObject(); +} + +void KPrDocument::refreshMenuCustomVariable() +{ + emit sig_refreshMenuCustomVariable(); +} + +void KPrDocument::slotDocumentRestored() +{ + setModified( false ); +} + +void KPrDocument::slotCommandExecuted() +{ + setModified( true ); +} + +void KPrDocument::saveConfig() +{ + if ( !isReadWrite()) + return; + KConfigGroup group( KoGlobal::kofficeConfig(), "Spelling" ); + group.writeEntry( "PersonalDict", m_spellCheckPersonalDict ); + if ( !isEmbedded() ) + { + KConfig *config = KPrFactory::global()->config(); + config->setGroup( "Interface" ); + config->writeEntry( "Zoom", m_zoomHandler->zoom() ); + config->writeEntry( "AllowAutoFormat" , m_bAllowAutoFormat ); + config->writeEntry( "ViewFormattingChars", m_bViewFormattingChars ); + config->writeEntry( "ShowGrid" , m_bShowGrid ); + config->writeEntry( "SnapToGrid" , m_bSnapToGrid ); + config->writeEntry( "ResolutionX", m_gridX ); + config->writeEntry( "ResolutionY", m_gridY ); + } +} + +void KPrDocument::initConfig() +{ + int zoom; + KConfig* config = KPrFactory::global()->config(); + if( config->hasGroup("Interface") ) { + config->setGroup( "Interface" ); + setAutoSave( config->readNumEntry( "AutoSave", defaultAutoSave()/60 ) * 60 ); + setBackupFile( config->readBoolEntry("BackupFile", true)); + setCursorInProtectedArea( config->readBoolEntry( "cursorInProtectArea", true )); + + // Config-file value in mm, default 10 pt + double indent = config->readDoubleNumEntry("Indent", MM_TO_POINT(10.0) ) ; + setIndentValue(indent); + m_maxRecentFiles = config->readNumEntry( "NbRecentFile", 10 ); + setShowRuler(config->readBoolEntry("Rulers",true)); + zoom = config->readNumEntry( "Zoom", 100 ); + setShowStatusBar( config->readBoolEntry( "ShowStatusBar" , true )); + setAllowAutoFormat( config->readBoolEntry( "AllowAutoFormat" , true )); + setViewFormattingChars( config->readBoolEntry( "ViewFormattingChars", false ) ); + setShowGrid( config->readBoolEntry( "ShowGrid" , true )); + setSnapToGrid( config->readBoolEntry( "SnapToGrid", true )); + setGridX( config->readDoubleNumEntry( "ResolutionX", MM_TO_POINT( 5.0 ) )); + setGridY( config->readDoubleNumEntry( "ResolutionY", MM_TO_POINT( 5.0 ) )); + + m_bInsertDirectCursor= config->readBoolEntry( "InsertDirectCursor", false ); + m_globalLanguage=config->readEntry("language", KGlobal::locale()->language()); + + } + else + zoom=100; + + QColor oldBgColor = Qt::white; + QColor oldGridColor = Qt::black; + if ( config->hasGroup( "KPresenter Color" ) ) { + config->setGroup( "KPresenter Color" ); + setTxtBackCol(config->readColorEntry( "BackgroundColor", &oldBgColor )); + setGridColor(config->readColorEntry( "GridColor", &oldGridColor )); + } + + + if( config->hasGroup("KSpell kpresenter" ) ) + { + config->setGroup( "KSpell kpresenter" ); + + // Default is false for spellcheck, but the spell-check config dialog + // should write out "true" when the user configures spell checking. + if ( isReadWrite() ) + m_bgSpellCheck->setEnabled(config->readBoolEntry( "SpellCheck", false )); + else + m_bgSpellCheck->setEnabled( false ); + } + int undo=30; + if(config->hasGroup("Misc" ) ) + { + config->setGroup( "Misc" ); + undo=config->readNumEntry("UndoRedo",-1); + } + if(undo!=-1) + setUndoRedoLimit(undo); + + if(config->hasGroup("Kpresenter Path" ) ) + { + config->setGroup( "Kpresenter Path" ); + m_picturePath=config->readPathEntry( "picture path",KGlobalSettings::documentPath()); + setBackupPath(config->readPathEntry( "backup path" )); + } + + // Load personal dict + KConfigGroup group( KoGlobal::kofficeConfig(), "Spelling" ); + m_spellCheckPersonalDict = group.readListEntry( "PersonalDict" ); + + // Apply configuration, without creating an undo/redo command + replaceObjs( false ); + zoomHandler()->setZoom( zoom ); + newZoomAndResolution(false,false); +} + +DCOPObject* KPrDocument::dcopObject() +{ + if ( !dcop ) + dcop = new KPrDocumentIface( this ); + + return dcop; +} + +KPrDocument::~KPrDocument() +{ + if(isReadWrite()) + saveConfig(); + clearTestCustomSlideShow(); + //Be carefull !!!!!! don't delete this pointer delete in stickypage +#if 0 + delete _header; + delete _footer; +#endif + + delete m_commandHistory; + delete m_zoomHandler; + delete m_autoFormat; + delete m_varColl; + delete m_varFormatCollection; + delete dcop; + delete m_masterPage; + delete m_bgSpellCheck; + delete m_styleColl; + + m_pageList.setAutoDelete( true ); + m_pageList.clear(); + m_deletedPageList.setAutoDelete( true ); + m_deletedPageList.clear(); + tmpSoundFileList.setAutoDelete( true ); + tmpSoundFileList.clear(); +} + +void KPrDocument::addCommand( KCommand * cmd ) +{ + kdDebug(33001) << "KPrDocument::addCommand " << cmd->name() << endl; + m_commandHistory->addCommand( cmd, false ); + setModified( true ); +} + +bool KPrDocument::saveChildren( KoStore* _store ) +{ + int i = 0; + + QPtrListIterator it( children() ); + for( ; it.current(); ++it ) { + // Don't save children that are only in the undo/redo history + // but not anymore in the presentation + QPtrListIterator pageIt( m_pageList ); + for ( int pagePos = 0; pageIt.current(); ++pageIt, ++pagePos ) + { + if ( saveOnlyPage == -1 || pagePos == saveOnlyPage ) + { + QPtrListIterator oIt(pageIt.current()->objectList()); + for (; oIt.current(); ++oIt ) + { + if ( oIt.current()->getType() == OT_PART && + dynamic_cast( oIt.current() )->getChild() == it.current() ) + { + if (((KoDocumentChild*)(it.current()))->document()!=0) + if ( !((KoDocumentChild*)(it.current()))->document()->saveToStore( _store, QString::number( i++ ) ) ) + return false; + } + } + } + } + if ( saveOnlyPage == -1 ) + { + QPtrListIterator oIt(m_masterPage->objectList()); + for (; oIt.current(); ++oIt ) + { + if ( oIt.current()->getType() == OT_PART && + dynamic_cast( oIt.current() )->getChild() == it.current() ) + { + if (((KoDocumentChild*)(it.current()))->document()!=0) + if ( !((KoDocumentChild*)(it.current()))->document()->saveToStore( _store, QString::number( i++ ) ) ) + return false; + } + } + } + } + return true; +} + +QDomDocument KPrDocument::saveXML() +{ + if ( saveOnlyPage == -1 ) { + emit sigProgress( 0 ); + } + + m_varColl->variableSetting()->setModificationDate(QDateTime::currentDateTime()); + recalcVariables( VT_DATE ); + recalcVariables( VT_TIME ); + recalcVariables( VT_STATISTIC ); + QDomDocument doc = createDomDocument( "DOC", CURRENT_DTD_VERSION ); + QDomElement presenter=doc.documentElement(); + presenter.setAttribute("editor", "KPresenter"); + presenter.setAttribute("mime", "application/x-kpresenter"); + presenter.setAttribute("syntaxVersion", CURRENT_SYNTAX_VERSION); + QDomElement paper=doc.createElement("PAPER"); + paper.setAttribute("format", static_cast( m_pageLayout.format )); + paper.setAttribute("ptWidth", QString::number( m_pageLayout.ptWidth, 'g', 10 )); + paper.setAttribute("ptHeight", QString::number( m_pageLayout.ptHeight, 'g', 10 )); + + paper.setAttribute("orientation", static_cast( m_pageLayout.orientation )); + paper.setAttribute("unit", unit() ); + paper.setAttribute("tabStopValue", m_tabStop ); + + QDomElement paperBorders=doc.createElement("PAPERBORDERS"); + + paperBorders.setAttribute("ptLeft", m_pageLayout.ptLeft); + paperBorders.setAttribute("ptTop", m_pageLayout.ptTop); + paperBorders.setAttribute("ptRight", m_pageLayout.ptRight); + paperBorders.setAttribute("ptBottom", m_pageLayout.ptBottom); + paper.appendChild(paperBorders); + presenter.appendChild(paper); + + m_varColl->variableSetting()->save(presenter ); + + presenter.appendChild(saveAttribute( doc )); + + if ( saveOnlyPage == -1 ) + emit sigProgress( 5 ); + + QDomElement element=doc.createElement("BACKGROUND"); + element.appendChild(saveBackground( doc )); + presenter.appendChild(element); + + if ( saveOnlyPage == -1 ) + emit sigProgress( 10 ); + + //TODO save correct page info for header/footer + element=doc.createElement("HEADER"); + element.setAttribute("show", static_cast( m_pageList.at(0)->hasHeader() )); + element.appendChild(_header->save( doc,0 )); + presenter.appendChild(element); + + element=doc.createElement("FOOTER"); + element.setAttribute("show", static_cast( m_pageList.at(0)->hasFooter() )); + element.appendChild(_footer->save( doc,0 )); + presenter.appendChild(element); + + element = doc.createElement( "HEADERFOOTERBYPAGE" ); + element.setAttribute( "value", "true" ); + presenter.appendChild( element ); + + element=doc.createElement("HELPLINES"); + element.setAttribute("show", static_cast( showGuideLines() )); + saveGuideLines( doc, element ); + presenter.appendChild(element); + + if ( saveOnlyPage == -1 ) + { + if( !m_spellCheckIgnoreList.isEmpty() ) + { + QDomElement spellCheckIgnore = doc.createElement( "SPELLCHECKIGNORELIST" ); + presenter.appendChild( spellCheckIgnore ); + for ( QStringList::Iterator it = m_spellCheckIgnoreList.begin(); it != m_spellCheckIgnoreList.end(); ++it ) + { + QDomElement spellElem = doc.createElement( "SPELLCHECKIGNOREWORD" ); + spellCheckIgnore.appendChild( spellElem ); + spellElem.setAttribute( "word", *it ); + } + } + } + + if ( saveOnlyPage == -1 ) + emit sigProgress( 20 ); + + presenter.appendChild(saveTitle( doc )); + + presenter.appendChild(saveNote( doc )); + + if ( saveOnlyPage == -1 ) + emit sigProgress( 30 ); + + presenter.appendChild(saveObjects(doc)); + + // ### If we will create a new version of the file format, fix that spelling error + element=doc.createElement("INFINITLOOP"); + element.setAttribute("value", _spInfiniteLoop); + element=doc.createElement("SHOWENDOFPRESENTATIONSLIDE"); + element.setAttribute("value", _spShowEndOfPresentationSlide); + presenter.appendChild(element); + element=doc.createElement("MANUALSWITCH"); + element.setAttribute("value", _spManualSwitch); + presenter.appendChild(element); + element=doc.createElement("PRESSPEED"); +//TODO FIXME !!!!!!!!!! +//element.setAttribute("value", static_cast( presSpeed )); + presenter.appendChild(element); + element=doc.createElement("SHOWPRESENTATIONDURATION"); + element.setAttribute("value", _showPresentationDuration); + presenter.appendChild(element); + + if ( saveOnlyPage == -1 ) + { + if ( !m_customListSlideShow.isEmpty() ) + { + QMap page2name; + int pos = 1; + for ( QPtrListIterator it( m_pageList ); it.current(); ++it ) + { + page2name.insert( it.current(), "page" + QString::number( pos++ ) ) ; + } + + element = doc.createElement( "CUSTOMSLIDESHOWCONFIG" ); + CustomSlideShowMap::Iterator it; + for ( it = m_customListSlideShow.begin(); it != m_customListSlideShow.end(); ++it ) + { + QDomElement slide=doc.createElement("CUSTOMSLIDESHOW"); + slide.setAttribute("name", it.key() ); + QString tmp; + QValueListIterator itPage ; + for( itPage = ( *it ).begin(); itPage != ( *it ).end(); ++itPage ) + { + int posPage = m_pageList.find( *itPage ); + if ( posPage != -1 ) + { + if ( itPage != ( *it ).begin() ) + tmp += ","; + tmp += page2name[*itPage]; + } + } + slide.setAttribute( "pages", tmp ); + element.appendChild(slide); + } + presenter.appendChild(element); + + } + + if ( !m_presentationName.isEmpty() ) + { + element = doc.createElement( "DEFAULTCUSTOMSLIDESHOWNAME" ); + element.setAttribute( "name", m_presentationName ); + presenter.appendChild(element); + } + } + + if ( saveOnlyPage == -1 ) + emit sigProgress( 40 ); + + if ( saveOnlyPage == -1 ) + { + element=doc.createElement("SELSLIDES"); + for ( uint i = 0; i < m_pageList.count(); i++ ) { + QDomElement slide=doc.createElement("SLIDE"); + slide.setAttribute("nr", i); + slide.setAttribute("show", m_pageList.at(i)->isSlideSelected()); + element.appendChild(slide); + } + presenter.appendChild(element); + + emit sigProgress( 50 ); + } + + if ( saveOnlyPage == -1 ) + { + QDomElement styles = doc.createElement( "STYLES" ); + presenter.appendChild( styles ); + QValueList styleList(m_styleColl->styleList()); + for ( QValueList::const_iterator it = styleList.begin(), end = styleList.end(); + it != end ; ++it ) + saveStyle( static_cast( *it ), styles ); + + emit sigProgress( 60 ); + } + + // Write "OBJECT" tag for every child + QPtrListIterator chl( children() ); + for( ; chl.current(); ++chl ) { + // Don't save children that are only in the undo/redo history + // but not anymore in the presentation + for ( int i = 0; i < static_cast( m_pageList.count() ); i++ ) { + if ( saveOnlyPage != -1 && i != saveOnlyPage ) + continue; + double offset=0; + if ( saveOnlyPage == -1 ) + { + offset = i * m_pageList.at(i)->getPageRect().height(); + } + saveEmbeddedObject(m_pageList.at(i), chl.current(),doc,presenter,offset ); + } + if ( saveOnlyPage == -1 ) + { + saveEmbeddedObject(m_masterPage, chl.current(),doc,presenter,0.0 ); + } + } + + if ( saveOnlyPage == -1 ) + emit sigProgress( 70 ); + makeUsedPixmapList(); + + QDomElement pictures = m_pictureCollection.saveXML( KoPictureCollection::CollectionPicture, doc, usedPictures ); + presenter.appendChild( pictures ); + + if ( saveOnlyPage == -1 ) + emit sigProgress( 90 ); + + // Save sound file list. + makeUsedSoundFileList(); + QDomElement soundFiles = saveUsedSoundFileToXML( doc, usedSoundFile ); + presenter.appendChild( soundFiles ); + + if ( saveOnlyPage == -1 ) + setModified( false ); + return doc; +} + +void KPrDocument::saveEmbeddedObject(KPrPage *page, const QPtrList& childList, + QDomDocument &doc,QDomElement &presenter ) +{ + QPtrListIterator chl( childList ); + double offset = 0.0; + // we need no offset for objects on the master page and when we copy a page + if ( m_pageList.findRef( page ) ) + { + offset=m_pageList.findRef(page)*page->getPageRect().height(); + } + for( ; chl.current(); ++chl ) + saveEmbeddedObject(page, chl.current(),doc,presenter, offset ); +} + +void KPrDocument::saveEmbeddedObject(KPrPage *page, KoDocumentChild *chl, QDomDocument &doc, + QDomElement &presenter, double offset ) +{ + QPtrListIterator oIt(page->objectList()); + for ( int pos = 0; oIt.current(); ++oIt, ++pos ) + { + if ( oIt.current()->getType() == OT_PART && + static_cast( oIt.current() )->getChild() == chl ) + { + QDomElement embedded=doc.createElement("EMBEDDED"); + KPrChild* curr = (KPrChild*)chl; + + // geometry is no zoom value ! + QRect _rect = curr->geometry(); + int tmpX = (int)zoomHandler()->unzoomItX( _rect.x() ); + int tmpY = (int)zoomHandler()->unzoomItY( _rect.y() ); + int tmpWidth = (int)zoomHandler()->unzoomItX( _rect.width() ); + int tmpHeight = (int)zoomHandler()->unzoomItY( _rect.height() ); + curr->setGeometry( QRect( tmpX, tmpY, tmpWidth, tmpHeight ) ); + + embedded.appendChild(curr->save(doc, true)); + + curr->setGeometry( _rect ); // replace zoom value + + QDomElement settings=doc.createElement("SETTINGS"); + settings.setAttribute( "z-index", pos ); + if ( page == m_masterPage ) + settings.setAttribute("sticky", 1 ); + QPtrListIterator setOIt(page->objectList()); + for (; setOIt.current(); ++setOIt ) + { + if ( setOIt.current()->getType() == OT_PART && + dynamic_cast( setOIt.current() )->getChild() == curr ) + settings.appendChild(setOIt.current()->save( doc,offset )); + } + embedded.appendChild(settings); + presenter.appendChild(embedded); + } + } + +} + +//TODO with changes with new file format header/footer can't be change +void KPrDocument::compatibilityFromOldFileFormat() +{ + //function to keep compatibility with old file format + //for example for presSpeed + if ( m_loadingInfo && m_loadingInfo->oldFormat() ) + { + EffectSpeed newValue = ES_MEDIUM; + bool presSpeedChanged = ( m_loadingInfo->presSpeed != -1 ); + if ( presSpeedChanged ) + { + if ( m_loadingInfo->presSpeed < 3 ) + newValue = ES_SLOW; + else if ( m_loadingInfo->presSpeed > 7 ) + newValue = ES_FAST; + } + if ( !m_loadingInfo->m_headerFooterByPage ) + { + for ( int i = 0; i < static_cast( m_pageList.count() ); i++ ) + { + if ( presSpeedChanged ) + m_pageList.at(i)->setPageEffectSpeed( newValue ); + m_pageList.at( i )->setHeader( m_loadingInfo->m_header ); + m_pageList.at( i )->setFooter( m_loadingInfo->m_footer ); + } + } + + } + delete m_loadingInfo; + m_loadingInfo = 0L; + +} + +void KPrDocument::enableEmbeddedParts( bool f ) +{ + QPtrListIterator it( m_pageList ); + for ( ; it.current(); ++it ) + it.current()->enableEmbeddedParts(f); +} + +QDomDocumentFragment KPrDocument::saveBackground( QDomDocument &doc ) +{ + QDomDocumentFragment fragment=doc.createDocumentFragment(); + for ( int i = 0; i < static_cast( m_pageList.count() ); i++ ) { + if ( saveOnlyPage != -1 && i != saveOnlyPage ) + continue; + fragment.appendChild( m_pageList.at(i)->save( doc ) ); + } + // save backgound of masterpage only when the complete doc is saved + if ( saveOnlyPage == -1 ) + { + fragment.appendChild( m_masterPage->save( doc ) ); + } + return fragment; +} + +QDomElement KPrDocument::saveObjects( QDomDocument &doc ) +{ + QDomElement objects=doc.createElement("OBJECTS"); + double yoffset=0.0; + for ( int i = 0; i < static_cast( m_pageList.count() ); i++ ) { + if ( saveOnlyPage != -1 && saveOnlyPage!=i) + continue; + yoffset=i*m_pageList.at(i)->getPageRect().height(); // yoffset is not zoom value !! + objects=m_pageList.at(i)->saveObjects( doc, objects, yoffset, saveOnlyPage ); + + } + if ( !_duplicatePage ) //don't copy objects on master slide when we duplicate page + { + objects = m_masterPage->saveObjects( doc, objects, 0.0, saveOnlyPage ); + } + + return objects; +} + +QDomElement KPrDocument::saveTitle( QDomDocument &doc ) +{ + QDomElement titles=doc.createElement("PAGETITLES"); + + if ( saveOnlyPage == -1 ) + { // All page titles. + for ( int i = 0; i < static_cast( m_pageList.count() ); i++ ) + { + QDomElement title=doc.createElement("Title"); + title.setAttribute("title", m_pageList.at(i)->manualTitle()); + titles.appendChild(title); + } + } + else + { // Only current page title. + QDomElement title=doc.createElement("Title"); + title.setAttribute("title", m_pageList.at(saveOnlyPage)->manualTitle()); + titles.appendChild(title); + } + return titles; +} + +QDomElement KPrDocument::saveNote( QDomDocument &doc ) +{ + QDomElement notes=doc.createElement("PAGENOTES"); + + if ( saveOnlyPage == -1 ) { // All page notes. + for ( int i = 0; i < static_cast( m_pageList.count() ); i++ ) + { + QDomElement note=doc.createElement("Note"); + note.setAttribute("note", m_pageList.at(i)->noteText( )); + notes.appendChild(note); + } + } + else { // Only current page note. + QDomElement note=doc.createElement("Note"); + note.setAttribute("note", m_pageList.at(saveOnlyPage)->noteText( )); + notes.appendChild(note); + } + + return notes; +} + +QDomElement KPrDocument::saveAttribute( QDomDocument &doc ) +{ + QDomElement attributes=doc.createElement("ATTRIBUTES"); + //store first view parameter. + int activePage=0; + + if ( m_initialActivePage ) + activePage=m_pageList.findRef(m_initialActivePage); + activePage = QMAX( activePage, 0); + attributes.setAttribute("activePage",activePage ); + attributes.setAttribute("gridx", m_gridX ); + attributes.setAttribute("gridy", m_gridY ); + attributes.setAttribute("snaptogrid", (int)m_bSnapToGrid ); + return attributes; +} + +QDomElement KPrDocument::saveUsedSoundFileToXML( QDomDocument &_doc, QStringList _list ) +{ + QDomElement soundFiles = _doc.createElement( "SOUNDS" ); + + unsigned int i = 0; + QStringList::Iterator it = _list.begin(); + for ( ; it != _list.end(); ++it ) { + QString soundFileName = *it; + int position = soundFileName.findRev( '.' ); + QString format = soundFileName.right( soundFileName.length() - position - 1 ); + QString _name = QString( "sounds/sound%1.%2" ).arg( ++i ).arg( format.lower() ); + + QDomElement fileElem = _doc.createElement( "FILE" ); + soundFiles.appendChild( fileElem ); + fileElem.setAttribute( "filename", soundFileName ); + fileElem.setAttribute( "name", _name ); + } + + return soundFiles; +} + +bool KPrDocument::completeSaving( KoStore* _store ) +{ + if ( !_store ) { + if ( saveOnlyPage == -1 ) { + emit sigProgress( 100 ); + emit sigProgress( -1 ); + } + return true; + } + + m_pictureCollection.saveToStore( KoPictureCollection::CollectionPicture, _store, usedPictures ); + + saveUsedSoundFileToStore( _store, usedSoundFile ); + + if ( saveOnlyPage == -1 ) { + emit sigProgress( 100 ); + emit sigProgress( -1 ); + } + + return true; +} + +int KPrDocument::supportedSpecialFormats() const +{ + return KoDocument::supportedSpecialFormats(); +} + +void KPrDocument::saveUsedSoundFileToStore( KoStore *_store, QStringList _list ) +{ + unsigned int i = 0; + QStringList::Iterator it = _list.begin(); + for ( ; it != _list.end(); ++it ) { + QString soundFileName = *it; + int position = soundFileName.findRev( '.' ); + QString format = soundFileName.right( soundFileName.length() - position - 1 ); + QString _storeURL = QString( "sounds/sound%1.%2" ).arg( ++i ).arg( format.lower() ); + + if ( _store->open( _storeURL ) ) { + KoStoreDevice dev( _store ); + QFile _file( soundFileName ); + if ( _file.open( IO_ReadOnly ) ) { + dev.writeBlock( ( _file.readAll() ).data(), _file.size() ); + _file.close(); + } + _store->close(); + } + } +} + +bool KPrDocument::loadChildren( KoStore* _store ) +{ + if ( objStartY == 0 && _clean) // Don't do this when inserting a template or a page... + { + QPtrListIterator it( children() ); + for( ; it.current(); ++it ) { + if ( !((KoDocumentChild*)it.current())->loadDocument( _store ) ) + return false; + } + } + else // instead load form the correct child on, m_childCountBeforeInsert has the be set + { + QPtrListIterator it( children() ); + for( int i = 0; it.current(); ++it, ++i ) { + if ( i < m_childCountBeforeInsert ) + continue; + if ( !((KoDocumentChild*)it.current())->loadDocument( _store ) ) + return false; + } + } + return true; +} + +bool KPrDocument::saveOasis( KoStore* store, KoXmlWriter* manifestWriter ) +{ + + //todo necessary for new format ? + if ( saveOnlyPage == -1 ) { + emit sigProgress( 0 ); + } + if ( !store->open( "content.xml" ) ) + return false; + m_pictureCollection.assignUniqueIds(); + KoStoreDevice contentDev( store ); + KoXmlWriter* contentWriter = createOasisXmlWriter( &contentDev, "office:document-content" ); + + + m_varColl->variableSetting()->setModificationDate(QDateTime::currentDateTime()); + recalcVariables( VT_DATE ); + recalcVariables( VT_TIME ); + recalcVariables( VT_STATISTIC ); + KoGenStyles mainStyles; + KoSavingContext savingContext( mainStyles, 0, false, KoSavingContext::Store ); + + // Save user styles as KoGenStyle objects + m_styleColl->saveOasis( mainStyles, KoGenStyle::STYLE_USER, savingContext ); + + KTempFile contentTmpFile; + contentTmpFile.setAutoDelete( true ); + QFile* tmpFile = contentTmpFile.file(); + KoXmlWriter contentTmpWriter( tmpFile, 1 ); + + + //For sticky objects + KTempFile stickyTmpFile; + stickyTmpFile.setAutoDelete( true ); + QFile* masterStyles = stickyTmpFile.file(); + KoXmlWriter stickyTmpWriter( masterStyles, 1 ); + + + contentTmpWriter.startElement( "office:body" ); + contentTmpWriter.startElement( "office:presentation" ); + + saveOasisCustomFied( contentTmpWriter ); + + int indexObj = 1; + int partIndexObj = 0; +//save page + + QMap pageNames; + + if ( !_duplicatePage ) + { + m_masterPage->saveOasisPage( store, stickyTmpWriter, 0, savingContext, indexObj, partIndexObj, manifestWriter, pageNames ); + + // Now mark all autostyles as "for styles.xml" since headers/footers need them + QValueList autoStyles = mainStyles.styles( KoGenStyle::STYLE_AUTO ); + for ( QValueList::const_iterator it = autoStyles.begin(); + it != autoStyles.end(); ++it ) { + kdDebug() << "marking for styles.xml:" << ( *it ).name << endl; + mainStyles.markStyleForStylesXml( ( *it ).name ); + } + + } + + if ( saveOnlyPage != -1 ) + { + m_pageList.at( saveOnlyPage )->saveOasisPage( store, contentTmpWriter, ( saveOnlyPage+1 ), savingContext, indexObj, partIndexObj , manifestWriter, pageNames ); + } + else + { + for ( int i = 0; i < static_cast( m_pageList.count() ); i++ ) + { + m_pageList.at( i )->saveOasisPage( store, contentTmpWriter, ( i+1 ), savingContext, indexObj, partIndexObj , manifestWriter, pageNames ); + } + } + if ( saveOnlyPage == -1 ) //don't save setting when we save on page + { + QMap page2name; + QMap::ConstIterator it( pageNames.begin() ); + for ( ; it != pageNames.end(); ++it ) + { + page2name.insert( it.data(), it.key() ); + } + saveOasisPresentationSettings( contentTmpWriter, page2name ); + } + + contentTmpWriter.endElement(); //office:presentation + contentTmpWriter.endElement(); //office:body + + writeAutomaticStyles( *contentWriter, mainStyles, savingContext, false ); + + // And now we can copy over the contents from the tempfile to the real one + tmpFile->close(); + contentWriter->addCompleteElement( tmpFile ); + contentTmpFile.close(); + + contentWriter->endElement(); // root element + contentWriter->endDocument(); + delete contentWriter; + + if ( !store->close() ) // done with content.xml + return false; + + //add manifest line for content.xml + manifestWriter->addManifestEntry( "content.xml", "text/xml" ); + + if ( !store->open( "styles.xml" ) ) + return false; + + manifestWriter->addManifestEntry( "styles.xml", "text/xml" ); + + //todo fixme???? + masterStyles->close(); + saveOasisDocumentStyles( store, mainStyles, masterStyles, savingContext ); + stickyTmpFile.close(); + + if ( !store->close() ) // done with styles.xml + return false; + + + if ( saveOnlyPage == -1 ) + emit sigProgress( 90 ); + + // Save sound file list. +//todo ???? + + + makeUsedPixmapList(); + + m_pictureCollection.saveOasisToStore( store, usedPictures, manifestWriter); + + if(!store->open("settings.xml")) + return false; + + KoXmlWriter& settingsWriter = *createOasisXmlWriter(&contentDev, "office:document-settings"); + settingsWriter.startElement("office:settings"); + + settingsWriter.startElement("config:config-item-set"); + settingsWriter.addAttribute("config:name", "view-settings"); + + KoUnit::saveOasis(&settingsWriter, unit()); + saveOasisSettings( settingsWriter ); + + settingsWriter.endElement(); // config:config-item-set + + settingsWriter.startElement("config:config-item-set"); + settingsWriter.addAttribute("config:name", "configuration-settings"); + settingsWriter.addConfigItem("SpellCheckerIgnoreList", m_spellCheckIgnoreList.join( "," ) ); + settingsWriter.addConfigItem("ShowPresentationDuration", _showPresentationDuration ); + settingsWriter.endElement(); // config:config-item-set + + m_varColl->variableSetting()->saveOasis( settingsWriter ); + + settingsWriter.endElement(); // office:settings + settingsWriter.endElement(); // Root:Element + settingsWriter.endDocument(); + delete &settingsWriter; + + if(!store->close()) + return false; + + manifestWriter->addManifestEntry("settings.xml", "text/xml"); + + //reset progressbar + emit sigProgress( 100 ); + emit sigProgress( -1 ); + + setModified( false ); + + return true; +} + +void KPrDocument::saveOasisCustomFied( KoXmlWriter &writer )const +{ + bool customVariableFound = false; + QPtrListIterator it( m_varColl->getVariables() ); + for ( ; it.current() ; ++it ) + { + if ( it.current()->type() == VT_CUSTOM ) + { + if ( !customVariableFound ) + { + writer.startElement( "text:user-field-decls" ); + customVariableFound = true; + } + // + writer.startElement( "text:user-field-decl" ); + writer.addAttribute( "office:value-type", "string" ); + writer.addAttribute( "office:string-value", static_cast( it.current() )->value() ); + writer.addAttribute( "text:name", static_cast( it.current() )->name() ); + writer.endElement(); + } + } + if ( customVariableFound ) + writer.endElement(); +} + +void KPrDocument::loadOasisIgnoreList( const KoOasisSettings& settings ) +{ + KoOasisSettings::Items configurationSettings = settings.itemSet( "configuration-settings" ); + if ( !configurationSettings.isNull() ) + { + _showPresentationDuration = configurationSettings.parseConfigItemBool( "ShowPresentationDuration", false ); + const QString ignorelist = configurationSettings.parseConfigItemString( "SpellCheckerIgnoreList" ); + m_spellCheckIgnoreList = QStringList::split( ',', ignorelist ); + } +} + +void KPrDocument::writeAutomaticStyles( KoXmlWriter& contentWriter, KoGenStyles& mainStyles, KoSavingContext& context, bool stylesDotXml ) +{ + if ( !stylesDotXml ) + { + context.writeFontFaces( contentWriter ); + contentWriter.startElement( "office:automatic-styles" ); + } + QValueList styles = mainStyles.styles( KoGenStyle::STYLE_AUTO, stylesDotXml ); + QValueList::const_iterator it = styles.begin(); + for ( ; it != styles.end() ; ++it ) { + (*it).style->writeStyle( &contentWriter, mainStyles, "style:style", (*it).name, "style:paragraph-properties" ); + } + + styles = mainStyles.styles( KoGenStyle::STYLE_AUTO_LIST, stylesDotXml ); + it = styles.begin(); + for ( ; it != styles.end() ; ++it ) { + ( *it ).style->writeStyle( &contentWriter, mainStyles, "text:list-style", (*it).name, 0 ); + } + + styles = mainStyles.styles( STYLE_BACKGROUNDPAGEAUTO, stylesDotXml ); + it = styles.begin(); + for ( ; it != styles.end() ; ++it ) { + (*it).style->writeStyle( &contentWriter, mainStyles, "style:style", (*it).name, "style:drawing-page-properties" ); + } + + styles = mainStyles.styles( KoGenStyle::STYLE_GRAPHICAUTO, stylesDotXml ); + it = styles.begin(); + for ( ; it != styles.end() ; ++it ) { + (*it).style->writeStyle( &contentWriter, mainStyles, "style:style", (*it).name , "style:graphic-properties" ); + } + + styles = mainStyles.styles( KoGenStyle::STYLE_NUMERIC_DATE, stylesDotXml ); + it = styles.begin(); + for ( ; it != styles.end() ; ++it ) { + (*it).style->writeStyle( &contentWriter, mainStyles, "number:date-style", (*it).name, 0 /*TODO ????*/ ); + } + styles = mainStyles.styles( KoGenStyle::STYLE_NUMERIC_TIME, stylesDotXml ); + it = styles.begin(); + for ( ; it != styles.end() ; ++it ) { + (*it).style->writeStyle( &contentWriter, mainStyles, "number:time-style", (*it).name, 0 /*TODO ????*/ ); + } + + if ( !stylesDotXml ) + { + contentWriter.endElement(); // office:automatic-styles + } +} + +void KPrDocument::loadOasisHeaderFooter(QDomNode & drawPage, KoOasisContext & context) +{ + QDomNode tmp = KoDom::namedItemNS( drawPage, KoXmlNS::style, "header" ); + if ( !tmp.isNull() ) + { + //kdDebug()<<" there is a header \n"; + _header->textObject()->loadOasisContent( tmp.toElement(), context, styleCollection() ); + } + tmp = KoDom::namedItemNS( drawPage, KoXmlNS::style, "footer" ); + if ( !tmp.isNull() ) + { + //kdDebug()<<" there is a footer \n"; + _footer->textObject()->loadOasisContent( tmp.toElement(), context, styleCollection() ); + } +} + +void KPrDocument::saveOasisSettings( KoXmlWriter &settingsWriter ) +{ + settingsWriter.startElement("config:config-item-map-indexed"); + settingsWriter.addAttribute("config:name", "Views"); + settingsWriter.startElement( "config:config-item-map-entry" ); + + //ooimpress save it as this line. + //H2260V14397H7693H12415H15345H1424 + QString guideLinesOasis; + //save in mm as in oo + for( QValueList::Iterator it = m_vGuideLines.begin(); it != m_vGuideLines.end(); ++it ) + { + int tmpX = ( int ) ( KoUnit::toMM( *it )*100 ); + guideLinesOasis += "V" + QString::number( tmpX ); + } + + for( QValueList::Iterator it = m_hGuideLines.begin(); it != m_hGuideLines.end(); ++it ) + { + int tmpY = ( int ) ( KoUnit::toMM( *it )*100 ); + guideLinesOasis += "H" + QString::number( tmpY ); + } + if ( !guideLinesOasis.isEmpty() ) + { + settingsWriter.addConfigItem( "SnapLinesDrawing", guideLinesOasis ); + } + //false + settingsWriter.addConfigItem( "IsSnapToGrid", m_bSnapToGrid ); + + //500 + settingsWriter.addConfigItem( "GridFineWidth", ( ( int ) ( KoUnit::toMM( ( m_gridX ) )*100 ) ) ); + + + //500 + settingsWriter.addConfigItem( "GridFineHeight", ( ( int ) ( KoUnit::toMM( ( m_gridY ) )*100 ) ) ); + + //3 + //store first view parameter. + int activePage=0; + if ( m_initialActivePage ) + activePage=m_pageList.findRef(m_initialActivePage); + activePage = QMAX( activePage, 0); + settingsWriter.addConfigItem( "SelectedPage", activePage ); + + //not define into oo spec + settingsWriter.addConfigItem( "SnapLineIsVisible", showGuideLines() ); + settingsWriter.endElement(); + settingsWriter.endElement(); +} + +void KPrDocument::loadOasisSettings(const QDomDocument&settingsDoc) +{ + kdDebug(33001)<<"void KPrDocument::loadOasisSettings(const QDomDocument&settingsDoc)**********\n"; + KoOasisSettings settings( settingsDoc ); + KoOasisSettings::Items viewSettings = settings.itemSet( "view-settings" ); + setUnit(KoUnit::unit(viewSettings.parseConfigItemString("unit"))); + KoOasisSettings::IndexedMap viewMap = viewSettings.indexedMap( "Views" ); + KoOasisSettings::Items firstView = viewMap.entry( 0 ); + if ( !firstView.isNull() ) + { + parseOasisGuideLines( firstView.parseConfigItemString( "SnapLinesDrawing" ) ); + setShowGuideLines( firstView.parseConfigItemBool( "SnapLineIsVisible" ) ); + int valx = firstView.parseConfigItemInt( "GridFineWidth" ); + m_gridX = MM_TO_POINT( valx / 100.0 ); + int valy = firstView.parseConfigItemInt( "GridFineHeight" ); + m_gridY = MM_TO_POINT( valy / 100.0 ); + + m_bSnapToGrid = firstView.parseConfigItemBool( "IsSnapToGrid" ); + + int activePage = firstView.parseConfigItemInt( "SelectedPage" ); + kdDebug(33001)<<" activePage :"<variableSetting()->loadOasis( settings ); +} + +void KPrDocument::parseOasisGuideLines( const QString &text ) +{ + QString str; + int newPos = text.length()-1; //start to element = 1 + for ( int pos = text.length()-1; pos >=0;--pos ) + { + if ( text[pos]=='V' ) + { + //vertical element + str = text.mid( pos+1, ( newPos-pos ) ); + //kdDebug()<<" vertical :"<< str < pageList; + for ( QStringList::Iterator it = tmp.begin(); it != tmp.end(); ++it ) + { + if ( m_loadingInfo->m_name2page.contains( *it ) ) + { + kdDebug(33001) << "slide show " << name << " page = " << *it << endl; + pageList.push_back( m_loadingInfo->m_name2page[*it] ); + } + } + if ( ! pageList.empty() ) + { + m_customListSlideShow.insert( name, pageList ); + } + } + } +} + +void KPrDocument::saveOasisPresentationSettings( KoXmlWriter &contentTmpWriter, QMap &page2name ) +{ + //todo don't save when is not value by default (check with oo) + //FIXME + contentTmpWriter.startElement( "presentation:settings" ); + contentTmpWriter.addAttribute( "presentation:endless", ( _spInfiniteLoop ? "true" : "false" ) ); + contentTmpWriter.addAttribute( "presentation:show-end-of-presentation-slide", ( _spShowEndOfPresentationSlide ? "true" : "false" ) ); + contentTmpWriter.addAttribute( "presentation:force-manual", ( _spManualSwitch ? "true" : "false" ) ); + //add for default presentation + if ( !m_presentationName.isEmpty() ) + contentTmpWriter.addAttribute( "presentation:show", m_presentationName ); + + saveOasisPresentationCustomSlideShow( contentTmpWriter, page2name ); + contentTmpWriter.endElement(); +} + +void KPrDocument::saveOasisPresentationCustomSlideShow( KoXmlWriter &contentTmpWriter, QMap &page2name ) +{ + if ( m_customListSlideShow.isEmpty() ) + return; + + CustomSlideShowMap::Iterator it; + for ( it = m_customListSlideShow.begin(); it != m_customListSlideShow.end(); ++it ) + { + contentTmpWriter.startElement( "presentation:show" ); + contentTmpWriter.addAttribute( "presentation:name", it.key() ); + QString tmp; + QValueListIterator itPage ; + for( itPage = ( *it ).begin(); itPage != ( *it ).end(); ++itPage ) + { + int posPage = m_pageList.find(*itPage ); + if ( posPage != -1 ) + { + if ( itPage != ( *it ).begin() ) + tmp += ","; + //tmp+=( *itPage )->oasisNamePage(posPage+1)+","; + tmp += page2name[posPage + 1]; + } + } + contentTmpWriter.addAttribute( "presentation:pages", tmp ); + contentTmpWriter.endElement(); + } + // +} + +void KPrDocument::saveOasisDocumentStyles( KoStore* store, KoGenStyles& mainStyles, QFile* masterStyles, + KoSavingContext & savingContext, SaveFlag saveFlag ) const +{ + KoStoreDevice stylesDev( store ); + KoXmlWriter* stylesWriter = createOasisXmlWriter( &stylesDev, "office:document-styles" ); + + // Yeah we need to save the same font faces in both content.xml and styles.xml... + savingContext.writeFontFaces( *stylesWriter ); + + stylesWriter->startElement( "office:styles" ); + QValueList styles = mainStyles.styles( KoGenStyle::STYLE_USER ); + QValueList::const_iterator it = styles.begin(); + for ( ; it != styles.end() ; ++it ) { + (*it).style->writeStyle( stylesWriter, mainStyles, "style:style", (*it).name, "style:paragraph-properties" ); + } + styles = mainStyles.styles( KoGenStyle::STYLE_LIST ); + it = styles.begin(); + for ( ; it != styles.end() ; ++it ) { + (*it).style->writeStyle( stylesWriter, mainStyles, "text:list-style", (*it).name, 0 ); + } + styles = mainStyles.styles( KoGenStyle::STYLE_HATCH ); + it = styles.begin(); + for ( ; it != styles.end() ; ++it ) { + (*it).style->writeStyle( stylesWriter, mainStyles, "draw:hatch", (*it).name, "style:graphic-properties" , true, true /*add draw:name*/); + } + styles = mainStyles.styles( STYLE_GRADIENT ); + it = styles.begin(); + for ( ; it != styles.end() ; ++it ) { + (*it).style->writeStyle( stylesWriter, mainStyles, "draw:gradient", (*it).name, "style:graphic-properties" , true, true /*add draw:name*/); + } + + styles = mainStyles.styles( STYLE_STROKE ); + it = styles.begin(); + for ( ; it != styles.end() ; ++it ) { + (*it).style->writeStyle( stylesWriter, mainStyles, "draw:stroke-dash", (*it).name, "style:graphic-properties" , true, true /*add draw:name*/); + } + + styles = mainStyles.styles( STYLE_MARKER ); + it = styles.begin(); + for ( ; it != styles.end() ; ++it ) { + (*it).style->writeStyle( stylesWriter, mainStyles, "draw:marker", (*it).name, "style:graphic-properties" , true, true /*add draw:name*/); + } + styles = mainStyles.styles( STYLE_PICTURE ); + it = styles.begin(); + for ( ; it != styles.end() ; ++it ) { + (*it).style->writeStyle( stylesWriter, mainStyles, "draw:fill-image", (*it).name, "style:image-properties" , true, true /*add draw:name*/); + } + + stylesWriter->endElement(); // office:styles + + if ( saveFlag == SaveAll ) + { + stylesWriter->startElement( "office:automatic-styles" ); + // this has to be the first + if ( masterStyles ) + { + writeAutomaticStyles( *stylesWriter, mainStyles, savingContext, true ); + } + + styles = mainStyles.styles( STYLE_BACKGROUNDPAGE ); + it = styles.begin(); + for ( ; it != styles.end() ; ++it ) { + (*it).style->writeStyle( stylesWriter, mainStyles, "style:style", (*it).name , "style:drawing-page-properties" ); + } + + // if there's more than one pagemaster we need to rethink all this + styles = mainStyles.styles( KoGenStyle::STYLE_PAGELAYOUT ); + Q_ASSERT( styles.count() == 1 ); + it = styles.begin(); + for ( ; it != styles.end() ; ++it ) { + (*it).style->writeStyle( stylesWriter, mainStyles, "style:page-layout", (*it).name, "style:page-layout-properties", false /*don't close*/ ); + stylesWriter->endElement(); + } + + styles = mainStyles.styles( STYLE_PRESENTATIONSTICKYOBJECT ); + it = styles.begin(); + for ( ; it != styles.end() ; ++it ) { + //TODO fix me graphic-properties ??? + (*it).style->writeStyle( stylesWriter, mainStyles, "style:style", (*it).name , "style:graphic-properties" ); + } + + stylesWriter->endElement(); // office:automatic-styles + + + if ( masterStyles ) + { + stylesWriter->startElement( "office:master-styles" ); + stylesWriter->addCompleteElement( masterStyles ); + stylesWriter->endElement(); + } + } + + stylesWriter->endElement(); // root element (office:document-styles) + stylesWriter->endDocument(); + delete stylesWriter; +} + +bool KPrDocument::loadOasis( const QDomDocument& doc, KoOasisStyles&oasisStyles, const QDomDocument&settingsDoc, KoStore*store ) +{ + QTime dt; + dt.start(); + m_loadingInfo = new KPrLoadingInfo; + ignoreSticky = FALSE; + emit sigProgress( 0 ); + + lastObj = -1; + // clean + if ( _clean ) { + m_styleColl->clear(); + // Some simple import filters don't define any style, + // so let's have a Standard style at least + KoParagStyle * standardStyle = new KoParagStyle( "Standard" ); // This gets translated later on + //kdDebug() << "KWDocument::KWDocument creating standardStyle " << standardStyle << endl; + standardStyle->format().setFont( m_defaultFont ); + m_styleColl->addStyle( standardStyle ); + + __pgLayout = KoPageLayout::standardLayout(); + _spInfiniteLoop = false; + _spShowEndOfPresentationSlide = true; + _spManualSwitch = true; + _showPresentationDuration = false; + _xRnd = 20; + _yRnd = 20; + urlIntern = url().path(); + } + else + m_spellCheckIgnoreList.clear(); + emit sigProgress( 5 ); + + QDomElement content = doc.documentElement(); + QDomElement realBody (KoDom::namedItemNS( content, KoXmlNS::office, "body" ) ); + if ( realBody.isNull() ) + { + kdError(33001) << "No office:body found!" << endl; + setErrorMessage( i18n( "Invalid OASIS OpenDocument file. No office:body tag found." ) ); + return false; + } + QDomElement body = KoDom::namedItemNS( realBody, KoXmlNS::office, "presentation" ); + if ( body.isNull() ) + { + kdError(33001) << "No office:presentation found!" << endl; + QDomElement childElem; + QString localName; + forEachElement( childElem, realBody ) { + localName = childElem.localName(); + } + if ( localName.isEmpty() ) + setErrorMessage( i18n( "Invalid OASIS OpenDocument file. No tag found inside office:body." ) ); + else + setErrorMessage( i18n( "This document is not a presentation, but a %1. Please try opening it with the appropriate application." ).arg( KoDocument::tagNameToDocumentType( localName ) ) ); + return false; + } + + // it seems that ooimpress has different paper-settings for every slide. + // we take the settings of the first slide for the whole document. + QDomNode drawPage = KoDom::namedItemNS( body, KoXmlNS::draw, "page" ); + if ( drawPage.isNull() ) // no slides? give up. + return false; + QDomElement dp = drawPage.toElement(); + + //code from kword + // TODO variable settings + // By default display real variable value + if ( !isReadWrite()) + getVariableCollection()->variableSetting()->setDisplayFieldCode(false); + + KoOasisContext context( this, *m_varColl, oasisStyles, store ); + Q_ASSERT( !oasisStyles.officeStyle().isNull() ); + + // Load all styles before the corresponding paragraphs try to use them! + m_styleColl->loadOasisStyles( context ); + + // if we only copy a page we have no master + // also don't copy master when you insert file as long as we don't have multiple masters + if ( !m_pageWhereLoadObject && _clean ) + { + QString masterPageName = drawPage.toElement().attributeNS( KoXmlNS::draw, "master-page-name", QString::null ); + QDomElement *master = oasisStyles.masterPages()[ masterPageName]; + + kdDebug()<<" master :"<loadOasis( context ); + + createPresentationAnimation( KoDom::namedItemNS( node, KoXmlNS::presentation, "animations")); + + loadOasisObject( m_masterPage, node , context); + + m_loadingInfo->clearAnimationShowDict(); // clear all show animations style + m_loadingInfo->clearAnimationHideDict(); // clear all hide animations style + + loadOasisHeaderFooter( node,context ); + context.setUseStylesAutoStyles( false ); + + kdDebug()<<" end load oasis master style \n"; + + Q_ASSERT( master ); + const QDomElement *style = master ? oasisStyles.findStyle(master->attributeNS( KoXmlNS::style, "page-layout-name", QString::null )) : 0; + const QDomElement *backgroundStyle = oasisStyles.findStyle( "Standard-background", "presentation" ); + kdDebug()<<"Standard background "<" as page + { + context.styleStack().clear(); // remove all styles + fillStyleStack( dp, context, "drawing-page" ); + context.styleStack().save(); + kdDebug ()<<"insert new page "<m_name2page.insert( str, newpage ); + QString idPage = dp.attributeNS( KoXmlNS::draw, "id", QString::null ); + + if ( dp.hasAttributeNS( KoXmlNS::koffice, "name" ) ) + { + str = dp.attributeNS( KoXmlNS::koffice, "name", QString::null ); + newpage->insertManualTitle(str); + } + else + { + // OO uses /page[0-9]+$/ as default for no name set + QRegExp rx( "^page[0-9]+$" ); + if ( rx.search( str ) == -1 ) + newpage->insertManualTitle(str); + } + context.styleStack().setTypeProperties( "drawing-page" ); + + newpage->loadOasis( context ); + + //All animation object for current page is store into this element + createPresentationAnimation(KoDom::namedItemNS( drawPage, KoXmlNS::presentation, "animations")); + // parse all objects + loadOasisObject( newpage, drawPage, context ); + + context.styleStack().restore(); + m_loadingInfo->clearAnimationShowDict(); // clear all show animations style + m_loadingInfo->clearAnimationHideDict(); // clear all hide animations style + ++pos; + } + } + + //load settings at the end as we need to know what the draw:name of a page is + QDomNode settings = KoDom::namedItemNS( body, KoXmlNS::presentation, "settings" ); + kdDebug()<<"settings :"<loadOasis(o, context, m_loadingInfo); + if ( groupObject ) + groupObject->addObjects( kptextobject ); + else + newpage->appendObject(kptextobject); + break; + } + else if ( localName == "image" ) + { + KPrPixmapObject *kppixmapobject = new KPrPixmapObject( pictureCollection() ); + kppixmapobject->loadOasis( o, context, m_loadingInfo); + if ( groupObject ) + groupObject->addObjects( kppixmapobject ); + else + newpage->appendObject(kppixmapobject); + break; + } + else if ( localName == "object" ) + { + KPrChild *ch = new KPrChild( this ); + QRect r; + KPrPartObject *kppartobject = new KPrPartObject( ch ); + kppartobject->loadOasis( o, context, m_loadingInfo ); + r = ch->geometry(); + if ( groupObject ) + groupObject->addObjects( kppartobject ); + else + newpage->appendObject(kppartobject); + insertChild( ch ); + kppartobject->setOrig( r.x(), r.y() ); + kppartobject->setSize( r.width(), r.height() ); + break; + } + } + } + else if ( name == "rect" && isDrawNS) // rectangle + { + fillStyleStack( o, context, "graphic" ); + KPrRectObject *kprectobject = new KPrRectObject(); + kprectobject->loadOasis(o, context , m_loadingInfo); + if ( groupObject ) + groupObject->addObjects( kprectobject ); + else + newpage->appendObject(kprectobject); + } + else if ( ( name == "circle" || name == "ellipse" )&& isDrawNS) + { + fillStyleStack( o, context, "graphic" ); + if ( o.hasAttributeNS( KoXmlNS::draw, "kind" ) ) // pie, chord or arc + { + KPrPieObject *kppieobject = new KPrPieObject(); + kppieobject->loadOasis(o, context, m_loadingInfo); + if ( groupObject ) + groupObject->addObjects( kppieobject ); + else + newpage->appendObject(kppieobject); + } + else // circle or ellipse + { + KPrEllipseObject *kpellipseobject = new KPrEllipseObject(); + kpellipseobject->loadOasis(o,context, m_loadingInfo); + if ( groupObject ) + groupObject->addObjects( kpellipseobject ); + else + newpage->appendObject(kpellipseobject); + } + } + else if ( name == "line" && isDrawNS) // line + { + fillStyleStack( o, context, "graphic" ); + KPrLineObject *kplineobject = new KPrLineObject(); + kplineobject->loadOasis(o, context, m_loadingInfo); + if ( groupObject ) + groupObject->addObjects( kplineobject ); + else + newpage->appendObject( kplineobject ); + } + else if (name=="polyline" && isDrawNS) { // polyline + fillStyleStack( o, context, "graphic" ); + KPrPolylineObject *kppolylineobject = new KPrPolylineObject(); + kppolylineobject->loadOasis(o, context, m_loadingInfo); + if ( groupObject ) + groupObject->addObjects( kppolylineobject ); + else + newpage->appendObject(kppolylineobject); + } + else if (name=="polygon" && isDrawNS) { // plcloseobject + fillStyleStack( o, context, "graphic" ); + KPrClosedLineObject *kpClosedObject = new KPrClosedLineObject(); + kpClosedObject->loadOasis( o, context, m_loadingInfo); + if ( groupObject ) + groupObject->addObjects( kpClosedObject ); + else + newpage->appendObject(kpClosedObject); + } + else if (name=="regular-polygon"&& isDrawNS) { // kppolygone object + fillStyleStack( o, context, "graphic" ); + KPrPolygonObject *kpPolygoneObject = new KPrPolygonObject(); + kpPolygoneObject->loadOasis( o, context, m_loadingInfo); + if ( groupObject ) + groupObject->addObjects( kpPolygoneObject ); + else + newpage->appendObject(kpPolygoneObject); + } + else if ( name == "path" && isDrawNS) + { + fillStyleStack( o, context, "graphic" ); + QString d = o.attributeNS( KoXmlNS::svg, "d", QString::null); + + KPrSVGPathParser parser; + ObjType objType = parser.getType( d ); + + switch ( objType ) + { + case OT_CUBICBEZIERCURVE: + { + kdDebug(33001) << "Cubicbeziercurve" << endl; + KPrCubicBezierCurveObject *kpCurveObject = new KPrCubicBezierCurveObject(); + kpCurveObject->loadOasis( o, context, m_loadingInfo ); + if ( groupObject ) + groupObject->addObjects( kpCurveObject ); + else + newpage->appendObject( kpCurveObject ); + } break; + case OT_QUADRICBEZIERCURVE: + { + kdDebug(33001) << "Quadricbeziercurve" << endl; + KPrQuadricBezierCurveObject *kpQuadricObject = new KPrQuadricBezierCurveObject(); + kpQuadricObject->loadOasis( o, context, m_loadingInfo ); + if ( groupObject ) + groupObject->addObjects( kpQuadricObject ); + else + newpage->appendObject( kpQuadricObject ); + } break; + case OT_FREEHAND: + { + kdDebug(33001) << "Freehand" << endl; + KPrFreehandObject *kpFreeHandObject = new KPrFreehandObject(); + kpFreeHandObject->loadOasis( o, context, m_loadingInfo ); + if ( groupObject ) + groupObject->addObjects( kpFreeHandObject ); + else + newpage->appendObject( kpFreeHandObject ); + } break; + case OT_CLOSED_LINE: + { + kdDebug(33001) << "Closed Line" << endl; + KPrClosedLineObject *kpClosedObject = new KPrClosedLineObject(); + kpClosedObject->loadOasis( o, context, m_loadingInfo ); + if ( groupObject ) + groupObject->addObjects( kpClosedObject ); + else + newpage->appendObject( kpClosedObject ); + } break; + default: + kdDebug(33001) << "draw:path found unsupported object type " << objType << " in svg:d " << d << endl; + break; + } + } + else if ( name == "custom-shape" && isDrawNS ) + { + fillStyleStack( o, context, "graphic" ); + + QDomElement enhancedGeometry = KoDom::namedItemNS( o, KoXmlNS::draw, "enhanced-geometry" ); + + if ( !enhancedGeometry.isNull() ) + { + QString d = enhancedGeometry.attributeNS( KoXmlNS::draw, "enhanced-path", QString::null ); + QRegExp rx( "^([0-9 ML]+Z) N$" ); + if ( rx.search( d ) != -1 ) + { + d = rx.cap( 1 ); + KPrSVGPathParser parser; + ObjType objType = parser.getType( d ); + + switch ( objType ) + { +#if 0 // not yet supported + case OT_CUBICBEZIERCURVE: + { + kdDebug(33001) << "Cubicbeziercurve" << endl; + KPrCubicBezierCurveObject *kpCurveObject = new KPrCubicBezierCurveObject(); + kpCurveObject->loadOasis( o, context, m_loadingInfo ); + if ( groupObject ) + groupObject->addObjects( kpCurveObject ); + else + newpage->appendObject( kpCurveObject ); + } break; + case OT_QUADRICBEZIERCURVE: + { + kdDebug(33001) << "Quadricbeziercurve" << endl; + KPrQuadricBezierCurveObject *kpQuadricObject = new KPrQuadricBezierCurveObject(); + kpQuadricObject->loadOasis( o, context, m_loadingInfo ); + if ( groupObject ) + groupObject->addObjects( kpQuadricObject ); + else + newpage->appendObject( kpQuadricObject ); + } break; + case OT_FREEHAND: + { + kdDebug(33001) << "Freehand" << endl; + KPrFreehandObject *kpFreeHandObject = new KPrFreehandObject(); + kpFreeHandObject->loadOasis( o, context, m_loadingInfo ); + if ( groupObject ) + groupObject->addObjects( kpFreeHandObject ); + else + newpage->appendObject( kpFreeHandObject ); + } break; +#endif + case OT_CLOSED_LINE: + { + kdDebug(33001) << "Closed Line" << endl; + KPrClosedLineObject *kpClosedObject = new KPrClosedLineObject(); + kpClosedObject->loadOasis( o, context, m_loadingInfo ); + if ( groupObject ) + groupObject->addObjects( kpClosedObject ); + else + newpage->appendObject( kpClosedObject ); + } break; + default: + kdDebug(33001) << "draw:custom-shape found unsupported object type " << objType << " in draw:enhanced-path " << d << endl; + break; + } + } + else + { + kdDebug(33001) << "draw:custom-shape not supported" << endl; + } + } + } + else if ( name == "g" && isDrawNS) + { + fillStyleStack( o, context, "graphic" ); + KPrGroupObject *kpgroupobject = new KPrGroupObject(); + QDomNode nodegroup = object.firstChild(); + + kpgroupobject->loadOasisGroupObject( this, newpage, object, context, m_loadingInfo); + if ( groupObject ) + groupObject->addObjects( kpgroupobject ); + else + newpage->appendObject(kpgroupobject); + } + else if ( name == "notes" && o.namespaceURI() == KoXmlNS::presentation ) // notes + { + //we must extend note attribute + //kdDebug()<<"presentation:notes----------------------------------\n"; + QDomNode frameBox = KoDom::namedItemNS( o, KoXmlNS::draw, "frame" ); + QString note; + + while ( !frameBox.isNull() ) + { + //add an empty line between the different frames + if ( !note.isEmpty() ) + note += "\n"; + + //todo load layout for note. + QDomNode textBox = KoDom::namedItemNS( frameBox, KoXmlNS::draw, "text-box" ); + + if ( !textBox.isNull() ) + { + for ( QDomNode text = textBox.firstChild(); !text.isNull(); text = text.nextSibling() ) + { + // We don't care about styles as they are not supported in kpresenter. + // Only add a linebreak for every child. + QDomElement t = text.toElement(); + if ( t.tagName() == "p" ) + { + note += t.text() + "\n"; + } + } + } + frameBox = frameBox.nextSibling(); + } + newpage->setNoteText( note ); + } + else if ( ( name == "header" || name == "footer" ) && o.namespaceURI() == KoXmlNS::style || + ( name == "animations" && o.namespaceURI() == KoXmlNS::presentation) ) + { + //nothing + } + else + { + kdDebug() << "Unsupported object '" << name << "'" << endl; + } + context.styleStack().restore(); + } + } + +} + +int KPrDocument::createPresentationAnimation(const QDomElement& element, int order, bool increaseOrder) +{ + kdDebug()<<"void KPrDocument::createPresentationAnimation(const QDomElement& element)\n"; + int orderAnimation = increaseOrder ? 0 : order; + for ( QDomNode n = element.firstChild(); !n.isNull(); n = n.nextSibling() ) + { + QDomElement e = n.toElement(); + QCString tagName = e.tagName().latin1(); + if ( ! tagName.isEmpty() ) // only tags that open + { + const bool isPresentationNS = e.namespaceURI() == KoXmlNS::presentation; + if ( isPresentationNS && + ( tagName == "show-shape" || tagName == "hide-shape" ) ) + { + Q_ASSERT( e.hasAttributeNS( KoXmlNS::draw, "shape-id" ) ); + QString name = e.attributeNS( KoXmlNS::draw, "shape-id", QString::null ); + kdDebug()<<" insert animation " << tagName << " name :" << name << endl; + + if ( e.hasAttributeNS( KoXmlNS::koffice, "order-id" ) ) + { + orderAnimation = e.attributeNS( KoXmlNS::koffice, "order-id", QString::null ).toInt(); + } + + lstAnimation *tmp = new lstAnimation; + tmp->element = new QDomElement( e ); + tmp->order = orderAnimation; + if ( tagName == "show-shape" ) + { + m_loadingInfo->storePresentationShowAnimation( tmp, name ); + } + else + { + m_loadingInfo->storePresentationHideAnimation( tmp, name ); + } + if ( increaseOrder ) + ++orderAnimation; + } + else if ( tagName == "animation-group" && isPresentationNS ) + { + orderAnimation = createPresentationAnimation( e, orderAnimation, false ); + } + } + } + //increase when we finish it necessary for group object + ++orderAnimation; + return orderAnimation; +} + +void KPrDocument::fillStyleStack( const QDomElement& object, KoOasisContext & context, const char* family ) +{ + // See OpenDoc 9.2.15 Common Drawing Shape Attributes + // presentation:style-name is allways family presentation + if ( object.hasAttributeNS( KoXmlNS::presentation, "style-name" )) + { + context.fillStyleStack( object, KoXmlNS::presentation, "style-name", "presentation" ); + } + if ( object.hasAttributeNS( KoXmlNS::draw, "style-name" ) ) + { + context.fillStyleStack( object, KoXmlNS::draw, "style-name", family ); + } + // draw:tex-style-name is allways family paragraph + if ( object.hasAttributeNS( KoXmlNS::draw, "text-style-name" ) ) + { + context.fillStyleStack( object, KoXmlNS::draw, "text-style-name", "paragraph" ); + } + if ( object.hasAttributeNS( KoXmlNS::text, "style-name" ) ) + { + context.fillStyleStack( object, KoXmlNS::text, "style-name", family ); + } +} + +bool KPrDocument::loadXML( QIODevice * dev, const QDomDocument& doc ) +{ + QTime dt; + dt.start(); + m_loadingInfo = new KPrLoadingInfo( true ); + + ignoreSticky = FALSE; + bool b=false; + QDomElement docelem = doc.documentElement(); + const int syntaxVersion = docelem.attribute( "syntaxVersion" ).toInt(); + if ( syntaxVersion < 2 ) + { + // This is an old style document, before the current TextObject + // We have kprconverter.pl for it + kdWarning(33001) << "KPresenter document version 1. Launching perl script to convert it." << endl; + + // Read the full XML and write it to a temp file + KTempFile tmpFileIn; + tmpFileIn.setAutoDelete( true ); + dev->reset(); + tmpFileIn.file()->writeBlock( dev->readAll() ); // copy stresm to temp file + tmpFileIn.close(); + + // Launch the perl script on it + KTempFile tmpFileOut; + tmpFileOut.setAutoDelete( true ); + QString cmd = KGlobal::dirs()->findExe("perl"); + if (cmd.isEmpty()) + { + setErrorMessage( i18n("You don't appear to have PERL installed.\nIt is needed to convert this document.\nPlease install PERL and try again.")); + return false; + } + cmd += " "; + cmd += locate( "exe", "kprconverter.pl" ); + cmd += " "; + cmd += KProcess::quote( tmpFileIn.name() ); + cmd += " "; + cmd += KProcess::quote( tmpFileOut.name() ); + system( QFile::encodeName(cmd) ); + + // Build a new QDomDocument from the result + QString errorMsg; + int errorLine; + int errorColumn; + QDomDocument newdoc; + if ( ! newdoc.setContent( tmpFileOut.file(), &errorMsg, &errorLine, &errorColumn ) ) + { + kdError (33001) << "Parsing Error! Aborting! (in KPrDocument::loadXML)" << endl + << " Line: " << errorLine << " Column: " << errorColumn << endl + << " Message: " << errorMsg << endl; + setErrorMessage( i18n( "parsing error in the main document (converted from an old KPresenter format) at line %1, column %2\nError message: %3" ) + .arg( errorLine ).arg( errorColumn ).arg( i18n ( errorMsg.utf8() ) ) ); + return false; + } + b = loadXML( newdoc ); + } + else + b = loadXML( doc ); + + ignoreSticky = TRUE; + + if(_clean) + { + startBackgroundSpellCheck(); + } + if ( m_pageWhereLoadObject == 0 && m_insertFilePage == 0 ) + setModified( false ); + kdDebug(33001) << "Loading took " << (float)(dt.elapsed()) / 1000.0 << " seconds" << endl; + return b; +} + +void KPrDocument::createHeaderFooter() +{ + //add header/footer to sticky page + KoRect pageRect=m_masterPage->getPageRect(); + _header->setOrig(pageRect.topLeft()); + _header->setSize(pageRect.width(),20); + + _footer->setOrig(pageRect.left(),pageRect.bottom()-20); + _footer->setSize(pageRect.width(),20); + + m_masterPage->appendObject(_header); + m_masterPage->appendObject(_footer); +} + +void KPrDocument::insertEmbedded( KoStore *store, QDomElement topElem, KMacroCommand * macroCmd, KPrPage *page, int pos ) +{ + QDomElement elem = topElem.firstChild().toElement(); + for ( ; !elem.isNull() ; elem = elem.nextSibling().toElement() ) + { + kdDebug(33001) << "Element name: " << elem.tagName() << endl; + if(elem.tagName()=="EMBEDDED") { + KPrChild *ch = new KPrChild( this ); + KPrPartObject *kppartobject = 0L; + QRect r; + + QDomElement object=elem.namedItem("OBJECT").toElement(); + if(!object.isNull()) { + ch->load(object, true); // true == uppercase + r = ch->geometry(); + ch->loadDocument( store ); + insertChild( ch ); + kppartobject = new KPrPartObject( ch ); + } + QDomElement settings=elem.namedItem("SETTINGS").toElement(); + int zIndex = 0; + if ( settings.hasAttribute( "z-index" ) ) + { + zIndex = settings.attribute( "z-index" ).toInt(); + } + double offset = 0.0; + if(!settings.isNull() && kppartobject!=0) + offset=kppartobject->load(settings); + else if ( settings.isNull() ) // all embedded obj must have SETTING tags + { + delete kppartobject; + kppartobject = 0L; + return; + } + int index = m_pageList.findRef(page); + int pageIndex = (int)(offset/__pgLayout.ptHeight)+index; + int newPos=(int)((offset+index*__pgLayout.ptHeight)-pageIndex*__pgLayout.ptHeight); + kppartobject->setOrig(kppartobject->getOrig().x(),newPos); + + KPrInsertCmd *insertCmd = new KPrInsertCmd( i18n( "Insert Part Object" ), kppartobject, this,page ); + insertCmd->execute(); + if ( !macroCmd ) + macroCmd = new KMacroCommand( i18n("Insert Part Object")); + macroCmd->addCommand( insertCmd ); + if ( pos != 0 ) + { + const QPtrList& oldList( page->objectList() ); + // tz TODO this is not 100% correct + if ( static_cast( oldList.count() ) > pos + zIndex ) + { + page->takeObject( kppartobject ); + page->insertObject( kppartobject, pos + zIndex ); + KPrLowerRaiseCmd *lrCmd = new KPrLowerRaiseCmd( i18n("Insert Part Object"), + oldList, page->objectList(), + this, page ); + macroCmd->addCommand( lrCmd ); + } + } + } + } +} + +bool KPrDocument::loadXML( const QDomDocument &doc ) +{ + emit sigProgress( 0 ); + int activePage=0; + lastObj = -1; + bool allSlides = false; + // clean + if ( _clean ) { + __pgLayout = KoPageLayout::standardLayout(); + _spInfiniteLoop = false; + _spShowEndOfPresentationSlide = true; + _spManualSwitch = true; + _showPresentationDuration = false; + _xRnd = 20; + _yRnd = 20; + //_txtBackCol = white; + urlIntern = url().path(); + } + else + m_spellCheckIgnoreList.clear(); + emit sigProgress( 5 ); + + QDomElement document=doc.documentElement(); + // DOC + if(document.tagName()!="DOC") { + kdWarning(33001) << "Missing DOC" << endl; + setErrorMessage( i18n("Invalid document, DOC tag missing.") ); + return false; + } + + if(!document.hasAttribute("mime") || ( + document.attribute("mime")!="application/x-kpresenter" && + document.attribute("mime")!="application/vnd.kde.kpresenter" ) ) { + kdError(33001) << "Unknown mime type " << document.attribute("mime") << endl; + setErrorMessage( i18n("Invalid document, expected mimetype application/x-kpresenter or application/vnd.kde.kpresenter, got %1").arg(document.attribute("mime")) ); + return false; + } + if(document.hasAttribute("url")) + urlIntern=KURL(document.attribute("url")).path(); + + emit sigProgress( 10 ); + + QDomElement elem=document.firstChild().toElement(); + + uint childTotalCount=document.childNodes().count(); + uint childCount = 0; + + loadTextStyle( document ); + + while(!elem.isNull()) { + kdDebug(33001) << "Element name: " << elem.tagName() << endl; + if(elem.tagName()=="EMBEDDED") { + KPrChild *ch = new KPrChild( this ); + KPrPartObject *kppartobject = 0L; + QRect r; + + QDomElement object=elem.namedItem("OBJECT").toElement(); + if(!object.isNull()) { + ch->load(object, true); // true == uppercase + r = ch->geometry(); + insertChild( ch ); + kppartobject = new KPrPartObject( ch ); + //emit sig_insertObject( ch, kppartobject ); + } + QDomElement settings=elem.namedItem("SETTINGS").toElement(); + int tmp=0; + int pos = -1; + if ( settings.hasAttribute( "z-index" ) ) + { + pos = settings.attribute( "z-index" ).toInt(); + } + if(settings.hasAttribute("sticky")) + tmp=settings.attribute("sticky").toInt(); + bool sticky=static_cast(tmp); + double offset = 0.0; + if(!settings.isNull() && kppartobject!=0) + { + offset=kppartobject->load(settings); + } + else if ( settings.isNull() ) // all embedded obj must have SETTING tags + { + delete kppartobject; + kppartobject = 0L; + } + //hack for some old file, they don't have ORIG tag ! + if ( offset == -1.0 ) + offset = r.y(); + if ( sticky && !ignoreSticky && kppartobject ) + { + if ( pos == -1 ) + { + m_masterPage->appendObject( kppartobject ); + } + else + { + m_masterPage->insertObject( kppartobject, pos ); + } + kppartobject->setOrig(kppartobject->getOrig().x(), offset); + } + else if ( kppartobject ) { + if ( m_pageWhereLoadObject ) + { + kppartobject->setOrig(kppartobject->getOrig().x(), offset); + m_pageWhereLoadObject->insertObject( kppartobject, pos ); + } + else + { + insertObjectInPage( offset, kppartobject, pos ); + } + } + } else if(elem.tagName()=="PAPER" && _clean) { + if(elem.hasAttribute("format")) + __pgLayout.format=static_cast(elem.attribute("format").toInt()); + if(elem.hasAttribute("orientation")) + __pgLayout.orientation=static_cast(elem.attribute("orientation").toInt()); + if(elem.hasAttribute("ptWidth")) + __pgLayout.ptWidth = elem.attribute("ptWidth").toDouble(); + else if(elem.hasAttribute("inchWidth")) //compatibility + __pgLayout.ptWidth = INCH_TO_POINT( elem.attribute("inchWidth").toDouble() ); + else if(elem.hasAttribute("mmWidth")) //compatibility + __pgLayout.ptWidth = MM_TO_POINT( elem.attribute("mmWidth").toDouble() ); + if(elem.hasAttribute("ptHeight")) + __pgLayout.ptHeight = elem.attribute("ptHeight").toDouble(); + else if(elem.hasAttribute("inchHeight")) //compatibility + __pgLayout.ptHeight = INCH_TO_POINT( elem.attribute("inchHeight").toDouble() ); + else if(elem.hasAttribute("mmHeight")) //compatibility + __pgLayout.ptHeight = MM_TO_POINT( elem.attribute("mmHeight").toDouble() ); + if(elem.hasAttribute("unit")) + setUnit( static_cast(elem.attribute("unit").toInt()) ); + if ( elem.hasAttribute("tabStopValue")) + m_tabStop = elem.attribute("tabStopValue").toDouble(); + + if(elem.hasAttribute("width")) + __pgLayout.ptWidth = MM_TO_POINT( elem.attribute("width").toDouble() ); + if(elem.hasAttribute("height")) + __pgLayout.ptHeight = MM_TO_POINT( elem.attribute("height").toDouble() ); + + QDomElement borders=elem.namedItem("PAPERBORDERS").toElement(); + if(!borders.isNull()) { + if(borders.hasAttribute("left")) + __pgLayout.ptLeft = MM_TO_POINT( borders.attribute("left").toDouble() ); + if(borders.hasAttribute("top")) + __pgLayout.ptTop = MM_TO_POINT( borders.attribute("top").toDouble() ); + if(borders.hasAttribute("right")) + __pgLayout.ptRight = MM_TO_POINT( borders.attribute("right").toDouble() ); + if(borders.hasAttribute("bottom")) + __pgLayout.ptBottom = MM_TO_POINT( borders.attribute("bottom").toDouble() ); + if(borders.hasAttribute("ptLeft")) + __pgLayout.ptLeft = borders.attribute("ptLeft").toDouble(); + else if(borders.hasAttribute("inchLeft")) //compatibility + __pgLayout.ptLeft = INCH_TO_POINT( borders.attribute("inchLeft").toDouble() ); + else if(borders.hasAttribute("mmLeft")) //compatibility + __pgLayout.ptLeft = MM_TO_POINT( borders.attribute("mmLeft").toDouble() ); + if(borders.hasAttribute("ptRight")) + __pgLayout.ptRight = borders.attribute("ptRight").toDouble(); + else if(borders.hasAttribute("inchRight")) //compatibility + __pgLayout.ptRight = INCH_TO_POINT( borders.attribute("inchRight").toDouble() ); + else if(borders.hasAttribute("mmRight")) //compatibility + __pgLayout.ptRight = MM_TO_POINT( borders.attribute("mmRight").toDouble() ); + if(borders.hasAttribute("ptTop")) + __pgLayout.ptTop = borders.attribute("ptTop").toDouble(); + else if(borders.hasAttribute("inchTop")) //compatibility + __pgLayout.ptTop = INCH_TO_POINT( borders.attribute("inchTop").toDouble() ); + else if(borders.hasAttribute("mmTop")) //compatibility + __pgLayout.ptTop = MM_TO_POINT( borders.attribute("mmTop").toDouble() ); + if(borders.hasAttribute("ptBottom")) + __pgLayout.ptBottom = borders.attribute("ptBottom").toDouble(); + else if(borders.hasAttribute("inchBottom")) //compatibility + __pgLayout.ptBottom = INCH_TO_POINT( borders.attribute("inchBottom").toDouble() ); + else if(borders.hasAttribute("mmBottom")) //compatibility + __pgLayout.ptBottom = MM_TO_POINT( borders.attribute("inchBottom").toDouble() ); + } + // PAPER found and parsed -> apply page layout + // e.g. the text objects need it + if ( _clean ) + setPageLayout( __pgLayout ); + + } else if(elem.tagName()=="VARIABLESETTINGS" && _clean){ + getVariableCollection()->variableSetting()->load(document); + //by default display real variable value + if ( !isReadWrite()) + getVariableCollection()->variableSetting()->setDisplayFieldCode(false); + + } + else if(elem.tagName()=="BACKGROUND") { + int red=0, green=0, blue=0; + if(elem.hasAttribute("xRnd")) + _xRnd = elem.attribute("xRnd").toInt(); + if(elem.hasAttribute("yRnd")) + _yRnd = elem.attribute("yRnd").toInt(); + if(elem.hasAttribute("bred")) + red = elem.attribute("bred").toInt(); + if(elem.hasAttribute("bgreen")) + green = elem.attribute("bgreen").toInt(); + if(elem.hasAttribute("bblue")) + blue = elem.attribute("bblue").toInt(); + loadBackground(elem); + } else if(elem.tagName()=="HEADER") { + if ( _clean /*don't reload header footer, header/footer was created at the beginning || !hasHeader()*/ ) { + if(elem.hasAttribute("show")) { + setHeader(static_cast(elem.attribute("show").toInt())); + } + _header->load(elem); + } + } else if ( elem.tagName()=="HEADERFOOTERBYPAGE" ) { + if ( elem.hasAttribute( "value" ) ) { + m_loadingInfo->m_headerFooterByPage = true; + } + } else if(elem.tagName()=="FOOTER") { + if ( _clean /*|| !hasFooter()*/ ) { + if(elem.hasAttribute("show")) { + setFooter( static_cast(elem.attribute("show").toInt() ) ); + } + _footer->load(elem); + } + }else if( elem.tagName()=="HELPLINES"){ + if ( _clean ) { + if(elem.hasAttribute("show")) { + setShowGuideLines( static_cast(elem.attribute("show").toInt() ) ); + } + loadGuideLines( elem ); + } + }else if( elem.tagName()=="SPELLCHECKIGNORELIST"){ + QDomElement spellWord=elem.toElement(); + spellWord=spellWord.firstChild().toElement(); + while ( !spellWord.isNull() ) + { + if ( spellWord.tagName()=="SPELLCHECKIGNOREWORD" ) + { + m_spellCheckIgnoreList.append(spellWord.attribute("word")); + } + spellWord=spellWord.nextSibling().toElement(); + } + }else if(elem.tagName()=="ATTRIBUTES" && _clean) { + if(elem.hasAttribute("activePage")) + activePage=elem.attribute("activePage").toInt(); + if(elem.hasAttribute("gridx")) + m_gridX = elem.attribute("gridx").toDouble(); + if(elem.hasAttribute("gridy")) + m_gridY = elem.attribute("gridy").toDouble(); + if(elem.hasAttribute("snaptogrid")) + m_bSnapToGrid = (bool)elem.attribute("snaptogrid").toInt(); + } else if(elem.tagName()=="PAGETITLES") { + loadTitle(elem); + } else if(elem.tagName()=="PAGENOTES") { + loadNote(elem); + } else if(elem.tagName()=="OBJECTS") { + //FIXME********************** +#if 0 + lastObj = _objectList->count() - 1; +#endif + //don't add command we don't paste object + KCommand * cmd =loadObjects(elem); + if ( cmd ) + delete cmd; + } else if(elem.tagName()=="INFINITLOOP") { + if(_clean) { + if(elem.hasAttribute("value")) + _spInfiniteLoop = static_cast(elem.attribute("value").toInt()); + } + } else if(elem.tagName()=="SHOWENDOFPRESENTATIONSLIDE") { + if(_clean) { + if(elem.hasAttribute("value")) + _spShowEndOfPresentationSlide = static_cast(elem.attribute("value").toInt()); + } + } else if(elem.tagName()=="PRESSPEED") { + if(_clean) { + if(elem.hasAttribute("value")) + m_loadingInfo->presSpeed = elem.attribute("value").toInt(); + } + } else if(elem.tagName()=="MANUALSWITCH") { + if(_clean) { + if(elem.hasAttribute("value")) + _spManualSwitch = static_cast(elem.attribute("value").toInt()); + } + } else if(elem.tagName()=="SHOWPRESENTATIONDURATION") { + if(_clean) { + if(elem.hasAttribute("value")) + _showPresentationDuration = static_cast(elem.attribute("value").toInt()); + } + } else if(elem.tagName()=="PRESSLIDES") { + if(elem.hasAttribute("value") && elem.attribute("value").toInt()==0) + allSlides = TRUE; + } else if ( elem.tagName()=="DEFAULTCUSTOMSLIDESHOWNAME" ) { + if(elem.hasAttribute("name") ) + m_presentationName=elem.attribute( "name" ); + } else if ( elem.tagName()=="CUSTOMSLIDESHOWCONFIG" ) { + if ( _clean ) { + QMap name2page; + int pos = 1; + for ( QPtrListIterator it( m_pageList ); it.current(); ++it ) + { + name2page.insert( "page" + QString::number( pos++ ), it.current() ) ; + } + + QDomElement slide=elem.firstChild().toElement(); + while(!slide.isNull()) { + if(slide.tagName()=="CUSTOMSLIDESHOW") { + QStringList tmp = QStringList::split( ",", slide.attribute( "pages" ) ); + QValueList pageList; + for ( QStringList::Iterator it = tmp.begin(); it != tmp.end(); ++it ) + { + if ( name2page.contains( *it ) ) + { + kdDebug(33001) << "slide show " << slide.attribute( "name" ) << " page = " << *it << endl; + pageList.push_back( name2page[*it] ); + } + } + if ( ! pageList.empty() ) + { + m_customListSlideShow.insert( slide.attribute( "name" ), pageList ); + } + } + slide=slide.nextSibling().toElement(); + } + } + } else if(elem.tagName()=="SELSLIDES") { + if( _clean ) { // Skip this when loading a single page + QDomElement slide=elem.firstChild().toElement(); + while(!slide.isNull()) { + if(slide.tagName()=="SLIDE") { + int nr = -1; + bool show = false; + if(slide.hasAttribute("nr")) + nr=slide.attribute("nr").toInt(); + if(slide.hasAttribute("show")) + show=static_cast(slide.attribute("show").toInt()); + if ( nr >= 0 ) + { + //kdDebug(33001) << "KPrDocument::loadXML m_selectedSlides nr=" << nr << " show=" << show << endl; + if ( nr > ( (int)m_pageList.count() - 1 ) ) + { + for (int i=(m_pageList.count()-1); islideSelected(show); + } else kdWarning(33001) << "Parse error. No nr in !" << endl; + } + slide=slide.nextSibling().toElement(); + } + } + } else if ( elem.tagName() == "SOUNDS" ) { + loadUsedSoundFileFromXML( elem ); + } + elem=elem.nextSibling().toElement(); + + emit sigProgress( childCount * ( 70/childTotalCount ) + 15 ); + childCount += 1; + } + + loadPictureMap( document ); + + if(activePage!=-1) + m_initialActivePage=m_pageList.at(activePage); + if ( m_pageWhereLoadObject == 0 && m_insertFilePage == 0 ) + setModified(false); + + return true; +} + +void KPrDocument::loadTextStyle( const QDomElement& domElement ) +{ + QDomElement style = domElement.namedItem( "STYLES" ).toElement(); + if ( _clean && ! style.isNull() ) + loadStyleTemplates( style ); +} + +void KPrDocument::loadPictureMap ( const QDomElement& domElement ) +{ + m_pictureMap.clear(); + + // + QDomElement picturesElem = domElement.namedItem( "PICTURES" ).toElement(); + if ( !picturesElem.isNull() ) + m_pictureCollection.readXML( picturesElem, m_pictureMap ); + + // + QDomElement pixmapsElem = domElement.namedItem( "PIXMAPS" ).toElement(); + if ( !pixmapsElem.isNull() ) + m_pictureCollection.readXML( pixmapsElem, m_pictureMap ); + + // + QDomElement clipartsElem = domElement.namedItem( "CLIPARTS" ).toElement(); + if ( !clipartsElem.isNull() ) + m_pictureCollection.readXML( pixmapsElem, m_pictureMap ); +} + +void KPrDocument::loadBackground( const QDomElement &element ) +{ + kdDebug(33001) << "KPrDocument::loadBackground" << endl; + QDomElement page=element.firstChild().toElement(); + int i=m_insertFilePage; + while(!page.isNull()) { + if(m_pageWhereLoadObject) + { + kdDebug(33001) << "m_pageWhereLoadObject->load(...)" << m_pageWhereLoadObject << endl; + m_pageWhereLoadObject->load(page); + break; + } + else + { + if ( page.tagName() == "MASTERPAGE" ) + { + m_masterPage->load( page ); + } + else + { + //test if there is a page at this index + //=> don't add new page if there is again a page + if ( i > ( (int)m_pageList.count() - 1 ) ) + m_pageList.append( new KPrPage( this, m_masterPage ) ); + m_pageList.at(i)->load(page); + i++; + } + } + page=page.nextSibling().toElement(); + } +} + +KCommand *KPrDocument::loadObjects( const QDomElement &element, bool paste ) +{ + ObjType t = OT_LINE; + QDomElement obj=element.firstChild().toElement(); + QValueList pasteObjects; + while(!obj.isNull()) { + if(obj.tagName()=="OBJECT" ) { + bool sticky=false; + int tmp=0; + if(obj.hasAttribute("type")) + tmp=obj.attribute("type").toInt(); + t=static_cast(tmp); + tmp=0; + if(obj.hasAttribute("sticky")) + tmp=obj.attribute("sticky").toInt(); + sticky=static_cast(tmp); + double offset=0; + switch ( t ) { + case OT_LINE: { + KPrLineObject *kplineobject = new KPrLineObject(); + offset=kplineobject->load(obj); + if ( sticky && !ignoreSticky) + { + m_masterPage->appendObject(kplineobject); + kplineobject->setOrig(kplineobject->getOrig().x(),offset); + } + else if (m_pageWhereLoadObject && paste) { + kplineobject->setOrig(kplineobject->getOrig().x(),offset); + pasteObjects.append( kplineobject ); + } + else if( m_pageWhereLoadObject &&!paste) + { + m_pageWhereLoadObject->appendObject(kplineobject); + kplineobject->setOrig(kplineobject->getOrig().x(),offset); + } + else + insertObjectInPage(offset, kplineobject); + } break; + case OT_RECT: { + KPrRectObject *kprectobject = new KPrRectObject(); + offset=kprectobject->load(obj); + if ( sticky && !ignoreSticky) + { + m_masterPage->appendObject(kprectobject); + kprectobject->setOrig(kprectobject->getOrig().x(),offset); + } + else if (m_pageWhereLoadObject && paste) { + kprectobject->setOrig(kprectobject->getOrig().x(),offset); + pasteObjects.append( kprectobject ); + } + else if( m_pageWhereLoadObject &&!paste) + { + m_pageWhereLoadObject->appendObject(kprectobject); + kprectobject->setOrig(kprectobject->getOrig().x(),offset); + } + else + insertObjectInPage(offset, kprectobject); + } break; + case OT_ELLIPSE: { + KPrEllipseObject *kpellipseobject = new KPrEllipseObject(); + offset=kpellipseobject->load(obj); + if ( sticky && !ignoreSticky) + { + m_masterPage->appendObject(kpellipseobject); + kpellipseobject->setOrig(kpellipseobject->getOrig().x(),offset); + } + else if ( m_pageWhereLoadObject && paste) + { + kpellipseobject->setOrig(kpellipseobject->getOrig().x(),offset); + pasteObjects.append( kpellipseobject ); + } + else if( m_pageWhereLoadObject &&!paste) + { + m_pageWhereLoadObject->appendObject(kpellipseobject); + kpellipseobject->setOrig(kpellipseobject->getOrig().x(),offset); + } + else + insertObjectInPage(offset, kpellipseobject); + } break; + case OT_PIE: { + KPrPieObject *kppieobject = new KPrPieObject(); + offset=kppieobject->load(obj); + if ( sticky && !ignoreSticky) + { + m_masterPage->appendObject(kppieobject); + kppieobject->setOrig(kppieobject->getOrig().x(),offset); + } + else if ( m_pageWhereLoadObject && paste) { + kppieobject->setOrig(kppieobject->getOrig().x(),offset); + pasteObjects.append( kppieobject ); + } + else if( m_pageWhereLoadObject &&!paste) + { + m_pageWhereLoadObject->appendObject(kppieobject); + kppieobject->setOrig(kppieobject->getOrig().x(),offset); + } + else + insertObjectInPage(offset, kppieobject); + } break; + case OT_AUTOFORM: { + KPrAutoformObject *kpautoformobject = new KPrAutoformObject(); + offset=kpautoformobject->load(obj); + if ( sticky && !ignoreSticky) + { + m_masterPage->appendObject(kpautoformobject); + kpautoformobject->setOrig(kpautoformobject->getOrig().x(),offset); + } + else if ( m_pageWhereLoadObject&& paste) { + kpautoformobject->setOrig(kpautoformobject->getOrig().x(),offset); + pasteObjects.append( kpautoformobject ); + } + else if( m_pageWhereLoadObject &&!paste) + { + m_pageWhereLoadObject->appendObject(kpautoformobject); + kpautoformobject->setOrig(kpautoformobject->getOrig().x(),offset); + } + else + insertObjectInPage(offset, kpautoformobject); + } break; + case OT_TEXT: { + KPrTextObject *kptextobject = new KPrTextObject( this ); + offset=kptextobject->load(obj); + if ( sticky && !ignoreSticky) + { + m_masterPage->appendObject(kptextobject); + kptextobject->setOrig(kptextobject->getOrig().x(),offset); + } + else if ( m_pageWhereLoadObject && paste) { + kptextobject->setOrig(kptextobject->getOrig().x(),offset); + pasteObjects.append( kptextobject ); + } + else if( m_pageWhereLoadObject &&!paste) + { + m_pageWhereLoadObject->appendObject(kptextobject); + kptextobject->setOrig(kptextobject->getOrig().x(),offset); + } + else + insertObjectInPage(offset, kptextobject); + } break; + case OT_CLIPART: + case OT_PICTURE: { + KPrPixmapObject *kppixmapobject = new KPrPixmapObject( pictureCollection() ); + offset=kppixmapobject->load(obj); + if ( sticky && !ignoreSticky) + { + m_masterPage->appendObject(kppixmapobject); + kppixmapobject->setOrig(kppixmapobject->getOrig().x(),offset); + } + else if ( m_pageWhereLoadObject && paste) { + kppixmapobject->setOrig(kppixmapobject->getOrig().x(),offset); + pasteObjects.append( kppixmapobject ); + kppixmapobject->reload(); + } + else if( m_pageWhereLoadObject &&!paste) + { + m_pageWhereLoadObject->appendObject(kppixmapobject); + kppixmapobject->setOrig(kppixmapobject->getOrig().x(),offset); + } + else + insertObjectInPage(offset, kppixmapobject); + } break; + case OT_FREEHAND: { + KPrFreehandObject *kpfreehandobject = new KPrFreehandObject(); + offset=kpfreehandobject->load(obj); + + if ( sticky && !ignoreSticky) + { + m_masterPage->appendObject(kpfreehandobject); + kpfreehandobject->setOrig(kpfreehandobject->getOrig().x(),offset); + } + else if ( m_pageWhereLoadObject && paste) { + kpfreehandobject->setOrig(kpfreehandobject->getOrig().x(),offset); + pasteObjects.append( kpfreehandobject ); + } + else if( m_pageWhereLoadObject &&!paste) + { + m_pageWhereLoadObject->appendObject(kpfreehandobject); + kpfreehandobject->setOrig(kpfreehandobject->getOrig().x(),offset); + } + else + insertObjectInPage(offset,kpfreehandobject); + } break; + case OT_POLYLINE: { + KPrPolylineObject *kppolylineobject = new KPrPolylineObject(); + offset=kppolylineobject->load(obj); + if ( sticky && !ignoreSticky) + { + m_masterPage->appendObject(kppolylineobject); + kppolylineobject->setOrig(kppolylineobject->getOrig().x(),offset); + } + else if (m_pageWhereLoadObject && paste) { + kppolylineobject->setOrig(kppolylineobject->getOrig().x(),offset); + pasteObjects.append( kppolylineobject ); + } + else if( m_pageWhereLoadObject &&!paste) + { + m_pageWhereLoadObject->appendObject(kppolylineobject); + kppolylineobject->setOrig(kppolylineobject->getOrig().x(),offset); + } + else + insertObjectInPage(offset, kppolylineobject); + } break; + case OT_QUADRICBEZIERCURVE: { + KPrQuadricBezierCurveObject *kpQuadricBezierCurveObject = new KPrQuadricBezierCurveObject(); + offset=kpQuadricBezierCurveObject->load(obj); + if ( sticky && !ignoreSticky) + { + m_masterPage->appendObject(kpQuadricBezierCurveObject); + kpQuadricBezierCurveObject->setOrig(kpQuadricBezierCurveObject->getOrig().x(),offset); + } + else if ( m_pageWhereLoadObject && paste) { + kpQuadricBezierCurveObject->setOrig(kpQuadricBezierCurveObject->getOrig().x(),offset); + pasteObjects.append( kpQuadricBezierCurveObject ); + } + else if( m_pageWhereLoadObject &&!paste) + { + m_pageWhereLoadObject->appendObject(kpQuadricBezierCurveObject); + kpQuadricBezierCurveObject->setOrig(kpQuadricBezierCurveObject->getOrig().x(),offset); + } + else + insertObjectInPage(offset, kpQuadricBezierCurveObject); + } break; + case OT_CUBICBEZIERCURVE: { + KPrCubicBezierCurveObject *kpCubicBezierCurveObject = new KPrCubicBezierCurveObject(); + offset=kpCubicBezierCurveObject->load(obj); + if ( sticky && !ignoreSticky) + { + m_masterPage->appendObject(kpCubicBezierCurveObject); + kpCubicBezierCurveObject->setOrig(kpCubicBezierCurveObject->getOrig().x(),offset); + } + else if ( m_pageWhereLoadObject && paste) { + kpCubicBezierCurveObject->setOrig(kpCubicBezierCurveObject->getOrig().x(),offset); + pasteObjects.append( kpCubicBezierCurveObject ); + } + else if( m_pageWhereLoadObject &&!paste) + { + m_pageWhereLoadObject->appendObject(kpCubicBezierCurveObject); + kpCubicBezierCurveObject->setOrig(kpCubicBezierCurveObject->getOrig().x(),offset); + } + else + insertObjectInPage(offset, kpCubicBezierCurveObject); + } break; + case OT_POLYGON: { + KPrPolygonObject *kpPolygonObject = new KPrPolygonObject(); + offset=kpPolygonObject->load( obj ); + if ( sticky && !ignoreSticky) + { + m_masterPage->appendObject(kpPolygonObject); + kpPolygonObject->setOrig(kpPolygonObject->getOrig().x(),offset); + } + else if ( m_pageWhereLoadObject && paste) { + kpPolygonObject->setOrig(kpPolygonObject->getOrig().x(),offset); + pasteObjects.append( kpPolygonObject ); + } + else if( m_pageWhereLoadObject &&!paste) + { + m_pageWhereLoadObject->appendObject(kpPolygonObject); + kpPolygonObject->setOrig(kpPolygonObject->getOrig().x(),offset); + } + else + insertObjectInPage(offset, kpPolygonObject); + } break; + case OT_CLOSED_LINE: { + KPrClosedLineObject *kpClosedLinneObject = new KPrClosedLineObject(); + offset = kpClosedLinneObject->load( obj ); + if ( sticky && !ignoreSticky) { + m_masterPage->appendObject( kpClosedLinneObject ); + kpClosedLinneObject->setOrig( kpClosedLinneObject->getOrig().x(), offset ); + } + else if ( m_pageWhereLoadObject && paste ) { + kpClosedLinneObject->setOrig( kpClosedLinneObject->getOrig().x(), offset ); + pasteObjects.append( kpClosedLinneObject ); + } + else if( m_pageWhereLoadObject &&!paste) + { + m_pageWhereLoadObject->appendObject( kpClosedLinneObject ); + kpClosedLinneObject->setOrig( kpClosedLinneObject->getOrig().x(), offset ); + } + else + insertObjectInPage( offset, kpClosedLinneObject ); + } break; + case OT_GROUP: { + KPrGroupObject *kpgroupobject = new KPrGroupObject(); + offset=kpgroupobject->load(obj, this); + if ( sticky && !ignoreSticky) + { + m_masterPage->appendObject(kpgroupobject); + kpgroupobject->setOrig(kpgroupobject->getOrig().x(),offset); + } + else if ( m_pageWhereLoadObject && paste) { + kpgroupobject->setOrig(kpgroupobject->getOrig().x(),offset); + pasteObjects.append( kpgroupobject ); + } + else if( m_pageWhereLoadObject &&!paste) + { + m_pageWhereLoadObject->appendObject(kpgroupobject); + kpgroupobject->setOrig(kpgroupobject->getOrig().x(),offset); + } + else + insertObjectInPage(offset, kpgroupobject); + } break; + default: break; + } + } + obj=obj.nextSibling().toElement(); + } + + KPrInsertCmd *insertCmd = 0; + if ( ! pasteObjects.empty() ) + { + insertCmd = new KPrInsertCmd( i18n( "Paste Objects" ), pasteObjects, + this , m_pageWhereLoadObject ); + insertCmd->execute(); + } + return insertCmd; +} + +void KPrDocument::loadTitle( const QDomElement &element ) +{ + QDomElement title=element.firstChild().toElement(); + int i=m_insertFilePage; + while ( !title.isNull() ) { + if ( title.tagName()=="Title" ) + { + //test if there is a page at this index + //=> don't add new page if there is again a page + if(!m_pageWhereLoadObject) + { + if ( i > ( (int)m_pageList.count() - 1 ) ) + m_pageList.append( new KPrPage( this, m_masterPage ) ); + m_pageList.at(i)->insertManualTitle(title.attribute("title")); + i++; + } + else + m_pageWhereLoadObject->insertManualTitle(title.attribute("title")); + } + title=title.nextSibling().toElement(); + } +} + +void KPrDocument::loadNote( const QDomElement &element ) +{ + QDomElement note=element.firstChild().toElement(); + int i=m_insertFilePage; + while ( !note.isNull() ) { + if ( note.tagName()=="Note" ) + { + //test if there is a page at this index + //=> don't add new page if there is again a page + if(!m_pageWhereLoadObject) + { + if ( i > ( (int)m_pageList.count() - 1 ) ) + m_pageList.append( new KPrPage( this, m_masterPage ) ); + m_pageList.at(i)->setNoteText(note.attribute("note")); + i++; + } + else + m_pageWhereLoadObject->setNoteText(note.attribute("note")); + } + note=note.nextSibling().toElement(); + } +} + +void KPrDocument::loadUsedSoundFileFromXML( const QDomElement &element ) +{ + usedSoundFile = QStringList(); + haveNotOwnDiskSoundFile = QStringList(); + QDomElement fileElement = element.firstChild().toElement(); + while ( !fileElement.isNull() ) { + if ( fileElement.tagName() == "FILE" ) { + QString fileName; + if ( fileElement.hasAttribute( "name" ) ) + fileName = fileElement.attribute( "name" ); + + if ( fileElement.hasAttribute( "filename" ) ) { + QString name = fileElement.attribute( "filename" ); + QFile _file( name ); + if ( _file.open( IO_ReadOnly ) ) { + fileName = name; + _file.close(); + } + else + haveNotOwnDiskSoundFile.append( name ); + } + + usedSoundFile.append( fileName ); + + fileElement = fileElement.nextSibling().toElement(); + } + } +} + +void KPrDocument::loadImagesFromStore( KoStore *_store ) +{ + if ( _store ) { + m_pictureCollection.readFromStore( _store, m_pictureMap ); + m_pictureMap.clear(); // Release memory + } +} + +bool KPrDocument::completeLoading( KoStore* _store ) +{ + kdDebug()<<"bool KPrDocument::completeLoading( KoStore* _store )*************************\n"; + emit sigProgress( 80 ); + + if ( _store ) { + loadImagesFromStore( _store ); + emit sigProgress( 90 ); + + if ( !usedSoundFile.isEmpty() ) + loadUsedSoundFileFromStore( _store, usedSoundFile ); + + if ( _clean ) + createHeaderFooter(); + //else { + //m_pageList.last()->updateBackgroundSize(); + //} + + + if ( saveOnlyPage == -1 ) { + // ### following call independant of saveOnlyPage's value? + m_masterPage->completeLoading( _clean, lastObj ); + QPtrListIterator it( m_pageList ); + for ( ; it.current(); ++it ) + it.current()->completeLoading( _clean, lastObj ); + } + } else { + if ( _clean ) + { + /// ### this has already been done, no? + setPageLayout( __pgLayout ); + } + else + setPageLayout( m_pageLayout ); + } + + compatibilityFromOldFileFormat(); + + emit sigProgress( 100 ); + recalcVariables( VT_FIELD ); + emit sigProgress( -1 ); + + connect( documentInfo(), SIGNAL( sigDocumentInfoModifed()),this,SLOT(slotDocumentInfoModifed() ) ); + //desactivate bgspellchecking + //attributes isReadWrite is not placed at the beginning ! + if ( !isReadWrite()) + enableBackgroundSpellCheck( false ); + return true; +} + +void KPrDocument::loadUsedSoundFileFromStore( KoStore *_store, QStringList _list ) +{ + int i = m_insertFilePage; + QStringList::Iterator it = _list.begin(); + for ( ; it != _list.end(); ++it ) { + QString soundFile = *it; + + if ( _store->open( soundFile ) ) { + kdDebug( 33001 ) << "Not found file on disk. Use this( " << soundFile << " ) file." << endl; + KoStoreDevice dev( _store ); + int size = _store->size(); + char *data = new char[size]; + dev.readBlock( data, size ); + + int position = soundFile.findRev( '.' ); + QString format = soundFile.right( soundFile.length() - position ); + KTempFile *tmpFile = new KTempFile( QString::null, format ); + tmpFile->setAutoDelete( true ); + tmpFile->file()->writeBlock( data, size ); + tmpFile->close(); + + QString tmpFileName = tmpFile->name(); + tmpSoundFileList.append( tmpFile ); + + QString _fileName = *haveNotOwnDiskSoundFile.at( i ); + ++i; + + QPtrListIterator it( m_pageList ); + for ( ; it.current(); ++it ) { + QString _file = it.current()->getPageSoundFileName(); + if ( !_file.isEmpty() && _file == _fileName ) + it.current()->setPageSoundFileName( tmpFileName ); + + QPtrListIterator oIt( it.current()->objectList() ); + for ( ; oIt.current(); ++oIt ) { + _file = oIt.current()->getAppearSoundEffectFileName(); + if ( !_file.isEmpty() && _file == _fileName ) + oIt.current()->setAppearSoundEffectFileName( tmpFileName ); + + _file = oIt.current()->getDisappearSoundEffectFileName(); + if ( !_file.isEmpty() && _file == _fileName ) + oIt.current()->setDisappearSoundEffectFileName( tmpFileName ); + } + } + + _store->close(); + delete[] data; + } + else { + kdDebug( 33001 ) << "Found this( " << soundFile << " ) file on disk" << endl; + } + } +} + +void KPrDocument::setPageLayout( const KoPageLayout &pgLayout ) +{ + // if ( _pageLayout == pgLayout ) + // return; + + m_pageLayout = pgLayout; + + //for ( int i = 0; i < static_cast( m_pageList.count() ); i++ ) + // m_pageList.at( i )->updateBackgroundSize(); + + repaint( false ); + layout(); + // don't setModified(true) here, since this is called on startup +} + +//when we change pagelayout we must re-position header/footer +void KPrDocument::updateHeaderFooterPosition( ) +{ + KoRect pageRect=m_masterPage->getPageRect(); + QRect oldBoundingRect = zoomHandler()->zoomRect( _header->getRepaintRect() ); + _header->setOrig(pageRect.topLeft ()); + _header->setSize(pageRect.width(),_header->getSize().height()); + repaint( oldBoundingRect ); + repaint(_header); + + oldBoundingRect = zoomHandler()->zoomRect( _footer->getRepaintRect() ); + _footer->setOrig(pageRect.left(),pageRect.bottom()-_footer->getSize().height()); + _footer->setSize(pageRect.width(),_footer->getSize().height()); + repaint(oldBoundingRect); + repaint(_footer); +} + +bool KPrDocument::initDoc(InitDocFlags flags, QWidget* parentWidget) +{ + + if (flags==KoDocument::InitDocEmpty) + { + QString fileName( locate("kpresenter_template", "Screenpresentations/.source/Plain.kpt", + KPrFactory::global() ) ); + objStartY = 0; + _clean = true; + bool ok = loadNativeFormat( fileName ); + if ( !ok ) + showLoadingErrorDialog(); + resetURL(); + setEmpty(); + return ok; + } + + QString file; + KoTemplateChooseDia::ReturnType ret; + KoTemplateChooseDia::DialogType dlgtype; + if (flags != InitDocFileNew) + dlgtype = KoTemplateChooseDia::Everything; + else + dlgtype = KoTemplateChooseDia::OnlyTemplates; + + ret = KoTemplateChooseDia::choose( KPrFactory::global(), file, + dlgtype, "kpresenter_template", parentWidget ); + if ( ret == KoTemplateChooseDia::Template ) { + _clean = true; //was a parameter called "clean", but unused + bool ok = loadNativeFormat( file ); + if ( !ok ) + showLoadingErrorDialog(); + objStartY = 0; + _clean = true; + resetURL(); + setEmpty(); + return ok; + } else if ( ret == KoTemplateChooseDia::File ) { + objStartY = 0; + _clean = true; + KURL url( file ); + bool ok = openURL( url ); + return ok; + } else if ( ret == KoTemplateChooseDia::Empty ) { + QString fileName( locate("kpresenter_template", "Screenpresentations/.source/Plain.kpt", + KPrFactory::global() ) ); + objStartY = 0; + _clean = true; + bool ok = loadNativeFormat( fileName ); + if ( !ok ) + showLoadingErrorDialog(); + resetURL(); + setEmpty(); + return ok; + } else + return false; +} + +void KPrDocument::openExistingFile( const QString& file ) +{ + objStartY = 0; + _clean = true; + KoDocument::openExistingFile( file ); +} + +void KPrDocument::openTemplate( const QString& file ) +{ + KoDocument::openTemplate( file ); + objStartY = 0; + _clean = true; +} + +void KPrDocument::initEmpty() +{ + QString fileName( locate("kpresenter_template", "Screenpresentations/.source/Plain.kpt", + KPrFactory::global() ) ); + objStartY = 0; + _clean = true; + setModified(true); + bool ok = loadNativeFormat( fileName ); + if ( !ok ) + showLoadingErrorDialog(); + resetURL(); +} + +void KPrDocument::setEmpty() +{ + KoDocument::setEmpty(); + // Whether loaded from template or from empty doc: this is a new one -> set creation date + m_varColl->variableSetting()->setCreationDate(QDateTime::currentDateTime()); + recalcVariables( VT_DATE ); // , VST_CREATION_DATE ... + // If we then load a document, it will override that date. +} + +void KPrDocument::setGridValue( double _x, double _y, bool _replace ) +{ + oldGridX = m_gridX; + oldGridY = m_gridY; + m_gridX=_x; + m_gridY=_y; + if ( _replace ) + replaceObjs(); +} + +void KPrDocument::repaint( bool erase ) +{ + QPtrListIterator it( views() ); + for( ; it.current(); ++it ) { + KPrCanvas* canvas = ((KPrView*)it.current())->getCanvas(); + canvas->repaint( erase ); + } +} + +void KPrDocument::repaint( const QRect& rect ) +{ + QRect r; + QPtrListIterator it( views() ); + for( ; it.current(); ++it ) { + r = rect; + KPrCanvas* canvas = ((KPrView*)it.current())->getCanvas(); + r.moveTopLeft( QPoint( r.x() - canvas->diffx(), + r.y() - canvas->diffy() ) ); + canvas->update( r ); + } +} + +void KPrDocument::layout(KPrObject *kpobject) +{ + KPrTextObject * obj = dynamic_cast( kpobject ); + if (obj) + obj->layout(); +} + +void KPrDocument::layout() +{ + QPtrListIterator it( views() ); + for( ; it.current(); ++it ) { + KPrCanvas* canvas = ((KPrView*)it.current())->getCanvas(); + canvas->layout(); + } +} + +void KPrDocument::repaint( KPrObject *kpobject ) +{ + repaint( m_zoomHandler->zoomRect( kpobject->getRepaintRect() ) ); +} + +QValueList KPrDocument::getPageEffectSteps( unsigned int num ) +{ + return m_pageList.at(num)->getEffectSteps(); +} + +QRect KPrDocument::getPageRect( bool decBorders ) const +{ + int pw, ph, bl = static_cast(m_pageLayout.ptLeft); + int br = static_cast(m_pageLayout.ptRight); + int bt = static_cast(m_pageLayout.ptTop); + int bb = static_cast(m_pageLayout.ptBottom); + int wid = static_cast(m_pageLayout.ptWidth); + int hei = static_cast(m_pageLayout.ptHeight); + + if ( !decBorders ) { + br = 0; + bt = 0; + bl = 0; + bb = 0; + } + + pw = wid - ( bl + br ); + ph = hei - ( bt + bb ); + + return QRect( bl, bt, pw, ph ); +} + +int KPrDocument::getLeftBorder() const +{ + return static_cast(m_pageLayout.ptLeft); +} + +int KPrDocument::getTopBorder() const +{ + return static_cast(m_pageLayout.ptTop); +} + +int KPrDocument::getBottomBorder() const +{ + return static_cast(m_pageLayout.ptBottom); +} + +int KPrDocument::getRightBorder() const +{ + return static_cast(m_pageLayout.ptRight); +} + +void KPrDocument::deletePage( int _page ) +{ + kdDebug(33001) << "KPrDocument::deletePage " << _page << endl; + //m_pageList.at(_page)->deletePage(); + if ( m_pageList.count()==1 ) + return; + KPrDeletePageCmd *cmd = new KPrDeletePageCmd( i18n("Delete Slide"), _page, this ); + cmd->execute(); + addCommand(cmd); +} + +void KPrDocument::insertPage( KPrPage *page, int currentPageNum, int insertPageNum ) +{ + // check if page was allready deleted + int pos = m_deletedPageList.findRef( page ); + if ( pos != -1 ) + m_deletedPageList.take( pos ); + + m_pageList.insert( insertPageNum, page ); + + pageOrderChanged(); + //activate this page in all views which on slide currentPageNum + QPtrListIterator it( views() ); + for (; it.current(); ++it ) + { + KPrView *view = static_cast( it.current() ); + view->addSideBarItem( insertPageNum ); + + // change to the new page if the view was on the current page. + if ( (int)view->getCurrPgNum() - 1 == currentPageNum ) + { + view->skipToPage( insertPageNum ); + } + else // recalc the page number as it might have been changed + { + view->recalcCurrentPageNum(); + } + } +} + +void KPrDocument::takePage( KPrPage *page, int pageNum ) +{ + int pos = m_pageList.findRef( page ); + m_pageList.take( pos ); + m_deletedPageList.append( page ); + + pageOrderChanged(); + + QPtrListIterator it( views() ); + for (; it.current(); ++it ) + { + KPrView *view = static_cast( it.current() ); + view->removeSideBarItem( pos ); + + // change to the new page if the view was on the current page. + if ( (int)view->getCurrPgNum() - 1 == pos ) + { + view->skipToPage( pageNum ); + } + else // recalc the page number as it might have been changed + { + view->recalcCurrentPageNum(); + } + } + + repaint( false ); +} + +void KPrDocument::pageOrderChanged() +{ + recalcVariables( VT_PGNUM ); + + //update statusbar + emit pageNumChanged(); + emit sig_updateMenuBar(); +} + +void KPrDocument::movePageTo( int oldPos, int newPos ) +{ + kdDebug(33001) << "movePage oldPos = " << oldPos << ", neuPos = " << newPos << endl; + + KPrPage * page = m_pageList.take( oldPos ); + m_pageList.insert( newPos, page ); + + pageOrderChanged(); + + // Update the sidebars + QPtrListIterator it( views() ); + for (; it.current(); ++it ) + { + KPrView *view = static_cast( it.current() ); + view->moveSideBarItem( oldPos, newPos ); + + // change to the new page if the view was on the old pos. + if ( (int)view->getCurrPgNum() - 1 == oldPos ) + { + view->skipToPage( newPos ); + } + else // recalc the page number as it might have been changed + { + view->recalcCurrentPageNum(); + } + } +} + +QString KPrDocument::templateFileName( bool chooseTemplate, const QString &theFile ) +{ + QString fileName; + if ( !chooseTemplate ) { + if ( theFile.isEmpty() ) + fileName = locateLocal( "appdata", "default.kpr" ); + else + fileName = theFile; + } else { + // TODO: pass parentWidget as parameter to this method + QWidget* parentWidget = 0; + QString _template; + if ( KoTemplateChooseDia::choose( KPrFactory::global(), _template, + KoTemplateChooseDia::OnlyTemplates, + "kpresenter_template", parentWidget ) == KoTemplateChooseDia::Cancel ) + return QString::null; + QFileInfo fileInfo( _template ); + fileName = fileInfo.dirPath( true ) + "/" + fileInfo.baseName() + ".kpt"; + + KURL src, dest; + src.setPath( fileName ); + dest.setPath( locateLocal( "appdata", "default.kpr" ) ); + kdDebug(33001) << "Copying template (in KPrDocument::templateFileName)" << endl + << " from: " << src.prettyURL() << endl + << " to: " << dest.prettyURL() << endl; + KIO::NetAccess::file_copy( src, + dest, + -1, /* default permissions */ + true /* overwrite */ ); + } + return fileName; +} + +int KPrDocument::insertNewPage( const QString &cmdName, int _page, InsertPos _insPos, + bool chooseTemplate, const QString &theFile ) +{ + kdDebug(33001) << "KPrDocument::insertNewPage " << _page << endl; + + QString fileName=templateFileName(chooseTemplate, theFile); + if(fileName.isEmpty()) + return -1; + + _clean = false; + + objStartY=-1; + + //insert page. + KPrPage *newpage = new KPrPage( this, m_masterPage ); + + m_pageWhereLoadObject=newpage; + m_childCountBeforeInsert = children().count(); + + bool ok = loadNativeFormat( fileName ); + if ( !ok ) + showLoadingErrorDialog(); + + objStartY = 0; + + KPrInsertPageCmd *cmd = new KPrInsertPageCmd( cmdName, _page, _insPos, newpage, this ); + cmd->execute(); + addCommand(cmd); + + _clean = true; + m_pageWhereLoadObject=0L; + m_childCountBeforeInsert = 0; + return _page; +} + +void KPrDocument::savePage( const QString &file, int pgnum, bool ignore ) +{ + saveOnlyPage = pgnum; + _duplicatePage=ignore; + saveNativeFormat( file ); + _duplicatePage=false; + saveOnlyPage = -1; +} + +void KPrDocument::replaceObjs( bool createUndoRedo ) +{ + KMacroCommand * macroCmd = 0L; + QPtrListIterator oIt(m_pageList); + for (; oIt.current(); ++oIt ) + { + KCommand *cmd=oIt.current()->replaceObjs( createUndoRedo, oldGridX,oldGridY,_txtBackCol, _otxtBackCol); + if(cmd && createUndoRedo) + { + if ( !macroCmd) + macroCmd = new KMacroCommand( i18n("Set New Options") ); + macroCmd->addCommand(cmd); + } + else + delete cmd; + } + + if(macroCmd) + { + macroCmd->execute(); + addCommand(macroCmd); + } +} + +void KPrDocument::restoreBackground( KPrPage *page ) +{ + page->background()->reload(); +} + +KCommand * KPrDocument::loadPastedObjs( const QString &in, KPrPage* _page ) +{ + QDomDocument doc; + doc.setContent( in ); + + QDomElement document=doc.documentElement(); + + // DOC + if (document.tagName()!="DOC") { + kdError(33001) << "Missing DOC" << endl; + return 0L; + } + + bool ok = false; + + if(document.hasAttribute("mime") && document.attribute("mime")=="application/x-kpresenter") + ok=true; + + if ( !ok ) + return 0L; + m_pageWhereLoadObject=_page; + KCommand *cmd = loadObjects(document,true); + m_pageWhereLoadObject=0L; + + repaint( false ); + setModified( true ); + return cmd; +} + +void KPrDocument::deSelectAllObj() +{ + QPtrListIterator it( views() ); + for (; it.current(); ++it ) + ((KPrView*)it.current())->getCanvas()->deSelectAllObj(); +} + +void KPrDocument::deSelectObj(KPrObject *obj) +{ + QPtrListIterator it( views() ); + for (; it.current(); ++it ) + ((KPrView*)it.current())->getCanvas()->deSelectObj( obj ); +} + +void KPrDocument::setDisplayObjectMasterPage( bool b ) +{ + QPtrListIterator it( views() ); + for (; it.current(); ++it ) + ((KPrView*)it.current())->updateDisplayObjectMasterPageButton(); + repaint(b); +} + +void KPrDocument::setDisplayBackground( bool b ) +{ + QPtrListIterator it( views() ); + for (; it.current(); ++it ) + ((KPrView*)it.current())->updateDisplayBackgroundButton(); + repaint(b); +} + +void KPrDocument::setHeader( bool b ) +{ + _header->setDrawEditRect( b ); + _header->setDrawEmpty( b ); + if(!b) + { + terminateEditing(_header); + deSelectObj(_header); + } + m_masterPage->setHeader( b, false ); + updateHeaderFooterButton(); + repaint(b); +} + +void KPrDocument::setFooter( bool b ) +{ + _footer->setDrawEditRect( b ); + _footer->setDrawEmpty( b ); + if(!b) + { + terminateEditing(_footer); + deSelectObj(_footer); + } + m_masterPage->setFooter( b, false ); + updateHeaderFooterButton(); + repaint(b); +} + +void KPrDocument::updateHeaderFooterButton() +{ + QPtrListIterator it( views() ); + for (; it.current(); ++it ) + ((KPrView*)it.current())->updateHeaderFooterButton(); +} + +void KPrDocument::makeUsedPixmapList() +{ + usedPictures.clear(); + + for ( uint i = 0; i < m_pageList.count(); i++ ) { + if ( saveOnlyPage != -1 && + static_cast(i) != saveOnlyPage ) + continue; + m_pageList.at(i)->makeUsedPixmapList(); + } + // ### following call independant of saveOnlyPage's value? + if ( saveOnlyPage == -1 ) + m_masterPage->makeUsedPixmapList(); +} + +void KPrDocument::makeUsedSoundFileList() +{ + if ( saveOnlyPage != -1 ) + return; + + usedSoundFile.clear(); + + QPtrListIterator it( m_pageList ); + for ( ; it.current(); ++it ) { + QString _file = it.current()->getPageSoundFileName(); + if ( !_file.isEmpty() && usedSoundFile.findIndex( _file ) == -1 ) + usedSoundFile.append( _file ); + + QPtrListIterator oIt( it.current()->objectList() ); + for ( ; oIt.current(); ++oIt ) { + _file = oIt.current()->getAppearSoundEffectFileName(); + if ( !_file.isEmpty() && usedSoundFile.findIndex( _file ) == -1 ) + usedSoundFile.append( _file ); + + _file = oIt.current()->getDisappearSoundEffectFileName(); + if ( !_file.isEmpty() && usedSoundFile.findIndex( _file ) == -1 ) + usedSoundFile.append( _file ); + } + } +} + +KoView* KPrDocument::createViewInstance( QWidget* parent, const char* name ) +{ + //the page numbers have to be recalced for the sticky objects + //as it could not be done during the constructor of KPrView + recalcPageNum(); + return new KPrView( this, parent, name ); +} + +void KPrDocument::paintContent( QPainter& painter, const QRect& rect, + bool /*transparent*/, double zoomX, double zoomY ) +{ + m_zoomHandler->setZoom( 100 ); + if ( zoomHandler()->zoomedResolutionX() != zoomX || zoomHandler()->zoomedResolutionY() != zoomY ) + { + int zoomLevel = qRound( 100 * zoomY / zoomHandler()->zoomedResolutionY() ); // ## ignores the case where the x and y scaling differs + zoomHandler()->setZoom( zoomLevel ); + bool forPrint = painter.device() && painter.device()->devType() == QInternal::Printer; + newZoomAndResolution( false, forPrint ); + } + //for the moment draw first page. + KPrPage *page=m_pageList.first(); + if( m_initialActivePage ) + page = m_initialActivePage; + + int pageNum = m_pageList.findRef( page ); + + if ( page->displayBackground() ) + page->background()->drawBackground( &painter, zoomHandler(), rect, false ); + if ( page->displayObjectFromMasterPage() ) + { + KPrPage *masterPage = page->masterPage(); + if ( masterPage ) + { + QPtrListIterator it( masterPage->objectList() ); + //draw objects on master slide + for ( ; it.current() ; ++it ) + { + if( (it.current()==_header && !page->hasHeader())||(it.current()==_footer && !page->hasFooter())) + continue; + it.current()->draw( &painter, zoomHandler(), pageNum, SM_NONE ); + } + } + } + QPtrListIterator it( page->objectList() ); + for ( ; it.current() ; ++it ) + it.current()->draw( &painter, zoomHandler(), pageNum, SM_NONE ); +} + +QPixmap KPrDocument::generatePreview( const QSize& size ) +{ + int oldZoom = zoomHandler()->zoom(); + double oldResolutionX = zoomHandler()->resolutionX(); + double oldResolutionY = zoomHandler()->resolutionY(); + + QPixmap pix = KoDocument::generatePreview(size); + + zoomHandler()->setResolution( oldResolutionX, oldResolutionY ); + zoomHandler()->setZoom(oldZoom); + newZoomAndResolution( false, false ); + + return pix; +} + +void KPrDocument::addShell( KoMainWindow *shell ) +{ + connect( shell, SIGNAL( documentSaved() ), m_commandHistory, SLOT( documentSaved() ) ); + KoDocument::addShell( shell ); +} + +void KPrDocument::movePage( int from, int to ) +{ + kdDebug(33001) << "KPrDocument::movePage from=" << from << " to=" << to << endl; + KPrMovePageCmd *cmd = new KPrMovePageCmd( i18n("Move Slide"), from, to, this ); + cmd->execute(); + addCommand(cmd); +} + +void KPrDocument::copyPage( int from ) +{ + _clean = false; + m_childCountBeforeInsert = children().count(); + + _duplicatePage=true; // ### now also set via savePage() parameter below + + kdDebug(33001) << "KPrDocument::copyPage from=" << from << " to=" << from + 1 << endl; + kdDebug(33001) << "mimeType = " << mimeType() << ", outputMimeType = " << outputMimeType() << endl; + bool wasSelected = isSlideSelected( from ); + KTempFile tempFile( QString::null, mimeType() == nativeOasisMimeType() ? ".oop": ".kpr" ); + tempFile.setAutoDelete( true ); + savePage( tempFile.name(), from, true ); + + //insert page. + KPrPage *newpage = new KPrPage( this, m_masterPage ); + + m_pageWhereLoadObject = newpage; + + bool ok = loadNativeFormat( tempFile.name() ); + if ( !ok ) + showLoadingErrorDialog(); + + KPrInsertPageCmd *cmd = new KPrInsertPageCmd( i18n("Duplicate Slide"), from, IP_AFTER, newpage, this ); + cmd->execute(); + addCommand(cmd); + + _duplicatePage=false; + + _clean = true; + m_pageWhereLoadObject=0L; + m_childCountBeforeInsert = 0; + + selectPage( from + 1, wasSelected ); +} + +void KPrDocument::copyPageToClipboard( int pgnum ) +{ + // We save the page to a temp file and set the URL of the file in the clipboard + // Yes it's a hack but at least we don't hit the clipboard size limit :) + // (and we don't have to implement copy-tar-structure-to-clipboard) + // In fact it even allows copying a [1-page] kpr in konq and pasting it in kpresenter :)) + kdDebug(33001) << "KPrDocument::copyPageToClipboard pgnum=" << pgnum << endl; + kdDebug(33001) << "mimeType = " << mimeType() << ", outputMimeType = " << outputMimeType() << endl; + KTempFile tempFile( QString::null, mimeType() == nativeOasisMimeType() ? ".oop": ".kpr" ); + savePage( tempFile.name(), pgnum, true ); + KURL url; url.setPath( tempFile.name() ); + KURL::List lst; + lst.append( url ); + QApplication::clipboard()->setData( new KURLDrag( lst ) ); + m_tempFileInClipboard = tempFile.name(); // do this last, the above calls clipboardDataChanged +} + +void KPrDocument::pastePage( const QMimeSource * data, int pgnum ) +{ + KURL::List lst; + if ( KURLDrag::decode( data, lst ) && !lst.isEmpty() ) + { + insertNewPage(i18n("Paste Slide"), pgnum, IP_BEFORE, FALSE, lst.first().path() ); + //selectPage( pgnum, true /* should be part of the file ? */ ); + } +} + +void KPrDocument::clipboardDataChanged() +{ + if ( !m_tempFileInClipboard.isEmpty() ) + { + kdDebug(33001) << "KPrDocument::clipboardDataChanged, deleting temp file " << m_tempFileInClipboard << endl; + unlink( QFile::encodeName( m_tempFileInClipboard ) ); + m_tempFileInClipboard = QString::null; + } + // TODO enable paste as well, when a txtobject is activated + // and there is plain text in the clipboard. Then enable this code. + //QMimeSource *data = QApplication::clipboard()->data(); + //bool canPaste = data->provides( "text/uri-list" ) || data->provides( "application/x-kpresenter-selection" ); + // emit enablePaste( canPaste ); +} + +void KPrDocument::selectPage( int pgNum /* 0-based */, bool select ) +{ + Q_ASSERT( pgNum >= 0 ); + KPrPage *page = m_pageList.at( pgNum ); + page->slideSelected(select); + kdDebug(33001) << "KPrDocument::selectPage pgNum=" << pgNum << " select=" << select << endl; + setModified(true); + + updateSideBarItem( page ); + updatePresentationButton(); + //update statusbar + emit pageNumChanged(); +} + +KPrPage * KPrDocument::findPage(KPrObject *object) +{ + QPtrList masterObjects( m_masterPage->objectList() ); + if ( masterObjects.findRef( object ) != -1 ) + { + //kdDebug(33001) << "Object is on the master page" << endl; + return m_masterPage; + } + QPtrListIterator it( m_pageList ); + for ( ; it.current(); ++it ) { + QPtrList list( it.current()->objectList() ); + if ( list.findRef( object ) != -1 ) { + //kdDebug(33001) << "Object is on page " << m_pageList.findRef(it.current()) + 1 << endl; + return it.current(); + } + } + kdDebug(33001) << "Object not found on a page" << endl; + return 0L; +} + +KPrPage * KPrDocument::findPage(QPtrList &objects) +{ + KPrObject *object; + for ( object = objects.first(); object; object=objects.next() ) { + QPtrList list( m_masterPage->objectList() ); + if ( list.findRef( object ) != -1 ) + { + //kdDebug(33001) << "Object is on the master page" << endl; + return m_masterPage; + } + } + object = objects.first(); + for ( KPrPage *page=m_pageList.first(); page; page=m_pageList.next() ) { + QPtrList list( page->objectList() ); + if ( list.findRef( object ) != -1 ) { + //kdDebug(33001) << "The Objects are on page " << m_pageList.findRef(page) + 1 << endl; + return page; + } + } + kdDebug(33001) << "Objects not found on a page" << endl; + return 0L; +} + +void KPrDocument::updateSideBarItem( KPrPage * page ) +{ + // Update the views + QPtrListIterator it( views() ); + for (; it.current(); ++it ) + static_cast( it.current() )->updateSideBarItem( page ); +} + +bool KPrDocument::isSlideSelected( int pgNum /* 0-based */ ) +{ + Q_ASSERT( pgNum >= 0 ); + return m_pageList.at(pgNum)->isSlideSelected(); +} + +QValueList KPrDocument::listOfDisplaySelectedSlides( const QValueList & lst) /* returned list is 0-based */ +{ + QValueList result; + QValueListConstIterator itPage; + QValueListConstIterator itPageEnd = lst.end(); + for( itPage = lst.begin() ; itPage != itPageEnd; ++itPage ) + { + int pageNum = m_pageList.find(*itPage ); + if ( pageNum != -1 ) + { + kdDebug()<<" KPrDocument::displaySelectedSlide : add slide number :"< KPrDocument::displaySelectedSlides() /* returned list is 0-based */ +{ + QValueList result; + if ( m_customListTest ) + return *m_customListTest; + if ( m_presentationName.isEmpty() ) + return selectedSlides(); + else + { + kdDebug()<<" KPrDocument::displaySelectedSlide m_presentationName : "< KPrDocument::selectedSlides() /* returned list is 0-based */ +{ + QValueList result; + for ( int i = 0; i < static_cast( m_pageList.count() ); i++ ) { + if(m_pageList.at(i)->isSlideSelected()) + result <( m_pageList.count() ); i++ ) { + if(m_pageList.at(i)->isSlideSelected()) { + if(continuous) + ++end; + else { + start=i; + end=i; + continuous=true; + } + } + else { + if(continuous) { + if(start==end) + ret+=QString::number(start+1)+","; + else + ret+=QString::number(start+1)+"-"+QString::number(end+1)+","; + continuous=false; + } + } + } + if(continuous) { + if(start==end) + ret+=QString::number(start+1); + else + ret+=QString::number(start+1)+"-"+QString::number(end+1); + } + if(','==ret[ret.length()-1]) + ret.truncate(ret.length()-1); + return ret; +} + +void KPrDocument::slotRepaintChanged( KPrTextObject *kptextobj ) +{ + //todo + //use this function for the moment + repaint( kptextobj ); +} + + +void KPrDocument::recalcVariables( int type ) +{ + recalcPageNum(); + QValueList modifiedVariables = m_varColl->recalcVariables(type); + if ( modifiedVariables.isEmpty() ) + return; + + // TODO use the return value from recalcVariables to only repaint what has changed. + QPtrListIterator it( m_pageList ); + for ( ; it.current(); ++it ) + it.current()->slotRepaintVariable(); + m_masterPage->slotRepaintVariable(); +} + +void KPrDocument::slotGuideLinesChanged( KoView *view ) +{ + ( (KPrView*)view )->getCanvas()->guideLines().getGuideLines( m_hGuideLines, m_vGuideLines ); + QPtrListIterator it( views() ); + for (; it.current(); ++it ) + { + if ( it.current() != view ) + { + ( (KPrView*)it.current() )->getCanvas()->guideLines().setGuideLines( m_hGuideLines, m_vGuideLines ); + } + } +} + +void KPrDocument::slotDocumentInfoModifed() +{ + if (!getVariableCollection()->variableSetting()->displayFieldCode()) + recalcVariables( VT_FIELD ); +} + +void KPrDocument::reorganizeGUI() +{ + QPtrListIterator it( views() ); + for (; it.current(); ++it ) + ((KPrView*)it.current())->reorganize(); +} + +int KPrDocument::undoRedoLimit() const +{ + return m_commandHistory->undoLimit(); +} + +void KPrDocument::setUndoRedoLimit(int val) +{ + m_commandHistory->setUndoLimit(val); + m_commandHistory->setRedoLimit(val); +} + +void KPrDocument::updateRuler() +{ + emit sig_updateRuler(); +} + +void KPrDocument::recalcPageNum() +{ + QPtrListIterator it( m_pageList ); + for ( ; it.current(); ++it ) + it.current()->recalcPageNum(); + m_masterPage->recalcPageNum(); +} + +KPrPage * KPrDocument::activePage()const +{ + return m_initialActivePage; +} + +void KPrDocument::insertObjectInPage(double offset, KPrObject *_obj, int pos) +{ + /// Why does this use __pgLayout instead of m_pageLayout ? + int page = (int)(offset/__pgLayout.ptHeight)+m_insertFilePage; + if ( page < 0 ) + { + kdDebug(33001) << "insertObjectInPage object cound not be inserted page = " << page << endl; + return; + } + double newPos = offset - ( page - m_insertFilePage ) * __pgLayout.ptHeight; + // due to a very small caluculating error which gives us the wrong page + // for objects placed on top of the page we have to move them to the right page. + if ( __pgLayout.ptHeight - newPos < 1e-6 ) + { + page++; + newPos = 0.0; + } + if ( page > ( (int)m_pageList.count()-1 ) ) + { + for (int i=(m_pageList.count()-1); isetOrig(_obj->getOrig().x(),newPos); + + if ( pos == -1 ) + { + m_pageList.at(page)->appendObject(_obj); + } + else + { + m_pageList.at( page )->insertObject( _obj, pos ); + } +} + +void KPrDocument::insertPixmapKey( KoPictureKey key ) +{ + if ( !usedPictures.contains( key ) ) + usedPictures.append( key ); +} + +KPrPage * KPrDocument::initialActivePage() const +{ + return m_initialActivePage; +} + +void KPrDocument::displayActivePage(KPrPage * _page) +{ + m_initialActivePage = _page; +} + +void KPrDocument::updateZoomRuler() +{ + QPtrListIterator it( views() ); + for (; it.current(); ++it ) + { + ((KPrView*)it.current())->getHRuler()->setZoom( m_zoomHandler->zoomedResolutionX() ); + ((KPrView*)it.current())->getVRuler()->setZoom( m_zoomHandler->zoomedResolutionY() ); + ((KPrView*)it.current())->slotUpdateRuler(); + } +} + +void KPrDocument::newZoomAndResolution( bool updateViews, bool /*forPrint*/ ) +{ + QPtrListIterator it( m_pageList ); + for ( ; it.current(); ++it ) { + QPtrListIterator oit(it.current()->objectList()); + for ( ; oit.current(); ++oit ) { + if ( oit.current()->getType() == OT_TEXT ) + static_cast( oit.current() )->textDocument()->formatCollection()->zoomChanged(); + } + } + if ( updateViews ) + { + QPtrListIterator it( views() ); + for (; it.current(); ++it ) + { + static_cast( it.current() )->getCanvas()->update(); + static_cast( it.current() )->getCanvas()->layout(); + } + } +} + +bool KPrDocument::isHeader(const KPrObject *obj) const +{ + return (obj==_header); +} + +bool KPrDocument::isFooter(const KPrObject *obj) const +{ + return (obj==_footer); +} + +bool KPrDocument::isHeaderFooter(const KPrObject *obj) const +{ + return (obj==_header)||(obj==_footer); +} + +void KPrDocument::updateRulerPageLayout() +{ + QPtrListIterator it( views() ); + for (; it.current(); ++it ) + { + ((KPrView*)it.current())->getHRuler()->setPageLayout(m_pageLayout ); + ((KPrView*)it.current())->getVRuler()->setPageLayout(m_pageLayout ); + + } +} + +void KPrDocument::refreshAllNoteBarMasterPage(const QString &text, KPrView *exceptView) +{ + m_masterPage->setNoteText(text ); + QPtrListIterator it( views() ); + for (; it.current(); ++it ) + { + KPrView* view=(KPrView*)it.current(); + if ( view->getNoteBar() && view != exceptView && view->editMaster() ) + view->getNoteBar()->setCurrentNoteText(text ); + } +} + +void KPrDocument::refreshAllNoteBar(int page, const QString &text, KPrView *exceptView) +{ + m_pageList.at(page)->setNoteText(text ); + QPtrListIterator it( views() ); + for (; it.current(); ++it ) + { + KPrView* view=(KPrView*)it.current(); + if ( view->getNoteBar() && view != exceptView && ((int)(view->getCurrPgNum())-1 == page)) + view->getNoteBar()->setCurrentNoteText(text ); + } +} + +void KPrDocument::loadStyleTemplates( const QDomElement &stylesElem ) +{ + QValueList followingStyles; + + QDomNodeList listStyles = stylesElem.elementsByTagName( "STYLE" ); + if( listStyles.count() > 0) { // we are going to import at least one style. + KoParagStyle *s = m_styleColl->findStyle("Standard"); + kdDebug(32001) << "KPrDocument::loadStyleTemplates looking for Standard, to delete it. Found " << s << endl; + if(s) // delete the standard style. + m_styleColl->removeStyle(s); + } + for (unsigned int item = 0; item < listStyles.count(); item++) { + QDomElement styleElem = listStyles.item( item ).toElement(); + + KoParagStyle *sty = new KoParagStyle( QString::null ); + // Load the style from the