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 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 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 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 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, 0 132 }; 133 134 GetView().GetViewFrame()->GetBindings().Invalidate(aInval); 135 136 sal_Bool bOldVal = bNoInterrupt; 137 bNoInterrupt = sal_True; // Trick, um AttrChangedNotify ueber Timer auszufuehren 138 GetView().AttrChangedNotify(this); 139 bNoInterrupt = bOldVal; 140 } 141 142 sal_Bool SwWrtShell::GotoMark( const ::rtl::OUString& rName ) 143 { 144 IDocumentMarkAccess::const_iterator_t ppMark = getIDocumentMarkAccess()->findMark( rName ); 145 if(ppMark == getIDocumentMarkAccess()->getMarksEnd()) return false; 146 return MoveBookMark( BOOKMARK_INDEX, ppMark->get() ); 147 } 148 149 150 sal_Bool SwWrtShell::GotoMark( const ::sw::mark::IMark* const pMark ) 151 { 152 return MoveBookMark( BOOKMARK_INDEX, pMark ); 153 } 154 155 156 sal_Bool SwWrtShell::GoNextBookmark() 157 { 158 return MoveBookMark( BOOKMARK_NEXT ); 159 } 160 161 162 sal_Bool SwWrtShell::GoPrevBookmark() 163 { 164 return MoveBookMark( BOOKMARK_PREV ); 165 } 166 167 168 void SwWrtShell::ExecMacro( const SvxMacro& rMacro, String* pRet, SbxArray* pArgs ) 169 { 170 // OD 11.02.2003 #100556# - execute macro, if it is allowed. 171 if ( IsMacroExecAllowed() ) 172 { 173 GetDoc()->ExecMacro( rMacro, pRet, pArgs ); 174 } 175 } 176 177 178 sal_uInt16 SwWrtShell::CallEvent( sal_uInt16 nEvent, const SwCallMouseEvent& rCallEvent, 179 sal_Bool bChkPtr, SbxArray* pArgs, 180 const Link* pCallBack ) 181 { 182 return GetDoc()->CallEvent( nEvent, rCallEvent, bChkPtr, pArgs, pCallBack ); 183 } 184 185 186 // fall ein util::URL-Button selektiert ist, dessen util::URL returnen, ansonsten 187 // einen LeerString 188 sal_Bool SwWrtShell::GetURLFromButton( String& rURL, String& rDescr ) const 189 { 190 sal_Bool bRet = sal_False; 191 const SdrView *pDView = GetDrawView(); 192 if( pDView ) 193 { 194 // Ein Fly ist genau dann erreichbar, wenn er selektiert ist. 195 const SdrMarkList &rMarkList = pDView->GetMarkedObjectList(); 196 197 if (rMarkList.GetMark(0)) 198 { 199 SdrUnoObj* pUnoCtrl = PTR_CAST(SdrUnoObj, rMarkList.GetMark(0)->GetMarkedSdrObj()); 200 if (pUnoCtrl && FmFormInventor == pUnoCtrl->GetObjInventor()) 201 { 202 uno::Reference< awt::XControlModel > xControlModel = pUnoCtrl->GetUnoControlModel(); 203 204 ASSERT( xControlModel.is(), "UNO-Control ohne Model" ); 205 if( !xControlModel.is() ) 206 return bRet; 207 208 uno::Reference< beans::XPropertySet > xPropSet(xControlModel, uno::UNO_QUERY); 209 210 uno::Any aTmp; 211 212 form::FormButtonType eButtonType = form::FormButtonType_URL; 213 uno::Reference< beans::XPropertySetInfo > xInfo = xPropSet->getPropertySetInfo(); 214 if(xInfo->hasPropertyByName( C2U("ButtonType") )) 215 { 216 aTmp = xPropSet->getPropertyValue( C2U("ButtonType") ); 217 form::FormButtonType eTmpButtonType; 218 aTmp >>= eTmpButtonType; 219 if( eButtonType == eTmpButtonType) 220 { 221 // Label 222 aTmp = xPropSet->getPropertyValue( C2U("Label") ); 223 OUString uTmp; 224 if( (aTmp >>= uTmp) && uTmp.getLength()) 225 { 226 rDescr = String(uTmp); 227 } 228 229 // util::URL 230 aTmp = xPropSet->getPropertyValue( C2U("TargetURL") ); 231 if( (aTmp >>= uTmp) && uTmp.getLength()) 232 { 233 rURL = String(uTmp); 234 } 235 bRet = sal_True; 236 } 237 } 238 } 239 } 240 } 241 242 return bRet; 243 } 244