xref: /aoo4110/main/cui/source/inc/cfgutil.hxx (revision b1cdbd2c)
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 
23 #ifndef _CFGUTIL_HXX
24 #define _CFGUTIL_HXX
25 
26 #include <vector>
27 #include <rtl/ustring.hxx>
28 #include <tools/string.hxx>
29 
30 #include <com/sun/star/frame/XModel.hpp>
31 #include <com/sun/star/frame/XFrame.hpp>
32 #include <com/sun/star/lang/XSingleComponentFactory.hpp>
33 #include <com/sun/star/container/XNameAccess.hpp>
34 #include <com/sun/star/script/browse/XBrowseNode.hpp>
35 
36 #define _SVSTDARR_STRINGSDTOR
37 #include <svl/svstdarr.hxx>
38 
39 #include <vcl/timer.hxx>
40 #include <svtools/svtabbx.hxx>
41 #include <svtools/svtreebx.hxx>
42 #include <vcl/image.hxx>
43 
44 class BasicManager;
45 class SfxSlotPool;
46 class SfxStringItem;
47 class SfxFontItem;
48 class SfxMacroInfoItem;
49 struct SfxStyleInfo_Impl;
50 struct SfxStylesInfo_Impl;
51 
52 #define css ::com::sun::star
53 
54 struct SfxStyleInfo_Impl
55 {
56     ::rtl::OUString sFamily;
57     ::rtl::OUString sStyle;
58     ::rtl::OUString sCommand;
59     ::rtl::OUString sLabel;
60 
SfxStyleInfo_ImplSfxStyleInfo_Impl61     SfxStyleInfo_Impl()
62     {}
63 
SfxStyleInfo_ImplSfxStyleInfo_Impl64     SfxStyleInfo_Impl(const SfxStyleInfo_Impl& rCopy)
65     {
66         sFamily  = rCopy.sFamily;
67         sStyle   = rCopy.sStyle;
68         sCommand = rCopy.sCommand;
69         sLabel   = rCopy.sLabel;
70     }
71 };
72 
73 struct SfxStylesInfo_Impl
74 {
75     private:
76 
77         ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xDoc;
78 
79     public:
80 
81         SfxStylesInfo_Impl();
82         void setModel(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel);
83 
84         sal_Bool parseStyleCommand(SfxStyleInfo_Impl& aStyle);
85         void getLabel4Style(SfxStyleInfo_Impl& aStyle);
86 
87         ::std::vector< SfxStyleInfo_Impl > getStyleFamilies();
88         ::std::vector< SfxStyleInfo_Impl > getStyles(const ::rtl::OUString& sFamily);
89 
90         static ::rtl::OUString generateCommand(const ::rtl::OUString& sFamily, const ::rtl::OUString& sStyle);
91 };
92 
93 #define SFX_CFGGROUP_FUNCTION           1
94 #define SFX_CFGFUNCTION_SLOT            2
95 #define SFX_CFGGROUP_SCRIPTCONTAINER    3
96 #define SFX_CFGFUNCTION_SCRIPT          4
97 #define SFX_CFGGROUP_STYLES             5
98 
99 struct SfxGroupInfo_Impl
100 {
101 	sal_uInt16	nKind;
102 	sal_uInt16	nUniqueID;
103 	void*		pObject;
104 	sal_Bool		bWasOpened;
105     String      sCommand;
106     String      sLabel;
107 
SfxGroupInfo_ImplSfxGroupInfo_Impl108 				SfxGroupInfo_Impl( sal_uInt16 n, sal_uInt16 nr, void* pObj = 0 ) :
109 					nKind( n ), nUniqueID( nr ), pObject( pObj ), bWasOpened(sal_False) {}
110 };
111 
112 struct CuiMacroInfo
113 {
114 };
115 
116 typedef SfxGroupInfo_Impl* SfxGroupInfoPtr;
117 SV_DECL_PTRARR_DEL(SfxGroupInfoArr_Impl, SfxGroupInfoPtr, 5, 5)
118 
119 class SfxConfigFunctionListBox_Impl : public SvTreeListBox
120 {
121     friend class SfxConfigGroupListBox_Impl;
122     Timer                aTimer;
123     SvLBoxEntry*         pCurEntry;
124     SfxGroupInfoArr_Impl aArr;
125     SfxStylesInfo_Impl*  pStylesInfo;
126 
127     DECL_LINK( TimerHdl, Timer* );
128     virtual void  MouseMove( const MouseEvent& rMEvt );
129 
130 public:
131                   SfxConfigFunctionListBox_Impl( Window*, const ResId& );
132                   ~SfxConfigFunctionListBox_Impl();
133 
134     void          ClearAll();
135     using Window::GetHelpText;
136     String        GetHelpText( SvLBoxEntry *pEntry );
137     String        GetCurCommand();
138     String        GetCurLabel();
139     String        GetSelectedScriptURI();
140     void          FunctionSelected();
141     void          SetStylesInfo(SfxStylesInfo_Impl* pStyles);
142 };
143 
144 struct SvxConfigGroupBoxResource_Impl;
145 class SfxConfigGroupListBox_Impl : public SvTreeListBox
146 {
147 	SvxConfigGroupBoxResource_Impl*	pImp;
148 	//SfxSlotPool*                    pSlotPool;
149     SfxConfigFunctionListBox_Impl*  pFunctionListBox;
150     SfxGroupInfoArr_Impl            aArr;
151     sal_uLong                       nMode;
152 
153     ::rtl::OUString m_sModuleLongName;
154     css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
155     css::uno::Reference< css::frame::XFrame > m_xFrame;
156     css::uno::Reference< css::container::XNameAccess > m_xGlobalCategoryInfo;
157     css::uno::Reference< css::container::XNameAccess > m_xModuleCategoryInfo;
158     css::uno::Reference< css::container::XNameAccess > m_xUICmdDescription;
159 
160     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 );
161 
162     ::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 );
163 
164     void InitModule();
165     void InitBasic();
166     void InitStyles();
167 
168     ::rtl::OUString MapCommand2UIName(const ::rtl::OUString& sCommand);
169 
170     SfxStylesInfo_Impl* pStylesInfo;
171 
172 protected:
173     virtual void        RequestingChilds( SvLBoxEntry *pEntry);
174     using SvListView::Expand;
175     virtual sal_Bool        Expand( SvLBoxEntry* pParent );
176 
177 public:
178     SfxConfigGroupListBox_Impl ( Window* pParent,
179                                  const ResId&,
180                                  sal_uLong nConfigMode = 0 );
181     ~SfxConfigGroupListBox_Impl();
182     void                ClearAll();
183 
184     void                Init(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR          ,
185                              const css::uno::Reference< css::frame::XFrame >&              xFrame         ,
186                              const ::rtl::OUString&                                        sModuleLongName);
SetFunctionListBox(SfxConfigFunctionListBox_Impl * pBox)187     void                SetFunctionListBox( SfxConfigFunctionListBox_Impl *pBox )
188                         { pFunctionListBox = pBox; }
189     void                Open( SvLBoxEntry*, sal_Bool );
190     void                GroupSelected();
191     void                SelectMacro( const SfxMacroInfoItem* );
192     void                SelectMacro( const String&, const String& );
193     String              GetGroup();
194     void                SetStylesInfo(SfxStylesInfo_Impl* pStyles);
195 };
196 
197 #undef css
198 
199 #endif
200 
201