Version 4.0.0.1, tag libreoffice-4.0.0.1
[LibreOffice.git] / cui / source / inc / cfgutil.hxx
bloba67548437524c366c31338c3263c0d67fd7e9db4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef _CFGUTIL_HXX
20 #define _CFGUTIL_HXX
22 #include <vector>
23 #include <boost/ptr_container/ptr_vector.hpp>
24 #include <rtl/ustring.hxx>
25 #include <tools/string.hxx>
27 #include <com/sun/star/frame/XModel.hpp>
28 #include <com/sun/star/frame/XFrame.hpp>
29 #include <com/sun/star/lang/XSingleComponentFactory.hpp>
30 #include <com/sun/star/container/XNameAccess.hpp>
31 #include <com/sun/star/script/browse/XBrowseNode.hpp>
32 #include <vcl/timer.hxx>
33 #include <svtools/svtabbx.hxx>
34 #include <svtools/treelistbox.hxx>
35 #include <vcl/image.hxx>
37 class SfxMacroInfoItem;
39 struct SfxStyleInfo_Impl
41 ::rtl::OUString sFamily;
42 ::rtl::OUString sStyle;
43 ::rtl::OUString sCommand;
44 ::rtl::OUString sLabel;
46 SfxStyleInfo_Impl()
49 SfxStyleInfo_Impl(const SfxStyleInfo_Impl& rCopy)
51 sFamily = rCopy.sFamily;
52 sStyle = rCopy.sStyle;
53 sCommand = rCopy.sCommand;
54 sLabel = rCopy.sLabel;
58 struct SfxStylesInfo_Impl
60 private:
62 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xDoc;
64 public:
66 SfxStylesInfo_Impl();
67 void setModel(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel);
69 sal_Bool parseStyleCommand(SfxStyleInfo_Impl& aStyle);
70 void getLabel4Style(SfxStyleInfo_Impl& aStyle);
72 ::std::vector< SfxStyleInfo_Impl > getStyleFamilies();
73 ::std::vector< SfxStyleInfo_Impl > getStyles(const ::rtl::OUString& sFamily);
75 static ::rtl::OUString generateCommand(const ::rtl::OUString& sFamily, const ::rtl::OUString& sStyle);
78 #define SFX_CFGGROUP_FUNCTION 1
79 #define SFX_CFGFUNCTION_SLOT 2
80 #define SFX_CFGGROUP_SCRIPTCONTAINER 3
81 #define SFX_CFGFUNCTION_SCRIPT 4
82 #define SFX_CFGGROUP_STYLES 5
84 struct SfxGroupInfo_Impl
86 sal_uInt16 nKind;
87 sal_uInt16 nUniqueID;
88 void* pObject;
89 sal_Bool bWasOpened;
90 String sCommand;
91 String sLabel;
93 SfxGroupInfo_Impl( sal_uInt16 n, sal_uInt16 nr, void* pObj = 0 ) :
94 nKind( n ), nUniqueID( nr ), pObject( pObj ), bWasOpened(sal_False) {}
97 struct CuiMacroInfo
101 typedef boost::ptr_vector<SfxGroupInfo_Impl> SfxGroupInfoArr_Impl;
103 class SfxConfigFunctionListBox_Impl : public SvTreeListBox
105 friend class SfxConfigGroupListBox_Impl;
106 Timer aTimer;
107 SvTreeListEntry* pCurEntry;
108 SfxGroupInfoArr_Impl aArr;
109 SfxStylesInfo_Impl* pStylesInfo;
111 DECL_LINK( TimerHdl, Timer* );
112 virtual void MouseMove( const MouseEvent& rMEvt );
114 public:
115 SfxConfigFunctionListBox_Impl( Window*, const ResId& );
116 ~SfxConfigFunctionListBox_Impl();
118 void ClearAll();
119 using Window::GetHelpText;
120 String GetHelpText( SvTreeListEntry *pEntry );
121 String GetCurCommand();
122 String GetCurLabel();
123 String GetSelectedScriptURI();
124 void FunctionSelected();
125 void SetStylesInfo(SfxStylesInfo_Impl* pStyles);
128 struct SvxConfigGroupBoxResource_Impl;
129 class SfxConfigGroupListBox_Impl : public SvTreeListBox
131 SvxConfigGroupBoxResource_Impl* pImp;
132 SfxConfigFunctionListBox_Impl* pFunctionListBox;
133 SfxGroupInfoArr_Impl aArr;
134 sal_uLong nMode;
136 ::rtl::OUString m_sModuleLongName;
137 css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
138 css::uno::Reference< css::frame::XFrame > m_xFrame;
139 css::uno::Reference< css::container::XNameAccess > m_xGlobalCategoryInfo;
140 css::uno::Reference< css::container::XNameAccess > m_xModuleCategoryInfo;
141 css::uno::Reference< css::container::XNameAccess > m_xUICmdDescription;
143 Image GetImage(
144 ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode > node,
145 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > xCtx,
146 bool bIsRootNode
149 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getDocumentModel(
150 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xCtx,
151 ::rtl::OUString& docName
155 void InitModule();
156 void InitBasic();
157 void InitStyles();
159 ::rtl::OUString MapCommand2UIName(const ::rtl::OUString& sCommand);
161 SfxStylesInfo_Impl* pStylesInfo;
163 protected:
164 virtual void RequestingChildren( SvTreeListEntry *pEntry);
165 using SvListView::Expand;
166 virtual sal_Bool Expand( SvTreeListEntry* pParent );
168 public:
169 SfxConfigGroupListBox_Impl ( Window* pParent,
170 const ResId&,
171 sal_uLong nConfigMode = 0 );
172 ~SfxConfigGroupListBox_Impl();
173 void ClearAll();
175 void Init(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR ,
176 const css::uno::Reference< css::frame::XFrame >& xFrame ,
177 const ::rtl::OUString& sModuleLongName);
178 void SetFunctionListBox( SfxConfigFunctionListBox_Impl *pBox )
179 { pFunctionListBox = pBox; }
180 void Open( SvTreeListEntry*, sal_Bool );
181 void GroupSelected();
182 void SelectMacro( const SfxMacroInfoItem* );
183 void SelectMacro( const String&, const String& );
184 String GetGroup();
185 void SetStylesInfo(SfxStylesInfo_Impl* pStyles);
188 #endif
190 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */