Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <svx/svxids.hrc>
21 : #include <sfx2/app.hxx>
22 : #include <sfx2/childwin.hxx>
23 : #include <sfx2/bindings.hxx>
24 : #include <svx/svdmark.hxx>
25 : #include <svx/svdview.hxx>
26 : #include <svx/fmglob.hxx>
27 : #include <svx/svdouno.hxx>
28 : #include <com/sun/star/form/FormButtonType.hpp>
29 : #include <com/sun/star/beans/XPropertySet.hpp>
30 : #include <sfx2/htmlmode.hxx>
31 : #include "wrtsh.hxx"
32 : #include "view.hxx"
33 : #include "IMark.hxx"
34 : #include "doc.hxx"
35 : #include "wrtsh.hrc"
36 :
37 : #include <unomid.h>
38 :
39 : using namespace ::com::sun::star;
40 :
41 : extern bool bNoInterrupt; // in mainwn.cxx
42 :
43 0 : sal_Bool SwWrtShell::MoveBookMark( BookMarkMove eFuncId, const ::sw::mark::IMark* const pMark)
44 : {
45 0 : addCurrentPosition();
46 0 : (this->*fnKillSel)( 0, sal_False );
47 :
48 0 : sal_Bool bRet = sal_True;
49 0 : switch(eFuncId)
50 : {
51 0 : case BOOKMARK_INDEX:bRet = SwCrsrShell::GotoMark( pMark );break;
52 0 : case BOOKMARK_NEXT: bRet = SwCrsrShell::GoNextBookmark();break;
53 0 : case BOOKMARK_PREV: bRet = SwCrsrShell::GoPrevBookmark();break;
54 : default:;//prevent warning
55 : }
56 :
57 0 : if( bRet && IsSelFrmMode() )
58 : {
59 0 : UnSelectFrm();
60 0 : LeaveSelFrmMode();
61 : }
62 0 : if( IsSelection() )
63 : {
64 0 : fnKillSel = &SwWrtShell::ResetSelect;
65 0 : fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
66 : }
67 0 : return bRet;
68 : }
69 :
70 0 : sal_Bool SwWrtShell::GotoField( const SwFmtFld& rFld )
71 : {
72 0 : (this->*fnKillSel)( 0, sal_False );
73 :
74 0 : sal_Bool bRet = SwCrsrShell::GotoFld( rFld );
75 0 : if( bRet && IsSelFrmMode() )
76 : {
77 0 : UnSelectFrm();
78 0 : LeaveSelFrmMode();
79 : }
80 :
81 0 : if( IsSelection() )
82 : {
83 0 : fnKillSel = &SwWrtShell::ResetSelect;
84 0 : fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
85 : }
86 :
87 0 : return bRet;
88 : }
89 :
90 0 : bool SwWrtShell::GotoFieldmark(::sw::mark::IFieldmark const * const pMark)
91 : {
92 0 : (this->*fnKillSel)( 0, sal_False );
93 0 : bool bRet = SwCrsrShell::GotoFieldmark(pMark);
94 0 : if( bRet && IsSelFrmMode() )
95 : {
96 0 : UnSelectFrm();
97 0 : LeaveSelFrmMode();
98 : }
99 0 : if( IsSelection() )
100 : {
101 0 : fnKillSel = &SwWrtShell::ResetSelect;
102 0 : fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
103 : }
104 0 : return bRet;
105 : }
106 :
107 : // Invalidate FontWork-Slots
108 :
109 380 : void SwWrtShell::DrawSelChanged( )
110 : {
111 : static sal_uInt16 const aInval[] =
112 : {
113 : SID_ATTR_FILL_STYLE, SID_ATTR_FILL_COLOR, SID_ATTR_LINE_STYLE,
114 : SID_ATTR_LINE_WIDTH, SID_ATTR_LINE_COLOR,
115 : /*AF: these may be needed for the sidebar.
116 : SID_SVX_AREA_TRANSPARENCY, SID_SVX_AREA_TRANSP_GRADIENT,
117 : SID_SVX_AREA_TRANS_TYPE,
118 : */
119 : 0
120 : };
121 :
122 380 : GetView().GetViewFrame()->GetBindings().Invalidate(aInval);
123 :
124 380 : bool bOldVal = bNoInterrupt;
125 380 : bNoInterrupt = true; // Trick to run AttrChangedNotify by timer.
126 380 : GetView().AttrChangedNotify(this);
127 380 : bNoInterrupt = bOldVal;
128 380 : }
129 :
130 0 : sal_Bool SwWrtShell::GotoMark( const OUString& rName )
131 : {
132 0 : IDocumentMarkAccess::const_iterator_t ppMark = getIDocumentMarkAccess()->findMark( rName );
133 0 : if(ppMark == getIDocumentMarkAccess()->getMarksEnd()) return false;
134 0 : return MoveBookMark( BOOKMARK_INDEX, ppMark->get() );
135 : }
136 :
137 0 : sal_Bool SwWrtShell::GotoMark( const ::sw::mark::IMark* const pMark )
138 : {
139 0 : return MoveBookMark( BOOKMARK_INDEX, pMark );
140 : }
141 :
142 0 : sal_Bool SwWrtShell::GoNextBookmark()
143 : {
144 0 : return MoveBookMark( BOOKMARK_NEXT );
145 : }
146 :
147 0 : sal_Bool SwWrtShell::GoPrevBookmark()
148 : {
149 0 : return MoveBookMark( BOOKMARK_PREV );
150 : }
151 :
152 0 : void SwWrtShell::ExecMacro( const SvxMacro& rMacro, String* pRet, SbxArray* pArgs )
153 : {
154 : // OD 11.02.2003 #100556# - execute macro, if it is allowed.
155 0 : if ( IsMacroExecAllowed() )
156 : {
157 0 : GetDoc()->ExecMacro( rMacro, pRet, pArgs );
158 : }
159 0 : }
160 :
161 :
162 0 : sal_uInt16 SwWrtShell::CallEvent( sal_uInt16 nEvent, const SwCallMouseEvent& rCallEvent,
163 : bool bChkPtr, SbxArray* pArgs,
164 : const Link* pCallBack )
165 : {
166 0 : return GetDoc()->CallEvent( nEvent, rCallEvent, bChkPtr, pArgs, pCallBack );
167 : }
168 :
169 :
170 : // If a util::URL-Button is selected, return its util::URL
171 : // otherwise an emtpy string.
172 0 : bool SwWrtShell::GetURLFromButton( String& rURL, String& rDescr ) const
173 : {
174 0 : bool bRet = false;
175 0 : const SdrView *pDView = GetDrawView();
176 0 : if( pDView )
177 : {
178 : // A fly is precisely achievable if it is selected.
179 0 : const SdrMarkList &rMarkList = pDView->GetMarkedObjectList();
180 :
181 0 : if (rMarkList.GetMark(0))
182 : {
183 0 : SdrUnoObj* pUnoCtrl = PTR_CAST(SdrUnoObj, rMarkList.GetMark(0)->GetMarkedSdrObj());
184 0 : if (pUnoCtrl && FmFormInventor == pUnoCtrl->GetObjInventor())
185 : {
186 0 : uno::Reference< awt::XControlModel > xControlModel = pUnoCtrl->GetUnoControlModel();
187 :
188 : OSL_ENSURE( xControlModel.is(), "UNO-Control without Model" );
189 0 : if( !xControlModel.is() )
190 0 : return bRet;
191 :
192 0 : uno::Reference< beans::XPropertySet > xPropSet(xControlModel, uno::UNO_QUERY);
193 :
194 0 : uno::Any aTmp;
195 :
196 0 : form::FormButtonType eButtonType = form::FormButtonType_URL;
197 0 : uno::Reference< beans::XPropertySetInfo > xInfo = xPropSet->getPropertySetInfo();
198 0 : if(xInfo->hasPropertyByName( "ButtonType" ))
199 : {
200 0 : aTmp = xPropSet->getPropertyValue( "ButtonType" );
201 : form::FormButtonType eTmpButtonType;
202 0 : aTmp >>= eTmpButtonType;
203 0 : if( eButtonType == eTmpButtonType)
204 : {
205 : // Label
206 0 : aTmp = xPropSet->getPropertyValue( "Label" );
207 0 : OUString uTmp;
208 0 : if( (aTmp >>= uTmp) && !uTmp.isEmpty())
209 : {
210 0 : rDescr = String(uTmp);
211 : }
212 :
213 : // util::URL
214 0 : aTmp = xPropSet->getPropertyValue( "TargetURL" );
215 0 : if( (aTmp >>= uTmp) && !uTmp.isEmpty())
216 : {
217 0 : rURL = String(uTmp);
218 : }
219 0 : bRet = true;
220 : }
221 0 : }
222 : }
223 : }
224 : }
225 :
226 0 : return bRet;
227 99 : }
228 :
229 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|