xref: /AOO41X/main/cui/source/inc/cfgutil.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir #ifndef _CFGUTIL_HXX
28*cdf0e10cSrcweir #define _CFGUTIL_HXX
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include <vector>
31*cdf0e10cSrcweir #include <rtl/ustring.hxx>
32*cdf0e10cSrcweir #include <tools/string.hxx>
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir #include <com/sun/star/frame/XModel.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/lang/XSingleComponentFactory.hpp>
37*cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
38*cdf0e10cSrcweir #include <com/sun/star/script/browse/XBrowseNode.hpp>
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir #define _SVSTDARR_STRINGSDTOR
41*cdf0e10cSrcweir #include <svl/svstdarr.hxx>
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir #include <vcl/timer.hxx>
44*cdf0e10cSrcweir #include <svtools/svtabbx.hxx>
45*cdf0e10cSrcweir #include <svtools/svtreebx.hxx>
46*cdf0e10cSrcweir #include <vcl/image.hxx>
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir class BasicManager;
49*cdf0e10cSrcweir class SfxSlotPool;
50*cdf0e10cSrcweir class SfxStringItem;
51*cdf0e10cSrcweir class SfxFontItem;
52*cdf0e10cSrcweir class SfxMacroInfoItem;
53*cdf0e10cSrcweir struct SfxStyleInfo_Impl;
54*cdf0e10cSrcweir struct SfxStylesInfo_Impl;
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir #define css ::com::sun::star
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir struct SfxStyleInfo_Impl
59*cdf0e10cSrcweir {
60*cdf0e10cSrcweir     ::rtl::OUString sFamily;
61*cdf0e10cSrcweir     ::rtl::OUString sStyle;
62*cdf0e10cSrcweir     ::rtl::OUString sCommand;
63*cdf0e10cSrcweir     ::rtl::OUString sLabel;
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir     SfxStyleInfo_Impl()
66*cdf0e10cSrcweir     {}
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir     SfxStyleInfo_Impl(const SfxStyleInfo_Impl& rCopy)
69*cdf0e10cSrcweir     {
70*cdf0e10cSrcweir         sFamily  = rCopy.sFamily;
71*cdf0e10cSrcweir         sStyle   = rCopy.sStyle;
72*cdf0e10cSrcweir         sCommand = rCopy.sCommand;
73*cdf0e10cSrcweir         sLabel   = rCopy.sLabel;
74*cdf0e10cSrcweir     }
75*cdf0e10cSrcweir };
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir struct SfxStylesInfo_Impl
78*cdf0e10cSrcweir {
79*cdf0e10cSrcweir     private:
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xDoc;
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir     public:
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir         SfxStylesInfo_Impl();
86*cdf0e10cSrcweir         void setModel(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel);
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir         sal_Bool parseStyleCommand(SfxStyleInfo_Impl& aStyle);
89*cdf0e10cSrcweir         void getLabel4Style(SfxStyleInfo_Impl& aStyle);
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir         ::std::vector< SfxStyleInfo_Impl > getStyleFamilies();
92*cdf0e10cSrcweir         ::std::vector< SfxStyleInfo_Impl > getStyles(const ::rtl::OUString& sFamily);
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir         static ::rtl::OUString generateCommand(const ::rtl::OUString& sFamily, const ::rtl::OUString& sStyle);
95*cdf0e10cSrcweir };
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir #define SFX_CFGGROUP_FUNCTION           1
98*cdf0e10cSrcweir #define SFX_CFGFUNCTION_SLOT            2
99*cdf0e10cSrcweir #define SFX_CFGGROUP_SCRIPTCONTAINER    3
100*cdf0e10cSrcweir #define SFX_CFGFUNCTION_SCRIPT          4
101*cdf0e10cSrcweir #define SFX_CFGGROUP_STYLES             5
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir struct SfxGroupInfo_Impl
104*cdf0e10cSrcweir {
105*cdf0e10cSrcweir 	sal_uInt16	nKind;
106*cdf0e10cSrcweir 	sal_uInt16	nUniqueID;
107*cdf0e10cSrcweir 	void*		pObject;
108*cdf0e10cSrcweir 	sal_Bool		bWasOpened;
109*cdf0e10cSrcweir     String      sCommand;
110*cdf0e10cSrcweir     String      sLabel;
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir 				SfxGroupInfo_Impl( sal_uInt16 n, sal_uInt16 nr, void* pObj = 0 ) :
113*cdf0e10cSrcweir 					nKind( n ), nUniqueID( nr ), pObject( pObj ), bWasOpened(sal_False) {}
114*cdf0e10cSrcweir };
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir struct CuiMacroInfo
117*cdf0e10cSrcweir {
118*cdf0e10cSrcweir };
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir typedef SfxGroupInfo_Impl* SfxGroupInfoPtr;
121*cdf0e10cSrcweir SV_DECL_PTRARR_DEL(SfxGroupInfoArr_Impl, SfxGroupInfoPtr, 5, 5)
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir class SfxConfigFunctionListBox_Impl : public SvTreeListBox
124*cdf0e10cSrcweir {
125*cdf0e10cSrcweir     friend class SfxConfigGroupListBox_Impl;
126*cdf0e10cSrcweir     Timer                aTimer;
127*cdf0e10cSrcweir     SvLBoxEntry*         pCurEntry;
128*cdf0e10cSrcweir     SfxGroupInfoArr_Impl aArr;
129*cdf0e10cSrcweir     SfxStylesInfo_Impl*  pStylesInfo;
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir     DECL_LINK( TimerHdl, Timer* );
132*cdf0e10cSrcweir     virtual void  MouseMove( const MouseEvent& rMEvt );
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir public:
135*cdf0e10cSrcweir                   SfxConfigFunctionListBox_Impl( Window*, const ResId& );
136*cdf0e10cSrcweir                   ~SfxConfigFunctionListBox_Impl();
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir     void          ClearAll();
139*cdf0e10cSrcweir     using Window::GetHelpText;
140*cdf0e10cSrcweir     String        GetHelpText( SvLBoxEntry *pEntry );
141*cdf0e10cSrcweir     String        GetCurCommand();
142*cdf0e10cSrcweir     String        GetCurLabel();
143*cdf0e10cSrcweir     String        GetSelectedScriptURI();
144*cdf0e10cSrcweir     void          FunctionSelected();
145*cdf0e10cSrcweir     void          SetStylesInfo(SfxStylesInfo_Impl* pStyles);
146*cdf0e10cSrcweir };
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir struct SvxConfigGroupBoxResource_Impl;
149*cdf0e10cSrcweir class SfxConfigGroupListBox_Impl : public SvTreeListBox
150*cdf0e10cSrcweir {
151*cdf0e10cSrcweir 	SvxConfigGroupBoxResource_Impl*	pImp;
152*cdf0e10cSrcweir 	//SfxSlotPool*                    pSlotPool;
153*cdf0e10cSrcweir     SfxConfigFunctionListBox_Impl*  pFunctionListBox;
154*cdf0e10cSrcweir     SfxGroupInfoArr_Impl            aArr;
155*cdf0e10cSrcweir     sal_uLong                       nMode;
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir     ::rtl::OUString m_sModuleLongName;
158*cdf0e10cSrcweir     css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
159*cdf0e10cSrcweir     css::uno::Reference< css::frame::XFrame > m_xFrame;
160*cdf0e10cSrcweir     css::uno::Reference< css::container::XNameAccess > m_xGlobalCategoryInfo;
161*cdf0e10cSrcweir     css::uno::Reference< css::container::XNameAccess > m_xModuleCategoryInfo;
162*cdf0e10cSrcweir     css::uno::Reference< css::container::XNameAccess > m_xUICmdDescription;
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir     Image GetImage( ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode > node, ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > xCtx, bool bIsRootNode, bool bHighContrast );
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface  > getDocumentModel( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xCtx, ::rtl::OUString& docName );
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir     void InitModule();
169*cdf0e10cSrcweir     void InitBasic();
170*cdf0e10cSrcweir     void InitStyles();
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir     ::rtl::OUString MapCommand2UIName(const ::rtl::OUString& sCommand);
173*cdf0e10cSrcweir 
174*cdf0e10cSrcweir     SfxStylesInfo_Impl* pStylesInfo;
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir protected:
177*cdf0e10cSrcweir     virtual void        RequestingChilds( SvLBoxEntry *pEntry);
178*cdf0e10cSrcweir     using SvListView::Expand;
179*cdf0e10cSrcweir     virtual sal_Bool        Expand( SvLBoxEntry* pParent );
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir public:
182*cdf0e10cSrcweir     SfxConfigGroupListBox_Impl ( Window* pParent,
183*cdf0e10cSrcweir                                  const ResId&,
184*cdf0e10cSrcweir                                  sal_uLong nConfigMode = 0 );
185*cdf0e10cSrcweir     ~SfxConfigGroupListBox_Impl();
186*cdf0e10cSrcweir     void                ClearAll();
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir     void                Init(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR          ,
189*cdf0e10cSrcweir                              const css::uno::Reference< css::frame::XFrame >&              xFrame         ,
190*cdf0e10cSrcweir                              const ::rtl::OUString&                                        sModuleLongName);
191*cdf0e10cSrcweir     void                SetFunctionListBox( SfxConfigFunctionListBox_Impl *pBox )
192*cdf0e10cSrcweir                         { pFunctionListBox = pBox; }
193*cdf0e10cSrcweir     void                Open( SvLBoxEntry*, sal_Bool );
194*cdf0e10cSrcweir     void                GroupSelected();
195*cdf0e10cSrcweir     void                SelectMacro( const SfxMacroInfoItem* );
196*cdf0e10cSrcweir     void                SelectMacro( const String&, const String& );
197*cdf0e10cSrcweir     String              GetGroup();
198*cdf0e10cSrcweir     void                SetStylesInfo(SfxStylesInfo_Impl* pStyles);
199*cdf0e10cSrcweir };
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir #undef css
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir #endif
204*cdf0e10cSrcweir 
205