xref: /aoo4110/main/sw/source/ui/docvw/edtwin3.cxx (revision b1cdbd2c)
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 
ScrollMDI(ViewShell * pVwSh,const SwRect & rRect,sal_uInt16 nRangeX,sal_uInt16 nRangeY)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 
IsScrollMDI(ViewShell * pVwSh,const SwRect & rRect)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 
SizeNotify(ViewShell * pVwSh,const Size & rSize)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 
PageNumNotify(ViewShell * pVwSh,sal_uInt16 nPhyNum,sal_uInt16 nVirtNum,const String & rPgStr)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 
FrameNotify(ViewShell * pVwSh,FlyMode eMode)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  --------------------------------------------------------------------*/
RulerColumnDrag(const MouseEvent & rMEvt,sal_Bool bVerticalMode)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
RulerMarginDrag(const MouseEvent & rMEvt,const bool bVerticalMode)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 // <--
AccessibilityScrollMDI(ViewShell * pVwSh,const SwRect & rRect,sal_uInt16 nRangeX,sal_uInt16 nRangeY,sal_Bool isLeftTop)145 void AccessibilityScrollMDI(ViewShell* pVwSh, const SwRect& rRect , sal_uInt16 nRangeX, sal_uInt16 nRangeY, sal_Bool isLeftTop)
146 {
147 	SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
148 	if (pSfxVwSh && pSfxVwSh->ISA(SwView))
149 	{
150 		SwView* pView = (SwView *)pSfxVwSh;
151 
152 		Size aSz( rRect.Left(), rRect.Top());
153 		aSz = pView->GetEditWin().PixelToLogic( aSz );
154 
155 		Point aTopLeft( aSz.Width(), aSz.Height() );
156 		Point aPoint;
157 		Rectangle aRect(aTopLeft,aPoint);
158 
159 		sal_Bool bIsCrsrAtTop = pView->IsCrsrAtTop();
160 		sal_Bool bIsCrsrAtCenter = pView->IsCrsrAtCenter();
161 		if(isLeftTop)
162 			pView->SetCrsrAtTop(sal_True);
163 
164 		pView->Scroll( aRect, nRangeX, nRangeY );
165 
166 		if(isLeftTop)
167 			pView->SetCrsrAtTop(bIsCrsrAtTop, bIsCrsrAtCenter);
168 	}
169 
170 }
171 
GetSearchDialog()172 LAYOUT_NS Dialog* GetSearchDialog()
173 {
174 	return SwView::GetSearchDialog();
175 }
176 
GetTblChgDefaultMode()177 TblChgMode GetTblChgDefaultMode()
178 {
179 	SwModuleOptions* pOpt = SW_MOD()->GetModuleConfig();
180 	return pOpt ? pOpt->GetTblMode() : TBLVAR_CHGABS;
181 }
182 
RepaintPagePreview(ViewShell * pVwSh,const SwRect & rRect)183 void RepaintPagePreview( ViewShell* pVwSh, const SwRect& rRect )
184 {
185 	SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
186 	if (pSfxVwSh && pSfxVwSh->ISA( SwPagePreView ))
187 		((SwPagePreView *)pSfxVwSh)->RepaintCoreRect( rRect );
188 }
189 
JumpToSwMark(ViewShell * pVwSh,const String & rMark)190 sal_Bool JumpToSwMark( ViewShell* pVwSh, const String& rMark )
191 {
192 	SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
193 	if( pSfxVwSh && pSfxVwSh->ISA( SwView ) )
194 		return ((SwView *)pSfxVwSh)->JumpToSwMark( rMark );
195 	return sal_False;
196 }
197 
DataChanged(const DataChangedEvent & rDCEvt)198 void SwEditWin::DataChanged( const DataChangedEvent& rDCEvt )
199 {
200 	Window::DataChanged( rDCEvt );
201 
202     SwWrtShell* pSh = GetView().GetWrtShellPtr();
203     //#99906#   DataChanged() is sometimes called prior to creating
204     //          the SwWrtShell
205     if(!pSh)
206         return;
207     sal_Bool bViewWasLocked = pSh->IsViewLocked(), bUnlockPaint = sal_False;
208     pSh->LockView( sal_True );
209 	switch( rDCEvt.GetType() )
210 	{
211 	case DATACHANGED_SETTINGS:
212 		// ScrollBars neu anordnen bzw. Resize ausloesen, da sich
213 		// ScrollBar-Groesse geaendert haben kann. Dazu muss dann im
214 		// Resize-Handler aber auch die Groesse der ScrollBars aus
215 		// den Settings abgefragt werden.
216 		if( rDCEvt.GetFlags() & SETTINGS_STYLE )
217 		{
218             pSh->LockPaint();
219 			bUnlockPaint = sal_True;
220             ViewShell::DeleteReplacementBitmaps();
221 			GetView().InvalidateBorder();				//Scrollbarbreiten
222 		}
223 		break;
224 
225 	case DATACHANGED_PRINTER:
226 	case DATACHANGED_DISPLAY:
227 	case DATACHANGED_FONTS:
228 	case DATACHANGED_FONTSUBSTITUTION:
229         pSh->LockPaint();
230 		bUnlockPaint = sal_True;
231 		GetView().GetDocShell()->UpdateFontList();	//z.B. Druckerwechsel
232 		break;
233 	}
234     pSh->LockView( bViewWasLocked );
235 	if( bUnlockPaint )
236         pSh->UnlockPaint();
237 }
238 
239