diff options
author | Zolnai Tamás <zolniatamas@caesar.elte.hu> | 2012-08-06 20:52:37 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@suse.cz> | 2012-08-07 10:50:23 +0200 |
commit | 2854d8b17cb873a5d61e06f9570ac344f054d666 (patch) | |
tree | 2d48cc3b620c25c4d894716d4470b4eefc8a86dd | |
parent | IDE: sal_Bool to bool (diff) | |
download | core-2854d8b17cb873a5d61e06f9570ac344f054d666.tar.gz core-2854d8b17cb873a5d61e06f9570ac344f054d666.zip |
fdo#46193 MessBox was made copyable
Part of MultiLineEdit was moved down from stvools to vcl
with name VCLMultiLineEdit. MessBox uses it to display the
message in read-only mode. Some of svtools' classes - which
are necessary to implement VCLMultiLineEdit - were moved to
vcl as a whole, and their includes are rewrite.
Note: ExtTextView and ExtTextEngine classes would be leaved in svtools
if VCLMultiLineEdit is a template class, but two macros: IMPL_LINK
end IMPL_LINK_NOARG make it impossible to use template syntax.
Change-Id: I26543868d8081c225c7125404d23369de3c3afcd
52 files changed, 1843 insertions, 1772 deletions
diff --git a/accessibility/inc/accessibility/extended/textwindowaccessibility.hxx b/accessibility/inc/accessibility/extended/textwindowaccessibility.hxx index f1557e16ec02..1ee7a3b00cd1 100644 --- a/accessibility/inc/accessibility/extended/textwindowaccessibility.hxx +++ b/accessibility/inc/accessibility/extended/textwindowaccessibility.hxx @@ -31,10 +31,10 @@ #include <toolkit/awt/vclxaccessiblecomponent.hxx> #include <svl/lstner.hxx> -#include <svtools/textdata.hxx> -#include <svtools/texteng.hxx> -#include <svtools/textview.hxx> -#include <svtools/txtattr.hxx> +#include <vcl/textdata.hxx> +#include <vcl/texteng.hxx> +#include <vcl/textview.hxx> +#include <vcl/txtattr.hxx> #include <com/sun/star/awt/FontWeight.hpp> #include <com/sun/star/lang/EventObject.hpp> #include <com/sun/star/uno/Reference.hxx> diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx index 2fd6660fa571..bb9ef6ea0a9c 100644 --- a/basctl/source/basicide/baside2.cxx +++ b/basctl/source/basicide/baside2.cxx @@ -42,7 +42,7 @@ #include <svl/aeitem.hxx> #include <svl/srchitem.hxx> #include <svl/whiter.hxx> -#include <svtools/xtextedt.hxx> +#include <vcl/xtextedt.hxx> #include <toolkit/helper/vclunohelper.hxx> #include <vcl/msgbox.hxx> diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx index 9577c65b1f8e..2854eb1fe7e6 100644 --- a/basctl/source/basicide/baside2b.cxx +++ b/basctl/source/basicide/baside2b.cxx @@ -38,8 +38,8 @@ #include <sfx2/viewfrm.hxx> #include <vcl/msgbox.hxx> #include <svl/urihelper.hxx> -#include <svtools/xtextedt.hxx> -#include <svtools/txtattr.hxx> +#include <vcl/xtextedt.hxx> +#include <vcl/txtattr.hxx> #include <svtools/textwindowpeer.hxx> #include <vcl/taskpanelist.hxx> #include <vcl/help.hxx> diff --git a/basctl/source/basicide/basides1.cxx b/basctl/source/basicide/basides1.cxx index f48d56bf004f..c43156cb3acb 100644 --- a/basctl/source/basicide/basides1.cxx +++ b/basctl/source/basicide/basides1.cxx @@ -50,7 +50,7 @@ #include <svl/srchitem.hxx> #include <svl/visitem.hxx> #include <svl/whiter.hxx> -#include <svtools/xtextedt.hxx> +#include <vcl/xtextedt.hxx> #include <vcl/msgbox.hxx> using namespace ::com::sun::star; diff --git a/basctl/source/basicide/basides2.cxx b/basctl/source/basicide/basides2.cxx index c49e8cfa9938..a324ebfbe4c6 100644 --- a/basctl/source/basicide/basides2.cxx +++ b/basctl/source/basicide/basides2.cxx @@ -29,9 +29,9 @@ #include <baside2.hxx> #include <basdoc.hxx> #include <basobj.hxx> -#include <svtools/texteng.hxx> -#include <svtools/textview.hxx> -#include <svtools/xtextedt.hxx> +#include <vcl/texteng.hxx> +#include <vcl/textview.hxx> +#include <vcl/xtextedt.hxx> #include <tools/diagnose_ex.h> #include <sfx2/childwin.hxx> #include <sfx2/dispatch.hxx> diff --git a/basctl/source/basicide/linenumberwindow.cxx b/basctl/source/basicide/linenumberwindow.cxx index 97674a6e4081..b6d5223f3d8e 100644 --- a/basctl/source/basicide/linenumberwindow.cxx +++ b/basctl/source/basicide/linenumberwindow.cxx @@ -29,8 +29,8 @@ #include "baside2.hxx" #include "linenumberwindow.hxx" -#include <svtools/xtextedt.hxx> -#include <svtools/textview.hxx> +#include <vcl/xtextedt.hxx> +#include <vcl/textview.hxx> LineNumberWindow::LineNumberWindow( Window* pParent, ModulWindow* pModulWin ) : Window( pParent, WB_BORDER ), diff --git a/cui/source/dialogs/SpellAttrib.hxx b/cui/source/dialogs/SpellAttrib.hxx index 4a260f5b2d54..1cc0304231a2 100644 --- a/cui/source/dialogs/SpellAttrib.hxx +++ b/cui/source/dialogs/SpellAttrib.hxx @@ -28,7 +28,7 @@ #ifndef _SVX_SPELL_ATTRIB #define _SVX_SPELL_ATTRIB -#include <svtools/txtattr.hxx> +#include <vcl/txtattr.hxx> #include <i18npool/lang.h> #include <com/sun/star/uno/Reference.h> #include <com/sun/star/uno/Sequence.h> diff --git a/cui/source/dialogs/SpellDialog.cxx b/cui/source/dialogs/SpellDialog.cxx index c832bbcab6c8..9dcd2ac13716 100644 --- a/cui/source/dialogs/SpellDialog.cxx +++ b/cui/source/dialogs/SpellDialog.cxx @@ -36,7 +36,7 @@ #include <sfx2/bindings.hxx> #include <svl/undo.hxx> #include <unotools/lingucfg.hxx> -#include <svtools/textdata.hxx> +#include <vcl/textdata.hxx> #include <svtools/filter.hxx> #include <editeng/unolingu.hxx> #include <editeng/splwrap.hxx> diff --git a/cui/source/inc/SpellDialog.hxx b/cui/source/inc/SpellDialog.hxx index c9cac11203f7..c58ff7ba1527 100644 --- a/cui/source/inc/SpellDialog.hxx +++ b/cui/source/inc/SpellDialog.hxx @@ -48,7 +48,7 @@ #include <svtools/svmedit.hxx> #include <svl/lstner.hxx> #include <svtools/fixedhyper.hxx> -#include <svtools/xtextedt.hxx> +#include <vcl/xtextedt.hxx> #include <editeng/SpellPortions.hxx> #include <set> diff --git a/desktop/source/deployment/gui/descedit.cxx b/desktop/source/deployment/gui/descedit.cxx index b90061ee0b72..49ab5b67ccfc 100644 --- a/desktop/source/deployment/gui/descedit.cxx +++ b/desktop/source/deployment/gui/descedit.cxx @@ -19,8 +19,8 @@ #include <vcl/scrbar.hxx> -#include <svtools/txtattr.hxx> -#include <svtools/xtextedt.hxx> +#include <vcl/txtattr.hxx> +#include <vcl/xtextedt.hxx> #include "descedit.hxx" diff --git a/desktop/source/deployment/gui/dp_gui_autoscrolledit.cxx b/desktop/source/deployment/gui/dp_gui_autoscrolledit.cxx index cf3c740562ff..d3a76d9513a1 100644 --- a/desktop/source/deployment/gui/dp_gui_autoscrolledit.cxx +++ b/desktop/source/deployment/gui/dp_gui_autoscrolledit.cxx @@ -19,7 +19,7 @@ #include "svtools/svmedit2.hxx" #include "svl/lstner.hxx" -#include "svtools/xtextedt.hxx" +#include "vcl/xtextedt.hxx" #include "vcl/scrbar.hxx" #include "dp_gui_autoscrolledit.hxx" diff --git a/desktop/source/deployment/gui/license_dialog.cxx b/desktop/source/deployment/gui/license_dialog.cxx index 2a76bba34659..3e1e23ed8561 100644 --- a/desktop/source/deployment/gui/license_dialog.cxx +++ b/desktop/source/deployment/gui/license_dialog.cxx @@ -40,7 +40,7 @@ #include "com/sun/star/task/XJobExecutor.hpp" #include "svtools/svmedit.hxx" #include "svl/lstner.hxx" -#include "svtools/xtextedt.hxx" +#include "vcl/xtextedt.hxx" #include <vcl/scrbar.hxx> #include "vcl/threadex.hxx" diff --git a/editeng/inc/editeng/unoedhlp.hxx b/editeng/inc/editeng/unoedhlp.hxx index df625f547431..5848338ef0ba 100644 --- a/editeng/inc/editeng/unoedhlp.hxx +++ b/editeng/inc/editeng/unoedhlp.hxx @@ -31,7 +31,7 @@ #include <memory> #include <tools/solar.h> -#include <svtools/textdata.hxx> +#include <vcl/textdata.hxx> #include <svl/hint.hxx> #include <tools/gen.hxx> #include "editeng/editengdllapi.h" diff --git a/filter/source/xsltdialog/xmlfileview.cxx b/filter/source/xsltdialog/xmlfileview.cxx index ca1fa3f425f1..a200a922b01d 100644 --- a/filter/source/xsltdialog/xmlfileview.cxx +++ b/filter/source/xsltdialog/xmlfileview.cxx @@ -36,7 +36,7 @@ #include <rtl/tencinfo.h> #include <vcl/svapp.hxx> #include <osl/mutex.hxx> -#include <svtools/textview.hxx> +#include <vcl/textview.hxx> #include <vcl/scrbar.hxx> #include <tools/stream.hxx> #include <tools/time.hxx> @@ -44,7 +44,7 @@ #include <vcl/msgbox.hxx> #include <svtools/colorcfg.hxx> #include <svtools/htmltokn.h> -#include <svtools/txtattr.hxx> +#include <vcl/txtattr.hxx> #include "xmlfilterdialogstrings.hrc" #include "xmlfiltersettingsdialog.hxx" diff --git a/filter/source/xsltdialog/xmlfileview.hxx b/filter/source/xsltdialog/xmlfileview.hxx index abbe4879984c..51684f164559 100644 --- a/filter/source/xsltdialog/xmlfileview.hxx +++ b/filter/source/xsltdialog/xmlfileview.hxx @@ -32,7 +32,7 @@ #include <svl/lstner.hxx> #include <vcl/timer.hxx> -#include <svtools/xtextedt.hxx> +#include <vcl/xtextedt.hxx> #include <vcl/wrkwin.hxx> #include <vcl/ctrl.hxx> #include <vcl/button.hxx> diff --git a/framework/source/services/license.cxx b/framework/source/services/license.cxx index c91321bd2ad7..99753a7b6a7e 100644 --- a/framework/source/services/license.cxx +++ b/framework/source/services/license.cxx @@ -62,7 +62,7 @@ #include <rtl/string.hxx> #include <unotools/bootstrap.hxx> #include <osl/file.hxx> -#include <svtools/xtextedt.hxx> +#include <vcl/xtextedt.hxx> #include <vcl/svapp.hxx> #include <comphelper/processfactory.hxx> #include <tools/date.hxx> diff --git a/svtools/Library_svt.mk b/svtools/Library_svt.mk index 3a0e7d0105ef..c265afb8eab0 100644 --- a/svtools/Library_svt.mk +++ b/svtools/Library_svt.mk @@ -148,14 +148,7 @@ $(eval $(call gb_Library_add_exception_objects,svt,\ svtools/source/edit/svmedit \ svtools/source/edit/svmedit2 \ svtools/source/edit/syntaxhighlight \ - svtools/source/edit/textdata \ - svtools/source/edit/textdoc \ - svtools/source/edit/texteng \ - svtools/source/edit/textundo \ - svtools/source/edit/textview \ svtools/source/edit/textwindowpeer \ - svtools/source/edit/txtattr \ - svtools/source/edit/xtextedt \ svtools/source/filter/FilterConfigCache \ svtools/source/filter/FilterConfigItem \ svtools/source/filter/SvFilterOptionsDialog \ diff --git a/svtools/Package_inc.mk b/svtools/Package_inc.mk index b0525ea255ec..a970653dabd0 100644 --- a/svtools/Package_inc.mk +++ b/svtools/Package_inc.mk @@ -158,9 +158,6 @@ $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/table/tabletypes.hxx,s $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/table/tablesort.hxx,svtools/table/tablesort.hxx)) $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/templatefoldercache.hxx,svtools/templatefoldercache.hxx)) $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/templdlg.hxx,svtools/templdlg.hxx)) -$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/textdata.hxx,svtools/textdata.hxx)) -$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/texteng.hxx,svtools/texteng.hxx)) -$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/textview.hxx,svtools/textview.hxx)) $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/textwindowpeer.hxx,svtools/textwindowpeer.hxx)) $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/toolbarmenu.hxx,svtools/toolbarmenu.hxx)) $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/toolboxcontroller.hxx,svtools/toolboxcontroller.hxx)) @@ -175,7 +172,6 @@ $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/toolpanel/toolpanel.hx $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/toolpanel/toolpaneldeck.hxx,svtools/toolpanel/toolpaneldeck.hxx)) $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/transfer.hxx,svtools/transfer.hxx)) $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/treelist.hxx,svtools/treelist.hxx)) -$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/txtattr.hxx,svtools/txtattr.hxx)) $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/txtcmp.hxx,svtools/txtcmp.hxx)) $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/unitconv.hxx,svtools/unitconv.hxx)) $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/unoevent.hxx,svtools/unoevent.hxx)) @@ -186,7 +182,6 @@ $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/wallitem.hxx,svtools/w $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/wizardmachine.hxx,svtools/wizardmachine.hxx)) $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/wizdlg.hxx,svtools/wizdlg.hxx)) $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/wmf.hxx,svtools/wmf.hxx)) -$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/xtextedt.hxx,svtools/xtextedt.hxx)) $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/xwindowitem.hxx,svtools/xwindowitem.hxx)) # vim: set noet sw=4 ts=4: diff --git a/svtools/inc/svtools/svmedit.hxx b/svtools/inc/svtools/svmedit.hxx index f0d30d16dc4b..90853492d2c0 100644 --- a/svtools/inc/svtools/svmedit.hxx +++ b/svtools/inc/svtools/svmedit.hxx @@ -29,127 +29,27 @@ #ifndef _SVEDIT_HXX #define _SVEDIT_HXX -#include <tools/wintypes.hxx> -#include <vcl/edit.hxx> +#include <vcl/vclmedit.hxx> #include <svtools/syntaxhighlight.hxx> #include <svtools/svtdllapi.h> #include <svtools/colorcfg.hxx> -class ImpSvMEdit; -class Timer; -class ExtTextEngine; -class ExtTextView; -class SVT_DLLPUBLIC MultiLineEdit : public Edit -{ -private: - ImpSvMEdit* pImpSvMEdit; - - XubString aSaveValue; - Link aModifyHdlLink; - - Timer* pUpdateDataTimer; - Link aUpdateDataHdlLink; - -protected: - - DECL_LINK( ImpUpdateDataHdl, void* ); - void StateChanged( StateChangedType nType ); - void DataChanged( const DataChangedEvent& rDCEvt ); - virtual long PreNotify( NotifyEvent& rNEvt ); - long Notify( NotifyEvent& rNEvt ); - using Control::ImplInitSettings; - void ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground ); - WinBits ImplInitStyle( WinBits nStyle ); - - ExtTextEngine* GetTextEngine() const; - ExtTextView* GetTextView() const; - ScrollBar* GetVScrollBar() const; +class SVT_DLLPUBLIC MultiLineEdit : public VCLMultiLineEdit +{ public: MultiLineEdit( Window* pParent, WinBits nWinStyle = WB_LEFT | WB_BORDER ); MultiLineEdit( Window* pParent, const ResId& rResId ); - ~MultiLineEdit(); - - - virtual void Modify(); - virtual void UpdateData(); - - virtual void SetModifyFlag(); - virtual void ClearModifyFlag(); - virtual sal_Bool IsModified() const; - - virtual void EnableUpdateData( sal_uLong nTimeout = EDIT_UPDATEDATA_TIMEOUT ); - virtual void DisableUpdateData() { delete pUpdateDataTimer; pUpdateDataTimer = NULL; } - virtual sal_uLong IsUpdateDataEnabled() const; - - virtual void SetReadOnly( sal_Bool bReadOnly = sal_True ); - virtual sal_Bool IsReadOnly() const; - - void EnableFocusSelectionHide( sal_Bool bHide ); - - virtual void SetMaxTextLen( xub_StrLen nMaxLen = 0 ); - virtual xub_StrLen GetMaxTextLen() const; - - virtual void SetSelection( const Selection& rSelection ); - virtual const Selection& GetSelection() const; - - virtual void ReplaceSelected( const XubString& rStr ); - virtual void DeleteSelected(); - virtual XubString GetSelected() const; - virtual XubString GetSelected( LineEnd aSeparator ) const; - - virtual void Cut(); - virtual void Copy(); - virtual void Paste(); - - virtual void SetText( const XubString& rStr ); - virtual void SetText( const XubString& rStr, const Selection& rNewSelection ) - { SetText( rStr ); SetSelection( rNewSelection ); } - String GetText() const; - String GetText( LineEnd aSeparator ) const; - String GetTextLines( LineEnd aSeparator ) const; - - void SetRightToLeft( sal_Bool bRightToLeft ); - sal_Bool IsRightToLeft() const; - - void SaveValue() { aSaveValue = GetText(); } - const XubString& GetSavedValue() const { return aSaveValue; } - - void SetModifyHdl( const Link& rLink ) { aModifyHdlLink = rLink; } - const Link& GetModifyHdl() const { return aModifyHdlLink; } - - void SetUpdateDataHdl( const Link& rLink ) { aUpdateDataHdlLink = rLink; } - const Link& GetUpdateDataHdl() const { return aUpdateDataHdlLink; } - - virtual void Resize(); - virtual void GetFocus(); - - Size CalcMinimumSize() const; - Size CalcAdjustedSize( const Size& rPrefSize ) const; - using Edit::CalcSize; - Size CalcSize( sal_uInt16 nColumns, sal_uInt16 nLines ) const; - void GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines ) const; - - void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ); - - void SetLeftMargin( sal_uInt16 n ); + ~MultiLineEdit(){}; virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > GetComponentInterface(sal_Bool bCreate = sal_True); - - void DisableSelectionOnFocus(); - - void SetTextSelectable( sal_Bool bTextSelectable ); }; -inline sal_uLong MultiLineEdit::IsUpdateDataEnabled() const -{ - return pUpdateDataTimer ? pUpdateDataTimer->GetTimeout() : 0; -} -#endif +#endif //_SVEDIT_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/brwbox/ebbcontrols.cxx b/svtools/source/brwbox/ebbcontrols.cxx index fd607f2a9c17..9031ea6d49ce 100644 --- a/svtools/source/brwbox/ebbcontrols.cxx +++ b/svtools/source/brwbox/ebbcontrols.cxx @@ -29,7 +29,7 @@ #include <svtools/editbrowsebox.hxx> #include <vcl/decoview.hxx> #include <svtools/fmtfield.hxx> -#include <svtools/xtextedt.hxx> +#include <vcl/xtextedt.hxx> #include <algorithm> diff --git a/svtools/source/contnr/DocumentInfoPreview.cxx b/svtools/source/contnr/DocumentInfoPreview.cxx index b27df1739a91..3f3f15a8cce9 100644 --- a/svtools/source/contnr/DocumentInfoPreview.cxx +++ b/svtools/source/contnr/DocumentInfoPreview.cxx @@ -38,7 +38,7 @@ #include "svl/inettype.hxx" #include "svtools/DocumentInfoPreview.hxx" #include "svtools/imagemgr.hxx" -#include "svtools/txtattr.hxx" +#include "vcl/txtattr.hxx" #include "tools/datetime.hxx" #include "tools/urlobj.hxx" #include "unotools/pathoptions.hxx" diff --git a/svtools/source/contnr/templwin.cxx b/svtools/source/contnr/templwin.cxx index 937236f785b0..301967a7d1a5 100644 --- a/svtools/source/contnr/templwin.cxx +++ b/svtools/source/contnr/templwin.cxx @@ -33,13 +33,13 @@ #include <unotools/pathoptions.hxx> #include <unotools/dynamicmenuoptions.hxx> #include <unotools/extendedsecurityoptions.hxx> -#include <svtools/xtextedt.hxx> +#include <vcl/xtextedt.hxx> #include <svl/inettype.hxx> #include <svtools/imagemgr.hxx> #include <svtools/miscopt.hxx> #include <svtools/templatefoldercache.hxx> #include <svtools/imgdef.hxx> -#include <svtools/txtattr.hxx> +#include <vcl/txtattr.hxx> #include <svtools/svtools.hrc> #include "templwin.hrc" #include <svtools/helpid.hrc> diff --git a/svtools/source/edit/editsyntaxhighlighter.cxx b/svtools/source/edit/editsyntaxhighlighter.cxx index 20749db44fc9..18361d33d9ed 100644 --- a/svtools/source/edit/editsyntaxhighlighter.cxx +++ b/svtools/source/edit/editsyntaxhighlighter.cxx @@ -28,9 +28,9 @@ #include <svtools/svmedit.hxx> -#include <svtools/xtextedt.hxx> +#include <vcl/xtextedt.hxx> #include <svtools/editsyntaxhighlighter.hxx> -#include <svtools/txtattr.hxx> +#include <vcl/txtattr.hxx> MultiLineEditSyntaxHighlight::MultiLineEditSyntaxHighlight( Window* pParent, WinBits nWinStyle, diff --git a/svtools/source/edit/svmedit.cxx b/svtools/source/edit/svmedit.cxx index 4fff9e02d1e4..24e97ec5707b 100644 --- a/svtools/source/edit/svmedit.cxx +++ b/svtools/source/edit/svmedit.cxx @@ -26,1593 +26,38 @@ * ************************************************************************/ -#include <memory> -#include "unoiface.hxx" - -#include <tools/rc.h> - -#include <vcl/decoview.hxx> -#include <vcl/svapp.hxx> -#include <svtools/svmedit.hxx> -#include <svtools/xtextedt.hxx> -#include <svl/brdcst.hxx> -#include <svl/undo.hxx> +#include "unoiface.hxx" #include <svtools/textwindowpeer.hxx> -#include <svl/lstner.hxx> -#include <svl/smplhint.hxx> - - -// IDs erstmal aus VCL geklaut, muss mal richtig delivert werden... -#define SV_MENU_EDIT_UNDO 1 -#define SV_MENU_EDIT_CUT 2 -#define SV_MENU_EDIT_COPY 3 -#define SV_MENU_EDIT_PASTE 4 -#define SV_MENU_EDIT_DELETE 5 -#define SV_MENU_EDIT_SELECTALL 6 -#define SV_MENU_EDIT_INSERTSYMBOL 7 -#include <vcl/scrbar.hxx> - -namespace css = ::com::sun::star; - -class TextWindow : public Window -{ -private: - ExtTextEngine* mpExtTextEngine; - ExtTextView* mpExtTextView; - - sal_Bool mbInMBDown; - sal_Bool mbFocusSelectionHide; - sal_Bool mbIgnoreTab; - sal_Bool mbActivePopup; - sal_Bool mbSelectOnTab; - sal_Bool mbTextSelectable; - -public: - TextWindow( Window* pParent ); - ~TextWindow(); - - ExtTextEngine* GetTextEngine() const { return mpExtTextEngine; } - ExtTextView* GetTextView() const { return mpExtTextView; } - - virtual void MouseMove( const MouseEvent& rMEvt ); - virtual void MouseButtonDown( const MouseEvent& rMEvt ); - virtual void MouseButtonUp( const MouseEvent& rMEvt ); - virtual void KeyInput( const KeyEvent& rKEvent ); - - virtual void Command( const CommandEvent& rCEvt ); - - virtual void Paint( const Rectangle& rRect ); - virtual void Resize(); - - virtual void GetFocus(); - virtual void LoseFocus(); - - sal_Bool IsAutoFocusHide() const { return mbFocusSelectionHide; } - void SetAutoFocusHide( sal_Bool bAutoHide ) { mbFocusSelectionHide = bAutoHide; } - - sal_Bool IsIgnoreTab() const { return mbIgnoreTab; } - void SetIgnoreTab( sal_Bool bIgnore ) { mbIgnoreTab = bIgnore; } - - void DisableSelectionOnFocus() { mbSelectOnTab = sal_False; } - - void SetTextSelectable( sal_Bool bTextSelectable ) { mbTextSelectable = bTextSelectable; } - - virtual - ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > - GetComponentInterface(sal_Bool bCreate = sal_True); -}; - - -class ImpSvMEdit : public SfxListener -{ -private: - MultiLineEdit* pSvMultiLineEdit; - - TextWindow* mpTextWindow; - ScrollBar* mpHScrollBar; - ScrollBar* mpVScrollBar; - ScrollBarBox* mpScrollBox; - - Point maTextWindowOffset; - xub_StrLen mnTextWidth; - mutable Selection maSelection; - -protected: - virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); - void ImpUpdateSrollBarVis( WinBits nWinStyle ); - void ImpInitScrollBars(); - void ImpSetScrollBarRanges(); - void ImpSetHScrollBarThumbPos(); - DECL_LINK( ScrollHdl, ScrollBar* ); - -public: - ImpSvMEdit( MultiLineEdit* pSvMultiLineEdit, WinBits nWinStyle ); - ~ImpSvMEdit(); - - void SetModified( sal_Bool bMod ); - sal_Bool IsModified() const; - - void SetReadOnly( sal_Bool bRdOnly ); - sal_Bool IsReadOnly() const; - - void SetMaxTextLen( xub_StrLen nLen ); - xub_StrLen GetMaxTextLen() const; - - sal_Bool IsInsertMode() const; - - void InsertText( const String& rStr ); - String GetSelected() const; - String GetSelected( LineEnd aSeparator ) const; - - void SetSelection( const Selection& rSelection ); - const Selection& GetSelection() const; - - void Cut(); - void Copy(); - void Paste(); - - void SetText( const String& rStr ); - String GetText() const; - String GetText( LineEnd aSeparator ) const; - String GetTextLines( LineEnd aSeparator ) const; - - void Resize(); - void GetFocus(); - - sal_Bool HandleCommand( const CommandEvent& rCEvt ); - - void Enable( sal_Bool bEnable ); - - Size CalcMinimumSize() const; - Size CalcSize( sal_uInt16 nColumns, sal_uInt16 nLines ) const; - void GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines ) const; - - void SetAlign( WinBits nWinStyle ); - - void InitFromStyle( WinBits nWinStyle ); - - TextWindow* GetTextWindow() { return mpTextWindow; } - ScrollBar* GetHScrollBar() { return mpHScrollBar; } - ScrollBar* GetVScrollBar() { return mpVScrollBar; } -}; - -ImpSvMEdit::ImpSvMEdit( MultiLineEdit* pEdt, WinBits nWinStyle ) - :mpHScrollBar(NULL) - ,mpVScrollBar(NULL) - ,mpScrollBox(NULL) -{ - pSvMultiLineEdit = pEdt; - mnTextWidth = 0; - mpTextWindow = new TextWindow( pEdt ); - mpTextWindow->Show(); - InitFromStyle( nWinStyle ); - StartListening( *mpTextWindow->GetTextEngine() ); -} - -void ImpSvMEdit::ImpUpdateSrollBarVis( WinBits nWinStyle ) -{ - const sal_Bool bHaveVScroll = (NULL != mpVScrollBar); - const sal_Bool bHaveHScroll = (NULL != mpHScrollBar); - const sal_Bool bHaveScrollBox = (NULL != mpScrollBox); - - sal_Bool bNeedVScroll = ( nWinStyle & WB_VSCROLL ) == WB_VSCROLL; - const sal_Bool bNeedHScroll = ( nWinStyle & WB_HSCROLL ) == WB_HSCROLL; - - const sal_Bool bAutoVScroll = ( nWinStyle & WB_AUTOVSCROLL ) == WB_AUTOVSCROLL; - if ( !bNeedVScroll && bAutoVScroll ) - { - TextEngine& rEngine( *mpTextWindow->GetTextEngine() ); - sal_uLong nOverallTextHeight(0); - for ( sal_uLong i=0; i<rEngine.GetParagraphCount(); ++i ) - nOverallTextHeight += rEngine.GetTextHeight( i ); - if ( nOverallTextHeight > (sal_uLong)mpTextWindow->GetOutputSizePixel().Height() ) - bNeedVScroll = true; - } - - const sal_Bool bNeedScrollBox = bNeedVScroll && bNeedHScroll; - - sal_Bool bScrollbarsChanged = false; - if ( bHaveVScroll != bNeedVScroll ) - { - delete mpVScrollBar; - mpVScrollBar = bNeedVScroll ? new ScrollBar( pSvMultiLineEdit, WB_VSCROLL|WB_DRAG ) : NULL; - - if ( bNeedVScroll ) - { - mpVScrollBar->Show(); - mpVScrollBar->SetScrollHdl( LINK( this, ImpSvMEdit, ScrollHdl ) ); - } - - bScrollbarsChanged = sal_True; - } - - if ( bHaveHScroll != bNeedHScroll ) - { - delete mpHScrollBar; - mpHScrollBar = bNeedHScroll ? new ScrollBar( pSvMultiLineEdit, WB_HSCROLL|WB_DRAG ) : NULL; - - if ( bNeedHScroll ) - { - mpHScrollBar->Show(); - mpHScrollBar->SetScrollHdl( LINK( this, ImpSvMEdit, ScrollHdl ) ); - } - - bScrollbarsChanged = sal_True; - } - - if ( bHaveScrollBox != bNeedScrollBox ) - { - delete mpScrollBox; - mpScrollBox = bNeedScrollBox ? new ScrollBarBox( pSvMultiLineEdit, WB_SIZEABLE ) : NULL; - - if ( bNeedScrollBox ) - mpScrollBox->Show(); - } - - if ( bScrollbarsChanged ) - { - ImpInitScrollBars(); - Resize(); - } -} - -void ImpSvMEdit::InitFromStyle( WinBits nWinStyle ) -{ - ImpUpdateSrollBarVis( nWinStyle ); - SetAlign( nWinStyle ); - - if ( nWinStyle & WB_NOHIDESELECTION ) - mpTextWindow->SetAutoFocusHide( sal_False ); - else - mpTextWindow->SetAutoFocusHide( sal_True ); - - if ( nWinStyle & WB_READONLY ) - mpTextWindow->GetTextView()->SetReadOnly( sal_True ); - else - mpTextWindow->GetTextView()->SetReadOnly( sal_False ); - - if ( nWinStyle & WB_IGNORETAB ) - { - mpTextWindow->SetIgnoreTab( sal_True ); - } - else - { - mpTextWindow->SetIgnoreTab( sal_False ); - // #103667# MultiLineEdit has the flag, but focusable window also needs this flag - WinBits nStyle = mpTextWindow->GetStyle(); - nStyle |= WINDOW_DLGCTRL_MOD1TAB; - mpTextWindow->SetStyle( nStyle ); - } -} - -ImpSvMEdit::~ImpSvMEdit() -{ - EndListening( *mpTextWindow->GetTextEngine() ); - delete mpTextWindow; - delete mpHScrollBar; - delete mpVScrollBar; - delete mpScrollBox; -} - -void ImpSvMEdit::ImpSetScrollBarRanges() -{ - if ( mpVScrollBar ) - { - sal_uLong nTextHeight = mpTextWindow->GetTextEngine()->GetTextHeight(); - mpVScrollBar->SetRange( Range( 0, (long)nTextHeight-1 ) ); - } - if ( mpHScrollBar ) - { -// sal_uLong nTextWidth = mpTextWindow->GetTextEngine()->CalcTextWidth(); - // Es gibt kein Notify bei Breiten-Aenderung... -// sal_uLong nW = Max( (sal_uLong)mpTextWindow->GetOutputSizePixel().Width()*5, (sal_uLong)nTextWidth ); -// mpHScrollBar->SetRange( Range( 0, (long)nW ) ); - mpHScrollBar->SetRange( Range( 0, (long)mnTextWidth-1 ) ); - } -} - -void ImpSvMEdit::ImpInitScrollBars() -{ - static const sal_Unicode sampleChar = { 'x' }; - if ( mpHScrollBar || mpVScrollBar ) - { - ImpSetScrollBarRanges(); - Size aCharBox; - aCharBox.Width() = mpTextWindow->GetTextWidth( rtl::OUString(sampleChar) ); - aCharBox.Height() = mpTextWindow->GetTextHeight(); - Size aOutSz = mpTextWindow->GetOutputSizePixel(); - if ( mpHScrollBar ) - { - mpHScrollBar->SetVisibleSize( aOutSz.Width() ); - mpHScrollBar->SetPageSize( aOutSz.Width() * 8 / 10 ); - mpHScrollBar->SetLineSize( aCharBox.Width()*10 ); - ImpSetHScrollBarThumbPos(); - } - if ( mpVScrollBar ) - { - mpVScrollBar->SetVisibleSize( aOutSz.Height() ); - mpVScrollBar->SetPageSize( aOutSz.Height() * 8 / 10 ); - mpVScrollBar->SetLineSize( aCharBox.Height() ); - mpVScrollBar->SetThumbPos( mpTextWindow->GetTextView()->GetStartDocPos().Y() ); - } - } -} - -void ImpSvMEdit::ImpSetHScrollBarThumbPos() -{ - long nX = mpTextWindow->GetTextView()->GetStartDocPos().X(); - if ( !mpTextWindow->GetTextEngine()->IsRightToLeft() ) - mpHScrollBar->SetThumbPos( nX ); - else - mpHScrollBar->SetThumbPos( mnTextWidth - mpHScrollBar->GetVisibleSize() - nX ); - -} - -IMPL_LINK( ImpSvMEdit, ScrollHdl, ScrollBar*, pCurScrollBar ) -{ - long nDiffX = 0, nDiffY = 0; - - if ( pCurScrollBar == mpVScrollBar ) - nDiffY = mpTextWindow->GetTextView()->GetStartDocPos().Y() - pCurScrollBar->GetThumbPos(); - else if ( pCurScrollBar == mpHScrollBar ) - nDiffX = mpTextWindow->GetTextView()->GetStartDocPos().X() - pCurScrollBar->GetThumbPos(); - - mpTextWindow->GetTextView()->Scroll( nDiffX, nDiffY ); - // mpTextWindow->GetTextView()->ShowCursor( sal_False, sal_True ); - - return 0; -} - - -// void ImpSvMEdit::ImpModified() -// { -// // Wann wird das gerufen ????????????????????? -// pSvMultiLineEdit->Modify(); -// } - -void ImpSvMEdit::SetAlign( WinBits nWinStyle ) -{ - sal_Bool bRTL = Application::GetSettings().GetLayoutRTL(); - mpTextWindow->GetTextEngine()->SetRightToLeft( bRTL ); - - if ( nWinStyle & WB_CENTER ) - mpTextWindow->GetTextEngine()->SetTextAlign( TXTALIGN_CENTER ); - else if ( nWinStyle & WB_RIGHT ) - mpTextWindow->GetTextEngine()->SetTextAlign( !bRTL ? TXTALIGN_RIGHT : TXTALIGN_LEFT ); - else if ( nWinStyle & WB_LEFT ) - mpTextWindow->GetTextEngine()->SetTextAlign( !bRTL ? TXTALIGN_LEFT : TXTALIGN_RIGHT ); -} - -void ImpSvMEdit::SetModified( sal_Bool bMod ) -{ - mpTextWindow->GetTextEngine()->SetModified( bMod ); -} - -sal_Bool ImpSvMEdit::IsModified() const -{ - return mpTextWindow->GetTextEngine()->IsModified(); -} - -void ImpSvMEdit::SetReadOnly( sal_Bool bRdOnly ) -{ - mpTextWindow->GetTextView()->SetReadOnly( bRdOnly ); - // Farbe anpassen ??????????????????????????? -} - -sal_Bool ImpSvMEdit::IsReadOnly() const -{ - return mpTextWindow->GetTextView()->IsReadOnly(); -} - -void ImpSvMEdit::SetMaxTextLen( xub_StrLen nLen ) -{ - mpTextWindow->GetTextEngine()->SetMaxTextLen( nLen ); -} - -xub_StrLen ImpSvMEdit::GetMaxTextLen() const -{ - return sal::static_int_cast< xub_StrLen >( - mpTextWindow->GetTextEngine()->GetMaxTextLen()); -} - -void ImpSvMEdit::InsertText( const String& rStr ) -{ - mpTextWindow->GetTextView()->InsertText( rStr ); -} - -String ImpSvMEdit::GetSelected() const -{ - return mpTextWindow->GetTextView()->GetSelected(); -} - -String ImpSvMEdit::GetSelected( LineEnd aSeparator ) const -{ - return mpTextWindow->GetTextView()->GetSelected( aSeparator ); -} - -void ImpSvMEdit::Resize() -{ - size_t nIteration = 1; - do - { - WinBits nWinStyle( pSvMultiLineEdit->GetStyle() ); - if ( ( nWinStyle & WB_AUTOVSCROLL ) == WB_AUTOVSCROLL ) - ImpUpdateSrollBarVis( nWinStyle ); - - Size aSz = pSvMultiLineEdit->GetOutputSizePixel(); - Size aEditSize = aSz; - long nSBWidth = pSvMultiLineEdit->GetSettings().GetStyleSettings().GetScrollBarSize(); - nSBWidth = pSvMultiLineEdit->CalcZoom( nSBWidth ); - - if ( mpHScrollBar ) - aSz.Height() -= nSBWidth+1; - if ( mpVScrollBar ) - aSz.Width() -= nSBWidth+1; - - if ( !mpHScrollBar ) - mpTextWindow->GetTextEngine()->SetMaxTextWidth( aSz.Width() ); - else - mpHScrollBar->SetPosSizePixel( 0, aEditSize.Height()-nSBWidth, aSz.Width(), nSBWidth ); - Point aTextWindowPos( maTextWindowOffset ); - if ( mpVScrollBar ) - { - if( Application::GetSettings().GetLayoutRTL() ) - { - mpVScrollBar->SetPosSizePixel( 0, 0, nSBWidth, aSz.Height() ); - aTextWindowPos.X() += nSBWidth; - } - else - mpVScrollBar->SetPosSizePixel( aEditSize.Width()-nSBWidth, 0, nSBWidth, aSz.Height() ); - } - - if ( mpScrollBox ) - mpScrollBox->SetPosSizePixel( aSz.Width(), aSz.Height(), nSBWidth, nSBWidth ); - - Size aTextWindowSize( aSz ); - aTextWindowSize.Width() -= maTextWindowOffset.X(); - aTextWindowSize.Height() -= maTextWindowOffset.Y(); - if ( aTextWindowSize.Width() < 0 ) - aTextWindowSize.Width() = 0; - if ( aTextWindowSize.Height() < 0 ) - aTextWindowSize.Height() = 0; - - Size aOldTextWindowSize( mpTextWindow->GetSizePixel() ); - mpTextWindow->SetPosSizePixel( aTextWindowPos, aTextWindowSize ); - if ( aOldTextWindowSize == aTextWindowSize ) - break; - - // Changing the text window size might effectively have changed the need for - // scrollbars, so do another iteration. - ++nIteration; - OSL_ENSURE( nIteration < 3, "ImpSvMEdit::Resize: isn't this expected to terminate with the second iteration?" ); - - } while ( nIteration <= 3 ); // artificial break after four iterations - - ImpInitScrollBars(); -} - -void ImpSvMEdit::GetFocus() -{ - mpTextWindow->GrabFocus(); -} - -void ImpSvMEdit::Cut() -{ - if ( !mpTextWindow->GetTextView()->IsReadOnly() ) - mpTextWindow->GetTextView()->Cut(); -} - -void ImpSvMEdit::Copy() -{ - mpTextWindow->GetTextView()->Copy(); -} -void ImpSvMEdit::Paste() -{ - if ( !mpTextWindow->GetTextView()->IsReadOnly() ) - mpTextWindow->GetTextView()->Paste(); -} - -void ImpSvMEdit::SetText( const String& rStr ) -{ - sal_Bool bWasModified = mpTextWindow->GetTextEngine()->IsModified(); - mpTextWindow->GetTextEngine()->SetText( rStr ); - if ( !bWasModified ) - mpTextWindow->GetTextEngine()->SetModified( sal_False ); - - mpTextWindow->GetTextView()->SetSelection( TextSelection() ); - - WinBits nWinStyle( pSvMultiLineEdit->GetStyle() ); - if ( ( nWinStyle & WB_AUTOVSCROLL ) == WB_AUTOVSCROLL ) - ImpUpdateSrollBarVis( nWinStyle ); -} - -String ImpSvMEdit::GetText() const -{ - return mpTextWindow->GetTextEngine()->GetText(); -} - -String ImpSvMEdit::GetText( LineEnd aSeparator ) const -{ - return mpTextWindow->GetTextEngine()->GetText( aSeparator ); -} - -String ImpSvMEdit::GetTextLines( LineEnd aSeparator ) const -{ - return mpTextWindow->GetTextEngine()->GetTextLines( aSeparator ); -} - -void ImpSvMEdit::Notify( SfxBroadcaster&, const SfxHint& rHint ) -{ - if ( rHint.ISA( TextHint ) ) - { - const TextHint& rTextHint = (const TextHint&)rHint; - if( rTextHint.GetId() == TEXT_HINT_VIEWSCROLLED ) - { - if ( mpHScrollBar ) - ImpSetHScrollBarThumbPos(); - if ( mpVScrollBar ) - mpVScrollBar->SetThumbPos( mpTextWindow->GetTextView()->GetStartDocPos().Y() ); - } - else if( rTextHint.GetId() == TEXT_HINT_TEXTHEIGHTCHANGED ) - { - if ( mpTextWindow->GetTextView()->GetStartDocPos().Y() ) - { - long nOutHeight = mpTextWindow->GetOutputSizePixel().Height(); - long nTextHeight = mpTextWindow->GetTextEngine()->GetTextHeight(); - if ( nTextHeight < nOutHeight ) - mpTextWindow->GetTextView()->Scroll( 0, mpTextWindow->GetTextView()->GetStartDocPos().Y() ); - } - - ImpSetScrollBarRanges(); - } - else if( rTextHint.GetId() == TEXT_HINT_TEXTFORMATTED ) - { - if ( mpHScrollBar ) - { - sal_uLong nWidth = mpTextWindow->GetTextEngine()->CalcTextWidth(); - if ( nWidth != mnTextWidth ) - { - mnTextWidth = sal::static_int_cast< xub_StrLen >(nWidth); - mpHScrollBar->SetRange( Range( 0, (long)mnTextWidth-1 ) ); - ImpSetHScrollBarThumbPos(); - } - } - } - else if( rTextHint.GetId() == TEXT_HINT_MODIFIED ) - { - pSvMultiLineEdit->Modify(); - } - } -} - -void ImpSvMEdit::SetSelection( const Selection& rSelection ) -{ - String aText = mpTextWindow->GetTextEngine()->GetText(); - - Selection aNewSelection( rSelection ); - if ( aNewSelection.Min() < 0 ) - aNewSelection.Min() = 0; - else if ( aNewSelection.Min() > aText.Len() ) - aNewSelection.Min() = aText.Len(); - if ( aNewSelection.Max() < 0 ) - aNewSelection.Max() = 0; - else if ( aNewSelection.Max() > aText.Len() ) - aNewSelection.Max() = aText.Len(); - - long nEnd = Max( aNewSelection.Min(), aNewSelection.Max() ); - TextSelection aTextSel; - sal_uLong nPara = 0; - sal_uInt16 nChar = 0; - sal_uInt16 x = 0; - while ( x <= nEnd ) - { - if ( x == aNewSelection.Min() ) - aTextSel.GetStart() = TextPaM( nPara, nChar ); - if ( x == aNewSelection.Max() ) - aTextSel.GetEnd() = TextPaM( nPara, nChar ); - - if ( ( x < aText.Len() ) && ( aText.GetChar( x ) == '\n' ) ) - { - nPara++; - nChar = 0; - } - else - nChar++; - x++; - } - mpTextWindow->GetTextView()->SetSelection( aTextSel ); -} - -const Selection& ImpSvMEdit::GetSelection() const -{ - maSelection = Selection(); - TextSelection aTextSel( mpTextWindow->GetTextView()->GetSelection() ); - aTextSel.Justify(); - // Selektion flachklopfen => jeder Umbruch ein Zeichen... - - ExtTextEngine* pExtTextEngine = mpTextWindow->GetTextEngine(); - // Absaetze davor: - sal_uLong n; - for ( n = 0; n < aTextSel.GetStart().GetPara(); n++ ) - { - maSelection.Min() += pExtTextEngine->GetTextLen( n ); - maSelection.Min()++; - } - - // Erster Absatz mit Selektion: - maSelection.Max() = maSelection.Min(); - maSelection.Min() += aTextSel.GetStart().GetIndex(); - - for ( n = aTextSel.GetStart().GetPara(); n < aTextSel.GetEnd().GetPara(); n++ ) - { - maSelection.Max() += pExtTextEngine->GetTextLen( n ); - maSelection.Max()++; - } - - maSelection.Max() += aTextSel.GetEnd().GetIndex(); - - return maSelection; -} - -Size ImpSvMEdit::CalcMinimumSize() const -{ - Size aSz( mpTextWindow->GetTextEngine()->CalcTextWidth(), - mpTextWindow->GetTextEngine()->GetTextHeight() ); - - if ( mpHScrollBar ) - aSz.Height() += mpHScrollBar->GetSizePixel().Height(); - if ( mpVScrollBar ) - aSz.Width() += mpVScrollBar->GetSizePixel().Width(); - - return aSz; -} - -Size ImpSvMEdit::CalcSize( sal_uInt16 nColumns, sal_uInt16 nLines ) const -{ - static const sal_Unicode sampleChar = 'X'; - - Size aSz; - Size aCharSz; - aCharSz.Width() = mpTextWindow->GetTextWidth( rtl::OUString(sampleChar) ); - aCharSz.Height() = mpTextWindow->GetTextHeight(); - - if ( nLines ) - aSz.Height() = nLines*aCharSz.Height(); - else - aSz.Height() = mpTextWindow->GetTextEngine()->GetTextHeight(); - - if ( nColumns ) - aSz.Width() = nColumns*aCharSz.Width(); - else - aSz.Width() = mpTextWindow->GetTextEngine()->CalcTextWidth(); - - if ( mpHScrollBar ) - aSz.Height() += mpHScrollBar->GetSizePixel().Height(); - if ( mpVScrollBar ) - aSz.Width() += mpVScrollBar->GetSizePixel().Width(); - - return aSz; -} - -void ImpSvMEdit::GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines ) const -{ - static const sal_Unicode sampleChar = { 'x' }; - Size aOutSz = mpTextWindow->GetOutputSizePixel(); - Size aCharSz( mpTextWindow->GetTextWidth( rtl::OUString(sampleChar) ), mpTextWindow->GetTextHeight() ); - rnCols = (sal_uInt16) (aOutSz.Width()/aCharSz.Width()); - rnLines = (sal_uInt16) (aOutSz.Height()/aCharSz.Height()); -} - -void ImpSvMEdit::Enable( sal_Bool bEnable ) -{ - mpTextWindow->Enable( bEnable ); - if ( mpHScrollBar ) - mpHScrollBar->Enable( bEnable ); - if ( mpVScrollBar ) - mpVScrollBar->Enable( bEnable ); -} - -sal_Bool ImpSvMEdit::HandleCommand( const CommandEvent& rCEvt ) -{ - sal_Bool bDone = sal_False; - if ( ( rCEvt.GetCommand() == COMMAND_WHEEL ) || - ( rCEvt.GetCommand() == COMMAND_STARTAUTOSCROLL ) || - ( rCEvt.GetCommand() == COMMAND_AUTOSCROLL ) ) - { - mpTextWindow->HandleScrollCommand( rCEvt, mpHScrollBar, mpVScrollBar ); - bDone = sal_True; - } - return bDone; -} - - -TextWindow::TextWindow( Window* pParent ) : Window( pParent ) -{ - mbInMBDown = sal_False; - mbSelectOnTab = sal_True; - mbFocusSelectionHide = sal_False; - mbIgnoreTab = sal_False; - mbActivePopup = sal_False; - mbSelectOnTab = sal_True; - mbTextSelectable = sal_True; - - SetPointer( Pointer( POINTER_TEXT ) ); - - mpExtTextEngine = new ExtTextEngine; - mpExtTextEngine->SetMaxTextLen( STRING_MAXLEN ); - if( pParent->GetStyle() & WB_BORDER ) - mpExtTextEngine->SetLeftMargin( 2 ); - mpExtTextEngine->SetLocale( GetSettings().GetLocale() ); - mpExtTextView = new ExtTextView( mpExtTextEngine, this ); - mpExtTextEngine->InsertView( mpExtTextView ); - mpExtTextEngine->EnableUndo( sal_True ); - mpExtTextView->ShowCursor(); - - Color aBackgroundColor = GetSettings().GetStyleSettings().GetWorkspaceColor(); - SetBackground( aBackgroundColor ); - pParent->SetBackground( aBackgroundColor ); -} - -TextWindow::~TextWindow() -{ - delete mpExtTextView; - delete mpExtTextEngine; -} - -void TextWindow::MouseMove( const MouseEvent& rMEvt ) -{ - mpExtTextView->MouseMove( rMEvt ); - Window::MouseMove( rMEvt ); -} - -void TextWindow::MouseButtonDown( const MouseEvent& rMEvt ) -{ - if ( !mbTextSelectable ) - return; - - mbInMBDown = sal_True; // Dann im GetFocus nicht alles selektieren wird - mpExtTextView->MouseButtonDown( rMEvt ); - Window::MouseButtonDown( rMEvt ); - GrabFocus(); - mbInMBDown = sal_False; -} - -void TextWindow::MouseButtonUp( const MouseEvent& rMEvt ) -{ - mpExtTextView->MouseButtonUp( rMEvt ); - Window::MouseButtonUp( rMEvt ); -} - -void TextWindow::KeyInput( const KeyEvent& rKEvent ) -{ - sal_Bool bDone = sal_False; - sal_uInt16 nCode = rKEvent.GetKeyCode().GetCode(); - if ( nCode == com::sun::star::awt::Key::SELECT_ALL || - ( (nCode == KEY_A) && rKEvent.GetKeyCode().IsMod1() && !rKEvent.GetKeyCode().IsMod2() ) - ) - { - mpExtTextView->SetSelection( TextSelection( TextPaM( 0, 0 ), TextPaM( 0xFFFF, 0xFFFF ) ) ); - bDone = sal_True; - } - else if ( (nCode == KEY_S) && rKEvent.GetKeyCode().IsShift() && rKEvent.GetKeyCode().IsMod1() ) - { - if ( Edit::GetGetSpecialCharsFunction() ) - { - // Damit die Selektion erhalten bleibt - mbActivePopup = sal_True; - rtl::OUString aChars = Edit::GetGetSpecialCharsFunction()( this, GetFont() ); - if (!aChars.isEmpty()) - { - mpExtTextView->InsertText( aChars ); - mpExtTextView->GetTextEngine()->SetModified( sal_True ); - } - mbActivePopup = sal_False; - bDone = sal_True; - } - } - else if ( nCode == KEY_TAB ) - { - if ( !mbIgnoreTab || rKEvent.GetKeyCode().IsMod1() ) - bDone = mpExtTextView->KeyInput( rKEvent ); - } - else - { - bDone = mpExtTextView->KeyInput( rKEvent ); - } - - if ( !bDone ) - Window::KeyInput( rKEvent ); -} - -void TextWindow::Paint( const Rectangle& rRect ) -{ - mpExtTextView->Paint( rRect ); -} - -void TextWindow::Resize() -{ -} - -void TextWindow::Command( const CommandEvent& rCEvt ) -{ - if ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU ) - { - PopupMenu* pPopup = Edit::CreatePopupMenu(); - if ( !mpExtTextView->HasSelection() ) - { - pPopup->EnableItem( SV_MENU_EDIT_CUT, sal_False ); - pPopup->EnableItem( SV_MENU_EDIT_COPY, sal_False ); - pPopup->EnableItem( SV_MENU_EDIT_DELETE, sal_False ); - } - if ( mpExtTextView->IsReadOnly() ) - { - pPopup->EnableItem( SV_MENU_EDIT_CUT, sal_False ); - pPopup->EnableItem( SV_MENU_EDIT_PASTE, sal_False ); - pPopup->EnableItem( SV_MENU_EDIT_DELETE, sal_False ); - pPopup->EnableItem( SV_MENU_EDIT_INSERTSYMBOL, sal_False ); - } - if ( !mpExtTextView->GetTextEngine()->HasUndoManager() || !mpExtTextView->GetTextEngine()->GetUndoManager().GetUndoActionCount() ) - { - pPopup->EnableItem( SV_MENU_EDIT_UNDO, sal_False ); - } -// if ( ( maSelection.Min() == 0 ) && ( maSelection.Max() == maText.Len() ) ) -// { -// pPopup->EnableItem( SV_MENU_EDIT_SELECTALL, sal_False ); -// } - if ( !Edit::GetGetSpecialCharsFunction() ) - { - sal_uInt16 nPos = pPopup->GetItemPos( SV_MENU_EDIT_INSERTSYMBOL ); - pPopup->RemoveItem( nPos ); - pPopup->RemoveItem( nPos-1 ); - } - - mbActivePopup = sal_True; - Point aPos = rCEvt.GetMousePosPixel(); - if ( !rCEvt.IsMouseEvent() ) - { - // !!! Irgendwann einmal Menu zentriert in der Selektion anzeigen !!! - Size aSize = GetOutputSizePixel(); - aPos = Point( aSize.Width()/2, aSize.Height()/2 ); - } -// pPopup->RemoveDisabledEntries(); - sal_uInt16 n = pPopup->Execute( this, aPos ); - Edit::DeletePopupMenu( pPopup ); - switch ( n ) - { - case SV_MENU_EDIT_UNDO: mpExtTextView->Undo(); - mpExtTextEngine->SetModified( sal_True ); - mpExtTextEngine->Broadcast( TextHint( TEXT_HINT_MODIFIED ) ); - break; - case SV_MENU_EDIT_CUT: mpExtTextView->Cut(); - mpExtTextEngine->SetModified( sal_True ); - mpExtTextEngine->Broadcast( TextHint( TEXT_HINT_MODIFIED ) ); - break; - case SV_MENU_EDIT_COPY: mpExtTextView->Copy(); - break; - case SV_MENU_EDIT_PASTE: mpExtTextView->Paste(); - mpExtTextEngine->SetModified( sal_True ); - mpExtTextEngine->Broadcast( TextHint( TEXT_HINT_MODIFIED ) ); - break; - case SV_MENU_EDIT_DELETE: mpExtTextView->DeleteSelected(); - mpExtTextEngine->SetModified( sal_True ); - mpExtTextEngine->Broadcast( TextHint( TEXT_HINT_MODIFIED ) ); - break; - case SV_MENU_EDIT_SELECTALL: mpExtTextView->SetSelection( TextSelection( TextPaM( 0, 0 ), TextPaM( 0xFFFFFFFF, 0xFFFF ) ) ); - break; - case SV_MENU_EDIT_INSERTSYMBOL: - { - rtl::OUString aChars = Edit::GetGetSpecialCharsFunction()( this, GetFont() ); - if (!aChars.isEmpty()) - { - mpExtTextView->InsertText( aChars ); - mpExtTextEngine->SetModified( sal_True ); - mpExtTextEngine->Broadcast( TextHint( TEXT_HINT_MODIFIED ) ); - } - } - break; - } - mbActivePopup = sal_False; - } - else - { - mpExtTextView->Command( rCEvt ); - } - Window::Command( rCEvt ); -} - -void TextWindow::GetFocus() -{ - Window::GetFocus(); - if ( !mbActivePopup ) - { - sal_Bool bGotoCursor = !mpExtTextView->IsReadOnly(); - if ( mbFocusSelectionHide && IsReallyVisible() && !mpExtTextView->IsReadOnly() - && ( mbSelectOnTab && - (!mbInMBDown || ( GetSettings().GetStyleSettings().GetSelectionOptions() & SELECTION_OPTION_FOCUS ) )) ) - { - // Alles selektieren, aber nicht scrollen - sal_Bool bAutoScroll = mpExtTextView->IsAutoScroll(); - mpExtTextView->SetAutoScroll( sal_False ); - mpExtTextView->SetSelection( TextSelection( TextPaM( 0, 0 ), TextPaM( 0xFFFF, 0xFFFF ) ) ); - mpExtTextView->SetAutoScroll( bAutoScroll ); - bGotoCursor = sal_False; - } - mpExtTextView->SetPaintSelection( sal_True ); - mpExtTextView->ShowCursor( bGotoCursor ); - } -} - -void TextWindow::LoseFocus() -{ - Window::LoseFocus(); - - if ( mbFocusSelectionHide && !mbActivePopup ) - mpExtTextView->SetPaintSelection( sal_False ); -} - -// virtual -::css::uno::Reference< ::css::awt::XWindowPeer > -TextWindow::GetComponentInterface(sal_Bool bCreate) -{ - ::css::uno::Reference< ::css::awt::XWindowPeer > xPeer( - Window::GetComponentInterface(false)); - if (!xPeer.is() && bCreate) - { - xPeer = new ::svt::TextWindowPeer(*GetTextView(), true); - SetComponentInterface(xPeer); - } - return xPeer; -} MultiLineEdit::MultiLineEdit( Window* pParent, WinBits nWinStyle ) - : Edit( pParent, nWinStyle ) + : VCLMultiLineEdit( pParent,nWinStyle ) { - SetType( WINDOW_MULTILINEEDIT ); - pImpSvMEdit = new ImpSvMEdit( this, nWinStyle ); - ImplInitSettings( sal_True, sal_True, sal_True ); - pUpdateDataTimer = 0; - - SetCompoundControl( sal_True ); - SetStyle( ImplInitStyle( nWinStyle ) ); } - MultiLineEdit::MultiLineEdit( Window* pParent, const ResId& rResId ) - : Edit( pParent, rResId.SetRT( RSC_MULTILINEEDIT ) ) -{ - SetType( WINDOW_MULTILINEEDIT ); - WinBits nWinStyle = rResId.GetWinBits(); - pImpSvMEdit = new ImpSvMEdit( this, nWinStyle ); - ImplInitSettings( sal_True, sal_True, sal_True ); - pUpdateDataTimer = 0; - - sal_uInt16 nMaxLen = Edit::GetMaxTextLen(); - if ( nMaxLen ) - SetMaxTextLen( nMaxLen ); - - SetText( Edit::GetText() ); - - if ( IsVisible() ) - pImpSvMEdit->Resize(); - - SetCompoundControl( sal_True ); - SetStyle( ImplInitStyle( nWinStyle ) ); - - // Base Edit ctor could call Show already, but that would cause problems - // with accessibility, as Show might (indirectly) trigger a call to virtual - // GetComponentInterface, which is the Edit's base version instead of the - // MultiLineEdit's version while in the base Edit ctor: - if ((GetStyle() & WB_HIDE) == 0) - Show(); - -} - -MultiLineEdit::~MultiLineEdit() -{ - { - ::std::auto_ptr< ImpSvMEdit > pDelete( pImpSvMEdit ); - pImpSvMEdit = NULL; - } - delete pUpdateDataTimer; -} - -WinBits MultiLineEdit::ImplInitStyle( WinBits nStyle ) -{ - if ( !(nStyle & WB_NOTABSTOP) ) - nStyle |= WB_TABSTOP; - - if ( !(nStyle & WB_NOGROUP) ) - nStyle |= WB_GROUP; - - if ( !(nStyle & WB_IGNORETAB )) - nStyle |= WINDOW_DLGCTRL_MOD1TAB; - - return nStyle; -} - - -void MultiLineEdit::ImplInitSettings( sal_Bool /*bFont*/, sal_Bool /*bForeground*/, sal_Bool bBackground ) + : VCLMultiLineEdit( pParent,rResId ) { - const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); - - // Der Font muss immer mit manipuliert werden, weil die TextEngine - // sich nicht um TextColor/Background kuemmert - - Color aTextColor = rStyleSettings.GetFieldTextColor(); - if ( IsControlForeground() ) - aTextColor = GetControlForeground(); - if ( !IsEnabled() ) - aTextColor = rStyleSettings.GetDisableColor(); - - Font aFont = rStyleSettings.GetFieldFont(); - if ( IsControlFont() ) - aFont.Merge( GetControlFont() ); - aFont.SetTransparent( IsPaintTransparent() ); - SetZoomedPointFont( aFont ); - Font TheFont = GetFont(); - TheFont.SetColor( aTextColor ); - if( IsPaintTransparent() ) - TheFont.SetFillColor( Color( COL_TRANSPARENT ) ); - else - TheFont.SetFillColor( IsControlBackground() ? GetControlBackground() : rStyleSettings.GetFieldColor() ); - pImpSvMEdit->GetTextWindow()->SetFont( TheFont ); - pImpSvMEdit->GetTextWindow()->GetTextEngine()->SetFont( TheFont ); - pImpSvMEdit->GetTextWindow()->SetTextColor( aTextColor ); - - if ( bBackground ) - { - if( IsPaintTransparent() ) - { - pImpSvMEdit->GetTextWindow()->SetPaintTransparent( sal_True ); - pImpSvMEdit->GetTextWindow()->SetBackground(); - pImpSvMEdit->GetTextWindow()->SetControlBackground(); - SetBackground(); - SetControlBackground(); - } - else - { - if( IsControlBackground() ) - pImpSvMEdit->GetTextWindow()->SetBackground( GetControlBackground() ); - else - pImpSvMEdit->GetTextWindow()->SetBackground( rStyleSettings.GetFieldColor() ); - // Auch am MultiLineEdit einstellen, weil die TextComponent - // ggf. die Scrollbars hidet. - SetBackground( pImpSvMEdit->GetTextWindow()->GetBackground() ); - } - } } -void MultiLineEdit::Modify() -{ - aModifyHdlLink.Call( this ); - - CallEventListeners( VCLEVENT_EDIT_MODIFY ); - - if ( pUpdateDataTimer ) - pUpdateDataTimer->Start(); -} - -IMPL_LINK_NOARG(MultiLineEdit, ImpUpdateDataHdl) -{ - UpdateData(); - return 0; -} - -void MultiLineEdit::UpdateData() -{ - aUpdateDataHdlLink.Call( this ); -} - -void MultiLineEdit::SetModifyFlag() -{ - pImpSvMEdit->SetModified( sal_True ); -} - -void MultiLineEdit::ClearModifyFlag() -{ - pImpSvMEdit->SetModified( sal_False ); -} - -sal_Bool MultiLineEdit::IsModified() const -{ - return pImpSvMEdit->IsModified(); -} - -void MultiLineEdit::EnableUpdateData( sal_uLong nTimeout ) -{ - if ( !nTimeout ) - DisableUpdateData(); - else - { - if ( !pUpdateDataTimer ) - { - pUpdateDataTimer = new Timer; - pUpdateDataTimer->SetTimeoutHdl( LINK( this, MultiLineEdit, ImpUpdateDataHdl ) ); - } - pUpdateDataTimer->SetTimeout( nTimeout ); - } -} - -void MultiLineEdit::SetReadOnly( sal_Bool bReadOnly ) -{ - pImpSvMEdit->SetReadOnly( bReadOnly ); - Edit::SetReadOnly( bReadOnly ); - - // #94921# ReadOnly can be overwritten in InitFromStyle() when WB not set. - WinBits nStyle = GetStyle(); - if ( bReadOnly ) - nStyle |= WB_READONLY; - else - nStyle &= ~WB_READONLY; - SetStyle( nStyle ); -} - -sal_Bool MultiLineEdit::IsReadOnly() const -{ - return pImpSvMEdit->IsReadOnly(); -} - -void MultiLineEdit::SetMaxTextLen( xub_StrLen nMaxLen ) -{ - pImpSvMEdit->SetMaxTextLen( nMaxLen ); -} - -xub_StrLen MultiLineEdit::GetMaxTextLen() const -{ - return pImpSvMEdit->GetMaxTextLen(); -} - -void MultiLineEdit::ReplaceSelected( const String& rStr ) -{ - pImpSvMEdit->InsertText( rStr ); -} - -void MultiLineEdit::DeleteSelected() -{ - pImpSvMEdit->InsertText( String() ); -} - -String MultiLineEdit::GetSelected() const -{ - return pImpSvMEdit->GetSelected(); -} - -String MultiLineEdit::GetSelected( LineEnd aSeparator ) const -{ - return pImpSvMEdit->GetSelected( aSeparator ); -} - -void MultiLineEdit::Cut() -{ - pImpSvMEdit->Cut(); -} - -void MultiLineEdit::Copy() -{ - pImpSvMEdit->Copy(); -} - -void MultiLineEdit::Paste() -{ - pImpSvMEdit->Paste(); -} - -void MultiLineEdit::SetText( const String& rStr ) -{ - pImpSvMEdit->SetText( rStr ); -} - -String MultiLineEdit::GetText() const -{ - return pImpSvMEdit->GetText(); -} - -String MultiLineEdit::GetText( LineEnd aSeparator ) const -{ - return pImpSvMEdit->GetText( aSeparator ); -} - -String MultiLineEdit::GetTextLines( LineEnd aSeparator ) const -{ - return pImpSvMEdit->GetTextLines( aSeparator ); -} - -void MultiLineEdit::Resize() -{ - pImpSvMEdit->Resize(); -} - -void MultiLineEdit::GetFocus() -{ - if ( !pImpSvMEdit ) // might be called from within the dtor, when pImpSvMEdit == NULL is a valid state - return; - - Edit::GetFocus(); - pImpSvMEdit->GetFocus(); -} - -void MultiLineEdit::SetSelection( const Selection& rSelection ) -{ - pImpSvMEdit->SetSelection( rSelection ); -} - -const Selection& MultiLineEdit::GetSelection() const -{ - return pImpSvMEdit->GetSelection(); -} - -Size MultiLineEdit::CalcMinimumSize() const -{ - Size aSz = pImpSvMEdit->CalcMinimumSize(); - - sal_Int32 nLeft, nTop, nRight, nBottom; - ((Window*)this)->GetBorder( nLeft, nTop, nRight, nBottom ); - aSz.Width() += nLeft+nRight; - aSz.Height() += nTop+nBottom; - - return aSz; -} - -Size MultiLineEdit::CalcAdjustedSize( const Size& rPrefSize ) const -{ - Size aSz = rPrefSize; - sal_Int32 nLeft, nTop, nRight, nBottom; - ((Window*)this)->GetBorder( nLeft, nTop, nRight, nBottom ); - - // In der Hoehe auf ganze Zeilen justieren - - long nHeight = aSz.Height() - nTop - nBottom; - long nLineHeight = pImpSvMEdit->CalcSize( 1, 1 ).Height(); - long nLines = nHeight / nLineHeight; - if ( nLines < 1 ) - nLines = 1; - - aSz.Height() = nLines * nLineHeight; - aSz.Height() += nTop+nBottom; - - return aSz; -} - -Size MultiLineEdit::CalcSize( sal_uInt16 nColumns, sal_uInt16 nLines ) const -{ - Size aSz = pImpSvMEdit->CalcSize( nColumns, nLines ); - - sal_Int32 nLeft, nTop, nRight, nBottom; - ((Window*)this)->GetBorder( nLeft, nTop, nRight, nBottom ); - aSz.Width() += nLeft+nRight; - aSz.Height() += nTop+nBottom; - return aSz; -} - -void MultiLineEdit::GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines ) const -{ - pImpSvMEdit->GetMaxVisColumnsAndLines( rnCols, rnLines ); -} - -void MultiLineEdit::StateChanged( StateChangedType nType ) -{ - if( nType == STATE_CHANGE_ENABLE ) - { - pImpSvMEdit->Enable( IsEnabled() ); - ImplInitSettings( sal_True, sal_False, sal_False ); - } - else if( nType == STATE_CHANGE_READONLY ) - { - pImpSvMEdit->SetReadOnly( IsReadOnly() ); - } - else if ( nType == STATE_CHANGE_ZOOM ) - { - pImpSvMEdit->GetTextWindow()->SetZoom( GetZoom() ); - ImplInitSettings( sal_True, sal_False, sal_False ); - Resize(); - } - else if ( nType == STATE_CHANGE_CONTROLFONT ) - { - ImplInitSettings( sal_True, sal_False, sal_False ); - Resize(); - Invalidate(); - } - else if ( nType == STATE_CHANGE_CONTROLFOREGROUND ) - { - ImplInitSettings( sal_False, sal_True, sal_False ); - Invalidate(); - } - else if ( nType == STATE_CHANGE_CONTROLBACKGROUND ) - { - ImplInitSettings( sal_False, sal_False, sal_True ); - Invalidate(); - } - else if ( nType == STATE_CHANGE_STYLE ) - { - pImpSvMEdit->InitFromStyle( GetStyle() ); - SetStyle( ImplInitStyle( GetStyle() ) ); - } - else if ( nType == STATE_CHANGE_INITSHOW ) - { - if( IsPaintTransparent() ) - { - pImpSvMEdit->GetTextWindow()->SetPaintTransparent( sal_True ); - pImpSvMEdit->GetTextWindow()->SetBackground(); - pImpSvMEdit->GetTextWindow()->SetControlBackground(); - SetBackground(); - SetControlBackground(); - } - } - - Control::StateChanged( nType ); -} - -void MultiLineEdit::DataChanged( const DataChangedEvent& rDCEvt ) -{ - if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && - (rDCEvt.GetFlags() & SETTINGS_STYLE) ) - { - ImplInitSettings( sal_True, sal_True, sal_True ); - Resize(); - Invalidate(); - } - else - Control::DataChanged( rDCEvt ); -} - -void MultiLineEdit::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ) -{ - ImplInitSettings( sal_True, sal_True, sal_True ); - - Point aPos = pDev->LogicToPixel( rPos ); - Size aSize = pDev->LogicToPixel( rSize ); - Font aFont = pImpSvMEdit->GetTextWindow()->GetDrawPixelFont( pDev ); - aFont.SetTransparent( sal_True ); - OutDevType eOutDevType = pDev->GetOutDevType(); - - pDev->Push(); - pDev->SetMapMode(); - pDev->SetFont( aFont ); - pDev->SetTextFillColor(); - - // Border/Background - pDev->SetLineColor(); - pDev->SetFillColor(); - sal_Bool bBorder = !(nFlags & WINDOW_DRAW_NOBORDER ) && (GetStyle() & WB_BORDER); - sal_Bool bBackground = !(nFlags & WINDOW_DRAW_NOBACKGROUND) && IsControlBackground(); - if ( bBorder || bBackground ) - { - Rectangle aRect( aPos, aSize ); - if ( bBorder ) - { - DecorationView aDecoView( pDev ); - aRect = aDecoView.DrawFrame( aRect, FRAME_DRAW_DOUBLEIN ); - } - if ( bBackground ) - { - pDev->SetFillColor( GetControlBackground() ); - pDev->DrawRect( aRect ); - } - } - - // Inhalt - if ( ( nFlags & WINDOW_DRAW_MONO ) || ( eOutDevType == OUTDEV_PRINTER ) ) - pDev->SetTextColor( Color( COL_BLACK ) ); - else - { - if ( !(nFlags & WINDOW_DRAW_NODISABLE ) && !IsEnabled() ) - { - const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); - pDev->SetTextColor( rStyleSettings.GetDisableColor() ); - } - else - { - pDev->SetTextColor( GetTextColor() ); - } - } - - rtl::OUString aText = GetText(); - Size aTextSz( pDev->GetTextWidth( aText ), pDev->GetTextHeight() ); - sal_uLong nLines = (sal_uLong) (aSize.Height() / aTextSz.Height()); - if ( !nLines ) - nLines = 1; - aTextSz.Height() = nLines*aTextSz.Height(); - long nOnePixel = GetDrawPixel( pDev, 1 ); - long nOffX = 3*nOnePixel; - long nOffY = 2*nOnePixel; - - // Clipping? - if ( ( nOffY < 0 ) || ( (nOffY+aTextSz.Height()) > aSize.Height() ) || ( (nOffX+aTextSz.Width()) > aSize.Width() ) ) - { - Rectangle aClip( aPos, aSize ); - if ( aTextSz.Height() > aSize.Height() ) - aClip.Bottom() += aTextSz.Height() - aSize.Height() + 1; // Damit HP-Drucker nicht 'weg-optimieren' - pDev->IntersectClipRegion( aClip ); - } - - TextEngine aTE; - aTE.SetText( GetText() ); - aTE.SetMaxTextWidth( aSize.Width() ); - aTE.SetFont( aFont ); - aTE.SetTextAlign( pImpSvMEdit->GetTextWindow()->GetTextEngine()->GetTextAlign() ); - aTE.Draw( pDev, Point( aPos.X() + nOffX, aPos.Y() + nOffY ) ); - - pDev->Pop(); -} - -long MultiLineEdit::Notify( NotifyEvent& rNEvt ) -{ - long nDone = 0; - if( rNEvt.GetType() == EVENT_COMMAND ) - { - nDone = pImpSvMEdit->HandleCommand( *rNEvt.GetCommandEvent() ); - } - return nDone ? nDone : Edit::Notify( rNEvt ); -} - -long MultiLineEdit::PreNotify( NotifyEvent& rNEvt ) -{ - long nDone = 0; - -#if (OSL_DEBUG_LEVEL > 1) && defined(DBG_UTIL) - if( rNEvt.GetType() == EVENT_KEYINPUT ) - { - const KeyEvent& rKEvent = *rNEvt.GetKeyEvent(); - if ( ( rKEvent.GetKeyCode().GetCode() == KEY_W ) && rKEvent.GetKeyCode().IsMod1() && rKEvent.GetKeyCode().IsMod2() ) - { - SetRightToLeft( !IsRightToLeft() ); - } - } -#endif - - if( ( rNEvt.GetType() == EVENT_KEYINPUT ) && ( !GetTextView()->IsCursorEnabled() ) ) - { - const KeyEvent& rKEvent = *rNEvt.GetKeyEvent(); - if ( !rKEvent.GetKeyCode().IsShift() && ( rKEvent.GetKeyCode().GetGroup() == KEYGROUP_CURSOR ) ) - { - nDone = 1; - TextSelection aSel = pImpSvMEdit->GetTextWindow()->GetTextView()->GetSelection(); - if ( aSel.HasRange() ) - { - aSel.GetStart() = aSel.GetEnd(); - pImpSvMEdit->GetTextWindow()->GetTextView()->SetSelection( aSel ); - } - else - { - switch ( rKEvent.GetKeyCode().GetCode() ) - { - case KEY_UP: - { - if ( pImpSvMEdit->GetVScrollBar() ) - pImpSvMEdit->GetVScrollBar()->DoScrollAction( SCROLL_LINEUP ); - } - break; - case KEY_DOWN: - { - if ( pImpSvMEdit->GetVScrollBar() ) - pImpSvMEdit->GetVScrollBar()->DoScrollAction( SCROLL_LINEDOWN ); - } - break; - case KEY_PAGEUP : - { - if ( pImpSvMEdit->GetVScrollBar() ) - pImpSvMEdit->GetVScrollBar()->DoScrollAction( SCROLL_PAGEUP ); - } - break; - case KEY_PAGEDOWN: - { - if ( pImpSvMEdit->GetVScrollBar() ) - pImpSvMEdit->GetVScrollBar()->DoScrollAction( SCROLL_PAGEDOWN ); - } - break; - case KEY_LEFT: - { - if ( pImpSvMEdit->GetHScrollBar() ) - pImpSvMEdit->GetHScrollBar()->DoScrollAction( SCROLL_LINEUP ); - } - break; - case KEY_RIGHT: - { - if ( pImpSvMEdit->GetHScrollBar() ) - pImpSvMEdit->GetHScrollBar()->DoScrollAction( SCROLL_LINEDOWN ); - } - break; - case KEY_HOME: - { - if ( rKEvent.GetKeyCode().IsMod1() ) - pImpSvMEdit->GetTextWindow()->GetTextView()-> - SetSelection( TextSelection( TextPaM( 0, 0 ) ) ); - } - break; - case KEY_END: - { - if ( rKEvent.GetKeyCode().IsMod1() ) - pImpSvMEdit->GetTextWindow()->GetTextView()-> - SetSelection( TextSelection( TextPaM( 0xFFFF, 0xFFFF ) ) ); - } - break; - default: - { - nDone = 0; - } - } - } - } - } - - return nDone ? nDone : Edit::PreNotify( rNEvt ); -} - -// -// Internas fuer abgeleitete Klassen, z.B. TextComponent - -ExtTextEngine* MultiLineEdit::GetTextEngine() const -{ - return pImpSvMEdit->GetTextWindow()->GetTextEngine(); -} - -ExtTextView* MultiLineEdit::GetTextView() const -{ - return pImpSvMEdit->GetTextWindow()->GetTextView(); -} - -ScrollBar* MultiLineEdit::GetVScrollBar() const -{ - return pImpSvMEdit->GetVScrollBar(); -} - -void MultiLineEdit::EnableFocusSelectionHide( sal_Bool bHide ) -{ - pImpSvMEdit->GetTextWindow()->SetAutoFocusHide( bHide ); -} - -void MultiLineEdit::SetLeftMargin( sal_uInt16 n ) -{ - if ( GetTextEngine() ) - GetTextEngine()->SetLeftMargin( n ); -} - -void MultiLineEdit::SetRightToLeft( sal_Bool bRightToLeft ) -{ - if ( GetTextEngine() ) - { - GetTextEngine()->SetRightToLeft( bRightToLeft ); - GetTextView()->ShowCursor(); - } -} - -sal_Bool MultiLineEdit::IsRightToLeft() const -{ - sal_Bool bRightToLeft = sal_False; - - if ( GetTextEngine() ) - bRightToLeft = GetTextEngine()->IsRightToLeft(); - - return bRightToLeft; -} +namespace css = ::com::sun::star; // virtual ::css::uno::Reference< ::css::awt::XWindowPeer > MultiLineEdit::GetComponentInterface(sal_Bool bCreate) { ::css::uno::Reference< ::css::awt::XWindowPeer > xPeer( - Edit::GetComponentInterface(false)); + VCLMultiLineEdit::GetComponentInterface(false)); if (!xPeer.is() && bCreate) { - ::std::auto_ptr< VCLXMultiLineEdit > xEdit(new VCLXMultiLineEdit()); - xEdit->SetWindow(this); - xPeer = xEdit.release(); + ::std::auto_ptr< VCLXMultiLineEdit > xVCLMEdit(new VCLXMultiLineEdit()); + xVCLMEdit->SetWindow(this); + xPeer = xVCLMEdit.release(); SetComponentInterface(xPeer); } return xPeer; } -void MultiLineEdit::DisableSelectionOnFocus() -{ - pImpSvMEdit->GetTextWindow()->DisableSelectionOnFocus(); -} - -void MultiLineEdit::SetTextSelectable( sal_Bool bTextSelectable ) -{ - pImpSvMEdit->GetTextWindow()->SetTextSelectable( bTextSelectable ); -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/edit/svmedit2.cxx b/svtools/source/edit/svmedit2.cxx index abd2fcf1b3a7..8d530b2ab65a 100644 --- a/svtools/source/edit/svmedit2.cxx +++ b/svtools/source/edit/svmedit2.cxx @@ -19,7 +19,7 @@ #include <svtools/svmedit2.hxx> -#include <svtools/xtextedt.hxx> +#include <vcl/xtextedt.hxx> ExtMultiLineEdit::ExtMultiLineEdit( Window* pParent, WinBits nWinStyle ) : diff --git a/svtools/source/edit/textwindowpeer.cxx b/svtools/source/edit/textwindowpeer.cxx index 36090632b817..59eee86937c3 100644 --- a/svtools/source/edit/textwindowpeer.cxx +++ b/svtools/source/edit/textwindowpeer.cxx @@ -19,7 +19,7 @@ #include <svtools/textwindowpeer.hxx> -#include <svtools/textview.hxx> +#include <vcl/textview.hxx> #include "svtaccessiblefactory.hxx" namespace css = ::com::sun::star; diff --git a/svx/source/dialog/docrecovery.cxx b/svx/source/dialog/docrecovery.cxx index c50da3817a6b..3dc92291e767 100644 --- a/svx/source/dialog/docrecovery.cxx +++ b/svx/source/dialog/docrecovery.cxx @@ -40,7 +40,7 @@ #include <comphelper/sequenceashashmap.hxx> #include <comphelper/string.hxx> #include <svtools/imagemgr.hxx> -#include <svtools/xtextedt.hxx> +#include <vcl/xtextedt.hxx> #include <tools/urlobj.hxx> #include <vcl/msgbox.hxx> #include <vcl/svapp.hxx> diff --git a/sw/source/ui/dbui/mmaddressblockpage.cxx b/sw/source/ui/dbui/mmaddressblockpage.cxx index 5cde4aacbe74..a9c86b2a8bc7 100644 --- a/sw/source/ui/dbui/mmaddressblockpage.cxx +++ b/sw/source/ui/dbui/mmaddressblockpage.cxx @@ -33,8 +33,8 @@ #include <mailmergewizard.hxx> #include <swtypes.hxx> #include <addresslistdialog.hxx> -#include <svtools/xtextedt.hxx> -#include <svtools/txtattr.hxx> +#include <vcl/xtextedt.hxx> +#include <vcl/txtattr.hxx> #include <vcl/msgbox.hxx> #include <mmconfigitem.hxx> #include <com/sun/star/container/XNameAccess.hpp> diff --git a/sw/source/ui/docvw/srcedtw.cxx b/sw/source/ui/docvw/srcedtw.cxx index c6bb14fecb14..66273f9f95a6 100644 --- a/sw/source/ui/docvw/srcedtw.cxx +++ b/sw/source/ui/docvw/srcedtw.cxx @@ -38,13 +38,13 @@ #include <rtl/oustringostreaminserter.hxx> #include <rtl/ustring.hxx> #include <sal/log.hxx> -#include <svtools/textview.hxx> +#include <vcl/textview.hxx> #include <svx/svxids.hrc> #include <vcl/scrbar.hxx> #include <sfx2/dispatch.hxx> #include <sfx2/app.hxx> #include <svtools/htmltokn.h> -#include <svtools/txtattr.hxx> +#include <vcl/txtattr.hxx> #include <svtools/colorcfg.hxx> #include <editeng/flstitem.hxx> #include <vcl/metric.hxx> diff --git a/sw/source/ui/inc/srcedtw.hxx b/sw/source/ui/inc/srcedtw.hxx index 8f4a443deaf6..74e1f425573e 100644 --- a/sw/source/ui/inc/srcedtw.hxx +++ b/sw/source/ui/inc/srcedtw.hxx @@ -32,7 +32,7 @@ #include <svl/lstner.hxx> #include <vcl/timer.hxx> -#include <svtools/xtextedt.hxx> +#include <vcl/xtextedt.hxx> #include <set> namespace com { namespace sun { namespace star { namespace beans { diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index 77717fde0a73..daa51764dd68 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -68,6 +68,7 @@ $(eval $(call gb_Library_add_defs,vcl,\ $(eval $(call gb_Library_use_sdk_api,vcl)) $(eval $(call gb_Library_use_libraries,vcl,\ + svl \ tl \ utl \ sot \ @@ -143,6 +144,14 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ vcl/source/control/spinfld \ vcl/source/control/tabctrl \ vcl/source/control/throbber \ + vcl/source/edit/vclmedit \ + vcl/source/edit/textdata \ + vcl/source/edit/textdoc \ + vcl/source/edit/texteng \ + vcl/source/edit/textundo \ + vcl/source/edit/textview \ + vcl/source/edit/txtattr \ + vcl/source/edit/xtextedt \ vcl/source/fontsubset/cff \ vcl/source/fontsubset/fontsubset \ vcl/source/fontsubset/gsub \ diff --git a/vcl/Package_inc.mk b/vcl/Package_inc.mk index a01822f46920..3f95e97ac184 100644 --- a/vcl/Package_inc.mk +++ b/vcl/Package_inc.mk @@ -150,19 +150,26 @@ $(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/tabctrl.hxx,vcl/tabctrl.hxx)) $(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/tabdlg.hxx,vcl/tabdlg.hxx)) $(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/tabpage.hxx,vcl/tabpage.hxx)) $(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/taskpanelist.hxx,vcl/taskpanelist.hxx)) +$(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/textdata.hxx,vcl/textdata.hxx)) +$(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/texteng.hxx,vcl/texteng.hxx)) +$(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/textview.hxx,vcl/textview.hxx)) $(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/threadex.hxx,vcl/threadex.hxx)) $(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/throbber.hxx,vcl/throbber.hxx)) $(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/timer.hxx,vcl/timer.hxx)) $(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/toolbox.hxx,vcl/toolbox.hxx)) +$(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/txtattr.hxx,vcl/txtattr.hxx)) $(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/unohelp2.hxx,vcl/unohelp2.hxx)) $(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/unohelp.hxx,vcl/unohelp.hxx)) $(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/unowrap.hxx,vcl/unowrap.hxx)) $(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/vclenum.hxx,vcl/vclenum.hxx)) $(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/vclevent.hxx,vcl/vclevent.hxx)) +$(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/vclmedit.hxx,vcl/vclmedit.hxx)) $(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/virdev.hxx,vcl/virdev.hxx)) $(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/waitobj.hxx,vcl/waitobj.hxx)) $(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/wall.hxx,vcl/wall.hxx)) $(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/window.hxx,vcl/window.hxx)) $(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/wrkwin.hxx,vcl/wrkwin.hxx)) +$(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/xtextedt.hxx,vcl/xtextedt.hxx)) + # vim: set noet sw=4 ts=4: diff --git a/vcl/inc/vcl/msgbox.hxx b/vcl/inc/vcl/msgbox.hxx index 1d76e1370acb..2bb73abed728 100644 --- a/vcl/inc/vcl/msgbox.hxx +++ b/vcl/inc/vcl/msgbox.hxx @@ -34,7 +34,7 @@ #include <vcl/btndlg.hxx> #include <vcl/image.hxx> #include <vcl/bitmap.hxx> -class FixedText; +class VCLMultiLineEdit; class FixedImage; class CheckBox; @@ -67,7 +67,7 @@ class CheckBox; class VCL_DLLPUBLIC MessBox : public ButtonDialog { protected: - FixedText* mpFixedText; + VCLMultiLineEdit* mpVCLMultiLineEdit; FixedImage* mpFixedImage; XubString maMessText; Image maImage; diff --git a/svtools/inc/svtools/textdata.hxx b/vcl/inc/vcl/textdata.hxx index 29d97e6e51e4..4ee0e2f24533 100644 --- a/svtools/inc/svtools/textdata.hxx +++ b/vcl/inc/vcl/textdata.hxx @@ -20,7 +20,7 @@ #ifndef _TEXTDATA_HXX #define _TEXTDATA_HXX -#include "svtools/svtdllapi.h" +#include <vcl/dllapi.h> #include <svl/brdcst.hxx> #include <svl/smplhint.hxx> #include <tools/string.hxx> @@ -72,7 +72,7 @@ inline sal_Bool TextPaM::operator > ( const TextPaM& rPaM ) const ( ( mnPara == rPaM.mnPara ) && mnIndex > rPaM.mnIndex ) ) ? sal_True : sal_False; } -class SVT_DLLPUBLIC TextSelection +class VCL_DLLPUBLIC TextSelection { private: TextPaM maStartPaM; @@ -122,7 +122,7 @@ inline sal_Bool TextSelection::operator != ( const TextSelection& rSel ) const #define TEXT_HINT_VIEWSCROLLED 100 #define TEXT_HINT_VIEWSELECTIONCHANGED 101 -class SVT_DLLPUBLIC TextHint : public SfxSimpleHint +class VCL_DLLPUBLIC TextHint : public SfxSimpleHint { private: sal_uLong mnValue; diff --git a/svtools/inc/svtools/texteng.hxx b/vcl/inc/vcl/texteng.hxx index b20a01bdb9d7..4eeee732d574 100644 --- a/svtools/inc/svtools/texteng.hxx +++ b/vcl/inc/vcl/texteng.hxx @@ -28,7 +28,7 @@ #ifndef _TEXTENG_HXX #define _TEXTENG_HXX -#include "svtools/svtdllapi.h" +#include <vcl/dllapi.h> class TextDoc; class TextView; @@ -81,7 +81,7 @@ enum TxtAlign { TXTALIGN_LEFT, TXTALIGN_CENTER, TXTALIGN_RIGHT }; typedef std::vector<TextView*> TextViews; -class SVT_DLLPUBLIC TextEngine : public SfxBroadcaster +class VCL_DLLPUBLIC TextEngine : public SfxBroadcaster { friend class TextView; friend class TextSelFunctionSet; diff --git a/svtools/inc/svtools/textview.hxx b/vcl/inc/vcl/textview.hxx index ebf7a4f6f2eb..72de5f0f713d 100644 --- a/svtools/inc/svtools/textview.hxx +++ b/vcl/inc/vcl/textview.hxx @@ -29,8 +29,8 @@ #ifndef _TEXTVIEW_HXX #define _TEXTVIEW_HXX -#include "svtools/svtdllapi.h" -#include <svtools/textdata.hxx> +#include <vcl/dllapi.h> +#include <vcl/textdata.hxx> #include <tools/gen.hxx> #include <vcl/dndhelp.hxx> @@ -56,7 +56,7 @@ namespace clipboard { struct ImpTextView; -class SVT_DLLPUBLIC TextView : public vcl::unohelper::DragAndDropClient +class VCL_DLLPUBLIC TextView : public vcl::unohelper::DragAndDropClient { friend class TextEngine; friend class TextUndo; diff --git a/svtools/inc/svtools/txtattr.hxx b/vcl/inc/vcl/txtattr.hxx index bf4c8e38b007..695dfc7307b3 100644 --- a/svtools/inc/svtools/txtattr.hxx +++ b/vcl/inc/vcl/txtattr.hxx @@ -29,7 +29,7 @@ #ifndef _TXTATTR_HXX #define _TXTATTR_HXX -#include "svtools/svtdllapi.h" +#include <vcl/dllapi.h> #include <tools/color.hxx> #include <vcl/vclenum.hxx> #include <tools/string.hxx> @@ -46,7 +46,7 @@ class Font; #define TEXTATTR_PROTECTED 4 -class SVT_DLLPUBLIC TextAttrib +class VCL_DLLPUBLIC TextAttrib { private: sal_uInt16 mnWhich; @@ -70,7 +70,7 @@ public: -class SVT_DLLPUBLIC TextAttribFontColor : public TextAttrib +class VCL_DLLPUBLIC TextAttribFontColor : public TextAttrib { private: Color maColor; @@ -88,7 +88,7 @@ public: }; -class SVT_DLLPUBLIC TextAttribFontWeight : public TextAttrib +class VCL_DLLPUBLIC TextAttribFontWeight : public TextAttrib { private: FontWeight meWeight; @@ -131,7 +131,7 @@ public: virtual int operator==( const TextAttrib& rAttr ) const; }; -class SVT_DLLPUBLIC TextAttribProtect : public TextAttrib +class VCL_DLLPUBLIC TextAttribProtect : public TextAttrib { public: TextAttribProtect(); diff --git a/vcl/inc/vcl/vclmedit.hxx b/vcl/inc/vcl/vclmedit.hxx new file mode 100644 index 000000000000..519cb0e0948c --- /dev/null +++ b/vcl/inc/vcl/vclmedit.hxx @@ -0,0 +1,149 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _VCLMEDIT_HXX +#define _VCLMEDIT_HXX + +#include <tools/wintypes.hxx> +#include <vcl/edit.hxx> +#include <vcl/dllapi.h> + + +class ImpSvMEdit; +class Timer; +class ExtTextEngine; +class ExtTextView; + +class VCL_DLLPUBLIC VCLMultiLineEdit : public Edit +{ +private: + ImpSvMEdit* pImpSvMEdit; + + XubString aSaveValue; + Link aModifyHdlLink; + + Timer* pUpdateDataTimer; + Link aUpdateDataHdlLink; + +protected: + + DECL_LINK( ImpUpdateDataHdl, void* ); + void StateChanged( StateChangedType nType ); + void DataChanged( const DataChangedEvent& rDCEvt ); + virtual long PreNotify( NotifyEvent& rNEvt ); + long Notify( NotifyEvent& rNEvt ); + using Control::ImplInitSettings; + void ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground ); + WinBits ImplInitStyle( WinBits nStyle ); + + ExtTextEngine* GetTextEngine() const; + ExtTextView* GetTextView() const; + ScrollBar* GetVScrollBar() const; + +public: + VCLMultiLineEdit( Window* pParent, WinBits nWinStyle = WB_LEFT | WB_BORDER ); + VCLMultiLineEdit( Window* pParent, const ResId& rResId ); + virtual ~VCLMultiLineEdit(); + + + virtual void Modify(); + virtual void UpdateData(); + + virtual void SetModifyFlag(); + virtual void ClearModifyFlag(); + virtual sal_Bool IsModified() const; + + virtual void EnableUpdateData( sal_uLong nTimeout = EDIT_UPDATEDATA_TIMEOUT ); + virtual void DisableUpdateData() { delete pUpdateDataTimer; pUpdateDataTimer = NULL; } + virtual sal_uLong IsUpdateDataEnabled() const; + + virtual void SetReadOnly( sal_Bool bReadOnly = sal_True ); + virtual sal_Bool IsReadOnly() const; + + void EnableFocusSelectionHide( sal_Bool bHide ); + + virtual void SetMaxTextLen( xub_StrLen nMaxLen = 0 ); + virtual xub_StrLen GetMaxTextLen() const; + + virtual void SetSelection( const Selection& rSelection ); + virtual const Selection& GetSelection() const; + + virtual void ReplaceSelected( const XubString& rStr ); + virtual void DeleteSelected(); + virtual XubString GetSelected() const; + virtual XubString GetSelected( LineEnd aSeparator ) const; + + virtual void Cut(); + virtual void Copy(); + virtual void Paste(); + + virtual void SetText( const XubString& rStr ); + virtual void SetText( const XubString& rStr, const Selection& rNewSelection ) + { SetText( rStr ); SetSelection( rNewSelection ); } + String GetText() const; + String GetText( LineEnd aSeparator ) const; + String GetTextLines( LineEnd aSeparator ) const; + + void SetRightToLeft( sal_Bool bRightToLeft ); + sal_Bool IsRightToLeft() const; + + void SaveValue() { aSaveValue = GetText(); } + const XubString& GetSavedValue() const { return aSaveValue; } + + void SetModifyHdl( const Link& rLink ) { aModifyHdlLink = rLink; } + const Link& GetModifyHdl() const { return aModifyHdlLink; } + + void SetUpdateDataHdl( const Link& rLink ) { aUpdateDataHdlLink = rLink; } + const Link& GetUpdateDataHdl() const { return aUpdateDataHdlLink; } + + virtual void Resize(); + virtual void GetFocus(); + + Size CalcMinimumSize() const; + Size CalcAdjustedSize( const Size& rPrefSize ) const; + using Edit::CalcSize; + Size CalcSize( sal_uInt16 nColumns, sal_uInt16 nLines ) const; + void GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines ) const; + + void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ); + + void SetLeftMargin( sal_uInt16 n ); + + void DisableSelectionOnFocus(); + + void SetTextSelectable( sal_Bool bTextSelectable ); +}; + +inline sal_uLong VCLMultiLineEdit::IsUpdateDataEnabled() const +{ + return pUpdateDataTimer ? pUpdateDataTimer->GetTimeout() : 0; +} + +#endif //_VCLMEDIT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/inc/svtools/xtextedt.hxx b/vcl/inc/vcl/xtextedt.hxx index b0b09b0aafa5..b763e37102c7 100644 --- a/svtools/inc/svtools/xtextedt.hxx +++ b/vcl/inc/vcl/xtextedt.hxx @@ -19,9 +19,9 @@ #ifndef _XTEXTEDT_HXX #define _XTEXTEDT_HXX -#include "svtools/svtdllapi.h" -#include <svtools/texteng.hxx> -#include <svtools/textview.hxx> +#include <vcl/dllapi.h> +#include <vcl/texteng.hxx> +#include <vcl/textview.hxx> namespace com { namespace sun { @@ -30,7 +30,7 @@ namespace util { struct SearchOptions; }}}} -class SVT_DLLPUBLIC ExtTextEngine : public TextEngine +class VCL_DLLPUBLIC ExtTextEngine : public TextEngine { private: String maGroupChars; @@ -46,7 +46,7 @@ public: sal_Bool Search( TextSelection& rSel, const ::com::sun::star::util::SearchOptions& rSearchOptions, sal_Bool bForward = sal_True ); }; -class SVT_DLLPUBLIC ExtTextView : public TextView +class VCL_DLLPUBLIC ExtTextView : public TextView { protected: sal_Bool ImpIndentBlock( sal_Bool bRight ); diff --git a/svtools/source/edit/textdat2.hxx b/vcl/source/edit/textdat2.hxx index c52d33e7fef1..c52d33e7fef1 100644 --- a/svtools/source/edit/textdat2.hxx +++ b/vcl/source/edit/textdat2.hxx diff --git a/svtools/source/edit/textdata.cxx b/vcl/source/edit/textdata.cxx index 7d55ee13cc6a..79f28f3f9573 100644 --- a/svtools/source/edit/textdata.cxx +++ b/vcl/source/edit/textdata.cxx @@ -27,7 +27,7 @@ ************************************************************************/ -#include <svtools/textdata.hxx> +#include <vcl/textdata.hxx> #include <textdat2.hxx> #include <tools/debug.hxx> diff --git a/svtools/source/edit/textdoc.cxx b/vcl/source/edit/textdoc.cxx index a8062ecefbf3..a8062ecefbf3 100644 --- a/svtools/source/edit/textdoc.cxx +++ b/vcl/source/edit/textdoc.cxx diff --git a/svtools/source/edit/textdoc.hxx b/vcl/source/edit/textdoc.hxx index 15511234d716..a1529a4999e3 100644 --- a/svtools/source/edit/textdoc.hxx +++ b/vcl/source/edit/textdoc.hxx @@ -29,8 +29,8 @@ #ifndef _TEXTDOC_HXX #define _TEXTDOC_HXX -#include <svtools/textdata.hxx> -#include <svtools/txtattr.hxx> +#include <vcl/textdata.hxx> +#include <vcl/txtattr.hxx> #include <tools/string.hxx> #include <vector> diff --git a/svtools/source/edit/texteng.cxx b/vcl/source/edit/texteng.cxx index efce793b44b0..bd6d1791bd3a 100644 --- a/svtools/source/edit/texteng.cxx +++ b/vcl/source/edit/texteng.cxx @@ -28,8 +28,8 @@ #include <tools/stream.hxx> -#include <svtools/texteng.hxx> -#include <svtools/textview.hxx> +#include <vcl/texteng.hxx> +#include <vcl/textview.hxx> #include <textdoc.hxx> #include <textdat2.hxx> #include <textundo.hxx> diff --git a/svtools/source/edit/textund2.hxx b/vcl/source/edit/textund2.hxx index c5ce90cc9e54..c5ce90cc9e54 100644 --- a/svtools/source/edit/textund2.hxx +++ b/vcl/source/edit/textund2.hxx diff --git a/svtools/source/edit/textundo.cxx b/vcl/source/edit/textundo.cxx index 1b82d0f1025b..807abf232ad8 100644 --- a/svtools/source/edit/textundo.cxx +++ b/vcl/source/edit/textundo.cxx @@ -27,11 +27,11 @@ ************************************************************************/ -#include <svtools/texteng.hxx> -#include <svtools/textview.hxx> +#include <vcl/texteng.hxx> +#include <vcl/textview.hxx> #include <textundo.hxx> #include <textund2.hxx> -#include <svtools/textdata.hxx> +#include <vcl/textdata.hxx> #include <textdoc.hxx> #include <textdat2.hxx> diff --git a/svtools/source/edit/textundo.hxx b/vcl/source/edit/textundo.hxx index f86f87763097..f86f87763097 100644 --- a/svtools/source/edit/textundo.hxx +++ b/vcl/source/edit/textundo.hxx diff --git a/svtools/source/edit/textview.cxx b/vcl/source/edit/textview.cxx index 40a67743f4bb..045fb304b065 100644 --- a/svtools/source/edit/textview.cxx +++ b/vcl/source/edit/textview.cxx @@ -26,10 +26,10 @@ * ************************************************************************/ -#include <svtools/textview.hxx> -#include <svtools/texteng.hxx> +#include <vcl/textview.hxx> +#include <vcl/texteng.hxx> #include <textdoc.hxx> -#include <svtools/textdata.hxx> +#include <vcl/textdata.hxx> #include <textdat2.hxx> #include <svl/undo.hxx> diff --git a/svtools/source/edit/txtattr.cxx b/vcl/source/edit/txtattr.cxx index a3324828e951..d0e3a84462b6 100644 --- a/svtools/source/edit/txtattr.cxx +++ b/vcl/source/edit/txtattr.cxx @@ -27,7 +27,7 @@ ************************************************************************/ -#include <svtools/txtattr.hxx> +#include <vcl/txtattr.hxx> #include <vcl/font.hxx> diff --git a/vcl/source/edit/vclmedit.cxx b/vcl/source/edit/vclmedit.cxx new file mode 100644 index 000000000000..677962c93742 --- /dev/null +++ b/vcl/source/edit/vclmedit.cxx @@ -0,0 +1,1572 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <memory> + +#include <tools/rc.h> + +#include <vcl/decoview.hxx> +#include <vcl/svapp.hxx> + +#include <vcl/vclmedit.hxx> +#include <vcl/xtextedt.hxx> +#include <svl/brdcst.hxx> +#include <svl/undo.hxx> +#include <svl/lstner.hxx> +#include <svl/smplhint.hxx> + +#include <svids.hrc> +#include <vcl/scrbar.hxx> + + +class TextWindow : public Window +{ +private: + ExtTextEngine* mpExtTextEngine; + ExtTextView* mpExtTextView; + + sal_Bool mbInMBDown; + sal_Bool mbFocusSelectionHide; + sal_Bool mbIgnoreTab; + sal_Bool mbActivePopup; + sal_Bool mbSelectOnTab; + sal_Bool mbTextSelectable; + +public: + TextWindow( Window* pParent ); + ~TextWindow(); + + ExtTextEngine* GetTextEngine() const { return mpExtTextEngine; } + ExtTextView* GetTextView() const { return mpExtTextView; } + + virtual void MouseMove( const MouseEvent& rMEvt ); + virtual void MouseButtonDown( const MouseEvent& rMEvt ); + virtual void MouseButtonUp( const MouseEvent& rMEvt ); + virtual void KeyInput( const KeyEvent& rKEvent ); + + virtual void Command( const CommandEvent& rCEvt ); + + virtual void Paint( const Rectangle& rRect ); + virtual void Resize(); + + virtual void GetFocus(); + virtual void LoseFocus(); + + sal_Bool IsAutoFocusHide() const { return mbFocusSelectionHide; } + void SetAutoFocusHide( sal_Bool bAutoHide ) { mbFocusSelectionHide = bAutoHide; } + + sal_Bool IsIgnoreTab() const { return mbIgnoreTab; } + void SetIgnoreTab( sal_Bool bIgnore ) { mbIgnoreTab = bIgnore; } + + void DisableSelectionOnFocus() { mbSelectOnTab = sal_False; } + + void SetTextSelectable( sal_Bool bTextSelectable ) { mbTextSelectable = bTextSelectable; } +}; + + +class ImpSvMEdit : public SfxListener +{ +private: + VCLMultiLineEdit* pSvVCLMultiLineEdit; + + TextWindow* mpTextWindow; + ScrollBar* mpHScrollBar; + ScrollBar* mpVScrollBar; + ScrollBarBox* mpScrollBox; + + Point maTextWindowOffset; + xub_StrLen mnTextWidth; + mutable Selection maSelection; + +protected: + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); + void ImpUpdateSrollBarVis( WinBits nWinStyle ); + void ImpInitScrollBars(); + void ImpSetScrollBarRanges(); + void ImpSetHScrollBarThumbPos(); + DECL_LINK( ScrollHdl, ScrollBar* ); + +public: + ImpSvMEdit( VCLMultiLineEdit* pSvVCLMultiLineEdit, WinBits nWinStyle ); + ~ImpSvMEdit(); + + void SetModified( sal_Bool bMod ); + sal_Bool IsModified() const; + + void SetReadOnly( sal_Bool bRdOnly ); + sal_Bool IsReadOnly() const; + + void SetMaxTextLen( xub_StrLen nLen ); + xub_StrLen GetMaxTextLen() const; + + sal_Bool IsInsertMode() const; + + void InsertText( const String& rStr ); + String GetSelected() const; + String GetSelected( LineEnd aSeparator ) const; + + void SetSelection( const Selection& rSelection ); + const Selection& GetSelection() const; + + void Cut(); + void Copy(); + void Paste(); + + void SetText( const String& rStr ); + String GetText() const; + String GetText( LineEnd aSeparator ) const; + String GetTextLines( LineEnd aSeparator ) const; + + void Resize(); + void GetFocus(); + + sal_Bool HandleCommand( const CommandEvent& rCEvt ); + + void Enable( sal_Bool bEnable ); + + Size CalcMinimumSize() const; + Size CalcSize( sal_uInt16 nColumns, sal_uInt16 nLines ) const; + void GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines ) const; + + void SetAlign( WinBits nWinStyle ); + + void InitFromStyle( WinBits nWinStyle ); + + TextWindow* GetTextWindow() { return mpTextWindow; } + ScrollBar* GetHScrollBar() { return mpHScrollBar; } + ScrollBar* GetVScrollBar() { return mpVScrollBar; } +}; + +ImpSvMEdit::ImpSvMEdit( VCLMultiLineEdit* pEdt, WinBits nWinStyle ) + :mpHScrollBar(NULL) + ,mpVScrollBar(NULL) + ,mpScrollBox(NULL) +{ + pSvVCLMultiLineEdit = pEdt; + mnTextWidth = 0; + mpTextWindow = new TextWindow( pEdt ); + mpTextWindow->Show(); + InitFromStyle( nWinStyle ); + StartListening( *mpTextWindow->GetTextEngine() ); +} + +void ImpSvMEdit::ImpUpdateSrollBarVis( WinBits nWinStyle ) +{ + const sal_Bool bHaveVScroll = (NULL != mpVScrollBar); + const sal_Bool bHaveHScroll = (NULL != mpHScrollBar); + const sal_Bool bHaveScrollBox = (NULL != mpScrollBox); + + sal_Bool bNeedVScroll = ( nWinStyle & WB_VSCROLL ) == WB_VSCROLL; + const sal_Bool bNeedHScroll = ( nWinStyle & WB_HSCROLL ) == WB_HSCROLL; + + const sal_Bool bAutoVScroll = ( nWinStyle & WB_AUTOVSCROLL ) == WB_AUTOVSCROLL; + if ( !bNeedVScroll && bAutoVScroll ) + { + TextEngine& rEngine( *mpTextWindow->GetTextEngine() ); + sal_uLong nOverallTextHeight(0); + for ( sal_uLong i=0; i<rEngine.GetParagraphCount(); ++i ) + nOverallTextHeight += rEngine.GetTextHeight( i ); + if ( nOverallTextHeight > (sal_uLong)mpTextWindow->GetOutputSizePixel().Height() ) + bNeedVScroll = true; + } + + const sal_Bool bNeedScrollBox = bNeedVScroll && bNeedHScroll; + + sal_Bool bScrollbarsChanged = false; + if ( bHaveVScroll != bNeedVScroll ) + { + delete mpVScrollBar; + mpVScrollBar = bNeedVScroll ? new ScrollBar( pSvVCLMultiLineEdit, WB_VSCROLL|WB_DRAG ) : NULL; + + if ( bNeedVScroll ) + { + mpVScrollBar->Show(); + mpVScrollBar->SetScrollHdl( LINK( this, ImpSvMEdit, ScrollHdl ) ); + } + + bScrollbarsChanged = sal_True; + } + + if ( bHaveHScroll != bNeedHScroll ) + { + delete mpHScrollBar; + mpHScrollBar = bNeedHScroll ? new ScrollBar( pSvVCLMultiLineEdit, WB_HSCROLL|WB_DRAG ) : NULL; + + if ( bNeedHScroll ) + { + mpHScrollBar->Show(); + mpHScrollBar->SetScrollHdl( LINK( this, ImpSvMEdit, ScrollHdl ) ); + } + + bScrollbarsChanged = sal_True; + } + + if ( bHaveScrollBox != bNeedScrollBox ) + { + delete mpScrollBox; + mpScrollBox = bNeedScrollBox ? new ScrollBarBox( pSvVCLMultiLineEdit, WB_SIZEABLE ) : NULL; + + if ( bNeedScrollBox ) + mpScrollBox->Show(); + } + + if ( bScrollbarsChanged ) + { + ImpInitScrollBars(); + Resize(); + } +} + +void ImpSvMEdit::InitFromStyle( WinBits nWinStyle ) +{ + ImpUpdateSrollBarVis( nWinStyle ); + SetAlign( nWinStyle ); + + if ( nWinStyle & WB_NOHIDESELECTION ) + mpTextWindow->SetAutoFocusHide( sal_False ); + else + mpTextWindow->SetAutoFocusHide( sal_True ); + + if ( nWinStyle & WB_READONLY ) + mpTextWindow->GetTextView()->SetReadOnly( sal_True ); + else + mpTextWindow->GetTextView()->SetReadOnly( sal_False ); + + if ( nWinStyle & WB_IGNORETAB ) + { + mpTextWindow->SetIgnoreTab( sal_True ); + } + else + { + mpTextWindow->SetIgnoreTab( sal_False ); + // #103667# VCLMultiLineEdit has the flag, but focusable window also needs this flag + WinBits nStyle = mpTextWindow->GetStyle(); + nStyle |= WINDOW_DLGCTRL_MOD1TAB; + mpTextWindow->SetStyle( nStyle ); + } +} + +ImpSvMEdit::~ImpSvMEdit() +{ + EndListening( *mpTextWindow->GetTextEngine() ); + delete mpTextWindow; + delete mpHScrollBar; + delete mpVScrollBar; + delete mpScrollBox; +} + +void ImpSvMEdit::ImpSetScrollBarRanges() +{ + if ( mpVScrollBar ) + { + sal_uLong nTextHeight = mpTextWindow->GetTextEngine()->GetTextHeight(); + mpVScrollBar->SetRange( Range( 0, (long)nTextHeight-1 ) ); + } + if ( mpHScrollBar ) + { +// sal_uLong nTextWidth = mpTextWindow->GetTextEngine()->CalcTextWidth(); + // Es gibt kein Notify bei Breiten-Aenderung... +// sal_uLong nW = Max( (sal_uLong)mpTextWindow->GetOutputSizePixel().Width()*5, (sal_uLong)nTextWidth ); +// mpHScrollBar->SetRange( Range( 0, (long)nW ) ); + mpHScrollBar->SetRange( Range( 0, (long)mnTextWidth-1 ) ); + } +} + +void ImpSvMEdit::ImpInitScrollBars() +{ + static const sal_Unicode sampleChar = { 'x' }; + if ( mpHScrollBar || mpVScrollBar ) + { + ImpSetScrollBarRanges(); + Size aCharBox; + aCharBox.Width() = mpTextWindow->GetTextWidth( rtl::OUString(sampleChar) ); + aCharBox.Height() = mpTextWindow->GetTextHeight(); + Size aOutSz = mpTextWindow->GetOutputSizePixel(); + if ( mpHScrollBar ) + { + mpHScrollBar->SetVisibleSize( aOutSz.Width() ); + mpHScrollBar->SetPageSize( aOutSz.Width() * 8 / 10 ); + mpHScrollBar->SetLineSize( aCharBox.Width()*10 ); + ImpSetHScrollBarThumbPos(); + } + if ( mpVScrollBar ) + { + mpVScrollBar->SetVisibleSize( aOutSz.Height() ); + mpVScrollBar->SetPageSize( aOutSz.Height() * 8 / 10 ); + mpVScrollBar->SetLineSize( aCharBox.Height() ); + mpVScrollBar->SetThumbPos( mpTextWindow->GetTextView()->GetStartDocPos().Y() ); + } + } +} + +void ImpSvMEdit::ImpSetHScrollBarThumbPos() +{ + long nX = mpTextWindow->GetTextView()->GetStartDocPos().X(); + if ( !mpTextWindow->GetTextEngine()->IsRightToLeft() ) + mpHScrollBar->SetThumbPos( nX ); + else + mpHScrollBar->SetThumbPos( mnTextWidth - mpHScrollBar->GetVisibleSize() - nX ); + +} + +IMPL_LINK( ImpSvMEdit, ScrollHdl, ScrollBar*, pCurScrollBar ) +{ + long nDiffX = 0, nDiffY = 0; + + if ( pCurScrollBar == mpVScrollBar ) + nDiffY = mpTextWindow->GetTextView()->GetStartDocPos().Y() - pCurScrollBar->GetThumbPos(); + else if ( pCurScrollBar == mpHScrollBar ) + nDiffX = mpTextWindow->GetTextView()->GetStartDocPos().X() - pCurScrollBar->GetThumbPos(); + + mpTextWindow->GetTextView()->Scroll( nDiffX, nDiffY ); + // mpTextWindow->GetTextView()->ShowCursor( sal_False, sal_True ); + + return 0; +} + + +// void ImpSvMEdit::ImpModified() +// { +// // Wann wird das gerufen ????????????????????? +// pSvVCLMultiLineEdit->Modify(); +// } + +void ImpSvMEdit::SetAlign( WinBits nWinStyle ) +{ + sal_Bool bRTL = Application::GetSettings().GetLayoutRTL(); + mpTextWindow->GetTextEngine()->SetRightToLeft( bRTL ); + + if ( nWinStyle & WB_CENTER ) + mpTextWindow->GetTextEngine()->SetTextAlign( TXTALIGN_CENTER ); + else if ( nWinStyle & WB_RIGHT ) + mpTextWindow->GetTextEngine()->SetTextAlign( !bRTL ? TXTALIGN_RIGHT : TXTALIGN_LEFT ); + else if ( nWinStyle & WB_LEFT ) + mpTextWindow->GetTextEngine()->SetTextAlign( !bRTL ? TXTALIGN_LEFT : TXTALIGN_RIGHT ); +} + +void ImpSvMEdit::SetModified( sal_Bool bMod ) +{ + mpTextWindow->GetTextEngine()->SetModified( bMod ); +} + +sal_Bool ImpSvMEdit::IsModified() const +{ + return mpTextWindow->GetTextEngine()->IsModified(); +} + +void ImpSvMEdit::SetReadOnly( sal_Bool bRdOnly ) +{ + mpTextWindow->GetTextView()->SetReadOnly( bRdOnly ); + // Farbe anpassen ??????????????????????????? +} + +sal_Bool ImpSvMEdit::IsReadOnly() const +{ + return mpTextWindow->GetTextView()->IsReadOnly(); +} + +void ImpSvMEdit::SetMaxTextLen( xub_StrLen nLen ) +{ + mpTextWindow->GetTextEngine()->SetMaxTextLen( nLen ); +} + +xub_StrLen ImpSvMEdit::GetMaxTextLen() const +{ + return sal::static_int_cast< xub_StrLen >( + mpTextWindow->GetTextEngine()->GetMaxTextLen()); +} + +void ImpSvMEdit::InsertText( const String& rStr ) +{ + mpTextWindow->GetTextView()->InsertText( rStr ); +} + +String ImpSvMEdit::GetSelected() const +{ + return mpTextWindow->GetTextView()->GetSelected(); +} + +String ImpSvMEdit::GetSelected( LineEnd aSeparator ) const +{ + return mpTextWindow->GetTextView()->GetSelected( aSeparator ); +} + +void ImpSvMEdit::Resize() +{ + size_t nIteration = 1; + do + { + WinBits nWinStyle( pSvVCLMultiLineEdit->GetStyle() ); + if ( ( nWinStyle & WB_AUTOVSCROLL ) == WB_AUTOVSCROLL ) + ImpUpdateSrollBarVis( nWinStyle ); + + Size aSz = pSvVCLMultiLineEdit->GetOutputSizePixel(); + Size aEditSize = aSz; + long nSBWidth = pSvVCLMultiLineEdit->GetSettings().GetStyleSettings().GetScrollBarSize(); + nSBWidth = pSvVCLMultiLineEdit->CalcZoom( nSBWidth ); + + if ( mpHScrollBar ) + aSz.Height() -= nSBWidth+1; + if ( mpVScrollBar ) + aSz.Width() -= nSBWidth+1; + + if ( !mpHScrollBar ) + mpTextWindow->GetTextEngine()->SetMaxTextWidth( aSz.Width() ); + else + mpHScrollBar->SetPosSizePixel( 0, aEditSize.Height()-nSBWidth, aSz.Width(), nSBWidth ); + + Point aTextWindowPos( maTextWindowOffset ); + if ( mpVScrollBar ) + { + if( Application::GetSettings().GetLayoutRTL() ) + { + mpVScrollBar->SetPosSizePixel( 0, 0, nSBWidth, aSz.Height() ); + aTextWindowPos.X() += nSBWidth; + } + else + mpVScrollBar->SetPosSizePixel( aEditSize.Width()-nSBWidth, 0, nSBWidth, aSz.Height() ); + } + + if ( mpScrollBox ) + mpScrollBox->SetPosSizePixel( aSz.Width(), aSz.Height(), nSBWidth, nSBWidth ); + + Size aTextWindowSize( aSz ); + aTextWindowSize.Width() -= maTextWindowOffset.X(); + aTextWindowSize.Height() -= maTextWindowOffset.Y(); + if ( aTextWindowSize.Width() < 0 ) + aTextWindowSize.Width() = 0; + if ( aTextWindowSize.Height() < 0 ) + aTextWindowSize.Height() = 0; + + Size aOldTextWindowSize( mpTextWindow->GetSizePixel() ); + mpTextWindow->SetPosSizePixel( aTextWindowPos, aTextWindowSize ); + if ( aOldTextWindowSize == aTextWindowSize ) + break; + + // Changing the text window size might effectively have changed the need for + // scrollbars, so do another iteration. + ++nIteration; + OSL_ENSURE( nIteration < 3, "ImpSvMEdit::Resize: isn't this expected to terminate with the second iteration?" ); + + } while ( nIteration <= 3 ); // artificial break after four iterations + + ImpInitScrollBars(); +} + +void ImpSvMEdit::GetFocus() +{ + mpTextWindow->GrabFocus(); +} + +void ImpSvMEdit::Cut() +{ + if ( !mpTextWindow->GetTextView()->IsReadOnly() ) + mpTextWindow->GetTextView()->Cut(); +} + +void ImpSvMEdit::Copy() +{ + mpTextWindow->GetTextView()->Copy(); +} + +void ImpSvMEdit::Paste() +{ + if ( !mpTextWindow->GetTextView()->IsReadOnly() ) + mpTextWindow->GetTextView()->Paste(); +} + +void ImpSvMEdit::SetText( const String& rStr ) +{ + sal_Bool bWasModified = mpTextWindow->GetTextEngine()->IsModified(); + mpTextWindow->GetTextEngine()->SetText( rStr ); + if ( !bWasModified ) + mpTextWindow->GetTextEngine()->SetModified( sal_False ); + + mpTextWindow->GetTextView()->SetSelection( TextSelection() ); + + WinBits nWinStyle( pSvVCLMultiLineEdit->GetStyle() ); + if ( ( nWinStyle & WB_AUTOVSCROLL ) == WB_AUTOVSCROLL ) + ImpUpdateSrollBarVis( nWinStyle ); +} + +String ImpSvMEdit::GetText() const +{ + return mpTextWindow->GetTextEngine()->GetText(); +} + +String ImpSvMEdit::GetText( LineEnd aSeparator ) const +{ + return mpTextWindow->GetTextEngine()->GetText( aSeparator ); +} + +String ImpSvMEdit::GetTextLines( LineEnd aSeparator ) const +{ + return mpTextWindow->GetTextEngine()->GetTextLines( aSeparator ); +} + +void ImpSvMEdit::Notify( SfxBroadcaster&, const SfxHint& rHint ) +{ + if ( rHint.ISA( TextHint ) ) + { + const TextHint& rTextHint = (const TextHint&)rHint; + if( rTextHint.GetId() == TEXT_HINT_VIEWSCROLLED ) + { + if ( mpHScrollBar ) + ImpSetHScrollBarThumbPos(); + if ( mpVScrollBar ) + mpVScrollBar->SetThumbPos( mpTextWindow->GetTextView()->GetStartDocPos().Y() ); + } + else if( rTextHint.GetId() == TEXT_HINT_TEXTHEIGHTCHANGED ) + { + if ( mpTextWindow->GetTextView()->GetStartDocPos().Y() ) + { + long nOutHeight = mpTextWindow->GetOutputSizePixel().Height(); + long nTextHeight = mpTextWindow->GetTextEngine()->GetTextHeight(); + if ( nTextHeight < nOutHeight ) + mpTextWindow->GetTextView()->Scroll( 0, mpTextWindow->GetTextView()->GetStartDocPos().Y() ); + } + + ImpSetScrollBarRanges(); + } + else if( rTextHint.GetId() == TEXT_HINT_TEXTFORMATTED ) + { + if ( mpHScrollBar ) + { + sal_uLong nWidth = mpTextWindow->GetTextEngine()->CalcTextWidth(); + if ( nWidth != mnTextWidth ) + { + mnTextWidth = sal::static_int_cast< xub_StrLen >(nWidth); + mpHScrollBar->SetRange( Range( 0, (long)mnTextWidth-1 ) ); + ImpSetHScrollBarThumbPos(); + } + } + } + else if( rTextHint.GetId() == TEXT_HINT_MODIFIED ) + { + pSvVCLMultiLineEdit->Modify(); + } + } +} + +void ImpSvMEdit::SetSelection( const Selection& rSelection ) +{ + String aText = mpTextWindow->GetTextEngine()->GetText(); + + Selection aNewSelection( rSelection ); + if ( aNewSelection.Min() < 0 ) + aNewSelection.Min() = 0; + else if ( aNewSelection.Min() > aText.Len() ) + aNewSelection.Min() = aText.Len(); + if ( aNewSelection.Max() < 0 ) + aNewSelection.Max() = 0; + else if ( aNewSelection.Max() > aText.Len() ) + aNewSelection.Max() = aText.Len(); + + long nEnd = Max( aNewSelection.Min(), aNewSelection.Max() ); + TextSelection aTextSel; + sal_uLong nPara = 0; + sal_uInt16 nChar = 0; + sal_uInt16 x = 0; + while ( x <= nEnd ) + { + if ( x == aNewSelection.Min() ) + aTextSel.GetStart() = TextPaM( nPara, nChar ); + if ( x == aNewSelection.Max() ) + aTextSel.GetEnd() = TextPaM( nPara, nChar ); + + if ( ( x < aText.Len() ) && ( aText.GetChar( x ) == '\n' ) ) + { + nPara++; + nChar = 0; + } + else + nChar++; + x++; + } + mpTextWindow->GetTextView()->SetSelection( aTextSel ); +} + +const Selection& ImpSvMEdit::GetSelection() const +{ + maSelection = Selection(); + TextSelection aTextSel( mpTextWindow->GetTextView()->GetSelection() ); + aTextSel.Justify(); + // Selektion flachklopfen => jeder Umbruch ein Zeichen... + + ExtTextEngine* pExtTextEngine = mpTextWindow->GetTextEngine(); + // Absaetze davor: + sal_uLong n; + for ( n = 0; n < aTextSel.GetStart().GetPara(); n++ ) + { + maSelection.Min() += pExtTextEngine->GetTextLen( n ); + maSelection.Min()++; + } + + // Erster Absatz mit Selektion: + maSelection.Max() = maSelection.Min(); + maSelection.Min() += aTextSel.GetStart().GetIndex(); + + for ( n = aTextSel.GetStart().GetPara(); n < aTextSel.GetEnd().GetPara(); n++ ) + { + maSelection.Max() += pExtTextEngine->GetTextLen( n ); + maSelection.Max()++; + } + + maSelection.Max() += aTextSel.GetEnd().GetIndex(); + + return maSelection; +} + +Size ImpSvMEdit::CalcMinimumSize() const +{ + Size aSz( mpTextWindow->GetTextEngine()->CalcTextWidth(), + mpTextWindow->GetTextEngine()->GetTextHeight() ); + + if ( mpHScrollBar ) + aSz.Height() += mpHScrollBar->GetSizePixel().Height(); + if ( mpVScrollBar ) + aSz.Width() += mpVScrollBar->GetSizePixel().Width(); + + return aSz; +} + +Size ImpSvMEdit::CalcSize( sal_uInt16 nColumns, sal_uInt16 nLines ) const +{ + static const sal_Unicode sampleChar = 'X'; + + Size aSz; + Size aCharSz; + aCharSz.Width() = mpTextWindow->GetTextWidth( rtl::OUString(sampleChar) ); + aCharSz.Height() = mpTextWindow->GetTextHeight(); + + if ( nLines ) + aSz.Height() = nLines*aCharSz.Height(); + else + aSz.Height() = mpTextWindow->GetTextEngine()->GetTextHeight(); + + if ( nColumns ) + aSz.Width() = nColumns*aCharSz.Width(); + else + aSz.Width() = mpTextWindow->GetTextEngine()->CalcTextWidth(); + + if ( mpHScrollBar ) + aSz.Height() += mpHScrollBar->GetSizePixel().Height(); + if ( mpVScrollBar ) + aSz.Width() += mpVScrollBar->GetSizePixel().Width(); + + return aSz; +} + +void ImpSvMEdit::GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines ) const +{ + static const sal_Unicode sampleChar = { 'x' }; + Size aOutSz = mpTextWindow->GetOutputSizePixel(); + Size aCharSz( mpTextWindow->GetTextWidth( rtl::OUString(sampleChar) ), mpTextWindow->GetTextHeight() ); + rnCols = (sal_uInt16) (aOutSz.Width()/aCharSz.Width()); + rnLines = (sal_uInt16) (aOutSz.Height()/aCharSz.Height()); +} + +void ImpSvMEdit::Enable( sal_Bool bEnable ) +{ + mpTextWindow->Enable( bEnable ); + if ( mpHScrollBar ) + mpHScrollBar->Enable( bEnable ); + if ( mpVScrollBar ) + mpVScrollBar->Enable( bEnable ); +} + +sal_Bool ImpSvMEdit::HandleCommand( const CommandEvent& rCEvt ) +{ + sal_Bool bDone = sal_False; + if ( ( rCEvt.GetCommand() == COMMAND_WHEEL ) || + ( rCEvt.GetCommand() == COMMAND_STARTAUTOSCROLL ) || + ( rCEvt.GetCommand() == COMMAND_AUTOSCROLL ) ) + { + mpTextWindow->HandleScrollCommand( rCEvt, mpHScrollBar, mpVScrollBar ); + bDone = sal_True; + } + return bDone; +} + + +TextWindow::TextWindow( Window* pParent ) : Window( pParent ) +{ + mbInMBDown = sal_False; + mbSelectOnTab = sal_True; + mbFocusSelectionHide = sal_False; + mbIgnoreTab = sal_False; + mbActivePopup = sal_False; + mbSelectOnTab = sal_True; + mbTextSelectable = sal_True; + + SetPointer( Pointer( POINTER_TEXT ) ); + + mpExtTextEngine = new ExtTextEngine; + mpExtTextEngine->SetMaxTextLen( STRING_MAXLEN ); + if( pParent->GetStyle() & WB_BORDER ) + mpExtTextEngine->SetLeftMargin( 2 ); + mpExtTextEngine->SetLocale( GetSettings().GetLocale() ); + mpExtTextView = new ExtTextView( mpExtTextEngine, this ); + mpExtTextEngine->InsertView( mpExtTextView ); + mpExtTextEngine->EnableUndo( sal_True ); + mpExtTextView->ShowCursor(); + + Color aBackgroundColor = GetSettings().GetStyleSettings().GetWorkspaceColor(); + SetBackground( aBackgroundColor ); + pParent->SetBackground( aBackgroundColor ); +} + +TextWindow::~TextWindow() +{ + delete mpExtTextView; + delete mpExtTextEngine; +} + +void TextWindow::MouseMove( const MouseEvent& rMEvt ) +{ + mpExtTextView->MouseMove( rMEvt ); + Window::MouseMove( rMEvt ); +} + +void TextWindow::MouseButtonDown( const MouseEvent& rMEvt ) +{ + if ( !mbTextSelectable ) + return; + + mbInMBDown = sal_True; // Dann im GetFocus nicht alles selektieren wird + mpExtTextView->MouseButtonDown( rMEvt ); + Window::MouseButtonDown( rMEvt ); + GrabFocus(); + mbInMBDown = sal_False; +} + +void TextWindow::MouseButtonUp( const MouseEvent& rMEvt ) +{ + mpExtTextView->MouseButtonUp( rMEvt ); + Window::MouseButtonUp( rMEvt ); +} + +void TextWindow::KeyInput( const KeyEvent& rKEvent ) +{ + sal_Bool bDone = sal_False; + sal_uInt16 nCode = rKEvent.GetKeyCode().GetCode(); + if ( nCode == com::sun::star::awt::Key::SELECT_ALL || + ( (nCode == KEY_A) && rKEvent.GetKeyCode().IsMod1() && !rKEvent.GetKeyCode().IsMod2() ) + ) + { + mpExtTextView->SetSelection( TextSelection( TextPaM( 0, 0 ), TextPaM( 0xFFFF, 0xFFFF ) ) ); + bDone = sal_True; + } + else if ( (nCode == KEY_S) && rKEvent.GetKeyCode().IsShift() && rKEvent.GetKeyCode().IsMod1() ) + { + if ( Edit::GetGetSpecialCharsFunction() ) + { + // Damit die Selektion erhalten bleibt + mbActivePopup = sal_True; + rtl::OUString aChars = Edit::GetGetSpecialCharsFunction()( this, GetFont() ); + if (!aChars.isEmpty()) + { + mpExtTextView->InsertText( aChars ); + mpExtTextView->GetTextEngine()->SetModified( sal_True ); + } + mbActivePopup = sal_False; + bDone = sal_True; + } + } + else if ( nCode == KEY_TAB ) + { + if ( !mbIgnoreTab || rKEvent.GetKeyCode().IsMod1() ) + bDone = mpExtTextView->KeyInput( rKEvent ); + } + else + { + bDone = mpExtTextView->KeyInput( rKEvent ); + } + + if ( !bDone ) + Window::KeyInput( rKEvent ); +} + +void TextWindow::Paint( const Rectangle& rRect ) +{ + mpExtTextView->Paint( rRect ); +} + +void TextWindow::Resize() +{ +} + +void TextWindow::Command( const CommandEvent& rCEvt ) +{ + if ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU ) + { + PopupMenu* pPopup = Edit::CreatePopupMenu(); + if ( !mpExtTextView->HasSelection() ) + { + pPopup->EnableItem( SV_MENU_EDIT_CUT, sal_False ); + pPopup->EnableItem( SV_MENU_EDIT_COPY, sal_False ); + pPopup->EnableItem( SV_MENU_EDIT_DELETE, sal_False ); + } + if ( mpExtTextView->IsReadOnly() ) + { + pPopup->EnableItem( SV_MENU_EDIT_CUT, sal_False ); + pPopup->EnableItem( SV_MENU_EDIT_PASTE, sal_False ); + pPopup->EnableItem( SV_MENU_EDIT_DELETE, sal_False ); + pPopup->EnableItem( SV_MENU_EDIT_INSERTSYMBOL, sal_False ); + } + if ( !mpExtTextView->GetTextEngine()->HasUndoManager() || !mpExtTextView->GetTextEngine()->GetUndoManager().GetUndoActionCount() ) + { + pPopup->EnableItem( SV_MENU_EDIT_UNDO, sal_False ); + } +// if ( ( maSelection.Min() == 0 ) && ( maSelection.Max() == maText.Len() ) ) +// { +// pPopup->EnableItem( SV_MENU_EDIT_SELECTALL, sal_False ); +// } + if ( !Edit::GetGetSpecialCharsFunction() ) + { + sal_uInt16 nPos = pPopup->GetItemPos( SV_MENU_EDIT_INSERTSYMBOL ); + pPopup->RemoveItem( nPos ); + pPopup->RemoveItem( nPos-1 ); + } + + mbActivePopup = sal_True; + Point aPos = rCEvt.GetMousePosPixel(); + if ( !rCEvt.IsMouseEvent() ) + { + // !!! Irgendwann einmal Menu zentriert in der Selektion anzeigen !!! + Size aSize = GetOutputSizePixel(); + aPos = Point( aSize.Width()/2, aSize.Height()/2 ); + } +// pPopup->RemoveDisabledEntries(); + sal_uInt16 n = pPopup->Execute( this, aPos ); + Edit::DeletePopupMenu( pPopup ); + switch ( n ) + { + case SV_MENU_EDIT_UNDO: mpExtTextView->Undo(); + mpExtTextEngine->SetModified( sal_True ); + mpExtTextEngine->Broadcast( TextHint( TEXT_HINT_MODIFIED ) ); + break; + case SV_MENU_EDIT_CUT: mpExtTextView->Cut(); + mpExtTextEngine->SetModified( sal_True ); + mpExtTextEngine->Broadcast( TextHint( TEXT_HINT_MODIFIED ) ); + break; + case SV_MENU_EDIT_COPY: mpExtTextView->Copy(); + break; + case SV_MENU_EDIT_PASTE: mpExtTextView->Paste(); + mpExtTextEngine->SetModified( sal_True ); + mpExtTextEngine->Broadcast( TextHint( TEXT_HINT_MODIFIED ) ); + break; + case SV_MENU_EDIT_DELETE: mpExtTextView->DeleteSelected(); + mpExtTextEngine->SetModified( sal_True ); + mpExtTextEngine->Broadcast( TextHint( TEXT_HINT_MODIFIED ) ); + break; + case SV_MENU_EDIT_SELECTALL: mpExtTextView->SetSelection( TextSelection( TextPaM( 0, 0 ), TextPaM( 0xFFFFFFFF, 0xFFFF ) ) ); + break; + case SV_MENU_EDIT_INSERTSYMBOL: + { + rtl::OUString aChars = Edit::GetGetSpecialCharsFunction()( this, GetFont() ); + if (!aChars.isEmpty()) + { + mpExtTextView->InsertText( aChars ); + mpExtTextEngine->SetModified( sal_True ); + mpExtTextEngine->Broadcast( TextHint( TEXT_HINT_MODIFIED ) ); + } + } + break; + } + mbActivePopup = sal_False; + } + else + { + mpExtTextView->Command( rCEvt ); + } + Window::Command( rCEvt ); +} + +void TextWindow::GetFocus() +{ + Window::GetFocus(); + if ( !mbActivePopup ) + { + sal_Bool bGotoCursor = !mpExtTextView->IsReadOnly(); + if ( mbFocusSelectionHide && IsReallyVisible() && !mpExtTextView->IsReadOnly() + && ( mbSelectOnTab && + (!mbInMBDown || ( GetSettings().GetStyleSettings().GetSelectionOptions() & SELECTION_OPTION_FOCUS ) )) ) + { + // Alles selektieren, aber nicht scrollen + sal_Bool bAutoScroll = mpExtTextView->IsAutoScroll(); + mpExtTextView->SetAutoScroll( sal_False ); + mpExtTextView->SetSelection( TextSelection( TextPaM( 0, 0 ), TextPaM( 0xFFFF, 0xFFFF ) ) ); + mpExtTextView->SetAutoScroll( bAutoScroll ); + bGotoCursor = sal_False; + } + mpExtTextView->SetPaintSelection( sal_True ); + mpExtTextView->ShowCursor( bGotoCursor ); + } +} + +void TextWindow::LoseFocus() +{ + Window::LoseFocus(); + + if ( mbFocusSelectionHide && !mbActivePopup ) + mpExtTextView->SetPaintSelection( sal_False ); +} + +VCLMultiLineEdit::VCLMultiLineEdit( Window* pParent, WinBits nWinStyle ) + : Edit( pParent, nWinStyle ) +{ + SetType( WINDOW_MULTILINEEDIT ); + pImpSvMEdit = new ImpSvMEdit( this, nWinStyle ); + ImplInitSettings( sal_True, sal_True, sal_True ); + pUpdateDataTimer = 0; + + SetCompoundControl( sal_True ); + SetStyle( ImplInitStyle( nWinStyle ) ); +} + +VCLMultiLineEdit::VCLMultiLineEdit( Window* pParent, const ResId& rResId ) + : Edit( pParent, rResId.SetRT( RSC_MULTILINEEDIT ) ) +{ + SetType( WINDOW_MULTILINEEDIT ); + WinBits nWinStyle = rResId.GetWinBits(); + pImpSvMEdit = new ImpSvMEdit( this, nWinStyle ); + ImplInitSettings( sal_True, sal_True, sal_True ); + pUpdateDataTimer = 0; + + sal_uInt16 nMaxLen = Edit::GetMaxTextLen(); + if ( nMaxLen ) + SetMaxTextLen( nMaxLen ); + + SetText( Edit::GetText() ); + + if ( IsVisible() ) + pImpSvMEdit->Resize(); + + SetCompoundControl( sal_True ); + SetStyle( ImplInitStyle( nWinStyle ) ); + + // Base Edit ctor could call Show already, but that would cause problems + // with accessibility, as Show might (indirectly) trigger a call to virtual + // GetComponentInterface, which is the Edit's base version instead of the + // VCLMultiLineEdit's version while in the base Edit ctor: + if ((GetStyle() & WB_HIDE) == 0) + Show(); + +} + +VCLMultiLineEdit::~VCLMultiLineEdit() +{ + { + ::std::auto_ptr< ImpSvMEdit > pDelete( pImpSvMEdit ); + pImpSvMEdit = NULL; + } + delete pUpdateDataTimer; +} + +WinBits VCLMultiLineEdit::ImplInitStyle( WinBits nStyle ) +{ + if ( !(nStyle & WB_NOTABSTOP) ) + nStyle |= WB_TABSTOP; + + if ( !(nStyle & WB_NOGROUP) ) + nStyle |= WB_GROUP; + + if ( !(nStyle & WB_IGNORETAB )) + nStyle |= WINDOW_DLGCTRL_MOD1TAB; + + return nStyle; +} + + +void VCLMultiLineEdit::ImplInitSettings( sal_Bool /*bFont*/, sal_Bool /*bForeground*/, sal_Bool bBackground ) +{ + const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); + + // Der Font muss immer mit manipuliert werden, weil die TextEngine + // sich nicht um TextColor/Background kuemmert + + Color aTextColor = rStyleSettings.GetFieldTextColor(); + if ( IsControlForeground() ) + aTextColor = GetControlForeground(); + if ( !IsEnabled() ) + aTextColor = rStyleSettings.GetDisableColor(); + + Font aFont = rStyleSettings.GetFieldFont(); + if ( IsControlFont() ) + aFont.Merge( GetControlFont() ); + aFont.SetTransparent( IsPaintTransparent() ); + SetZoomedPointFont( aFont ); + Font TheFont = GetFont(); + TheFont.SetColor( aTextColor ); + if( IsPaintTransparent() ) + TheFont.SetFillColor( Color( COL_TRANSPARENT ) ); + else + TheFont.SetFillColor( IsControlBackground() ? GetControlBackground() : rStyleSettings.GetFieldColor() ); + pImpSvMEdit->GetTextWindow()->SetFont( TheFont ); + pImpSvMEdit->GetTextWindow()->GetTextEngine()->SetFont( TheFont ); + pImpSvMEdit->GetTextWindow()->SetTextColor( aTextColor ); + + if ( bBackground ) + { + if( IsPaintTransparent() ) + { + pImpSvMEdit->GetTextWindow()->SetPaintTransparent( sal_True ); + pImpSvMEdit->GetTextWindow()->SetBackground(); + pImpSvMEdit->GetTextWindow()->SetControlBackground(); + SetBackground(); + SetControlBackground(); + } + else + { + if( IsControlBackground() ) + pImpSvMEdit->GetTextWindow()->SetBackground( GetControlBackground() ); + else + pImpSvMEdit->GetTextWindow()->SetBackground( rStyleSettings.GetFieldColor() ); + // Auch am VCLMultiLineEdit einstellen, weil die TextComponent + // ggf. die Scrollbars hidet. + SetBackground( pImpSvMEdit->GetTextWindow()->GetBackground() ); + } + } +} + +void VCLMultiLineEdit::Modify() +{ + aModifyHdlLink.Call( this ); + + CallEventListeners( VCLEVENT_EDIT_MODIFY ); + + if ( pUpdateDataTimer ) + pUpdateDataTimer->Start(); +} + +IMPL_LINK_NOARG(VCLMultiLineEdit, ImpUpdateDataHdl) +{ + UpdateData(); + return 0; +} + +void VCLMultiLineEdit::UpdateData() +{ + aUpdateDataHdlLink.Call( this ); +} + +void VCLMultiLineEdit::SetModifyFlag() +{ + pImpSvMEdit->SetModified( sal_True ); +} + +void VCLMultiLineEdit::ClearModifyFlag() +{ + pImpSvMEdit->SetModified( sal_False ); +} + +sal_Bool VCLMultiLineEdit::IsModified() const +{ + return pImpSvMEdit->IsModified(); +} + +void VCLMultiLineEdit::EnableUpdateData( sal_uLong nTimeout ) +{ + if ( !nTimeout ) + DisableUpdateData(); + else + { + if ( !pUpdateDataTimer ) + { + pUpdateDataTimer = new Timer; + pUpdateDataTimer->SetTimeoutHdl( LINK( this, VCLMultiLineEdit, ImpUpdateDataHdl ) ); + } + pUpdateDataTimer->SetTimeout( nTimeout ); + } +} + +void VCLMultiLineEdit::SetReadOnly( sal_Bool bReadOnly ) +{ + pImpSvMEdit->SetReadOnly( bReadOnly ); + Edit::SetReadOnly( bReadOnly ); + + // #94921# ReadOnly can be overwritten in InitFromStyle() when WB not set. + WinBits nStyle = GetStyle(); + if ( bReadOnly ) + nStyle |= WB_READONLY; + else + nStyle &= ~WB_READONLY; + SetStyle( nStyle ); +} + +sal_Bool VCLMultiLineEdit::IsReadOnly() const +{ + return pImpSvMEdit->IsReadOnly(); +} + +void VCLMultiLineEdit::SetMaxTextLen( xub_StrLen nMaxLen ) +{ + pImpSvMEdit->SetMaxTextLen( nMaxLen ); +} + +xub_StrLen VCLMultiLineEdit::GetMaxTextLen() const +{ + return pImpSvMEdit->GetMaxTextLen(); +} + +void VCLMultiLineEdit::ReplaceSelected( const String& rStr ) +{ + pImpSvMEdit->InsertText( rStr ); +} + +void VCLMultiLineEdit::DeleteSelected() +{ + pImpSvMEdit->InsertText( String() ); +} + +String VCLMultiLineEdit::GetSelected() const +{ + return pImpSvMEdit->GetSelected(); +} + +String VCLMultiLineEdit::GetSelected( LineEnd aSeparator ) const +{ + return pImpSvMEdit->GetSelected( aSeparator ); +} + +void VCLMultiLineEdit::Cut() +{ + pImpSvMEdit->Cut(); +} + +void VCLMultiLineEdit::Copy() +{ + pImpSvMEdit->Copy(); +} + +void VCLMultiLineEdit::Paste() +{ + pImpSvMEdit->Paste(); +} + +void VCLMultiLineEdit::SetText( const String& rStr ) +{ + pImpSvMEdit->SetText( rStr ); +} + +String VCLMultiLineEdit::GetText() const +{ + return pImpSvMEdit->GetText(); +} + +String VCLMultiLineEdit::GetText( LineEnd aSeparator ) const +{ + return pImpSvMEdit->GetText( aSeparator ); +} + +String VCLMultiLineEdit::GetTextLines( LineEnd aSeparator ) const +{ + return pImpSvMEdit->GetTextLines( aSeparator ); +} + +void VCLMultiLineEdit::Resize() +{ + pImpSvMEdit->Resize(); +} + +void VCLMultiLineEdit::GetFocus() +{ + if ( !pImpSvMEdit ) // might be called from within the dtor, when pImpSvMEdit == NULL is a valid state + return; + + Edit::GetFocus(); + pImpSvMEdit->GetFocus(); +} + +void VCLMultiLineEdit::SetSelection( const Selection& rSelection ) +{ + pImpSvMEdit->SetSelection( rSelection ); +} + +const Selection& VCLMultiLineEdit::GetSelection() const +{ + return pImpSvMEdit->GetSelection(); +} + +Size VCLMultiLineEdit::CalcMinimumSize() const +{ + Size aSz = pImpSvMEdit->CalcMinimumSize(); + + sal_Int32 nLeft, nTop, nRight, nBottom; + ((Window*)this)->GetBorder( nLeft, nTop, nRight, nBottom ); + aSz.Width() += nLeft+nRight; + aSz.Height() += nTop+nBottom; + + return aSz; +} + +Size VCLMultiLineEdit::CalcAdjustedSize( const Size& rPrefSize ) const +{ + Size aSz = rPrefSize; + sal_Int32 nLeft, nTop, nRight, nBottom; + ((Window*)this)->GetBorder( nLeft, nTop, nRight, nBottom ); + + // In der Hoehe auf ganze Zeilen justieren + + long nHeight = aSz.Height() - nTop - nBottom; + long nLineHeight = pImpSvMEdit->CalcSize( 1, 1 ).Height(); + long nLines = nHeight / nLineHeight; + if ( nLines < 1 ) + nLines = 1; + + aSz.Height() = nLines * nLineHeight; + aSz.Height() += nTop+nBottom; + + return aSz; +} + +Size VCLMultiLineEdit::CalcSize( sal_uInt16 nColumns, sal_uInt16 nLines ) const +{ + Size aSz = pImpSvMEdit->CalcSize( nColumns, nLines ); + + sal_Int32 nLeft, nTop, nRight, nBottom; + ((Window*)this)->GetBorder( nLeft, nTop, nRight, nBottom ); + aSz.Width() += nLeft+nRight; + aSz.Height() += nTop+nBottom; + return aSz; +} + +void VCLMultiLineEdit::GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines ) const +{ + pImpSvMEdit->GetMaxVisColumnsAndLines( rnCols, rnLines ); +} + +void VCLMultiLineEdit::StateChanged( StateChangedType nType ) +{ + if( nType == STATE_CHANGE_ENABLE ) + { + pImpSvMEdit->Enable( IsEnabled() ); + ImplInitSettings( sal_True, sal_False, sal_False ); + } + else if( nType == STATE_CHANGE_READONLY ) + { + pImpSvMEdit->SetReadOnly( IsReadOnly() ); + } + else if ( nType == STATE_CHANGE_ZOOM ) + { + pImpSvMEdit->GetTextWindow()->SetZoom( GetZoom() ); + ImplInitSettings( sal_True, sal_False, sal_False ); + Resize(); + } + else if ( nType == STATE_CHANGE_CONTROLFONT ) + { + ImplInitSettings( sal_True, sal_False, sal_False ); + Resize(); + Invalidate(); + } + else if ( nType == STATE_CHANGE_CONTROLFOREGROUND ) + { + ImplInitSettings( sal_False, sal_True, sal_False ); + Invalidate(); + } + else if ( nType == STATE_CHANGE_CONTROLBACKGROUND ) + { + ImplInitSettings( sal_False, sal_False, sal_True ); + Invalidate(); + } + else if ( nType == STATE_CHANGE_STYLE ) + { + pImpSvMEdit->InitFromStyle( GetStyle() ); + SetStyle( ImplInitStyle( GetStyle() ) ); + } + else if ( nType == STATE_CHANGE_INITSHOW ) + { + if( IsPaintTransparent() ) + { + pImpSvMEdit->GetTextWindow()->SetPaintTransparent( sal_True ); + pImpSvMEdit->GetTextWindow()->SetBackground(); + pImpSvMEdit->GetTextWindow()->SetControlBackground(); + SetBackground(); + SetControlBackground(); + } + } + + Control::StateChanged( nType ); +} + +void VCLMultiLineEdit::DataChanged( const DataChangedEvent& rDCEvt ) +{ + if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && + (rDCEvt.GetFlags() & SETTINGS_STYLE) ) + { + ImplInitSettings( sal_True, sal_True, sal_True ); + Resize(); + Invalidate(); + } + else + Control::DataChanged( rDCEvt ); +} + +void VCLMultiLineEdit::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ) +{ + ImplInitSettings( sal_True, sal_True, sal_True ); + + Point aPos = pDev->LogicToPixel( rPos ); + Size aSize = pDev->LogicToPixel( rSize ); + Font aFont = pImpSvMEdit->GetTextWindow()->GetDrawPixelFont( pDev ); + aFont.SetTransparent( sal_True ); + OutDevType eOutDevType = pDev->GetOutDevType(); + + pDev->Push(); + pDev->SetMapMode(); + pDev->SetFont( aFont ); + pDev->SetTextFillColor(); + + // Border/Background + pDev->SetLineColor(); + pDev->SetFillColor(); + sal_Bool bBorder = !(nFlags & WINDOW_DRAW_NOBORDER ) && (GetStyle() & WB_BORDER); + sal_Bool bBackground = !(nFlags & WINDOW_DRAW_NOBACKGROUND) && IsControlBackground(); + if ( bBorder || bBackground ) + { + Rectangle aRect( aPos, aSize ); + if ( bBorder ) + { + DecorationView aDecoView( pDev ); + aRect = aDecoView.DrawFrame( aRect, FRAME_DRAW_DOUBLEIN ); + } + if ( bBackground ) + { + pDev->SetFillColor( GetControlBackground() ); + pDev->DrawRect( aRect ); + } + } + + // Inhalt + if ( ( nFlags & WINDOW_DRAW_MONO ) || ( eOutDevType == OUTDEV_PRINTER ) ) + pDev->SetTextColor( Color( COL_BLACK ) ); + else + { + if ( !(nFlags & WINDOW_DRAW_NODISABLE ) && !IsEnabled() ) + { + const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); + pDev->SetTextColor( rStyleSettings.GetDisableColor() ); + } + else + { + pDev->SetTextColor( GetTextColor() ); + } + } + + rtl::OUString aText = GetText(); + Size aTextSz( pDev->GetTextWidth( aText ), pDev->GetTextHeight() ); + sal_uLong nLines = (sal_uLong) (aSize.Height() / aTextSz.Height()); + if ( !nLines ) + nLines = 1; + aTextSz.Height() = nLines*aTextSz.Height(); + long nOnePixel = GetDrawPixel( pDev, 1 ); + long nOffX = 3*nOnePixel; + long nOffY = 2*nOnePixel; + + // Clipping? + if ( ( nOffY < 0 ) || ( (nOffY+aTextSz.Height()) > aSize.Height() ) || ( (nOffX+aTextSz.Width()) > aSize.Width() ) ) + { + Rectangle aClip( aPos, aSize ); + if ( aTextSz.Height() > aSize.Height() ) + aClip.Bottom() += aTextSz.Height() - aSize.Height() + 1; // Damit HP-Drucker nicht 'weg-optimieren' + pDev->IntersectClipRegion( aClip ); + } + + ExtTextEngine aTE; + aTE.SetText( GetText() ); + aTE.SetMaxTextWidth( aSize.Width() ); + aTE.SetFont( aFont ); + aTE.SetTextAlign( pImpSvMEdit->GetTextWindow()->GetTextEngine()->GetTextAlign() ); + aTE.Draw( pDev, Point( aPos.X() + nOffX, aPos.Y() + nOffY ) ); + + pDev->Pop(); +} + +long VCLMultiLineEdit::Notify( NotifyEvent& rNEvt ) +{ + long nDone = 0; + if( rNEvt.GetType() == EVENT_COMMAND ) + { + nDone = pImpSvMEdit->HandleCommand( *rNEvt.GetCommandEvent() ); + } + return nDone ? nDone : Edit::Notify( rNEvt ); +} + +long VCLMultiLineEdit::PreNotify( NotifyEvent& rNEvt ) +{ + long nDone = 0; + +#if (OSL_DEBUG_LEVEL > 1) && defined(DBG_UTIL) + if( rNEvt.GetType() == EVENT_KEYINPUT ) + { + const KeyEvent& rKEvent = *rNEvt.GetKeyEvent(); + if ( ( rKEvent.GetKeyCode().GetCode() == KEY_W ) && rKEvent.GetKeyCode().IsMod1() && rKEvent.GetKeyCode().IsMod2() ) + { + SetRightToLeft( !IsRightToLeft() ); + } + } +#endif + + if( ( rNEvt.GetType() == EVENT_KEYINPUT ) && ( !GetTextView()->IsCursorEnabled() ) ) + { + const KeyEvent& rKEvent = *rNEvt.GetKeyEvent(); + if ( !rKEvent.GetKeyCode().IsShift() && ( rKEvent.GetKeyCode().GetGroup() == KEYGROUP_CURSOR ) ) + { + nDone = 1; + TextSelection aSel = pImpSvMEdit->GetTextWindow()->GetTextView()->GetSelection(); + if ( aSel.HasRange() ) + { + aSel.GetStart() = aSel.GetEnd(); + pImpSvMEdit->GetTextWindow()->GetTextView()->SetSelection( aSel ); + } + else + { + switch ( rKEvent.GetKeyCode().GetCode() ) + { + case KEY_UP: + { + if ( pImpSvMEdit->GetVScrollBar() ) + pImpSvMEdit->GetVScrollBar()->DoScrollAction( SCROLL_LINEUP ); + } + break; + case KEY_DOWN: + { + if ( pImpSvMEdit->GetVScrollBar() ) + pImpSvMEdit->GetVScrollBar()->DoScrollAction( SCROLL_LINEDOWN ); + } + break; + case KEY_PAGEUP : + { + if ( pImpSvMEdit->GetVScrollBar() ) + pImpSvMEdit->GetVScrollBar()->DoScrollAction( SCROLL_PAGEUP ); + } + break; + case KEY_PAGEDOWN: + { + if ( pImpSvMEdit->GetVScrollBar() ) + pImpSvMEdit->GetVScrollBar()->DoScrollAction( SCROLL_PAGEDOWN ); + } + break; + case KEY_LEFT: + { + if ( pImpSvMEdit->GetHScrollBar() ) + pImpSvMEdit->GetHScrollBar()->DoScrollAction( SCROLL_LINEUP ); + } + break; + case KEY_RIGHT: + { + if ( pImpSvMEdit->GetHScrollBar() ) + pImpSvMEdit->GetHScrollBar()->DoScrollAction( SCROLL_LINEDOWN ); + } + break; + case KEY_HOME: + { + if ( rKEvent.GetKeyCode().IsMod1() ) + pImpSvMEdit->GetTextWindow()->GetTextView()-> + SetSelection( TextSelection( TextPaM( 0, 0 ) ) ); + } + break; + case KEY_END: + { + if ( rKEvent.GetKeyCode().IsMod1() ) + pImpSvMEdit->GetTextWindow()->GetTextView()-> + SetSelection( TextSelection( TextPaM( 0xFFFF, 0xFFFF ) ) ); + } + break; + default: + { + nDone = 0; + } + } + } + } + } + + return nDone ? nDone : Edit::PreNotify( rNEvt ); +} + +// +// Internas fuer abgeleitete Klassen, z.B. TextComponent + +ExtTextEngine* VCLMultiLineEdit::GetTextEngine() const +{ + return pImpSvMEdit->GetTextWindow()->GetTextEngine(); +} + +ExtTextView* VCLMultiLineEdit::GetTextView() const +{ + return pImpSvMEdit->GetTextWindow()->GetTextView(); +} + +ScrollBar* VCLMultiLineEdit::GetVScrollBar() const +{ + return pImpSvMEdit->GetVScrollBar(); +} + +void VCLMultiLineEdit::EnableFocusSelectionHide( sal_Bool bHide ) +{ + pImpSvMEdit->GetTextWindow()->SetAutoFocusHide( bHide ); +} + +void VCLMultiLineEdit::SetLeftMargin( sal_uInt16 n ) +{ + if ( GetTextEngine() ) + GetTextEngine()->SetLeftMargin( n ); +} + +void VCLMultiLineEdit::SetRightToLeft( sal_Bool bRightToLeft ) +{ + if ( GetTextEngine() ) + { + GetTextEngine()->SetRightToLeft( bRightToLeft ); + GetTextView()->ShowCursor(); + } +} + +sal_Bool VCLMultiLineEdit::IsRightToLeft() const +{ + sal_Bool bRightToLeft = sal_False; + + if ( GetTextEngine() ) + bRightToLeft = GetTextEngine()->IsRightToLeft(); + + return bRightToLeft; +} + +void VCLMultiLineEdit::DisableSelectionOnFocus() +{ + pImpSvMEdit->GetTextWindow()->DisableSelectionOnFocus(); +} + +void VCLMultiLineEdit::SetTextSelectable( sal_Bool bTextSelectable ) +{ + pImpSvMEdit->GetTextWindow()->SetTextSelectable( bTextSelectable ); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/edit/xtextedt.cxx b/vcl/source/edit/xtextedt.cxx index a02f6aa4b84a..c434ad0d776e 100644 --- a/svtools/source/edit/xtextedt.cxx +++ b/vcl/source/edit/xtextedt.cxx @@ -27,7 +27,7 @@ ************************************************************************/ -#include <svtools/xtextedt.hxx> +#include <vcl/xtextedt.hxx> #include <vcl/svapp.hxx> // International #include <unotools/textsearch.hxx> #include <com/sun/star/util/SearchOptions.hpp> diff --git a/vcl/source/window/msgbox.cxx b/vcl/source/window/msgbox.cxx index 7d49f3eb734b..2c20baba5da7 100644 --- a/vcl/source/window/msgbox.cxx +++ b/vcl/source/window/msgbox.cxx @@ -38,6 +38,7 @@ #include <vcl/svapp.hxx> #include <vcl/wrkwin.hxx> #include <vcl/fixed.hxx> +#include <vcl/vclmedit.hxx> #include <vcl/msgbox.hxx> #include <vcl/button.hxx> #include <vcl/mnemonic.hxx> @@ -66,7 +67,7 @@ static void ImplInitMsgBoxImageList() void MessBox::ImplInitMessBoxData() { - mpFixedText = NULL; + mpVCLMultiLineEdit = NULL; mpFixedImage = NULL; mbHelpBtn = sal_False; mpCheckBox = NULL; @@ -203,7 +204,7 @@ void MessBox::ImplLoadRes( const ResId& ) MessBox::~MessBox() { - delete mpFixedText; + delete mpVCLMultiLineEdit; delete mpFixedImage; delete mpCheckBox; } @@ -236,16 +237,16 @@ void MessBox::ImplPosControls() Point aTextPos( IMPL_DIALOG_OFFSET, IMPL_DIALOG_OFFSET+IMPL_MSGBOX_OFFSET_EXTRA_Y ); Size aImageSize; Size aPageSize; - Size aFixedSize; + Size aMEditSize; long nTitleWidth; long nButtonSize = ImplGetButtonSize(); long nMaxWidth = GetDesktopRectPixel().GetWidth()-8; long nMaxLineWidth; long nWidth; - WinBits nWinStyle = WB_LEFT | WB_WORDBREAK | WB_NOLABEL | WB_INFO; + WinBits nWinStyle = WB_LEFT | WB_WORDBREAK | WB_NOLABEL; sal_uInt16 nTextStyle = TEXT_DRAW_MULTILINE | TEXT_DRAW_TOP | TEXT_DRAW_LEFT; - delete mpFixedText; + delete mpVCLMultiLineEdit; if ( mpFixedImage ) { delete mpFixedImage; @@ -325,25 +326,27 @@ void MessBox::ImplPosControls() aFormatRect = GetTextRect( aRect, aMessText, nTextStyle, &aTextInfo ); } - // Style fuer FixedText ermitteln + // Style fuer VCLMultiLineEdit ermitteln + mpVCLMultiLineEdit = new VCLMultiLineEdit( this, nWinStyle ); + mpVCLMultiLineEdit->SetText( aMessText ); + aMEditSize = mpVCLMultiLineEdit->CalcMinimumSize(); + aPageSize.Width() = aImageSize.Width(); - aFixedSize.Width() = aTextInfo.GetMaxLineWidth()+1; - aFixedSize.Height() = aFormatRect.GetHeight(); - if ( aFixedSize.Height() < aImageSize.Height() ) + if ( aMEditSize.Height() < aImageSize.Height() ) { nWinStyle |= WB_VCENTER; aPageSize.Height() = aImageSize.Height(); - aFixedSize.Height() = aImageSize.Height(); + aMEditSize.Height() = aImageSize.Height(); } else { nWinStyle |= WB_TOP; - aPageSize.Height() = aFixedSize.Height(); + aPageSize.Height() = aMEditSize.Height(); } if ( aImageSize.Width() ) aPageSize.Width() += IMPL_SEP_MSGBOX_IMAGE; aPageSize.Width() += (IMPL_DIALOG_OFFSET*2)+(IMPL_MSGBOX_OFFSET_EXTRA_X*2); - aPageSize.Width() += aFixedSize.Width()+1; + aPageSize.Width() += aMEditSize.Width()+1; aPageSize.Height() += (IMPL_DIALOG_OFFSET*2)+(IMPL_MSGBOX_OFFSET_EXTRA_Y*2); if ( aPageSize.Width() < IMPL_MINSIZE_MSGBOX_WIDTH ) @@ -353,7 +356,7 @@ void MessBox::ImplPosControls() if ( maCheckBoxText.Len() ) { - Size aMinCheckboxSize ( aFixedSize ); + Size aMinCheckboxSize ( aMEditSize ); if ( aPageSize.Width() < IMPL_MINSIZE_MSGBOX_WIDTH+80 ) { aPageSize.Width() = IMPL_MINSIZE_MSGBOX_WIDTH+80; @@ -388,7 +391,7 @@ void MessBox::ImplPosControls() mpCheckBox->SetText( maCheckBoxText ); Point aPos( aTextPos ); - aPos.Y() += aFixedSize.Height() + (IMPL_DIALOG_OFFSET)+(IMPL_MSGBOX_OFFSET_EXTRA_Y*2); + aPos.Y() += aMEditSize.Height() + (IMPL_DIALOG_OFFSET)+(IMPL_MSGBOX_OFFSET_EXTRA_Y*2); // increase messagebox aPageSize.Height() += aSize.Height() + (IMPL_DIALOG_OFFSET*2)+(IMPL_MSGBOX_OFFSET_EXTRA_Y*2); @@ -397,12 +400,10 @@ void MessBox::ImplPosControls() mpCheckBox->Show(); } - mpFixedText = new FixedText( this, nWinStyle ); - if( mpFixedText->GetStyle() & WB_EXTRAOFFSET ) // TODO: use CalcMinimumSize() instead - aFixedSize.Width() += 2; - mpFixedText->SetPosSizePixel( aTextPos, aFixedSize ); - mpFixedText->SetText( aMessText ); - mpFixedText->Show(); + + mpVCLMultiLineEdit->SetPosSizePixel( aTextPos, aMEditSize ); + mpVCLMultiLineEdit->Show(); + mpVCLMultiLineEdit->SetPaintTransparent(sal_True); SetPageSizePixel( aPageSize ); } |