xref: /aoo41x/main/sw/source/ui/wrtsh/wrtsh3.cxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_sw.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir #ifndef _SVX_SVXIDS_HRC //autogen
33*cdf0e10cSrcweir #include <svx/svxids.hrc>
34*cdf0e10cSrcweir #endif
35*cdf0e10cSrcweir #include <sfx2/app.hxx>
36*cdf0e10cSrcweir #include <sfx2/childwin.hxx>
37*cdf0e10cSrcweir #include <sfx2/bindings.hxx>
38*cdf0e10cSrcweir #include <svx/svdmark.hxx>
39*cdf0e10cSrcweir #include <svx/svdview.hxx>
40*cdf0e10cSrcweir #include <svx/fmglob.hxx>
41*cdf0e10cSrcweir #include <svx/svdouno.hxx>
42*cdf0e10cSrcweir #include <com/sun/star/form/FormButtonType.hpp>
43*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
44*cdf0e10cSrcweir #include <svx/htmlmode.hxx>
45*cdf0e10cSrcweir #include <tools/urlobj.hxx>
46*cdf0e10cSrcweir #include "wrtsh.hxx"
47*cdf0e10cSrcweir #include "view.hxx"
48*cdf0e10cSrcweir #include "IMark.hxx"
49*cdf0e10cSrcweir #include "doc.hxx"
50*cdf0e10cSrcweir #include "wrtsh.hrc"
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir #include <unomid.h>
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir using namespace ::com::sun::star;
56*cdf0e10cSrcweir using ::rtl::OUString;
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir extern sal_Bool bNoInterrupt;       // in mainwn.cxx
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir sal_Bool SwWrtShell::MoveBookMark( BookMarkMove eFuncId, const ::sw::mark::IMark* const pMark)
61*cdf0e10cSrcweir {
62*cdf0e10cSrcweir //JP 08.03.96: die Wizards brauchen die Selektion !!
63*cdf0e10cSrcweir //  EndSelect();
64*cdf0e10cSrcweir     (this->*fnKillSel)( 0, sal_False );
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir     sal_Bool bRet = sal_True;
67*cdf0e10cSrcweir     switch(eFuncId)
68*cdf0e10cSrcweir     {
69*cdf0e10cSrcweir         case BOOKMARK_INDEX:bRet = SwCrsrShell::GotoMark( pMark );break;
70*cdf0e10cSrcweir         case BOOKMARK_NEXT: bRet = SwCrsrShell::GoNextBookmark();break;
71*cdf0e10cSrcweir         case BOOKMARK_PREV: bRet = SwCrsrShell::GoPrevBookmark();break;
72*cdf0e10cSrcweir         default:;//prevent warning
73*cdf0e10cSrcweir     }
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir     if( bRet && IsSelFrmMode() )
76*cdf0e10cSrcweir     {
77*cdf0e10cSrcweir         UnSelectFrm();
78*cdf0e10cSrcweir         LeaveSelFrmMode();
79*cdf0e10cSrcweir     }
80*cdf0e10cSrcweir     if( IsSelection() )
81*cdf0e10cSrcweir     {
82*cdf0e10cSrcweir         fnKillSel = &SwWrtShell::ResetSelect;
83*cdf0e10cSrcweir         fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
84*cdf0e10cSrcweir     }
85*cdf0e10cSrcweir     return bRet;
86*cdf0e10cSrcweir }
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir sal_Bool SwWrtShell::GotoField( const SwFmtFld& rFld )
89*cdf0e10cSrcweir {
90*cdf0e10cSrcweir     (this->*fnKillSel)( 0, sal_False );
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir     sal_Bool bRet = SwCrsrShell::GotoFld( rFld );
93*cdf0e10cSrcweir     if( bRet && IsSelFrmMode() )
94*cdf0e10cSrcweir     {
95*cdf0e10cSrcweir         UnSelectFrm();
96*cdf0e10cSrcweir         LeaveSelFrmMode();
97*cdf0e10cSrcweir     }
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir 	if( IsSelection() )
100*cdf0e10cSrcweir     {
101*cdf0e10cSrcweir         fnKillSel = &SwWrtShell::ResetSelect;
102*cdf0e10cSrcweir         fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
103*cdf0e10cSrcweir     }
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir 	return bRet;
106*cdf0e10cSrcweir }
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir bool SwWrtShell::GotoFieldmark(::sw::mark::IFieldmark const * const pMark)
109*cdf0e10cSrcweir {
110*cdf0e10cSrcweir     (this->*fnKillSel)( 0, sal_False );
111*cdf0e10cSrcweir     bool bRet = SwCrsrShell::GotoFieldmark(pMark);
112*cdf0e10cSrcweir     if( bRet && IsSelFrmMode() )
113*cdf0e10cSrcweir     {
114*cdf0e10cSrcweir         UnSelectFrm();
115*cdf0e10cSrcweir         LeaveSelFrmMode();
116*cdf0e10cSrcweir     }
117*cdf0e10cSrcweir     if( IsSelection() )
118*cdf0e10cSrcweir     {
119*cdf0e10cSrcweir         fnKillSel = &SwWrtShell::ResetSelect;
120*cdf0e10cSrcweir         fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
121*cdf0e10cSrcweir     }
122*cdf0e10cSrcweir     return bRet;
123*cdf0e10cSrcweir }
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir /*--------------------------------------------------------------------
126*cdf0e10cSrcweir     Beschreibung: FontWork-Slots invalidieren
127*cdf0e10cSrcweir  --------------------------------------------------------------------*/
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir void SwWrtShell::DrawSelChanged( )
131*cdf0e10cSrcweir {
132*cdf0e10cSrcweir     static sal_uInt16 __READONLY_DATA aInval[] =
133*cdf0e10cSrcweir     {
134*cdf0e10cSrcweir         SID_ATTR_FILL_STYLE, SID_ATTR_FILL_COLOR, SID_ATTR_LINE_STYLE,
135*cdf0e10cSrcweir         SID_ATTR_LINE_WIDTH, SID_ATTR_LINE_COLOR, 0
136*cdf0e10cSrcweir     };
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir     GetView().GetViewFrame()->GetBindings().Invalidate(aInval);
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir     sal_Bool bOldVal = bNoInterrupt;
141*cdf0e10cSrcweir     bNoInterrupt = sal_True;    // Trick, um AttrChangedNotify ueber Timer auszufuehren
142*cdf0e10cSrcweir     GetView().AttrChangedNotify(this);
143*cdf0e10cSrcweir     bNoInterrupt = bOldVal;
144*cdf0e10cSrcweir }
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir sal_Bool SwWrtShell::GotoMark( const ::rtl::OUString& rName )
147*cdf0e10cSrcweir {
148*cdf0e10cSrcweir     IDocumentMarkAccess::const_iterator_t ppMark = getIDocumentMarkAccess()->findMark( rName );
149*cdf0e10cSrcweir     if(ppMark == getIDocumentMarkAccess()->getMarksEnd()) return false;
150*cdf0e10cSrcweir     return MoveBookMark( BOOKMARK_INDEX, ppMark->get() );
151*cdf0e10cSrcweir }
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir sal_Bool SwWrtShell::GotoMark( const ::sw::mark::IMark* const pMark )
155*cdf0e10cSrcweir {
156*cdf0e10cSrcweir     return MoveBookMark( BOOKMARK_INDEX, pMark );
157*cdf0e10cSrcweir }
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir sal_Bool SwWrtShell::GoNextBookmark()
161*cdf0e10cSrcweir {
162*cdf0e10cSrcweir     return MoveBookMark( BOOKMARK_NEXT );
163*cdf0e10cSrcweir }
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir sal_Bool SwWrtShell::GoPrevBookmark()
167*cdf0e10cSrcweir {
168*cdf0e10cSrcweir     return MoveBookMark( BOOKMARK_PREV );
169*cdf0e10cSrcweir }
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir void SwWrtShell::ExecMacro( const SvxMacro& rMacro, String* pRet, SbxArray* pArgs )
173*cdf0e10cSrcweir {
174*cdf0e10cSrcweir     // OD 11.02.2003 #100556# - execute macro, if it is allowed.
175*cdf0e10cSrcweir     if ( IsMacroExecAllowed() )
176*cdf0e10cSrcweir     {
177*cdf0e10cSrcweir         GetDoc()->ExecMacro( rMacro, pRet, pArgs );
178*cdf0e10cSrcweir     }
179*cdf0e10cSrcweir }
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir sal_uInt16 SwWrtShell::CallEvent( sal_uInt16 nEvent, const SwCallMouseEvent& rCallEvent,
183*cdf0e10cSrcweir                                 sal_Bool bChkPtr, SbxArray* pArgs,
184*cdf0e10cSrcweir                                 const Link* pCallBack )
185*cdf0e10cSrcweir {
186*cdf0e10cSrcweir     return GetDoc()->CallEvent( nEvent, rCallEvent, bChkPtr, pArgs, pCallBack );
187*cdf0e10cSrcweir }
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir     // fall ein util::URL-Button selektiert ist, dessen util::URL returnen, ansonsten
191*cdf0e10cSrcweir     // einen LeerString
192*cdf0e10cSrcweir sal_Bool SwWrtShell::GetURLFromButton( String& rURL, String& rDescr ) const
193*cdf0e10cSrcweir {
194*cdf0e10cSrcweir     sal_Bool bRet = sal_False;
195*cdf0e10cSrcweir     const SdrView *pDView = GetDrawView();
196*cdf0e10cSrcweir     if( pDView )
197*cdf0e10cSrcweir     {
198*cdf0e10cSrcweir         // Ein Fly ist genau dann erreichbar, wenn er selektiert ist.
199*cdf0e10cSrcweir         const SdrMarkList &rMarkList = pDView->GetMarkedObjectList();
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir         if (rMarkList.GetMark(0))
202*cdf0e10cSrcweir         {
203*cdf0e10cSrcweir             SdrUnoObj* pUnoCtrl = PTR_CAST(SdrUnoObj, rMarkList.GetMark(0)->GetMarkedSdrObj());
204*cdf0e10cSrcweir             if (pUnoCtrl && FmFormInventor == pUnoCtrl->GetObjInventor())
205*cdf0e10cSrcweir             {
206*cdf0e10cSrcweir                 uno::Reference< awt::XControlModel >  xControlModel = pUnoCtrl->GetUnoControlModel();
207*cdf0e10cSrcweir 
208*cdf0e10cSrcweir                 ASSERT( xControlModel.is(), "UNO-Control ohne Model" );
209*cdf0e10cSrcweir                 if( !xControlModel.is() )
210*cdf0e10cSrcweir                     return bRet;
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir                 uno::Reference< beans::XPropertySet >  xPropSet(xControlModel, uno::UNO_QUERY);
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir                 uno::Any aTmp;
215*cdf0e10cSrcweir 
216*cdf0e10cSrcweir                 form::FormButtonType eButtonType = form::FormButtonType_URL;
217*cdf0e10cSrcweir                 uno::Reference< beans::XPropertySetInfo >   xInfo = xPropSet->getPropertySetInfo();
218*cdf0e10cSrcweir                 if(xInfo->hasPropertyByName( C2U("ButtonType") ))
219*cdf0e10cSrcweir                 {
220*cdf0e10cSrcweir                     aTmp = xPropSet->getPropertyValue( C2U("ButtonType") );
221*cdf0e10cSrcweir                     form::FormButtonType eTmpButtonType;
222*cdf0e10cSrcweir                     aTmp >>= eTmpButtonType;
223*cdf0e10cSrcweir                     if( eButtonType == eTmpButtonType)
224*cdf0e10cSrcweir                     {
225*cdf0e10cSrcweir                         // Label
226*cdf0e10cSrcweir                         aTmp = xPropSet->getPropertyValue( C2U("Label") );
227*cdf0e10cSrcweir                         OUString uTmp;
228*cdf0e10cSrcweir                         if( (aTmp >>= uTmp) && uTmp.getLength())
229*cdf0e10cSrcweir                         {
230*cdf0e10cSrcweir                             rDescr = String(uTmp);
231*cdf0e10cSrcweir                         }
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir                         // util::URL
234*cdf0e10cSrcweir                         aTmp = xPropSet->getPropertyValue( C2U("TargetURL") );
235*cdf0e10cSrcweir                         if( (aTmp >>= uTmp) && uTmp.getLength())
236*cdf0e10cSrcweir                         {
237*cdf0e10cSrcweir                             rURL = String(uTmp);
238*cdf0e10cSrcweir                         }
239*cdf0e10cSrcweir                         bRet = sal_True;
240*cdf0e10cSrcweir                     }
241*cdf0e10cSrcweir                 }
242*cdf0e10cSrcweir             }
243*cdf0e10cSrcweir         }
244*cdf0e10cSrcweir     }
245*cdf0e10cSrcweir 
246*cdf0e10cSrcweir     return bRet;
247*cdf0e10cSrcweir }
248