xref: /trunk/main/sw/source/ui/wrtsh/wrtsh3.cxx (revision dec99bbd)
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 #ifndef _SVX_SVXIDS_HRC //autogen
29 #include <svx/svxids.hrc>
30 #endif
31 #include <sfx2/app.hxx>
32 #include <sfx2/childwin.hxx>
33 #include <sfx2/bindings.hxx>
34 #include <svx/svdmark.hxx>
35 #include <svx/svdview.hxx>
36 #include <svx/fmglob.hxx>
37 #include <svx/svdouno.hxx>
38 #include <com/sun/star/form/FormButtonType.hpp>
39 #include <com/sun/star/beans/XPropertySet.hpp>
40 #include <svx/htmlmode.hxx>
41 #include <tools/urlobj.hxx>
42 #include "wrtsh.hxx"
43 #include "view.hxx"
44 #include "IMark.hxx"
45 #include "doc.hxx"
46 #include "wrtsh.hrc"
47 
48 #include <unomid.h>
49 
50 
51 using namespace ::com::sun::star;
52 using ::rtl::OUString;
53 
54 extern sal_Bool bNoInterrupt;       // in mainwn.cxx
55 
MoveBookMark(BookMarkMove eFuncId,const::sw::mark::IMark * const pMark)56 sal_Bool SwWrtShell::MoveBookMark( BookMarkMove eFuncId, const ::sw::mark::IMark* const pMark)
57 {
58 //JP 08.03.96: die Wizards brauchen die Selektion !!
59 //  EndSelect();
60     (this->*fnKillSel)( 0, sal_False );
61 
62     sal_Bool bRet = sal_True;
63     switch(eFuncId)
64     {
65         case BOOKMARK_INDEX:bRet = SwCrsrShell::GotoMark( pMark );break;
66         case BOOKMARK_NEXT: bRet = SwCrsrShell::GoNextBookmark();break;
67         case BOOKMARK_PREV: bRet = SwCrsrShell::GoPrevBookmark();break;
68         default:;//prevent warning
69     }
70 
71     if( bRet && IsSelFrmMode() )
72     {
73         UnSelectFrm();
74         LeaveSelFrmMode();
75     }
76     if( IsSelection() )
77     {
78         fnKillSel = &SwWrtShell::ResetSelect;
79         fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
80     }
81     return bRet;
82 }
83 
GotoField(const SwFmtFld & rFld)84 sal_Bool SwWrtShell::GotoField( const SwFmtFld& rFld )
85 {
86     (this->*fnKillSel)( 0, sal_False );
87 
88     sal_Bool bRet = SwCrsrShell::GotoFld( rFld );
89     if( bRet && IsSelFrmMode() )
90     {
91         UnSelectFrm();
92         LeaveSelFrmMode();
93     }
94 
95 	if( IsSelection() )
96     {
97         fnKillSel = &SwWrtShell::ResetSelect;
98         fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
99     }
100 
101 	return bRet;
102 }
103 
GotoFieldmark(::sw::mark::IFieldmark const * const pMark)104 bool SwWrtShell::GotoFieldmark(::sw::mark::IFieldmark const * const pMark)
105 {
106     (this->*fnKillSel)( 0, sal_False );
107     bool bRet = SwCrsrShell::GotoFieldmark(pMark);
108     if( bRet && IsSelFrmMode() )
109     {
110         UnSelectFrm();
111         LeaveSelFrmMode();
112     }
113     if( IsSelection() )
114     {
115         fnKillSel = &SwWrtShell::ResetSelect;
116         fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
117     }
118     return bRet;
119 }
120 
121 /*--------------------------------------------------------------------
122     Beschreibung: FontWork-Slots invalidieren
123  --------------------------------------------------------------------*/
124 
125 
DrawSelChanged()126 void SwWrtShell::DrawSelChanged( )
127 {
128     static sal_uInt16 __READONLY_DATA aInval[] =
129     {
130         SID_ATTR_FILL_STYLE, SID_ATTR_FILL_COLOR, SID_ATTR_LINE_STYLE,
131         SID_ATTR_LINE_WIDTH, SID_ATTR_LINE_COLOR,
132         /*AF: these may be needed for the sidebar.
133         SID_SVX_AREA_TRANSPARENCY, SID_SVX_AREA_TRANSP_GRADIENT,
134         SID_SVX_AREA_TRANS_TYPE,
135         */
136         0
137     };
138 
139     GetView().GetViewFrame()->GetBindings().Invalidate(aInval);
140 
141     sal_Bool bOldVal = bNoInterrupt;
142     bNoInterrupt = sal_True;    // Trick, um AttrChangedNotify ueber Timer auszufuehren
143     GetView().AttrChangedNotify(this);
144     bNoInterrupt = bOldVal;
145 }
146 
GotoMark(const::rtl::OUString & rName)147 sal_Bool SwWrtShell::GotoMark( const ::rtl::OUString& rName )
148 {
149     IDocumentMarkAccess::const_iterator_t ppMark = getIDocumentMarkAccess()->findMark( rName );
150     if(ppMark == getIDocumentMarkAccess()->getAllMarksEnd()) return false;
151     return MoveBookMark( BOOKMARK_INDEX, ppMark->get() );
152 }
153 
154 
GotoMark(const::sw::mark::IMark * const pMark)155 sal_Bool SwWrtShell::GotoMark( const ::sw::mark::IMark* const pMark )
156 {
157     return MoveBookMark( BOOKMARK_INDEX, pMark );
158 }
159 
160 
GoNextBookmark()161 sal_Bool SwWrtShell::GoNextBookmark()
162 {
163     return MoveBookMark( BOOKMARK_NEXT );
164 }
165 
166 
GoPrevBookmark()167 sal_Bool SwWrtShell::GoPrevBookmark()
168 {
169     return MoveBookMark( BOOKMARK_PREV );
170 }
171 
172 
ExecMacro(const SvxMacro & rMacro,String * pRet,SbxArray * pArgs)173 void SwWrtShell::ExecMacro( const SvxMacro& rMacro, String* pRet, SbxArray* pArgs )
174 {
175     // OD 11.02.2003 #100556# - execute macro, if it is allowed.
176     if ( IsMacroExecAllowed() )
177     {
178         GetDoc()->ExecMacro( rMacro, pRet, pArgs );
179     }
180 }
181 
182 
CallEvent(sal_uInt16 nEvent,const SwCallMouseEvent & rCallEvent,sal_Bool bChkPtr,SbxArray * pArgs,const Link * pCallBack)183 sal_uInt16 SwWrtShell::CallEvent( sal_uInt16 nEvent, const SwCallMouseEvent& rCallEvent,
184                                 sal_Bool bChkPtr, SbxArray* pArgs,
185                                 const Link* pCallBack )
186 {
187     return GetDoc()->CallEvent( nEvent, rCallEvent, bChkPtr, pArgs, pCallBack );
188 }
189 
190 
191     // fall ein util::URL-Button selektiert ist, dessen util::URL returnen, ansonsten
192     // einen LeerString
GetURLFromButton(String & rURL,String & rDescr) const193 sal_Bool SwWrtShell::GetURLFromButton( String& rURL, String& rDescr ) const
194 {
195     sal_Bool bRet = sal_False;
196     const SdrView *pDView = GetDrawView();
197     if( pDView )
198     {
199         // Ein Fly ist genau dann erreichbar, wenn er selektiert ist.
200         const SdrMarkList &rMarkList = pDView->GetMarkedObjectList();
201 
202         if (rMarkList.GetMark(0))
203         {
204             SdrUnoObj* pUnoCtrl = PTR_CAST(SdrUnoObj, rMarkList.GetMark(0)->GetMarkedSdrObj());
205             if (pUnoCtrl && FmFormInventor == pUnoCtrl->GetObjInventor())
206             {
207                 uno::Reference< awt::XControlModel >  xControlModel = pUnoCtrl->GetUnoControlModel();
208 
209                 ASSERT( xControlModel.is(), "UNO-Control ohne Model" );
210                 if( !xControlModel.is() )
211                     return bRet;
212 
213                 uno::Reference< beans::XPropertySet >  xPropSet(xControlModel, uno::UNO_QUERY);
214 
215                 uno::Any aTmp;
216 
217                 form::FormButtonType eButtonType = form::FormButtonType_URL;
218                 uno::Reference< beans::XPropertySetInfo >   xInfo = xPropSet->getPropertySetInfo();
219                 if(xInfo->hasPropertyByName( C2U("ButtonType") ))
220                 {
221                     aTmp = xPropSet->getPropertyValue( C2U("ButtonType") );
222                     form::FormButtonType eTmpButtonType;
223                     aTmp >>= eTmpButtonType;
224                     if( eButtonType == eTmpButtonType)
225                     {
226                         // Label
227                         aTmp = xPropSet->getPropertyValue( C2U("Label") );
228                         OUString uTmp;
229                         if( (aTmp >>= uTmp) && uTmp.getLength())
230                         {
231                             rDescr = String(uTmp);
232                         }
233 
234                         // util::URL
235                         aTmp = xPropSet->getPropertyValue( C2U("TargetURL") );
236                         if( (aTmp >>= uTmp) && uTmp.getLength())
237                         {
238                             rURL = String(uTmp);
239                         }
240                         bRet = sal_True;
241                     }
242                 }
243             }
244         }
245     }
246 
247     return bRet;
248 }
249