xref: /aoo41x/main/cui/source/inc/cfgutil.hxx (revision c4eee24d)
1*c4eee24dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*c4eee24dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*c4eee24dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*c4eee24dSAndrew Rist  * distributed with this work for additional information
6*c4eee24dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*c4eee24dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*c4eee24dSAndrew Rist  * "License"); you may not use this file except in compliance
9*c4eee24dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*c4eee24dSAndrew Rist  *
11*c4eee24dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*c4eee24dSAndrew Rist  *
13*c4eee24dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*c4eee24dSAndrew Rist  * software distributed under the License is distributed on an
15*c4eee24dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*c4eee24dSAndrew Rist  * KIND, either express or implied.  See the License for the
17*c4eee24dSAndrew Rist  * specific language governing permissions and limitations
18*c4eee24dSAndrew Rist  * under the License.
19*c4eee24dSAndrew Rist  *
20*c4eee24dSAndrew Rist  *************************************************************/
21*c4eee24dSAndrew Rist 
22*c4eee24dSAndrew Rist 
23cdf0e10cSrcweir #ifndef _CFGUTIL_HXX
24cdf0e10cSrcweir #define _CFGUTIL_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include <vector>
27cdf0e10cSrcweir #include <rtl/ustring.hxx>
28cdf0e10cSrcweir #include <tools/string.hxx>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include <com/sun/star/frame/XModel.hpp>
31cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp>
32cdf0e10cSrcweir #include <com/sun/star/lang/XSingleComponentFactory.hpp>
33cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
34cdf0e10cSrcweir #include <com/sun/star/script/browse/XBrowseNode.hpp>
35cdf0e10cSrcweir 
36cdf0e10cSrcweir #define _SVSTDARR_STRINGSDTOR
37cdf0e10cSrcweir #include <svl/svstdarr.hxx>
38cdf0e10cSrcweir 
39cdf0e10cSrcweir #include <vcl/timer.hxx>
40cdf0e10cSrcweir #include <svtools/svtabbx.hxx>
41cdf0e10cSrcweir #include <svtools/svtreebx.hxx>
42cdf0e10cSrcweir #include <vcl/image.hxx>
43cdf0e10cSrcweir 
44cdf0e10cSrcweir class BasicManager;
45cdf0e10cSrcweir class SfxSlotPool;
46cdf0e10cSrcweir class SfxStringItem;
47cdf0e10cSrcweir class SfxFontItem;
48cdf0e10cSrcweir class SfxMacroInfoItem;
49cdf0e10cSrcweir struct SfxStyleInfo_Impl;
50cdf0e10cSrcweir struct SfxStylesInfo_Impl;
51cdf0e10cSrcweir 
52cdf0e10cSrcweir #define css ::com::sun::star
53cdf0e10cSrcweir 
54cdf0e10cSrcweir struct SfxStyleInfo_Impl
55cdf0e10cSrcweir {
56cdf0e10cSrcweir     ::rtl::OUString sFamily;
57cdf0e10cSrcweir     ::rtl::OUString sStyle;
58cdf0e10cSrcweir     ::rtl::OUString sCommand;
59cdf0e10cSrcweir     ::rtl::OUString sLabel;
60cdf0e10cSrcweir 
SfxStyleInfo_ImplSfxStyleInfo_Impl61cdf0e10cSrcweir     SfxStyleInfo_Impl()
62cdf0e10cSrcweir     {}
63cdf0e10cSrcweir 
SfxStyleInfo_ImplSfxStyleInfo_Impl64cdf0e10cSrcweir     SfxStyleInfo_Impl(const SfxStyleInfo_Impl& rCopy)
65cdf0e10cSrcweir     {
66cdf0e10cSrcweir         sFamily  = rCopy.sFamily;
67cdf0e10cSrcweir         sStyle   = rCopy.sStyle;
68cdf0e10cSrcweir         sCommand = rCopy.sCommand;
69cdf0e10cSrcweir         sLabel   = rCopy.sLabel;
70cdf0e10cSrcweir     }
71cdf0e10cSrcweir };
72cdf0e10cSrcweir 
73cdf0e10cSrcweir struct SfxStylesInfo_Impl
74cdf0e10cSrcweir {
75cdf0e10cSrcweir     private:
76cdf0e10cSrcweir 
77cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xDoc;
78cdf0e10cSrcweir 
79cdf0e10cSrcweir     public:
80cdf0e10cSrcweir 
81cdf0e10cSrcweir         SfxStylesInfo_Impl();
82cdf0e10cSrcweir         void setModel(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel);
83cdf0e10cSrcweir 
84cdf0e10cSrcweir         sal_Bool parseStyleCommand(SfxStyleInfo_Impl& aStyle);
85cdf0e10cSrcweir         void getLabel4Style(SfxStyleInfo_Impl& aStyle);
86cdf0e10cSrcweir 
87cdf0e10cSrcweir         ::std::vector< SfxStyleInfo_Impl > getStyleFamilies();
88cdf0e10cSrcweir         ::std::vector< SfxStyleInfo_Impl > getStyles(const ::rtl::OUString& sFamily);
89cdf0e10cSrcweir 
90cdf0e10cSrcweir         static ::rtl::OUString generateCommand(const ::rtl::OUString& sFamily, const ::rtl::OUString& sStyle);
91cdf0e10cSrcweir };
92cdf0e10cSrcweir 
93cdf0e10cSrcweir #define SFX_CFGGROUP_FUNCTION           1
94cdf0e10cSrcweir #define SFX_CFGFUNCTION_SLOT            2
95cdf0e10cSrcweir #define SFX_CFGGROUP_SCRIPTCONTAINER    3
96cdf0e10cSrcweir #define SFX_CFGFUNCTION_SCRIPT          4
97cdf0e10cSrcweir #define SFX_CFGGROUP_STYLES             5
98cdf0e10cSrcweir 
99cdf0e10cSrcweir struct SfxGroupInfo_Impl
100cdf0e10cSrcweir {
101cdf0e10cSrcweir 	sal_uInt16	nKind;
102cdf0e10cSrcweir 	sal_uInt16	nUniqueID;
103cdf0e10cSrcweir 	void*		pObject;
104cdf0e10cSrcweir 	sal_Bool		bWasOpened;
105cdf0e10cSrcweir     String      sCommand;
106cdf0e10cSrcweir     String      sLabel;
107cdf0e10cSrcweir 
SfxGroupInfo_ImplSfxGroupInfo_Impl108cdf0e10cSrcweir 				SfxGroupInfo_Impl( sal_uInt16 n, sal_uInt16 nr, void* pObj = 0 ) :
109cdf0e10cSrcweir 					nKind( n ), nUniqueID( nr ), pObject( pObj ), bWasOpened(sal_False) {}
110cdf0e10cSrcweir };
111cdf0e10cSrcweir 
112cdf0e10cSrcweir struct CuiMacroInfo
113cdf0e10cSrcweir {
114cdf0e10cSrcweir };
115cdf0e10cSrcweir 
116cdf0e10cSrcweir typedef SfxGroupInfo_Impl* SfxGroupInfoPtr;
117cdf0e10cSrcweir SV_DECL_PTRARR_DEL(SfxGroupInfoArr_Impl, SfxGroupInfoPtr, 5, 5)
118cdf0e10cSrcweir 
119cdf0e10cSrcweir class SfxConfigFunctionListBox_Impl : public SvTreeListBox
120cdf0e10cSrcweir {
121cdf0e10cSrcweir     friend class SfxConfigGroupListBox_Impl;
122cdf0e10cSrcweir     Timer                aTimer;
123cdf0e10cSrcweir     SvLBoxEntry*         pCurEntry;
124cdf0e10cSrcweir     SfxGroupInfoArr_Impl aArr;
125cdf0e10cSrcweir     SfxStylesInfo_Impl*  pStylesInfo;
126cdf0e10cSrcweir 
127cdf0e10cSrcweir     DECL_LINK( TimerHdl, Timer* );
128cdf0e10cSrcweir     virtual void  MouseMove( const MouseEvent& rMEvt );
129cdf0e10cSrcweir 
130cdf0e10cSrcweir public:
131cdf0e10cSrcweir                   SfxConfigFunctionListBox_Impl( Window*, const ResId& );
132cdf0e10cSrcweir                   ~SfxConfigFunctionListBox_Impl();
133cdf0e10cSrcweir 
134cdf0e10cSrcweir     void          ClearAll();
135cdf0e10cSrcweir     using Window::GetHelpText;
136cdf0e10cSrcweir     String        GetHelpText( SvLBoxEntry *pEntry );
137cdf0e10cSrcweir     String        GetCurCommand();
138cdf0e10cSrcweir     String        GetCurLabel();
139cdf0e10cSrcweir     String        GetSelectedScriptURI();
140cdf0e10cSrcweir     void          FunctionSelected();
141cdf0e10cSrcweir     void          SetStylesInfo(SfxStylesInfo_Impl* pStyles);
142cdf0e10cSrcweir };
143cdf0e10cSrcweir 
144cdf0e10cSrcweir struct SvxConfigGroupBoxResource_Impl;
145cdf0e10cSrcweir class SfxConfigGroupListBox_Impl : public SvTreeListBox
146cdf0e10cSrcweir {
147cdf0e10cSrcweir 	SvxConfigGroupBoxResource_Impl*	pImp;
148cdf0e10cSrcweir 	//SfxSlotPool*                    pSlotPool;
149cdf0e10cSrcweir     SfxConfigFunctionListBox_Impl*  pFunctionListBox;
150cdf0e10cSrcweir     SfxGroupInfoArr_Impl            aArr;
151cdf0e10cSrcweir     sal_uLong                       nMode;
152cdf0e10cSrcweir 
153cdf0e10cSrcweir     ::rtl::OUString m_sModuleLongName;
154cdf0e10cSrcweir     css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
155cdf0e10cSrcweir     css::uno::Reference< css::frame::XFrame > m_xFrame;
156cdf0e10cSrcweir     css::uno::Reference< css::container::XNameAccess > m_xGlobalCategoryInfo;
157cdf0e10cSrcweir     css::uno::Reference< css::container::XNameAccess > m_xModuleCategoryInfo;
158cdf0e10cSrcweir     css::uno::Reference< css::container::XNameAccess > m_xUICmdDescription;
159cdf0e10cSrcweir 
160cdf0e10cSrcweir     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 );
161cdf0e10cSrcweir 
162cdf0e10cSrcweir     ::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 );
163cdf0e10cSrcweir 
164cdf0e10cSrcweir     void InitModule();
165cdf0e10cSrcweir     void InitBasic();
166cdf0e10cSrcweir     void InitStyles();
167cdf0e10cSrcweir 
168cdf0e10cSrcweir     ::rtl::OUString MapCommand2UIName(const ::rtl::OUString& sCommand);
169cdf0e10cSrcweir 
170cdf0e10cSrcweir     SfxStylesInfo_Impl* pStylesInfo;
171cdf0e10cSrcweir 
172cdf0e10cSrcweir protected:
173cdf0e10cSrcweir     virtual void        RequestingChilds( SvLBoxEntry *pEntry);
174cdf0e10cSrcweir     using SvListView::Expand;
175cdf0e10cSrcweir     virtual sal_Bool        Expand( SvLBoxEntry* pParent );
176cdf0e10cSrcweir 
177cdf0e10cSrcweir public:
178cdf0e10cSrcweir     SfxConfigGroupListBox_Impl ( Window* pParent,
179cdf0e10cSrcweir                                  const ResId&,
180cdf0e10cSrcweir                                  sal_uLong nConfigMode = 0 );
181cdf0e10cSrcweir     ~SfxConfigGroupListBox_Impl();
182cdf0e10cSrcweir     void                ClearAll();
183cdf0e10cSrcweir 
184cdf0e10cSrcweir     void                Init(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR          ,
185cdf0e10cSrcweir                              const css::uno::Reference< css::frame::XFrame >&              xFrame         ,
186cdf0e10cSrcweir                              const ::rtl::OUString&                                        sModuleLongName);
SetFunctionListBox(SfxConfigFunctionListBox_Impl * pBox)187cdf0e10cSrcweir     void                SetFunctionListBox( SfxConfigFunctionListBox_Impl *pBox )
188cdf0e10cSrcweir                         { pFunctionListBox = pBox; }
189cdf0e10cSrcweir     void                Open( SvLBoxEntry*, sal_Bool );
190cdf0e10cSrcweir     void                GroupSelected();
191cdf0e10cSrcweir     void                SelectMacro( const SfxMacroInfoItem* );
192cdf0e10cSrcweir     void                SelectMacro( const String&, const String& );
193cdf0e10cSrcweir     String              GetGroup();
194cdf0e10cSrcweir     void                SetStylesInfo(SfxStylesInfo_Impl* pStyles);
195cdf0e10cSrcweir };
196cdf0e10cSrcweir 
197cdf0e10cSrcweir #undef css
198cdf0e10cSrcweir 
199cdf0e10cSrcweir #endif
200cdf0e10cSrcweir 
201