LibreOffice Module sw (master) 1
edtwin3.cxx
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
20#include <vcl/event.hxx>
21#include <vcl/settings.hxx>
22#include <svx/ruler.hxx>
23#include <view.hxx>
24#include <wrtsh.hxx>
25#include <basesh.hxx>
26#include <pview.hxx>
27#include <mdiexp.hxx>
28#include <edtwin.hxx>
29#include <swmodule.hxx>
30#include <modcfg.hxx>
31#include <docsh.hxx>
32#include <uiobject.hxx>
33
34// Core-Notify
35void ScrollMDI( SwViewShell const * pVwSh, const SwRect &rRect,
36 sal_uInt16 nRangeX, sal_uInt16 nRangeY)
37{
38 SfxViewShell *pSfxViewShell = pVwSh->GetSfxViewShell();
39
40 if (SwView* pSwView = dynamic_cast<SwView *>(pSfxViewShell))
41 pSwView->Scroll(rRect.SVRect(), nRangeX, nRangeY);
42}
43
44// Docmdi - movable
45bool IsScrollMDI( SwViewShell const * pVwSh, const SwRect &rRect )
46{
47 SfxViewShell *pSfxViewShell = pVwSh->GetSfxViewShell();
48
49 if (SwView* pSwView = dynamic_cast<SwView *>(pSfxViewShell))
50 return pSwView->IsScroll(rRect.SVRect());
51
52 return false;
53}
54
55// Notify for size change
56void SizeNotify(SwViewShell const * pVwSh, const Size &rSize)
57{
58 SfxViewShell *pSfxViewShell = pVwSh->GetSfxViewShell();
59
60 if (SwView* pSwView = dynamic_cast<SwView *>(pSfxViewShell))
61 pSwView->DocSzChgd(rSize);
62 else if (SwPagePreview* pSwPageView = dynamic_cast<SwPagePreview *>(pSfxViewShell))
63 pSwPageView->DocSzChgd(rSize);
64}
65
66// Notify for page number update
67void PageNumNotify(SwViewShell const * pVwSh)
68{
69 SfxViewShell *pSfxViewShell = pVwSh->GetSfxViewShell();
70
71 if (SwView* pSwView = dynamic_cast<SwView *>(pSfxViewShell))
72 {
73 if (pSwView->GetCurShell())
74 pSwView->UpdatePageNums();
75 }
76}
77
78void FrameNotify( SwViewShell* pVwSh, FlyMode eMode )
79{
80 if (SwWrtShell* pWrtShell = dynamic_cast<SwWrtShell *>(pVwSh))
82}
83
84// Notify for page number update
85bool SwEditWin::RulerColumnDrag( const MouseEvent& rMEvt, bool bVerticalMode)
86{
87 SvxRuler& rRuler = bVerticalMode ? m_rView.GetVRuler() : m_rView.GetHRuler();
88 return (!rRuler.StartDocDrag( rMEvt, RulerType::Border ) &&
89 !rRuler.StartDocDrag( rMEvt, RulerType::Margin1) &&
90 !rRuler.StartDocDrag( rMEvt, RulerType::Margin2));
91}
92
93// #i23726#
94// #i42921# - add 3rd parameter <bVerticalMode> in order
95// to consider vertical layout
97 const bool bVerticalMode )
98{
99 SvxRuler& rRuler = bVerticalMode ? m_rView.GetVRuler() : m_rView.GetHRuler();
100 return !rRuler.StartDocDrag( rMEvt, RulerType::Indent);
101}
102
104{
105 SwModuleOptions* pOpt = SW_MOD()->GetModuleConfig();
106 return pOpt ? pOpt->GetTableMode() : TableChgMode::VarWidthChangeAbs;
107}
108
109void RepaintPagePreview( SwViewShell const * pVwSh, const SwRect& rRect )
110{
111 SfxViewShell *pSfxViewShell = pVwSh->GetSfxViewShell();
112
113 if (SwPagePreview* pSwPagePreview = dynamic_cast<SwPagePreview *>(pSfxViewShell))
114 pSwPagePreview->RepaintCoreRect(rRect);
115}
116
117bool JumpToSwMark( SwViewShell const * pVwSh, std::u16string_view rMark )
118{
119 SfxViewShell *pSfxViewShell = pVwSh->GetSfxViewShell();
120
121 if (SwView* pSwView = dynamic_cast<SwView *>(pSfxViewShell))
122 return pSwView->JumpToSwMark(rMark);
123
124 return false;
125}
126
128{
129 Window::DataChanged( rDCEvt );
130
132 // DataChanged() is sometimes called prior to creating
133 // the SwWrtShell
134 if(!pSh)
135 return;
136 bool bViewWasLocked = pSh->IsViewLocked(), bUnlockPaint = false;
137 pSh->LockView( true );
138 switch( rDCEvt.GetType() )
139 {
140 case DataChangedEventType::SETTINGS:
141 // rearrange ScrollBars, respectively trigger resize, because
142 // the ScrollBar size can have change. For that, in the reset
143 // handler, the size of the ScrollBars also has to be queried
144 // from the settings.
145 if( rDCEvt.GetFlags() & AllSettingsFlags::STYLE )
146 {
147 pSh->LockPaint();
148 bUnlockPaint = true;
150 GetView().InvalidateBorder(); //Scrollbar work
151 }
152 break;
153
154 case DataChangedEventType::PRINTER:
155 case DataChangedEventType::DISPLAY:
156 case DataChangedEventType::FONTS:
157 case DataChangedEventType::FONTSUBSTITUTION:
158 pSh->LockPaint();
159 bUnlockPaint = true;
160 GetView().GetDocShell()->UpdateFontList(); //e.g. printer change
161 pSh->InvalidateLayout(true);
162 break;
163 default: break;
164 }
165 pSh->LockView( bViewWasLocked );
166 if( bUnlockPaint )
167 pSh->UnlockPaint();
168}
169
171{
173}
174
175/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
DataChangedEventType GetType() const
AllSettingsFlags GetFlags() const
void InvalidateBorder()
static void SetFrameMode(FlyMode eMode, SwWrtShell *pShell)
Definition: basesh.cxx:2130
void UpdateFontList()
Definition: docshini.cxx:414
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
Definition: uiobject.cxx:146
virtual FactoryFunction GetUITestFactory() const override
Definition: edtwin3.cxx:170
SwView & m_rView
Definition: edtwin.hxx:98
bool RulerMarginDrag(const MouseEvent &rMEvt, const bool bVerticalMode)
Definition: edtwin3.cxx:96
virtual void DataChanged(const DataChangedEvent &) override
Definition: edtwin3.cxx:127
const SwView & GetView() const
Definition: edtwin.hxx:245
bool RulerColumnDrag(const MouseEvent &rMEvt, bool bVerticalMode)
Definition: edtwin3.cxx:85
TableChgMode GetTableMode() const
Definition: modcfg.hxx:225
View of a document.
Definition: pview.hxx:162
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
tools::Rectangle SVRect() const
Definition: swrect.hxx:292
bool IsViewLocked() const
Definition: viewsh.hxx:471
void UnlockPaint(bool bVirDev=false)
Definition: viewsh.hxx:619
void DeleteReplacementBitmaps()
Definition: viewsh.cxx:2747
void InvalidateLayout(bool bSizeChanged)
Definition: viewsh.cxx:2103
void LockPaint()
Definition: viewsh.hxx:614
SfxViewShell * GetSfxViewShell() const
Definition: viewsh.hxx:451
void LockView(bool b)
Definition: viewsh.hxx:472
Definition: view.hxx:146
SvxRuler & GetVRuler()
Definition: view.hxx:498
SwWrtShell * GetWrtShellPtr() const
Definition: view.hxx:417
SwDocShell * GetDocShell()
Definition: view.cxx:1160
SvxRuler & GetHRuler()
Definition: view.hxx:497
Used by the UI to modify the document model.
Definition: wrtsh.hxx:97
void SizeNotify(SwViewShell const *pVwSh, const Size &rSize)
Definition: edtwin3.cxx:56
TableChgMode GetTableChgDefaultMode()
Definition: edtwin3.cxx:103
void PageNumNotify(SwViewShell const *pVwSh)
Definition: edtwin3.cxx:67
bool JumpToSwMark(SwViewShell const *pVwSh, std::u16string_view rMark)
Definition: edtwin3.cxx:117
bool IsScrollMDI(SwViewShell const *pVwSh, const SwRect &rRect)
Definition: edtwin3.cxx:45
void FrameNotify(SwViewShell *pVwSh, FlyMode eMode)
Definition: edtwin3.cxx:78
void RepaintPagePreview(SwViewShell const *pVwSh, const SwRect &rRect)
Definition: edtwin3.cxx:109
void ScrollMDI(SwViewShell const *pVwSh, const SwRect &rRect, sal_uInt16 nRangeX, sal_uInt16 nRangeY)
Definition: edtwin3.cxx:35
std::function< std::unique_ptr< UIObject >(vcl::Window *)> FactoryFunction
Mode eMode
FlyMode
Definition: mdiexp.hxx:41
#define SW_MOD()
Definition: swmodule.hxx:256
TableChgMode
Definition: tblenum.hxx:48