Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / source / uibase / inc / srcedtw.hxx
blobe0c728ff9031a08bd46430b573ac6976a064ba65
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_SW_SOURCE_UIBASE_INC_SRCEDTW_HXX
20 #define INCLUDED_SW_SOURCE_UIBASE_INC_SRCEDTW_HXX
22 #include <vcl/window.hxx>
23 #include <svl/lstner.hxx>
24 #include <vcl/timer.hxx>
25 #include <vcl/idle.hxx>
27 #include <vcl/xtextedt.hxx>
28 #include <mutex>
29 #include <set>
31 namespace com::sun::star::beans { class XMultiPropertySet; }
32 namespace weld { class Scrollbar; }
33 class ScrollAdaptor;
34 class SwSrcView;
35 class SwSrcEditWindow;
36 class TextEngine;
37 class TextView;
38 class DataChangedEvent;
40 class TextViewOutWin final : public vcl::Window
42 TextView* m_pTextView;
44 virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& ) override;
45 virtual void KeyInput( const KeyEvent& rKeyEvt ) override;
46 virtual void MouseMove( const MouseEvent& rMEvt ) override;
47 virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
48 virtual void MouseButtonUp( const MouseEvent& rMEvt ) override;
49 virtual void Command( const CommandEvent& rCEvt ) override;
50 virtual void DataChanged( const DataChangedEvent& ) override;
52 public:
53 TextViewOutWin(vcl::Window* pParent, WinBits nBits) :
54 Window(pParent, nBits), m_pTextView(nullptr){}
56 void SetTextView( TextView* pView ) {m_pTextView = pView;}
60 class SwSrcEditWindow final : public vcl::Window, public SfxListener
62 private:
63 class ChangesListener;
64 friend class ChangesListener;
65 std::unique_ptr<TextView> m_pTextView;
66 std::unique_ptr<ExtTextEngine> m_pTextEngine;
68 VclPtr<TextViewOutWin> m_pOutWin;
69 VclPtr<ScrollAdaptor> m_pHScrollbar,
70 m_pVScrollbar;
72 SwSrcView* m_pSrcView;
74 rtl::Reference< ChangesListener > m_xListener;
75 std::mutex mutex_;
76 css::uno::Reference< css::beans::XMultiPropertySet >
77 m_xNotifier;
79 tools::Long m_nCurTextWidth;
80 sal_uInt16 m_nStartLine;
81 rtl_TextEncoding m_eSourceEncoding;
82 bool m_bReadonly;
83 bool m_bHighlighting;
85 Idle m_aSyntaxIdle;
86 std::set<sal_uInt16> m_aSyntaxLineTable;
88 void ImpDoHighlight( std::u16string_view aSource, sal_uInt16 nLineOff );
90 void SetFont();
92 DECL_LINK( SyntaxTimerHdl, Timer *, void );
94 using Window::Invalidate;
96 virtual void Resize() override;
97 virtual void DataChanged( const DataChangedEvent& ) override;
98 virtual void GetFocus() override;
100 void CreateTextEngine();
101 void DoSyntaxHighlight( sal_uInt16 nPara );
103 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
105 DECL_LINK(HorzScrollHdl, weld::Scrollbar&, void);
106 DECL_LINK(VertScrollHdl, weld::Scrollbar&, void);
108 public:
109 SwSrcEditWindow( vcl::Window* pParent, SwSrcView* pParentView );
110 virtual ~SwSrcEditWindow() override;
111 virtual void dispose() override;
113 void SetScrollBarRanges();
114 void InitScrollBars();
115 void Read(SvStream& rInput) { m_pTextEngine->Read(rInput); }
116 void Write(SvStream& rOutput) { m_pTextEngine->Write(rOutput); }
118 TextView* GetTextView()
119 {return m_pTextView.get();}
120 TextEngine* GetTextEngine()
121 {return m_pTextEngine.get();}
122 SwSrcView* GetSrcView() {return m_pSrcView;}
124 TextViewOutWin* GetOutWin() {return m_pOutWin;}
126 virtual void Invalidate( InvalidateFlags nFlags = InvalidateFlags::NONE ) override;
128 void ClearModifyFlag()
129 { m_pTextEngine->SetModified(false); }
130 bool IsModified() const
131 { return m_pTextEngine->IsModified();}
133 void SetReadonly(bool bSet){m_bReadonly = bSet;}
134 bool IsReadonly() const {return m_bReadonly;}
136 void SetStartLine(sal_uInt16 nLine){m_nStartLine = nLine;}
138 virtual void Command( const CommandEvent& rCEvt ) override;
139 void HandleWheelCommand( const CommandEvent& rCEvt );
141 void SetTextEncoding(rtl_TextEncoding eEncoding);
144 #endif
146 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */