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 <set>
29 
30 namespace com { namespace sun { namespace star { namespace beans {
31  class XMultiPropertySet;
32 } } } }
33 
34 class ScrollBar;
35 class SwSrcView;
36 class SwSrcEditWindow;
37 class TextEngine;
38 class TextView;
39 class DataChangedEvent;
40 
42 {
44 
45 protected:
46  virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& ) override;
47  virtual void KeyInput( const KeyEvent& rKeyEvt ) override;
48  virtual void MouseMove( const MouseEvent& rMEvt ) override;
49  virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
50  virtual void MouseButtonUp( const MouseEvent& rMEvt ) override;
51  virtual void Command( const CommandEvent& rCEvt ) override;
52  virtual void DataChanged( const DataChangedEvent& ) override;
53 
54 public:
55  TextViewOutWin(vcl::Window* pParent, WinBits nBits) :
56  Window(pParent, nBits), pTextView(nullptr){}
57 
58  void SetTextView( TextView* pView ) {pTextView = pView;}
59 
60 };
61 
62 class SwSrcEditWindow : public vcl::Window, public SfxListener
63 {
64 private:
66  friend class ChangesListener;
67  std::unique_ptr<TextView> m_pTextView;
68  std::unique_ptr<ExtTextEngine> m_pTextEngine;
69 
73 
75 
77  osl::Mutex mutex_;
78  css::uno::Reference< css::beans::XMultiPropertySet >
80 
82  sal_uInt16 m_nStartLine;
83  rtl_TextEncoding m_eSourceEncoding;
86 
88  std::set<sal_uInt16> m_aSyntaxLineTable;
89 
90  void ImpDoHighlight( const OUString& rSource, sal_uInt16 nLineOff );
91 
93  void SetFont();
94 
95  DECL_LINK( SyntaxTimerHdl, Timer *, void );
96 
97  using Window::Invalidate;
98 
99 protected:
100 
101  virtual void Resize() override;
102  virtual void DataChanged( const DataChangedEvent& ) override;
103  virtual void GetFocus() override;
104 // virtual void LoseFocus();
105 
106  void CreateTextEngine();
107  void DoSyntaxHighlight( sal_uInt16 nPara );
108 
109  virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
110 
111  DECL_LINK(ScrollHdl, ScrollBar*, void);
112 
113 public:
114  SwSrcEditWindow( vcl::Window* pParent, SwSrcView* pParentView );
115  virtual ~SwSrcEditWindow() override;
116  virtual void dispose() override;
117 
118  void SetScrollBarRanges();
119  void InitScrollBars();
120  void Read(SvStream& rInput) { m_pTextEngine->Read(rInput); }
121  void Write(SvStream& rOutput) { m_pTextEngine->Write(rOutput); }
122 
124  {return m_pTextView.get();}
126  {return m_pTextEngine.get();}
128 
130 
131  virtual void Invalidate( InvalidateFlags nFlags = InvalidateFlags::NONE ) override;
132 
134  { m_pTextEngine->SetModified(false); }
135  bool IsModified() const
136  { return m_pTextEngine->IsModified();}
137 
138  void SetReadonly(bool bSet){m_bReadonly = bSet;}
139  bool IsReadonly() const {return m_bReadonly;}
140 
141  void SetStartLine(sal_uInt16 nLine){m_nStartLine = nLine;}
142 
143  virtual void Command( const CommandEvent& rCEvt ) override;
144  void HandleWheelCommand( const CommandEvent& rCEvt );
145 
146  void SetTextEncoding(rtl_TextEncoding eEncoding);
147 };
148 
149 #endif
150 
151 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
TextEngine * GetTextEngine()
Definition: srcedtw.hxx:125
virtual void Command(const CommandEvent &rCEvt) override
Definition: srcedtw.cxx:763
void InitScrollBars()
Definition: srcedtw.cxx:554
void SetReadonly(bool bSet)
Definition: srcedtw.hxx:138
virtual void KeyInput(const KeyEvent &rKeyEvt) override
Definition: srcedtw.cxx:451
InvalidateFlags
void HandleWheelCommand(const CommandEvent &rCEvt)
Definition: srcedtw.cxx:781
Window(vcl::Window *pParent, WinBits nStyle=0)
virtual void MouseMove(const MouseEvent &rMEvt) override
Definition: srcedtw.cxx:395
SwSrcView * GetSrcView()
Definition: srcedtw.hxx:127
VclPtr< ScrollBar > m_pVScrollbar
Definition: srcedtw.hxx:71
sal_uInt16 m_nStartLine
Definition: srcedtw.hxx:82
rtl::Reference< ChangesListener > m_xListener
Definition: srcedtw.hxx:76
SwSrcView * m_pSrcView
Definition: srcedtw.hxx:74
virtual void DataChanged(const DataChangedEvent &) override
Definition: srcedtw.cxx:303
TextViewOutWin * GetOutWin()
Definition: srcedtw.hxx:129
VclPtr< ScrollBar > m_pHScrollbar
Definition: srcedtw.hxx:71
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
Definition: srcedtw.cxx:417
sal_Int64 WinBits
virtual void MouseButtonUp(const MouseEvent &rMEvt) override
Definition: srcedtw.cxx:401
TextView * pTextView
Definition: srcedtw.hxx:43
std::unique_ptr< ExtTextEngine > m_pTextEngine
Definition: srcedtw.hxx:68
VclPtr< TextViewOutWin > m_pOutWin
Definition: srcedtw.hxx:70
void SetTextEncoding(rtl_TextEncoding eEncoding)
Definition: srcedtw.cxx:990
void DoSyntaxHighlight(sal_uInt16 nPara)
Definition: srcedtw.cxx:644
bool m_bHighlighting
Definition: srcedtw.hxx:85
virtual void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE) override
Definition: srcedtw.cxx:757
bool IsModified() const
Definition: srcedtw.hxx:135
void SetFont()
Definition: srcedtw.cxx:952
TextViewOutWin(vcl::Window *pParent, WinBits nBits)
Definition: srcedtw.hxx:55
DECL_LINK(SyntaxTimerHdl, Timer *, void)
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: srcedtw.cxx:725
osl::Mutex mutex_
Definition: srcedtw.hxx:77
virtual void Resize() override
Definition: srcedtw.cxx:321
void ImpDoHighlight(const OUString &rSource, sal_uInt16 nLineOff)
Definition: srcedtw.cxx:669
Idle m_aSyntaxIdle
Definition: srcedtw.hxx:87
TextView * GetTextView()
Definition: srcedtw.hxx:123
long m_nCurTextWidth
Definition: srcedtw.hxx:81
void SetStartLine(sal_uInt16 nLine)
Definition: srcedtw.hxx:141
virtual void DataChanged(const DataChangedEvent &) override
Definition: srcedtw.cxx:374
virtual void Command(const CommandEvent &rCEvt) override
Definition: srcedtw.cxx:424
void SetScrollBarRanges()
Definition: srcedtw.cxx:546
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &) override
Definition: srcedtw.cxx:489
css::uno::Reference< css::beans::XMultiPropertySet > m_xNotifier
Definition: srcedtw.hxx:79
void Read(SvStream &rInput)
Definition: srcedtw.hxx:120
rtl_TextEncoding m_eSourceEncoding
Definition: srcedtw.hxx:83
void CreateTextEngine()
Definition: srcedtw.cxx:494
void SetTextView(TextView *pView)
Definition: srcedtw.hxx:58
void Write(SvStream &rOutput)
Definition: srcedtw.hxx:121
std::set< sal_uInt16 > m_aSyntaxLineTable
Definition: srcedtw.hxx:88
void SetFont(const vcl::Font &rNewFont)
virtual ~SwSrcEditWindow() override
Definition: srcedtw.cxx:270
std::unique_ptr< TextView > m_pTextView
Definition: srcedtw.hxx:67
virtual void GetFocus() override
Definition: srcedtw.cxx:787
SwSrcEditWindow(vcl::Window *pParent, SwSrcView *pParentView)
Definition: srcedtw.cxx:235
bool IsReadonly() const
Definition: srcedtw.hxx:139
virtual void dispose() override
Definition: srcedtw.cxx:275
void ClearModifyFlag()
Definition: srcedtw.hxx:133
bool m_bReadonly
Definition: srcedtw.hxx:84