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 INCLUDED_CUI_SOURCE_INC_CFGUTIL_HXX
20 : #define INCLUDED_CUI_SOURCE_INC_CFGUTIL_HXX
21 :
22 : #include <vector>
23 : #include <boost/ptr_container/ptr_vector.hpp>
24 : #include <rtl/ustring.hxx>
25 :
26 : #include <com/sun/star/frame/XModel.hpp>
27 : #include <com/sun/star/frame/XFrame.hpp>
28 : #include <com/sun/star/lang/XSingleComponentFactory.hpp>
29 : #include <com/sun/star/container/XNameAccess.hpp>
30 : #include <com/sun/star/script/browse/XBrowseNode.hpp>
31 : #include <vcl/timer.hxx>
32 : #include <svtools/svtabbx.hxx>
33 : #include <svtools/treelistbox.hxx>
34 : #include <vcl/image.hxx>
35 :
36 : class SfxMacroInfoItem;
37 :
38 0 : struct SfxStyleInfo_Impl
39 : {
40 : OUString sFamily;
41 : OUString sStyle;
42 : OUString sCommand;
43 : OUString sLabel;
44 :
45 0 : SfxStyleInfo_Impl()
46 0 : {}
47 :
48 0 : SfxStyleInfo_Impl(const SfxStyleInfo_Impl& rCopy)
49 0 : {
50 0 : sFamily = rCopy.sFamily;
51 0 : sStyle = rCopy.sStyle;
52 0 : sCommand = rCopy.sCommand;
53 0 : sLabel = rCopy.sLabel;
54 0 : }
55 : };
56 :
57 0 : struct SfxStylesInfo_Impl
58 : {
59 : private:
60 :
61 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xDoc;
62 :
63 : public:
64 :
65 : SfxStylesInfo_Impl();
66 : void setModel(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel);
67 :
68 : sal_Bool parseStyleCommand(SfxStyleInfo_Impl& aStyle);
69 : void getLabel4Style(SfxStyleInfo_Impl& aStyle);
70 :
71 : ::std::vector< SfxStyleInfo_Impl > getStyleFamilies();
72 : ::std::vector< SfxStyleInfo_Impl > getStyles(const OUString& sFamily);
73 :
74 : static OUString generateCommand(const OUString& sFamily, const OUString& sStyle);
75 : };
76 :
77 : #define SFX_CFGGROUP_FUNCTION 1
78 : #define SFX_CFGFUNCTION_SLOT 2
79 : #define SFX_CFGGROUP_SCRIPTCONTAINER 3
80 : #define SFX_CFGFUNCTION_SCRIPT 4
81 : #define SFX_CFGGROUP_STYLES 5
82 :
83 0 : struct SfxGroupInfo_Impl
84 : {
85 : sal_uInt16 nKind;
86 : sal_uInt16 nUniqueID;
87 : void* pObject;
88 : sal_Bool bWasOpened;
89 : OUString sCommand;
90 : OUString sLabel;
91 :
92 0 : SfxGroupInfo_Impl( sal_uInt16 n, sal_uInt16 nr, void* pObj = 0 ) :
93 0 : nKind( n ), nUniqueID( nr ), pObject( pObj ), bWasOpened(sal_False) {}
94 : };
95 :
96 : struct CuiMacroInfo
97 : {
98 : };
99 :
100 : typedef boost::ptr_vector<SfxGroupInfo_Impl> SfxGroupInfoArr_Impl;
101 :
102 : class SfxConfigFunctionListBox : public SvTreeListBox
103 : {
104 : friend class SfxConfigGroupListBox;
105 : Timer aTimer;
106 : SvTreeListEntry* pCurEntry;
107 : SfxGroupInfoArr_Impl aArr;
108 : SfxStylesInfo_Impl* pStylesInfo;
109 :
110 : DECL_LINK( TimerHdl, Timer* );
111 : virtual void MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
112 :
113 : public:
114 : SfxConfigFunctionListBox(Window*, WinBits nStyle);
115 : virtual ~SfxConfigFunctionListBox();
116 :
117 : void ClearAll();
118 : using Window::GetHelpText;
119 : OUString GetHelpText( SvTreeListEntry *pEntry );
120 : OUString GetCurCommand();
121 : OUString GetCurLabel();
122 : OUString GetSelectedScriptURI();
123 : void FunctionSelected();
124 : void SetStylesInfo(SfxStylesInfo_Impl* pStyles);
125 : };
126 :
127 : struct SvxConfigGroupBoxResource_Impl;
128 : class SfxConfigGroupListBox : public SvTreeListBox
129 : {
130 : SvxConfigGroupBoxResource_Impl* pImp;
131 : SfxConfigFunctionListBox* pFunctionListBox;
132 : SfxGroupInfoArr_Impl aArr;
133 :
134 : OUString m_sModuleLongName;
135 : css::uno::Reference< css::uno::XComponentContext > m_xContext;
136 : css::uno::Reference< css::frame::XFrame > m_xFrame;
137 : css::uno::Reference< css::container::XNameAccess > m_xGlobalCategoryInfo;
138 : css::uno::Reference< css::container::XNameAccess > m_xModuleCategoryInfo;
139 : css::uno::Reference< css::container::XNameAccess > m_xUICmdDescription;
140 :
141 : Image GetImage(
142 : ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode > node,
143 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > xCtx,
144 : bool bIsRootNode
145 : );
146 :
147 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getDocumentModel(
148 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xCtx,
149 : OUString& docName
150 : );
151 :
152 :
153 : void InitModule();
154 : void InitBasic();
155 : void InitStyles();
156 :
157 : OUString MapCommand2UIName(const OUString& sCommand);
158 :
159 : SfxStylesInfo_Impl* pStylesInfo;
160 :
161 : protected:
162 : virtual void RequestingChildren( SvTreeListEntry *pEntry) SAL_OVERRIDE;
163 : virtual sal_Bool Expand( SvTreeListEntry* pParent );
164 :
165 : public:
166 : SfxConfigGroupListBox(Window* pParent, WinBits nStyle);
167 : virtual ~SfxConfigGroupListBox();
168 : void ClearAll();
169 :
170 : void Init(const css::uno::Reference< css::uno::XComponentContext >& xContext,
171 : const css::uno::Reference< css::frame::XFrame >& xFrame,
172 : const OUString& sModuleLongName,
173 : bool bEventMode);
174 0 : void SetFunctionListBox( SfxConfigFunctionListBox *pBox )
175 0 : { pFunctionListBox = pBox; }
176 : void Open( SvTreeListEntry*, sal_Bool );
177 : void GroupSelected();
178 : void SelectMacro( const SfxMacroInfoItem* );
179 : void SelectMacro( const OUString&, const OUString& );
180 : void SetStylesInfo(SfxStylesInfo_Impl* pStyles);
181 : };
182 :
183 : #endif
184 :
185 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|