diff options
-rw-r--r-- | include/svl/svl.hrc | 1 | ||||
-rw-r--r-- | include/svtools/strings.hrc | 1 | ||||
-rw-r--r-- | include/toolkit/awt/vclxwindows.hxx | 49 | ||||
-rw-r--r-- | solenv/clang-format/blacklist | 4 | ||||
-rw-r--r-- | svtools/Library_svt.mk | 1 | ||||
-rw-r--r-- | svtools/inc/pch/precompiled_svt.hxx | 5 | ||||
-rw-r--r-- | svtools/source/inc/unoiface.hxx | 57 | ||||
-rw-r--r-- | svtools/source/uno/unoiface.cxx | 293 | ||||
-rw-r--r-- | toolkit/Library_tk.mk | 2 | ||||
-rw-r--r-- | toolkit/inc/controls/filectrl.hxx (renamed from svtools/source/inc/filectrl.hxx) | 0 | ||||
-rw-r--r-- | toolkit/source/awt/vclxtoolkit.cxx | 6 | ||||
-rw-r--r-- | toolkit/source/awt/vclxwindows.cxx | 289 | ||||
-rw-r--r-- | toolkit/source/controls/filectrl.cxx (renamed from svtools/source/control/filectrl.cxx) | 8 |
13 files changed, 353 insertions, 363 deletions
diff --git a/include/svl/svl.hrc b/include/svl/svl.hrc index cd60edf6c346..231d26c0f3b5 100644 --- a/include/svl/svl.hrc +++ b/include/svl/svl.hrc @@ -24,6 +24,7 @@ // Internet Media Type Presentations #define STR_SVT_MIMETYPE_CNT_FSYSBOX NC_("STR_SVT_MIMETYPE_CNT_FSYSBOX", "Workplace") +#define STR_FILECTRL_BUTTONTEXT NC_("STR_FILECTRL_BUTTONTEXT", "Browse...") #endif diff --git a/include/svtools/strings.hrc b/include/svtools/strings.hrc index 5b99e51605e3..a71792e20026 100644 --- a/include/svtools/strings.hrc +++ b/include/svtools/strings.hrc @@ -179,7 +179,6 @@ #define STR_SVT_FONTMAP_STYLENOTAVAILABLE NC_("STR_SVT_FONTMAP_STYLENOTAVAILABLE", "This font style will be simulated or the closest matching style will be used.") #define STR_SVT_FONTMAP_NOTAVAILABLE NC_("STR_SVT_FONTMAP_NOTAVAILABLE", "This font has not been installed. The closest available font will be used.") -#define STR_FILECTRL_BUTTONTEXT NC_("STR_FILECTRL_BUTTONTEXT", "Browse...") #define STR_TABBAR_PUSHBUTTON_MOVET0HOME NC_("STR_TABBAR_PUSHBUTTON_MOVET0HOME", "Move To Home") #define STR_TABBAR_PUSHBUTTON_MOVELEFT NC_("STR_TABBAR_PUSHBUTTON_MOVELEFT", "Move Left") #define STR_TABBAR_PUSHBUTTON_MOVERIGHT NC_("STR_TABBAR_PUSHBUTTON_MOVERIGHT", "Move Right") diff --git a/include/toolkit/awt/vclxwindows.hxx b/include/toolkit/awt/vclxwindows.hxx index e3763da5012a..e470b5e3a46e 100644 --- a/include/toolkit/awt/vclxwindows.hxx +++ b/include/toolkit/awt/vclxwindows.hxx @@ -60,7 +60,7 @@ class FormatterBase; class TabControl; class TabPage; - +class Edit; // class VCLXGraphicControl // deriving from VCLXWindow, drawing the graphic which exists as "Graphic" at the model @@ -1226,8 +1226,55 @@ public: virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override { return ImplGetPropertyIds( aIds ); } }; +class VCLXFileControl final : public css::awt::XTextComponent, public css::awt::XTextLayoutConstrains, public VCLXWindow +{ + DECL_LINK(ModifyHdl, Edit&, void); + void ModifyHdl(); + TextListenerMultiplexer maTextListeners; + +public: + VCLXFileControl(); + virtual ~VCLXFileControl() override; + + virtual void SetWindow( const VclPtr< vcl::Window > &pWindow ) 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; + + // 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; + void SAL_CALL setProperty( const OUString& PropertyName, const css::uno::Any& Value) 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 diff --git a/solenv/clang-format/blacklist b/solenv/clang-format/blacklist index 6c5b5e257384..9324dcfbb7b7 100644 --- a/solenv/clang-format/blacklist +++ b/solenv/clang-format/blacklist @@ -13247,7 +13247,6 @@ svtools/source/control/calendar.cxx svtools/source/control/collatorres.cxx svtools/source/control/ctrlbox.cxx svtools/source/control/ctrltool.cxx -svtools/source/control/filectrl.cxx svtools/source/control/indexentryres.cxx svtools/source/control/inettbc.cxx svtools/source/control/managedmenubutton.cxx @@ -13281,7 +13280,6 @@ svtools/source/hatchwindow/hatchwindow.cxx svtools/source/hatchwindow/hatchwindowfactory.cxx svtools/source/hatchwindow/ipwin.cxx svtools/source/hatchwindow/ipwin.hxx -svtools/source/inc/filectrl.hxx svtools/source/inc/hatchwindow.hxx svtools/source/inc/unoiface.hxx svtools/source/java/javacontext.cxx @@ -15981,6 +15979,7 @@ toolkit/inc/controls/animatedimages.hxx toolkit/inc/controls/controlmodelcontainerbase.hxx toolkit/inc/controls/dialogcontrol.hxx toolkit/inc/controls/eventcontainer.hxx +toolkit/inc/controls/filectrl.hxx toolkit/inc/controls/formattedcontrol.hxx toolkit/inc/controls/geometrycontrolmodel.hxx toolkit/inc/controls/geometrycontrolmodel_impl.hxx @@ -16031,6 +16030,7 @@ toolkit/source/controls/controlmodelcontainerbase.cxx toolkit/source/controls/controlmodelcontainerbase_internal.hxx toolkit/source/controls/dialogcontrol.cxx toolkit/source/controls/eventcontainer.cxx +toolkit/source/controls/filectrl.cxx toolkit/source/controls/formattedcontrol.cxx toolkit/source/controls/geometrycontrolmodel.cxx toolkit/source/controls/grid/defaultgridcolumnmodel.cxx diff --git a/svtools/Library_svt.mk b/svtools/Library_svt.mk index ab191699615b..759b880600f9 100644 --- a/svtools/Library_svt.mk +++ b/svtools/Library_svt.mk @@ -96,7 +96,6 @@ $(eval $(call gb_Library_add_exception_objects,svt,\ svtools/source/control/collatorres \ svtools/source/control/ctrlbox \ svtools/source/control/ctrltool \ - svtools/source/control/filectrl \ svtools/source/control/indexentryres \ svtools/source/control/inettbc \ svtools/source/control/managedmenubutton \ diff --git a/svtools/inc/pch/precompiled_svt.hxx b/svtools/inc/pch/precompiled_svt.hxx index 632affc2a513..a26b21753606 100644 --- a/svtools/inc/pch/precompiled_svt.hxx +++ b/svtools/inc/pch/precompiled_svt.hxx @@ -13,7 +13,7 @@ manual changes will be rewritten by the next run of update_pch.sh (which presumably also fixes all possible problems, so it's usually better to use it). - Generated on 2020-02-01 10:58:20 using: + Generated on 2020-02-13 16:04:02 using: ./bin/update_pch svtools svt --cutoff=4 --exclude:system --include:module --exclude:local If after updating build fails, use the following command to locate conflicting headers: @@ -54,7 +54,6 @@ #if PCH_LEVEL >= 2 #include <osl/diagnose.h> #include <osl/endian.h> -#include <osl/file.h> #include <osl/file.hxx> #include <osl/interlck.h> #include <osl/mutex.hxx> @@ -102,7 +101,6 @@ #include <vcl/bitmap.hxx> #include <vcl/bitmapex.hxx> #include <vcl/builder.hxx> -#include <vcl/button.hxx> #include <vcl/checksum.hxx> #include <vcl/combobox.hxx> #include <vcl/commandevent.hxx> @@ -392,7 +390,6 @@ #include <svtools/htmltokn.h> #include <svtools/svtdllapi.h> #include <svtools/svtresid.hxx> -#include <table/tabletypes.hxx> #include <svtools/valueset.hxx> #endif // PCH_LEVEL >= 4 diff --git a/svtools/source/inc/unoiface.hxx b/svtools/source/inc/unoiface.hxx index 11613d3c9852..7696d32fd5b9 100644 --- a/svtools/source/inc/unoiface.hxx +++ b/svtools/source/inc/unoiface.hxx @@ -27,8 +27,6 @@ #include <com/sun/star/awt/XTextComponent.hpp> #include <com/sun/star/awt/XTextLayoutConstrains.hpp> #include <tools/lineend.hxx> -#include <vcl/edit.hxx> - namespace com { namespace sun { namespace star { namespace util { class XNumberFormatsSupplier; @@ -100,61 +98,6 @@ public: virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override { return ImplGetPropertyIds( aIds ); } }; - - -class VCLXFileControl final : public css::awt::XTextComponent, public css::awt::XTextLayoutConstrains, public VCLXWindow -{ - DECL_LINK(ModifyHdl, Edit&, void); - void ModifyHdl(); - TextListenerMultiplexer maTextListeners; - -public: - VCLXFileControl(); - virtual ~VCLXFileControl() override; - - virtual void SetWindow( const VclPtr< vcl::Window > &pWindow ) 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; - - // 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; - - void SAL_CALL setProperty( const OUString& PropertyName, const css::uno::Any& Value) override; - - static void ImplGetPropertyIds( std::vector< sal_uInt16 > &aIds ); - virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override { return ImplGetPropertyIds( aIds ); } -}; - - - - class SVTXFormattedField : public VCLXSpinField { protected: diff --git a/svtools/source/uno/unoiface.cxx b/svtools/source/uno/unoiface.cxx index d4ffbfe4f2e6..6f0550135725 100644 --- a/svtools/source/uno/unoiface.cxx +++ b/svtools/source/uno/unoiface.cxx @@ -22,7 +22,6 @@ #include <vcl/svapp.hxx> #include <svl/zforlist.hxx> #include <svtools/svmedit.hxx> -#include <filectrl.hxx> #include <unoiface.hxx> #include <com/sun/star/awt/LineEndFormat.hpp> #include <cppuhelper/queryinterface.hxx> @@ -73,19 +72,6 @@ SAL_DLLPUBLIC_EXPORT vcl::Window* CreateWindow( VCLXWindow** ppNewComp, const cs return nullptr; } } - else if ( aServiceName.equalsIgnoreAsciiCase( "FileControl" ) ) - { - if ( pParent ) - { - pWindow = VclPtr<FileControl>::Create( pParent, nWinBits ); - *ppNewComp = new VCLXFileControl; - } - else - { - *ppNewComp = nullptr; - return nullptr; - } - } else if (aServiceName.equalsIgnoreAsciiCase("FormattedField") ) { pWindow = VclPtr<FormattedField>::Create( pParent, nWinBits ); @@ -504,285 +490,6 @@ void VCLXMultiLineEdit::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds ) VCLXWindow::ImplGetPropertyIds( rIds, true ); } - -VCLXFileControl::VCLXFileControl() : maTextListeners( *this ) -{ -} - -VCLXFileControl::~VCLXFileControl() -{ - VclPtr< FileControl > pControl = GetAs< FileControl >(); - if ( pControl ) - pControl->GetEdit().SetModifyHdl( Link<Edit&,void>() ); -} - -css::uno::Any VCLXFileControl::queryInterface( const css::uno::Type & rType ) -{ - css::uno::Any aRet = ::cppu::queryInterface( rType, - static_cast< css::awt::XTextComponent* >(this), - static_cast< css::awt::XTextLayoutConstrains* >(this), - static_cast< css::lang::XTypeProvider* >(this) ); - return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType )); -} - -IMPL_IMPLEMENTATION_ID( VCLXFileControl ) - -// css::lang::XTypeProvider -css::uno::Sequence< css::uno::Type > VCLXFileControl::getTypes() -{ - static const ::cppu::OTypeCollection aTypeList( - cppu::UnoType<css::lang::XTypeProvider>::get(), - cppu::UnoType<css::awt::XTextComponent>::get(), - cppu::UnoType<css::awt::XTextLayoutConstrains>::get(), - VCLXWindow::getTypes() - ); - return aTypeList.getTypes(); -} - -void SAL_CALL VCLXFileControl::setProperty( const OUString& PropertyName, const css::uno::Any& Value) -{ - SolarMutexGuard aGuard; - - VclPtr< FileControl > pControl = GetAs< FileControl >(); - if ( !pControl ) - return; - - sal_uInt16 nPropType = GetPropertyId( PropertyName ); - switch ( nPropType ) - { - case BASEPROPERTY_HIDEINACTIVESELECTION: - { - bool bValue(false); - OSL_VERIFY( Value >>= bValue ); - - lcl_setWinBits( pControl, WB_NOHIDESELECTION, !bValue ); - lcl_setWinBits( &pControl->GetEdit(), WB_NOHIDESELECTION, !bValue ); - } - break; - - default: - VCLXWindow::setProperty( PropertyName, Value ); - break; - } -} - -void VCLXFileControl::SetWindow( const VclPtr< vcl::Window > &pWindow ) -{ - VclPtr< FileControl > pPrevFileControl = GetAsDynamic< FileControl >(); - if ( pPrevFileControl ) - pPrevFileControl->SetEditModifyHdl( Link<Edit&,void>() ); - - FileControl* pNewFileControl = dynamic_cast<FileControl*>( pWindow.get() ); - if ( pNewFileControl ) - pNewFileControl->SetEditModifyHdl( LINK( this, VCLXFileControl, ModifyHdl ) ); - - VCLXWindow::SetWindow( pWindow ); -} - -void VCLXFileControl::addTextListener( const css::uno::Reference< css::awt::XTextListener > & l ) -{ - maTextListeners.addInterface( l ); -} - -void VCLXFileControl::removeTextListener( const css::uno::Reference< css::awt::XTextListener > & l ) -{ - maTextListeners.removeInterface( l ); -} - -void VCLXFileControl::setText( const OUString& aText ) -{ - SolarMutexGuard aGuard; - - VclPtr<vcl::Window> pWindow = GetWindow(); - if ( pWindow ) - { - pWindow->SetText( aText ); - - // also in Java a textChanged is triggered, not in VCL. - // css::awt::Toolkit should be JAVA-compliant... - ModifyHdl(); - } -} - -void VCLXFileControl::insertText( const css::awt::Selection& rSel, const OUString& aText ) -{ - SolarMutexGuard aGuard; - - VclPtr< FileControl > pFileControl = GetAs< FileControl >(); - if ( pFileControl ) - { - pFileControl->GetEdit().SetSelection( Selection( rSel.Min, rSel.Max ) ); - pFileControl->GetEdit().ReplaceSelected( aText ); - } -} - -OUString VCLXFileControl::getText() -{ - SolarMutexGuard aGuard; - - OUString aText; - VclPtr<vcl::Window> pWindow = GetWindow(); - if ( pWindow ) - aText = pWindow->GetText(); - return aText; -} - -OUString VCLXFileControl::getSelectedText() -{ - SolarMutexGuard aGuard; - - OUString aText; - VclPtr< FileControl > pFileControl = GetAs< FileControl >(); - if ( pFileControl) - aText = pFileControl->GetEdit().GetSelected(); - return aText; - -} - -void VCLXFileControl::setSelection( const css::awt::Selection& aSelection ) -{ - SolarMutexGuard aGuard; - - VclPtr< FileControl > pFileControl = GetAs< FileControl >(); - if ( pFileControl ) - pFileControl->GetEdit().SetSelection( Selection( aSelection.Min, aSelection.Max ) ); -} - -css::awt::Selection VCLXFileControl::getSelection() -{ - SolarMutexGuard aGuard; - - css::awt::Selection aSel; - VclPtr< FileControl > pFileControl = GetAs< FileControl >(); - if ( pFileControl ) - { - aSel.Min = pFileControl->GetEdit().GetSelection().Min(); - aSel.Max = pFileControl->GetEdit().GetSelection().Max(); - } - return aSel; -} - -sal_Bool VCLXFileControl::isEditable() -{ - SolarMutexGuard aGuard; - - VclPtr< FileControl > pFileControl = GetAs< FileControl >(); - return pFileControl && !pFileControl->GetEdit().IsReadOnly() && pFileControl->GetEdit().IsEnabled(); -} - -void VCLXFileControl::setEditable( sal_Bool bEditable ) -{ - SolarMutexGuard aGuard; - - VclPtr< FileControl > pFileControl = GetAs< FileControl >(); - if ( pFileControl ) - pFileControl->GetEdit().SetReadOnly( !bEditable ); -} - -void VCLXFileControl::setMaxTextLen( sal_Int16 nLen ) -{ - SolarMutexGuard aGuard; - - VclPtr< FileControl > pFileControl = GetAs< FileControl >(); - if ( pFileControl ) - pFileControl->GetEdit().SetMaxTextLen( nLen ); -} - -sal_Int16 VCLXFileControl::getMaxTextLen() -{ - SolarMutexGuard aGuard; - - VclPtr< FileControl > pFileControl = GetAs< FileControl >(); - return pFileControl ? pFileControl->GetEdit().GetMaxTextLen() : 0; -} - - -IMPL_LINK_NOARG(VCLXFileControl, ModifyHdl, Edit&, void) -{ - ModifyHdl(); -} - -void VCLXFileControl::ModifyHdl() -{ - css::awt::TextEvent aEvent; - aEvent.Source = static_cast<cppu::OWeakObject*>(this); - maTextListeners.textChanged( aEvent ); -} - -css::awt::Size VCLXFileControl::getMinimumSize() -{ - SolarMutexGuard aGuard; - - css::awt::Size aSz; - VclPtr< FileControl > pControl = GetAs< FileControl >(); - if ( pControl ) - { - Size aTmpSize = pControl->GetEdit().CalcMinimumSize(); - aTmpSize.AdjustWidth(pControl->GetButton().CalcMinimumSize().Width() ); - aSz = AWTSize(pControl->CalcWindowSize( aTmpSize )); - } - return aSz; -} - -css::awt::Size VCLXFileControl::getPreferredSize() -{ - css::awt::Size aSz = getMinimumSize(); - aSz.Height += 4; - return aSz; -} - -css::awt::Size VCLXFileControl::calcAdjustedSize( const css::awt::Size& rNewSize ) -{ - SolarMutexGuard aGuard; - - css::awt::Size aSz =rNewSize; - VclPtr< FileControl > pControl = GetAs< FileControl >(); - if ( pControl ) - { - css::awt::Size aMinSz = getMinimumSize(); - if ( aSz.Height != aMinSz.Height ) - aSz.Height = aMinSz.Height; - } - return aSz; -} - -css::awt::Size VCLXFileControl::getMinimumSize( sal_Int16 nCols, sal_Int16 ) -{ - SolarMutexGuard aGuard; - - css::awt::Size aSz; - VclPtr< FileControl > pControl = GetAs< FileControl >(); - if ( pControl ) - { - aSz = AWTSize(pControl->GetEdit().CalcSize( nCols )); - aSz.Width += pControl->GetButton().CalcMinimumSize().Width(); - } - return aSz; -} - -void VCLXFileControl::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) -{ - SolarMutexGuard aGuard; - - nCols = 0; - nLines = 1; - VclPtr< FileControl > pControl = GetAs< FileControl >(); - if ( pControl ) - nCols = pControl->GetEdit().GetMaxVisChars(); -} - -void VCLXFileControl::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds ) -{ - PushPropertyIds( rIds, - // FIXME: elide duplication ? - BASEPROPERTY_HIDEINACTIVESELECTION, - 0); - VCLXWindow::ImplGetPropertyIds( rIds, true ); -} - - - - SVTXFormattedField::SVTXFormattedField() :bIsStandardSupplier(true) ,nKeyToSetDelayed(-1) diff --git a/toolkit/Library_tk.mk b/toolkit/Library_tk.mk index a582bd4e76b2..55639910d7fb 100644 --- a/toolkit/Library_tk.mk +++ b/toolkit/Library_tk.mk @@ -50,6 +50,7 @@ $(eval $(call gb_Library_use_libraries,tk,\ sal \ salhelper \ i18nlangtag \ + svl \ tl \ utl \ vcl \ @@ -82,6 +83,7 @@ $(eval $(call gb_Library_add_exception_objects,tk,\ toolkit/source/controls/controlmodelcontainerbase \ toolkit/source/controls/dialogcontrol \ toolkit/source/controls/eventcontainer \ + toolkit/source/controls/filectrl \ toolkit/source/controls/formattedcontrol \ toolkit/source/controls/geometrycontrolmodel \ toolkit/source/controls/grid/defaultgridcolumnmodel \ diff --git a/svtools/source/inc/filectrl.hxx b/toolkit/inc/controls/filectrl.hxx index cb01ff29b0fe..cb01ff29b0fe 100644 --- a/svtools/source/inc/filectrl.hxx +++ b/toolkit/inc/controls/filectrl.hxx diff --git a/toolkit/source/awt/vclxtoolkit.cxx b/toolkit/source/awt/vclxtoolkit.cxx index 01c0d3cd2499..bf875134d9cf 100644 --- a/toolkit/source/awt/vclxtoolkit.cxx +++ b/toolkit/source/awt/vclxtoolkit.cxx @@ -78,6 +78,7 @@ #include <toolkit/helper/property.hxx> #include <toolkit/helper/convert.hxx> +#include <controls/filectrl.hxx> #include <vcl/button.hxx> #include <vcl/combobox.hxx> #include <vcl/ctrl.hxx> @@ -1802,6 +1803,11 @@ vcl::Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, pNewWindow = VclPtr<ProgressBar>::Create( pParent, nWinBits ); *ppNewComp = new VCLXProgressBar; } + else if (aServiceName == "filecontrol") + { + pNewWindow = VclPtr<FileControl>::Create( pParent, nWinBits ); + *ppNewComp = new VCLXFileControl; + } break; default: OSL_ENSURE( false, "VCLXToolkit::ImplCreateWindow: unknown window type!" ); diff --git a/toolkit/source/awt/vclxwindows.cxx b/toolkit/source/awt/vclxwindows.cxx index 5789fe5ebf80..1a500e869e7e 100644 --- a/toolkit/source/awt/vclxwindows.cxx +++ b/toolkit/source/awt/vclxwindows.cxx @@ -40,6 +40,7 @@ #include <comphelper/processfactory.hxx> #include <sal/log.hxx> +#include <controls/filectrl.hxx> #include <vcl/button.hxx> #include <vcl/graph.hxx> #include <vcl/lstbox.hxx> @@ -6881,4 +6882,292 @@ void VCLXProgressBar::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds ) VCLXWindow::ImplGetPropertyIds( rIds, true ); } +VCLXFileControl::VCLXFileControl() : maTextListeners( *this ) +{ +} + +VCLXFileControl::~VCLXFileControl() +{ + VclPtr< FileControl > pControl = GetAs< FileControl >(); + if ( pControl ) + pControl->GetEdit().SetModifyHdl( Link<Edit&,void>() ); +} + +css::uno::Any VCLXFileControl::queryInterface( const css::uno::Type & rType ) +{ + css::uno::Any aRet = ::cppu::queryInterface( rType, + static_cast< css::awt::XTextComponent* >(this), + static_cast< css::awt::XTextLayoutConstrains* >(this), + static_cast< css::lang::XTypeProvider* >(this) ); + return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType )); +} + +IMPL_IMPLEMENTATION_ID( VCLXFileControl ) + +// css::lang::XTypeProvider +css::uno::Sequence< css::uno::Type > VCLXFileControl::getTypes() +{ + static const ::cppu::OTypeCollection aTypeList( + cppu::UnoType<css::lang::XTypeProvider>::get(), + cppu::UnoType<css::awt::XTextComponent>::get(), + cppu::UnoType<css::awt::XTextLayoutConstrains>::get(), + VCLXWindow::getTypes() + ); + return aTypeList.getTypes(); +} + +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 ); + } +} + +void SAL_CALL VCLXFileControl::setProperty( const OUString& PropertyName, const css::uno::Any& Value) +{ + SolarMutexGuard aGuard; + + VclPtr< FileControl > pControl = GetAs< FileControl >(); + if ( !pControl ) + return; + + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_HIDEINACTIVESELECTION: + { + bool bValue(false); + OSL_VERIFY( Value >>= bValue ); + + lcl_setWinBits( pControl, WB_NOHIDESELECTION, !bValue ); + lcl_setWinBits( &pControl->GetEdit(), WB_NOHIDESELECTION, !bValue ); + } + break; + + default: + VCLXWindow::setProperty( PropertyName, Value ); + break; + } +} + +void VCLXFileControl::SetWindow( const VclPtr< vcl::Window > &pWindow ) +{ + VclPtr< FileControl > pPrevFileControl = GetAsDynamic< FileControl >(); + if ( pPrevFileControl ) + pPrevFileControl->SetEditModifyHdl( Link<Edit&,void>() ); + + FileControl* pNewFileControl = dynamic_cast<FileControl*>( pWindow.get() ); + if ( pNewFileControl ) + pNewFileControl->SetEditModifyHdl( LINK( this, VCLXFileControl, ModifyHdl ) ); + + VCLXWindow::SetWindow( pWindow ); +} + +void VCLXFileControl::addTextListener( const css::uno::Reference< css::awt::XTextListener > & l ) +{ + maTextListeners.addInterface( l ); +} + +void VCLXFileControl::removeTextListener( const css::uno::Reference< css::awt::XTextListener > & l ) +{ + maTextListeners.removeInterface( l ); +} + +void VCLXFileControl::setText( const OUString& aText ) +{ + SolarMutexGuard aGuard; + + VclPtr<vcl::Window> pWindow = GetWindow(); + if ( pWindow ) + { + pWindow->SetText( aText ); + + // also in Java a textChanged is triggered, not in VCL. + // css::awt::Toolkit should be JAVA-compliant... + ModifyHdl(); + } +} + +void VCLXFileControl::insertText( const css::awt::Selection& rSel, const OUString& aText ) +{ + SolarMutexGuard aGuard; + + VclPtr< FileControl > pFileControl = GetAs< FileControl >(); + if ( pFileControl ) + { + pFileControl->GetEdit().SetSelection( Selection( rSel.Min, rSel.Max ) ); + pFileControl->GetEdit().ReplaceSelected( aText ); + } +} + +OUString VCLXFileControl::getText() +{ + SolarMutexGuard aGuard; + + OUString aText; + VclPtr<vcl::Window> pWindow = GetWindow(); + if ( pWindow ) + aText = pWindow->GetText(); + return aText; +} + +OUString VCLXFileControl::getSelectedText() +{ + SolarMutexGuard aGuard; + + OUString aText; + VclPtr< FileControl > pFileControl = GetAs< FileControl >(); + if ( pFileControl) + aText = pFileControl->GetEdit().GetSelected(); + return aText; + +} + +void VCLXFileControl::setSelection( const css::awt::Selection& aSelection ) +{ + SolarMutexGuard aGuard; + + VclPtr< FileControl > pFileControl = GetAs< FileControl >(); + if ( pFileControl ) + pFileControl->GetEdit().SetSelection( Selection( aSelection.Min, aSelection.Max ) ); +} + +css::awt::Selection VCLXFileControl::getSelection() +{ + SolarMutexGuard aGuard; + + css::awt::Selection aSel; + VclPtr< FileControl > pFileControl = GetAs< FileControl >(); + if ( pFileControl ) + { + aSel.Min = pFileControl->GetEdit().GetSelection().Min(); + aSel.Max = pFileControl->GetEdit().GetSelection().Max(); + } + return aSel; +} + +sal_Bool VCLXFileControl::isEditable() +{ + SolarMutexGuard aGuard; + + VclPtr< FileControl > pFileControl = GetAs< FileControl >(); + return pFileControl && !pFileControl->GetEdit().IsReadOnly() && pFileControl->GetEdit().IsEnabled(); +} + +void VCLXFileControl::setEditable( sal_Bool bEditable ) +{ + SolarMutexGuard aGuard; + + VclPtr< FileControl > pFileControl = GetAs< FileControl >(); + if ( pFileControl ) + pFileControl->GetEdit().SetReadOnly( !bEditable ); +} + +void VCLXFileControl::setMaxTextLen( sal_Int16 nLen ) +{ + SolarMutexGuard aGuard; + + VclPtr< FileControl > pFileControl = GetAs< FileControl >(); + if ( pFileControl ) + pFileControl->GetEdit().SetMaxTextLen( nLen ); +} + +sal_Int16 VCLXFileControl::getMaxTextLen() +{ + SolarMutexGuard aGuard; + + VclPtr< FileControl > pFileControl = GetAs< FileControl >(); + return pFileControl ? pFileControl->GetEdit().GetMaxTextLen() : 0; +} + + +IMPL_LINK_NOARG(VCLXFileControl, ModifyHdl, Edit&, void) +{ + ModifyHdl(); +} + +void VCLXFileControl::ModifyHdl() +{ + css::awt::TextEvent aEvent; + aEvent.Source = static_cast<cppu::OWeakObject*>(this); + maTextListeners.textChanged( aEvent ); +} + +css::awt::Size VCLXFileControl::getMinimumSize() +{ + SolarMutexGuard aGuard; + + css::awt::Size aSz; + VclPtr< FileControl > pControl = GetAs< FileControl >(); + if ( pControl ) + { + Size aTmpSize = pControl->GetEdit().CalcMinimumSize(); + aTmpSize.AdjustWidth(pControl->GetButton().CalcMinimumSize().Width() ); + aSz = AWTSize(pControl->CalcWindowSize( aTmpSize )); + } + return aSz; +} + +css::awt::Size VCLXFileControl::getPreferredSize() +{ + css::awt::Size aSz = getMinimumSize(); + aSz.Height += 4; + return aSz; +} + +css::awt::Size VCLXFileControl::calcAdjustedSize( const css::awt::Size& rNewSize ) +{ + SolarMutexGuard aGuard; + + css::awt::Size aSz =rNewSize; + VclPtr< FileControl > pControl = GetAs< FileControl >(); + if ( pControl ) + { + css::awt::Size aMinSz = getMinimumSize(); + if ( aSz.Height != aMinSz.Height ) + aSz.Height = aMinSz.Height; + } + return aSz; +} + +css::awt::Size VCLXFileControl::getMinimumSize( sal_Int16 nCols, sal_Int16 ) +{ + SolarMutexGuard aGuard; + + css::awt::Size aSz; + VclPtr< FileControl > pControl = GetAs< FileControl >(); + if ( pControl ) + { + aSz = AWTSize(pControl->GetEdit().CalcSize( nCols )); + aSz.Width += pControl->GetButton().CalcMinimumSize().Width(); + } + return aSz; +} + +void VCLXFileControl::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) +{ + SolarMutexGuard aGuard; + + nCols = 0; + nLines = 1; + VclPtr< FileControl > pControl = GetAs< FileControl >(); + if ( pControl ) + nCols = pControl->GetEdit().GetMaxVisChars(); +} + +void VCLXFileControl::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds ) +{ + PushPropertyIds( rIds, + // FIXME: elide duplication ? + BASEPROPERTY_HIDEINACTIVESELECTION, + 0); + VCLXWindow::ImplGetPropertyIds( rIds, true ); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/control/filectrl.cxx b/toolkit/source/controls/filectrl.cxx index 6f3704d9d3bb..3757f91da678 100644 --- a/svtools/source/control/filectrl.cxx +++ b/toolkit/source/controls/filectrl.cxx @@ -17,17 +17,17 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <filectrl.hxx> +#include <controls/filectrl.hxx> #include <com/sun/star/ui/dialogs/FilePicker.hpp> #include <com/sun/star/ui/dialogs/TemplateDescription.hpp> #include <comphelper/processfactory.hxx> #include <osl/file.h> #include <osl/diagnose.h> -#include <svtools/svtresid.hxx> +#include <svl/svlresid.hxx> +#include <svl/svl.hrc> #include <tools/urlobj.hxx> #include <vcl/edit.hxx> -#include <svtools/strings.hrc> using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; @@ -38,7 +38,7 @@ FileControl::FileControl( vcl::Window* pParent, WinBits nStyle ) : Window( pParent, nStyle|WB_DIALOGCONTROL ), maEdit( VclPtr<Edit>::Create(this, (nStyle&(~WB_BORDER))|WB_NOTABSTOP) ), maButton( VclPtr<PushButton>::Create( this, (nStyle&(~WB_BORDER))|WB_NOLIGHTBORDER|WB_NOPOINTERFOCUS|WB_NOTABSTOP ) ), - maButtonText( SvtResId(STR_FILECTRL_BUTTONTEXT) ), + maButtonText( SvlResId(STR_FILECTRL_BUTTONTEXT) ), mnInternalFlags( FileControlMode_Internal::ORIGINALBUTTONTEXT ) { maButton->SetClickHdl( LINK( this, FileControl, ButtonHdl ) ); |