xref: /aoo41x/main/sw/source/ui/wrtsh/wrtsh3.cxx (revision d5370dc8)
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_TRANSFORM_POS_X,           // ( SID_SVX_START + 88 )  // for TransformationPropertyPanel
131         SID_ATTR_TRANSFORM_POS_Y,           // ( SID_SVX_START + 89 )  // for TransformationPropertyPanel
132         SID_ATTR_TRANSFORM_WIDTH,           // ( SID_SVX_START + 90 )  // for TransformationPropertyPanel
133         SID_ATTR_TRANSFORM_HEIGHT,          // ( SID_SVX_START + 91 )  // for TransformationPropertyPanel
134         SID_ATTR_TRANSFORM_ROT_X,           // ( SID_SVX_START + 93 )  // for TransformationPropertyPanel
135         SID_ATTR_TRANSFORM_ROT_Y,           // ( SID_SVX_START + 94 )  // for TransformationPropertyPanel
136         SID_ATTR_TRANSFORM_ANGLE,           // ( SID_SVX_START + 95 )  // for TransformationPropertyPanel
137         SID_ATTR_FILL_STYLE,                // ( SID_SVX_START + 164 )
138         SID_ATTR_FILL_COLOR,                // ( SID_SVX_START + 165 )
139         SID_ATTR_FILL_GRADIENT,             // ( SID_SVX_START + 166 ) // for AreaPropertyPanel
140         SID_ATTR_FILL_HATCH,                // ( SID_SVX_START + 167 ) // for AreaPropertyPanel
141         SID_ATTR_FILL_BITMAP,               // ( SID_SVX_START + 168 ) // for AreaPropertyPanel
142         SID_ATTR_LINE_STYLE,                // ( SID_SVX_START + 169 )
143         SID_ATTR_LINE_DASH,                 // ( SID_SVX_START + 170 ) // for LinePropertyPanel
144         SID_ATTR_LINE_WIDTH,                // ( SID_SVX_START + 171 )
145         SID_ATTR_LINE_COLOR,                // ( SID_SVX_START + 172 )
146         SID_ATTR_LINE_START,                // ( SID_SVX_START + 173 ) // for LinePropertyPanel
147         SID_ATTR_LINE_END,                  // ( SID_SVX_START + 174 ) // for LinePropertyPanel
148         SID_COLOR_TABLE,                    // ( SID_SVX_START + 179 ) // for AreaPropertyPanel
149         SID_GRADIENT_LIST,                  // ( SID_SVX_START + 180 ) // for AreaPropertyPanel
150         SID_HATCH_LIST,                     // ( SID_SVX_START + 181 ) // for AreaPropertyPanel
151         SID_BITMAP_LIST,                    // ( SID_SVX_START + 182 ) // for AreaPropertyPanel
152         SID_LINEEND_LIST,                   // ( SID_SVX_START + 184 ) // for LinePropertyPanel
153         SID_ATTR_TRANSFORM_PROTECT_POS,     // ( SID_SVX_START + 236 ) // for TransformationPropertyPanel
154         SID_ATTR_TRANSFORM_PROTECT_SIZE,    // ( SID_SVX_START + 237 ) // for TransformationPropertyPanel
155         SID_ATTR_TRANSFORM_AUTOWIDTH,       // ( SID_SVX_START + 310 ) // for TransformationPropertyPanel
156         SID_ATTR_TRANSFORM_AUTOHEIGHT,      // ( SID_SVX_START + 311 ) // for TransformationPropertyPanel
157         SID_ATTR_TRANSFORM_ANCHOR,          // ( SID_SVX_START + 318 ) // for TransformationPropertyPanel
158         SID_ATTR_FILL_TRANSPARENCE,         // (SID_SVX_START+1105)
159         SID_ATTR_FILL_FLOATTRANSPARENCE,    // (SID_SVX_START+1106)
160         SID_ATTR_LINE_TRANSPARENCE,         // (SID_SVX_START+1107)
161         SID_ATTR_LINE_JOINT,                // (SID_SVX_START+1110)
162         SID_ATTR_LINE_CAP,                  // (SID_SVX_START+1111)
163         0
164     };
165 
166     GetView().GetViewFrame()->GetBindings().Invalidate(aInval);
167 
168     sal_Bool bOldVal = bNoInterrupt;
169     bNoInterrupt = sal_True;    // Trick, um AttrChangedNotify ueber Timer auszufuehren
170     GetView().AttrChangedNotify(this);
171     bNoInterrupt = bOldVal;
172 }
173 
174 sal_Bool SwWrtShell::GotoMark( const ::rtl::OUString& rName )
175 {
176     IDocumentMarkAccess::const_iterator_t ppMark = getIDocumentMarkAccess()->findMark( rName );
177     if(ppMark == getIDocumentMarkAccess()->getMarksEnd()) return false;
178     return MoveBookMark( BOOKMARK_INDEX, ppMark->get() );
179 }
180 
181 
182 sal_Bool SwWrtShell::GotoMark( const ::sw::mark::IMark* const pMark )
183 {
184     return MoveBookMark( BOOKMARK_INDEX, pMark );
185 }
186 
187 
188 sal_Bool SwWrtShell::GoNextBookmark()
189 {
190     return MoveBookMark( BOOKMARK_NEXT );
191 }
192 
193 
194 sal_Bool SwWrtShell::GoPrevBookmark()
195 {
196     return MoveBookMark( BOOKMARK_PREV );
197 }
198 
199 
200 void SwWrtShell::ExecMacro( const SvxMacro& rMacro, String* pRet, SbxArray* pArgs )
201 {
202     // OD 11.02.2003 #100556# - execute macro, if it is allowed.
203     if ( IsMacroExecAllowed() )
204     {
205         GetDoc()->ExecMacro( rMacro, pRet, pArgs );
206     }
207 }
208 
209 
210 sal_uInt16 SwWrtShell::CallEvent( sal_uInt16 nEvent, const SwCallMouseEvent& rCallEvent,
211                                 sal_Bool bChkPtr, SbxArray* pArgs,
212                                 const Link* pCallBack )
213 {
214     return GetDoc()->CallEvent( nEvent, rCallEvent, bChkPtr, pArgs, pCallBack );
215 }
216 
217 
218     // fall ein util::URL-Button selektiert ist, dessen util::URL returnen, ansonsten
219     // einen LeerString
220 sal_Bool SwWrtShell::GetURLFromButton( String& rURL, String& rDescr ) const
221 {
222     sal_Bool bRet = sal_False;
223     const SdrView *pDView = GetDrawView();
224     if( pDView )
225     {
226         // Ein Fly ist genau dann erreichbar, wenn er selektiert ist.
227         const SdrMarkList &rMarkList = pDView->GetMarkedObjectList();
228 
229         if (rMarkList.GetMark(0))
230         {
231             SdrUnoObj* pUnoCtrl = PTR_CAST(SdrUnoObj, rMarkList.GetMark(0)->GetMarkedSdrObj());
232             if (pUnoCtrl && FmFormInventor == pUnoCtrl->GetObjInventor())
233             {
234                 uno::Reference< awt::XControlModel >  xControlModel = pUnoCtrl->GetUnoControlModel();
235 
236                 ASSERT( xControlModel.is(), "UNO-Control ohne Model" );
237                 if( !xControlModel.is() )
238                     return bRet;
239 
240                 uno::Reference< beans::XPropertySet >  xPropSet(xControlModel, uno::UNO_QUERY);
241 
242                 uno::Any aTmp;
243 
244                 form::FormButtonType eButtonType = form::FormButtonType_URL;
245                 uno::Reference< beans::XPropertySetInfo >   xInfo = xPropSet->getPropertySetInfo();
246                 if(xInfo->hasPropertyByName( C2U("ButtonType") ))
247                 {
248                     aTmp = xPropSet->getPropertyValue( C2U("ButtonType") );
249                     form::FormButtonType eTmpButtonType;
250                     aTmp >>= eTmpButtonType;
251                     if( eButtonType == eTmpButtonType)
252                     {
253                         // Label
254                         aTmp = xPropSet->getPropertyValue( C2U("Label") );
255                         OUString uTmp;
256                         if( (aTmp >>= uTmp) && uTmp.getLength())
257                         {
258                             rDescr = String(uTmp);
259                         }
260 
261                         // util::URL
262                         aTmp = xPropSet->getPropertyValue( C2U("TargetURL") );
263                         if( (aTmp >>= uTmp) && uTmp.getLength())
264                         {
265                             rURL = String(uTmp);
266                         }
267                         bRet = sal_True;
268                     }
269                 }
270             }
271         }
272     }
273 
274     return bRet;
275 }
276