1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: toolbarmerger.hxx,v $
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>
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
;
71 typedef ::std::vector
< AddonToolbarItem
> AddonToolbarItemContainer
;
73 struct ReferenceToolbarPathInfo
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
,
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
,
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
,
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
,
123 sal_uInt16 nModIndex
,
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
,
133 CommandToInfoMap
& rCommandMap
,
134 const ::rtl::OUString
& rModuleIdentifier
,
135 const AddonToolbarItemContainer
& rAddonToolbarItems
);
137 static bool RemoveItems( ToolBox
* pToolbar
,
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
,
145 const ::rtl::OUString
& rCommandURL
,
148 const ::rtl::OUString
& rControlType
);
150 static void CreateToolbarItem( ToolBox
* pToolbox
,
153 const AddonToolbarItem
& rAddonToolbarItem
);
157 ToolBarMerger( const ToolBarMerger
& );
158 ToolBarMerger
& operator=( const ToolBarMerger
& );
161 } // namespace framework
163 #endif // __FRAMEWORK_UIELEMENT_TOOLBARMERGER_HXX_