xref: /AOO41X/main/sw/source/ui/wrtsh/wrtsh3.cxx (revision d5370dc8b91641fa460c79c207c7018af41d7460)
1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5efeef26fSAndrew Rist  * distributed with this work for additional information
6efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17efeef26fSAndrew Rist  * specific language governing permissions and limitations
18efeef26fSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20efeef26fSAndrew Rist  *************************************************************/
21efeef26fSAndrew Rist 
22efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #ifndef _SVX_SVXIDS_HRC //autogen
29cdf0e10cSrcweir #include <svx/svxids.hrc>
30cdf0e10cSrcweir #endif
31cdf0e10cSrcweir #include <sfx2/app.hxx>
32cdf0e10cSrcweir #include <sfx2/childwin.hxx>
33cdf0e10cSrcweir #include <sfx2/bindings.hxx>
34cdf0e10cSrcweir #include <svx/svdmark.hxx>
35cdf0e10cSrcweir #include <svx/svdview.hxx>
36cdf0e10cSrcweir #include <svx/fmglob.hxx>
37cdf0e10cSrcweir #include <svx/svdouno.hxx>
38cdf0e10cSrcweir #include <com/sun/star/form/FormButtonType.hpp>
39cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
40cdf0e10cSrcweir #include <svx/htmlmode.hxx>
41cdf0e10cSrcweir #include <tools/urlobj.hxx>
42cdf0e10cSrcweir #include "wrtsh.hxx"
43cdf0e10cSrcweir #include "view.hxx"
44cdf0e10cSrcweir #include "IMark.hxx"
45cdf0e10cSrcweir #include "doc.hxx"
46cdf0e10cSrcweir #include "wrtsh.hrc"
47cdf0e10cSrcweir 
48cdf0e10cSrcweir #include <unomid.h>
49cdf0e10cSrcweir 
50cdf0e10cSrcweir 
51cdf0e10cSrcweir using namespace ::com::sun::star;
52cdf0e10cSrcweir using ::rtl::OUString;
53cdf0e10cSrcweir 
54cdf0e10cSrcweir extern sal_Bool bNoInterrupt;       // in mainwn.cxx
55cdf0e10cSrcweir 
56cdf0e10cSrcweir sal_Bool SwWrtShell::MoveBookMark( BookMarkMove eFuncId, const ::sw::mark::IMark* const pMark)
57cdf0e10cSrcweir {
58cdf0e10cSrcweir //JP 08.03.96: die Wizards brauchen die Selektion !!
59cdf0e10cSrcweir //  EndSelect();
60cdf0e10cSrcweir     (this->*fnKillSel)( 0, sal_False );
61cdf0e10cSrcweir 
62cdf0e10cSrcweir     sal_Bool bRet = sal_True;
63cdf0e10cSrcweir     switch(eFuncId)
64cdf0e10cSrcweir     {
65cdf0e10cSrcweir         case BOOKMARK_INDEX:bRet = SwCrsrShell::GotoMark( pMark );break;
66cdf0e10cSrcweir         case BOOKMARK_NEXT: bRet = SwCrsrShell::GoNextBookmark();break;
67cdf0e10cSrcweir         case BOOKMARK_PREV: bRet = SwCrsrShell::GoPrevBookmark();break;
68cdf0e10cSrcweir         default:;//prevent warning
69cdf0e10cSrcweir     }
70cdf0e10cSrcweir 
71cdf0e10cSrcweir     if( bRet && IsSelFrmMode() )
72cdf0e10cSrcweir     {
73cdf0e10cSrcweir         UnSelectFrm();
74cdf0e10cSrcweir         LeaveSelFrmMode();
75cdf0e10cSrcweir     }
76cdf0e10cSrcweir     if( IsSelection() )
77cdf0e10cSrcweir     {
78cdf0e10cSrcweir         fnKillSel = &SwWrtShell::ResetSelect;
79cdf0e10cSrcweir         fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
80cdf0e10cSrcweir     }
81cdf0e10cSrcweir     return bRet;
82cdf0e10cSrcweir }
83cdf0e10cSrcweir 
84cdf0e10cSrcweir sal_Bool SwWrtShell::GotoField( const SwFmtFld& rFld )
85cdf0e10cSrcweir {
86cdf0e10cSrcweir     (this->*fnKillSel)( 0, sal_False );
87cdf0e10cSrcweir 
88cdf0e10cSrcweir     sal_Bool bRet = SwCrsrShell::GotoFld( rFld );
89cdf0e10cSrcweir     if( bRet && IsSelFrmMode() )
90cdf0e10cSrcweir     {
91cdf0e10cSrcweir         UnSelectFrm();
92cdf0e10cSrcweir         LeaveSelFrmMode();
93cdf0e10cSrcweir     }
94cdf0e10cSrcweir 
95cdf0e10cSrcweir 	if( IsSelection() )
96cdf0e10cSrcweir     {
97cdf0e10cSrcweir         fnKillSel = &SwWrtShell::ResetSelect;
98cdf0e10cSrcweir         fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
99cdf0e10cSrcweir     }
100cdf0e10cSrcweir 
101cdf0e10cSrcweir 	return bRet;
102cdf0e10cSrcweir }
103cdf0e10cSrcweir 
104cdf0e10cSrcweir bool SwWrtShell::GotoFieldmark(::sw::mark::IFieldmark const * const pMark)
105cdf0e10cSrcweir {
106cdf0e10cSrcweir     (this->*fnKillSel)( 0, sal_False );
107cdf0e10cSrcweir     bool bRet = SwCrsrShell::GotoFieldmark(pMark);
108cdf0e10cSrcweir     if( bRet && IsSelFrmMode() )
109cdf0e10cSrcweir     {
110cdf0e10cSrcweir         UnSelectFrm();
111cdf0e10cSrcweir         LeaveSelFrmMode();
112cdf0e10cSrcweir     }
113cdf0e10cSrcweir     if( IsSelection() )
114cdf0e10cSrcweir     {
115cdf0e10cSrcweir         fnKillSel = &SwWrtShell::ResetSelect;
116cdf0e10cSrcweir         fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
117cdf0e10cSrcweir     }
118cdf0e10cSrcweir     return bRet;
119cdf0e10cSrcweir }
120cdf0e10cSrcweir 
121cdf0e10cSrcweir /*--------------------------------------------------------------------
122cdf0e10cSrcweir     Beschreibung: FontWork-Slots invalidieren
123cdf0e10cSrcweir  --------------------------------------------------------------------*/
124cdf0e10cSrcweir 
125cdf0e10cSrcweir 
126cdf0e10cSrcweir void SwWrtShell::DrawSelChanged( )
127cdf0e10cSrcweir {
128cdf0e10cSrcweir     static sal_uInt16 __READONLY_DATA aInval[] =
129cdf0e10cSrcweir     {
130*d5370dc8SArmin Le Grand         SID_ATTR_TRANSFORM_POS_X,           // ( SID_SVX_START + 88 )  // for TransformationPropertyPanel
131*d5370dc8SArmin Le Grand         SID_ATTR_TRANSFORM_POS_Y,           // ( SID_SVX_START + 89 )  // for TransformationPropertyPanel
132*d5370dc8SArmin Le Grand         SID_ATTR_TRANSFORM_WIDTH,           // ( SID_SVX_START + 90 )  // for TransformationPropertyPanel
133*d5370dc8SArmin Le Grand         SID_ATTR_TRANSFORM_HEIGHT,          // ( SID_SVX_START + 91 )  // for TransformationPropertyPanel
134*d5370dc8SArmin Le Grand         SID_ATTR_TRANSFORM_ROT_X,           // ( SID_SVX_START + 93 )  // for TransformationPropertyPanel
135*d5370dc8SArmin Le Grand         SID_ATTR_TRANSFORM_ROT_Y,           // ( SID_SVX_START + 94 )  // for TransformationPropertyPanel
136*d5370dc8SArmin Le Grand         SID_ATTR_TRANSFORM_ANGLE,           // ( SID_SVX_START + 95 )  // for TransformationPropertyPanel
137*d5370dc8SArmin Le Grand         SID_ATTR_FILL_STYLE,                // ( SID_SVX_START + 164 )
138*d5370dc8SArmin Le Grand         SID_ATTR_FILL_COLOR,                // ( SID_SVX_START + 165 )
139*d5370dc8SArmin Le Grand         SID_ATTR_FILL_GRADIENT,             // ( SID_SVX_START + 166 ) // for AreaPropertyPanel
140*d5370dc8SArmin Le Grand         SID_ATTR_FILL_HATCH,                // ( SID_SVX_START + 167 ) // for AreaPropertyPanel
141*d5370dc8SArmin Le Grand         SID_ATTR_FILL_BITMAP,               // ( SID_SVX_START + 168 ) // for AreaPropertyPanel
142*d5370dc8SArmin Le Grand         SID_ATTR_LINE_STYLE,                // ( SID_SVX_START + 169 )
143*d5370dc8SArmin Le Grand         SID_ATTR_LINE_DASH,                 // ( SID_SVX_START + 170 ) // for LinePropertyPanel
144*d5370dc8SArmin Le Grand         SID_ATTR_LINE_WIDTH,                // ( SID_SVX_START + 171 )
145*d5370dc8SArmin Le Grand         SID_ATTR_LINE_COLOR,                // ( SID_SVX_START + 172 )
146*d5370dc8SArmin Le Grand         SID_ATTR_LINE_START,                // ( SID_SVX_START + 173 ) // for LinePropertyPanel
147*d5370dc8SArmin Le Grand         SID_ATTR_LINE_END,                  // ( SID_SVX_START + 174 ) // for LinePropertyPanel
148*d5370dc8SArmin Le Grand         SID_COLOR_TABLE,                    // ( SID_SVX_START + 179 ) // for AreaPropertyPanel
149*d5370dc8SArmin Le Grand         SID_GRADIENT_LIST,                  // ( SID_SVX_START + 180 ) // for AreaPropertyPanel
150*d5370dc8SArmin Le Grand         SID_HATCH_LIST,                     // ( SID_SVX_START + 181 ) // for AreaPropertyPanel
151*d5370dc8SArmin Le Grand         SID_BITMAP_LIST,                    // ( SID_SVX_START + 182 ) // for AreaPropertyPanel
152*d5370dc8SArmin Le Grand         SID_LINEEND_LIST,                   // ( SID_SVX_START + 184 ) // for LinePropertyPanel
153*d5370dc8SArmin Le Grand         SID_ATTR_TRANSFORM_PROTECT_POS,     // ( SID_SVX_START + 236 ) // for TransformationPropertyPanel
154*d5370dc8SArmin Le Grand         SID_ATTR_TRANSFORM_PROTECT_SIZE,    // ( SID_SVX_START + 237 ) // for TransformationPropertyPanel
155*d5370dc8SArmin Le Grand         SID_ATTR_TRANSFORM_AUTOWIDTH,       // ( SID_SVX_START + 310 ) // for TransformationPropertyPanel
156*d5370dc8SArmin Le Grand         SID_ATTR_TRANSFORM_AUTOHEIGHT,      // ( SID_SVX_START + 311 ) // for TransformationPropertyPanel
157*d5370dc8SArmin Le Grand         SID_ATTR_TRANSFORM_ANCHOR,          // ( SID_SVX_START + 318 ) // for TransformationPropertyPanel
158*d5370dc8SArmin Le Grand         SID_ATTR_FILL_TRANSPARENCE,         // (SID_SVX_START+1105)
159*d5370dc8SArmin Le Grand         SID_ATTR_FILL_FLOATTRANSPARENCE,    // (SID_SVX_START+1106)
160*d5370dc8SArmin Le Grand         SID_ATTR_LINE_TRANSPARENCE,         // (SID_SVX_START+1107)
161*d5370dc8SArmin Le Grand         SID_ATTR_LINE_JOINT,                // (SID_SVX_START+1110)
162*d5370dc8SArmin Le Grand         SID_ATTR_LINE_CAP,                  // (SID_SVX_START+1111)
163*d5370dc8SArmin Le Grand         0
164cdf0e10cSrcweir     };
165cdf0e10cSrcweir 
166cdf0e10cSrcweir     GetView().GetViewFrame()->GetBindings().Invalidate(aInval);
167cdf0e10cSrcweir 
168cdf0e10cSrcweir     sal_Bool bOldVal = bNoInterrupt;
169cdf0e10cSrcweir     bNoInterrupt = sal_True;    // Trick, um AttrChangedNotify ueber Timer auszufuehren
170cdf0e10cSrcweir     GetView().AttrChangedNotify(this);
171cdf0e10cSrcweir     bNoInterrupt = bOldVal;
172cdf0e10cSrcweir }
173cdf0e10cSrcweir 
174cdf0e10cSrcweir sal_Bool SwWrtShell::GotoMark( const ::rtl::OUString& rName )
175cdf0e10cSrcweir {
176cdf0e10cSrcweir     IDocumentMarkAccess::const_iterator_t ppMark = getIDocumentMarkAccess()->findMark( rName );
177cdf0e10cSrcweir     if(ppMark == getIDocumentMarkAccess()->getMarksEnd()) return false;
178cdf0e10cSrcweir     return MoveBookMark( BOOKMARK_INDEX, ppMark->get() );
179cdf0e10cSrcweir }
180cdf0e10cSrcweir 
181cdf0e10cSrcweir 
182cdf0e10cSrcweir sal_Bool SwWrtShell::GotoMark( const ::sw::mark::IMark* const pMark )
183cdf0e10cSrcweir {
184cdf0e10cSrcweir     return MoveBookMark( BOOKMARK_INDEX, pMark );
185cdf0e10cSrcweir }
186cdf0e10cSrcweir 
187cdf0e10cSrcweir 
188cdf0e10cSrcweir sal_Bool SwWrtShell::GoNextBookmark()
189cdf0e10cSrcweir {
190cdf0e10cSrcweir     return MoveBookMark( BOOKMARK_NEXT );
191cdf0e10cSrcweir }
192cdf0e10cSrcweir 
193cdf0e10cSrcweir 
194cdf0e10cSrcweir sal_Bool SwWrtShell::GoPrevBookmark()
195cdf0e10cSrcweir {
196cdf0e10cSrcweir     return MoveBookMark( BOOKMARK_PREV );
197cdf0e10cSrcweir }
198cdf0e10cSrcweir 
199cdf0e10cSrcweir 
200cdf0e10cSrcweir void SwWrtShell::ExecMacro( const SvxMacro& rMacro, String* pRet, SbxArray* pArgs )
201cdf0e10cSrcweir {
202cdf0e10cSrcweir     // OD 11.02.2003 #100556# - execute macro, if it is allowed.
203cdf0e10cSrcweir     if ( IsMacroExecAllowed() )
204cdf0e10cSrcweir     {
205cdf0e10cSrcweir         GetDoc()->ExecMacro( rMacro, pRet, pArgs );
206cdf0e10cSrcweir     }
207cdf0e10cSrcweir }
208cdf0e10cSrcweir 
209cdf0e10cSrcweir 
210cdf0e10cSrcweir sal_uInt16 SwWrtShell::CallEvent( sal_uInt16 nEvent, const SwCallMouseEvent& rCallEvent,
211cdf0e10cSrcweir                                 sal_Bool bChkPtr, SbxArray* pArgs,
212cdf0e10cSrcweir                                 const Link* pCallBack )
213cdf0e10cSrcweir {
214cdf0e10cSrcweir     return GetDoc()->CallEvent( nEvent, rCallEvent, bChkPtr, pArgs, pCallBack );
215cdf0e10cSrcweir }
216cdf0e10cSrcweir 
217cdf0e10cSrcweir 
218cdf0e10cSrcweir     // fall ein util::URL-Button selektiert ist, dessen util::URL returnen, ansonsten
219cdf0e10cSrcweir     // einen LeerString
220cdf0e10cSrcweir sal_Bool SwWrtShell::GetURLFromButton( String& rURL, String& rDescr ) const
221cdf0e10cSrcweir {
222cdf0e10cSrcweir     sal_Bool bRet = sal_False;
223cdf0e10cSrcweir     const SdrView *pDView = GetDrawView();
224cdf0e10cSrcweir     if( pDView )
225cdf0e10cSrcweir     {
226cdf0e10cSrcweir         // Ein Fly ist genau dann erreichbar, wenn er selektiert ist.
227cdf0e10cSrcweir         const SdrMarkList &rMarkList = pDView->GetMarkedObjectList();
228cdf0e10cSrcweir 
229cdf0e10cSrcweir         if (rMarkList.GetMark(0))
230cdf0e10cSrcweir         {
231cdf0e10cSrcweir             SdrUnoObj* pUnoCtrl = PTR_CAST(SdrUnoObj, rMarkList.GetMark(0)->GetMarkedSdrObj());
232cdf0e10cSrcweir             if (pUnoCtrl && FmFormInventor == pUnoCtrl->GetObjInventor())
233cdf0e10cSrcweir             {
234cdf0e10cSrcweir                 uno::Reference< awt::XControlModel >  xControlModel = pUnoCtrl->GetUnoControlModel();
235cdf0e10cSrcweir 
236cdf0e10cSrcweir                 ASSERT( xControlModel.is(), "UNO-Control ohne Model" );
237cdf0e10cSrcweir                 if( !xControlModel.is() )
238cdf0e10cSrcweir                     return bRet;
239cdf0e10cSrcweir 
240cdf0e10cSrcweir                 uno::Reference< beans::XPropertySet >  xPropSet(xControlModel, uno::UNO_QUERY);
241cdf0e10cSrcweir 
242cdf0e10cSrcweir                 uno::Any aTmp;
243cdf0e10cSrcweir 
244cdf0e10cSrcweir                 form::FormButtonType eButtonType = form::FormButtonType_URL;
245cdf0e10cSrcweir                 uno::Reference< beans::XPropertySetInfo >   xInfo = xPropSet->getPropertySetInfo();
246cdf0e10cSrcweir                 if(xInfo->hasPropertyByName( C2U("ButtonType") ))
247cdf0e10cSrcweir                 {
248cdf0e10cSrcweir                     aTmp = xPropSet->getPropertyValue( C2U("ButtonType") );
249cdf0e10cSrcweir                     form::FormButtonType eTmpButtonType;
250cdf0e10cSrcweir                     aTmp >>= eTmpButtonType;
251cdf0e10cSrcweir                     if( eButtonType == eTmpButtonType)
252cdf0e10cSrcweir                     {
253cdf0e10cSrcweir                         // Label
254cdf0e10cSrcweir                         aTmp = xPropSet->getPropertyValue( C2U("Label") );
255cdf0e10cSrcweir                         OUString uTmp;
256cdf0e10cSrcweir                         if( (aTmp >>= uTmp) && uTmp.getLength())
257cdf0e10cSrcweir                         {
258cdf0e10cSrcweir                             rDescr = String(uTmp);
259cdf0e10cSrcweir                         }
260cdf0e10cSrcweir 
261cdf0e10cSrcweir                         // util::URL
262cdf0e10cSrcweir                         aTmp = xPropSet->getPropertyValue( C2U("TargetURL") );
263cdf0e10cSrcweir                         if( (aTmp >>= uTmp) && uTmp.getLength())
264cdf0e10cSrcweir                         {
265cdf0e10cSrcweir                             rURL = String(uTmp);
266cdf0e10cSrcweir                         }
267cdf0e10cSrcweir                         bRet = sal_True;
268cdf0e10cSrcweir                     }
269cdf0e10cSrcweir                 }
270cdf0e10cSrcweir             }
271cdf0e10cSrcweir         }
272cdf0e10cSrcweir     }
273cdf0e10cSrcweir 
274cdf0e10cSrcweir     return bRet;
275cdf0e10cSrcweir }
276