xref: /trunk/main/sw/source/ui/docvw/edtwin3.cxx (revision a3cdc23e488c57f3433f22cd4458e65c27aa499c)
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 // MARKER(update_precomp.py): autogen include statement, do not remove
23 #include "precompiled_sw.hxx"
24 
25 #include <hintids.hxx>
26 #include <vcl/settings.hxx>
27 #include <svx/ruler.hxx>
28 #include <viewopt.hxx>
29 #include "view.hxx"
30 #include "wrtsh.hxx"
31 #include "basesh.hxx"
32 #include "pview.hxx"
33 #include "mdiexp.hxx"
34 #include "edtwin.hxx"
35 #include "swmodule.hxx"
36 #include "modcfg.hxx"
37 #include "swtable.hxx"
38 #include "docsh.hxx"
39 #include "pagedesc.hxx"     // Aktuelles Seitenformat
40 #include <frmatr.hxx>
41 #include <editeng/frmdiritem.hxx>
42 
43 /*--------------------------------------------------------------------
44     Beschreibung:   Core-Notify
45  --------------------------------------------------------------------*/
46 
47 void ScrollMDI( ViewShell* pVwSh, const SwRect &rRect,
48                 sal_uInt16 nRangeX, sal_uInt16 nRangeY)
49 {
50     SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
51     if (pSfxVwSh && pSfxVwSh->ISA(SwView))
52         ((SwView *)pSfxVwSh)->Scroll( rRect.SVRect(), nRangeX, nRangeY );
53 }
54 
55 /*--------------------------------------------------------------------
56     Beschreibung:   Docmdi - verschiebbar
57  --------------------------------------------------------------------*/
58 
59 sal_Bool IsScrollMDI( ViewShell* pVwSh, const SwRect &rRect )
60 {
61     SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
62     if (pSfxVwSh && pSfxVwSh->ISA(SwView))
63         return (((SwView *)pSfxVwSh)->IsScroll(rRect.SVRect()));
64     return sal_False;
65 }
66 
67 /*--------------------------------------------------------------------
68     Beschreibung:   Notify fuer Groessen-Aenderung
69  --------------------------------------------------------------------*/
70 
71 void SizeNotify(ViewShell* pVwSh, const Size &rSize)
72 {
73     SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
74     if (pSfxVwSh)
75     {
76         if (pSfxVwSh->ISA(SwView))
77             ((SwView *)pSfxVwSh)->DocSzChgd(rSize);
78         else if (pSfxVwSh->ISA(SwPagePreView))
79             ((SwPagePreView *)pSfxVwSh)->DocSzChgd( rSize );
80     }
81 }
82 
83 /*--------------------------------------------------------------------
84     Beschreibung:   Notify fuer Seitenzahl-Update
85  --------------------------------------------------------------------*/
86 
87 void PageNumNotify( ViewShell* pVwSh, sal_uInt16 nPhyNum, sal_uInt16 nVirtNum,
88                                                     const String& rPgStr)
89 {
90     SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
91     if ( pSfxVwSh && pSfxVwSh->ISA(SwView) &&
92          ((SwView*)pSfxVwSh)->GetCurShell() )
93             ((SwView *)pSfxVwSh)->UpdatePageNums(nPhyNum, nVirtNum, rPgStr);
94 }
95 
96 /******************************************************************************
97  *  Methode     :   void FrameNotify( DocMDIBase *pWin, FlyMode eMode )
98  *  Beschreibung:
99  *  Erstellt    :   OK 08.02.94 13:49
100  *  Aenderung   :
101  ******************************************************************************/
102 
103 void FrameNotify( ViewShell* pVwSh, FlyMode eMode )
104 {
105     if ( pVwSh->ISA(SwCrsrShell) )
106         SwBaseShell::SetFrmMode( eMode, (SwWrtShell*)pVwSh );
107 }
108 
109 /*--------------------------------------------------------------------
110     Beschreibung:   Notify fuer Seitenzahl-Update
111  --------------------------------------------------------------------*/
112 sal_Bool SwEditWin::RulerColumnDrag( const MouseEvent& rMEvt, sal_Bool bVerticalMode)
113 {
114     SvxRuler& rRuler = bVerticalMode ?  rView.GetVRuler() : rView.GetHRuler();
115     return (!rRuler.StartDocDrag( rMEvt, RULER_TYPE_BORDER ) &&
116             !rRuler.StartDocDrag( rMEvt, RULER_TYPE_MARGIN1) &&
117             !rRuler.StartDocDrag( rMEvt, RULER_TYPE_MARGIN2));
118 }
119 
120 // #i23726#
121 // --> OD 2005-02-18 #i42921# - add 3rd parameter <bVerticalMode> in order
122 // to consider vertical layout
123 sal_Bool SwEditWin::RulerMarginDrag( const MouseEvent& rMEvt,
124                                  const bool bVerticalMode )
125 {
126     SvxRuler& rRuler = bVerticalMode ?  rView.GetVRuler() : rView.GetHRuler();
127     return !rRuler.StartDocDrag( rMEvt, RULER_TYPE_INDENT);
128 }
129 // <--
130 void AccessibilityScrollMDI(ViewShell* pVwSh, const SwRect& rRect , sal_uInt16 nRangeX, sal_uInt16 nRangeY, sal_Bool isLeftTop)
131 {
132     SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
133     if (pSfxVwSh && pSfxVwSh->ISA(SwView))
134     {
135         SwView* pView = (SwView *)pSfxVwSh;
136 
137         Size aSz( rRect.Left(), rRect.Top());
138         aSz = pView->GetEditWin().PixelToLogic( aSz );
139 
140         Point aTopLeft( aSz.Width(), aSz.Height() );
141         Point aPoint;
142         Rectangle aRect(aTopLeft,aPoint);
143 
144         sal_Bool bIsCrsrAtTop = pView->IsCrsrAtTop();
145         sal_Bool bIsCrsrAtCenter = pView->IsCrsrAtCenter();
146         if(isLeftTop)
147             pView->SetCrsrAtTop(sal_True);
148 
149         pView->Scroll( aRect, nRangeX, nRangeY );
150 
151         if(isLeftTop)
152             pView->SetCrsrAtTop(bIsCrsrAtTop, bIsCrsrAtCenter);
153     }
154 
155 }
156 
157 LAYOUT_NS Dialog* GetSearchDialog()
158 {
159     return SwView::GetSearchDialog();
160 }
161 
162 TblChgMode GetTblChgDefaultMode()
163 {
164     SwModuleOptions* pOpt = SW_MOD()->GetModuleConfig();
165     return pOpt ? pOpt->GetTblMode() : TBLVAR_CHGABS;
166 }
167 
168 void RepaintPagePreview( ViewShell* pVwSh, const SwRect& rRect )
169 {
170     SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
171     if (pSfxVwSh && pSfxVwSh->ISA( SwPagePreView ))
172         ((SwPagePreView *)pSfxVwSh)->RepaintCoreRect( rRect );
173 }
174 
175 sal_Bool JumpToSwMark( ViewShell* pVwSh, const String& rMark )
176 {
177     SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
178     if( pSfxVwSh && pSfxVwSh->ISA( SwView ) )
179         return ((SwView *)pSfxVwSh)->JumpToSwMark( rMark );
180     return sal_False;
181 }
182 
183 void SwEditWin::DataChanged( const DataChangedEvent& rDCEvt )
184 {
185     Window::DataChanged( rDCEvt );
186 
187     SwWrtShell* pSh = GetView().GetWrtShellPtr();
188     //#99906#   DataChanged() is sometimes called prior to creating
189     //          the SwWrtShell
190     if(!pSh)
191         return;
192     sal_Bool bViewWasLocked = pSh->IsViewLocked(), bUnlockPaint = sal_False;
193     pSh->LockView( sal_True );
194     switch( rDCEvt.GetType() )
195     {
196     case DATACHANGED_SETTINGS:
197         // ScrollBars neu anordnen bzw. Resize auslösen, da sich
198         // ScrollBar-Groesse geaendert haben kann. Dazu muss dann im
199         // Resize-Handler aber auch die Groesse der ScrollBars aus
200         // den Settings abgefragt werden.
201         if( rDCEvt.GetFlags() & SETTINGS_STYLE )
202         {
203             pSh->LockPaint();
204             bUnlockPaint = sal_True;
205             ViewShell::DeleteReplacementBitmaps();
206             GetView().InvalidateBorder();               //Scrollbarbreiten
207         }
208         break;
209 
210     case DATACHANGED_PRINTER:
211     case DATACHANGED_DISPLAY:
212     case DATACHANGED_FONTS:
213     case DATACHANGED_FONTSUBSTITUTION:
214         pSh->LockPaint();
215         bUnlockPaint = sal_True;
216         GetView().GetDocShell()->UpdateFontList(); // z.B. Druckerwechsel
217         break;
218     }
219     pSh->LockView( bViewWasLocked );
220     if( bUnlockPaint )
221         pSh->UnlockPaint();
222 }
223 
224 /* vim: set noet sw=4 ts=4: */
225