xref: /AOO41X/main/sw/source/ui/docvw/edtwin3.cxx (revision 0deba7fbda3d9908785c25a443701a293b6f4e71)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 
27 
28 
29 #include <hintids.hxx>
30 #include <vcl/settings.hxx>
31 #include <svx/ruler.hxx>
32 #include <viewopt.hxx>
33 #include "view.hxx"
34 #include "wrtsh.hxx"
35 #include "basesh.hxx"
36 #include "pview.hxx"
37 #include "mdiexp.hxx"
38 #include "edtwin.hxx"
39 #include "swmodule.hxx"
40 #include "modcfg.hxx"
41 #include "swtable.hxx"
42 #include "docsh.hxx"
43 #include "pagedesc.hxx"     // Aktuelles Seitenformat
44 #include <frmatr.hxx>
45 #include <editeng/frmdiritem.hxx>
46 
47 
48 /*--------------------------------------------------------------------
49 	Beschreibung:	Core-Notify
50  --------------------------------------------------------------------*/
51 
52 
53 
54 void ScrollMDI( ViewShell* pVwSh, const SwRect &rRect,
55 				sal_uInt16 nRangeX, sal_uInt16 nRangeY)
56 {
57 	SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
58 	if (pSfxVwSh && pSfxVwSh->ISA(SwView))
59 		((SwView *)pSfxVwSh)->Scroll( rRect.SVRect(), nRangeX, nRangeY );
60 }
61 
62 /*--------------------------------------------------------------------
63 	Beschreibung:	Docmdi - verschiebbar
64  --------------------------------------------------------------------*/
65 
66 
67 
68 sal_Bool IsScrollMDI( ViewShell* pVwSh, const SwRect &rRect )
69 {
70 	SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
71 	if (pSfxVwSh && pSfxVwSh->ISA(SwView))
72 		return (((SwView *)pSfxVwSh)->IsScroll(rRect.SVRect()));
73 	return sal_False;
74 }
75 
76 /*--------------------------------------------------------------------
77 	Beschreibung:	Notify fuer Groessen-Aenderung
78  --------------------------------------------------------------------*/
79 
80 
81 
82 void SizeNotify(ViewShell* pVwSh, const Size &rSize)
83 {
84 	SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
85 	if (pSfxVwSh)
86 	{
87 		if (pSfxVwSh->ISA(SwView))
88 			((SwView *)pSfxVwSh)->DocSzChgd(rSize);
89 		else if (pSfxVwSh->ISA(SwPagePreView))
90 			((SwPagePreView *)pSfxVwSh)->DocSzChgd( rSize );
91 	}
92 }
93 
94 /*--------------------------------------------------------------------
95 	Beschreibung:	Notify fuer Seitenzahl-Update
96  --------------------------------------------------------------------*/
97 
98 
99 
100 void PageNumNotify( ViewShell* pVwSh, sal_uInt16 nPhyNum, sal_uInt16 nVirtNum,
101 													const String& rPgStr)
102 {
103 	SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
104 	if ( pSfxVwSh && pSfxVwSh->ISA(SwView) &&
105 		 ((SwView*)pSfxVwSh)->GetCurShell() )
106 			((SwView *)pSfxVwSh)->UpdatePageNums(nPhyNum, nVirtNum, rPgStr);
107 }
108 
109 /******************************************************************************
110  *	Methode		:	void FrameNotify( DocMDIBase *pWin, FlyMode eMode )
111  *	Beschreibung:
112  *	Erstellt	:	OK 08.02.94 13:49
113  *	Aenderung	:
114  ******************************************************************************/
115 
116 
117 
118 void FrameNotify( ViewShell* pVwSh, FlyMode eMode )
119 {
120 	if ( pVwSh->ISA(SwCrsrShell) )
121 		SwBaseShell::SetFrmMode( eMode, (SwWrtShell*)pVwSh );
122 }
123 
124 /*--------------------------------------------------------------------
125 	Beschreibung:	Notify fuer Seitenzahl-Update
126  --------------------------------------------------------------------*/
127 sal_Bool SwEditWin::RulerColumnDrag( const MouseEvent& rMEvt, sal_Bool bVerticalMode)
128 {
129     SvxRuler& rRuler = bVerticalMode ?  rView.GetVLineal() : rView.GetHLineal();
130     return (!rRuler.StartDocDrag( rMEvt, RULER_TYPE_BORDER ) &&
131             !rRuler.StartDocDrag( rMEvt, RULER_TYPE_MARGIN1) &&
132             !rRuler.StartDocDrag( rMEvt, RULER_TYPE_MARGIN2));
133 }
134 
135 // #i23726#
136 // --> OD 2005-02-18 #i42921# - add 3rd parameter <bVerticalMode> in order
137 // to consider vertical layout
138 sal_Bool SwEditWin::RulerMarginDrag( const MouseEvent& rMEvt,
139                                  const bool bVerticalMode )
140 {
141     SvxRuler& rRuler = bVerticalMode ?  rView.GetVLineal() : rView.GetHLineal();
142     return !rRuler.StartDocDrag( rMEvt, RULER_TYPE_INDENT);
143 }
144 // <--
145 //IAccessibility2 Impplementaton 2009-----
146 void AccessibilityScrollMDI(ViewShell* pVwSh, const SwRect& rRect , sal_uInt16 nRangeX, sal_uInt16 nRangeY, sal_Bool isLeftTop)
147 {
148 	SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
149 	if (pSfxVwSh && pSfxVwSh->ISA(SwView))
150 	{
151 		SwView* pView = (SwView *)pSfxVwSh;
152 
153 		Size aSz( rRect.Left(), rRect.Top());
154 		aSz = pView->GetEditWin().PixelToLogic( aSz );
155 
156 		Point aTopLeft( aSz.Width(), aSz.Height() );
157 		Point aPoint;
158 		Rectangle aRect(aTopLeft,aPoint);
159 
160 		sal_Bool bIsCrsrAtTop = pView->IsCrsrAtTop();
161 		sal_Bool bIsCrsrAtCenter = pView->IsCrsrAtCenter();
162 		if(isLeftTop)
163 			pView->SetCrsrAtTop(sal_True);
164 
165 		pView->Scroll( aRect, nRangeX, nRangeY );
166 
167 		if(isLeftTop)
168 			pView->SetCrsrAtTop(bIsCrsrAtTop, bIsCrsrAtCenter);
169 	}
170 
171 }
172 //-----IAccessibility2 Impplementaton 2009
173 
174 LAYOUT_NS Dialog* GetSearchDialog()
175 {
176 	return SwView::GetSearchDialog();
177 }
178 
179 TblChgMode GetTblChgDefaultMode()
180 {
181 	SwModuleOptions* pOpt = SW_MOD()->GetModuleConfig();
182 	return pOpt ? pOpt->GetTblMode() : TBLVAR_CHGABS;
183 }
184 
185 void RepaintPagePreview( ViewShell* pVwSh, const SwRect& rRect )
186 {
187 	SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
188 	if (pSfxVwSh && pSfxVwSh->ISA( SwPagePreView ))
189 		((SwPagePreView *)pSfxVwSh)->RepaintCoreRect( rRect );
190 }
191 
192 sal_Bool JumpToSwMark( ViewShell* pVwSh, const String& rMark )
193 {
194 	SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
195 	if( pSfxVwSh && pSfxVwSh->ISA( SwView ) )
196 		return ((SwView *)pSfxVwSh)->JumpToSwMark( rMark );
197 	return sal_False;
198 }
199 
200 void SwEditWin::DataChanged( const DataChangedEvent& rDCEvt )
201 {
202 	Window::DataChanged( rDCEvt );
203 
204     SwWrtShell* pSh = GetView().GetWrtShellPtr();
205     //#99906#   DataChanged() is sometimes called prior to creating
206     //          the SwWrtShell
207     if(!pSh)
208         return;
209     sal_Bool bViewWasLocked = pSh->IsViewLocked(), bUnlockPaint = sal_False;
210     pSh->LockView( sal_True );
211 	switch( rDCEvt.GetType() )
212 	{
213 	case DATACHANGED_SETTINGS:
214 		// ScrollBars neu anordnen bzw. Resize ausloesen, da sich
215 		// ScrollBar-Groesse geaendert haben kann. Dazu muss dann im
216 		// Resize-Handler aber auch die Groesse der ScrollBars aus
217 		// den Settings abgefragt werden.
218 		if( rDCEvt.GetFlags() & SETTINGS_STYLE )
219 		{
220             pSh->LockPaint();
221 			bUnlockPaint = sal_True;
222             ViewShell::DeleteReplacementBitmaps();
223 			GetView().InvalidateBorder();				//Scrollbarbreiten
224 		}
225 		break;
226 
227 	case DATACHANGED_PRINTER:
228 	case DATACHANGED_DISPLAY:
229 	case DATACHANGED_FONTS:
230 	case DATACHANGED_FONTSUBSTITUTION:
231         pSh->LockPaint();
232 		bUnlockPaint = sal_True;
233 		GetView().GetDocShell()->UpdateFontList();	//z.B. Druckerwechsel
234 		break;
235 	}
236     pSh->LockView( bViewWasLocked );
237 	if( bUnlockPaint )
238         pSh->UnlockPaint();
239 }
240 
241