Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 : #ifndef _CFGUTIL_HXX
20 : #define _CFGUTIL_HXX
21 :
22 : #include <vector>
23 : #include <boost/ptr_container/ptr_vector.hpp>
24 : #include <rtl/ustring.hxx>
25 : #include <tools/string.hxx>
26 :
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>
36 :
37 : class SfxMacroInfoItem;
38 :
39 0 : struct SfxStyleInfo_Impl
40 : {
41 : ::rtl::OUString sFamily;
42 : ::rtl::OUString sStyle;
43 : ::rtl::OUString sCommand;
44 : ::rtl::OUString sLabel;
45 :
46 0 : SfxStyleInfo_Impl()
47 0 : {}
48 :
49 0 : SfxStyleInfo_Impl(const SfxStyleInfo_Impl& rCopy)
50 0 : {
51 0 : sFamily = rCopy.sFamily;
52 0 : sStyle = rCopy.sStyle;
53 0 : sCommand = rCopy.sCommand;
54 0 : sLabel = rCopy.sLabel;
55 0 : }
56 : };
57 :
58 0 : struct SfxStylesInfo_Impl
59 : {
60 : private:
61 :
62 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xDoc;
63 :
64 : public:
65 :
66 : SfxStylesInfo_Impl();
67 : void setModel(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel);
68 :
69 : sal_Bool parseStyleCommand(SfxStyleInfo_Impl& aStyle);
70 : void getLabel4Style(SfxStyleInfo_Impl& aStyle);
71 :
72 : ::std::vector< SfxStyleInfo_Impl > getStyleFamilies();
73 : ::std::vector< SfxStyleInfo_Impl > getStyles(const ::rtl::OUString& sFamily);
74 :
75 : static ::rtl::OUString generateCommand(const ::rtl::OUString& sFamily, const ::rtl::OUString& sStyle);
76 : };
77 :
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
83 :
84 0 : struct SfxGroupInfo_Impl
85 : {
86 : sal_uInt16 nKind;
87 : sal_uInt16 nUniqueID;
88 : void* pObject;
89 : sal_Bool bWasOpened;
90 : String sCommand;
91 : String sLabel;
92 :
93 0 : SfxGroupInfo_Impl( sal_uInt16 n, sal_uInt16 nr, void* pObj = 0 ) :
94 0 : nKind( n ), nUniqueID( nr ), pObject( pObj ), bWasOpened(sal_False) {}
95 : };
96 :
97 : struct CuiMacroInfo
98 : {
99 : };
100 :
101 : typedef boost::ptr_vector<SfxGroupInfo_Impl> SfxGroupInfoArr_Impl;
102 :
103 : class SfxConfigFunctionListBox_Impl : public SvTreeListBox
104 : {
105 : friend class SfxConfigGroupListBox_Impl;
106 : Timer aTimer;
107 : SvTreeListEntry* pCurEntry;
108 : SfxGroupInfoArr_Impl aArr;
109 : SfxStylesInfo_Impl* pStylesInfo;
110 :
111 : DECL_LINK( TimerHdl, Timer* );
112 : virtual void MouseMove( const MouseEvent& rMEvt );
113 :
114 : public:
115 : SfxConfigFunctionListBox_Impl( Window*, const ResId& );
116 : ~SfxConfigFunctionListBox_Impl();
117 :
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);
126 : };
127 :
128 : struct SvxConfigGroupBoxResource_Impl;
129 : class SfxConfigGroupListBox_Impl : public SvTreeListBox
130 : {
131 : SvxConfigGroupBoxResource_Impl* pImp;
132 : SfxConfigFunctionListBox_Impl* pFunctionListBox;
133 : SfxGroupInfoArr_Impl aArr;
134 : sal_uLong nMode;
135 :
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;
142 :
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
147 : );
148 :
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
152 : );
153 :
154 :
155 : void InitModule();
156 : void InitBasic();
157 : void InitStyles();
158 :
159 : ::rtl::OUString MapCommand2UIName(const ::rtl::OUString& sCommand);
160 :
161 : SfxStylesInfo_Impl* pStylesInfo;
162 :
163 : protected:
164 : virtual void RequestingChildren( SvTreeListEntry *pEntry);
165 : using SvListView::Expand;
166 : virtual sal_Bool Expand( SvTreeListEntry* pParent );
167 :
168 : public:
169 : SfxConfigGroupListBox_Impl ( Window* pParent,
170 : const ResId&,
171 : sal_uLong nConfigMode = 0 );
172 : ~SfxConfigGroupListBox_Impl();
173 : void ClearAll();
174 :
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 0 : void SetFunctionListBox( SfxConfigFunctionListBox_Impl *pBox )
179 0 : { 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);
186 : };
187 :
188 : #endif
189 :
190 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|