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, sal_uInt16 nPhyNum, sal_uInt16 nVirtNum,
68  const OUString& rPgStr)
69 {
70  SfxViewShell *pSfxViewShell = pVwSh->GetSfxViewShell();
71 
72  if (SwView* pSwView = dynamic_cast<SwView *>(pSfxViewShell))
73  {
74  if (pSwView->GetCurShell())
75  pSwView->UpdatePageNums(nPhyNum, nVirtNum, rPgStr);
76  }
77 }
78 
79 void FrameNotify( SwViewShell* pVwSh, FlyMode eMode )
80 {
81  if (SwWrtShell* pWrtShell = dynamic_cast<SwWrtShell *>(pVwSh))
82  SwBaseShell::SetFrameMode(eMode, pWrtShell);
83 }
84 
85 // Notify for page number update
86 bool SwEditWin::RulerColumnDrag( const MouseEvent& rMEvt, bool bVerticalMode)
87 {
88  SvxRuler& rRuler = bVerticalMode ? m_rView.GetVRuler() : m_rView.GetHRuler();
89  return (!rRuler.StartDocDrag( rMEvt, RulerType::Border ) &&
90  !rRuler.StartDocDrag( rMEvt, RulerType::Margin1) &&
91  !rRuler.StartDocDrag( rMEvt, RulerType::Margin2));
92 }
93 
94 // #i23726#
95 // #i42921# - add 3rd parameter <bVerticalMode> in order
96 // to consider vertical layout
98  const bool bVerticalMode )
99 {
100  SvxRuler& rRuler = bVerticalMode ? m_rView.GetVRuler() : m_rView.GetHRuler();
101  return !rRuler.StartDocDrag( rMEvt, RulerType::Indent);
102 }
103 
105 {
106  SwModuleOptions* pOpt = SW_MOD()->GetModuleConfig();
107  return pOpt ? pOpt->GetTableMode() : TableChgMode::VarWidthChangeAbs;
108 }
109 
110 void RepaintPagePreview( SwViewShell const * pVwSh, const SwRect& rRect )
111 {
112  SfxViewShell *pSfxViewShell = pVwSh->GetSfxViewShell();
113 
114  if (SwPagePreview* pSwPagePreview = dynamic_cast<SwPagePreview *>(pSfxViewShell))
115  pSwPagePreview->RepaintCoreRect(rRect);
116 }
117 
118 bool JumpToSwMark( SwViewShell const * pVwSh, const OUString& rMark )
119 {
120  SfxViewShell *pSfxViewShell = pVwSh->GetSfxViewShell();
121 
122  if (SwView* pSwView = dynamic_cast<SwView *>(pSfxViewShell))
123  return pSwView->JumpToSwMark(rMark);
124 
125  return false;
126 }
127 
129 {
130  Window::DataChanged( rDCEvt );
131 
132  SwWrtShell* pSh = GetView().GetWrtShellPtr();
133  // DataChanged() is sometimes called prior to creating
134  // the SwWrtShell
135  if(!pSh)
136  return;
137  bool bViewWasLocked = pSh->IsViewLocked(), bUnlockPaint = false;
138  pSh->LockView( true );
139  switch( rDCEvt.GetType() )
140  {
141  case DataChangedEventType::SETTINGS:
142  // rearrange ScrollBars, respectively trigger resize, because
143  // the ScrollBar size can have change. For that, in the reset
144  // handler, the size of the ScrollBars also has to be queried
145  // from the settings.
146  if( rDCEvt.GetFlags() & AllSettingsFlags::STYLE )
147  {
148  pSh->LockPaint();
149  bUnlockPaint = true;
151  GetView().InvalidateBorder(); //Scrollbar work
152  }
153  break;
154 
155  case DataChangedEventType::PRINTER:
156  case DataChangedEventType::DISPLAY:
157  case DataChangedEventType::FONTS:
158  case DataChangedEventType::FONTSUBSTITUTION:
159  pSh->LockPaint();
160  bUnlockPaint = true;
161  GetView().GetDocShell()->UpdateFontList(); //e.g. printer change
162  pSh->InvalidateLayout(true);
163  break;
164  default: break;
165  }
166  pSh->LockView( bViewWasLocked );
167  if( bUnlockPaint )
168  pSh->UnlockPaint();
169 }
170 
172 {
174 }
175 
176 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void FrameNotify(SwViewShell *pVwSh, FlyMode eMode)
Definition: edtwin3.cxx:79
FlyMode
Definition: mdiexp.hxx:41
virtual void DataChanged(const DataChangedEvent &) override
Definition: edtwin3.cxx:128
bool JumpToSwMark(SwViewShell const *pVwSh, const OUString &rMark)
Definition: edtwin3.cxx:118
void UpdateFontList()
Definition: docshini.cxx:409
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:67
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
SfxViewShell * GetSfxViewShell() const
Definition: viewsh.hxx:444
void SizeNotify(SwViewShell const *pVwSh, const Size &rSize)
Definition: edtwin3.cxx:56
SvxRuler & GetVRuler()
Definition: view.hxx:482
Used by the UI to modify the document model.
Definition: wrtsh.hxx:90
void InvalidateBorder()
void InvalidateLayout(bool bSizeChanged)
Definition: viewsh.cxx:2012
AllSettingsFlags GetFlags() const
TableChgMode GetTableChgDefaultMode()
Definition: edtwin3.cxx:104
#define SW_MOD()
Definition: swmodule.hxx:256
void RepaintPagePreview(SwViewShell const *pVwSh, const SwRect &rRect)
Definition: edtwin3.cxx:110
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
Definition: uiobject.cxx:124
void DeleteReplacementBitmaps()
Definition: viewsh.cxx:2567
static void SetFrameMode(FlyMode eMode, SwWrtShell *pShell)
Definition: basesh.cxx:2001
bool RulerMarginDrag(const MouseEvent &rMEvt, const bool bVerticalMode)
Definition: edtwin3.cxx:97
void LockPaint()
Definition: viewsh.hxx:604
SwDocShell * GetDocShell()
Definition: view.cxx:1107
TableChgMode GetTableMode() const
Definition: modcfg.hxx:223
SwWrtShell * GetWrtShellPtr() const
Definition: view.hxx:401
tools::Rectangle SVRect() const
Definition: swrect.hxx:283
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:465
bool IsScrollMDI(SwViewShell const *pVwSh, const SwRect &rRect)
Definition: edtwin3.cxx:45
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:171
bool RulerColumnDrag(const MouseEvent &rMEvt, bool bVerticalMode)
Definition: edtwin3.cxx:86
bool IsViewLocked() const
Definition: viewsh.hxx:464
Definition: view.hxx:146
void UnlockPaint(bool bVirDev=false)
Definition: viewsh.hxx:609