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