diff options
-rw-r--r-- | include/toolkit/awt/vclxwindows.hxx | 67 | ||||
-rw-r--r-- | solenv/clang-format/excludelist | 4 | ||||
-rw-r--r-- | svtools/Library_svt.mk | 1 | ||||
-rw-r--r-- | svtools/source/inc/unoiface.hxx | 67 | ||||
-rw-r--r-- | svtools/source/uno/unoiface.cxx | 411 | ||||
-rw-r--r-- | toolkit/Library_tk.mk | 1 | ||||
-rw-r--r-- | toolkit/inc/controls/svmedit.hxx (renamed from svtools/inc/svmedit.hxx) | 5 | ||||
-rw-r--r-- | toolkit/source/awt/vclxtoolkit.cxx | 5 | ||||
-rw-r--r-- | toolkit/source/awt/vclxwindows.cxx | 369 | ||||
-rw-r--r-- | toolkit/source/controls/svmedit.cxx (renamed from svtools/source/edit/svmedit.cxx) | 4 |
10 files changed, 448 insertions, 486 deletions
diff --git a/include/toolkit/awt/vclxwindows.hxx b/include/toolkit/awt/vclxwindows.hxx index d9a11b66f6f0..ba13cd2f7da1 100644 --- a/include/toolkit/awt/vclxwindows.hxx +++ b/include/toolkit/awt/vclxwindows.hxx @@ -47,6 +47,9 @@ #include <com/sun/star/awt/XCheckBox.hpp> #include <com/sun/star/awt/XItemListListener.hpp> #include <com/sun/star/awt/XSimpleTabController.hpp> +#include <com/sun/star/awt/XTextArea.hpp> +#include <com/sun/star/awt/XTextComponent.hpp> +#include <com/sun/star/awt/XTextLayoutConstrains.hpp> #include <com/sun/star/util/Time.hpp> #include <com/sun/star/util/Date.hpp> #include <cppuhelper/implbase.hxx> @@ -58,6 +61,8 @@ #include <toolkit/awt/vclxtopwindow.hxx> #include <toolkit/helper/listenermultiplexer.hxx> +#include <tools/lineend.hxx> + #include <vcl/image.hxx> class FormatterBase; @@ -1363,6 +1368,68 @@ public: virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override { return ImplGetPropertyIds( aIds ); } }; +class VCLXMultiLineEdit : public css::awt::XTextComponent, + public css::awt::XTextArea, + public css::awt::XTextLayoutConstrains, + public VCLXWindow +{ +private: + TextListenerMultiplexer maTextListeners; + LineEnd meLineEndType; + +protected: + void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) override; + +public: + VCLXMultiLineEdit(); + virtual ~VCLXMultiLineEdit() override; + + // css::uno::XInterface + css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + void SAL_CALL acquire() throw() override { VCLXWindow::acquire(); } + void SAL_CALL release() throw() override { VCLXWindow::release(); } + + // css::lang::XTypeProvider + css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // css::awt::XTextComponent + void SAL_CALL addTextListener( const css::uno::Reference< css::awt::XTextListener >& l ) override; + void SAL_CALL removeTextListener( const css::uno::Reference< css::awt::XTextListener >& l ) override; + void SAL_CALL setText( const OUString& aText ) override; + void SAL_CALL insertText( const css::awt::Selection& Sel, const OUString& Text ) override; + OUString SAL_CALL getText( ) override; + OUString SAL_CALL getSelectedText( ) override; + void SAL_CALL setSelection( const css::awt::Selection& aSelection ) override; + css::awt::Selection SAL_CALL getSelection( ) override; + sal_Bool SAL_CALL isEditable( ) override; + void SAL_CALL setEditable( sal_Bool bEditable ) override; + void SAL_CALL setMaxTextLen( sal_Int16 nLen ) override; + sal_Int16 SAL_CALL getMaxTextLen( ) override; + + //XTextArea + OUString SAL_CALL getTextLines( ) override; + + // css::awt::XLayoutConstrains + css::awt::Size SAL_CALL getMinimumSize( ) override; + css::awt::Size SAL_CALL getPreferredSize( ) override; + css::awt::Size SAL_CALL calcAdjustedSize( const css::awt::Size& aNewSize ) override; + + // css::awt::XTextLayoutConstrains + css::awt::Size SAL_CALL getMinimumSize( sal_Int16 nCols, sal_Int16 nLines ) override; + void SAL_CALL getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) override; + + // css::awt::XVclWindowPeer + void SAL_CALL setProperty( const OUString& PropertyName, const css::uno::Any& Value ) override; + css::uno::Any SAL_CALL getProperty( const OUString& PropertyName ) override; + + // css::awt::XWindow + void SAL_CALL setFocus( ) override; + + static void ImplGetPropertyIds( std::vector< sal_uInt16 > &aIds ); + virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override { return ImplGetPropertyIds( aIds ); } +}; + #endif // INCLUDED_TOOLKIT_AWT_VCLXWINDOWS_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/solenv/clang-format/excludelist b/solenv/clang-format/excludelist index 72626c886579..93532dfb4d12 100644 --- a/solenv/clang-format/excludelist +++ b/solenv/clang-format/excludelist @@ -12956,7 +12956,6 @@ svl/source/undo/undo.cxx svl/source/uno/pathservice.cxx svl/unx/source/svdde/ddedummy.cxx svtools/inc/strings.hxx -svtools/inc/svmedit.hxx svtools/inc/table/defaultinputhandler.hxx svtools/inc/table/gridtablerenderer.hxx svtools/inc/table/tablecontrol.hxx @@ -13022,7 +13021,6 @@ svtools/source/dialogs/insdlg.cxx svtools/source/dialogs/prnsetup.cxx svtools/source/dialogs/restartdialog.cxx svtools/source/edit/editsyntaxhighlighter.cxx -svtools/source/edit/svmedit.cxx svtools/source/edit/textwindowpeer.cxx svtools/source/filter/DocumentToGraphicRenderer.cxx svtools/source/filter/SvFilterOptionsDialog.cxx @@ -15717,6 +15715,7 @@ toolkit/inc/controls/roadmapcontrol.hxx toolkit/inc/controls/roadmapentry.hxx toolkit/inc/controls/stdtabcontroller.hxx toolkit/inc/controls/stdtabcontrollermodel.hxx +toolkit/inc/controls/svmedit.hxx toolkit/inc/controls/tabpagecontainer.hxx toolkit/inc/controls/tabpagemodel.hxx toolkit/inc/controls/tkscrollbar.hxx @@ -15776,6 +15775,7 @@ toolkit/source/controls/roadmapentry.cxx toolkit/source/controls/spinningprogress.cxx toolkit/source/controls/stdtabcontroller.cxx toolkit/source/controls/stdtabcontrollermodel.cxx +toolkit/source/controls/svmedit.cxx toolkit/source/controls/tabpagecontainer.cxx toolkit/source/controls/tabpagemodel.cxx toolkit/source/controls/tkscrollbar.cxx diff --git a/svtools/Library_svt.mk b/svtools/Library_svt.mk index 3367324e843a..0cb98dd8dde7 100644 --- a/svtools/Library_svt.mk +++ b/svtools/Library_svt.mk @@ -112,7 +112,6 @@ $(eval $(call gb_Library_add_exception_objects,svt,\ svtools/source/dialogs/restartdialog \ svtools/source/dialogs/ServerDetailsControls \ svtools/source/edit/editsyntaxhighlighter \ - svtools/source/edit/svmedit \ svtools/source/edit/textwindowpeer \ svtools/source/filter/SvFilterOptionsDialog \ svtools/source/filter/DocumentToGraphicRenderer \ diff --git a/svtools/source/inc/unoiface.hxx b/svtools/source/inc/unoiface.hxx index 1d3d5cb8ccd6..8134bb5ddfc3 100644 --- a/svtools/source/inc/unoiface.hxx +++ b/svtools/source/inc/unoiface.hxx @@ -23,11 +23,6 @@ #include <toolkit/awt/vclxwindows.hxx> #include <toolkit/helper/listenermultiplexer.hxx> -#include <com/sun/star/awt/XTextArea.hpp> -#include <com/sun/star/awt/XTextComponent.hpp> -#include <com/sun/star/awt/XTextLayoutConstrains.hpp> -#include <tools/lineend.hxx> - namespace com::sun::star::util { class XNumberFormatsSupplier; } @@ -36,66 +31,4 @@ class SvNumberFormatsSupplierObj; -class VCLXMultiLineEdit : public css::awt::XTextComponent, - public css::awt::XTextArea, - public css::awt::XTextLayoutConstrains, - public VCLXWindow -{ -private: - TextListenerMultiplexer maTextListeners; - LineEnd meLineEndType; - -protected: - void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) override; - -public: - VCLXMultiLineEdit(); - virtual ~VCLXMultiLineEdit() override; - - // css::uno::XInterface - css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; - void SAL_CALL acquire() throw() override { VCLXWindow::acquire(); } - void SAL_CALL release() throw() override { VCLXWindow::release(); } - - // css::lang::XTypeProvider - css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; - css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; - - // css::awt::XTextComponent - void SAL_CALL addTextListener( const css::uno::Reference< css::awt::XTextListener >& l ) override; - void SAL_CALL removeTextListener( const css::uno::Reference< css::awt::XTextListener >& l ) override; - void SAL_CALL setText( const OUString& aText ) override; - void SAL_CALL insertText( const css::awt::Selection& Sel, const OUString& Text ) override; - OUString SAL_CALL getText( ) override; - OUString SAL_CALL getSelectedText( ) override; - void SAL_CALL setSelection( const css::awt::Selection& aSelection ) override; - css::awt::Selection SAL_CALL getSelection( ) override; - sal_Bool SAL_CALL isEditable( ) override; - void SAL_CALL setEditable( sal_Bool bEditable ) override; - void SAL_CALL setMaxTextLen( sal_Int16 nLen ) override; - sal_Int16 SAL_CALL getMaxTextLen( ) override; - - //XTextArea - OUString SAL_CALL getTextLines( ) override; - - // css::awt::XLayoutConstrains - css::awt::Size SAL_CALL getMinimumSize( ) override; - css::awt::Size SAL_CALL getPreferredSize( ) override; - css::awt::Size SAL_CALL calcAdjustedSize( const css::awt::Size& aNewSize ) override; - - // css::awt::XTextLayoutConstrains - css::awt::Size SAL_CALL getMinimumSize( sal_Int16 nCols, sal_Int16 nLines ) override; - void SAL_CALL getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) override; - - // css::awt::XVclWindowPeer - void SAL_CALL setProperty( const OUString& PropertyName, const css::uno::Any& Value ) override; - css::uno::Any SAL_CALL getProperty( const OUString& PropertyName ) override; - - // css::awt::XWindow - void SAL_CALL setFocus( ) override; - - static void ImplGetPropertyIds( std::vector< sal_uInt16 > &aIds ); - virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override { return ImplGetPropertyIds( aIds ); } -}; - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/uno/unoiface.cxx b/svtools/source/uno/unoiface.cxx index fbd257f8f13c..748fcc9dd700 100644 --- a/svtools/source/uno/unoiface.cxx +++ b/svtools/source/uno/unoiface.cxx @@ -17,59 +17,19 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ - -#include <tools/debug.hxx> -#include <vcl/svapp.hxx> -#include <svl/zforlist.hxx> -#include <svmedit.hxx> #include <unoiface.hxx> -#include <com/sun/star/awt/LineEndFormat.hpp> -#include <cppuhelper/queryinterface.hxx> -#include <cppuhelper/typeprovider.hxx> -#include <toolkit/helper/convert.hxx> -#include <toolkit/helper/property.hxx> -#include <svl/numuno.hxx> #include "svtxgridcontrol.hxx" #include <table/tablecontrol.hxx> -namespace -{ - void lcl_setWinBits( vcl::Window* _pWindow, WinBits _nBits, bool _bSet ) - { - WinBits nStyle = _pWindow->GetStyle(); - if ( _bSet ) - nStyle |= _nBits; - else - nStyle &= ~_nBits; - _pWindow->SetStyle( nStyle ); - } -} - - // help function for the toolkit... - extern "C" { SAL_DLLPUBLIC_EXPORT vcl::Window* CreateWindow( VCLXWindow** ppNewComp, const css::awt::WindowDescriptor* pDescriptor, vcl::Window* pParent, WinBits nWinBits ) { vcl::Window* pWindow = nullptr; OUString aServiceName( pDescriptor->WindowServiceName ); - if ( aServiceName.equalsIgnoreAsciiCase( "MultiLineEdit" ) ) - { - if ( pParent ) - { - pWindow = VclPtr<MultiLineEdit>::Create( pParent, nWinBits|WB_IGNORETAB); - static_cast< MultiLineEdit* >( pWindow )->DisableSelectionOnFocus(); - *ppNewComp = new VCLXMultiLineEdit; - } - else - { - *ppNewComp = nullptr; - return nullptr; - } - } - else if ( aServiceName.equalsIgnoreAsciiCase( "Grid" ) ) + if ( aServiceName.equalsIgnoreAsciiCase( "Grid" ) ) { if ( pParent ) { @@ -87,373 +47,4 @@ SAL_DLLPUBLIC_EXPORT vcl::Window* CreateWindow( VCLXWindow** ppNewComp, const cs } // extern "C" - - -VCLXMultiLineEdit::VCLXMultiLineEdit() - :maTextListeners( *this ) - ,meLineEndType( LINEEND_LF ) // default behavior before introducing this property: LF (unix-like) -{ -} - -VCLXMultiLineEdit::~VCLXMultiLineEdit() -{ -} - -css::uno::Any VCLXMultiLineEdit::queryInterface( const css::uno::Type & rType ) -{ - css::uno::Any aRet = ::cppu::queryInterface( rType, - static_cast< css::awt::XTextComponent* >(this), - static_cast< css::awt::XTextArea* >(this), - static_cast< css::awt::XTextLayoutConstrains* >(this), - static_cast< css::lang::XTypeProvider* >(this) ); - return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType )); -} - -IMPL_IMPLEMENTATION_ID( VCLXMultiLineEdit ) - -// css::lang::XTypeProvider -css::uno::Sequence< css::uno::Type > VCLXMultiLineEdit::getTypes() -{ - static const ::cppu::OTypeCollection aTypeList( - cppu::UnoType<css::lang::XTypeProvider>::get(), - cppu::UnoType<css::awt::XTextComponent>::get(), - cppu::UnoType<css::awt::XTextArea>::get(), - cppu::UnoType<css::awt::XTextLayoutConstrains>::get(), - VCLXWindow::getTypes() - ); - return aTypeList.getTypes(); -} - -void VCLXMultiLineEdit::addTextListener( const css::uno::Reference< css::awt::XTextListener > & l ) -{ - maTextListeners.addInterface( l ); -} - -void VCLXMultiLineEdit::removeTextListener( const css::uno::Reference< css::awt::XTextListener > & l ) -{ - maTextListeners.removeInterface( l ); -} - -void VCLXMultiLineEdit::setText( const OUString& aText ) -{ - SolarMutexGuard aGuard; - - VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >(); - if ( pEdit ) - { - pEdit->SetText( aText ); - - // #107218# Call same listeners like VCL would do after user interaction - SetSynthesizingVCLEvent( true ); - pEdit->SetModifyFlag(); - pEdit->Modify(); - SetSynthesizingVCLEvent( false ); - } -} - -void VCLXMultiLineEdit::insertText( const css::awt::Selection& rSel, const OUString& aText ) -{ - SolarMutexGuard aGuard; - - VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >(); - if ( pEdit ) - { - setSelection( rSel ); - pEdit->ReplaceSelected( aText ); - } -} - -OUString VCLXMultiLineEdit::getText() -{ - SolarMutexGuard aGuard; - - OUString aText; - VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >(); - if ( pEdit ) - aText = pEdit->GetText( meLineEndType ); - return aText; -} - -OUString VCLXMultiLineEdit::getSelectedText() -{ - SolarMutexGuard aGuard; - - OUString aText; - VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >(); - if ( pMultiLineEdit) - aText = pMultiLineEdit->GetSelected( meLineEndType ); - return aText; - -} - -void VCLXMultiLineEdit::setSelection( const css::awt::Selection& aSelection ) -{ - SolarMutexGuard aGuard; - - VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >(); - if ( pMultiLineEdit ) - { - pMultiLineEdit->SetSelection( Selection( aSelection.Min, aSelection.Max ) ); - } -} - -css::awt::Selection VCLXMultiLineEdit::getSelection() -{ - SolarMutexGuard aGuard; - - css::awt::Selection aSel; - VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >(); - if ( pMultiLineEdit ) - { - aSel.Min = pMultiLineEdit->GetSelection().Min(); - aSel.Max = pMultiLineEdit->GetSelection().Max(); - } - return aSel; -} - -sal_Bool VCLXMultiLineEdit::isEditable() -{ - SolarMutexGuard aGuard; - - VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >(); - return pMultiLineEdit && !pMultiLineEdit->IsReadOnly() && pMultiLineEdit->IsEnabled(); -} - -void VCLXMultiLineEdit::setEditable( sal_Bool bEditable ) -{ - SolarMutexGuard aGuard; - - VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >(); - if ( pMultiLineEdit ) - pMultiLineEdit->SetReadOnly( !bEditable ); -} - -void VCLXMultiLineEdit::setMaxTextLen( sal_Int16 nLen ) -{ - SolarMutexGuard aGuard; - - VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >(); - if ( pMultiLineEdit ) - pMultiLineEdit->SetMaxTextLen( nLen ); -} - -sal_Int16 VCLXMultiLineEdit::getMaxTextLen() -{ - SolarMutexGuard aGuard; - - VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >(); - return pMultiLineEdit ? static_cast<sal_Int16>(pMultiLineEdit->GetMaxTextLen()) : sal_Int16(0); -} - -OUString VCLXMultiLineEdit::getTextLines() -{ - SolarMutexGuard aGuard; - - OUString aText; - VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >(); - if ( pEdit ) - aText = pEdit->GetTextLines( meLineEndType ); - return aText; -} - -css::awt::Size VCLXMultiLineEdit::getMinimumSize() -{ - SolarMutexGuard aGuard; - - css::awt::Size aSz; - VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >(); - if ( pEdit ) - aSz = AWTSize(pEdit->CalcMinimumSize()); - return aSz; -} - -css::awt::Size VCLXMultiLineEdit::getPreferredSize() -{ - return getMinimumSize(); -} - -css::awt::Size VCLXMultiLineEdit::calcAdjustedSize( const css::awt::Size& rNewSize ) -{ - SolarMutexGuard aGuard; - - css::awt::Size aSz = rNewSize; - VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >(); - if ( pEdit ) - aSz = AWTSize(pEdit->CalcAdjustedSize( VCLSize(rNewSize ))); - return aSz; -} - -css::awt::Size VCLXMultiLineEdit::getMinimumSize( sal_Int16 nCols, sal_Int16 nLines ) -{ - SolarMutexGuard aGuard; - - css::awt::Size aSz; - VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >(); - if ( pEdit ) - aSz = AWTSize(pEdit->CalcBlockSize( nCols, nLines )); - return aSz; -} - -void VCLXMultiLineEdit::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) -{ - SolarMutexGuard aGuard; - - nCols = nLines = 0; - VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >(); - if ( pEdit ) - { - sal_uInt16 nC, nL; - pEdit->GetMaxVisColumnsAndLines( nC, nL ); - nCols = nC; - nLines = nL; - } -} - -void VCLXMultiLineEdit::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) -{ - switch ( rVclWindowEvent.GetId() ) - { - case VclEventId::EditModify: - { - if ( maTextListeners.getLength() ) - { - css::awt::TextEvent aEvent; - aEvent.Source = static_cast<cppu::OWeakObject*>(this); - maTextListeners.textChanged( aEvent ); - } - } - break; - default: - { - VCLXWindow::ProcessWindowEvent( rVclWindowEvent ); - } - break; - } -} - -void VCLXMultiLineEdit::setProperty( const OUString& PropertyName, const css::uno::Any& Value) -{ - SolarMutexGuard aGuard; - - VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >(); - if ( !pMultiLineEdit ) - return; - - sal_uInt16 nPropType = GetPropertyId( PropertyName ); - switch ( nPropType ) - { - case BASEPROPERTY_LINE_END_FORMAT: - { - sal_Int16 nLineEndType = css::awt::LineEndFormat::LINE_FEED; - OSL_VERIFY( Value >>= nLineEndType ); - switch ( nLineEndType ) - { - case css::awt::LineEndFormat::CARRIAGE_RETURN: meLineEndType = LINEEND_CR; break; - case css::awt::LineEndFormat::LINE_FEED: meLineEndType = LINEEND_LF; break; - case css::awt::LineEndFormat::CARRIAGE_RETURN_LINE_FEED: meLineEndType = LINEEND_CRLF; break; - default: OSL_FAIL( "VCLXMultiLineEdit::setProperty: invalid line end value!" ); break; - } - } - break; - - case BASEPROPERTY_READONLY: - { - bool b; - if ( Value >>= b ) - pMultiLineEdit->SetReadOnly( b ); - } - break; - case BASEPROPERTY_MAXTEXTLEN: - { - sal_Int16 n = sal_Int16(); - if ( Value >>= n ) - pMultiLineEdit->SetMaxTextLen( n ); - } - break; - case BASEPROPERTY_HIDEINACTIVESELECTION: - { - bool b; - if ( Value >>= b ) - { - pMultiLineEdit->EnableFocusSelectionHide( b ); - lcl_setWinBits( pMultiLineEdit, WB_NOHIDESELECTION, !b ); - } - } - break; - default: - { - VCLXWindow::setProperty( PropertyName, Value ); - } - } -} - -css::uno::Any VCLXMultiLineEdit::getProperty( const OUString& PropertyName ) -{ - SolarMutexGuard aGuard; - - css::uno::Any aProp; - VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >(); - if ( pMultiLineEdit ) - { - sal_uInt16 nPropType = GetPropertyId( PropertyName ); - switch ( nPropType ) - { - case BASEPROPERTY_LINE_END_FORMAT: - { - sal_Int16 nLineEndType = css::awt::LineEndFormat::LINE_FEED; - switch ( meLineEndType ) - { - case LINEEND_CR: nLineEndType = css::awt::LineEndFormat::CARRIAGE_RETURN; break; - case LINEEND_LF: nLineEndType = css::awt::LineEndFormat::LINE_FEED; break; - case LINEEND_CRLF: nLineEndType = css::awt::LineEndFormat::CARRIAGE_RETURN_LINE_FEED; break; - default: OSL_FAIL( "VCLXMultiLineEdit::getProperty: invalid line end value!" ); break; - } - aProp <<= nLineEndType; - } - break; - - case BASEPROPERTY_READONLY: - { - aProp <<= pMultiLineEdit->IsReadOnly(); - } - break; - case BASEPROPERTY_MAXTEXTLEN: - { - aProp <<= static_cast<sal_Int16>(pMultiLineEdit->GetMaxTextLen()); - } - break; - default: - { - aProp = VCLXWindow::getProperty( PropertyName ); - } - } - } - return aProp; -} - -void SAL_CALL VCLXMultiLineEdit::setFocus( ) -{ - SolarMutexGuard aGuard; - - // don't grab the focus if we already have it. Reason is that the only thing which the edit - // does is forwarding the focus to its text window. This text window then does a "select all". - // So if the text window already has the focus, and we give the focus to the multi line - // edit, then all which happens is that everything is selected. - // #i27072# - if ( GetWindow() && !GetWindow()->HasChildPathFocus() ) - GetWindow()->GrabFocus(); -} - -void VCLXMultiLineEdit::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds ) -{ - PushPropertyIds( rIds, - // FIXME: elide duplication ? - BASEPROPERTY_LINE_END_FORMAT, - BASEPROPERTY_READONLY, - BASEPROPERTY_MAXTEXTLEN, - BASEPROPERTY_HIDEINACTIVESELECTION, - 0); - VCLXWindow::ImplGetPropertyIds( rIds, true ); -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/Library_tk.mk b/toolkit/Library_tk.mk index 752a0cc15f7b..88013385ccbe 100644 --- a/toolkit/Library_tk.mk +++ b/toolkit/Library_tk.mk @@ -94,6 +94,7 @@ $(eval $(call gb_Library_add_exception_objects,tk,\ toolkit/source/controls/grid/gridcontrol \ toolkit/source/controls/roadmapcontrol \ toolkit/source/controls/roadmapentry \ + toolkit/source/controls/svmedit \ toolkit/source/controls/tabpagecontainer \ toolkit/source/controls/tabpagemodel \ toolkit/source/controls/stdtabcontroller \ diff --git a/svtools/inc/svmedit.hxx b/toolkit/inc/controls/svmedit.hxx index bafa79ea1ebc..b783ce79487c 100644 --- a/svtools/inc/svmedit.hxx +++ b/toolkit/inc/controls/svmedit.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_SVTOOLS_SVMEDIT_HXX -#define INCLUDED_SVTOOLS_SVMEDIT_HXX +#pragma once #include <vcl/vclmedit.hxx> @@ -30,6 +29,4 @@ public: virtual css::uno::Reference< css::awt::XWindowPeer > GetComponentInterface(bool bCreate = true) override; }; -#endif // INCLUDED_SVTOOLS_SVMEDIT_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/source/awt/vclxtoolkit.cxx b/toolkit/source/awt/vclxtoolkit.cxx index 95c43c643a45..4f7dc2150d61 100644 --- a/toolkit/source/awt/vclxtoolkit.cxx +++ b/toolkit/source/awt/vclxtoolkit.cxx @@ -79,6 +79,7 @@ #include <toolkit/helper/convert.hxx> #include <controls/filectrl.hxx> +#include <controls/svmedit.hxx> #include <controls/treecontrolpeer.hxx> #include <vcl/toolkit/button.hxx> #include <vcl/toolkit/calendar.hxx> @@ -1465,6 +1466,10 @@ vcl::Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, pNewWindow = VclPtr<DockingAreaWindow>::Create( pParent ); break; case WindowType::MULTILINEEDIT: + pNewWindow = VclPtr<MultiLineEdit>::Create(pParent, nWinBits|WB_IGNORETAB); + static_cast<MultiLineEdit*>(pNewWindow.get())->DisableSelectionOnFocus(); + *ppNewComp = new VCLXMultiLineEdit; + break; case WindowType::EDIT: pNewWindow = VclPtr<Edit>::Create( pParent, nWinBits ); *ppNewComp = new VCLXEdit; diff --git a/toolkit/source/awt/vclxwindows.cxx b/toolkit/source/awt/vclxwindows.cxx index 6475fbd4062e..ad85262917e3 100644 --- a/toolkit/source/awt/vclxwindows.cxx +++ b/toolkit/source/awt/vclxwindows.cxx @@ -19,6 +19,7 @@ #include <toolkit/awt/vclxwindows.hxx> #include <toolkit/helper/accessiblefactory.hxx> +#include <com/sun/star/awt/LineEndFormat.hpp> #include <com/sun/star/awt/ScrollBarOrientation.hpp> #include <com/sun/star/graphic/GraphicProvider.hpp> #include <com/sun/star/graphic/XGraphicProvider.hpp> @@ -41,6 +42,7 @@ #include <sal/log.hxx> #include <controls/filectrl.hxx> +#include <controls/svmedit.hxx> #include <svl/zforlist.hxx> #include <vcl/toolkit/button.hxx> #include <vcl/toolkit/fmtfield.hxx> @@ -7870,4 +7872,371 @@ void SVTXDateField::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds ) VCLXDateField::ImplGetPropertyIds( rIds ); } +VCLXMultiLineEdit::VCLXMultiLineEdit() + :maTextListeners( *this ) + ,meLineEndType( LINEEND_LF ) // default behavior before introducing this property: LF (unix-like) +{ +} + +VCLXMultiLineEdit::~VCLXMultiLineEdit() +{ +} + +css::uno::Any VCLXMultiLineEdit::queryInterface( const css::uno::Type & rType ) +{ + css::uno::Any aRet = ::cppu::queryInterface( rType, + static_cast< css::awt::XTextComponent* >(this), + static_cast< css::awt::XTextArea* >(this), + static_cast< css::awt::XTextLayoutConstrains* >(this), + static_cast< css::lang::XTypeProvider* >(this) ); + return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType )); +} + +IMPL_IMPLEMENTATION_ID( VCLXMultiLineEdit ) + +// css::lang::XTypeProvider +css::uno::Sequence< css::uno::Type > VCLXMultiLineEdit::getTypes() +{ + static const ::cppu::OTypeCollection aTypeList( + cppu::UnoType<css::lang::XTypeProvider>::get(), + cppu::UnoType<css::awt::XTextComponent>::get(), + cppu::UnoType<css::awt::XTextArea>::get(), + cppu::UnoType<css::awt::XTextLayoutConstrains>::get(), + VCLXWindow::getTypes() + ); + return aTypeList.getTypes(); +} + +void VCLXMultiLineEdit::addTextListener( const css::uno::Reference< css::awt::XTextListener > & l ) +{ + maTextListeners.addInterface( l ); +} + +void VCLXMultiLineEdit::removeTextListener( const css::uno::Reference< css::awt::XTextListener > & l ) +{ + maTextListeners.removeInterface( l ); +} + +void VCLXMultiLineEdit::setText( const OUString& aText ) +{ + SolarMutexGuard aGuard; + + VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >(); + if ( pEdit ) + { + pEdit->SetText( aText ); + + // #107218# Call same listeners like VCL would do after user interaction + SetSynthesizingVCLEvent( true ); + pEdit->SetModifyFlag(); + pEdit->Modify(); + SetSynthesizingVCLEvent( false ); + } +} + +void VCLXMultiLineEdit::insertText( const css::awt::Selection& rSel, const OUString& aText ) +{ + SolarMutexGuard aGuard; + + VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >(); + if ( pEdit ) + { + setSelection( rSel ); + pEdit->ReplaceSelected( aText ); + } +} + +OUString VCLXMultiLineEdit::getText() +{ + SolarMutexGuard aGuard; + + OUString aText; + VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >(); + if ( pEdit ) + aText = pEdit->GetText( meLineEndType ); + return aText; +} + +OUString VCLXMultiLineEdit::getSelectedText() +{ + SolarMutexGuard aGuard; + + OUString aText; + VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >(); + if ( pMultiLineEdit) + aText = pMultiLineEdit->GetSelected( meLineEndType ); + return aText; + +} + +void VCLXMultiLineEdit::setSelection( const css::awt::Selection& aSelection ) +{ + SolarMutexGuard aGuard; + + VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >(); + if ( pMultiLineEdit ) + { + pMultiLineEdit->SetSelection( Selection( aSelection.Min, aSelection.Max ) ); + } +} + +css::awt::Selection VCLXMultiLineEdit::getSelection() +{ + SolarMutexGuard aGuard; + + css::awt::Selection aSel; + VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >(); + if ( pMultiLineEdit ) + { + aSel.Min = pMultiLineEdit->GetSelection().Min(); + aSel.Max = pMultiLineEdit->GetSelection().Max(); + } + return aSel; +} + +sal_Bool VCLXMultiLineEdit::isEditable() +{ + SolarMutexGuard aGuard; + + VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >(); + return pMultiLineEdit && !pMultiLineEdit->IsReadOnly() && pMultiLineEdit->IsEnabled(); +} + +void VCLXMultiLineEdit::setEditable( sal_Bool bEditable ) +{ + SolarMutexGuard aGuard; + + VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >(); + if ( pMultiLineEdit ) + pMultiLineEdit->SetReadOnly( !bEditable ); +} + +void VCLXMultiLineEdit::setMaxTextLen( sal_Int16 nLen ) +{ + SolarMutexGuard aGuard; + + VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >(); + if ( pMultiLineEdit ) + pMultiLineEdit->SetMaxTextLen( nLen ); +} + +sal_Int16 VCLXMultiLineEdit::getMaxTextLen() +{ + SolarMutexGuard aGuard; + + VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >(); + return pMultiLineEdit ? static_cast<sal_Int16>(pMultiLineEdit->GetMaxTextLen()) : sal_Int16(0); +} + +OUString VCLXMultiLineEdit::getTextLines() +{ + SolarMutexGuard aGuard; + + OUString aText; + VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >(); + if ( pEdit ) + aText = pEdit->GetTextLines( meLineEndType ); + return aText; +} + +css::awt::Size VCLXMultiLineEdit::getMinimumSize() +{ + SolarMutexGuard aGuard; + + css::awt::Size aSz; + VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >(); + if ( pEdit ) + aSz = AWTSize(pEdit->CalcMinimumSize()); + return aSz; +} + +css::awt::Size VCLXMultiLineEdit::getPreferredSize() +{ + return getMinimumSize(); +} + +css::awt::Size VCLXMultiLineEdit::calcAdjustedSize( const css::awt::Size& rNewSize ) +{ + SolarMutexGuard aGuard; + + css::awt::Size aSz = rNewSize; + VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >(); + if ( pEdit ) + aSz = AWTSize(pEdit->CalcAdjustedSize( VCLSize(rNewSize ))); + return aSz; +} + +css::awt::Size VCLXMultiLineEdit::getMinimumSize( sal_Int16 nCols, sal_Int16 nLines ) +{ + SolarMutexGuard aGuard; + + css::awt::Size aSz; + VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >(); + if ( pEdit ) + aSz = AWTSize(pEdit->CalcBlockSize( nCols, nLines )); + return aSz; +} + +void VCLXMultiLineEdit::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) +{ + SolarMutexGuard aGuard; + + nCols = nLines = 0; + VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >(); + if ( pEdit ) + { + sal_uInt16 nC, nL; + pEdit->GetMaxVisColumnsAndLines( nC, nL ); + nCols = nC; + nLines = nL; + } +} + +void VCLXMultiLineEdit::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) +{ + switch ( rVclWindowEvent.GetId() ) + { + case VclEventId::EditModify: + { + if ( maTextListeners.getLength() ) + { + css::awt::TextEvent aEvent; + aEvent.Source = static_cast<cppu::OWeakObject*>(this); + maTextListeners.textChanged( aEvent ); + } + } + break; + default: + { + VCLXWindow::ProcessWindowEvent( rVclWindowEvent ); + } + break; + } +} + +void VCLXMultiLineEdit::setProperty( const OUString& PropertyName, const css::uno::Any& Value) +{ + SolarMutexGuard aGuard; + + VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >(); + if ( !pMultiLineEdit ) + return; + + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_LINE_END_FORMAT: + { + sal_Int16 nLineEndType = css::awt::LineEndFormat::LINE_FEED; + OSL_VERIFY( Value >>= nLineEndType ); + switch ( nLineEndType ) + { + case css::awt::LineEndFormat::CARRIAGE_RETURN: meLineEndType = LINEEND_CR; break; + case css::awt::LineEndFormat::LINE_FEED: meLineEndType = LINEEND_LF; break; + case css::awt::LineEndFormat::CARRIAGE_RETURN_LINE_FEED: meLineEndType = LINEEND_CRLF; break; + default: OSL_FAIL( "VCLXMultiLineEdit::setProperty: invalid line end value!" ); break; + } + } + break; + + case BASEPROPERTY_READONLY: + { + bool b; + if ( Value >>= b ) + pMultiLineEdit->SetReadOnly( b ); + } + break; + case BASEPROPERTY_MAXTEXTLEN: + { + sal_Int16 n = sal_Int16(); + if ( Value >>= n ) + pMultiLineEdit->SetMaxTextLen( n ); + } + break; + case BASEPROPERTY_HIDEINACTIVESELECTION: + { + bool b; + if ( Value >>= b ) + { + pMultiLineEdit->EnableFocusSelectionHide( b ); + lcl_setWinBits( pMultiLineEdit, WB_NOHIDESELECTION, !b ); + } + } + break; + default: + { + VCLXWindow::setProperty( PropertyName, Value ); + } + } +} + +css::uno::Any VCLXMultiLineEdit::getProperty( const OUString& PropertyName ) +{ + SolarMutexGuard aGuard; + + css::uno::Any aProp; + VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >(); + if ( pMultiLineEdit ) + { + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_LINE_END_FORMAT: + { + sal_Int16 nLineEndType = css::awt::LineEndFormat::LINE_FEED; + switch ( meLineEndType ) + { + case LINEEND_CR: nLineEndType = css::awt::LineEndFormat::CARRIAGE_RETURN; break; + case LINEEND_LF: nLineEndType = css::awt::LineEndFormat::LINE_FEED; break; + case LINEEND_CRLF: nLineEndType = css::awt::LineEndFormat::CARRIAGE_RETURN_LINE_FEED; break; + default: OSL_FAIL( "VCLXMultiLineEdit::getProperty: invalid line end value!" ); break; + } + aProp <<= nLineEndType; + } + break; + + case BASEPROPERTY_READONLY: + { + aProp <<= pMultiLineEdit->IsReadOnly(); + } + break; + case BASEPROPERTY_MAXTEXTLEN: + { + aProp <<= static_cast<sal_Int16>(pMultiLineEdit->GetMaxTextLen()); + } + break; + default: + { + aProp = VCLXWindow::getProperty( PropertyName ); + } + } + } + return aProp; +} + +void SAL_CALL VCLXMultiLineEdit::setFocus( ) +{ + SolarMutexGuard aGuard; + + // don't grab the focus if we already have it. Reason is that the only thing which the edit + // does is forwarding the focus to its text window. This text window then does a "select all". + // So if the text window already has the focus, and we give the focus to the multi line + // edit, then all which happens is that everything is selected. + // #i27072# + if ( GetWindow() && !GetWindow()->HasChildPathFocus() ) + GetWindow()->GrabFocus(); +} + +void VCLXMultiLineEdit::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds ) +{ + PushPropertyIds( rIds, + // FIXME: elide duplication ? + BASEPROPERTY_LINE_END_FORMAT, + BASEPROPERTY_READONLY, + BASEPROPERTY_MAXTEXTLEN, + BASEPROPERTY_HIDEINACTIVESELECTION, + 0); + VCLXWindow::ImplGetPropertyIds( rIds, true ); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/edit/svmedit.cxx b/toolkit/source/controls/svmedit.cxx index 207cbdb894af..a6d1e6a55341 100644 --- a/svtools/source/edit/svmedit.cxx +++ b/toolkit/source/controls/svmedit.cxx @@ -17,8 +17,8 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <svmedit.hxx> -#include <unoiface.hxx> +#include <toolkit/awt/vclxwindows.hxx> +#include <controls/svmedit.hxx> MultiLineEdit::MultiLineEdit( vcl::Window* pParent, WinBits nWinStyle ) : VclMultiLineEdit( pParent,nWinStyle ) |