tdf#130857 qt weld: Support mail merge "Server Auth" dialog
[LibreOffice.git] / extensions / source / propctrlr / browserlistbox.hxx
blobfc1f35541208b445c8c7f157dce51d1d88363695
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 "browserline.hxx"
24 #include <com/sun/star/inspection/XPropertyControl.hpp>
25 #include <com/sun/star/inspection/XPropertyHandler.hpp>
26 #include <utility>
27 #include <vcl/weld.hxx>
28 #include <rtl/ref.hxx>
30 #include <memory>
31 #include <vector>
33 #define EDITOR_LIST_REPLACE_EXISTING \
34 std::numeric_limits<ListBoxLines::size_type>::max()
36 namespace pcr
40 class IPropertyLineListener;
41 class IPropertyControlObserver;
42 struct OLineDescriptor;
43 class InspectorHelpWindow;
44 class PropertyControlContext_Impl;
47 // administrative structures for OBrowserListBox
49 typedef std::shared_ptr< OBrowserLine > BrowserLinePointer;
50 struct ListBoxLine
52 OUString aName;
53 BrowserLinePointer pLine;
54 css::uno::Reference< css::inspection::XPropertyHandler >
55 xHandler;
57 ListBoxLine( OUString _aName, BrowserLinePointer _pLine, css::uno::Reference< css::inspection::XPropertyHandler > _xHandler )
58 : aName(std::move( _aName )),
59 pLine(std::move( _pLine )),
60 xHandler(std::move( _xHandler ))
64 typedef std::vector< ListBoxLine > ListBoxLines;
67 class OBrowserListBox final : public IButtonClickListener
69 std::unique_ptr<weld::ScrolledWindow> m_xScrolledWindow;
70 std::unique_ptr<weld::Container> m_xLinesPlayground;
71 std::unique_ptr<weld::SizeGroup> m_xSizeGroup;
72 std::unique_ptr<InspectorHelpWindow> m_xHelpWindow;
73 weld::Container* m_pInitialControlParent;
74 ListBoxLines m_aLines;
75 IPropertyLineListener* m_pLineListener;
76 IPropertyControlObserver* m_pControlObserver;
77 css::uno::Reference< css::inspection::XPropertyControl >
78 m_xActiveControl;
79 sal_uInt16 m_nTheNameSize;
80 int m_nRowHeight;
81 ::rtl::Reference< PropertyControlContext_Impl >
82 m_pControlContextImpl;
84 void UpdatePlayGround();
85 void ShowEntry(sal_uInt16 nPos);
87 public:
88 explicit OBrowserListBox(weld::Builder& rBuilder, weld::Container* pContainer);
89 ~OBrowserListBox();
91 void SetListener( IPropertyLineListener* _pListener );
92 void SetObserver( IPropertyControlObserver* _pObserver );
94 void EnableHelpSection( bool _bEnable );
95 bool HasHelpSection() const;
96 void SetHelpText( const OUString& _rHelpText );
98 void Clear();
100 void InsertEntry( const OLineDescriptor&, sal_uInt16 nPos );
101 bool RemoveEntry( const OUString& _rName );
102 void ChangeEntry( const OLineDescriptor&, ListBoxLines::size_type nPos );
104 void SetPropertyValue( const OUString& rEntryName, const css::uno::Any& rValue, bool _bUnknownValue );
105 sal_uInt16 GetPropertyPos( std::u16string_view rEntryName ) const;
106 css::uno::Reference< css::inspection::XPropertyControl >
107 GetPropertyControl( const OUString& rEntryName );
108 void EnablePropertyControls( const OUString& _rEntryName, sal_Int16 _nControls, bool _bEnable );
109 void EnablePropertyLine( const OUString& _rEntryName, bool _bEnable );
111 bool IsModified( ) const;
112 void CommitModified( );
114 /// @throws css::uno::RuntimeException
115 void focusGained( const css::uno::Reference< css::inspection::XPropertyControl >& Control );
116 /// @throws css::uno::RuntimeException
117 void valueChanged( const css::uno::Reference< css::inspection::XPropertyControl >& Control );
118 /// @throws css::uno::RuntimeException
119 void activateNextControl( const css::uno::Reference< css::inspection::XPropertyControl >& CurrentControl );
121 private:
122 // IButtonClickListener
123 void buttonClicked( OBrowserLine* _pLine, bool _bPrimary ) override;
125 /** retrieves the index of a given control in our line list
126 @param _rxControl
127 The control to lookup. Must denote a control of one of the lines in ->m_aLines
129 sal_uInt16 impl_getControlPos( const css::uno::Reference< css::inspection::XPropertyControl >& _rxControl ) const;
131 /** sets the given property value at the given control, after converting it as necessary
132 @param _rLine
133 The line whose at which the value is to be set.
134 @param _rPropertyValue
135 the property value to set. If it's not compatible with the control value,
136 it will be converted, using <member>XPropertyHandler::convertToControlValue</member>
138 static void impl_setControlAsPropertyValue( const ListBoxLine& _rLine, const css::uno::Any& _rPropertyValue );
140 /** retrieves the value for the given control, as a property value, after converting it as necessary
141 @param _rLine
142 The line whose at which the value is to be set.
144 static css::uno::Any
145 impl_getControlAsPropertyValue( const ListBoxLine& _rLine );
147 /** retrieves the ->BrowserLinePointer for a given entry name
148 @param _rEntryName
149 the name whose line is to be looked up
150 @param _out_rpLine
151 contains, upon return, the found browser line, if any
152 @return
153 <TRUE/> if and only if a non-<NULL/> line for the given entry name could be
154 found.
156 bool impl_getBrowserLineForName( const OUString& _rEntryName, BrowserLinePointer& _out_rpLine ) const;
160 } // namespace pcr
164 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */