From ed5640d8b587fbcfed7dd7967f3de04b37a76f26 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:06:44 +0200 Subject: Adding upstream version 4:7.4.7. Signed-off-by: Daniel Baumann --- toolkit/CppunitTest_toolkit.mk | 58 + toolkit/CppunitTest_toolkit_a11y.mk | 65 + toolkit/IwyuFilter_toolkit.yaml | 103 + toolkit/JunitTest_toolkit_complex.mk | 44 + toolkit/JunitTest_toolkit_unoapi_1.mk | 24 + toolkit/JunitTest_toolkit_unoapi_2.mk | 24 + toolkit/JunitTest_toolkit_unoapi_3.mk | 24 + toolkit/JunitTest_toolkit_unoapi_4.mk | 24 + toolkit/Library_tk.mk | 142 + toolkit/Makefile | 7 + toolkit/Module_toolkit.mk | 44 + toolkit/README.md | 15 + toolkit/inc/awt/animatedimagespeer.hxx | 103 + toolkit/inc/awt/vclxbitmap.hxx | 67 + toolkit/inc/awt/vclxcontainer.hxx | 62 + toolkit/inc/awt/vclxgraphics.hxx | 122 + toolkit/inc/awt/vclxpointer.hxx | 62 + toolkit/inc/awt/vclxprinter.hxx | 194 + toolkit/inc/awt/vclxregion.hxx | 67 + toolkit/inc/awt/vclxspinbutton.hxx | 88 + toolkit/inc/awt/vclxsystemdependentwindow.hxx | 49 + toolkit/inc/awt/vclxtabpagecontainer.hxx | 73 + toolkit/inc/awt/vclxtopwindow.hxx | 78 + toolkit/inc/awt/vclxwindows.hxx | 697 ++ toolkit/inc/controls/accessiblecontrolcontext.hxx | 123 + toolkit/inc/controls/animatedimages.hxx | 86 + toolkit/inc/controls/controlmodelcontainerbase.hxx | 270 + toolkit/inc/controls/dialogcontrol.hxx | 311 + toolkit/inc/controls/eventcontainer.hxx | 82 + toolkit/inc/controls/filectrl.hxx | 70 + toolkit/inc/controls/formattedcontrol.hxx | 122 + toolkit/inc/controls/geometrycontrolmodel.hxx | 251 + toolkit/inc/controls/geometrycontrolmodel_impl.hxx | 69 + toolkit/inc/controls/roadmapcontrol.hxx | 183 + toolkit/inc/controls/roadmapentry.hxx | 69 + toolkit/inc/controls/stdtabcontroller.hxx | 86 + toolkit/inc/controls/stdtabcontrollermodel.hxx | 123 + toolkit/inc/controls/svmedit.hxx | 32 + toolkit/inc/controls/tabpagecontainer.hxx | 127 + toolkit/inc/controls/tabpagemodel.hxx | 80 + toolkit/inc/controls/tkscrollbar.hxx | 112 + toolkit/inc/controls/treecontrolpeer.hxx | 166 + toolkit/inc/controls/unocontrolcontainer.hxx | 151 + toolkit/inc/controls/unocontrolcontainermodel.hxx | 51 + toolkit/inc/helper/accessibilityclient.hxx | 57 + toolkit/inc/helper/btndlg.hxx | 89 + toolkit/inc/helper/imagealign.hxx | 52 + toolkit/inc/helper/msgbox.hxx | 79 + toolkit/inc/helper/scrollabledialog.hxx | 66 + toolkit/inc/helper/servicenames.hxx | 24 + toolkit/inc/helper/tkresmgr.hxx | 34 + toolkit/inc/helper/unopropertyarrayhelper.hxx | 52 + toolkit/inc/helper/unowrapper.hxx | 73 + .../complex/toolkit/AccessibleStatusBarItem.java | 359 + toolkit/qa/complex/toolkit/Assert.java | 185 + toolkit/qa/complex/toolkit/GridControl.java | 746 ++ .../accessibility/_XAccessibleComponent.java | 463 ++ .../toolkit/accessibility/_XAccessibleContext.java | 246 + .../_XAccessibleEventBroadcaster.java | 177 + .../_XAccessibleExtendedComponent.java | 75 + .../toolkit/accessibility/_XAccessibleText.java | 1001 +++ .../qa/complex/toolkit/awtgrid/DummyColumn.java | 167 + .../complex/toolkit/awtgrid/GridDataListener.java | 107 + .../toolkit/awtgrid/TMutableGridDataModel.java | 449 ++ toolkit/qa/cppunit/Dialog.cxx | 73 + toolkit/qa/cppunit/EventContainer.cxx | 84 + toolkit/qa/cppunit/UnitConversion.cxx | 215 + toolkit/qa/cppunit/a11y/AccessibilityTools.cxx | 515 ++ toolkit/qa/cppunit/a11y/AccessibilityTools.hxx | 158 + .../qa/cppunit/a11y/AccessibleStatusBarTest.cxx | 184 + .../qa/cppunit/a11y/XAccessibleComponentTester.cxx | 290 + .../qa/cppunit/a11y/XAccessibleComponentTester.hxx | 66 + .../qa/cppunit/a11y/XAccessibleContextTester.cxx | 164 + .../qa/cppunit/a11y/XAccessibleContextTester.hxx | 62 + .../a11y/XAccessibleEventBroadcasterTester.cxx | 186 + .../a11y/XAccessibleEventBroadcasterTester.hxx | 54 + .../a11y/XAccessibleExtendedComponentTester.cxx | 53 + .../a11y/XAccessibleExtendedComponentTester.hxx | 50 + toolkit/qa/unoapi/knownissues.xcl | 259 + toolkit/qa/unoapi/testdocuments/poliball.gif | Bin 0 -> 945 bytes toolkit/qa/unoapi/toolkit_1.sce | 40 + toolkit/qa/unoapi/toolkit_2.sce | 36 + toolkit/qa/unoapi/toolkit_3.sce | 37 + toolkit/qa/unoapi/toolkit_4.sce | 31 + toolkit/source/awt/animatedimagespeer.cxx | 476 ++ toolkit/source/awt/asynccallback.cxx | 121 + toolkit/source/awt/non-interactable-containers.xml | 32 + toolkit/source/awt/scrollabledialog.cxx | 173 + toolkit/source/awt/stylesettings.cxx | 926 +++ toolkit/source/awt/stylesettings.hxx | 181 + toolkit/source/awt/vclxaccessiblecomponent.cxx | 830 ++ toolkit/source/awt/vclxbitmap.cxx | 63 + toolkit/source/awt/vclxcontainer.cxx | 290 + toolkit/source/awt/vclxdevice.cxx | 254 + toolkit/source/awt/vclxfont.cxx | 191 + toolkit/source/awt/vclxgraphics.cxx | 490 ++ toolkit/source/awt/vclxmenu.cxx | 872 +++ toolkit/source/awt/vclxpointer.cxx | 73 + toolkit/source/awt/vclxprinter.cxx | 379 + toolkit/source/awt/vclxregion.cxx | 145 + toolkit/source/awt/vclxspinbutton.cxx | 331 + toolkit/source/awt/vclxsystemdependentwindow.cxx | 114 + toolkit/source/awt/vclxtabpagecontainer.cxx | 231 + toolkit/source/awt/vclxtoolkit.cxx | 2668 +++++++ toolkit/source/awt/vclxtopwindow.cxx | 254 + toolkit/source/awt/vclxwindow.cxx | 2557 ++++++ toolkit/source/awt/vclxwindow1.cxx | 94 + toolkit/source/awt/vclxwindows.cxx | 8220 ++++++++++++++++++++ toolkit/source/awt/vclxwindows_internal.hxx | 33 + .../source/controls/accessiblecontrolcontext.cxx | 358 + toolkit/source/controls/animatedimages.cxx | 491 ++ .../source/controls/controlmodelcontainerbase.cxx | 1820 +++++ .../controlmodelcontainerbase_internal.hxx | 30 + toolkit/source/controls/dialogcontrol.cxx | 1244 +++ toolkit/source/controls/eventcontainer.cxx | 179 + toolkit/source/controls/filectrl.cxx | 244 + toolkit/source/controls/formattedcontrol.cxx | 476 ++ toolkit/source/controls/geometrycontrolmodel.cxx | 608 ++ .../controls/grid/defaultgridcolumnmodel.cxx | 389 + .../source/controls/grid/defaultgriddatamodel.cxx | 505 ++ toolkit/source/controls/grid/gridcolumn.cxx | 300 + toolkit/source/controls/grid/gridcolumn.hxx | 128 + toolkit/source/controls/grid/gridcontrol.cxx | 460 ++ toolkit/source/controls/grid/gridcontrol.hxx | 142 + .../source/controls/grid/grideventforwarder.cxx | 128 + .../source/controls/grid/grideventforwarder.hxx | 77 + .../source/controls/grid/sortablegriddatamodel.cxx | 928 +++ toolkit/source/controls/roadmapcontrol.cxx | 513 ++ toolkit/source/controls/roadmapentry.cxx | 105 + toolkit/source/controls/spinningprogress.cxx | 132 + toolkit/source/controls/stdtabcontroller.cxx | 415 + toolkit/source/controls/stdtabcontrollermodel.cxx | 439 ++ toolkit/source/controls/svmedit.cxx | 43 + toolkit/source/controls/tabpagecontainer.cxx | 351 + toolkit/source/controls/tabpagemodel.cxx | 304 + toolkit/source/controls/tkscrollbar.cxx | 324 + toolkit/source/controls/tkspinbutton.cxx | 421 + toolkit/source/controls/tree/treecontrol.cxx | 514 ++ toolkit/source/controls/tree/treecontrol.hxx | 65 + toolkit/source/controls/tree/treecontrolpeer.cxx | 1579 ++++ toolkit/source/controls/tree/treedatamodel.cxx | 523 ++ toolkit/source/controls/unocontrol.cxx | 1565 ++++ toolkit/source/controls/unocontrolbase.cxx | 253 + toolkit/source/controls/unocontrolcontainer.cxx | 822 ++ .../source/controls/unocontrolcontainermodel.cxx | 93 + toolkit/source/controls/unocontrolmodel.cxx | 1388 ++++ toolkit/source/controls/unocontrols.cxx | 4760 ++++++++++++ toolkit/source/hatchwindow/documentcloser.cxx | 228 + toolkit/source/hatchwindow/hatchwindow.cxx | 200 + toolkit/source/hatchwindow/hatchwindow.hxx | 69 + toolkit/source/hatchwindow/hatchwindowfactory.cxx | 89 + toolkit/source/hatchwindow/ipwin.cxx | 623 ++ toolkit/source/hatchwindow/ipwin.hxx | 92 + toolkit/source/helper/accessibilityclient.cxx | 232 + toolkit/source/helper/btndlg.cxx | 304 + toolkit/source/helper/formpdfexport.cxx | 789 ++ toolkit/source/helper/imagealign.cxx | 128 + toolkit/source/helper/listenermultiplexer.cxx | 242 + toolkit/source/helper/property.cxx | 380 + toolkit/source/helper/servicenames.cxx | 24 + toolkit/source/helper/tkresmgr.cxx | 57 + toolkit/source/helper/unopropertyarrayhelper.cxx | 148 + toolkit/source/helper/unowrapper.cxx | 314 + toolkit/source/helper/vclunohelper.cxx | 608 ++ toolkit/test/accessibility/AWB.sxw | Bin 0 -> 9257 bytes toolkit/test/accessibility/AccTreeNode.java | 346 + toolkit/test/accessibility/AccessibilityTree.java | 379 + .../test/accessibility/AccessibilityTreeModel.java | 471 ++ .../accessibility/AccessibilityTreeModelBase.java | 140 + .../test/accessibility/AccessibilityWorkBench.java | 591 ++ .../accessibility/AccessibleActionHandler.java | 91 + .../test/accessibility/AccessibleActionNode.java | 67 + .../test/accessibility/AccessibleCellHandler.java | 168 + .../accessibility/AccessibleComponentHandler.java | 121 + .../accessibility/AccessibleContextHandler.java | 95 + .../AccessibleEditableTextHandler.java | 53 + .../AccessibleExtendedComponentHandler.java | 93 + .../accessibility/AccessibleHyperlinkHandler.java | 53 + .../accessibility/AccessibleHypertextHandler.java | 53 + .../test/accessibility/AccessibleImageHandler.java | 70 + .../accessibility/AccessibleRelationHandler.java | 115 + .../accessibility/AccessibleSelectionHandler.java | 145 + .../test/accessibility/AccessibleTableHandler.java | 103 + .../test/accessibility/AccessibleTextHandler.java | 821 ++ .../test/accessibility/AccessibleTreeHandler.java | 130 + toolkit/test/accessibility/AccessibleTreeNode.java | 113 + .../test/accessibility/AccessibleUNOHandler.java | 126 + toolkit/test/accessibility/Canvas.java | 463 ++ toolkit/test/accessibility/CanvasShape.java | 290 + toolkit/test/accessibility/ChildEventHandler.java | 66 + .../test/accessibility/ContextEventHandler.java | 70 + toolkit/test/accessibility/EventHandler.java | 75 + toolkit/test/accessibility/EventListener.java | 108 + toolkit/test/accessibility/EventQueue.java | 140 + .../test/accessibility/GeometryEventHandler.java | 71 + toolkit/test/accessibility/HelpWindow.java | 189 + toolkit/test/accessibility/MessageArea.java | 131 + toolkit/test/accessibility/NodeFactory.java | 142 + toolkit/test/accessibility/NodeHandler.java | 133 + toolkit/test/accessibility/NodeMap.java | 117 + toolkit/test/accessibility/OfficeConnection.java | 98 + toolkit/test/accessibility/Options.java | 122 + toolkit/test/accessibility/QueuedListener.java | 70 + .../accessibility/QueuedTopWindowListener.java | 97 + toolkit/test/accessibility/SelectionDialog.java | 203 + toolkit/test/accessibility/SimpleOffice.java | 139 + toolkit/test/accessibility/StringNode.java | 36 + toolkit/test/accessibility/TableEventHandler.java | 58 + toolkit/test/accessibility/TopWindowListener.java | 175 + toolkit/test/accessibility/VectorNode.java | 74 + toolkit/test/accessibility/about.html | 8 + toolkit/test/accessibility/help.html | 91 + toolkit/test/accessibility/jawb.mf | 3 + toolkit/test/accessibility/news.html | 36 + toolkit/test/accessibility/ov/ContextView.java | 140 + toolkit/test/accessibility/ov/FocusView.java | 141 + .../test/accessibility/ov/ListeningObjectView.java | 80 + toolkit/test/accessibility/ov/ObjectView.java | 80 + .../test/accessibility/ov/ObjectViewContainer.java | 152 + toolkit/test/accessibility/ov/TextView.java | 133 + toolkit/test/accessibility/tools/NameProvider.java | 276 + toolkit/util/tk.component | 394 + 222 files changed, 68444 insertions(+) create mode 100644 toolkit/CppunitTest_toolkit.mk create mode 100644 toolkit/CppunitTest_toolkit_a11y.mk create mode 100644 toolkit/IwyuFilter_toolkit.yaml create mode 100644 toolkit/JunitTest_toolkit_complex.mk create mode 100644 toolkit/JunitTest_toolkit_unoapi_1.mk create mode 100644 toolkit/JunitTest_toolkit_unoapi_2.mk create mode 100644 toolkit/JunitTest_toolkit_unoapi_3.mk create mode 100644 toolkit/JunitTest_toolkit_unoapi_4.mk create mode 100644 toolkit/Library_tk.mk create mode 100644 toolkit/Makefile create mode 100644 toolkit/Module_toolkit.mk create mode 100644 toolkit/README.md create mode 100644 toolkit/inc/awt/animatedimagespeer.hxx create mode 100644 toolkit/inc/awt/vclxbitmap.hxx create mode 100644 toolkit/inc/awt/vclxcontainer.hxx create mode 100644 toolkit/inc/awt/vclxgraphics.hxx create mode 100644 toolkit/inc/awt/vclxpointer.hxx create mode 100644 toolkit/inc/awt/vclxprinter.hxx create mode 100644 toolkit/inc/awt/vclxregion.hxx create mode 100644 toolkit/inc/awt/vclxspinbutton.hxx create mode 100644 toolkit/inc/awt/vclxsystemdependentwindow.hxx create mode 100644 toolkit/inc/awt/vclxtabpagecontainer.hxx create mode 100644 toolkit/inc/awt/vclxtopwindow.hxx create mode 100644 toolkit/inc/awt/vclxwindows.hxx create mode 100644 toolkit/inc/controls/accessiblecontrolcontext.hxx create mode 100644 toolkit/inc/controls/animatedimages.hxx create mode 100644 toolkit/inc/controls/controlmodelcontainerbase.hxx create mode 100644 toolkit/inc/controls/dialogcontrol.hxx create mode 100644 toolkit/inc/controls/eventcontainer.hxx create mode 100644 toolkit/inc/controls/filectrl.hxx create mode 100644 toolkit/inc/controls/formattedcontrol.hxx create mode 100644 toolkit/inc/controls/geometrycontrolmodel.hxx create mode 100644 toolkit/inc/controls/geometrycontrolmodel_impl.hxx create mode 100644 toolkit/inc/controls/roadmapcontrol.hxx create mode 100644 toolkit/inc/controls/roadmapentry.hxx create mode 100644 toolkit/inc/controls/stdtabcontroller.hxx create mode 100644 toolkit/inc/controls/stdtabcontrollermodel.hxx create mode 100644 toolkit/inc/controls/svmedit.hxx create mode 100644 toolkit/inc/controls/tabpagecontainer.hxx create mode 100644 toolkit/inc/controls/tabpagemodel.hxx create mode 100644 toolkit/inc/controls/tkscrollbar.hxx create mode 100644 toolkit/inc/controls/treecontrolpeer.hxx create mode 100644 toolkit/inc/controls/unocontrolcontainer.hxx create mode 100644 toolkit/inc/controls/unocontrolcontainermodel.hxx create mode 100644 toolkit/inc/helper/accessibilityclient.hxx create mode 100644 toolkit/inc/helper/btndlg.hxx create mode 100644 toolkit/inc/helper/imagealign.hxx create mode 100644 toolkit/inc/helper/msgbox.hxx create mode 100644 toolkit/inc/helper/scrollabledialog.hxx create mode 100644 toolkit/inc/helper/servicenames.hxx create mode 100644 toolkit/inc/helper/tkresmgr.hxx create mode 100644 toolkit/inc/helper/unopropertyarrayhelper.hxx create mode 100644 toolkit/inc/helper/unowrapper.hxx create mode 100644 toolkit/qa/complex/toolkit/AccessibleStatusBarItem.java create mode 100644 toolkit/qa/complex/toolkit/Assert.java create mode 100644 toolkit/qa/complex/toolkit/GridControl.java create mode 100644 toolkit/qa/complex/toolkit/accessibility/_XAccessibleComponent.java create mode 100644 toolkit/qa/complex/toolkit/accessibility/_XAccessibleContext.java create mode 100644 toolkit/qa/complex/toolkit/accessibility/_XAccessibleEventBroadcaster.java create mode 100644 toolkit/qa/complex/toolkit/accessibility/_XAccessibleExtendedComponent.java create mode 100644 toolkit/qa/complex/toolkit/accessibility/_XAccessibleText.java create mode 100644 toolkit/qa/complex/toolkit/awtgrid/DummyColumn.java create mode 100644 toolkit/qa/complex/toolkit/awtgrid/GridDataListener.java create mode 100644 toolkit/qa/complex/toolkit/awtgrid/TMutableGridDataModel.java create mode 100644 toolkit/qa/cppunit/Dialog.cxx create mode 100644 toolkit/qa/cppunit/EventContainer.cxx create mode 100644 toolkit/qa/cppunit/UnitConversion.cxx create mode 100644 toolkit/qa/cppunit/a11y/AccessibilityTools.cxx create mode 100644 toolkit/qa/cppunit/a11y/AccessibilityTools.hxx create mode 100644 toolkit/qa/cppunit/a11y/AccessibleStatusBarTest.cxx create mode 100644 toolkit/qa/cppunit/a11y/XAccessibleComponentTester.cxx create mode 100644 toolkit/qa/cppunit/a11y/XAccessibleComponentTester.hxx create mode 100644 toolkit/qa/cppunit/a11y/XAccessibleContextTester.cxx create mode 100644 toolkit/qa/cppunit/a11y/XAccessibleContextTester.hxx create mode 100644 toolkit/qa/cppunit/a11y/XAccessibleEventBroadcasterTester.cxx create mode 100644 toolkit/qa/cppunit/a11y/XAccessibleEventBroadcasterTester.hxx create mode 100644 toolkit/qa/cppunit/a11y/XAccessibleExtendedComponentTester.cxx create mode 100644 toolkit/qa/cppunit/a11y/XAccessibleExtendedComponentTester.hxx create mode 100644 toolkit/qa/unoapi/knownissues.xcl create mode 100644 toolkit/qa/unoapi/testdocuments/poliball.gif create mode 100644 toolkit/qa/unoapi/toolkit_1.sce create mode 100644 toolkit/qa/unoapi/toolkit_2.sce create mode 100644 toolkit/qa/unoapi/toolkit_3.sce create mode 100644 toolkit/qa/unoapi/toolkit_4.sce create mode 100644 toolkit/source/awt/animatedimagespeer.cxx create mode 100644 toolkit/source/awt/asynccallback.cxx create mode 100644 toolkit/source/awt/non-interactable-containers.xml create mode 100644 toolkit/source/awt/scrollabledialog.cxx create mode 100644 toolkit/source/awt/stylesettings.cxx create mode 100644 toolkit/source/awt/stylesettings.hxx create mode 100644 toolkit/source/awt/vclxaccessiblecomponent.cxx create mode 100644 toolkit/source/awt/vclxbitmap.cxx create mode 100644 toolkit/source/awt/vclxcontainer.cxx create mode 100644 toolkit/source/awt/vclxdevice.cxx create mode 100644 toolkit/source/awt/vclxfont.cxx create mode 100644 toolkit/source/awt/vclxgraphics.cxx create mode 100644 toolkit/source/awt/vclxmenu.cxx create mode 100644 toolkit/source/awt/vclxpointer.cxx create mode 100644 toolkit/source/awt/vclxprinter.cxx create mode 100644 toolkit/source/awt/vclxregion.cxx create mode 100644 toolkit/source/awt/vclxspinbutton.cxx create mode 100644 toolkit/source/awt/vclxsystemdependentwindow.cxx create mode 100644 toolkit/source/awt/vclxtabpagecontainer.cxx create mode 100644 toolkit/source/awt/vclxtoolkit.cxx create mode 100644 toolkit/source/awt/vclxtopwindow.cxx create mode 100644 toolkit/source/awt/vclxwindow.cxx create mode 100644 toolkit/source/awt/vclxwindow1.cxx create mode 100644 toolkit/source/awt/vclxwindows.cxx create mode 100644 toolkit/source/awt/vclxwindows_internal.hxx create mode 100644 toolkit/source/controls/accessiblecontrolcontext.cxx create mode 100644 toolkit/source/controls/animatedimages.cxx create mode 100644 toolkit/source/controls/controlmodelcontainerbase.cxx create mode 100644 toolkit/source/controls/controlmodelcontainerbase_internal.hxx create mode 100644 toolkit/source/controls/dialogcontrol.cxx create mode 100644 toolkit/source/controls/eventcontainer.cxx create mode 100644 toolkit/source/controls/filectrl.cxx create mode 100644 toolkit/source/controls/formattedcontrol.cxx create mode 100644 toolkit/source/controls/geometrycontrolmodel.cxx create mode 100644 toolkit/source/controls/grid/defaultgridcolumnmodel.cxx create mode 100644 toolkit/source/controls/grid/defaultgriddatamodel.cxx create mode 100644 toolkit/source/controls/grid/gridcolumn.cxx create mode 100644 toolkit/source/controls/grid/gridcolumn.hxx create mode 100644 toolkit/source/controls/grid/gridcontrol.cxx create mode 100644 toolkit/source/controls/grid/gridcontrol.hxx create mode 100644 toolkit/source/controls/grid/grideventforwarder.cxx create mode 100644 toolkit/source/controls/grid/grideventforwarder.hxx create mode 100644 toolkit/source/controls/grid/sortablegriddatamodel.cxx create mode 100644 toolkit/source/controls/roadmapcontrol.cxx create mode 100644 toolkit/source/controls/roadmapentry.cxx create mode 100644 toolkit/source/controls/spinningprogress.cxx create mode 100644 toolkit/source/controls/stdtabcontroller.cxx create mode 100644 toolkit/source/controls/stdtabcontrollermodel.cxx create mode 100644 toolkit/source/controls/svmedit.cxx create mode 100644 toolkit/source/controls/tabpagecontainer.cxx create mode 100644 toolkit/source/controls/tabpagemodel.cxx create mode 100644 toolkit/source/controls/tkscrollbar.cxx create mode 100644 toolkit/source/controls/tkspinbutton.cxx create mode 100644 toolkit/source/controls/tree/treecontrol.cxx create mode 100644 toolkit/source/controls/tree/treecontrol.hxx create mode 100644 toolkit/source/controls/tree/treecontrolpeer.cxx create mode 100644 toolkit/source/controls/tree/treedatamodel.cxx create mode 100644 toolkit/source/controls/unocontrol.cxx create mode 100644 toolkit/source/controls/unocontrolbase.cxx create mode 100644 toolkit/source/controls/unocontrolcontainer.cxx create mode 100644 toolkit/source/controls/unocontrolcontainermodel.cxx create mode 100644 toolkit/source/controls/unocontrolmodel.cxx create mode 100644 toolkit/source/controls/unocontrols.cxx create mode 100644 toolkit/source/hatchwindow/documentcloser.cxx create mode 100644 toolkit/source/hatchwindow/hatchwindow.cxx create mode 100644 toolkit/source/hatchwindow/hatchwindow.hxx create mode 100644 toolkit/source/hatchwindow/hatchwindowfactory.cxx create mode 100644 toolkit/source/hatchwindow/ipwin.cxx create mode 100644 toolkit/source/hatchwindow/ipwin.hxx create mode 100644 toolkit/source/helper/accessibilityclient.cxx create mode 100644 toolkit/source/helper/btndlg.cxx create mode 100644 toolkit/source/helper/formpdfexport.cxx create mode 100644 toolkit/source/helper/imagealign.cxx create mode 100644 toolkit/source/helper/listenermultiplexer.cxx create mode 100644 toolkit/source/helper/property.cxx create mode 100644 toolkit/source/helper/servicenames.cxx create mode 100644 toolkit/source/helper/tkresmgr.cxx create mode 100644 toolkit/source/helper/unopropertyarrayhelper.cxx create mode 100644 toolkit/source/helper/unowrapper.cxx create mode 100644 toolkit/source/helper/vclunohelper.cxx create mode 100644 toolkit/test/accessibility/AWB.sxw create mode 100644 toolkit/test/accessibility/AccTreeNode.java create mode 100644 toolkit/test/accessibility/AccessibilityTree.java create mode 100644 toolkit/test/accessibility/AccessibilityTreeModel.java create mode 100644 toolkit/test/accessibility/AccessibilityTreeModelBase.java create mode 100644 toolkit/test/accessibility/AccessibilityWorkBench.java create mode 100644 toolkit/test/accessibility/AccessibleActionHandler.java create mode 100644 toolkit/test/accessibility/AccessibleActionNode.java create mode 100644 toolkit/test/accessibility/AccessibleCellHandler.java create mode 100644 toolkit/test/accessibility/AccessibleComponentHandler.java create mode 100644 toolkit/test/accessibility/AccessibleContextHandler.java create mode 100644 toolkit/test/accessibility/AccessibleEditableTextHandler.java create mode 100644 toolkit/test/accessibility/AccessibleExtendedComponentHandler.java create mode 100644 toolkit/test/accessibility/AccessibleHyperlinkHandler.java create mode 100644 toolkit/test/accessibility/AccessibleHypertextHandler.java create mode 100644 toolkit/test/accessibility/AccessibleImageHandler.java create mode 100644 toolkit/test/accessibility/AccessibleRelationHandler.java create mode 100644 toolkit/test/accessibility/AccessibleSelectionHandler.java create mode 100644 toolkit/test/accessibility/AccessibleTableHandler.java create mode 100644 toolkit/test/accessibility/AccessibleTextHandler.java create mode 100644 toolkit/test/accessibility/AccessibleTreeHandler.java create mode 100644 toolkit/test/accessibility/AccessibleTreeNode.java create mode 100644 toolkit/test/accessibility/AccessibleUNOHandler.java create mode 100644 toolkit/test/accessibility/Canvas.java create mode 100644 toolkit/test/accessibility/CanvasShape.java create mode 100644 toolkit/test/accessibility/ChildEventHandler.java create mode 100644 toolkit/test/accessibility/ContextEventHandler.java create mode 100644 toolkit/test/accessibility/EventHandler.java create mode 100644 toolkit/test/accessibility/EventListener.java create mode 100644 toolkit/test/accessibility/EventQueue.java create mode 100644 toolkit/test/accessibility/GeometryEventHandler.java create mode 100644 toolkit/test/accessibility/HelpWindow.java create mode 100644 toolkit/test/accessibility/MessageArea.java create mode 100644 toolkit/test/accessibility/NodeFactory.java create mode 100644 toolkit/test/accessibility/NodeHandler.java create mode 100644 toolkit/test/accessibility/NodeMap.java create mode 100644 toolkit/test/accessibility/OfficeConnection.java create mode 100644 toolkit/test/accessibility/Options.java create mode 100644 toolkit/test/accessibility/QueuedListener.java create mode 100644 toolkit/test/accessibility/QueuedTopWindowListener.java create mode 100644 toolkit/test/accessibility/SelectionDialog.java create mode 100644 toolkit/test/accessibility/SimpleOffice.java create mode 100644 toolkit/test/accessibility/StringNode.java create mode 100644 toolkit/test/accessibility/TableEventHandler.java create mode 100644 toolkit/test/accessibility/TopWindowListener.java create mode 100644 toolkit/test/accessibility/VectorNode.java create mode 100644 toolkit/test/accessibility/about.html create mode 100644 toolkit/test/accessibility/help.html create mode 100644 toolkit/test/accessibility/jawb.mf create mode 100644 toolkit/test/accessibility/news.html create mode 100644 toolkit/test/accessibility/ov/ContextView.java create mode 100644 toolkit/test/accessibility/ov/FocusView.java create mode 100644 toolkit/test/accessibility/ov/ListeningObjectView.java create mode 100644 toolkit/test/accessibility/ov/ObjectView.java create mode 100644 toolkit/test/accessibility/ov/ObjectViewContainer.java create mode 100644 toolkit/test/accessibility/ov/TextView.java create mode 100644 toolkit/test/accessibility/tools/NameProvider.java create mode 100644 toolkit/util/tk.component (limited to 'toolkit') diff --git a/toolkit/CppunitTest_toolkit.mk b/toolkit/CppunitTest_toolkit.mk new file mode 100644 index 000000000..496ed0d7b --- /dev/null +++ b/toolkit/CppunitTest_toolkit.mk @@ -0,0 +1,58 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_CppunitTest_CppunitTest,toolkit)) + +$(eval $(call gb_CppunitTest_add_exception_objects,toolkit, \ + toolkit/qa/cppunit/Dialog \ + toolkit/qa/cppunit/EventContainer \ + toolkit/qa/cppunit/UnitConversion \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,toolkit, \ + basegfx \ + comphelper \ + cppu \ + cppuhelper \ + sal \ + salhelper \ + test \ + tk \ + tl \ + unotest \ + vcl \ +)) + +$(eval $(call gb_CppunitTest_use_api,toolkit,\ + offapi \ + udkapi \ +)) + +$(eval $(call gb_CppunitTest_use_externals,toolkit,\ + boost_headers \ +)) + +$(eval $(call gb_CppunitTest_use_ure,toolkit)) + +$(eval $(call gb_CppunitTest_use_configuration,toolkit)) + +$(eval $(call gb_CppunitTest_use_vcl,toolkit)) + +$(eval $(call gb_CppunitTest_use_components,toolkit,\ + comphelper/util/comphelp \ + configmgr/source/configmgr \ + framework/util/fwk \ + i18npool/util/i18npool \ + sfx2/util/sfx \ + toolkit/util/tk \ + ucb/source/core/ucb1 \ + ucb/source/ucp/file/ucpfile1 \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/toolkit/CppunitTest_toolkit_a11y.mk b/toolkit/CppunitTest_toolkit_a11y.mk new file mode 100644 index 000000000..9739ec7f9 --- /dev/null +++ b/toolkit/CppunitTest_toolkit_a11y.mk @@ -0,0 +1,65 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_CppunitTest_CppunitTest,toolkit_a11y)) + +$(eval $(call gb_CppunitTest_add_exception_objects,toolkit_a11y, \ + toolkit/qa/cppunit/a11y/AccessibleStatusBarTest \ + toolkit/qa/cppunit/a11y/AccessibilityTools \ + toolkit/qa/cppunit/a11y/XAccessibleComponentTester \ + toolkit/qa/cppunit/a11y/XAccessibleContextTester \ + toolkit/qa/cppunit/a11y/XAccessibleEventBroadcasterTester \ + toolkit/qa/cppunit/a11y/XAccessibleExtendedComponentTester \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,toolkit_a11y, \ + basegfx \ + comphelper \ + cppu \ + cppuhelper \ + sal \ + salhelper \ + test \ + tk \ + tl \ + unotest \ + vcl \ +)) + +$(eval $(call gb_CppunitTest_use_api,toolkit_a11y,\ + offapi \ + udkapi \ +)) + +$(eval $(call gb_CppunitTest_use_externals,toolkit_a11y,\ + boost_headers \ +)) + +$(eval $(call gb_CppunitTest_use_sdk_api,toolkit_a11y)) + +$(eval $(call gb_CppunitTest_use_ure,toolkit_a11y)) + +$(eval $(call gb_CppunitTest_use_configuration,toolkit_a11y)) + +$(eval $(call gb_CppunitTest_use_vcl,toolkit_a11y)) + +$(eval $(call gb_CppunitTest_use_rdb,toolkit_a11y,services)) + +#~ $(eval $(call gb_CppunitTest_use_components,toolkit_a11y,\ +#~ comphelper/util/comphelp \ +#~ configmgr/source/configmgr \ +#~ framework/util/fwk \ +#~ i18npool/util/i18npool \ +#~ sfx2/util/sfx \ +#~ toolkit/util/tk \ +#~ ucb/source/core/ucb1 \ +#~ ucb/source/ucp/file/ucpfile1 \ +#~ )) + +# vim: set noet sw=4 ts=4: diff --git a/toolkit/IwyuFilter_toolkit.yaml b/toolkit/IwyuFilter_toolkit.yaml new file mode 100644 index 000000000..6606014d2 --- /dev/null +++ b/toolkit/IwyuFilter_toolkit.yaml @@ -0,0 +1,103 @@ +--- +assumeFilename: toolkit/source/controls/unocontrol.cxx +excludelist: + toolkit/source/awt/vclxmenu.cxx: + # Needed for direct member access + - vcl/window.hxx + toolkit/source/helper/servicenames.cxx: + # Needed for extern array declarations + - toolkit/helper/servicenames.hxx + toolkit/inc/awt/animatedimagespeer.hxx: + # base class has to be a complete type + - com/sun/star/awt/XAnimation.hpp + - com/sun/star/container/XContainerListener.hpp + - com/sun/star/util/XModifyListener.hpp + - toolkit/awt/vclxwindow.hxx + toolkit/inc/awt/vclxpointer.hxx: + # base class has to be a complete type + - com/sun/star/awt/XPointer.hpp + - com/sun/star/lang/XServiceInfo.hpp + - com/sun/star/lang/XUnoTunnel.hpp + toolkit/inc/awt/vclxspinbutton.hxx: + # base class has to be a complete type + - com/sun/star/awt/XSpinValue.hpp + toolkit/inc/awt/vclxprinter.hxx: + # base class has to be a complete type + - com/sun/star/awt/XPrinterPropertySet.hpp + - com/sun/star/awt/XInfoPrinter.hpp + - com/sun/star/awt/XPrinterPropertySet.hpp + - com/sun/star/awt/XPrinterServer.hpp + - com/sun/star/lang/XServiceInfo.hpp + toolkit/inc/awt/vclxtabpagecontainer.hxx: + # base class has to be a complete type + - com/sun/star/awt/tab/XTabPageContainer.hpp + - com/sun/star/container/XContainerListener.hpp + - toolkit/awt/vclxcontainer.hxx + toolkit/inc/controls/accessiblecontrolcontext.hxx: + # base class has to be a complete type + - com/sun/star/lang/XEventListener.hpp + toolkit/inc/controls/animatedimages.hxx: + # base class has to be a complete type + - com/sun/star/awt/XAnimatedImages.hpp + - toolkit/controls/unocontrolmodel.hxx + toolkit/inc/controls/controlmodelcontainerbase.hxx: + # base class has to be a complete type + - com/sun/star/awt/tab/XTabPageModel.hpp + - com/sun/star/awt/XTabControllerModel.hpp + - com/sun/star/beans/XPropertyChangeListener.hpp + - com/sun/star/container/XContainer.hpp + - com/sun/star/container/XNameContainer.hpp + - com/sun/star/lang/XInitialization.hpp + - com/sun/star/lang/XMultiServiceFactory.hpp + - com/sun/star/util/XChangesListener.hpp + - com/sun/star/util/XChangesNotifier.hpp + - toolkit/controls/unocontrolcontainer.hxx + toolkit/inc/controls/dialogcontrol.hxx: + # base class has to be a complete type + - com/sun/star/awt/UnoControlDialog.hpp + toolkit/inc/controls/eventcontainer.hxx: + # base class has to be a complete type + - com/sun/star/container/XContainer.hpp + - com/sun/star/container/XNameContainer.hpp + toolkit/inc/controls/geometrycontrolmodel.hxx: + # base class has to be a complete type + - com/sun/star/script/XScriptEventsSupplier.hpp + - com/sun/star/util/XCloneable.hpp + # Needed for template classes + - controls/geometrycontrolmodel_impl.hxx + toolkit/inc/controls/roadmapcontrol.hxx: + # base class has to be a complete type + - com/sun/star/awt/XItemEventBroadcaster.hpp + - com/sun/star/awt/XItemListener.hpp + - com/sun/star/beans/XPropertyChangeListener.hpp + - com/sun/star/container/XContainerListener.hpp + toolkit/inc/controls/roadmapentry.hxx: + # base class has to be a complete type + - com/sun/star/lang/XServiceInfo.hpp + toolkit/inc/controls/tabpagecontainer.hxx: + # base class has to be a complete type + - com/sun/star/awt/tab/XTabPageContainer.hpp + - toolkit/controls/controlmodelcontainerbase.hxx + toolkit/inc/controls/tabpagemodel.hxx: + # base class has to be a complete type + - com/sun/star/awt/tab/XTabPage.hpp + - toolkit/controls/unocontrolcontainer.hxx + toolkit/inc/controls/unocontrolcontainer.hxx: + # base class has to be a complete type + - com/sun/star/awt/XControlContainer.hpp + - com/sun/star/awt/XUnoControlContainer.hpp + - com/sun/star/container/XContainer.hpp + - com/sun/star/container/XIdentifierContainer.hpp + - toolkit/controls/unocontrolbase.hxx + toolkit/source/controls/animatedimages.cxx: + # Actually used + - com/sun/star/beans/XPropertySetInfo.hpp + toolkit/source/awt/vclxwindow.cxx: + # Needed for rtl::math::round + - rtl/math.hxx + toolkit/source/hatchwindow/hatchwindow.cxx: + # Actually used + - com/sun/star/embed/XHatchWindowController.hpp + toolkit/source/helper/servicenames.cxx: + # Needed for extern + - helper/servicenames.hxx diff --git a/toolkit/JunitTest_toolkit_complex.mk b/toolkit/JunitTest_toolkit_complex.mk new file mode 100644 index 000000000..4a06582a0 --- /dev/null +++ b/toolkit/JunitTest_toolkit_complex.mk @@ -0,0 +1,44 @@ +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This file incorporates work covered by the following license notice: +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to you under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.apache.org/licenses/LICENSE-2.0 . +# + +$(eval $(call gb_JunitTest_JunitTest,toolkit_complex)) + +$(eval $(call gb_JunitTest_use_jars,toolkit_complex,\ + OOoRunner \ + libreoffice \ + test \ +)) + +$(eval $(call gb_JunitTest_add_sourcefiles,toolkit_complex,\ + toolkit/qa/complex/toolkit/accessibility/_XAccessibleComponent \ + toolkit/qa/complex/toolkit/accessibility/_XAccessibleContext \ + toolkit/qa/complex/toolkit/accessibility/_XAccessibleEventBroadcaster \ + toolkit/qa/complex/toolkit/accessibility/_XAccessibleExtendedComponent \ + toolkit/qa/complex/toolkit/accessibility/_XAccessibleText \ + toolkit/qa/complex/toolkit/Assert \ + toolkit/qa/complex/toolkit/awtgrid/GridDataListener \ + toolkit/qa/complex/toolkit/awtgrid/TMutableGridDataModel \ + toolkit/qa/complex/toolkit/awtgrid/DummyColumn \ + toolkit/qa/complex/toolkit/GridControl \ +)) + +$(eval $(call gb_JunitTest_add_classes,toolkit_complex,\ + complex.toolkit.GridControl \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/toolkit/JunitTest_toolkit_unoapi_1.mk b/toolkit/JunitTest_toolkit_unoapi_1.mk new file mode 100644 index 000000000..ddd916107 --- /dev/null +++ b/toolkit/JunitTest_toolkit_unoapi_1.mk @@ -0,0 +1,24 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This file incorporates work covered by the following license notice: +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to you under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.apache.org/licenses/LICENSE-2.0 . +# + +$(eval $(call gb_JunitTest_JunitTest,toolkit_unoapi_1)) + +$(eval $(call gb_JunitTest_set_unoapi_test_defaults,toolkit_unoapi_1)) + +# vim: set noet sw=4 ts=4: diff --git a/toolkit/JunitTest_toolkit_unoapi_2.mk b/toolkit/JunitTest_toolkit_unoapi_2.mk new file mode 100644 index 000000000..642829a23 --- /dev/null +++ b/toolkit/JunitTest_toolkit_unoapi_2.mk @@ -0,0 +1,24 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This file incorporates work covered by the following license notice: +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to you under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.apache.org/licenses/LICENSE-2.0 . +# + +$(eval $(call gb_JunitTest_JunitTest,toolkit_unoapi_2)) + +$(eval $(call gb_JunitTest_set_unoapi_test_defaults,toolkit_unoapi_2)) + +# vim: set noet sw=4 ts=4: diff --git a/toolkit/JunitTest_toolkit_unoapi_3.mk b/toolkit/JunitTest_toolkit_unoapi_3.mk new file mode 100644 index 000000000..71c69d0a2 --- /dev/null +++ b/toolkit/JunitTest_toolkit_unoapi_3.mk @@ -0,0 +1,24 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This file incorporates work covered by the following license notice: +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to you under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.apache.org/licenses/LICENSE-2.0 . +# + +$(eval $(call gb_JunitTest_JunitTest,toolkit_unoapi_3)) + +$(eval $(call gb_JunitTest_set_unoapi_test_defaults,toolkit_unoapi_3)) + +# vim: set noet sw=4 ts=4: diff --git a/toolkit/JunitTest_toolkit_unoapi_4.mk b/toolkit/JunitTest_toolkit_unoapi_4.mk new file mode 100644 index 000000000..e61571633 --- /dev/null +++ b/toolkit/JunitTest_toolkit_unoapi_4.mk @@ -0,0 +1,24 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This file incorporates work covered by the following license notice: +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to you under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.apache.org/licenses/LICENSE-2.0 . +# + +$(eval $(call gb_JunitTest_JunitTest,toolkit_unoapi_4)) + +$(eval $(call gb_JunitTest_set_unoapi_test_defaults,toolkit_unoapi_4)) + +# vim: set noet sw=4 ts=4: diff --git a/toolkit/Library_tk.mk b/toolkit/Library_tk.mk new file mode 100644 index 000000000..018c44ddb --- /dev/null +++ b/toolkit/Library_tk.mk @@ -0,0 +1,142 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This file incorporates work covered by the following license notice: +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to you under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.apache.org/licenses/LICENSE-2.0 . +# + +$(eval $(call gb_Library_Library,tk)) + +$(eval $(call gb_Library_set_componentfile,tk,toolkit/util/tk,services)) + +$(eval $(call gb_Library_use_externals,tk,\ + boost_headers \ + epoxy \ +)) + +$(eval $(call gb_Library_set_include,tk,\ + $$(INCLUDE) \ + -I$(SRCDIR)/toolkit/inc \ + -I$(SRCDIR)/toolkit/source \ +)) + +$(eval $(call gb_Library_add_defs,tk,\ + -DTOOLKIT_DLLIMPLEMENTATION \ + -DSVT_DLL_NAME=\"$(call gb_Library_get_runtime_filename,$(call gb_Library__get_name,svt))\" \ +)) + +$(eval $(call gb_Library_use_sdk_api,tk)) + +$(eval $(call gb_Library_use_libraries,tk,\ + comphelper \ + cppu \ + cppuhelper \ + sal \ + salhelper \ + i18nlangtag \ + svl \ + tl \ + utl \ + vcl \ +)) + +$(eval $(call gb_Library_add_exception_objects,tk,\ + toolkit/source/awt/asynccallback \ + toolkit/source/awt/stylesettings \ + toolkit/source/awt/scrollabledialog \ + toolkit/source/awt/vclxaccessiblecomponent \ + toolkit/source/awt/vclxbitmap \ + toolkit/source/awt/vclxcontainer \ + toolkit/source/awt/vclxdevice \ + toolkit/source/awt/vclxfont \ + toolkit/source/awt/vclxgraphics \ + toolkit/source/awt/vclxmenu \ + toolkit/source/awt/vclxpointer \ + toolkit/source/awt/vclxprinter \ + toolkit/source/awt/vclxregion \ + toolkit/source/awt/vclxspinbutton \ + toolkit/source/awt/vclxsystemdependentwindow \ + toolkit/source/awt/vclxtabpagecontainer \ + toolkit/source/awt/animatedimagespeer \ + toolkit/source/awt/vclxtoolkit \ + toolkit/source/awt/vclxtopwindow \ + toolkit/source/awt/vclxwindow \ + toolkit/source/awt/vclxwindow1 \ + toolkit/source/awt/vclxwindows \ + toolkit/source/controls/accessiblecontrolcontext \ + toolkit/source/controls/controlmodelcontainerbase \ + toolkit/source/controls/dialogcontrol \ + toolkit/source/controls/eventcontainer \ + toolkit/source/controls/filectrl \ + toolkit/source/controls/formattedcontrol \ + toolkit/source/controls/geometrycontrolmodel \ + toolkit/source/controls/grid/defaultgridcolumnmodel \ + toolkit/source/controls/grid/defaultgriddatamodel \ + toolkit/source/controls/grid/gridcolumn \ + toolkit/source/controls/grid/grideventforwarder \ + toolkit/source/controls/grid/sortablegriddatamodel \ + toolkit/source/controls/grid/gridcontrol \ + toolkit/source/controls/roadmapcontrol \ + toolkit/source/controls/roadmapentry \ + toolkit/source/controls/svmedit \ + toolkit/source/controls/tabpagecontainer \ + toolkit/source/controls/tabpagemodel \ + toolkit/source/controls/stdtabcontroller \ + toolkit/source/controls/stdtabcontrollermodel \ + toolkit/source/controls/tkscrollbar \ + toolkit/source/controls/tkspinbutton \ + toolkit/source/controls/animatedimages \ + toolkit/source/controls/spinningprogress \ + toolkit/source/controls/tree/treecontrol \ + toolkit/source/controls/tree/treecontrolpeer \ + toolkit/source/controls/tree/treedatamodel \ + toolkit/source/controls/unocontrol \ + toolkit/source/controls/unocontrolbase \ + toolkit/source/controls/unocontrolcontainer \ + toolkit/source/controls/unocontrolcontainermodel \ + toolkit/source/controls/unocontrolmodel \ + toolkit/source/controls/unocontrols \ + toolkit/source/hatchwindow/documentcloser \ + toolkit/source/hatchwindow/hatchwindow \ + toolkit/source/hatchwindow/hatchwindowfactory \ + toolkit/source/hatchwindow/ipwin \ + toolkit/source/helper/accessibilityclient \ + toolkit/source/helper/btndlg \ + toolkit/source/helper/formpdfexport \ + toolkit/source/helper/imagealign \ + toolkit/source/helper/listenermultiplexer \ + toolkit/source/helper/property \ + toolkit/source/helper/servicenames \ + toolkit/source/helper/tkresmgr \ + toolkit/source/helper/unopropertyarrayhelper \ + toolkit/source/helper/unowrapper \ + toolkit/source/helper/vclunohelper \ +)) + +ifeq ($(OS),MACOSX) +$(eval $(call gb_Library_add_cxxflags,tk,\ + $(gb_OBJCXXFLAGS) \ +)) +$(eval $(call gb_Library_add_libs,tk,\ + -lobjc \ +)) +endif + +ifeq ($(OS),iOS) +$(eval $(call gb_Library_add_cxxflags,tk,\ + $(gb_OBJCXXFLAGS))) +endif + +# vim: set noet sw=4 ts=4: diff --git a/toolkit/Makefile b/toolkit/Makefile new file mode 100644 index 000000000..ccb1c85a0 --- /dev/null +++ b/toolkit/Makefile @@ -0,0 +1,7 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- + +module_directory:=$(dir $(realpath $(firstword $(MAKEFILE_LIST)))) + +include $(module_directory)/../solenv/gbuild/partial_build.mk + +# vim: set noet sw=4 ts=4: diff --git a/toolkit/Module_toolkit.mk b/toolkit/Module_toolkit.mk new file mode 100644 index 000000000..d03955931 --- /dev/null +++ b/toolkit/Module_toolkit.mk @@ -0,0 +1,44 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This file incorporates work covered by the following license notice: +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to you under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.apache.org/licenses/LICENSE-2.0 . +# + +$(eval $(call gb_Module_Module,toolkit)) + +$(eval $(call gb_Module_add_targets,toolkit,\ + Library_tk \ +)) + +# FIXME fails on some tinderboxes, needs investigation +ifneq ($(OS),WNT) +$(eval $(call gb_Module_add_check_targets,toolkit,\ + CppunitTest_toolkit \ + CppunitTest_toolkit_a11y \ +)) +endif + +ifneq ($(OOO_JUNIT_JAR),) +$(eval $(call gb_Module_add_subsequentcheck_targets,toolkit,\ + JunitTest_toolkit_complex \ + JunitTest_toolkit_unoapi_1 \ + JunitTest_toolkit_unoapi_2 \ + JunitTest_toolkit_unoapi_3 \ + JunitTest_toolkit_unoapi_4 \ +)) +endif + +# vim: set noet sw=4 ts=4: diff --git a/toolkit/README.md b/toolkit/README.md new file mode 100644 index 000000000..f41fb3760 --- /dev/null +++ b/toolkit/README.md @@ -0,0 +1,15 @@ +# Abstract Windowing Toolkit + +"Abstract" windowing thing. UNO implementations of windowing stuff so that it +can be used from Basic or Java. But also stuff that has no connection to Basic +or Java. + +## Notes + +The "awt" here has no relation to the Java AWT, as far as I know. It +might be inspired by it API-wise, perhaps. (If you know differently, feel free +to improve this `README.md` file.) + +Also note that `toolkit/` is itself not really a toolkit, it is at root a +reasonably simple wrapper of `vcl/`. If you came here looking for a +toolkit, please look at `vcl/` instead. diff --git a/toolkit/inc/awt/animatedimagespeer.hxx b/toolkit/inc/awt/animatedimagespeer.hxx new file mode 100644 index 000000000..839e249b3 --- /dev/null +++ b/toolkit/inc/awt/animatedimagespeer.hxx @@ -0,0 +1,103 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include + +#include +#include +#include +#include + +#include + +namespace toolkit +{ + + + //= AnimatedImagesPeer + + struct AnimatedImagesPeer_Data; + typedef cppu::ImplInheritanceHelper< VCLXWindow, + css::awt::XAnimation, + css::container::XContainerListener, + css::util::XModifyListener + > AnimatedImagesPeer_Base; + + class AnimatedImagesPeer final : public AnimatedImagesPeer_Base + { + public: + AnimatedImagesPeer(); + + private: + virtual ~AnimatedImagesPeer() override; + + public: + // XAnimation + virtual void SAL_CALL startAnimation( ) override; + virtual void SAL_CALL stopAnimation( ) override; + virtual sal_Bool SAL_CALL isAnimationRunning( ) override; + + // VclWindowPeer + virtual void SAL_CALL setProperty( const OUString& PropertyName, const css::uno::Any& Value ) override; + virtual css::uno::Any SAL_CALL getProperty( const OUString& PropertyName ) override; + + // XContainerListener + virtual void SAL_CALL elementInserted( const css::container::ContainerEvent& Event ) override; + virtual void SAL_CALL elementRemoved( const css::container::ContainerEvent& Event ) override; + virtual void SAL_CALL elementReplaced( const css::container::ContainerEvent& Event ) override; + + // XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& i_event ) override; + + // XModifyListener + virtual void SAL_CALL modified( const css::lang::EventObject& i_event ) override; + + // XComponent + void SAL_CALL dispose( ) override; + + struct CachedImage + { + OUString sImageURL; + mutable css::uno::Reference< css::graphic::XGraphic > xGraphic; + }; + + private: + void ProcessWindowEvent( const VclWindowEvent& i_windowEvent ) override; + + /** updates our images with the ones from the given XAnimatedImages component + */ + void impl_updateImages_nolck( const css::uno::Reference< css::uno::XInterface >& i_animatedImages ); + + AnimatedImagesPeer(const AnimatedImagesPeer&) = delete; + AnimatedImagesPeer& operator=(const AnimatedImagesPeer&) = delete; + + void updateImageList_nothrow(); + void updateImageList_nothrow( const css::uno::Reference< css::awt::XAnimatedImages >& i_images ); + + std::vector< std::vector< CachedImage > > maCachedImageSets; + }; + + +} // namespace toolkit + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/inc/awt/vclxbitmap.hxx b/toolkit/inc/awt/vclxbitmap.hxx new file mode 100644 index 000000000..6cf8928e0 --- /dev/null +++ b/toolkit/inc/awt/vclxbitmap.hxx @@ -0,0 +1,67 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include + + + + +class VCLXBitmap final : public cppu::WeakImplHelper< + css::awt::XBitmap, + css::awt::XDisplayBitmap, + css::lang::XUnoTunnel, + css::util::XAccounting> +{ + std::mutex maMutex; + BitmapEx maBitmap; + + std::mutex& GetMutex() { return maMutex; } + + +public: + // inline constructors + VCLXBitmap() : maMutex(), maBitmap() {} + VCLXBitmap(const BitmapEx& rBitmapEx) : maMutex(), maBitmap(rBitmapEx) {} + + void SetBitmap( const BitmapEx& rBmp ) { maBitmap = rBmp; } + const BitmapEx& GetBitmap() const { return maBitmap; } + + // css::lang::XUnoTunnel + UNO3_GETIMPLEMENTATION_DECL(VCLXBitmap) + + // css::awt::XBitmap + css::awt::Size SAL_CALL getSize() override; + css::uno::Sequence< sal_Int8 > SAL_CALL getDIB() override; + css::uno::Sequence< sal_Int8 > SAL_CALL getMaskDIB() override; + + // XAccounting + sal_Int64 SAL_CALL estimateUsage() override; +}; + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/inc/awt/vclxcontainer.hxx b/toolkit/inc/awt/vclxcontainer.hxx new file mode 100644 index 000000000..d93c967b8 --- /dev/null +++ b/toolkit/inc/awt/vclxcontainer.hxx @@ -0,0 +1,62 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include +#include + +#include + +class VCLXContainer : public css::awt::XVclContainer, + public css::awt::XVclContainerPeer, + public VCLXWindow +{ +public: + VCLXContainer(); + virtual ~VCLXContainer() override; + + // css::uno::XInterface + css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + void SAL_CALL acquire() noexcept override { OWeakObject::acquire(); } + void SAL_CALL release() noexcept override { OWeakObject::release(); } + + // css::lang::XTypeProvider + css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // css::awt::XVclContainer + void SAL_CALL addVclContainerListener( const css::uno::Reference< css::awt::XVclContainerListener >& l ) override; + void SAL_CALL removeVclContainerListener( const css::uno::Reference< css::awt::XVclContainerListener >& l ) override; + css::uno::Sequence< css::uno::Reference< css::awt::XWindow > > SAL_CALL getWindows( ) override; + + // css::awt::XVclContainerPeer + void SAL_CALL enableDialogControl( sal_Bool bEnable ) override; + void SAL_CALL setTabOrder( const css::uno::Sequence< css::uno::Reference< css::awt::XWindow > >& WindowOrder, const css::uno::Sequence< css::uno::Any >& Tabs, sal_Bool GroupControl ) override; + void SAL_CALL setGroup( const css::uno::Sequence< css::uno::Reference< css::awt::XWindow > >& Windows ) override; + + // css::awt::XVclWindowPeer + void SAL_CALL setProperty( const OUString& PropertyName, const css::uno::Any& Value ) override; + + static void ImplGetPropertyIds( std::vector< sal_uInt16 > &aIds ); + virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override { return ImplGetPropertyIds( aIds ); } +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/inc/awt/vclxgraphics.hxx b/toolkit/inc/awt/vclxgraphics.hxx new file mode 100644 index 000000000..ff697ead3 --- /dev/null +++ b/toolkit/inc/awt/vclxgraphics.hxx @@ -0,0 +1,122 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +class OutputDevice; +namespace vcl { class Region; } +namespace com::sun::star::graphic { class XGraphic; } + + +enum class InitOutDevFlags +{ + NONE = 0x0000, + FONT = 0x0001, + COLORS = 0x0002, +}; +namespace o3tl +{ + template<> struct typed_flags : is_typed_flags {}; +} + + + + +class VCLXGraphics final : public cppu::WeakImplHelper< + css::awt::XGraphics2, + css::lang::XUnoTunnel> +{ +private: + // used to return same reference on each call to getDevice() + css::uno::Reference< css::awt::XDevice> mxDevice; + + VclPtr mpOutputDevice; + vcl::Font maFont; + Color maTextColor; + Color maTextFillColor; + Color maLineColor; + Color maFillColor; + RasterOp meRasterOp; + std::unique_ptr mpClipRegion; + + void initAttrs(); + +public: + VCLXGraphics(); + virtual ~VCLXGraphics() override; + + void Init( OutputDevice* pOutDev ); + void InitOutputDevice( InitOutDevFlags nFlags ); + + void SetOutputDevice( OutputDevice* pOutDev ); + OutputDevice* GetOutputDevice() const { return mpOutputDevice; } + + // css::lang::XUnoTunnel + UNO3_GETIMPLEMENTATION_DECL(VCLXGraphics) + + // css::awt::XGraphics Attributes + virtual css::uno::Reference< css::awt::XDevice > SAL_CALL getDevice() override; + virtual void SAL_CALL setTextColor( ::sal_Int32 _textcolor ) override; + virtual void SAL_CALL setTextFillColor( ::sal_Int32 _textfillcolor ) override; + virtual void SAL_CALL setLineColor( ::sal_Int32 _linecolor ) override; + virtual void SAL_CALL setFillColor( ::sal_Int32 _fillcolor ) override; + virtual void SAL_CALL setRasterOp( css::awt::RasterOperation _rasterop ) override; + virtual void SAL_CALL setFont( const css::uno::Reference< css::awt::XFont >& _font ) override; + virtual css::awt::SimpleFontMetric SAL_CALL getFontMetric() override; + + // css::awt::XGraphics Methods + virtual void SAL_CALL selectFont( const css::awt::FontDescriptor& aDescription ) override; + virtual void SAL_CALL setClipRegion( const css::uno::Reference< css::awt::XRegion >& Clipping ) override; + virtual void SAL_CALL intersectClipRegion( const css::uno::Reference< css::awt::XRegion >& xClipping ) override; + virtual void SAL_CALL push( ) override; + virtual void SAL_CALL pop( ) override; + virtual void SAL_CALL clear( const css::awt::Rectangle& aRect ) override; + virtual void SAL_CALL copy( const css::uno::Reference< css::awt::XDevice >& xSource, ::sal_Int32 nSourceX, ::sal_Int32 nSourceY, ::sal_Int32 nSourceWidth, ::sal_Int32 nSourceHeight, ::sal_Int32 nDestX, ::sal_Int32 nDestY, ::sal_Int32 nDestWidth, ::sal_Int32 nDestHeight ) override; + virtual void SAL_CALL draw( const css::uno::Reference< css::awt::XDisplayBitmap >& xBitmapHandle, ::sal_Int32 SourceX, ::sal_Int32 SourceY, ::sal_Int32 SourceWidth, ::sal_Int32 SourceHeight, ::sal_Int32 DestX, ::sal_Int32 DestY, ::sal_Int32 DestWidth, ::sal_Int32 DestHeight ) override; + virtual void SAL_CALL drawPixel( ::sal_Int32 X, ::sal_Int32 Y ) override; + virtual void SAL_CALL drawLine( ::sal_Int32 X1, ::sal_Int32 Y1, ::sal_Int32 X2, ::sal_Int32 Y2 ) override; + virtual void SAL_CALL drawRect( ::sal_Int32 X, ::sal_Int32 Y, ::sal_Int32 Width, ::sal_Int32 Height ) override; + virtual void SAL_CALL drawRoundedRect( ::sal_Int32 X, ::sal_Int32 Y, ::sal_Int32 Width, ::sal_Int32 Height, ::sal_Int32 nHorzRound, ::sal_Int32 nVertRound ) override; + virtual void SAL_CALL drawPolyLine( const css::uno::Sequence< ::sal_Int32 >& DataX, const css::uno::Sequence< ::sal_Int32 >& DataY ) override; + virtual void SAL_CALL drawPolygon( const css::uno::Sequence< ::sal_Int32 >& DataX, const css::uno::Sequence< ::sal_Int32 >& DataY ) override; + virtual void SAL_CALL drawPolyPolygon( const css::uno::Sequence< css::uno::Sequence< ::sal_Int32 > >& DataX, const css::uno::Sequence< css::uno::Sequence< ::sal_Int32 > >& DataY ) override; + virtual void SAL_CALL drawEllipse( ::sal_Int32 X, ::sal_Int32 Y, ::sal_Int32 Width, ::sal_Int32 Height ) override; + virtual void SAL_CALL drawArc( ::sal_Int32 X, ::sal_Int32 Y, ::sal_Int32 Width, ::sal_Int32 Height, ::sal_Int32 X1, ::sal_Int32 Y1, ::sal_Int32 X2, ::sal_Int32 Y2 ) override; + virtual void SAL_CALL drawPie( ::sal_Int32 X, ::sal_Int32 Y, ::sal_Int32 Width, ::sal_Int32 Height, ::sal_Int32 X1, ::sal_Int32 Y1, ::sal_Int32 X2, ::sal_Int32 Y2 ) override; + virtual void SAL_CALL drawChord( ::sal_Int32 nX, ::sal_Int32 nY, ::sal_Int32 nWidth, ::sal_Int32 nHeight, ::sal_Int32 nX1, ::sal_Int32 nY1, ::sal_Int32 nX2, ::sal_Int32 nY2 ) override; + virtual void SAL_CALL drawGradient( ::sal_Int32 nX, ::sal_Int32 nY, ::sal_Int32 nWidth, ::sal_Int32 Height, const css::awt::Gradient& aGradient ) override; + virtual void SAL_CALL drawText( ::sal_Int32 X, ::sal_Int32 Y, const OUString& Text ) override; + virtual void SAL_CALL drawTextArray( ::sal_Int32 X, ::sal_Int32 Y, const OUString& Text, const css::uno::Sequence< ::sal_Int32 >& Longs ) override; + virtual void SAL_CALL drawImage( ::sal_Int32 nX, ::sal_Int32 nY, ::sal_Int32 nWidth, ::sal_Int32 nHeight, ::sal_Int16 nStyle, const css::uno::Reference< css::graphic::XGraphic >& aGraphic ) override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/inc/awt/vclxpointer.hxx b/toolkit/inc/awt/vclxpointer.hxx new file mode 100644 index 000000000..3bfcceeab --- /dev/null +++ b/toolkit/inc/awt/vclxpointer.hxx @@ -0,0 +1,62 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + + +#include +#include +#include +#include +#include +#include + +#include + + + + +class VCLXPointer final : public cppu::WeakImplHelper< + css::awt::XPointer, css::lang::XUnoTunnel, css::lang::XServiceInfo> +{ + std::mutex maMutex; + PointerStyle maPointer; + +public: + VCLXPointer(); + virtual ~VCLXPointer() override; + + PointerStyle GetPointer() const { return maPointer; } + + // css::lang::XUnoTunnel + UNO3_GETIMPLEMENTATION_DECL(VCLXPointer) + + // css::awt::XPointer + void SAL_CALL setType( sal_Int32 nType ) override; + sal_Int32 SAL_CALL getType( ) override; + + OUString SAL_CALL getImplementationName() override; + + sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override; + + css::uno::Sequence SAL_CALL getSupportedServiceNames() override; +}; + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/inc/awt/vclxprinter.hxx b/toolkit/inc/awt/vclxprinter.hxx new file mode 100644 index 000000000..41a74044b --- /dev/null +++ b/toolkit/inc/awt/vclxprinter.hxx @@ -0,0 +1,194 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include + +namespace com::sun::star::awt { class XPrinter; } +namespace vcl { class OldStylePrintAdaptor; } +class Printer; + +// relevant properties for the printer: +/* + sal_Bool Horizontal + sal_uInt16 CopyCount; + sal_Bool Collate; + String FormDescriptor; + sal_uInt16 Orientation; // PORTRAIT, LANDSCAPE +*/ + + + + +typedef ::cppu::WeakImplHelper < css::awt::XPrinterPropertySet + > VCLXPrinterPropertySet_Base; +class VCLXPrinterPropertySet :public VCLXPrinterPropertySet_Base + ,public MutexAndBroadcastHelper + ,public ::cppu::OPropertySetHelper +{ +protected: + VclPtr mxPrinter; + css::uno::Reference< css::awt::XDevice > mxPrnDevice; + + sal_Int16 mnOrientation; + bool mbHorizontal; +public: + VCLXPrinterPropertySet( const OUString& rPrinterName ); + virtual ~VCLXPrinterPropertySet() override; + + Printer* GetPrinter() const { return mxPrinter.get(); } + css::uno::Reference< css::awt::XDevice > const & GetDevice(); + + // css::uno::XInterface + DECLARE_XINTERFACE(); + + // css::lang::XTypeProvider + DECLARE_XTYPEPROVIDER(); + + // css::beans::XPropertySet + css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; + void SAL_CALL setPropertyValue( const OUString& rPropertyName, const css::uno::Any& aValue ) override { OPropertySetHelper::setPropertyValue( rPropertyName, aValue ); } + css::uno::Any SAL_CALL getPropertyValue( const OUString& rPropertyName ) override { return OPropertySetHelper::getPropertyValue( rPropertyName ); } + void SAL_CALL addPropertyChangeListener( const OUString& rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& rxListener ) override { OPropertySetHelper::addPropertyChangeListener( rPropertyName, rxListener ); } + void SAL_CALL removePropertyChangeListener( const OUString& rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& rxListener ) override { OPropertySetHelper::removePropertyChangeListener( rPropertyName, rxListener ); } + void SAL_CALL addVetoableChangeListener( const OUString& rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& rxListener ) override { OPropertySetHelper::addVetoableChangeListener( rPropertyName, rxListener ); } + void SAL_CALL removeVetoableChangeListener( const OUString& rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& rxListener ) override { OPropertySetHelper::removeVetoableChangeListener( rPropertyName, rxListener ); } + + // ::cppu::OPropertySetHelper + ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + sal_Bool SAL_CALL convertFastPropertyValue( css::uno::Any & rConvertedValue, css::uno::Any & rOldValue, sal_Int32 nHandle, const css::uno::Any& rValue ) override; + void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const css::uno::Any& rValue ) override; + using cppu::OPropertySetHelper::getFastPropertyValue; + void SAL_CALL getFastPropertyValue( css::uno::Any& rValue, sal_Int32 nHandle ) const override; + + // css::awt::XPrinterPropertySet + void SAL_CALL setHorizontal( sal_Bool bHorizontal ) override; + css::uno::Sequence< OUString > SAL_CALL getFormDescriptions( ) override; + void SAL_CALL selectForm( const OUString& aFormDescription ) override; + css::uno::Sequence< sal_Int8 > SAL_CALL getBinarySetup( ) override; + void SAL_CALL setBinarySetup( const css::uno::Sequence< sal_Int8 >& data ) override; +}; + + + + +typedef ::cppu::ImplInheritanceHelper < VCLXPrinterPropertySet + , css::awt::XPrinter + > VCLXPrinter_Base; +class VCLXPrinter final : public VCLXPrinter_Base +{ + std::shared_ptr mxListener; + JobSetup maInitJobSetup; +public: + VCLXPrinter( const OUString& rPrinterName ); + virtual ~VCLXPrinter() override; + + // css::beans::XPropertySet + css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override { return VCLXPrinterPropertySet::getPropertySetInfo(); } + void SAL_CALL setPropertyValue( const OUString& rPropertyName, const css::uno::Any& aValue ) override { VCLXPrinterPropertySet::setPropertyValue( rPropertyName, aValue ); } + css::uno::Any SAL_CALL getPropertyValue( const OUString& rPropertyName ) override { return VCLXPrinterPropertySet::getPropertyValue( rPropertyName ); } + void SAL_CALL addPropertyChangeListener( const OUString& rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& rxListener ) override { VCLXPrinterPropertySet::addPropertyChangeListener( rPropertyName, rxListener ); } + void SAL_CALL removePropertyChangeListener( const OUString& rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& rxListener ) override { VCLXPrinterPropertySet::removePropertyChangeListener( rPropertyName, rxListener ); } + void SAL_CALL addVetoableChangeListener( const OUString& rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& rxListener ) override { VCLXPrinterPropertySet::addVetoableChangeListener( rPropertyName, rxListener ); } + void SAL_CALL removeVetoableChangeListener( const OUString& rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& rxListener ) override { VCLXPrinterPropertySet::removeVetoableChangeListener( rPropertyName, rxListener ); } + + // css::awt::XPrinterPropertySet + void SAL_CALL setHorizontal( sal_Bool bHorizontal ) override { VCLXPrinterPropertySet::setHorizontal( bHorizontal ); } + css::uno::Sequence< OUString > SAL_CALL getFormDescriptions( ) override { return VCLXPrinterPropertySet::getFormDescriptions(); } + void SAL_CALL selectForm( const OUString& aFormDescription ) override { VCLXPrinterPropertySet::selectForm( aFormDescription ); } + css::uno::Sequence< sal_Int8 > SAL_CALL getBinarySetup( ) override { return VCLXPrinterPropertySet::getBinarySetup(); } + void SAL_CALL setBinarySetup( const css::uno::Sequence< sal_Int8 >& data ) override { VCLXPrinterPropertySet::setBinarySetup( data ); } + + // css::awt::XPrinter + sal_Bool SAL_CALL start( const OUString& nJobName, sal_Int16 nCopies, sal_Bool nCollate ) override; + void SAL_CALL end( ) override; + void SAL_CALL terminate( ) override; + css::uno::Reference< css::awt::XDevice > SAL_CALL startPage( ) override; + void SAL_CALL endPage( ) override; +}; + + + + +typedef ::cppu::ImplInheritanceHelper < VCLXPrinterPropertySet + , css::awt::XInfoPrinter + > VCLXInfoPrinter_Base; +class VCLXInfoPrinter final : public VCLXInfoPrinter_Base +{ +public: + VCLXInfoPrinter( const OUString& rPrinterName ); + virtual ~VCLXInfoPrinter() override; + + // css::beans::XPropertySet + css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override { return VCLXPrinterPropertySet::getPropertySetInfo(); } + void SAL_CALL setPropertyValue( const OUString& rPropertyName, const css::uno::Any& aValue ) override { VCLXPrinterPropertySet::setPropertyValue( rPropertyName, aValue ); } + css::uno::Any SAL_CALL getPropertyValue( const OUString& rPropertyName ) override { return VCLXPrinterPropertySet::getPropertyValue( rPropertyName ); } + void SAL_CALL addPropertyChangeListener( const OUString& rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& rxListener ) override { VCLXPrinterPropertySet::addPropertyChangeListener( rPropertyName, rxListener ); } + void SAL_CALL removePropertyChangeListener( const OUString& rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& rxListener ) override { VCLXPrinterPropertySet::removePropertyChangeListener( rPropertyName, rxListener ); } + void SAL_CALL addVetoableChangeListener( const OUString& rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& rxListener ) override { VCLXPrinterPropertySet::addVetoableChangeListener( rPropertyName, rxListener ); } + void SAL_CALL removeVetoableChangeListener( const OUString& rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& rxListener ) override { VCLXPrinterPropertySet::removeVetoableChangeListener( rPropertyName, rxListener ); } + + // css::awt::XPrinterPropertySet + void SAL_CALL setHorizontal( sal_Bool bHorizontal ) override { VCLXPrinterPropertySet::setHorizontal( bHorizontal ); } + css::uno::Sequence< OUString > SAL_CALL getFormDescriptions( ) override { return VCLXPrinterPropertySet::getFormDescriptions(); } + void SAL_CALL selectForm( const OUString& aFormDescription ) override { VCLXPrinterPropertySet::selectForm( aFormDescription ); } + css::uno::Sequence< sal_Int8 > SAL_CALL getBinarySetup( ) override { return VCLXPrinterPropertySet::getBinarySetup(); } + void SAL_CALL setBinarySetup( const css::uno::Sequence< sal_Int8 >& data ) override { VCLXPrinterPropertySet::setBinarySetup( data ); } + + // css::awt::XInfoPrinter + css::uno::Reference< css::awt::XDevice > SAL_CALL createDevice( ) override; +}; + + + + +typedef ::cppu::WeakImplHelper < css::awt::XPrinterServer2, + css::lang::XServiceInfo + > VCLXPrinterServer_Base; +class VCLXPrinterServer final : public VCLXPrinterServer_Base +{ +public: + // css::awt::XPrinterServer2 + css::uno::Sequence< OUString > SAL_CALL getPrinterNames( ) override; + OUString SAL_CALL getDefaultPrinterName() override; + css::uno::Reference< css::awt::XPrinter > SAL_CALL createPrinter( const OUString& printerName ) override; + css::uno::Reference< css::awt::XInfoPrinter > SAL_CALL createInfoPrinter( const OUString& printerName ) override; + + OUString SAL_CALL getImplementationName() override; + + sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override; + + css::uno::Sequence SAL_CALL getSupportedServiceNames() override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/inc/awt/vclxregion.hxx b/toolkit/inc/awt/vclxregion.hxx new file mode 100644 index 000000000..70b79990c --- /dev/null +++ b/toolkit/inc/awt/vclxregion.hxx @@ -0,0 +1,67 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + + +#include +#include +#include +#include +#include + +#include + + + + +class VCLXRegion final : public cppu::WeakImplHelper< + css::awt::XRegion, + css::lang::XUnoTunnel> +{ + std::mutex maMutex; + vcl::Region maRegion; + +public: + VCLXRegion(); + virtual ~VCLXRegion() override; + + const vcl::Region& GetRegion() const { return maRegion; } + + // css::lang::XUnoTunnel + UNO3_GETIMPLEMENTATION_DECL(VCLXRegion) + + // css::awt::XRegion + css::awt::Rectangle SAL_CALL getBounds() override; + void SAL_CALL clear() override; + void SAL_CALL move( sal_Int32 nHorzMove, sal_Int32 nVertMove ) override; + void SAL_CALL unionRectangle( const css::awt::Rectangle& rRect ) override; + void SAL_CALL intersectRectangle( const css::awt::Rectangle& rRect ) override; + void SAL_CALL excludeRectangle( const css::awt::Rectangle& rRect ) override; + void SAL_CALL xOrRectangle( const css::awt::Rectangle& rRect ) override; + void SAL_CALL unionRegion( const css::uno::Reference< css::awt::XRegion >& rxRegion ) override; + void SAL_CALL intersectRegion( const css::uno::Reference< css::awt::XRegion >& rxRegion ) override; + void SAL_CALL excludeRegion( const css::uno::Reference< css::awt::XRegion >& rxRegion ) override; + void SAL_CALL xOrRegion( const css::uno::Reference< css::awt::XRegion >& rxRegion ) override; + css::uno::Sequence< css::awt::Rectangle > SAL_CALL getRectangles() override; + +}; + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/inc/awt/vclxspinbutton.hxx b/toolkit/inc/awt/vclxspinbutton.hxx new file mode 100644 index 000000000..acd7a6898 --- /dev/null +++ b/toolkit/inc/awt/vclxspinbutton.hxx @@ -0,0 +1,88 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include +#include +#include +#include +#include + + +namespace toolkit +{ + + + //= VCLXSpinButton + + typedef ::cppu::ImplHelper1 < css::awt::XSpinValue + > VCLXSpinButton_Base; + + class VCLXSpinButton final : public VCLXWindow + ,public VCLXSpinButton_Base + { + private: + AdjustmentListenerMultiplexer maAdjustmentListeners; + + public: + VCLXSpinButton(); + + private: + virtual ~VCLXSpinButton( ) override; + + // XInterface + DECLARE_XINTERFACE() + + // XTypeProvider + DECLARE_XTYPEPROVIDER() + + // XComponent + void SAL_CALL dispose( ) override; + + // XSpinValue + virtual void SAL_CALL addAdjustmentListener( const css::uno::Reference< css::awt::XAdjustmentListener >& listener ) override; + virtual void SAL_CALL removeAdjustmentListener( const css::uno::Reference< css::awt::XAdjustmentListener >& listener ) override; + virtual void SAL_CALL setValue( sal_Int32 n ) override; + virtual void SAL_CALL setValues( sal_Int32 minValue, sal_Int32 maxValue, sal_Int32 currentValue ) override; + virtual sal_Int32 SAL_CALL getValue( ) override; + virtual void SAL_CALL setMinimum( sal_Int32 minValue ) override; + virtual void SAL_CALL setMaximum( sal_Int32 maxValue ) override; + virtual sal_Int32 SAL_CALL getMinimum( ) override; + virtual sal_Int32 SAL_CALL getMaximum( ) override; + virtual void SAL_CALL setSpinIncrement( sal_Int32 spinIncrement ) override; + virtual sal_Int32 SAL_CALL getSpinIncrement( ) override; + virtual void SAL_CALL setOrientation( sal_Int32 orientation ) override; + virtual sal_Int32 SAL_CALL getOrientation( ) override; + + // VclWindowPeer + virtual void SAL_CALL setProperty( const OUString& PropertyName, const css::uno::Any& Value ) override; + virtual css::uno::Any SAL_CALL getProperty( const OUString& PropertyName ) override; + + // VCLXWindow + void ProcessWindowEvent( const VclWindowEvent& _rVclWindowEvent ) override; + + VCLXSpinButton( const VCLXSpinButton& ) = delete; + VCLXSpinButton& operator=( const VCLXSpinButton& ) = delete; + }; + + +} // namespacetoolkit + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/inc/awt/vclxsystemdependentwindow.hxx b/toolkit/inc/awt/vclxsystemdependentwindow.hxx new file mode 100644 index 000000000..4bab43c49 --- /dev/null +++ b/toolkit/inc/awt/vclxsystemdependentwindow.hxx @@ -0,0 +1,49 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + + +#include +#include + +#include + +class VCLXSystemDependentWindow final : public css::awt::XSystemDependentWindowPeer, + public VCLXWindow +{ +public: + VCLXSystemDependentWindow(); + virtual ~VCLXSystemDependentWindow() override; + + // css::uno::XInterface + css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + void SAL_CALL acquire() noexcept override { OWeakObject::acquire(); } + void SAL_CALL release() noexcept override { OWeakObject::release(); } + + // css::lang::XTypeProvider + css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // css::awt::XSystemDependentWindowPeer + css::uno::Any SAL_CALL getWindowHandle( const css::uno::Sequence< sal_Int8 >& ProcessId, sal_Int16 SystemType ) override; +}; + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/inc/awt/vclxtabpagecontainer.hxx b/toolkit/inc/awt/vclxtabpagecontainer.hxx new file mode 100644 index 000000000..e300e03af --- /dev/null +++ b/toolkit/inc/awt/vclxtabpagecontainer.hxx @@ -0,0 +1,73 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include +#include +#include +#include +#include + + +typedef cppu::ImplInheritanceHelper< VCLXContainer, + css::awt::tab::XTabPageContainer, + css::beans::XPropertiesChangeListener, + css::container::XContainerListener + > VCLXTabPageContainer_Base; +class VCLXTabPageContainer final : public VCLXTabPageContainer_Base +{ +public: + VCLXTabPageContainer(); + virtual ~VCLXTabPageContainer() override; + + // css::awt::XView + void SAL_CALL draw( sal_Int32 nX, sal_Int32 nY ) override; + + // css::awt::grid::XTabPageContainer + virtual ::sal_Int16 SAL_CALL getActiveTabPageID() override; + virtual void SAL_CALL setActiveTabPageID( ::sal_Int16 _activetabpageid ) override; + virtual ::sal_Int16 SAL_CALL getTabPageCount( ) override; + virtual sal_Bool SAL_CALL isTabPageActive( ::sal_Int16 tabPageIndex ) override; + virtual css::uno::Reference< css::awt::tab::XTabPage > SAL_CALL getTabPage( ::sal_Int16 tabPageIndex ) override; + virtual css::uno::Reference< css::awt::tab::XTabPage > SAL_CALL getTabPageByID( ::sal_Int16 tabPageID ) override; + virtual void SAL_CALL addTabPageContainerListener( const css::uno::Reference< css::awt::tab::XTabPageContainerListener >& listener ) override; + virtual void SAL_CALL removeTabPageContainerListener( const css::uno::Reference< css::awt::tab::XTabPageContainerListener >& listener ) override; + + virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override; + + virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + virtual void SAL_CALL elementInserted( const css::container::ContainerEvent& Event ) override; + virtual void SAL_CALL elementRemoved( const css::container::ContainerEvent& Event ) override; + virtual void SAL_CALL elementReplaced( const css::container::ContainerEvent& Event ) override; + + // css::beans::XPropertiesChangeListener + virtual void SAL_CALL propertiesChange( const ::css::uno::Sequence< ::css::beans::PropertyChangeEvent >& aEvent ) override; + + // css::awt::XVclWindowPeer + void SAL_CALL setProperty( const OUString& PropertyName, const css::uno::Any& Value ) override; +private: + virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) override; + + TabPageListenerMultiplexer m_aTabPageListeners; + ::std::vector< css::uno::Reference< css::awt::tab::XTabPage > > m_aTabPages; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/inc/awt/vclxtopwindow.hxx b/toolkit/inc/awt/vclxtopwindow.hxx new file mode 100644 index 000000000..ad07c2780 --- /dev/null +++ b/toolkit/inc/awt/vclxtopwindow.hxx @@ -0,0 +1,78 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_TOOLKIT_AWT_VCLXTOPWINDOW_HXX +#define INCLUDED_TOOLKIT_AWT_VCLXTOPWINDOW_HXX + +#include +#include +#include + +#include + +#include + +namespace com::sun::star::awt { class XMenuBar; } + +typedef ::cppu::ImplHelper2 < css::awt::XTopWindow2, css::awt::XSystemDependentWindowPeer + > VCLXTopWindow_XBase; + + +class VCLXTopWindow: public VCLXTopWindow_XBase, + public VCLXContainer +{ +public: + VCLXTopWindow(); + virtual ~VCLXTopWindow() override; + + // css::uno::XInterface + css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + void SAL_CALL acquire() noexcept override { OWeakObject::acquire(); } + void SAL_CALL release() noexcept override { OWeakObject::release(); } + + // css::lang::XTypeProvider + css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // css::awt::XSystemDependentWindowPeer + css::uno::Any SAL_CALL getWindowHandle( const css::uno::Sequence< sal_Int8 >& ProcessId, sal_Int16 SystemType ) override; + + // css::awt::XTopWindow + void SAL_CALL addTopWindowListener( const css::uno::Reference< css::awt::XTopWindowListener >& rxListener ) override; + void SAL_CALL removeTopWindowListener( const css::uno::Reference< css::awt::XTopWindowListener >& rxListener ) override; + void SAL_CALL toFront() override; + void SAL_CALL toBack() override; + void SAL_CALL setMenuBar( const css::uno::Reference< css::awt::XMenuBar >& xMenu ) override; + + // XTopWindow2 + virtual sal_Bool SAL_CALL getIsMaximized() override; + virtual void SAL_CALL setIsMaximized( sal_Bool _ismaximized ) override; + virtual sal_Bool SAL_CALL getIsMinimized() override; + virtual void SAL_CALL setIsMinimized( sal_Bool _isminimized ) override; + virtual ::sal_Int32 SAL_CALL getDisplay() override; + virtual void SAL_CALL setDisplay( ::sal_Int32 _display ) override; + + static void ImplGetPropertyIds( std::vector< sal_uInt16 > &aIds ); + virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override { return ImplGetPropertyIds( aIds ); } +}; + + +#endif // INCLUDED_TOOLKIT_AWT_VCLXTOPWINDOW_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/inc/awt/vclxwindows.hxx b/toolkit/inc/awt/vclxwindows.hxx new file mode 100644 index 000000000..21950271e --- /dev/null +++ b/toolkit/inc/awt/vclxwindows.hxx @@ -0,0 +1,697 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +class FormatterBase; +class TabControl; +class TabPage; +class Edit; + +// class VCLXImageControl +class VCLXImageControl final : public VCLXGraphicControl +{ +public: + VCLXImageControl(); + virtual ~VCLXImageControl() override; + + // css::awt::XLayoutConstrains + css::awt::Size SAL_CALL getMinimumSize( ) override; + css::awt::Size SAL_CALL getPreferredSize( ) override; + css::awt::Size SAL_CALL calcAdjustedSize( const css::awt::Size& rNewSize ) override; + + // css::awt::VclWindowPeer + void SAL_CALL setProperty( const OUString& PropertyName, const css::uno::Any& Value ) override; + css::uno::Any SAL_CALL getProperty( const OUString& PropertyName ) override; + + static void ImplGetPropertyIds( std::vector< sal_uInt16 > &aIds ); + virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override { return ImplGetPropertyIds( aIds ); } + +private: + virtual void ImplSetNewImage() override; +}; + +// class VCLXMessageBox +class VCLXMessageBox final : public css::awt::XMessageBox, + public VCLXTopWindow +{ +public: + VCLXMessageBox(); + virtual ~VCLXMessageBox() override; + + // css::uno::XInterface + css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + void SAL_CALL acquire() noexcept override { OWeakObject::acquire(); } + void SAL_CALL release() noexcept override { OWeakObject::release(); } + + // css::lang::XTypeProvider + css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + + // css::awt::XMessageBox + void SAL_CALL setCaptionText( const OUString& aText ) override; + OUString SAL_CALL getCaptionText( ) override; + void SAL_CALL setMessageText( const OUString& aText ) override; + OUString SAL_CALL getMessageText( ) override; + sal_Int16 SAL_CALL execute( ) override; + + // css::awt::XLayoutConstrains + css::awt::Size SAL_CALL getMinimumSize() override; + + virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override; +}; + +// class VCLXFrame +class VCLXFrame final : public VCLXContainer +{ + void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) override; + +public: + VCLXFrame(); + virtual ~VCLXFrame() override; + + // css::uno::XInterface + void SAL_CALL acquire() noexcept override { OWeakObject::acquire(); } + void SAL_CALL release() noexcept override { OWeakObject::release(); } + + // css::lang::XTypeProvider + css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // css::awt::XView + void SAL_CALL draw( sal_Int32 nX, sal_Int32 nY ) override; + + // css::awt::XVclWindowPeer + void SAL_CALL setProperty( const OUString& PropertyName, const css::uno::Any& Value ) override; + + static void ImplGetPropertyIds( std::vector< sal_uInt16 > &aIds ); + virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override { return ImplGetPropertyIds( aIds ); } +}; + +// class VCLXDialog +class VCLXDialog final : public css::awt::XDialog2, + public VCLXTopWindow +{ +public: + VCLXDialog(); + virtual ~VCLXDialog() override; + + // css::uno::XInterface + css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + void SAL_CALL acquire() noexcept override { OWeakObject::acquire(); } + void SAL_CALL release() noexcept override { OWeakObject::release(); } + + // css::lang::XTypeProvider + css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // css::awt::XDialog2 + virtual void SAL_CALL endDialog( ::sal_Int32 Result ) override; + virtual void SAL_CALL setHelpId( const OUString& Id ) override; + + // css::awt::XDialog + void SAL_CALL setTitle( const OUString& Title ) override; + OUString SAL_CALL getTitle( ) override; + sal_Int16 SAL_CALL execute( ) override; + void SAL_CALL endExecute( ) override; + + // css::awt::XView + void SAL_CALL draw( sal_Int32 nX, sal_Int32 nY ) override; + + // css::awt::XDevice, + css::awt::DeviceInfo SAL_CALL getInfo() override; + + virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override; + + // css::awt::XVclWindowPeer + void SAL_CALL setProperty( const OUString& PropertyName, const css::uno::Any& Value ) override; + +}; + +// class VCLXTabPage +class VCLXTabPage final : public VCLXContainer +{ +public: + VCLXTabPage(); + virtual ~VCLXTabPage() override; + + // css::uno::XInterface + void SAL_CALL acquire() noexcept override { OWeakObject::acquire(); } + void SAL_CALL release() noexcept override { OWeakObject::release(); } + + // css::lang::XTypeProvider + css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // css::awt::XView + void SAL_CALL draw( sal_Int32 nX, sal_Int32 nY ) override; + + // css::awt::XVclWindowPeer + void SAL_CALL setProperty( const OUString& PropertyName, const css::uno::Any& Value ) override; + + /// @throws css::uno::RuntimeException + TabPage* getTabPage() const; + static void ImplGetPropertyIds( std::vector< sal_uInt16 > &aIds ); + virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override { return ImplGetPropertyIds( aIds ); } +}; + +class VCLXMultiPage final : public css::awt::XSimpleTabController, public VCLXContainer +{ + TabListenerMultiplexer maTabListeners; + sal_Int32 mTabId; + + void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) override; +public: + VCLXMultiPage(); + virtual ~VCLXMultiPage() override; + + // css::uno::XInterface + css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + void SAL_CALL acquire() noexcept override { OWeakObject::acquire(); } + void SAL_CALL release() noexcept override { OWeakObject::release(); } + + // css::lang::XTypeProvider + css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // css::lang::XComponent + void SAL_CALL dispose( ) override; + + // css::awt::XView + void SAL_CALL draw( sal_Int32 nX, sal_Int32 nY ) override; + + // css::awt::XVclWindowPeer + void SAL_CALL setProperty( const OUString& PropertyName, const css::uno::Any& Value ) override; + css::uno::Any SAL_CALL getProperty( const OUString& PropertyName ) override; + // XSimpleTabController + virtual ::sal_Int32 SAL_CALL insertTab() override; + virtual void SAL_CALL removeTab( ::sal_Int32 ID ) override; + + virtual void SAL_CALL setTabProps( ::sal_Int32 ID, const css::uno::Sequence< css::beans::NamedValue >& Properties ) override; + virtual css::uno::Sequence< css::beans::NamedValue > SAL_CALL getTabProps( ::sal_Int32 ID ) override; + + virtual void SAL_CALL activateTab( ::sal_Int32 ID ) override; + virtual ::sal_Int32 SAL_CALL getActiveTabID() override; + + virtual void SAL_CALL addTabListener( const css::uno::Reference< css::awt::XTabListener >& Listener ) override; + virtual void SAL_CALL removeTabListener( const css::uno::Reference< css::awt::XTabListener >& Listener ) override; + // C++ + /// @throws css::uno::RuntimeException + TabControl* getTabControl() const; + sal_uInt16 insertTab( TabPage*, OUString const & sTitle ); + static void ImplGetPropertyIds( std::vector< sal_uInt16 > &aIds ); + virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override { return ImplGetPropertyIds( aIds ); } +}; + +class VCLXMultiLineEdit final : public css::awt::XTextComponent, + public css::awt::XTextArea, + public css::awt::XTextLayoutConstrains, + public VCLXWindow +{ +private: + TextListenerMultiplexer maTextListeners; + LineEnd meLineEndType; + + void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) override; + +public: + VCLXMultiLineEdit(); + virtual ~VCLXMultiLineEdit() override; + + // css::uno::XInterface + css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + void SAL_CALL acquire() noexcept override { VCLXWindow::acquire(); } + void SAL_CALL release() noexcept override { VCLXWindow::release(); } + + // css::lang::XTypeProvider + css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // css::awt::XTextComponent + void SAL_CALL addTextListener( const css::uno::Reference< css::awt::XTextListener >& l ) override; + void SAL_CALL removeTextListener( const css::uno::Reference< css::awt::XTextListener >& l ) override; + void SAL_CALL setText( const OUString& aText ) override; + void SAL_CALL insertText( const css::awt::Selection& Sel, const OUString& Text ) override; + OUString SAL_CALL getText( ) override; + OUString SAL_CALL getSelectedText( ) override; + void SAL_CALL setSelection( const css::awt::Selection& aSelection ) override; + css::awt::Selection SAL_CALL getSelection( ) override; + sal_Bool SAL_CALL isEditable( ) override; + void SAL_CALL setEditable( sal_Bool bEditable ) override; + void SAL_CALL setMaxTextLen( sal_Int16 nLen ) override; + sal_Int16 SAL_CALL getMaxTextLen( ) override; + + //XTextArea + OUString SAL_CALL getTextLines( ) override; + + // css::awt::XLayoutConstrains + css::awt::Size SAL_CALL getMinimumSize( ) override; + css::awt::Size SAL_CALL getPreferredSize( ) override; + css::awt::Size SAL_CALL calcAdjustedSize( const css::awt::Size& aNewSize ) override; + + // css::awt::XTextLayoutConstrains + css::awt::Size SAL_CALL getMinimumSize( sal_Int16 nCols, sal_Int16 nLines ) override; + void SAL_CALL getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) override; + + // css::awt::XVclWindowPeer + void SAL_CALL setProperty( const OUString& PropertyName, const css::uno::Any& Value ) override; + css::uno::Any SAL_CALL getProperty( const OUString& PropertyName ) override; + + // css::awt::XWindow + void SAL_CALL setFocus( ) override; + + static void ImplGetPropertyIds( std::vector< sal_uInt16 > &aIds ); + virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override { return ImplGetPropertyIds( aIds ); } +}; + +// class VCLXProgressBar +class VCLXProgressBar final : public css::awt::XProgressBar + , public VCLXWindow +{ +private: + sal_Int32 m_nValue; + sal_Int32 m_nValueMin; + sal_Int32 m_nValueMax; + + void ImplUpdateValue(); + +public: + VCLXProgressBar(); + virtual ~VCLXProgressBar() override; + + // css::uno::XInterface + css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + void SAL_CALL acquire() noexcept override { VCLXWindow::acquire(); } + void SAL_CALL release() noexcept override { VCLXWindow::release(); } + + // css::lang::XTypeProvider + css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // css::awt::XProgressBar + void SAL_CALL setForegroundColor( sal_Int32 nColor ) override; + void SAL_CALL setBackgroundColor( sal_Int32 nColor ) override; + void SAL_CALL setValue( sal_Int32 nValue ) override; + void SAL_CALL setRange( sal_Int32 nMin, sal_Int32 nMax ) override; + sal_Int32 SAL_CALL getValue() override; + + // css::awt::VclWindowPeer + void SAL_CALL setProperty( const OUString& PropertyName, const css::uno::Any& Value ) override; + css::uno::Any SAL_CALL getProperty( const OUString& PropertyName ) override; + + static void ImplGetPropertyIds( std::vector< sal_uInt16 > &aIds ); + virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override { return ImplGetPropertyIds( aIds ); } +}; + + +// class VCLXFormattedSpinField +class VCLXFormattedSpinField : public VCLXSpinField +{ +private: + FormatterBase* mpFormatter; + +protected: + FormatterBase* GetFormatter() const { return GetWindow() ? mpFormatter : nullptr; } + +public: + VCLXFormattedSpinField(); + virtual ~VCLXFormattedSpinField() override; + + void SetFormatter( FormatterBase* pFormatter ) { mpFormatter = pFormatter; } + + void setStrictFormat( bool bStrict ); + bool isStrictFormat() const; + + // css::awt::VclWindowPeer + void SAL_CALL setProperty( const OUString& PropertyName, const css::uno::Any& Value ) override; + css::uno::Any SAL_CALL getProperty( const OUString& PropertyName ) override; + + static void ImplGetPropertyIds( std::vector< sal_uInt16 > &aIds ); + virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override { return ImplGetPropertyIds( aIds ); } +}; + + +// class VCLXDateField + +class VCLXDateField : public css::awt::XDateField, + public VCLXFormattedSpinField +{ +protected: + virtual css::uno::Reference< css::accessibility::XAccessibleContext > CreateAccessibleContext() override; +public: + VCLXDateField(); + virtual ~VCLXDateField() override; + + // css::uno::XInterface + css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + void SAL_CALL acquire() noexcept override { OWeakObject::acquire(); } + void SAL_CALL release() noexcept override { OWeakObject::release(); } + + // css::lang::XTypeProvider + css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + + // css::awt::XDateField + void SAL_CALL setDate( const css::util::Date& Date ) override; + css::util::Date SAL_CALL getDate( ) override; + void SAL_CALL setMin( const css::util::Date& Date ) override; + css::util::Date SAL_CALL getMin( ) override; + void SAL_CALL setMax( const css::util::Date& Date ) override; + css::util::Date SAL_CALL getMax( ) override; + void SAL_CALL setFirst( const css::util::Date& Date ) override; + css::util::Date SAL_CALL getFirst( ) override; + void SAL_CALL setLast( const css::util::Date& Date ) override; + css::util::Date SAL_CALL getLast( ) override; + void SAL_CALL setLongFormat( sal_Bool bLong ) override; + sal_Bool SAL_CALL isLongFormat( ) override; + void SAL_CALL setEmpty( ) override; + sal_Bool SAL_CALL isEmpty( ) override; + void SAL_CALL setStrictFormat( sal_Bool bStrict ) override; + sal_Bool SAL_CALL isStrictFormat( ) override; + + // css::awt::VclWindowPeer + void SAL_CALL setProperty( const OUString& PropertyName, const css::uno::Any& Value ) override; + css::uno::Any SAL_CALL getProperty( const OUString& PropertyName ) override; + + static void ImplGetPropertyIds( std::vector< sal_uInt16 > &aIds ); + virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override { return ImplGetPropertyIds( aIds ); } +}; + + +// class VCLXTimeField + +class VCLXTimeField final : public css::awt::XTimeField, + public VCLXFormattedSpinField +{ + virtual css::uno::Reference< css::accessibility::XAccessibleContext > CreateAccessibleContext() override; +public: + VCLXTimeField(); + virtual ~VCLXTimeField() override; + + // css::uno::XInterface + css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + void SAL_CALL acquire() noexcept override { OWeakObject::acquire(); } + void SAL_CALL release() noexcept override { OWeakObject::release(); } + + // css::lang::XTypeProvider + css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // css::awt::XTimeField + void SAL_CALL setTime( const css::util::Time& Time ) override; + css::util::Time SAL_CALL getTime( ) override; + void SAL_CALL setMin( const css::util::Time& Time ) override; + css::util::Time SAL_CALL getMin( ) override; + void SAL_CALL setMax( const css::util::Time& Time ) override; + css::util::Time SAL_CALL getMax( ) override; + void SAL_CALL setFirst( const css::util::Time& Time ) override; + css::util::Time SAL_CALL getFirst( ) override; + void SAL_CALL setLast( const css::util::Time& Time ) override; + css::util::Time SAL_CALL getLast( ) override; + void SAL_CALL setEmpty( ) override; + sal_Bool SAL_CALL isEmpty( ) override; + void SAL_CALL setStrictFormat( sal_Bool bStrict ) override; + sal_Bool SAL_CALL isStrictFormat( ) override; + + // css::awt::VclWindowPeer + void SAL_CALL setProperty( const OUString& PropertyName, const css::uno::Any& Value ) override; + css::uno::Any SAL_CALL getProperty( const OUString& PropertyName ) override; + + static void ImplGetPropertyIds( std::vector< sal_uInt16 > &aIds ); + virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override { return ImplGetPropertyIds( aIds ); } +}; + + +// class VCLXNumericField + +class VCLXNumericField final : public css::awt::XNumericField, + public VCLXFormattedSpinField +{ +public: + VCLXNumericField(); + virtual ~VCLXNumericField() override; + + // css::uno::XInterface + css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + void SAL_CALL acquire() noexcept override { OWeakObject::acquire(); } + void SAL_CALL release() noexcept override { OWeakObject::release(); } + + // css::lang::XTypeProvider + css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // css::awt::XNumericField + void SAL_CALL setValue( double Value ) override; + double SAL_CALL getValue( ) override; + void SAL_CALL setMin( double Value ) override; + double SAL_CALL getMin( ) override; + void SAL_CALL setMax( double Value ) override; + double SAL_CALL getMax( ) override; + void SAL_CALL setFirst( double Value ) override; + double SAL_CALL getFirst( ) override; + void SAL_CALL setLast( double Value ) override; + double SAL_CALL getLast( ) override; + void SAL_CALL setSpinSize( double Value ) override; + double SAL_CALL getSpinSize( ) override; + void SAL_CALL setDecimalDigits( sal_Int16 nDigits ) override; + sal_Int16 SAL_CALL getDecimalDigits( ) override; + void SAL_CALL setStrictFormat( sal_Bool bStrict ) override; + sal_Bool SAL_CALL isStrictFormat( ) override; + + // css::awt::VclWindowPeer + void SAL_CALL setProperty( const OUString& PropertyName, const css::uno::Any& Value ) override; + css::uno::Any SAL_CALL getProperty( const OUString& PropertyName ) override; + + static void ImplGetPropertyIds( std::vector< sal_uInt16 > &aIds ); + virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override { return ImplGetPropertyIds( aIds ); } +}; + + +// class VCLXMetricField + +class MetricFormatter; +class MetricField; +class VCLXMetricField final : public css::awt::XMetricField, + public VCLXFormattedSpinField +{ + /// @throws css::uno::RuntimeException + MetricFormatter *GetMetricFormatter(); + /// @throws css::uno::RuntimeException + MetricField *GetMetricField(); + void CallListeners(); +public: + VCLXMetricField(); + virtual ~VCLXMetricField() override; + + // css::uno::XInterface + css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + void SAL_CALL acquire() noexcept override { OWeakObject::acquire(); } + void SAL_CALL release() noexcept override { OWeakObject::release(); } + + // css::lang::XTypeProvider + css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // css::awt::XMetricField + virtual void SAL_CALL setValue( ::sal_Int64 Value, ::sal_Int16 Unit ) override; + virtual void SAL_CALL setUserValue( ::sal_Int64 Value, ::sal_Int16 Unit ) override; + virtual ::sal_Int64 SAL_CALL getValue( ::sal_Int16 Unit ) override; + virtual ::sal_Int64 SAL_CALL getCorrectedValue( ::sal_Int16 Unit ) override; + virtual void SAL_CALL setMin( ::sal_Int64 Value, ::sal_Int16 Unit ) override; + virtual ::sal_Int64 SAL_CALL getMin( ::sal_Int16 Unit ) override; + virtual void SAL_CALL setMax( ::sal_Int64 Value, ::sal_Int16 Unit ) override; + virtual ::sal_Int64 SAL_CALL getMax( ::sal_Int16 Unit ) override; + virtual void SAL_CALL setFirst( ::sal_Int64 Value, ::sal_Int16 Unit ) override; + virtual ::sal_Int64 SAL_CALL getFirst( ::sal_Int16 Unit ) override; + virtual void SAL_CALL setLast( ::sal_Int64 Value, ::sal_Int16 Unit ) override; + virtual ::sal_Int64 SAL_CALL getLast( ::sal_Int16 Unit ) override; + virtual void SAL_CALL setSpinSize( ::sal_Int64 Value ) override; + virtual ::sal_Int64 SAL_CALL getSpinSize( ) override; + virtual void SAL_CALL setDecimalDigits( ::sal_Int16 nDigits ) override; + virtual ::sal_Int16 SAL_CALL getDecimalDigits( ) override; + virtual void SAL_CALL setStrictFormat( sal_Bool bStrict ) override; + virtual sal_Bool SAL_CALL isStrictFormat( ) override; + + // css::awt::VclWindowPeer + void SAL_CALL setProperty( const OUString& PropertyName, const css::uno::Any& Value ) override; + css::uno::Any SAL_CALL getProperty( const OUString& PropertyName ) override; + + static void ImplGetPropertyIds( std::vector< sal_uInt16 > &aIds ); + virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override { return ImplGetPropertyIds( aIds ); } +}; + +// class VCLXPatternField +class VCLXPatternField final : public css::awt::XPatternField, + public VCLXFormattedSpinField +{ +public: + VCLXPatternField(); + virtual ~VCLXPatternField() override; + + // css::uno::XInterface + css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + void SAL_CALL acquire() noexcept override { OWeakObject::acquire(); } + void SAL_CALL release() noexcept override { OWeakObject::release(); } + + // css::lang::XTypeProvider + css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + + // css::awt::XPatternField + void SAL_CALL setMasks( const OUString& EditMask, const OUString& LiteralMask ) override; + void SAL_CALL getMasks( OUString& EditMask, OUString& LiteralMask ) override; + void SAL_CALL setString( const OUString& Str ) override; + OUString SAL_CALL getString( ) override; + void SAL_CALL setStrictFormat( sal_Bool bStrict ) override; + sal_Bool SAL_CALL isStrictFormat( ) override; + + // css::awt::VclWindowPeer + void SAL_CALL setProperty( const OUString& PropertyName, const css::uno::Any& Value ) override; + css::uno::Any SAL_CALL getProperty( const OUString& PropertyName ) override; + + static void ImplGetPropertyIds( std::vector< sal_uInt16 > &aIds ); + virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override { return ImplGetPropertyIds( aIds ); } +}; + + +class VCLXFileControl final : public css::awt::XTextComponent, public css::awt::XTextLayoutConstrains, public VCLXWindow +{ + DECL_LINK(ModifyHdl, Edit&, void); + void ModifyHdl(); + TextListenerMultiplexer maTextListeners; + +public: + VCLXFileControl(); + virtual ~VCLXFileControl() override; + + virtual void SetWindow( const VclPtr< vcl::Window > &pWindow ) override; + + // css::uno::XInterface + css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + void SAL_CALL acquire() noexcept override { VCLXWindow::acquire(); } + void SAL_CALL release() noexcept override { VCLXWindow::release(); } + + // css::lang::XTypeProvider + css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // css::awt::XTextComponent + void SAL_CALL addTextListener( const css::uno::Reference< css::awt::XTextListener >& l ) override; + void SAL_CALL removeTextListener( const css::uno::Reference< css::awt::XTextListener >& l ) override; + void SAL_CALL setText( const OUString& aText ) override; + void SAL_CALL insertText( const css::awt::Selection& Sel, const OUString& Text ) override; + OUString SAL_CALL getText( ) override; + OUString SAL_CALL getSelectedText( ) override; + void SAL_CALL setSelection( const css::awt::Selection& aSelection ) override; + css::awt::Selection SAL_CALL getSelection( ) override; + sal_Bool SAL_CALL isEditable( ) override; + void SAL_CALL setEditable( sal_Bool bEditable ) override; + void SAL_CALL setMaxTextLen( sal_Int16 nLen ) override; + sal_Int16 SAL_CALL getMaxTextLen( ) override; + + // css::awt::XLayoutConstrains + css::awt::Size SAL_CALL getMinimumSize( ) override; + css::awt::Size SAL_CALL getPreferredSize( ) override; + css::awt::Size SAL_CALL calcAdjustedSize( const css::awt::Size& aNewSize ) override; + + // css::awt::XTextLayoutConstrains + css::awt::Size SAL_CALL getMinimumSize( sal_Int16 nCols, sal_Int16 nLines ) override; + void SAL_CALL getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) override; + + void SAL_CALL setProperty( const OUString& PropertyName, const css::uno::Any& Value) override; + + static void ImplGetPropertyIds( std::vector< sal_uInt16 > &aIds ); + virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override { return ImplGetPropertyIds( aIds ); } +}; + +class SVTXCurrencyField final : public css::awt::XCurrencyField, public SVTXFormattedField +{ +public: + SVTXCurrencyField(); + virtual ~SVTXCurrencyField() override; + + // css::uno::XInterface + css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + void SAL_CALL acquire() noexcept override { SVTXFormattedField::acquire(); } + void SAL_CALL release() noexcept override { SVTXFormattedField::release(); } + + // css::lang::XTypeProvider + css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // css::awt::XVclWindowPeer + void SAL_CALL setProperty( const OUString& PropertyName, const css::uno::Any& Value ) override; + css::uno::Any SAL_CALL getProperty( const OUString& PropertyName ) override; + + // css::awt::XCurrencyField + void SAL_CALL setValue( double Value ) override; + double SAL_CALL getValue( ) override; + void SAL_CALL setMin( double Value ) override; + double SAL_CALL getMin( ) override; + void SAL_CALL setMax( double Value ) override; + double SAL_CALL getMax( ) override; + void SAL_CALL setFirst( double Value ) override; + double SAL_CALL getFirst( ) override; + void SAL_CALL setLast( double Value ) override; + double SAL_CALL getLast( ) override; + void SAL_CALL setSpinSize( double Value ) override; + double SAL_CALL getSpinSize( ) override; + void SAL_CALL setDecimalDigits( sal_Int16 nDigits ) override; + sal_Int16 SAL_CALL getDecimalDigits( ) override; + void SAL_CALL setStrictFormat( sal_Bool bStrict ) override; + sal_Bool SAL_CALL isStrictFormat( ) override; + + static void ImplGetPropertyIds( std::vector< sal_uInt16 > &aIds ); + virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override { return ImplGetPropertyIds( aIds ); } +}; + + +class SVTXDateField final : public VCLXDateField +{ +public: + SVTXDateField(); + virtual ~SVTXDateField() override; + + // css::awt::VclWindowPeer + void SAL_CALL setProperty( const OUString& PropertyName, const css::uno::Any& Value ) override; + + static void ImplGetPropertyIds( std::vector< sal_uInt16 > &aIds ); + virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override { return ImplGetPropertyIds( aIds ); } +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/inc/controls/accessiblecontrolcontext.hxx b/toolkit/inc/controls/accessiblecontrolcontext.hxx new file mode 100644 index 000000000..d5233cc54 --- /dev/null +++ b/toolkit/inc/controls/accessiblecontrolcontext.hxx @@ -0,0 +1,123 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include +#include +#include +#include + +namespace vcl { class Window; } +namespace com::sun::star::awt { class XWindow; } +namespace com::sun::star::beans { class XPropertySet; } +namespace com::sun::star::beans { class XPropertySetInfo; } + +namespace toolkit +{ + + + //= OAccessibleControlContext + + + typedef ::comphelper::OAccessibleComponentHelper OAccessibleControlContext_Base; + typedef ::cppu::ImplHelper1 < css::lang::XEventListener + > OAccessibleControlContext_IBase; + + /** class implementing the AccessibleContext for a UNO control - to be used in design mode of the control. +

life time control
+ This control should be held weak by the creator (a UNO control), it itself holds a hard reference to the + control model, and a weak reference to the control. The reference to the model is freed when the model + is being disposed.

+ */ + class OAccessibleControlContext final + :public ::comphelper::OAccessibleImplementationAccess + ,public OAccessibleControlContext_Base + ,public OAccessibleControlContext_IBase + { + public: + /** creates an accessible context for a uno control + @param _rxCreator + the uno control's XAccessible interface. This must be an XControl, from which an XControlModel + can be retrieved. + */ + static rtl::Reference create( + const css::uno::Reference< css::accessibility::XAccessible >& _rxCreator + ); + + // XInterface + DECLARE_XINTERFACE( ) + DECLARE_XTYPEPROVIDER( ) + private: + + // XAccessibleContext + virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) override; + virtual sal_Int16 SAL_CALL getAccessibleRole( ) override; + virtual OUString SAL_CALL getAccessibleDescription( ) override; + virtual OUString SAL_CALL getAccessibleName( ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ) override; + + // XAccessibleComponent + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const css::awt::Point& aPoint ) override; + virtual void SAL_CALL grabFocus( ) override; + virtual sal_Int32 SAL_CALL getForeground( ) override; + virtual sal_Int32 SAL_CALL getBackground( ) override; + + // XEventListener + using comphelper::OAccessibleContextHelper::disposing; + virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + + // retrieves the value of a string property from the model, if the property is present + OUString getModelStringProperty( const char* _pPropertyName ); + + // starts listening at the control model (currently for disposal only) + void startModelListening( ); + // stops listening at the control model + void stopModelListening( ); + + vcl::Window* implGetWindow( css::uno::Reference< css::awt::XWindow >* _pxUNOWindow = nullptr ) const; + + /// ctor. @see Init + OAccessibleControlContext(); + virtual ~OAccessibleControlContext() override; + + /** late ctor + */ + void Init( + const css::uno::Reference< css::accessibility::XAccessible >& _rxCreator + ); + + // OCommonAccessibleComponent overridables + virtual css::awt::Rectangle implGetBounds( ) override; + + css::uno::Reference< css::beans::XPropertySet > + m_xControlModel; // the model of the control which's context we implement + css::uno::Reference< css::beans::XPropertySetInfo > + m_xModelPropsInfo; // the cached property set info of the model + }; + + +} // namespace toolkit + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/inc/controls/animatedimages.hxx b/toolkit/inc/controls/animatedimages.hxx new file mode 100644 index 000000000..a341447c5 --- /dev/null +++ b/toolkit/inc/controls/animatedimages.hxx @@ -0,0 +1,86 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include +#include + +namespace com::sun::star::container { class XContainerListener; } +namespace com::sun::star::uno { class XComponentContext; } + +namespace toolkit +{ + + + typedef ::cppu::AggImplInheritanceHelper1 < UnoControlModel + , css::awt::XAnimatedImages + > AnimatedImagesControlModel_Base; + class AnimatedImagesControlModel : public AnimatedImagesControlModel_Base + { + public: + AnimatedImagesControlModel( css::uno::Reference< css::uno::XComponentContext > const & i_factory ); + AnimatedImagesControlModel( const AnimatedImagesControlModel& i_copySource ); + + virtual rtl::Reference Clone() const override; + + // XPropertySet + css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; + + // XPersistObject + OUString SAL_CALL getServiceName() override; + + // XServiceInfo + OUString SAL_CALL getImplementationName( ) override; + css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + + // XAnimatedImages + virtual ::sal_Int32 SAL_CALL getStepTime() override; + virtual void SAL_CALL setStepTime( ::sal_Int32 _steptime ) override; + virtual sal_Bool SAL_CALL getAutoRepeat() override; + virtual void SAL_CALL setAutoRepeat( sal_Bool _autorepeat ) override; + virtual ::sal_Int16 SAL_CALL getScaleMode() override; + virtual void SAL_CALL setScaleMode( ::sal_Int16 _scalemode ) override; + virtual ::sal_Int32 SAL_CALL getImageSetCount( ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getImageSet( ::sal_Int32 i_index ) override; + virtual void SAL_CALL insertImageSet( ::sal_Int32 i_index, const css::uno::Sequence< OUString >& i_imageURLs ) override; + virtual void SAL_CALL replaceImageSet( ::sal_Int32 i_index, const css::uno::Sequence< OUString >& i_imageURLs ) override; + virtual void SAL_CALL removeImageSet( ::sal_Int32 i_index ) override; + + // XAnimatedImages::XContainer + virtual void SAL_CALL addContainerListener( const css::uno::Reference< css::container::XContainerListener >& i_listener ) override; + virtual void SAL_CALL removeContainerListener( const css::uno::Reference< css::container::XContainerListener >& i_listener ) override; + + protected: + virtual ~AnimatedImagesControlModel() override; + + css::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const override; + ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const css::uno::Any& rValue ) override; + + private: + std::vector< css::uno::Sequence< OUString > > maImageSets; + }; + + +} // namespace toolkit + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/inc/controls/controlmodelcontainerbase.hxx b/toolkit/inc/controls/controlmodelcontainerbase.hxx new file mode 100644 index 000000000..1bbc3f301 --- /dev/null +++ b/toolkit/inc/controls/controlmodelcontainerbase.hxx @@ -0,0 +1,270 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace com::sun::star::resource { class XStringResourceResolver; } +namespace com::sun::star::uno { class XComponentContext; } + + +typedef UnoControlModel ControlModel_Base; +typedef ::cppu::AggImplInheritanceHelper8 < ControlModel_Base + , css::lang::XMultiServiceFactory + , css::container::XContainer + , css::container::XNameContainer + , css::awt::XTabControllerModel + , css::util::XChangesNotifier + , css::beans::XPropertyChangeListener + , css::awt::tab::XTabPageModel + , css::lang::XInitialization + > ControlModelContainer_IBase; + +class ControlModelContainerBase : public ControlModelContainer_IBase +{ +public: + enum ChildOperation { Insert = 0, Remove }; + // would like to make this typedef private, too, but the Forte 7 compiler does have + // problems with this... + typedef ::std::pair< css::uno::Reference< css::awt::XControlModel >, OUString > + UnoControlModelHolder; +private: + typedef ::std::vector< UnoControlModelHolder > UnoControlModelHolderVector; + +public: + // for grouping control models (XTabControllerModel::getGroupXXX) + typedef ::std::vector< css::uno::Reference< css::awt::XControlModel > > + ModelGroup; + typedef ::std::vector< ModelGroup > AllGroups; + + friend struct CloneControlModel; + friend struct CompareControlModel; + +protected: + ContainerListenerMultiplexer maContainerListeners; + ::comphelper::OInterfaceContainerHelper3 maChangeListeners; + UnoControlModelHolderVector maModels; + + AllGroups maGroups; + bool mbGroupsUpToDate; + + OUString m_sImageURL; + OUString m_sTooltip; + sal_Int16 m_nTabPageId; + + void Clone_Impl(ControlModelContainerBase& _rClone) const; +protected: + css::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const override; + ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + + UnoControlModelHolderVector::iterator ImplFindElement( std::u16string_view rName ); + + /// @throws css::lang::IllegalArgumentException + /// @throws css::container::ElementExistException + /// @throws css::lang::WrappedTargetException + /// @throws css::uno::RuntimeException + void updateUserFormChildren( const css::uno::Reference< css::container::XNameContainer >& xAllChildren, const OUString& aName, ChildOperation Operation, const css::uno::Reference< css::awt::XControlModel >& xTarget ); +public: + ControlModelContainerBase( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + ControlModelContainerBase( const ControlModelContainerBase& rModel ); + virtual ~ControlModelContainerBase() override; + + rtl::Reference Clone() const override; + + // css::container::XContainer + void SAL_CALL addContainerListener( const css::uno::Reference< css::container::XContainerListener >& xListener ) override; + void SAL_CALL removeContainerListener( const css::uno::Reference< css::container::XContainerListener >& xListener ) override; + + // css::container::XElementAccess + css::uno::Type SAL_CALL getElementType( ) override; + sal_Bool SAL_CALL hasElements( ) override; + + // css::container::XNameContainer, XNameReplace, XNameAccess + void SAL_CALL replaceByName( const OUString& aName, const css::uno::Any& aElement ) override; + css::uno::Any SAL_CALL getByName( const OUString& aName ) override; + css::uno::Sequence< OUString > SAL_CALL getElementNames( ) override; + sal_Bool SAL_CALL hasByName( const OUString& aName ) override; + void SAL_CALL insertByName( const OUString& aName, const css::uno::Any& aElement ) override; + void SAL_CALL removeByName( const OUString& Name ) override; + + // css::beans::XMultiPropertySet + css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; + + // css::lang::XMultiServiceFactory + css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance( const OUString& aServiceSpecifier ) override; + css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithArguments( const OUString& ServiceSpecifier, const css::uno::Sequence< css::uno::Any >& Arguments ) override; + css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames( ) override; + + // XComponent + void SAL_CALL dispose( ) override; + + // XTabControllerModel + virtual sal_Bool SAL_CALL getGroupControl( ) override; + virtual void SAL_CALL setGroupControl( sal_Bool GroupControl ) override; + virtual void SAL_CALL setControlModels( const css::uno::Sequence< css::uno::Reference< css::awt::XControlModel > >& Controls ) override; + virtual css::uno::Sequence< css::uno::Reference< css::awt::XControlModel > > SAL_CALL getControlModels( ) override; + virtual void SAL_CALL setGroup( const css::uno::Sequence< css::uno::Reference< css::awt::XControlModel > >& Group, const OUString& GroupName ) override; + virtual sal_Int32 SAL_CALL getGroupCount( ) override; + virtual void SAL_CALL getGroup( sal_Int32 nGroup, css::uno::Sequence< css::uno::Reference< css::awt::XControlModel > >& Group, OUString& Name ) override; + virtual void SAL_CALL getGroupByName( const OUString& Name, css::uno::Sequence< css::uno::Reference< css::awt::XControlModel > >& Group ) override; + + // XChangesNotifier + virtual void SAL_CALL addChangesListener( const css::uno::Reference< css::util::XChangesListener >& aListener ) override; + virtual void SAL_CALL removeChangesListener( const css::uno::Reference< css::util::XChangesListener >& aListener ) override; + + // XPropertyChangeListener + virtual void SAL_CALL propertyChange( const css::beans::PropertyChangeEvent& evt ) override; + + // XEventListener + using cppu::OPropertySetHelper::disposing; + virtual void SAL_CALL disposing( const css::lang::EventObject& evt ) override; + + // XServiceInfo + DECLIMPL_SERVICEINFO_DERIVED(ControlModelContainerBase, ControlModel_Base, "toolkit.ControlModelContainerBase" ) + + // XInitialization + virtual void SAL_CALL initialize (const css::uno::Sequence& rArguments) override; + + // css::awt::tab::XTabPageModel + virtual ::sal_Int16 SAL_CALL getTabPageID() override; + virtual sal_Bool SAL_CALL getEnabled() override; + virtual void SAL_CALL setEnabled( sal_Bool _enabled ) override; + virtual OUString SAL_CALL getTitle() override; + virtual void SAL_CALL setTitle( const OUString& _title ) override; + virtual OUString SAL_CALL getImageURL() override; + virtual void SAL_CALL setImageURL( const OUString& _imageurl ) override; + virtual OUString SAL_CALL getToolTip() override; + virtual void SAL_CALL setToolTip( const OUString& _tooltip ) override; + +protected: + void startControlListening( const css::uno::Reference< css::awt::XControlModel >& _rxChildModel ); + void stopControlListening( const css::uno::Reference< css::awt::XControlModel >& _rxChildModel ); + + void implNotifyTabModelChange( const OUString& _rAccessor ); + + void implUpdateGroupStructure(); +}; + +class ResourceListener final : public css::util::XModifyListener, + public ::cppu::OWeakObject +{ + public: + ResourceListener( const css::uno::Reference< css::util::XModifyListener >& xListener ); + virtual ~ResourceListener() override; + + void startListening( const css::uno::Reference< css::resource::XStringResourceResolver >& rResource ); + void stopListening(); + + // XInterface + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override; + virtual void SAL_CALL acquire() noexcept override; + virtual void SAL_CALL release() noexcept override; + + // XModifyListener + virtual void SAL_CALL modified( const css::lang::EventObject& aEvent ) override; + + // XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + + private: + std::mutex m_aMutex; + css::uno::Reference< css::resource::XStringResourceResolver > m_xResource; + css::uno::Reference< css::util::XModifyListener > m_xListener; + bool m_bListening; +}; + +typedef ::cppu::AggImplInheritanceHelper3 < UnoControlContainer + , css::container::XContainerListener + , css::util::XChangesListener + , css::util::XModifyListener + > ControlContainer_IBase; + +class ControlContainerBase : public ControlContainer_IBase +{ +protected: + css::uno::Reference< css::uno::XComponentContext > m_xContext; + bool mbSizeModified; + bool mbPosModified; + css::uno::Reference< css::awt::XTabController > mxTabController; + css::uno::Reference< css::util::XModifyListener > mxListener; + + void ImplInsertControl( css::uno::Reference< css::awt::XControlModel > const & rxModel, const OUString& rName ); + void ImplRemoveControl( css::uno::Reference< css::awt::XControlModel > const & rxModel ); + virtual void ImplSetPosSize( css::uno::Reference< css::awt::XControl >& rxCtrl ); + void ImplUpdateResourceResolver(); + void ImplStartListingForResourceEvents(); + +#ifdef _MSC_VER + // just implemented to let the various FooImplInheritanceHelper compile + ControlContainerBase(); +#endif + +public: + ControlContainerBase( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + virtual ~ControlContainerBase() override; + + DECLIMPL_SERVICEINFO_DERIVED( ControlContainerBase, UnoControlBase, "toolkit.ControlContainerBase" ) + + void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + void SAL_CALL dispose() override; + + void SAL_CALL createPeer( const css::uno::Reference< css::awt::XToolkit >& Toolkit, const css::uno::Reference< css::awt::XWindowPeer >& Parent ) override; + + // css::container::XContainerListener + void SAL_CALL elementInserted( const css::container::ContainerEvent& Event ) override; + void SAL_CALL elementRemoved( const css::container::ContainerEvent& Event ) override; + void SAL_CALL elementReplaced( const css::container::ContainerEvent& Event ) override; + + // XChangesListener + virtual void SAL_CALL changesOccurred( const css::util::ChangesEvent& Event ) override; + + // css::awt::XControl + sal_Bool SAL_CALL setModel( const css::uno::Reference< css::awt::XControlModel >& Model ) override; + void SAL_CALL setDesignMode( sal_Bool bOn ) override; + // XModifyListener + // Using a dummy/no-op implementation here, not sure if every container control needs + // to implement this, certainly Dialog does, lets see about others + virtual void SAL_CALL modified( const css::lang::EventObject& ) override {} +protected: + virtual void ImplModelPropertiesChanged( const css::uno::Sequence< css::beans::PropertyChangeEvent >& rEvents ) override; + virtual void removingControl( const css::uno::Reference< css::awt::XControl >& _rxControl ) override; + virtual void addingControl( const css::uno::Reference< css::awt::XControl >& _rxControl ) override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/inc/controls/dialogcontrol.hxx b/toolkit/inc/controls/dialogcontrol.hxx new file mode 100644 index 000000000..b23c60f44 --- /dev/null +++ b/toolkit/inc/controls/dialogcontrol.hxx @@ -0,0 +1,311 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include +#include +#include +#include + +namespace com::sun::star::awt { class XTopWindowListener; } + +typedef ::cppu::AggImplInheritanceHelper2 < ControlContainerBase + , css::awt::XUnoControlDialog + , css::awt::XWindowListener + > UnoDialogControl_Base; +class UnoDialogControl final : public UnoDialogControl_Base +{ +private: + css::uno::Reference< css::awt::XMenuBar > mxMenuBar; + TopWindowListenerMultiplexer maTopWindowListeners; + bool mbWindowListener; + +public: + + UnoDialogControl( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + virtual ~UnoDialogControl() override; + OUString GetComponentServiceName() const override; + + void SAL_CALL createPeer( const css::uno::Reference< css::awt::XToolkit >& Toolkit, const css::uno::Reference< css::awt::XWindowPeer >& Parent ) override; + void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + void SAL_CALL dispose() override; + + // css::awt::XTopWindow + void SAL_CALL addTopWindowListener( const css::uno::Reference< css::awt::XTopWindowListener >& xListener ) override; + void SAL_CALL removeTopWindowListener( const css::uno::Reference< css::awt::XTopWindowListener >& xListener ) override; + void SAL_CALL toFront( ) override; + void SAL_CALL toBack( ) override; + void SAL_CALL setMenuBar( const css::uno::Reference< css::awt::XMenuBar >& xMenu ) override; + + // css::awt::XWindowListener + virtual void SAL_CALL windowResized( const css::awt::WindowEvent& e ) override; + virtual void SAL_CALL windowMoved( const css::awt::WindowEvent& e ) override; + virtual void SAL_CALL windowShown( const css::lang::EventObject& e ) override; + virtual void SAL_CALL windowHidden( const css::lang::EventObject& e ) override; + + // css::awt::XDialog2 + virtual void SAL_CALL endDialog( ::sal_Int32 Result ) override; + virtual void SAL_CALL setHelpId( const OUString& Id ) override; + + // css::awt::XDialog + void SAL_CALL setTitle( const OUString& Title ) override; + OUString SAL_CALL getTitle() override; + sal_Int16 SAL_CALL execute() override; + void SAL_CALL endExecute() override; + + // css::awt::XControl + sal_Bool SAL_CALL setModel( const css::uno::Reference< css::awt::XControlModel >& Model ) override; + + // XModifyListener + virtual void SAL_CALL modified( const css::lang::EventObject& aEvent ) override; + + // resolve some ambiguous methods + virtual css::uno::Reference SAL_CALL getPeer() override + { return UnoDialogControl_Base::ControlContainerBase::getPeer(); } + virtual void SAL_CALL addWindowListener(const css::uno::Reference& p1) override + { UnoDialogControl_Base::ControlContainerBase::addWindowListener(p1); } + virtual css::uno::Reference SAL_CALL getModel() override + { return UnoDialogControl_Base::ControlContainerBase::getModel(); } + virtual void SAL_CALL addEventListener(const css::uno::Reference& p1) override + { UnoDialogControl_Base::ControlContainerBase::addEventListener(p1); } + virtual void SAL_CALL removeEventListener(const css::uno::Reference& p1) override + { UnoDialogControl_Base::ControlContainerBase::removeEventListener(p1); } + virtual void SAL_CALL setContext(const css::uno::Reference& p1) override + { UnoDialogControl_Base::ControlContainerBase::setContext(p1); } + virtual css::uno::Reference SAL_CALL getContext() override + { return UnoDialogControl_Base::ControlContainerBase::getContext(); } + virtual css::uno::Reference SAL_CALL getView() override + { return UnoDialogControl_Base::ControlContainerBase::getView(); } + virtual void SAL_CALL setDesignMode(sal_Bool p1) override + { UnoDialogControl_Base::ControlContainerBase::setDesignMode(p1); } + virtual sal_Bool SAL_CALL isDesignMode() override + { return UnoDialogControl_Base::ControlContainerBase::isDesignMode(); } + virtual sal_Bool SAL_CALL isTransparent() override + { return UnoDialogControl_Base::ControlContainerBase::isTransparent(); } + virtual void SAL_CALL setPosSize(sal_Int32 p1, sal_Int32 p2, sal_Int32 p3, sal_Int32 p4, sal_Int16 p5) override + { UnoDialogControl_Base::ControlContainerBase::setPosSize(p1, p2, p3, p4, p5); } + virtual css::awt::Rectangle SAL_CALL getPosSize() override + { return UnoDialogControl_Base::ControlContainerBase::getPosSize(); } + virtual void SAL_CALL setVisible(sal_Bool p1) override + { UnoDialogControl_Base::ControlContainerBase::setVisible(p1); } + virtual void SAL_CALL setEnable(sal_Bool p1) override + { UnoDialogControl_Base::ControlContainerBase::setEnable(p1); } + virtual void SAL_CALL setFocus() override + { UnoDialogControl_Base::ControlContainerBase::setFocus(); } + virtual void SAL_CALL removeWindowListener(const css::uno::Reference& p1) override + { UnoDialogControl_Base::ControlContainerBase::removeWindowListener(p1); } + virtual void SAL_CALL addFocusListener(const css::uno::Reference& p1) override + { UnoDialogControl_Base::ControlContainerBase::addFocusListener(p1); } + virtual void SAL_CALL removeFocusListener(const css::uno::Reference& p1) override + { UnoDialogControl_Base::ControlContainerBase::removeFocusListener(p1); } + virtual void SAL_CALL addKeyListener(const css::uno::Reference& p1) override + { UnoDialogControl_Base::ControlContainerBase::addKeyListener(p1); } + virtual void SAL_CALL removeKeyListener(const css::uno::Reference& p1) override + { UnoDialogControl_Base::ControlContainerBase::removeKeyListener(p1); } + virtual void SAL_CALL addMouseListener(const css::uno::Reference& p1) override + { UnoDialogControl_Base::ControlContainerBase::addMouseListener(p1); } + virtual void SAL_CALL removeMouseListener(const css::uno::Reference& p1) override + { UnoDialogControl_Base::ControlContainerBase::removeMouseListener(p1); } + virtual void SAL_CALL addMouseMotionListener(const css::uno::Reference& p1) override + { UnoDialogControl_Base::ControlContainerBase::addMouseMotionListener(p1); } + virtual void SAL_CALL removeMouseMotionListener(const css::uno::Reference& p1) override + { UnoDialogControl_Base::ControlContainerBase::removeMouseMotionListener(p1); } + virtual void SAL_CALL addPaintListener(const css::uno::Reference& p1) override + { UnoDialogControl_Base::ControlContainerBase::addPaintListener(p1); } + virtual void SAL_CALL removePaintListener(const css::uno::Reference& p1) override + { UnoDialogControl_Base::ControlContainerBase::removePaintListener(p1); } + virtual void SAL_CALL setStatusText(const OUString& p1) override + { UnoDialogControl_Base::ControlContainerBase::setStatusText(p1); } + virtual css::uno::Sequence > SAL_CALL getControls() override + { return UnoDialogControl_Base::ControlContainerBase::getControls(); } + virtual css::uno::Reference SAL_CALL getControl(const OUString& p1) override + { return UnoDialogControl_Base::ControlContainerBase::getControl(p1); } + virtual void SAL_CALL addControl(const OUString& p1, const css::uno::Reference& p2) override + { UnoDialogControl_Base::ControlContainerBase::addControl(p1, p2); } + virtual void SAL_CALL removeControl(const css::uno::Reference& p1) override + { UnoDialogControl_Base::ControlContainerBase::removeControl(p1); } + + + // css::lang::XServiceInfo + OUString SAL_CALL getImplementationName() override; + + sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override; + + css::uno::Sequence SAL_CALL getSupportedServiceNames() override; + +private: + virtual void PrepareWindowDescriptor( css::awt::WindowDescriptor& rDesc ) override; + virtual void ImplModelPropertiesChanged( const css::uno::Sequence< css::beans::PropertyChangeEvent >& rEvents ) override; +}; + +class UnoMultiPageModel final : public ControlModelContainerBase +{ +public: + UnoMultiPageModel( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + virtual ~UnoMultiPageModel() override; + + UnoMultiPageModel(UnoMultiPageModel const &) = default; + UnoMultiPageModel(UnoMultiPageModel &&) = default; + UnoMultiPageModel & operator =(UnoMultiPageModel const &) = delete; // due to ControlModelContainerBase + UnoMultiPageModel & operator =(UnoMultiPageModel &&) = delete; // due to ControlModelContainerBase + + rtl::Reference Clone() const override; + + DECLIMPL_SERVICEINFO_DERIVED( UnoMultiPageModel, ControlModelContainerBase, "com.sun.star.awt.UnoMultiPageModel" ) + + virtual OUString SAL_CALL getServiceName() override; + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; + // XNamedContainer + void SAL_CALL insertByName( const OUString& aName, const css::uno::Any& aElement ) override; + + // Override the method of parent class + virtual sal_Bool SAL_CALL getGroupControl( ) override; +private: + virtual css::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const override; + ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + +}; + +class UnoMultiPageControl final : public ControlContainerBase + ,public css::awt::XSimpleTabController + ,public css::awt::XTabListener +{ + TabListenerMultiplexer maTabListeners; + void bindPage( const css::uno::Reference< css::awt::XControl >& _rxControl ); +public: + UnoMultiPageControl( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + virtual ~UnoMultiPageControl() override; + OUString GetComponentServiceName() const override; + + // css::lang::XServiceInfo + DECLIMPL_SERVICEINFO_DERIVED( UnoMultiPageControl, ControlContainerBase, "com.sun.star.awt.UnoControlMultiPage" ) + css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override { return ControlContainerBase::queryInterface(rType); } + css::uno::Any SAL_CALL queryAggregation( const css::uno::Type & rType ) override; + void SAL_CALL acquire() noexcept override { OWeakAggObject::acquire(); } + void SAL_CALL release() noexcept override { OWeakAggObject::release(); } + // css::lang::XTypeProvider + css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + void SAL_CALL createPeer( const css::uno::Reference< css::awt::XToolkit >& Toolkit, const css::uno::Reference< css::awt::XWindowPeer >& Parent ) override; + // css::awt::XSimpleTabController + virtual ::sal_Int32 SAL_CALL insertTab() override; + virtual void SAL_CALL removeTab( ::sal_Int32 ID ) override; + + virtual void SAL_CALL setTabProps( ::sal_Int32 ID, const css::uno::Sequence< css::beans::NamedValue >& Properties ) override; + virtual css::uno::Sequence< css::beans::NamedValue > SAL_CALL getTabProps( ::sal_Int32 ID ) override; + + virtual void SAL_CALL activateTab( ::sal_Int32 ID ) override; + virtual ::sal_Int32 SAL_CALL getActiveTabID() override; + + virtual void SAL_CALL addTabListener( const css::uno::Reference< css::awt::XTabListener >& Listener ) override; + virtual void SAL_CALL removeTabListener( const css::uno::Reference< css::awt::XTabListener >& Listener ) override; + // XTabListener + virtual void SAL_CALL inserted( ::sal_Int32 ID ) override; + virtual void SAL_CALL removed( ::sal_Int32 ID ) override; + virtual void SAL_CALL changed( ::sal_Int32 ID, const css::uno::Sequence< css::beans::NamedValue >& Properties ) override; + virtual void SAL_CALL activated( ::sal_Int32 ID ) override; + virtual void SAL_CALL deactivated( ::sal_Int32 ID ) override; + virtual void SAL_CALL disposing( const css::lang::EventObject& evt ) override; + // XComponent + void SAL_CALL dispose( ) override; + +private: + virtual void impl_createControlPeerIfNecessary( + const css::uno::Reference< css::awt::XControl >& _rxControl + ) override; + +}; + + +class UnoPageModel final : public ControlModelContainerBase +{ +public: + UnoPageModel( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + virtual ~UnoPageModel() override; + + UnoPageModel(UnoPageModel const &) = default; + UnoPageModel(UnoPageModel &&) = default; + UnoPageModel & operator =(UnoPageModel const &) = delete; // due to ControlModelContainerBase + UnoPageModel & operator =(UnoPageModel &&) = delete; // due to ControlModelContainerBase + + rtl::Reference Clone() const override; + + DECLIMPL_SERVICEINFO_DERIVED( UnoPageModel, ControlModelContainerBase, "com.sun.star.awt.UnoPageModel" ) + + virtual OUString SAL_CALL getServiceName() override; + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; + + // Override the method of parent class + virtual sal_Bool SAL_CALL getGroupControl( ) override; +private: + virtual css::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const override; + ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + +}; + +class UnoPageControl final : public ControlContainerBase +{ +public: + UnoPageControl( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + virtual ~UnoPageControl() override; + OUString GetComponentServiceName() const override; + + + // css::lang::XServiceInfo + DECLIMPL_SERVICEINFO_DERIVED( UnoPageControl, ControlContainerBase, "com.sun.star.awt.UnoControlPage" ) +}; + +class UnoFrameModel final : public ControlModelContainerBase +{ +public: + UnoFrameModel( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + virtual ~UnoFrameModel() override; + + UnoFrameModel(UnoFrameModel const &) = default; + UnoFrameModel(UnoFrameModel &&) = default; + UnoFrameModel & operator =(UnoFrameModel const &) = delete; // due to ControlModelContainerBase + UnoFrameModel & operator =(UnoFrameModel &&) = delete; // due to ControlModelContainerBase + + rtl::Reference Clone() const override; + + DECLIMPL_SERVICEINFO_DERIVED( UnoFrameModel, ControlModelContainerBase, "com.sun.star.awt.UnoFrameModel" ) + + virtual OUString SAL_CALL getServiceName() override; + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; + +private: + virtual css::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const override; + ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; +}; + +class UnoFrameControl final : public ControlContainerBase +{ + virtual void ImplSetPosSize( css::uno::Reference< css::awt::XControl >& rxCtrl ) override; +public: + UnoFrameControl( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + virtual ~UnoFrameControl() override; + OUString GetComponentServiceName() const override; + +// css::lang::XServiceInfo +DECLIMPL_SERVICEINFO_DERIVED( UnoFrameControl, ControlContainerBase, "com.sun.star.awt.UnoControlFrame" ) +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/inc/controls/eventcontainer.hxx b/toolkit/inc/controls/eventcontainer.hxx new file mode 100644 index 000000000..79a434a39 --- /dev/null +++ b/toolkit/inc/controls/eventcontainer.hxx @@ -0,0 +1,82 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include + +#include + +#include +#include + +namespace toolkit +{ + +// Hashtable to optimize +typedef std::unordered_map +< + OUString, + sal_Int32, + OUStringHash +> +NameContainerNameMap; + +class ScriptEventContainer final : public ::cppu::WeakImplHelper< + css::container::XNameContainer, + css::container::XContainer > +{ + // The map needs to keep the insertion order, otherwise Macro signatures would get broken + // if the order changes here (Dialog xml files are digitally signed too). + // Thus a std::map or std::unordered_map can't be used. + NameContainerNameMap mHashMap; + css::uno::Sequence< OUString > mNames; + std::vector< css::uno::Any > mValues; + css::uno::Type mType; + + ContainerListenerMultiplexer maContainerListeners; + +public: + ScriptEventContainer(); + + // Methods XElementAccess + virtual css::uno::Type SAL_CALL getElementType( ) override; + virtual sal_Bool SAL_CALL hasElements( ) override; + + // Methods XNameAccess + virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getElementNames( ) override; + virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override; + + // Methods XNameReplace + virtual void SAL_CALL replaceByName( const OUString& aName, const css::uno::Any& aElement ) override; + + // Methods XNameContainer + virtual void SAL_CALL insertByName( const OUString& aName, const css::uno::Any& aElement ) override; + virtual void SAL_CALL removeByName( const OUString& Name ) override; + + // Methods XContainer + void SAL_CALL addContainerListener( const css::uno::Reference< css::container::XContainerListener >& xListener ) override; + void SAL_CALL removeContainerListener( const css::uno::Reference< css::container::XContainerListener >& xListener ) override; +}; + +} // namespace toolkit_namecontainer + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/inc/controls/filectrl.hxx b/toolkit/inc/controls/filectrl.hxx new file mode 100644 index 000000000..1330d0ce7 --- /dev/null +++ b/toolkit/inc/controls/filectrl.hxx @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include + +class Edit; + +// Flags for internal use of FileControl +enum class FileControlMode_Internal +{ + INRESIZE = 0x0001, + ORIGINALBUTTONTEXT = 0x0002, +}; + +namespace o3tl +{ + template<> struct typed_flags : is_typed_flags {}; +} + + +class FileControl final : public vcl::Window +{ + VclPtr maEdit; + VclPtr maButton; + OUString maButtonText; + FileControlMode_Internal mnInternalFlags; + + void Resize() override; + void GetFocus() override; + void StateChanged( StateChangedType nType ) override; + WinBits ImplInitStyle( WinBits nStyle ); + DECL_LINK( ButtonHdl, Button*, void ); + +public: + FileControl( vcl::Window* pParent, WinBits nStyle ); + virtual ~FileControl() override; + virtual void dispose() override; + + Edit& GetEdit() { return *maEdit; } + PushButton& GetButton() { return *maButton; } + + void Draw( OutputDevice* pDev, const Point& rPos, SystemTextColorFlags nFlags ) override; + + void SetText( const OUString& rStr ) override; + OUString GetText() const override; + + void SetEditModifyHdl( const Link& rLink ); +}; + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/inc/controls/formattedcontrol.hxx b/toolkit/inc/controls/formattedcontrol.hxx new file mode 100644 index 000000000..388d94312 --- /dev/null +++ b/toolkit/inc/controls/formattedcontrol.hxx @@ -0,0 +1,122 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include + +namespace com::sun::star::util { class XNumberFormatter; } + + +namespace toolkit +{ + + + // = UnoControlFormattedFieldModel + + class UnoControlFormattedFieldModel final : public UnoControlModel + { + public: + UnoControlFormattedFieldModel( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + UnoControlFormattedFieldModel( const UnoControlFormattedFieldModel& rModel ) + : UnoControlModel(rModel) + , m_bRevokedAsClient(false) + , m_bSettingValueAndText(false) + { + } + + rtl::Reference Clone() const override { return new UnoControlFormattedFieldModel( *this ); } + + // css::io::XPersistObject + OUString SAL_CALL getServiceName() override; + + // css::beans::XMultiPropertySet + css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; + + + // css::lang::XServiceInfo + OUString SAL_CALL getImplementationName() override; + + css::uno::Sequence SAL_CALL getSupportedServiceNames() override; + + private: + virtual ~UnoControlFormattedFieldModel() override; + + // XComponent + void SAL_CALL dispose() override; + + // XPropertySet + void SAL_CALL setPropertyValues( const css::uno::Sequence< OUString >& PropertyNames, const css::uno::Sequence< css::uno::Any >& Values ) override; + + // UnoControlModel + virtual void ImplNormalizePropertySequence( + const sal_Int32 _nCount, /// the number of entries in the arrays + sal_Int32* _pHandles, /// the handles of the properties to set + css::uno::Any* _pValues, /// the values of the properties to set + sal_Int32* _pValidHandles /// pointer to the valid handles, allowed to be adjusted + ) const override; + void impl_updateTextFromValue_nothrow(); + void impl_updateCachedFormatter_nothrow(); + void impl_updateCachedFormatKey_nothrow(); + + css::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const override; + ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + sal_Bool SAL_CALL convertFastPropertyValue( + css::uno::Any& rConvertedValue, + css::uno::Any& rOldValue, + sal_Int32 nPropId, + const css::uno::Any& rValue + ) override; + + void SAL_CALL setFastPropertyValue_NoBroadcast( + sal_Int32 nHandle, + const css::uno::Any& rValue + ) override; + + css::uno::Any m_aCachedFormat; + bool m_bRevokedAsClient; + bool m_bSettingValueAndText; + css::uno::Reference< css::util::XNumberFormatter > + m_xCachedFormatter; + }; + + + // = UnoFormattedFieldControl + + class UnoFormattedFieldControl final : public UnoSpinFieldControl + { + public: + UnoFormattedFieldControl(); + OUString GetComponentServiceName() const override; + + // css::awt::XTextListener + void SAL_CALL textChanged( const css::awt::TextEvent& rEvent ) override; + + // css::lang::XServiceInfo + OUString SAL_CALL getImplementationName() override; + + css::uno::Sequence SAL_CALL getSupportedServiceNames() override; + }; + + +} // namespace toolkit + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/inc/controls/geometrycontrolmodel.hxx b/toolkit/inc/controls/geometrycontrolmodel.hxx new file mode 100644 index 000000000..d6b204b19 --- /dev/null +++ b/toolkit/inc/controls/geometrycontrolmodel.hxx @@ -0,0 +1,251 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace com::sun::star::resource { class XStringResourceResolver; } + +namespace com::sun::star { + namespace uno { + class XComponentContext; + } +} + + +// namespace toolkit +// { + + + //= OGeometryControlModel_Base + + typedef ::cppu::WeakAggComponentImplHelper2 < css::util::XCloneable + , css::script::XScriptEventsSupplier + > OGCM_Base; + class OGeometryControlModel_Base + :public ::comphelper::OMutexAndBroadcastHelper + ,public ::comphelper::OPropertySetAggregationHelper + ,public ::comphelper::OPropertyContainer + ,public OGCM_Base + { + protected: + css::uno::Reference< css::uno::XAggregation > + m_xAggregate; + css::uno::Reference< css::container::XNameContainer > + mxEventContainer; + + // + sal_Int32 m_nPosX; + sal_Int32 m_nPosY; + sal_Int32 m_nWidth; + sal_Int32 m_nHeight; + OUString m_aName; + sal_Int16 m_nTabIndex; + sal_Int32 m_nStep; + OUString m_aTag; + css::uno::Reference< css::resource::XStringResourceResolver > m_xStrResolver; + // + + bool m_bCloneable; + + protected: + static css::uno::Any ImplGetDefaultValueByHandle(sal_Int32 nHandle); + css::uno::Any ImplGetPropertyValueByHandle(sal_Int32 nHandle) const; + void ImplSetPropertyValueByHandle(sal_Int32 nHandle, const css::uno::Any& aValue); + + protected: + /** + @param _pAggregateInstance + the object to be aggregated. The refcount of the instance given MUST be 0! + */ + OGeometryControlModel_Base(css::uno::XAggregation* _pAggregateInstance); + + /** + @param _rxAggregateInstance + is the object to be aggregated. Must be acquired exactly once (by the reference object given).
+ Will be reset to NULL upon leaving + */ + OGeometryControlModel_Base(css::uno::Reference< css::util::XCloneable >& _rxAggregateInstance); + + /** releases the aggregation +

Can be used if in a derived class, an exception has to be thrown after this base class here already + did the aggregation

+ */ + void releaseAggregation(); + + protected: + virtual ~OGeometryControlModel_Base() override; + + // XAggregation + css::uno::Any SAL_CALL queryAggregation( const css::uno::Type& _aType ) override; + + public: + // XInterface + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override; + virtual void SAL_CALL acquire( ) noexcept override; + virtual void SAL_CALL release( ) noexcept override; + + protected: + // XTypeProvider + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; + + // OPropertySetHelper overridables + virtual sal_Bool SAL_CALL convertFastPropertyValue( + css::uno::Any& _rConvertedValue, css::uno::Any& _rOldValue, + sal_Int32 _nHandle, const css::uno::Any& _rValue ) override; + + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( + sal_Int32 _nHandle, const css::uno::Any& _rValue) override; + + using comphelper::OPropertySetAggregationHelper::getFastPropertyValue; + virtual void SAL_CALL getFastPropertyValue( + css::uno::Any& _rValue, sal_Int32 _nHandle) const override; + + // OPropertyStateHelper overridables + virtual css::beans::PropertyState getPropertyStateByHandle(sal_Int32 nHandle) override; + virtual void setPropertyToDefaultByHandle(sal_Int32 nHandle) override; + virtual css::uno::Any getPropertyDefaultByHandle(sal_Int32 nHandle) const override; + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() override; + + // OPropertySetAggregationHelper overridables + using OPropertySetAggregationHelper::getInfoHelper; + + // XCloneable + virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone( ) override; + + //XScriptEventsSupplier + virtual css::uno::Reference< css::container::XNameContainer > + SAL_CALL getEvents( ) override; + + // XCloneable implementation - to be overwritten + virtual rtl::Reference createClone_Impl( + css::uno::Reference< css::util::XCloneable >& _rxAggregateInstance) = 0; + + // XComponent + using comphelper::OPropertySetAggregationHelper::disposing; + virtual void SAL_CALL disposing() override; + + private: + void registerProperties(); + }; + + + //= OTemplateInstanceDisambiguation + + template + class OTemplateInstanceDisambiguation + { + }; + + + //= OGeometryControlModel + + /* example for usage: + Reference< XAggregation > xIFace = new ::toolkit::OGeometryControlModel< UnoControlButtonModel > (); + */ + template + class OGeometryControlModel final + :public OGeometryControlModel_Base + ,public ::comphelper::OAggregationArrayUsageHelper< OTemplateInstanceDisambiguation< CONTROLMODEL > > + { + public: + OGeometryControlModel( const css::uno::Reference< css::uno::XComponentContext >& i_factory ); + + private: + OGeometryControlModel(css::uno::Reference< css::util::XCloneable >& _rxAggregateInstance); + + // OAggregationArrayUsageHelper overridables + virtual void fillProperties( + css::uno::Sequence< css::beans::Property >& _rProps, + css::uno::Sequence< css::beans::Property >& _rAggregateProps + ) const override; + + // OPropertySetAggregationHelper overridables + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + + // OGeometryControlModel_Base + virtual rtl::Reference createClone_Impl( + css::uno::Reference< css::util::XCloneable >& _rxAggregateInstance) override; + + // XTypeProvider + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) override; + }; + + + //= OCommonGeometryControlModel + + /** allows to extend an arbitrary com.sun.star.awt::UnoControlModel with geometry + information. + */ + class OCommonGeometryControlModel final + :public OGeometryControlModel_Base + ,public ::comphelper::OIdPropertyArrayUsageHelper< OCommonGeometryControlModel > + { + private: + OUString m_sServiceSpecifier; // the service specifier of our aggregate + sal_Int32 m_nPropertyMapId; // our unique property info id, used to look up in s_aAggregateProperties + + public: + /** instantiate the model + + @param _rxAgg + the instance to aggregate. Must support the com.sun.star.awt::UnoControlModel + (this is not checked here) + */ + OCommonGeometryControlModel( + css::uno::Reference< css::util::XCloneable >& _rxAgg, + const OUString& _rxServiceSpecifier + ); + + // OIdPropertyArrayUsageHelper overridables + virtual ::cppu::IPropertyArrayHelper* createArrayHelper(sal_Int32 nId) const override; + + // OPropertySetAggregationHelper overridables + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + + // OGeometryControlModel_Base + virtual rtl::Reference createClone_Impl( + css::uno::Reference< css::util::XCloneable >& _rxAggregateInstance) override; + + // XTypeProvider + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) override; + + private: + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( + sal_Int32 _nHandle, const css::uno::Any& _rValue) override; + }; + +#include + + +// } // namespace toolkit + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/inc/controls/geometrycontrolmodel_impl.hxx b/toolkit/inc/controls/geometrycontrolmodel_impl.hxx new file mode 100644 index 000000000..2ec8595dd --- /dev/null +++ b/toolkit/inc/controls/geometrycontrolmodel_impl.hxx @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +// no include protection. This is included from within geometrycontrolmodel.hxx only + +//= OGeometryControlModel + +template +OGeometryControlModel::OGeometryControlModel( + const css::uno::Reference& i_factory) + : OGeometryControlModel_Base(new CONTROLMODEL(i_factory)) +{ +} + +template +OGeometryControlModel::OGeometryControlModel( + css::uno::Reference& _rxAggregateInstance) + : OGeometryControlModel_Base(_rxAggregateInstance) +{ +} + +template +::cppu::IPropertyArrayHelper& SAL_CALL OGeometryControlModel::getInfoHelper() +{ + return *this->getArrayHelper(); +} + +template +void OGeometryControlModel::fillProperties( + css::uno::Sequence& _rProps, + css::uno::Sequence& _rAggregateProps) const +{ + // our own properties + OPropertyContainer::describeProperties(_rProps); + // the aggregate properties + if (m_xAggregateSet.is()) + _rAggregateProps = m_xAggregateSet->getPropertySetInfo()->getProperties(); +} + +template +css::uno::Sequence SAL_CALL OGeometryControlModel::getImplementationId() +{ + return css::uno::Sequence(); +} + +template +rtl::Reference OGeometryControlModel::createClone_Impl( + css::uno::Reference& _rxAggregateInstance) +{ + return new OGeometryControlModel(_rxAggregateInstance); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/inc/controls/roadmapcontrol.hxx b/toolkit/inc/controls/roadmapcontrol.hxx new file mode 100644 index 000000000..2a4a1021e --- /dev/null +++ b/toolkit/inc/controls/roadmapcontrol.hxx @@ -0,0 +1,183 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#include + + +namespace toolkit +{ + + + typedef GraphicControlModel UnoControlRoadmapModel_Base; + + + typedef ::cppu::ImplHelper3 < css::lang::XSingleServiceFactory + , css::container::XContainer + , css::container::XIndexContainer + > UnoControlRoadmapModel_IBase; + + + typedef UnoControlBase UnoControlRoadmap_Base; + typedef ::cppu::ImplHelper4 < css::awt::XItemEventBroadcaster + , css::container::XContainerListener + , css::awt::XItemListener + , css::beans::XPropertyChangeListener + > UnoControlRoadmap_IBase; + + + typedef ::cppu::ImplHelper2< css::container::XContainerListener, + css::awt::XItemEventBroadcaster> SVTXRoadmap_Base; + + + // = UnoControlRoadmapModel + + class UnoControlRoadmapModel final : public UnoControlRoadmapModel_Base, + public UnoControlRoadmapModel_IBase + + { + private: +// PropertyChangeListenerMultiplexer maPropertyListeners; + + typedef ::std::vector< css::uno::Reference< XInterface > > RoadmapItemHolderList; + + ContainerListenerMultiplexer maContainerListeners; + RoadmapItemHolderList maRoadmapItems; + + void MakeRMItemValidation( sal_Int32 Index, const css::uno::Reference< XInterface >& xRoadmapItem ); + css::container::ContainerEvent GetContainerEvent(sal_Int32 Index, const css::uno::Reference< XInterface >& ); + void SetRMItemDefaultProperties( const css::uno::Reference< XInterface >& ); + static sal_Int16 GetCurrentItemID( const css::uno::Reference< css::beans::XPropertySet >& xPropertySet ); + sal_Int32 GetUniqueID(); + + css::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const override; + ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + + public: + UnoControlRoadmapModel( const css::uno::Reference< css::uno::XComponentContext >& i_factory ); + UnoControlRoadmapModel( const UnoControlRoadmapModel& rModel ) : + UnoControlRoadmapModel_Base( rModel ), + UnoControlRoadmapModel_IBase( rModel ), + maContainerListeners( *this ) {} + rtl::Reference Clone() const override { return new UnoControlRoadmapModel( *this ); } + + + // XTypeProvider + DECLARE_XTYPEPROVIDER( ) + + + // css::io::XPersistObject + OUString SAL_CALL getServiceName() override; + + // css::lang::XServiceInfo + OUString SAL_CALL getImplementationName() override; + + css::uno::Sequence SAL_CALL getSupportedServiceNames() override; + + sal_Int32 SAL_CALL getCount() override; + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override; + + virtual void SAL_CALL insertByIndex( sal_Int32 Index, const css::uno::Any & Element) override; + virtual void SAL_CALL removeByIndex( sal_Int32 Index ) override; + virtual void SAL_CALL replaceByIndex( sal_Int32 Index, const css::uno::Any & Element) override; + + virtual void SAL_CALL addContainerListener( const css::uno::Reference< css::container::XContainerListener >& xListener ) override; + virtual void SAL_CALL removeContainerListener( const css::uno::Reference< css::container::XContainerListener >& xListener ) override; + + css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override { return UnoControlRoadmapModel_Base::queryInterface(rType); } + css::uno::Any SAL_CALL queryAggregation( const css::uno::Type & rType ) override; + void SAL_CALL acquire() noexcept override { UnoControlRoadmapModel_Base::acquire(); } + void SAL_CALL release() noexcept override { UnoControlRoadmapModel_Base::release(); } + + + // css::beans::XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; + + + virtual css::uno::Reference< XInterface > SAL_CALL createInstance( ) override; + virtual css::uno::Reference< XInterface > SAL_CALL createInstanceWithArguments( const css::uno::Sequence< css::uno::Any >& aArguments ) override; + + virtual css::uno::Type SAL_CALL getElementType() override; + + virtual sal_Bool SAL_CALL hasElements() override; + + }; + + + // = UnoRoadmapControl + + class UnoRoadmapControl final : public UnoControlRoadmap_Base, + public UnoControlRoadmap_IBase + { + private: + ItemListenerMultiplexer maItemListeners; + public: + UnoRoadmapControl(); + OUString GetComponentServiceName() const override; + + void SAL_CALL disposing( const css::lang::EventObject& Source ) override { UnoControlBase::disposing( Source ); } + + void SAL_CALL dispose( ) override; + + + sal_Bool SAL_CALL setModel(const css::uno::Reference< css::awt::XControlModel >& Model) override; + + void SAL_CALL elementInserted( const css::container::ContainerEvent& rEvent ) override; + void SAL_CALL elementRemoved( const css::container::ContainerEvent& rEvent ) override; + void SAL_CALL elementReplaced( const css::container::ContainerEvent& rEvent ) override; + + virtual void SAL_CALL addItemListener( const css::uno::Reference< css::awt::XItemListener >& l ) override; + virtual void SAL_CALL removeItemListener( const css::uno::Reference< css::awt::XItemListener >& l ) override; + + + virtual void SAL_CALL itemStateChanged( const css::awt::ItemEvent& rEvent ) override; + + virtual void SAL_CALL propertyChange( const css::beans::PropertyChangeEvent& evt ) override; + + // XTypeProvider + DECLARE_XTYPEPROVIDER( ) + DECLARE_XINTERFACE() + + // css::lang::XServiceInfo + OUString SAL_CALL getImplementationName() override; + + css::uno::Sequence SAL_CALL getSupportedServiceNames() override; + }; + + +} // toolkit + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/inc/controls/roadmapentry.hxx b/toolkit/inc/controls/roadmapentry.hxx new file mode 100644 index 000000000..b8490439c --- /dev/null +++ b/toolkit/inc/controls/roadmapentry.hxx @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include +#include +#include +#include +#include +#include + + +#define RM_PROPERTY_ID_LABEL 1 +#define RM_PROPERTY_ID_ID 2 +#define RM_PROPERTY_ID_ENABLED 4 +#define RM_PROPERTY_ID_INTERACTIVE 5 + +typedef cppu::WeakImplHelper< css::lang::XServiceInfo > ORoadmapEntry_Base; + +class ORoadmapEntry final : public ORoadmapEntry_Base + ,public ::comphelper::OMutexAndBroadcastHelper + ,public ::comphelper::OPropertyContainer + ,public ::comphelper::OPropertyArrayUsageHelper< ORoadmapEntry > +{ + +public: + ORoadmapEntry(); + + DECLARE_XINTERFACE() // merge XInterface implementations + DECLARE_XTYPEPROVIDER() // merge XTypeProvider implementations + +private: + /// @see css::beans::XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > + SAL_CALL getPropertySetInfo() override; + + // OPropertySetHelper + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + + // OPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const override; + + virtual OUString SAL_CALL getImplementationName( ) override; + virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override; + + OUString m_sLabel; + sal_Int32 m_nID; + bool m_bEnabled; + bool m_bInteractive; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/inc/controls/stdtabcontroller.hxx b/toolkit/inc/controls/stdtabcontroller.hxx new file mode 100644 index 000000000..37de42d7d --- /dev/null +++ b/toolkit/inc/controls/stdtabcontroller.hxx @@ -0,0 +1,86 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + + +#include +#include +#include +#include +#include + + +namespace com::sun::star::awt { class XWindow; } +namespace com::sun::star::awt { class XControl; } +namespace com::sun::star::awt { class XControlContainer; } + +class StdTabController final : public css::awt::XTabController, + public css::lang::XServiceInfo, + public css::lang::XTypeProvider, + public ::cppu::OWeakAggObject +{ +private: + ::osl::Mutex maMutex; + css::uno::Reference< css::awt::XTabControllerModel > mxModel; + css::uno::Reference< css::awt::XControlContainer > mxControlContainer; + + ::osl::Mutex& GetMutex() { return maMutex; } + static bool ImplCreateComponentSequence( css::uno::Sequence< css::uno::Reference< css::awt::XControl > >& rControls, const css::uno::Sequence< css::uno::Reference< css::awt::XControlModel > >& rModels, css::uno::Sequence< css::uno::Reference< css::awt::XWindow > >& rComponents, css::uno::Sequence< css::uno::Any>* pTabStops, bool bPeerComponent ); + // if sequence length of rModels is less than rControls, return only the matching elements in rModels sequence and remove corresponding elements from rControls + void ImplActivateControl( bool bFirst ) const; + +public: + StdTabController(); + virtual ~StdTabController() override; + + static css::uno::Reference< css::awt::XControl > FindControl( css::uno::Sequence< css::uno::Reference< css::awt::XControl > >& rCtrls, const css::uno::Reference< css::awt::XControlModel > & rxCtrlModel ); + + // css::uno::XInterface + css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override { return OWeakAggObject::queryInterface(rType); } + void SAL_CALL acquire() noexcept override { OWeakAggObject::acquire(); } + void SAL_CALL release() noexcept override { OWeakAggObject::release(); } + + css::uno::Any SAL_CALL queryAggregation( const css::uno::Type & rType ) override; + + // css::lang::XTypeProvider + css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // XTabController + void SAL_CALL setModel( const css::uno::Reference< css::awt::XTabControllerModel >& Model ) override; + css::uno::Reference< css::awt::XTabControllerModel > SAL_CALL getModel( ) override; + void SAL_CALL setContainer( const css::uno::Reference< css::awt::XControlContainer >& Container ) override; + css::uno::Reference< css::awt::XControlContainer > SAL_CALL getContainer( ) override; + css::uno::Sequence< css::uno::Reference< css::awt::XControl > > SAL_CALL getControls( ) override; + void SAL_CALL autoTabOrder( ) override; + void SAL_CALL activateTabOrder( ) override; + void SAL_CALL activateFirst( ) override; + void SAL_CALL activateLast( ) override; + + // XServiceInfo + OUString SAL_CALL getImplementationName() override; + + sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override; + + css::uno::Sequence SAL_CALL getSupportedServiceNames() override; +}; + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/inc/controls/stdtabcontrollermodel.hxx b/toolkit/inc/controls/stdtabcontrollermodel.hxx new file mode 100644 index 000000000..4fa12d252 --- /dev/null +++ b/toolkit/inc/controls/stdtabcontrollermodel.hxx @@ -0,0 +1,123 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + + +#include +#include +#include +#include +#include +#include + +#include + +struct UnoControlModelEntry; +typedef ::std::vector< UnoControlModelEntry* > UnoControlModelEntryListBase; + +class UnoControlModelEntryList +{ +private: + UnoControlModelEntryListBase maList; + OUString maGroupName; + +public: + UnoControlModelEntryList(); + ~UnoControlModelEntryList(); + + const OUString& GetName() const { return maGroupName; } + void SetName( const OUString& rName ) { maGroupName = rName; } + + void Reset(); + void DestroyEntry( size_t nEntry ); + size_t size() const; + UnoControlModelEntry* operator[]( size_t i ) const; + void push_back( UnoControlModelEntry* item ); + void insert( size_t i, UnoControlModelEntry* item ); +}; + +struct UnoControlModelEntry +{ + bool bGroup; + union + { + css::uno::Reference< css::awt::XControlModel >* pxControl; + UnoControlModelEntryList* pGroup; + }; +}; + +#define CONTROLPOS_NOTFOUND 0xFFFFFFFF + +class StdTabControllerModel final : public css::awt::XTabControllerModel, + public css::lang::XServiceInfo, + public css::io::XPersistObject, + public css::lang::XTypeProvider, + public ::cppu::OWeakAggObject +{ + ::osl::Mutex maMutex; + UnoControlModelEntryList maControls; + bool mbGroupControl; + + ::osl::Mutex& GetMutex() { return maMutex; } + sal_uInt32 ImplGetControlCount( const UnoControlModelEntryList& rList ) const; + void ImplGetControlModels( css::uno::Reference< css::awt::XControlModel > ** pRefs, const UnoControlModelEntryList& rList ) const; + static void ImplSetControlModels( UnoControlModelEntryList& rList, const css::uno::Sequence< css::uno::Reference< css::awt::XControlModel > >& Controls ); + static sal_uInt32 ImplGetControlPos( const css::uno::Reference< css::awt::XControlModel >& rCtrl, const UnoControlModelEntryList& rList ); + +public: + StdTabControllerModel(); + virtual ~StdTabControllerModel() override; + + // css::uno::XInterface + css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override { return OWeakAggObject::queryInterface(rType); } + void SAL_CALL acquire() noexcept override { OWeakAggObject::acquire(); } + void SAL_CALL release() noexcept override { OWeakAggObject::release(); } + + css::uno::Any SAL_CALL queryAggregation( const css::uno::Type & rType ) override; + + // css::lang::XTypeProvider + css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // css::awt::XTabControllerModel + sal_Bool SAL_CALL getGroupControl( ) override; + void SAL_CALL setGroupControl( sal_Bool GroupControl ) override; + void SAL_CALL setControlModels( const css::uno::Sequence< css::uno::Reference< css::awt::XControlModel > >& Controls ) override; + css::uno::Sequence< css::uno::Reference< css::awt::XControlModel > > SAL_CALL getControlModels( ) override; + void SAL_CALL setGroup( const css::uno::Sequence< css::uno::Reference< css::awt::XControlModel > >& Group, const OUString& GroupName ) override; + sal_Int32 SAL_CALL getGroupCount( ) override; + void SAL_CALL getGroup( sal_Int32 nGroup, css::uno::Sequence< css::uno::Reference< css::awt::XControlModel > >& Group, OUString& Name ) override; + void SAL_CALL getGroupByName( const OUString& Name, css::uno::Sequence< css::uno::Reference< css::awt::XControlModel > >& Group ) override; + + // css::io::XPersistObject + OUString SAL_CALL getServiceName( ) override; + void SAL_CALL write( const css::uno::Reference< css::io::XObjectOutputStream >& OutStream ) override; + void SAL_CALL read( const css::uno::Reference< css::io::XObjectInputStream >& InStream ) override; + + // XServiceInfo + OUString SAL_CALL getImplementationName() override; + + sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override; + + css::uno::Sequence SAL_CALL getSupportedServiceNames() override; +}; + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/inc/controls/svmedit.hxx b/toolkit/inc/controls/svmedit.hxx new file mode 100644 index 000000000..77295cdd5 --- /dev/null +++ b/toolkit/inc/controls/svmedit.hxx @@ -0,0 +1,32 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include + +class MultiLineEdit final : public VclMultiLineEdit +{ +public: + MultiLineEdit( vcl::Window* pParent, WinBits nWinStyle ); + + virtual css::uno::Reference< css::awt::XWindowPeer > GetComponentInterface(bool bCreate = true) override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/inc/controls/tabpagecontainer.hxx b/toolkit/inc/controls/tabpagecontainer.hxx new file mode 100644 index 000000000..d8cc32664 --- /dev/null +++ b/toolkit/inc/controls/tabpagecontainer.hxx @@ -0,0 +1,127 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include + + +namespace com::sun::star::awt::tab { class XTabPage; } +namespace com::sun::star::awt::tab { class XTabPageContainerListener; } +namespace com::sun::star::awt::tab { class XTabPageModel; } + + +typedef ::cppu::AggImplInheritanceHelper1 < UnoControlModel + , css::awt::tab::XTabPageContainerModel + > UnoControlTabPageContainerModel_Base; +class UnoControlTabPageContainerModel final : public UnoControlTabPageContainerModel_Base +{ +private: + std::vector< css::uno::Reference< css::awt::tab::XTabPageModel > > m_aTabPageVector; + ContainerListenerMultiplexer maContainerListeners; + + css::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const override; + ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + // css::beans::XMultiPropertySet + css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; + +public: + UnoControlTabPageContainerModel( const css::uno::Reference< css::uno::XComponentContext >& i_factory ); + UnoControlTabPageContainerModel( const UnoControlTabPageContainerModel& rModel ) : UnoControlTabPageContainerModel_Base( rModel ),maContainerListeners( *this ) {} + + rtl::Reference Clone() const override { return new UnoControlTabPageContainerModel( *this ); } + + // css::io::XPersistObject + OUString SAL_CALL getServiceName() override; + + // css::lang::XServiceInfo + DECLIMPL_SERVICEINFO_DERIVED( UnoControlTabPageContainerModel, UnoControlModel, "com.sun.star.awt.tab.UnoControlTabPageContainerModel" ) + + // XTabPageContainerModel + virtual css::uno::Reference< css::awt::tab::XTabPageModel > SAL_CALL createTabPage( ::sal_Int16 TabPageID ) override; + virtual css::uno::Reference< css::awt::tab::XTabPageModel > SAL_CALL loadTabPage( ::sal_Int16 TabPageID, const OUString& ResourceURL ) override; + + // XIndexContainer + virtual void SAL_CALL insertByIndex( sal_Int32 Index, const css::uno::Any& Element ) override; + virtual void SAL_CALL removeByIndex( sal_Int32 Index ) override; + + // XIndexReplace + virtual void SAL_CALL replaceByIndex( sal_Int32 Index, const css::uno::Any& Element ) override; + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() override; + + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + // css::container::XContainer + void SAL_CALL addContainerListener( const css::uno::Reference< css::container::XContainerListener >& xListener ) override; + void SAL_CALL removeContainerListener( const css::uno::Reference< css::container::XContainerListener >& xListener ) override; +}; + +// = UnoControlTabPageContainer + +typedef ::cppu::AggImplInheritanceHelper1 < ControlContainerBase + , css::awt::tab::XTabPageContainer + > UnoControlTabPageContainer_Base; +class UnoControlTabPageContainer final : public UnoControlTabPageContainer_Base +{ +public: + UnoControlTabPageContainer( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + OUString GetComponentServiceName() const override; + + // css::lang::XComponent + void SAL_CALL dispose( ) override; + + // css::awt::XControl + void SAL_CALL createPeer( const css::uno::Reference< css::awt::XToolkit >& Toolkit, const css::uno::Reference< css::awt::XWindowPeer >& Parent ) override; + + // css::awt::tab::XTabPageContainer + virtual ::sal_Int16 SAL_CALL getActiveTabPageID() override; + virtual void SAL_CALL setActiveTabPageID( ::sal_Int16 _activetabpageid ) override; + virtual ::sal_Int16 SAL_CALL getTabPageCount( ) override; + virtual sal_Bool SAL_CALL isTabPageActive( ::sal_Int16 tabPageIndex ) override; + virtual css::uno::Reference< css::awt::tab::XTabPage > SAL_CALL getTabPage( ::sal_Int16 tabPageIndex ) override; + virtual css::uno::Reference< css::awt::tab::XTabPage > SAL_CALL getTabPageByID( ::sal_Int16 tabPageID ) override; + virtual void SAL_CALL addTabPageContainerListener( const css::uno::Reference< css::awt::tab::XTabPageContainerListener >& listener ) override; + virtual void SAL_CALL removeTabPageContainerListener( const css::uno::Reference< css::awt::tab::XTabPageContainerListener >& listener ) override; + + // css::beans::XPropertiesChangeListener + virtual void SAL_CALL propertiesChange( const ::css::uno::Sequence< ::css::beans::PropertyChangeEvent >& aEvent ) override; + + virtual void SAL_CALL addControl( const OUString& Name, const css::uno::Reference< css::awt::XControl >& Control ) override; + // css::lang::XServiceInfo + DECLIMPL_SERVICEINFO_DERIVED( UnoControlTabPageContainer, UnoControlBase, "com.sun.star.awt.tab.UnoControlTabPageContainer" ) + +// using UnoControl::getPeer; +private: + virtual void updateFromModel() override; + TabPageListenerMultiplexer m_aTabPageListeners; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/inc/controls/tabpagemodel.hxx b/toolkit/inc/controls/tabpagemodel.hxx new file mode 100644 index 000000000..6c12981b2 --- /dev/null +++ b/toolkit/inc/controls/tabpagemodel.hxx @@ -0,0 +1,80 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include +#include + +class UnoControlTabPageModel final : public ControlModelContainerBase +{ + css::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const override; + ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; +public: + UnoControlTabPageModel( css::uno::Reference< css::uno::XComponentContext > const & i_factory); + + // css::io::XPersistObject + OUString SAL_CALL getServiceName() override; + + // css::beans::XMultiPropertySet + css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; + // XInitialization + virtual void SAL_CALL initialize (const css::uno::Sequence& rArguments) override; + + // XServiceInfo + OUString SAL_CALL getImplementationName() override; + + css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; +}; + + + +typedef ::cppu::AggImplInheritanceHelper2 < ControlContainerBase + , css::awt::tab::XTabPage + , css::awt::XWindowListener + > UnoControlTabPage_Base; +class UnoControlTabPage final : public UnoControlTabPage_Base +{ +private: + bool m_bWindowListener; +public: + + UnoControlTabPage( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + virtual ~UnoControlTabPage() override; + OUString GetComponentServiceName() const override; + + void SAL_CALL createPeer( const css::uno::Reference< css::awt::XToolkit >& Toolkit, const css::uno::Reference< css::awt::XWindowPeer >& Parent ) override; + void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + void SAL_CALL dispose() override; + + // css::awt::XWindowListener + virtual void SAL_CALL windowResized( const css::awt::WindowEvent& e ) override; + virtual void SAL_CALL windowMoved( const css::awt::WindowEvent& e ) override; + virtual void SAL_CALL windowShown( const css::lang::EventObject& e ) override; + virtual void SAL_CALL windowHidden( const css::lang::EventObject& e ) override; + // css::lang::XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + + virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override; + + virtual css::uno::Sequence SAL_CALL getSupportedServiceNames() override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/inc/controls/tkscrollbar.hxx b/toolkit/inc/controls/tkscrollbar.hxx new file mode 100644 index 000000000..ec774fa9d --- /dev/null +++ b/toolkit/inc/controls/tkscrollbar.hxx @@ -0,0 +1,112 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include +#include +#include +#include + + +namespace toolkit +{ + + + //= UnoControlScrollBarModel + + class UnoControlScrollBarModel final : public UnoControlModel + { + css::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const override; + ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + + public: + UnoControlScrollBarModel( const css::uno::Reference< css::uno::XComponentContext >& i_factory ); + UnoControlScrollBarModel( const UnoControlScrollBarModel& rModel ) : UnoControlModel( rModel ) {} + + rtl::Reference Clone() const override { return new UnoControlScrollBarModel( *this ); } + + // css::beans::XMultiPropertySet + css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; + + // css::io::XPersistObject + OUString SAL_CALL getServiceName() override; + + // XServiceInfo + OUString SAL_CALL getImplementationName() override; + + css::uno::Sequence SAL_CALL getSupportedServiceNames() override; + }; + + + //= UnoControlScrollBarModel + + class UnoScrollBarControl final : public UnoControlBase, + public css::awt::XAdjustmentListener, + public css::awt::XScrollBar + { + private: + AdjustmentListenerMultiplexer maAdjustmentListeners; + + public: + UnoScrollBarControl(); + OUString GetComponentServiceName() const override; + + css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override { return UnoControlBase::queryInterface(rType); } + css::uno::Any SAL_CALL queryAggregation( const css::uno::Type & rType ) override; + void SAL_CALL acquire() noexcept override { OWeakAggObject::acquire(); } + void SAL_CALL release() noexcept override { OWeakAggObject::release(); } + void SAL_CALL createPeer( const css::uno::Reference< css::awt::XToolkit >& Toolkit, const css::uno::Reference< css::awt::XWindowPeer >& Parent ) override; + void SAL_CALL disposing( const css::lang::EventObject& Source ) override { UnoControlBase::disposing( Source ); } + void SAL_CALL dispose( ) override; + + // css::lang::XTypeProvider + css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // css::awt::XAdjustmentListener + void SAL_CALL adjustmentValueChanged( const css::awt::AdjustmentEvent& rEvent ) override; + + // css::awt::XScrollBar + void SAL_CALL addAdjustmentListener( const css::uno::Reference< css::awt::XAdjustmentListener >& l ) override; + void SAL_CALL removeAdjustmentListener( const css::uno::Reference< css::awt::XAdjustmentListener >& l ) override; + void SAL_CALL setValue( sal_Int32 n ) override; + void SAL_CALL setValues( sal_Int32 nValue, sal_Int32 nVisible, sal_Int32 nMax ) override; + sal_Int32 SAL_CALL getValue( ) override; + void SAL_CALL setMaximum( sal_Int32 n ) override; + sal_Int32 SAL_CALL getMaximum( ) override; + void SAL_CALL setLineIncrement( sal_Int32 n ) override; + sal_Int32 SAL_CALL getLineIncrement( ) override; + void SAL_CALL setBlockIncrement( sal_Int32 n ) override; + sal_Int32 SAL_CALL getBlockIncrement( ) override; + void SAL_CALL setVisibleSize( sal_Int32 n ) override; + sal_Int32 SAL_CALL getVisibleSize( ) override; + void SAL_CALL setOrientation( sal_Int32 n ) override; + sal_Int32 SAL_CALL getOrientation( ) override; + + // css::lang::XServiceInfo + OUString SAL_CALL getImplementationName() override; + + css::uno::Sequence SAL_CALL getSupportedServiceNames() override; + }; + + +} // namespacetoolkit + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/inc/controls/treecontrolpeer.hxx b/toolkit/inc/controls/treecontrolpeer.hxx new file mode 100644 index 000000000..d584516ae --- /dev/null +++ b/toolkit/inc/controls/treecontrolpeer.hxx @@ -0,0 +1,166 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include +#include + +#include +#include + +#include + +#include + +#include + +namespace com::sun::star::awt::tree { class XTreeNode; } + +class UnoTreeListEntry; +class TreeControlPeer; +class UnoTreeListBoxImpl; + +class TreeControlPeer final : public ::cppu::ImplInheritanceHelper< VCLXWindow, css::awt::tree::XTreeControl, css::awt::tree::XTreeDataModelListener > +{ + typedef std::map, UnoTreeListEntry*> TreeNodeMap; + + friend class UnoTreeListBoxImpl; + friend class UnoTreeListEntry; +public: + TreeControlPeer(); + virtual ~TreeControlPeer() override; + + vcl::Window* createVclControl( vcl::Window* pParent, sal_Int64 nWinStyle ); + + // css::view::XSelectionSupplier + virtual sal_Bool SAL_CALL select( const css::uno::Any& xSelection ) override; + virtual css::uno::Any SAL_CALL getSelection( ) override; + virtual void SAL_CALL addSelectionChangeListener( const css::uno::Reference< css::view::XSelectionChangeListener >& xListener ) override; + virtual void SAL_CALL removeSelectionChangeListener( const css::uno::Reference< css::view::XSelectionChangeListener >& xListener ) override; + + // css::view::XMultiSelectionSupplier + virtual sal_Bool SAL_CALL addSelection( const css::uno::Any& Selection ) override; + virtual void SAL_CALL removeSelection( const css::uno::Any& Selection ) override; + virtual void SAL_CALL clearSelection( ) override; + virtual ::sal_Int32 SAL_CALL getSelectionCount( ) override; + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createSelectionEnumeration( ) override; + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createReverseSelectionEnumeration( ) override; + + // css::awt::XTreeControl + virtual OUString SAL_CALL getDefaultExpandedGraphicURL() override; + virtual void SAL_CALL setDefaultExpandedGraphicURL( const OUString& _defaultexpandedgraphicurl ) override; + virtual OUString SAL_CALL getDefaultCollapsedGraphicURL() override; + virtual void SAL_CALL setDefaultCollapsedGraphicURL( const OUString& _defaultcollapsedgraphicurl ) override; + virtual sal_Bool SAL_CALL isNodeExpanded( const css::uno::Reference< css::awt::tree::XTreeNode >& Node ) override; + virtual sal_Bool SAL_CALL isNodeCollapsed( const css::uno::Reference< css::awt::tree::XTreeNode >& Node ) override; + virtual void SAL_CALL makeNodeVisible( const css::uno::Reference< css::awt::tree::XTreeNode >& Node ) override; + virtual sal_Bool SAL_CALL isNodeVisible( const css::uno::Reference< css::awt::tree::XTreeNode >& Node ) override; + virtual void SAL_CALL expandNode( const css::uno::Reference< css::awt::tree::XTreeNode >& Node ) override; + virtual void SAL_CALL collapseNode( const css::uno::Reference< css::awt::tree::XTreeNode >& Node ) override; + virtual void SAL_CALL addTreeExpansionListener( const css::uno::Reference< css::awt::tree::XTreeExpansionListener >& Listener ) override; + virtual void SAL_CALL removeTreeExpansionListener( const css::uno::Reference< css::awt::tree::XTreeExpansionListener >& Listener ) override; + virtual css::uno::Reference< css::awt::tree::XTreeNode > SAL_CALL getNodeForLocation( ::sal_Int32 x, ::sal_Int32 y ) override; + virtual css::uno::Reference< css::awt::tree::XTreeNode > SAL_CALL getClosestNodeForLocation( ::sal_Int32 x, ::sal_Int32 y ) override; + virtual css::awt::Rectangle SAL_CALL getNodeRect( const css::uno::Reference< css::awt::tree::XTreeNode >& Node ) override; + virtual sal_Bool SAL_CALL isEditing( ) override; + virtual sal_Bool SAL_CALL stopEditing( ) override; + virtual void SAL_CALL cancelEditing( ) override; + virtual void SAL_CALL startEditingAtNode( const css::uno::Reference< css::awt::tree::XTreeNode >& Node ) override; + virtual void SAL_CALL addTreeEditListener( const css::uno::Reference< css::awt::tree::XTreeEditListener >& Listener ) override; + virtual void SAL_CALL removeTreeEditListener( const css::uno::Reference< css::awt::tree::XTreeEditListener >& Listener ) override; + + // css::awt::tree::TreeDataModelListener + virtual void SAL_CALL treeNodesChanged( const css::awt::tree::TreeDataModelEvent& aEvent ) override; + virtual void SAL_CALL treeNodesInserted( const css::awt::tree::TreeDataModelEvent& aEvent ) override; + virtual void SAL_CALL treeNodesRemoved( const css::awt::tree::TreeDataModelEvent& aEvent ) override; + virtual void SAL_CALL treeStructureChanged( const css::awt::tree::TreeDataModelEvent& aEvent ) override; + + // XEventListener + void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + + // css::awt::XLayoutConstrains + css::awt::Size SAL_CALL getMinimumSize() override; + css::awt::Size SAL_CALL getPreferredSize() override; + css::awt::Size SAL_CALL calcAdjustedSize( const css::awt::Size& aNewSize ) override; + + // css::awt::XVclWindowPeer + void SAL_CALL setProperty( const OUString& PropertyName, const css::uno::Any& Value ) override; + css::uno::Any SAL_CALL getProperty( const OUString& PropertyName ) override; + +private: + /// @throws css::lang::IllegalArgumentException + UnoTreeListEntry* getEntry( const css::uno::Reference< css::awt::tree::XTreeNode >& xNode, bool bThrow = true ); + + void disposeControl(); + + bool onEditingEntry( UnoTreeListEntry const * pEntry ); + bool onEditedEntry( UnoTreeListEntry const * pEntry, const OUString& rNewText ); + + void fillTree( UnoTreeListBoxImpl& rTree, const css::uno::Reference< css::awt::tree::XTreeDataModel >& xDataModel ); + void addNode( UnoTreeListBoxImpl& rTree, const css::uno::Reference< css::awt::tree::XTreeNode >& xNode, UnoTreeListEntry* pParentEntry ); + + UnoTreeListEntry* createEntry( const css::uno::Reference< css::awt::tree::XTreeNode >& xNode, UnoTreeListEntry* pParent, sal_uLong nPos ); + void updateEntry( UnoTreeListEntry* pEntry ); + + void updateTree( const css::awt::tree::TreeDataModelEvent& rEvent ); + void updateNode( UnoTreeListBoxImpl const & rTree, const css::uno::Reference< css::awt::tree::XTreeNode >& xNode ); + void updateChildNodes( UnoTreeListBoxImpl const & rTree, const css::uno::Reference< css::awt::tree::XTreeNode >& xParentNode, UnoTreeListEntry* pParentEntry ); + + static OUString getEntryString( const css::uno::Any& rValue ); + + /// @throws css::uno::RuntimeException + UnoTreeListBoxImpl& getTreeListBoxOrThrow() const; + /// @throws css::uno::RuntimeException + /// @throws css::lang::IllegalArgumentException + void ChangeNodesSelection( const css::uno::Any& rSelection, bool bSelect, bool bSetSelection ); + + void onChangeDataModel( UnoTreeListBoxImpl& rTree, const css::uno::Reference< css::awt::tree::XTreeDataModel >& xDataModel ); + + void onSelectionChanged(); + void onRequestChildNodes( const css::uno::Reference< css::awt::tree::XTreeNode >& xNode ); + bool onExpanding( const css::uno::Reference< css::awt::tree::XTreeNode >& xNode, bool bExpanding ); + void onExpanded( const css::uno::Reference< css::awt::tree::XTreeNode >& xNode, bool bExpanding ); + + void onChangeRootDisplayed( bool bIsRootDisplayed ); + + void addEntry( UnoTreeListEntry* pEntry ); + void removeEntry( UnoTreeListEntry const * pEntry ); + + bool loadImage( const OUString& rURL, Image& rImage ); + +private: + css::uno::Reference< css::awt::tree::XTreeDataModel >mxDataModel; + TreeSelectionListenerMultiplexer maSelectionListeners; + TreeExpansionListenerMultiplexer maTreeExpansionListeners; + TreeEditListenerMultiplexer maTreeEditListeners; + bool mbIsRootDisplayed; + VclPtr mpTreeImpl; + sal_Int32 mnEditLock; + OUString msDefaultCollapsedGraphicURL; + OUString msDefaultExpandedGraphicURL; + Image maDefaultExpandedImage; + Image maDefaultCollapsedImage; + std::unique_ptr mpTreeNodeMap; + css::uno::Reference< css::graphic::XGraphicProvider > mxGraphicProvider; +}; + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/inc/controls/unocontrolcontainer.hxx b/toolkit/inc/controls/unocontrolcontainer.hxx new file mode 100644 index 000000000..f8e9d1085 --- /dev/null +++ b/toolkit/inc/controls/unocontrolcontainer.hxx @@ -0,0 +1,151 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + + +#include +#include +#include +#include + +#include + +#include +#include + +class UnoControlHolderList; + + + +typedef ::cppu::AggImplInheritanceHelper4 < UnoControlBase + , css::awt::XUnoControlContainer + , css::awt::XControlContainer + , css::container::XContainer + , css::container::XIdentifierContainer + > UnoControlContainer_Base; + +class UnoControlContainer : public UnoControlContainer_Base +{ +private: + std::unique_ptr mpControls; + css::uno::Sequence< css::uno::Reference< css::awt::XTabController > > maTabControllers; + ContainerListenerMultiplexer maCListeners; + +protected: + void ImplActivateTabControllers(); + +public: + UnoControlContainer(); + UnoControlContainer( const css::uno::Reference< css::awt::XWindowPeer >& xPeer ); + virtual ~UnoControlContainer() override; + + + // css::lang::XComponent + void SAL_CALL dispose() override; + + // css::lang::XEventListener + void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + + // css::container::XContainer + void SAL_CALL addContainerListener( const css::uno::Reference< css::container::XContainerListener >& xListener ) override; + void SAL_CALL removeContainerListener( const css::uno::Reference< css::container::XContainerListener >& xListener ) override; + + // css::container::XIdentifierContainer + virtual ::sal_Int32 SAL_CALL insert( const css::uno::Any& aElement ) override; + + // css::container::XIdentifierReplace + virtual void SAL_CALL removeByIdentifier( ::sal_Int32 Identifier ) override; + virtual void SAL_CALL replaceByIdentifer( ::sal_Int32 Identifier, const css::uno::Any& aElement ) override; + + // css::container::XIdentifierAccess + virtual css::uno::Any SAL_CALL getByIdentifier( ::sal_Int32 Identifierr ) override; + virtual css::uno::Sequence< ::sal_Int32 > SAL_CALL getIdentifiers( ) override; + + // css::container::XElementAccess + virtual css::uno::Type SAL_CALL getElementType( ) override; + virtual sal_Bool SAL_CALL hasElements( ) override; + + // css::awt::XControlContainer + void SAL_CALL setStatusText( const OUString& StatusText ) override; + css::uno::Sequence< css::uno::Reference< css::awt::XControl > > SAL_CALL getControls( ) override; + css::uno::Reference< css::awt::XControl > SAL_CALL getControl( const OUString& aName ) override; + void SAL_CALL addControl( const OUString& Name, const css::uno::Reference< css::awt::XControl >& Control ) override; + void SAL_CALL removeControl( const css::uno::Reference< css::awt::XControl >& Control ) override; + + // css::awt::XUnoControlContainer + void SAL_CALL setTabControllers( const css::uno::Sequence< css::uno::Reference< css::awt::XTabController > >& TabControllers ) override; + css::uno::Sequence< css::uno::Reference< css::awt::XTabController > > SAL_CALL getTabControllers( ) override; + void SAL_CALL addTabController( const css::uno::Reference< css::awt::XTabController >& TabController ) override; + void SAL_CALL removeTabController( const css::uno::Reference< css::awt::XTabController >& TabController ) override; + + // css::awt::XControl + void SAL_CALL createPeer( const css::uno::Reference< css::awt::XToolkit >& Toolkit, const css::uno::Reference< css::awt::XWindowPeer >& Parent ) override; + + // css::awt::XWindow + void SAL_CALL setVisible( sal_Bool Visible ) override; + + OUString SAL_CALL getImplementationName() override; + + css::uno::Sequence SAL_CALL getSupportedServiceNames() override; + +protected: + virtual void PrepareWindowDescriptor( css::awt::WindowDescriptor& rDesc ) override; + virtual void removingControl( const css::uno::Reference< css::awt::XControl >& _rxControl ); + virtual void addingControl( const css::uno::Reference< css::awt::XControl >& _rxControl ); + + /** ensures that the given control has a peer, if necessary and possible + @param _rxControl + an ->XControl which has just been inserted into the container. Must not be . + @precond + our mutex is locked + */ + virtual void impl_createControlPeerIfNecessary( + const css::uno::Reference< css::awt::XControl >& _rxControl + ); +private: + /** adds the control to the container, does necessary notifications, and the like + @param _rxControl + the control to add. Must not be + @param _pName + Pointer to a name for the control. Might be , in this case an automatic name is generated + @return + the ID of the newly added control + */ + sal_Int32 impl_addControl( + const css::uno::Reference< css::awt::XControl >& _rxControl, + const OUString* _pName = nullptr + ); + + /** removes the given control from the container, including necessary notifications and the like + @param _nId + the ID of the control to remove + @param _rxControl + the control itself. Must be the one which is stored under the given ID. This parameter could also be + obtained inside the method, but callers usually have obtained it, anyway. + */ + void impl_removeControl( + sal_Int32 _nId, + const css::uno::Reference< css::awt::XControl >& _rxControl + ); + +}; + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/inc/controls/unocontrolcontainermodel.hxx b/toolkit/inc/controls/unocontrolcontainermodel.hxx new file mode 100644 index 000000000..4fe48cdca --- /dev/null +++ b/toolkit/inc/controls/unocontrolcontainermodel.hxx @@ -0,0 +1,51 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + + +#include + + + +class UnoControlContainerModel final : public UnoControlModel +{ + css::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const override; + ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + +public: + UnoControlContainerModel( const css::uno::Reference< css::uno::XComponentContext >& i_factory ); + UnoControlContainerModel( const UnoControlContainerModel& rModel ) : UnoControlModel( rModel ) {} + + rtl::Reference Clone() const override { return new UnoControlContainerModel( *this ); } + + // css::beans::XMultiPropertySet + css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; + + // css::io::XPersistObject + OUString SAL_CALL getServiceName() override; + + // css::lang::XServiceInfo + OUString SAL_CALL getImplementationName() override; + + css::uno::Sequence SAL_CALL getSupportedServiceNames() override; +}; + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/inc/helper/accessibilityclient.hxx b/toolkit/inc/helper/accessibilityclient.hxx new file mode 100644 index 000000000..f90414671 --- /dev/null +++ b/toolkit/inc/helper/accessibilityclient.hxx @@ -0,0 +1,57 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_TOOLKIT_INC_HELPER_ACCESSIBILITYCLIENT_HXX +#define INCLUDED_TOOLKIT_INC_HELPER_ACCESSIBILITYCLIENT_HXX + +#include + +namespace toolkit +{ + /** a client for the accessibility implementations which have been + outsourced from the main toolkit library + + All instances of this class share a reference to a common IAccessibleFactory + instance, which is used for creating all kind of Accessibility related + components. + + When the AccessibilityClient goes away, also this factory goes away, and the respective + library is unloaded. + + This class is not thread-safe. + */ + class AccessibilityClient + { + private: + bool m_bInitialized; + + public: + AccessibilityClient(); + + IAccessibleFactory& getFactory(); + + private: + void ensureInitialized(); + }; + +} // namespace toolkit + +#endif // INCLUDED_TOOLKIT_INC_HELPER_ACCESSIBILITYCLIENT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/inc/helper/btndlg.hxx b/toolkit/inc/helper/btndlg.hxx new file mode 100644 index 000000000..8894b8dec --- /dev/null +++ b/toolkit/inc/helper/btndlg.hxx @@ -0,0 +1,89 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_VCL_BTNDLG_HXX +#define INCLUDED_VCL_BTNDLG_HXX + +#include +#include + +#include +#include + +struct ImplBtnDlgItem; +class PushButton; +class Button; + +#define BUTTONDIALOG_BUTTON_NOTFOUND (sal_uInt16(0xFFFF)) + +enum class ButtonDialogFlags +{ + NONE = 0x0000, + Default = 0x0001, + OK = 0x0002, + Cancel = 0x0004, + Help = 0x0008, + Focus = 0x0010, +}; +namespace o3tl +{ + template<> struct typed_flags : is_typed_flags {}; +} + +class ButtonDialog : public Dialog +{ +public: + virtual ~ButtonDialog() override; + virtual void dispose() override; + + virtual void Resize() override; + virtual void StateChanged( StateChangedType nStateChange ) override; + + void SetPageSizePixel( const Size& rSize ) { maPageSize = rSize; } + + void AddButton( StandardButtonType eType, sal_uInt16 nId, ButtonDialogFlags nBtnFlags, tools::Long nSepPixel = 0 ); + void RemoveButton( sal_uInt16 nId ); + +protected: + ButtonDialog( WindowType nType ); + tools::Long ImplGetButtonSize(); + +private: + ButtonDialog( const ButtonDialog & ) = delete; + ButtonDialog& operator=( const ButtonDialog& ) = delete; + +private: + std::vector> m_ItemList; + Size maPageSize; + Size maCtrlSize; + tools::Long mnButtonSize; + sal_uInt16 mnCurButtonId; + sal_uInt16 mnFocusButtonId; + bool mbFormat; + + void ImplInitButtonDialogData(); + VclPtr ImplCreatePushButton( ButtonDialogFlags nBtnFlags ); + DECL_LINK( ImplClickHdl, Button* pBtn, void ); + void ImplPosControls(); + +}; + +#endif // INCLUDED_VCL_BTNDLG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/inc/helper/imagealign.hxx b/toolkit/inc/helper/imagealign.hxx new file mode 100644 index 000000000..087a9f540 --- /dev/null +++ b/toolkit/inc/helper/imagealign.hxx @@ -0,0 +1,52 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_TOOLKIT_INC_HELPER_IMAGEALIGN_HXX +#define INCLUDED_TOOLKIT_INC_HELPER_IMAGEALIGN_HXX + +#include +#include + +namespace toolkit +{ + + + /** translates a VCL ImageAlign value into a css.awt.ImagePosition value + */ + sal_Int16 translateImagePosition( ImageAlign _eVCLAlign ); + + /** translates a css.awt.ImagePosition value into a VCL ImageAlign + */ + ImageAlign translateImagePosition( sal_Int16 _nImagePosition ); + + /** translates a VCL ImageAlign value into a compatible css.awt.ImageAlign value + */ + sal_Int16 getCompatibleImageAlign( ImageAlign _eAlign ); + + /** translates a css.awt.ImageAlign value into a css.awt.ImagePosition value + */ + sal_Int16 getExtendedImagePosition( sal_Int16 _nImageAlign ); + + +} // namespace toolkit + + +#endif // INCLUDED_TOOLKIT_INC_HELPER_IMAGEALIGN_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/inc/helper/msgbox.hxx b/toolkit/inc/helper/msgbox.hxx new file mode 100644 index 000000000..cef129cf4 --- /dev/null +++ b/toolkit/inc/helper/msgbox.hxx @@ -0,0 +1,79 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include +#include +#include +#include + +// Window-Bits for MessageBoxen +enum class MessBoxStyle +{ + NONE = 0x0000, + Ok = 0x0001, + OkCancel = 0x0002, + YesNo = 0x0004, + YesNoCancel = 0x0008, + RetryCancel = 0x0010, + DefaultOk = 0x0020, + DefaultCancel = 0x0040, + DefaultRetry = 0x0080, + DefaultYes = 0x0100, + DefaultNo = 0x0200, + AbortRetryIgnore = 0x1000, + DefaultIgnore = 0x2000, +}; +namespace o3tl +{ +template <> struct typed_flags : is_typed_flags +{ +}; +} + +class MessBox : public ButtonDialog +{ + VclPtr mpVCLMultiLineEdit; + VclPtr mpFixedImage; + Image maImage; + bool mbHelpBtn; + MessBoxStyle mnMessBoxStyle; + +protected: + OUString maMessText; + + void ImplInitButtons(); + void ImplPosControls(); + +public: + MessBox(vcl::Window* pParent, MessBoxStyle nMessBoxStyle, WinBits n, const OUString& rTitle, + const OUString& rMessage); + virtual ~MessBox() override; + virtual void dispose() override; + + virtual void StateChanged(StateChangedType nStateChange) override; + + void SetMessText(const OUString& rText) { maMessText = rText; } + const OUString& GetMessText() const { return maMessText; } + + void SetImage(const Image& rImage) { maImage = rImage; } + + virtual Size GetOptimalSize() const override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/inc/helper/scrollabledialog.hxx b/toolkit/inc/helper/scrollabledialog.hxx new file mode 100644 index 000000000..26068b4f5 --- /dev/null +++ b/toolkit/inc/helper/scrollabledialog.hxx @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_TOOLKIT_AWT_SCROLLABLEDIALOG_HXX +#define INCLUDED_TOOLKIT_AWT_SCROLLABLEDIALOG_HXX + +#include +#include + +namespace toolkit +{ + class ScrollableDialog final : public Dialog + { + public: + enum ScrollBarVisibility { None, Vert, Hori, Both }; + + private: + VclPtr maHScrollBar; + VclPtr maVScrollBar; + Size maScrollArea; + bool mbHasHoriBar; + bool mbHasVertBar; + Point mnScrollPos; + tools::Long mnScrWidth; + ScrollBarVisibility maScrollVis; + + void lcl_Scroll( tools::Long nX, tools::Long nY ); + DECL_LINK( ScrollBarHdl, ScrollBar*, void ); + + public: + ScrollableDialog( vcl::Window* pParent, WinBits nStyle, Dialog::InitFlag eFlag = Dialog::InitFlag::Default ); + virtual ~ScrollableDialog() override; + virtual void dispose() override; + // Window + virtual void Resize() override; + + void SetScrollWidth( tools::Long nWidth ); + void SetScrollHeight( tools::Long nHeight ); + void SetScrollLeft( tools::Long nLeft ); + void SetScrollTop( tools::Long Top ); + void setScrollVisibility( ScrollBarVisibility rState ); + void ResetScrollBars(); + }; + +} // namespacetoolkit + + +#endif // INCLUDED_TOOLKIT_AWT_SCROLLABLEDIALOG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/inc/helper/servicenames.hxx b/toolkit/inc/helper/servicenames.hxx new file mode 100644 index 000000000..7fb7ab2a5 --- /dev/null +++ b/toolkit/inc/helper/servicenames.hxx @@ -0,0 +1,24 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +extern const char szServiceName_UnoControlDialog[]; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/inc/helper/tkresmgr.hxx b/toolkit/inc/helper/tkresmgr.hxx new file mode 100644 index 000000000..70cc4118c --- /dev/null +++ b/toolkit/inc/helper/tkresmgr.hxx @@ -0,0 +1,34 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_TOOLKIT_INC_HELPER_TKRESMGR_HXX +#define INCLUDED_TOOLKIT_INC_HELPER_TKRESMGR_HXX + +#include + +class Image; + +namespace TkResMgr +{ +Image getImageFromURL(const OUString& i_rImageURL); +}; + +#endif // INCLUDED_TOOLKIT_INC_HELPER_TKRESMGR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/inc/helper/unopropertyarrayhelper.hxx b/toolkit/inc/helper/unopropertyarrayhelper.hxx new file mode 100644 index 000000000..31940ec4c --- /dev/null +++ b/toolkit/inc/helper/unopropertyarrayhelper.hxx @@ -0,0 +1,52 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_TOOLKIT_INC_HELPER_UNOPROPERTYARRAYHELPER_HXX +#define INCLUDED_TOOLKIT_INC_HELPER_UNOPROPERTYARRAYHELPER_HXX + +#include + +#include +#include + + + +class UnoPropertyArrayHelper final : public ::cppu::IPropertyArrayHelper +{ + o3tl::sorted_vector maIDs; + + bool ImplHasProperty( sal_uInt16 nPropId ) const; + +public: + UnoPropertyArrayHelper( const css::uno::Sequence& rIDs ); + UnoPropertyArrayHelper( const std::vector< sal_uInt16 > &rIDs ); + + // ::cppu::IPropertyArrayHelper + sal_Bool SAL_CALL fillPropertyMembersByHandle( OUString * pPropName, sal_Int16 * pAttributes, sal_Int32 nHandle ) override; + css::uno::Sequence< css::beans::Property > SAL_CALL getProperties() override; + css::beans::Property SAL_CALL getPropertyByName(const OUString& rPropertyName) override; + sal_Bool SAL_CALL hasPropertyByName(const OUString& rPropertyName) override; + sal_Int32 SAL_CALL getHandleByName( const OUString & rPropertyName ) override; + sal_Int32 SAL_CALL fillHandles( sal_Int32* pHandles, const css::uno::Sequence< OUString > & rPropNames ) override; +}; + + +#endif // INCLUDED_TOOLKIT_INC_HELPER_UNOPROPERTYARRAYHELPER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/inc/helper/unowrapper.hxx b/toolkit/inc/helper/unowrapper.hxx new file mode 100644 index 000000000..03a9b525c --- /dev/null +++ b/toolkit/inc/helper/unowrapper.hxx @@ -0,0 +1,73 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_TOOLKIT_INC_HELPER_UNOWRAPPER_HXX +#define INCLUDED_TOOLKIT_INC_HELPER_UNOWRAPPER_HXX + +#include +#include +#include +#include + +#include +#include + +#include + + + +class UnoWrapper final : public UnoWrapperBase +{ +private: + css::uno::Reference< css::awt::XToolkit> mxToolkit; + ::toolkit::AccessibilityClient maAccessibleFactoryAccess; + +public: + UnoWrapper( const css::uno::Reference< css::awt::XToolkit>& rxToolkit ); + + virtual void Destroy() override; + + // Toolkit + virtual css::uno::Reference< css::awt::XToolkit> GetVCLToolkit() override; + + // Graphics + virtual css::uno::Reference< css::awt::XGraphics> CreateGraphics( OutputDevice* pOutDev ) override; + virtual void ReleaseAllGraphics( OutputDevice* pOutDev ) override; + + // Window + virtual css::uno::Reference< css::awt::XWindowPeer> GetWindowInterface( vcl::Window* pWindow ) override; + virtual void SetWindowInterface( vcl::Window* pWindow, const css::uno::Reference< css::awt::XWindowPeer> & xIFace ) override; + virtual VclPtr GetWindow(const css::uno::Reference& rxWindow) override; + + // Menu + virtual css::uno::Reference CreateMenuInterface( PopupMenu* pPopupMenu ) override; + + void WindowDestroyed( vcl::Window* pWindow ) override; + + // Accessibility + virtual css::uno::Reference< css::accessibility::XAccessible > + CreateAccessible( Menu* pMenu, bool bIsMenuBar ) override; + +private: + virtual ~UnoWrapper(); +}; + +#endif // INCLUDED_TOOLKIT_INC_HELPER_UNOWRAPPER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/qa/complex/toolkit/AccessibleStatusBarItem.java b/toolkit/qa/complex/toolkit/AccessibleStatusBarItem.java new file mode 100644 index 000000000..a3fac8c3d --- /dev/null +++ b/toolkit/qa/complex/toolkit/AccessibleStatusBarItem.java @@ -0,0 +1,359 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package complex.toolkit; + +import java.util.logging.Logger; +import java.util.logging.Level; +import complex.toolkit.accessibility._XAccessibleEventBroadcaster; +import complex.toolkit.accessibility._XAccessibleExtendedComponent; +import complex.toolkit.accessibility._XAccessibleText; +import complex.toolkit.accessibility._XAccessibleComponent; +import complex.toolkit.accessibility._XAccessibleContext; +import util.SOfficeFactory; +import util.AccessibilityTools; +import com.sun.star.awt.XWindow; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XServiceInfo; +import com.sun.star.sheet.XSpreadsheetDocument; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.XInterface; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.util.XCloseable; +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.awt.XExtendedToolkit; + + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.openoffice.test.OfficeConnection; +import static org.junit.Assert.*; + +/** + * + */ +public class AccessibleStatusBarItem { + + XMultiServiceFactory xMSF = null; + XAccessibleContext testObject = null; + XWindow xWindow = null; + + /** + * Check document types + */ + @Test + public void checkDocs() + { + checkWriterDoc(); + checkMathDoc(); + checkDrawDoc(); + checkImpressDoc(); + checkCalcDoc(); + } + + private XMultiServiceFactory getMSF() + { + return UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager()); + } + + /** + * Test the interfaces on a writer document + */ + private void checkWriterDoc() { + xMSF = getMSF(); + SOfficeFactory xSOF = SOfficeFactory.getFactory(xMSF); + XTextDocument xTextDoc = null; + try { + System.out.println("****** Open a new writer document"); + xTextDoc = xSOF.createTextDoc("_blank"); + getTestObject(); + } + catch(com.sun.star.uno.Exception e) { + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); + } + runAllInterfaceTests(); + + if (xTextDoc != null) { + XCloseable xClose = UnoRuntime.queryInterface(XCloseable.class, xTextDoc); + try { + xClose.close(false); + } + catch(com.sun.star.util.CloseVetoException e) { + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); + } + } + } + + /** + * Test the interfaces on a math document + */ + public void checkMathDoc() { + xMSF = getMSF(); + SOfficeFactory xSOF = SOfficeFactory.getFactory(xMSF); + XComponent xMathDoc = null; + try { + System.out.println("****** Open a new math document"); + xMathDoc = xSOF.createMathDoc("_blank"); + getTestObject(); + } + catch(com.sun.star.uno.Exception e) { + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); + } + runAllInterfaceTests(); + + if (xMathDoc != null) { + XCloseable xClose = UnoRuntime.queryInterface(XCloseable.class, xMathDoc); + try { + xClose.close(false); + } + catch(com.sun.star.util.CloseVetoException e) { + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); + } + } + } + + /** + * Test the interfaces on a draw document + */ + public void checkDrawDoc() { + xMSF = getMSF(); + SOfficeFactory xSOF = SOfficeFactory.getFactory(xMSF); + XComponent xDrawDoc = null; + try { + System.out.println("****** Open a new draw document"); + xDrawDoc = xSOF.createDrawDoc("_blank"); + getTestObject(); + } + catch(com.sun.star.uno.Exception e) { + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); + } + runAllInterfaceTests(); + + if (xDrawDoc != null) { + XCloseable xClose = UnoRuntime.queryInterface(XCloseable.class, xDrawDoc); + try { + xClose.close(false); + } + catch(com.sun.star.util.CloseVetoException e) { + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); + } + } + } + + /** + * Test the interfaces on an impress document + */ + public void checkImpressDoc() { + xMSF = getMSF(); + SOfficeFactory xSOF = SOfficeFactory.getFactory(xMSF); + XComponent xImpressDoc = null; + try { + System.out.println("****** Open a new impress document"); + xImpressDoc = xSOF.createImpressDoc("_blank"); + getTestObject(); + } + catch(com.sun.star.uno.Exception e) { + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); + } + runAllInterfaceTests(); + + if (xImpressDoc != null) { + XCloseable xClose = UnoRuntime.queryInterface(XCloseable.class, xImpressDoc); + try { + xClose.close(false); + } + catch(com.sun.star.util.CloseVetoException e) { + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); + } + } + } + /** + * Test the interfaces on a calc document + */ + public void checkCalcDoc() { + xMSF = getMSF(); + SOfficeFactory xSOF = SOfficeFactory.getFactory(xMSF); + XSpreadsheetDocument xSpreadsheetDoc = null; + try { + System.out.println("****** Open a new calc document"); + xSpreadsheetDoc = xSOF.createCalcDoc("_blank"); + util.utils.waitForEventIdle(xMSF); + getTestObject(); + } + catch(com.sun.star.uno.Exception e) { + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); + } + runAllInterfaceTests(); + + if (xSpreadsheetDoc != null) { + XCloseable xClose = UnoRuntime.queryInterface(XCloseable.class, xSpreadsheetDoc); + try { + xClose.close(false); + } + catch(com.sun.star.util.CloseVetoException e) { + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); + } + } + } + + public void getTestObject() { + try { + XInterface xIfc = (XInterface) xMSF.createInstance( + "com.sun.star.awt.Toolkit") ; + XExtendedToolkit tk = + UnoRuntime.queryInterface(XExtendedToolkit.class,xIfc); + + util.utils.waitForEventIdle(xMSF); + xWindow = UnoRuntime.queryInterface( + XWindow.class,tk.getActiveTopWindow()); + + util.utils.waitForEventIdle(xMSF); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + XAccessibleContext parentContext = null; + + System.out.println("Get the accessible status bar."); + parentContext = AccessibilityTools.getAccessibleObjectForRole( + xRoot, AccessibleRole.STATUS_BAR, ""); + util.utils.waitForEventIdle(xMSF); + if ( parentContext == null ) { + fail("Could not create a test object."); + } + System.out.println("...OK."); + + testObject=parentContext; + } + catch(com.sun.star.uno.Exception e) { + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); + } + catch(Throwable t) { + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", t ); + } + } + + public void runAllInterfaceTests() { + int count = testObject.getAccessibleChildCount(); + System.out.println("*****"); + System.out.println("**** Found items to test: " + count); + for (int i=0;ino exception must be throw by invoking the method. + */ + public static void assertException( final String i_message, final Object i_object, final String i_methodName, + final Class[] i_argClasses, final Object[] i_methodArgs, final Class i_expectedExceptionClass ) + { + Class objectClass = i_object.getClass(); + + boolean noExceptionAllowed = ( i_expectedExceptionClass == null ); + + boolean caughtExpected = noExceptionAllowed; + try + { + Method method = impl_getMethod( objectClass, i_methodName, i_argClasses ); + method.invoke(i_object, i_methodArgs ); + } + catch ( NoSuchMethodException e ) + { + StringBuilder message = new StringBuilder(); + message.append( "no such method: " ).append( objectClass.getName() ).append( '.' ).append( i_methodName ).append( "( " ); + for ( int i=0; ifoo( int ), {@link Class#getMethod} would not return this + * method when you pass Integer.class. impl_getMethod will recognize this, and + * properly retrieve the method. + * + * Note: impl_getMethod is limited in that it will not try all possible combinations of primitive + * and non-primitive types. That is, a method like foo( int, Integer, int ) is likely to not be + * found. + * + * @param i_objectClass + * @param i_methodName + * @param i_argClasses + * @return + */ + private static Method impl_getMethod( final Class i_objectClass, final String i_methodName, final Class[] i_argClasses ) throws NoSuchMethodException + { + try + { + return i_objectClass.getMethod( i_methodName, i_argClasses ); + } + catch ( NoSuchMethodException ex ) + { + } + + int substitutedTypes = 0; + int substitutedTypesLastRound = 0; + final Class[][] substitutionTable = new Class[][] { + new Class[] { Long.class, long.class }, + new Class[] { Integer.class, int.class }, + new Class[] { Short.class, short.class }, + new Class[] { Byte.class, byte.class }, + new Class[] { Double.class, double.class }, + new Class[] { Float.class, float.class }, + new Class[] { Character.class, char.class } + }; + do + { + substitutedTypes = 0; + final Class[] argClasses = new Class[ i_argClasses.length ]; + for ( int i=0; i < argClasses.length; ++i ) + { + argClasses[i] = i_argClasses[i]; + if ( substitutedTypes > substitutedTypesLastRound ) + continue; + + for ( int c=0; c 0 ); + throw new NoSuchMethodException(); + } + + /** invokes a given method on a given object, and assures a certain exception is caught + * @param i_message is the message to print when the check fails + * @param i_object is the object to invoke the method on + * @param i_methodName is the name of the method to invoke + * @param i_methodArgs are the arguments to pass to the method. Those implicitly define + * the classes of the arguments of the method which is called. + * @param i_expectedExceptionClass is the class of the exception to be caught. If this is null, + * it means that no exception must be throw by invoking the method. + */ + public static void assertException( final String i_message, final Object i_object, final String i_methodName, + final Object[] i_methodArgs, final Class i_expectedExceptionClass ) + { + Class[] argClasses = new Class[ i_methodArgs.length ]; + for ( int i=0; iXMutableGridDataModel interface + */ + @Test + public void testMutableGridDataModel() throws Exception + { + impl_recreateGridModel(); + + TMutableGridDataModel test = new TMutableGridDataModel( m_dataModel ); + test.testAddRow(); + test.testAddRows(); + test.testInsertRow(); + test.testInsertRows(); + test.testRemoveRow(); + test.testRemoveAllRows(); + test.testUpdateCellData(); + test.testUpdateRowData(); + test.testUpdateRowHeading(); + test.cleanup(); + + // a somewhat less straight-forward test: the data model is expected to implicitly increase its column count + // when you add a row which has more columns than currently known + final XMutableGridDataModel dataModel = DefaultGridDataModel.create( m_context ); + dataModel.addRow( 0, new Object[] { 1 } ); + assertEquals( "unexpected column count after adding the most simple row", 1, dataModel.getColumnCount() ); + dataModel.addRow( 1, new Object[] { 1, 2 } ); + assertEquals( "implicit extension of the column count doesn't work", 2, dataModel.getColumnCount() ); + } + + + @Test + public void testGridColumnModel() throws Exception + { + impl_recreateGridModel(); + + ColumnModelListener listener = new ColumnModelListener(); + m_columnModel.addContainerListener( listener ); + + // insert default columns into the previously empty model, ensure we get the right notifications + final int defaultColumnsCount = 3; + m_columnModel.setDefaultColumns( defaultColumnsCount ); + impl_assertColumnModelConsistency(); + List< ContainerEvent > events = listener.assertExclusiveInsertionEvents(); + listener.reset(); + assertEquals( "wrong number of events fired by setDefaultColumns", defaultColumnsCount, events.size() ); + for ( int i=0; i removalEvents = listener.getRemovalEvents(); + final List< ContainerEvent > insertionEvents = listener.getInsertionEvents(); + listener.reset(); + + // for the removal events, check the indexes + assertEquals( "wrong number of columns removed (or notified) upon setting default columns", + defaultColumnsCount, removalEvents.size() ); + for ( int i=0; i currentSortOrder = m_dataModel.getCurrentSortOrder(); + assertEquals( "invalid current sort column (column " + colIndex + ")", currentSortOrder.First.intValue(), colIndex ); + assertEquals( "invalid current sort direction", currentSortOrder.Second.booleanValue(), ascending ); + + /*for ( int i=0; i= nextIntValue ); + + // ensure the data in the other columns, and the row headings, are sorted as well + final Object rowHeading = m_dataModel.getRowHeading( rowIndex ); + final int unsortedRowIndex = impl_assertInteger( rowHeading ); + for ( int innerColIndex = 0; innerColIndex < colCount; ++innerColIndex ) + { + assertEquals( "sorted row " + rowIndex + ", unsorted row " + unsortedRowIndex + ", col " + innerColIndex + + ": wrong data", + data[unsortedRowIndex][innerColIndex], m_dataModel.getCellData( innerColIndex, rowIndex ) ); + } + } + } + } + } + + + @Test + public void testView() throws Exception + { + final XControl control = impl_createDialogWithGridControl(); + final XPropertySet gridModelProps = + UnoRuntime.queryInterface( XPropertySet.class, control.getModel() ); + + // in the current implementation (not sure this is a good idea at all), the control (more precise: the peer) + // ensures that if there are no columns in the column model, but in the data model, then the column model + // will implicitly have the needed columns added. + // To ensure that clients which rely on this do not break in the future, check this here. + final XMutableGridDataModel dataModel = UnoRuntime.queryInterface( XMutableGridDataModel.class, + gridModelProps.getPropertyValue( "GridDataModel" ) ); + assertNotNull( dataModel ); + assertEquals( 0, dataModel.getColumnCount() ); + + final XGridColumnModel columnModel = UnoRuntime.queryInterface( XGridColumnModel.class, + gridModelProps.getPropertyValue( "ColumnModel" ) ); + assertNotNull( columnModel ); + assertEquals( 0, columnModel.getColumnCount() ); + + final int columnCount = 3; + final int rowCount = 2; + dataModel.addRow( null, new Object[] { 1, 2, 3 } ); + dataModel.addRow( null, new Object[] { 6, 5, 4 } ); + + assertEquals( columnCount, dataModel.getColumnCount() ); + assertEquals( columnCount, columnModel.getColumnCount() ); + + // some cursor traveling + final XGridControl gridControl = UnoRuntime.queryInterface( XGridControl.class, control ); + gridControl.goToCell( 0, 0 ); + assertEquals( "wrong 'current column' (1)", 0, gridControl.getCurrentColumn() ); + assertEquals( "wrong 'current row' (1)", 0, gridControl.getCurrentRow() ); + gridControl.goToCell( columnCount - 1, rowCount - 1 ); + assertEquals( "wrong 'current column' (2)", dataModel.getColumnCount() - 1, gridControl.getCurrentColumn() ); + assertEquals( "wrong 'current row' (2)", dataModel.getRowCount() - 1, gridControl.getCurrentRow() ); + + // removing the last column, while the active cell is in this very last column, is expected to adjust + // the active cell + columnModel.removeColumn( columnCount - 1 ); + assertEquals( "removed the last and active column, active column was not adjusted!", + columnCount - 2, gridControl.getCurrentColumn() ); + // same holds for rows + dataModel.removeRow( rowCount - 1 ); + assertEquals( "removed the last and active row, active row was not adjusted!", + rowCount - 2, gridControl.getCurrentRow() ); + } + + + private XControl impl_createDialogWithGridControl() throws Exception + { + // create a simple dialog model/control/peer trinity + final XControlModel dialogModel = createInstance( XControlModel.class, "com.sun.star.awt.UnoControlDialogModel" ); + m_disposables.add( dialogModel ); + final XPropertySet dialogProps = UnoRuntime.queryInterface( XPropertySet.class, dialogModel ); + dialogProps.setPropertyValue( "Width", 200 ); + dialogProps.setPropertyValue( "Height", 100 ); + dialogProps.setPropertyValue( "Title", "Grid Control Unit Test" ); + final XControl dialogControl = createInstance( XControl.class, "com.sun.star.awt.UnoControlDialog" ); + m_disposables.add( dialogControl ); + dialogControl.setModel( dialogModel ); + dialogControl.createPeer( createInstance( XToolkit.class, "com.sun.star.awt.Toolkit" ), null ); + + // insert a grid control model + final XMultiServiceFactory controlModelFactory = UnoRuntime.queryInterface( XMultiServiceFactory.class, + dialogModel ); + final XPropertySet gridModelProps = UnoRuntime.queryInterface( XPropertySet.class, + controlModelFactory.createInstance( "com.sun.star.awt.grid.UnoControlGridModel" ) ); + m_disposables.add( gridModelProps ); + gridModelProps.setPropertyValue( "PositionX", 6 ); + gridModelProps.setPropertyValue( "PositionY", 6 ); + gridModelProps.setPropertyValue( "Width", 188 ); + gridModelProps.setPropertyValue( "Height", 88 ); + final XNameContainer modelContainer = UnoRuntime.queryInterface( XNameContainer.class, dialogModel ); + modelContainer.insertByName( "grid", gridModelProps ); + + // check the respective control has been created + final XControlContainer controlContainer = UnoRuntime.queryInterface( XControlContainer.class, dialogControl ); + final XControl gridControl = controlContainer.getControl( "grid" ); + assertNotNull( "no grid control created in the dialog", gridControl ); + + return gridControl; + } + + + private int impl_assertInteger( final Object i_object ) + { + assertTrue( i_object instanceof Integer ); + return ((Integer)i_object).intValue(); + } + + + private void impl_assertColumnModelConsistency() throws IndexOutOfBoundsException + { + for ( int col = 0; col < m_columnModel.getColumnCount(); ++col ) + { + final XGridColumn column = m_columnModel.getColumn( col ); + assertNotNull( column ); + assertEquals( "column/model inconsistency: column " + col + " has a wrong index!", col, column.getIndex() ); + } + + final XGridColumn[] allColumns = m_columnModel.getColumns(); + assertEquals( "getColumns returns the wrong number of column objects", + m_columnModel.getColumnCount(), allColumns.length ); + for ( int col = 0; col < m_columnModel.getColumnCount(); ++col ) + { + assertTrue( "getColumns inconsistency", impl_areSameInterface( allColumns[col], m_columnModel.getColumn(col) ) ); + } + } + + + private void impl_assertEquality( final XGridDataModel i_reference, final XGridDataModel i_compare ) throws IndexOutOfBoundsException + { + assertNotNull( i_reference ); + assertNotNull( i_compare ); + + assertEquals( "data model comparison: wrong column counts", i_reference.getColumnCount(), i_compare.getColumnCount() ); + assertEquals( "data model comparison: wrong row counts", i_reference.getRowCount(), i_compare.getRowCount() ); + + for ( int row = 0; row < i_reference.getRowCount(); ++row ) + { + assertEquals( "data model comparison: wrong row heading content in row " + row, + i_reference.getRowHeading( row ) ); + for ( int col = 0; col < i_reference.getRowCount(); ++col ) + { + assertEquals( "data model comparison: wrong cell content in cell (" + col + ", " + row + ")", + i_reference.getCellData( col, row ) ); + assertEquals( "data model comparison: wrong tooltip content in cell (" + col + ", " + row + ")", + i_reference.getCellToolTip( col, row ) ); + } + } + } + + + private void impl_assertEquality( final XGridColumnModel i_reference, final XGridColumnModel i_compare ) throws IndexOutOfBoundsException + { + assertEquals( "column model comparison: wrong column counts", i_reference.getColumnCount(), i_compare.getColumnCount() ); + for ( int col = 0; col < i_reference.getColumnCount(); ++col ) + { + final XGridColumn referenceColumn = i_reference.getColumn( col ); + final XGridColumn compareColumn = i_compare.getColumn( col ); + impl_assertEquality( referenceColumn, compareColumn ); + } + } + + + private void impl_assertEquality( final XGridColumn i_reference, final XGridColumn i_compare ) + { + final Method[] methods = XGridColumn.class.getMethods(); + for ( int m=0; m T createInstance( Class i_interfaceClass, final String i_serviceIndentifier ) throws Exception + { + return UnoRuntime.queryInterface( i_interfaceClass, createInstance( i_serviceIndentifier ) ); + } + + + private Object createInstance( final String i_serviceName ) throws Exception + { + Object instance = m_context.getServiceManager().createInstanceWithContext( i_serviceName, m_context ); + assertNotNull( "could not create an instance of '" + i_serviceName + "'", instance ); + return instance; + } + + private static final class DisposeListener implements XEventListener + { + DisposeListener( final Object i_component ) + { + m_component = UnoRuntime.queryInterface( XComponent.class, i_component ); + assertNotNull( m_component ); + m_component.addEventListener( this ); + } + + public void disposing( EventObject i_event ) + { + assertTrue( UnoRuntime.areSame( i_event.Source, m_component ) ); + m_isDisposed = true; + } + + final boolean isDisposed() { return m_isDisposed; } + + private final XComponent m_component; + private boolean m_isDisposed; + } + + + private static final class ColumnModelListener implements XContainerListener + { + ColumnModelListener() + { + } + + public void elementInserted( ContainerEvent i_event ) + { + m_insertionEvents.add( i_event ); + } + + public void elementRemoved( ContainerEvent i_event ) + { + m_removalEvents.add( i_event ); + } + + public void elementReplaced( ContainerEvent i_event ) + { + m_replacementEvents.add( i_event ); + } + + public void disposing( EventObject eo ) + { + } + + private List< ContainerEvent > assertExclusiveInsertionEvents() + { + assertFalse( m_insertionEvents.isEmpty() ); + assertTrue( m_removalEvents.isEmpty() ); + assertTrue( m_replacementEvents.isEmpty() ); + return m_insertionEvents; + } + + private List< ContainerEvent > assertExclusiveRemovalEvents() + { + assertTrue( m_insertionEvents.isEmpty() ); + assertFalse( m_removalEvents.isEmpty() ); + assertTrue( m_replacementEvents.isEmpty() ); + return m_removalEvents; + } + + private void reset() + { + m_insertionEvents = new ArrayList< ContainerEvent >(); + m_removalEvents = new ArrayList< ContainerEvent >(); + m_replacementEvents = new ArrayList< ContainerEvent >(); + } + + private List< ContainerEvent > getInsertionEvents() { return m_insertionEvents; } + private List< ContainerEvent > getRemovalEvents() { return m_removalEvents; } + + private List< ContainerEvent > m_insertionEvents = new ArrayList< ContainerEvent >(); + private List< ContainerEvent > m_removalEvents = new ArrayList< ContainerEvent >(); + private List< ContainerEvent > m_replacementEvents = new ArrayList< ContainerEvent >(); + } + + + private static final OfficeConnection m_connection = new OfficeConnection(); + private static Random m_randomGenerator = new Random(); + private final XComponentContext m_context; + + private XPropertySet m_gridControlModel; + private XGridColumnModel m_columnModel; + private XSortableMutableGridDataModel m_dataModel; + private final List< Object > m_disposables = new ArrayList< Object >(); +} diff --git a/toolkit/qa/complex/toolkit/accessibility/_XAccessibleComponent.java b/toolkit/qa/complex/toolkit/accessibility/_XAccessibleComponent.java new file mode 100644 index 000000000..3d4df2c5f --- /dev/null +++ b/toolkit/qa/complex/toolkit/accessibility/_XAccessibleComponent.java @@ -0,0 +1,463 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package complex.toolkit.accessibility; + +import java.util.ArrayList; + +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleComponent; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.awt.Point; +import com.sun.star.awt.Rectangle; +import com.sun.star.awt.Size; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Testing com.sun.star.accessibility.XAccessibleComponent + * interface methods : + *
    + *
  • containsPoint()
  • + *
  • getAccessibleAtPoint()
  • + *
  • getBounds()
  • + *
  • getLocation()
  • + *
  • getLocationOnScreen()
  • + *
  • getSize()
  • + *
  • grabFocus()
  • + *

+ * + * @see com.sun.star.accessibility.XAccessibleComponent + */ +public class _XAccessibleComponent { + + private final XAccessibleComponent oObj; + + private Rectangle bounds = null ; + + /** + * Constructor + */ + public _XAccessibleComponent(XInterface object/*, LogWriter log*/) { + oObj = UnoRuntime.queryInterface( + XAccessibleComponent.class, object); + } + + /** + * First checks 4 inner bounds (upper, lower, left and right) + * of component bounding box to contain + * at least one point of the component. Second 4 outer bounds + * are checked to not contain any component points.

+ * + * Has OK status if inner bounds contain component points + * and outer bounds don't contain any component points.

+ * + * The following method tests are to be completed successfully before : + *

    + *
  • getBounds() : to have size of a component.
  • + *
+ */ + public boolean _containsPoint() { + + boolean result = true ; + + int curX = 0; + while (!oObj.containsPoint(new Point(curX, 0)) && curX < bounds.Width) { + curX++; + } + if (curX < bounds.Width) { + System.out.println("Upper bound of box contains point (" + + curX + ",0) - OK"); + } else { + System.out.println + ("Upper bound of box contains no component points - FAILED"); + result = false; + } + + curX = 0; + while (!oObj.containsPoint(new Point(curX, bounds.Height - 1)) + && curX < bounds.Width) { + + System.out.println("Contains returns false for ("+curX+","+bounds.Height+")"); + curX++; + } + if (curX < bounds.Width) { + System.out.println("Lower bound of box contains point (" + + curX + "," + (bounds.Height - 1) + ") - OK"); + } else { + System.out.println + ("Lower bound of box contains no component points - FAILED"); + result = false; + } + + int curY = 0; + while (!oObj.containsPoint(new Point(0, curY)) && curY < bounds.Height) { + curY++; + } + if (curY < bounds.Height) { + System.out.println("Left bound of box contains point (0," + + curY + ") - OK"); + } else { + System.out.println + ("Left bound of box contains no component points - FAILED"); + result = false; + } + + curY = 0; + while (!oObj.containsPoint(new Point(bounds.Width - 1, curY)) && curY < bounds.Height) { + curY++; + } + if (curY < bounds.Height) { + System.out.println("Right bound of box contains point (" + + (bounds.Width - 1) + "," + curY + ") - OK"); + } else { + System.out.println + ("Right bound of box contains no component points - FAILED"); + result = false; + } + + boolean locRes = true; + for (int x = -1; x <= bounds.Width; x++) { + locRes &= !oObj.containsPoint(new Point(x, -1)); + locRes &= !oObj.containsPoint(new Point(x, bounds.Height+bounds.Y)); + } + if (locRes) { + System.out.println("Outer upper and lower bounds contain no component " + + "points - OK"); + } else { + System.out.println("Outer upper and lower bounds CONTAIN some component " + + "points - FAILED"); + result = false; + } + + locRes = true; + for (int y = -1; y <= bounds.Height; y++) { + locRes &= !oObj.containsPoint(new Point(-1, y)); + locRes &= !oObj.containsPoint(new Point(bounds.X+bounds.Width, y)); + } + if (locRes) { + System.out.println("Outer left and right bounds contain no component " + + "points - OK"); + } else { + System.out.println("Outer left and right bounds CONTAIN some component " + + "points - FAILED"); + result = false; + } + + return result; + } + + /** + * Iterates through all children which implement + * XAccessibleComponent (if they exist) determines their + * boundaries and tries to get each child by getAccessibleAtPoint + * passing point which belongs to the child. + * Also the point is checked which doesn't belong to child boundary + * box.

+ * + * Has OK status if in the first cases the right children + * are returned, and in the second null or + * another child is returned. + */ + public boolean _getAccessibleAtPoint() { + + boolean result = true ; + XAccessibleComponent[] children = getChildrenComponents(); + + if (children.length > 0) { + for (int i = 0; i < children.length; i++) { + Rectangle chBnd = children[i].getBounds(); + if (chBnd.X == -1) + { + continue; + } + System.out.println("Checking child with bounds " + + "(" + chBnd.X + "," + chBnd.Y + "),(" + + chBnd.Width + "," + chBnd.Height + "): " + + util.AccessibilityTools.accessibleToString(children[i])); + + System.out.println("finding the point which lies on the component"); + int curX = 0; + int curY = 0; + while (!children[i].containsPoint(new Point(curX, curY)) + && curX < chBnd.Width) { + curX++; + curY++; + } + + if (curX==chBnd.Width) { + System.out.println("Couldn't find a point with contains"); + continue; + } + + // trying the point laying on child + XAccessible xAcc = oObj.getAccessibleAtPoint + (new Point(chBnd.X , chBnd.Y)); + if (xAcc == null) { + System.out.println("The child not found at point (" + + (chBnd.X ) + "," + chBnd.Y + ") - FAILED"); + result = false; + } else { + XAccessible xAccCh = UnoRuntime.queryInterface + (XAccessible.class, children[i]); + System.out.println("Child found at point (" + + (chBnd.X ) + "," + chBnd.Y + ") - OK"); + boolean res = util.AccessibilityTools.equals(xAccCh, xAcc); + if (!res) { + int expIndex = xAccCh.getAccessibleContext().getAccessibleIndexInParent(); + int gotIndex = xAcc.getAccessibleContext().getAccessibleIndexInParent(); + if (expIndex < gotIndex) { + System.out.println("The children found is not the same"); + System.out.println("The expected child " + + xAccCh.getAccessibleContext().getAccessibleName()); + System.out.println("is hidden behind the found Child "); + System.out.println(xAcc.getAccessibleContext().getAccessibleName()+" - OK"); + } else { + System.out.println("The children found is not the same - FAILED"); + System.out.println("Expected: " + +xAccCh.getAccessibleContext().getAccessibleName()); + System.out.println("Found: " + +xAcc.getAccessibleContext().getAccessibleName()); + result = false ; + } + } + } + + // trying the point NOT laying on child + xAcc = oObj.getAccessibleAtPoint + (new Point(chBnd.X - 1, chBnd.Y - 1)); + if (xAcc == null) { + System.out.println("No children found at point (" + + (chBnd.X - 1) + "," + (chBnd.Y - 1) + ") - OK"); + result &= true; + } else { + XAccessible xAccCh = UnoRuntime.queryInterface(XAccessible.class, children[i]); + boolean res = util.AccessibilityTools.equals(xAccCh, xAcc); + if (res) { + System.out.println("The same child found outside " + + "its bounds - FAILED"); + result = false ; + } + } + } + } else { + System.out.println("There are no children supporting " + + "XAccessibleComponent"); + } + + return result; + } + + /** + * Retrieves the component bounds and stores it.

+ * + * Has OK status if boundary position (x,y) is not negative + * and size (Width, Height) is greater than 0. + */ + public boolean _getBounds() { + boolean result = true ; + + bounds = oObj.getBounds() ; + result &= bounds != null + && bounds.X >=0 && bounds.Y >=0 + && bounds.Width >0 && bounds.Height >0; + + System.out.println("Bounds = " + (bounds != null + ? "(" + bounds.X + "," + bounds.Y + "),(" + + bounds.Width + "," + bounds.Height + ")" : "null")); + + return result; + } + + /** + * Gets the location.

+ * + * Has OK status if the location is the same as location + * of boundary obtained by getBounds() method. + * + * The following method tests are to be completed successfully before : + *

    + *
  • getBounds() : to have bounds
  • + *
+ */ + public boolean _getLocation() { + + boolean result = true ; + Point loc = oObj.getLocation() ; + + result &= loc.X == bounds.X && loc.Y == bounds.Y ; + + return result; + } + + /** + * Get the screen location of the component and its parent + * (if it exists and supports XAccessibleComponent).

+ * + * Has OK status if component screen location equals + * to screen location of its parent plus location of the component + * relative to the parent.

+ * + * The following method tests are to be completed successfully before : + *

    + *
  • getBounds() : to have location of the component + * relative to its parent
  • + *
+ */ + public boolean _getLocationOnScreen() { + + XAccessibleComponent parent = getParentComponent(); + + boolean result = true ; + Point loc = oObj.getLocationOnScreen(); + System.out.println("Location is (" + loc.X + "," + loc.Y + ")"); + + if (parent != null) { + Point parLoc = parent.getLocationOnScreen(); + System.out.println("Parent location is (" + + parLoc.X + "," + parLoc.Y + ")"); + + result &= parLoc.X + bounds.X == loc.X; + result &= parLoc.Y + bounds.Y == loc.Y; + } + + return result; + } + + /** + * Obtains the size of the component.

+ * + * Has OK status if the size is the same as in bounds.

+ * + * The following method tests are to be completed successfully before : + *

    + *
  • getBounds()
  • + *
+ */ + public boolean _getSize() { + + boolean result = true ; + Size size = oObj.getSize() ; + + result &= size.Width == bounds.Width; + result &= size.Height == bounds.Height; + + return result; + } + + /** + * Just calls the method.

+ * + * Has OK status if no runtime exceptions occurred. + */ + public boolean _grabFocus() { + + boolean result = true ; + oObj.grabFocus() ; + + return result ; + } + + /** + * Retrieves all children (not more than 50) of the current + * component which support XAccessibleComponent. + * + * @return The array of children. Empty array returned if + * such children were not found or some error occurred. + */ + private XAccessibleComponent[] getChildrenComponents() { + XAccessible xAcc = UnoRuntime.queryInterface(XAccessible.class, oObj) ; + if (xAcc == null) { + System.out.println("Component doesn't support XAccessible."); + return new XAccessibleComponent[0]; + } + XAccessibleContext xAccCon = xAcc.getAccessibleContext(); + int cnt = xAccCon.getAccessibleChildCount(); + + // for cases when too many children exist checking only first 50 + if (cnt > 50) + { + cnt = 50; + } + + ArrayList childComp = new ArrayList(); + for (int i = 0; i < cnt; i++) { + try { + XAccessible child = xAccCon.getAccessibleChild(i); + XAccessibleContext xAccConCh = child.getAccessibleContext(); + XAccessibleComponent xChAccComp = UnoRuntime.queryInterface(XAccessibleComponent.class, xAccConCh); + if (xChAccComp != null) { + childComp.add(xChAccComp) ; + } + } catch (com.sun.star.lang.IndexOutOfBoundsException e) {} + } + + return childComp.toArray(new XAccessibleComponent[childComp.size()]); + } + + /** + * Gets the parent of the current component which support + * XAccessibleComponent. + * + * @return The parent or null if the component + * has no parent or some errors occurred. + */ + private XAccessibleComponent getParentComponent() { + XAccessible xAcc = UnoRuntime.queryInterface(XAccessible.class, oObj) ; + if (xAcc == null) { + System.out.println("Component doesn't support XAccessible."); + return null; + } + + XAccessibleContext xAccCon = xAcc.getAccessibleContext(); + XAccessible xAccPar = xAccCon.getAccessibleParent(); + + if (xAccPar == null) { + System.out.println("Component has no accessible parent."); + return null; + } + XAccessibleContext xAccConPar = xAccPar.getAccessibleContext(); + XAccessibleComponent parent = UnoRuntime.queryInterface(XAccessibleComponent.class, xAccConPar); + if (parent == null) { + System.out.println + ("Accessible parent doesn't support XAccessibleComponent"); + return null; + } + + return parent; + } + + /** + * Just calls the method. + */ + public boolean _getForeground() { + int forColor = oObj.getForeground(); + System.out.println("getForeground(): " + forColor); + return true; + } + + /** + * Just calls the method. + */ + public boolean _getBackground() { + int backColor = oObj.getBackground(); + System.out.println("getBackground(): " + backColor); + return true; + } + +} diff --git a/toolkit/qa/complex/toolkit/accessibility/_XAccessibleContext.java b/toolkit/qa/complex/toolkit/accessibility/_XAccessibleContext.java new file mode 100644 index 000000000..df7ef76ab --- /dev/null +++ b/toolkit/qa/complex/toolkit/accessibility/_XAccessibleContext.java @@ -0,0 +1,246 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package complex.toolkit.accessibility; + +import com.sun.star.lang.Locale; +import com.sun.star.uno.XInterface; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.accessibility.IllegalAccessibleComponentStateException; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.accessibility.XAccessibleRelationSet; +import com.sun.star.accessibility.XAccessibleStateSet; +import util.AccessibilityTools; + +/** + * Testing com.sun.star.accessibility.XAccessibleContext + * interface methods : + *

    + *
  • getAccessibleChildCount()
  • + *
  • getAccessibleChild()
  • + *
  • getAccessibleParent()
  • + *
  • getAccessibleIndexInParent()
  • + *
  • getAccessibleRole()
  • + *
  • getAccessibleDescription()
  • + *
  • getAccessibleName()
  • + *
  • getAccessibleRelationSet()
  • + *
  • getAccessibleStateSet()
  • + *
  • getLocale()
  • + *

+ * + * @see com.sun.star.accessibility.XAccessibleContext + */ +public class _XAccessibleContext { + + private final XAccessibleContext oObj; + + private int childCount = 0; + private XAccessible parent = null ; + + public _XAccessibleContext(XInterface object) { + oObj = UnoRuntime.queryInterface(XAccessibleContext.class, object); + } + + /** + * Calls the method and stores the number of children.

+ * Has OK status if non-negative number rutrned. + */ + public boolean _getAccessibleChildCount() { + childCount = oObj.getAccessibleChildCount(); + System.out.println(childCount + " children found."); + return childCount > -1; + } + + /** + * Tries to get every child and checks its parent.

+ * + * Has OK status if parent of every child + * and the tested component are the same objects. + * + * The following method tests are to be completed successfully before : + *

    + *
  • getAccessibleChildCount() : to have a number of + * children
  • + *
+ */ + public boolean _getAccessibleChild() { + boolean bOK = true; + int counter = childCount; + if (childCount > 500) + { + counter = 500; + } + for (int i = 0; i < counter; i++) { + try { + XAccessible ch = oObj.getAccessibleChild(i) ; + XAccessibleContext chAC = ch.getAccessibleContext(); + + System.out.println(" Child " + i + ": " + + chAC.getAccessibleDescription()) ; + + if (!AccessibilityTools.equals + (chAC.getAccessibleParent().getAccessibleContext(), oObj)){ + + System.out.println("Role:"); + System.out.println("Getting: "+chAC.getAccessibleParent().getAccessibleContext().getAccessibleRole()); + System.out.println("Expected: "+oObj.getAccessibleRole()); + + System.out.println("ImplementationName:"); + System.out.println("Getting: "+util.utils.getImplName(chAC.getAccessibleParent().getAccessibleContext())); + System.out.println("Expected: "+util.utils.getImplName(oObj)); + + System.out.println("The parent of child and component "+ + "itself differ."); + System.out.println("Getting(Description): " + +chAC.getAccessibleParent().getAccessibleContext().getAccessibleDescription()); + System.out.println("Expected(Description): " + +oObj.getAccessibleDescription()); + + bOK = false; + } else { + System.out.println("Getting the expected Child -- OK"); + } + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + e.printStackTrace(); + bOK = false; + } + } + + return bOK; + } + + /** + * Just gets the parent.

+ * + * Has OK status if parent is not null. + */ + public boolean _getAccessibleParent() { + // assume that the component is not ROOT + parent = oObj.getAccessibleParent(); + return parent != null; + } + + /** + * Retrieves the index of tested component in its parent. + * Then gets the parent's child by this index and compares + * it with tested component.

+ * + * Has OK status if the parent's child and the tested + * component are the same objects. + * + * The following method tests are to be completed successfully before : + *

    + *
  • getAccessibleParent() : to have a parent
  • + *
+ */ + public boolean _getAccessibleIndexInParent() { + + boolean bOK = true; + int idx = oObj.getAccessibleIndexInParent(); + + XAccessibleContext parentAC = parent.getAccessibleContext() ; + try { + bOK &= AccessibilityTools.equals( + parentAC.getAccessibleChild(idx).getAccessibleContext(),oObj); + if (!bOK) { + System.out.println("Expected: "+util.utils.getImplName(oObj)); + System.out.println("Getting: "+util.utils.getImplName( + parentAC.getAccessibleChild(idx).getAccessibleContext())); + } + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + e.printStackTrace(); + bOK = false; + } + return bOK; + } + + /** + * Get the accessible role of component.

+ * + * Has OK status if non-negative number rutrned. + */ + public boolean _getAccessibleRole() { + short role = oObj.getAccessibleRole(); + System.out.println("The role is " + role); + return role > -1; + } + + /** + * Get the accessible name of the component.

+ * + * Has OK status if the name has non-zero length. + */ + public boolean _getAccessibleName() { + String name = oObj.getAccessibleName(); + System.out.println("The name is '" + name + "'"); + return name != null; + } + + /** + * Get the accessible description of the component.

+ * + * Has OK status if the description has non-zero length. + */ + public boolean _getAccessibleDescription() { + String descr = oObj.getAccessibleDescription(); + System.out.println("The description is '" + descr + "'"); + return descr != null; + } + + /** + * Just gets the set.

+ * + * Has OK status if the set is not null. + */ + public boolean _getAccessibleRelationSet() { + XAccessibleRelationSet set = oObj.getAccessibleRelationSet(); + return set != null; + } + + /** + * Just gets the set.

+ * + * Has OK status if the set is not null. + */ + public boolean _getAccessibleStateSet() { + XAccessibleStateSet set = oObj.getAccessibleStateSet(); + return set != null; + } + + /** + * Gets the locale.

+ * + * Has OK status if Country and + * Language fields of locale structure + * are not empty. + */ + public boolean _getLocale() { + Locale loc = null ; + try { + loc = oObj.getLocale(); + System.out.println("The locale is " + loc.Language + "," + loc.Country); + } catch (IllegalAccessibleComponentStateException e) { + e.printStackTrace(); + } + + return loc != null && loc.Language.length() > 0 && + loc.Country.length() > 0; + } +} + diff --git a/toolkit/qa/complex/toolkit/accessibility/_XAccessibleEventBroadcaster.java b/toolkit/qa/complex/toolkit/accessibility/_XAccessibleEventBroadcaster.java new file mode 100644 index 000000000..fe48a6cb8 --- /dev/null +++ b/toolkit/qa/complex/toolkit/accessibility/_XAccessibleEventBroadcaster.java @@ -0,0 +1,177 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package complex.toolkit.accessibility; + +import com.sun.star.accessibility.AccessibleEventObject; +import com.sun.star.accessibility.AccessibleStateType; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.accessibility.XAccessibleEventBroadcaster; +import com.sun.star.accessibility.XAccessibleEventListener; +import com.sun.star.awt.PosSize; +import com.sun.star.awt.Rectangle; +import com.sun.star.awt.XWindow; +import com.sun.star.lang.EventObject; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Testing + * com.sun.star.accessibility.XAccessibleEventBroadcaster + * interface methods : + *

    + *
  • addAccessibleEventListener()
  • + *
  • removeAccessibleEventListener()
  • + *
+ * + *

This test needs the following object relations :

+ *
    + *
  • 'EventProducer' (of type + * ifc.accessibility._XAccessibleEventBroadcaster.EventProducer): + * this must be an implementation of the interface which could perform + * some actions for generating any kind of AccessibleEvent
  • + *
+ * + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + */ +public class _XAccessibleEventBroadcaster { + + private final XAccessibleEventBroadcaster oObj; + private final EventProducer prod; + private final EvListener list = new EvListener(); + + /** + * An event producer + */ + private static class EventProducer { + private final XWindow xWindow; + private EventProducer(XWindow window) { + xWindow = window; + } + + private void fireEvent() { + Rectangle newPosSize = xWindow.getPosSize(); + newPosSize.Width = newPosSize.Width - 20; + newPosSize.Height = newPosSize.Height - 20; + newPosSize.X = newPosSize.X + 20; + newPosSize.Y = newPosSize.Y + 20; + xWindow.setPosSize(newPosSize.X, newPosSize.Y, newPosSize.Width, + newPosSize.Height, PosSize.POSSIZE); + } + } + + /** + * Listener implementation which registers listener calls. + */ + private class EvListener implements XAccessibleEventListener { + public AccessibleEventObject notifiedEvent = null ; + public void notifyEvent(AccessibleEventObject ev) { + System.out.println("Listener, Event : " + ev.EventId); + System.out.println("EventID: " + ev.EventId); + Object old=ev.OldValue; + if (old instanceof com.sun.star.accessibility.XAccessible) { + System.out.println("Old: "+((XAccessible)old).getAccessibleContext().getAccessibleName()); + } + + Object nev=ev.NewValue; + if (nev instanceof com.sun.star.accessibility.XAccessible) { + System.out.println("New: "+((XAccessible)nev).getAccessibleContext().getAccessibleName()); + } + notifiedEvent = ev; + } + + public void disposing(EventObject ev) {} + } + + public _XAccessibleEventBroadcaster(XInterface object, XWindow window) { + oObj = UnoRuntime.queryInterface(XAccessibleEventBroadcaster.class, object); + prod = new EventProducer(window); + } + + /** + * Adds two listeners and fires event by mean of object relation.

+ * Has OK status if both listeners were called + */ + public boolean _addEventListener(XMultiServiceFactory xMSF) { + System.out.println("adding two listeners"); + oObj.addAccessibleEventListener(list); + boolean isTransient = chkTransient(oObj); + System.out.println("fire event"); + prod.fireEvent() ; + + util.utils.waitForEventIdle(xMSF); + + boolean works = true; + + if (list.notifiedEvent == null) { + if (!isTransient) { + System.out.println("listener wasn't called"); + works = false; + } else { + System.out.println("Object is Transient, listener isn't expected to be called"); + } + oObj.removeAccessibleEventListener(list); + } + + return works; + } + + /** + * Removes one of two listeners added before and fires event + * by mean of object relation.

+ * + * Has OK status if the removed listener wasn't called.

+ * + * The following method tests are to be completed successfully before : + *

    + *
  • addEventListener() : to have added listeners
  • + *
+ */ + public boolean _removeEventListener(XMultiServiceFactory xMSF) { + + list.notifiedEvent = null; + + System.out.println("remove first listener"); + oObj.removeAccessibleEventListener(list); + + System.out.println("fire event"); + prod.fireEvent() ; + + util.utils.waitForEventIdle(xMSF); + + if (list.notifiedEvent == null) { + System.out.println("listener wasn't called -- OK"); + } + + return list.notifiedEvent == null; + + } + + private static boolean chkTransient(Object Testcase) { + XAccessibleContext accCon = UnoRuntime.queryInterface(XAccessibleContext.class, Testcase); + return accCon.getAccessibleStateSet().contains( + AccessibleStateType.TRANSIENT) + && accCon.getAccessibleParent().getAccessibleContext() + .getAccessibleStateSet().contains( + AccessibleStateType.MANAGES_DESCENDANTS); + } + +} + diff --git a/toolkit/qa/complex/toolkit/accessibility/_XAccessibleExtendedComponent.java b/toolkit/qa/complex/toolkit/accessibility/_XAccessibleExtendedComponent.java new file mode 100644 index 000000000..64dd66fcb --- /dev/null +++ b/toolkit/qa/complex/toolkit/accessibility/_XAccessibleExtendedComponent.java @@ -0,0 +1,75 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package complex.toolkit.accessibility; + +import com.sun.star.accessibility.XAccessibleExtendedComponent; +import com.sun.star.awt.XFont; +import com.sun.star.uno.XInterface; +import com.sun.star.uno.UnoRuntime; + +/** + * Testing com.sun.star.accessibility.XAccessibleExtendedComponent + * interface methods : + *
    + *
  • getForeground()
  • + *
  • getBackground()
  • + *
  • getFont()
  • + *
  • isEnabled()
  • + *
  • getTitledBorderText()
  • + *
  • getToolTipText()
  • + *

+ * @see com.sun.star.accessibility.XAccessibleExtendedComponent + */ +public class _XAccessibleExtendedComponent { + + private final XAccessibleExtendedComponent oObj; + + public _XAccessibleExtendedComponent(XInterface object/*, LogWriter log*/) { + oObj = UnoRuntime.queryInterface(XAccessibleExtendedComponent.class, object); + } + + /** + * Just calls the method. + */ + public boolean _getFont() { + XFont font = oObj.getFont(); + System.out.println("getFont(): " + font); + return true; + } + + /** + * Calls the method and checks returned value. + * Has OK status if returned value isn't null. + */ + public boolean _getTitledBorderText() { + String titleBorderText = oObj.getTitledBorderText(); + System.out.println("getTitledBorderText(): '" + titleBorderText + "'"); + return titleBorderText != null; + } + + /** + * Calls the method and checks returned value. + * Has OK status if returned value isn't null. + */ + public boolean _getToolTipText() { + String toolTipText = oObj.getToolTipText(); + System.out.println("getToolTipText(): '" + toolTipText + "'"); + return toolTipText != null; + } +} diff --git a/toolkit/qa/complex/toolkit/accessibility/_XAccessibleText.java b/toolkit/qa/complex/toolkit/accessibility/_XAccessibleText.java new file mode 100644 index 000000000..1cd97d63a --- /dev/null +++ b/toolkit/qa/complex/toolkit/accessibility/_XAccessibleText.java @@ -0,0 +1,1001 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package complex.toolkit.accessibility; + +import com.sun.star.accessibility.XAccessibleText; +import com.sun.star.beans.PropertyValue; +import com.sun.star.awt.Rectangle; +import com.sun.star.awt.Point; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.accessibility.AccessibleTextType; +import com.sun.star.accessibility.TextSegment; +import com.sun.star.beans.UnknownPropertyException; +import com.sun.star.uno.XInterface; +import com.sun.star.uno.UnoRuntime; + +/** + * Testing com.sun.star.accessibility.XAccessibleText + * interface methods : + *

    + *
  • getCaretPosition()
  • + *
  • setCaretPosition()
  • + *
  • getCharacter()
  • + *
  • getCharacterAttributes()
  • + *
  • getCharacterBounds()
  • + *
  • getCharacterCount()
  • + *
  • getIndexAtPoint()
  • + *
  • getSelectedText()
  • + *
  • getSelectionStart()
  • + *
  • getSelectionEnd()
  • + *
  • setSelection()
  • + *
  • getText()
  • + *
  • getTextRange()
  • + *
  • getTextAtIndex()
  • + *
  • getTextBeforeIndex()
  • + *
  • getTextBehindIndex()
  • + *
  • copyText()
  • + *
+ *

This test needs the following object relations :

+ *
    + *
  • 'XAccessibleText.Text' (of type String) + * optional : + * the string presentation of component's text. If the relation + * is not specified, then text from method getText() + * is used. + *
  • + *
+ * @see com.sun.star.accessibility.XAccessibleText + */ +public class _XAccessibleText { + + private final XAccessibleText oObj; + private final XMultiServiceFactory xMSF; + + private Rectangle chBounds = null; + private int chCount = 0; + + private String text = null; + private final String editOnly; + + + public _XAccessibleText(XInterface object, XMultiServiceFactory xMSF, String editOnly) { + this.oObj = UnoRuntime.queryInterface(XAccessibleText.class, object); + this.xMSF = xMSF; + this.editOnly = editOnly; + } + + + /** + * Calls the method and checks returned value. + * Has OK status if returned value is equal to chCount - 1. + * The following method tests are to be executed before: + *
    + *
  • setCaretPosition()
  • + *
+ */ + public boolean _getCaretPosition() { + + if (editOnly != null) { + System.out.println(editOnly); + return true; + } + + boolean res = true; + if ( chCount > 0 ) { + try { + oObj.setCaretPosition(chCount - 1); + } catch (com.sun.star.lang.IndexOutOfBoundsException ie) { + + } + int carPos = oObj.getCaretPosition(); + System.out.println("getCaretPosition: " + carPos); + res = carPos == (chCount - 1); + } + return res; + } + + /** + * Calls the method with the wrong index and with the correct index + * chCount - 1. + * Has OK status if exception was thrown for wrong index and + * if exception wasn't thrown for the correct index. + * The following method tests are to be executed before: + *
    + *
  • getCharacterCount()
  • + *
+ */ + public boolean _setCaretPosition() { + boolean res = true; + + try { + System.out.println("setCaretPosition(-1):"); + oObj.setCaretPosition(-1); + res &= false; + System.out.println("exception was expected"); + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + System.out.println("expected exception"); + res &= true; + } + + try { + System.out.println("setCaretPosition(chCount+1):"); + oObj.setCaretPosition(chCount+1); + res &= false; + System.out.println("exception was expected"); + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + System.out.println("expected exception"); + res &= true; + } + if ( chCount > 0 ) { + try { + System.out.println("setCaretPosition(chCount - 1)"); + oObj.setCaretPosition(chCount - 1); + res &= true; + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + System.out.println("unexpected exception"); + e.printStackTrace(); + res &= false; + } + } + + return res; + } + + /** + * Calls the method with the wrong index and with the correct indexes. + * Checks every character in the text. + * Has OK status if exception was thrown for wrong index, + * if exception wasn't thrown for the correct index and + * if every character is equal to corresponding character in the text. + * The following method tests are to be executed before: + *
    + *
  • getCharacterCount()
  • + *
+ */ + public boolean _getCharacter() { + boolean res = true; + + try { + System.out.println("getCharacter(-1)"); + oObj.getCharacter(-1); + System.out.println("Exception was expected"); + res = false; + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + System.out.println("Expected exception"); + res = true; + } + + try { + System.out.println("getCharacter(chCount)"); + oObj.getCharacter(chCount); + System.out.println("Exception was expected"); + res &= false; + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + System.out.println("Expected exception"); + res &= true; + } + + try { + System.out.println("Checking of every character in the text..."); + boolean isEqCh = true; + for(int i = 0; i < chCount; i++) { + char ch = oObj.getCharacter(i); + isEqCh = ch == text.charAt(i); + res &= isEqCh; + if (!isEqCh) { + System.out.println("At the position " + i + + "was expected character: " + text.charAt(i)); + System.out.println("but was returned: " + ch); + break; + } + } + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + System.out.println("Unexpected exception"); + e.printStackTrace(); + res &= false; + } + + return res; + } + + /** + * Calls the method with the wrong indexes and with the correct index, + * checks a returned value. + * Has OK status if exception was thrown for the wrong indexes, + * if exception wasn't thrown for the correct index and + * if returned value isn't null. + * The following method tests are to be executed before: + *
    + *
  • getCharacterCount()
  • + *
+ */ + public boolean _getCharacterAttributes() { + boolean res = true; + + try { + System.out.println("getCharacterAttributes(-1)"); + oObj.getCharacterAttributes(-1, new String[0]); + System.out.println("Exception was expected"); + res &= false; + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + System.out.println("Expected exception"); + res &= true; + } catch(UnknownPropertyException e) { + System.out.println("unexpected exception => FAILED"); + res &= false; + } + + try { + System.out.println("getCharacterAttributes(chCount)"); + oObj.getCharacterAttributes(chCount, new String[0]); + System.out.println("Exception was expected"); + res &= false; + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + System.out.println("Expected exception"); + res &= true; + } catch(UnknownPropertyException e) { + System.out.println("unexpected exception => FAILED"); + res &= false; + } + + try { + if ( chCount > 0 ) { + System.out.println("getCharacterAttributes(chCount-1)"); + PropertyValue[] props = oObj.getCharacterAttributes(chCount - 1, new String[0]); + res &= props != null; + } + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + System.out.println("Unexpected exception"); + e.printStackTrace(); + res &= false; + } catch(UnknownPropertyException e) { + System.out.println("unexpected exception => FAILED"); + res &= false; + } + + return res; + } + + + /** + * Calls the method with the wrong indexes and with the correct index. + * checks and stores a returned value. + * Has OK status if exception was thrown for the wrong indexes, + * if exception wasn't thrown for the correct index and + * if returned value isn't null. + * The following method tests are to be executed before: + *
    + *
  • getCharacterCount()
  • + *
+ */ + public boolean _getCharacterBounds() { + boolean res = true; + + try { + System.out.println("getCharacterBounds(-1)"); + oObj.getCharacterBounds(-1); + System.out.println("Exception was expected"); + res &= false; + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + System.out.println("Expected exception"); + res &= true; + } + + try { + System.out.println("getCharacterBounds(chCount)"); + oObj.getCharacterBounds(chCount); + System.out.println("Exception was expected"); + res &= false; + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + System.out.println("Expected exception"); + res &= true; + } + + try { + if (chCount > 0) { + System.out.println("getCharacterBounds(chCount-1)"); + chBounds = oObj.getCharacterBounds(chCount-1); + res &= chBounds != null; + System.out.println("rect: " + chBounds.X + ", " + chBounds.Y + ", " + + chBounds.Width + ", " + chBounds.Height); + } + + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + System.out.println("Unexpected exception"); + e.printStackTrace(); + res &= false; + } + + return res; + } + + + /** + * Calls the method and stores a returned value to the variable + * chCount. + * Has OK status if a returned value is equal to the text length. + */ + public boolean _getCharacterCount() { + chCount = oObj.getCharacterCount(); + System.out.println("Character count:" + chCount); + boolean res = chCount == text.length(); + return res; + } + + /** + * Calls the method for an invalid point and for the point of rectangle + * returned by the method getCharacterBounds(). + * Has OK status if returned value is equal to -1 for an + * invalid point and if returned value is equal to chCount-1 + * for a valid point. + * The following method tests are to be executed before: + *
    + *
  • getCharacterBounds()
  • + *
+ */ + public boolean _getIndexAtPoint() { + + boolean res = true; + System.out.println("getIndexAtPoint(-1, -1):"); + Point pt = new Point(-1, -1); + int index = oObj.getIndexAtPoint(pt); + System.out.println(Integer.toString(index)); + res &= index == -1; + + if (chBounds != null) { + pt = new Point(chBounds.X , chBounds.Y ); + System.out.println("getIndexAtPoint(" + pt.X + ", " + pt.Y + "):"); + index = oObj.getIndexAtPoint(pt); + System.out.println(Integer.toString(index)); + res &= index == (chCount - 1); + } + + return res; + } + + /** + * Checks a returned values after different calls of the method + * setSelection(). + * The following method tests are to be executed before: + *
    + *
  • setSelection()
  • + *
+ */ + public boolean _getSelectedText() { + if (editOnly != null) { + System.out.println(editOnly); + return true; + } + + boolean res = true; + + try { + System.out.println("setSelection(0, 0)"); + oObj.setSelection(0, 0); + System.out.println("getSelectedText():"); + String txt = oObj.getSelectedText(); + System.out.println("'" + txt + "'"); + res &= txt.length() == 0; + + System.out.println("setSelection(0, chCount)"); + oObj.setSelection(0, chCount); + System.out.println("getSelectedText():"); + txt = oObj.getSelectedText(); + System.out.println("'" + txt + "'"); + res &= txt.equals(text); + + if (chCount > 2) { + System.out.println("setSelection(1, chCount-1)"); + oObj.setSelection(1, chCount - 1); + System.out.println("getSelectedText():"); + txt = oObj.getSelectedText(); + System.out.println("'" + txt + "'"); + res &= txt.equals(text.substring(1, chCount - 1)); + } + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + System.out.println("Unexpected exception"); + e.printStackTrace(); + res &= false; + } + + return res; + } + + /** + * Checks a returned values after different calls of the method + * setSelection(). + * The following method tests are to be executed before: + *
    + *
  • setSelection()
  • + *
+ */ + public boolean _getSelectionStart() { + if (editOnly != null) { + System.out.println(editOnly); + return true; + } + + boolean res = true; + + try { + System.out.println("setSelection(0, chCount)"); + oObj.setSelection(0, chCount); + int start = oObj.getSelectionStart(); + System.out.println("getSelectionStart():" + start); + res &= start == 0; + + if (chCount > 2) { + System.out.println("setSelection(1, chCount-1)"); + oObj.setSelection(1, chCount - 1); + start = oObj.getSelectionStart(); + System.out.println("getSelectionStart():" + start); + res &= start == 1; + } + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + System.out.println("Unexpected exception"); + e.printStackTrace(); + res &= false; + } + + return res; + } + + /** + * Checks a returned values after different calls of the method + * setSelection(). + * The following method tests are to be executed before: + *
    + *
  • setSelection()
  • + *
+ */ + public boolean _getSelectionEnd() { + if (editOnly != null) { + System.out.println(editOnly); + return true; + } + + boolean res = true; + + try { + System.out.println("setSelection(0, chCount)"); + oObj.setSelection(0, chCount); + int end = oObj.getSelectionEnd(); + System.out.println("getSelectionEnd():" + end); + res &= end == chCount; + + if (chCount > 2) { + System.out.println("setSelection(1, chCount-1)"); + oObj.setSelection(1, chCount - 1); + end = oObj.getSelectionEnd(); + System.out.println("getSelectionEnd():" + end); + res &= end == chCount - 1; + } + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + System.out.println("Unexpected exception"); + e.printStackTrace(); + res &= false; + } + + return res; + } + + /** + * Calls the method with invalid parameters and with valid parameters. + * Has OK status if exception was thrown for invalid parameters, + * if exception wasn't thrown for valid parameters. + * The following method tests are to be executed before: + *
    + *
  • getCharacterCount()
  • + *
+ */ + public boolean _setSelection() { + boolean res = true; + boolean locRes = true; + + if (editOnly != null) { + System.out.println(editOnly); + return true; + } + + try { + System.out.println("setSelection(-1, chCount-1):"); + locRes = oObj.setSelection(-1, chCount - 1); + System.out.println(locRes + " exception was expected"); + res &= !locRes; + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + System.out.println("Expected exception"); + res &= true; + } + + try { + System.out.println("setSelection(0, chCount+1):"); + locRes = oObj.setSelection(0, chCount + 1); + System.out.println(locRes + " exception was expected"); + res &= !locRes; + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + System.out.println("Expected exception"); + res &= true; + } + + try { + if (chCount > 2) { + System.out.println("setSelection(1, chCount-1):"); + locRes = oObj.setSelection(1, chCount - 1); + System.out.println(Boolean.toString(locRes)); + res &= locRes; + + System.out.println("setSelection(chCount-1, 1):"); + locRes = oObj.setSelection(chCount - 1, 1); + System.out.println(Boolean.toString(locRes)); + res &= locRes; + } + + if (chCount > 1) { + System.out.println("setSelection(0, chCount-1):"); + locRes = oObj.setSelection(0, chCount-1); + System.out.println(Boolean.toString(locRes)); + res &= locRes; + + System.out.println("setSelection(chCount-1, 0):"); + locRes = oObj.setSelection(chCount-1, 0); + System.out.println(Boolean.toString(locRes)); + res &= locRes; + } + + System.out.println("setSelection(0, 0):"); + locRes = oObj.setSelection(0, 0); + System.out.println(Boolean.toString(locRes)); + res &= locRes; + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + System.out.println("Unexpected exception"); + e.printStackTrace(); + res &= false; + } + + return res; + } + + /** + * Calls the method and checks returned value. + * Has OK status if returned string is not null + * received from relation. + */ + public boolean _getText() { + text = oObj.getText(); + System.out.println("getText: '" + text + "'"); + return (text != null); + } + + /** + * Calls the method with invalid parameters and with valid parameters, + * checks returned values. + * Has OK status if exception was thrown for invalid parameters, + * if exception wasn't thrown for valid parameters and if returned values + * are equal to corresponding substrings of the text received by relation. + * The following method tests are to be executed before: + *
    + *
  • getCharacterCount()
  • + *
+ */ + public boolean _getTextRange() { + boolean res = true; + boolean locRes = true; + + try { + if (chCount > 3) { + System.out.println("getTextRange(1, chCount - 2): "); + String txtRange = oObj.getTextRange(1, chCount - 2); + System.out.println(txtRange); + locRes = txtRange.equals(text.substring(1, chCount - 2)); + res &= locRes; + if (!locRes) { + System.out.println("Was expected: " + + text.substring(1, chCount - 2)); + } + } + + if (chCount > 0) { + System.out.println("getTextRange(0, chCount-1): "); + String txtRange = oObj.getTextRange(0, chCount-1); + System.out.println(txtRange); + locRes = txtRange.equals(text.substring(0, chCount - 1)); + res &= locRes; + if (!locRes) { + System.out.println("Was expected: " + + text.substring(0, chCount - 1)); + } + + System.out.println("getTextRange(chCount, 0): "); + txtRange = oObj.getTextRange(chCount, 0); + System.out.println(txtRange); + res &= txtRange.equals(text); + + System.out.println("getTextRange(0, 0): "); + txtRange = oObj.getTextRange(0, 0); + System.out.println(txtRange); + locRes = txtRange.length() == 0; + res &= locRes; + if (!locRes) { + System.out.println("Empty string was expected"); + } + } + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + System.out.println("Unexpected exception"); + e.printStackTrace(); + res &= false; + } + + try { + System.out.println("getTextRange(-1, chCount - 1): "); + oObj.getTextRange(-1, chCount - 1); + System.out.println("Exception was expected"); + res &= false; + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + System.out.println("Expected exception"); + res &= true; + } + + try { + System.out.println("getTextRange(0, chCount + 1): "); + oObj.getTextRange(0, chCount + 1); + System.out.println("Exception was expected"); + res &= false; + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + System.out.println("Expected exception"); + res &= true; + } + + try { + System.out.println("getTextRange(chCount+1, -1): "); + oObj.getTextRange(chCount+1, -1); + System.out.println("Exception was expected"); + res &= false; + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + System.out.println("Expected exception"); + res &= true; + } + + return res; + } + + /** + * Calls the method with invalid parameters and with valid parameters, + * checks returned values. + * Has OK status if exception was thrown for invalid parameters, + * if exception wasn't thrown for valid parameters and if returned values + * are equal to corresponding substrings of the text received by relation. + * The following method tests are to be executed before: + *
    + *
  • getCharacterCount()
  • + *
+ */ + public boolean _getTextAtIndex() { + boolean res = true; + + try { + System.out.println("getTextAtIndex(-1, AccessibleTextType.PARAGRAPH):"); + oObj.getTextAtIndex(-1, AccessibleTextType.PARAGRAPH); + System.out.println("Exception was expected"); + res &= false; + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + System.out.println("Expected exception"); + res &= true; + } catch(com.sun.star.lang.IllegalArgumentException e) { + System.out.println("Expected exception"); + res &= true; + } + + try { + System.out.println("getTextAtIndex(chCount+1," + + " AccessibleTextType.PARAGRAPH):"); + oObj.getTextAtIndex(chCount + 1, AccessibleTextType.PARAGRAPH); + System.out.println("Exception was expected"); + res &= false; + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + System.out.println("Expected exception"); + res &= true; + } catch(com.sun.star.lang.IllegalArgumentException e) { + System.out.println("Expected exception"); + res &= true; + } + + + try { + if ( chCount > 0 ) { + System.out.println("getTextAtIndex(chCount," + + " AccessibleTextType.PARAGRAPH):"); + TextSegment txt = oObj.getTextAtIndex(chCount, + AccessibleTextType.PARAGRAPH); + System.out.println("'" + txt.SegmentText + "'"); + res &= txt.SegmentText.length() == 0; + + System.out.println("getTextAtIndex(1," + + " AccessibleTextType.PARAGRAPH):"); + txt = oObj.getTextAtIndex(1, + AccessibleTextType.PARAGRAPH); + System.out.println("'" + txt.SegmentText + "'"); + res &= txt.SegmentText.equals(text); + } + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + System.out.println("Unexpected exception"); + e.printStackTrace(); + res &= false; + } catch(com.sun.star.lang.IllegalArgumentException e) { + System.out.println("Unexpected exception"); + res &= false; + } + + + return res; + } + + /** + * Calls the method with invalid parameters and with valid parameters, + * checks returned values. + * Has OK status if exception was thrown for invalid parameters, + * if exception wasn't thrown for valid parameters and if returned values + * are equal to corresponding substrings of the text received by relation. + * The following method tests are to be executed before: + *
    + *
  • getCharacterCount()
  • + *
+ */ + public boolean _getTextBeforeIndex() { + boolean res = true; + + try { + System.out.println("getTextBeforeIndex(-1, AccessibleTextType.PARAGRAPH):"); + oObj.getTextBeforeIndex(-1, AccessibleTextType.PARAGRAPH); + System.out.println("Exception was expected"); + res &= false; + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + System.out.println("Expected exception"); + res &= true; + } catch(com.sun.star.lang.IllegalArgumentException e) { + System.out.println("Expected exception"); + res &= true; + } + + + try { + System.out.println("getTextBeforeIndex(chCount+1, " + + "AccessibleTextType.PARAGRAPH):"); + oObj.getTextBeforeIndex(chCount + 1, AccessibleTextType.PARAGRAPH); + System.out.println("Exception was expected"); + res &= false; + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + System.out.println("Expected exception"); + res &= true; + } catch(com.sun.star.lang.IllegalArgumentException e) { + System.out.println("Expected exception"); + res &= true; + } + + TextSegment txt = null; + try { + if (chCount > 0) { + System.out.println("getTextBeforeIndex(chCount," + + " AccessibleTextType.PARAGRAPH):"); + txt = oObj.getTextBeforeIndex(chCount, + AccessibleTextType.PARAGRAPH); + System.out.println("'" + txt.SegmentText + "'"); + res &= txt.SegmentText.length() == chCount ; + + System.out.println("getTextBeforeIndex(1," + + " AccessibleTextType.PARAGRAPH):"); + txt = oObj.getTextBeforeIndex(1, + AccessibleTextType.PARAGRAPH); + System.out.println("'" + txt.SegmentText + "'"); + res &= txt.SegmentText.length() == 0; + } + + if (chCount > 2) { + System.out.println("getTextBeforeIndex(chCount-1," + + " AccessibleTextType.CHARACTER):"); + txt = oObj.getTextBeforeIndex(chCount - 1, + AccessibleTextType.CHARACTER); + System.out.println("'" + txt.SegmentText + "'"); + res &= txt.SegmentText.equals(text.substring(chCount - 2, chCount - 1)); + System.out.println("getTextBeforeIndex(2," + + " AccessibleTextType.CHARACTER):"); + txt = oObj.getTextBeforeIndex(2, + AccessibleTextType.CHARACTER); + System.out.println("'" + txt.SegmentText + "'"); + res &= txt.SegmentText.equals(text.substring(1, 2)); + } + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + System.out.println("Unexpected exception"); + e.printStackTrace(); + res &= false; + } catch(com.sun.star.lang.IllegalArgumentException e) { + System.out.println("Unexpected exception"); + res &= false; + } + + + return res; + } + + /** + * Calls the method with invalid parameters and with valid parameters, + * checks returned values. + * Has OK status if exception was thrown for invalid parameters, + * if exception wasn't thrown for valid parameters and if returned values + * are equal to corresponding substrings of the text received by relation. + * The following method tests are to be executed before: + *
    + *
  • getCharacterCount()
  • + *
+ */ + public boolean _getTextBehindIndex() { + boolean res = true; + + try { + System.out.println("getTextBehindIndex(-1, AccessibleTextType.PARAGRAPH):"); + oObj.getTextBehindIndex(-1, AccessibleTextType.PARAGRAPH); + System.out.println("Exception was expected"); + res &= false; + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + System.out.println("Expected exception"); + res &= true; + } catch(com.sun.star.lang.IllegalArgumentException e) { + System.out.println("Expected exception"); + res &= true; + } + + + try { + System.out.println("getTextBehindIndex(chCount+1, " + + "AccessibleTextType.PARAGRAPH):"); + oObj.getTextBehindIndex(chCount + 1, AccessibleTextType.PARAGRAPH); + System.out.println("Exception was expected"); + res &= false; + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + System.out.println("Expected exception"); + res &= true; + } catch(com.sun.star.lang.IllegalArgumentException e) { + System.out.println("Expected exception"); + res &= true; + } + + + try { + if ( chCount > 0 ) { + System.out.println("getTextBehindIndex(chCount," + + " AccessibleTextType.PARAGRAPH):"); + TextSegment txt = oObj.getTextBehindIndex(chCount, + AccessibleTextType.PARAGRAPH); + System.out.println("'" + txt.SegmentText + "'"); + res &= txt.SegmentText.length() == 0; + + System.out.println("getTextBehindIndex(chCount-1," + + " AccessibleTextType.PARAGRAPH):"); + txt = oObj.getTextBehindIndex(chCount - 1, + AccessibleTextType.PARAGRAPH); + System.out.println("'" + txt.SegmentText + "'"); + res &= txt.SegmentText.length() == 0; + } + if ( chCount > 1 ) { + System.out.println("getTextBehindIndex(1," + + " AccessibleTextType.CHARACTER):"); + TextSegment txt = oObj.getTextBehindIndex(1, + AccessibleTextType.CHARACTER); + System.out.println("'" + txt.SegmentText + "'"); + res &= txt.SegmentText.equals(text.substring(2, 3)); + } + if (chCount > 2) { + System.out.println("getTextBehindIndex(chCount-2," + + " AccessibleTextType.CHARACTER):"); + TextSegment txt = oObj.getTextBehindIndex(chCount - 2, + AccessibleTextType.CHARACTER); + System.out.println("'" + txt.SegmentText + "'"); + res &= txt.SegmentText.equals(text.substring(chCount - 1, chCount)); + } + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + System.out.println("Unexpected exception"); + e.printStackTrace(); + res &= false; + } catch(com.sun.star.lang.IllegalArgumentException e) { + System.out.println("Unexpected exception"); + res &= false; + } + + + return res; + } + + /** + * Calls the method with invalid parameters and with valid parameter, + * checks returned values. + * Has OK status if exception was thrown for invalid parameters, + * if exception wasn't thrown for valid parameter and if returned value for + * valid parameter is equal to true. + */ + public boolean _copyText() { + boolean res = true; + boolean locRes = true; + + if (editOnly != null) { + System.out.println(editOnly); + return true; + } + + try { + System.out.println("copyText(-1,chCount):"); + oObj.copyText(-1, chCount); + System.out.println("Exception was expected"); + res &= false; + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + System.out.println("Expected exception"); + res &= true; + } + + try { + System.out.println("copyText(0,chCount+1):"); + oObj.copyText(0, chCount + 1); + System.out.println("Exception was expected"); + res &= false; + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + System.out.println("Expected exception"); + res &= true; + } + + try { + System.out.println("copyText(0,chCount):"); + locRes = oObj.copyText(0, chCount); + System.out.println(locRes); + res &= locRes; + + String cbText = null; + try { + cbText = + util.SysUtils.getSysClipboardText(xMSF); + } catch (com.sun.star.uno.Exception e) { + System.out.println("Couldn't access system clipboard :"); + e.printStackTrace(); + } + System.out.println("Clipboard: '" + cbText + "'"); + res &= text.equals(cbText); + + if (chCount > 2) { + System.out.println("copyText(1,chCount-1):"); + locRes = oObj.copyText(1, chCount - 1); + System.out.println(locRes); + res &= locRes; + + try { + cbText = util.SysUtils.getSysClipboardText(xMSF); + } catch (com.sun.star.uno.Exception e) { + System.out.println("Couldn't access system clipboard :"); + e.printStackTrace(); + } + + System.out.println("Clipboard: '" + cbText + "'"); + res &= text.substring(1, chCount - 1).equals(cbText); + } + + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + System.out.println("Unexpected exception"); + e.printStackTrace(); + res &= false; + } + + return res; + } +} diff --git a/toolkit/qa/complex/toolkit/awtgrid/DummyColumn.java b/toolkit/qa/complex/toolkit/awtgrid/DummyColumn.java new file mode 100644 index 000000000..d86df3f1c --- /dev/null +++ b/toolkit/qa/complex/toolkit/awtgrid/DummyColumn.java @@ -0,0 +1,167 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package complex.toolkit.awtgrid; + +import com.sun.star.awt.grid.XGridColumn; +import com.sun.star.awt.grid.XGridColumnListener; +import com.sun.star.lang.IllegalArgumentException; +import com.sun.star.lang.XEventListener; +import com.sun.star.style.HorizontalAlignment; +import com.sun.star.util.XCloneable; + +/** + * a dummy implementation of css.awt.grid.XGridColumn + */ +public class DummyColumn implements XGridColumn +{ + public Object getIdentifier() + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public void setIdentifier( Object o ) + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public int getColumnWidth() + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public void setColumnWidth( int i ) + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public int getMinWidth() + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public void setMinWidth( int i ) + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public int getMaxWidth() + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public void setMaxWidth( int i ) + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public boolean getResizeable() + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public void setResizeable( boolean bln ) + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public int getFlexibility() + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public void setFlexibility( int i ) throws IllegalArgumentException + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public HorizontalAlignment getHorizontalAlign() + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public void setHorizontalAlign( HorizontalAlignment ha ) + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public String getTitle() + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public void setTitle( String string ) + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public String getHelpText() + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public void setHelpText( String string ) + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public int getIndex() + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public int getDataColumnIndex() + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public void setDataColumnIndex( int i ) + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public void addGridColumnListener( XGridColumnListener xl ) + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public void removeGridColumnListener( XGridColumnListener xl ) + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public void dispose() + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public void addEventListener( XEventListener xl ) + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public void removeEventListener( XEventListener xl ) + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public XCloneable createClone() + { + throw new UnsupportedOperationException( "Not supported yet." ); + } +} diff --git a/toolkit/qa/complex/toolkit/awtgrid/GridDataListener.java b/toolkit/qa/complex/toolkit/awtgrid/GridDataListener.java new file mode 100644 index 000000000..800727bb3 --- /dev/null +++ b/toolkit/qa/complex/toolkit/awtgrid/GridDataListener.java @@ -0,0 +1,107 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package complex.toolkit.awtgrid; + +import com.sun.star.awt.grid.GridDataEvent; +import com.sun.star.awt.grid.XGridDataListener; +import com.sun.star.lang.EventObject; +import static org.junit.Assert.*; + +final public class GridDataListener implements XGridDataListener +{ + public void rowsInserted( GridDataEvent i_event ) + { + assertNull( m_rowInsertionEvent ); + m_rowInsertionEvent = i_event; + } + + public void rowsRemoved( GridDataEvent i_event ) + { + assertNull( m_rowRemovalEvent ); + m_rowRemovalEvent = i_event; + } + + public void dataChanged( GridDataEvent i_event ) + { + assertNull( m_dataChangeEvent ); + m_dataChangeEvent = i_event; + } + + public void rowHeadingChanged( GridDataEvent i_event ) + { + assertNull( m_rowHeadingChangeEvent ); + m_rowHeadingChangeEvent = i_event; + } + + public void disposing( EventObject eo ) + { + m_disposed = true; + } + + public final GridDataEvent assertSingleRowInsertionEvent() + { + assertNotNull( m_rowInsertionEvent ); + assertNull( m_rowRemovalEvent ); + assertNull( m_dataChangeEvent ); + assertNull( m_rowHeadingChangeEvent ); + assertFalse( m_disposed ); + return m_rowInsertionEvent; + } + + public final GridDataEvent assertSingleRowRemovalEvent() + { + assertNull( m_rowInsertionEvent ); + assertNotNull( m_rowRemovalEvent ); + assertNull( m_dataChangeEvent ); + assertNull( m_rowHeadingChangeEvent ); + assertFalse( m_disposed ); + return m_rowRemovalEvent; + } + + public final GridDataEvent assertSingleDataChangeEvent() + { + assertNull( m_rowInsertionEvent ); + assertNull( m_rowRemovalEvent ); + assertNotNull( m_dataChangeEvent ); + assertNull( m_rowHeadingChangeEvent ); + assertFalse( m_disposed ); + return m_dataChangeEvent; + } + + public final GridDataEvent assertSingleRowHeadingChangeEvent() + { + assertNull( m_rowInsertionEvent ); + assertNull( m_rowRemovalEvent ); + assertNull( m_dataChangeEvent ); + assertNotNull( m_rowHeadingChangeEvent ); + assertFalse( m_disposed ); + return m_rowHeadingChangeEvent; + } + + public final void reset() + { + m_rowInsertionEvent = m_rowRemovalEvent = m_dataChangeEvent = m_rowHeadingChangeEvent = null; + // m_disposed is not reset intentionally + } + private GridDataEvent m_rowInsertionEvent = null; + private GridDataEvent m_rowRemovalEvent = null; + private GridDataEvent m_dataChangeEvent = null; + private GridDataEvent m_rowHeadingChangeEvent = null; + private boolean m_disposed = false; +} diff --git a/toolkit/qa/complex/toolkit/awtgrid/TMutableGridDataModel.java b/toolkit/qa/complex/toolkit/awtgrid/TMutableGridDataModel.java new file mode 100644 index 000000000..1623af8b6 --- /dev/null +++ b/toolkit/qa/complex/toolkit/awtgrid/TMutableGridDataModel.java @@ -0,0 +1,449 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package complex.toolkit.awtgrid; + +import com.sun.star.awt.grid.GridDataEvent; +import com.sun.star.awt.grid.XMutableGridDataModel; +import com.sun.star.lang.IllegalArgumentException; +import com.sun.star.lang.IndexOutOfBoundsException; +import static org.junit.Assert.*; +import static complex.toolkit.Assert.*; + +/** test for the css.awt.grid.XMutableGridData interface + * + */ +public class TMutableGridDataModel +{ + public TMutableGridDataModel( final XMutableGridDataModel i_dataModel ) + { + m_dataModel = i_dataModel; + + m_listener = new GridDataListener(); + m_dataModel.addGridDataListener( m_listener ); + } + + /* + * tests the XMutableGridDataModel.addRow method + */ + public void testAddRow() throws IndexOutOfBoundsException + { + m_dataModel.addRow( m_rowHeadings[0], m_rowValues[0] ); + GridDataEvent event = m_listener.assertSingleRowInsertionEvent(); + m_listener.reset(); + assertEquals( "row insertion: wrong FirstRow (1)", 0, event.FirstRow ); + assertEquals( "row insertion: wrong LastRow (1)", 0, event.LastRow ); + impl_assertRowData( 0 ); + + m_dataModel.addRow( m_rowHeadings[1], m_rowValues[1] ); + event = m_listener.assertSingleRowInsertionEvent(); + m_listener.reset(); + assertEquals( "row insertion: wrong FirstRow (2)", 1, event.FirstRow ); + assertEquals( "row insertion: wrong LastRow (2)", 1, event.LastRow ); + impl_assertRowData( 1 ); + } + + /** + * tests the XMutableGridDataModel.addRows method + */ + public void testAddRows() throws IndexOutOfBoundsException, IllegalArgumentException + { + assertEquals( "precondition not met: call this directly after testAddRow, please!", 2, m_dataModel.getRowCount() ); + + m_dataModel.addRows( + new Object[] { m_rowHeadings[2], m_rowHeadings[3], m_rowHeadings[4] }, + new Object[][] { m_rowValues[2], m_rowValues[3], m_rowValues[4] } ); + GridDataEvent event = m_listener.assertSingleRowInsertionEvent(); + assertEquals( "row insertion: wrong FirstRow (1)", 2, event.FirstRow ); + assertEquals( "row insertion: wrong LastRow (1)", 4, event.LastRow ); + m_listener.reset(); + + assertEquals( "data model's row count is not adjusted when adding rows", m_rowValues.length, m_dataModel.getRowCount() ); + assertEquals( "data model's column count is not adjusted when adding rows", m_rowValues[0].length, m_dataModel.getColumnCount() ); + for ( int row=0; row rowCount is expected to throw", + m_dataModel, "insertRow", + new Class[] { Integer.class, Object.class, Object[].class }, + new Object[] { expectedRowCount + 1, "", new Object[] { "1", 2, 3 } }, + IndexOutOfBoundsException.class ); + assertException( "inserting a row at a position < 0 is expected to throw", + m_dataModel, "insertRow", + new Class[] { Integer.class, Object.class, Object[].class }, + new Object[] { -1, "", new Object[] { "1", 2, 3 } }, + IndexOutOfBoundsException.class ); + + // remove the row, to create the situation expected by the next test + m_dataModel.removeRow( insertionPos ); + m_listener.reset(); + } + + /** + * tests the XMutableGridDataModel.insertRows method + */ + public void testInsertRows() throws IndexOutOfBoundsException, IllegalArgumentException + { + int expectedRowCount = m_rowValues.length; + assertEquals( "precondition not met: call this directly after testInsertRow, please!", expectedRowCount, m_dataModel.getRowCount() ); + + // inserting some rows somewhere between the other rows + final int insertionPos = 3; + final Object[] rowHeadings = new Object[] { "A", "B", "C" }; + final Object[][] rowData = new Object[][] { + new Object[] { "A", "B", "C", "D", "E" }, + new Object[] { "J", "I", "H", "G", "F" }, + new Object[] { "K", "L", "M", "N", "O" } + }; + final int insertedRowCount = rowData.length; + assertEquals( "invalid test data", rowHeadings.length, insertedRowCount ); + + m_dataModel.insertRows( insertionPos, rowHeadings, rowData ); + expectedRowCount += insertedRowCount; + + final GridDataEvent event = m_listener.assertSingleRowInsertionEvent(); + assertEquals( "inserting multiple rows results in wrong FirstRow being notified", + insertionPos, event.FirstRow ); + assertEquals( "inserting multiple rows results in wrong LastRow being notified", + insertionPos + insertedRowCount - 1, event.LastRow ); + m_listener.reset(); + + for ( int row=0; row= insertionPos ) && ( row < insertionPos + insertedRowCount ) + ? rowData[ row - insertionPos ] + : m_rowValues[ row - insertedRowCount ]; + assertArrayEquals( "row number " + row + " has wrong content after inserting multiple rows", + expectedRowData, actualRowData ); + + final Object actualHeading = m_dataModel.getRowHeading(row); + final Object expectedHeading = + ( row < insertionPos ) + ? m_rowHeadings[ row ] + : ( row >= insertionPos ) && ( row < insertionPos + insertedRowCount ) + ? rowHeadings[ row - insertionPos ] + : m_rowHeadings[ row - insertedRowCount ]; + assertEquals( "row " + row + " has a wrong heading after invoking insertRows", + expectedHeading, actualHeading ); + } + + // exceptions + assertException( "inserting multiple rows at a position > rowCount is expected to throw an IndexOutOfBoundsException", + m_dataModel, "insertRows", + new Class[] { Integer.class, Object[].class, Object[][].class }, + new Object[] { expectedRowCount + 1, new Object[0], new Object[][] { } }, + IndexOutOfBoundsException.class ); + assertException( "inserting multiple rows at a position < 0 is expected to throw an IndexOutOfBoundsException", + m_dataModel, "insertRows", + new Class[] { Integer.class, Object[].class, Object[][].class }, + new Object[] { -1, new Object[0], new Object[][] { } }, + IndexOutOfBoundsException.class ); + assertException( "inserting multiple rows with inconsistent array lengths is expected to throw an IllegalArgumentException", + m_dataModel, "insertRows", + new Class[] { Integer.class, Object[].class, Object[][].class }, + new Object[] { 0, new Object[0], new Object[][] { new Object[0] } }, + IllegalArgumentException.class ); + + // remove the row, to create the situation expected by the next test + for ( int i=0; i +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +using namespace css; + +namespace +{ +/// Test dialogs constructed via UNO +class DialogTest : public test::BootstrapFixture, public unotest::MacrosTest +{ +protected: + uno::Reference mxContext; + +public: + virtual void setUp() override; +}; + +void DialogTest::setUp() +{ + test::BootstrapFixture::setUp(); + + mxContext.set(comphelper::getComponentContext(getMultiServiceFactory())); +} + +CPPUNIT_TEST_FIXTURE(DialogTest, testDialogSizeable) +{ + uno::Reference xDialog; + uno::Reference xFactory(mxContext->getServiceManager(), + uno::UNO_SET_THROW); + uno::Reference xControlModel( + xFactory->createInstanceWithContext("com.sun.star.awt.UnoControlDialogModel", mxContext), + uno::UNO_QUERY_THROW); + + uno::Reference xPropSet(xControlModel, uno::UNO_QUERY_THROW); + xPropSet->setPropertyValue("Sizeable", uno::Any(true)); + + uno::Reference xControl = awt::UnoControlDialog::create(mxContext); + xControl->setModel(xControlModel); + xControl->setVisible(true); + xDialog.set(xControl, uno::UNO_QUERY_THROW); + xDialog->execute(); + + VclPtr pWindow = VCLUnoHelper::GetWindow(xControl->getPeer()); + CPPUNIT_ASSERT(pWindow); + CPPUNIT_ASSERT(pWindow->GetStyle() & WB_SIZEABLE); + + xDialog->endExecute(); + css::uno::Reference(xDialog, css::uno::UNO_QUERY_THROW)->dispose(); + css::uno::Reference(xControlModel, css::uno::UNO_QUERY_THROW)->dispose(); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/qa/cppunit/EventContainer.cxx b/toolkit/qa/cppunit/EventContainer.cxx new file mode 100644 index 000000000..ad62f9310 --- /dev/null +++ b/toolkit/qa/cppunit/EventContainer.cxx @@ -0,0 +1,84 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +using namespace css; +using namespace css::awt; +using namespace css::container; +using namespace css::lang; +using namespace css::script; +using namespace css::uno; + +namespace +{ +/// Test EventContainer class +class EventContainerTest : public test::BootstrapFixture +{ +protected: + Reference mxContext; + +public: + virtual void setUp() override; +}; + +void EventContainerTest::setUp() +{ + test::BootstrapFixture::setUp(); + + mxContext.set(comphelper::getComponentContext(getMultiServiceFactory())); +} + +// Make sure that EventContainer keeps insertion order, and does not reorder its elements. +// Otherwise this would break macro signatures. +CPPUNIT_TEST_FIXTURE(EventContainerTest, testInsertOrder) +{ + Reference xFactory(mxContext->getServiceManager(), UNO_SET_THROW); + Reference xControlModel( + xFactory->createInstanceWithContext("com.sun.star.awt.UnoControlDialogModel", mxContext), + UNO_QUERY_THROW); + + Reference xPropSet(xControlModel, UNO_QUERY_THROW); + + Reference xEventsSupplier(xPropSet, UNO_QUERY_THROW); + Reference xEvents(xEventsSupplier->getEvents(), UNO_SET_THROW); + script::ScriptEventDescriptor descr1; + script::ScriptEventDescriptor descr2; + script::ScriptEventDescriptor descr3; + script::ScriptEventDescriptor descr4; + xEvents->insertByName("b", Any(descr1)); + xEvents->insertByName("a", Any(descr2)); + xEvents->insertByName("1", Any(descr3)); + xEvents->insertByName("A", Any(descr4)); + + Sequence aEventNames(xEvents->getElementNames()); + sal_Int32 nEventCount = aEventNames.getLength(); + CPPUNIT_ASSERT_EQUAL(static_cast(4), nEventCount); + + CPPUNIT_ASSERT_EQUAL(OUString("b"), aEventNames[0]); + CPPUNIT_ASSERT_EQUAL(OUString("a"), aEventNames[1]); + CPPUNIT_ASSERT_EQUAL(OUString("1"), aEventNames[2]); + CPPUNIT_ASSERT_EQUAL(OUString("A"), aEventNames[3]); + + css::uno::Reference(xControlModel, css::uno::UNO_QUERY_THROW)->dispose(); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/qa/cppunit/UnitConversion.cxx b/toolkit/qa/cppunit/UnitConversion.cxx new file mode 100644 index 000000000..5e28667f5 --- /dev/null +++ b/toolkit/qa/cppunit/UnitConversion.cxx @@ -0,0 +1,215 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef _WIN32 +#include +#endif + +using namespace ::com::sun::star; + +namespace +{ +class ToolkitTest : public test::BootstrapFixture +{ +public: + void testXUnitConversion(); + + CPPUNIT_TEST_SUITE(ToolkitTest); + CPPUNIT_TEST(testXUnitConversion); + CPPUNIT_TEST_SUITE_END(); +}; + +/** + * Creates a floating XWindow on the given position and size. + * @return a floating XWindow + * @param X the X-Position of the floating XWindow + * @param Y the Y-Position of the floating XWindow + * @param width the width of the floating XWindow + * @param height the height of the floating XWindow + * @param xMSF the MultiServiceFactory + */ +uno::Reference +createFloatingWindow(uno::Reference const& xMSF, sal_Int32 const nX, + sal_Int32 const nY, sal_Int32 const nWidth, sal_Int32 const nHeight) +{ + uno::Reference const xTk(xMSF->createInstance("com.sun.star.awt.Toolkit"), + uno::UNO_QUERY); + + awt::WindowDescriptor descriptor; + descriptor.Type = awt::WindowClass_TOP; + descriptor.WindowServiceName = "modelessdialog"; + descriptor.ParentIndex = -1; + descriptor.Bounds.X = nX; + descriptor.Bounds.Y = nY; + descriptor.Bounds.Width = nWidth; + descriptor.Bounds.Height = nHeight; + descriptor.WindowAttributes + = (awt::WindowAttribute::BORDER + awt::WindowAttribute::MOVEABLE + + awt::WindowAttribute::SIZEABLE + awt::WindowAttribute::CLOSEABLE + + awt::VclWindowPeerAttribute::CLIPCHILDREN); + + return xTk->createWindow(descriptor); +} + +/** + * Not really a check, + * only a simple test call to convertSizeToLogic(...) with different parameters + */ +void checkSize(uno::Reference const& xConv, awt::Size const& rSize, + sal_Int16 const nMeasureUnit, OUString const& rUnit) +{ + awt::Size const aSizeIn = xConv->convertSizeToLogic(rSize, nMeasureUnit); + std::cerr << "Window size:\n"; + std::cerr << "Width: " << aSizeIn.Width << " " << rUnit << "\n"; + std::cerr << "Height: " << aSizeIn.Height << " " << rUnit << "\n"; +} + +/** + * The real test function + * 2. try to create an empty window + * 3. try to convert the WindowPeer to an XWindow + * 4. try to resize and move the window to another position, so we get a well knowing position and size. + * 5. run some more tests + */ +void ToolkitTest::testXUnitConversion() +{ +#ifdef _WIN32 + HKEY hkey; + DWORD type; + DWORD data; + DWORD size(sizeof(data)); + LONG ret = ::RegOpenKeyW(HKEY_CURRENT_USER, L"Control Panel\\Desktop", &hkey); + if (ret == ERROR_SUCCESS) + { + ret = ::RegQueryValueExW(hkey, L"LogPixels", nullptr, &type, + reinterpret_cast(&data), &size); + if (ret == ERROR_SUCCESS && type == REG_DWORD && data != 96) + { + std::cerr << "non-default resolution, skipping textXUnitConversion\n"; + return; + } + } +#endif + + // create a window + sal_Int32 x = 100; + sal_Int32 y = 100; + sal_Int32 width = 640; + sal_Int32 height = 480; + uno::Reference const xWindowPeer + = createFloatingWindow(getMultiServiceFactory(), x, y, width, height); + CPPUNIT_ASSERT(xWindowPeer.is()); + + // resize and move the window to a well known position and size + uno::Reference const xWindow(xWindowPeer, uno::UNO_QUERY); + CPPUNIT_ASSERT(xWindow.is()); + + xWindow->setVisible(true); + + awt::Rectangle aRect = xWindow->getPosSize(); + awt::Point aPoint(aRect.X, aRect.Y); + awt::Size aSize(aRect.Width, aRect.Height); + + std::cerr << "Window position and size in pixel:\n"; + std::cerr << "X: " << aPoint.X << "\n"; + std::cerr << "Y: " << aPoint.Y << "\n"; + std::cerr << "Width: " << aSize.Width << "\n"; + std::cerr << "Height: " << aSize.Height << "\n"; + + CPPUNIT_ASSERT_EQUAL_MESSAGE("Window size wrong", width, aSize.Width); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Window size wrong", height, aSize.Height); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Window pos wrong", x, aPoint.X); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Window pos wrong", y, aPoint.Y); + + uno::Reference const xConv(xWindowPeer, uno::UNO_QUERY); + + // try to get the position of the window in 1/100mm with the XUnitConversion method + awt::Point const aPointInMM_100TH + = xConv->convertPointToLogic(aPoint, util::MeasureUnit::MM_100TH); + std::cerr << "Window position:\n"; + std::cerr << "X: " << aPointInMM_100TH.X << " 1/100mm\n"; + std::cerr << "Y: " << aPointInMM_100TH.Y << " 1/100mm\n"; + + // try to get the size of the window in 1/100mm with the XUnitConversion method + awt::Size const aSizeInMM_100TH = xConv->convertSizeToLogic(aSize, util::MeasureUnit::MM_100TH); + std::cerr << "Window size:\n"; + std::cerr << "Width: " << aSizeInMM_100TH.Width << " 1/100mm\n"; + std::cerr << "Height: " << aSizeInMM_100TH.Height << " 1/100mm\n"; + + // try to get the size of the window in 1/10mm with the XUnitConversion method + awt::Size const aSizeInMM_10TH = xConv->convertSizeToLogic(aSize, util::MeasureUnit::MM_10TH); + std::cerr << "Window size:\n"; + std::cerr << "Width: " << aSizeInMM_10TH.Width << " 1/10mm\n"; + std::cerr << "Height: " << aSizeInMM_10TH.Height << " 1/10mm\n"; + + // check the size with a delta which must be smaller a given difference + CPPUNIT_ASSERT_MESSAGE("Size.Width not correct", + std::abs(aSizeInMM_100TH.Width - aSizeInMM_10TH.Width * 10) < 10); + CPPUNIT_ASSERT_MESSAGE("Size.Height not correct", + std::abs(aSizeInMM_100TH.Height - aSizeInMM_10TH.Height * 10) < 10); + + // new + checkSize(xConv, aSize, util::MeasureUnit::PIXEL, "pixel"); + checkSize(xConv, aSize, util::MeasureUnit::APPFONT, "appfont"); + checkSize(xConv, aSize, util::MeasureUnit::SYSFONT, "sysfont"); + + // simply check some more parameters + checkSize(xConv, aSize, util::MeasureUnit::MM, "mm"); + checkSize(xConv, aSize, util::MeasureUnit::CM, "cm"); + checkSize(xConv, aSize, util::MeasureUnit::INCH_1000TH, "1/1000inch"); + checkSize(xConv, aSize, util::MeasureUnit::INCH_100TH, "1/100inch"); + checkSize(xConv, aSize, util::MeasureUnit::INCH_10TH, "1/10inch"); + checkSize(xConv, aSize, util::MeasureUnit::INCH, "inch"); + checkSize(xConv, aSize, util::MeasureUnit::POINT, "point"); + checkSize(xConv, aSize, util::MeasureUnit::TWIP, "twip"); + + // convert the 1/100mm window size back to pixel + awt::Size const aNewSize + = xConv->convertSizeToPixel(aSizeInMM_100TH, util::MeasureUnit::MM_100TH); + std::cerr << "Window size:\n"; + std::cerr << "Width: " << aNewSize.Width << " pixel\n"; + std::cerr << "Height: " << aNewSize.Height << " pixel\n"; + + // assure the pixels are the same as we already know + CPPUNIT_ASSERT_EQUAL_MESSAGE("failed: Size from pixel to 1/100mm to pixel", aNewSize.Width, + aSize.Width); + CPPUNIT_ASSERT_EQUAL_MESSAGE("failed: Size from pixel to 1/100mm to pixel", aNewSize.Height, + aSize.Height); + + // close the window. + xWindow->dispose(); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(ToolkitTest); +} + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/toolkit/qa/cppunit/a11y/AccessibilityTools.cxx b/toolkit/qa/cppunit/a11y/AccessibilityTools.cxx new file mode 100644 index 000000000..572f82e62 --- /dev/null +++ b/toolkit/qa/cppunit/a11y/AccessibilityTools.cxx @@ -0,0 +1,515 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "AccessibilityTools.hxx" + +#include +#include +#include +#include +#include + +#include +#include +#include + +using namespace css; + +/* FIXME: mostly copied from sw/qa/extras/accessibility/accessible_relation_set.cxx */ +css::uno::Reference +AccessibilityTools::getAccessibleObjectForRole( + const css::uno::Reference& xacc, sal_Int16 role) +{ + css::uno::Reference ac = xacc->getAccessibleContext(); + bool isShowing + = ac->getAccessibleStateSet()->contains(accessibility::AccessibleStateType::SHOWING); + + if ((ac->getAccessibleRole() == role) && isShowing) + { + return ac; + } + else + { + int count = ac->getAccessibleChildCount(); + + for (int i = 0; i < count && i < AccessibilityTools::MAX_CHILDREN; i++) + { + css::uno::Reference ac2 + = AccessibilityTools::getAccessibleObjectForRole(ac->getAccessibleChild(i), role); + if (ac2.is()) + return ac2; + } + } + return nullptr; +} +/* FIXME: end copy */ + +bool AccessibilityTools::equals(const uno::Reference& xacc1, + const uno::Reference& xacc2) +{ + if (!xacc1.is() || !xacc2.is()) + return xacc1.is() == xacc2.is(); + return equals(xacc1->getAccessibleContext(), xacc2->getAccessibleContext()); +} + +bool AccessibilityTools::equals(const uno::Reference& xctx1, + const uno::Reference& xctx2) +{ + if (!xctx1.is() || !xctx2.is()) + return xctx1.is() == xctx2.is(); + + if (xctx1->getAccessibleRole() != xctx2->getAccessibleRole()) + return false; + + if (xctx1->getAccessibleName() != xctx2->getAccessibleName()) + return false; + + if (xctx1->getAccessibleDescription() != xctx2->getAccessibleDescription()) + return false; + + if (xctx1->getAccessibleChildCount() != xctx2->getAccessibleChildCount()) + return false; + + /* this one was not in the Java version */ + if (xctx1->getAccessibleIndexInParent() != xctx2->getAccessibleIndexInParent()) + return false; + + return equals(xctx1->getAccessibleParent(), xctx2->getAccessibleParent()); +} + +bool AccessibilityTools::equals(const uno::Reference& xsts1, + const uno::Reference& xsts2) +{ + if (!xsts1.is() || !xsts2.is()) + return xsts1.is() == xsts2.is(); + return xsts1->getStates() == xsts2->getStates(); +} + +OUString AccessibilityTools::getRoleName(const sal_Int16 role) +{ + switch (role) + { + case accessibility::AccessibleRole::UNKNOWN: + return "UNKNOWN"; + case accessibility::AccessibleRole::ALERT: + return "ALERT"; + case accessibility::AccessibleRole::BUTTON_DROPDOWN: + return "BUTTON_DROPDOWN"; + case accessibility::AccessibleRole::BUTTON_MENU: + return "BUTTON_MENU"; + case accessibility::AccessibleRole::CANVAS: + return "CANVAS"; + case accessibility::AccessibleRole::CAPTION: + return "CAPTION"; + case accessibility::AccessibleRole::CHART: + return "CHART"; + case accessibility::AccessibleRole::CHECK_BOX: + return "CHECK_BOX"; + case accessibility::AccessibleRole::CHECK_MENU_ITEM: + return "CHECK_MENU_ITEM"; + case accessibility::AccessibleRole::COLOR_CHOOSER: + return "COLOR_CHOOSER"; + case accessibility::AccessibleRole::COLUMN_HEADER: + return "COLUMN_HEADER"; + case accessibility::AccessibleRole::COMBO_BOX: + return "COMBO_BOX"; + case accessibility::AccessibleRole::COMMENT: + return "COMMENT"; + case accessibility::AccessibleRole::COMMENT_END: + return "COMMENT_END"; + case accessibility::AccessibleRole::DATE_EDITOR: + return "DATE_EDITOR"; + case accessibility::AccessibleRole::DESKTOP_ICON: + return "DESKTOP_ICON"; + case accessibility::AccessibleRole::DESKTOP_PANE: + return "DESKTOP_PANE"; + case accessibility::AccessibleRole::DIALOG: + return "DIALOG"; + case accessibility::AccessibleRole::DIRECTORY_PANE: + return "DIRECTORY_PANE"; + case accessibility::AccessibleRole::DOCUMENT: + return "DOCUMENT"; + case accessibility::AccessibleRole::DOCUMENT_PRESENTATION: + return "DOCUMENT_PRESENTATION"; + case accessibility::AccessibleRole::DOCUMENT_SPREADSHEET: + return "DOCUMENT_SPREADSHEET"; + case accessibility::AccessibleRole::DOCUMENT_TEXT: + return "DOCUMENT_TEXT"; + case accessibility::AccessibleRole::EDIT_BAR: + return "EDIT_BAR"; + case accessibility::AccessibleRole::EMBEDDED_OBJECT: + return "EMBEDDED_OBJECT"; + case accessibility::AccessibleRole::END_NOTE: + return "END_NOTE"; + case accessibility::AccessibleRole::FILE_CHOOSER: + return "FILE_CHOOSER"; + case accessibility::AccessibleRole::FILLER: + return "FILLER"; + case accessibility::AccessibleRole::FONT_CHOOSER: + return "FONT_CHOOSER"; + case accessibility::AccessibleRole::FOOTER: + return "FOOTER"; + case accessibility::AccessibleRole::FOOTNOTE: + return "FOOTNOTE"; + case accessibility::AccessibleRole::FORM: + return "FORM"; + case accessibility::AccessibleRole::FRAME: + return "FRAME"; + case accessibility::AccessibleRole::GLASS_PANE: + return "GLASS_PANE"; + case accessibility::AccessibleRole::GRAPHIC: + return "GRAPHIC"; + case accessibility::AccessibleRole::GROUP_BOX: + return "GROUP_BOX"; + case accessibility::AccessibleRole::HEADER: + return "HEADER"; + case accessibility::AccessibleRole::HEADING: + return "HEADING"; + case accessibility::AccessibleRole::HYPER_LINK: + return "HYPER_LINK"; + case accessibility::AccessibleRole::ICON: + return "ICON"; + case accessibility::AccessibleRole::IMAGE_MAP: + return "IMAGE_MAP"; + case accessibility::AccessibleRole::INTERNAL_FRAME: + return "INTERNAL_FRAME"; + case accessibility::AccessibleRole::LABEL: + return "LABEL"; + case accessibility::AccessibleRole::LAYERED_PANE: + return "LAYERED_PANE"; + case accessibility::AccessibleRole::LIST: + return "LIST"; + case accessibility::AccessibleRole::LIST_ITEM: + return "LIST_ITEM"; + case accessibility::AccessibleRole::MENU: + return "MENU"; + case accessibility::AccessibleRole::MENU_BAR: + return "MENU_BAR"; + case accessibility::AccessibleRole::MENU_ITEM: + return "MENU_ITEM"; + case accessibility::AccessibleRole::NOTE: + return "NOTE"; + case accessibility::AccessibleRole::OPTION_PANE: + return "OPTION_PANE"; + case accessibility::AccessibleRole::PAGE: + return "PAGE"; + case accessibility::AccessibleRole::PAGE_TAB: + return "PAGE_TAB"; + case accessibility::AccessibleRole::PAGE_TAB_LIST: + return "PAGE_TAB_LIST"; + case accessibility::AccessibleRole::PANEL: + return "PANEL"; + case accessibility::AccessibleRole::PARAGRAPH: + return "PARAGRAPH"; + case accessibility::AccessibleRole::PASSWORD_TEXT: + return "PASSWORD_TEXT"; + case accessibility::AccessibleRole::POPUP_MENU: + return "POPUP_MENU"; + case accessibility::AccessibleRole::PROGRESS_BAR: + return "PROGRESS_BAR"; + case accessibility::AccessibleRole::PUSH_BUTTON: + return "PUSH_BUTTON"; + case accessibility::AccessibleRole::RADIO_BUTTON: + return "RADIO_BUTTON"; + case accessibility::AccessibleRole::RADIO_MENU_ITEM: + return "RADIO_MENU_ITEM"; + case accessibility::AccessibleRole::ROOT_PANE: + return "ROOT_PANE"; + case accessibility::AccessibleRole::ROW_HEADER: + return "ROW_HEADER"; + case accessibility::AccessibleRole::RULER: + return "RULER"; + case accessibility::AccessibleRole::SCROLL_BAR: + return "SCROLL_BAR"; + case accessibility::AccessibleRole::SCROLL_PANE: + return "SCROLL_PANE"; + case accessibility::AccessibleRole::SECTION: + return "SECTION"; + case accessibility::AccessibleRole::SEPARATOR: + return "SEPARATOR"; + case accessibility::AccessibleRole::SHAPE: + return "SHAPE"; + case accessibility::AccessibleRole::SLIDER: + return "SLIDER"; + case accessibility::AccessibleRole::SPIN_BOX: + return "SPIN_BOX"; + case accessibility::AccessibleRole::SPLIT_PANE: + return "SPLIT_PANE"; + case accessibility::AccessibleRole::STATIC: + return "STATIC"; + case accessibility::AccessibleRole::STATUS_BAR: + return "STATUS_BAR"; + case accessibility::AccessibleRole::TABLE: + return "TABLE"; + case accessibility::AccessibleRole::TABLE_CELL: + return "TABLE_CELL"; + case accessibility::AccessibleRole::TEXT: + return "TEXT"; + case accessibility::AccessibleRole::TEXT_FRAME: + return "TEXT_FRAME"; + case accessibility::AccessibleRole::TOGGLE_BUTTON: + return "TOGGLE_BUTTON"; + case accessibility::AccessibleRole::TOOL_BAR: + return "TOOL_BAR"; + case accessibility::AccessibleRole::TOOL_TIP: + return "TOOL_TIP"; + case accessibility::AccessibleRole::TREE: + return "TREE"; + case accessibility::AccessibleRole::TREE_ITEM: + return "TREE_ITEM"; + case accessibility::AccessibleRole::TREE_TABLE: + return "TREE_TABLE"; + case accessibility::AccessibleRole::VIEW_PORT: + return "VIEW_PORT"; + case accessibility::AccessibleRole::WINDOW: + return "WINDOW"; + }; + return "unknown"; +} + +OUString AccessibilityTools::getStateName(const sal_Int16 state) +{ + switch (state) + { + case accessibility::AccessibleStateType::ACTIVE: + return "ACTIVE"; + case accessibility::AccessibleStateType::ARMED: + return "ARMED"; + case accessibility::AccessibleStateType::BUSY: + return "BUSY"; + case accessibility::AccessibleStateType::CHECKED: + return "CHECKED"; + case accessibility::AccessibleStateType::COLLAPSE: + return "COLLAPSE"; + case accessibility::AccessibleStateType::DEFAULT: + return "DEFAULT"; + case accessibility::AccessibleStateType::DEFUNC: + return "DEFUNC"; + case accessibility::AccessibleStateType::EDITABLE: + return "EDITABLE"; + case accessibility::AccessibleStateType::ENABLED: + return "ENABLED"; + case accessibility::AccessibleStateType::EXPANDABLE: + return "EXPANDABLE"; + case accessibility::AccessibleStateType::EXPANDED: + return "EXPANDED"; + case accessibility::AccessibleStateType::FOCUSABLE: + return "FOCUSABLE"; + case accessibility::AccessibleStateType::FOCUSED: + return "FOCUSED"; + case accessibility::AccessibleStateType::HORIZONTAL: + return "HORIZONTAL"; + case accessibility::AccessibleStateType::ICONIFIED: + return "ICONIFIED"; + case accessibility::AccessibleStateType::INDETERMINATE: + return "INDETERMINATE"; + case accessibility::AccessibleStateType::INVALID: + return "INVALID"; + case accessibility::AccessibleStateType::MANAGES_DESCENDANTS: + return "MANAGES_DESCENDANTS"; + case accessibility::AccessibleStateType::MODAL: + return "MODAL"; + case accessibility::AccessibleStateType::MOVEABLE: + return "MOVEABLE"; + case accessibility::AccessibleStateType::MULTI_LINE: + return "MULTI_LINE"; + case accessibility::AccessibleStateType::MULTI_SELECTABLE: + return "MULTI_SELECTABLE"; + case accessibility::AccessibleStateType::OFFSCREEN: + return "OFFSCREEN"; + case accessibility::AccessibleStateType::OPAQUE: + return "OPAQUE"; + case accessibility::AccessibleStateType::PRESSED: + return "PRESSED"; + case accessibility::AccessibleStateType::RESIZABLE: + return "RESIZABLE"; + case accessibility::AccessibleStateType::SELECTABLE: + return "SELECTABLE"; + case accessibility::AccessibleStateType::SELECTED: + return "SELECTED"; + case accessibility::AccessibleStateType::SENSITIVE: + return "SENSITIVE"; + case accessibility::AccessibleStateType::SHOWING: + return "SHOWING"; + case accessibility::AccessibleStateType::SINGLE_LINE: + return "SINGLE_LINE"; + case accessibility::AccessibleStateType::STALE: + return "STALE"; + case accessibility::AccessibleStateType::TRANSIENT: + return "TRANSIENT"; + case accessibility::AccessibleStateType::VERTICAL: + return "VERTICAL"; + case accessibility::AccessibleStateType::VISIBLE: + return "VISIBLE"; + } + return "unknown"; +} + +OUString AccessibilityTools::getEventIdName(const sal_Int16 event_id) +{ + switch (event_id) + { + case accessibility::AccessibleEventId::ACTION_CHANGED: + return "ACTION_CHANGED"; + case accessibility::AccessibleEventId::ACTIVE_DESCENDANT_CHANGED: + return "ACTIVE_DESCENDANT_CHANGED"; + case accessibility::AccessibleEventId::ACTIVE_DESCENDANT_CHANGED_NOFOCUS: + return "ACTIVE_DESCENDANT_CHANGED_NOFOCUS"; + case accessibility::AccessibleEventId::BOUNDRECT_CHANGED: + return "BOUNDRECT_CHANGED"; + case accessibility::AccessibleEventId::CARET_CHANGED: + return "CARET_CHANGED"; + case accessibility::AccessibleEventId::CHILD: + return "CHILD"; + case accessibility::AccessibleEventId::COLUMN_CHANGED: + return "COLUMN_CHANGED"; + case accessibility::AccessibleEventId::CONTENT_FLOWS_FROM_RELATION_CHANGED: + return "CONTENT_FLOWS_FROM_RELATION_CHANGED"; + case accessibility::AccessibleEventId::CONTENT_FLOWS_TO_RELATION_CHANGED: + return "CONTENT_FLOWS_TO_RELATION_CHANGED"; + case accessibility::AccessibleEventId::CONTROLLED_BY_RELATION_CHANGED: + return "CONTROLLED_BY_RELATION_CHANGED"; + case accessibility::AccessibleEventId::CONTROLLER_FOR_RELATION_CHANGED: + return "CONTROLLER_FOR_RELATION_CHANGED"; + case accessibility::AccessibleEventId::DESCRIPTION_CHANGED: + return "DESCRIPTION_CHANGED"; + case accessibility::AccessibleEventId::HYPERTEXT_CHANGED: + return "HYPERTEXT_CHANGED"; + case accessibility::AccessibleEventId::INVALIDATE_ALL_CHILDREN: + return "INVALIDATE_ALL_CHILDREN"; + case accessibility::AccessibleEventId::LABELED_BY_RELATION_CHANGED: + return "LABELED_BY_RELATION_CHANGED"; + case accessibility::AccessibleEventId::LABEL_FOR_RELATION_CHANGED: + return "LABEL_FOR_RELATION_CHANGED"; + case accessibility::AccessibleEventId::LISTBOX_ENTRY_COLLAPSED: + return "LISTBOX_ENTRY_COLLAPSED"; + case accessibility::AccessibleEventId::LISTBOX_ENTRY_EXPANDED: + return "LISTBOX_ENTRY_EXPANDED"; + case accessibility::AccessibleEventId::MEMBER_OF_RELATION_CHANGED: + return "MEMBER_OF_RELATION_CHANGED"; + case accessibility::AccessibleEventId::NAME_CHANGED: + return "NAME_CHANGED"; + case accessibility::AccessibleEventId::PAGE_CHANGED: + return "PAGE_CHANGED"; + case accessibility::AccessibleEventId::ROLE_CHANGED: + return "ROLE_CHANGED"; + case accessibility::AccessibleEventId::SECTION_CHANGED: + return "SECTION_CHANGED"; + case accessibility::AccessibleEventId::SELECTION_CHANGED: + return "SELECTION_CHANGED"; + case accessibility::AccessibleEventId::SELECTION_CHANGED_ADD: + return "SELECTION_CHANGED_ADD"; + case accessibility::AccessibleEventId::SELECTION_CHANGED_REMOVE: + return "SELECTION_CHANGED_REMOVE"; + case accessibility::AccessibleEventId::SELECTION_CHANGED_WITHIN: + return "SELECTION_CHANGED_WITHIN"; + case accessibility::AccessibleEventId::STATE_CHANGED: + return "STATE_CHANGED"; + case accessibility::AccessibleEventId::SUB_WINDOW_OF_RELATION_CHANGED: + return "SUB_WINDOW_OF_RELATION_CHANGED"; + case accessibility::AccessibleEventId::TABLE_CAPTION_CHANGED: + return "TABLE_CAPTION_CHANGED"; + case accessibility::AccessibleEventId::TABLE_COLUMN_DESCRIPTION_CHANGED: + return "TABLE_COLUMN_DESCRIPTION_CHANGED"; + case accessibility::AccessibleEventId::TABLE_COLUMN_HEADER_CHANGED: + return "TABLE_COLUMN_HEADER_CHANGED"; + case accessibility::AccessibleEventId::TABLE_MODEL_CHANGED: + return "TABLE_MODEL_CHANGED"; + case accessibility::AccessibleEventId::TABLE_ROW_DESCRIPTION_CHANGED: + return "TABLE_ROW_DESCRIPTION_CHANGED"; + case accessibility::AccessibleEventId::TABLE_ROW_HEADER_CHANGED: + return "TABLE_ROW_HEADER_CHANGED"; + case accessibility::AccessibleEventId::TABLE_SUMMARY_CHANGED: + return "TABLE_SUMMARY_CHANGED"; + case accessibility::AccessibleEventId::TEXT_ATTRIBUTE_CHANGED: + return "TEXT_ATTRIBUTE_CHANGED"; + case accessibility::AccessibleEventId::TEXT_CHANGED: + return "TEXT_CHANGED"; + case accessibility::AccessibleEventId::TEXT_SELECTION_CHANGED: + return "TEXT_SELECTION_CHANGED"; + case accessibility::AccessibleEventId::VALUE_CHANGED: + return "VALUE_CHANGED"; + case accessibility::AccessibleEventId::VISIBLE_DATA_CHANGED: + return "VISIBLE_DATA_CHANGED"; + } + return "unknown"; +} + +OUString AccessibilityTools::debugName(accessibility::XAccessibleContext* ctx) +{ + return "role=" + AccessibilityTools::getRoleName(ctx->getAccessibleRole()) + " name=\"" + + ctx->getAccessibleName() + "\" description=\"" + ctx->getAccessibleDescription() + + "\""; +} + +OUString AccessibilityTools::debugName(accessibility::XAccessible* acc) +{ + return debugName(acc->getAccessibleContext().get()); +} + +OUString AccessibilityTools::debugName(accessibility::XAccessibleStateSet* xsts) +{ + OUString name; + + for (auto state : xsts->getStates()) + { + if (name.getLength()) + name += " | "; + name += AccessibilityTools::getStateName(state); + } + + return name; +} + +OUString AccessibilityTools::debugName(const accessibility::AccessibleEventObject* evobj) +{ + return "(AccessibleEventObject) { id=" + getEventIdName(evobj->EventId) + + " old=" + evobj->OldValue.getValueTypeName() + + " new=" + evobj->NewValue.getValueTypeName() + " }"; +} + +bool AccessibilityTools::Await(const std::function& cUntilCallback, sal_uInt64 nTimeoutMs) +{ + bool success = false; + Timer aTimer("wait for event"); + aTimer.SetTimeout(nTimeoutMs); + aTimer.Start(); + do + { + Scheduler::ProcessEventsToIdle(); + success = cUntilCallback(); + } while (!success && aTimer.IsActive()); + SAL_WARN_IF(!success, "test", "timeout reached"); + return success; +} + +void AccessibilityTools::Wait(sal_uInt64 nTimeoutMs) +{ + Timer aTimer("wait for event"); + aTimer.SetTimeout(nTimeoutMs); + aTimer.Start(); + std::cout << "waiting for " << nTimeoutMs << "ms... "; + do + { + Scheduler::ProcessEventsToIdle(); + } while (aTimer.IsActive()); + std::cout << "ok." << std::endl; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/toolkit/qa/cppunit/a11y/AccessibilityTools.hxx b/toolkit/qa/cppunit/a11y/AccessibilityTools.hxx new file mode 100644 index 000000000..a16338a85 --- /dev/null +++ b/toolkit/qa/cppunit/a11y/AccessibilityTools.hxx @@ -0,0 +1,158 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include + +#include + +#include +#include +#include +#include + +class AccessibilityTools +{ +public: + /** Maximum number of children to work on. This is especially useful for + * Calc which has a million elements, if not more. */ + static const sal_Int32 MAX_CHILDREN = 500; + + static css::uno::Reference + getAccessibleObjectForRole(const css::uno::Reference& xacc, + sal_Int16 role); + + static bool equals(const css::uno::Reference& xacc1, + const css::uno::Reference& xacc2); + static bool equals(const css::uno::Reference& xctx1, + const css::uno::Reference& xctx2); + static bool equals(const css::uno::Reference& xsts1, + const css::uno::Reference& xsts2); + + static OUString getRoleName(const sal_Int16 role); + static OUString getStateName(const sal_Int16 state); + static OUString getEventIdName(const sal_Int16 event_id); + + template static std::string debugString(const css::uno::Reference& x) + { + return debugString(x.get()); + } + + template static std::string debugString(const T& x) { return debugString(&x); } + + template static std::string debugString(const T* p) + { + /* only the forwarding to debugName() might actually dereference @c p, + * and we rely on specializations to be as constant as possible and not + * violate the cast here. In practice it'll be the case for all types + * handle if we carefully write the specializations. In most case the + * specialization could take a const itself if the methods were + * properly marked const, but well. */ + return debugString(const_cast(p)); + } + + template static std::string debugString(T* p) + { + CPPUNIT_NS::OStringStream ost; + + ost << "(" << static_cast(p) << ")"; + if (p != nullptr) + ost << " " << debugName(p); + + return ost.str(); + } + + /** + * @brief Process events until a condition or a timeout + * @param cUntilCallback Callback condition + * @param nTimeoutMs Maximum time in ms to wait for condition + * @returns @c true if the condition was met, or @c false if the timeout + * has been reached. + * + * Processes events until idle, and either until the given condition + * becomes @c true or a timeout is reached. + * + * This is similar to Scheduler::ProcessEventsToIdle() but awaits a + * condition up to a timeout. This is useful if the waited-on condition + * might happen after the first idle time. The timeout helps in case the + * condition is not satisfied in reasonable time. + * + * @p cUntilCallback is called each time the scheduler reaches idle to check + * whether the condition is met. + * + * Example: + * @code + * ProcessEvents([&]() { return taskHasRun; }); + * @endcode + * + * @see Scheduler::ProcessEventsToIdle() + */ + static bool Await(const std::function& cUntilCallback, sal_uInt64 nTimeoutMs = 3000); + + /** + * @brief Process events for a given time + * @param nTimeoutMs Time to dispatch events for + * + * Process events for a given time. This can be useful if waiting is in + * order but there is no actual condition to wait on (e.g. expect + * something *not* to happen). This similar in spirit to + * @c sleep(nTimeoutMs), but dispatches events during the wait. + * + * This function should be used sparsely because waiting a given time is + * rarely a good solution for a problem, but in some specific situations + * there is no better alternative (like, again, waiting for something not + * to happen). + */ + static void Wait(sal_uInt64 nTimeoutMs); + +private: + static OUString debugName(css::accessibility::XAccessibleContext* xctx); + static OUString debugName(css::accessibility::XAccessible* xacc); + static OUString debugName(css::accessibility::XAccessibleStateSet* xsts); + static OUString debugName(const css::accessibility::AccessibleEventObject* evobj); +}; + +CPPUNIT_NS_BEGIN +/* How to generate those automatically? We don't want to match all types + * not to mess up cppunit for types we don't support */ +#define AT_ASSERTION_TRAITS(T) \ + template <> struct assertion_traits> \ + { \ + static bool equal(const css::uno::Reference& x, const css::uno::Reference& y) \ + { \ + return AccessibilityTools::equals(x, y); \ + } \ + \ + static std::string toString(const css::uno::Reference& x) \ + { \ + return AccessibilityTools::debugString(x); \ + } \ + } + +AT_ASSERTION_TRAITS(css::accessibility::XAccessible); +AT_ASSERTION_TRAITS(css::accessibility::XAccessibleContext); +AT_ASSERTION_TRAITS(css::accessibility::XAccessibleStateSet); + +#undef AT_ASSERTION_TRAITS + +CPPUNIT_NS_END + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/toolkit/qa/cppunit/a11y/AccessibleStatusBarTest.cxx b/toolkit/qa/cppunit/a11y/AccessibleStatusBarTest.cxx new file mode 100644 index 000000000..822223a74 --- /dev/null +++ b/toolkit/qa/cppunit/a11y/AccessibleStatusBarTest.cxx @@ -0,0 +1,184 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "AccessibilityTools.hxx" +#include "XAccessibleComponentTester.hxx" +#include "XAccessibleContextTester.hxx" +#include "XAccessibleExtendedComponentTester.hxx" +#include "XAccessibleEventBroadcasterTester.hxx" + +using namespace css; + +namespace +{ +class AccessibleStatusBarTest : public test::BootstrapFixture +{ +private: + uno::Reference mxDesktop; + + uno::Reference + getTestObject(const uno::Reference& xWindow); + void runAllTests(const uno::Reference& xWindow); + uno::Reference openDocument(std::string_view sKind); + void testDocument(std::string_view sKind); + + void testWriterDoc() { testDocument("swriter"); } + void testMathDoc() { testDocument("smath"); } + void testDrawDoc() { testDocument("sdraw"); } + void testImpressDoc() { testDocument("simpress"); } + void testCalcDoc() { testDocument("scalc"); } + +public: + virtual void setUp() override; + + CPPUNIT_TEST_SUITE(AccessibleStatusBarTest); + CPPUNIT_TEST(testWriterDoc); + CPPUNIT_TEST(testMathDoc); + CPPUNIT_TEST(testDrawDoc); + CPPUNIT_TEST(testImpressDoc); + CPPUNIT_TEST(testCalcDoc); + CPPUNIT_TEST_SUITE_END(); +}; + +void AccessibleStatusBarTest::setUp() +{ + test::BootstrapFixture::setUp(); + + mxDesktop = frame::Desktop::create(mxComponentContext); +} + +uno::Reference +AccessibleStatusBarTest::getTestObject(const uno::Reference& xWindow) +{ + uno::Reference xAccessible(xWindow, uno::UNO_QUERY_THROW); + std::cout << "got accessible: " << xAccessible << std::endl; + std::cout << "accessible name: " << AccessibilityTools::debugString(xAccessible) << std::endl; + + auto xContext = AccessibilityTools::getAccessibleObjectForRole( + xAccessible, accessibility::AccessibleRole::STATUS_BAR); + std::cout << "got context: " << xContext << std::endl; + std::cout << "context name: " << AccessibilityTools::debugString(xContext) << std::endl; + + Scheduler::ProcessEventsToIdle(); // not sure why? + + uno::Reference xSI(xContext, uno::UNO_QUERY_THROW); + std::cout << "implementation name: " << xSI->getImplementationName() << std::endl; + auto serviceNames = xSI->getSupportedServiceNames(); + std::cout << "has " << serviceNames.size() << " services:" << std::endl; + for (auto& service : serviceNames) + std::cout << " * service: " << service << std::endl; + + return xContext; +} + +void AccessibleStatusBarTest::runAllTests(const uno::Reference& xWindow) +{ + auto xContext = getTestObject(xWindow); + + uno::Reference xAccessibleComponent(xContext, + uno::UNO_QUERY_THROW); + XAccessibleComponentTester componentTester(xAccessibleComponent); + componentTester.testAll(); + + XAccessibleContextTester contextTester(xContext); + contextTester.testAll(); + + uno::Reference xAccessibleExtendedComponent( + xContext, uno::UNO_QUERY_THROW); + XAccessibleExtendedComponentTester extendedComponentTester(xAccessibleExtendedComponent); + extendedComponentTester.testAll(); + + uno::Reference xAccessibleEventBroadcaster( + xContext, uno::UNO_QUERY_THROW); + XAccessibleEventBroadcasterTester eventBroadcasterTester(xAccessibleEventBroadcaster, xWindow); + eventBroadcasterTester.testAll(); +} + +uno::Reference AccessibleStatusBarTest::openDocument(std::string_view sKind) +{ + /* not sure what's that about, but from SOfficeFactory.java:openDoc() */ + // that noargs thing for load attributes + std::vector aArgs; + if (sKind == "simpress") + { + beans::PropertyValue aValue; + aValue.Name = "OpenFlags"; + aValue.Handle = -1; + aValue.Value <<= OUString("S"); + aValue.State = beans::PropertyState_DIRECT_VALUE; + aArgs.push_back(aValue); + } + + rtl::OUStringBuffer sURL("private:factory/"); + sURL.appendAscii(sKind.data(), sKind.length()); + + return mxDesktop->loadComponentFromURL(sURL.makeStringAndClear(), "_blank", 40, + comphelper::containerToSequence(aArgs)); +} + +void AccessibleStatusBarTest::testDocument(std::string_view sKind) +{ + auto xDoc = openDocument(sKind); + std::cout << "got document: " << xDoc << std::endl; + CPPUNIT_ASSERT(xDoc.is()); + uno::Reference xModel(xDoc, uno::UNO_QUERY_THROW); + std::cout << "got model: " << xModel << std::endl; + uno::Reference xWindow( + xModel->getCurrentController()->getFrame()->getContainerWindow()); + std::cout << "got window: " << xWindow << std::endl; + uno::Reference xTopWindow(xWindow, uno::UNO_QUERY_THROW); + std::cout << "got top window: " << xTopWindow << std::endl; + xTopWindow->toFront(); + + Scheduler::ProcessEventsToIdle(); + + runAllTests(xWindow); + + // close document + uno::Reference xCloseable(xDoc, uno::UNO_QUERY_THROW); + xCloseable->close(false); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(AccessibleStatusBarTest); +} // namespace + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/toolkit/qa/cppunit/a11y/XAccessibleComponentTester.cxx b/toolkit/qa/cppunit/a11y/XAccessibleComponentTester.cxx new file mode 100644 index 000000000..ea46ff778 --- /dev/null +++ b/toolkit/qa/cppunit/a11y/XAccessibleComponentTester.cxx @@ -0,0 +1,290 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "XAccessibleComponentTester.hxx" + +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include "AccessibilityTools.hxx" + +using namespace css; + +/** + * @brief Checks the component's bounds + * + * Checks the X and Y coordinates are non-negative, and that the width and + * height are greater than 0. + * + * Coherence with @c getLocation() is tested in the test for the + * latter. + */ +void XAccessibleComponentTester::testBounds() +{ + auto bounds = mxComponent->getBounds(); + std::cout << "bounds: " << bounds.Width << "x" << bounds.Height << std::showpos << bounds.X + << bounds.Y << std::noshowpos << std::endl; + CPPUNIT_ASSERT_GREATEREQUAL(static_cast(0), bounds.X); + CPPUNIT_ASSERT_GREATEREQUAL(static_cast(0), bounds.Y); + CPPUNIT_ASSERT_GREATER(static_cast(0), bounds.Width); + CPPUNIT_ASSERT_GREATER(static_cast(0), bounds.Height); +} + +/** + * @brief Tests results of XAccessibleComponent::getSize() + * + * Succeeds if the size is the same as in bounds. + */ +void XAccessibleComponentTester::testSize() +{ + auto bounds = mxComponent->getBounds(); + auto size = mxComponent->getSize(); + CPPUNIT_ASSERT_EQUAL(bounds.Width, size.Width); + CPPUNIT_ASSERT_EQUAL(bounds.Height, size.Height); +} + +/** + * @brief Tests results of XAccessibleComponent::getBounds() + * + * First checks 4 inner bounds (upper, lower, left and right) of component + * bounding box to contain at least one point of the component. Second 4 outer + * bounds are checked to not contain any component points. + * + * Succeeds if inner bounds contain component points and outer bounds don't + * contain any component points. + */ +void XAccessibleComponentTester::testContainsPoint() +{ + auto bounds = mxComponent->getBounds(); + + /* upper end */ + int curX = 0; + while (!mxComponent->containsPoint(awt::Point(curX, 0)) && curX < bounds.Width) + curX++; + CPPUNIT_ASSERT_MESSAGE("Upper bound of box contains no component points", curX < bounds.Width); + std::cout << "Upper bound of box contains point (" << curX << ",0)" << std::endl; + /* lower end */ + curX = 0; + while (!mxComponent->containsPoint(awt::Point(curX, bounds.Height - 1)) && curX < bounds.Width) + curX++; + CPPUNIT_ASSERT_MESSAGE("Lower bound of box contains no component points", curX < bounds.Width); + std::cout << "Lower bound of box contains point (" << curX << "," << (bounds.Height - 1) << ")" + << std::endl; + /* left end */ + int curY = 0; + while (!mxComponent->containsPoint(awt::Point(0, curY)) && curY < bounds.Height) + curY++; + CPPUNIT_ASSERT_MESSAGE("Left bound of box contains no component points", curY < bounds.Height); + std::cout << "Left bound of box contains point (0," << curY << ")" << std::endl; + /* right end */ + curY = 0; + while (!mxComponent->containsPoint(awt::Point(bounds.Width - 1, curY)) && curY < bounds.Height) + curY++; + CPPUNIT_ASSERT_MESSAGE("Right bound of box contains no component points", curY < bounds.Height); + std::cout << "Right bound of box contains point (" << (bounds.Width - 1) << "," << curY << ")" + << std::endl; + /* no match outside the bounds */ + for (int x = -1; x <= bounds.Width; x++) + { + CPPUNIT_ASSERT_MESSAGE("Outer upper bound CONTAINS a component point", + !mxComponent->containsPoint(awt::Point(x, -1))); + CPPUNIT_ASSERT_MESSAGE("Outer lower bound CONTAINS a component point", + !mxComponent->containsPoint(awt::Point(x, bounds.Height))); + } + for (int y = -1; y <= bounds.Height; y++) + { + CPPUNIT_ASSERT_MESSAGE("Outer left bound CONTAINS a component point", + !mxComponent->containsPoint(awt::Point(-1, y))); + CPPUNIT_ASSERT_MESSAGE("Outer right bound CONTAINS a component point", + !mxComponent->containsPoint(awt::Point(bounds.Width, y))); + } +} + +/** + * @brief Tests results of XAccessibleComponent::getAccessibleAtPoint() + * + * Iterates through all children which implement + * XAccessibleComponent (if they exist) determines their + * boundaries and tries to get each child by getAccessibleAtPoint + * passing point which belongs to the child. + * Also the point is checked which doesn't belong to child boundary box. + * + * Succeeds if in the first cases the right children are returned, and in the + * second null or another child is returned. + */ +void XAccessibleComponentTester::testAccessibleAtPoint() +{ + int count = mxContext->getAccessibleChildCount(); + std::cout << "Found " << count << " children" << std::endl; + for (int i = 0; i < count && i < AccessibilityTools::MAX_CHILDREN; i++) + { + auto child = mxContext->getAccessibleChild(i); + uno::Reference childContext( + child->getAccessibleContext(), uno::UNO_SET_THROW); + std::cout << "* Found child: " << AccessibilityTools::debugString(child) << std::endl; + std::cout << " states: " + << AccessibilityTools::debugString(childContext->getAccessibleStateSet()) + << std::endl; + uno::Reference xChildComponent(childContext, + uno::UNO_QUERY); + std::cout << " component: " << xChildComponent << std::endl; + if (!xChildComponent) + continue; + + auto childBounds = xChildComponent->getBounds(); + if (childBounds.X == -1) + continue; + std::cout << " bounds: " << childBounds.Width << "x" << childBounds.Height << std::showpos + << childBounds.X << childBounds.Y << std::noshowpos << std::endl; + + std::cout << "finding the point which lies on the component" << std::endl; + int curX = 0; + int curY = 0; + while (!xChildComponent->containsPoint(awt::Point(curX, curY)) && curX < childBounds.Width) + { + curX++; + curY++; + } + if (curX >= childBounds.Width) + { + std::cout << "Couldn't find a point with contains" << std::endl; + continue; + } + else + { + std::cout << "Child found at point +" << childBounds.X + curX << "+" + << childBounds.Y + curY << std::endl; + } + + // trying the point laying on child + auto xAccAtPoint + = mxComponent->getAccessibleAtPoint(awt::Point(childBounds.X, childBounds.Y)); + CPPUNIT_ASSERT_MESSAGE("Child not found at point", xAccAtPoint.is()); + if (!AccessibilityTools::equals(child, xAccAtPoint)) + { + auto idxExpected = childContext->getAccessibleIndexInParent(); + auto idxResult = xAccAtPoint->getAccessibleContext()->getAccessibleIndexInParent(); + std::cout << "The child found (" << AccessibilityTools::debugString(xAccAtPoint) + << ") is not the expected one (" << AccessibilityTools::debugString(child) + << ")" << std::endl; + if (idxExpected < idxResult) + { + std::cout << "-- it probably is hidden behind? Skipping." << std::endl; + } + else + { + CPPUNIT_ASSERT_EQUAL_MESSAGE("The child found is NOT the expected one", child, + xAccAtPoint); + } + } + + // trying the point NOT laying on child + xAccAtPoint + = mxComponent->getAccessibleAtPoint(awt::Point(childBounds.X - 1, childBounds.Y - 1)); + if (xAccAtPoint.is()) + { + CPPUNIT_ASSERT_MESSAGE("Child found OUTSIDE its bounds", + !AccessibilityTools::equals(child, xAccAtPoint)); + } + } +} + +/** + * @brief Tests results of XAccessibleComponent::getLocation() + * + * Succeeds if the location is the same as location of boundary obtained by + * the getBounds() method. + */ +void XAccessibleComponentTester::testLocation() +{ + auto bounds = mxComponent->getBounds(); + auto location = mxComponent->getLocation(); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Invalid X location", bounds.X, location.X); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Invalid Y location", bounds.Y, location.Y); +} + +/** + * @brief Tests results of XAccessibleComponent::getLocationOnScreen() + * @returns @c true on success. + * + * Get the screen location of the component and its parent + * (if it exists and supports XAccessibleComponent). + * + * Succeeds component screen location equals to screen location of its parent + * plus location of the component relative to the parent. + */ +void XAccessibleComponentTester::testLocationOnScreen() +{ + auto location = mxComponent->getLocationOnScreen(); + std::cout << "location on screen: +" << location.X << "+" << location.Y << std::endl; + + auto xParent = mxContext->getAccessibleParent(); + if (!xParent.is()) + std::cout << "No parent" << std::endl; + else + { + std::cout << "Found parent: " << AccessibilityTools::debugString(xParent) << std::endl; + uno::Reference xParentComponent( + xParent->getAccessibleContext(), uno::UNO_QUERY); + if (!xParentComponent.is()) + std::cout << "Parent is not a Component" << std::endl; + else + { + auto bounds = mxComponent->getBounds(); + auto parentLocation = xParentComponent->getLocationOnScreen(); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Invalid X screen location", parentLocation.X + bounds.X, + location.X); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Invalid Y screen location", parentLocation.Y + bounds.Y, + location.Y); + } + } +} + +/** + * Just calls the method. + */ +void XAccessibleComponentTester::testGrabFocus() { mxComponent->grabFocus(); } + +/** + * Just calls the method. + */ +void XAccessibleComponentTester::testGetForeground() +{ + auto color = mxComponent->getForeground(); + std::cout << "foreground color: " << Color(ColorAlpha, color) << std::endl; +} + +/** + * Just calls the method. + */ +void XAccessibleComponentTester::testGetBackground() +{ + auto color = mxComponent->getBackground(); + std::cout << "background color: " << Color(ColorAlpha, color) << std::endl; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/toolkit/qa/cppunit/a11y/XAccessibleComponentTester.hxx b/toolkit/qa/cppunit/a11y/XAccessibleComponentTester.hxx new file mode 100644 index 000000000..ba84fbbac --- /dev/null +++ b/toolkit/qa/cppunit/a11y/XAccessibleComponentTester.hxx @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include +#include + +#include "AccessibilityTools.hxx" + +class XAccessibleComponentTester +{ +private: + const css::uno::Reference mxComponent; + const css::uno::Reference mxContext; + +public: + XAccessibleComponentTester( + const css::uno::Reference& component) + : mxComponent(component) + , mxContext(component, css::uno::UNO_QUERY_THROW) + { + } + + void testBounds(); + void testSize(); + void testContainsPoint(); + void testAccessibleAtPoint(); + void testLocation(); + void testLocationOnScreen(); + void testGrabFocus(); + void testGetForeground(); + void testGetBackground(); + + void testAll() + { + testBounds(); + testSize(); + testContainsPoint(); + testAccessibleAtPoint(); + testLocation(); + testLocationOnScreen(); + testGrabFocus(); + testGetForeground(); + testGetBackground(); + } +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/toolkit/qa/cppunit/a11y/XAccessibleContextTester.cxx b/toolkit/qa/cppunit/a11y/XAccessibleContextTester.cxx new file mode 100644 index 000000000..b8c7898f9 --- /dev/null +++ b/toolkit/qa/cppunit/a11y/XAccessibleContextTester.cxx @@ -0,0 +1,164 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "XAccessibleContextTester.hxx" + +#include + +#include +#include + +#include "AccessibilityTools.hxx" + +/** + * @brief Tries to get every child and checks its parent. + * + * Checks that the parent of every child and the tested component are the same object. + */ +void XAccessibleContextTester::testGetAccessibleChild() +{ + int count = mxContext->getAccessibleChildCount(); + for (int i = 0; i < count && i < AccessibilityTools::MAX_CHILDREN; i++) + { + auto child = mxContext->getAccessibleChild(i); + auto childCtx = child->getAccessibleContext(); + + std::cout << " Child " << i << ": " << AccessibilityTools::debugString(childCtx) + << std::endl; + + CPPUNIT_ASSERT_EQUAL_MESSAGE("child's parent context is not parent's context!", + childCtx->getAccessibleParent()->getAccessibleContext(), + mxContext); + } +} + +/** + * @brief Calls the method. + * + * Checks that the child count is non-negative. + */ +void XAccessibleContextTester::testGetAccessibleChildCount() +{ + auto childCount = mxContext->getAccessibleChildCount(); + std::cout << childCount << " children found." << std::endl; + CPPUNIT_ASSERT_GREATEREQUAL(static_cast(0), childCount); +} + +/** + * @brief Get the accessible description of the component. + */ +void XAccessibleContextTester::testGetAccessibleDescription() +{ + auto desc = mxContext->getAccessibleDescription(); + std::cout << "The description is '" << desc << "'" << std::endl; +} + +/** + * @brief Checks the index in parent + * + * Checks that the parent's child and the tested component are the same objects. + * + * Retrieves the index of tested component in its parent. + * Then gets the parent's child by this index and compares + * it with tested component. + */ +void XAccessibleContextTester::testGetAccessibleIndexInParent() +{ + int idx = mxContext->getAccessibleIndexInParent(); + std::cout << "The index in parent is " << idx << std::endl; + + auto parent = mxContext->getAccessibleParent(); + CPPUNIT_ASSERT(parent.is()); + auto parentCtx = parent->getAccessibleContext(); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Parent's child context at our index is not us!", mxContext, + parentCtx->getAccessibleChild(idx)->getAccessibleContext()); +} + +/** + * @brief Get the accessible name of the component. + */ +void XAccessibleContextTester::testGetAccessibleName() +{ + auto name = mxContext->getAccessibleName(); + std::cout << "The name is '" << name << "'" << std::endl; +} + +/** + * @brief Just gets the parent. + * + * Checks that the parent is not null. + */ +void XAccessibleContextTester::testGetAccessibleParent() +{ + // assume that the component is not ROOT + auto parent = mxContext->getAccessibleParent(); + std::cout << "The parent is " << AccessibilityTools::debugString(parent) << std::endl; + CPPUNIT_ASSERT_MESSAGE("parent is not set", parent.is()); +} + +/** + * @brief Just gets the relation set. + * + * Checks that the relation set is not null. + */ +void XAccessibleContextTester::testGetAccessibleRelationSet() +{ + auto relSet = mxContext->getAccessibleRelationSet(); + CPPUNIT_ASSERT_MESSAGE("relation set is not set", relSet.is()); +} + +/** + * @brief Get the accessible role of component. + * + * Checks that the role is a non-negative number. + */ +void XAccessibleContextTester::testGetAccessibleRole() +{ + sal_Int32 role = mxContext->getAccessibleRole(); + std::cout << "The role is " << role << " (" << AccessibilityTools::getRoleName(role) << ")" + << std::endl; + CPPUNIT_ASSERT_GREATEREQUAL(static_cast(0), role); +} + +/** + * @brief Just gets the state set. + * + * Checks that the state set is not null. + */ +void XAccessibleContextTester::testGetAccessibleStateSet() +{ + auto stateSet = mxContext->getAccessibleStateSet(); + std::cout << "The state set is: " << AccessibilityTools::debugString(stateSet) << std::endl; + CPPUNIT_ASSERT_MESSAGE("state set is not set", stateSet.is()); +} + +/** + * @brief Gets the locale. + * + * Checks that @c Country and @c Language fields of locale structure are not empty. + */ +void XAccessibleContextTester::testGetLocale() +{ + auto loc = mxContext->getLocale(); + std::cout << "The locale is " << loc.Language << "," << loc.Country << std::endl; + CPPUNIT_ASSERT_GREATER(static_cast(0), loc.Language.getLength()); + CPPUNIT_ASSERT_GREATER(static_cast(0), loc.Country.getLength()); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/toolkit/qa/cppunit/a11y/XAccessibleContextTester.hxx b/toolkit/qa/cppunit/a11y/XAccessibleContextTester.hxx new file mode 100644 index 000000000..b399028cf --- /dev/null +++ b/toolkit/qa/cppunit/a11y/XAccessibleContextTester.hxx @@ -0,0 +1,62 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include + +class XAccessibleContextTester +{ +protected: + const css::uno::Reference mxContext; + +public: + XAccessibleContextTester(const css::uno::Reference& ctx) + : mxContext(ctx) + { + } + + void testGetAccessibleChild(); + void testGetAccessibleChildCount(); + void testGetAccessibleDescription(); + void testGetAccessibleIndexInParent(); + void testGetAccessibleName(); + void testGetAccessibleParent(); + void testGetAccessibleRelationSet(); + void testGetAccessibleRole(); + void testGetAccessibleStateSet(); + void testGetLocale(); + + void testAll() + { + testGetAccessibleChild(); + testGetAccessibleChildCount(); + testGetAccessibleDescription(); + testGetAccessibleIndexInParent(); + testGetAccessibleName(); + testGetAccessibleParent(); + testGetAccessibleRelationSet(); + testGetAccessibleRole(); + testGetAccessibleStateSet(); + testGetLocale(); + } +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/toolkit/qa/cppunit/a11y/XAccessibleEventBroadcasterTester.cxx b/toolkit/qa/cppunit/a11y/XAccessibleEventBroadcasterTester.cxx new file mode 100644 index 000000000..80aa2c079 --- /dev/null +++ b/toolkit/qa/cppunit/a11y/XAccessibleEventBroadcasterTester.cxx @@ -0,0 +1,186 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "XAccessibleEventBroadcasterTester.hxx" + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "AccessibilityTools.hxx" + +using namespace css; + +namespace +{ +class EvListener : public cppu::WeakImplHelper +{ +public: + bool mbGotEvent; + + EvListener() + : mbGotEvent(false) + { + } + + // XEventListener + virtual void SAL_CALL disposing(const lang::EventObject&) override {} + + // XAccessibleEventListener + virtual void SAL_CALL notifyEvent(const accessibility::AccessibleEventObject& aEvent) override + { + std::cout << "Listener got event: " << AccessibilityTools::debugString(aEvent) << std::endl; + uno::Reference xOld(aEvent.OldValue, uno::UNO_QUERY); + if (xOld.is()) + std::cout << "Old: " << AccessibilityTools::debugString(xOld) << std::endl; + + uno::Reference xNew(aEvent.NewValue, uno::UNO_QUERY); + if (xNew.is()) + std::cout << "New: " << AccessibilityTools::debugString(xNew) << std::endl; + + mbGotEvent = true; + } +}; +} + +XAccessibleEventBroadcasterTester::XAccessibleEventBroadcasterTester( + const uno::Reference& xBroadcaster, + const uno::Reference& xWindow) + : mxBroadcaster(xBroadcaster) + , mxWindow(xWindow) +{ +} + +bool XAccessibleEventBroadcasterTester::isTransient( + const uno::Reference xBroadcaster) +{ + uno::Reference xCtx(xBroadcaster, uno::UNO_QUERY_THROW); + return isTransient(xCtx); +} + +bool XAccessibleEventBroadcasterTester::isTransient( + const uno::Reference xCtx) +{ + return ( + xCtx->getAccessibleStateSet()->contains(accessibility::AccessibleStateType::TRANSIENT) + && xCtx->getAccessibleParent()->getAccessibleContext()->getAccessibleStateSet()->contains( + accessibility::AccessibleStateType::MANAGES_DESCENDANTS)); +} + +/** + * @brief Generates an event on @c mxBroadcaster. + * + * This method indirectly alters the state of @c mxBroadcaster so that an + * accessible event will be fired for it. It can be called as many times as + * needed and triggers an event each time. + */ +void XAccessibleEventBroadcasterTester::fireEvent() +{ + awt::Rectangle newPosSize = mxWindow->getPosSize(); + newPosSize.Width = newPosSize.Width - 20; + newPosSize.Height = newPosSize.Height - 20; + newPosSize.X = newPosSize.X + 20; + newPosSize.Y = newPosSize.Y + 20; + mxWindow->setPosSize(newPosSize.X, newPosSize.Y, newPosSize.Width, newPosSize.Height, + awt::PosSize::POSSIZE); +} + +/** + * @brief Adds a listener and fires events by mean of object relation. + * + * Asserts that the listener was properly called. + */ +void XAccessibleEventBroadcasterTester::testAddEventListener() +{ + rtl::Reference xListener(new EvListener); + mxBroadcaster->addAccessibleEventListener(xListener); + bool transient = isTransient(mxBroadcaster); + + std::cout << "firing event" << std::endl; + fireEvent(); + + AccessibilityTools::Await([&xListener]() { return xListener->mbGotEvent; }); + + if (!transient) + CPPUNIT_ASSERT_MESSAGE("listener wasn't called", xListener->mbGotEvent); + else + CPPUNIT_ASSERT_MESSAGE("Object is Transient, listener isn't expected to be called", + !xListener->mbGotEvent); + + mxBroadcaster->removeAccessibleEventListener(xListener); +} + +/** + * @brief Similar to @c testAddEventListener() but also removes the listener + * + * Adds an event listener just like @c testAddEventListener(), and then removes it and verifies an + * event doesn't trigger the supposedly removed listener. + * + * @see testAddEventListener() + */ +void XAccessibleEventBroadcasterTester::testRemoveEventListener() +{ + /* there is nothing we can really test for transient objects */ + if (isTransient(mxBroadcaster)) + { + std::cerr << "could not test removing listener on transient object " << mxBroadcaster + << std::endl; + return; + } + + rtl::Reference xListener(new EvListener); + mxBroadcaster->addAccessibleEventListener(xListener); + + std::cout << "firing event (with listener)" << std::endl; + fireEvent(); + + AccessibilityTools::Await([&xListener]() { return xListener->mbGotEvent; }); + + CPPUNIT_ASSERT_MESSAGE("listener wasn't called", xListener->mbGotEvent); + + /* reset listener, remove it and try again */ + xListener->mbGotEvent = false; + + std::cout << "removing listener" << std::endl; + mxBroadcaster->removeAccessibleEventListener(xListener); + + std::cout << "firing event (without listener)" << std::endl; + fireEvent(); + + AccessibilityTools::Wait(500); + + CPPUNIT_ASSERT_MESSAGE("removed listener was called", !xListener->mbGotEvent); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/toolkit/qa/cppunit/a11y/XAccessibleEventBroadcasterTester.hxx b/toolkit/qa/cppunit/a11y/XAccessibleEventBroadcasterTester.hxx new file mode 100644 index 000000000..0fc7c23bd --- /dev/null +++ b/toolkit/qa/cppunit/a11y/XAccessibleEventBroadcasterTester.hxx @@ -0,0 +1,54 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include +#include +#include + +class XAccessibleEventBroadcasterTester +{ +private: + const css::uno::Reference mxBroadcaster; + const css::uno::Reference mxWindow; + + static bool isTransient( + const css::uno::Reference xBroadcaster); + static bool isTransient(const css::uno::Reference xCtx); + + void fireEvent(); + +public: + XAccessibleEventBroadcasterTester( + const css::uno::Reference& xBroadcaster, + const css::uno::Reference& xWindow); + + void testAddEventListener(); + void testRemoveEventListener(); + + void testAll() + { + testAddEventListener(); + testRemoveEventListener(); + } +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/toolkit/qa/cppunit/a11y/XAccessibleExtendedComponentTester.cxx b/toolkit/qa/cppunit/a11y/XAccessibleExtendedComponentTester.cxx new file mode 100644 index 000000000..a7137c4ba --- /dev/null +++ b/toolkit/qa/cppunit/a11y/XAccessibleExtendedComponentTester.cxx @@ -0,0 +1,53 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "XAccessibleExtendedComponentTester.hxx" + +#include + +#include + +/** + * @brief Just calls the method. + */ +void XAccessibleExtendedComponentTester::testGetFont() +{ + auto font = mxExtendedComponent->getFont(); + std::cout << "font: " << font << std::endl; +} + +/** + * @brief Just calls the method. + */ +void XAccessibleExtendedComponentTester::testGetTitledBorderText() +{ + auto titleBorderText = mxExtendedComponent->getTitledBorderText(); + std::cout << "getTitledBorderText(): '" << titleBorderText << "'" << std::endl; +} + +/** + * @brief Just calls the method. + */ +void XAccessibleExtendedComponentTester::testGetToolTipText() +{ + auto toolTipText = mxExtendedComponent->getToolTipText(); + std::cout << "getToolTipText(): '" << toolTipText << "'" << std::endl; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/toolkit/qa/cppunit/a11y/XAccessibleExtendedComponentTester.hxx b/toolkit/qa/cppunit/a11y/XAccessibleExtendedComponentTester.hxx new file mode 100644 index 000000000..129705282 --- /dev/null +++ b/toolkit/qa/cppunit/a11y/XAccessibleExtendedComponentTester.hxx @@ -0,0 +1,50 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include + +class XAccessibleExtendedComponentTester +{ +protected: + const css::uno::Reference mxExtendedComponent; + +public: + XAccessibleExtendedComponentTester( + const css::uno::Reference& + extendedComponent) + : mxExtendedComponent(extendedComponent) + { + } + + void testGetFont(); + void testGetTitledBorderText(); + void testGetToolTipText(); + + void testAll() + { + testGetFont(); + testGetTitledBorderText(); + testGetToolTipText(); + } +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/toolkit/qa/unoapi/knownissues.xcl b/toolkit/qa/unoapi/knownissues.xcl new file mode 100644 index 000000000..7a2f95577 --- /dev/null +++ b/toolkit/qa/unoapi/knownissues.xcl @@ -0,0 +1,259 @@ +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This file incorporates work covered by the following license notice: +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to you under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.apache.org/licenses/LICENSE-2.0 . +# + +### i86545 ### +toolkit.AccessibleToolBoxItem::com::sun::star::accessibility::XAccessibleText + +### i30818 ### +toolkit.AccessibleToolBox::com::sun::star::accessibility::XAccessibleEventBroadcaster + +### i68852 ### +toolkit.TabControllerModel::com::sun::star::io::XPersistObject + +### i79111 ### +toolkit.UnoControlButtonModel::com::sun::star::awt::UnoControlButtonModel + +### i79110 ### +toolkit.UnoControlCheckBoxModel::com::sun::star::awt::UnoControlCheckBoxModel + +### i84314 ### +toolkit.UnoControlImageControlModel::com::sun::star::awt::UnoControlImageControlModel + +### i86542 ### +toolkit.UnoControlProgressBarModel::com::sun::star::awt::UnoControlProgressBarModel + +### i86543 ### +toolkit.UnoControlRadioButtonModel::com::sun::star::awt::UnoControlRadioButtonModel + +### i79098 ### +toolkit.UnoControlScrollBarModel::com::sun::star::awt::UnoControlScrollBarModel + +### i86544 ### +toolkit.UnoTreeModel::com::sun::star::awt::tree::TreeControlModel + +### i74011 ### +toolkit.UnoControlDateField::com::sun::star::awt::XWindow +toolkit.UnoSpinButtonControl::com::sun::star::awt::XWindow +toolkit.UnoControlPatternField::com::sun::star::awt::XWindow +toolkit.UnoControlRadioButton::com::sun::star::awt::XWindow +toolkit.UnoControlButton::com::sun::star::awt::XWindow +toolkit.UnoControlTimeField::com::sun::star::awt::XWindow +toolkit.UnoControlFormattedField::com::sun::star::awt::XWindow +toolkit.UnoControlContainer::com::sun::star::awt::XWindow +toolkit.UnoControlGroupBox::com::sun::star::awt::XWindow +toolkit.UnoControlFixedText::com::sun::star::awt::XWindow +toolkit.UnoControlListBox::com::sun::star::awt::XWindow +toolkit.UnoControlImageControl::com::sun::star::awt::XWindow +toolkit.UnoControlDialog::com::sun::star::awt::XWindow +toolkit.UnoControlEdit::com::sun::star::awt::XWindow +toolkit.UnoControlCurrencyField::com::sun::star::awt::XWindow +toolkit.UnoControlFileControl::com::sun::star::awt::XWindow +toolkit.UnoControlComboBox::com::sun::star::awt::XWindow +toolkit.UnoControlNumericField::com::sun::star::awt::XWindow +toolkit.UnoControlCheckBox::com::sun::star::awt::XWindow +toolkit.UnoScrollBarControl::com::sun::star::awt::XWindow + +### i86296 ### +toolkit.UnoControlContainerModel::com::sun::star::awt::UnoControlContainerModel + +### i86297 ### +toolkit.UnoControlFixedTextModel::com::sun::star::awt::UnoControlFixedTextModel + +### i86299 ### +toolkit.UnoTreeModel::com::sun::star::awt::UnoControlModel + +### i86300 ### +toolkit.UnoTreeModel::com::sun::star::beans::XMultiPropertySet + +### i86007 ### +toolkit.AccessibleButton +# -> disabled in toolkit.sce + +### i86008 ### +toolkit.AccessibleComboBox +# -> disabled in toolkit.sce + +### i86110 ### +toolkit.AccessibleEdit +toolkit.AccessibleList +toolkit.AccessibleListBox +toolkit.AccessibleListItem +toolkit.AccessibleRadioButton +# -> disabled in toolkit.sce + +### i86009 ### +toolkit.AccessibleMenuItem +# -> disabled in toolkit.sce + +### i86107 ### +toolkit.AccessibleRadioButton +# -> disabled in toolkit.sce + +### i86287 ### +toolkit.AccessibleToolBox +# -> disabled in toolkit.sce + +### i86011 ### +toolkit.UnoControlFileControl +# -> disabled in toolkit.sce + +### i86013 ### +toolkit.UnoControlFormattedField +# -> disabled in toolkit.sce + +### i86019 ### +toolkit.UnoControlListBox +# -> disabled in toolkit.sce + +### i86298 ### +toolkit.UnoTreeControl +# -> disabled in toolkit.sce + +### i52607 ### +toolkit.AccessiblePopupMenu +# -> disabled in toolkit.sce + +### i86660 ### +toolkit.UnoControlDateField::com::sun::star::awt::XView +toolkit.UnoSpinButtonControl::com::sun::star::awt::XView +toolkit.UnoControlPatternField::com::sun::star::awt::XView +toolkit.UnoControlRadioButton::com::sun::star::awt::XView +toolkit.UnoControlButton::com::sun::star::awt::XView +toolkit.UnoControlTimeField::com::sun::star::awt::XView +toolkit.UnoControlFormattedField::com::sun::star::awt::XView +toolkit.UnoControlGroupBox::com::sun::star::awt::XView +toolkit.UnoControlContainer::com::sun::star::awt::XView +toolkit.UnoControlFixedText::com::sun::star::awt::XView +toolkit.UnoControlListBox::com::sun::star::awt::XView +toolkit.UnoControlEdit::com::sun::star::awt::XView +toolkit.UnoControlImageControl::com::sun::star::awt::XView +toolkit.UnoControlDialog::com::sun::star::awt::XView +toolkit.UnoControlFileControl::com::sun::star::awt::XView +toolkit.UnoControlCurrencyField::com::sun::star::awt::XView +toolkit.UnoControlComboBox::com::sun::star::awt::XView +toolkit.UnoControlNumericField::com::sun::star::awt::XView +toolkit.UnoControlCheckBox::com::sun::star::awt::XView +toolkit.UnoScrollBarControl::com::sun::star::awt::XView + +### i37643 ### +toolkit.AccessibleStatusBarItem::com::sun::star::accessibility::XAccessibleEventBroadcaster + +### i87864 ### +toolkit.UnoControlContainerModel::com::sun::star::lang::XComponent +toolkit.UnoTreeModel::com::sun::star::lang::XComponent +toolkit.UnoControlTimeFieldModel::com::sun::star::lang::XComponent +toolkit.UnoControlDateField::com::sun::star::lang::XComponent +toolkit.UnoControlButtonModel::com::sun::star::lang::XComponent +toolkit.UnoControlPatternFieldModel::com::sun::star::lang::XComponent +toolkit.UnoSpinButtonControl::com::sun::star::lang::XComponent +toolkit.UnoControlDateFieldModel::com::sun::star::lang::XComponent +toolkit.UnoControlPatternField::com::sun::star::lang::XComponent +toolkit.UnoControlRadioButtonModel::com::sun::star::lang::XComponent +toolkit.UnoControlFormattedFieldModel::com::sun::star::lang::XComponent +toolkit.UnoControlRadioButton::com::sun::star::lang::XComponent +toolkit.UnoControlButton::com::sun::star::lang::XComponent +toolkit.UnoControlTimeField::com::sun::star::lang::XComponent +toolkit.UnoControlFormattedField::com::sun::star::lang::XComponent +toolkit.UnoControlFixedLineModel::com::sun::star::lang::XComponent +toolkit.UnoControlDialogModel::com::sun::star::lang::XComponent +toolkit.UnoControlFileControlModel::com::sun::star::lang::XComponent +toolkit.UnoControlGroupBox::com::sun::star::lang::XComponent +toolkit.UnoControlContainer::com::sun::star::lang::XComponent +toolkit.UnoControlFixedText::com::sun::star::lang::XComponent +toolkit.UnoControlListBox::com::sun::star::lang::XComponent +toolkit.UnoControlCheckBoxModel::com::sun::star::lang::XComponent +toolkit.UnoControlEditModel::com::sun::star::lang::XComponent +toolkit.UnoControlEdit::com::sun::star::lang::XComponent +toolkit.UnoControlImageControl::com::sun::star::lang::XComponent +toolkit.UnoControlDialog::com::sun::star::lang::XComponent +toolkit.UnoControlGroupBoxModel::com::sun::star::lang::XComponent +toolkit.UnoControlImageControlModel::com::sun::star::lang::XComponent +toolkit.UnoControlNumericFieldModel::com::sun::star::lang::XComponent +toolkit.UnoControlFileControl::com::sun::star::lang::XComponent +toolkit.UnoControlCurrencyField::com::sun::star::lang::XComponent +toolkit.UnoControlComboBoxModel::com::sun::star::lang::XComponent +toolkit.UnoControlComboBox::com::sun::star::lang::XComponent +toolkit.UnoControlNumericField::com::sun::star::lang::XComponent +toolkit.UnoControlScrollBarModel::com::sun::star::lang::XComponent +toolkit.UnoControlProgressBarModel::com::sun::star::lang::XComponent +toolkit.UnoControlListBoxModel::com::sun::star::lang::XComponent +toolkit.UnoControlFixedTextModel::com::sun::star::lang::XComponent +toolkit.UnoSpinButtonControlModel::com::sun::star::lang::XComponent +toolkit.UnoControlCurrencyFieldModel::com::sun::star::lang::XComponent +toolkit.UnoControlCheckBox::com::sun::star::lang::XComponent +toolkit.UnoScrollBarControl::com::sun::star::lang::XComponent + +### i89415 ### +toolkit.UnoControlContainer::com::sun::star::awt::XControl + +### i89417 ### +toolkit.UnoControlContainer::com::sun::star::accessibility::XAccessible + +### i89418 ### +toolkit.UnoSpinButtonControl::com::sun::star::awt::XSpinValue + +### i88332 ### +toolkit.AccessibleCheckBox +# -> disabled in toolkit.sce + +### i88605 ### +toolkit.AccessibleToolBoxItem +# -> disabled in toolkit.sce + +### i89019 ### +toolkit.AccessibleWindow::com::sun::star::accessibility::XAccessibleEventBroadcaster + +### i90354 ### +toolkit.AccessibleScrollBar::com::sun::star::accessibility::XAccessibleComponent + +### i90356 ### +toolkit.UnoScrollBarControl::com::sun::star::awt::XScrollBar + +### i94344 ### +toolkit.AccessibleTabPage::com::sun::star::accessibility::XAccessibleText + +### i109643 ### +toolkit.AccessibleMenu::com::sun::star::accessibility::XAccessibleValue +toolkit.AccessibleMenuBar::com::sun::star::accessibility::XAccessibleEventBroadcaster +toolkit.AccessibleMenuBar::com::sun::star::accessibility::XAccessibleSelection + +### i111113 ### +toolkit.AccessibleStatusBarItem::com::sun::star::accessibility::XAccessibleComponent +toolkit.AccessibleStatusBarItem::com::sun::star::accessibility::XAccessibleContext + +### i111195 ### +toolkit.AccessibleScrollBar::com::sun::star::accessibility::XAccessibleValue + +### i113489 ### +toolkit.AccessibleMenu::com::sun::star::accessibility::XAccessibleText +toolkit.AccessibleMenuBar::com::sun::star::accessibility::XAccessibleComponent +toolkit.AccessibleMenuSeparator::com::sun::star::accessibility::XAccessibleComponent + +### i114213 ### +toolkit.AccessibleMenu::com::sun::star::accessibility::XAccessibleSelection + +### i114636 ### +toolkit.AccessibleScrollBar::com::sun::star::accessibility::XAccessibleAction +toolkit.AccessibleScrollBar::com::sun::star::accessibility::XAccessibleContext +toolkit.AccessibleScrollBar::com::sun::star::accessibility::XAccessibleEventBroadcaster + +### fd#35666 ### +toolkit.UnoControlDialogModel::com::sun::star::io::XPersistObject + +### fd#35772 ### +toolkit.Toolkit::com::sun::star::awt::XMessageBoxFactory diff --git a/toolkit/qa/unoapi/testdocuments/poliball.gif b/toolkit/qa/unoapi/testdocuments/poliball.gif new file mode 100644 index 000000000..dda461bd3 Binary files /dev/null and b/toolkit/qa/unoapi/testdocuments/poliball.gif differ diff --git a/toolkit/qa/unoapi/toolkit_1.sce b/toolkit/qa/unoapi/toolkit_1.sce new file mode 100644 index 000000000..3cee05dc3 --- /dev/null +++ b/toolkit/qa/unoapi/toolkit_1.sce @@ -0,0 +1,40 @@ +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This file incorporates work covered by the following license notice: +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to you under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.apache.org/licenses/LICENSE-2.0 . +# + +#i86007 -o toolkit.AccessibleButton +#i88332 -o toolkit.AccessibleCheckBox +#i86008 -o toolkit.AccessibleComboBox +-o toolkit.AccessibleDropDownComboBox +-o toolkit.AccessibleDropDownListBox +#i86110 -o toolkit.AccessibleEdit +-o toolkit.AccessibleFixedText +#i86110 -o toolkit.AccessibleList +#i86110 -o toolkit.AccessibleListBox +#i86110 -o toolkit.AccessibleListItem +-o toolkit.AccessibleMenu +-o toolkit.AccessibleMenuBar +#i86009 -o toolkit.AccessibleMenuItem +-o toolkit.AccessibleMenuSeparator +#i52607 -o toolkit.AccessiblePopupMenu +#i86107,i86110 -o toolkit.AccessibleRadioButton +-o toolkit.AccessibleScrollBar +-o toolkit.AccessibleStatusBarItem +#i109643 -o toolkit.AccessibleTabControl +#i109643 -o toolkit.AccessibleTabPage +#i86287 -o toolkit.AccessibleToolBox +#i88605 -o toolkit.AccessibleToolBoxItem diff --git a/toolkit/qa/unoapi/toolkit_2.sce b/toolkit/qa/unoapi/toolkit_2.sce new file mode 100644 index 000000000..2c5957f34 --- /dev/null +++ b/toolkit/qa/unoapi/toolkit_2.sce @@ -0,0 +1,36 @@ +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This file incorporates work covered by the following license notice: +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to you under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.apache.org/licenses/LICENSE-2.0 . +# + +-o toolkit.AccessibleWindow +-o toolkit.MutableTreeDataModel +-o toolkit.MutableTreeNode +-o toolkit.TabController +-o toolkit.TabControllerModel +-o toolkit.Toolkit +-o toolkit.UnoControlButton +-o toolkit.UnoControlButtonModel +-o toolkit.UnoControlCheckBox +-o toolkit.UnoControlCheckBoxModel +-o toolkit.UnoControlComboBox +-o toolkit.UnoControlComboBoxModel +-o toolkit.UnoControlContainer +-o toolkit.UnoControlContainerModel +-o toolkit.UnoControlCurrencyField +-o toolkit.UnoControlCurrencyFieldModel +-o toolkit.UnoControlDateField +-o toolkit.UnoControlDateFieldModel diff --git a/toolkit/qa/unoapi/toolkit_3.sce b/toolkit/qa/unoapi/toolkit_3.sce new file mode 100644 index 000000000..91f07709e --- /dev/null +++ b/toolkit/qa/unoapi/toolkit_3.sce @@ -0,0 +1,37 @@ +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This file incorporates work covered by the following license notice: +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to you under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.apache.org/licenses/LICENSE-2.0 . +# + +#allegedly was i80788, but still broken: -o toolkit.UnoControlDialog +-o toolkit.UnoControlDialogModel +-o toolkit.UnoControlEdit +-o toolkit.UnoControlEditModel +#i86011 -o toolkit.UnoControlFileControl +-o toolkit.UnoControlFileControlModel +-o toolkit.UnoControlFixedLineModel +-o toolkit.UnoControlFixedText +-o toolkit.UnoControlFixedTextModel +#i86013 -o toolkit.UnoControlFormattedField +-o toolkit.UnoControlFormattedFieldModel +-o toolkit.UnoControlGroupBox +-o toolkit.UnoControlGroupBoxModel +-o toolkit.UnoControlImageControl +-o toolkit.UnoControlImageControlModel +#i86019 -o toolkit.UnoControlListBox +-o toolkit.UnoControlListBoxModel +-o toolkit.UnoControlNumericField +-o toolkit.UnoControlNumericFieldModel diff --git a/toolkit/qa/unoapi/toolkit_4.sce b/toolkit/qa/unoapi/toolkit_4.sce new file mode 100644 index 000000000..d8cdcbe38 --- /dev/null +++ b/toolkit/qa/unoapi/toolkit_4.sce @@ -0,0 +1,31 @@ +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This file incorporates work covered by the following license notice: +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to you under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.apache.org/licenses/LICENSE-2.0 . +# + +-o toolkit.UnoControlPatternField +-o toolkit.UnoControlPatternFieldModel +-o toolkit.UnoControlProgressBarModel +-o toolkit.UnoControlRadioButton +-o toolkit.UnoControlRadioButtonModel +-o toolkit.UnoControlScrollBarModel +-o toolkit.UnoControlTimeField +-o toolkit.UnoControlTimeFieldModel +-o toolkit.UnoScrollBarControl +-o toolkit.UnoSpinButtonControl +-o toolkit.UnoSpinButtonControlModel +#i86298 -o toolkit.UnoTreeControl +-o toolkit.UnoTreeModel diff --git a/toolkit/source/awt/animatedimagespeer.cxx b/toolkit/source/awt/animatedimagespeer.cxx new file mode 100644 index 000000000..b542b564b --- /dev/null +++ b/toolkit/source/awt/animatedimagespeer.cxx @@ -0,0 +1,476 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + + +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +namespace toolkit +{ + + + using ::com::sun::star::uno::XComponentContext; + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::lang::EventObject; + using ::com::sun::star::container::ContainerEvent; + using ::com::sun::star::awt::XAnimatedImages; + using ::com::sun::star::awt::Size; + using ::com::sun::star::graphic::XGraphicProvider; + using ::com::sun::star::beans::XPropertySet; + using ::com::sun::star::graphic::XGraphic; + + namespace ImageScaleMode = ::com::sun::star::awt::ImageScaleMode; + + //= helper + + namespace + { + + OUString lcl_getHighContrastURL( OUString const& i_imageURL ) + { + INetURLObject aURL( i_imageURL ); + if ( aURL.GetProtocol() != INetProtocol::PrivSoffice ) + { + OSL_VERIFY( aURL.insertName( u"sifr", false, 0 ) ); + return aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ); + } + // the private: scheme is not considered to be hierarchical by INetURLObject, so manually insert the + // segment + const sal_Int32 separatorPos = i_imageURL.indexOf( '/' ); + ENSURE_OR_RETURN( separatorPos != -1, "lcl_getHighContrastURL: unsupported URL scheme - cannot automatically determine HC version!", i_imageURL ); + + OUString composer = OUString::Concat(i_imageURL.subView(0, separatorPos)) + "/sifr" + + i_imageURL.subView(separatorPos); + return composer; + } + + + bool lcl_ensureImage_throw( Reference< XGraphicProvider > const& i_graphicProvider, const bool i_isHighContrast, const AnimatedImagesPeer::CachedImage& i_cachedImage ) + { + if ( !i_cachedImage.xGraphic.is() ) + { + ::comphelper::NamedValueCollection aMediaProperties; + if ( i_isHighContrast ) + { + // try (to find) the high-contrast version of the graphic first + aMediaProperties.put( "URL", lcl_getHighContrastURL( i_cachedImage.sImageURL ) ); + i_cachedImage.xGraphic = i_graphicProvider->queryGraphic( aMediaProperties.getPropertyValues() ); + } + if ( !i_cachedImage.xGraphic.is() ) + { + aMediaProperties.put( "URL", i_cachedImage.sImageURL ); + i_cachedImage.xGraphic = i_graphicProvider->queryGraphic( aMediaProperties.getPropertyValues() ); + } + } + return i_cachedImage.xGraphic.is(); + } + + + Size lcl_getGraphicSizePixel( Reference< XGraphic > const& i_graphic ) + { + Size aSizePixel; + try + { + if ( i_graphic.is() ) + { + const Reference< XPropertySet > xGraphicProps( i_graphic, UNO_QUERY_THROW ); + OSL_VERIFY( xGraphicProps->getPropertyValue("SizePixel") >>= aSizePixel ); + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION("toolkit"); + } + return aSizePixel; + } + + + void lcl_init( Sequence< OUString > const& i_imageURLs, ::std::vector< AnimatedImagesPeer::CachedImage >& o_images ) + { + o_images.resize(0); + size_t count = size_t( i_imageURLs.getLength() ); + o_images.reserve( count ); + for ( const auto& rImageURL : i_imageURLs ) + { + o_images.emplace_back( AnimatedImagesPeer::CachedImage{ rImageURL, nullptr } ); + } + } + + + } + + + //= AnimatedImagesPeer + + + AnimatedImagesPeer::AnimatedImagesPeer() + { + } + + + AnimatedImagesPeer::~AnimatedImagesPeer() + { + } + + + void SAL_CALL AnimatedImagesPeer::startAnimation() + { + SolarMutexGuard aGuard; + VclPtr pThrobber = GetAsDynamic(); + if (pThrobber) + pThrobber->start(); + } + + void SAL_CALL AnimatedImagesPeer::stopAnimation() + { + SolarMutexGuard aGuard; + VclPtr pThrobber = GetAsDynamic(); + if (pThrobber) + pThrobber->stop(); + } + + sal_Bool SAL_CALL AnimatedImagesPeer::isAnimationRunning() + { + SolarMutexGuard aGuard; + VclPtr pThrobber = GetAsDynamic(); + if (pThrobber) + return pThrobber->isRunning(); + return false; + } + + void SAL_CALL AnimatedImagesPeer::setProperty( const OUString& i_propertyName, const Any& i_value ) + { + SolarMutexGuard aGuard; + + VclPtr pThrobber = GetAsDynamic(); + if ( pThrobber ) + { + VCLXWindow::setProperty( i_propertyName, i_value ); + return; + } + + const sal_uInt16 nPropertyId = GetPropertyId( i_propertyName ); + switch ( nPropertyId ) + { + case BASEPROPERTY_STEP_TIME: + { + sal_Int32 nStepTime( 0 ); + if ( i_value >>= nStepTime ) + pThrobber->setStepTime( nStepTime ); + break; + } + case BASEPROPERTY_AUTO_REPEAT: + { + bool bRepeat( true ); + if ( i_value >>= bRepeat ) + pThrobber->setRepeat( bRepeat ); + break; + } + + case BASEPROPERTY_IMAGE_SCALE_MODE: + { + sal_Int16 nScaleMode( ImageScaleMode::ANISOTROPIC ); + VclPtr pImageControl = GetAsDynamic< ImageControl >(); + if ( pImageControl && ( i_value >>= nScaleMode ) ) + pImageControl->SetScaleMode( nScaleMode ); + } + break; + + default: + AnimatedImagesPeer_Base::setProperty( i_propertyName, i_value ); + break; + } + } + + + Any SAL_CALL AnimatedImagesPeer::getProperty( const OUString& i_propertyName ) + { + SolarMutexGuard aGuard; + + Any aReturn; + + VclPtr pThrobber = GetAsDynamic(); + if ( !pThrobber ) + return VCLXWindow::getProperty( i_propertyName ); + + const sal_uInt16 nPropertyId = GetPropertyId( i_propertyName ); + switch ( nPropertyId ) + { + case BASEPROPERTY_STEP_TIME: + aReturn <<= pThrobber->getStepTime(); + break; + + case BASEPROPERTY_AUTO_REPEAT: + aReturn <<= pThrobber->getRepeat(); + break; + + case BASEPROPERTY_IMAGE_SCALE_MODE: + { + VclPtr pImageControl = GetAsDynamic(); + aReturn <<= ( pImageControl ? pImageControl->GetScaleMode() : ImageScaleMode::ANISOTROPIC ); + } + break; + + default: + aReturn = AnimatedImagesPeer_Base::getProperty( i_propertyName ); + break; + } + + return aReturn; + } + + + void AnimatedImagesPeer::ProcessWindowEvent( const VclWindowEvent& i_windowEvent ) + { + if ( i_windowEvent.GetId() == VclEventId::WindowResize ) + { + updateImageList_nothrow(); + } + + AnimatedImagesPeer_Base::ProcessWindowEvent( i_windowEvent ); + } + + + void AnimatedImagesPeer::impl_updateImages_nolck( const Reference< XInterface >& i_animatedImages ) + { + SolarMutexGuard aGuard; + + updateImageList_nothrow( Reference< XAnimatedImages >( i_animatedImages, UNO_QUERY_THROW ) ); + } + + + void SAL_CALL AnimatedImagesPeer::elementInserted( const ContainerEvent& i_event ) + { + SolarMutexGuard aGuard; + Reference< XAnimatedImages > xAnimatedImages( i_event.Source, UNO_QUERY_THROW ); + + sal_Int32 nPosition(0); + OSL_VERIFY( i_event.Accessor >>= nPosition ); + size_t position = size_t( nPosition ); + if ( position > maCachedImageSets.size() ) + { + OSL_ENSURE( false, "AnimatedImagesPeer::elementInserted: illegal accessor/index!" ); + updateImageList_nothrow( xAnimatedImages ); + } + + Sequence< OUString > aImageURLs; + OSL_VERIFY( i_event.Element >>= aImageURLs ); + ::std::vector< CachedImage > aImages; + lcl_init( aImageURLs, aImages ); + maCachedImageSets.insert( maCachedImageSets.begin() + position, aImages ); + updateImageList_nothrow(); + } + + + void SAL_CALL AnimatedImagesPeer::elementRemoved( const ContainerEvent& i_event ) + { + SolarMutexGuard aGuard; + Reference< XAnimatedImages > xAnimatedImages( i_event.Source, UNO_QUERY_THROW ); + + sal_Int32 nPosition(0); + OSL_VERIFY( i_event.Accessor >>= nPosition ); + size_t position = size_t( nPosition ); + if ( position >= maCachedImageSets.size() ) + { + OSL_ENSURE( false, "AnimatedImagesPeer::elementRemoved: illegal accessor/index!" ); + updateImageList_nothrow( xAnimatedImages ); + } + + maCachedImageSets.erase( maCachedImageSets.begin() + position ); + updateImageList_nothrow(); + } + + + void SAL_CALL AnimatedImagesPeer::elementReplaced( const ContainerEvent& i_event ) + { + SolarMutexGuard aGuard; + Reference< XAnimatedImages > xAnimatedImages( i_event.Source, UNO_QUERY_THROW ); + + sal_Int32 nPosition(0); + OSL_VERIFY( i_event.Accessor >>= nPosition ); + size_t position = size_t( nPosition ); + if ( position >= maCachedImageSets.size() ) + { + OSL_ENSURE( false, "AnimatedImagesPeer::elementReplaced: illegal accessor/index!" ); + updateImageList_nothrow( xAnimatedImages ); + } + + Sequence< OUString > aImageURLs; + OSL_VERIFY( i_event.Element >>= aImageURLs ); + ::std::vector< CachedImage > aImages; + lcl_init( aImageURLs, aImages ); + maCachedImageSets[ position ] = aImages; + updateImageList_nothrow(); + } + + + void SAL_CALL AnimatedImagesPeer::disposing( const EventObject& i_event ) + { + VCLXWindow::disposing( i_event ); + } + + + void SAL_CALL AnimatedImagesPeer::modified( const EventObject& i_event ) + { + impl_updateImages_nolck( i_event.Source ); + } + + + void SAL_CALL AnimatedImagesPeer::dispose( ) + { + AnimatedImagesPeer_Base::dispose(); + SolarMutexGuard aGuard; + maCachedImageSets.resize(0); + } + + void AnimatedImagesPeer::updateImageList_nothrow() + { + VclPtr pThrobber = GetAsDynamic(); + if ( !pThrobber ) + return; + + try + { + // collect the image sizes of the different image sets + const Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); + const Reference< XGraphicProvider > xGraphicProvider( css::graphic::GraphicProvider::create(xContext) ); + + const bool isHighContrast = pThrobber->GetSettings().GetStyleSettings().GetHighContrastMode(); + + sal_Int32 nPreferredSet = -1; + const size_t nImageSetCount = maCachedImageSets.size(); + if ( nImageSetCount < 2 ) + { + nPreferredSet = sal_Int32( nImageSetCount ) - 1; + } + else + { + ::std::vector< Size > aImageSizes( nImageSetCount ); + for ( size_t nImageSet = 0; nImageSet < nImageSetCount; ++nImageSet ) + { + ::std::vector< CachedImage > const& rImageSet( maCachedImageSets[ nImageSet ] ); + if ( ( rImageSet.empty() ) + || ( !lcl_ensureImage_throw( xGraphicProvider, isHighContrast, rImageSet[0] ) ) + ) + { + aImageSizes[ nImageSet ] = Size( SAL_MAX_INT32, SAL_MAX_INT32 ); + } + else + { + aImageSizes[ nImageSet ] = lcl_getGraphicSizePixel( rImageSet[0].xGraphic ); + } + } + + // find the set with the smallest difference between window size and image size + const ::Size aWindowSizePixel = pThrobber->GetSizePixel(); + tools::Long nMinimalDistance = ::std::numeric_limits< tools::Long >::max(); + for ( ::std::vector< Size >::const_iterator check = aImageSizes.begin(); + check != aImageSizes.end(); + ++check + ) + { + if ( ( check->Width > aWindowSizePixel.Width() ) + || ( check->Height > aWindowSizePixel.Height() ) + ) + // do not use an image set which doesn't fit into the window + continue; + + const sal_Int64 distance = + ( aWindowSizePixel.Width() - check->Width ) * ( aWindowSizePixel.Width() - check->Width ) + + ( aWindowSizePixel.Height() - check->Height ) * ( aWindowSizePixel.Height() - check->Height ); + if ( distance < nMinimalDistance ) + { + nMinimalDistance = distance; + nPreferredSet = check - aImageSizes.begin(); + } + } + } + + // found a set? + std::vector< Image > aImages; + if ( ( nPreferredSet >= 0 ) && ( o3tl::make_unsigned( nPreferredSet ) < nImageSetCount ) ) + { + // => set the images + ::std::vector< CachedImage > const& rImageSet( maCachedImageSets[ nPreferredSet ] ); + aImages.resize( rImageSet.size() ); + sal_Int32 imageIndex = 0; + for ( const auto& rCachedImage : rImageSet ) + { + lcl_ensureImage_throw( xGraphicProvider, isHighContrast, rCachedImage ); + aImages[ imageIndex++ ] = Image(rCachedImage.xGraphic); + } + } + pThrobber->setImageList( std::move(aImages) ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION("toolkit"); + } + } + + + void AnimatedImagesPeer::updateImageList_nothrow( const Reference< XAnimatedImages >& i_images ) + { + try + { + const sal_Int32 nImageSetCount = i_images->getImageSetCount(); + maCachedImageSets.resize(0); + for ( sal_Int32 set = 0; set < nImageSetCount; ++set ) + { + const Sequence< OUString > aImageURLs( i_images->getImageSet( set ) ); + ::std::vector< CachedImage > aImages; + lcl_init( aImageURLs, aImages ); + maCachedImageSets.push_back( aImages ); + } + + updateImageList_nothrow(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION("toolkit"); + } + } + +} // namespace toolkit + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/source/awt/asynccallback.cxx b/toolkit/source/awt/asynccallback.cxx new file mode 100644 index 000000000..751647447 --- /dev/null +++ b/toolkit/source/awt/asynccallback.cxx @@ -0,0 +1,121 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include + +#include +#include +#include +#include +#include +#include + +/// anonymous implementation namespace +namespace { + +class AsyncCallback: + public ::cppu::WeakImplHelper< + css::lang::XServiceInfo, + css::awt::XRequestCallback> +{ +public: + AsyncCallback() {} + AsyncCallback(const AsyncCallback&) = delete; + AsyncCallback& operator=(const AsyncCallback&) = delete; + + // css::lang::XServiceInfo: + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService(const OUString & ServiceName) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + + // css::awt::XRequestCallback: + virtual void SAL_CALL addCallback(const css::uno::Reference< css::awt::XCallback > & xCallback, const css::uno::Any & aData) override; + +private: + + struct CallbackData + { + CallbackData( const css::uno::Reference< css::awt::XCallback >& rCallback, const css::uno::Any& rAny ) : + xCallback( rCallback ), aData( rAny ) {} + + css::uno::Reference< css::awt::XCallback > xCallback; + css::uno::Any aData; + }; + + DECL_STATIC_LINK( AsyncCallback, Notify_Impl, void*, void ); + + virtual ~AsyncCallback() override {} +}; + +// com.sun.star.uno.XServiceInfo: +OUString SAL_CALL AsyncCallback::getImplementationName() +{ + return "com.sun.star.awt.comp.AsyncCallback"; +} + +sal_Bool SAL_CALL AsyncCallback::supportsService(OUString const & serviceName) +{ + return cppu::supportsService(this, serviceName); +} + +css::uno::Sequence< OUString > SAL_CALL AsyncCallback::getSupportedServiceNames() +{ + return { "com.sun.star.awt.AsyncCallback" }; +} + +// css::awt::XRequestCallback: +void SAL_CALL AsyncCallback::addCallback(const css::uno::Reference< css::awt::XCallback > & xCallback, const css::uno::Any & aData) +{ + if ( Application::IsInMain() ) + { + // NOTE: We don't need SolarMutexGuard here as Application::PostUserEvent is thread-safe + CallbackData* pCallbackData = new CallbackData( xCallback, aData ); + Application::PostUserEvent( LINK( this, AsyncCallback, Notify_Impl ), pCallbackData ); + } +} + +// private asynchronous link to call reference to the callback object +IMPL_STATIC_LINK( AsyncCallback, Notify_Impl, void*, p, void ) +{ + CallbackData* pCallbackData = static_cast(p); + try + { + // Asynchronous execution + // Check pointer and reference before! + if ( pCallbackData && pCallbackData->xCallback.is() ) + pCallbackData->xCallback->notify( pCallbackData->aData ); + } + catch ( css::uno::Exception& ) + { + } + + delete pCallbackData; +} + +} // closing anonymous implementation namespace + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * +com_sun_star_awt_comp_AsyncCallback_get_implementation( + css::uno::XComponentContext *, + css::uno::Sequence const &) +{ + return cppu::acquire(new AsyncCallback()); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/source/awt/non-interactable-containers.xml b/toolkit/source/awt/non-interactable-containers.xml new file mode 100644 index 000000000..00f3f2a93 --- /dev/null +++ b/toolkit/source/awt/non-interactable-containers.xml @@ -0,0 +1,32 @@ + + + + + + + + + + +
+
+
diff --git a/toolkit/source/awt/scrollabledialog.cxx b/toolkit/source/awt/scrollabledialog.cxx new file mode 100644 index 000000000..bcc8d18e0 --- /dev/null +++ b/toolkit/source/awt/scrollabledialog.cxx @@ -0,0 +1,173 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include +#include + +namespace toolkit +{ + +// Using WB_AUTOHSCROLL, WB_AUTOVSCROLL here sucks big time, there is a +// problem in the toolkit class where there are some clashing IDs +// ( css::awt::VclWindowPeerAttribute::VSCROLL has the same value +// as css::awt::WindowAttribute::NODECORATION and they are used +// in the same bitmap :-( WB_VSCROLL & WB_HSCROLL apparently are only for +// child classes ( whole thing is a mess if you ask me ) +ScrollableDialog::ScrollableDialog( vcl::Window* pParent, WinBits nStyle, Dialog::InitFlag eFlag ) + : Dialog( pParent, nStyle & ~( WB_AUTOHSCROLL | WB_AUTOVSCROLL ), eFlag ), + maHScrollBar( VclPtr::Create(this, WB_HSCROLL | WB_DRAG) ), + maVScrollBar( VclPtr::Create(this, WB_VSCROLL | WB_DRAG) ), + mbHasHoriBar( false ), + mbHasVertBar( false ), + maScrollVis( None ) +{ + Link aLink( LINK( this, ScrollableDialog, ScrollBarHdl ) ); + maVScrollBar->SetScrollHdl( aLink ); + maHScrollBar->SetScrollHdl( aLink ); + + ScrollBarVisibility aVis = None; + + if ( nStyle & ( WB_AUTOHSCROLL | WB_AUTOVSCROLL ) ) + { + if ( nStyle & WB_AUTOHSCROLL ) + aVis = Hori; + if ( nStyle & WB_AUTOVSCROLL ) + { + if ( aVis == Hori ) + aVis = Both; + else + aVis = Vert; + } + } + setScrollVisibility( aVis ); + mnScrWidth = Dialog::GetSettings().GetStyleSettings().GetScrollBarSize(); +} + +void ScrollableDialog::setScrollVisibility( ScrollBarVisibility rVisState ) +{ + maScrollVis = rVisState; + if ( maScrollVis == Hori || maScrollVis == Both ) + { + mbHasHoriBar = true; + maHScrollBar->Show(); + } + if ( maScrollVis == Vert || maScrollVis == Both ) + { + mbHasVertBar = true; + maVScrollBar->Show(); + } + if ( mbHasHoriBar || mbHasVertBar ) + SetStyle( Dialog::GetStyle() | WB_CLIPCHILDREN ); +} + +ScrollableDialog::~ScrollableDialog() +{ + disposeOnce(); +} + +void ScrollableDialog::dispose() +{ + maHScrollBar.disposeAndClear(); + maVScrollBar.disposeAndClear(); + Dialog::dispose(); +} + +void ScrollableDialog::lcl_Scroll( tools::Long nX, tools::Long nY ) +{ + tools::Long nXScroll = mnScrollPos.X() - nX; + tools::Long nYScroll = mnScrollPos.Y() - nY; + mnScrollPos = Point( nX, nY ); + + tools::Rectangle aScrollableArea( 0, 0, maScrollArea.Width(), maScrollArea.Height() ); + Scroll(nXScroll, nYScroll, aScrollableArea ); + // Manually scroll all children ( except the scrollbars ) + for ( int index = 0; index < GetChildCount(); ++index ) + { + vcl::Window* pChild = GetChild( index ); + if ( pChild && pChild != maVScrollBar.get() && pChild != maHScrollBar.get() ) + { + Point aPos = pChild->GetPosPixel(); + aPos += Point( nXScroll, nYScroll ); + pChild->SetPosPixel( aPos ); + } + } +} + +IMPL_LINK( ScrollableDialog, ScrollBarHdl, ScrollBar*, pSB, void ) +{ + sal_uInt16 nPos = static_cast(pSB->GetThumbPos()); + if( pSB == maVScrollBar.get() ) + lcl_Scroll(mnScrollPos.X(), nPos ); + else if( pSB == maHScrollBar.get() ) + lcl_Scroll(nPos, mnScrollPos.Y() ); +} + +void ScrollableDialog::SetScrollTop( tools::Long nTop ) +{ + Point aOld = mnScrollPos; + lcl_Scroll( mnScrollPos.X() , mnScrollPos.Y() - nTop ); + maHScrollBar->SetThumbPos( 0 ); + // new pos is 0,0 + mnScrollPos = aOld; +} +void ScrollableDialog::SetScrollLeft( tools::Long nLeft ) +{ + Point aOld = mnScrollPos; + lcl_Scroll( mnScrollPos.X() - nLeft , mnScrollPos.Y() ); + maVScrollBar->SetThumbPos( 0 ); + // new pos is 0,0 + mnScrollPos = aOld; +} + +void ScrollableDialog::SetScrollWidth( tools::Long nWidth ) +{ + maScrollArea.setWidth( nWidth ); + ResetScrollBars(); +} + +void ScrollableDialog::SetScrollHeight( tools::Long nHeight ) +{ + maScrollArea.setHeight( nHeight ); + ResetScrollBars(); +} + +void ScrollableDialog::Resize() +{ + ResetScrollBars(); +} + +void ScrollableDialog::ResetScrollBars() +{ + Size aOutSz = GetOutputSizePixel(); + + Point aVPos( aOutSz.Width() - mnScrWidth, 0 ); + Point aHPos( 0, aOutSz.Height() - mnScrWidth ); + + maVScrollBar->SetPosSizePixel( aVPos, Size( mnScrWidth, GetSizePixel().Height() - mnScrWidth ) ); + maHScrollBar->SetPosSizePixel( aHPos, Size( GetSizePixel().Width() - mnScrWidth, mnScrWidth ) ); + + maHScrollBar->SetRangeMax( maScrollArea.Width() + mnScrWidth ); + maHScrollBar->SetVisibleSize( GetSizePixel().Width() ); + + maVScrollBar->SetRangeMax( maScrollArea.Height() + mnScrWidth ); + maVScrollBar->SetVisibleSize( GetSizePixel().Height() ); +} + +} // toolkit +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/source/awt/stylesettings.cxx b/toolkit/source/awt/stylesettings.cxx new file mode 100644 index 000000000..75c2b687d --- /dev/null +++ b/toolkit/source/awt/stylesettings.cxx @@ -0,0 +1,926 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + + +#include "stylesettings.hxx" +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + + +namespace toolkit +{ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::lang::DisposedException; + using ::com::sun::star::lang::EventObject; + using ::com::sun::star::awt::FontDescriptor; + using ::com::sun::star::awt::XStyleChangeListener; + + + IMPL_LINK( WindowStyleSettings, OnWindowEvent, VclWindowEvent&, rEvent, void ) + { + if ( rEvent.GetId() != VclEventId::WindowDataChanged ) + return; + const DataChangedEvent* pDataChangedEvent = static_cast< const DataChangedEvent* >( rEvent.GetData() ); + if ( !pDataChangedEvent || ( pDataChangedEvent->GetType() != DataChangedEventType::SETTINGS ) ) + return; + if ( !( pDataChangedEvent->GetFlags() & AllSettingsFlags::STYLE ) ) + return; + + EventObject aEvent( *pOwningWindow ); + aStyleChangeListeners.notifyEach( &XStyleChangeListener::styleSettingsChanged, aEvent ); + } + + + //= StyleMethodGuard + + namespace { + + class StyleMethodGuard + { + public: + explicit StyleMethodGuard( const VCLXWindow* pOwningWindow ) + { + if ( pOwningWindow == nullptr ) + throw DisposedException(); + } + + private: + SolarMutexGuard m_aGuard; + }; + + } + + //= WindowStyleSettings + + + WindowStyleSettings::WindowStyleSettings(::osl::Mutex& i_rListenerMutex, VCLXWindow& i_rOwningWindow ) + : pOwningWindow( &i_rOwningWindow ) + ,aStyleChangeListeners( i_rListenerMutex ) + { + VclPtr pWindow = i_rOwningWindow.GetWindow(); + if ( !pWindow ) + throw RuntimeException(); + pWindow->AddEventListener( LINK( this, WindowStyleSettings, OnWindowEvent ) ); + } + + + WindowStyleSettings::~WindowStyleSettings() + { + } + + + void WindowStyleSettings::dispose() + { + StyleMethodGuard aGuard( pOwningWindow ); + + VclPtr pWindow = pOwningWindow->GetWindow(); + OSL_ENSURE( pWindow, "WindowStyleSettings::dispose: window has been reset before we could revoke the listener!" ); + if ( pWindow ) + pWindow->RemoveEventListener( LINK( this, WindowStyleSettings, OnWindowEvent ) ); + + EventObject aEvent( *this ); + aStyleChangeListeners.disposeAndClear( aEvent ); + + pOwningWindow = nullptr; + } + + + sal_Int32 WindowStyleSettings::ImplGetStyleColor( Color const & (StyleSettings::*i_pGetter)() const ) const + { + const VclPtr& pWindow = pOwningWindow->GetWindow(); + const AllSettings aAllSettings = pWindow->GetSettings(); + const StyleSettings& aStyleSettings = aAllSettings.GetStyleSettings(); + return sal_Int32((aStyleSettings.*i_pGetter)()); + } + + void WindowStyleSettings::ImplSetStyleColor( void (StyleSettings::*i_pSetter)( Color const & ), sal_Int32 i_nColor ) + { + VclPtr pWindow = pOwningWindow->GetWindow(); + AllSettings aAllSettings = pWindow->GetSettings(); + StyleSettings aStyleSettings = aAllSettings.GetStyleSettings(); + (aStyleSettings.*i_pSetter)( Color(ColorTransparency, i_nColor) ); + aAllSettings.SetStyleSettings( aStyleSettings ); + pWindow->SetSettings( aAllSettings ); + } + + FontDescriptor WindowStyleSettings::ImplGetStyleFont( vcl::Font const & (StyleSettings::*i_pGetter)() const ) const + { + const VclPtr& pWindow = pOwningWindow->GetWindow(); + const AllSettings aAllSettings = pWindow->GetSettings(); + const StyleSettings& aStyleSettings = aAllSettings.GetStyleSettings(); + return VCLUnoHelper::CreateFontDescriptor( (aStyleSettings.*i_pGetter)() ); + } + + void WindowStyleSettings::ImplSetStyleFont( void (StyleSettings::*i_pSetter)( vcl::Font const &), + vcl::Font const & (StyleSettings::*i_pGetter)() const, const FontDescriptor& i_rFont ) + { + VclPtr pWindow = pOwningWindow->GetWindow(); + AllSettings aAllSettings = pWindow->GetSettings(); + StyleSettings aStyleSettings = aAllSettings.GetStyleSettings(); + const vcl::Font aNewFont = VCLUnoHelper::CreateFont( i_rFont, (aStyleSettings.*i_pGetter)() ); + (aStyleSettings.*i_pSetter)( aNewFont ); + aAllSettings.SetStyleSettings( aStyleSettings ); + pWindow->SetSettings( aAllSettings ); + } + + ::sal_Int32 SAL_CALL WindowStyleSettings::getActiveBorderColor() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleColor( &StyleSettings::GetActiveBorderColor ); + } + + + void SAL_CALL WindowStyleSettings::setActiveBorderColor( ::sal_Int32 _activebordercolor ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleColor( &StyleSettings::SetActiveBorderColor, _activebordercolor ); + } + + + ::sal_Int32 SAL_CALL WindowStyleSettings::getActiveColor() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleColor( &StyleSettings::GetActiveColor ); + } + + + void SAL_CALL WindowStyleSettings::setActiveColor( ::sal_Int32 _activecolor ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleColor( &StyleSettings::SetActiveColor, _activecolor ); + } + + + ::sal_Int32 SAL_CALL WindowStyleSettings::getActiveTabColor() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleColor( &StyleSettings::GetActiveTabColor ); + } + + + void SAL_CALL WindowStyleSettings::setActiveTabColor( ::sal_Int32 _activetabcolor ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleColor( &StyleSettings::SetActiveTabColor, _activetabcolor ); + } + + + ::sal_Int32 SAL_CALL WindowStyleSettings::getActiveTextColor() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleColor( &StyleSettings::GetActiveTextColor ); + } + + + void SAL_CALL WindowStyleSettings::setActiveTextColor( ::sal_Int32 _activetextcolor ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleColor( &StyleSettings::SetActiveTextColor, _activetextcolor ); + } + + + ::sal_Int32 SAL_CALL WindowStyleSettings::getButtonRolloverTextColor() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleColor( &StyleSettings::GetButtonRolloverTextColor ); + } + + + void SAL_CALL WindowStyleSettings::setButtonRolloverTextColor( ::sal_Int32 _buttonrollovertextcolor ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleColor( &StyleSettings::SetButtonRolloverTextColor, _buttonrollovertextcolor ); + // Also need to set ActionButtonRolloverTextColor as this setting can't be + // set through the UNO interface otherwise. + // Previously this setting was used to set colors for both scenarios, + // but action button setting was added to differentiate the buttons from + // "normal" buttons in some themes. + ImplSetStyleColor( &StyleSettings::SetActionButtonRolloverTextColor, _buttonrollovertextcolor ); + } + + + ::sal_Int32 SAL_CALL WindowStyleSettings::getButtonTextColor() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleColor( &StyleSettings::GetButtonTextColor ); + } + + + void SAL_CALL WindowStyleSettings::setButtonTextColor( ::sal_Int32 _buttontextcolor ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleColor( &StyleSettings::SetButtonTextColor, _buttontextcolor ); + // Also need to set ActionButtonTextColor and DefaultActionButtonTextColor + // as this two settings can't be set through the UNO interface otherwise. + // Previously this setting was used to set colors for all three scenarios, + // but action button setting was added to differentiate the buttons from + // "normal" buttons in some themes. + ImplSetStyleColor( &StyleSettings::SetActionButtonTextColor, _buttontextcolor ); + ImplSetStyleColor( &StyleSettings::SetDefaultActionButtonTextColor, _buttontextcolor ); + } + + + ::sal_Int32 SAL_CALL WindowStyleSettings::getCheckedColor() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleColor( &StyleSettings::GetCheckedColor ); + } + + + void SAL_CALL WindowStyleSettings::setCheckedColor( ::sal_Int32 _checkedcolor ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleColor( &StyleSettings::SetCheckedColor, _checkedcolor ); + } + + + ::sal_Int32 SAL_CALL WindowStyleSettings::getDarkShadowColor() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleColor( &StyleSettings::GetDarkShadowColor ); + } + + + void SAL_CALL WindowStyleSettings::setDarkShadowColor( ::sal_Int32 _darkshadowcolor ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleColor( &StyleSettings::SetDarkShadowColor, _darkshadowcolor ); + } + + + ::sal_Int32 SAL_CALL WindowStyleSettings::getDeactiveBorderColor() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleColor( &StyleSettings::GetDeactiveBorderColor ); + } + + + void SAL_CALL WindowStyleSettings::setDeactiveBorderColor( ::sal_Int32 _deactivebordercolor ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleColor( &StyleSettings::SetDeactiveBorderColor, _deactivebordercolor ); + } + + + ::sal_Int32 SAL_CALL WindowStyleSettings::getDeactiveColor() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleColor( &StyleSettings::GetDeactiveColor ); + } + + + void SAL_CALL WindowStyleSettings::setDeactiveColor( ::sal_Int32 _deactivecolor ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleColor( &StyleSettings::SetDeactiveColor, _deactivecolor ); + } + + + ::sal_Int32 SAL_CALL WindowStyleSettings::getDeactiveTextColor() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleColor( &StyleSettings::GetDeactiveTextColor ); + } + + + void SAL_CALL WindowStyleSettings::setDeactiveTextColor( ::sal_Int32 _deactivetextcolor ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleColor( &StyleSettings::SetDeactiveTextColor, _deactivetextcolor ); + } + + + ::sal_Int32 SAL_CALL WindowStyleSettings::getDialogColor() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleColor( &StyleSettings::GetDialogColor ); + } + + + void SAL_CALL WindowStyleSettings::setDialogColor( ::sal_Int32 _dialogcolor ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleColor( &StyleSettings::SetDialogColor, _dialogcolor ); + } + + + ::sal_Int32 SAL_CALL WindowStyleSettings::getDialogTextColor() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleColor( &StyleSettings::GetDialogTextColor ); + } + + + void SAL_CALL WindowStyleSettings::setDialogTextColor( ::sal_Int32 _dialogtextcolor ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleColor( &StyleSettings::SetDialogTextColor, _dialogtextcolor ); + } + + + ::sal_Int32 SAL_CALL WindowStyleSettings::getDisableColor() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleColor( &StyleSettings::GetDisableColor ); + } + + + void SAL_CALL WindowStyleSettings::setDisableColor( ::sal_Int32 _disablecolor ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleColor( &StyleSettings::SetDisableColor, _disablecolor ); + } + + + ::sal_Int32 SAL_CALL WindowStyleSettings::getFaceColor() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleColor( &StyleSettings::GetFaceColor ); + } + + + void SAL_CALL WindowStyleSettings::setFaceColor( ::sal_Int32 _facecolor ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleColor( &StyleSettings::SetFaceColor, _facecolor ); + } + + + ::sal_Int32 SAL_CALL WindowStyleSettings::getFaceGradientColor() + { + StyleMethodGuard aGuard( pOwningWindow ); + const VclPtr& pWindow = pOwningWindow->GetWindow(); + const AllSettings aAllSettings = pWindow->GetSettings(); + const StyleSettings& aStyleSettings = aAllSettings.GetStyleSettings(); + return sal_Int32(aStyleSettings.GetFaceGradientColor()); + } + + + ::sal_Int32 SAL_CALL WindowStyleSettings::getFieldColor() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleColor( &StyleSettings::GetFieldColor ); + } + + + void SAL_CALL WindowStyleSettings::setFieldColor( ::sal_Int32 _fieldcolor ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleColor( &StyleSettings::SetFieldColor, _fieldcolor ); + } + + + ::sal_Int32 SAL_CALL WindowStyleSettings::getFieldRolloverTextColor() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleColor( &StyleSettings::GetFieldRolloverTextColor ); + } + + + void SAL_CALL WindowStyleSettings::setFieldRolloverTextColor( ::sal_Int32 _fieldrollovertextcolor ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleColor( &StyleSettings::SetFieldRolloverTextColor, _fieldrollovertextcolor ); + } + + + ::sal_Int32 SAL_CALL WindowStyleSettings::getFieldTextColor() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleColor( &StyleSettings::GetFieldTextColor ); + } + + + void SAL_CALL WindowStyleSettings::setFieldTextColor( ::sal_Int32 _fieldtextcolor ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleColor( &StyleSettings::SetFieldTextColor, _fieldtextcolor ); + } + + + ::sal_Int32 SAL_CALL WindowStyleSettings::getGroupTextColor() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleColor( &StyleSettings::GetGroupTextColor ); + } + + + void SAL_CALL WindowStyleSettings::setGroupTextColor( ::sal_Int32 _grouptextcolor ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleColor( &StyleSettings::SetGroupTextColor, _grouptextcolor ); + } + + + ::sal_Int32 SAL_CALL WindowStyleSettings::getHelpColor() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleColor( &StyleSettings::GetHelpColor ); + } + + + void SAL_CALL WindowStyleSettings::setHelpColor( ::sal_Int32 _helpcolor ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleColor( &StyleSettings::SetHelpColor, _helpcolor ); + } + + + ::sal_Int32 SAL_CALL WindowStyleSettings::getHelpTextColor() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleColor( &StyleSettings::GetHelpTextColor ); + } + + + void SAL_CALL WindowStyleSettings::setHelpTextColor( ::sal_Int32 _helptextcolor ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleColor( &StyleSettings::SetHelpTextColor, _helptextcolor ); + } + + + ::sal_Int32 SAL_CALL WindowStyleSettings::getHighlightColor() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleColor( &StyleSettings::GetHighlightColor ); + } + + + void SAL_CALL WindowStyleSettings::setHighlightColor( ::sal_Int32 _highlightcolor ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleColor( &StyleSettings::SetHighlightColor, _highlightcolor ); + } + + + ::sal_Int32 SAL_CALL WindowStyleSettings::getHighlightTextColor() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleColor( &StyleSettings::GetHighlightTextColor ); + } + + + void SAL_CALL WindowStyleSettings::setHighlightTextColor( ::sal_Int32 _highlighttextcolor ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleColor( &StyleSettings::SetHighlightTextColor, _highlighttextcolor ); + } + + + ::sal_Int32 SAL_CALL WindowStyleSettings::getInactiveTabColor() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleColor( &StyleSettings::GetInactiveTabColor ); + } + + + void SAL_CALL WindowStyleSettings::setInactiveTabColor( ::sal_Int32 _inactivetabcolor ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleColor( &StyleSettings::SetInactiveTabColor, _inactivetabcolor ); + } + + + ::sal_Int32 SAL_CALL WindowStyleSettings::getLabelTextColor() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleColor( &StyleSettings::GetLabelTextColor ); + } + + + void SAL_CALL WindowStyleSettings::setLabelTextColor( ::sal_Int32 _labeltextcolor ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleColor( &StyleSettings::SetLabelTextColor, _labeltextcolor ); + } + + + ::sal_Int32 SAL_CALL WindowStyleSettings::getLightColor() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleColor( &StyleSettings::GetLightColor ); + } + + + void SAL_CALL WindowStyleSettings::setLightColor( ::sal_Int32 _lightcolor ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleColor( &StyleSettings::SetLightColor, _lightcolor ); + } + + + ::sal_Int32 SAL_CALL WindowStyleSettings::getMenuBarColor() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleColor( &StyleSettings::GetMenuBarColor ); + } + + + void SAL_CALL WindowStyleSettings::setMenuBarColor( ::sal_Int32 _menubarcolor ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleColor( &StyleSettings::SetMenuBarColor, _menubarcolor ); + } + + + ::sal_Int32 SAL_CALL WindowStyleSettings::getMenuBarTextColor() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleColor( &StyleSettings::GetMenuBarTextColor ); + } + + + void SAL_CALL WindowStyleSettings::setMenuBarTextColor( ::sal_Int32 _menubartextcolor ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleColor( &StyleSettings::SetMenuBarTextColor, _menubartextcolor ); + } + + + ::sal_Int32 SAL_CALL WindowStyleSettings::getMenuBorderColor() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleColor( &StyleSettings::GetMenuBorderColor ); + } + + + void SAL_CALL WindowStyleSettings::setMenuBorderColor( ::sal_Int32 _menubordercolor ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleColor( &StyleSettings::SetMenuBorderColor, _menubordercolor ); + } + + + ::sal_Int32 SAL_CALL WindowStyleSettings::getMenuColor() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleColor( &StyleSettings::GetMenuColor ); + } + + + void SAL_CALL WindowStyleSettings::setMenuColor( ::sal_Int32 _menucolor ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleColor( &StyleSettings::SetMenuColor, _menucolor ); + } + + + ::sal_Int32 SAL_CALL WindowStyleSettings::getMenuHighlightColor() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleColor( &StyleSettings::GetMenuHighlightColor ); + } + + + void SAL_CALL WindowStyleSettings::setMenuHighlightColor( ::sal_Int32 _menuhighlightcolor ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleColor( &StyleSettings::SetMenuHighlightColor, _menuhighlightcolor ); + } + + + ::sal_Int32 SAL_CALL WindowStyleSettings::getMenuHighlightTextColor() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleColor( &StyleSettings::GetMenuHighlightTextColor ); + } + + + void SAL_CALL WindowStyleSettings::setMenuHighlightTextColor( ::sal_Int32 _menuhighlighttextcolor ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleColor( &StyleSettings::SetMenuHighlightTextColor, _menuhighlighttextcolor ); + } + + + ::sal_Int32 SAL_CALL WindowStyleSettings::getMenuTextColor() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleColor( &StyleSettings::GetMenuTextColor ); + } + + + void SAL_CALL WindowStyleSettings::setMenuTextColor( ::sal_Int32 _menutextcolor ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleColor( &StyleSettings::SetMenuTextColor, _menutextcolor ); + } + + + ::sal_Int32 SAL_CALL WindowStyleSettings::getMonoColor() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleColor( &StyleSettings::GetMonoColor ); + } + + + void SAL_CALL WindowStyleSettings::setMonoColor( ::sal_Int32 _monocolor ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleColor( &StyleSettings::SetMonoColor, _monocolor ); + } + + + ::sal_Int32 SAL_CALL WindowStyleSettings::getRadioCheckTextColor() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleColor( &StyleSettings::GetRadioCheckTextColor ); + } + + + void SAL_CALL WindowStyleSettings::setRadioCheckTextColor( ::sal_Int32 _radiochecktextcolor ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleColor( &StyleSettings::SetRadioCheckTextColor, _radiochecktextcolor ); + } + + + ::sal_Int32 SAL_CALL WindowStyleSettings::getSeparatorColor() + { + StyleMethodGuard aGuard( pOwningWindow ); + const VclPtr& pWindow = pOwningWindow->GetWindow(); + const AllSettings aAllSettings = pWindow->GetSettings(); + const StyleSettings& aStyleSettings = aAllSettings.GetStyleSettings(); + return sal_Int32(aStyleSettings.GetSeparatorColor()); + } + + + ::sal_Int32 SAL_CALL WindowStyleSettings::getShadowColor() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleColor( &StyleSettings::GetShadowColor ); + } + + + void SAL_CALL WindowStyleSettings::setShadowColor( ::sal_Int32 _shadowcolor ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleColor( &StyleSettings::SetShadowColor, _shadowcolor ); + } + + + ::sal_Int32 SAL_CALL WindowStyleSettings::getWindowColor() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleColor( &StyleSettings::GetWindowColor ); + } + + + void SAL_CALL WindowStyleSettings::setWindowColor( ::sal_Int32 _windowcolor ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleColor( &StyleSettings::SetWindowColor, _windowcolor ); + } + + + ::sal_Int32 SAL_CALL WindowStyleSettings::getWindowTextColor() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleColor( &StyleSettings::GetWindowTextColor ); + } + + + void SAL_CALL WindowStyleSettings::setWindowTextColor( ::sal_Int32 _windowtextcolor ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleColor( &StyleSettings::SetWindowTextColor, _windowtextcolor ); + } + + + ::sal_Int32 SAL_CALL WindowStyleSettings::getWorkspaceColor() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleColor( &StyleSettings::GetWorkspaceColor ); + } + + + void SAL_CALL WindowStyleSettings::setWorkspaceColor( ::sal_Int32 _workspacecolor ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleColor( &StyleSettings::SetWorkspaceColor, _workspacecolor ); + } + + + sal_Bool SAL_CALL WindowStyleSettings::getHighContrastMode() + { + StyleMethodGuard aGuard( pOwningWindow ); + const VclPtr& pWindow = pOwningWindow->GetWindow(); + const AllSettings aAllSettings = pWindow->GetSettings(); + const StyleSettings& aStyleSettings = aAllSettings.GetStyleSettings(); + return aStyleSettings.GetHighContrastMode(); + } + + + void SAL_CALL WindowStyleSettings::setHighContrastMode( sal_Bool _highcontrastmode ) + { + StyleMethodGuard aGuard( pOwningWindow ); + VclPtr pWindow = pOwningWindow->GetWindow(); + AllSettings aAllSettings = pWindow->GetSettings(); + StyleSettings aStyleSettings = aAllSettings.GetStyleSettings(); + aStyleSettings.SetHighContrastMode( _highcontrastmode ); + aAllSettings.SetStyleSettings( aStyleSettings ); + pWindow->SetSettings( aAllSettings ); + } + + + FontDescriptor SAL_CALL WindowStyleSettings::getApplicationFont() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleFont( &StyleSettings::GetAppFont ); + } + + + void SAL_CALL WindowStyleSettings::setApplicationFont( const FontDescriptor& _applicationfont ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleFont( &StyleSettings::SetAppFont, &StyleSettings::GetAppFont, _applicationfont ); + } + + + FontDescriptor SAL_CALL WindowStyleSettings::getHelpFont() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleFont( &StyleSettings::GetHelpFont ); + } + + + void SAL_CALL WindowStyleSettings::setHelpFont( const FontDescriptor& _helpfont ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleFont( &StyleSettings::SetHelpFont, &StyleSettings::GetHelpFont, _helpfont ); + } + + + FontDescriptor SAL_CALL WindowStyleSettings::getTitleFont() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleFont( &StyleSettings::GetTitleFont ); + } + + + void SAL_CALL WindowStyleSettings::setTitleFont( const FontDescriptor& _titlefont ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleFont( &StyleSettings::SetTitleFont, &StyleSettings::GetTitleFont, _titlefont ); + } + + + FontDescriptor SAL_CALL WindowStyleSettings::getFloatTitleFont() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleFont( &StyleSettings::GetFloatTitleFont ); + } + + + void SAL_CALL WindowStyleSettings::setFloatTitleFont( const FontDescriptor& _floattitlefont ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleFont( &StyleSettings::SetFloatTitleFont, &StyleSettings::GetFloatTitleFont, _floattitlefont ); + } + + + FontDescriptor SAL_CALL WindowStyleSettings::getMenuFont() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleFont( &StyleSettings::GetMenuFont ); + } + + + void SAL_CALL WindowStyleSettings::setMenuFont( const FontDescriptor& _menufont ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleFont( &StyleSettings::SetMenuFont, &StyleSettings::GetMenuFont, _menufont ); + } + + + FontDescriptor SAL_CALL WindowStyleSettings::getToolFont() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleFont( &StyleSettings::GetToolFont ); + } + + + void SAL_CALL WindowStyleSettings::setToolFont( const FontDescriptor& _toolfont ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleFont( &StyleSettings::SetToolFont, &StyleSettings::GetToolFont, _toolfont ); + } + + + FontDescriptor SAL_CALL WindowStyleSettings::getGroupFont() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleFont( &StyleSettings::GetGroupFont ); + } + + + void SAL_CALL WindowStyleSettings::setGroupFont( const FontDescriptor& _groupfont ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleFont( &StyleSettings::SetGroupFont, &StyleSettings::GetGroupFont, _groupfont ); + } + + + FontDescriptor SAL_CALL WindowStyleSettings::getLabelFont() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleFont( &StyleSettings::GetLabelFont ); + } + + + void SAL_CALL WindowStyleSettings::setLabelFont( const FontDescriptor& _labelfont ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleFont( &StyleSettings::SetLabelFont, &StyleSettings::GetLabelFont, _labelfont ); + } + + + FontDescriptor SAL_CALL WindowStyleSettings::getRadioCheckFont() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleFont( &StyleSettings::GetRadioCheckFont ); + } + + + void SAL_CALL WindowStyleSettings::setRadioCheckFont( const FontDescriptor& _radiocheckfont ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleFont( &StyleSettings::SetRadioCheckFont, &StyleSettings::GetRadioCheckFont, _radiocheckfont ); + } + + + FontDescriptor SAL_CALL WindowStyleSettings::getPushButtonFont() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleFont( &StyleSettings::GetPushButtonFont ); + } + + + void SAL_CALL WindowStyleSettings::setPushButtonFont( const FontDescriptor& _pushbuttonfont ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleFont( &StyleSettings::SetPushButtonFont, &StyleSettings::GetPushButtonFont, _pushbuttonfont ); + } + + + FontDescriptor SAL_CALL WindowStyleSettings::getFieldFont() + { + StyleMethodGuard aGuard( pOwningWindow ); + return ImplGetStyleFont( &StyleSettings::GetFieldFont ); + } + + + void SAL_CALL WindowStyleSettings::setFieldFont( const FontDescriptor& _fieldfont ) + { + StyleMethodGuard aGuard( pOwningWindow ); + ImplSetStyleFont( &StyleSettings::SetFieldFont, &StyleSettings::GetFieldFont, _fieldfont ); + } + + + void SAL_CALL WindowStyleSettings::addStyleChangeListener( const Reference< XStyleChangeListener >& i_rListener ) + { + StyleMethodGuard aGuard( pOwningWindow ); + if ( i_rListener.is() ) + aStyleChangeListeners.addInterface( i_rListener ); + } + + + void SAL_CALL WindowStyleSettings::removeStyleChangeListener( const Reference< XStyleChangeListener >& i_rListener ) + { + StyleMethodGuard aGuard( pOwningWindow ); + if ( i_rListener.is() ) + aStyleChangeListeners.removeInterface( i_rListener ); + } + + +} // namespace toolkit + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/source/awt/stylesettings.hxx b/toolkit/source/awt/stylesettings.hxx new file mode 100644 index 000000000..4e3f0b2df --- /dev/null +++ b/toolkit/source/awt/stylesettings.hxx @@ -0,0 +1,181 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_TOOLKIT_SOURCE_AWT_STYLESETTINGS_HXX +#define INCLUDED_TOOLKIT_SOURCE_AWT_STYLESETTINGS_HXX + +#include + +#include +#include +#include + +namespace osl +{ + class Mutex; +} +class Color; +class VCLXWindow; +class VclWindowEvent; +class StyleSettings; +namespace vcl { class Font; } + +namespace toolkit +{ + + + //= WindowStyleSettings + + typedef ::cppu::WeakImplHelper < css::awt::XStyleSettings + > WindowStyleSettings_Base; + class WindowStyleSettings : public WindowStyleSettings_Base + { + public: + WindowStyleSettings( ::osl::Mutex& i_rListenerMutex, VCLXWindow& i_rOwningWindow ); + virtual ~WindowStyleSettings() override; + + void dispose(); + + // XStyleSettings + virtual ::sal_Int32 SAL_CALL getActiveBorderColor() override; + virtual void SAL_CALL setActiveBorderColor( ::sal_Int32 _activebordercolor ) override; + virtual ::sal_Int32 SAL_CALL getActiveColor() override; + virtual void SAL_CALL setActiveColor( ::sal_Int32 _activecolor ) override; + virtual ::sal_Int32 SAL_CALL getActiveTabColor() override; + virtual void SAL_CALL setActiveTabColor( ::sal_Int32 _activetabcolor ) override; + virtual ::sal_Int32 SAL_CALL getActiveTextColor() override; + virtual void SAL_CALL setActiveTextColor( ::sal_Int32 _activetextcolor ) override; + virtual ::sal_Int32 SAL_CALL getButtonRolloverTextColor() override; + virtual void SAL_CALL setButtonRolloverTextColor( ::sal_Int32 _buttonrollovertextcolor ) override; + virtual ::sal_Int32 SAL_CALL getButtonTextColor() override; + virtual void SAL_CALL setButtonTextColor( ::sal_Int32 _buttontextcolor ) override; + virtual ::sal_Int32 SAL_CALL getCheckedColor() override; + virtual void SAL_CALL setCheckedColor( ::sal_Int32 _checkedcolor ) override; + virtual ::sal_Int32 SAL_CALL getDarkShadowColor() override; + virtual void SAL_CALL setDarkShadowColor( ::sal_Int32 _darkshadowcolor ) override; + virtual ::sal_Int32 SAL_CALL getDeactiveBorderColor() override; + virtual void SAL_CALL setDeactiveBorderColor( ::sal_Int32 _deactivebordercolor ) override; + virtual ::sal_Int32 SAL_CALL getDeactiveColor() override; + virtual void SAL_CALL setDeactiveColor( ::sal_Int32 _deactivecolor ) override; + virtual ::sal_Int32 SAL_CALL getDeactiveTextColor() override; + virtual void SAL_CALL setDeactiveTextColor( ::sal_Int32 _deactivetextcolor ) override; + virtual ::sal_Int32 SAL_CALL getDialogColor() override; + virtual void SAL_CALL setDialogColor( ::sal_Int32 _dialogcolor ) override; + virtual ::sal_Int32 SAL_CALL getDialogTextColor() override; + virtual void SAL_CALL setDialogTextColor( ::sal_Int32 _dialogtextcolor ) override; + virtual ::sal_Int32 SAL_CALL getDisableColor() override; + virtual void SAL_CALL setDisableColor( ::sal_Int32 _disablecolor ) override; + virtual ::sal_Int32 SAL_CALL getFaceColor() override; + virtual void SAL_CALL setFaceColor( ::sal_Int32 _facecolor ) override; + virtual ::sal_Int32 SAL_CALL getFaceGradientColor() override; + virtual ::sal_Int32 SAL_CALL getFieldColor() override; + virtual void SAL_CALL setFieldColor( ::sal_Int32 _fieldcolor ) override; + virtual ::sal_Int32 SAL_CALL getFieldRolloverTextColor() override; + virtual void SAL_CALL setFieldRolloverTextColor( ::sal_Int32 _fieldrollovertextcolor ) override; + virtual ::sal_Int32 SAL_CALL getFieldTextColor() override; + virtual void SAL_CALL setFieldTextColor( ::sal_Int32 _fieldtextcolor ) override; + virtual ::sal_Int32 SAL_CALL getGroupTextColor() override; + virtual void SAL_CALL setGroupTextColor( ::sal_Int32 _grouptextcolor ) override; + virtual ::sal_Int32 SAL_CALL getHelpColor() override; + virtual void SAL_CALL setHelpColor( ::sal_Int32 _helpcolor ) override; + virtual ::sal_Int32 SAL_CALL getHelpTextColor() override; + virtual void SAL_CALL setHelpTextColor( ::sal_Int32 _helptextcolor ) override; + virtual ::sal_Int32 SAL_CALL getHighlightColor() override; + virtual void SAL_CALL setHighlightColor( ::sal_Int32 _highlightcolor ) override; + virtual ::sal_Int32 SAL_CALL getHighlightTextColor() override; + virtual void SAL_CALL setHighlightTextColor( ::sal_Int32 _highlighttextcolor ) override; + virtual ::sal_Int32 SAL_CALL getInactiveTabColor() override; + virtual void SAL_CALL setInactiveTabColor( ::sal_Int32 _inactivetabcolor ) override; + virtual ::sal_Int32 SAL_CALL getLabelTextColor() override; + virtual void SAL_CALL setLabelTextColor( ::sal_Int32 _labeltextcolor ) override; + virtual ::sal_Int32 SAL_CALL getLightColor() override; + virtual void SAL_CALL setLightColor( ::sal_Int32 _lightcolor ) override; + virtual ::sal_Int32 SAL_CALL getMenuBarColor() override; + virtual void SAL_CALL setMenuBarColor( ::sal_Int32 _menubarcolor ) override; + virtual ::sal_Int32 SAL_CALL getMenuBarTextColor() override; + virtual void SAL_CALL setMenuBarTextColor( ::sal_Int32 _menubartextcolor ) override; + virtual ::sal_Int32 SAL_CALL getMenuBorderColor() override; + virtual void SAL_CALL setMenuBorderColor( ::sal_Int32 _menubordercolor ) override; + virtual ::sal_Int32 SAL_CALL getMenuColor() override; + virtual void SAL_CALL setMenuColor( ::sal_Int32 _menucolor ) override; + virtual ::sal_Int32 SAL_CALL getMenuHighlightColor() override; + virtual void SAL_CALL setMenuHighlightColor( ::sal_Int32 _menuhighlightcolor ) override; + virtual ::sal_Int32 SAL_CALL getMenuHighlightTextColor() override; + virtual void SAL_CALL setMenuHighlightTextColor( ::sal_Int32 _menuhighlighttextcolor ) override; + virtual ::sal_Int32 SAL_CALL getMenuTextColor() override; + virtual void SAL_CALL setMenuTextColor( ::sal_Int32 _menutextcolor ) override; + virtual ::sal_Int32 SAL_CALL getMonoColor() override; + virtual void SAL_CALL setMonoColor( ::sal_Int32 _monocolor ) override; + virtual ::sal_Int32 SAL_CALL getRadioCheckTextColor() override; + virtual void SAL_CALL setRadioCheckTextColor( ::sal_Int32 _radiochecktextcolor ) override; + virtual ::sal_Int32 SAL_CALL getSeparatorColor() override; + virtual ::sal_Int32 SAL_CALL getShadowColor() override; + virtual void SAL_CALL setShadowColor( ::sal_Int32 _shadowcolor ) override; + virtual ::sal_Int32 SAL_CALL getWindowColor() override; + virtual void SAL_CALL setWindowColor( ::sal_Int32 _windowcolor ) override; + virtual ::sal_Int32 SAL_CALL getWindowTextColor() override; + virtual void SAL_CALL setWindowTextColor( ::sal_Int32 _windowtextcolor ) override; + virtual ::sal_Int32 SAL_CALL getWorkspaceColor() override; + virtual void SAL_CALL setWorkspaceColor( ::sal_Int32 _workspacecolor ) override; + virtual sal_Bool SAL_CALL getHighContrastMode() override; + virtual void SAL_CALL setHighContrastMode( sal_Bool _highcontrastmode ) override; + virtual css::awt::FontDescriptor SAL_CALL getApplicationFont() override; + virtual void SAL_CALL setApplicationFont( const css::awt::FontDescriptor& _applicationfont ) override; + virtual css::awt::FontDescriptor SAL_CALL getHelpFont() override; + virtual void SAL_CALL setHelpFont( const css::awt::FontDescriptor& _helpfont ) override; + virtual css::awt::FontDescriptor SAL_CALL getTitleFont() override; + virtual void SAL_CALL setTitleFont( const css::awt::FontDescriptor& _titlefont ) override; + virtual css::awt::FontDescriptor SAL_CALL getFloatTitleFont() override; + virtual void SAL_CALL setFloatTitleFont( const css::awt::FontDescriptor& _floattitlefont ) override; + virtual css::awt::FontDescriptor SAL_CALL getMenuFont() override; + virtual void SAL_CALL setMenuFont( const css::awt::FontDescriptor& _menufont ) override; + virtual css::awt::FontDescriptor SAL_CALL getToolFont() override; + virtual void SAL_CALL setToolFont( const css::awt::FontDescriptor& _toolfont ) override; + virtual css::awt::FontDescriptor SAL_CALL getGroupFont() override; + virtual void SAL_CALL setGroupFont( const css::awt::FontDescriptor& _groupfont ) override; + virtual css::awt::FontDescriptor SAL_CALL getLabelFont() override; + virtual void SAL_CALL setLabelFont( const css::awt::FontDescriptor& _labelfont ) override; + virtual css::awt::FontDescriptor SAL_CALL getRadioCheckFont() override; + virtual void SAL_CALL setRadioCheckFont( const css::awt::FontDescriptor& _radiocheckfont ) override; + virtual css::awt::FontDescriptor SAL_CALL getPushButtonFont() override; + virtual void SAL_CALL setPushButtonFont( const css::awt::FontDescriptor& _pushbuttonfont ) override; + virtual css::awt::FontDescriptor SAL_CALL getFieldFont() override; + virtual void SAL_CALL setFieldFont( const css::awt::FontDescriptor& _fieldfont ) override; + virtual void SAL_CALL addStyleChangeListener( const css::uno::Reference< css::awt::XStyleChangeListener >& Listener ) override; + virtual void SAL_CALL removeStyleChangeListener( const css::uno::Reference< css::awt::XStyleChangeListener >& Listener ) override; + + private: + void ImplSetStyleFont( void (StyleSettings::*i_pSetter)( vcl::Font const &), + vcl::Font const & (StyleSettings::*i_pGetter)() const, const css::awt::FontDescriptor& i_rFont ); + void ImplSetStyleColor( void (StyleSettings::*i_pSetter)( Color const & ), sal_Int32 i_nColor ); + sal_Int32 ImplGetStyleColor( Color const & (StyleSettings::*i_pGetter)() const ) const; + css::awt::FontDescriptor ImplGetStyleFont( vcl::Font const & (StyleSettings::*i_pGetter)() const ) const; + DECL_LINK( OnWindowEvent, VclWindowEvent&, void ); + + VCLXWindow* pOwningWindow; + ::comphelper::OInterfaceContainerHelper3 aStyleChangeListeners; + }; + + +} // namespace toolkit + + +#endif // INCLUDED_TOOLKIT_SOURCE_AWT_STYLESETTINGS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/source/awt/vclxaccessiblecomponent.cxx b/toolkit/source/awt/vclxaccessiblecomponent.cxx new file mode 100644 index 000000000..767004c35 --- /dev/null +++ b/toolkit/source/awt/vclxaccessiblecomponent.cxx @@ -0,0 +1,830 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace ::com::sun::star; +using namespace ::comphelper; + +VCLXAccessibleComponent::VCLXAccessibleComponent( VCLXWindow* pVCLXWindow ) +{ + m_xVCLXWindow = pVCLXWindow; + + DBG_ASSERT( pVCLXWindow->GetWindow(), "VCLXAccessibleComponent - no window!" ); + m_xEventSource = pVCLXWindow->GetWindow(); + if ( m_xEventSource ) + { + m_xEventSource->AddEventListener( LINK( this, VCLXAccessibleComponent, WindowEventListener ) ); + m_xEventSource->AddChildEventListener( LINK( this, VCLXAccessibleComponent, WindowChildEventListener ) ); + } + + // announce the XAccessible of our creator to the base class + lateInit( pVCLXWindow ); +} + +VCLXWindow* VCLXAccessibleComponent::GetVCLXWindow() const +{ + return m_xVCLXWindow.get(); +} + +void VCLXAccessibleComponent::DisconnectEvents() +{ + if ( m_xEventSource ) + { + m_xEventSource->RemoveEventListener( LINK( this, VCLXAccessibleComponent, WindowEventListener ) ); + m_xEventSource->RemoveChildEventListener( LINK( this, VCLXAccessibleComponent, WindowChildEventListener ) ); + m_xEventSource.clear(); + } +} + +VCLXAccessibleComponent::~VCLXAccessibleComponent() +{ + ensureDisposed(); + DisconnectEvents(); +} + +IMPLEMENT_FORWARD_XINTERFACE3( VCLXAccessibleComponent, OAccessibleExtendedComponentHelper, OAccessibleImplementationAccess, VCLXAccessibleComponent_BASE ) +css::uno::Sequence< css::uno::Type > SAL_CALL VCLXAccessibleComponent::getTypes() +{ + return ::comphelper::concatSequences( + OAccessibleExtendedComponentHelper::getTypes(), + OAccessibleImplementationAccess::getTypes(), + VCLXAccessibleComponent_BASE::getTypes() + ); +} +IMPLEMENT_GET_IMPLEMENTATION_ID( VCLXAccessibleComponent ) + +OUString VCLXAccessibleComponent::getImplementationName() +{ + return "com.sun.star.comp.toolkit.AccessibleWindow"; +} + +sal_Bool VCLXAccessibleComponent::supportsService( const OUString& rServiceName ) +{ + return cppu::supportsService(this, rServiceName); +} + +uno::Sequence< OUString > VCLXAccessibleComponent::getSupportedServiceNames() +{ + uno::Sequence< OUString > aNames { "com.sun.star.awt.AccessibleWindow" }; + return aNames; +} + +IMPL_LINK( VCLXAccessibleComponent, WindowEventListener, VclWindowEvent&, rEvent, void ) +{ + /* Ignore VclEventId::WindowEndPopupMode, because the UNO accessibility wrapper + * might have been destroyed by the previous VCLEventListener (if no AT tool + * is running), e.g. sub-toolbars in impress. + */ + if ( m_xVCLXWindow.is() /* #122218# */ && (rEvent.GetId() != VclEventId::WindowEndPopupMode) ) + { + DBG_ASSERT( rEvent.GetWindow(), "Window???" ); + if( !rEvent.GetWindow()->IsAccessibilityEventsSuppressed() || ( rEvent.GetId() == VclEventId::ObjectDying ) ) + { + ProcessWindowEvent( rEvent ); + } + } +} + +IMPL_LINK( VCLXAccessibleComponent, WindowChildEventListener, VclWindowEvent&, rEvent, void ) +{ + if ( m_xVCLXWindow.is() /* #i68079# */ ) + { + DBG_ASSERT( rEvent.GetWindow(), "Window???" ); + if( !rEvent.GetWindow()->IsAccessibilityEventsSuppressed() ) + { + // #103087# to prevent an early release of the component + uno::Reference< accessibility::XAccessibleContext > xHoldAlive = this; + + ProcessWindowChildEvent( rEvent ); + } + } +} + +uno::Reference< accessibility::XAccessible > VCLXAccessibleComponent::GetChildAccessible( const VclWindowEvent& rVclWindowEvent ) +{ + // checks if the data in the window event is our direct child + // and returns its accessible + + // MT: Change this later, normally a show/hide event shouldn't have the vcl::Window* in pData. + vcl::Window* pChildWindow = static_cast(rVclWindowEvent.GetData()); + if( pChildWindow && GetWindow() == pChildWindow->GetAccessibleParentWindow() ) + return pChildWindow->GetAccessible( rVclWindowEvent.GetId() == VclEventId::WindowShow ); + else + return uno::Reference< accessibility::XAccessible > (); +} + +void VCLXAccessibleComponent::ProcessWindowChildEvent( const VclWindowEvent& rVclWindowEvent ) +{ + uno::Any aOldValue, aNewValue; + uno::Reference< accessibility::XAccessible > xAcc; + + switch ( rVclWindowEvent.GetId() ) + { + case VclEventId::WindowShow: // send create on show for direct accessible children + { + xAcc = GetChildAccessible( rVclWindowEvent ); + if( xAcc.is() ) + { + aNewValue <<= xAcc; + NotifyAccessibleEvent( accessibility::AccessibleEventId::CHILD, aOldValue, aNewValue ); + } + } + break; + case VclEventId::WindowHide: // send destroy on hide for direct accessible children + { + xAcc = GetChildAccessible( rVclWindowEvent ); + if( xAcc.is() ) + { + aOldValue <<= xAcc; + NotifyAccessibleEvent( accessibility::AccessibleEventId::CHILD, aOldValue, aNewValue ); + } + } + break; + default: break; + } +} + +void VCLXAccessibleComponent::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) +{ + uno::Any aOldValue, aNewValue; + + vcl::Window* pAccWindow = rVclWindowEvent.GetWindow(); + assert(pAccWindow && "VCLXAccessibleComponent::ProcessWindowEvent - Window?"); + + switch ( rVclWindowEvent.GetId() ) + { + case VclEventId::ObjectDying: + { + DisconnectEvents(); + m_xVCLXWindow.clear(); + } + break; + case VclEventId::WindowChildDestroyed: + { + vcl::Window* pWindow = static_cast(rVclWindowEvent.GetData()); + DBG_ASSERT( pWindow, "VclEventId::WindowChildDestroyed - Window=?" ); + if ( pWindow->GetAccessible( false ).is() ) + { + aOldValue <<= pWindow->GetAccessible( false ); + NotifyAccessibleEvent( accessibility::AccessibleEventId::CHILD, aOldValue, aNewValue ); + } + } + break; + case VclEventId::WindowActivate: + { + sal_Int16 aAccessibleRole = getAccessibleRole(); + // avoid notification if a child frame is already active + // only one frame may be active at a given time + if ( !pAccWindow->HasActiveChildFrame() && + ( aAccessibleRole == accessibility::AccessibleRole::FRAME || + aAccessibleRole == accessibility::AccessibleRole::ALERT || + aAccessibleRole == accessibility::AccessibleRole::DIALOG ) ) // #i18891# + { + aNewValue <<= accessibility::AccessibleStateType::ACTIVE; + NotifyAccessibleEvent( accessibility::AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue ); + } + } + break; + case VclEventId::WindowDeactivate: + { + sal_Int16 aAccessibleRole = getAccessibleRole(); + if ( aAccessibleRole == accessibility::AccessibleRole::FRAME || + aAccessibleRole == accessibility::AccessibleRole::ALERT || + aAccessibleRole == accessibility::AccessibleRole::DIALOG ) // #i18891# + { + aOldValue <<= accessibility::AccessibleStateType::ACTIVE; + NotifyAccessibleEvent( accessibility::AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue ); + } + } + break; + case VclEventId::WindowGetFocus: + case VclEventId::ControlGetFocus: + { + if( (pAccWindow->IsCompoundControl() && rVclWindowEvent.GetId() == VclEventId::ControlGetFocus) || + (!pAccWindow->IsCompoundControl() && rVclWindowEvent.GetId() == VclEventId::WindowGetFocus) ) + { + // if multiple listeners were registered it is possible that the + // focus was changed during event processing (eg SfxTopWindow ) + // #106082# allow ChildPathFocus only for CompoundControls, for windows the focus must be in the window itself + if( (pAccWindow->IsCompoundControl() && pAccWindow->HasChildPathFocus()) || + (!pAccWindow->IsCompoundControl() && pAccWindow->HasFocus()) ) + { + aNewValue <<= accessibility::AccessibleStateType::FOCUSED; + NotifyAccessibleEvent( accessibility::AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue ); + } + } + } + break; + case VclEventId::WindowLoseFocus: + case VclEventId::ControlLoseFocus: + { + if( (pAccWindow->IsCompoundControl() && rVclWindowEvent.GetId() == VclEventId::ControlLoseFocus) || + (!pAccWindow->IsCompoundControl() && rVclWindowEvent.GetId() == VclEventId::WindowLoseFocus) ) + { + aOldValue <<= accessibility::AccessibleStateType::FOCUSED; + NotifyAccessibleEvent( accessibility::AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue ); + } + } + break; + case VclEventId::WindowFrameTitleChanged: + { + OUString aOldName( *static_cast(rVclWindowEvent.GetData()) ); + OUString aNewName( getAccessibleName() ); + aOldValue <<= aOldName; + aNewValue <<= aNewName; + NotifyAccessibleEvent( accessibility::AccessibleEventId::NAME_CHANGED, aOldValue, aNewValue ); + } + break; + case VclEventId::WindowEnabled: + { + aNewValue <<= accessibility::AccessibleStateType::ENABLED; + NotifyAccessibleEvent( accessibility::AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue ); + aNewValue <<= accessibility::AccessibleStateType::SENSITIVE; + NotifyAccessibleEvent( accessibility::AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue ); + } + break; + case VclEventId::WindowDisabled: + { + aOldValue <<= accessibility::AccessibleStateType::SENSITIVE; + NotifyAccessibleEvent( accessibility::AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue ); + + aOldValue <<= accessibility::AccessibleStateType::ENABLED; + NotifyAccessibleEvent( accessibility::AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue ); + } + break; + case VclEventId::WindowMove: + case VclEventId::WindowResize: + { + NotifyAccessibleEvent( accessibility::AccessibleEventId::BOUNDRECT_CHANGED, aOldValue, aNewValue ); + } + break; + case VclEventId::WindowMenubarAdded: + { + MenuBar* pMenuBar = static_cast(rVclWindowEvent.GetData()); + if ( pMenuBar ) + { + uno::Reference< accessibility::XAccessible > xChild( pMenuBar->GetAccessible() ); + if ( xChild.is() ) + { + aNewValue <<= xChild; + NotifyAccessibleEvent( accessibility::AccessibleEventId::CHILD, aOldValue, aNewValue ); + } + } + } + break; + case VclEventId::WindowMenubarRemoved: + { + MenuBar* pMenuBar = static_cast(rVclWindowEvent.GetData()); + if ( pMenuBar ) + { + uno::Reference< accessibility::XAccessible > xChild( pMenuBar->GetAccessible() ); + if ( xChild.is() ) + { + aOldValue <<= xChild; + NotifyAccessibleEvent( accessibility::AccessibleEventId::CHILD, aOldValue, aNewValue ); + } + } + } + break; + case VclEventId::WindowMinimize: + { + aNewValue <<= accessibility::AccessibleStateType::ICONIFIED; + NotifyAccessibleEvent( accessibility::AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue ); + } + break; + case VclEventId::WindowNormalize: + { + aOldValue <<= accessibility::AccessibleStateType::ICONIFIED; + NotifyAccessibleEvent( accessibility::AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue ); + } + break; + default: + { + } + break; + } +} + +void VCLXAccessibleComponent::disposing() +{ + DisconnectEvents(); + + OAccessibleExtendedComponentHelper::disposing(); + + m_xVCLXWindow.clear(); +} + +vcl::Window* VCLXAccessibleComponent::GetWindow() const +{ + return GetVCLXWindow() ? GetVCLXWindow()->GetWindow() + : nullptr; +} + +void VCLXAccessibleComponent::FillAccessibleRelationSet( utl::AccessibleRelationSetHelper& rRelationSet ) +{ + VclPtr pWindow = GetWindow(); + if ( !pWindow ) + return; + + vcl::Window *pLabeledBy = pWindow->GetAccessibleRelationLabeledBy(); + if ( pLabeledBy && pLabeledBy != pWindow ) + { + uno::Sequence< uno::Reference< uno::XInterface > > aSequence { pLabeledBy->GetAccessible() }; + rRelationSet.AddRelation( accessibility::AccessibleRelation( accessibility::AccessibleRelationType::LABELED_BY, aSequence ) ); + } + + vcl::Window* pLabelFor = pWindow->GetAccessibleRelationLabelFor(); + if ( pLabelFor && pLabelFor != pWindow ) + { + uno::Sequence< uno::Reference< uno::XInterface > > aSequence { pLabelFor->GetAccessible() }; + rRelationSet.AddRelation( accessibility::AccessibleRelation( accessibility::AccessibleRelationType::LABEL_FOR, aSequence ) ); + } + + vcl::Window* pMemberOf = pWindow->GetAccessibleRelationMemberOf(); + if ( pMemberOf && pMemberOf != pWindow ) + { + uno::Sequence< uno::Reference< uno::XInterface > > aSequence { pMemberOf->GetAccessible() }; + rRelationSet.AddRelation( accessibility::AccessibleRelation( accessibility::AccessibleRelationType::MEMBER_OF, aSequence ) ); + } +} + +void VCLXAccessibleComponent::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet ) +{ + VclPtr pWindow = GetWindow(); + if ( pWindow ) + { + if ( pWindow->IsVisible() ) + { + rStateSet.AddState( accessibility::AccessibleStateType::VISIBLE ); + rStateSet.AddState( accessibility::AccessibleStateType::SHOWING ); + } + else + { + rStateSet.AddState( accessibility::AccessibleStateType::INVALID ); + } + + if ( pWindow->IsEnabled() ) + { + rStateSet.AddState( accessibility::AccessibleStateType::ENABLED ); + rStateSet.AddState( accessibility::AccessibleStateType::SENSITIVE ); + } + + if ( pWindow->HasChildPathFocus() && + ( getAccessibleRole() == accessibility::AccessibleRole::FRAME || + getAccessibleRole() == accessibility::AccessibleRole::ALERT || + getAccessibleRole() == accessibility::AccessibleRole::DIALOG ) ) // #i18891# + rStateSet.AddState( accessibility::AccessibleStateType::ACTIVE ); + + if ( pWindow->HasFocus() || ( pWindow->IsCompoundControl() && pWindow->HasChildPathFocus() ) ) + rStateSet.AddState( accessibility::AccessibleStateType::FOCUSED ); + + if ( pWindow->IsWait() ) + rStateSet.AddState( accessibility::AccessibleStateType::BUSY ); + + if ( pWindow->GetStyle() & WB_SIZEABLE ) + rStateSet.AddState( accessibility::AccessibleStateType::RESIZABLE ); + // 6. frame doesn't have MOVABLE state + // 10. for password text, where is the sensitive state? + if( ( getAccessibleRole() == accessibility::AccessibleRole::FRAME ||getAccessibleRole() == accessibility::AccessibleRole::DIALOG )&& pWindow->GetStyle() & WB_MOVEABLE ) + rStateSet.AddState( accessibility::AccessibleStateType::MOVEABLE ); + if( pWindow->IsDialog() ) + { + Dialog *pDlg = static_cast< Dialog* >( pWindow.get() ); + if( pDlg->IsInExecute() ) + rStateSet.AddState( accessibility::AccessibleStateType::MODAL ); + } + //If a combobox or list's edit child isn't read-only,EDITABLE state + //should be set. + if( pWindow && pWindow->GetType() == WindowType::COMBOBOX ) + { + if( !( pWindow->GetStyle() & WB_READONLY) || + !static_cast(pWindow.get())->IsReadOnly() ) + rStateSet.AddState( accessibility::AccessibleStateType::EDITABLE ); + } + + VclPtr pChild = pWindow->GetWindow( GetWindowType::FirstChild ); + + while( pWindow && pChild ) + { + VclPtr pWinTemp = pChild->GetWindow( GetWindowType::FirstChild ); + if( pWinTemp && pWinTemp->GetType() == WindowType::EDIT ) + { + if( !( pWinTemp->GetStyle() & WB_READONLY) || + !static_cast(pWinTemp.get())->IsReadOnly() ) + rStateSet.AddState( accessibility::AccessibleStateType::EDITABLE ); + break; + } + if( pChild->GetType() == WindowType::EDIT ) + { + if( !( pChild->GetStyle() & WB_READONLY) || + !static_cast(pChild.get())->IsReadOnly()) + rStateSet.AddState( accessibility::AccessibleStateType::EDITABLE ); + break; + } + pChild = pChild->GetWindow( GetWindowType::Next ); + } + } + else + { + rStateSet.AddState( accessibility::AccessibleStateType::DEFUNC ); + } + +/* + +MUST BE SET FROM DERIVED CLASSES: + +CHECKED +COLLAPSED +EXPANDED +EXPANDABLE +EDITABLE +FOCUSABLE +HORIZONTAL +VERTICAL +ICONIFIED +MULTILINE +MULTI_SELECTABLE +PRESSED +SELECTABLE +SELECTED +SINGLE_LINE +TRANSIENT + + */ +} + + +// accessibility::XAccessibleContext +sal_Int32 VCLXAccessibleComponent::getAccessibleChildCount() +{ + OExternalLockGuard aGuard( this ); + + sal_Int32 nChildren = 0; + if ( GetWindow() ) + nChildren = GetWindow()->GetAccessibleChildWindowCount(); + + return nChildren; +} + +uno::Reference< accessibility::XAccessible > VCLXAccessibleComponent::getAccessibleChild( sal_Int32 i ) +{ + OExternalLockGuard aGuard( this ); + + if ( i >= getAccessibleChildCount() ) + throw lang::IndexOutOfBoundsException(); + + uno::Reference< accessibility::XAccessible > xAcc; + if ( GetWindow() ) + { + vcl::Window* pChild = GetWindow()->GetAccessibleChildWindow( static_cast(i) ); + if ( pChild ) + xAcc = pChild->GetAccessible(); + } + + return xAcc; +} + +uno::Reference< accessibility::XAccessible > VCLXAccessibleComponent::getVclParent() const +{ + uno::Reference< accessibility::XAccessible > xAcc; + if ( GetWindow() ) + { + vcl::Window* pParent = GetWindow()->GetAccessibleParentWindow(); + if ( pParent ) + xAcc = pParent->GetAccessible(); + } + return xAcc; +} + +uno::Reference< accessibility::XAccessible > VCLXAccessibleComponent::getAccessibleParent( ) +{ + OExternalLockGuard aGuard( this ); + + // we do _not_ have a foreign-controlled parent -> default to our VCL parent + uno::Reference< accessibility::XAccessible > xAcc = getVclParent(); + + return xAcc; +} + +sal_Int32 VCLXAccessibleComponent::getAccessibleIndexInParent( ) +{ + OExternalLockGuard aGuard( this ); + + sal_Int32 nIndex = -1; + + if ( GetWindow() ) + { + vcl::Window* pParent = GetWindow()->GetAccessibleParentWindow(); + if ( pParent ) + { + // Iterate over all the parent's children and search for this object. + // this should be compatible with the code in SVX + uno::Reference< accessibility::XAccessible > xParentAcc( pParent->GetAccessible() ); + if ( xParentAcc.is() ) + { + uno::Reference< accessibility::XAccessibleContext > xParentContext ( xParentAcc->getAccessibleContext() ); + if ( xParentContext.is() ) + { + sal_Int32 nChildCount = xParentContext->getAccessibleChildCount(); + for ( sal_Int32 i=0; i xChild( xParentContext->getAccessibleChild(i) ); + if ( xChild.is() ) + { + uno::Reference< accessibility::XAccessibleContext > xChildContext = xChild->getAccessibleContext(); + if ( xChildContext == static_cast(this) ) + { + nIndex = i; + break; + } + } + } + } + } + } + } + return nIndex; +} + +sal_Int16 VCLXAccessibleComponent::getAccessibleRole( ) +{ + OExternalLockGuard aGuard( this ); + + sal_Int16 nRole = 0; + + if ( GetWindow() ) + nRole = GetWindow()->GetAccessibleRole(); + + return nRole; +} + +OUString VCLXAccessibleComponent::getAccessibleDescription( ) +{ + OExternalLockGuard aGuard( this ); + + OUString aDescription; + + if ( GetWindow() ) + aDescription = GetWindow()->GetAccessibleDescription(); + + return aDescription; +} + +OUString VCLXAccessibleComponent::getAccessibleName( ) +{ + OExternalLockGuard aGuard( this ); + + OUString aName; + if ( GetWindow() ) + { + aName = GetWindow()->GetAccessibleName(); +#if OSL_DEBUG_LEVEL > 0 + aName += " (Type = " + OUString::number(static_cast(GetWindow()->GetType())) + ")"; +#endif + } + return aName; +} + +OUString VCLXAccessibleComponent::getAccessibleId( ) +{ + OExternalLockGuard aGuard( this ); + + OUString aId; + if ( GetWindow() ) + { + const OUString &aWindowId = GetWindow()->get_id(); + aId = aWindowId; + } + return aId; +} + +uno::Reference< accessibility::XAccessibleRelationSet > VCLXAccessibleComponent::getAccessibleRelationSet( ) +{ + OExternalLockGuard aGuard( this ); + + rtl::Reference pRelationSetHelper = new utl::AccessibleRelationSetHelper; + FillAccessibleRelationSet( *pRelationSetHelper ); + return pRelationSetHelper; +} + +uno::Reference< accessibility::XAccessibleStateSet > VCLXAccessibleComponent::getAccessibleStateSet( ) +{ + OExternalLockGuard aGuard( this ); + + rtl::Reference pStateSetHelper = new utl::AccessibleStateSetHelper; + FillAccessibleStateSet( *pStateSetHelper ); + return pStateSetHelper; +} + +lang::Locale VCLXAccessibleComponent::getLocale() +{ + OExternalLockGuard aGuard( this ); + + return Application::GetSettings().GetLanguageTag().getLocale(); +} + +uno::Reference< accessibility::XAccessible > VCLXAccessibleComponent::getAccessibleAtPoint( const awt::Point& rPoint ) +{ + OExternalLockGuard aGuard( this ); + + uno::Reference< accessibility::XAccessible > xChild; + for ( sal_uInt32 i = 0, nCount = getAccessibleChildCount(); i < nCount; ++i ) + { + uno::Reference< accessibility::XAccessible > xAcc = getAccessibleChild( i ); + if ( xAcc.is() ) + { + uno::Reference< accessibility::XAccessibleComponent > xComp( xAcc->getAccessibleContext(), uno::UNO_QUERY ); + if ( xComp.is() ) + { + tools::Rectangle aRect = VCLRectangle( xComp->getBounds() ); + Point aPos = VCLPoint( rPoint ); + if ( aRect.Contains( aPos ) ) + { + xChild = xAcc; + break; + } + } + } + } + + return xChild; +} + +// accessibility::XAccessibleComponent +awt::Rectangle VCLXAccessibleComponent::implGetBounds() +{ + awt::Rectangle aBounds ( 0, 0, 0, 0 ); + + VclPtr pWindow = GetWindow(); + if ( pWindow ) + { + tools::Rectangle aRect = pWindow->GetWindowExtentsRelative( nullptr ); + aBounds = AWTRectangle( aRect ); + vcl::Window* pParent = pWindow->GetAccessibleParentWindow(); + if ( pParent ) + { + tools::Rectangle aParentRect = pParent->GetWindowExtentsRelative( nullptr ); + awt::Point aParentScreenLoc = AWTPoint( aParentRect.TopLeft() ); + aBounds.X -= aParentScreenLoc.X; + aBounds.Y -= aParentScreenLoc.Y; + } + } + + return aBounds; +} + +awt::Point VCLXAccessibleComponent::getLocationOnScreen( ) +{ + OExternalLockGuard aGuard( this ); + + awt::Point aPos; + if ( GetWindow() ) + { + tools::Rectangle aRect = GetWindow()->GetWindowExtentsRelative( nullptr ); + aPos.X = aRect.Left(); + aPos.Y = aRect.Top(); + } + + return aPos; +} + +void VCLXAccessibleComponent::grabFocus( ) +{ + OExternalLockGuard aGuard( this ); + + uno::Reference< accessibility::XAccessibleStateSet > xStates = getAccessibleStateSet(); + if ( m_xVCLXWindow.is() && xStates.is() && xStates->contains( accessibility::AccessibleStateType::FOCUSABLE ) ) + m_xVCLXWindow->setFocus(); +} + +sal_Int32 SAL_CALL VCLXAccessibleComponent::getForeground( ) +{ + OExternalLockGuard aGuard( this ); + + Color nColor; + VclPtr pWindow = GetWindow(); + if ( pWindow ) + { + if ( pWindow->IsControlForeground() ) + nColor = pWindow->GetControlForeground(); + else + { + vcl::Font aFont; + if ( pWindow->IsControlFont() ) + aFont = pWindow->GetControlFont(); + else + aFont = pWindow->GetFont(); + nColor = aFont.GetColor(); + // COL_AUTO is not very meaningful for AT + if ( nColor == COL_AUTO) + nColor = pWindow->GetTextColor(); + } + } + + return sal_Int32(nColor); +} + +sal_Int32 SAL_CALL VCLXAccessibleComponent::getBackground( ) +{ + OExternalLockGuard aGuard( this ); + + Color nColor; + VclPtr pWindow = GetWindow(); + if ( pWindow ) + { + if ( pWindow->IsControlBackground() ) + nColor = pWindow->GetControlBackground(); + else + nColor = pWindow->GetBackground().GetColor(); + } + + return sal_Int32(nColor); +} + +// XAccessibleExtendedComponent + +uno::Reference< awt::XFont > SAL_CALL VCLXAccessibleComponent::getFont( ) +{ + OExternalLockGuard aGuard( this ); + + uno::Reference< awt::XFont > xFont; + VclPtr pWindow = GetWindow(); + if ( pWindow ) + { + uno::Reference< awt::XDevice > xDev( pWindow->GetComponentInterface(), uno::UNO_QUERY ); + if ( xDev.is() ) + { + vcl::Font aFont; + if ( pWindow->IsControlFont() ) + aFont = pWindow->GetControlFont(); + else + aFont = pWindow->GetFont(); + rtl::Reference pVCLXFont = new VCLXFont; + pVCLXFont->Init( *xDev, aFont ); + xFont = pVCLXFont; + } + } + + return xFont; +} + +OUString SAL_CALL VCLXAccessibleComponent::getTitledBorderText( ) +{ + OExternalLockGuard aGuard( this ); + + OUString sRet; + if ( GetWindow() ) + sRet = GetWindow()->GetText(); + + return sRet; +} + +OUString SAL_CALL VCLXAccessibleComponent::getToolTipText( ) +{ + OExternalLockGuard aGuard( this ); + + OUString sRet; + if ( GetWindow() ) + sRet = GetWindow()->GetQuickHelpText(); + + return sRet; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/source/awt/vclxbitmap.cxx b/toolkit/source/awt/vclxbitmap.cxx new file mode 100644 index 000000000..17111311d --- /dev/null +++ b/toolkit/source/awt/vclxbitmap.cxx @@ -0,0 +1,63 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include +#include +#include +#include + + + + +// css::lang::XUnoTunnel +UNO3_GETIMPLEMENTATION_IMPL( VCLXBitmap ); + +// css::awt::XBitmap +css::awt::Size VCLXBitmap::getSize() +{ + std::scoped_lock aGuard( GetMutex() ); + + css::awt::Size aSize( maBitmap.GetSizePixel().Width(), maBitmap.GetSizePixel().Height() ); + return aSize; +} + +css::uno::Sequence< sal_Int8 > VCLXBitmap::getDIB() +{ + std::scoped_lock aGuard( GetMutex() ); + + SvMemoryStream aMem; + WriteDIB(maBitmap.GetBitmap(), aMem, false, true); + return css::uno::Sequence( static_cast(aMem.GetData()), aMem.Tell() ); +} + +css::uno::Sequence< sal_Int8 > VCLXBitmap::getMaskDIB() +{ + std::scoped_lock aGuard( GetMutex() ); + + return vcl::bitmap::GetMaskDIB(maBitmap); +} + +sal_Int64 SAL_CALL VCLXBitmap::estimateUsage() +{ + std::scoped_lock aGuard( GetMutex() ); + + return maBitmap.GetSizeBytes(); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/source/awt/vclxcontainer.cxx b/toolkit/source/awt/vclxcontainer.cxx new file mode 100644 index 000000000..05e321d1b --- /dev/null +++ b/toolkit/source/awt/vclxcontainer.cxx @@ -0,0 +1,290 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +void VCLXContainer::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds ) +{ + VCLXWindow::ImplGetPropertyIds( rIds ); +} + +VCLXContainer::VCLXContainer() +{ +} + +VCLXContainer::~VCLXContainer() +{ +} + +// css::uno::XInterface +css::uno::Any VCLXContainer::queryInterface( const css::uno::Type & rType ) +{ + css::uno::Any aRet = ::cppu::queryInterface( rType, + static_cast< css::awt::XVclContainer* >(this), + static_cast< css::awt::XVclContainerPeer* >(this) ); + return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType )); +} + +IMPL_IMPLEMENTATION_ID( VCLXContainer ) + +// css::lang::XTypeProvider +css::uno::Sequence< css::uno::Type > VCLXContainer::getTypes() +{ + static const ::cppu::OTypeCollection aTypeList( + cppu::UnoType::get(), + cppu::UnoType::get(), + cppu::UnoType::get(), + VCLXWindow::getTypes() + ); + return aTypeList.getTypes(); +} + + +// css::awt::XVclContainer +void VCLXContainer::addVclContainerListener( const css::uno::Reference< css::awt::XVclContainerListener >& rxListener ) +{ + SolarMutexGuard aGuard; + + if (!IsDisposed()) + GetContainerListeners().addInterface( rxListener ); +} + +void VCLXContainer::removeVclContainerListener( const css::uno::Reference< css::awt::XVclContainerListener >& rxListener ) +{ + SolarMutexGuard aGuard; + + if (!IsDisposed()) + GetContainerListeners().removeInterface( rxListener ); +} + +css::uno::Sequence< css::uno::Reference< css::awt::XWindow > > VCLXContainer::getWindows( ) +{ + SolarMutexGuard aGuard; + + // Request container interface from all children + css::uno::Sequence< css::uno::Reference< css::awt::XWindow > > aSeq; + VclPtr pWindow = GetWindow(); + if ( pWindow ) + { + sal_uInt16 nChildren = pWindow->GetChildCount(); + if ( nChildren ) + { + aSeq = css::uno::Sequence< css::uno::Reference< css::awt::XWindow > >( nChildren ); + css::uno::Reference< css::awt::XWindow > * pChildRefs = aSeq.getArray(); + for ( sal_uInt16 n = 0; n < nChildren; n++ ) + { + vcl::Window* pChild = pWindow->GetChild( n ); + css::uno::Reference< css::awt::XWindowPeer > xWP = pChild->GetComponentInterface(); + css::uno::Reference< css::awt::XWindow > xW( xWP, css::uno::UNO_QUERY ); + pChildRefs[n] = xW; + } + } + } + return aSeq; +} + + +// css::awt::XVclContainerPeer +void VCLXContainer::enableDialogControl( sal_Bool bEnable ) +{ + SolarMutexGuard aGuard; + + VclPtr pWindow = GetWindow(); + if ( pWindow ) + { + WinBits nStyle = pWindow->GetStyle(); + if ( bEnable ) + nStyle |= WB_DIALOGCONTROL; + else + nStyle &= (~WB_DIALOGCONTROL); + pWindow->SetStyle( nStyle ); + } +} + +void VCLXContainer::setTabOrder( const css::uno::Sequence< css::uno::Reference< css::awt::XWindow > >& Components, const css::uno::Sequence< css::uno::Any >& Tabs, sal_Bool bGroupControl ) +{ + SolarMutexGuard aGuard; + + sal_uInt32 nCount = Components.getLength(); + DBG_ASSERT( nCount == static_cast(Tabs.getLength()), "setTabOrder: TabCount != ComponentCount" ); + const css::uno::Reference< css::awt::XWindow > * pComps = Components.getConstArray(); + const css::uno::Any* pTabs = Tabs.getConstArray(); + + vcl::Window* pPrevWin = nullptr; + for ( sal_uInt32 n = 0; n < nCount; n++ ) + { + // css::style::TabStop + VclPtr pWin = VCLUnoHelper::GetWindow( pComps[n] ); + // May be NULL if a css::uno::Sequence is originated from TabController and is missing a peer! + if ( pWin ) + { + // Order windows before manipulating their style, because elements such as the + // RadioButton considers the PREV-window in StateChanged. + if ( pPrevWin ) + pWin->SetZOrder( pPrevWin, ZOrderFlags::Behind ); + + WinBits nStyle = pWin->GetStyle(); + nStyle &= ~(WB_TABSTOP|WB_NOTABSTOP|WB_GROUP); + if ( pTabs[n].getValueType().getTypeClass() == css::uno::TypeClass_BOOLEAN ) + { + bool bTab = false; + pTabs[n] >>= bTab; + nStyle |= ( bTab ? WB_TABSTOP : WB_NOTABSTOP ); + } + pWin->SetStyle( nStyle ); + + if ( bGroupControl ) + { + if ( n == 0 ) + pWin->SetDialogControlStart( true ); + else + pWin->SetDialogControlStart( false ); + } + + pPrevWin = pWin; + } + } +} + +void VCLXContainer::setGroup( const css::uno::Sequence< css::uno::Reference< css::awt::XWindow > >& Components ) +{ + SolarMutexGuard aGuard; + + sal_uInt32 nCount = Components.getLength(); + const css::uno::Reference< css::awt::XWindow > * pComps = Components.getConstArray(); + + vcl::Window* pPrevWin = nullptr; + vcl::Window* pPrevRadio = nullptr; + for ( sal_uInt32 n = 0; n < nCount; n++ ) + { + VclPtr pWin = VCLUnoHelper::GetWindow( pComps[n] ); + if ( pWin ) + { + vcl::Window* pSortBehind = pPrevWin; + // #57096# Sort all radios consecutively + bool bNewPrevWin = true; + if ( pWin->GetType() == WindowType::RADIOBUTTON ) + { + if ( pPrevRadio ) + { + // This RadioButton was sorted before PrevWin + bNewPrevWin = ( pPrevWin == pPrevRadio ); + pSortBehind = pPrevRadio; + } + pPrevRadio = pWin; + } + + // Z-Order + if ( pSortBehind ) + pWin->SetZOrder( pSortBehind, ZOrderFlags::Behind ); + + WinBits nStyle = pWin->GetStyle(); + if ( n == 0 ) + nStyle |= WB_GROUP; + else + nStyle &= (~WB_GROUP); + pWin->SetStyle( nStyle ); + + // Add WB_GROUP after the last group + if ( n == ( nCount - 1 ) ) + { + vcl::Window* pBehindLast = pWin->GetWindow( GetWindowType::Next ); + if ( pBehindLast ) + { + WinBits nLastStyle = pBehindLast->GetStyle(); + nLastStyle |= WB_GROUP; + pBehindLast->SetStyle( nLastStyle ); + } + } + + if ( bNewPrevWin ) + pPrevWin = pWin; + } + } +} + +void SAL_CALL VCLXContainer::setProperty( + const OUString& PropertyName, + const css::uno::Any& Value ) +{ + SolarMutexGuard aGuard; + + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_SCROLLHEIGHT: + case BASEPROPERTY_SCROLLWIDTH: + case BASEPROPERTY_SCROLLTOP: + case BASEPROPERTY_SCROLLLEFT: + { + sal_Int32 nVal =0; + Value >>= nVal; + Size aSize( nVal, nVal ); + VclPtr pWindow = GetWindow(); + MapMode aMode( MapUnit::MapAppFont ); + toolkit::ScrollableDialog* pScrollable = dynamic_cast< toolkit::ScrollableDialog* >( pWindow.get() ); + TabPage* pScrollTabPage = dynamic_cast< TabPage* >( pWindow.get() ); + if ( pWindow && (pScrollable || pScrollTabPage) ) + { + aSize = pWindow->LogicToPixel( aSize, aMode ); + switch ( nPropType ) + { + case BASEPROPERTY_SCROLLHEIGHT: + pScrollable ? pScrollable->SetScrollHeight( aSize.Height() ) : (void)0; + pScrollTabPage ? pScrollTabPage->SetScrollHeight( aSize.Height() ) : (void)0; + break; + case BASEPROPERTY_SCROLLWIDTH: + pScrollable ? pScrollable->SetScrollWidth( aSize.Width() ) : (void)0; + pScrollTabPage ? pScrollTabPage->SetScrollWidth( aSize.Width() ) : (void)0; + break; + case BASEPROPERTY_SCROLLTOP: + pScrollable ? pScrollable->SetScrollTop( aSize.Height() ) : (void)0; + pScrollTabPage ? pScrollTabPage->SetScrollTop( aSize.Height() ) : (void)0; + break; + case BASEPROPERTY_SCROLLLEFT: + pScrollable ? pScrollable->SetScrollLeft( aSize.Width() ) : (void)0; + pScrollTabPage ? pScrollTabPage->SetScrollLeft( aSize.Width() ) : (void)0; + break; + default: + break; + } + break; + } + break; + } + + default: + { + VCLXWindow::setProperty( PropertyName, Value ); + } + } +} +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/source/awt/vclxdevice.cxx b/toolkit/source/awt/vclxdevice.cxx new file mode 100644 index 000000000..5b83b9e62 --- /dev/null +++ b/toolkit/source/awt/vclxdevice.cxx @@ -0,0 +1,254 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include + +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + + +VCLXDevice::VCLXDevice() +{ +} + +VCLXDevice::~VCLXDevice() +{ + //TODO: why was this empty, and everything done in ~VCLXVirtualDevice? + SolarMutexGuard g; + mpOutputDevice.reset(); +} + +// css::lang::XUnoTunnel +UNO3_GETIMPLEMENTATION_IMPL( VCLXDevice ); + +// css::awt::XDevice, +css::uno::Reference< css::awt::XGraphics > VCLXDevice::createGraphics( ) +{ + SolarMutexGuard aGuard; + + css::uno::Reference< css::awt::XGraphics > xRef; + + if ( mpOutputDevice ) + xRef = mpOutputDevice->CreateUnoGraphics(); + + return xRef; +} + +css::uno::Reference< css::awt::XDevice > VCLXDevice::createDevice( sal_Int32 nWidth, sal_Int32 nHeight ) +{ + SolarMutexGuard aGuard; + + css::uno::Reference< css::awt::XDevice > xRef; + if ( GetOutputDevice() ) + { + rtl::Reference pVDev = new VCLXVirtualDevice; + VclPtrInstance pVclVDev( *GetOutputDevice() ); + pVclVDev->SetOutputSizePixel( Size( nWidth, nHeight ) ); + pVDev->SetVirtualDevice( pVclVDev ); + xRef = pVDev; + } + return xRef; +} + +css::awt::DeviceInfo VCLXDevice::getInfo() +{ + SolarMutexGuard aGuard; + + css::awt::DeviceInfo aInfo; + + if (mpOutputDevice) + aInfo = mpOutputDevice->GetDeviceInfo(); + + return aInfo; +} + +css::uno::Sequence< css::awt::FontDescriptor > VCLXDevice::getFontDescriptors( ) +{ + SolarMutexGuard aGuard; + + css::uno::Sequence< css::awt::FontDescriptor> aFonts; + if( mpOutputDevice ) + { + int nFonts = mpOutputDevice->GetFontFaceCollectionCount(); + if ( nFonts ) + { + aFonts = css::uno::Sequence< css::awt::FontDescriptor>( nFonts ); + css::awt::FontDescriptor* pFonts = aFonts.getArray(); + for ( int n = 0; n < nFonts; n++ ) + pFonts[n] = VCLUnoHelper::CreateFontDescriptor( mpOutputDevice->GetFontMetricFromCollection( n ) ); + } + } + return aFonts; +} + +css::uno::Reference< css::awt::XFont > VCLXDevice::getFont( const css::awt::FontDescriptor& rDescriptor ) +{ + SolarMutexGuard aGuard; + + css::uno::Reference< css::awt::XFont > xRef; + if( mpOutputDevice ) + { + rtl::Reference pMetric = new VCLXFont; + pMetric->Init( *this, VCLUnoHelper::CreateFont( rDescriptor, mpOutputDevice->GetFont() ) ); + xRef = pMetric; + } + return xRef; +} + +css::uno::Reference< css::awt::XBitmap > VCLXDevice::createBitmap( sal_Int32 nX, sal_Int32 nY, sal_Int32 nWidth, sal_Int32 nHeight ) +{ + SolarMutexGuard aGuard; + + css::uno::Reference< css::awt::XBitmap > xBmp; + if( mpOutputDevice ) + { + BitmapEx aBmp = mpOutputDevice->GetBitmapEx( Point( nX, nY ), Size( nWidth, nHeight ) ); + + rtl::Reference pBmp = new VCLXBitmap; + pBmp->SetBitmap( aBmp ); + xBmp = pBmp; + } + return xBmp; +} + +css::uno::Reference< css::awt::XDisplayBitmap > VCLXDevice::createDisplayBitmap( const css::uno::Reference< css::awt::XBitmap >& rxBitmap ) +{ + SolarMutexGuard aGuard; + + BitmapEx aBmp = VCLUnoHelper::GetBitmap( rxBitmap ); + rtl::Reference pBmp = new VCLXBitmap; + pBmp->SetBitmap( aBmp ); + return pBmp; +} + +VCLXVirtualDevice::~VCLXVirtualDevice() +{ + SolarMutexGuard aGuard; + + mpOutputDevice.disposeAndClear(); +} + +// Interface implementation of css::awt::XUnitConversion + +css::awt::Point SAL_CALL VCLXDevice::convertPointToLogic( const css::awt::Point& aPoint, ::sal_Int16 TargetUnit ) +{ + SolarMutexGuard aGuard; + if (TargetUnit == css::util::MeasureUnit::PERCENT ) + { + // percentage not allowed here + throw css::lang::IllegalArgumentException(); + } + + css::awt::Point aAWTPoint(0,0); + // X,Y + + if( mpOutputDevice ) + { + MapMode aMode(VCLUnoHelper::ConvertToMapModeUnit(TargetUnit)); + ::Point aVCLPoint = VCLUnoHelper::ConvertToVCLPoint(aPoint); + ::Point aDevPoint = mpOutputDevice->PixelToLogic(aVCLPoint, aMode ); + aAWTPoint = VCLUnoHelper::ConvertToAWTPoint(aDevPoint); + } + + return aAWTPoint; +} + + +css::awt::Point SAL_CALL VCLXDevice::convertPointToPixel( const css::awt::Point& aPoint, ::sal_Int16 SourceUnit ) +{ + SolarMutexGuard aGuard; + if (SourceUnit == css::util::MeasureUnit::PERCENT || + SourceUnit == css::util::MeasureUnit::PIXEL ) + { + // pixel or percentage not allowed here + throw css::lang::IllegalArgumentException(); + } + + css::awt::Point aAWTPoint(0,0); + + if( mpOutputDevice ) + { + MapMode aMode(VCLUnoHelper::ConvertToMapModeUnit(SourceUnit)); + ::Point aVCLPoint = VCLUnoHelper::ConvertToVCLPoint(aPoint); + ::Point aDevPoint = mpOutputDevice->LogicToPixel(aVCLPoint, aMode ); + aAWTPoint = VCLUnoHelper::ConvertToAWTPoint(aDevPoint); + } + + return aAWTPoint; +} + +css::awt::Size SAL_CALL VCLXDevice::convertSizeToLogic( const css::awt::Size& aSize, ::sal_Int16 TargetUnit ) +{ + SolarMutexGuard aGuard; + if (TargetUnit == css::util::MeasureUnit::PERCENT) + { + // percentage not allowed here + throw css::lang::IllegalArgumentException(); + } + + css::awt::Size aAWTSize(0,0); + // Width, Height + + + if( mpOutputDevice ) + { + MapMode aMode(VCLUnoHelper::ConvertToMapModeUnit(TargetUnit)); + ::Size aVCLSize = VCLUnoHelper::ConvertToVCLSize(aSize); + ::Size aDevSz = mpOutputDevice->PixelToLogic(aVCLSize, aMode ); + aAWTSize = VCLUnoHelper::ConvertToAWTSize(aDevSz); + } + + return aAWTSize; +} + +css::awt::Size SAL_CALL VCLXDevice::convertSizeToPixel( const css::awt::Size& aSize, ::sal_Int16 SourceUnit ) +{ + SolarMutexGuard aGuard; + if (SourceUnit == css::util::MeasureUnit::PERCENT || + SourceUnit == css::util::MeasureUnit::PIXEL) + { + // pixel or percentage not allowed here + throw css::lang::IllegalArgumentException(); + } + + css::awt::Size aAWTSize(0,0); + // Width, Height + if( mpOutputDevice ) + { + MapMode aMode(VCLUnoHelper::ConvertToMapModeUnit(SourceUnit)); + ::Size aVCLSize = VCLUnoHelper::ConvertToVCLSize(aSize); + ::Size aDevSz = mpOutputDevice->LogicToPixel(aVCLSize, aMode ); + aAWTSize = VCLUnoHelper::ConvertToAWTSize(aDevSz); + } + + return aAWTSize; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/source/awt/vclxfont.cxx b/toolkit/source/awt/vclxfont.cxx new file mode 100644 index 000000000..e84fe338c --- /dev/null +++ b/toolkit/source/awt/vclxfont.cxx @@ -0,0 +1,191 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include + +#include + +#include +#include +#include + +#include +#include +#include + + + +VCLXFont::VCLXFont() +{ + mpFontMetric = nullptr; +} + +VCLXFont::~VCLXFont() +{ +} + +void VCLXFont::Init( css::awt::XDevice& rxDev, const vcl::Font& rFont ) +{ + mxDevice = &rxDev; + + mpFontMetric.reset(); + + maFont = rFont; +} + +bool VCLXFont::ImplAssertValidFontMetric() +{ + if ( !mpFontMetric && mxDevice.is() ) + { + OutputDevice* pOutDev = VCLUnoHelper::GetOutputDevice( mxDevice ); + if ( pOutDev ) + { + vcl::Font aOldFont = pOutDev->GetFont(); + pOutDev->SetFont( maFont ); + mpFontMetric.reset( new FontMetric( pOutDev->GetFontMetric() ) ); + pOutDev->SetFont( aOldFont ); + } + } + return mpFontMetric != nullptr; +} + +// css::lang::XUnoTunnel +UNO3_GETIMPLEMENTATION_IMPL( VCLXFont ); + +css::awt::FontDescriptor VCLXFont::getFontDescriptor( ) +{ + std::unique_lock aGuard( maMutex ); + + return VCLUnoHelper::CreateFontDescriptor( maFont ); + +} + +css::awt::SimpleFontMetric VCLXFont::getFontMetric( ) +{ + std::unique_lock aGuard( maMutex ); + + css::awt::SimpleFontMetric aFM; + if ( ImplAssertValidFontMetric() ) + aFM = VCLUnoHelper::CreateFontMetric( *mpFontMetric ); + return aFM; +} + +sal_Int16 VCLXFont::getCharWidth( sal_Unicode c ) +{ + std::unique_lock aGuard( maMutex ); + + sal_Int16 nRet = -1; + OutputDevice* pOutDev = VCLUnoHelper::GetOutputDevice( mxDevice ); + if ( pOutDev ) + { + vcl::Font aOldFont = pOutDev->GetFont(); + pOutDev->SetFont( maFont ); + + nRet = sal::static_int_cast< sal_Int16 >( + pOutDev->GetTextWidth( OUString(c) )); + + pOutDev->SetFont( aOldFont ); + } + return nRet; +} + +css::uno::Sequence< sal_Int16 > VCLXFont::getCharWidths( sal_Unicode nFirst, sal_Unicode nLast ) +{ + std::unique_lock aGuard( maMutex ); + + css::uno::Sequence aSeq; + OutputDevice* pOutDev = VCLUnoHelper::GetOutputDevice( mxDevice ); + if ( pOutDev ) + { + vcl::Font aOldFont = pOutDev->GetFont(); + pOutDev->SetFont( maFont ); + + sal_Int16 nCount = nLast-nFirst + 1; + aSeq = css::uno::Sequence( nCount ); + for ( sal_uInt16 n = 0; n < nCount; n++ ) + { + aSeq.getArray()[n] = sal::static_int_cast< sal_Int16 >( + pOutDev->GetTextWidth( + OUString(static_cast< sal_Unicode >(nFirst+n)) )); + } + + pOutDev->SetFont( aOldFont ); + } + return aSeq; +} + +sal_Int32 VCLXFont::getStringWidth( const OUString& str ) +{ + std::unique_lock aGuard( maMutex ); + + sal_Int32 nRet = -1; + OutputDevice* pOutDev = VCLUnoHelper::GetOutputDevice( mxDevice ); + if ( pOutDev ) + { + vcl::Font aOldFont = pOutDev->GetFont(); + pOutDev->SetFont( maFont ); + nRet = pOutDev->GetTextWidth( str ); + pOutDev->SetFont( aOldFont ); + } + return nRet; +} + +sal_Int32 VCLXFont::getStringWidthArray( const OUString& str, css::uno::Sequence< sal_Int32 >& rDXArray ) +{ + std::unique_lock aGuard( maMutex ); + + sal_Int32 nRet = -1; + OutputDevice* pOutDev = VCLUnoHelper::GetOutputDevice( mxDevice ); + if ( pOutDev ) + { + vcl::Font aOldFont = pOutDev->GetFont(); + pOutDev->SetFont( maFont ); + std::vector aDXA; + nRet = pOutDev->GetTextArray( str, &aDXA ); + // I don't know if size of aDXA is guaranteed same as length of str, so use arrayToSequence + rDXArray = comphelper::arrayToSequence(aDXA.data(), str.getLength()); + pOutDev->SetFont( aOldFont ); + } + return nRet; +} + +void VCLXFont::getKernPairs( css::uno::Sequence< sal_Unicode >& /*rnChars1*/, css::uno::Sequence< sal_Unicode >& /*rnChars2*/, css::uno::Sequence< sal_Int16 >& /*rnKerns*/ ) +{ + // NOTE: this empty method is just used for keeping the related UNO-API stable +} + +// css::awt::XFont2 +sal_Bool VCLXFont::hasGlyphs( const OUString& aText ) +{ + std::unique_lock aGuard( maMutex ); + SolarMutexGuard aSolarGuard; + + OutputDevice* pOutDev = VCLUnoHelper::GetOutputDevice( mxDevice ); + if ( pOutDev ) + { + if ( pOutDev->HasGlyphs( maFont, aText ) == -1 ) + { + return true; + } + } + + return false; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/source/awt/vclxgraphics.cxx b/toolkit/source/awt/vclxgraphics.cxx new file mode 100644 index 000000000..a8409a5cf --- /dev/null +++ b/toolkit/source/awt/vclxgraphics.cxx @@ -0,0 +1,490 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +using namespace com::sun::star; + + + +// lang::XUnoTunnel +UNO3_GETIMPLEMENTATION_IMPL( VCLXGraphics ); + +VCLXGraphics::VCLXGraphics() + : mpOutputDevice(nullptr) + , meRasterOp(RasterOp::OverPaint) +{ +} + +VCLXGraphics::~VCLXGraphics() +{ + std::vector< VCLXGraphics* > *pLst = mpOutputDevice ? mpOutputDevice->GetUnoGraphicsList() : nullptr; + if ( pLst ) + { + auto it = std::find(pLst->begin(), pLst->end(), this); + if (it != pLst->end()) + pLst->erase( it ); + } + + mpClipRegion.reset(); + + SolarMutexGuard g; + mpOutputDevice.reset(); +} + +void VCLXGraphics::SetOutputDevice( OutputDevice* pOutDev ) +{ + mpOutputDevice = pOutDev; + mxDevice = nullptr; + initAttrs(); +} + +void VCLXGraphics::Init( OutputDevice* pOutDev ) +{ + DBG_ASSERT( !mpOutputDevice, "VCLXGraphics::Init already has pOutDev !" ); + mpOutputDevice = pOutDev; + + initAttrs(); + mpClipRegion = nullptr; + + // Register at OutputDevice + std::vector< VCLXGraphics* > *pLst = mpOutputDevice->GetUnoGraphicsList(); + if ( !pLst ) + pLst = mpOutputDevice->CreateUnoGraphicsList(); + pLst->push_back( this ); +} + +void VCLXGraphics::initAttrs() +{ + if ( !mpOutputDevice ) + return; + + maFont = mpOutputDevice->GetFont(); + maTextColor = mpOutputDevice->GetTextColor(); /* COL_BLACK */ + maTextFillColor = mpOutputDevice->GetTextFillColor(); /* COL_TRANSPARENT */ + maLineColor = mpOutputDevice->GetLineColor(); /* COL_BLACK */ + maFillColor = mpOutputDevice->GetFillColor(); /* COL_WHITE */ + meRasterOp = mpOutputDevice->GetRasterOp(); /* RasterOp::OverPaint */ +} + +void VCLXGraphics::InitOutputDevice( InitOutDevFlags nFlags ) +{ + if(!mpOutputDevice) + return; + + SolarMutexGuard aVclGuard; + + if ( nFlags & InitOutDevFlags::FONT ) + { + mpOutputDevice->SetFont( maFont ); + mpOutputDevice->SetTextColor( maTextColor ); + mpOutputDevice->SetTextFillColor( maTextFillColor ); + } + + if ( nFlags & InitOutDevFlags::COLORS ) + { + mpOutputDevice->SetLineColor( maLineColor ); + mpOutputDevice->SetFillColor( maFillColor ); + } + + mpOutputDevice->SetRasterOp( meRasterOp ); + + if( mpClipRegion ) + mpOutputDevice->SetClipRegion( *mpClipRegion ); + else + mpOutputDevice->SetClipRegion(); +} + +uno::Reference< awt::XDevice > VCLXGraphics::getDevice() +{ + SolarMutexGuard aGuard; + + if( !mxDevice.is() && mpOutputDevice ) + { + rtl::Reference pDev = new VCLXDevice; + pDev->SetOutputDevice( mpOutputDevice ); + mxDevice = pDev; + } + return mxDevice; +} + +awt::SimpleFontMetric VCLXGraphics::getFontMetric() +{ + SolarMutexGuard aGuard; + + awt::SimpleFontMetric aM; + if( mpOutputDevice ) + { + mpOutputDevice->SetFont( maFont ); + aM = VCLUnoHelper::CreateFontMetric( mpOutputDevice->GetFontMetric() ); + } + return aM; +} + +void VCLXGraphics::setFont( const uno::Reference< awt::XFont >& rxFont ) +{ + SolarMutexGuard aGuard; + + maFont = VCLUnoHelper::CreateFont( rxFont ); +} + +void VCLXGraphics::selectFont( const awt::FontDescriptor& rDescription ) +{ + SolarMutexGuard aGuard; + + maFont = VCLUnoHelper::CreateFont( rDescription, vcl::Font() ); +} + +void VCLXGraphics::setTextColor( sal_Int32 nColor ) +{ + SolarMutexGuard aGuard; + + maTextColor = Color( ColorTransparency, nColor ); +} + +void VCLXGraphics::setTextFillColor( sal_Int32 nColor ) +{ + SolarMutexGuard aGuard; + + maTextFillColor = Color( ColorTransparency, nColor ); +} + +void VCLXGraphics::setLineColor( sal_Int32 nColor ) +{ + SolarMutexGuard aGuard; + + maLineColor = Color( ColorTransparency, nColor ); +} + +void VCLXGraphics::setFillColor( sal_Int32 nColor ) +{ + SolarMutexGuard aGuard; + + maFillColor = Color( ColorTransparency, nColor ); +} + +void VCLXGraphics::setRasterOp( awt::RasterOperation eROP ) +{ + SolarMutexGuard aGuard; + + meRasterOp = static_cast(eROP); +} + +void VCLXGraphics::setClipRegion( const uno::Reference< awt::XRegion >& rxRegion ) +{ + SolarMutexGuard aGuard; + + if ( rxRegion.is() ) + mpClipRegion.reset( new vcl::Region( VCLUnoHelper::GetRegion( rxRegion ) ) ); + else + mpClipRegion.reset(); +} + +void VCLXGraphics::intersectClipRegion( const uno::Reference< awt::XRegion >& rxRegion ) +{ + SolarMutexGuard aGuard; + + if ( rxRegion.is() ) + { + vcl::Region aRegion( VCLUnoHelper::GetRegion( rxRegion ) ); + if ( !mpClipRegion ) + mpClipRegion.reset( new vcl::Region( aRegion ) ); + else + mpClipRegion->Intersect( aRegion ); + } +} + +void VCLXGraphics::push( ) +{ + SolarMutexGuard aGuard; + + + if( mpOutputDevice ) + mpOutputDevice->Push(); +} + +void VCLXGraphics::pop( ) +{ + SolarMutexGuard aGuard; + + + if( mpOutputDevice ) + mpOutputDevice->Pop(); +} + +void VCLXGraphics::clear( + const awt::Rectangle& aRect ) +{ + SolarMutexGuard aGuard; + + if( mpOutputDevice ) + { + const ::tools::Rectangle aVCLRect = VCLUnoHelper::ConvertToVCLRect( aRect ); + mpOutputDevice->Erase( aVCLRect ); + } +} + +void VCLXGraphics::copy( const uno::Reference< awt::XDevice >& rxSource, sal_Int32 nSourceX, sal_Int32 nSourceY, sal_Int32 nSourceWidth, sal_Int32 nSourceHeight, sal_Int32 nDestX, sal_Int32 nDestY, sal_Int32 nDestWidth, sal_Int32 nDestHeight ) +{ + SolarMutexGuard aGuard; + + if ( mpOutputDevice ) + { + VCLXDevice* pFromDev = comphelper::getFromUnoTunnel( rxSource ); + DBG_ASSERT( pFromDev, "VCLXGraphics::copy - invalid device" ); + if ( pFromDev ) + { + InitOutputDevice( InitOutDevFlags::NONE ); + mpOutputDevice->DrawOutDev( Point( nDestX, nDestY ), Size( nDestWidth, nDestHeight ), + Point( nSourceX, nSourceY ), Size( nSourceWidth, nSourceHeight ), *pFromDev->GetOutputDevice() ); + } + } +} + +void VCLXGraphics::draw( const uno::Reference< awt::XDisplayBitmap >& rxBitmapHandle, sal_Int32 nSourceX, sal_Int32 nSourceY, sal_Int32 nSourceWidth, sal_Int32 nSourceHeight, sal_Int32 nDestX, sal_Int32 nDestY, sal_Int32 nDestWidth, sal_Int32 nDestHeight ) +{ + SolarMutexGuard aGuard; + + if( !mpOutputDevice ) + return; + + InitOutputDevice( InitOutDevFlags::NONE); + uno::Reference< awt::XBitmap > xBitmap( rxBitmapHandle, uno::UNO_QUERY ); + BitmapEx aBmpEx = VCLUnoHelper::GetBitmap( xBitmap ); + + Point aPos(nDestX - nSourceX, nDestY - nSourceY); + Size aSz = aBmpEx.GetSizePixel(); + + if(nDestWidth != nSourceWidth) + { + float zoomX = static_cast(nDestWidth) / static_cast(nSourceWidth); + aSz.setWidth( static_cast(static_cast(aSz.Width()) * zoomX) ); + } + + if(nDestHeight != nSourceHeight) + { + float zoomY = static_cast(nDestHeight) / static_cast(nSourceHeight); + aSz.setHeight( static_cast(static_cast(aSz.Height()) * zoomY) ); + } + + if(nSourceX || nSourceY || aSz.Width() != nSourceWidth || aSz.Height() != nSourceHeight) + mpOutputDevice->IntersectClipRegion(vcl::Region(tools::Rectangle(nDestX, nDestY, nDestX + nDestWidth - 1, nDestY + nDestHeight - 1))); + + mpOutputDevice->DrawBitmapEx( aPos, aSz, aBmpEx ); +} + +void VCLXGraphics::drawPixel( sal_Int32 x, sal_Int32 y ) +{ + SolarMutexGuard aGuard; + + if( mpOutputDevice ) + { + InitOutputDevice( InitOutDevFlags::COLORS ); + mpOutputDevice->DrawPixel( Point( x, y ) ); + } +} + +void VCLXGraphics::drawLine( sal_Int32 x1, sal_Int32 y1, sal_Int32 x2, sal_Int32 y2 ) +{ + SolarMutexGuard aGuard; + + if( mpOutputDevice ) + { + InitOutputDevice( InitOutDevFlags::COLORS ); + mpOutputDevice->DrawLine( Point( x1, y1 ), Point( x2, y2 ) ); + } +} + +void VCLXGraphics::drawRect( sal_Int32 x, sal_Int32 y, sal_Int32 width, sal_Int32 height ) +{ + SolarMutexGuard aGuard; + + if( mpOutputDevice ) + { + InitOutputDevice( InitOutDevFlags::COLORS ); + mpOutputDevice->DrawRect( tools::Rectangle( Point( x, y ), Size( width, height ) ) ); + } +} + +void VCLXGraphics::drawRoundedRect( sal_Int32 x, sal_Int32 y, sal_Int32 width, sal_Int32 height, sal_Int32 nHorzRound, sal_Int32 nVertRound ) +{ + SolarMutexGuard aGuard; + + if( mpOutputDevice ) + { + InitOutputDevice( InitOutDevFlags::COLORS ); + mpOutputDevice->DrawRect( tools::Rectangle( Point( x, y ), Size( width, height ) ), nHorzRound, nVertRound ); + } +} + +void VCLXGraphics::drawPolyLine( const uno::Sequence< sal_Int32 >& DataX, const uno::Sequence< sal_Int32 >& DataY ) +{ + SolarMutexGuard aGuard; + + if( mpOutputDevice ) + { + InitOutputDevice( InitOutDevFlags::COLORS ); + mpOutputDevice->DrawPolyLine( VCLUnoHelper::CreatePolygon( DataX, DataY ) ); + } +} + +void VCLXGraphics::drawPolygon( const uno::Sequence< sal_Int32 >& DataX, const uno::Sequence< sal_Int32 >& DataY ) +{ + SolarMutexGuard aGuard; + + if( mpOutputDevice ) + { + InitOutputDevice( InitOutDevFlags::COLORS ); + mpOutputDevice->DrawPolygon( VCLUnoHelper::CreatePolygon( DataX, DataY ) ); + } +} + +void VCLXGraphics::drawPolyPolygon( const uno::Sequence< uno::Sequence< sal_Int32 > >& DataX, const uno::Sequence< uno::Sequence< sal_Int32 > >& DataY ) +{ + SolarMutexGuard aGuard; + + if( mpOutputDevice ) + { + InitOutputDevice( InitOutDevFlags::COLORS ); + sal_uInt16 nPolys = static_cast(DataX.getLength()); + tools::PolyPolygon aPolyPoly( nPolys ); + for ( sal_uInt16 n = 0; n < nPolys; n++ ) + aPolyPoly[n] = VCLUnoHelper::CreatePolygon( DataX.getConstArray()[n], DataY.getConstArray()[n] ); + + mpOutputDevice->DrawPolyPolygon( aPolyPoly ); + } +} + +void VCLXGraphics::drawEllipse( sal_Int32 x, sal_Int32 y, sal_Int32 width, sal_Int32 height ) +{ + SolarMutexGuard aGuard; + + if( mpOutputDevice ) + { + InitOutputDevice( InitOutDevFlags::COLORS ); + mpOutputDevice->DrawEllipse( tools::Rectangle( Point( x, y ), Size( width, height ) ) ); + } +} + +void VCLXGraphics::drawArc( sal_Int32 x, sal_Int32 y, sal_Int32 width, sal_Int32 height, sal_Int32 x1, sal_Int32 y1, sal_Int32 x2, sal_Int32 y2 ) +{ + SolarMutexGuard aGuard; + + if( mpOutputDevice ) + { + InitOutputDevice( InitOutDevFlags::COLORS ); + mpOutputDevice->DrawArc( tools::Rectangle( Point( x, y ), Size( width, height ) ), Point( x1, y1 ), Point( x2, y2 ) ); + } +} + +void VCLXGraphics::drawPie( sal_Int32 x, sal_Int32 y, sal_Int32 width, sal_Int32 height, sal_Int32 x1, sal_Int32 y1, sal_Int32 x2, sal_Int32 y2 ) +{ + SolarMutexGuard aGuard; + + if( mpOutputDevice ) + { + InitOutputDevice( InitOutDevFlags::COLORS ); + mpOutputDevice->DrawPie( tools::Rectangle( Point( x, y ), Size( width, height ) ), Point( x1, y1 ), Point( x2, y2 ) ); + } +} + +void VCLXGraphics::drawChord( sal_Int32 x, sal_Int32 y, sal_Int32 width, sal_Int32 height, sal_Int32 x1, sal_Int32 y1, sal_Int32 x2, sal_Int32 y2 ) +{ + SolarMutexGuard aGuard; + + if( mpOutputDevice ) + { + InitOutputDevice( InitOutDevFlags::COLORS ); + mpOutputDevice->DrawChord( tools::Rectangle( Point( x, y ), Size( width, height ) ), Point( x1, y1 ), Point( x2, y2 ) ); + } +} + +void VCLXGraphics::drawGradient( sal_Int32 x, sal_Int32 y, sal_Int32 width, sal_Int32 height, const awt::Gradient& rGradient ) +{ + SolarMutexGuard aGuard; + + if( !mpOutputDevice ) + return; + + InitOutputDevice( InitOutDevFlags::COLORS ); + Gradient aGradient(static_cast(rGradient.Style), Color(ColorTransparency, rGradient.StartColor), Color(ColorTransparency, rGradient.EndColor)); + aGradient.SetAngle(Degree10(rGradient.Angle)); + aGradient.SetBorder(rGradient.Border); + aGradient.SetOfsX(rGradient.XOffset); + aGradient.SetOfsY(rGradient.YOffset); + aGradient.SetStartIntensity(rGradient.StartIntensity); + aGradient.SetEndIntensity(rGradient.EndIntensity); + aGradient.SetSteps(rGradient.StepCount); + mpOutputDevice->DrawGradient( tools::Rectangle( Point( x, y ), Size( width, height ) ), aGradient ); +} + +void VCLXGraphics::drawText( sal_Int32 x, sal_Int32 y, const OUString& rText ) +{ + SolarMutexGuard aGuard; + + if( mpOutputDevice ) + { + InitOutputDevice( InitOutDevFlags::COLORS |InitOutDevFlags::FONT); + mpOutputDevice->DrawText( Point( x, y ), rText ); + } +} + +void VCLXGraphics::drawTextArray( sal_Int32 x, sal_Int32 y, const OUString& rText, const uno::Sequence< sal_Int32 >& rLongs ) +{ + SolarMutexGuard aGuard; + + if( mpOutputDevice ) + { + InitOutputDevice( InitOutDevFlags::COLORS|InitOutDevFlags::FONT ); + std::vector aDXA(rText.getLength()); + for(int i = 0; i < rText.getLength(); i++) + { + aDXA[i] = rLongs[i]; + } + mpOutputDevice->DrawTextArray( Point( x, y ), rText, aDXA ); + } +} + + +void VCLXGraphics::drawImage( sal_Int32 x, sal_Int32 y, sal_Int32 width, sal_Int32 height, sal_Int16 nStyle, const uno::Reference< graphic::XGraphic >& xGraphic ) +{ + SolarMutexGuard aGuard; + + if( mpOutputDevice && xGraphic.is() ) + { + Image aImage( xGraphic ); + if ( !!aImage ) + { + InitOutputDevice( InitOutDevFlags::COLORS ); + mpOutputDevice->DrawImage( Point( x, y ), Size( width, height ), aImage, static_cast(nStyle) ); + } + } +} +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/source/awt/vclxmenu.cxx b/toolkit/source/awt/vclxmenu.cxx new file mode 100644 index 000000000..b17f32c2a --- /dev/null +++ b/toolkit/source/awt/vclxmenu.cxx @@ -0,0 +1,872 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +VCLXMenu::VCLXMenu() + : maMenuListeners( *this ) + , mnDefaultItem(0) +{ + mpMenu = nullptr; +} + +VCLXMenu::VCLXMenu( Menu* pMenu ) + : maMenuListeners( *this ) + , mnDefaultItem(0) +{ + mpMenu = pMenu; +} + +VCLXMenu::~VCLXMenu() +{ + maPopupMenuRefs.clear(); + if ( mpMenu ) + { + SolarMutexGuard g; + mpMenu->RemoveEventListener( LINK( this, VCLXMenu, MenuEventListener ) ); + mpMenu.disposeAndClear(); + } +} + +bool VCLXMenu::IsPopupMenu() const +{ + return (mpMenu && ! mpMenu->IsMenuBar()); +} + +void VCLXMenu::ImplCreateMenu( bool bPopup ) +{ + DBG_ASSERT( !mpMenu, "CreateMenu: Menu exists!" ); + + if ( bPopup ) + mpMenu = VclPtr::Create(); + else + mpMenu = VclPtr::Create(); + + mpMenu->AddEventListener( LINK( this, VCLXMenu, MenuEventListener ) ); +} + +void VCLXMenu::ImplAddListener() +{ + assert(mpMenu); + mpMenu->AddEventListener( LINK( this, VCLXMenu, MenuEventListener ) ); +} + +IMPL_LINK( VCLXMenu, MenuEventListener, VclMenuEvent&, rMenuEvent, void ) +{ + DBG_ASSERT( rMenuEvent.GetMenu() && mpMenu, "Menu???" ); + + if ( rMenuEvent.GetMenu() != mpMenu ) // Also called for the root menu + return; + + switch ( rMenuEvent.GetId() ) + { + case VclEventId::MenuSelect: + { + if ( maMenuListeners.getLength() ) + { + css::awt::MenuEvent aEvent; + aEvent.Source = static_cast(this); + aEvent.MenuId = mpMenu->GetCurItemId(); + maMenuListeners.itemSelected( aEvent ); + } + } + break; + case VclEventId::ObjectDying: + { + mpMenu = nullptr; + } + break; + case VclEventId::MenuHighlight: + { + if ( maMenuListeners.getLength() ) + { + css::awt::MenuEvent aEvent; + aEvent.Source = static_cast(this); + aEvent.MenuId = mpMenu->GetCurItemId(); + maMenuListeners.itemHighlighted( aEvent ); + } + } + break; + case VclEventId::MenuActivate: + { + if ( maMenuListeners.getLength() ) + { + css::awt::MenuEvent aEvent; + aEvent.Source = static_cast(this); + aEvent.MenuId = mpMenu->GetCurItemId(); + maMenuListeners.itemActivated( aEvent ); + } + } + break; + case VclEventId::MenuDeactivate: + { + if ( maMenuListeners.getLength() ) + { + css::awt::MenuEvent aEvent; + aEvent.Source = static_cast(this); + aEvent.MenuId = mpMenu->GetCurItemId(); + maMenuListeners.itemDeactivated( aEvent ); + } + } + break; + + // ignore accessibility events + case VclEventId::MenuEnable: + case VclEventId::MenuInsertItem: + case VclEventId::MenuRemoveItem: + case VclEventId::MenuSubmenuActivate: + case VclEventId::MenuSubmenuDeactivate: + case VclEventId::MenuSubmenuChanged: + case VclEventId::MenuDehighlight: + case VclEventId::MenuDisable: + case VclEventId::MenuItemTextChanged: + case VclEventId::MenuItemChecked: + case VclEventId::MenuItemUnchecked: + case VclEventId::MenuShow: + case VclEventId::MenuHide: + break; + + default: OSL_FAIL( "MenuEventListener - Unknown event!" ); + } +} + + +OUString SAL_CALL VCLXMenu::getImplementationName( ) +{ + std::unique_lock aGuard( maMutex ); + const bool bIsPopupMenu = IsPopupMenu(); + aGuard.unlock(); + + OUString implName( "stardiv.Toolkit." ); + if ( bIsPopupMenu ) + implName += "VCLXPopupMenu"; + else + implName += "VCLXMenuBar"; + + return implName; +} + +css::uno::Sequence< OUString > SAL_CALL VCLXMenu::getSupportedServiceNames( ) +{ + std::unique_lock aGuard( maMutex ); + const bool bIsPopupMenu = IsPopupMenu(); + aGuard.unlock(); + + if ( bIsPopupMenu ) + return css::uno::Sequence{ + "com.sun.star.awt.PopupMenu", + "stardiv.vcl.PopupMenu"}; + else + return css::uno::Sequence{ + "com.sun.star.awt.MenuBar", + "stardiv.vcl.MenuBar"}; +} + +sal_Bool SAL_CALL VCLXMenu::supportsService(const OUString& rServiceName ) +{ + return cppu::supportsService(this, rServiceName); +} + +css::uno::Any VCLXMenu::queryInterface( + const css::uno::Type & rType ) +{ + std::unique_lock aGuard( maMutex ); + const bool bIsPopupMenu = IsPopupMenu(); + aGuard.unlock(); + + css::uno::Any aRet; + + if ( bIsPopupMenu ) + aRet = ::cppu::queryInterface( rType, + static_cast< css::awt::XMenu* >(static_cast(this)), + static_cast< css::awt::XPopupMenu* >(this), + static_cast< css::lang::XTypeProvider* >(this), + static_cast< css::lang::XServiceInfo* >(this), + static_cast< css::lang::XUnoTunnel* >(this) ); + else + aRet = ::cppu::queryInterface( rType, + static_cast< css::awt::XMenu* >(static_cast(this)), + static_cast< css::awt::XMenuBar* >(this), + static_cast< css::lang::XTypeProvider* >(this), + static_cast< css::lang::XServiceInfo* >(this), + static_cast< css::lang::XUnoTunnel* >(this) ); + + return (aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType )); +} + + +UNO3_GETIMPLEMENTATION_IMPL( VCLXMenu ); + +css::uno::Sequence< css::uno::Type > VCLXMenu::getTypes() +{ + std::unique_lock aGuard( maMutex ); + const bool bIsPopupMenu = IsPopupMenu(); + aGuard.unlock(); + + if ( bIsPopupMenu ) + { + static cppu::OTypeCollection collectionPopupMenu( + cppu::UnoType::get(), cppu::UnoType::get(), + cppu::UnoType::get(), + cppu::UnoType::get()); + return collectionPopupMenu.getTypes(); + } + else + { + static cppu::OTypeCollection collectionMenuBar( + cppu::UnoType::get(), cppu::UnoType::get(), + cppu::UnoType::get(), + cppu::UnoType::get()); + return collectionMenuBar.getTypes(); + } +} + + +css::uno::Sequence< sal_Int8 > VCLXMenu::getImplementationId() +{ + return css::uno::Sequence(); +} + +void VCLXMenu::addMenuListener( + const css::uno::Reference< css::awt::XMenuListener >& rxListener ) +{ + std::unique_lock aGuard( maMutex ); + + maMenuListeners.addInterface( rxListener ); +} + +void VCLXMenu::removeMenuListener( + const css::uno::Reference< css::awt::XMenuListener >& rxListener ) +{ + std::unique_lock aGuard( maMutex ); + + maMenuListeners.removeInterface( rxListener ); +} + +void VCLXMenu::insertItem( + sal_Int16 nItemId, + const OUString& aText, + sal_Int16 nItemStyle, + sal_Int16 nPos ) +{ + SolarMutexGuard aSolarGuard; + std::unique_lock aGuard( maMutex ); + + if ( mpMenu ) + mpMenu->InsertItem(nItemId, aText, static_cast(nItemStyle), OString(), nPos); +} + +void VCLXMenu::removeItem( + sal_Int16 nPos, + sal_Int16 nCount ) +{ + SolarMutexGuard aSolarGuard; + std::unique_lock aGuard( maMutex ); + + if (!mpMenu) + return; + + sal_Int32 nItemCount = static_cast(mpMenu->GetItemCount()); + if ((nCount > 0) && (nPos >= 0) && (nPos < nItemCount)) + { + sal_Int16 nP = sal::static_int_cast< sal_Int16 >( + std::min( static_cast(nPos+nCount), static_cast(nItemCount) )); + while( nP-nPos > 0 ) + mpMenu->RemoveItem( --nP ); + } +} + +sal_Int16 VCLXMenu::getItemCount( ) +{ + SolarMutexGuard aSolarGuard; + std::unique_lock aGuard( maMutex ); + + return mpMenu ? mpMenu->GetItemCount() : 0; +} + +sal_Int16 VCLXMenu::getItemId( + sal_Int16 nPos ) +{ + SolarMutexGuard aSolarGuard; + std::unique_lock aGuard( maMutex ); + + return mpMenu ? mpMenu->GetItemId( nPos ) : 0; +} + +sal_Int16 VCLXMenu::getItemPos( + sal_Int16 nId ) +{ + SolarMutexGuard aSolarGuard; + std::unique_lock aGuard( maMutex ); + + return mpMenu ? mpMenu->GetItemPos( nId ) : 0; +} + +void VCLXMenu::enableItem( + sal_Int16 nItemId, + sal_Bool bEnable ) +{ + SolarMutexGuard aSolarGuard; + std::unique_lock aGuard( maMutex ); + + if ( mpMenu ) + mpMenu->EnableItem( nItemId, bEnable ); +} + +sal_Bool VCLXMenu::isItemEnabled( + sal_Int16 nItemId ) +{ + SolarMutexGuard aSolarGuard; + std::unique_lock aGuard( maMutex ); + + return mpMenu && mpMenu->IsItemEnabled( nItemId ); +} + +void VCLXMenu::setItemText( + sal_Int16 nItemId, + const OUString& aText ) +{ + SolarMutexGuard aSolarGuard; + std::unique_lock aGuard( maMutex ); + + if ( mpMenu ) + mpMenu->SetItemText( nItemId, aText ); +} + +OUString VCLXMenu::getItemText( + sal_Int16 nItemId ) +{ + SolarMutexGuard aSolarGuard; + std::unique_lock aGuard( maMutex ); + + OUString aItemText; + if ( mpMenu ) + aItemText = mpMenu->GetItemText( nItemId ); + return aItemText; +} + +void VCLXMenu::setPopupMenu( + sal_Int16 nItemId, + const css::uno::Reference< css::awt::XPopupMenu >& rxPopupMenu ) +{ + SolarMutexGuard aSolarGuard; + std::unique_lock aGuard( maMutex ); + + VCLXMenu* pVCLMenu = comphelper::getFromUnoTunnel( rxPopupMenu ); + DBG_ASSERT( pVCLMenu && pVCLMenu->GetMenu() && pVCLMenu->IsPopupMenu(), "setPopupMenu: Invalid Menu!" ); + + if ( mpMenu && pVCLMenu && pVCLMenu->GetMenu() && pVCLMenu->IsPopupMenu() ) + { + maPopupMenuRefs.push_back( rxPopupMenu ); + + mpMenu->SetPopupMenu( nItemId, static_cast( pVCLMenu->GetMenu() ) ); + } +} + +css::uno::Reference< css::awt::XPopupMenu > VCLXMenu::getPopupMenu( + sal_Int16 nItemId ) +{ + SolarMutexGuard aSolarGuard; + std::unique_lock aGuard( maMutex ); + + css::uno::Reference< css::awt::XPopupMenu > aRef; + Menu* pMenu = mpMenu ? mpMenu->GetPopupMenu( nItemId ) : nullptr; + if ( pMenu ) + { + for ( size_t n = maPopupMenuRefs.size(); n; ) + { + css::uno::Reference< css::awt::XPopupMenu >& rRef = maPopupMenuRefs[ --n ]; + Menu* pM = static_cast(rRef.get())->GetMenu(); + if ( pM == pMenu ) + { + aRef = rRef; + break; + } + } + // it seems the popup menu is not insert into maPopupMenuRefs + // if the popup men is not created by stardiv.Toolkit.VCLXPopupMenu + if( !aRef.is() ) + { + aRef = new VCLXPopupMenu( static_cast(pMenu) ); + } + } + return aRef; +} + +// css::awt::XPopupMenu +void VCLXMenu::insertSeparator( + sal_Int16 nPos ) +{ + SolarMutexGuard aSolarGuard; + std::unique_lock aGuard( maMutex ); + + if ( mpMenu ) + mpMenu->InsertSeparator(OString(), nPos); +} + +void VCLXMenu::setDefaultItem( + sal_Int16 nItemId ) +{ + std::unique_lock aGuard( maMutex ); + + mnDefaultItem = nItemId; +} + +sal_Int16 VCLXMenu::getDefaultItem( ) +{ + std::unique_lock aGuard( maMutex ); + + return mnDefaultItem; +} + +void VCLXMenu::checkItem( + sal_Int16 nItemId, + sal_Bool bCheck ) +{ + SolarMutexGuard aSolarGuard; + std::unique_lock aGuard( maMutex ); + + if ( mpMenu ) + mpMenu->CheckItem( nItemId, bCheck ); +} + +sal_Bool VCLXMenu::isItemChecked( + sal_Int16 nItemId ) +{ + SolarMutexGuard aSolarGuard; + std::unique_lock aGuard( maMutex ); + + return mpMenu && mpMenu->IsItemChecked( nItemId ); +} + +sal_Int16 VCLXMenu::execute( + const css::uno::Reference< css::awt::XWindowPeer >& rxWindowPeer, + const css::awt::Rectangle& rPos, + sal_Int16 nFlags ) +{ + SolarMutexGuard aSolarGuard; + auto pMenu = mpMenu; + { + std::unique_lock aGuard( maMutex ); + if ( !mpMenu || !IsPopupMenu() ) + return 0; + } + // cannot call this with mutex locked because it will call back into us + return static_cast(pMenu.get())->Execute( + VCLUnoHelper::GetWindow( rxWindowPeer ), + VCLRectangle( rPos ), + static_cast(nFlags) | PopupMenuFlags::NoMouseUpClose ); +} + + +void SAL_CALL VCLXMenu::setCommand( + sal_Int16 nItemId, + const OUString& aCommand ) +{ + SolarMutexGuard aSolarGuard; + std::unique_lock aGuard( maMutex ); + + if ( mpMenu ) + mpMenu->SetItemCommand( nItemId, aCommand ); +} + +OUString SAL_CALL VCLXMenu::getCommand( + sal_Int16 nItemId ) +{ + SolarMutexGuard aSolarGuard; + std::unique_lock aGuard( maMutex ); + + OUString aItemCommand; + if ( mpMenu ) + aItemCommand = mpMenu->GetItemCommand( nItemId ); + return aItemCommand; +} + +void SAL_CALL VCLXMenu::setHelpCommand( + sal_Int16 nItemId, + const OUString& aHelp ) +{ + SolarMutexGuard aSolarGuard; + std::unique_lock aGuard( maMutex ); + + if ( mpMenu ) + mpMenu->SetHelpCommand( nItemId, aHelp ); +} + +OUString SAL_CALL VCLXMenu::getHelpCommand( + sal_Int16 nItemId ) +{ + SolarMutexGuard aSolarGuard; + std::unique_lock aGuard( maMutex ); + + OUString aHelpCommand; + if ( mpMenu ) + aHelpCommand = mpMenu->GetHelpCommand( nItemId ); + return aHelpCommand; +} + + +namespace +{ + Image lcl_XGraphic2VCLImage( + const css::uno::Reference< css::graphic::XGraphic >& xGraphic, + bool bResize ) + { + Image aImage; + if ( !xGraphic.is() ) + return aImage; + + aImage = Image( xGraphic ); + const ::Size aCurSize = aImage.GetSizePixel(); + const sal_Int32 nCurWidth = aCurSize.Width(); + const sal_Int32 nCurHeight = aCurSize.Height(); + constexpr sal_Int32 nIdeal( 16 ); + + if ( nCurWidth > 0 && nCurHeight > 0 ) + { + if ( bResize && ( nCurWidth > nIdeal || nCurHeight > nIdeal ) ) + { + sal_Int32 nIdealWidth = std::min(nCurWidth, nIdeal); + sal_Int32 nIdealHeight = std::min(nCurHeight, nIdeal); + + ::Size aNewSize( nIdealWidth, nIdealHeight ); + + bool bModified( false ); + BitmapEx aBitmapEx = aImage.GetBitmapEx(); + bModified = aBitmapEx.Scale( aNewSize, BmpScaleFlag::BestQuality ); + + if ( bModified ) + aImage = Image( aBitmapEx ); + } + } + return aImage; + } + + /** Copied from include/svtools/acceleratorexecute.hxx */ + css::awt::KeyEvent lcl_VCLKey2AWTKey( + const vcl::KeyCode& aVCLKey) + { + css::awt::KeyEvent aAWTKey; + aAWTKey.Modifiers = 0; + aAWTKey.KeyCode = static_cast(aVCLKey.GetCode()); + + if (aVCLKey.IsShift()) + aAWTKey.Modifiers |= css::awt::KeyModifier::SHIFT; + if (aVCLKey.IsMod1()) + aAWTKey.Modifiers |= css::awt::KeyModifier::MOD1; + if (aVCLKey.IsMod2()) + aAWTKey.Modifiers |= css::awt::KeyModifier::MOD2; + if (aVCLKey.IsMod3()) + aAWTKey.Modifiers |= css::awt::KeyModifier::MOD3; + + return aAWTKey; + } + + vcl::KeyCode lcl_AWTKey2VCLKey(const css::awt::KeyEvent& aAWTKey) + { + bool bShift = ((aAWTKey.Modifiers & css::awt::KeyModifier::SHIFT) == css::awt::KeyModifier::SHIFT ); + bool bMod1 = ((aAWTKey.Modifiers & css::awt::KeyModifier::MOD1 ) == css::awt::KeyModifier::MOD1 ); + bool bMod2 = ((aAWTKey.Modifiers & css::awt::KeyModifier::MOD2 ) == css::awt::KeyModifier::MOD2 ); + bool bMod3 = ((aAWTKey.Modifiers & css::awt::KeyModifier::MOD3 ) == css::awt::KeyModifier::MOD3 ); + sal_uInt16 nKey = static_cast(aAWTKey.KeyCode); + + return vcl::KeyCode(nKey, bShift, bMod1, bMod2, bMod3); + } + +} + + +sal_Bool SAL_CALL VCLXMenu::isPopupMenu( ) +{ + SolarMutexGuard aSolarGuard; + std::unique_lock aGuard( maMutex ); + return IsPopupMenu(); +} + +void SAL_CALL VCLXMenu::clear( ) +{ + SolarMutexGuard aSolarGuard; + std::unique_lock aGuard( maMutex ); + if ( mpMenu ) + mpMenu->Clear(); +} + + +css::awt::MenuItemType SAL_CALL VCLXMenu::getItemType( + ::sal_Int16 nItemPos ) +{ + SolarMutexGuard aSolarGuard; + std::unique_lock aGuard( maMutex ); + + css::awt::MenuItemType aMenuItemType = + css::awt::MenuItemType_DONTKNOW; + if ( mpMenu ) + { + aMenuItemType = static_cast(mpMenu->GetItemType( nItemPos )); + } + + return aMenuItemType; +} + +void SAL_CALL VCLXMenu::hideDisabledEntries( + sal_Bool bHide ) +{ + SolarMutexGuard aSolarGuard; + std::unique_lock aGuard( maMutex ); + if ( mpMenu ) + { + if ( bHide ) + mpMenu->SetMenuFlags( mpMenu->GetMenuFlags() | MenuFlags::HideDisabledEntries ); + else + mpMenu->SetMenuFlags( mpMenu->GetMenuFlags() & ~MenuFlags::HideDisabledEntries ); + } +} + + +sal_Bool SAL_CALL VCLXMenu::isInExecute( ) +{ + SolarMutexGuard aSolarGuard; + std::unique_lock aGuard( maMutex ); + + if ( mpMenu && IsPopupMenu() ) + return vcl::IsInPopupMenuExecute(); + else + return false; +} + + +void SAL_CALL VCLXMenu::endExecute() +{ + SolarMutexGuard aSolarGuard; + std::unique_lock aGuard( maMutex ); + + if ( mpMenu && IsPopupMenu() ) + static_cast( mpMenu.get() )->EndExecute(); +} + + +void SAL_CALL VCLXMenu::enableAutoMnemonics( + sal_Bool bEnable ) +{ + SolarMutexGuard aSolarGuard; + std::unique_lock aGuard( maMutex ); + if ( mpMenu ) + { + if ( !bEnable ) + mpMenu->SetMenuFlags( mpMenu->GetMenuFlags() | MenuFlags::NoAutoMnemonics ); + else + mpMenu->SetMenuFlags( mpMenu->GetMenuFlags() & ~MenuFlags::NoAutoMnemonics ); + } +} + + +void SAL_CALL VCLXMenu::setAcceleratorKeyEvent( + ::sal_Int16 nItemId, + const css::awt::KeyEvent& aKeyEvent ) +{ + SolarMutexGuard aSolarGuard; + std::unique_lock aGuard( maMutex ); + + if ( mpMenu && IsPopupMenu() && MENU_ITEM_NOTFOUND != mpMenu->GetItemPos( nItemId ) ) + { + vcl::KeyCode aVCLKeyCode = lcl_AWTKey2VCLKey( aKeyEvent ); + mpMenu->SetAccelKey( nItemId, aVCLKeyCode ); + } +} + + +css::awt::KeyEvent SAL_CALL VCLXMenu::getAcceleratorKeyEvent( + ::sal_Int16 nItemId ) +{ + SolarMutexGuard aSolarGuard; + std::unique_lock aGuard( maMutex ); + + css::awt::KeyEvent aKeyEvent; + if ( mpMenu && IsPopupMenu() && MENU_ITEM_NOTFOUND != mpMenu->GetItemPos( nItemId ) ) + { + vcl::KeyCode nKeyCode = mpMenu->GetAccelKey( nItemId ); + aKeyEvent = lcl_VCLKey2AWTKey( nKeyCode ); + } + + return aKeyEvent; +} + + +void SAL_CALL VCLXMenu::setHelpText( + ::sal_Int16 nItemId, + const OUString& sHelpText ) +{ + SolarMutexGuard aSolarGuard; + std::unique_lock aGuard( maMutex ); + + if ( mpMenu && MENU_ITEM_NOTFOUND != mpMenu->GetItemPos( nItemId ) ) + { + mpMenu->SetHelpText( nItemId, sHelpText ); + } +} + + +OUString SAL_CALL VCLXMenu::getHelpText( + ::sal_Int16 nItemId ) +{ + SolarMutexGuard aSolarGuard; + std::unique_lock aGuard( maMutex ); + + OUString sHelpText; + if ( mpMenu && MENU_ITEM_NOTFOUND != mpMenu->GetItemPos( nItemId ) ) + { + sHelpText = mpMenu->GetHelpText( nItemId ); + } + + return sHelpText; +} + + +void SAL_CALL VCLXMenu::setTipHelpText( + ::sal_Int16 nItemId, + const OUString& sTipHelpText ) +{ + SolarMutexGuard aSolarGuard; + std::unique_lock aGuard( maMutex ); + + if ( mpMenu && MENU_ITEM_NOTFOUND != mpMenu->GetItemPos( nItemId ) ) + { + mpMenu->SetTipHelpText( nItemId, sTipHelpText ); + } +} + + +OUString SAL_CALL VCLXMenu::getTipHelpText( + ::sal_Int16 nItemId ) +{ + SolarMutexGuard aSolarGuard; + std::unique_lock aGuard( maMutex ); + + OUString sTipHelpText; + if ( mpMenu && MENU_ITEM_NOTFOUND != mpMenu->GetItemPos( nItemId ) ) + { + sTipHelpText = mpMenu->GetTipHelpText( nItemId ); + } + return sTipHelpText; +} + + +void SAL_CALL VCLXMenu::setItemImage( + ::sal_Int16 nItemId, + const css::uno::Reference< css::graphic::XGraphic >& xGraphic, + sal_Bool bScale ) +{ + SolarMutexGuard aSolarGuard; + std::unique_lock aGuard( maMutex ); + + if ( mpMenu && IsPopupMenu() && MENU_ITEM_NOTFOUND != mpMenu->GetItemPos( nItemId ) ) + { + Image aImage = lcl_XGraphic2VCLImage( xGraphic, bScale ); + mpMenu->SetItemImage( nItemId, aImage ); + } +} + + +css::uno::Reference< css::graphic::XGraphic > SAL_CALL +VCLXMenu::getItemImage( + ::sal_Int16 nItemId ) +{ + SolarMutexGuard aSolarGuard; + std::unique_lock aGuard( maMutex ); + + css::uno::Reference< css::graphic::XGraphic > rxGraphic; + + if ( mpMenu && IsPopupMenu() && MENU_ITEM_NOTFOUND != mpMenu->GetItemPos( nItemId ) ) + { + Image aImage = mpMenu->GetItemImage( nItemId ); + if ( !!aImage ) + rxGraphic = Graphic(aImage.GetBitmapEx()).GetXGraphic(); + } + return rxGraphic; +} + +void VCLXMenu::setUserValue(sal_uInt16 nItemId, void* nUserValue, MenuUserDataReleaseFunction aFunc) +{ + SolarMutexGuard aSolarGuard; + std::unique_lock aGuard(maMutex); + + mpMenu->SetUserValue(nItemId, nUserValue, aFunc); +} + +void* VCLXMenu::getUserValue(sal_uInt16 nItemId) +{ + SolarMutexGuard aSolarGuard; + std::unique_lock aGuard(maMutex); + + return mpMenu->GetUserValue(nItemId); +} + +VCLXMenuBar::VCLXMenuBar() +{ + ImplCreateMenu( false ); +} + +VCLXMenuBar::VCLXMenuBar( MenuBar* pMenuBar ) : VCLXMenu( static_cast(pMenuBar) ) +{ +} + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * +stardiv_Toolkit_VCLXMenuBar_get_implementation( + css::uno::XComponentContext *, + css::uno::Sequence const &) +{ + return cppu::acquire(new VCLXMenuBar()); +} + +VCLXPopupMenu::VCLXPopupMenu() +{ + ImplCreateMenu( true ); +} + +VCLXPopupMenu::VCLXPopupMenu( PopupMenu* pPopMenu ) : VCLXMenu( static_cast(pPopMenu) ) +{ + ImplAddListener(); +} + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * +stardiv_Toolkit_VCLXPopupMenu_get_implementation( + css::uno::XComponentContext *, + css::uno::Sequence const &) +{ + return cppu::acquire(new VCLXPopupMenu()); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/source/awt/vclxpointer.cxx b/toolkit/source/awt/vclxpointer.cxx new file mode 100644 index 000000000..89828e48a --- /dev/null +++ b/toolkit/source/awt/vclxpointer.cxx @@ -0,0 +1,73 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include +#include +#include + +VCLXPointer::VCLXPointer() : maPointer(PointerStyle::Arrow) +{ +} + +VCLXPointer::~VCLXPointer() +{ +} + +// css::lang::XUnoTunnel +UNO3_GETIMPLEMENTATION_IMPL( VCLXPointer ); + +void VCLXPointer::setType( sal_Int32 nType ) +{ + std::scoped_lock aGuard( maMutex ); + + maPointer = static_cast(nType); +} + +sal_Int32 VCLXPointer::getType() +{ + std::scoped_lock aGuard( maMutex ); + + return static_cast(maPointer); +} + +OUString VCLXPointer::getImplementationName() +{ + return "stardiv.Toolkit.VCLXPointer"; +} + +sal_Bool VCLXPointer::supportsService(OUString const & ServiceName) +{ + return cppu::supportsService(this, ServiceName); +} + +css::uno::Sequence VCLXPointer::getSupportedServiceNames() +{ + return css::uno::Sequence{ + "com.sun.star.awt.Pointer", "stardiv.vcl.Pointer"}; +} + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * +stardiv_Toolkit_VCLXPointer_get_implementation( + css::uno::XComponentContext *, + css::uno::Sequence const &) +{ + return cppu::acquire(new VCLXPointer()); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/source/awt/vclxprinter.cxx b/toolkit/source/awt/vclxprinter.cxx new file mode 100644 index 000000000..c0db73db4 --- /dev/null +++ b/toolkit/source/awt/vclxprinter.cxx @@ -0,0 +1,379 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include + + +#define BINARYSETUPMARKER 0x23864691 + +#define PROPERTY_Orientation 0 +#define PROPERTY_Horizontal 1 + +// ---------------------------------------------------- +// class VCLXPrinterPropertySet +// ---------------------------------------------------- + +IMPLEMENT_FORWARD_XINTERFACE2( VCLXPrinterPropertySet, VCLXPrinterPropertySet_Base, OPropertySetHelper ) +IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXPrinterPropertySet, VCLXPrinterPropertySet_Base, ::cppu::OPropertySetHelper ) + +VCLXPrinterPropertySet::VCLXPrinterPropertySet( const OUString& rPrinterName ) + : OPropertySetHelper( BrdcstHelper ) + , mxPrinter(VclPtrInstance< Printer >(rPrinterName)) +{ + SolarMutexGuard aSolarGuard; + + mnOrientation = 0; + mbHorizontal = false; +} + +VCLXPrinterPropertySet::~VCLXPrinterPropertySet() +{ + SolarMutexGuard aSolarGuard; + mxPrinter.reset(); +} + +css::uno::Reference< css::awt::XDevice > const & VCLXPrinterPropertySet::GetDevice() +{ + if ( !mxPrnDevice.is() ) + { + rtl::Reference pDev = new VCLXDevice; + pDev->SetOutputDevice( GetPrinter() ); + mxPrnDevice = pDev; + } + return mxPrnDevice; +} + +css::uno::Reference< css::beans::XPropertySetInfo > VCLXPrinterPropertySet::getPropertySetInfo( ) +{ + static css::uno::Reference< css::beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); + return xInfo; +} + +::cppu::IPropertyArrayHelper& VCLXPrinterPropertySet::getInfoHelper() +{ + static ::cppu::OPropertyArrayHelper s_PropertyArrayHelper( + css::uno::Sequence{ + css::beans::Property( "Orientation", PROPERTY_Orientation, cppu::UnoType::get(), 0 ), + css::beans::Property( "Horizontal", PROPERTY_Horizontal, cppu::UnoType::get(), 0 )}, + false); + + return s_PropertyArrayHelper; +} + +sal_Bool VCLXPrinterPropertySet::convertFastPropertyValue( css::uno::Any & rConvertedValue, css::uno::Any & rOldValue, sal_Int32 nHandle, const css::uno::Any& rValue ) +{ + ::osl::MutexGuard aGuard( Mutex ); + + bool bDifferent = false; + switch ( nHandle ) + { + case PROPERTY_Orientation: + { + sal_Int16 n; + if( ( rValue >>= n ) && ( n != mnOrientation ) ) + { + rConvertedValue <<= n; + rOldValue <<= mnOrientation; + bDifferent = true; + } + } + break; + case PROPERTY_Horizontal: + { + bool b; + if( ( rValue >>= b ) && ( b != mbHorizontal ) ) + { + rConvertedValue <<= b; + rOldValue <<= mbHorizontal; + bDifferent = true; + } + } + break; + default: + { + OSL_FAIL( "VCLXPrinterPropertySet_Impl::convertFastPropertyValue - invalid Handle" ); + } + } + return bDifferent; +} + +void VCLXPrinterPropertySet::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const css::uno::Any& rValue ) +{ + ::osl::MutexGuard aGuard( Mutex ); + + switch( nHandle ) + { + case PROPERTY_Orientation: + { + rValue >>= mnOrientation; + } + break; + case PROPERTY_Horizontal: + { + rValue >>= mbHorizontal; + } + break; + default: + { + OSL_FAIL( "VCLXPrinterPropertySet_Impl::convertFastPropertyValue - invalid Handle" ); + } + } +} + +void VCLXPrinterPropertySet::getFastPropertyValue( css::uno::Any& rValue, sal_Int32 nHandle ) const +{ + ::osl::MutexGuard aGuard( const_cast(this)->Mutex ); + + switch( nHandle ) + { + case PROPERTY_Orientation: + rValue <<= mnOrientation; + break; + case PROPERTY_Horizontal: + rValue <<= mbHorizontal; + break; + default: + { + OSL_FAIL( "VCLXPrinterPropertySet_Impl::convertFastPropertyValue - invalid Handle" ); + } + } +} + +// css::awt::XPrinterPropertySet +void VCLXPrinterPropertySet::setHorizontal( sal_Bool bHorizontal ) +{ + ::osl::MutexGuard aGuard( Mutex ); + + css::uno::Any aValue; + aValue <<= bHorizontal; + setFastPropertyValue( PROPERTY_Horizontal, aValue ); +} + +css::uno::Sequence< OUString > VCLXPrinterPropertySet::getFormDescriptions( ) +{ + ::osl::MutexGuard aGuard( Mutex ); + + const sal_uInt16 nPaperBinCount = GetPrinter()->GetPaperBinCount(); + css::uno::Sequence< OUString > aDescriptions( nPaperBinCount ); + for ( sal_uInt16 n = 0; n < nPaperBinCount; n++ ) + { + // Format: + OUString aDescr = "*;*;" + GetPrinter()->GetPaperBinName( n ) + ";" + + OUString::number(n) + ";*;*"; + + aDescriptions.getArray()[n] = aDescr; + } + return aDescriptions; +} + +void VCLXPrinterPropertySet::selectForm( const OUString& rFormDescription ) +{ + ::osl::MutexGuard aGuard( Mutex ); + + sal_uInt16 nPaperBin = sal::static_int_cast< sal_uInt16 >( + o3tl::toInt32(o3tl::getToken(rFormDescription, 3, ';' ))); + GetPrinter()->SetPaperBin( nPaperBin ); +} + +css::uno::Sequence< sal_Int8 > VCLXPrinterPropertySet::getBinarySetup( ) +{ + ::osl::MutexGuard aGuard( Mutex ); + + SvMemoryStream aMem; + aMem.WriteUInt32( BINARYSETUPMARKER ); + WriteJobSetup( aMem, GetPrinter()->GetJobSetup() ); + return css::uno::Sequence( static_cast(aMem.GetData()), aMem.Tell() ); +} + +void VCLXPrinterPropertySet::setBinarySetup( const css::uno::Sequence< sal_Int8 >& data ) +{ + ::osl::MutexGuard aGuard( Mutex ); + + SvMemoryStream aMem( const_cast(data.getConstArray()), data.getLength(), StreamMode::READ ); + sal_uInt32 nMarker; + aMem.ReadUInt32( nMarker ); + DBG_ASSERT( nMarker == BINARYSETUPMARKER, "setBinarySetup - invalid!" ); + if ( nMarker == BINARYSETUPMARKER ) + { + JobSetup aSetup; + ReadJobSetup( aMem, aSetup ); + GetPrinter()->SetJobSetup( aSetup ); + } +} + + +// ---------------------------------------------------- +// class VCLXPrinter +// ---------------------------------------------------- +VCLXPrinter::VCLXPrinter( const OUString& rPrinterName ) + : VCLXPrinter_Base( rPrinterName ) +{ +} + +VCLXPrinter::~VCLXPrinter() +{ +} + +sal_Bool VCLXPrinter::start( const OUString& /*rJobName*/, sal_Int16 /*nCopies*/, sal_Bool /*bCollate*/ ) +{ + ::osl::MutexGuard aGuard( Mutex ); + + if (mxPrinter) + { + maInitJobSetup = mxPrinter->GetJobSetup(); + mxListener = std::make_shared(mxPrinter, nullptr); + } + + return true; +} + +void VCLXPrinter::end( ) +{ + ::osl::MutexGuard aGuard( Mutex ); + + if (mxListener) + { + Printer::PrintJob(mxListener, maInitJobSetup); + mxListener.reset(); + } +} + +void VCLXPrinter::terminate( ) +{ + ::osl::MutexGuard aGuard( Mutex ); + + mxListener.reset(); +} + +css::uno::Reference< css::awt::XDevice > VCLXPrinter::startPage( ) +{ + ::osl::MutexGuard aGuard( Mutex ); + + if (mxListener) + { + mxListener->StartPage(); + } + return GetDevice(); +} + +void VCLXPrinter::endPage( ) +{ + ::osl::MutexGuard aGuard( Mutex ); + + if (mxListener) + { + mxListener->EndPage(); + } +} + + +// ---------------------------------------------------- +// class VCLXInfoPrinter +// ---------------------------------------------------- + +VCLXInfoPrinter::VCLXInfoPrinter( const OUString& rPrinterName ) + : VCLXInfoPrinter_Base( rPrinterName ) +{ +} + +VCLXInfoPrinter::~VCLXInfoPrinter() +{ +} + +// css::awt::XInfoPrinter +css::uno::Reference< css::awt::XDevice > VCLXInfoPrinter::createDevice( ) +{ + ::osl::MutexGuard aGuard( Mutex ); + + return GetDevice(); +} + +// ---------------------------------------------------- +// class VCLXPrinterServer +// ---------------------------------------------------- + +// css::awt::XPrinterServer2 +css::uno::Sequence< OUString > VCLXPrinterServer::getPrinterNames( ) +{ + const std::vector& rQueues = Printer::GetPrinterQueues(); + sal_uInt32 nPrinters = rQueues.size(); + + css::uno::Sequence< OUString > aNames( nPrinters ); + for ( sal_uInt32 n = 0; n < nPrinters; n++ ) + aNames.getArray()[n] = rQueues[n]; + + return aNames; +} + +OUString VCLXPrinterServer::getDefaultPrinterName() +{ + return Printer::GetDefaultPrinterName(); +} + +css::uno::Reference< css::awt::XPrinter > VCLXPrinterServer::createPrinter( const OUString& rPrinterName ) +{ + css::uno::Reference< css::awt::XPrinter > xP = new VCLXPrinter( rPrinterName ); + return xP; +} + +css::uno::Reference< css::awt::XInfoPrinter > VCLXPrinterServer::createInfoPrinter( const OUString& rPrinterName ) +{ + css::uno::Reference< css::awt::XInfoPrinter > xP = new VCLXInfoPrinter( rPrinterName ); + return xP; +} + +OUString VCLXPrinterServer::getImplementationName() +{ + return "stardiv.Toolkit.VCLXPrinterServer"; +} + +sal_Bool VCLXPrinterServer::supportsService(OUString const & ServiceName) +{ + return cppu::supportsService(this, ServiceName); +} + +css::uno::Sequence VCLXPrinterServer::getSupportedServiceNames() +{ + return css::uno::Sequence{ + "com.sun.star.awt.PrinterServer", "stardiv.vcl.PrinterServer"}; +} + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * +stardiv_Toolkit_VCLXPrinterServer_get_implementation( + css::uno::XComponentContext *, + css::uno::Sequence const &) +{ + return cppu::acquire(new VCLXPrinterServer); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/source/awt/vclxregion.cxx b/toolkit/source/awt/vclxregion.cxx new file mode 100644 index 000000000..d9abedecf --- /dev/null +++ b/toolkit/source/awt/vclxregion.cxx @@ -0,0 +1,145 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include +#include +#include + + + +VCLXRegion::VCLXRegion() +{ +} + +VCLXRegion::~VCLXRegion() +{ +} + +// css::lang::XUnoTunnel +UNO3_GETIMPLEMENTATION_IMPL( VCLXRegion ); + +css::awt::Rectangle VCLXRegion::getBounds() +{ + std::scoped_lock aGuard( maMutex ); + + return AWTRectangle( maRegion.GetBoundRect() ); +} + +void VCLXRegion::clear() +{ + std::scoped_lock aGuard( maMutex ); + + maRegion.SetEmpty(); +} + +void VCLXRegion::move( sal_Int32 nHorzMove, sal_Int32 nVertMove ) +{ + std::scoped_lock aGuard( maMutex ); + + maRegion.Move( nHorzMove, nVertMove ); +} + +void VCLXRegion::unionRectangle( const css::awt::Rectangle& rRect ) +{ + std::scoped_lock aGuard( maMutex ); + + maRegion.Union( VCLRectangle( rRect ) ); +} + +void VCLXRegion::intersectRectangle( const css::awt::Rectangle& rRect ) +{ + std::scoped_lock aGuard( maMutex ); + + maRegion.Intersect( VCLRectangle( rRect ) ); +} + +void VCLXRegion::excludeRectangle( const css::awt::Rectangle& rRect ) +{ + std::scoped_lock aGuard( maMutex ); + + maRegion.Exclude( VCLRectangle( rRect ) ); +} + +void VCLXRegion::xOrRectangle( const css::awt::Rectangle& rRect ) +{ + std::scoped_lock aGuard( maMutex ); + + maRegion.XOr( VCLRectangle( rRect ) ); +} + +void VCLXRegion::unionRegion( const css::uno::Reference< css::awt::XRegion >& rxRegion ) +{ + std::scoped_lock aGuard( maMutex ); + + if ( rxRegion.is() ) + maRegion.Union( VCLUnoHelper::GetRegion( rxRegion ) ); +} + +void VCLXRegion::intersectRegion( const css::uno::Reference< css::awt::XRegion >& rxRegion ) +{ + std::scoped_lock aGuard( maMutex ); + + if ( rxRegion.is() ) + maRegion.Intersect( VCLUnoHelper::GetRegion( rxRegion ) ); +} + +void VCLXRegion::excludeRegion( const css::uno::Reference< css::awt::XRegion >& rxRegion ) +{ + std::scoped_lock aGuard( maMutex ); + + if ( rxRegion.is() ) + maRegion.Exclude( VCLUnoHelper::GetRegion( rxRegion ) ); +} + +void VCLXRegion::xOrRegion( const css::uno::Reference< css::awt::XRegion >& rxRegion ) +{ + std::scoped_lock aGuard( maMutex ); + + if ( rxRegion.is() ) + maRegion.XOr( VCLUnoHelper::GetRegion( rxRegion ) ); +} + +css::uno::Sequence< css::awt::Rectangle > VCLXRegion::getRectangles() +{ + std::scoped_lock aGuard( maMutex ); + + RectangleVector aRectangles; + maRegion.GetRegionRectangles(aRectangles); + +// sal_uLong nRects = maRegion.GetRectCount(); + css::uno::Sequence< css::awt::Rectangle > aRects(aRectangles.size()); + sal_uInt32 a(0); + + for(const auto& rRect : aRectangles) + { + aRects.getArray()[a++] = AWTRectangle(rRect); + } + + //Rectangle aRect; + //sal_uInt32 nR = 0; + //RegionHandle h = maRegion.BeginEnumRects(); + //while ( maRegion.GetEnumRects( h, aRect ) ) + // aRects.getArray()[nR++] = AWTRectangle( aRect ); + //maRegion.EndEnumRects( h ); + + return aRects; +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/source/awt/vclxspinbutton.cxx b/toolkit/source/awt/vclxspinbutton.cxx new file mode 100644 index 000000000..db5d1f1b0 --- /dev/null +++ b/toolkit/source/awt/vclxspinbutton.cxx @@ -0,0 +1,331 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include +#include +#include + +#include +#include +#include "vclxwindows_internal.hxx" + +namespace toolkit +{ + + + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::awt; + using namespace ::com::sun::star::lang; + using namespace ::com::sun::star::beans; + + + namespace + { + void lcl_modifyStyle( vcl::Window* _pWindow, WinBits _nStyleBits, bool _bShouldBePresent ) + { + WinBits nStyle = _pWindow->GetStyle(); + if ( _bShouldBePresent ) + nStyle |= _nStyleBits; + else + nStyle &= ~_nStyleBits; + _pWindow->SetStyle( nStyle ); + } + } + + VCLXSpinButton::VCLXSpinButton() + :maAdjustmentListeners( *this ) + { + } + + + VCLXSpinButton::~VCLXSpinButton() + { + } + + + IMPLEMENT_FORWARD_XINTERFACE2( VCLXSpinButton, VCLXWindow, VCLXSpinButton_Base ) + + + IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXSpinButton, VCLXWindow, VCLXSpinButton_Base ) + + + void SAL_CALL VCLXSpinButton::dispose( ) + { + { + SolarMutexGuard aGuard; + + EventObject aDisposeEvent; + aDisposeEvent.Source = *this; + maAdjustmentListeners.disposeAndClear( aDisposeEvent ); + } + + VCLXWindow::dispose(); + } + + + void SAL_CALL VCLXSpinButton::addAdjustmentListener( const Reference< XAdjustmentListener >& listener ) + { + if ( listener.is() ) + maAdjustmentListeners.addInterface( listener ); + } + + + void SAL_CALL VCLXSpinButton::removeAdjustmentListener( const Reference< XAdjustmentListener >& listener ) + { + if ( listener.is() ) + maAdjustmentListeners.removeInterface( listener ); + } + + namespace + { + typedef void (SpinButton::*SetSpinButtonValue) (tools::Long); + typedef tools::Long (SpinButton::*GetSpinButtonValue) () const; + + + void lcl_setSpinButtonValue(vcl::Window* _pWindow, SetSpinButtonValue _pSetter, sal_Int32 _nValue ) + { + SolarMutexGuard aGuard; + SpinButton* pSpinButton = static_cast< SpinButton* >( _pWindow ); + if ( pSpinButton ) + (pSpinButton->*_pSetter)( _nValue ); + } + + + sal_Int32 lcl_getSpinButtonValue(const vcl::Window* _pWindow, GetSpinButtonValue _pGetter ) + { + SolarMutexGuard aGuard; + + sal_Int32 nValue = 0; + + const SpinButton* pSpinButton = static_cast< const SpinButton* >( _pWindow ); + if ( pSpinButton ) + nValue = (pSpinButton->*_pGetter)( ); + return nValue; + } + } + + + void SAL_CALL VCLXSpinButton::setValue( sal_Int32 n ) + { + lcl_setSpinButtonValue( GetWindow(), &SpinButton::SetValue, n ); + } + + + void SAL_CALL VCLXSpinButton::setValues( sal_Int32 minValue, sal_Int32 maxValue, sal_Int32 currentValue ) + { + SolarMutexGuard aGuard; + + setMinimum( minValue ); + setMaximum( maxValue ); + setValue( currentValue ); + } + + + sal_Int32 SAL_CALL VCLXSpinButton::getValue( ) + { + return lcl_getSpinButtonValue( GetWindow(), &SpinButton::GetValue ); + } + + + void SAL_CALL VCLXSpinButton::setMinimum( sal_Int32 minValue ) + { + lcl_setSpinButtonValue( GetWindow(), &SpinButton::SetRangeMin, minValue ); + } + + + void SAL_CALL VCLXSpinButton::setMaximum( sal_Int32 maxValue ) + { + lcl_setSpinButtonValue( GetWindow(), &SpinButton::SetRangeMax, maxValue ); + } + + + sal_Int32 SAL_CALL VCLXSpinButton::getMinimum( ) + { + return lcl_getSpinButtonValue( GetWindow(), &SpinButton::GetRangeMin ); + } + + + sal_Int32 SAL_CALL VCLXSpinButton::getMaximum( ) + { + return lcl_getSpinButtonValue( GetWindow(), &SpinButton::GetRangeMax ); + } + + + void SAL_CALL VCLXSpinButton::setSpinIncrement( sal_Int32 spinIncrement ) + { + lcl_setSpinButtonValue( GetWindow(), &SpinButton::SetValueStep, spinIncrement ); + } + + + sal_Int32 SAL_CALL VCLXSpinButton::getSpinIncrement( ) + { + return lcl_getSpinButtonValue( GetWindow(), &SpinButton::GetValueStep ); + } + + + void SAL_CALL VCLXSpinButton::setOrientation( sal_Int32 orientation ) + { + SolarMutexGuard aGuard; + + lcl_modifyStyle( GetWindow(), WB_HSCROLL, orientation == ScrollBarOrientation::HORIZONTAL ); + } + + + sal_Int32 SAL_CALL VCLXSpinButton::getOrientation( ) + { + return ( 0 != ( GetWindow()->GetStyle() & WB_HSCROLL ) ) + ? ScrollBarOrientation::HORIZONTAL + : ScrollBarOrientation::VERTICAL; + } + + + void VCLXSpinButton::ProcessWindowEvent( const VclWindowEvent& _rVclWindowEvent ) + { + SolarMutexClearableGuard aGuard; + Reference< XSpinValue > xKeepAlive( this ); + VclPtr pSpinButton = GetAs(); + if ( !pSpinButton ) + return; + + switch ( _rVclWindowEvent.GetId() ) + { + case VclEventId::SpinbuttonUp: + case VclEventId::SpinbuttonDown: + if ( maAdjustmentListeners.getLength() ) + { + AdjustmentEvent aEvent; + aEvent.Source = *this; + aEvent.Value = pSpinButton->GetValue(); + + aGuard.clear(); + maAdjustmentListeners.adjustmentValueChanged( aEvent ); + } + break; + + default: + xKeepAlive.clear(); + aGuard.clear(); + VCLXWindow::ProcessWindowEvent( _rVclWindowEvent ); + break; + } + } + + + void SAL_CALL VCLXSpinButton::setProperty( const OUString& PropertyName, const Any& Value ) + { + SolarMutexGuard aGuard; + + sal_Int32 nValue = 0; + bool bIsLongValue = ( Value >>= nValue ); + + if ( !GetWindow() ) + return; + + sal_uInt16 nPropertyId = GetPropertyId( PropertyName ); + switch ( nPropertyId ) + { + case BASEPROPERTY_BACKGROUNDCOLOR: + // the default implementation of the base class doesn't work here, since our + // interpretation for this property is slightly different + setButtonLikeFaceColor( GetWindow(), Value); + break; + + case BASEPROPERTY_SPINVALUE: + if ( bIsLongValue ) + setValue( nValue ); + break; + + case BASEPROPERTY_SPINVALUE_MIN: + if ( bIsLongValue ) + setMinimum( nValue ); + break; + + case BASEPROPERTY_SPINVALUE_MAX: + if ( bIsLongValue ) + setMaximum( nValue ); + break; + + case BASEPROPERTY_SPININCREMENT: + if ( bIsLongValue ) + setSpinIncrement( nValue ); + break; + + case BASEPROPERTY_ORIENTATION: + if ( bIsLongValue ) + lcl_modifyStyle( GetWindow(), WB_HSCROLL, nValue == ScrollBarOrientation::HORIZONTAL ); + break; + + default: + VCLXWindow::setProperty( PropertyName, Value ); + } + } + + + Any SAL_CALL VCLXSpinButton::getProperty( const OUString& PropertyName ) + { + SolarMutexGuard aGuard; + + Any aReturn; + + if ( GetWindow() ) + { + sal_uInt16 nPropertyId = GetPropertyId( PropertyName ); + switch ( nPropertyId ) + { + case BASEPROPERTY_BACKGROUNDCOLOR: + // the default implementation of the base class doesn't work here, since our + // interpretation for this property is slightly different + aReturn = getButtonLikeFaceColor( GetWindow() ); + break; + + case BASEPROPERTY_SPINVALUE: + aReturn <<= getValue( ); + break; + + case BASEPROPERTY_SPINVALUE_MIN: + aReturn <<= getMinimum( ); + break; + + case BASEPROPERTY_SPINVALUE_MAX: + aReturn <<= getMaximum( ); + break; + + case BASEPROPERTY_SPININCREMENT: + aReturn <<= getSpinIncrement( ); + break; + + case BASEPROPERTY_ORIENTATION: + aReturn <<= static_cast( ( 0 != ( GetWindow()->GetStyle() & WB_HSCROLL ) ) + ? ScrollBarOrientation::HORIZONTAL + : ScrollBarOrientation::VERTICAL + ); + break; + + default: + aReturn = VCLXWindow::getProperty( PropertyName ); + } + } + return aReturn; + } + + +} // namespace toolkit + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/source/awt/vclxsystemdependentwindow.cxx b/toolkit/source/awt/vclxsystemdependentwindow.cxx new file mode 100644 index 000000000..37d7f86d9 --- /dev/null +++ b/toolkit/source/awt/vclxsystemdependentwindow.cxx @@ -0,0 +1,114 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include + +#if defined UNX && ! defined MACOSX +#include +#endif + +#include +#include +#include +#include + +#ifdef MACOSX +#include +#include +#include +#endif + +#include +#include +#include + + + +VCLXSystemDependentWindow::VCLXSystemDependentWindow() +{ +} + +VCLXSystemDependentWindow::~VCLXSystemDependentWindow() +{ +} + +// css::uno::XInterface +css::uno::Any VCLXSystemDependentWindow::queryInterface( const css::uno::Type & rType ) +{ + css::uno::Any aRet = ::cppu::queryInterface( rType, + static_cast< css::awt::XSystemDependentWindowPeer* >(this) ); + return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType )); +} + +IMPL_IMPLEMENTATION_ID( VCLXSystemDependentWindow ) + +// css::lang::XTypeProvider +css::uno::Sequence< css::uno::Type > VCLXSystemDependentWindow::getTypes() +{ + static const ::cppu::OTypeCollection aTypeList( + cppu::UnoType::get(), + cppu::UnoType::get(), + VCLXWindow::getTypes() + ); + return aTypeList.getTypes(); +} + +css::uno::Any VCLXSystemDependentWindow::getWindowHandle( const css::uno::Sequence< sal_Int8 >& /*ProcessId*/, sal_Int16 SystemType ) +{ + SolarMutexGuard aGuard; + + // TODO, check the process id + css::uno::Any aRet; + VclPtr pWindow = GetWindow(); + if ( pWindow ) + { + const SystemEnvData* pSysData = static_cast(pWindow.get())->GetSystemData(); + if( pSysData ) + { +#if defined(_WIN32) + if( SystemType == css::lang::SystemDependent::SYSTEM_WIN32 ) + { + aRet <<= reinterpret_cast(pSysData->hWnd); + } +#elif defined(MACOSX) + if( SystemType == css::lang::SystemDependent::SYSTEM_MAC ) + { + aRet <<= reinterpret_cast(pSysData->mpNSView); + } +#elif defined(ANDROID) + // Nothing + (void) SystemType; +#elif defined(IOS) + // Nothing + (void) SystemType; +#elif defined(UNX) + if( SystemType == css::lang::SystemDependent::SYSTEM_XWINDOW ) + { + css::awt::SystemDependentXWindow aSD; + aSD.DisplayPointer = sal::static_int_cast< sal_Int64 >(reinterpret_cast< sal_IntPtr >(pSysData->pDisplay)); + aSD.WindowHandle = pSysData->GetWindowHandle(pWindow->ImplGetFrame()); + aRet <<= aSD; + } +#endif + } + } + return aRet; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/source/awt/vclxtabpagecontainer.cxx b/toolkit/source/awt/vclxtabpagecontainer.cxx new file mode 100644 index 000000000..80124c9de --- /dev/null +++ b/toolkit/source/awt/vclxtabpagecontainer.cxx @@ -0,0 +1,231 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::view; + + +void VCLXTabPageContainer::GetPropertyIds( std::vector< sal_uInt16 > &rIds ) +{ + VCLXWindow::ImplGetPropertyIds( rIds ); +} + +VCLXTabPageContainer::VCLXTabPageContainer() : + m_aTabPageListeners( *this ) +{ +} + +VCLXTabPageContainer::~VCLXTabPageContainer() +{ + SAL_INFO("toolkit", __FUNCTION__); +} + +void SAL_CALL VCLXTabPageContainer::draw( sal_Int32 nX, sal_Int32 nY ) +{ + SolarMutexGuard aGuard; + VclPtr pTabControl = GetAs(); + if ( pTabControl ) + { + TabPage *pTabPage = pTabControl->GetTabPage( sal::static_int_cast< sal_uInt16 >( pTabControl->GetCurPageId( ) ) ); + OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() ); + if (pTabPage && pDev) + { + ::Point aPos( nX, nY ); + aPos = pDev->PixelToLogic( aPos ); + pTabPage->Draw( pDev, aPos, SystemTextColorFlags::NONE ); + } + } + + VCLXWindow::draw( nX, nY ); +} + +void SAL_CALL VCLXTabPageContainer::setProperty(const OUString& PropertyName, const Any& Value ) +{ + SolarMutexGuard aGuard; + VclPtr pTabPage = GetAs(); + if ( pTabPage ) + VCLXWindow::setProperty( PropertyName, Value ); +} + +::sal_Int16 SAL_CALL VCLXTabPageContainer::getActiveTabPageID() +{ + VclPtr pTabCtrl = GetAs(); + return pTabCtrl ? pTabCtrl->GetCurPageId( ) : 0; +} + +void SAL_CALL VCLXTabPageContainer::setActiveTabPageID( ::sal_Int16 _activetabpageid ) +{ + VclPtr pTabCtrl = GetAs(); + if ( pTabCtrl ) + pTabCtrl->SelectTabPage(_activetabpageid); +} + +::sal_Int16 SAL_CALL VCLXTabPageContainer::getTabPageCount( ) +{ + VclPtr pTabCtrl = GetAs(); + return pTabCtrl ? pTabCtrl->GetPageCount() : 0; +} + +sal_Bool SAL_CALL VCLXTabPageContainer::isTabPageActive( ::sal_Int16 tabPageIndex ) +{ + return (getActiveTabPageID() == tabPageIndex); +} + +Reference< css::awt::tab::XTabPage > SAL_CALL VCLXTabPageContainer::getTabPage( ::sal_Int16 tabPageIndex ) +{ + return (tabPageIndex >= 0 && o3tl::make_unsigned(tabPageIndex) < m_aTabPages.size()) ? m_aTabPages[tabPageIndex] : nullptr; +} + +Reference< css::awt::tab::XTabPage > SAL_CALL VCLXTabPageContainer::getTabPageByID( ::sal_Int16 tabPageID ) +{ + SolarMutexGuard aGuard; + Reference< css::awt::tab::XTabPage > xTabPage; + for(const auto& rTabPage : m_aTabPages) + { + Reference< awt::XControl > xControl(rTabPage,UNO_QUERY ); + Reference< awt::tab::XTabPageModel > xP( xControl->getModel(), UNO_QUERY ); + if ( tabPageID == xP->getTabPageID() ) + { + xTabPage = rTabPage; + break; + } + } + return xTabPage; +} + +void SAL_CALL VCLXTabPageContainer::addTabPageContainerListener( const Reference< css::awt::tab::XTabPageContainerListener >& listener ) +{ + m_aTabPageListeners.addInterface( listener ); +} + +void SAL_CALL VCLXTabPageContainer::removeTabPageContainerListener( const Reference< css::awt::tab::XTabPageContainerListener >& listener ) +{ + m_aTabPageListeners.removeInterface( listener ); +} + +void VCLXTabPageContainer::ProcessWindowEvent( const VclWindowEvent& _rVclWindowEvent ) +{ + SolarMutexClearableGuard aGuard; + VclPtr pTabControl = GetAs(); + if ( !pTabControl ) + return; + + switch ( _rVclWindowEvent.GetId() ) + { + case VclEventId::TabpageActivate: + { + sal_uLong page = reinterpret_cast(_rVclWindowEvent.GetData()); + awt::tab::TabPageActivatedEvent aEvent(nullptr,page); + m_aTabPageListeners.tabPageActivated(aEvent); + break; + } + default: + aGuard.clear(); + VCLXWindow::ProcessWindowEvent( _rVclWindowEvent ); + break; + } +} +void SAL_CALL VCLXTabPageContainer::disposing( const css::lang::EventObject& /*Source*/ ) +{ +} +void SAL_CALL VCLXTabPageContainer::elementInserted( const css::container::ContainerEvent& Event ) +{ + SolarMutexGuard aGuard; + VclPtr pTabCtrl = GetAs(); + Reference< css::awt::tab::XTabPage > xTabPage(Event.Element,uno::UNO_QUERY); + if ( !pTabCtrl || !xTabPage.is() ) + return; + + Reference< awt::XControl > xControl(xTabPage,UNO_QUERY ); + Reference< awt::tab::XTabPageModel > xP( xControl->getModel(), UNO_QUERY ); + sal_Int16 nPageID = xP->getTabPageID(); + + if (!xControl->getPeer().is()) + throw RuntimeException("No peer for tabpage container!"); + VclPtr pWindow = VCLUnoHelper::GetWindow(xControl->getPeer()); + TabPage* pPage = static_cast(pWindow.get()); + pTabCtrl->InsertPage(nPageID,pPage->GetText()); + + pPage->Hide(); + pTabCtrl->SetTabPage(nPageID,pPage); + pTabCtrl->SetHelpText(nPageID,xP->getToolTip()); + pTabCtrl->SetPageImage(nPageID,TkResMgr::getImageFromURL(xP->getImageURL())); + pTabCtrl->SelectTabPage(nPageID); + pTabCtrl->SetPageEnabled(nPageID,xP->getEnabled()); + m_aTabPages.push_back(xTabPage); + +} +void SAL_CALL VCLXTabPageContainer::elementRemoved( const css::container::ContainerEvent& Event ) +{ + SolarMutexGuard aGuard; + VclPtr pTabCtrl = GetAs(); + Reference< css::awt::tab::XTabPage > xTabPage(Event.Element,uno::UNO_QUERY); + if ( pTabCtrl && xTabPage.is() ) + { + Reference< awt::XControl > xControl(xTabPage,UNO_QUERY ); + Reference< awt::tab::XTabPageModel > xP( xControl->getModel(), UNO_QUERY ); + pTabCtrl->RemovePage(xP->getTabPageID()); + m_aTabPages.erase(::std::remove(m_aTabPages.begin(),m_aTabPages.end(),xTabPage)); + } +} +void SAL_CALL VCLXTabPageContainer::elementReplaced( const css::container::ContainerEvent& /*Event*/ ) +{ +} + +void VCLXTabPageContainer::propertiesChange(const::css::uno::Sequence& rEvents) +{ + SolarMutexGuard aGuard; + VclPtr pTabCtrl = GetAs(); + if (!pTabCtrl) + return; + + for (const beans::PropertyChangeEvent& rEvent : rEvents) { + // handle property changes for tab pages + Reference< css::awt::tab::XTabPageModel > xTabPageModel(rEvent.Source, uno::UNO_QUERY); + if (!xTabPageModel.is()) + continue; + + const sal_Int16 nId = xTabPageModel->getTabPageID(); + if (rEvent.PropertyName == GetPropertyName(BASEPROPERTY_ENABLED)) { + pTabCtrl->SetPageEnabled(nId, xTabPageModel->getEnabled()); + } else if (rEvent.PropertyName == GetPropertyName(BASEPROPERTY_TITLE)) { + pTabCtrl->SetPageText(nId, xTabPageModel->getTitle()); + } + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/source/awt/vclxtoolkit.cxx b/toolkit/source/awt/vclxtoolkit.cxx new file mode 100644 index 000000000..e73511960 --- /dev/null +++ b/toolkit/source/awt/vclxtoolkit.cxx @@ -0,0 +1,2668 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include + +#include + +#ifdef _WIN32 +#include +#include +#endif +#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 + +#ifdef MACOSX +#include +#include +#include +#endif + +#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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if HAVE_FEATURE_OPENGL +#include +#endif +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#if defined(_WIN32) +#define SYSTEM_DEPENDENT_TYPE css::lang::SystemDependent::SYSTEM_WIN32 +#elif defined(MACOSX) +#define SYSTEM_DEPENDENT_TYPE css::lang::SystemDependent::SYSTEM_MAC +#elif defined(UNX) +#define SYSTEM_DEPENDENT_TYPE css::lang::SystemDependent::SYSTEM_XWINDOW +#endif + +void MessBox::ImplInitButtons() +{ + ButtonDialogFlags nOKFlags = ButtonDialogFlags::OK; + ButtonDialogFlags nCancelFlags = ButtonDialogFlags::Cancel; + ButtonDialogFlags nRetryFlags = ButtonDialogFlags::NONE; + ButtonDialogFlags nYesFlags = ButtonDialogFlags::NONE; + ButtonDialogFlags nNoFlags = ButtonDialogFlags::NONE; + + if ( mnMessBoxStyle & MessBoxStyle::OkCancel ) + { + if ( mnMessBoxStyle & MessBoxStyle::DefaultCancel ) + nCancelFlags |= ButtonDialogFlags::Default | ButtonDialogFlags::Focus; + else // MessBoxStyle::DefaultOk + nOKFlags |= ButtonDialogFlags::Default | ButtonDialogFlags::Focus; + + AddButton( StandardButtonType::OK, RET_OK, nOKFlags ); + AddButton( StandardButtonType::Cancel, RET_CANCEL, nCancelFlags ); + } + else if ( mnMessBoxStyle & MessBoxStyle::YesNo ) + { + if ( mnMessBoxStyle & MessBoxStyle::DefaultYes ) + nYesFlags |= ButtonDialogFlags::Default | ButtonDialogFlags::Focus; + else // MessBoxStyle::DefaultNo + nNoFlags |= ButtonDialogFlags::Default | ButtonDialogFlags::Focus; + nNoFlags |= ButtonDialogFlags::Cancel; + + AddButton( StandardButtonType::Yes, RET_YES, nYesFlags ); + AddButton( StandardButtonType::No, RET_NO, nNoFlags ); + } + else if ( mnMessBoxStyle & MessBoxStyle::YesNoCancel ) + { + if ( mnMessBoxStyle & MessBoxStyle::DefaultYes ) + nYesFlags |= ButtonDialogFlags::Default | ButtonDialogFlags::Focus; + else if ( mnMessBoxStyle & MessBoxStyle::DefaultNo ) + nNoFlags |= ButtonDialogFlags::Default | ButtonDialogFlags::Focus; + else + nCancelFlags |= ButtonDialogFlags::Default | ButtonDialogFlags::Focus; + + AddButton( StandardButtonType::Yes, RET_YES, nYesFlags ); + AddButton( StandardButtonType::No, RET_NO, nNoFlags ); + AddButton( StandardButtonType::Cancel, RET_CANCEL, nCancelFlags ); + } + else if ( mnMessBoxStyle & MessBoxStyle::RetryCancel ) + { + if ( mnMessBoxStyle & MessBoxStyle::DefaultCancel ) + nCancelFlags |= ButtonDialogFlags::Default | ButtonDialogFlags::Focus; + else // MessBoxStyle::DefaultRetry + nRetryFlags |= ButtonDialogFlags::Default | ButtonDialogFlags::Focus; + + AddButton( StandardButtonType::Retry, RET_RETRY, nRetryFlags ); + AddButton( StandardButtonType::Cancel, RET_CANCEL, nCancelFlags ); + } + else if ( mnMessBoxStyle & MessBoxStyle::AbortRetryIgnore ) + { + ButtonDialogFlags nAbortFlags = ButtonDialogFlags::NONE; + ButtonDialogFlags nIgnoreFlags = ButtonDialogFlags::NONE; + + if ( mnMessBoxStyle & MessBoxStyle::DefaultCancel ) + nAbortFlags |= ButtonDialogFlags::Default | ButtonDialogFlags::Focus; + else if ( mnMessBoxStyle & MessBoxStyle::DefaultRetry ) + nRetryFlags |= ButtonDialogFlags::Default | ButtonDialogFlags::Focus; + else if ( mnMessBoxStyle & MessBoxStyle::DefaultIgnore ) + nIgnoreFlags |= ButtonDialogFlags::Default | ButtonDialogFlags::Focus; + + AddButton( StandardButtonType::Abort, RET_CANCEL, nAbortFlags ); + AddButton( StandardButtonType::Retry, RET_RETRY, nRetryFlags ); + AddButton( StandardButtonType::Ignore, RET_IGNORE, nIgnoreFlags ); + } + else if ( mnMessBoxStyle & MessBoxStyle::Ok ) + { + nOKFlags |= ButtonDialogFlags::Default | ButtonDialogFlags::Focus; + + AddButton( StandardButtonType::OK, RET_OK, nOKFlags ); + } +} + +MessBox::MessBox(vcl::Window* pParent, MessBoxStyle nMessBoxStyle, WinBits nWinBits, + const OUString& rTitle, const OUString& rMessage) : + ButtonDialog( WindowType::MESSBOX ), + mbHelpBtn( false ), + mnMessBoxStyle( nMessBoxStyle ), + maMessText( rMessage ) +{ + ImplLOKNotifier(pParent); + ImplInitDialog(pParent, nWinBits | WB_MOVEABLE | WB_HORZ | WB_CENTER); + ImplInitButtons(); + + if ( !rTitle.isEmpty() ) + SetText( rTitle ); +} + +MessBox::~MessBox() +{ + disposeOnce(); +} + +void MessBox::dispose() +{ + mpVCLMultiLineEdit.disposeAndClear(); + mpFixedImage.disposeAndClear(); + ButtonDialog::dispose(); +} + +void MessBox::ImplPosControls() +{ + if ( !GetHelpId().isEmpty() ) + { + if ( !mbHelpBtn ) + { + AddButton( StandardButtonType::Help, RET_HELP, ButtonDialogFlags::Help, 3 ); + mbHelpBtn = true; + } + } + else + { + if ( mbHelpBtn ) + { + RemoveButton( RET_HELP ); + mbHelpBtn = false; + } + } + + TextRectInfo aTextInfo; + tools::Rectangle aRect( 0, 0, 30000, 30000 ); + tools::Rectangle aFormatRect; + Point aTextPos( IMPL_DIALOG_OFFSET, IMPL_DIALOG_OFFSET+IMPL_MSGBOX_OFFSET_EXTRA_Y ); + Size aImageSize; + Size aPageSize; + Size aMEditSize; + tools::Long nTitleWidth; + tools::Long nButtonSize = ImplGetButtonSize(); + tools::Long nMaxLineWidth; + tools::Long nWidth; + WinBits nWinStyle = WB_LEFT | WB_NOLABEL; + DrawTextFlags nTextStyle = DrawTextFlags::MultiLine | DrawTextFlags::Top | DrawTextFlags::Left; + + mpVCLMultiLineEdit.disposeAndClear(); + mpFixedImage.disposeAndClear(); + + // Clean up message text with tabs + OUString aMessText(maMessText.replaceAll("\t", " ")); + + //If window too small, we make dialog box be wider + tools::Long nMaxWidth = 630 * GetDPIScaleFactor(); + + // MessagBox should be at least as wide as to see the title + // Extra-Width for Close button, because Close button is set after this call + nTitleWidth = CalcTitleWidth(); + + nMaxWidth -= (IMPL_DIALOG_OFFSET*2)+(IMPL_MSGBOX_OFFSET_EXTRA_X*2); + + // for an image, get its size, create a suitable control and position it + aImageSize = maImage.GetSizePixel(); + if ( aImageSize.Width() ) + { + aImageSize.AdjustWidth(4 ); + aImageSize.AdjustHeight(4 ); + aTextPos.AdjustX(aImageSize.Width()+IMPL_SEP_MSGBOX_IMAGE ); + mpFixedImage = VclPtr::Create( this ); + mpFixedImage->SetPosSizePixel( Point( IMPL_DIALOG_OFFSET-2+IMPL_MSGBOX_OFFSET_EXTRA_X, + IMPL_DIALOG_OFFSET-2+IMPL_MSGBOX_OFFSET_EXTRA_Y ), + aImageSize ); + mpFixedImage->SetImage( maImage ); + mpFixedImage->Show(); + nMaxWidth -= aImageSize.Width()+IMPL_SEP_MSGBOX_IMAGE; + } + else + aTextPos.AdjustX(IMPL_MSGBOX_OFFSET_EXTRA_X ); + + // Determine maximum line length without wordbreak + aFormatRect = GetTextRect( aRect, aMessText, nTextStyle, &aTextInfo ); + nMaxLineWidth = aFormatRect.GetWidth(); + nTextStyle |= DrawTextFlags::WordBreak; + + // Determine the width for text formatting + if ( nMaxLineWidth > 450 ) + nWidth = 450; + else if ( nMaxLineWidth > 300 ) + nWidth = nMaxLineWidth+5; + else + nWidth = 300; + + nWidth *= GetDPIScaleFactor(); + + if ( nButtonSize > nWidth ) + nWidth = nButtonSize-(aTextPos.X()-IMPL_DIALOG_OFFSET); + if ( nWidth > nMaxWidth ) + nWidth = nMaxWidth; + + aRect.SetRight( nWidth ); + aFormatRect = GetTextRect( aRect, aMessText, nTextStyle, &aTextInfo ); + if ( aTextInfo.GetMaxLineWidth() > nWidth ) + { + nWidth = aTextInfo.GetMaxLineWidth()+8; + aRect.SetRight( nWidth ); + aFormatRect = GetTextRect( aRect, aMessText, nTextStyle, &aTextInfo ); + } + + // get Style for VCLMultiLineEdit + aMEditSize.setWidth( aTextInfo.GetMaxLineWidth()+1 ); + aMEditSize.setHeight( aFormatRect.GetHeight() ); + aPageSize.setWidth( aImageSize.Width() ); + if ( aMEditSize.Height() < aImageSize.Height() ) + { + nWinStyle |= WB_VCENTER; + aPageSize.setHeight( aImageSize.Height() ); + aMEditSize.setHeight( aImageSize.Height() ); + } + else + { + nWinStyle |= WB_TOP; + aPageSize.setHeight( aMEditSize.Height() ); + } + if ( aImageSize.Width() ) + aPageSize.AdjustWidth(IMPL_SEP_MSGBOX_IMAGE ); + aPageSize.AdjustWidth((IMPL_DIALOG_OFFSET*2)+(IMPL_MSGBOX_OFFSET_EXTRA_X*2) ); + aPageSize.AdjustWidth(aMEditSize.Width()+1 ); + aPageSize.AdjustHeight((IMPL_DIALOG_OFFSET*2)+(IMPL_MSGBOX_OFFSET_EXTRA_Y*2) ); + + if ( aPageSize.Width() < IMPL_MINSIZE_MSGBOX_WIDTH ) + aPageSize.setWidth( IMPL_MINSIZE_MSGBOX_WIDTH ); + if ( aPageSize.Width() < nTitleWidth ) + aPageSize.setWidth( nTitleWidth ); + + mpVCLMultiLineEdit = VclPtr::Create( this, nWinStyle ); + mpVCLMultiLineEdit->SetText( aMessText ); + mpVCLMultiLineEdit->SetPosSizePixel( aTextPos, aMEditSize ); + mpVCLMultiLineEdit->Show(); + mpVCLMultiLineEdit->SetPaintTransparent(true); + mpVCLMultiLineEdit->EnableCursor(false); + SetPageSizePixel( aPageSize ); +} + +void MessBox::StateChanged( StateChangedType nType ) +{ + if ( nType == StateChangedType::InitShow ) + { + ImplPosControls(); + } + ButtonDialog::StateChanged( nType ); +} + +Size MessBox::GetOptimalSize() const +{ + // FIXME: base me on the font size ? + return Size( 250, 100 ); +} + + +namespace { + +extern "C" typedef vcl::Window* (*FN_SvtCreateWindow)( + rtl::Reference* ppNewComp, + const css::awt::WindowDescriptor* pDescriptor, + vcl::Window* pParent, + WinBits nWinBits ); + +class Pause : public Idle +{ +public: + explicit Pause(sal_Int32 nPauseMilliseconds) : + Idle("pause"), + m_nPauseMilliseconds(nPauseMilliseconds) + { + SetPriority(TaskPriority::HIGHEST); + Start(); + } + + virtual void Invoke() override + { + SolarMutexGuard aSolarGuard; + osl::Thread::wait(std::chrono::milliseconds(m_nPauseMilliseconds)); + Stop(); + delete this; + } + + sal_Int32 m_nPauseMilliseconds; +}; + +class VCLXToolkit : public cppu::BaseMutex, + public cppu::WeakComponentImplHelper< + css::awt::XToolkitExperimental, + css::awt::XToolkitRobot, + css::lang::XServiceInfo > +{ + css::uno::Reference< css::datatransfer::clipboard::XClipboard > mxClipboard; + css::uno::Reference< css::datatransfer::clipboard::XClipboard > mxSelection; + + oslModule hSvToolsLib; + FN_SvtCreateWindow fnSvtCreateWindow; + + ::comphelper::OInterfaceContainerHelper3 m_aTopWindowListeners; + ::comphelper::OInterfaceContainerHelper3 m_aKeyHandlers; + ::comphelper::OInterfaceContainerHelper3 m_aFocusListeners; + ::Link m_aEventListenerLink; + ::Link m_aKeyListenerLink; + bool m_bEventListener; + bool m_bKeyListener; + + DECL_LINK(eventListenerHandler, ::VclSimpleEvent&, void); + + DECL_LINK(keyListenerHandler, ::VclWindowEvent&, bool); + + void callTopWindowListeners( + ::VclSimpleEvent const * pEvent, + void (SAL_CALL css::awt::XTopWindowListener::* pFn)( + css::lang::EventObject const &)); + + bool callKeyHandlers(::VclSimpleEvent const * pEvent, bool bPressed); + + void callFocusListeners(::VclSimpleEvent const * pEvent, bool bGained); + +protected: + ::osl::Mutex& GetMutex() { return m_aMutex; } + + virtual void SAL_CALL disposing() override; + + static vcl::Window* ImplCreateWindow( rtl::Reference* ppNewComp, const css::awt::WindowDescriptor& rDescriptor, vcl::Window* pParent, + WinBits nWinBits, MessBoxStyle nMessBoxStyle ); + css::uno::Reference< css::awt::XWindowPeer > ImplCreateWindow( const css::awt::WindowDescriptor& Descriptor, + MessBoxStyle nForceMessBoxStyle ); + +public: + + VCLXToolkit(); + + // css::awt::XToolkitExperimental + virtual void SAL_CALL processEventsToIdle() override; + + virtual sal_Int64 SAL_CALL getOpenGLBufferSwapCounter() override; + + virtual void SAL_CALL setDeterministicScheduling(sal_Bool bDeterministicMode) override; + + virtual void SAL_CALL pause(sal_Int32 nMilliseconds) override; + + virtual void SAL_CALL startRecording() override; + + virtual void SAL_CALL stopRecording() override; + + css::uno::Sequence< OUString > SAL_CALL getRecordingAndClear() override; + + // css::awt::XToolkit + css::uno::Reference< css::awt::XWindowPeer > SAL_CALL getDesktopWindow( ) override; + css::awt::Rectangle SAL_CALL getWorkArea( ) override; + css::uno::Reference< css::awt::XWindowPeer > SAL_CALL createWindow( const css::awt::WindowDescriptor& Descriptor ) override; + css::uno::Sequence< css::uno::Reference< css::awt::XWindowPeer > > SAL_CALL createWindows( const css::uno::Sequence< css::awt::WindowDescriptor >& Descriptors ) override; + css::uno::Reference< css::awt::XDevice > SAL_CALL createScreenCompatibleDevice( sal_Int32 Width, sal_Int32 Height ) override; + css::uno::Reference< css::awt::XRegion > SAL_CALL createRegion( ) override; + + // css::awt::XSystemChildFactory + css::uno::Reference< css::awt::XWindowPeer > SAL_CALL createSystemChild( const css::uno::Any& Parent, const css::uno::Sequence< sal_Int8 >& ProcessId, sal_Int16 SystemType ) override; + + // css::awt::XMessageBoxFactory + virtual css::uno::Reference< css::awt::XMessageBox > SAL_CALL createMessageBox( const css::uno::Reference< css::awt::XWindowPeer >& aParent, css::awt::MessageBoxType eType, ::sal_Int32 aButtons, const OUString& aTitle, const OUString& aMessage ) override; + + // css::awt::XDataTransfer + css::uno::Reference< css::datatransfer::dnd::XDragGestureRecognizer > SAL_CALL getDragGestureRecognizer( const css::uno::Reference< css::awt::XWindow >& window ) override; + css::uno::Reference< css::datatransfer::dnd::XDragSource > SAL_CALL getDragSource( const css::uno::Reference< css::awt::XWindow >& window ) override; + css::uno::Reference< css::datatransfer::dnd::XDropTarget > SAL_CALL getDropTarget( const css::uno::Reference< css::awt::XWindow >& window ) override; + css::uno::Reference< css::datatransfer::clipboard::XClipboard > SAL_CALL getClipboard( const OUString& clipboardName ) override; + + // css::lang::XServiceInfo + OUString SAL_CALL getImplementationName( ) override; + sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; + css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override; + + // css::awt::XExtendedToolkit: + + virtual ::sal_Int32 SAL_CALL getTopWindowCount() override; + + virtual css::uno::Reference< css::awt::XTopWindow > + SAL_CALL getTopWindow(::sal_Int32 nIndex) override; + + virtual css::uno::Reference< css::awt::XTopWindow > + SAL_CALL getActiveTopWindow() override; + + virtual void SAL_CALL addTopWindowListener( + css::uno::Reference< + css::awt::XTopWindowListener > const & rListener) override; + + virtual void SAL_CALL removeTopWindowListener( + css::uno::Reference< + css::awt::XTopWindowListener > const & rListener) override; + + virtual void SAL_CALL addKeyHandler( + css::uno::Reference< + css::awt::XKeyHandler > const & rHandler) override; + + virtual void SAL_CALL removeKeyHandler( + css::uno::Reference< + css::awt::XKeyHandler > const & rHandler) override; + + virtual void SAL_CALL addFocusListener( + css::uno::Reference< + css::awt::XFocusListener > const & rListener) override; + + virtual void SAL_CALL removeFocusListener( + css::uno::Reference< + css::awt::XFocusListener > const & rListener) override; + + virtual void SAL_CALL fireFocusGained( + css::uno::Reference< + css::uno::XInterface > const & source) override; + + virtual void SAL_CALL fireFocusLost( + css::uno::Reference< + css::uno::XInterface > const & source) override; + + // css::awt::XReschedule: + virtual void SAL_CALL reschedule() override; + + // css::awt::XFontMappingUse: + virtual void SAL_CALL startTrackingFontMappingUse() override; + + virtual css::uno::Sequence SAL_CALL finishTrackingFontMappingUse() override; + + // css:awt:XToolkitRobot + virtual void SAL_CALL keyPress( const css::awt::KeyEvent & aKeyEvent ) override; + + virtual void SAL_CALL keyRelease( const css::awt::KeyEvent & aKeyEvent ) override; + + virtual void SAL_CALL mousePress( const css::awt::MouseEvent & aMouseEvent ) override; + + virtual void SAL_CALL mouseRelease( const css::awt::MouseEvent & aMouseEvent ) override; + + virtual void SAL_CALL mouseMove( const css::awt::MouseEvent & aMouseEvent ) override; + +}; + +std::pair ImplGetWinBits( sal_uInt32 nComponentAttribs, WindowType nCompType ) +{ + WinBits nWinBits = 0; + MessBoxStyle nStyle = MessBoxStyle::NONE; + + bool bMessBox = false; + if ( ( nCompType == WindowType::INFOBOX ) || + ( nCompType == WindowType::MESSBOX ) || + ( nCompType == WindowType::QUERYBOX ) || + ( nCompType == WindowType::WARNINGBOX ) || + ( nCompType == WindowType::ERRORBOX ) ) + { + bMessBox = true; + } + + bool bDecoratedWindow = false; + if ( bMessBox + || ( nCompType == WindowType::DIALOG ) + || ( nCompType == WindowType::MODELESSDIALOG ) + || ( nCompType == WindowType::DOCKINGWINDOW ) + || ( nCompType == WindowType::TABDIALOG ) + || ( nCompType == WindowType::BUTTONDIALOG ) + || ( nCompType == WindowType::SYSTEMCHILDWINDOW ) + ) + { + bDecoratedWindow = true; + } + + if( nComponentAttribs & css::awt::WindowAttribute::BORDER ) + nWinBits |= WB_BORDER; + if( nComponentAttribs & css::awt::VclWindowPeerAttribute::NOBORDER ) + nWinBits |= WB_NOBORDER; + if( nComponentAttribs & css::awt::WindowAttribute::SIZEABLE ) + nWinBits |= WB_SIZEABLE; + if( nComponentAttribs & css::awt::WindowAttribute::MOVEABLE ) + nWinBits |= WB_MOVEABLE; + if( nComponentAttribs & css::awt::WindowAttribute::CLOSEABLE ) + nWinBits |= WB_CLOSEABLE; + if( nComponentAttribs & css::awt::VclWindowPeerAttribute::HSCROLL ) + nWinBits |= WB_HSCROLL; + if( nComponentAttribs & css::awt::VclWindowPeerAttribute::VSCROLL ) + nWinBits |= WB_VSCROLL; + if( nComponentAttribs & css::awt::VclWindowPeerAttribute::LEFT ) + nWinBits |= WB_LEFT; + if( nComponentAttribs & css::awt::VclWindowPeerAttribute::CENTER ) + nWinBits |= WB_CENTER; + if( nComponentAttribs & css::awt::VclWindowPeerAttribute::RIGHT ) + nWinBits |= WB_RIGHT; + if( nComponentAttribs & css::awt::VclWindowPeerAttribute::SPIN ) + nWinBits |= WB_SPIN; + if( nComponentAttribs & css::awt::VclWindowPeerAttribute::SORT ) + nWinBits |= WB_SORT; + if( nComponentAttribs & css::awt::VclWindowPeerAttribute::DROPDOWN ) + nWinBits |= WB_DROPDOWN; + if( nComponentAttribs & css::awt::VclWindowPeerAttribute::DEFBUTTON ) + nWinBits |= WB_DEFBUTTON; + if( nComponentAttribs & css::awt::VclWindowPeerAttribute::READONLY ) + nWinBits |= WB_READONLY; + if( nComponentAttribs & css::awt::VclWindowPeerAttribute::CLIPCHILDREN ) + nWinBits |= WB_CLIPCHILDREN; + if( nComponentAttribs & css::awt::VclWindowPeerAttribute::GROUP ) + nWinBits |= WB_GROUP; + if( nComponentAttribs & css::awt::VclWindowPeerAttribute::NOLABEL ) //added for issue79712 + nWinBits |= WB_NOLABEL; + + // These bits are not unique + if ( bMessBox ) + { + if( nComponentAttribs & css::awt::VclWindowPeerAttribute::OK ) + nStyle |= MessBoxStyle::Ok; + if( nComponentAttribs & css::awt::VclWindowPeerAttribute::OK_CANCEL ) + nStyle |= MessBoxStyle::OkCancel; + if( nComponentAttribs & css::awt::VclWindowPeerAttribute::YES_NO ) + nStyle |= MessBoxStyle::YesNo; + if( nComponentAttribs & css::awt::VclWindowPeerAttribute::YES_NO_CANCEL ) + nStyle |= MessBoxStyle::YesNoCancel; + if( nComponentAttribs & css::awt::VclWindowPeerAttribute::RETRY_CANCEL ) + nStyle |= MessBoxStyle::RetryCancel; + if( nComponentAttribs & css::awt::VclWindowPeerAttribute::DEF_OK ) + nStyle |= MessBoxStyle::DefaultOk; + if( nComponentAttribs & css::awt::VclWindowPeerAttribute::DEF_CANCEL ) + nStyle |= MessBoxStyle::DefaultCancel; + if( nComponentAttribs & css::awt::VclWindowPeerAttribute::DEF_RETRY ) + nStyle |= MessBoxStyle::DefaultRetry; + if( nComponentAttribs & css::awt::VclWindowPeerAttribute::DEF_YES ) + nStyle |= MessBoxStyle::DefaultYes; + if( nComponentAttribs & css::awt::VclWindowPeerAttribute::DEF_NO ) + nStyle |= MessBoxStyle::DefaultNo; + } + if ( nCompType == WindowType::MULTILINEEDIT || nCompType == WindowType::DIALOG + || nCompType == WindowType::GROUPBOX || nCompType == WindowType::TABPAGE ) + { + if( nComponentAttribs & css::awt::VclWindowPeerAttribute::AUTOHSCROLL ) + nWinBits |= WB_AUTOHSCROLL; + if( nComponentAttribs & css::awt::VclWindowPeerAttribute::AUTOVSCROLL ) + nWinBits |= WB_AUTOVSCROLL; + } + + + if ( bDecoratedWindow ) + { + if( nComponentAttribs & css::awt::WindowAttribute::NODECORATION ) + { + // No decoration removes several window attributes and must + // set WB_NOBORDER! + nWinBits &= ~WB_BORDER; + nWinBits &= ~WB_SIZEABLE; + nWinBits &= ~WB_MOVEABLE; + nWinBits &= ~WB_CLOSEABLE; + nWinBits |= WB_NOBORDER; + } + } + + return { nWinBits, nStyle }; +} + +struct ComponentInfo +{ + std::u16string_view sName; + WindowType nWinType; +}; + +ComponentInfo const aComponentInfos [] = +{ + { std::u16string_view(u"animatedimages"), WindowType::CONTROL }, + { std::u16string_view(u"buttondialog"), WindowType::BUTTONDIALOG }, + { std::u16string_view(u"cancelbutton"), WindowType::CANCELBUTTON }, + { std::u16string_view(u"checkbox"), WindowType::CHECKBOX }, + { std::u16string_view(u"combobox"), WindowType::COMBOBOX }, + { std::u16string_view(u"control"), WindowType::CONTROL }, + { std::u16string_view(u"currencybox"), WindowType::CURRENCYBOX }, + { std::u16string_view(u"currencyfield"), WindowType::CURRENCYFIELD }, + { std::u16string_view(u"datebox"), WindowType::DATEBOX }, + { std::u16string_view(u"datefield"), WindowType::CONTROL }, + { std::u16string_view(u"dialog"), WindowType::DIALOG }, + { std::u16string_view(u"dockingarea"), WindowType::DOCKINGAREA }, + { std::u16string_view(u"dockingwindow"), WindowType::DOCKINGWINDOW }, + { std::u16string_view(u"edit"), WindowType::EDIT }, + { std::u16string_view(u"errorbox"), WindowType::ERRORBOX }, + { std::u16string_view(u"filecontrol"), WindowType::CONTROL }, + { std::u16string_view(u"fixedbitmap"), WindowType::FIXEDBITMAP }, + { std::u16string_view(u"fixedhyperlink"), WindowType::CONTROL }, + { std::u16string_view(u"fixedimage"), WindowType::FIXEDIMAGE }, + { std::u16string_view(u"fixedline"), WindowType::FIXEDLINE }, + { std::u16string_view(u"fixedtext"), WindowType::FIXEDTEXT }, + { std::u16string_view(u"floatingwindow"), WindowType::FLOATINGWINDOW }, + { std::u16string_view(u"formattedfield"), WindowType::CONTROL }, + { std::u16string_view(u"frame"), WindowType::GROUPBOX }, + { std::u16string_view(u"framewindow"), WindowType::TOOLKIT_FRAMEWINDOW }, + { std::u16string_view(u"groupbox"), WindowType::GROUPBOX }, + { std::u16string_view(u"helpbutton"), WindowType::HELPBUTTON }, + { std::u16string_view(u"imagebutton"), WindowType::IMAGEBUTTON }, + { std::u16string_view(u"infobox"), WindowType::INFOBOX }, + { std::u16string_view(u"listbox"), WindowType::LISTBOX }, + { std::u16string_view(u"longcurrencybox"), WindowType::LONGCURRENCYBOX }, + { std::u16string_view(u"longcurrencyfield"), WindowType::CONTROL }, + { std::u16string_view(u"menubutton"), WindowType::MENUBUTTON }, + { std::u16string_view(u"messbox"), WindowType::MESSBOX }, + { std::u16string_view(u"metricbox"), WindowType::METRICBOX }, + { std::u16string_view(u"metricfield"), WindowType::METRICFIELD }, + { std::u16string_view(u"modelessdialog"), WindowType::MODELESSDIALOG }, + { std::u16string_view(u"morebutton"), WindowType::MOREBUTTON }, + { std::u16string_view(u"multilineedit"), WindowType::MULTILINEEDIT }, + { std::u16string_view(u"multilistbox"), WindowType::MULTILISTBOX }, + { std::u16string_view(u"numericbox"), WindowType::NUMERICBOX }, + { std::u16string_view(u"numericfield"), WindowType::CONTROL }, + { std::u16string_view(u"okbutton"), WindowType::OKBUTTON }, + { std::u16string_view(u"patternbox"), WindowType::PATTERNBOX }, + { std::u16string_view(u"patternfield"), WindowType::PATTERNFIELD }, + { std::u16string_view(u"progressbar"), WindowType::CONTROL }, + { std::u16string_view(u"pushbutton"), WindowType::PUSHBUTTON }, + { std::u16string_view(u"querybox"), WindowType::QUERYBOX }, + { std::u16string_view(u"radiobutton"), WindowType::RADIOBUTTON }, + { std::u16string_view(u"roadmap"), WindowType::CONTROL }, + { std::u16string_view(u"scrollbar"), WindowType::SCROLLBAR }, + { std::u16string_view(u"scrollbarbox"), WindowType::SCROLLBARBOX }, + { std::u16string_view(u"spinbutton"), WindowType::SPINBUTTON }, + { std::u16string_view(u"spinfield"), WindowType::SPINFIELD }, + { std::u16string_view(u"splitter"), WindowType::SPLITTER }, + { std::u16string_view(u"splitwindow"), WindowType::SPLITWINDOW }, + { std::u16string_view(u"statusbar"), WindowType::STATUSBAR }, + { std::u16string_view(u"systemchildwindow"), WindowType::TOOLKIT_SYSTEMCHILDWINDOW }, + { std::u16string_view(u"tabcontrol"), WindowType::TABCONTROL }, + { std::u16string_view(u"tabdialog"), WindowType::TABDIALOG }, + { std::u16string_view(u"tabpage"), WindowType::TABPAGE }, + { std::u16string_view(u"tabpagecontainer"), WindowType::CONTROL }, + { std::u16string_view(u"tabpagemodel"), WindowType::TABPAGE }, + { std::u16string_view(u"timebox"), WindowType::TIMEBOX }, + { std::u16string_view(u"timefield"), WindowType::TIMEFIELD }, + { std::u16string_view(u"toolbox"), WindowType::TOOLBOX }, + { std::u16string_view(u"tree"), WindowType::CONTROL }, + { std::u16string_view(u"tristatebox"), WindowType::TRISTATEBOX }, + { std::u16string_view(u"warningbox"), WindowType::WARNINGBOX }, + { std::u16string_view(u"window"), WindowType::WINDOW }, + { std::u16string_view(u"workwindow"), WindowType::WORKWINDOW } +}; + +bool ComponentInfoFindCompare( const ComponentInfo & lhs, const OUString & s) +{ + return rtl_ustr_compareIgnoreAsciiCase_WithLength(s.pData->buffer, s.pData->length, + lhs.sName.data(), lhs.sName.size()) > 0; +} + +WindowType ImplGetComponentType( const OUString& rServiceName ) +{ + static bool bSorted = false; + if( !bSorted ) + { + assert( std::is_sorted( std::begin(aComponentInfos), std::end(aComponentInfos), + [](const ComponentInfo & lhs, const ComponentInfo & rhs) { + return + rtl_ustr_compare_WithLength( + lhs.sName.data(), lhs.sName.size(), rhs.sName.data(), + rhs.sName.size()) + < 0; + } ) ); + bSorted = true; + } + + OUString sSearch; + if ( !rServiceName.isEmpty() ) + sSearch = rServiceName; + else + sSearch = "window"; + + auto it = std::lower_bound( std::begin(aComponentInfos), std::end(aComponentInfos), sSearch, + ComponentInfoFindCompare ); + if (it != std::end(aComponentInfos) && + rtl_ustr_compareIgnoreAsciiCase_WithLength(sSearch.pData->buffer, sSearch.pData->length, it->sName.data(), it->sName.size()) == 0) + return it->nWinType; + return WindowType::NONE; +} + +struct MessageBoxTypeInfo +{ + css::awt::MessageBoxType eType; + const char *pName; + sal_Int32 nLen; +}; + +const MessageBoxTypeInfo aMessageBoxTypeInfo[] = +{ + { css::awt::MessageBoxType_MESSAGEBOX, RTL_CONSTASCII_STRINGPARAM("messbox") }, + { css::awt::MessageBoxType_INFOBOX, RTL_CONSTASCII_STRINGPARAM("infobox") }, + { css::awt::MessageBoxType_WARNINGBOX, RTL_CONSTASCII_STRINGPARAM("warningbox") }, + { css::awt::MessageBoxType_ERRORBOX, RTL_CONSTASCII_STRINGPARAM("errorbox") }, + { css::awt::MessageBoxType_QUERYBOX, RTL_CONSTASCII_STRINGPARAM("querybox") }, + { css::awt::MessageBoxType::MessageBoxType_MAKE_FIXED_SIZE, nullptr, 0 } +}; + +bool lcl_convertMessageBoxType( + OUString &sType, + css::awt::MessageBoxType eType ) +{ + const MessageBoxTypeInfo *pMap = aMessageBoxTypeInfo; + css::awt::MessageBoxType eVal = css::awt::MessageBoxType::MessageBoxType_MAKE_FIXED_SIZE; + + while ( pMap->pName ) + { + if ( pMap->eType == eType ) + { + eVal = eType; + sType = OUString( pMap->pName, pMap->nLen, RTL_TEXTENCODING_ASCII_US ); + break; + } + pMap++; + } + + return ( eVal != css::awt::MessageBoxType::MessageBoxType_MAKE_FIXED_SIZE ); +} + +#ifndef IOS + +sal_Int32 nVCLToolkitInstanceCount = 0; +bool bInitedByVCLToolkit = false; + +osl::Mutex & getInitMutex() +{ + static osl::Mutex aMutex; + return aMutex; +} + +osl::Condition & getInitCondition() +{ + static osl::Condition aCondition; + return aCondition; +} + +extern "C" +{ +static void ToolkitWorkerFunction( void* pArgs ) +{ + osl_setThreadName("VCLXToolkit VCL main thread"); + + css::uno::Reference xServiceManager; + try + { + xServiceManager = ::comphelper::getProcessServiceFactory(); + } + catch (const css::uno::DeploymentException&) + { + } + if (!xServiceManager.is()) + { + css::uno::Reference xContext = + ::cppu::defaultBootstrap_InitialComponentContext(); + + xServiceManager.set( xContext->getServiceManager(), css::uno::UNO_QUERY_THROW ); + // set global process service factory used by unotools config helpers + ::comphelper::setProcessServiceFactory( xServiceManager ); + } + + VCLXToolkit * pTk = static_cast(pArgs); + bInitedByVCLToolkit = !IsVCLInit() && InitVCL(); + if( bInitedByVCLToolkit ) + { + UnoWrapper* pUnoWrapper = new UnoWrapper( pTk ); + UnoWrapperBase::SetUnoWrapper( pUnoWrapper ); + } + getInitCondition().set(); + if( bInitedByVCLToolkit ) + { + { + SolarMutexGuard aGuard; + Application::Execute(); + } + try + { + pTk->dispose(); + } + catch( css::uno::Exception & ) + { + } + DeInitVCL(); + } + else + { + // having the thread join itself is pretty stupid. + // but we can't get the osl_Thread to destroy here so just leak it. + } +} +} + +#endif + +// constructor, which might initialize VCL +VCLXToolkit::VCLXToolkit(): + cppu::WeakComponentImplHelper< + css::awt::XToolkitExperimental, + css::awt::XToolkitRobot, + css::lang::XServiceInfo>( GetMutex() ), + m_aTopWindowListeners(rBHelper.rMutex), + m_aKeyHandlers(rBHelper.rMutex), + m_aFocusListeners(rBHelper.rMutex), + m_aEventListenerLink(LINK(this, VCLXToolkit, eventListenerHandler)), + m_aKeyListenerLink(LINK(this, VCLXToolkit, keyListenerHandler)), + m_bEventListener(false), + m_bKeyListener(false) +{ + hSvToolsLib = nullptr; + fnSvtCreateWindow = nullptr; + +#ifndef IOS + osl::Guard< osl::Mutex > aGuard( getInitMutex() ); + nVCLToolkitInstanceCount++; + if( ( nVCLToolkitInstanceCount == 1 ) && ( !Application::IsInMain() ) ) + { + // setup execute thread + CreateMainLoopThread( ToolkitWorkerFunction, this ); + getInitCondition().wait(); + } +#endif +} + +void SAL_CALL VCLXToolkit::disposing() +{ +#ifndef DISABLE_DYNLOADING + if ( hSvToolsLib ) + { + osl_unloadModule( hSvToolsLib ); + hSvToolsLib = nullptr; + fnSvtCreateWindow = nullptr; + } +#endif + +#ifndef IOS + { + osl::Guard< osl::Mutex > aGuard( getInitMutex() ); + if( --nVCLToolkitInstanceCount == 0 ) + { + if( bInitedByVCLToolkit ) + { + Application::Quit(); + JoinMainLoopThread(); + bInitedByVCLToolkit = false; + } + } + } +#endif + if (m_bEventListener) + { + ::Application::RemoveEventListener(m_aEventListenerLink); + m_bEventListener = false; + } + if (m_bKeyListener) + { + ::Application::RemoveKeyListener(m_aKeyListenerLink); + m_bKeyListener = false; + } + css::lang::EventObject aEvent( + static_cast< ::cppu::OWeakObject * >(this)); + m_aTopWindowListeners.disposeAndClear(aEvent); + m_aKeyHandlers.disposeAndClear(aEvent); + m_aFocusListeners.disposeAndClear(aEvent); +} + + +css::uno::Reference< css::awt::XWindowPeer > VCLXToolkit::getDesktopWindow( ) +{ + css::uno::Reference< css::awt::XWindowPeer > xRef; + // 07/00: AppWindow doesn't exist anymore... + return xRef; +} + +css::awt::Rectangle VCLXToolkit::getWorkArea( ) +{ + sal_Int32 nDisplay = Application::GetDisplayBuiltInScreen(); + tools::Rectangle aWorkRect = Application::GetScreenPosSizePixel( nDisplay ); + css::awt::Rectangle aNotherRect; + aNotherRect.X = aWorkRect.Left(); + aNotherRect.Y = aWorkRect.Top(); + aNotherRect.Width = aWorkRect.getWidth(); + aNotherRect.Height = aWorkRect.getHeight(); + return aNotherRect; +} + +css::uno::Reference< css::awt::XWindowPeer > VCLXToolkit::createWindow( const css::awt::WindowDescriptor& rDescriptor ) +{ + return ImplCreateWindow( rDescriptor, MessBoxStyle::NONE ); +} + +css::uno::Reference< css::awt::XDevice > VCLXToolkit::createScreenCompatibleDevice( sal_Int32 Width, sal_Int32 Height ) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + rtl::Reference pVDev = new VCLXVirtualDevice; + + SolarMutexGuard aSolarGuard; + + VclPtrInstance pV; + pV->SetOutputSizePixel( Size( Width, Height ) ); + pVDev->SetVirtualDevice( pV ); + + return pVDev; +} + +css::uno::Reference< css::awt::XRegion > VCLXToolkit::createRegion( ) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + css::uno::Reference< css::awt::XRegion > xRef = new VCLXRegion; + return xRef; +} + +class InfoBox : public MessBox +{ +public: + InfoBox(vcl::Window* pParent, const OUString& rMessage) + : MessBox(pParent, MessBoxStyle::Ok | MessBoxStyle::DefaultOk, 0, OUString(), rMessage) + { + // Default Text is the display title from the application + if (GetText().isEmpty()) + SetText(GetStandardInfoBoxText()); + SetImage(GetStandardInfoBoxImage()); + } +}; + +class ErrorBox : public MessBox +{ +public: + ErrorBox(vcl::Window* pParent, MessBoxStyle nStyle, WinBits nWinBits, const OUString& rMessage) + : MessBox(pParent, nStyle, nWinBits, OUString(), rMessage) + { + // Default Text is the display title from the application + if (GetText().isEmpty()) + SetText(GetStandardErrorBoxText()); + SetImage(GetStandardErrorBoxImage()); + } +}; + +class QueryBox : public MessBox +{ +public: + QueryBox(vcl::Window* pParent, MessBoxStyle nStyle, WinBits nWinBits, const OUString& rMessage) + : MessBox(pParent, nStyle, nWinBits, OUString(), rMessage) + { + // Default Text is the display title from the application + if (GetText().isEmpty()) + SetText(GetStandardQueryBoxText()); + SetImage(GetStandardQueryBoxImage()); + } +}; + +class WarningBox : public MessBox +{ +public: + WarningBox(vcl::Window* pParent, MessBoxStyle nStyle, WinBits nWinBits, const OUString& rMessage) + : MessBox(pParent, nStyle, nWinBits, OUString(), rMessage) + { + // Default Text is the display title from the application + if (GetText().isEmpty()) + SetText(GetStandardWarningBoxText()); + SetImage(GetStandardWarningBoxImage()); + } +}; + + +struct RMItemData +{ + bool b_Enabled; + sal_Int32 n_ID; + OUString Label; +}; + +typedef ::cppu::ImplInheritanceHelper < VCLXGraphicControl + , css::container::XContainerListener + , css::beans::XPropertyChangeListener + , css::awt::XItemEventBroadcaster + > SVTXRoadmap_Base; +class SVTXRoadmap final : public SVTXRoadmap_Base +{ +public: + SVTXRoadmap(); + + void SAL_CALL disposing( const css::lang::EventObject& Source ) override { VCLXWindow::disposing( Source ); } + + // css::awt::XVclWindowPeer + void SAL_CALL setProperty( const OUString& PropertyName, const css::uno::Any& Value ) override; + + css::uno::Any SAL_CALL getProperty( const OUString& PropertyName ) override; + + // XContainerListener + void SAL_CALL elementInserted( const css::container::ContainerEvent& rEvent ) override; + void SAL_CALL elementRemoved( const css::container::ContainerEvent& rEvent ) override; + void SAL_CALL elementReplaced( const css::container::ContainerEvent& rEvent ) override; + + // XItemEventBroadcaster + virtual void SAL_CALL addItemListener( const css::uno::Reference< css::awt::XItemListener >& l ) override; + virtual void SAL_CALL removeItemListener( const css::uno::Reference< css::awt::XItemListener >& l ) override; + + // XPropertyChangeListener + virtual void SAL_CALL propertyChange( const css::beans::PropertyChangeEvent& evt ) override; + +private: + + // VCLXGraphicControl overridables + virtual void ImplSetNewImage() override; + + static void ImplGetPropertyIds( std::vector< sal_uInt16 > &aIds ); + virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override { return ImplGetPropertyIds( aIds ); } + + static RMItemData GetRMItemData( const css::container::ContainerEvent& _rEvent ); + + virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) override; + + virtual ~SVTXRoadmap() override; + + ItemListenerMultiplexer maItemListeners; +}; + + + + +SVTXRoadmap::SVTXRoadmap() : maItemListeners( *this ) +{ +} + +SVTXRoadmap::~SVTXRoadmap() +{ +} + +void SVTXRoadmap::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) +{ + switch ( rVclWindowEvent.GetId() ) + { + case VclEventId::RoadmapItemSelected: + { + SolarMutexGuard aGuard; + VclPtr<::vcl::ORoadmap> pField = GetAs< vcl::ORoadmap >(); + if ( pField ) + { + sal_Int16 CurItemID = pField->GetCurrentRoadmapItemID(); + css::awt::ItemEvent aEvent; + aEvent.Selected = CurItemID; + aEvent.Highlighted = CurItemID; + aEvent.ItemId = CurItemID; + maItemListeners.itemStateChanged( aEvent ); + } + } + break; + default: + SVTXRoadmap_Base::ProcessWindowEvent( rVclWindowEvent ); + break; + } +} + +void SVTXRoadmap::propertyChange( const css::beans::PropertyChangeEvent& evt ) +{ + SolarMutexGuard aGuard; + VclPtr<::vcl::ORoadmap> pField = GetAs< vcl::ORoadmap >(); + if ( !pField ) + return; + + css::uno::Reference< css::uno::XInterface > xRoadmapItem = evt.Source; + sal_Int32 nID = 0; + css::uno::Reference< css::beans::XPropertySet > xPropertySet( xRoadmapItem, css::uno::UNO_QUERY ); + css::uno::Any aValue = xPropertySet->getPropertyValue("ID"); + aValue >>= nID; + + OUString sPropertyName = evt.PropertyName; + if ( sPropertyName == "Enabled" ) + { + bool bEnable = false; + evt.NewValue >>= bEnable; + pField->EnableRoadmapItem( static_cast(nID) , bEnable ); + } + else if ( sPropertyName == "Label" ) + { + OUString sLabel; + evt.NewValue >>= sLabel; + pField->ChangeRoadmapItemLabel( static_cast(nID) , sLabel ); + } + else if ( sPropertyName == "ID" ) + { + sal_Int32 nNewID = 0; + evt.NewValue >>= nNewID; + evt.OldValue >>= nID; + pField->ChangeRoadmapItemID( static_cast(nID), static_cast(nNewID) ); + } +// else + // TODO handle Interactive appropriately +} + +void SVTXRoadmap::addItemListener( const css::uno::Reference< css::awt::XItemListener >& l ) +{ + maItemListeners.addInterface( l ); +} + +void SVTXRoadmap::removeItemListener( const css::uno::Reference< css::awt::XItemListener >& l ) +{ + maItemListeners.removeInterface( l ); +} + +RMItemData SVTXRoadmap::GetRMItemData( const css::container::ContainerEvent& _rEvent ) +{ + RMItemData aCurRMItemData; + css::uno::Reference< css::uno::XInterface > xRoadmapItem; + _rEvent.Element >>= xRoadmapItem; + css::uno::Reference< css::beans::XPropertySet > xPropertySet( xRoadmapItem, css::uno::UNO_QUERY ); + if ( xPropertySet.is() ) + { + css::uno::Any aValue = xPropertySet->getPropertyValue("Label"); + aValue >>= aCurRMItemData.Label; + aValue = xPropertySet->getPropertyValue("ID"); + aValue >>= aCurRMItemData.n_ID; + aValue = xPropertySet->getPropertyValue("Enabled"); + aValue >>= aCurRMItemData.b_Enabled; + } + else + { + aCurRMItemData.b_Enabled = false; + aCurRMItemData.n_ID = 0; + } + return aCurRMItemData; +} + +void SVTXRoadmap::elementInserted( const css::container::ContainerEvent& _rEvent ) +{ + SolarMutexGuard aGuard; + VclPtr<::vcl::ORoadmap> pField = GetAs< vcl::ORoadmap >(); + if ( pField ) + { + RMItemData CurItemData = GetRMItemData( _rEvent ); + sal_Int32 InsertIndex = 0; + _rEvent.Accessor >>= InsertIndex; + pField->InsertRoadmapItem( InsertIndex, CurItemData.Label, static_cast(CurItemData.n_ID), CurItemData.b_Enabled ); + } +} + +void SVTXRoadmap::elementRemoved( const css::container::ContainerEvent& _rEvent ) +{ + SolarMutexGuard aGuard; + VclPtr<::vcl::ORoadmap> pField = GetAs< vcl::ORoadmap >(); + if ( pField ) + { + sal_Int32 DelIndex = 0; + _rEvent.Accessor >>= DelIndex; + pField->DeleteRoadmapItem(DelIndex); + } +} + +void SVTXRoadmap::elementReplaced( const css::container::ContainerEvent& _rEvent ) +{ + SolarMutexGuard aGuard; + VclPtr<::vcl::ORoadmap> pField = GetAs< vcl::ORoadmap >(); + if ( pField ) + { + RMItemData CurItemData = GetRMItemData( _rEvent ); + sal_Int32 ReplaceIndex = 0; + _rEvent.Accessor >>= ReplaceIndex; + pField->ReplaceRoadmapItem( ReplaceIndex, CurItemData.Label, static_cast(CurItemData.n_ID), CurItemData.b_Enabled ); + } +} + +void SVTXRoadmap::setProperty( const OUString& PropertyName, const css::uno::Any& Value) +{ + SolarMutexGuard aGuard; + + VclPtr<::vcl::ORoadmap> pField = GetAs< vcl::ORoadmap >(); + if ( pField ) + { + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch (nPropType) + { + case BASEPROPERTY_COMPLETE: + { + bool b = false; + Value >>= b; + pField->SetRoadmapComplete( b); + } + break; + + case BASEPROPERTY_ACTIVATED: + { + bool b = false; + Value >>= b; + pField->SetRoadmapInteractive( b); + } + break; + + case BASEPROPERTY_CURRENTITEMID: + { + sal_Int32 nId = 0; + Value >>= nId; + pField->SelectRoadmapItemByID( static_cast(nId) ); + } + break; + + case BASEPROPERTY_TEXT: + { + OUString aStr; + Value >>= aStr; + pField->SetText( aStr ); + pField->Invalidate(); + } + break; + + default: + SVTXRoadmap_Base::setProperty( PropertyName, Value ); + break; + } + + } + else + SVTXRoadmap_Base::setProperty( PropertyName, Value ); +} + + +css::uno::Any SVTXRoadmap::getProperty( const OUString& PropertyName ) +{ + SolarMutexGuard aGuard; + + css::uno::Any aReturn; + + VclPtr<::vcl::ORoadmap> pField = GetAs< vcl::ORoadmap >(); + if ( pField ) + { + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch (nPropType) + { + case BASEPROPERTY_COMPLETE: + aReturn <<= pField->IsRoadmapComplete(); + break; + case BASEPROPERTY_ACTIVATED: + aReturn <<= pField->IsRoadmapInteractive(); + break; + case BASEPROPERTY_CURRENTITEMID: + aReturn <<= pField->GetCurrentRoadmapItemID(); + break; + default: + aReturn = SVTXRoadmap_Base::getProperty(PropertyName); + break; + } + } + return aReturn; +} + +void SVTXRoadmap::ImplSetNewImage() +{ + OSL_PRECOND( GetWindow(), "SVTXRoadmap::ImplSetNewImage: window is required to be not-NULL!" ); + VclPtr< ::vcl::ORoadmap > pButton = GetAs< ::vcl::ORoadmap >(); + pButton->SetRoadmapBitmap( GetImage().GetBitmapEx() ); +} + +void SVTXRoadmap::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds ) +{ + PushPropertyIds( rIds, + BASEPROPERTY_COMPLETE, + BASEPROPERTY_ACTIVATED, + BASEPROPERTY_CURRENTITEMID, + BASEPROPERTY_TEXT, + 0); + VCLXWindow::ImplGetPropertyIds( rIds, true ); + VCLXGraphicControl::ImplGetPropertyIds( rIds ); +} + +vcl::Window* VCLXToolkit::ImplCreateWindow( rtl::Reference* ppNewComp, + const css::awt::WindowDescriptor& rDescriptor, + vcl::Window* pParent, WinBits nWinBits, MessBoxStyle nMessBoxStyle ) +{ + OUString aServiceName = rDescriptor.WindowServiceName.toAsciiLowerCase(); + + VclPtr pNewWindow; + WindowType nType = ImplGetComponentType( aServiceName ); + bool bFrameControl = false; + if ( aServiceName == "frame" ) + bFrameControl = true; + if ( aServiceName == "tabcontrolnotabs" ) + { + nWinBits |= WB_NOBORDER; + nType = ImplGetComponentType( "tabcontrol" ); + } + if ( !pParent ) + { + // If the component needs a parent, then return NULL, + // some time later css::uno::Exception... + bool bException = true; + if ( ( nType == WindowType::DIALOG ) + || ( nType == WindowType::MODELESSDIALOG ) + || ( nType == WindowType::MESSBOX ) + || ( nType == WindowType::INFOBOX ) + || ( nType == WindowType::WARNINGBOX ) + || ( nType == WindowType::ERRORBOX ) + || ( nType == WindowType::QUERYBOX ) + ) + bException = false; + else if ( ( nType == WindowType::WINDOW ) || + ( nType == WindowType::WORKWINDOW ) || + ( nType == WindowType::TOOLKIT_FRAMEWINDOW ) ) + { + if ( rDescriptor.Type == css::awt::WindowClass_TOP ) + bException = false; + } + + if ( bException ) + { + *ppNewComp = nullptr; + return nullptr; + } + } + + if ( nType != WindowType::NONE ) + { + SolarMutexGuard aVclGuard; + switch ( nType ) + { + case WindowType::CANCELBUTTON: + pNewWindow = VclPtr::Create( pParent, nWinBits ); + *ppNewComp = new VCLXButton; + break; + case WindowType::CHECKBOX: + pNewWindow = VclPtr::Create( pParent, nWinBits ); + *ppNewComp = new VCLXCheckBox; + break; + case WindowType::COMBOBOX: + pNewWindow = VclPtr::Create( pParent, nWinBits|WB_AUTOHSCROLL ); + static_cast(pNewWindow.get())->EnableAutoSize( false ); + *ppNewComp = new VCLXComboBox; + break; + case WindowType::CURRENCYBOX: + pNewWindow = VclPtr::Create( pParent, nWinBits ); + break; + case WindowType::CURRENCYFIELD: + pNewWindow = VclPtr::Create( pParent, nWinBits ); + static_cast(pNewWindow.get())->EnableEmptyFieldValue( true ); + *ppNewComp = new VCLXNumericField; + static_cast((*ppNewComp).get())->SetFormatter( static_cast(static_cast(pNewWindow.get())) ); + break; + case WindowType::DATEBOX: + pNewWindow = VclPtr::Create( pParent, nWinBits ); + break; + case WindowType::DOCKINGAREA: + pNewWindow = VclPtr::Create( pParent ); + break; + case WindowType::MULTILINEEDIT: + pNewWindow = VclPtr::Create(pParent, nWinBits|WB_IGNORETAB); + static_cast(pNewWindow.get())->DisableSelectionOnFocus(); + *ppNewComp = new VCLXMultiLineEdit; + break; + case WindowType::EDIT: + pNewWindow = VclPtr::Create( pParent, nWinBits ); + *ppNewComp = new VCLXEdit; + break; + case WindowType::ERRORBOX: + pNewWindow = VclPtr::Create( pParent, nMessBoxStyle, nWinBits, OUString() ); + *ppNewComp = new VCLXMessageBox; + break; + case WindowType::FIXEDBITMAP: + pNewWindow = VclPtr::Create( pParent, nWinBits ); + break; + case WindowType::FIXEDIMAGE: + pNewWindow = VclPtr::Create( pParent, nWinBits ); + *ppNewComp = new VCLXImageControl; + break; + case WindowType::FIXEDLINE: + pNewWindow = VclPtr::Create( pParent, nWinBits ); + break; + case WindowType::FIXEDTEXT: + pNewWindow = VclPtr::Create( pParent, nWinBits ); + *ppNewComp = new VCLXFixedText; + break; + case WindowType::FLOATINGWINDOW: + pNewWindow = VclPtr::Create( pParent, nWinBits ); + break; + case WindowType::GROUPBOX: + pNewWindow = VclPtr::Create( pParent, nWinBits ); + if ( bFrameControl ) + { + GroupBox* pGroupBox = static_cast< GroupBox* >( pNewWindow.get() ); + *ppNewComp = new VCLXFrame; + // Frame control needs to receive + // Mouse events + pGroupBox->SetMouseTransparent( false ); + } + break; + case WindowType::HELPBUTTON: + pNewWindow = VclPtr::Create( pParent, nWinBits ); + *ppNewComp = new VCLXButton; + break; + case WindowType::IMAGEBUTTON: + pNewWindow = VclPtr::Create( pParent, nWinBits ); + *ppNewComp = new VCLXButton; + break; + case WindowType::INFOBOX: + pNewWindow = VclPtr::Create( pParent, OUString() ); + *ppNewComp = new VCLXMessageBox; + break; + case WindowType::LISTBOX: + pNewWindow = VclPtr::Create( pParent, nWinBits|WB_SIMPLEMODE|WB_AUTOHSCROLL ); + static_cast(pNewWindow.get())->EnableAutoSize( false ); + *ppNewComp = new VCLXListBox; + break; + case WindowType::LONGCURRENCYBOX: + pNewWindow = VclPtr::Create( pParent, nWinBits ); + break; + case WindowType::MENUBUTTON: + pNewWindow = VclPtr::Create( pParent, nWinBits ); + *ppNewComp = new VCLXButton; + break; + case WindowType::MESSBOX: + pNewWindow = VclPtr::Create( pParent, nMessBoxStyle, nWinBits, OUString(), OUString() ); + *ppNewComp = new VCLXMessageBox; + break; + case WindowType::METRICBOX: + pNewWindow = VclPtr::Create( pParent, nWinBits ); + break; + case WindowType::METRICFIELD: + pNewWindow = VclPtr::Create( pParent, nWinBits ); + *ppNewComp = new VCLXMetricField; + static_cast((*ppNewComp).get())->SetFormatter( static_cast(static_cast(pNewWindow.get())) ); + break; + case WindowType::DIALOG: + case WindowType::MODELESSDIALOG: + { + // Modal/Modeless only via Show/Execute + if ( (pParent == nullptr ) && ( rDescriptor.ParentIndex == -1 ) ) + pNewWindow = VclPtr::Create( nullptr, nWinBits, Dialog::InitFlag::NoParent ); + else + pNewWindow = VclPtr::Create( pParent, nWinBits ); + // #i70217# Don't always create a new component object. It's possible that VCL has called + // GetComponentInterface( sal_True ) in the Dialog ctor itself (see Window::IsTopWindow() ) + // which creates a component object. + css::uno::Reference< css::awt::XWindowPeer > xWinPeer = pNewWindow->GetComponentInterface( false ); + if ( xWinPeer.is() ) + *ppNewComp = dynamic_cast< VCLXDialog* >( xWinPeer.get() ); + else + *ppNewComp = new VCLXDialog; + } + break; + case WindowType::MOREBUTTON: + pNewWindow = VclPtr::Create( pParent, nWinBits ); + *ppNewComp = new VCLXButton; + break; + case WindowType::MULTILISTBOX: + pNewWindow = VclPtr::Create( pParent, nWinBits ); + *ppNewComp = new VCLXListBox; + break; + case WindowType::NUMERICBOX: + pNewWindow = VclPtr::Create( pParent, nWinBits ); + break; + case WindowType::OKBUTTON: + pNewWindow = VclPtr::Create( pParent, nWinBits ); + *ppNewComp = new VCLXButton; + break; + case WindowType::PATTERNBOX: + pNewWindow = VclPtr::Create( pParent, nWinBits ); + break; + case WindowType::PATTERNFIELD: + pNewWindow = VclPtr::Create( pParent, nWinBits ); + *ppNewComp = new VCLXPatternField; + static_cast((*ppNewComp).get())->SetFormatter( static_cast(static_cast(pNewWindow.get())) ); + break; + case WindowType::PUSHBUTTON: + pNewWindow = VclPtr::Create( pParent, nWinBits ); + *ppNewComp = new VCLXButton; + break; + case WindowType::QUERYBOX: + pNewWindow = VclPtr::Create( pParent, nMessBoxStyle, nWinBits, OUString() ); + *ppNewComp = new VCLXMessageBox; + break; + case WindowType::RADIOBUTTON: + pNewWindow = VclPtr::Create(pParent, false, nWinBits); + *ppNewComp = new VCLXRadioButton; + + // by default, disable RadioCheck + // Since the VCLXRadioButton really cares for its RadioCheck settings, this is important: + // if we enable it, the VCLXRadioButton will use RadioButton::Check instead of RadioButton::SetState + // This leads to a strange behaviour if the control is newly created: when settings the initial + // state to "checked", the RadioButton::Check (called because RadioCheck=sal_True) will uncheck + // _all_other_ radio buttons in the same group. However, at this moment the grouping of the controls + // is not really valid: the controls are grouped after they have been created, but we're still in + // the creation process, so the RadioButton::Check relies on invalid grouping information. + // 07.08.2001 - #87254# - frank.schoenheit@sun.com + static_cast(pNewWindow.get())->EnableRadioCheck( false ); + break; + case WindowType::SCROLLBAR: + pNewWindow = VclPtr::Create( pParent, nWinBits ); + *ppNewComp = new VCLXScrollBar; + break; + case WindowType::SCROLLBARBOX: + pNewWindow = VclPtr::Create( pParent, nWinBits ); + break; + case WindowType::SPINBUTTON: + pNewWindow = VclPtr::Create( pParent, nWinBits ); + *ppNewComp = new ::toolkit::VCLXSpinButton; + break; + case WindowType::SPINFIELD: + pNewWindow = VclPtr::Create( pParent, nWinBits ); + *ppNewComp = new VCLXNumericField; + break; + case WindowType::SPLITTER: + pNewWindow = VclPtr::Create( pParent, nWinBits ); + break; + case WindowType::SPLITWINDOW: + pNewWindow = VclPtr::Create( pParent, nWinBits ); + break; + case WindowType::STATUSBAR: + pNewWindow = VclPtr::Create( pParent, nWinBits ); + break; + case WindowType::TOOLKIT_SYSTEMCHILDWINDOW: + pNewWindow = VclPtr::Create( pParent, nWinBits ); + *ppNewComp = new VCLXSystemDependentWindow(); + break; + case WindowType::TABCONTROL: + pNewWindow = VclPtr::Create( pParent, nWinBits ); + *ppNewComp = new VCLXMultiPage; + break; + case WindowType::TABDIALOG: + pNewWindow = VclPtr::Create( pParent, nWinBits ); + break; + case WindowType::TABPAGE: + { + pNewWindow = VclPtr::Create( pParent, nWinBits ); + *ppNewComp = new VCLXTabPage; + } + break; + case WindowType::TIMEBOX: + pNewWindow = VclPtr::Create( pParent, nWinBits ); + break; + case WindowType::TIMEFIELD: + pNewWindow = VclPtr::Create( pParent, nWinBits ); + static_cast(pNewWindow.get())->EnableEmptyFieldValue( true ); + *ppNewComp = new VCLXTimeField; + static_cast((*ppNewComp).get())->SetFormatter( static_cast(static_cast(pNewWindow.get())) ); + break; + case WindowType::TOOLBOX: + pNewWindow = VclPtr::Create( pParent, nWinBits ); + *ppNewComp = new VCLXToolBox; + break; + case WindowType::TRISTATEBOX: + pNewWindow = VclPtr::Create( pParent, nWinBits ); + static_cast(pNewWindow.get())->EnableTriState(true); + break; + case WindowType::WARNINGBOX: + pNewWindow = VclPtr::Create( pParent, nMessBoxStyle, nWinBits, OUString() ); + *ppNewComp = new VCLXMessageBox; + break; + case WindowType::WORKWINDOW: + case WindowType::WINDOW: + case WindowType::TOOLKIT_FRAMEWINDOW: + case WindowType::DOCKINGWINDOW: + if ( rDescriptor.Type == css::awt::WindowClass_TOP ) + { + if (nType == WindowType::DOCKINGWINDOW ) + pNewWindow = VclPtr::Create( pParent, nWinBits ); + else + { + if ((pParent == nullptr) && rDescriptor.Parent.is()) + { + // try to get a system dependent window handle + css::uno::Reference< css::awt::XSystemDependentWindowPeer > xSystemDepParent(rDescriptor.Parent, css::uno::UNO_QUERY); + + if (xSystemDepParent.is()) + { + sal_Int8 processID[16]; + + rtl_getGlobalProcessId( reinterpret_cast(processID) ); + + // coverity[overrun-buffer-arg : FALSE] - coverity has difficulty with css::uno::Sequence + css::uno::Sequence processIdSeq(processID, 16); + + css::uno::Any anyHandle = xSystemDepParent->getWindowHandle(processIdSeq, SYSTEM_DEPENDENT_TYPE); + + // use sal_Int64 here to accommodate all int types + // uno::Any shift operator will upcast if necessary + sal_Int64 nWindowHandle = 0; + bool bXEmbed = false; + + bool bUseParentData = true; + if( ! (anyHandle >>= nWindowHandle) ) + { + css::uno::Sequence< css::beans::NamedValue > aProps; + if( anyHandle >>= aProps ) + { + for( const css::beans::NamedValue& rProp : std::as_const(aProps) ) + { + if ( rProp.Name == "WINDOW" ) + rProp.Value >>= nWindowHandle; + else if ( rProp.Name == "XEMBED" ) + rProp.Value >>= bXEmbed; + } + } + else + bUseParentData = false; + } + + if( bUseParentData ) + { + SystemParentData aParentData; + aParentData.nSize = sizeof( aParentData ); + #if defined MACOSX + aParentData.pView = reinterpret_cast(nWindowHandle); + #elif defined ANDROID + // Nothing + #elif defined IOS + // Nothing + #elif defined UNX + aParentData.aWindow = nWindowHandle; + aParentData.bXEmbedSupport = bXEmbed; + #elif defined _WIN32 + aParentData.hWnd = reinterpret_cast(nWindowHandle); + #endif + pNewWindow = VclPtr::Create( &aParentData ); + } + } + } + + if (!pNewWindow) + pNewWindow = VclPtr::Create( pParent, nWinBits ); + } + + *ppNewComp = new VCLXTopWindow(); + } + else if ( rDescriptor.Type == css::awt::WindowClass_CONTAINER ) + { + if (nType == WindowType::DOCKINGWINDOW ) + pNewWindow = VclPtr::Create( pParent, nWinBits ); + else + pNewWindow = VclPtr::Create( pParent, nWinBits ); + *ppNewComp = new VCLXContainer; + } + else + { + if (nType == WindowType::DOCKINGWINDOW ) + pNewWindow = VclPtr::Create( pParent, nWinBits ); + else + pNewWindow = VclPtr::Create( pParent, nWinBits ); + *ppNewComp = new VCLXWindow; + } + break; + case WindowType::CONTROL: + if ( aServiceName == "tabpagecontainer" ) + { + // TabControl has a special case for tabs without border: they are displayed + // in a different way, so we need to ensure that this style is not set, so + // we can guarantee normal tab behavior + pNewWindow = VclPtr::Create( pParent, nWinBits & (~WB_NOBORDER)); + *ppNewComp = new VCLXTabPageContainer; + } + else if ( aServiceName == "animatedimages" ) + { + pNewWindow = VclPtr::Create( pParent, nWinBits ); + *ppNewComp = new ::toolkit::AnimatedImagesPeer; + } + else if (aServiceName == "roadmap") + { + pNewWindow = VclPtr<::vcl::ORoadmap>::Create( pParent, WB_TABSTOP ); + *ppNewComp = new SVTXRoadmap; + } + else if (aServiceName == "fixedhyperlink") + { + pNewWindow = VclPtr::Create( pParent, nWinBits ); + *ppNewComp = new VCLXFixedHyperlink; + } + else if (aServiceName == "progressbar") + { + pNewWindow = VclPtr::Create( pParent, nWinBits ); + *ppNewComp = new VCLXProgressBar; + } + else if (aServiceName == "filecontrol") + { + pNewWindow = VclPtr::Create( pParent, nWinBits ); + *ppNewComp = new VCLXFileControl; + } + else if (aServiceName == "tree") + { + rtl::Reference pPeer = new TreeControlPeer; + *ppNewComp = pPeer; + pNewWindow = pPeer->createVclControl( pParent, nWinBits ); + } + else if (aServiceName == "formattedfield") + { + pNewWindow = VclPtr::Create( pParent, nWinBits ); + *ppNewComp = new SVTXFormattedField; + } + else if (aServiceName == "numericfield") + { + pNewWindow = VclPtr::Create( pParent, nWinBits ); + *ppNewComp = new SVTXNumericField; + } + else if (aServiceName == "longcurrencyfield") + { + pNewWindow = VclPtr::Create( pParent, nWinBits ); + *ppNewComp = new SVTXCurrencyField; + } + else if (aServiceName == "datefield") + { + pNewWindow = VclPtr::Create(pParent, nWinBits); + static_cast(pNewWindow.get())->EnableToday(); + static_cast(pNewWindow.get())->EnableNone(); + static_cast(pNewWindow.get())->EnableEmptyFieldValue( true ); + rtl::Reference newComp = new SVTXDateField; + *ppNewComp = newComp; + newComp->SetFormatter( static_cast(static_cast(pNewWindow.get())) ); + } + break; + default: + OSL_ENSURE( false, "VCLXToolkit::ImplCreateWindow: unknown window type!" ); + break; + } + } + + // tdf#126717 default that formcontrols show accelerators + if (Control* pControl = dynamic_cast(pNewWindow.get())) + pControl->SetShowAccelerator(true); + return pNewWindow; +} + +#ifndef DISABLE_DYNLOADING + +extern "C" { static void thisModule() {} } + +#else + +extern "C" vcl::Window* SAL_CALL CreateWindow( rtl::Reference* ppNewComp, const css::awt::WindowDescriptor* pDescriptor, vcl::Window* pParent, WinBits nWinBits ); + +#endif + +css::uno::Reference< css::awt::XWindowPeer > VCLXToolkit::ImplCreateWindow( + const css::awt::WindowDescriptor& rDescriptor, + MessBoxStyle nForceMessBoxStyle ) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + SolarMutexGuard aSolarGuard; + + css::uno::Reference< css::awt::XWindowPeer > xRef; + + VclPtr pParent; + if ( rDescriptor.Parent.is() ) + { + VCLXWindow* pParentComponent = comphelper::getFromUnoTunnel( rDescriptor.Parent ); + + // #103939# Don't throw assertion, may be it's a system dependent window, used in ImplCreateWindow. + // DBG_ASSERT( pParentComponent, "ParentComponent not valid" ); + + if ( pParentComponent ) + pParent = pParentComponent->GetWindow(); + } + std::pair aPair = ImplGetWinBits( rDescriptor.WindowAttributes, + ImplGetComponentType( rDescriptor.WindowServiceName ) ); + WinBits nWinBits = aPair.first; + aPair.second |= nForceMessBoxStyle; + + rtl::Reference pNewComp; + + vcl::Window* pNewWindow = nullptr; + // Try to create the window with SvTools + // (do this _before_ creating it on our own: The old mechanism (extended toolkit in SvTools) did it this way, + // and we need to stay compatible) + // try to load the lib + if ( !fnSvtCreateWindow +#ifndef DISABLE_DYNLOADING + && !hSvToolsLib +#endif + ) + { +#ifndef DISABLE_DYNLOADING + OUString aLibName(SVT_DLL_NAME); + hSvToolsLib = osl_loadModuleRelative( + &thisModule, aLibName.pData, SAL_LOADMODULE_DEFAULT ); + if ( hSvToolsLib ) + { + OUString aFunctionName( "CreateWindow" ); + fnSvtCreateWindow = reinterpret_cast(osl_getFunctionSymbol( hSvToolsLib, aFunctionName.pData )); + } +#else + fnSvtCreateWindow = CreateWindow; +#endif + } + // ask the SvTool creation function + if ( fnSvtCreateWindow ) + pNewWindow = fnSvtCreateWindow( &pNewComp, &rDescriptor, pParent, nWinBits ); + + // if SvTools could not provide a window, create it ourself + if ( !pNewWindow ) + pNewWindow = ImplCreateWindow( &pNewComp, rDescriptor, pParent, nWinBits, aPair.second ); + + DBG_ASSERT( pNewWindow, "createWindow: Unknown Component!" ); + SAL_INFO_IF( !pNewComp, "toolkit", "createWindow: No special Interface!" ); + + if ( pNewWindow ) + { + pNewWindow->SetCreatedWithToolkit( true ); + //pNewWindow->SetPosPixel( Point() ); // do not force (0,0) position, keep default pos instead + + if ( rDescriptor.WindowAttributes & css::awt::WindowAttribute::MINSIZE ) + { + pNewWindow->SetSizePixel( Size() ); + } + else if ( rDescriptor.WindowAttributes & css::awt::WindowAttribute::FULLSIZE ) + { + if ( pParent ) + pNewWindow->SetSizePixel( pParent->GetOutputSizePixel() ); + } + else if ( !VCLUnoHelper::IsZero( rDescriptor.Bounds ) ) + { + tools::Rectangle aRect = VCLRectangle( rDescriptor.Bounds ); + pNewWindow->SetPosSizePixel( aRect.TopLeft(), aRect.GetSize() ); + } + + if ( !pNewComp ) + { + // Default-Interface + xRef = pNewWindow->GetComponentInterface(); + } + else + { + xRef = pNewComp; + pNewWindow->SetComponentInterface( xRef ); + } + DBG_ASSERT( pNewWindow->GetComponentInterface( false ) == xRef, + "VCLXToolkit::createWindow: did #133706# resurge?" ); + + if ( rDescriptor.WindowAttributes & css::awt::WindowAttribute::SHOW ) + pNewWindow->Show(); + } + + return xRef; +} + +css::uno::Sequence< css::uno::Reference< css::awt::XWindowPeer > > VCLXToolkit::createWindows( const css::uno::Sequence< css::awt::WindowDescriptor >& rDescriptors ) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + sal_uInt32 nComponents = rDescriptors.getLength(); + css::uno::Sequence< css::uno::Reference< css::awt::XWindowPeer > > aSeq( nComponents ); + for ( sal_uInt32 n = 0; n < nComponents; n++ ) + { + css::awt::WindowDescriptor aDescr = rDescriptors.getConstArray()[n]; + + if ( aDescr.ParentIndex == -1 ) + aDescr.Parent = nullptr; + else if ( ( aDescr.ParentIndex >= 0 ) && ( o3tl::make_unsigned(aDescr.ParentIndex) < n ) ) + aDescr.Parent = aSeq.getConstArray()[aDescr.ParentIndex]; + aSeq.getArray()[n] = createWindow( aDescr ); + } + return aSeq; +} + +// css::awt::XSystemChildFactory +css::uno::Reference< css::awt::XWindowPeer > VCLXToolkit::createSystemChild( const css::uno::Any& Parent, const css::uno::Sequence< sal_Int8 >& /*ProcessId*/, sal_Int16 nSystemType ) +{ + VclPtr pChildWindow; + if ( nSystemType == SYSTEM_DEPENDENT_TYPE ) + { + // use sal_Int64 here to accommodate all int types + // uno::Any shift operator will upcast if necessary + sal_Int64 nWindowHandle = 0; + bool bXEmbed = false; + + bool bUseParentData = true; + if( ! (Parent >>= nWindowHandle) ) + { + css::uno::Sequence< css::beans::NamedValue > aProps; + if( Parent >>= aProps ) + { + for( const css::beans::NamedValue& rProp : std::as_const(aProps) ) + { + if ( rProp.Name == "WINDOW" ) + rProp.Value >>= nWindowHandle; + else if ( rProp.Name == "XEMBED" ) + rProp.Value >>= bXEmbed; + } + } + else + bUseParentData = false; + } + + if( bUseParentData ) + { + SystemParentData aParentData; + aParentData.nSize = sizeof( aParentData ); + #if defined MACOSX + aParentData.pView = reinterpret_cast(nWindowHandle); + #elif defined ANDROID + // Nothing + #elif defined IOS + // Nothing + #elif defined UNX + aParentData.aWindow = nWindowHandle; + aParentData.bXEmbedSupport = bXEmbed; + #elif defined _WIN32 + aParentData.hWnd = reinterpret_cast(nWindowHandle); + #endif + SolarMutexGuard aGuard; + try + { + pChildWindow.reset( VclPtr::Create( &aParentData ) ); + } + catch ( const css::uno::RuntimeException & ) + { + // system child window could not be created + DBG_UNHANDLED_EXCEPTION("toolkit"); + pChildWindow.clear(); + } + } + } + else if (nSystemType == css::lang::SystemDependent::SYSTEM_JAVA) + { + SolarMutexGuard aGuard; + pChildWindow.reset(VclPtr::Create(nullptr, Parent)); + } + + css::uno::Reference< css::awt::XWindowPeer > xPeer; + if ( pChildWindow ) + { + rtl::Reference pPeer = new VCLXTopWindow; + SolarMutexGuard aGuard; + pPeer->SetWindow( pChildWindow ); + xPeer = pPeer; + pChildWindow->SetWindowPeer(xPeer, pPeer.get()); + } + + return xPeer; +} + +// css::awt::XMessageBoxFactory +css::uno::Reference< css::awt::XMessageBox > SAL_CALL VCLXToolkit::createMessageBox( + const css::uno::Reference< css::awt::XWindowPeer >& aParent, + css::awt::MessageBoxType eType, + ::sal_Int32 aButtons, + const OUString& aTitle, + const OUString& aMessage ) +{ + css::awt::WindowDescriptor aDescriptor; + + sal_Int32 nWindowAttributes = css::awt::WindowAttribute::BORDER|css::awt::WindowAttribute::MOVEABLE|css::awt::WindowAttribute::CLOSEABLE; + + // Map button definitions to window attributes + if (( aButtons & 0x0000ffffL ) == css::awt::MessageBoxButtons::BUTTONS_OK ) + nWindowAttributes |= css::awt::VclWindowPeerAttribute::OK; + else if (( aButtons & 0x0000ffffL ) == css::awt::MessageBoxButtons::BUTTONS_OK_CANCEL ) + nWindowAttributes |= css::awt::VclWindowPeerAttribute::OK_CANCEL; + else if (( aButtons & 0x0000ffffL ) == css::awt::MessageBoxButtons::BUTTONS_YES_NO ) + nWindowAttributes |= css::awt::VclWindowPeerAttribute::YES_NO; + else if (( aButtons & 0x0000ffffL ) == css::awt::MessageBoxButtons::BUTTONS_YES_NO_CANCEL ) + nWindowAttributes |= css::awt::VclWindowPeerAttribute::YES_NO_CANCEL; + else if (( aButtons & 0x0000ffffL ) == css::awt::MessageBoxButtons::BUTTONS_RETRY_CANCEL ) + nWindowAttributes |= css::awt::VclWindowPeerAttribute::RETRY_CANCEL; + + // Map default button definitions to window attributes + if (sal_Int32( aButtons & 0xffff0000L ) == css::awt::MessageBoxButtons::DEFAULT_BUTTON_OK ) + nWindowAttributes |= css::awt::VclWindowPeerAttribute::DEF_OK; + else if (sal_Int32( aButtons & 0xffff0000L ) == css::awt::MessageBoxButtons::DEFAULT_BUTTON_CANCEL ) + nWindowAttributes |= css::awt::VclWindowPeerAttribute::DEF_CANCEL; + else if (sal_Int32( aButtons & 0xffff0000L ) == css::awt::MessageBoxButtons::DEFAULT_BUTTON_YES ) + nWindowAttributes |= css::awt::VclWindowPeerAttribute::DEF_YES; + else if (sal_Int32( aButtons & 0xffff0000L ) == css::awt::MessageBoxButtons::DEFAULT_BUTTON_NO ) + nWindowAttributes |= css::awt::VclWindowPeerAttribute::DEF_NO; + else if (sal_Int32( aButtons & 0xffff0000L ) == css::awt::MessageBoxButtons::DEFAULT_BUTTON_RETRY ) + nWindowAttributes |= css::awt::VclWindowPeerAttribute::DEF_RETRY; + + // No more bits for VclWindowPeerAttribute possible. Mapping must be + // done explicitly using VCL methods + MessBoxStyle nAddWinBits = MessBoxStyle::NONE; + if (( aButtons & 0x0000ffffL ) == css::awt::MessageBoxButtons::BUTTONS_ABORT_IGNORE_RETRY ) + nAddWinBits |= MessBoxStyle::AbortRetryIgnore; + if ( sal_Int32( aButtons & 0xffff0000L ) == css::awt::MessageBoxButtons::DEFAULT_BUTTON_IGNORE ) + nAddWinBits |= MessBoxStyle::DefaultIgnore; + + OUString aType; + lcl_convertMessageBoxType( aType, eType ); + + aDescriptor.Type = css::awt::WindowClass_MODALTOP; + aDescriptor.WindowServiceName = aType; + aDescriptor.ParentIndex = -1; + aDescriptor.Parent = aParent; + aDescriptor.WindowAttributes = nWindowAttributes; + css::uno::Reference< css::awt::XMessageBox > xMsgBox( + ImplCreateWindow( aDescriptor, nAddWinBits ), css::uno::UNO_QUERY ); + css::uno::Reference< css::awt::XWindow > xWindow( xMsgBox, css::uno::UNO_QUERY ); + if ( xMsgBox.is() && xWindow.is() ) + { + VclPtr pWindow = VCLUnoHelper::GetWindow( xWindow ); + if ( pWindow ) + { + SolarMutexGuard aGuard; + xMsgBox->setCaptionText( aTitle ); + xMsgBox->setMessageText( aMessage ); + } + } + + return xMsgBox; +} + +css::uno::Reference< css::datatransfer::dnd::XDragGestureRecognizer > SAL_CALL VCLXToolkit::getDragGestureRecognizer( const css::uno::Reference< css::awt::XWindow >& window ) +{ + SolarMutexGuard g; + + VclPtr pWindow = VCLUnoHelper::GetWindow( window ); + + if( pWindow ) + return pWindow->GetDragGestureRecognizer(); + + return css::uno::Reference< css::datatransfer::dnd::XDragGestureRecognizer >(); +} + +css::uno::Reference< css::datatransfer::dnd::XDragSource > SAL_CALL VCLXToolkit::getDragSource( const css::uno::Reference< css::awt::XWindow >& window ) +{ + SolarMutexGuard g; + + VclPtr pWindow = VCLUnoHelper::GetWindow( window ); + + if( pWindow ) + return pWindow->GetDragSource(); + + return css::uno::Reference< css::datatransfer::dnd::XDragSource >(); +} + +css::uno::Reference< css::datatransfer::dnd::XDropTarget > SAL_CALL VCLXToolkit::getDropTarget( const css::uno::Reference< css::awt::XWindow >& window ) +{ + SolarMutexGuard g; + + VclPtr pWindow = VCLUnoHelper::GetWindow( window ); + + if( pWindow ) + return pWindow->GetDropTarget(); + + return css::uno::Reference< css::datatransfer::dnd::XDropTarget >(); +} + +css::uno::Reference< css::datatransfer::clipboard::XClipboard > SAL_CALL VCLXToolkit::getClipboard( const OUString& clipboardName ) +{ + if( clipboardName.isEmpty() ) + { + if( !mxClipboard.is() ) + { + // remember clipboard here + mxClipboard = css::datatransfer::clipboard::SystemClipboard::create( + comphelper::getProcessComponentContext()); + } + + return mxClipboard; + } + + else if( clipboardName == "Selection" ) + { + return mxSelection; + } + + return css::uno::Reference< css::datatransfer::clipboard::XClipboard >(); +} + +// XServiceInfo +OUString VCLXToolkit::getImplementationName() +{ + return "stardiv.Toolkit.VCLXToolkit"; +} + +sal_Bool VCLXToolkit::supportsService( const OUString& rServiceName ) +{ + return cppu::supportsService(this, rServiceName); +} + +css::uno::Sequence< OUString > VCLXToolkit::getSupportedServiceNames() +{ + return css::uno::Sequence{ + "com.sun.star.awt.Toolkit", "stardiv.vcl.VclToolkit"}; +} + +// css::awt::XExtendedToolkit: + +// virtual +::sal_Int32 SAL_CALL VCLXToolkit::getTopWindowCount() +{ + return static_cast< ::sal_Int32 >(::Application::GetTopWindowCount()); + // XXX numeric overflow +} + +// virtual +css::uno::Reference< css::awt::XTopWindow > SAL_CALL +VCLXToolkit::getTopWindow(::sal_Int32 nIndex) +{ + vcl::Window * p = ::Application::GetTopWindow(static_cast< tools::Long >(nIndex)); + // XXX numeric overflow + return css::uno::Reference< css::awt::XTopWindow >( + p == nullptr ? nullptr : static_cast< css::awt::XWindow * >(p->GetWindowPeer()), + css::uno::UNO_QUERY); +} + +// virtual +css::uno::Reference< css::awt::XTopWindow > SAL_CALL +VCLXToolkit::getActiveTopWindow() +{ + vcl::Window * p = ::Application::GetActiveTopWindow(); + return css::uno::Reference< css::awt::XTopWindow >( + p == nullptr ? nullptr : static_cast< css::awt::XWindow * >(p->GetWindowPeer()), + css::uno::UNO_QUERY); +} + +// virtual +void SAL_CALL VCLXToolkit::addTopWindowListener( + css::uno::Reference< css::awt::XTopWindowListener > const & rListener) +{ + OSL_ENSURE(rListener.is(), "Null rListener"); + ::osl::ClearableMutexGuard aGuard(rBHelper.rMutex); + if (rBHelper.bDisposed || rBHelper.bInDispose) + { + aGuard.clear(); + rListener->disposing( + css::lang::EventObject( + static_cast< ::cppu::OWeakObject * >(this))); + } + else if (m_aTopWindowListeners.addInterface(rListener) == 1 + && !m_bEventListener) + { + m_bEventListener = true; + ::Application::AddEventListener(m_aEventListenerLink); + } +} + +// virtual +void SAL_CALL VCLXToolkit::removeTopWindowListener( + css::uno::Reference< css::awt::XTopWindowListener > const & rListener) +{ + ::osl::MutexGuard aGuard(rBHelper.rMutex); + if (!(rBHelper.bDisposed || rBHelper.bInDispose) + && m_aTopWindowListeners.removeInterface(rListener) == 0 + && m_aFocusListeners.getLength() == 0 && m_bEventListener) + { + ::Application::RemoveEventListener(m_aEventListenerLink); + m_bEventListener = false; + } +} + +// virtual +void SAL_CALL VCLXToolkit::addKeyHandler( + css::uno::Reference< css::awt::XKeyHandler > const & rHandler) +{ + OSL_ENSURE(rHandler.is(), "Null rHandler"); + ::osl::ClearableMutexGuard aGuard(rBHelper.rMutex); + if (rBHelper.bDisposed || rBHelper.bInDispose) + { + aGuard.clear(); + rHandler->disposing( + css::lang::EventObject( + static_cast< ::cppu::OWeakObject * >(this))); + } + else if (m_aKeyHandlers.addInterface(rHandler) == 1 && !m_bKeyListener) + { + m_bKeyListener = true; + ::Application::AddKeyListener(m_aKeyListenerLink); + } +} + +// virtual +void SAL_CALL VCLXToolkit::removeKeyHandler( + css::uno::Reference< css::awt::XKeyHandler > const & rHandler) +{ + ::osl::MutexGuard aGuard(rBHelper.rMutex); + if (!(rBHelper.bDisposed || rBHelper.bInDispose) + && m_aKeyHandlers.removeInterface(rHandler) == 0 && m_bKeyListener) + { + ::Application::RemoveKeyListener(m_aKeyListenerLink); + m_bKeyListener = false; + } +} + +// virtual +void SAL_CALL VCLXToolkit::addFocusListener( + css::uno::Reference< css::awt::XFocusListener > const & rListener) +{ + OSL_ENSURE(rListener.is(), "Null rListener"); + ::osl::ClearableMutexGuard aGuard(rBHelper.rMutex); + if (rBHelper.bDisposed || rBHelper.bInDispose) + { + aGuard.clear(); + rListener->disposing( + css::lang::EventObject( + static_cast< ::cppu::OWeakObject * >(this))); + } + else if (m_aFocusListeners.addInterface(rListener) == 1 + && !m_bEventListener) + { + m_bEventListener = true; + ::Application::AddEventListener(m_aEventListenerLink); + } +} + +// virtual +void SAL_CALL VCLXToolkit::removeFocusListener( + css::uno::Reference< css::awt::XFocusListener > const & rListener) +{ + ::osl::MutexGuard aGuard(rBHelper.rMutex); + if (!(rBHelper.bDisposed || rBHelper.bInDispose) + && m_aFocusListeners.removeInterface(rListener) == 0 + && m_aTopWindowListeners.getLength() == 0 && m_bEventListener) + { + ::Application::RemoveEventListener(m_aEventListenerLink); + m_bEventListener = false; + } +} + +// virtual +void SAL_CALL VCLXToolkit::fireFocusGained( + css::uno::Reference< + css::uno::XInterface > const &) +{ +} + +// virtual +void SAL_CALL VCLXToolkit::fireFocusLost( + css::uno::Reference< + css::uno::XInterface > const &) +{ +} + + +IMPL_LINK(VCLXToolkit, eventListenerHandler, ::VclSimpleEvent&, rEvent, void) +{ + switch (rEvent.GetId()) + { + case VclEventId::WindowShow: + callTopWindowListeners( + &rEvent, &css::awt::XTopWindowListener::windowOpened); + break; + case VclEventId::WindowHide: + callTopWindowListeners( + &rEvent, &css::awt::XTopWindowListener::windowClosed); + break; + case VclEventId::WindowActivate: + callTopWindowListeners( + &rEvent, &css::awt::XTopWindowListener::windowActivated); + break; + case VclEventId::WindowDeactivate: + callTopWindowListeners( + &rEvent, &css::awt::XTopWindowListener::windowDeactivated); + break; + case VclEventId::WindowClose: + callTopWindowListeners( + &rEvent, &css::awt::XTopWindowListener::windowClosing); + break; + case VclEventId::WindowGetFocus: + callFocusListeners(&rEvent, true); + break; + case VclEventId::WindowLoseFocus: + callFocusListeners(&rEvent, false); + break; + case VclEventId::WindowMinimize: + callTopWindowListeners( + &rEvent, &css::awt::XTopWindowListener::windowMinimized); + break; + case VclEventId::WindowNormalize: + callTopWindowListeners( + &rEvent, &css::awt::XTopWindowListener::windowNormalized); + break; + default: break; + } +} + +IMPL_LINK(VCLXToolkit, keyListenerHandler, ::VclWindowEvent&, rEvent, bool) +{ + switch (rEvent.GetId()) + { + case VclEventId::WindowKeyInput: + return callKeyHandlers(&rEvent, true); + case VclEventId::WindowKeyUp: + return callKeyHandlers(&rEvent, false); + default: break; + } + return false; +} + +void VCLXToolkit::callTopWindowListeners( + ::VclSimpleEvent const * pEvent, + void (SAL_CALL css::awt::XTopWindowListener::* pFn)( + css::lang::EventObject const &)) +{ + vcl::Window * pWindow + = static_cast< ::VclWindowEvent const * >(pEvent)->GetWindow(); + if (!pWindow->IsTopWindow()) + return; + + std::vector< css::uno::Reference< css::awt::XTopWindowListener > > + aListeners(m_aTopWindowListeners.getElements()); + if (aListeners.empty()) + return; + + css::lang::EventObject aAwtEvent( + static_cast< css::awt::XWindow * >(pWindow->GetWindowPeer())); + for (const css::uno::Reference & xListener : aListeners) + { + try + { + (xListener.get()->*pFn)(aAwtEvent); + } + catch (const css::uno::RuntimeException &) + { + DBG_UNHANDLED_EXCEPTION("toolkit"); + } + } +} + +bool VCLXToolkit::callKeyHandlers(::VclSimpleEvent const * pEvent, + bool bPressed) +{ + std::vector< css::uno::Reference< css::awt::XKeyHandler > > + aHandlers(m_aKeyHandlers.getElements()); + + if (!aHandlers.empty()) + { + vcl::Window * pWindow = static_cast< ::VclWindowEvent const * >(pEvent)->GetWindow(); + + // See implementation in vclxwindow.cxx for mapping between VCL and UNO AWT event + ::KeyEvent * pKeyEvent = static_cast< ::KeyEvent * >( + static_cast< ::VclWindowEvent const * >(pEvent)->GetData()); + css::awt::KeyEvent aAwtEvent( + static_cast< css::awt::XWindow * >(pWindow->GetWindowPeer()), + (pKeyEvent->GetKeyCode().IsShift() + ? css::awt::KeyModifier::SHIFT : 0) + | (pKeyEvent->GetKeyCode().IsMod1() + ? css::awt::KeyModifier::MOD1 : 0) + | (pKeyEvent->GetKeyCode().IsMod2() + ? css::awt::KeyModifier::MOD2 : 0) + | (pKeyEvent->GetKeyCode().IsMod3() + ? css::awt::KeyModifier::MOD3 : 0), + pKeyEvent->GetKeyCode().GetCode(), pKeyEvent->GetCharCode(), + sal::static_int_cast< sal_Int16 >( + pKeyEvent->GetKeyCode().GetFunction())); + for (const css::uno::Reference & xHandler : aHandlers) + { + try + { + if (bPressed ? xHandler->keyPressed(aAwtEvent) + : xHandler->keyReleased(aAwtEvent)) + return true; + } + catch (const css::uno::RuntimeException &) + { + DBG_UNHANDLED_EXCEPTION("toolkit"); + } + } + } + return false; +} + +void VCLXToolkit::callFocusListeners(::VclSimpleEvent const * pEvent, + bool bGained) +{ + vcl::Window * pWindow + = static_cast< ::VclWindowEvent const * >(pEvent)->GetWindow(); + if (!pWindow->IsTopWindow()) + return; + + std::vector< css::uno::Reference< css::awt::XFocusListener > > + aListeners(m_aFocusListeners.getElements()); + if (aListeners.empty()) + return; + + // Ignore the interior of compound controls when determining the + // window that gets the focus next (see implementation in + // vclxwindow.cxx for mapping between VCL and UNO AWT event): + css::uno::Reference< css::uno::XInterface > xNext; + vcl::Window * pFocus = ::Application::GetFocusWindow(); + for (vcl::Window * p = pFocus; p != nullptr; p = p->GetParent()) + if (!p->IsCompoundControl()) + { + pFocus = p; + break; + } + if (pFocus != nullptr) + xNext = pFocus->GetComponentInterface(); + css::awt::FocusEvent aAwtEvent( + static_cast< css::awt::XWindow * >(pWindow->GetWindowPeer()), + static_cast(pWindow->GetGetFocusFlags()), + xNext, false); + for (const css::uno::Reference & xListener : aListeners) + { + try + { + bGained ? xListener->focusGained(aAwtEvent) + : xListener->focusLost(aAwtEvent); + } + catch (const css::uno::RuntimeException &) + { + DBG_UNHANDLED_EXCEPTION("toolkit"); + } + } +} + +// css::awt::XReschedule: + +void SAL_CALL VCLXToolkit::reschedule() +{ + SolarMutexGuard aSolarGuard; + Application::Reschedule(true); +} + +// css::awt::XFontMappingUse: +void SAL_CALL VCLXToolkit::startTrackingFontMappingUse() +{ + SolarMutexGuard aSolarGuard; + OutputDevice::StartTrackingFontMappingUse(); +} + +css::uno::Sequence +SAL_CALL VCLXToolkit::finishTrackingFontMappingUse() +{ + SolarMutexGuard aSolarGuard; + OutputDevice::FontMappingUseData data = OutputDevice::FinishTrackingFontMappingUse(); + css::uno::Sequence ret( data.size()); + css::awt::XFontMappingUseItem* retData = ret.getArray(); + for( size_t i = 0; i < data.size(); ++i ) + { + retData[ i ].originalFont = data[ i ].mOriginalFont; + retData[ i ].usedFonts = comphelper::arrayToSequence + (data[ i ].mUsedFonts.data(), data[ i ].mUsedFonts.size()); + retData[ i ].count = data[ i ].mCount; + } + return ret; +} + +// css::awt::XToolkitExperimental + +void SAL_CALL VCLXToolkit::processEventsToIdle() +{ + SolarMutexGuard aSolarGuard; + comphelper::ProfileZone aZone("processEvents"); + Scheduler::ProcessEventsToIdle(); +} + +sal_Int64 SAL_CALL VCLXToolkit::getOpenGLBufferSwapCounter() +{ +#if HAVE_FEATURE_OPENGL + return OpenGLWrapper::getBufferSwapCounter(); +#else + return 0; +#endif +} + +void SAL_CALL VCLXToolkit::setDeterministicScheduling(sal_Bool bDeterministicMode) +{ + SolarMutexGuard aSolarGuard; + Scheduler::SetDeterministicMode(bDeterministicMode); +} + +void SAL_CALL VCLXToolkit::pause(sal_Int32 nMilliseconds) +{ + new Pause(nMilliseconds); +} + +void SAL_CALL VCLXToolkit::startRecording() +{ + comphelper::TraceEvent::startRecording(); +} + +void SAL_CALL VCLXToolkit::stopRecording() +{ + comphelper::TraceEvent::stopRecording(); +} + +css::uno::Sequence< OUString > VCLXToolkit::getRecordingAndClear() +{ + return comphelper::ProfileZone::getRecordingAndClear(); +} + +// css:awt:XToolkitRobot + +void SAL_CALL VCLXToolkit::keyPress( const css::awt::KeyEvent & aKeyEvent ) +{ + css::uno::Reference xWindow ( aKeyEvent.Source, css::uno::UNO_QUERY_THROW ); + VclPtr pWindow = VCLUnoHelper::GetWindow( xWindow ); + if( !pWindow ) + throw css::uno::RuntimeException( "invalid event source" ); + + ::KeyEvent aVCLKeyEvent = VCLUnoHelper::createVCLKeyEvent( aKeyEvent ); + ::Application::PostKeyEvent( VclEventId::WindowKeyInput, pWindow, &aVCLKeyEvent ); +} + +void SAL_CALL VCLXToolkit::keyRelease( const css::awt::KeyEvent & aKeyEvent ) +{ + css::uno::Reference xWindow ( aKeyEvent.Source, css::uno::UNO_QUERY_THROW ); + VclPtr pWindow = VCLUnoHelper::GetWindow( xWindow ); + if( !pWindow ) + throw css::uno::RuntimeException( "invalid event source" ); + + ::KeyEvent aVCLKeyEvent = VCLUnoHelper::createVCLKeyEvent( aKeyEvent ); + ::Application::PostKeyEvent( VclEventId::WindowKeyUp, pWindow, &aVCLKeyEvent ); +} + + +void SAL_CALL VCLXToolkit::mousePress( const css::awt::MouseEvent & aMouseEvent ) +{ + css::uno::Reference xWindow ( aMouseEvent.Source, css::uno::UNO_QUERY_THROW ); + VclPtr pWindow = VCLUnoHelper::GetWindow( xWindow ); + if( !pWindow ) + throw css::uno::RuntimeException( "invalid event source" ); + + ::MouseEvent aVCLMouseEvent = VCLUnoHelper::createVCLMouseEvent( aMouseEvent ); + ::Application::PostMouseEvent( VclEventId::WindowMouseButtonDown, pWindow, &aVCLMouseEvent ); +} + +void SAL_CALL VCLXToolkit::mouseRelease( const css::awt::MouseEvent & aMouseEvent ) +{ + css::uno::Reference xWindow ( aMouseEvent.Source, css::uno::UNO_QUERY_THROW ); + VclPtr pWindow = VCLUnoHelper::GetWindow( xWindow ); + if( !pWindow ) + throw css::uno::RuntimeException( "invalid event source" ); + + ::MouseEvent aVCLMouseEvent = VCLUnoHelper::createVCLMouseEvent( aMouseEvent ); + ::Application::PostMouseEvent( VclEventId::WindowMouseButtonUp, pWindow, &aVCLMouseEvent ); +} + +void SAL_CALL VCLXToolkit::mouseMove( const css::awt::MouseEvent & aMouseEvent ) +{ + css::uno::Reference xWindow ( aMouseEvent.Source, css::uno::UNO_QUERY_THROW ); + VclPtr pWindow = VCLUnoHelper::GetWindow( xWindow ); + if( !pWindow ) + throw css::uno::RuntimeException( "invalid event source" ); + + ::MouseEvent aVCLMouseEvent = VCLUnoHelper::createVCLMouseEvent( aMouseEvent ); + ::Application::PostMouseEvent( VclEventId::WindowMouseMove, pWindow, &aVCLMouseEvent ); +} + + +} + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * +stardiv_Toolkit_VCLXToolkit_get_implementation( + css::uno::XComponentContext *, + css::uno::Sequence const &) +{ + return cppu::acquire(new VCLXToolkit()); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/source/awt/vclxtopwindow.cxx b/toolkit/source/awt/vclxtopwindow.cxx new file mode 100644 index 000000000..db42fa802 --- /dev/null +++ b/toolkit/source/awt/vclxtopwindow.cxx @@ -0,0 +1,254 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include + +#include +#include +#include + +#if defined ( MACOSX ) +#include +#include +#include +#endif + +#include +#include +#include + +#include +#include + +#include +#include +#include +#include + +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::uno::Type; +using ::com::sun::star::uno::Any; +using ::com::sun::star::lang::IndexOutOfBoundsException; + + +css::uno::Any VCLXTopWindow::getWindowHandle( const css::uno::Sequence< sal_Int8 >& /*ProcessId*/, sal_Int16 SystemType ) +{ + SolarMutexGuard aGuard; + + // TODO, check the process id + css::uno::Any aRet; + vcl::Window* pWindow = VCLXContainer::GetWindow(); + if ( pWindow ) + { + const SystemEnvData* pSysData = static_cast(pWindow)->GetSystemData(); + if( pSysData ) + { +#if defined (_WIN32) + if( SystemType == css::lang::SystemDependent::SYSTEM_WIN32 ) + { + aRet <<= reinterpret_cast(pSysData->hWnd); + } +#elif defined(MACOSX) + if( SystemType == css::lang::SystemDependent::SYSTEM_MAC ) + { + aRet <<= reinterpret_cast(pSysData->mpNSView); + } +#elif defined(ANDROID) + // Nothing + (void) SystemType; +#elif defined(IOS) + // Nothing + (void) SystemType; +#elif defined(UNX) + if( SystemType == css::lang::SystemDependent::SYSTEM_XWINDOW ) + { + css::awt::SystemDependentXWindow aSD; + aSD.DisplayPointer = sal::static_int_cast< sal_Int64 >(reinterpret_cast< sal_IntPtr >(pSysData->pDisplay)); + aSD.WindowHandle = pSysData->GetWindowHandle(pWindow->ImplGetFrame()); + aRet <<= aSD; + } +#endif + } + } + return aRet; +} + +void VCLXTopWindow::addTopWindowListener( const css::uno::Reference< css::awt::XTopWindowListener >& rxListener ) +{ + SolarMutexGuard aGuard; + + if (!IsDisposed()) + GetTopWindowListeners().addInterface( rxListener ); +} + +void VCLXTopWindow::removeTopWindowListener( const css::uno::Reference< css::awt::XTopWindowListener >& rxListener ) +{ + SolarMutexGuard aGuard; + + if (!IsDisposed()) + GetTopWindowListeners().removeInterface( rxListener ); +} + +void VCLXTopWindow::toFront( ) +{ + SolarMutexGuard aGuard; + + vcl::Window* pWindow = VCLXContainer::GetWindow(); + if (pWindow) + pWindow->ToTop( ToTopFlags::RestoreWhenMin ); +} + +void VCLXTopWindow::toBack( ) +{ +} + +void VCLXTopWindow::setMenuBar( const css::uno::Reference< css::awt::XMenuBar >& rxMenu ) +{ + SolarMutexGuard aGuard; + + vcl::Window* pWindow = VCLXContainer::GetWindow(); + if ( pWindow ) + { + SystemWindow* pSystemWindow = static_cast( pWindow ); + pSystemWindow->SetMenuBar( nullptr ); + if ( rxMenu.is() ) + { + VCLXMenu* pMenu = comphelper::getFromUnoTunnel( rxMenu ); + if ( pMenu && !pMenu->IsPopupMenu() ) + pSystemWindow->SetMenuBar( static_cast( pMenu->GetMenu() )); + } + } +} + + +sal_Bool SAL_CALL VCLXTopWindow::getIsMaximized() +{ + SolarMutexGuard aGuard; + + const WorkWindow* pWindow = VCLXContainer::GetAsDynamic(); + if ( !pWindow ) + return false; + + return pWindow->IsMaximized(); +} + + +void SAL_CALL VCLXTopWindow::setIsMaximized( sal_Bool _ismaximized ) +{ + SolarMutexGuard aGuard; + + WorkWindow* pWindow = VCLXContainer::GetAsDynamic(); + if ( !pWindow ) + return; + + pWindow->Maximize( _ismaximized ); +} + + +sal_Bool SAL_CALL VCLXTopWindow::getIsMinimized() +{ + SolarMutexGuard aGuard; + + const WorkWindow* pWindow = VCLXContainer::GetAsDynamic(); + if ( !pWindow ) + return false; + + return pWindow->IsMinimized(); +} + + +void SAL_CALL VCLXTopWindow::setIsMinimized( sal_Bool _isMinimized ) +{ + SolarMutexGuard aGuard; + + WorkWindow* pWindow = VCLXContainer::GetAsDynamic(); + if ( !pWindow ) + return; + + _isMinimized ? pWindow->Minimize() : pWindow->Restore(); +} + + +::sal_Int32 SAL_CALL VCLXTopWindow::getDisplay() +{ + SolarMutexGuard aGuard; + + const SystemWindow* pWindow = VCLXContainer::GetAsDynamic(); + if ( !pWindow ) + return 0; + + return pWindow->GetScreenNumber(); +} + + +void SAL_CALL VCLXTopWindow::setDisplay( ::sal_Int32 _display ) +{ + SolarMutexGuard aGuard; + + if ( ( _display < 0 ) || ( o3tl::make_unsigned(_display) >= Application::GetScreenCount() ) ) + throw IndexOutOfBoundsException(); + + SystemWindow* pWindow = VCLXContainer::GetAsDynamic(); + if ( !pWindow ) + return; + + pWindow->SetScreenNumber( _display ); +} + + + + +void VCLXTopWindow::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds ) +{ + VCLXContainer::ImplGetPropertyIds( rIds ); +} + +VCLXTopWindow::VCLXTopWindow() +{ +} + +VCLXTopWindow::~VCLXTopWindow() +{ +} + +// css::uno::XInterface +css::uno::Any VCLXTopWindow::queryInterface( const css::uno::Type & rType ) +{ + css::uno::Any aRet( VCLXTopWindow_XBase::queryInterface( rType ) ); + + if (!aRet.hasValue()) + aRet = VCLXTopWindow_XBase::queryInterface( rType ); + if ( !aRet.hasValue() ) + aRet = VCLXContainer::queryInterface( rType ); + + return aRet; +} + +css::uno::Sequence< sal_Int8 > VCLXTopWindow::getImplementationId() +{ + return css::uno::Sequence(); +} + +css::uno::Sequence< css::uno::Type > VCLXTopWindow::getTypes() +{ + return ::comphelper::concatSequences( VCLXTopWindow_XBase::getTypes(), VCLXContainer::getTypes() ); +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/source/awt/vclxwindow.cxx b/toolkit/source/awt/vclxwindow.cxx new file mode 100644 index 000000000..d3252dd7a --- /dev/null +++ b/toolkit/source/awt/vclxwindow.cxx @@ -0,0 +1,2557 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + + +#include +#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 "stylesettings.hxx" +#include + +#include +#include + +using namespace ::com::sun::star; + +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::UNO_QUERY; +using ::com::sun::star::lang::EventObject; +using ::com::sun::star::awt::XWindowListener2; +using ::com::sun::star::awt::XDockableWindowListener; +using ::com::sun::star::awt::XDevice; +using ::com::sun::star::awt::XStyleSettings; +using ::com::sun::star::lang::DisposedException; +using ::com::sun::star::style::VerticalAlignment; +using ::com::sun::star::style::VerticalAlignment_TOP; +using ::com::sun::star::style::VerticalAlignment_MIDDLE; +using ::com::sun::star::style::VerticalAlignment_BOTTOM; + +namespace WritingMode2 = ::com::sun::star::text::WritingMode2; + + +//= VCLXWindowImpl + +class VCLXWindowImpl +{ +private: + typedef ::std::vector< VCLXWindow::Callback > CallbackArray; + +private: + VCLXWindow& mrAntiImpl; + ::toolkit::AccessibilityClient maAccFactory; + bool mbDisposed; + bool mbDrawingOntoParent; // no bit mask, is passed around by reference + bool mbEnableVisible; + bool mbDirectVisible; + + ::osl::Mutex maListenerContainerMutex; + ::comphelper::OInterfaceContainerHelper3 maWindow2Listeners; + ::comphelper::OInterfaceContainerHelper3 maDockableWindowListeners; + EventListenerMultiplexer maEventListeners; + FocusListenerMultiplexer maFocusListeners; + WindowListenerMultiplexer maWindowListeners; + KeyListenerMultiplexer maKeyListeners; + MouseListenerMultiplexer maMouseListeners; + MouseMotionListenerMultiplexer maMouseMotionListeners; + PaintListenerMultiplexer maPaintListeners; + VclContainerListenerMultiplexer maContainerListeners; + TopWindowListenerMultiplexer maTopWindowListeners; + + CallbackArray maCallbackEvents; + ImplSVEvent * mnCallbackEventId; + +public: + bool mbDisposing : 1; + bool mbDesignMode : 1; + bool mbSynthesizingVCLEvent : 1; + bool mbWithDefaultProps : 1; + + sal_uLong mnListenerLockLevel; + sal_Int16 mnWritingMode; + sal_Int16 mnContextWritingMode; + + std::unique_ptr + mpPropHelper; + + css::uno::Reference< css::accessibility::XAccessibleContext > + mxAccessibleContext; + css::uno::Reference< css::awt::XGraphics > + mxViewGraphics; + css::uno::Reference< css::awt::XStyleSettings > + mxWindowStyleSettings; + +public: + bool& getDrawingOntoParent_ref() { return mbDrawingOntoParent; } + +public: + /** ctor + @param _pAntiImpl + the VCLXWindow instance which the object belongs to. Must + live longer then the object just being constructed. + */ + VCLXWindowImpl( VCLXWindow& _rAntiImpl, bool _bWithDefaultProps ); + + VCLXWindowImpl( const VCLXWindowImpl& ) = delete; + const VCLXWindowImpl& operator=(const VCLXWindowImpl&) = delete; + + /** synchronously mbEnableVisible + */ + void setEnableVisible( bool bEnableVisible ) { mbEnableVisible = bEnableVisible; } + bool isEnableVisible() const { return mbEnableVisible; } + /** synchronously mbDirectVisible; + */ + void setDirectVisible( bool bDirectVisible ) { mbDirectVisible = bDirectVisible; } + bool isDirectVisible() const { return mbDirectVisible; } + + /** impl-version of VCLXWindow::ImplExecuteAsyncWithoutSolarLock + */ + void callBackAsync( const VCLXWindow::Callback& i_callback ); + + /** notifies the object that its VCLXWindow is being disposed + */ + void disposing(); + + ::toolkit::AccessibilityClient& getAccessibleFactory() + { + return maAccFactory; + } + + Reference< XStyleSettings > getStyleSettings(); + + /** returns the container of registered XWindowListener2 listeners + */ + ::comphelper::OInterfaceContainerHelper3& getWindow2Listeners() { return maWindow2Listeners; } + ::comphelper::OInterfaceContainerHelper3& getDockableWindowListeners() { return maDockableWindowListeners; } + EventListenerMultiplexer& getEventListeners() { return maEventListeners; } + FocusListenerMultiplexer& getFocusListeners() { return maFocusListeners; } + WindowListenerMultiplexer& getWindowListeners() { return maWindowListeners; } + KeyListenerMultiplexer& getKeyListeners() { return maKeyListeners; } + MouseListenerMultiplexer& getMouseListeners() { return maMouseListeners; } + MouseMotionListenerMultiplexer& getMouseMotionListeners() { return maMouseMotionListeners; } + PaintListenerMultiplexer& getPaintListeners() { return maPaintListeners; } + VclContainerListenerMultiplexer& getContainerListeners() { return maContainerListeners; } + TopWindowListenerMultiplexer& getTopWindowListeners() { return maTopWindowListeners; } + +private: + DECL_LINK( OnProcessCallbacks, void*, void ); +}; + + +VCLXWindowImpl::VCLXWindowImpl( VCLXWindow& _rAntiImpl, bool _bWithDefaultProps ) + :mrAntiImpl( _rAntiImpl ) + ,mbDisposed( false ) + ,mbDrawingOntoParent( false ) + ,mbEnableVisible(true) + ,mbDirectVisible(true) + ,maWindow2Listeners( maListenerContainerMutex ) + ,maDockableWindowListeners( maListenerContainerMutex ) + ,maEventListeners( _rAntiImpl ) + ,maFocusListeners( _rAntiImpl ) + ,maWindowListeners( _rAntiImpl ) + ,maKeyListeners( _rAntiImpl ) + ,maMouseListeners( _rAntiImpl ) + ,maMouseMotionListeners( _rAntiImpl ) + ,maPaintListeners( _rAntiImpl ) + ,maContainerListeners( _rAntiImpl ) + ,maTopWindowListeners( _rAntiImpl ) + ,mnCallbackEventId( nullptr ) + ,mbDisposing( false ) + ,mbDesignMode( false ) + ,mbSynthesizingVCLEvent( false ) + ,mbWithDefaultProps( _bWithDefaultProps ) + ,mnListenerLockLevel( 0 ) + ,mnWritingMode( WritingMode2::CONTEXT ) + ,mnContextWritingMode( WritingMode2::CONTEXT ) +{ +} + +void VCLXWindowImpl::disposing() +{ + SolarMutexGuard aGuard; + + assert(!mbDisposed); + + mbDisposed = true; + + if ( mnCallbackEventId ) + { + Application::RemoveUserEvent( mnCallbackEventId ); + mnCallbackEventId = nullptr; + // we acquired our VCLXWindow once before posting the event, release this one ref now + mrAntiImpl.release(); + } + maCallbackEvents.clear(); + + css::lang::EventObject aEvent; + aEvent.Source = mrAntiImpl; + + maDockableWindowListeners.disposeAndClear( aEvent ); + maEventListeners.disposeAndClear( aEvent ); + maFocusListeners.disposeAndClear( aEvent ); + maWindowListeners.disposeAndClear( aEvent ); + maKeyListeners.disposeAndClear( aEvent ); + maMouseListeners.disposeAndClear( aEvent ); + maMouseMotionListeners.disposeAndClear( aEvent ); + maPaintListeners.disposeAndClear( aEvent ); + maContainerListeners.disposeAndClear( aEvent ); + maTopWindowListeners.disposeAndClear( aEvent ); + maWindow2Listeners.disposeAndClear( aEvent ); + + ::toolkit::WindowStyleSettings* pStyleSettings = static_cast< ::toolkit::WindowStyleSettings* >( mxWindowStyleSettings.get() ); + if ( pStyleSettings != nullptr ) + pStyleSettings->dispose(); + mxWindowStyleSettings.clear(); +} + + +void VCLXWindowImpl::callBackAsync( const VCLXWindow::Callback& i_callback ) +{ + DBG_TESTSOLARMUTEX(); + maCallbackEvents.push_back( i_callback ); + if ( !mnCallbackEventId ) + { + // ensure our VCLXWindow is not destroyed while the event is underway + mrAntiImpl.acquire(); + mnCallbackEventId = Application::PostUserEvent( LINK( this, VCLXWindowImpl, OnProcessCallbacks ) ); + } +} + + +IMPL_LINK_NOARG(VCLXWindowImpl, OnProcessCallbacks, void*, void) +{ + const Reference< uno::XInterface > xKeepAlive( mrAntiImpl ); + + SAL_INFO("toolkit.controls", "OnProcessCallbacks grabbing solarmutex"); + + // work on a copy of the callback array + CallbackArray aCallbacksCopy; + { + SolarMutexGuard aGuard; + aCallbacksCopy.swap(maCallbackEvents); + + // we acquired our VCLXWindow once before posting the event, release this one ref now + mrAntiImpl.release(); + + assert( mnCallbackEventId && "should not be possible to call us if the event was removed"); + + mnCallbackEventId = nullptr; + } + + { + SAL_INFO("toolkit.controls", "OnProcessCallbacks relinquished solarmutex"); + SolarMutexReleaser aReleaseSolar; + for (const auto& rCallback : aCallbacksCopy) + { + rCallback(); + } + } +} + +Reference< XStyleSettings > VCLXWindowImpl::getStyleSettings() +{ + SolarMutexGuard aGuard; + if ( mbDisposed ) + throw DisposedException( OUString(), mrAntiImpl ); + if ( !mxWindowStyleSettings.is() ) + mxWindowStyleSettings = new ::toolkit::WindowStyleSettings( maListenerContainerMutex, mrAntiImpl ); + return mxWindowStyleSettings; +} + + +// Uses an out-parameter instead of return value, due to the object reference + +static void ImplInitWindowEvent( css::awt::WindowEvent& rEvent, vcl::Window const * pWindow ) +{ + Point aPos = pWindow->GetPosPixel(); + Size aSz = pWindow->GetSizePixel(); + + rEvent.X = aPos.X(); + rEvent.Y = aPos.Y(); + + rEvent.Width = aSz.Width(); + rEvent.Height = aSz.Height(); + + pWindow->GetBorder( rEvent.LeftInset, rEvent.TopInset, rEvent.RightInset, rEvent.BottomInset ); +} + +VCLXWindow::VCLXWindow( bool _bWithDefaultProps ) +{ + mpImpl.reset( new VCLXWindowImpl( *this, _bWithDefaultProps ) ); +} + +VCLXWindow::~VCLXWindow() +{ + assert(mpImpl->mbDisposing && "forgot to call dispose()"); +} + + +void VCLXWindow::ImplExecuteAsyncWithoutSolarLock( const Callback& i_callback ) +{ + if (mpImpl->mbDisposing) + return; + mpImpl->callBackAsync( i_callback ); +} + + +::toolkit::IAccessibleFactory& VCLXWindow::getAccessibleFactory() +{ + return mpImpl->getAccessibleFactory().getFactory(); +} + +void VCLXWindow::SetWindow( const VclPtr &pWindow ) +{ + assert(!mpImpl->mbDisposing || !pWindow); + + if ( GetWindow() ) + { + GetWindow()->RemoveEventListener( LINK( this, VCLXWindow, WindowEventListener ) ); +// GetWindow()->DbgAssertNoEventListeners(); + } + + SetOutputDevice( pWindow ? pWindow->GetOutDev() : nullptr ); + + if ( GetWindow() ) + { + GetWindow()->AddEventListener( LINK( this, VCLXWindow, WindowEventListener ) ); + bool bDirectVisible = pWindow && pWindow->IsVisible(); + mpImpl->setDirectVisible( bDirectVisible ); + } +} + +void VCLXWindow::suspendVclEventListening( ) +{ + ++mpImpl->mnListenerLockLevel; +} + +void VCLXWindow::resumeVclEventListening( ) +{ + DBG_ASSERT( mpImpl->mnListenerLockLevel, "VCLXWindow::resumeVclEventListening: not suspended!" ); + --mpImpl->mnListenerLockLevel; +} + +void VCLXWindow::notifyWindowRemoved( vcl::Window const & _rWindow ) +{ + if ( mpImpl->getContainerListeners().getLength() ) + { + awt::VclContainerEvent aEvent; + aEvent.Source = *this; + aEvent.Child = static_cast< XWindow* >( _rWindow.GetWindowPeer() ); + mpImpl->getContainerListeners().windowRemoved( aEvent ); + } +} + +IMPL_LINK( VCLXWindow, WindowEventListener, VclWindowEvent&, rEvent, void ) +{ + if ( mpImpl->mbDisposing || mpImpl->mnListenerLockLevel ) + return; + + DBG_ASSERT( rEvent.GetWindow() && GetWindow(), "Window???" ); + ProcessWindowEvent( rEvent ); +} + +namespace +{ + struct CallWindow2Listener + { + CallWindow2Listener( ::comphelper::OInterfaceContainerHelper3& i_rWindow2Listeners, const bool i_bEnabled, const EventObject& i_rEvent ) + :m_rWindow2Listeners( i_rWindow2Listeners ) + ,m_bEnabled( i_bEnabled ) + ,m_aEvent( i_rEvent ) + { + } + + void operator()() + { + m_rWindow2Listeners.notifyEach( m_bEnabled ? &XWindowListener2::windowEnabled : &XWindowListener2::windowDisabled, m_aEvent ); + } + + ::comphelper::OInterfaceContainerHelper3& m_rWindow2Listeners; + const bool m_bEnabled; + const EventObject m_aEvent; + }; +} + +void VCLXWindow::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) +{ + if (mpImpl->mbDisposing) + return; + css::uno::Reference< css::uno::XInterface > xThis( static_cast(this) ); + + switch ( rVclWindowEvent.GetId() ) + { + case VclEventId::WindowEnabled: + case VclEventId::WindowDisabled: + { + Callback aCallback = CallWindow2Listener( + mpImpl->getWindow2Listeners(), + ( VclEventId::WindowEnabled == rVclWindowEvent.GetId() ), + EventObject( *this ) + ); + ImplExecuteAsyncWithoutSolarLock( aCallback ); + } + break; + + case VclEventId::WindowPaint: + { + if ( mpImpl->getPaintListeners().getLength() ) + { + css::awt::PaintEvent aEvent; + aEvent.Source = static_cast(this); + aEvent.UpdateRect = AWTRectangle( *static_cast(rVclWindowEvent.GetData()) ); + aEvent.Count = 0; + mpImpl->getPaintListeners().windowPaint( aEvent ); + } + } + break; + case VclEventId::WindowMove: + { + if ( mpImpl->getWindowListeners().getLength() ) + { + css::awt::WindowEvent aEvent; + aEvent.Source = static_cast(this); + ImplInitWindowEvent( aEvent, rVclWindowEvent.GetWindow() ); + mpImpl->getWindowListeners().windowMoved( aEvent ); + } + } + break; + case VclEventId::WindowResize: + { + if ( mpImpl->getWindowListeners().getLength() ) + { + css::awt::WindowEvent aEvent; + aEvent.Source = static_cast(this); + ImplInitWindowEvent( aEvent, rVclWindowEvent.GetWindow() ); + mpImpl->getWindowListeners().windowResized( aEvent ); + } + } + break; + case VclEventId::WindowShow: + { + if ( mpImpl->getWindowListeners().getLength() ) + { + css::awt::WindowEvent aEvent; + aEvent.Source = static_cast(this); + ImplInitWindowEvent( aEvent, rVclWindowEvent.GetWindow() ); + mpImpl->getWindowListeners().windowShown( aEvent ); + } + + // For TopWindows this means opened... + if ( mpImpl->getTopWindowListeners().getLength() ) + { + css::lang::EventObject aEvent; + aEvent.Source = static_cast(this); + mpImpl->getTopWindowListeners().windowOpened( aEvent ); + } + } + break; + case VclEventId::WindowHide: + { + if ( mpImpl->getWindowListeners().getLength() ) + { + css::awt::WindowEvent aEvent; + aEvent.Source = static_cast(this); + ImplInitWindowEvent( aEvent, rVclWindowEvent.GetWindow() ); + mpImpl->getWindowListeners().windowHidden( aEvent ); + } + + // For TopWindows this means closed... + if ( mpImpl->getTopWindowListeners().getLength() ) + { + css::lang::EventObject aEvent; + aEvent.Source = static_cast(this); + mpImpl->getTopWindowListeners().windowClosed( aEvent ); + } + } + break; + case VclEventId::WindowActivate: + case VclEventId::WindowDeactivate: + { + if (!mpImpl->getTopWindowListeners().getLength()) + return; + + // Suppress events which are unlikely to be interesting to our listeners. + vcl::Window* pWin = static_cast(rVclWindowEvent.GetData()); + bool bSuppress = false; + + while (pWin) + { + // Either the event came from the same window, from its + // child, or from a child of its border window (e.g. + // menubar or notebookbar). + if (pWin->GetWindow(GetWindowType::Client) == GetWindow()) + return; + + if (pWin->IsMenuFloatingWindow()) + bSuppress = true; + + if (pWin->GetType() == WindowType::FLOATINGWINDOW && + static_cast(pWin)->IsInPopupMode()) + bSuppress = true; + + // Otherwise, don't suppress if the event came from a different frame. + if (!bSuppress && pWin->GetWindow(GetWindowType::Frame) == pWin) + break; + + pWin = pWin->GetWindow(GetWindowType::RealParent); + } + + css::lang::EventObject aEvent; + aEvent.Source = static_cast(this); + if (rVclWindowEvent.GetId() == VclEventId::WindowActivate) + mpImpl->getTopWindowListeners().windowActivated( aEvent ); + else + mpImpl->getTopWindowListeners().windowDeactivated( aEvent ); + } + break; + case VclEventId::WindowClose: + { + if ( mpImpl->getDockableWindowListeners().getLength() ) + { + css::lang::EventObject aEvent; + aEvent.Source = static_cast(this); + mpImpl->getDockableWindowListeners().notifyEach( &XDockableWindowListener::closed, aEvent ); + } + if ( mpImpl->getTopWindowListeners().getLength() ) + { + css::lang::EventObject aEvent; + aEvent.Source = static_cast(this); + mpImpl->getTopWindowListeners().windowClosing( aEvent ); + } + } + break; + case VclEventId::ControlGetFocus: + case VclEventId::WindowGetFocus: + { + if ( ( rVclWindowEvent.GetWindow()->IsCompoundControl() + && rVclWindowEvent.GetId() == VclEventId::ControlGetFocus + ) + || ( !rVclWindowEvent.GetWindow()->IsCompoundControl() + && rVclWindowEvent.GetId() == VclEventId::WindowGetFocus + ) + ) + { + if ( mpImpl->getFocusListeners().getLength() ) + { + css::awt::FocusEvent aEvent; + aEvent.Source = static_cast(this); + aEvent.FocusFlags = static_cast(rVclWindowEvent.GetWindow()->GetGetFocusFlags()); + aEvent.Temporary = false; + mpImpl->getFocusListeners().focusGained( aEvent ); + } + } + } + break; + case VclEventId::ControlLoseFocus: + case VclEventId::WindowLoseFocus: + { + if ( ( rVclWindowEvent.GetWindow()->IsCompoundControl() + && rVclWindowEvent.GetId() == VclEventId::ControlLoseFocus + ) + || ( !rVclWindowEvent.GetWindow()->IsCompoundControl() + && rVclWindowEvent.GetId() == VclEventId::WindowLoseFocus + ) + ) + { + if ( mpImpl->getFocusListeners().getLength() ) + { + css::awt::FocusEvent aEvent; + aEvent.Source = static_cast(this); + aEvent.FocusFlags = static_cast(rVclWindowEvent.GetWindow()->GetGetFocusFlags()); + aEvent.Temporary = false; + + vcl::Window* pNext = Application::GetFocusWindow(); + if ( pNext ) + { + // Don't care about internals if this control is compound + vcl::Window* pNextC = pNext; + while ( pNextC && !pNextC->IsCompoundControl() ) + pNextC = pNextC->GetParent(); + if ( pNextC ) + pNext = pNextC; + + pNext->GetComponentInterface(); + aEvent.NextFocus = static_cast(pNext->GetWindowPeer()); + } + mpImpl->getFocusListeners().focusLost( aEvent ); + } + } + } + break; + case VclEventId::WindowMinimize: + { + if ( mpImpl->getTopWindowListeners().getLength() ) + { + css::lang::EventObject aEvent; + aEvent.Source = static_cast(this); + mpImpl->getTopWindowListeners().windowMinimized( aEvent ); + } + } + break; + case VclEventId::WindowNormalize: + { + if ( mpImpl->getTopWindowListeners().getLength() ) + { + css::lang::EventObject aEvent; + aEvent.Source = static_cast(this); + mpImpl->getTopWindowListeners().windowNormalized( aEvent ); + } + } + break; + case VclEventId::WindowKeyInput: + { + if ( mpImpl->getKeyListeners().getLength() ) + { + css::awt::KeyEvent aEvent( VCLUnoHelper::createKeyEvent( + *static_cast(rVclWindowEvent.GetData()), *this + ) ); + mpImpl->getKeyListeners().keyPressed( aEvent ); + } + } + break; + case VclEventId::WindowKeyUp: + { + if ( mpImpl->getKeyListeners().getLength() ) + { + css::awt::KeyEvent aEvent( VCLUnoHelper::createKeyEvent( + *static_cast(rVclWindowEvent.GetData()), *this + ) ); + mpImpl->getKeyListeners().keyReleased( aEvent ); + } + } + break; + case VclEventId::WindowCommand: + { + CommandEvent* pCmdEvt = static_cast(rVclWindowEvent.GetData()); + if ( mpImpl->getMouseListeners().getLength() && ( pCmdEvt->GetCommand() == CommandEventId::ContextMenu ) ) + { + // CommandEventId::ContextMenu: send as mousePressed with PopupTrigger = true ... + Point aWhere = static_cast< CommandEvent* >( rVclWindowEvent.GetData() )->GetMousePosPixel(); + if ( !pCmdEvt->IsMouseEvent() ) + { // for keyboard events, we set the coordinates to -1,-1. This is a slight HACK, but the current API + // handles a context menu command as special case of a mouse event, which is simply wrong. + // Without extending the API, we would not have another chance to notify listeners of a + // keyboard-triggered context menu request + aWhere = Point( -1, -1 ); + } + + MouseEvent aMEvt( aWhere, 1, MouseEventModifiers::SIMPLECLICK, MOUSE_LEFT, 0 ); + awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( aMEvt, *this ) ); + aEvent.PopupTrigger = true; + + Callback aCallback = [ this, aEvent ]() + { this->mpImpl->getMouseListeners().mousePressed( aEvent ); }; + + ImplExecuteAsyncWithoutSolarLock( aCallback ); + } + } + break; + case VclEventId::WindowMouseMove: + { + MouseEvent* pMouseEvt = static_cast(rVclWindowEvent.GetData()); + if ( mpImpl->getMouseListeners().getLength() && ( pMouseEvt->IsEnterWindow() || pMouseEvt->IsLeaveWindow() ) ) + { + awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( *pMouseEvt, *this ) ); + bool const isEnter(pMouseEvt->IsEnterWindow()); + Callback aCallback = [ this, isEnter, aEvent ]() + { MouseListenerMultiplexer& rMouseListeners = this->mpImpl->getMouseListeners(); + isEnter + ? rMouseListeners.mouseEntered(aEvent) + : rMouseListeners.mouseExited(aEvent); }; + + ImplExecuteAsyncWithoutSolarLock( aCallback ); + } + + if ( mpImpl->getMouseMotionListeners().getLength() && !pMouseEvt->IsEnterWindow() && !pMouseEvt->IsLeaveWindow() ) + { + awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( *pMouseEvt, *this ) ); + aEvent.ClickCount = 0; + if ( pMouseEvt->GetMode() & MouseEventModifiers::SIMPLEMOVE ) + mpImpl->getMouseMotionListeners().mouseMoved( aEvent ); + else + mpImpl->getMouseMotionListeners().mouseDragged( aEvent ); + } + } + break; + case VclEventId::WindowMouseButtonDown: + { + if ( mpImpl->getMouseListeners().getLength() ) + { + awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( *static_cast(rVclWindowEvent.GetData()), *this ) ); + Callback aCallback = [ this, aEvent ]() + { this->mpImpl->getMouseListeners().mousePressed( aEvent ); }; + ImplExecuteAsyncWithoutSolarLock( aCallback ); + } + } + break; + case VclEventId::WindowMouseButtonUp: + { + if ( mpImpl->getMouseListeners().getLength() ) + { + awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( *static_cast(rVclWindowEvent.GetData()), *this ) ); + + Callback aCallback = [ this, aEvent ]() + { this->mpImpl->getMouseListeners().mouseReleased( aEvent ); }; + ImplExecuteAsyncWithoutSolarLock( aCallback ); + } + } + break; + case VclEventId::WindowStartDocking: + { + if ( mpImpl->getDockableWindowListeners().getLength() ) + { + DockingData *pData = static_cast(rVclWindowEvent.GetData()); + + if( pData ) + { + css::awt::DockingEvent aEvent; + aEvent.Source = static_cast(this); + aEvent.TrackingRectangle = AWTRectangle( pData->maTrackRect ); + aEvent.MousePos.X = pData->maMousePos.X(); + aEvent.MousePos.Y = pData->maMousePos.Y(); + aEvent.bLiveMode = false; + aEvent.bInteractive = true; + + mpImpl->getDockableWindowListeners().notifyEach( &XDockableWindowListener::startDocking, aEvent ); + } + } + } + break; + case VclEventId::WindowDocking: + { + if ( mpImpl->getDockableWindowListeners().getLength() ) + { + DockingData *pData = static_cast(rVclWindowEvent.GetData()); + + if( pData ) + { + css::awt::DockingEvent aEvent; + aEvent.Source = static_cast(this); + aEvent.TrackingRectangle = AWTRectangle( pData->maTrackRect ); + aEvent.MousePos.X = pData->maMousePos.X(); + aEvent.MousePos.Y = pData->maMousePos.Y(); + aEvent.bLiveMode = false; + aEvent.bInteractive = true; + + Reference< XDockableWindowListener > xFirstListener; + ::comphelper::OInterfaceIteratorHelper3 aIter( mpImpl->getDockableWindowListeners() ); + while ( aIter.hasMoreElements() && !xFirstListener.is() ) + { + xFirstListener = aIter.next(); + } + + css::awt::DockingData aDockingData = + xFirstListener->docking( aEvent ); + pData->maTrackRect = VCLRectangle( aDockingData.TrackingRectangle ); + pData->mbFloating = aDockingData.bFloating; + } + } + } + break; + case VclEventId::WindowEndDocking: + { + if ( mpImpl->getDockableWindowListeners().getLength() ) + { + EndDockingData *pData = static_cast(rVclWindowEvent.GetData()); + + if( pData ) + { + css::awt::EndDockingEvent aEvent; + aEvent.Source = static_cast(this); + aEvent.WindowRectangle = AWTRectangle( pData->maWindowRect ); + aEvent.bFloating = pData->mbFloating; + aEvent.bCancelled = pData->mbCancelled; + mpImpl->getDockableWindowListeners().notifyEach( &XDockableWindowListener::endDocking, aEvent ); + } + } + } + break; + case VclEventId::WindowPrepareToggleFloating: + { + if ( mpImpl->getDockableWindowListeners().getLength() ) + { + sal_Bool *p_bFloating = static_cast(rVclWindowEvent.GetData()); + + css::lang::EventObject aEvent; + aEvent.Source = static_cast(this); + + Reference< XDockableWindowListener > xFirstListener; + ::comphelper::OInterfaceIteratorHelper3 aIter( mpImpl->getDockableWindowListeners() ); + while ( aIter.hasMoreElements() && !xFirstListener.is() ) + { + xFirstListener = aIter.next(); + } + + *p_bFloating = xFirstListener->prepareToggleFloatingMode( aEvent ); + } + } + break; + case VclEventId::WindowToggleFloating: + { + if ( mpImpl->getDockableWindowListeners().getLength() ) + { + css::lang::EventObject aEvent; + aEvent.Source = static_cast(this); + mpImpl->getDockableWindowListeners().notifyEach( &XDockableWindowListener::toggleFloatingMode, aEvent ); + } + } + break; + case VclEventId::WindowEndPopupMode: + { + if ( mpImpl->getDockableWindowListeners().getLength() ) + { + EndPopupModeData *pData = static_cast(rVclWindowEvent.GetData()); + + if( pData ) + { + css::awt::EndPopupModeEvent aEvent; + aEvent.Source = static_cast(this); + aEvent.FloatingPosition.X = pData->maFloatingPos.X(); + aEvent.FloatingPosition.Y = pData->maFloatingPos.Y(); + aEvent.bTearoff = pData->mbTearoff; + mpImpl->getDockableWindowListeners().notifyEach( &XDockableWindowListener::endPopupMode, aEvent ); + } + } + } + break; + default: break; + } +} + +uno::Reference< accessibility::XAccessibleContext > VCLXWindow::CreateAccessibleContext() +{ + SolarMutexGuard aGuard; + if (mpImpl->mbDisposing) + return nullptr; + return getAccessibleFactory().createAccessibleContext( this ); +} + +void VCLXWindow::SetSynthesizingVCLEvent( bool _b ) +{ + mpImpl->mbSynthesizingVCLEvent = _b; +} + +bool VCLXWindow::IsSynthesizingVCLEvent() const +{ + return mpImpl->mbSynthesizingVCLEvent; +} + +Size VCLXWindow::ImplCalcWindowSize( const Size& rOutSz ) const +{ + Size aSz = rOutSz; + + VclPtr pWindow = GetWindow(); + if ( pWindow ) + { + sal_Int32 nLeft, nTop, nRight, nBottom; + pWindow->GetBorder( nLeft, nTop, nRight, nBottom ); + aSz.AdjustWidth(nLeft+nRight ); + aSz.AdjustHeight(nTop+nBottom ); + } + return aSz; +} + + +// css::lang::XUnoTunnel +UNO3_GETIMPLEMENTATION2_IMPL(VCLXWindow, VCLXDevice); + + +// css::lang::Component +void VCLXWindow::dispose( ) +{ + SolarMutexGuard aGuard; + + if ( mpImpl->mbDisposing ) + return; + + mpImpl->mbDisposing = true; + + mpImpl->mxViewGraphics = nullptr; + + mpImpl->disposing(); + + if ( VclPtr pWindow = GetWindow() ) + { + pWindow->RemoveEventListener( LINK( this, VCLXWindow, WindowEventListener ) ); + pWindow->SetWindowPeer( nullptr, nullptr ); + pWindow->SetAccessible( nullptr ); + + SetOutputDevice( nullptr ); + pWindow.disposeAndClear(); + } + + // #i14103# dispose the accessible context after the window has been destroyed, + // otherwise the old value in the child event fired in VCLXAccessibleComponent::ProcessWindowEvent() + // for VclEventId::WindowChildDestroyed contains a reference to an already disposed accessible object + try + { + css::uno::Reference< css::lang::XComponent > xComponent( mpImpl->mxAccessibleContext, css::uno::UNO_QUERY ); + if ( xComponent.is() ) + xComponent->dispose(); + } + catch ( const css::uno::Exception& ) + { + OSL_FAIL( "VCLXWindow::dispose: could not dispose the accessible context!" ); + } + mpImpl->mxAccessibleContext.clear(); +} + +void VCLXWindow::addEventListener( const css::uno::Reference< css::lang::XEventListener >& rxListener ) +{ + SolarMutexGuard aGuard; + if (mpImpl->mbDisposing) // called during dispose by accessibility stuff + return; + mpImpl->getEventListeners().addInterface( rxListener ); +} + +void VCLXWindow::removeEventListener( const css::uno::Reference< css::lang::XEventListener >& rxListener ) +{ + SolarMutexGuard aGuard; + if (mpImpl->mbDisposing) + return; + mpImpl->getEventListeners().removeInterface( rxListener ); +} + + +// css::awt::XWindow +void VCLXWindow::setPosSize( sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height, sal_Int16 Flags ) +{ + SolarMutexGuard aGuard; + comphelper::ProfileZone aZone("setPosSize"); + + if ( GetWindow() ) + { + if( vcl::Window::GetDockingManager()->IsDockable( GetWindow() ) ) + vcl::Window::GetDockingManager()->SetPosSizePixel( GetWindow() , X, Y, Width, Height, static_cast(Flags) ); + else + GetWindow()->setPosSizePixel( X, Y, Width, Height, static_cast(Flags) ); + } +} + +css::awt::Rectangle VCLXWindow::getPosSize( ) +{ + SolarMutexGuard aGuard; + + css::awt::Rectangle aBounds; + if ( GetWindow() ) + { + if( vcl::Window::GetDockingManager()->IsDockable( GetWindow() ) ) + aBounds = AWTRectangle( vcl::Window::GetDockingManager()->GetPosSizePixel( GetWindow() ) ); + else + aBounds = AWTRectangle( tools::Rectangle( GetWindow()->GetPosPixel(), GetWindow()->GetSizePixel() ) ); + } + + return aBounds; +} + +void VCLXWindow::setVisible( sal_Bool bVisible ) +{ + SolarMutexGuard aGuard; + + VclPtr pWindow = GetWindow(); + if ( pWindow ) + { + mpImpl->setDirectVisible( bVisible ); + pWindow->Show( bVisible && mpImpl->isEnableVisible() ); + } +} + +void VCLXWindow::setEnable( sal_Bool bEnable ) +{ + SolarMutexGuard aGuard; + + VclPtr pWindow = GetWindow(); + if ( pWindow ) + { + pWindow->Enable( bEnable, false ); // #95824# without children! + pWindow->EnableInput( bEnable ); + } +} + +void VCLXWindow::setFocus( ) +{ + SolarMutexGuard aGuard; + + if ( GetWindow() ) + GetWindow()->GrabFocus(); +} + +void VCLXWindow::addWindowListener( const css::uno::Reference< css::awt::XWindowListener >& rxListener ) +{ + SolarMutexGuard aGuard; + if (mpImpl->mbDisposing) + return; + + mpImpl->getWindowListeners().addInterface( rxListener ); + + Reference< XWindowListener2 > xListener2( rxListener, UNO_QUERY ); + if ( xListener2.is() ) + mpImpl->getWindow2Listeners().addInterface( xListener2 ); + + // #100119# Get all resize events, even if height or width 0, or invisible + if ( GetWindow() ) + GetWindow()->EnableAllResize(); +} + +void VCLXWindow::removeWindowListener( const css::uno::Reference< css::awt::XWindowListener >& rxListener ) +{ + SolarMutexGuard aGuard; + + if (mpImpl->mbDisposing) + return; + + Reference< XWindowListener2 > xListener2( rxListener, UNO_QUERY ); + if ( xListener2.is() ) + mpImpl->getWindow2Listeners().removeInterface( xListener2 ); + + mpImpl->getWindowListeners().removeInterface( rxListener ); +} + +void VCLXWindow::addFocusListener( const css::uno::Reference< css::awt::XFocusListener >& rxListener ) +{ + SolarMutexGuard aGuard; + if (mpImpl->mbDisposing) + return; + mpImpl->getFocusListeners().addInterface( rxListener ); +} + +void VCLXWindow::removeFocusListener( const css::uno::Reference< css::awt::XFocusListener >& rxListener ) +{ + SolarMutexGuard aGuard; + if (mpImpl->mbDisposing) + return; + mpImpl->getFocusListeners().removeInterface( rxListener ); +} + +void VCLXWindow::addKeyListener( const css::uno::Reference< css::awt::XKeyListener >& rxListener ) +{ + SolarMutexGuard aGuard; + if (mpImpl->mbDisposing) + return; + mpImpl->getKeyListeners().addInterface( rxListener ); +} + +void VCLXWindow::removeKeyListener( const css::uno::Reference< css::awt::XKeyListener >& rxListener ) +{ + SolarMutexGuard aGuard; + if (mpImpl->mbDisposing) + return; + mpImpl->getKeyListeners().removeInterface( rxListener ); +} + +void VCLXWindow::addMouseListener( const css::uno::Reference< css::awt::XMouseListener >& rxListener ) +{ + SolarMutexGuard aGuard; + if (mpImpl->mbDisposing) + return; + mpImpl->getMouseListeners().addInterface( rxListener ); +} + +void VCLXWindow::removeMouseListener( const css::uno::Reference< css::awt::XMouseListener >& rxListener ) +{ + SolarMutexGuard aGuard; + if (mpImpl->mbDisposing) + return; + mpImpl->getMouseListeners().removeInterface( rxListener ); +} + +void VCLXWindow::addMouseMotionListener( const css::uno::Reference< css::awt::XMouseMotionListener >& rxListener ) +{ + SolarMutexGuard aGuard; + if (mpImpl->mbDisposing) + return; + mpImpl->getMouseMotionListeners().addInterface( rxListener ); +} + +void VCLXWindow::removeMouseMotionListener( const css::uno::Reference< css::awt::XMouseMotionListener >& rxListener ) +{ + SolarMutexGuard aGuard; + if (mpImpl->mbDisposing) + return; + mpImpl->getMouseMotionListeners().removeInterface( rxListener ); +} + +void VCLXWindow::addPaintListener( const css::uno::Reference< css::awt::XPaintListener >& rxListener ) +{ + SolarMutexGuard aGuard; + if (mpImpl->mbDisposing) + return; + mpImpl->getPaintListeners().addInterface( rxListener ); +} + +void VCLXWindow::removePaintListener( const css::uno::Reference< css::awt::XPaintListener >& rxListener ) +{ + SolarMutexGuard aGuard; + if (mpImpl->mbDisposing) + return; + mpImpl->getPaintListeners().removeInterface( rxListener ); +} + +// css::awt::XWindowPeer +css::uno::Reference< css::awt::XToolkit > VCLXWindow::getToolkit( ) +{ + // no guard. nothing to guard here. + // 82463 - 12/21/00 - fs + return Application::GetVCLToolkit(); +} + +void VCLXWindow::setPointer( const css::uno::Reference< css::awt::XPointer >& rxPointer ) +{ + SolarMutexGuard aGuard; + + VCLXPointer* pPointer = comphelper::getFromUnoTunnel( rxPointer ); + if ( pPointer && GetWindow() ) + GetWindow()->SetPointer( pPointer->GetPointer() ); +} + +void VCLXWindow::setBackground( sal_Int32 nColor ) +{ + SolarMutexGuard aGuard; + + if ( !GetWindow() ) + return; + + Color aColor(ColorTransparency, nColor); + GetWindow()->SetBackground( aColor ); + GetWindow()->SetControlBackground( aColor ); + + WindowType eWinType = GetWindow()->GetType(); + if ( ( eWinType == WindowType::WINDOW ) || + ( eWinType == WindowType::WORKWINDOW ) || + ( eWinType == WindowType::FLOATINGWINDOW ) ) + { + GetWindow()->Invalidate(); + } +} + +void VCLXWindow::invalidate( sal_Int16 nInvalidateFlags ) +{ + SolarMutexGuard aGuard; + + if ( GetWindow() ) + GetWindow()->Invalidate( static_cast(nInvalidateFlags) ); +} + +void VCLXWindow::invalidateRect( const css::awt::Rectangle& rRect, sal_Int16 nInvalidateFlags ) +{ + SolarMutexGuard aGuard; + + if ( GetWindow() ) + GetWindow()->Invalidate( VCLRectangle(rRect), static_cast(nInvalidateFlags) ); +} + + +// css::awt::XVclWindowPeer +sal_Bool VCLXWindow::isChild( const css::uno::Reference< css::awt::XWindowPeer >& rxPeer ) +{ + SolarMutexGuard aGuard; + + bool bIsChild = false; + VclPtr pWindow = GetWindow(); + if ( pWindow ) + { + VclPtr pPeerWindow = VCLUnoHelper::GetWindow( rxPeer ); + bIsChild = pPeerWindow && pWindow->IsChild( pPeerWindow ); + } + + return bIsChild; +} + +void VCLXWindow::setDesignMode( sal_Bool bOn ) +{ + SolarMutexGuard aGuard; + + mpImpl->mbDesignMode = bOn; +} + +sal_Bool VCLXWindow::isDesignMode( ) +{ + SolarMutexGuard aGuard; + return mpImpl->mbDesignMode; +} + +void VCLXWindow::enableClipSiblings( sal_Bool bClip ) +{ + SolarMutexGuard aGuard; + + if ( GetWindow() ) + GetWindow()->EnableClipSiblings( bClip ); +} + +void VCLXWindow::setForeground( sal_Int32 nColor ) +{ + SolarMutexGuard aGuard; + + if ( GetWindow() ) + { + GetWindow()->SetControlForeground( Color(ColorTransparency, nColor) ); + } +} + +void VCLXWindow::setControlFont( const css::awt::FontDescriptor& rFont ) +{ + SolarMutexGuard aGuard; + + if ( GetWindow() ) + GetWindow()->SetControlFont( VCLUnoHelper::CreateFont( rFont, GetWindow()->GetControlFont() ) ); +} + +void VCLXWindow::getStyles( sal_Int16 nType, css::awt::FontDescriptor& Font, sal_Int32& ForegroundColor, sal_Int32& BackgroundColor ) +{ + SolarMutexGuard aGuard; + + if ( !GetWindow() ) + return; + + const StyleSettings& rStyleSettings = GetWindow()->GetSettings().GetStyleSettings(); + + switch ( nType ) + { + case css::awt::Style::FRAME: + { + Font = VCLUnoHelper::CreateFontDescriptor( rStyleSettings.GetAppFont() ); + ForegroundColor = sal_Int32(rStyleSettings.GetWindowTextColor()); + BackgroundColor = sal_Int32(rStyleSettings.GetWindowColor()); + } + break; + case css::awt::Style::DIALOG: + { + Font = VCLUnoHelper::CreateFontDescriptor( rStyleSettings.GetAppFont() ); + ForegroundColor = sal_Int32(rStyleSettings.GetDialogTextColor()); + BackgroundColor = sal_Int32(rStyleSettings.GetDialogColor()); + } + break; + default: OSL_FAIL( "VCLWindow::getStyles() - unknown Type" ); + } +} + +namespace toolkit +{ + static void setColorSettings( vcl::Window* _pWindow, const css::uno::Any& _rValue, + void (StyleSettings::*pSetter)( const Color& ), const Color& (StyleSettings::*pGetter)( ) const ) + { + sal_Int32 nColor = 0; + if ( !( _rValue >>= nColor ) ) + nColor = sal_Int32((Application::GetSettings().GetStyleSettings().*pGetter)()); + + AllSettings aSettings = _pWindow->GetSettings(); + StyleSettings aStyleSettings = aSettings.GetStyleSettings(); + + (aStyleSettings.*pSetter)( Color( ColorTransparency, nColor ) ); + + aSettings.SetStyleSettings( aStyleSettings ); + _pWindow->SetSettings( aSettings, true ); + } +} + +// Terminated by BASEPROPERTY_NOTFOUND (or 0) +void VCLXWindow::PushPropertyIds( std::vector< sal_uInt16 > &rIds, + int nFirstId, ...) +{ + va_list pVarArgs; + va_start( pVarArgs, nFirstId ); + + for ( int nId = nFirstId; nId != BASEPROPERTY_NOTFOUND; + nId = va_arg( pVarArgs, int ) ) + rIds.push_back( static_cast(nId) ); + + va_end( pVarArgs ); +} + +void VCLXWindow::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds, bool bWithDefaults ) +{ + // These are common across ~all VCLXWindow derived classes + if( bWithDefaults ) + PushPropertyIds( rIds, + BASEPROPERTY_ALIGN, + BASEPROPERTY_BACKGROUNDCOLOR, + BASEPROPERTY_BORDER, + BASEPROPERTY_BORDERCOLOR, + BASEPROPERTY_DEFAULTCONTROL, + BASEPROPERTY_ENABLED, + BASEPROPERTY_FONTDESCRIPTOR, + BASEPROPERTY_HELPTEXT, + BASEPROPERTY_HELPURL, + BASEPROPERTY_TEXT, + BASEPROPERTY_PRINTABLE, + BASEPROPERTY_ENABLEVISIBLE, // for visibility + BASEPROPERTY_TABSTOP, + 0); + + // lovely hack from: + // void UnoControlModel::ImplRegisterProperty( sal_uInt16 nPropId ) + if( std::find(rIds.begin(), rIds.end(), BASEPROPERTY_FONTDESCRIPTOR) != rIds.end() ) + { + // some properties are not included in the FontDescriptor, but every time + // when we have a FontDescriptor we want to have these properties too. + // => Easier to register the here, instead everywhere where I register the FontDescriptor... + + rIds.push_back( BASEPROPERTY_TEXTCOLOR ); + rIds.push_back( BASEPROPERTY_TEXTLINECOLOR ); + rIds.push_back( BASEPROPERTY_FONTRELIEF ); + rIds.push_back( BASEPROPERTY_FONTEMPHASISMARK ); + } +} + +void VCLXWindow::GetPropertyIds( std::vector< sal_uInt16 >& _out_rIds ) +{ + return ImplGetPropertyIds( _out_rIds, mpImpl->mbWithDefaultProps ); +} + +::comphelper::OInterfaceContainerHelper3& VCLXWindow::GetContainerListeners() +{ + return mpImpl->getContainerListeners(); +} + +::comphelper::OInterfaceContainerHelper3& VCLXWindow::GetTopWindowListeners() +{ + return mpImpl->getTopWindowListeners(); +} + +namespace +{ + void lcl_updateWritingMode( vcl::Window& _rWindow, const sal_Int16 _nWritingMode, const sal_Int16 _nContextWritingMode ) + { + bool bEnableRTL = false; + switch ( _nWritingMode ) + { + case WritingMode2::LR_TB: bEnableRTL = false; break; + case WritingMode2::RL_TB: bEnableRTL = true; break; + case WritingMode2::CONTEXT: + { + // consult our ContextWritingMode. If it has an explicit RTL/LTR value, then use + // it. If it doesn't (but is CONTEXT itself), then just ask the parent window of our + // own window for its RTL mode + switch ( _nContextWritingMode ) + { + case WritingMode2::LR_TB: bEnableRTL = false; break; + case WritingMode2::RL_TB: bEnableRTL = true; break; + case WritingMode2::CONTEXT: + { + const vcl::Window* pParent = _rWindow.GetParent(); + OSL_ENSURE( pParent, "lcl_updateWritingMode: cannot determine context's writing mode!" ); + if ( pParent ) + bEnableRTL = pParent->IsRTLEnabled(); + } + break; + } + } + break; + default: + OSL_FAIL( "lcl_updateWritingMode: unsupported WritingMode!" ); + } // switch ( nWritingMode ) + + _rWindow.EnableRTL( bEnableRTL ); + } +} + +void VCLXWindow::setProperty( const OUString& PropertyName, const css::uno::Any& Value ) +{ + SolarMutexGuard aGuard; + + VclPtr pWindow = GetWindow(); + if ( !pWindow ) + return; + + bool bVoid = Value.getValueType().getTypeClass() == css::uno::TypeClass_VOID; + + WindowType eWinType = pWindow->GetType(); + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_REFERENCE_DEVICE: + { + Control* pControl = dynamic_cast< Control* >( pWindow.get() ); + OSL_ENSURE( pControl, "VCLXWindow::setProperty( RefDevice ): need a Control for this!" ); + if ( !pControl ) + break; + Reference< XDevice > xDevice( Value, UNO_QUERY ); + OutputDevice* pDevice = VCLUnoHelper::GetOutputDevice( xDevice ); + pControl->SetReferenceDevice( pDevice ); + } + break; + + case BASEPROPERTY_CONTEXT_WRITING_MODE: + { + OSL_VERIFY( Value >>= mpImpl->mnContextWritingMode ); + if ( mpImpl->mnWritingMode == WritingMode2::CONTEXT ) + lcl_updateWritingMode( *pWindow, mpImpl->mnWritingMode, mpImpl->mnContextWritingMode ); + } + break; + + case BASEPROPERTY_WRITING_MODE: + { + bool bProperType = ( Value >>= mpImpl->mnWritingMode ); + OSL_ENSURE( bProperType, "VCLXWindow::setProperty( 'WritingMode' ): illegal value type!" ); + if ( bProperType ) + lcl_updateWritingMode( *pWindow, mpImpl->mnWritingMode, mpImpl->mnContextWritingMode ); + } + break; + + case BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR: + { + sal_uInt16 nWheelBehavior( css::awt::MouseWheelBehavior::SCROLL_FOCUS_ONLY ); + OSL_VERIFY( Value >>= nWheelBehavior ); + + AllSettings aSettings = pWindow->GetSettings(); + MouseSettings aMouseSettings = aSettings.GetMouseSettings(); + + MouseWheelBehaviour nVclBehavior( MouseWheelBehaviour::FocusOnly ); + switch ( nWheelBehavior ) + { + case css::awt::MouseWheelBehavior::SCROLL_DISABLED: nVclBehavior = MouseWheelBehaviour::Disable; break; + case css::awt::MouseWheelBehavior::SCROLL_FOCUS_ONLY: nVclBehavior = MouseWheelBehaviour::FocusOnly; break; + case css::awt::MouseWheelBehavior::SCROLL_ALWAYS: nVclBehavior = MouseWheelBehaviour::ALWAYS; break; + default: + OSL_FAIL( "VCLXWindow::setProperty( 'MouseWheelBehavior' ): illegal property value!" ); + } + + aMouseSettings.SetWheelBehavior( nVclBehavior ); + aSettings.SetMouseSettings( aMouseSettings ); + pWindow->SetSettings( aSettings, true ); + } + break; + + case BASEPROPERTY_NATIVE_WIDGET_LOOK: + { + bool bEnable( true ); + OSL_VERIFY( Value >>= bEnable ); + pWindow->EnableNativeWidget( bEnable ); + } + break; + + case BASEPROPERTY_PLUGINPARENT: + { + // set parent handle + SetSystemParent_Impl( Value ); + } + break; + + case BASEPROPERTY_ENABLED: + { + bool b = bool(); + if ( Value >>= b ) + setEnable( b ); + } + break; + case BASEPROPERTY_ENABLEVISIBLE: + { + bool b = false; + if ( Value >>= b ) + { + if( b != mpImpl->isEnableVisible() ) + { + mpImpl->setEnableVisible( b ); + pWindow->Show( b && mpImpl->isDirectVisible() ); + } + } + } + break; + case BASEPROPERTY_TEXT: + case BASEPROPERTY_LABEL: + case BASEPROPERTY_TITLE: + { + OUString aText; + if ( Value >>= aText ) + { + switch (eWinType) + { + case WindowType::OKBUTTON: + case WindowType::CANCELBUTTON: + case WindowType::HELPBUTTON: + // Standard Button: overwrite only if not empty. + if (!aText.isEmpty()) + pWindow->SetText( aText ); + break; + + default: + pWindow->SetText( aText ); + break; + } + } + } + break; + case BASEPROPERTY_ACCESSIBLENAME: + { + OUString aText; + if ( Value >>= aText ) + pWindow->SetAccessibleName( aText ); + } + break; + case BASEPROPERTY_HELPURL: + { + OUString aURL; + if ( Value >>= aURL ) + { + INetURLObject aHelpURL( aURL ); + if ( aHelpURL.GetProtocol() == INetProtocol::Hid ) + pWindow->SetHelpId( OUStringToOString( aHelpURL.GetURLPath(), RTL_TEXTENCODING_UTF8 ) ); + else + pWindow->SetHelpId( OUStringToOString( aURL, RTL_TEXTENCODING_UTF8 ) ); + } + } + break; + case BASEPROPERTY_HELPTEXT: + { + OUString aHelpText; + if ( Value >>= aHelpText ) + { + pWindow->SetQuickHelpText( aHelpText ); + } + } + break; + case BASEPROPERTY_FONTDESCRIPTOR: + { + if ( bVoid ) + pWindow->SetControlFont( vcl::Font() ); + else + { + css::awt::FontDescriptor aFont; + if ( Value >>= aFont ) + pWindow->SetControlFont( VCLUnoHelper::CreateFont( aFont, pWindow->GetControlFont() ) ); + } + } + break; + case BASEPROPERTY_FONTRELIEF: + { + sal_Int16 n = sal_Int16(); + if ( Value >>= n ) + { + vcl::Font aFont = pWindow->GetControlFont(); + aFont.SetRelief( static_cast(n) ); + pWindow->SetControlFont( aFont ); + } + } + break; + case BASEPROPERTY_FONTEMPHASISMARK: + { + sal_Int16 n = sal_Int16(); + if ( Value >>= n ) + { + vcl::Font aFont = pWindow->GetControlFont(); + aFont.SetEmphasisMark( static_cast(n) ); + pWindow->SetControlFont( aFont ); + } + } + break; + case BASEPROPERTY_BACKGROUNDCOLOR: + if ( bVoid ) + { + switch ( eWinType ) + { + // set dialog color for default + case WindowType::DIALOG: + case WindowType::MESSBOX: + case WindowType::INFOBOX: + case WindowType::WARNINGBOX: + case WindowType::ERRORBOX: + case WindowType::QUERYBOX: + case WindowType::TABPAGE: + { + Color aColor = pWindow->GetSettings().GetStyleSettings().GetDialogColor(); + pWindow->SetBackground( aColor ); + pWindow->SetControlBackground( aColor ); + break; + } + + case WindowType::FIXEDTEXT: + case WindowType::CHECKBOX: + case WindowType::RADIOBUTTON: + case WindowType::GROUPBOX: + case WindowType::FIXEDLINE: + { + // support transparency only for special controls + pWindow->SetBackground(); + pWindow->SetControlBackground(); + pWindow->SetPaintTransparent( true ); + break; + } + + default: + { + // default code which enables transparency for + // compound controls. It's not real transparency + // as most of these controls repaint their client + // area completely new. + if ( pWindow->IsCompoundControl() ) + pWindow->SetBackground(); + pWindow->SetControlBackground(); + break; + } + } + } + else + { + Color aColor; + if ( Value >>= aColor ) + { + pWindow->SetControlBackground( aColor ); + pWindow->SetBackground( aColor ); + switch ( eWinType ) + { + // reset paint transparent mode + case WindowType::FIXEDTEXT: + case WindowType::CHECKBOX: + case WindowType::RADIOBUTTON: + case WindowType::GROUPBOX: + case WindowType::FIXEDLINE: + pWindow->SetPaintTransparent( false ); + break; + default: + break; + } + pWindow->Invalidate(); // Invalidate if control does not respond to it + } + } + break; + case BASEPROPERTY_TEXTCOLOR: + if ( bVoid ) + { + pWindow->SetControlForeground(); + } + else + { + Color nColor ; + if ( Value >>= nColor ) + { + pWindow->SetTextColor( nColor ); + pWindow->SetControlForeground( nColor ); + } + } + break; + case BASEPROPERTY_TEXTLINECOLOR: + if ( bVoid ) + { + pWindow->SetTextLineColor(); + } + else + { + Color nColor; + if ( Value >>= nColor ) + pWindow->SetTextLineColor( nColor ); + } + break; + case BASEPROPERTY_FILLCOLOR: + if ( bVoid ) + pWindow->GetOutDev()->SetFillColor(); + else + { + Color nColor; + if ( Value >>= nColor ) + pWindow->GetOutDev()->SetFillColor( nColor ); + } + break; + case BASEPROPERTY_LINECOLOR: + if ( bVoid ) + pWindow->GetOutDev()->SetLineColor(); + else + { + Color nColor; + if ( Value >>= nColor ) + pWindow->GetOutDev()->SetLineColor( nColor ); + } + break; + case BASEPROPERTY_BORDER: + { + WinBits nStyle = pWindow->GetStyle(); + sal_uInt16 nTmp = 0; + Value >>= nTmp; + // clear any dodgy bits passed in, can come from dodgy extensions + nTmp &= o3tl::typed_flags::mask; + WindowBorderStyle nBorder = static_cast(nTmp); + if ( !bool(nBorder) ) + { + pWindow->SetStyle( nStyle & ~WB_BORDER ); + } + else + { + pWindow->SetStyle( nStyle | WB_BORDER ); + pWindow->SetBorderStyle( nBorder ); + } + } + break; + case BASEPROPERTY_TABSTOP: + { + WinBits nStyle = pWindow->GetStyle() & ~WB_TABSTOP; + if ( !bVoid ) + { + bool bTab = false; + Value >>= bTab; + if ( bTab ) + nStyle |= WB_TABSTOP; + else + nStyle |= WB_NOTABSTOP; + } + pWindow->SetStyle( nStyle ); + } + break; + case BASEPROPERTY_VERTICALALIGN: + { + VerticalAlignment eAlign = css::style::VerticalAlignment::VerticalAlignment_MAKE_FIXED_SIZE; + WinBits nStyle = pWindow->GetStyle(); + nStyle &= ~(WB_TOP|WB_VCENTER|WB_BOTTOM); + if ( !bVoid ) + Value >>= eAlign; + switch ( eAlign ) + { + case VerticalAlignment_TOP: + nStyle |= WB_TOP; + break; + case VerticalAlignment_MIDDLE: + nStyle |= WB_VCENTER; + break; + case VerticalAlignment_BOTTOM: + nStyle |= WB_BOTTOM; + break; + default: ; // for warning free code, MAKE_FIXED_SIZE + } + pWindow->SetStyle( nStyle ); + } + break; + case BASEPROPERTY_ALIGN: + { + sal_Int16 nAlign = PROPERTY_ALIGN_LEFT; + switch ( eWinType ) + { + case WindowType::COMBOBOX: + case WindowType::PUSHBUTTON: + case WindowType::OKBUTTON: + case WindowType::CANCELBUTTON: + case WindowType::HELPBUTTON: + nAlign = PROPERTY_ALIGN_CENTER; + [[fallthrough]]; + case WindowType::FIXEDTEXT: + case WindowType::EDIT: + case WindowType::MULTILINEEDIT: + case WindowType::CHECKBOX: + case WindowType::RADIOBUTTON: + case WindowType::LISTBOX: + { + WinBits nStyle = pWindow->GetStyle(); + nStyle &= ~(WB_LEFT|WB_CENTER|WB_RIGHT); + if ( !bVoid ) + Value >>= nAlign; + if ( nAlign == PROPERTY_ALIGN_LEFT ) + nStyle |= WB_LEFT; + else if ( nAlign == PROPERTY_ALIGN_CENTER ) + nStyle |= WB_CENTER; + else + nStyle |= WB_RIGHT; + pWindow->SetStyle( nStyle ); + } + break; + default: break; + } + } + break; + case BASEPROPERTY_MULTILINE: + { + if ( ( eWinType == WindowType::FIXEDTEXT ) + || ( eWinType == WindowType::CHECKBOX ) + || ( eWinType == WindowType::RADIOBUTTON ) + || ( eWinType == WindowType::PUSHBUTTON ) + || ( eWinType == WindowType::OKBUTTON ) + || ( eWinType == WindowType::CANCELBUTTON ) + || ( eWinType == WindowType::HELPBUTTON ) + ) + { + WinBits nStyle = pWindow->GetStyle(); + bool bMulti = false; + Value >>= bMulti; + if ( bMulti ) + nStyle |= WB_WORDBREAK; + else + nStyle &= ~WB_WORDBREAK; + pWindow->SetStyle( nStyle ); + } + } + break; + case BASEPROPERTY_ORIENTATION: + { + if ( eWinType == WindowType::FIXEDLINE) + { + sal_Int32 nOrientation = 0; + if ( Value >>= nOrientation ) + { + WinBits nStyle = pWindow->GetStyle(); + nStyle &= ~(WB_HORZ|WB_VERT); + if ( nOrientation == 0 ) + nStyle |= WB_HORZ; + else + nStyle |= WB_VERT; + + pWindow->SetStyle( nStyle ); + } + } + } + break; + case BASEPROPERTY_AUTOMNEMONICS: + { + bool bAutoMnemonics = false; + Value >>= bAutoMnemonics; + AllSettings aSettings = pWindow->GetSettings(); + StyleSettings aStyleSettings = aSettings.GetStyleSettings(); + if ( aStyleSettings.GetAutoMnemonic() != bAutoMnemonics ) + { + aStyleSettings.SetAutoMnemonic( bAutoMnemonics ); + aSettings.SetStyleSettings( aStyleSettings ); + pWindow->SetSettings( aSettings ); + } + } + break; + case BASEPROPERTY_MOUSETRANSPARENT: + { + bool bMouseTransparent = false; + Value >>= bMouseTransparent; + pWindow->SetMouseTransparent( bMouseTransparent ); + } + break; + case BASEPROPERTY_PAINTTRANSPARENT: + { + bool bPaintTransparent = false; + Value >>= bPaintTransparent; + pWindow->SetPaintTransparent( bPaintTransparent ); +// pWindow->SetBackground(); + } + break; + + case BASEPROPERTY_REPEAT: + { + bool bRepeat( false ); + Value >>= bRepeat; + + WinBits nStyle = pWindow->GetStyle(); + if ( bRepeat ) + nStyle |= WB_REPEAT; + else + nStyle &= ~WB_REPEAT; + pWindow->SetStyle( nStyle ); + } + break; + + case BASEPROPERTY_REPEAT_DELAY: + { + sal_Int32 nRepeatDelay = 0; + if ( Value >>= nRepeatDelay ) + { + AllSettings aSettings = pWindow->GetSettings(); + MouseSettings aMouseSettings = aSettings.GetMouseSettings(); + + aMouseSettings.SetButtonRepeat( nRepeatDelay ); + aSettings.SetMouseSettings( aMouseSettings ); + + pWindow->SetSettings( aSettings, true ); + } + } + break; + + case BASEPROPERTY_SYMBOL_COLOR: + ::toolkit::setColorSettings( pWindow, Value, &StyleSettings::SetButtonTextColor, &StyleSettings::GetButtonTextColor ); + break; + + case BASEPROPERTY_BORDERCOLOR: + ::toolkit::setColorSettings( pWindow, Value, &StyleSettings::SetMonoColor, &StyleSettings::GetMonoColor); + break; + } +} + +css::uno::Any VCLXWindow::getProperty( const OUString& PropertyName ) +{ + SolarMutexGuard aGuard; + + css::uno::Any aProp; + if ( GetWindow() ) + { + WindowType eWinType = GetWindow()->GetType(); + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_REFERENCE_DEVICE: + { + VclPtr pControl = GetAsDynamic(); + OSL_ENSURE( pControl, "VCLXWindow::setProperty( RefDevice ): need a Control for this!" ); + if ( !pControl ) + break; + + rtl::Reference pDevice = new VCLXDevice; + pDevice->SetOutputDevice( pControl->GetReferenceDevice() ); + aProp <<= Reference< XDevice >( pDevice ); + } + break; + + case BASEPROPERTY_CONTEXT_WRITING_MODE: + aProp <<= mpImpl->mnContextWritingMode; + break; + + case BASEPROPERTY_WRITING_MODE: + aProp <<= mpImpl->mnWritingMode; + break; + + case BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR: + { + MouseWheelBehaviour nVclBehavior = GetWindow()->GetSettings().GetMouseSettings().GetWheelBehavior(); + sal_uInt16 nBehavior = css::awt::MouseWheelBehavior::SCROLL_FOCUS_ONLY; + switch ( nVclBehavior ) + { + case MouseWheelBehaviour::Disable: nBehavior = css::awt::MouseWheelBehavior::SCROLL_DISABLED; break; + case MouseWheelBehaviour::FocusOnly: nBehavior = css::awt::MouseWheelBehavior::SCROLL_FOCUS_ONLY; break; + case MouseWheelBehaviour::ALWAYS: nBehavior = css::awt::MouseWheelBehavior::SCROLL_ALWAYS; break; + default: + OSL_FAIL( "VCLXWindow::getProperty( 'MouseWheelBehavior' ): illegal VCL value!" ); + } + aProp <<= nBehavior; + } + break; + + case BASEPROPERTY_NATIVE_WIDGET_LOOK: + aProp <<= GetWindow()->IsNativeWidgetEnabled(); + break; + + case BASEPROPERTY_ENABLED: + aProp <<= GetWindow()->IsEnabled(); + break; + + case BASEPROPERTY_ENABLEVISIBLE: + aProp <<= mpImpl->isEnableVisible(); + break; + + case BASEPROPERTY_HIGHCONTRASTMODE: + aProp <<= GetWindow()->GetSettings().GetStyleSettings().GetHighContrastMode(); + break; + + case BASEPROPERTY_TEXT: + case BASEPROPERTY_LABEL: + case BASEPROPERTY_TITLE: + { + OUString aText = GetWindow()->GetText(); + aProp <<= aText; + } + break; + case BASEPROPERTY_ACCESSIBLENAME: + { + OUString aText = GetWindow()->GetAccessibleName(); + aProp <<= aText; + } + break; + case BASEPROPERTY_HELPTEXT: + { + OUString aText = GetWindow()->GetQuickHelpText(); + aProp <<= aText; + } + break; + case BASEPROPERTY_HELPURL: + { + OUString aHelpId( OStringToOUString( GetWindow()->GetHelpId(), RTL_TEXTENCODING_UTF8 ) ); + aProp <<= aHelpId; + } + break; + case BASEPROPERTY_FONTDESCRIPTOR: + { + vcl::Font aFont = GetWindow()->GetControlFont(); + css::awt::FontDescriptor aFD = VCLUnoHelper::CreateFontDescriptor( aFont ); + aProp <<= aFD; + } + break; + case BASEPROPERTY_BACKGROUNDCOLOR: + aProp <<= GetWindow()->GetControlBackground(); + break; + case BASEPROPERTY_DISPLAYBACKGROUNDCOLOR: + aProp <<= GetWindow()->GetBackgroundColor(); + break; + case BASEPROPERTY_FONTRELIEF: + aProp <<= static_cast(GetWindow()->GetControlFont().GetRelief()); + break; + case BASEPROPERTY_FONTEMPHASISMARK: + aProp <<= static_cast(GetWindow()->GetControlFont().GetEmphasisMark()); + break; + case BASEPROPERTY_TEXTCOLOR: + aProp <<= GetWindow()->GetControlForeground(); + break; + case BASEPROPERTY_TEXTLINECOLOR: + aProp <<= GetWindow()->GetTextLineColor(); + break; + case BASEPROPERTY_FILLCOLOR: + aProp <<= GetWindow()->GetOutDev()->GetFillColor(); + break; + case BASEPROPERTY_LINECOLOR: + aProp <<= GetWindow()->GetOutDev()->GetLineColor(); + break; + case BASEPROPERTY_BORDER: + { + WindowBorderStyle nBorder = WindowBorderStyle::NONE; + if ( GetWindow()->GetStyle() & WB_BORDER ) + nBorder = GetWindow()->GetBorderStyle(); + aProp <<= static_cast(nBorder); + } + break; + case BASEPROPERTY_TABSTOP: + aProp <<= ( GetWindow()->GetStyle() & WB_TABSTOP ) != 0; + break; + case BASEPROPERTY_VERTICALALIGN: + { + WinBits nStyle = GetWindow()->GetStyle(); + if ( nStyle & WB_TOP ) + aProp <<= VerticalAlignment_TOP; + else if ( nStyle & WB_VCENTER ) + aProp <<= VerticalAlignment_MIDDLE; + else if ( nStyle & WB_BOTTOM ) + aProp <<= VerticalAlignment_BOTTOM; + } + break; + case BASEPROPERTY_ALIGN: + { + switch ( eWinType ) + { + case WindowType::FIXEDTEXT: + case WindowType::EDIT: + case WindowType::MULTILINEEDIT: + case WindowType::CHECKBOX: + case WindowType::RADIOBUTTON: + case WindowType::LISTBOX: + case WindowType::COMBOBOX: + case WindowType::PUSHBUTTON: + case WindowType::OKBUTTON: + case WindowType::CANCELBUTTON: + case WindowType::HELPBUTTON: + { + WinBits nStyle = GetWindow()->GetStyle(); + if ( nStyle & WB_LEFT ) + aProp <<= sal_Int16(PROPERTY_ALIGN_LEFT); + else if ( nStyle & WB_CENTER ) + aProp <<= sal_Int16(PROPERTY_ALIGN_CENTER); + else if ( nStyle & WB_RIGHT ) + aProp <<= sal_Int16(PROPERTY_ALIGN_RIGHT); + } + break; + default: break; + } + } + break; + case BASEPROPERTY_MULTILINE: + { + if ( ( eWinType == WindowType::FIXEDTEXT ) + || ( eWinType == WindowType::CHECKBOX ) + || ( eWinType == WindowType::RADIOBUTTON ) + || ( eWinType == WindowType::PUSHBUTTON ) + || ( eWinType == WindowType::OKBUTTON ) + || ( eWinType == WindowType::CANCELBUTTON ) + || ( eWinType == WindowType::HELPBUTTON ) + ) + aProp <<= ( GetWindow()->GetStyle() & WB_WORDBREAK ) != 0; + } + break; + case BASEPROPERTY_AUTOMNEMONICS: + { + bool bAutoMnemonics = GetWindow()->GetSettings().GetStyleSettings().GetAutoMnemonic(); + aProp <<= bAutoMnemonics; + } + break; + case BASEPROPERTY_MOUSETRANSPARENT: + { + bool bMouseTransparent = GetWindow()->IsMouseTransparent(); + aProp <<= bMouseTransparent; + } + break; + case BASEPROPERTY_PAINTTRANSPARENT: + { + bool bPaintTransparent = GetWindow()->IsPaintTransparent(); + aProp <<= bPaintTransparent; + } + break; + + case BASEPROPERTY_REPEAT: + aProp <<= ( 0 != ( GetWindow()->GetStyle() & WB_REPEAT ) ); + break; + + case BASEPROPERTY_REPEAT_DELAY: + { + sal_Int32 nButtonRepeat = GetWindow()->GetSettings().GetMouseSettings().GetButtonRepeat(); + aProp <<= nButtonRepeat; + } + break; + + case BASEPROPERTY_SYMBOL_COLOR: + aProp <<= GetWindow()->GetSettings().GetStyleSettings().GetButtonTextColor(); + break; + + case BASEPROPERTY_BORDERCOLOR: + aProp <<= GetWindow()->GetSettings().GetStyleSettings().GetMonoColor(); + break; + } + } + return aProp; +} + + +// css::awt::XLayoutConstrains +css::awt::Size VCLXWindow::getMinimumSize( ) +{ + SolarMutexGuard aGuard; + + // Use this method only for those components which can be created through + // css::awt::Toolkit , but do not have an interface + + Size aSz; + if ( GetWindow() ) + { + WindowType nWinType = GetWindow()->GetType(); + switch ( nWinType ) + { + case WindowType::CONTROL: + aSz.setWidth( GetWindow()->GetTextWidth( GetWindow()->GetText() )+2*12 ); + aSz.setHeight( GetWindow()->GetTextHeight()+2*6 ); + break; + + case WindowType::PATTERNBOX: + case WindowType::NUMERICBOX: + case WindowType::METRICBOX: + case WindowType::CURRENCYBOX: + case WindowType::DATEBOX: + case WindowType::TIMEBOX: + case WindowType::LONGCURRENCYBOX: + aSz.setWidth( GetWindow()->GetTextWidth( GetWindow()->GetText() )+2*2 ); + aSz.setHeight( GetWindow()->GetTextHeight()+2*2 ); + break; + case WindowType::SCROLLBARBOX: + return VCLXScrollBar::implGetMinimumSize( GetWindow() ); + default: + aSz = GetWindow()->get_preferred_size(); + } + } + + return css::awt::Size( aSz.Width(), aSz.Height() ); +} + +css::awt::Size VCLXWindow::getPreferredSize( ) +{ + return getMinimumSize(); +} + +css::awt::Size VCLXWindow::calcAdjustedSize( const css::awt::Size& rNewSize ) +{ + SolarMutexGuard aGuard; + + css::awt::Size aNewSize( rNewSize ); + css::awt::Size aMinSize = getMinimumSize(); + + if ( aNewSize.Width < aMinSize.Width ) + aNewSize.Width = aMinSize.Width; + if ( aNewSize.Height < aMinSize.Height ) + aNewSize.Height = aMinSize.Height; + + return aNewSize; +} + + +// css::awt::XView +sal_Bool VCLXWindow::setGraphics( const css::uno::Reference< css::awt::XGraphics >& rxDevice ) +{ + SolarMutexGuard aGuard; + + if ( VCLUnoHelper::GetOutputDevice( rxDevice ) ) + mpImpl->mxViewGraphics = rxDevice; + else + mpImpl->mxViewGraphics = nullptr; + + return mpImpl->mxViewGraphics.is(); +} + +css::uno::Reference< css::awt::XGraphics > VCLXWindow::getGraphics( ) +{ + SolarMutexGuard aGuard; + + return mpImpl->mxViewGraphics; +} + +css::awt::Size VCLXWindow::getSize( ) +{ + SolarMutexGuard aGuard; + + Size aSz; + if ( GetWindow() ) + aSz = GetWindow()->GetSizePixel(); + return css::awt::Size( aSz.Width(), aSz.Height() ); +} + +void VCLXWindow::draw( sal_Int32 nX, sal_Int32 nY ) +{ + SolarMutexGuard aGuard; + + VclPtr pWindow = GetWindow(); + if ( !pWindow ) + return; + + if ( !(isDesignMode() || mpImpl->isEnableVisible()) ) + return; + + OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( mpImpl->mxViewGraphics ); + if (!pDev) + pDev = pWindow->GetParent()->GetOutDev(); + TabPage* pTabPage = dynamic_cast< TabPage* >( pWindow.get() ); + if ( pTabPage ) + { + Point aPos( nX, nY ); + aPos = pDev->PixelToLogic( aPos ); + pTabPage->Draw( pDev, aPos, SystemTextColorFlags::NONE ); + return; + } + + Point aPos( nX, nY ); + + if ( pWindow->GetParent() && !pWindow->IsSystemWindow() && ( pWindow->GetParent()->GetOutDev() == pDev ) ) + { + // #i40647# don't draw here if this is a recursive call + // sometimes this is called recursively, because the Update call on the parent + // (strangely) triggers another paint. Prevent a stack overflow here + // Yes, this is only fixing symptoms for the moment... + // #i40647# / 2005-01-18 / frank.schoenheit@sun.com + if ( !mpImpl->getDrawingOntoParent_ref() ) + { + ::comphelper::FlagGuard aDrawingflagGuard( mpImpl->getDrawingOntoParent_ref() ); + + bool bWasVisible = pWindow->IsVisible(); + Point aOldPos( pWindow->GetPosPixel() ); + + if ( bWasVisible && aOldPos == aPos ) + { + pWindow->PaintImmediately(); + return; + } + + pWindow->SetPosPixel( aPos ); + + // Update parent first to avoid painting the parent upon the update + // of this window, as it may otherwise cause the parent + // to hide this window again + if( pWindow->GetParent() ) + pWindow->GetParent()->PaintImmediately(); + + pWindow->Show(); + pWindow->PaintImmediately(); + pWindow->SetParentUpdateMode( false ); + pWindow->Hide(); + pWindow->SetParentUpdateMode( true ); + + pWindow->SetPosPixel( aOldPos ); + if ( bWasVisible ) + pWindow->Show(); + } + } + else if ( pDev ) + { + Point aP = pDev->PixelToLogic( aPos ); + + vcl::PDFExtOutDevData* pPDFExport = dynamic_cast(pDev->GetExtOutDevData()); + bool bDrawSimple = ( pDev->GetOutDevType() == OUTDEV_PRINTER ) + || ( pDev->GetOutDevViewType() == OutDevViewType::PrintPreview ) + || ( pPDFExport != nullptr ); + if ( bDrawSimple ) + { + pWindow->Draw( pDev, aP, SystemTextColorFlags::NoControls ); + } + else + { + bool bOldNW =pWindow->IsNativeWidgetEnabled(); + if( bOldNW ) + pWindow->EnableNativeWidget(false); + pWindow->PaintToDevice( pDev, aP ); + if( bOldNW ) + pWindow->EnableNativeWidget(); + } + } +} + +void VCLXWindow::setZoom( float fZoomX, float /*fZoomY*/ ) +{ + SolarMutexGuard aGuard; + + if ( GetWindow() ) + { + // Fraction::Fraction takes a double, but we have a float only. + // The implicit conversion from float to double can result in a precision loss, i.e. 1.2 is converted to + // 1.200000000047something. To prevent this, we convert explicitly to double, and round it. + double nZoom( fZoomX ); + Fraction aZoom(::rtl::math::round(nZoom, 4)); + aZoom.ReduceInaccurate(10); // to avoid runovers and BigInt mapping + GetWindow()->SetZoom(aZoom); + } +} + +// css::lang::XEventListener +void SAL_CALL VCLXWindow::disposing( const css::lang::EventObject& _rSource ) +{ + SolarMutexGuard aGuard; + + if (mpImpl->mbDisposing) + return; + + // check if it comes from our AccessibleContext + uno::Reference< uno::XInterface > aAC( mpImpl->mxAccessibleContext, uno::UNO_QUERY ); + uno::Reference< uno::XInterface > xSource( _rSource.Source, uno::UNO_QUERY ); + + if ( aAC.get() == xSource.get() ) + { // yep, it does + mpImpl->mxAccessibleContext.clear(); + } +} + +// css::accessibility::XAccessible +css::uno::Reference< css::accessibility::XAccessibleContext > VCLXWindow::getAccessibleContext( ) +{ + SolarMutexGuard aGuard; + + // already disposed + if (mpImpl->mbDisposing) + return uno::Reference< accessibility::XAccessibleContext >(); + + if ( !mpImpl->mxAccessibleContext.is() && GetWindow() ) + { + mpImpl->mxAccessibleContext = CreateAccessibleContext(); + + // add as event listener to this component + // in case somebody disposes it, we do not want to have a (though weak) reference to a dead + // object + uno::Reference< lang::XComponent > xComp( mpImpl->mxAccessibleContext, uno::UNO_QUERY ); + if ( xComp.is() ) + xComp->addEventListener( this ); + } + + return mpImpl->mxAccessibleContext; +} + +// css::awt::XDockable +void SAL_CALL VCLXWindow::addDockableWindowListener( const css::uno::Reference< css::awt::XDockableWindowListener >& xListener ) +{ + SolarMutexGuard aGuard; + + if (!mpImpl->mbDisposing && xListener.is() ) + mpImpl->getDockableWindowListeners().addInterface( xListener ); + +} + +void SAL_CALL VCLXWindow::removeDockableWindowListener( const css::uno::Reference< css::awt::XDockableWindowListener >& xListener ) +{ + SolarMutexGuard aGuard; + + if (!mpImpl->mbDisposing) + mpImpl->getDockableWindowListeners().removeInterface( xListener ); +} + +void SAL_CALL VCLXWindow::enableDocking( sal_Bool bEnable ) +{ + SolarMutexGuard aGuard; + + VclPtr pWindow = GetWindow(); + if ( pWindow ) + pWindow->EnableDocking( bEnable ); +} + +sal_Bool SAL_CALL VCLXWindow::isFloating( ) +{ + SolarMutexGuard aGuard; + + VclPtr pWindow = GetWindow(); + if( pWindow ) + return vcl::Window::GetDockingManager()->IsFloating( pWindow ); + else + return false; +} + +void SAL_CALL VCLXWindow::setFloatingMode( sal_Bool bFloating ) +{ + SolarMutexGuard aGuard; + + VclPtr pWindow = GetWindow(); + if( pWindow ) + vcl::Window::GetDockingManager()->SetFloatingMode( pWindow, bFloating ); +} + +sal_Bool SAL_CALL VCLXWindow::isLocked( ) +{ + SolarMutexGuard aGuard; + + VclPtr pWindow = GetWindow(); + if( pWindow ) + return vcl::Window::GetDockingManager()->IsLocked( pWindow ); + else + return false; +} + +void SAL_CALL VCLXWindow::lock( ) +{ + SolarMutexGuard aGuard; + + VclPtr pWindow = GetWindow(); + if( pWindow && !vcl::Window::GetDockingManager()->IsFloating( pWindow ) ) + vcl::Window::GetDockingManager()->Lock( pWindow ); +} + +void SAL_CALL VCLXWindow::unlock( ) +{ + SolarMutexGuard aGuard; + + VclPtr pWindow = GetWindow(); + if( pWindow && !vcl::Window::GetDockingManager()->IsFloating( pWindow ) ) + vcl::Window::GetDockingManager()->Unlock( pWindow ); +} + +void SAL_CALL VCLXWindow::startPopupMode( const css::awt::Rectangle& ) +{ + // deprecated +} + +sal_Bool SAL_CALL VCLXWindow::isInPopupMode( ) +{ + // deprecated + return false; +} + + +// css::awt::XWindow2 + +void SAL_CALL VCLXWindow::setOutputSize( const css::awt::Size& aSize ) +{ + SolarMutexGuard aGuard; + if( VclPtr pWindow = GetWindow() ) + pWindow->SetOutputSizePixel( VCLSize( aSize ) ); +} + +css::awt::Size SAL_CALL VCLXWindow::getOutputSize( ) +{ + SolarMutexGuard aGuard; + if( VclPtr pWindow = GetWindow() ) + return AWTSize( pWindow->GetOutputSizePixel() ); + else + return css::awt::Size(); +} + +sal_Bool SAL_CALL VCLXWindow::isVisible( ) +{ + SolarMutexGuard aGuard; + if( GetWindow() ) + return GetWindow()->IsVisible(); + else + return false; +} + +sal_Bool SAL_CALL VCLXWindow::isActive( ) +{ + SolarMutexGuard aGuard; + if( GetWindow() ) + return GetWindow()->IsActive(); + else + return false; + +} + +sal_Bool SAL_CALL VCLXWindow::isEnabled( ) +{ + SolarMutexGuard aGuard; + if( GetWindow() ) + return GetWindow()->IsEnabled(); + else + return false; +} + +sal_Bool SAL_CALL VCLXWindow::hasFocus( ) +{ + SolarMutexGuard aGuard; + if( GetWindow() ) + return GetWindow()->HasFocus(); + else + return false; +} + +// css::beans::XPropertySetInfo + +UnoPropertyArrayHelper * +VCLXWindow::GetPropHelper() +{ + SolarMutexGuard aGuard; + if ( mpImpl->mpPropHelper == nullptr ) + { + std::vector< sal_uInt16 > aIDs; + GetPropertyIds( aIDs ); + mpImpl->mpPropHelper.reset( new UnoPropertyArrayHelper( aIDs ) ); + } + return mpImpl->mpPropHelper.get(); +} + +css::uno::Sequence< css::beans::Property > SAL_CALL +VCLXWindow::getProperties() +{ + return GetPropHelper()->getProperties(); +} +css::beans::Property SAL_CALL +VCLXWindow::getPropertyByName( const OUString& rName ) +{ + return GetPropHelper()->getPropertyByName( rName ); +} + +sal_Bool SAL_CALL +VCLXWindow::hasPropertyByName( const OUString& rName ) +{ + return GetPropHelper()->hasPropertyByName( rName ); +} + +Reference< XStyleSettings > SAL_CALL VCLXWindow::getStyleSettings() +{ + return mpImpl->getStyleSettings(); +} + +bool VCLXWindow::IsDisposed() const +{ + return mpImpl->mbDisposing; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/source/awt/vclxwindow1.cxx b/toolkit/source/awt/vclxwindow1.cxx new file mode 100644 index 000000000..7b7b7192f --- /dev/null +++ b/toolkit/source/awt/vclxwindow1.cxx @@ -0,0 +1,94 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include +#include +#include +#include + +#ifdef _WIN32 +#include +#include +#elif defined(MACOSX) +#include +#include +#include +#endif +#include + +/// helper method to set a window handle into a SystemParentData struct +void VCLXWindow::SetSystemParent_Impl(const css::uno::Any& rHandle) +{ + // does only work for WorkWindows + VclPtr pWindow = GetWindow(); + if (pWindow->GetType() != WindowType::WORKWINDOW) + { + css::uno::RuntimeException aException; + aException.Message = "not a work window"; + throw aException; + } + + // use sal_Int64 here to accommodate all int types + // uno::Any shift operator will upcast if necessary + sal_Int64 nHandle = 0; + bool bXEmbed = false; + bool bThrow = false; + if (!(rHandle >>= nHandle)) + { + css::uno::Sequence aProps; + if (rHandle >>= aProps) + { + for (const css::beans::NamedValue& rProp : std::as_const(aProps)) + { + if (rProp.Name == "WINDOW") + rProp.Value >>= nHandle; + else if (rProp.Name == "XEMBED") + rProp.Value >>= bXEmbed; + } + } + else + bThrow = true; + } + if (bThrow) + { + css::uno::RuntimeException aException; + aException.Message = "incorrect window handle type"; + throw aException; + } + // create system parent data + SystemParentData aSysParentData; + aSysParentData.nSize = sizeof(SystemParentData); +#if defined(_WIN32) + aSysParentData.hWnd = reinterpret_cast(nHandle); +#elif defined(MACOSX) + aSysParentData.pView = reinterpret_cast(nHandle); +#elif defined(ANDROID) + // Nothing +#elif defined(IOS) + // Nothing +#elif defined(UNX) + aSysParentData.aWindow = nHandle; + aSysParentData.bXEmbedSupport = bXEmbed; +#endif + + // set system parent + static_cast(pWindow.get())->SetPluginParent(&aSysParentData); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/source/awt/vclxwindows.cxx b/toolkit/source/awt/vclxwindows.cxx new file mode 100644 index 000000000..e444d6d3a --- /dev/null +++ b/toolkit/source/awt/vclxwindows.cxx @@ -0,0 +1,8220 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include +#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 +#include +#include "vclxwindows_internal.hxx" +#include + +using ::com::sun::star::uno::Any; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::RuntimeException; +using ::com::sun::star::lang::EventObject; +using ::com::sun::star::awt::ItemListEvent; +using ::com::sun::star::awt::XItemList; +using ::com::sun::star::graphic::XGraphic; +using ::com::sun::star::graphic::XGraphicProvider; + +using namespace ::com::sun::star; +using namespace ::com::sun::star::awt::VisualEffect; +namespace ImageScaleMode = ::com::sun::star::awt::ImageScaleMode; + +static double ImplCalcLongValue( double nValue, sal_uInt16 nDigits ) +{ + double n = nValue; + for ( sal_uInt16 d = 0; d < nDigits; d++ ) + n *= 10; + return n; +} + +static double ImplCalcDoubleValue( double nValue, sal_uInt16 nDigits ) +{ + double n = nValue; + for ( sal_uInt16 d = 0; d < nDigits; d++ ) + n /= 10; + return n; +} + +namespace toolkit +{ + /** sets the "face color" for button like controls (scroll bar, spin button) + */ + void setButtonLikeFaceColor( vcl::Window* _pWindow, const css::uno::Any& _rColorValue ) + { + AllSettings aSettings = _pWindow->GetSettings(); + StyleSettings aStyleSettings = aSettings.GetStyleSettings(); + + if ( !_rColorValue.hasValue() ) + { + const StyleSettings& aAppStyle = Application::GetSettings().GetStyleSettings(); + aStyleSettings.SetFaceColor( aAppStyle.GetFaceColor( ) ); + aStyleSettings.SetCheckedColor( aAppStyle.GetCheckedColor( ) ); + aStyleSettings.SetLightBorderColor( aAppStyle.GetLightBorderColor() ); + aStyleSettings.SetLightColor( aAppStyle.GetLightColor() ); + aStyleSettings.SetShadowColor( aAppStyle.GetShadowColor() ); + aStyleSettings.SetDarkShadowColor( aAppStyle.GetDarkShadowColor() ); + } + else + { + Color nBackgroundColor; + _rColorValue >>= nBackgroundColor; + aStyleSettings.SetFaceColor( nBackgroundColor ); + + // for the real background (everything except the buttons and the thumb), + // use an average between the desired color and "white" + Color aWhite( COL_WHITE ); + Color aCheckedBackground( nBackgroundColor ); + aCheckedBackground.SetRed( ( aCheckedBackground.GetRed() + aWhite.GetRed() ) / 2 ); + aCheckedBackground.SetGreen( ( aCheckedBackground.GetGreen() + aWhite.GetGreen() ) / 2 ); + aCheckedBackground.SetBlue( ( aCheckedBackground.GetBlue() + aWhite.GetBlue() ) / 2 ); + aStyleSettings.SetCheckedColor( aCheckedBackground ); + + sal_Int32 nBackgroundLuminance = nBackgroundColor.GetLuminance(); + sal_Int32 nWhiteLuminance = COL_WHITE.GetLuminance(); + + Color aLightShadow( nBackgroundColor ); + aLightShadow.IncreaseLuminance( static_cast( ( nWhiteLuminance - nBackgroundLuminance ) * 2 / 3 ) ); + aStyleSettings.SetLightBorderColor( aLightShadow ); + + Color aLight( nBackgroundColor ); + aLight.IncreaseLuminance( static_cast( ( nWhiteLuminance - nBackgroundLuminance ) * 1 / 3 ) ); + aStyleSettings.SetLightColor( aLight ); + + Color aShadow( nBackgroundColor ); + aShadow.DecreaseLuminance( static_cast( nBackgroundLuminance * 1 / 3 ) ); + aStyleSettings.SetShadowColor( aShadow ); + + Color aDarkShadow( nBackgroundColor ); + aDarkShadow.DecreaseLuminance( static_cast( nBackgroundLuminance * 2 / 3 ) ); + aStyleSettings.SetDarkShadowColor( aDarkShadow ); + } + + aSettings.SetStyleSettings( aStyleSettings ); + _pWindow->SetSettings( aSettings, true ); + } + + Any getButtonLikeFaceColor( const vcl::Window* _pWindow ) + { + Color nBackgroundColor = _pWindow->GetSettings().GetStyleSettings().GetFaceColor(); + return Any( sal_Int32(nBackgroundColor) ); + } + + static void adjustBooleanWindowStyle( const Any& _rValue, vcl::Window* _pWindow, WinBits _nBits, bool _bInverseSemantics ) + { + WinBits nStyle = _pWindow->GetStyle(); + bool bValue( false ); + OSL_VERIFY( _rValue >>= bValue ); + if ( bValue != _bInverseSemantics ) + nStyle |= _nBits; + else + nStyle &= ~_nBits; + _pWindow->SetStyle( nStyle ); + } + + static void setVisualEffect( const Any& _rValue, vcl::Window* _pWindow ) + { + AllSettings aSettings = _pWindow->GetSettings(); + StyleSettings aStyleSettings = aSettings.GetStyleSettings(); + + sal_Int16 nStyle = LOOK3D; + OSL_VERIFY( _rValue >>= nStyle ); + switch ( nStyle ) + { + case FLAT: + aStyleSettings.SetOptions( aStyleSettings.GetOptions() | StyleSettingsOptions::Mono ); + break; + case LOOK3D: + default: + aStyleSettings.SetOptions( aStyleSettings.GetOptions() & ~StyleSettingsOptions::Mono ); + } + aSettings.SetStyleSettings( aStyleSettings ); + _pWindow->SetSettings( aSettings ); + } + + static Any getVisualEffect( vcl::Window const * _pWindow ) + { + Any aEffect; + + StyleSettings aStyleSettings = _pWindow->GetSettings().GetStyleSettings(); + if ( aStyleSettings.GetOptions() & StyleSettingsOptions::Mono ) + aEffect <<= sal_Int16(FLAT); + else + aEffect <<= sal_Int16(LOOK3D); + return aEffect; + } +} + + + + +void VCLXGraphicControl::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds ) +{ + VCLXWindow::ImplGetPropertyIds( rIds ); +} + +void VCLXGraphicControl::ImplSetNewImage() +{ + OSL_PRECOND( GetWindow(), "VCLXGraphicControl::ImplSetNewImage: window is required to be not-NULL!" ); + VclPtr< Button > pButton = GetAsDynamic< Button >(); + pButton->SetModeImage( GetImage() ); +} + +void VCLXGraphicControl::setPosSize( sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height, sal_Int16 Flags ) +{ + SolarMutexGuard aGuard; + + if ( GetWindow() ) + { + Size aOldSize = GetWindow()->GetSizePixel(); + VCLXWindow::setPosSize( X, Y, Width, Height, Flags ); + if ( ( aOldSize.Width() != Width ) || ( aOldSize.Height() != Height ) ) + ImplSetNewImage(); + } +} + +void VCLXGraphicControl::setProperty( const OUString& PropertyName, const css::uno::Any& Value) +{ + SolarMutexGuard aGuard; + + if ( !GetWindow() ) + return; + + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_GRAPHIC: + { + Reference< XGraphic > xGraphic; + OSL_VERIFY( Value >>= xGraphic ); + maImage = Image( xGraphic ); + ImplSetNewImage(); + } + break; + + case BASEPROPERTY_IMAGEALIGN: + { + WindowType eType = GetWindow()->GetType(); + if ( ( eType == WindowType::PUSHBUTTON ) + || ( eType == WindowType::RADIOBUTTON ) + || ( eType == WindowType::CHECKBOX ) + ) + { + sal_Int16 nAlignment = sal_Int16(); + if ( Value >>= nAlignment ) + GetAs< Button >()->SetImageAlign( static_cast< ImageAlign >( nAlignment ) ); + } + } + break; + case BASEPROPERTY_IMAGEPOSITION: + { + WindowType eType = GetWindow()->GetType(); + if ( ( eType == WindowType::PUSHBUTTON ) + || ( eType == WindowType::RADIOBUTTON ) + || ( eType == WindowType::CHECKBOX ) + ) + { + sal_Int16 nImagePosition = 2; + OSL_VERIFY( Value >>= nImagePosition ); + GetAs