merge the formfield patch from ooo-build
[ooovba.git] / framework / inc / uielement / toolbarmerger.hxx
blob64e89a58fb27a72f217d181a3f515495aa8b83a6
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: toolbarmerger.hxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef __FRAMEWORK_UIELEMENT_TOOLBARMERGER_HXX_
32 #define __FRAMEWORK_UIELEMENT_TOOLBARMERGER_HXX_
34 #include <uielement/comboboxtoolbarcontroller.hxx>
35 #include <uielement/imagebuttontoolbarcontroller.hxx>
36 #include <uielement/togglebuttontoolbarcontroller.hxx>
37 #include <uielement/buttontoolbarcontroller.hxx>
38 #include <uielement/spinfieldtoolbarcontroller.hxx>
39 #include <uielement/edittoolbarcontroller.hxx>
40 #include <uielement/dropdownboxtoolbarcontroller.hxx>
41 #include <uielement/commandinfo.hxx>
43 #include <com/sun/star/beans/PropertyValue.hpp>
45 #include <svtools/toolboxcontroller.hxx>
47 #include <rtl/ustring.hxx>
48 #include <vcl/toolbox.hxx>
50 namespace framework
53 struct AddonsParams
55 ::rtl::OUString aImageId;
56 ::rtl::OUString aTarget;
57 ::rtl::OUString aControlType;
60 struct AddonToolbarItem
62 ::rtl::OUString aCommandURL;
63 ::rtl::OUString aLabel;
64 ::rtl::OUString aImageIdentifier;
65 ::rtl::OUString aTarget;
66 ::rtl::OUString aContext;
67 ::rtl::OUString aControlType;
68 sal_uInt16 nWidth;
71 typedef ::std::vector< AddonToolbarItem > AddonToolbarItemContainer;
73 struct ReferenceToolbarPathInfo
75 ToolBox* pToolbar;
76 sal_uInt16 nPos;
77 bool bResult;
80 class ToolBarMerger
82 public:
83 static bool IsCorrectContext( const ::rtl::OUString& aContext, const ::rtl::OUString& aModuleIdentifier );
85 static bool ConvertSeqSeqToVector( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > > rSequence,
86 AddonToolbarItemContainer& rContainer );
88 static void ConvertSequenceToValues( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > rSequence,
89 ::rtl::OUString& rCommandURL,
90 ::rtl::OUString& rLabel,
91 ::rtl::OUString& rImageIdentifier,
92 ::rtl::OUString& rTarget,
93 ::rtl::OUString& rContext,
94 ::rtl::OUString& rControlType,
95 sal_uInt16& rWidth );
97 static ReferenceToolbarPathInfo FindReferencePoint( ToolBox* pToolbar,
98 const ::rtl::OUString& rReferencePoint );
100 static bool ProcessMergeOperation( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame,
101 ToolBox* pToolbar,
102 sal_uInt16 nPos,
103 sal_uInt16& rItemId,
104 CommandToInfoMap& rCommandMap,
105 const ::rtl::OUString& rModuleIdentifier,
106 const ::rtl::OUString& rMergeCommand,
107 const ::rtl::OUString& rMergeCommandParameter,
108 const AddonToolbarItemContainer& rItems );
110 static bool ProcessMergeFallback( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame,
111 ToolBox* pToolbar,
112 sal_uInt16 nPos,
113 sal_uInt16& rItemId,
114 CommandToInfoMap& rCommandMap,
115 const ::rtl::OUString& rModuleIdentifier,
116 const ::rtl::OUString& rMergeCommand,
117 const ::rtl::OUString& rMergeFallback,
118 const AddonToolbarItemContainer& rItems );
120 static bool MergeItems( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame,
121 ToolBox* pToolbar,
122 sal_uInt16 nPos,
123 sal_uInt16 nModIndex,
124 sal_uInt16& rItemId,
125 CommandToInfoMap& rCommandMap,
126 const ::rtl::OUString& rModuleIdentifier,
127 const AddonToolbarItemContainer& rAddonToolbarItems );
129 static bool ReplaceItem( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame,
130 ToolBox* pToolbar,
131 sal_uInt16 nPos,
132 sal_uInt16& rItemId,
133 CommandToInfoMap& rCommandMap,
134 const ::rtl::OUString& rModuleIdentifier,
135 const AddonToolbarItemContainer& rAddonToolbarItems );
137 static bool RemoveItems( ToolBox* pToolbar,
138 sal_uInt16 nPos,
139 const ::rtl::OUString& rMergeCommandParameter );
141 static ::cppu::OWeakObject* CreateController(
142 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xSMGR,
143 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame,
144 ToolBox* pToolbar,
145 const ::rtl::OUString& rCommandURL,
146 sal_uInt16 nId,
147 sal_uInt16 nWidth,
148 const ::rtl::OUString& rControlType );
150 static void CreateToolbarItem( ToolBox* pToolbox,
151 sal_uInt16 nPos,
152 sal_uInt16 nItemId,
153 const AddonToolbarItem& rAddonToolbarItem );
155 private:
156 ToolBarMerger();
157 ToolBarMerger( const ToolBarMerger& );
158 ToolBarMerger& operator=( const ToolBarMerger& );
161 } // namespace framework
163 #endif // __FRAMEWORK_UIELEMENT_TOOLBARMERGER_HXX_