basctl/source/basicide/baside2.cxx | 4 basctl/source/basicide/baside2.hxx | 16 - basctl/source/basicide/baside2b.cxx | 4 compilerplugins/clang/mergeclasses.results | 1 desktop/source/deployment/gui/license_dialog.cxx | 2 include/vcl/texteng.hxx | 1 include/vcl/textview.hxx | 37 +++- include/vcl/vclmedit.hxx | 4 include/vcl/xtextedt.hxx | 18 -- sw/source/ui/dbui/mmaddressblockpage.cxx | 16 - sw/source/uibase/docvw/srcedtw.cxx | 2 sw/source/uibase/inc/srcedtw.hxx | 10 - sw/source/uibase/uiview/srcview.cxx | 2 vcl/source/edit/textview.cxx | 189 +++++++++++++++++++++-- vcl/source/edit/vclmedit.cxx | 8 vcl/source/edit/xtextedt.cxx | 181 ---------------------- 16 files changed, 240 insertions(+), 255 deletions(-)
New commits: commit 3223c551c37c6b10b5b7de23ffa4520d720338b6 Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Fri Oct 14 14:35:04 2016 +0200 loplugin:mergeclasses merge TextView with ExtTextView Change-Id: If7e11dd8f6b2cb6dc19c6aa3f7e50e2e88861eac Reviewed-on: https://gerrit.libreoffice.org/29828 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx index 7ece041..9d3f9cf 100644 --- a/basctl/source/basicide/baside2.cxx +++ b/basctl/source/basicide/baside2.cxx @@ -560,7 +560,7 @@ void ModulWindow::BasicToggleBreakPointEnabled() { AssertValidEditEngine(); - ExtTextView* pView = GetEditView(); + TextView* pView = GetEditView(); if ( pView ) { TextSelection aSel = pView->GetSelection(); @@ -1211,7 +1211,7 @@ sal_uInt16 ModulWindow::StartSearchAndReplace( const SvxSearchItem& rSearchItem, // one could also relinquish syntaxhighlighting/formatting instead of the stupid replace-everything... AssertValidEditEngine(); - ExtTextView* pView = GetEditView(); + TextView* pView = GetEditView(); TextSelection aSel; if ( bFromStart ) { diff --git a/basctl/source/basicide/baside2.hxx b/basctl/source/basicide/baside2.hxx index c8bf2e6..9a51560 100644 --- a/basctl/source/basicide/baside2.hxx +++ b/basctl/source/basicide/baside2.hxx @@ -26,9 +26,6 @@ #include "breakpoint.hxx" #include "linenumberwindow.hxx" -class ExtTextEngine; -class ExtTextView; -class SvxSearchItem; #include <svtools/svtabbx.hxx> #include <svtools/headbar.hxx> @@ -50,6 +47,9 @@ class SvxSearchItem; #include <comphelper/syntaxhighlight.hxx> #include <com/sun/star/reflection/XIdlReflection.hpp> +class ExtTextEngine; +class TextView; +class SvxSearchItem; namespace com { namespace sun { namespace star { namespace beans { class XMultiPropertySet; } } } } @@ -74,8 +74,8 @@ friend class CodeCompleteListBox; private: class ChangesListener; - std::unique_ptr<ExtTextView> pEditView; - std::unique_ptr<ExtTextEngine> pEditEngine; + std::unique_ptr<TextView> pEditView; + std::unique_ptr<ExtTextEngine> pEditEngine; ModulWindow& rModulWindow; rtl::Reference< ChangesListener > listener_; @@ -139,7 +139,7 @@ public: virtual void dispose() override; ExtTextEngine* GetEditEngine() const { return pEditEngine.get(); } - ExtTextView* GetEditView() const { return pEditView.get(); } + TextView* GetEditView() const { return pEditView.get(); } void CreateProgress( const OUString& rText, sal_uLong nRange ); void DestroyProgress(); @@ -389,7 +389,7 @@ public: LineNumberWindow& GetLineNumberWindow() { return m_aXEditorWindow->GetLineNumberWindow(); } ScrollBar& GetEditVScrollBar() { return m_aXEditorWindow->GetEWVScrollBar(); } ExtTextEngine* GetEditEngine() { return GetEditorWindow().GetEditEngine(); } - ExtTextView* GetEditView() { return GetEditorWindow().GetEditView(); } + TextView* GetEditView() { return GetEditorWindow().GetEditView(); } BreakPointList& GetBreakPoints() { return GetBreakPointWindow().GetBreakPoints(); } ModulWindowLayout& GetLayout () { return m_rLayout; } @@ -486,7 +486,7 @@ private: void SetMatchingEntries(); // sets the visible entries based on aFuncBuffer variable void HideAndRestoreFocus(); - ExtTextView* GetParentEditView(); + TextView* GetParentEditView(); public: explicit CodeCompleteListBox( CodeCompleteWindow* pPar ); diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx index d02782e..64003b6 100644 --- a/basctl/source/basicide/baside2b.cxx +++ b/basctl/source/basicide/baside2b.cxx @@ -954,7 +954,7 @@ void EditorWindow::CreateEditEngine() return; pEditEngine.reset(new ExtTextEngine); - pEditView.reset(new ExtTextView(pEditEngine.get(), this)); + pEditView.reset(new TextView(pEditEngine.get(), this)); pEditView->SetAutoIndentMode(true); pEditEngine->SetUpdateMode(false); pEditEngine->InsertView(pEditView.get()); @@ -2632,7 +2632,7 @@ IMPL_LINK_NOARG(CodeCompleteListBox, ImplSelectHdl, ListBox&, void) pCodeCompleteWindow->pParent->GrabFocus(); } -ExtTextView* CodeCompleteListBox::GetParentEditView() +TextView* CodeCompleteListBox::GetParentEditView() { return pCodeCompleteWindow->pParent->GetEditView(); } diff --git a/compilerplugins/clang/mergeclasses.results b/compilerplugins/clang/mergeclasses.results index 442ba92..096d79a 100644 --- a/compilerplugins/clang/mergeclasses.results +++ b/compilerplugins/clang/mergeclasses.results @@ -162,7 +162,6 @@ merge SwXParagraphEnumeration with SwXParagraphEnumerationImpl merge SwXTextRanges with SwXTextRangesImpl merge TextObj with TextObjBinary merge TextRenderImpl with CairoTextRender -merge TextView with ExtTextView merge UniqueIndexImpl with UniqueIndex merge ValueGetter with CellValueGetter merge ValueSetter with CellValueSetter diff --git a/desktop/source/deployment/gui/license_dialog.cxx b/desktop/source/deployment/gui/license_dialog.cxx index 6540181..801d7f0 100644 --- a/desktop/source/deployment/gui/license_dialog.cxx +++ b/desktop/source/deployment/gui/license_dialog.cxx @@ -157,7 +157,7 @@ bool LicenseView::IsEndReached() const { bool bEndReached; - ExtTextView* pView = GetTextView(); + TextView* pView = GetTextView(); ExtTextEngine* pEdit = GetTextEngine(); const long nHeight = pEdit->GetTextHeight(); Size aOutSize = pView->GetWindow()->GetOutputSizePixel(); diff --git a/include/vcl/texteng.hxx b/include/vcl/texteng.hxx index 5a13c23..f9d3e19 100644 --- a/include/vcl/texteng.hxx +++ b/include/vcl/texteng.hxx @@ -79,7 +79,6 @@ class VCL_DLLPUBLIC TextEngine : public SfxBroadcaster friend class TextView; friend class TextSelFunctionSet; friend class ExtTextEngine; - friend class ExtTextView; friend class TextUndo; friend class TextUndoManager; diff --git a/include/vcl/textview.hxx b/include/vcl/textview.hxx index 6eef0f9..efb197e 100644 --- a/include/vcl/textview.hxx +++ b/include/vcl/textview.hxx @@ -39,11 +39,18 @@ class SelectionEngine; class VirtualDevice; struct TextDDInfo; -namespace com { namespace sun { namespace star { namespace datatransfer { namespace clipboard { - class XClipboard; -}}}}} +namespace com { namespace sun { namespace star { + namespace datatransfer { namespace clipboard { + class XClipboard; + } } + namespace util { + struct SearchOptions; + } +}}} + struct ImpTextView; +class ExtTextEngine; class VCL_DLLPUBLIC TextView : public vcl::unohelper::DragAndDropClient { @@ -51,7 +58,6 @@ class VCL_DLLPUBLIC TextView : public vcl::unohelper::DragAndDropClient friend class TextUndo; friend class TextUndoManager; friend class TextSelFunctionSet; - friend class ExtTextView; private: std::unique_ptr<ImpTextView> mpImpl; @@ -60,6 +66,7 @@ private: TextView& operator=( const TextView& ) = delete; protected: + bool ImpIndentBlock( bool bRight ); void ShowSelection(); void HideSelection(); void ShowSelection( const TextSelection& rSel ); @@ -95,7 +102,7 @@ protected: using DragAndDropClient::dragOver; public: - TextView( TextEngine* pEng, vcl::Window* pWindow ); + TextView( ExtTextEngine* pEng, vcl::Window* pWindow ); virtual ~TextView() override; TextEngine* GetTextEngine() const; @@ -139,7 +146,7 @@ public: void Undo(); void Redo(); - bool Read( SvStream& rInput ); + bool Read( SvStream& rInput ); void SetStartDocPos( const Point& rPos ); const Point& GetStartDocPos() const; @@ -148,18 +155,18 @@ public: Point GetWindowPos( const Point& rDocPos ) const; void SetInsertMode( bool bInsert ); - bool IsInsertMode() const; + bool IsInsertMode() const; void SetAutoIndentMode( bool bAutoIndent ); void SetReadOnly( bool bReadOnly ); - bool IsReadOnly() const; + bool IsReadOnly() const; void SetAutoScroll( bool bAutoScroll ); - bool IsAutoScroll() const; + bool IsAutoScroll() const; - bool SetCursorAtPoint( const Point& rPointPixel ); - bool IsSelectionAtPoint( const Point& rPointPixel ); + bool SetCursorAtPoint( const Point& rPointPixel ); + bool IsSelectionAtPoint( const Point& rPointPixel ); void SetPaintSelection( bool bPaint); @@ -194,6 +201,14 @@ public: if enabled, -1 otherwise. */ sal_Int32 GetLineNumberOfCursorInSelection() const; + + bool MatchGroup(); + + bool Search( const css::util::SearchOptions& rSearchOptions, bool bForward ); + sal_uInt16 Replace( const css::util::SearchOptions& rSearchOptions, bool bAll, bool bForward ); + + bool IndentBlock(); + bool UnindentBlock(); }; #endif diff --git a/include/vcl/vclmedit.hxx b/include/vcl/vclmedit.hxx index f89447f..84b5a6b 100644 --- a/include/vcl/vclmedit.hxx +++ b/include/vcl/vclmedit.hxx @@ -28,7 +28,7 @@ class ImpVclMEdit; class Timer; class ExtTextEngine; -class ExtTextView; +class TextView; class VCL_DLLPUBLIC VclMultiLineEdit : public Edit { @@ -53,7 +53,7 @@ protected: static WinBits ImplInitStyle( WinBits nStyle ); ExtTextEngine* GetTextEngine() const; - ExtTextView* GetTextView() const; + TextView* GetTextView() const; ScrollBar* GetVScrollBar() const; virtual void ApplySettings(vcl::RenderContext& rRenderContext) override; diff --git a/include/vcl/xtextedt.hxx b/include/vcl/xtextedt.hxx index 565872e..3db5f6c 100644 --- a/include/vcl/xtextedt.hxx +++ b/include/vcl/xtextedt.hxx @@ -43,24 +43,6 @@ public: bool Search( TextSelection& rSel, const css::util::SearchOptions& rSearchOptions, bool bForward = true ); }; -class VCL_DLLPUBLIC ExtTextView : public TextView -{ -protected: - bool ImpIndentBlock( bool bRight ); - -public: - ExtTextView( ExtTextEngine* pEng, vcl::Window* pWindow ); - virtual ~ExtTextView() override; - - bool MatchGroup(); - - bool Search( const css::util::SearchOptions& rSearchOptions, bool bForward ); - sal_uInt16 Replace( const css::util::SearchOptions& rSearchOptions, bool bAll, bool bForward ); - - bool IndentBlock(); - bool UnindentBlock(); -}; - #endif // INCLUDED_VCL_XTEXTEDT_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/dbui/mmaddressblockpage.cxx b/sw/source/ui/dbui/mmaddressblockpage.cxx index cbb9362..105fab5 100644 --- a/sw/source/ui/dbui/mmaddressblockpage.cxx +++ b/sw/source/ui/dbui/mmaddressblockpage.cxx @@ -1423,7 +1423,7 @@ void AddressMultiLineEdit::SetText( const OUString& rStr ) void AddressMultiLineEdit::InsertNewEntry( const OUString& rStr ) { // insert new entry after current selected one. - ExtTextView* pTextView = GetTextView(); + TextView* pTextView = GetTextView(); const TextSelection& rSelection = pTextView->GetSelection(); const sal_uInt32 nPara = rSelection.GetStart().GetPara(); sal_Int32 nIndex = rSelection.GetEnd().GetIndex(); @@ -1453,7 +1453,7 @@ void AddressMultiLineEdit::InsertNewEntryAtPosition( const OUString& rStr, sal_u SetText( GetAddress() ); //select the newly inserted/moved element TextSelection aEntrySel(aInsertPos); - ExtTextView* pTextView = GetTextView(); + TextView* pTextView = GetTextView(); pTextView->SetSelection(aEntrySel); m_aSelectionLink.Call(*this); } @@ -1461,7 +1461,7 @@ void AddressMultiLineEdit::InsertNewEntryAtPosition( const OUString& rStr, sal_u void AddressMultiLineEdit::RemoveCurrentEntry() { ExtTextEngine* pTextEngine = GetTextEngine(); - ExtTextView* pTextView = GetTextView(); + TextView* pTextView = GetTextView(); const TextSelection& rSelection = pTextView->GetSelection(); const TextCharAttrib* pBeginAttrib = pTextEngine->FindCharAttrib( rSelection.GetStart(), TEXTATTR_PROTECTED ); if(pBeginAttrib && @@ -1480,7 +1480,7 @@ void AddressMultiLineEdit::RemoveCurrentEntry() void AddressMultiLineEdit::MoveCurrentItem(MoveItemFlags nMove) { ExtTextEngine* pTextEngine = GetTextEngine(); - ExtTextView* pTextView = GetTextView(); + TextView* pTextView = GetTextView(); const TextSelection& rSelection = pTextView->GetSelection(); const TextCharAttrib* pBeginAttrib = pTextEngine->FindCharAttrib( rSelection.GetStart(), TEXTATTR_PROTECTED ); if(pBeginAttrib && @@ -1555,7 +1555,7 @@ MoveItemFlags AddressMultiLineEdit::IsCurrentItemMoveable() { MoveItemFlags nRet = MoveItemFlags::NONE; ExtTextEngine* pTextEngine = GetTextEngine(); - ExtTextView* pTextView = GetTextView(); + TextView* pTextView = GetTextView(); const TextSelection& rSelection = pTextView->GetSelection(); const TextCharAttrib* pBeginAttrib = pTextEngine->FindCharAttrib( rSelection.GetStart(), TEXTATTR_PROTECTED ); if(pBeginAttrib && @@ -1575,7 +1575,7 @@ MoveItemFlags AddressMultiLineEdit::IsCurrentItemMoveable() bool AddressMultiLineEdit::HasCurrentItem() { ExtTextEngine* pTextEngine = GetTextEngine(); - ExtTextView* pTextView = GetTextView(); + TextView* pTextView = GetTextView(); const TextSelection& rSelection = pTextView->GetSelection(); const TextCharAttrib* pBeginAttrib = pTextEngine->FindCharAttrib( rSelection.GetStart(), TEXTATTR_PROTECTED ); return (pBeginAttrib && @@ -1586,7 +1586,7 @@ bool AddressMultiLineEdit::HasCurrentItem() OUString AddressMultiLineEdit::GetCurrentItem() { ExtTextEngine* pTextEngine = GetTextEngine(); - ExtTextView* pTextView = GetTextView(); + TextView* pTextView = GetTextView(); const TextSelection& rSelection = pTextView->GetSelection(); const TextCharAttrib* pBeginAttrib = pTextEngine->FindCharAttrib( rSelection.GetStart(), TEXTATTR_PROTECTED ); if(pBeginAttrib && @@ -1603,7 +1603,7 @@ OUString AddressMultiLineEdit::GetCurrentItem() void AddressMultiLineEdit::SelectCurrentItem() { ExtTextEngine* pTextEngine = GetTextEngine(); - ExtTextView* pTextView = GetTextView(); + TextView* pTextView = GetTextView(); const TextSelection& rSelection = pTextView->GetSelection(); const TextCharAttrib* pBeginAttrib = pTextEngine->FindCharAttrib( rSelection.GetStart(), TEXTATTR_PROTECTED ); if(pBeginAttrib && diff --git a/sw/source/uibase/docvw/srcedtw.cxx b/sw/source/uibase/docvw/srcedtw.cxx index 95865fe..8f2e3bf 100644 --- a/sw/source/uibase/docvw/srcedtw.cxx +++ b/sw/source/uibase/docvw/srcedtw.cxx @@ -519,7 +519,7 @@ void SwSrcEditWindow::CreateTextEngine() m_pVScrollbar->Show(); m_pTextEngine = new ExtTextEngine; - m_pTextView = new ExtTextView( m_pTextEngine, m_pOutWin ); + m_pTextView = new TextView( m_pTextEngine, m_pOutWin ); m_pTextView->SetAutoIndentMode(true); m_pOutWin->SetTextView(m_pTextView); diff --git a/sw/source/uibase/inc/srcedtw.hxx b/sw/source/uibase/inc/srcedtw.hxx index c78199b..ca5aa38 100644 --- a/sw/source/uibase/inc/srcedtw.hxx +++ b/sw/source/uibase/inc/srcedtw.hxx @@ -35,12 +35,12 @@ class ScrollBar; class SwSrcView; class SwSrcEditWindow; class TextEngine; -class ExtTextView; +class TextView; class DataChangedEvent; class TextViewOutWin : public vcl::Window { - ExtTextView* pTextView; + TextView* pTextView; protected: virtual void Paint( vcl::RenderContext& rRenderContext, const Rectangle& ) override; @@ -55,7 +55,7 @@ public: TextViewOutWin(vcl::Window* pParent, WinBits nBits) : Window(pParent, nBits), pTextView(nullptr){} - void SetTextView( ExtTextView* pView ) {pTextView = pView;} + void SetTextView( TextView* pView ) {pTextView = pView;} }; @@ -64,7 +64,7 @@ class SwSrcEditWindow : public vcl::Window, public SfxListener private: class ChangesListener; friend class ChangesListener; - ExtTextView* m_pTextView; + TextView* m_pTextView; ExtTextEngine* m_pTextEngine; VclPtr<TextViewOutWin> m_pOutWin; @@ -121,7 +121,7 @@ public: void Read(SvStream& rInput) { m_pTextEngine->Read(rInput); } void Write(SvStream& rOutput) { m_pTextEngine->Write(rOutput); } - ExtTextView* GetTextView() + TextView* GetTextView() {return m_pTextView;} TextEngine* GetTextEngine() {return m_pTextEngine;} diff --git a/sw/source/uibase/uiview/srcview.cxx b/sw/source/uibase/uiview/srcview.cxx index 554645d..4967023 100644 --- a/sw/source/uibase/uiview/srcview.cxx +++ b/sw/source/uibase/uiview/srcview.cxx @@ -570,7 +570,7 @@ void SwSrcView::StartSearchAndReplace(const SvxSearchItem& rSearchItem, bool bApi, bool bRecursive) { - ExtTextView* pTextView = aEditWin->GetTextView(); + TextView* pTextView = aEditWin->GetTextView(); TextSelection aSel; TextPaM aPaM; diff --git a/vcl/source/edit/textview.cxx b/vcl/source/edit/textview.cxx index 4893d30..81d0906 100644 --- a/vcl/source/edit/textview.cxx +++ b/vcl/source/edit/textview.cxx @@ -22,6 +22,7 @@ #include <vcl/settings.hxx> #include <textdoc.hxx> #include <vcl/textdata.hxx> +#include <vcl/xtextedt.hxx> #include <textdat2.hxx> #include <svl/undo.hxx> @@ -33,22 +34,21 @@ #include <sot/formats.hxx> #include <svl/urlbmk.hxx> -#include <com/sun/star/i18n/XBreakIterator.hpp> - -#include <com/sun/star/i18n/CharacterIteratorMode.hpp> - -#include <com/sun/star/i18n/WordType.hpp> #include <cppuhelper/weak.hxx> #include <cppuhelper/queryinterface.hxx> #include <vcl/unohelp.hxx> +#include <com/sun/star/i18n/XBreakIterator.hpp> +#include <com/sun/star/i18n/CharacterIteratorMode.hpp> +#include <com/sun/star/i18n/WordType.hpp> #include <com/sun/star/datatransfer/XTransferable.hpp> #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp> #include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> - #include <com/sun/star/datatransfer/dnd/DNDConstants.hpp> #include <com/sun/star/datatransfer/dnd/XDragGestureRecognizer.hpp> #include <com/sun/star/datatransfer/dnd/XDropTarget.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/util/SearchOptions.hpp> +#include <com/sun/star/util/SearchFlags.hpp> #include <vcl/edit.hxx> @@ -145,7 +145,7 @@ sal_Bool TETextDataObject::isDataFlavorSupported( const css::datatransfer::DataF struct ImpTextView { - TextEngine* mpTextEngine; + ExtTextEngine* mpTextEngine; VclPtr<vcl::Window> mpWindow; TextSelection maSelection; @@ -177,7 +177,7 @@ struct ImpTextView bool mbCursorAtEndOfLine; }; -TextView::TextView( TextEngine* pEng, vcl::Window* pWindow ) : +TextView::TextView( ExtTextEngine* pEng, vcl::Window* pWindow ) : mpImpl(new ImpTextView) { pWindow->EnableRTL( false ); @@ -2247,4 +2247,175 @@ bool TextView::IsInsertMode() const void TextView::SupportProtectAttribute(bool bSupport) { mpImpl->mbSupportProtectAttribute = bSupport;} +bool TextView::MatchGroup() +{ + TextSelection aTmpSel( GetSelection() ); + aTmpSel.Justify(); + if ( ( aTmpSel.GetStart().GetPara() != aTmpSel.GetEnd().GetPara() ) || + ( ( aTmpSel.GetEnd().GetIndex() - aTmpSel.GetStart().GetIndex() ) > 1 ) ) + { + return false; + } + + TextSelection aMatchSel = static_cast<ExtTextEngine*>(GetTextEngine())->MatchGroup( aTmpSel.GetStart() ); + if ( aMatchSel.HasRange() ) + SetSelection( aMatchSel ); + + return aMatchSel.HasRange(); +} + +bool TextView::Search( const css::util::SearchOptions& rSearchOptions, bool bForward ) +{ + bool bFound = false; + TextSelection aSel( GetSelection() ); + if ( static_cast<ExtTextEngine*>(GetTextEngine())->Search( aSel, rSearchOptions, bForward ) ) + { + bFound = true; + // First add the beginning of the word to the selection, + // so that the whole word is in the visible region. + SetSelection( aSel.GetStart() ); + ShowCursor( true, false ); + } + else + { + aSel = GetSelection().GetEnd(); + } + + SetSelection( aSel ); + ShowCursor(); + + return bFound; +} + +sal_uInt16 TextView::Replace( const css::util::SearchOptions& rSearchOptions, bool bAll, bool bForward ) +{ + sal_uInt16 nFound = 0; + + if ( !bAll ) + { + if ( GetSelection().HasRange() ) + { + InsertText( rSearchOptions.replaceString ); + nFound = 1; + Search( rSearchOptions, bForward ); // right away to the next + } + else + { + if( Search( rSearchOptions, bForward ) ) + nFound = 1; + } + } + else + { + // the writer replaces all, from beginning to end + + ExtTextEngine* pTextEngine = static_cast<ExtTextEngine*>(GetTextEngine()); + + // HideSelection(); + TextSelection aSel; + + bool bSearchInSelection = (0 != (rSearchOptions.searchFlag & css::util::SearchFlags::REG_NOT_BEGINOFLINE) ); + if ( bSearchInSelection ) + { + aSel = GetSelection(); + aSel.Justify(); + } + + TextSelection aSearchSel( aSel ); + + bool bFound = pTextEngine->Search( aSel, rSearchOptions ); + if ( bFound ) + pTextEngine->UndoActionStart(); + while ( bFound ) + { + nFound++; + + TextPaM aNewStart = pTextEngine->ImpInsertText( aSel, rSearchOptions.replaceString ); + aSel = aSearchSel; + aSel.GetStart() = aNewStart; + bFound = pTextEngine->Search( aSel, rSearchOptions ); + } + if ( nFound ) + { + SetSelection( aSel.GetStart() ); + pTextEngine->FormatAndUpdate( this ); + pTextEngine->UndoActionEnd(); + } + } + return nFound; +} + +bool TextView::ImpIndentBlock( bool bRight ) +{ + bool bDone = false; + + TextSelection aSel = GetSelection(); + aSel.Justify(); + + HideSelection(); + GetTextEngine()->UndoActionStart(); + + const sal_uInt32 nStartPara = aSel.GetStart().GetPara(); + sal_uInt32 nEndPara = aSel.GetEnd().GetPara(); + if ( aSel.HasRange() && !aSel.GetEnd().GetIndex() ) + { + nEndPara--; // do not indent + } + + for ( sal_uInt32 nPara = nStartPara; nPara <= nEndPara; ++nPara ) + { + if ( bRight ) + { + // add tabs + GetTextEngine()->ImpInsertText( TextPaM( nPara, 0 ), '\t' ); + bDone = true; + } + else + { + // remove Tabs/Blanks + OUString aText = GetTextEngine()->GetText( nPara ); + if ( !aText.isEmpty() && ( + ( aText[ 0 ] == '\t' ) || + ( aText[ 0 ] == ' ' ) ) ) + { + GetTextEngine()->ImpDeleteText( TextSelection( TextPaM( nPara, 0 ), TextPaM( nPara, 1 ) ) ); + bDone = true; + } + } + } + + GetTextEngine()->UndoActionEnd(); + + bool bRange = aSel.HasRange(); + if ( bRight ) + { + ++aSel.GetStart().GetIndex(); + if ( bRange && ( aSel.GetEnd().GetPara() == nEndPara ) ) + ++aSel.GetEnd().GetIndex(); + } + else + { + if ( aSel.GetStart().GetIndex() ) + --aSel.GetStart().GetIndex(); + if ( bRange && aSel.GetEnd().GetIndex() ) + --aSel.GetEnd().GetIndex(); + } + + ImpSetSelection( aSel ); + GetTextEngine()->FormatAndUpdate( this ); + + return bDone; +} + +bool TextView::IndentBlock() +{ + return ImpIndentBlock( true ); +} + +bool TextView::UnindentBlock() +{ + return ImpIndentBlock( false ); +} + + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/edit/vclmedit.cxx b/vcl/source/edit/vclmedit.cxx index 744abc2..38c72c6 100644 --- a/vcl/source/edit/vclmedit.cxx +++ b/vcl/source/edit/vclmedit.cxx @@ -35,7 +35,7 @@ class TextWindow : public vcl::Window { private: ExtTextEngine* mpExtTextEngine; - ExtTextView* mpExtTextView; + TextView* mpExtTextView; bool mbInMBDown; bool mbFocusSelectionHide; @@ -49,7 +49,7 @@ public: virtual void dispose() override; ExtTextEngine* GetTextEngine() const { return mpExtTextEngine; } - ExtTextView* GetTextView() const { return mpExtTextView; } + TextView* GetTextView() const { return mpExtTextView; } virtual void MouseMove( const MouseEvent& rMEvt ) override; virtual void MouseButtonDown( const MouseEvent& rMEvt ) override; @@ -715,7 +715,7 @@ TextWindow::TextWindow( vcl::Window* pParent ) : Window( pParent ) if( pParent->GetStyle() & WB_BORDER ) mpExtTextEngine->SetLeftMargin( 2 ); mpExtTextEngine->SetLocale( GetSettings().GetLanguageTag().getLocale() ); - mpExtTextView = new ExtTextView( mpExtTextEngine, this ); + mpExtTextView = new TextView( mpExtTextEngine, this ); mpExtTextEngine->InsertView( mpExtTextView ); mpExtTextEngine->EnableUndo( true ); mpExtTextView->ShowCursor(); @@ -1532,7 +1532,7 @@ ExtTextEngine* VclMultiLineEdit::GetTextEngine() const return pImpVclMEdit->GetTextWindow()->GetTextEngine(); } -ExtTextView* VclMultiLineEdit::GetTextView() const +TextView* VclMultiLineEdit::GetTextView() const { return pImpVclMEdit->GetTextWindow()->GetTextView(); } diff --git a/vcl/source/edit/xtextedt.cxx b/vcl/source/edit/xtextedt.cxx index 950ab6d..2a43f95 100644 --- a/vcl/source/edit/xtextedt.cxx +++ b/vcl/source/edit/xtextedt.cxx @@ -220,185 +220,4 @@ bool ExtTextEngine::Search( TextSelection& rSel, const util::SearchOptions& rSea return bFound; } -// class ExtTextView - -ExtTextView::ExtTextView( ExtTextEngine* pEng, vcl::Window* pWindow ) - : TextView( pEng, pWindow ) -{ -} - -ExtTextView::~ExtTextView() -{ -} - -bool ExtTextView::MatchGroup() -{ - TextSelection aTmpSel( GetSelection() ); - aTmpSel.Justify(); - if ( ( aTmpSel.GetStart().GetPara() != aTmpSel.GetEnd().GetPara() ) || - ( ( aTmpSel.GetEnd().GetIndex() - aTmpSel.GetStart().GetIndex() ) > 1 ) ) - { - return false; - } - - TextSelection aMatchSel = static_cast<ExtTextEngine*>(GetTextEngine())->MatchGroup( aTmpSel.GetStart() ); - if ( aMatchSel.HasRange() ) - SetSelection( aMatchSel ); - - return aMatchSel.HasRange(); -} - -bool ExtTextView::Search( const util::SearchOptions& rSearchOptions, bool bForward ) -{ - bool bFound = false; - TextSelection aSel( GetSelection() ); - if ( static_cast<ExtTextEngine*>(GetTextEngine())->Search( aSel, rSearchOptions, bForward ) ) - { - bFound = true; - // First add the beginning of the word to the selection, - // so that the whole word is in the visible region. - SetSelection( aSel.GetStart() ); - ShowCursor( true, false ); - } - else - { - aSel = GetSelection().GetEnd(); - } - - SetSelection( aSel ); - ShowCursor(); - - return bFound; -} - -sal_uInt16 ExtTextView::Replace( const util::SearchOptions& rSearchOptions, bool bAll, bool bForward ) -{ - sal_uInt16 nFound = 0; - - if ( !bAll ) - { - if ( GetSelection().HasRange() ) - { - InsertText( rSearchOptions.replaceString ); - nFound = 1; - Search( rSearchOptions, bForward ); // right away to the next - } - else - { - if( Search( rSearchOptions, bForward ) ) - nFound = 1; - } - } - else - { - // the writer replaces all, from beginning to end - - ExtTextEngine* pTextEngine = static_cast<ExtTextEngine*>(GetTextEngine()); - - // HideSelection(); - TextSelection aSel; - - bool bSearchInSelection = (0 != (rSearchOptions.searchFlag & util::SearchFlags::REG_NOT_BEGINOFLINE) ); - if ( bSearchInSelection ) - { - aSel = GetSelection(); - aSel.Justify(); - } - - TextSelection aSearchSel( aSel ); - - bool bFound = pTextEngine->Search( aSel, rSearchOptions ); - if ( bFound ) - pTextEngine->UndoActionStart(); - while ( bFound ) - { - nFound++; - - TextPaM aNewStart = pTextEngine->ImpInsertText( aSel, rSearchOptions.replaceString ); - aSel = aSearchSel; - aSel.GetStart() = aNewStart; - bFound = pTextEngine->Search( aSel, rSearchOptions ); - } - if ( nFound ) - { - SetSelection( aSel.GetStart() ); - pTextEngine->FormatAndUpdate( this ); - pTextEngine->UndoActionEnd(); - } - } - return nFound; -} - -bool ExtTextView::ImpIndentBlock( bool bRight ) -{ - bool bDone = false; - - TextSelection aSel = GetSelection(); - aSel.Justify(); - - HideSelection(); - GetTextEngine()->UndoActionStart(); - - const sal_uInt32 nStartPara = aSel.GetStart().GetPara(); - sal_uInt32 nEndPara = aSel.GetEnd().GetPara(); - if ( aSel.HasRange() && !aSel.GetEnd().GetIndex() ) - { - nEndPara--; // do not indent - } - - for ( sal_uInt32 nPara = nStartPara; nPara <= nEndPara; ++nPara ) - { - if ( bRight ) - { - // add tabs - GetTextEngine()->ImpInsertText( TextPaM( nPara, 0 ), '\t' ); - bDone = true; - } - else - { - // remove Tabs/Blanks - OUString aText = GetTextEngine()->GetText( nPara ); - if ( !aText.isEmpty() && ( - ( aText[ 0 ] == '\t' ) || - ( aText[ 0 ] == ' ' ) ) ) - { - GetTextEngine()->ImpDeleteText( TextSelection( TextPaM( nPara, 0 ), TextPaM( nPara, 1 ) ) ); - bDone = true; - } - } - } - - GetTextEngine()->UndoActionEnd(); - - bool bRange = aSel.HasRange(); - if ( bRight ) - { - ++aSel.GetStart().GetIndex(); - if ( bRange && ( aSel.GetEnd().GetPara() == nEndPara ) ) - ++aSel.GetEnd().GetIndex(); - } - else - { - if ( aSel.GetStart().GetIndex() ) - --aSel.GetStart().GetIndex(); - if ( bRange && aSel.GetEnd().GetIndex() ) - --aSel.GetEnd().GetIndex(); - } - - ImpSetSelection( aSel ); - GetTextEngine()->FormatAndUpdate( this ); - - return bDone; -} - -bool ExtTextView::IndentBlock() -{ - return ImpIndentBlock( true ); -} - -bool ExtTextView::UnindentBlock() -{ - return ImpIndentBlock( false ); -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits