Line data Source code
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/settings.hxx>
22 : #include <svx/ruler.hxx>
23 : #include <viewopt.hxx>
24 : #include "view.hxx"
25 : #include "wrtsh.hxx"
26 : #include "basesh.hxx"
27 : #include "pview.hxx"
28 : #include "mdiexp.hxx"
29 : #include "edtwin.hxx"
30 : #include "swmodule.hxx"
31 : #include "modcfg.hxx"
32 : #include "swtable.hxx"
33 : #include "docsh.hxx"
34 : #include "pagedesc.hxx"
35 : #include <frmatr.hxx>
36 : #include <editeng/frmdiritem.hxx>
37 :
38 : // Core-Notify
39 0 : void ScrollMDI( SwViewShell* pVwSh, const SwRect &rRect,
40 : sal_uInt16 nRangeX, sal_uInt16 nRangeY)
41 : {
42 0 : SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
43 0 : if (pSfxVwSh && pSfxVwSh->ISA(SwView))
44 0 : ((SwView *)pSfxVwSh)->Scroll( rRect.SVRect(), nRangeX, nRangeY );
45 0 : }
46 :
47 : // Docmdi - movable
48 0 : sal_Bool IsScrollMDI( SwViewShell* pVwSh, const SwRect &rRect )
49 : {
50 0 : SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
51 0 : if (pSfxVwSh && pSfxVwSh->ISA(SwView))
52 0 : return (((SwView *)pSfxVwSh)->IsScroll(rRect.SVRect()));
53 0 : return sal_False;
54 : }
55 :
56 : // Notify for size change
57 0 : void SizeNotify(SwViewShell* pVwSh, const Size &rSize)
58 : {
59 0 : SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
60 0 : if (pSfxVwSh)
61 : {
62 0 : if (pSfxVwSh->ISA(SwView))
63 0 : ((SwView *)pSfxVwSh)->DocSzChgd(rSize);
64 0 : else if (pSfxVwSh->ISA(SwPagePreview))
65 0 : ((SwPagePreview *)pSfxVwSh)->DocSzChgd( rSize );
66 : }
67 0 : }
68 :
69 : // Notify for page number update
70 0 : void PageNumNotify( SwViewShell* pVwSh, sal_uInt16 nPhyNum, sal_uInt16 nVirtNum,
71 : const OUString& rPgStr)
72 : {
73 0 : SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
74 0 : if ( pSfxVwSh && pSfxVwSh->ISA(SwView) &&
75 0 : ((SwView*)pSfxVwSh)->GetCurShell() )
76 0 : ((SwView *)pSfxVwSh)->UpdatePageNums(nPhyNum, nVirtNum, rPgStr);
77 0 : }
78 :
79 0 : void FrameNotify( SwViewShell* pVwSh, FlyMode eMode )
80 : {
81 0 : if ( pVwSh->ISA(SwCrsrShell) )
82 0 : SwBaseShell::SetFrmMode( eMode, (SwWrtShell*)pVwSh );
83 0 : }
84 :
85 : // Notify for page number update
86 0 : sal_Bool SwEditWin::RulerColumnDrag( const MouseEvent& rMEvt, sal_Bool bVerticalMode)
87 : {
88 0 : SvxRuler& rRuler = bVerticalMode ? m_rView.GetVRuler() : m_rView.GetHRuler();
89 0 : return (!rRuler.StartDocDrag( rMEvt, RULER_TYPE_BORDER ) &&
90 0 : !rRuler.StartDocDrag( rMEvt, RULER_TYPE_MARGIN1) &&
91 0 : !rRuler.StartDocDrag( rMEvt, RULER_TYPE_MARGIN2));
92 : }
93 :
94 : // #i23726#
95 : // #i42921# - add 3rd parameter <bVerticalMode> in order
96 : // to consider vertical layout
97 0 : sal_Bool SwEditWin::RulerMarginDrag( const MouseEvent& rMEvt,
98 : const bool bVerticalMode )
99 : {
100 0 : SvxRuler& rRuler = bVerticalMode ? m_rView.GetVRuler() : m_rView.GetHRuler();
101 0 : return !rRuler.StartDocDrag( rMEvt, RULER_TYPE_INDENT);
102 : }
103 :
104 0 : void SwAccessibilityScrollMDI(SwViewShell* pVwSh, const SwRect& rRect , sal_uInt16 nRangeX, sal_uInt16 nRangeY, sal_Bool isLeftTop)
105 : {
106 0 : SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
107 0 : if (pSfxVwSh && pSfxVwSh->ISA(SwView))
108 : {
109 0 : SwView* pView = (SwView *)pSfxVwSh;
110 :
111 0 : Size aSz( rRect.Left(), rRect.Top());
112 0 : aSz = pView->GetEditWin().PixelToLogic( aSz );
113 :
114 0 : Point aTopLeft( aSz.Width(), aSz.Height() );
115 0 : Point aPoint;
116 0 : Rectangle aRect(aTopLeft,aPoint);
117 :
118 0 : sal_Bool bIsCrsrAtTop = pView->IsCrsrAtTop();
119 0 : sal_Bool bIsCrsrAtCenter = pView->IsCrsrAtCenter();
120 0 : if(isLeftTop)
121 0 : pView->SetCrsrAtTop(sal_True);
122 :
123 0 : pView->Scroll( aRect, nRangeX, nRangeY );
124 :
125 0 : if(isLeftTop)
126 0 : pView->SetCrsrAtTop(bIsCrsrAtTop, bIsCrsrAtCenter);
127 : }
128 :
129 0 : }
130 :
131 0 : TblChgMode GetTblChgDefaultMode()
132 : {
133 0 : SwModuleOptions* pOpt = SW_MOD()->GetModuleConfig();
134 0 : return pOpt ? pOpt->GetTblMode() : TBLVAR_CHGABS;
135 : }
136 :
137 0 : void RepaintPagePreview( SwViewShell* pVwSh, const SwRect& rRect )
138 : {
139 0 : SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
140 0 : if (pSfxVwSh && pSfxVwSh->ISA( SwPagePreview ))
141 0 : ((SwPagePreview *)pSfxVwSh)->RepaintCoreRect( rRect );
142 0 : }
143 :
144 0 : bool JumpToSwMark( SwViewShell* pVwSh, const OUString& rMark )
145 : {
146 0 : SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
147 0 : if( pSfxVwSh && pSfxVwSh->ISA( SwView ) )
148 0 : return ((SwView *)pSfxVwSh)->JumpToSwMark( rMark );
149 0 : return false;
150 : }
151 :
152 0 : void SwEditWin::DataChanged( const DataChangedEvent& rDCEvt )
153 : {
154 0 : Window::DataChanged( rDCEvt );
155 :
156 0 : SwWrtShell* pSh = GetView().GetWrtShellPtr();
157 : // DataChanged() is sometimes called prior to creating
158 : // the SwWrtShell
159 0 : if(!pSh)
160 0 : return;
161 0 : sal_Bool bViewWasLocked = pSh->IsViewLocked(), bUnlockPaint = sal_False;
162 0 : pSh->LockView( sal_True );
163 0 : switch( rDCEvt.GetType() )
164 : {
165 : case DATACHANGED_SETTINGS:
166 : // rearrange ScrollBars, respectively trigger resize, because
167 : // the ScrollBar size can have change. For that, in the reset
168 : // handler, the size of the ScrollBars also has to be queried
169 : // from the settings.
170 0 : if( rDCEvt.GetFlags() & SETTINGS_STYLE )
171 : {
172 0 : pSh->LockPaint();
173 0 : bUnlockPaint = sal_True;
174 0 : SwViewShell::DeleteReplacementBitmaps();
175 0 : GetView().InvalidateBorder(); //Scrollbar work
176 : }
177 0 : break;
178 :
179 : case DATACHANGED_PRINTER:
180 : case DATACHANGED_DISPLAY:
181 : case DATACHANGED_FONTS:
182 : case DATACHANGED_FONTSUBSTITUTION:
183 0 : pSh->LockPaint();
184 0 : bUnlockPaint = sal_True;
185 0 : GetView().GetDocShell()->UpdateFontList(); //e.g. printer change
186 0 : break;
187 : }
188 0 : pSh->LockView( bViewWasLocked );
189 0 : if( bUnlockPaint )
190 0 : pSh->UnlockPaint();
191 : }
192 :
193 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|