LibreOffice Module sw (master) 1
srcedtw.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19#ifndef INCLUDED_SW_SOURCE_UIBASE_INC_SRCEDTW_HXX
20#define INCLUDED_SW_SOURCE_UIBASE_INC_SRCEDTW_HXX
21
22#include <vcl/window.hxx>
23#include <svl/lstner.hxx>
24#include <vcl/timer.hxx>
25#include <vcl/idle.hxx>
26
27#include <vcl/xtextedt.hxx>
28#include <mutex>
29#include <set>
30
31namespace com::sun::star::beans { class XMultiPropertySet; }
32namespace weld { class Scrollbar; }
33class ScrollAdaptor;
34class SwSrcView;
35class SwSrcEditWindow;
36class TextEngine;
37class TextView;
39
40class TextViewOutWin final : public vcl::Window
41{
43
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;
51
52public:
54 Window(pParent, nBits), m_pTextView(nullptr){}
55
56 void SetTextView( TextView* pView ) {m_pTextView = pView;}
57
58};
59
60class SwSrcEditWindow final : public vcl::Window, public SfxListener
61{
62private:
63 class ChangesListener;
64 friend class ChangesListener;
65 std::unique_ptr<TextView> m_pTextView;
66 std::unique_ptr<ExtTextEngine> m_pTextEngine;
67
71
73
75 std::mutex mutex_;
76 css::uno::Reference< css::beans::XMultiPropertySet >
78
80 sal_uInt16 m_nStartLine;
81 rtl_TextEncoding m_eSourceEncoding;
84
86 std::set<sal_uInt16> m_aSyntaxLineTable;
87
88 void ImpDoHighlight( std::u16string_view aSource, sal_uInt16 nLineOff );
89
90 void SetFont();
91
92 DECL_LINK( SyntaxTimerHdl, Timer *, void );
93
94 using Window::Invalidate;
95
96 virtual void Resize() override;
97 virtual void DataChanged( const DataChangedEvent& ) override;
98 virtual void GetFocus() override;
99
100 void CreateTextEngine();
101 void DoSyntaxHighlight( sal_uInt16 nPara );
102
103 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
104
105 DECL_LINK(HorzScrollHdl, weld::Scrollbar&, void);
106 DECL_LINK(VertScrollHdl, weld::Scrollbar&, void);
107
108public:
109 SwSrcEditWindow( vcl::Window* pParent, SwSrcView* pParentView );
110 virtual ~SwSrcEditWindow() override;
111 virtual void dispose() override;
112
113 void SetScrollBarRanges();
114 void InitScrollBars();
115 void Read(SvStream& rInput) { m_pTextEngine->Read(rInput); }
116 void Write(SvStream& rOutput) { m_pTextEngine->Write(rOutput); }
117
119 {return m_pTextView.get();}
121 {return m_pTextEngine.get();}
123
125
126 virtual void Invalidate( InvalidateFlags nFlags = InvalidateFlags::NONE ) override;
127
129 { m_pTextEngine->SetModified(false); }
130 bool IsModified() const
131 { return m_pTextEngine->IsModified();}
132
133 void SetReadonly(bool bSet){m_bReadonly = bSet;}
134 bool IsReadonly() const {return m_bReadonly;}
135
136 void SetStartLine(sal_uInt16 nLine){m_nStartLine = nLine;}
137
138 virtual void Command( const CommandEvent& rCEvt ) override;
139 void HandleWheelCommand( const CommandEvent& rCEvt );
140
141 void SetTextEncoding(rtl_TextEncoding eEncoding);
142};
143
144#endif
145
146/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void ClearModifyFlag()
Definition: srcedtw.hxx:128
std::set< sal_uInt16 > m_aSyntaxLineTable
Definition: srcedtw.hxx:86
sal_uInt16 m_nStartLine
Definition: srcedtw.hxx:80
virtual void GetFocus() override
Definition: srcedtw.cxx:773
DECL_LINK(VertScrollHdl, weld::Scrollbar &, void)
virtual void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE) override
Definition: srcedtw.cxx:743
Idle m_aSyntaxIdle
Definition: srcedtw.hxx:85
std::unique_ptr< ExtTextEngine > m_pTextEngine
Definition: srcedtw.hxx:66
bool IsModified() const
Definition: srcedtw.hxx:130
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: srcedtw.cxx:711
SwSrcView * GetSrcView()
Definition: srcedtw.hxx:122
void HandleWheelCommand(const CommandEvent &rCEvt)
Definition: srcedtw.cxx:767
SwSrcView * m_pSrcView
Definition: srcedtw.hxx:72
VclPtr< ScrollAdaptor > m_pVScrollbar
Definition: srcedtw.hxx:70
TextView * GetTextView()
Definition: srcedtw.hxx:118
SwSrcEditWindow(vcl::Window *pParent, SwSrcView *pParentView)
Definition: srcedtw.cxx:226
DECL_LINK(HorzScrollHdl, weld::Scrollbar &, void)
void ImpDoHighlight(std::u16string_view aSource, sal_uInt16 nLineOff)
Definition: srcedtw.cxx:655
bool m_bHighlighting
Definition: srcedtw.hxx:83
virtual void DataChanged(const DataChangedEvent &) override
Definition: srcedtw.cxx:291
tools::Long m_nCurTextWidth
Definition: srcedtw.hxx:79
void SetFont()
Definition: srcedtw.cxx:938
void Read(SvStream &rInput)
Definition: srcedtw.hxx:115
rtl_TextEncoding m_eSourceEncoding
Definition: srcedtw.hxx:81
virtual ~SwSrcEditWindow() override
Definition: srcedtw.cxx:258
void SetScrollBarRanges()
Definition: srcedtw.cxx:533
TextViewOutWin * GetOutWin()
Definition: srcedtw.hxx:124
css::uno::Reference< css::beans::XMultiPropertySet > m_xNotifier
Definition: srcedtw.hxx:77
virtual void Command(const CommandEvent &rCEvt) override
Definition: srcedtw.cxx:749
rtl::Reference< ChangesListener > m_xListener
Definition: srcedtw.hxx:74
virtual void dispose() override
Definition: srcedtw.cxx:263
VclPtr< ScrollAdaptor > m_pHScrollbar
Definition: srcedtw.hxx:69
void DoSyntaxHighlight(sal_uInt16 nPara)
Definition: srcedtw.cxx:630
void Write(SvStream &rOutput)
Definition: srcedtw.hxx:116
TextEngine * GetTextEngine()
Definition: srcedtw.hxx:120
void SetReadonly(bool bSet)
Definition: srcedtw.hxx:133
void CreateTextEngine()
Definition: srcedtw.cxx:482
bool m_bReadonly
Definition: srcedtw.hxx:82
std::mutex mutex_
Definition: srcedtw.hxx:75
virtual void Resize() override
Definition: srcedtw.cxx:309
DECL_LINK(SyntaxTimerHdl, Timer *, void)
void SetStartLine(sal_uInt16 nLine)
Definition: srcedtw.hxx:136
std::unique_ptr< TextView > m_pTextView
Definition: srcedtw.hxx:65
VclPtr< TextViewOutWin > m_pOutWin
Definition: srcedtw.hxx:68
void InitScrollBars()
Definition: srcedtw.cxx:541
void SetTextEncoding(rtl_TextEncoding eEncoding)
Definition: srcedtw.cxx:976
bool IsReadonly() const
Definition: srcedtw.hxx:134
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &) override
Definition: srcedtw.cxx:477
virtual void MouseButtonUp(const MouseEvent &rMEvt) override
Definition: srcedtw.cxx:389
TextViewOutWin(vcl::Window *pParent, WinBits nBits)
Definition: srcedtw.hxx:53
virtual void DataChanged(const DataChangedEvent &) override
Definition: srcedtw.cxx:362
virtual void Command(const CommandEvent &rCEvt) override
Definition: srcedtw.cxx:412
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
Definition: srcedtw.cxx:405
TextView * m_pTextView
Definition: srcedtw.hxx:42
void SetTextView(TextView *pView)
Definition: srcedtw.hxx:56
virtual void MouseMove(const MouseEvent &rMEvt) override
Definition: srcedtw.cxx:383
virtual void KeyInput(const KeyEvent &rKeyEvt) override
Definition: srcedtw.cxx:439
Window(vcl::Window *pParent, WinBits nStyle=0)
long Long
InvalidateFlags
sal_Int64 WinBits