1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 #ifndef SVX_SIDEBAR_INSERT_PROPERTY_PAGE_HXX
23 #define SVX_SIDEBAR_INSERT_PROPERTY_PAGE_HXX
24 
25 #include <boost/scoped_ptr.hpp>
26 
27 #include <vcl/ctrl.hxx>
28 #include <com/sun/star/frame/XFrame.hpp>
29 #include <com/sun/star/frame/XDispatch.hpp>
30 #include <com/sun/star/frame/XToolbarController.hpp>
31 
32 #include <map>
33 
34 
35 namespace css = ::com::sun::star;
36 namespace cssu = ::com::sun::star::uno;
37 
38 class ToolBox;
39 
40 namespace svx { namespace sidebar {
41 
42 class InsertPropertyPanel
43     : public Control
44 {
45 public:
46     InsertPropertyPanel (
47         Window* pParent,
48         const cssu::Reference<css::frame::XFrame>& rxFrame);
49     virtual ~InsertPropertyPanel (void);
50 
51 private:
52 	::boost::scoped_ptr<Window> mpStandardShapesBackground;
53     ::boost::scoped_ptr<ToolBox> mpStandardShapesToolBox;
54 	::boost::scoped_ptr<Window> mpCustomShapesBackground;
55     ::boost::scoped_ptr<ToolBox> mpCustomShapesToolBox;
56     class ItemDescriptor
57     {
58     public:
59         cssu::Reference<css::frame::XToolbarController> mxController;
60         css::util::URL maURL;
61         rtl::OUString msCurrentCommand;
62         cssu::Reference<css::frame::XDispatch> mxDispatch;
63     };
64     typedef ::std::map<sal_uInt16, ItemDescriptor> ControllerContainer;
65     ControllerContainer maControllers;
66     const cssu::Reference<css::frame::XFrame> mxFrame;
67 
68     /** Add listeners to toolbox and update its size to match its
69         content.
70     */
71     void SetupToolBox (ToolBox& rToolBox);
72     cssu::Reference<css::frame::XToolbarController> GetControllerForItemId (
73         const sal_uInt16 nItemId) const;
74     ToolBox* GetToolBoxForItemId (const sal_uInt16 nItemId) const;
75     sal_uInt16 GetItemIdForSubToolbarName (
76         const ::rtl::OUString& rsCOmmandName) const;
77 
78     /** Create toolbox controller for one item.
79     */
80     void CreateController (
81         const sal_uInt16 nItemId);
82     void UpdateIcons (void);
83 
84     DECL_LINK(DropDownClickHandler, ToolBox*);
85     DECL_LINK(ClickHandler, ToolBox*);
86     DECL_LINK(DoubleClickHandler, ToolBox*);
87     DECL_LINK(SelectHandler, ToolBox*);
88     DECL_LINK(WindowEventListener, VclSimpleEvent*);
89     DECL_LINK(Activate, ToolBox*);
90     DECL_LINK(Deactivate, ToolBox*);
91 };
92 
93 
94 } } // end of namespace ::svx::sidebar
95 
96 #endif
97