cid#1636693 COPY_INSTEAD_OF_MOVE
[LibreOffice.git] / extensions / source / propctrlr / propertyeditor.hxx
blob96199b31af4cc6b1fa04d5fb0105353347124a28
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 .
20 #pragma once
22 #include "browserpage.hxx"
23 #include "pcrcommon.hxx"
25 #include <com/sun/star/inspection/XPropertyControl.hpp>
26 #include <com/sun/star/uno/XComponentContext.hpp>
27 #include <vcl/weld.hxx>
28 #include <map>
30 namespace pcr
32 class IPropertyLineListener;
33 class IPropertyControlObserver;
34 class OBrowserPage;
35 struct OLineDescriptor;
36 class OBrowserListBox;
38 //= OPropertyEditor
39 class OPropertyEditor final
41 private:
42 typedef std::map< OUString, sal_uInt16 > MapStringToPageId;
43 struct PropertyPage
45 sal_uInt16 nPos;
46 OUString sLabel;
47 std::unique_ptr<OBrowserPage> xPage;
48 PropertyPage();
49 PropertyPage(sal_uInt16 nPagePos, OUString aLabel, std::unique_ptr<OBrowserPage> pPage);
52 std::unique_ptr<weld::Container> m_xContainer;
53 std::unique_ptr<weld::Notebook> m_xTabControl;
54 // controls initially have this parent before they are moved
55 std::unique_ptr<weld::Container> m_xControlHoldingParent;
56 css::uno::Reference<css::uno::XComponentContext> m_xContext;
57 IPropertyLineListener* m_pListener;
58 IPropertyControlObserver* m_pObserver;
59 sal_uInt16 m_nNextId;
60 Link<const OUString&,void> m_aPageActivationHandler;
61 bool m_bHasHelpSection;
63 MapStringToPageId m_aPropertyPageIds;
64 std::map<sal_uInt16, PropertyPage> m_aShownPages;
65 std::map<sal_uInt16, PropertyPage> m_aHiddenPages;
67 public:
68 explicit OPropertyEditor(const css::uno::Reference<css::uno::XComponentContext>& rContext, weld::Builder& rBuilder);
69 ~OPropertyEditor();
71 void SetLineListener( IPropertyLineListener* );
72 void SetControlObserver( IPropertyControlObserver* );
74 void EnableHelpSection( bool _bEnable );
75 bool HasHelpSection() const { return m_bHasHelpSection; }
76 void SetHelpText( const OUString& _rHelpText );
78 void SetHelpId( const OUString& sHelpId );
79 sal_uInt16 AppendPage( const OUString& r, const OUString& _rHelpId );
80 void SetPage( sal_uInt16 );
81 void RemovePage(sal_uInt16 nID);
82 sal_uInt16 GetCurPage() const;
83 void ClearAll();
85 void SetPropertyValue(const OUString& _rEntryName, const css::uno::Any& _rValue, bool _bUnknownValue );
86 sal_uInt16 GetPropertyPos(const OUString& rEntryName ) const;
87 css::uno::Reference< css::inspection::XPropertyControl >
88 GetPropertyControl( const OUString& rEntryName );
89 void EnablePropertyLine( const OUString& _rEntryName, bool _bEnable );
90 void EnablePropertyControls( const OUString& _rEntryName, sal_Int16 _nControls, bool _bEnable );
92 void ShowPropertyPage( sal_uInt16 _nPageId, bool _bShow );
94 void InsertEntry( const OLineDescriptor&, sal_uInt16 _nPageId, sal_uInt16 nPos = EDITOR_LIST_APPEND );
95 void RemoveEntry( const OUString& _rName );
96 void ChangeEntry( const OLineDescriptor& );
98 void setPageActivationHandler(const Link<const OUString&,void>& _rHdl) { m_aPageActivationHandler = _rHdl; }
100 Size get_preferred_size() const;
102 weld::Widget* getWidget() const { return m_xTabControl.get(); }
104 void Show() { m_xTabControl->show(); }
105 void Hide() { m_xTabControl->hide(); }
106 void GrabFocus() { m_xTabControl->grab_focus(); }
108 void CommitModified();
110 private:
111 OBrowserPage* getPage( sal_uInt16 _rPageId );
112 const OBrowserPage* getPage( sal_uInt16 _rPageId ) const;
114 OBrowserPage* getPage( const OUString& _rPropertyName );
115 const OBrowserPage* getPage( const OUString& _rPropertyName ) const;
117 typedef void (OPropertyEditor::*PageOperation)( OBrowserPage&, const void* );
118 void forEachPage( PageOperation _pOperation );
120 void setPageLineListener( OBrowserPage& _rPage, const void* );
121 void setPageControlObserver( OBrowserPage& _rPage, const void* );
122 void enableHelpSection( OBrowserPage& _rPage, const void* );
123 static void setHelpSectionText( OBrowserPage& _rPage, const void* _pPointerToOUString );
125 DECL_LINK(OnPageDeactivate, const OUString&, bool);
126 DECL_LINK(OnPageActivate, const OUString&, void);
130 } // namespace pcr
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */