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
35 void 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
45 bool 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
56 void 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
67 void 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 
78 void FrameNotify( SwViewShell* pVwSh, FlyMode eMode )
79 {
80  if (SwWrtShell* pWrtShell = dynamic_cast<SwWrtShell *>(pVwSh))
81  SwBaseShell::SetFrameMode(eMode, pWrtShell);
82 }
83 
84 // Notify for page number update
85 bool 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 
109 void 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 
117 bool 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 
131  SwWrtShell* pSh = GetView().GetWrtShellPtr();
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: */
void FrameNotify(SwViewShell *pVwSh, FlyMode eMode)
Definition: edtwin3.cxx:78
FlyMode
Definition: mdiexp.hxx:40
void PageNumNotify(SwViewShell const *pVwSh)
Definition: edtwin3.cxx:67
virtual void DataChanged(const DataChangedEvent &) override
Definition: edtwin3.cxx:127
void UpdateFontList()
Definition: docshini.cxx:415
View of a document.
Definition: pview.hxx:161
const SwView & GetView() const
Definition: edtwin.hxx:244
std::function< std::unique_ptr< UIObject >vcl::Window *)> FactoryFunction
DataChangedEventType GetType() const
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
SfxViewShell * GetSfxViewShell() const
Definition: viewsh.hxx:441
void SizeNotify(SwViewShell const *pVwSh, const Size &rSize)
Definition: edtwin3.cxx:56
bool JumpToSwMark(SwViewShell const *pVwSh, std::u16string_view rMark)
Definition: edtwin3.cxx:117
SvxRuler & GetVRuler()
Definition: view.hxx:495
Used by the UI to modify the document model.
Definition: wrtsh.hxx:93
void InvalidateBorder()
void InvalidateLayout(bool bSizeChanged)
Definition: viewsh.cxx:2010
AllSettingsFlags GetFlags() const
TableChgMode GetTableChgDefaultMode()
Definition: edtwin3.cxx:103
#define SW_MOD()
Definition: swmodule.hxx:256
void RepaintPagePreview(SwViewShell const *pVwSh, const SwRect &rRect)
Definition: edtwin3.cxx:109
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
Definition: uiobject.cxx:142
void DeleteReplacementBitmaps()
Definition: viewsh.cxx:2643
static void SetFrameMode(FlyMode eMode, SwWrtShell *pShell)
Definition: basesh.cxx:2100
bool RulerMarginDrag(const MouseEvent &rMEvt, const bool bVerticalMode)
Definition: edtwin3.cxx:96
void LockPaint()
Definition: viewsh.hxx:602
SwDocShell * GetDocShell()
Definition: view.cxx:1127
TableChgMode GetTableMode() const
Definition: modcfg.hxx:225
SwWrtShell * GetWrtShellPtr() const
Definition: view.hxx:414
tools::Rectangle SVRect() const
Definition: swrect.hxx:272
void ScrollMDI(SwViewShell const *pVwSh, const SwRect &rRect, sal_uInt16 nRangeX, sal_uInt16 nRangeY)
Definition: edtwin3.cxx:35
void LockView(bool b)
Definition: viewsh.hxx:462
bool IsScrollMDI(SwViewShell const *pVwSh, const SwRect &rRect)
Definition: edtwin3.cxx:45
SvxRuler & GetHRuler()
Definition: view.hxx:494
SwView & m_rView
Definition: edtwin.hxx:97
TableChgMode
Definition: tblenum.hxx:46
virtual FactoryFunction GetUITestFactory() const override
Definition: edtwin3.cxx:170
bool RulerColumnDrag(const MouseEvent &rMEvt, bool bVerticalMode)
Definition: edtwin3.cxx:85
bool IsViewLocked() const
Definition: viewsh.hxx:461
Definition: view.hxx:144
void UnlockPaint(bool bVirDev=false)
Definition: viewsh.hxx:607