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 : static 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 : 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(false) {}
94 : };
95 :
96 : typedef boost::ptr_vector<SfxGroupInfo_Impl> SfxGroupInfoArr_Impl;
97 :
98 : class SfxConfigFunctionListBox : public SvTreeListBox
99 : {
100 : friend class SfxConfigGroupListBox;
101 : SvTreeListEntry* pCurEntry;
102 : SfxGroupInfoArr_Impl aArr;
103 : SfxStylesInfo_Impl* pStylesInfo;
104 :
105 : virtual void MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
106 :
107 : public:
108 : SfxConfigFunctionListBox(vcl::Window*, WinBits nStyle);
109 : virtual ~SfxConfigFunctionListBox();
110 : virtual void dispose() SAL_OVERRIDE;
111 :
112 : void ClearAll();
113 : using Window::GetHelpText;
114 : OUString GetHelpText( SvTreeListEntry *pEntry );
115 : OUString GetCurCommand();
116 : OUString GetCurLabel();
117 : OUString GetSelectedScriptURI();
118 : void SetStylesInfo(SfxStylesInfo_Impl* pStyles);
119 : };
120 :
121 : struct SvxConfigGroupBoxResource_Impl;
122 : class SfxConfigGroupListBox : public SvTreeListBox
123 : {
124 : SvxConfigGroupBoxResource_Impl* pImp;
125 : VclPtr<SfxConfigFunctionListBox> pFunctionListBox;
126 : SfxGroupInfoArr_Impl aArr;
127 :
128 : OUString m_sModuleLongName;
129 : css::uno::Reference< css::uno::XComponentContext > m_xContext;
130 : css::uno::Reference< css::frame::XFrame > m_xFrame;
131 : css::uno::Reference< css::container::XNameAccess > m_xGlobalCategoryInfo;
132 : css::uno::Reference< css::container::XNameAccess > m_xModuleCategoryInfo;
133 : css::uno::Reference< css::container::XNameAccess > m_xUICmdDescription;
134 :
135 : Image GetImage(
136 : ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode > node,
137 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > xCtx,
138 : bool bIsRootNode
139 : );
140 :
141 : static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getDocumentModel(
142 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xCtx,
143 : OUString& docName
144 : );
145 :
146 :
147 : void InitModule();
148 :
149 : OUString MapCommand2UIName(const OUString& sCommand);
150 :
151 : SfxStylesInfo_Impl* pStylesInfo;
152 :
153 : protected:
154 : virtual void RequestingChildren( SvTreeListEntry *pEntry) SAL_OVERRIDE;
155 : virtual bool Expand( SvTreeListEntry* pParent ) SAL_OVERRIDE;
156 :
157 : public:
158 : SfxConfigGroupListBox(vcl::Window* pParent, WinBits nStyle);
159 : virtual ~SfxConfigGroupListBox();
160 : virtual void dispose() SAL_OVERRIDE;
161 : void ClearAll();
162 :
163 : void Init(const css::uno::Reference< css::uno::XComponentContext >& xContext,
164 : const css::uno::Reference< css::frame::XFrame >& xFrame,
165 : const OUString& sModuleLongName,
166 : bool bEventMode);
167 0 : void SetFunctionListBox( SfxConfigFunctionListBox *pBox )
168 0 : { pFunctionListBox = pBox; }
169 : void Open( SvTreeListEntry*, bool );
170 : void GroupSelected();
171 : void SelectMacro( const SfxMacroInfoItem* );
172 : void SelectMacro( const OUString&, const OUString& );
173 : void SetStylesInfo(SfxStylesInfo_Impl* pStyles);
174 : };
175 :
176 : #endif
177 :
178 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|