Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / source / uibase / docvw / edtwin3.cxx
blob2b9d1a7f1e039303ab40f7743089881fc6551812
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
34 // Core-Notify
35 void ScrollMDI( SwViewShell const * pVwSh, const SwRect &rRect,
36 sal_uInt16 nRangeX, sal_uInt16 nRangeY)
38 SfxViewShell *pSfxViewShell = pVwSh->GetSfxViewShell();
40 if (SwView* pSwView = dynamic_cast<SwView *>(pSfxViewShell))
41 pSwView->Scroll(rRect.SVRect(), nRangeX, nRangeY);
44 // Docmdi - movable
45 bool IsScrollMDI( SwViewShell const * pVwSh, const SwRect &rRect )
47 SfxViewShell *pSfxViewShell = pVwSh->GetSfxViewShell();
49 if (SwView* pSwView = dynamic_cast<SwView *>(pSfxViewShell))
50 return pSwView->IsScroll(rRect.SVRect());
52 return false;
55 // Notify for size change
56 void SizeNotify(SwViewShell const * pVwSh, const Size &rSize)
58 SfxViewShell *pSfxViewShell = pVwSh->GetSfxViewShell();
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);
66 // Notify for page number update
67 void PageNumNotify(SwViewShell const * pVwSh)
69 SfxViewShell *pSfxViewShell = pVwSh->GetSfxViewShell();
71 if (SwView* pSwView = dynamic_cast<SwView *>(pSfxViewShell))
73 if (pSwView->GetCurShell())
74 pSwView->UpdatePageNums();
78 void FrameNotify( SwViewShell* pVwSh, FlyMode eMode )
80 if (SwWrtShell* pWrtShell = dynamic_cast<SwWrtShell *>(pVwSh))
81 SwBaseShell::SetFrameMode(eMode, pWrtShell);
84 // Notify for page number update
85 bool SwEditWin::RulerColumnDrag( const MouseEvent& rMEvt, bool bVerticalMode)
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));
93 // #i23726#
94 // #i42921# - add 3rd parameter <bVerticalMode> in order
95 // to consider vertical layout
96 bool SwEditWin::RulerMarginDrag( const MouseEvent& rMEvt,
97 const bool bVerticalMode )
99 SvxRuler& rRuler = bVerticalMode ? m_rView.GetVRuler() : m_rView.GetHRuler();
100 return !rRuler.StartDocDrag( rMEvt, RulerType::Indent);
103 TableChgMode GetTableChgDefaultMode()
105 SwModuleOptions* pOpt = SW_MOD()->GetModuleConfig();
106 return pOpt ? pOpt->GetTableMode() : TableChgMode::VarWidthChangeAbs;
109 void RepaintPagePreview( SwViewShell const * pVwSh, const SwRect& rRect )
111 SfxViewShell *pSfxViewShell = pVwSh->GetSfxViewShell();
113 if (SwPagePreview* pSwPagePreview = dynamic_cast<SwPagePreview *>(pSfxViewShell))
114 pSwPagePreview->RepaintCoreRect(rRect);
117 bool JumpToSwMark( SwViewShell const * pVwSh, std::u16string_view rMark )
119 SfxViewShell *pSfxViewShell = pVwSh->GetSfxViewShell();
121 if (SwView* pSwView = dynamic_cast<SwView *>(pSfxViewShell))
122 return pSwView->JumpToSwMark(rMark);
124 return false;
127 void SwEditWin::DataChanged( const DataChangedEvent& rDCEvt )
129 Window::DataChanged( rDCEvt );
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() )
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 )
147 pSh->LockPaint(LockPaintReason::DataChanged);
148 bUnlockPaint = true;
149 pSh->DeleteReplacementBitmaps();
150 GetView().InvalidateBorder(); //Scrollbar work
152 break;
154 case DataChangedEventType::PRINTER:
155 case DataChangedEventType::DISPLAY:
156 case DataChangedEventType::FONTS:
157 case DataChangedEventType::FONTSUBSTITUTION:
158 pSh->LockPaint(LockPaintReason::DataChanged);
159 bUnlockPaint = true;
160 GetView().GetDocShell()->UpdateFontList(); //e.g. printer change
161 pSh->InvalidateLayout(true);
162 break;
163 default: break;
165 pSh->LockView( bViewWasLocked );
166 if( bUnlockPaint )
167 pSh->UnlockPaint();
170 FactoryFunction SwEditWin::GetUITestFactory() const
172 return SwEditWinUIObject::create;
175 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */