1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_sd.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include "Outliner.hxx" 32*cdf0e10cSrcweir #include <vcl/wrkwin.hxx> 33*cdf0e10cSrcweir #include <svl/srchitem.hxx> 34*cdf0e10cSrcweir #include <editeng/colritem.hxx> 35*cdf0e10cSrcweir #include <editeng/eeitem.hxx> 36*cdf0e10cSrcweir #include <editeng/editstat.hxx> 37*cdf0e10cSrcweir #include <vcl/outdev.hxx> 38*cdf0e10cSrcweir #include <svx/dlgutil.hxx> 39*cdf0e10cSrcweir #include <svx/xtable.hxx> 40*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 41*cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 42*cdf0e10cSrcweir #include <sfx2/printer.hxx> 43*cdf0e10cSrcweir #include <svx/svxerr.hxx> 44*cdf0e10cSrcweir #include <svx/svdotext.hxx> 45*cdf0e10cSrcweir #include <editeng/unolingu.hxx> 46*cdf0e10cSrcweir #include <svx/svditer.hxx> 47*cdf0e10cSrcweir #include <comphelper/extract.hxx> 48*cdf0e10cSrcweir #include <com/sun/star/linguistic2/XSpellChecker1.hpp> 49*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 50*cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 51*cdf0e10cSrcweir #include <editeng/eeitem.hxx> 52*cdf0e10cSrcweir #include <editeng/forbiddencharacterstable.hxx> 53*cdf0e10cSrcweir #include <svx/srchdlg.hxx> 54*cdf0e10cSrcweir #include <unotools/linguprops.hxx> 55*cdf0e10cSrcweir #include <unotools/lingucfg.hxx> 56*cdf0e10cSrcweir #include <editeng/editeng.hxx> 57*cdf0e10cSrcweir #include <vcl/metric.hxx> 58*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx> 59*cdf0e10cSrcweir #include <svtools/langtab.hxx> 60*cdf0e10cSrcweir #include <tools/diagnose_ex.h> 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir #include "strings.hrc" 63*cdf0e10cSrcweir #include "sdstring.hrc" 64*cdf0e10cSrcweir #include "eetext.hxx" 65*cdf0e10cSrcweir #include "sdpage.hxx" 66*cdf0e10cSrcweir #include "app.hxx" 67*cdf0e10cSrcweir #include "Window.hxx" 68*cdf0e10cSrcweir #include "sdresid.hxx" 69*cdf0e10cSrcweir #include "DrawViewShell.hxx" 70*cdf0e10cSrcweir #include "OutlineViewShell.hxx" 71*cdf0e10cSrcweir #include "drawdoc.hxx" 72*cdf0e10cSrcweir #include "DrawDocShell.hxx" 73*cdf0e10cSrcweir #include "FrameView.hxx" 74*cdf0e10cSrcweir #include "optsitem.hxx" 75*cdf0e10cSrcweir #include "drawview.hxx" 76*cdf0e10cSrcweir #include "ViewShellBase.hxx" 77*cdf0e10cSrcweir #include "SpellDialogChildWindow.hxx" 78*cdf0e10cSrcweir #include "ToolBarManager.hxx" 79*cdf0e10cSrcweir #include "framework/FrameworkHelper.hxx" 80*cdf0e10cSrcweir #include <svx/svxids.hrc> 81*cdf0e10cSrcweir #include <editeng/editerr.hxx> 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir using ::rtl::OUString; 84*cdf0e10cSrcweir using namespace ::com::sun::star; 85*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 86*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 87*cdf0e10cSrcweir using namespace ::com::sun::star::linguistic2; 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir class SfxStyleSheetPool; 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir namespace sd { 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir class Outliner::Implementation 94*cdf0e10cSrcweir { 95*cdf0e10cSrcweir public: 96*cdf0e10cSrcweir /** The original edit mode directly after switching to a different view 97*cdf0e10cSrcweir mode. Used for restoring the edit mode when leaving that view mode 98*cdf0e10cSrcweir again. 99*cdf0e10cSrcweir */ 100*cdf0e10cSrcweir EditMode meOriginalEditMode; 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir Implementation (void); 103*cdf0e10cSrcweir ~Implementation (void); 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir /** Return the OutlinerView that was provided by the last call to 106*cdf0e10cSrcweir ProvideOutlinerView() (or NULL when there was no such call.) 107*cdf0e10cSrcweir */ 108*cdf0e10cSrcweir OutlinerView* GetOutlinerView (void); 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir /** Provide in the member mpOutlineView an instance of OutlinerView that 111*cdf0e10cSrcweir is either taken from the ViewShell, when it is an OutlineViewShell, 112*cdf0e10cSrcweir or is created. When an OutlinerView already exists it is initialied. 113*cdf0e10cSrcweir */ 114*cdf0e10cSrcweir void ProvideOutlinerView ( 115*cdf0e10cSrcweir Outliner& rOutliner, 116*cdf0e10cSrcweir const ::boost::shared_ptr<ViewShell>& rpViewShell, 117*cdf0e10cSrcweir ::Window* pWindow); 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir /** This method is called when the OutlinerView is no longer used. 120*cdf0e10cSrcweir */ 121*cdf0e10cSrcweir void ReleaseOutlinerView (void); 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir private: 124*cdf0e10cSrcweir /** Flag that specifies whether we own the outline view pointed to by 125*cdf0e10cSrcweir <member>mpOutlineView</member> and thus have to 126*cdf0e10cSrcweir delete it in <member>EndSpelling()</member>. 127*cdf0e10cSrcweir */ 128*cdf0e10cSrcweir bool mbOwnOutlineView; 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir /** The outline view used for searching and spelling. If searching or 131*cdf0e10cSrcweir spell checking an outline view this data member points to that view. 132*cdf0e10cSrcweir For all other views an instance is created. The 133*cdf0e10cSrcweir <member>mbOwnOutlineView</member> distinguishes between both cases. 134*cdf0e10cSrcweir */ 135*cdf0e10cSrcweir OutlinerView* mpOutlineView; 136*cdf0e10cSrcweir }; 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir /************************************************************************* 142*cdf0e10cSrcweir |* 143*cdf0e10cSrcweir |* Ctor 144*cdf0e10cSrcweir |* 145*cdf0e10cSrcweir \************************************************************************/ 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir Outliner::Outliner( SdDrawDocument* pDoc, sal_uInt16 nMode ) 148*cdf0e10cSrcweir : SdrOutliner( &pDoc->GetItemPool(), nMode ), 149*cdf0e10cSrcweir mpImpl(new Implementation()), 150*cdf0e10cSrcweir meMode(SEARCH), 151*cdf0e10cSrcweir mpView(NULL), 152*cdf0e10cSrcweir mpViewShell(), 153*cdf0e10cSrcweir mpWindow(NULL), 154*cdf0e10cSrcweir mpDrawDocument(pDoc), 155*cdf0e10cSrcweir mnConversionLanguage(LANGUAGE_NONE), 156*cdf0e10cSrcweir mnIgnoreCurrentPageChangesLevel(0), 157*cdf0e10cSrcweir mbStringFound(sal_False), 158*cdf0e10cSrcweir mbMatchMayExist(false), 159*cdf0e10cSrcweir mnPageCount(0), 160*cdf0e10cSrcweir mnObjectCount(0), 161*cdf0e10cSrcweir mbEndOfSearch(sal_False), 162*cdf0e10cSrcweir mbFoundObject(sal_False), 163*cdf0e10cSrcweir mbError(sal_False), 164*cdf0e10cSrcweir mbDirectionIsForward(true), 165*cdf0e10cSrcweir mbRestrictSearchToSelection(false), 166*cdf0e10cSrcweir maMarkListCopy(), 167*cdf0e10cSrcweir mbProcessCurrentViewOnly(false), 168*cdf0e10cSrcweir mpObj(NULL), 169*cdf0e10cSrcweir mpFirstObj(NULL), 170*cdf0e10cSrcweir mpTextObj(NULL), 171*cdf0e10cSrcweir mnText(0), 172*cdf0e10cSrcweir mpParaObj(NULL), 173*cdf0e10cSrcweir meStartViewMode(PK_STANDARD), 174*cdf0e10cSrcweir meStartEditMode(EM_PAGE), 175*cdf0e10cSrcweir mnStartPageIndex((sal_uInt16)-1), 176*cdf0e10cSrcweir mpStartEditedObject(NULL), 177*cdf0e10cSrcweir maStartSelection(), 178*cdf0e10cSrcweir mpSearchItem(NULL), 179*cdf0e10cSrcweir maObjectIterator(), 180*cdf0e10cSrcweir maCurrentPosition(), 181*cdf0e10cSrcweir maSearchStartPosition(), 182*cdf0e10cSrcweir maLastValidPosition(), 183*cdf0e10cSrcweir mbSelectionHasChanged(false), 184*cdf0e10cSrcweir mbExpectingSelectionChangeEvent(false), 185*cdf0e10cSrcweir mbWholeDocumentProcessed(false), 186*cdf0e10cSrcweir mbPrepareSpellingPending(true), 187*cdf0e10cSrcweir mbViewShellValid(true) 188*cdf0e10cSrcweir { 189*cdf0e10cSrcweir SetStyleSheetPool((SfxStyleSheetPool*) mpDrawDocument->GetStyleSheetPool()); 190*cdf0e10cSrcweir SetEditTextObjectPool( &pDoc->GetItemPool() ); 191*cdf0e10cSrcweir SetCalcFieldValueHdl(LINK(SD_MOD(), SdModule, CalcFieldValueHdl)); 192*cdf0e10cSrcweir SetForbiddenCharsTable( pDoc->GetForbiddenCharsTable() ); 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir sal_uLong nCntrl = GetControlWord(); 195*cdf0e10cSrcweir nCntrl |= EE_CNTRL_ALLOWBIGOBJS; 196*cdf0e10cSrcweir nCntrl |= EE_CNTRL_URLSFXEXECUTE; 197*cdf0e10cSrcweir nCntrl |= EE_CNTRL_MARKFIELDS; 198*cdf0e10cSrcweir nCntrl |= EE_CNTRL_AUTOCORRECT; 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir sal_Bool bOnlineSpell = false; 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir DrawDocShell* pDocSh = mpDrawDocument->GetDocSh(); 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir if (pDocSh) 205*cdf0e10cSrcweir { 206*cdf0e10cSrcweir bOnlineSpell = mpDrawDocument->GetOnlineSpell(); 207*cdf0e10cSrcweir } 208*cdf0e10cSrcweir else 209*cdf0e10cSrcweir { 210*cdf0e10cSrcweir bOnlineSpell = false; 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir try 213*cdf0e10cSrcweir { 214*cdf0e10cSrcweir const SvtLinguConfig aLinguConfig; 215*cdf0e10cSrcweir Any aAny; 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir aAny = aLinguConfig.GetProperty( 218*cdf0e10cSrcweir rtl::OUString::createFromAscii( UPN_IS_SPELL_AUTO ) ); 219*cdf0e10cSrcweir aAny >>= bOnlineSpell; 220*cdf0e10cSrcweir } 221*cdf0e10cSrcweir catch( ... ) 222*cdf0e10cSrcweir { 223*cdf0e10cSrcweir DBG_ERROR( "Ill. type in linguistic property" ); 224*cdf0e10cSrcweir } 225*cdf0e10cSrcweir } 226*cdf0e10cSrcweir 227*cdf0e10cSrcweir if (bOnlineSpell) 228*cdf0e10cSrcweir nCntrl |= EE_CNTRL_ONLINESPELLING; 229*cdf0e10cSrcweir else 230*cdf0e10cSrcweir nCntrl &= ~EE_CNTRL_ONLINESPELLING; 231*cdf0e10cSrcweir 232*cdf0e10cSrcweir SetControlWord(nCntrl); 233*cdf0e10cSrcweir 234*cdf0e10cSrcweir Reference< XSpellChecker1 > xSpellChecker( LinguMgr::GetSpellChecker() ); 235*cdf0e10cSrcweir if ( xSpellChecker.is() ) 236*cdf0e10cSrcweir SetSpeller( xSpellChecker ); 237*cdf0e10cSrcweir 238*cdf0e10cSrcweir Reference< XHyphenator > xHyphenator( LinguMgr::GetHyphenator() ); 239*cdf0e10cSrcweir if( xHyphenator.is() ) 240*cdf0e10cSrcweir SetHyphenator( xHyphenator ); 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir SetDefaultLanguage( Application::GetSettings().GetLanguage() ); 243*cdf0e10cSrcweir } 244*cdf0e10cSrcweir 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir /// Nothing spectecular in the destructor. 249*cdf0e10cSrcweir Outliner::~Outliner (void) 250*cdf0e10cSrcweir { 251*cdf0e10cSrcweir mpImpl.reset(); 252*cdf0e10cSrcweir } 253*cdf0e10cSrcweir 254*cdf0e10cSrcweir 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir 257*cdf0e10cSrcweir /** Prepare find&replace or spellchecking. This distinguishes between three 258*cdf0e10cSrcweir cases: 259*cdf0e10cSrcweir <ol> 260*cdf0e10cSrcweir <li>The current shell is a <type>DrawViewShell</type>: Create a 261*cdf0e10cSrcweir <type>OutlinerView</type> object and search all objects of (i) the 262*cdf0e10cSrcweir current mark list, (ii) of the current view, or (iii) of all the view 263*cdf0e10cSrcweir combinations: 264*cdf0e10cSrcweir <ol> 265*cdf0e10cSrcweir <li>Draw view, slide view</li> 266*cdf0e10cSrcweir <li>Draw view, background view</li> 267*cdf0e10cSrcweir <li>Notes view, slide view</li> 268*cdf0e10cSrcweir <li>Notes view, background view</li> 269*cdf0e10cSrcweir <li>Handout view, slide view</li> 270*cdf0e10cSrcweir <li>Handout view, background view</li> 271*cdf0e10cSrcweir </ol> 272*cdf0e10cSrcweir 273*cdf0e10cSrcweir <li>When the current shell is a <type>SdOutlineViewShell</type> then 274*cdf0e10cSrcweir directly operate on it. No switching into other views takes place.</li> 275*cdf0e10cSrcweir 276*cdf0e10cSrcweir <li>For a <type>SlideViewShell</type> no action is performed.</li> 277*cdf0e10cSrcweir </ol> 278*cdf0e10cSrcweir */ 279*cdf0e10cSrcweir void Outliner::PrepareSpelling (void) 280*cdf0e10cSrcweir { 281*cdf0e10cSrcweir if (mbViewShellValid) 282*cdf0e10cSrcweir { 283*cdf0e10cSrcweir mbPrepareSpellingPending = false; 284*cdf0e10cSrcweir 285*cdf0e10cSrcweir ViewShellBase* pBase = PTR_CAST(ViewShellBase,SfxViewShell::Current()); 286*cdf0e10cSrcweir if (pBase != NULL) 287*cdf0e10cSrcweir SetViewShell (pBase->GetMainViewShell()); 288*cdf0e10cSrcweir SetRefDevice( SD_MOD()->GetRefDevice( *mpDrawDocument->GetDocSh() ) ); 289*cdf0e10cSrcweir 290*cdf0e10cSrcweir if (mpViewShell.get() != NULL) 291*cdf0e10cSrcweir { 292*cdf0e10cSrcweir mbStringFound = sal_False; 293*cdf0e10cSrcweir 294*cdf0e10cSrcweir mbWholeDocumentProcessed = false; 295*cdf0e10cSrcweir // Supposed that we are not located at the very beginning/end of 296*cdf0e10cSrcweir // the document then there may be a match in the document 297*cdf0e10cSrcweir // prior/after the current position. 298*cdf0e10cSrcweir mbMatchMayExist = sal_True; 299*cdf0e10cSrcweir 300*cdf0e10cSrcweir maObjectIterator = ::sd::outliner::Iterator(); 301*cdf0e10cSrcweir maSearchStartPosition = ::sd::outliner::Iterator(); 302*cdf0e10cSrcweir RememberStartPosition(); 303*cdf0e10cSrcweir 304*cdf0e10cSrcweir mpImpl->ProvideOutlinerView(*this, mpViewShell, mpWindow); 305*cdf0e10cSrcweir 306*cdf0e10cSrcweir HandleChangedSelection (); 307*cdf0e10cSrcweir } 308*cdf0e10cSrcweir ClearModifyFlag(); 309*cdf0e10cSrcweir } 310*cdf0e10cSrcweir } 311*cdf0e10cSrcweir 312*cdf0e10cSrcweir 313*cdf0e10cSrcweir 314*cdf0e10cSrcweir 315*cdf0e10cSrcweir 316*cdf0e10cSrcweir void Outliner::StartSpelling (void) 317*cdf0e10cSrcweir { 318*cdf0e10cSrcweir meMode = SPELL; 319*cdf0e10cSrcweir mbDirectionIsForward = true; 320*cdf0e10cSrcweir mpSearchItem = NULL; 321*cdf0e10cSrcweir } 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir /** Proxy for method from base class to avoid compiler warning */ 324*cdf0e10cSrcweir void Outliner::StartSpelling(EditView& rView, unsigned char c) 325*cdf0e10cSrcweir { 326*cdf0e10cSrcweir SdrOutliner::StartSpelling( rView, c ); 327*cdf0e10cSrcweir } 328*cdf0e10cSrcweir 329*cdf0e10cSrcweir /** Free all resources acquired during the search/spell check. After a 330*cdf0e10cSrcweir spell check the start position is restored here. 331*cdf0e10cSrcweir */ 332*cdf0e10cSrcweir void Outliner::EndSpelling (void) 333*cdf0e10cSrcweir { 334*cdf0e10cSrcweir if (mbViewShellValid) 335*cdf0e10cSrcweir { 336*cdf0e10cSrcweir // Keep old view shell alive until we release the outliner view. 337*cdf0e10cSrcweir ::boost::shared_ptr<ViewShell> pOldViewShell (mpViewShell); 338*cdf0e10cSrcweir 339*cdf0e10cSrcweir ViewShellBase* pBase = PTR_CAST(ViewShellBase,SfxViewShell::Current()); 340*cdf0e10cSrcweir if (pBase != NULL) 341*cdf0e10cSrcweir mpViewShell = pBase->GetMainViewShell(); 342*cdf0e10cSrcweir else 343*cdf0e10cSrcweir mpViewShell.reset(); 344*cdf0e10cSrcweir 345*cdf0e10cSrcweir // When in <member>PrepareSpelling()</member> a new outline view has 346*cdf0e10cSrcweir // been created then delete it here. 347*cdf0e10cSrcweir sal_Bool bViewIsDrawViewShell(mpViewShell.get()!=NULL 348*cdf0e10cSrcweir && mpViewShell->ISA(DrawViewShell)); 349*cdf0e10cSrcweir if (bViewIsDrawViewShell) 350*cdf0e10cSrcweir { 351*cdf0e10cSrcweir SetStatusEventHdl(Link()); 352*cdf0e10cSrcweir mpView = mpViewShell->GetView(); 353*cdf0e10cSrcweir mpView->UnmarkAllObj (mpView->GetSdrPageView()); 354*cdf0e10cSrcweir mpView->SdrEndTextEdit(); 355*cdf0e10cSrcweir // Make FuSelection the current function. 356*cdf0e10cSrcweir mpViewShell->GetDispatcher()->Execute( 357*cdf0e10cSrcweir SID_OBJECT_SELECT, 358*cdf0e10cSrcweir SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD); 359*cdf0e10cSrcweir 360*cdf0e10cSrcweir // Remove and, if previously created by us, delete the outline 361*cdf0e10cSrcweir // view. 362*cdf0e10cSrcweir OutlinerView* pOutlinerView = mpImpl->GetOutlinerView(); 363*cdf0e10cSrcweir if (pOutlinerView != NULL) 364*cdf0e10cSrcweir { 365*cdf0e10cSrcweir RemoveView(pOutlinerView); 366*cdf0e10cSrcweir mpImpl->ReleaseOutlinerView(); 367*cdf0e10cSrcweir } 368*cdf0e10cSrcweir 369*cdf0e10cSrcweir SetUpdateMode(sal_True); 370*cdf0e10cSrcweir } 371*cdf0e10cSrcweir 372*cdf0e10cSrcweir // #95811# Before clearing the modify flag use it as a hint that 373*cdf0e10cSrcweir // changes were done at SpellCheck 374*cdf0e10cSrcweir if(IsModified()) 375*cdf0e10cSrcweir { 376*cdf0e10cSrcweir if(mpView && mpView->ISA(OutlineView)) 377*cdf0e10cSrcweir static_cast<OutlineView*>(mpView)->PrepareClose(sal_False); 378*cdf0e10cSrcweir if(mpDrawDocument && !mpDrawDocument->IsChanged()) 379*cdf0e10cSrcweir mpDrawDocument->SetChanged(sal_True); 380*cdf0e10cSrcweir } 381*cdf0e10cSrcweir 382*cdf0e10cSrcweir // #95811# now clear the modify flag to have a specified state of 383*cdf0e10cSrcweir // Outliner 384*cdf0e10cSrcweir ClearModifyFlag(); 385*cdf0e10cSrcweir 386*cdf0e10cSrcweir // When spell checking then restore the start position. 387*cdf0e10cSrcweir if (meMode==SPELL || meMode==TEXT_CONVERSION) 388*cdf0e10cSrcweir RestoreStartPosition (); 389*cdf0e10cSrcweir } 390*cdf0e10cSrcweir 391*cdf0e10cSrcweir mpViewShell.reset(); 392*cdf0e10cSrcweir mpView = NULL; 393*cdf0e10cSrcweir mpWindow = NULL; 394*cdf0e10cSrcweir } 395*cdf0e10cSrcweir 396*cdf0e10cSrcweir 397*cdf0e10cSrcweir 398*cdf0e10cSrcweir 399*cdf0e10cSrcweir sal_Bool Outliner::SpellNextDocument (void) 400*cdf0e10cSrcweir { 401*cdf0e10cSrcweir if (mpViewShell->ISA(OutlineViewShell)) 402*cdf0e10cSrcweir { 403*cdf0e10cSrcweir // When doing a spell check in the outline view then there is 404*cdf0e10cSrcweir // only one document. 405*cdf0e10cSrcweir mbEndOfSearch = true; 406*cdf0e10cSrcweir EndOfSearch (); 407*cdf0e10cSrcweir } 408*cdf0e10cSrcweir else 409*cdf0e10cSrcweir { 410*cdf0e10cSrcweir if (mpView->ISA(OutlineView)) 411*cdf0e10cSrcweir ((OutlineView*)mpView)->PrepareClose(sal_False); 412*cdf0e10cSrcweir mpDrawDocument->GetDocSh()->SetWaitCursor( sal_True ); 413*cdf0e10cSrcweir 414*cdf0e10cSrcweir Initialize (true); 415*cdf0e10cSrcweir 416*cdf0e10cSrcweir mpWindow = mpViewShell->GetActiveWindow(); 417*cdf0e10cSrcweir OutlinerView* pOutlinerView = mpImpl->GetOutlinerView(); 418*cdf0e10cSrcweir if (pOutlinerView != NULL) 419*cdf0e10cSrcweir pOutlinerView->SetWindow(mpWindow); 420*cdf0e10cSrcweir ProvideNextTextObject (); 421*cdf0e10cSrcweir 422*cdf0e10cSrcweir mpDrawDocument->GetDocSh()->SetWaitCursor( sal_False ); 423*cdf0e10cSrcweir ClearModifyFlag(); 424*cdf0e10cSrcweir } 425*cdf0e10cSrcweir 426*cdf0e10cSrcweir return mbEndOfSearch ? sal_False : sal_True; 427*cdf0e10cSrcweir 428*cdf0e10cSrcweir } 429*cdf0e10cSrcweir 430*cdf0e10cSrcweir 431*cdf0e10cSrcweir /************************************************************************* 432*cdf0e10cSrcweir |* 433*cdf0e10cSrcweir |* Spelling: naechstes TextObjekt pruefen 434*cdf0e10cSrcweir |* 435*cdf0e10cSrcweir \************************************************************************/ 436*cdf0e10cSrcweir 437*cdf0e10cSrcweir ::svx::SpellPortions Outliner::GetNextSpellSentence (void) 438*cdf0e10cSrcweir { 439*cdf0e10cSrcweir ::svx::SpellPortions aResult; 440*cdf0e10cSrcweir 441*cdf0e10cSrcweir DetectChange(); 442*cdf0e10cSrcweir // Iterate over sentences and text shapes until a sentence with a 443*cdf0e10cSrcweir // spelling error has been found. If no such sentence can be 444*cdf0e10cSrcweir // found the loop is left through a break. 445*cdf0e10cSrcweir // It is the responsibility of the sd outliner object to correctly 446*cdf0e10cSrcweir // iterate over all text shapes, i.e. switch between views, wrap 447*cdf0e10cSrcweir // arround at the end of the document, stop when all text shapes 448*cdf0e10cSrcweir // have been examined exactly once. 449*cdf0e10cSrcweir bool bFoundNextSentence = false; 450*cdf0e10cSrcweir while ( ! bFoundNextSentence) 451*cdf0e10cSrcweir { 452*cdf0e10cSrcweir OutlinerView* pOutlinerView = GetView(0); 453*cdf0e10cSrcweir if (pOutlinerView != NULL) 454*cdf0e10cSrcweir { 455*cdf0e10cSrcweir ESelection aCurrentSelection (pOutlinerView->GetSelection()); 456*cdf0e10cSrcweir if ( ! mbMatchMayExist 457*cdf0e10cSrcweir && maStartSelection.IsLess(aCurrentSelection)) 458*cdf0e10cSrcweir EndOfSearch(); 459*cdf0e10cSrcweir 460*cdf0e10cSrcweir // Advance to the next sentence. 461*cdf0e10cSrcweir bFoundNextSentence = SpellSentence ( 462*cdf0e10cSrcweir pOutlinerView->GetEditView(), 463*cdf0e10cSrcweir aResult, false); 464*cdf0e10cSrcweir } 465*cdf0e10cSrcweir 466*cdf0e10cSrcweir // When no sentence with spelling errors has been found in the 467*cdf0e10cSrcweir // currently selected text shape or there is no selected text 468*cdf0e10cSrcweir // shape then advance to the next text shape. 469*cdf0e10cSrcweir if ( ! bFoundNextSentence) 470*cdf0e10cSrcweir if ( ! SpellNextDocument()) 471*cdf0e10cSrcweir // All text objects have been processed so exit the 472*cdf0e10cSrcweir // loop and return an empty portions list. 473*cdf0e10cSrcweir break; 474*cdf0e10cSrcweir } 475*cdf0e10cSrcweir 476*cdf0e10cSrcweir return aResult; 477*cdf0e10cSrcweir } 478*cdf0e10cSrcweir 479*cdf0e10cSrcweir 480*cdf0e10cSrcweir 481*cdf0e10cSrcweir 482*cdf0e10cSrcweir /** Go to next match. 483*cdf0e10cSrcweir */ 484*cdf0e10cSrcweir bool Outliner::StartSearchAndReplace (const SvxSearchItem* pSearchItem) 485*cdf0e10cSrcweir { 486*cdf0e10cSrcweir sal_Bool bEndOfSearch = sal_True; 487*cdf0e10cSrcweir 488*cdf0e10cSrcweir if (mbViewShellValid) 489*cdf0e10cSrcweir { 490*cdf0e10cSrcweir mpDrawDocument->GetDocSh()->SetWaitCursor( sal_True ); 491*cdf0e10cSrcweir if (mbPrepareSpellingPending) 492*cdf0e10cSrcweir PrepareSpelling(); 493*cdf0e10cSrcweir ViewShellBase* pBase = PTR_CAST(ViewShellBase,SfxViewShell::Current()); 494*cdf0e10cSrcweir // Determine whether we have to abort the search. This is necessary 495*cdf0e10cSrcweir // when the main view shell does not support searching. 496*cdf0e10cSrcweir bool bAbort = false; 497*cdf0e10cSrcweir if (pBase != NULL) 498*cdf0e10cSrcweir { 499*cdf0e10cSrcweir ::boost::shared_ptr<ViewShell> pShell (pBase->GetMainViewShell()); 500*cdf0e10cSrcweir SetViewShell(pShell); 501*cdf0e10cSrcweir if (pShell.get() == NULL) 502*cdf0e10cSrcweir bAbort = true; 503*cdf0e10cSrcweir else 504*cdf0e10cSrcweir switch (pShell->GetShellType()) 505*cdf0e10cSrcweir { 506*cdf0e10cSrcweir case ViewShell::ST_DRAW: 507*cdf0e10cSrcweir case ViewShell::ST_IMPRESS: 508*cdf0e10cSrcweir case ViewShell::ST_NOTES: 509*cdf0e10cSrcweir case ViewShell::ST_HANDOUT: 510*cdf0e10cSrcweir case ViewShell::ST_OUTLINE: 511*cdf0e10cSrcweir bAbort = false; 512*cdf0e10cSrcweir break; 513*cdf0e10cSrcweir default: 514*cdf0e10cSrcweir bAbort = true; 515*cdf0e10cSrcweir break; 516*cdf0e10cSrcweir } 517*cdf0e10cSrcweir } 518*cdf0e10cSrcweir 519*cdf0e10cSrcweir if ( ! bAbort) 520*cdf0e10cSrcweir { 521*cdf0e10cSrcweir meMode = SEARCH; 522*cdf0e10cSrcweir mpSearchItem = pSearchItem; 523*cdf0e10cSrcweir 524*cdf0e10cSrcweir mbFoundObject = sal_False; 525*cdf0e10cSrcweir 526*cdf0e10cSrcweir Initialize ( ! mpSearchItem->GetBackward()); 527*cdf0e10cSrcweir 528*cdf0e10cSrcweir sal_uInt16 nCommand = mpSearchItem->GetCommand(); 529*cdf0e10cSrcweir if (nCommand == SVX_SEARCHCMD_REPLACE_ALL) 530*cdf0e10cSrcweir bEndOfSearch = SearchAndReplaceAll (); 531*cdf0e10cSrcweir else 532*cdf0e10cSrcweir { 533*cdf0e10cSrcweir RememberStartPosition (); 534*cdf0e10cSrcweir bEndOfSearch = SearchAndReplaceOnce (); 535*cdf0e10cSrcweir //#107233# restore start position if nothing was found 536*cdf0e10cSrcweir if(!mbStringFound) 537*cdf0e10cSrcweir RestoreStartPosition (); 538*cdf0e10cSrcweir else 539*cdf0e10cSrcweir mnStartPageIndex = (sal_uInt16)-1; 540*cdf0e10cSrcweir } 541*cdf0e10cSrcweir } 542*cdf0e10cSrcweir else 543*cdf0e10cSrcweir mpDrawDocument->GetDocSh()->SetWaitCursor( sal_False ); 544*cdf0e10cSrcweir } 545*cdf0e10cSrcweir 546*cdf0e10cSrcweir return bEndOfSearch; 547*cdf0e10cSrcweir } 548*cdf0e10cSrcweir 549*cdf0e10cSrcweir 550*cdf0e10cSrcweir 551*cdf0e10cSrcweir 552*cdf0e10cSrcweir void Outliner::Initialize (bool bDirectionIsForward) 553*cdf0e10cSrcweir { 554*cdf0e10cSrcweir const bool bIsAtEnd (maObjectIterator == ::sd::outliner::OutlinerContainer(this).end()); 555*cdf0e10cSrcweir const bool bOldDirectionIsForward = mbDirectionIsForward; 556*cdf0e10cSrcweir mbDirectionIsForward = bDirectionIsForward; 557*cdf0e10cSrcweir 558*cdf0e10cSrcweir if (maObjectIterator == ::sd::outliner::Iterator()) 559*cdf0e10cSrcweir { 560*cdf0e10cSrcweir // Initialize a new search. 561*cdf0e10cSrcweir maObjectIterator = ::sd::outliner::OutlinerContainer(this).current(); 562*cdf0e10cSrcweir maCurrentPosition = *maObjectIterator; 563*cdf0e10cSrcweir 564*cdf0e10cSrcweir // In case we are searching in an outline view then first remove the 565*cdf0e10cSrcweir // current selection and place cursor at its start or end. 566*cdf0e10cSrcweir if (mpViewShell->ISA(OutlineViewShell)) 567*cdf0e10cSrcweir { 568*cdf0e10cSrcweir ESelection aSelection = mpImpl->GetOutlinerView()->GetSelection (); 569*cdf0e10cSrcweir if (mbDirectionIsForward) 570*cdf0e10cSrcweir { 571*cdf0e10cSrcweir aSelection.nEndPara = aSelection.nStartPara; 572*cdf0e10cSrcweir aSelection.nEndPos = aSelection.nStartPos; 573*cdf0e10cSrcweir } 574*cdf0e10cSrcweir else 575*cdf0e10cSrcweir { 576*cdf0e10cSrcweir aSelection.nStartPara = aSelection.nEndPara; 577*cdf0e10cSrcweir aSelection.nStartPos = aSelection.nEndPos; 578*cdf0e10cSrcweir } 579*cdf0e10cSrcweir mpImpl->GetOutlinerView()->SetSelection (aSelection); 580*cdf0e10cSrcweir } 581*cdf0e10cSrcweir 582*cdf0e10cSrcweir // When not beginning the search at the beginning of the search area 583*cdf0e10cSrcweir // then there may be matches before the current position. 584*cdf0e10cSrcweir mbMatchMayExist = (maObjectIterator!=::sd::outliner::OutlinerContainer(this).begin()); 585*cdf0e10cSrcweir } 586*cdf0e10cSrcweir else if (bOldDirectionIsForward != mbDirectionIsForward) 587*cdf0e10cSrcweir { 588*cdf0e10cSrcweir // Requested iteration direction has changed. Turn arround the iterator. 589*cdf0e10cSrcweir maObjectIterator.Reverse(); 590*cdf0e10cSrcweir if (bIsAtEnd) 591*cdf0e10cSrcweir { 592*cdf0e10cSrcweir // The iterator has pointed to end(), which after the search 593*cdf0e10cSrcweir // direction is reversed, becomes begin(). 594*cdf0e10cSrcweir maObjectIterator = ::sd::outliner::OutlinerContainer(this).begin(); 595*cdf0e10cSrcweir } 596*cdf0e10cSrcweir else 597*cdf0e10cSrcweir { 598*cdf0e10cSrcweir // The iterator has pointed to the object one ahead/before the current 599*cdf0e10cSrcweir // one. Now move it to the one before/ahead the current one. 600*cdf0e10cSrcweir ++maObjectIterator; 601*cdf0e10cSrcweir ++maObjectIterator; 602*cdf0e10cSrcweir } 603*cdf0e10cSrcweir 604*cdf0e10cSrcweir mbMatchMayExist = true; 605*cdf0e10cSrcweir } 606*cdf0e10cSrcweir 607*cdf0e10cSrcweir // Initialize the last valid position with where the search starts so 608*cdf0e10cSrcweir // that it always points to a valid position. 609*cdf0e10cSrcweir maLastValidPosition = *::sd::outliner::OutlinerContainer(this).current(); 610*cdf0e10cSrcweir } 611*cdf0e10cSrcweir 612*cdf0e10cSrcweir 613*cdf0e10cSrcweir 614*cdf0e10cSrcweir 615*cdf0e10cSrcweir bool Outliner::SearchAndReplaceAll (void) 616*cdf0e10cSrcweir { 617*cdf0e10cSrcweir // Save the current position to be restored after having replaced all 618*cdf0e10cSrcweir // matches. 619*cdf0e10cSrcweir RememberStartPosition (); 620*cdf0e10cSrcweir 621*cdf0e10cSrcweir if (mpViewShell->ISA(OutlineViewShell)) 622*cdf0e10cSrcweir { 623*cdf0e10cSrcweir // Put the cursor to the beginning/end of the outliner. 624*cdf0e10cSrcweir mpImpl->GetOutlinerView()->SetSelection (GetSearchStartPosition ()); 625*cdf0e10cSrcweir 626*cdf0e10cSrcweir // The outliner does all the work for us when we are in this mode. 627*cdf0e10cSrcweir SearchAndReplaceOnce(); 628*cdf0e10cSrcweir } 629*cdf0e10cSrcweir else if (mpViewShell->ISA(DrawViewShell)) 630*cdf0e10cSrcweir { 631*cdf0e10cSrcweir // Go to beginning/end of document. 632*cdf0e10cSrcweir maObjectIterator = ::sd::outliner::OutlinerContainer(this).begin(); 633*cdf0e10cSrcweir // Switch to the current object only if it is a valid text object. 634*cdf0e10cSrcweir ::sd::outliner::IteratorPosition aNewPosition (*maObjectIterator); 635*cdf0e10cSrcweir if (IsValidTextObject (aNewPosition)) 636*cdf0e10cSrcweir { 637*cdf0e10cSrcweir maCurrentPosition = aNewPosition; 638*cdf0e10cSrcweir SetObject (maCurrentPosition); 639*cdf0e10cSrcweir } 640*cdf0e10cSrcweir 641*cdf0e10cSrcweir // Search/replace until the end of the document is reached. 642*cdf0e10cSrcweir bool bFoundMatch; 643*cdf0e10cSrcweir do 644*cdf0e10cSrcweir { 645*cdf0e10cSrcweir bFoundMatch = ! SearchAndReplaceOnce(); 646*cdf0e10cSrcweir } 647*cdf0e10cSrcweir while (bFoundMatch); 648*cdf0e10cSrcweir } 649*cdf0e10cSrcweir 650*cdf0e10cSrcweir RestoreStartPosition (); 651*cdf0e10cSrcweir 652*cdf0e10cSrcweir return true; 653*cdf0e10cSrcweir } 654*cdf0e10cSrcweir 655*cdf0e10cSrcweir 656*cdf0e10cSrcweir 657*cdf0e10cSrcweir 658*cdf0e10cSrcweir bool Outliner::SearchAndReplaceOnce (void) 659*cdf0e10cSrcweir { 660*cdf0e10cSrcweir DetectChange (); 661*cdf0e10cSrcweir 662*cdf0e10cSrcweir OutlinerView* pOutlinerView = mpImpl->GetOutlinerView(); 663*cdf0e10cSrcweir DBG_ASSERT(pOutlinerView!=NULL && GetEditEngine().HasView( &pOutlinerView->GetEditView() ), 664*cdf0e10cSrcweir "SearchAndReplace without valid view!" ); 665*cdf0e10cSrcweir 666*cdf0e10cSrcweir if( NULL == pOutlinerView || !GetEditEngine().HasView( &pOutlinerView->GetEditView() ) ) 667*cdf0e10cSrcweir return true; 668*cdf0e10cSrcweir 669*cdf0e10cSrcweir if (mpViewShell != NULL) 670*cdf0e10cSrcweir { 671*cdf0e10cSrcweir mpView = mpViewShell->GetView(); 672*cdf0e10cSrcweir mpWindow = mpViewShell->GetActiveWindow(); 673*cdf0e10cSrcweir pOutlinerView->SetWindow(mpWindow); 674*cdf0e10cSrcweir 675*cdf0e10cSrcweir if (mpViewShell->ISA(DrawViewShell) ) 676*cdf0e10cSrcweir { 677*cdf0e10cSrcweir // When replacing we first check if there is a selection 678*cdf0e10cSrcweir // indicating a match. If there is then replace it. The 679*cdf0e10cSrcweir // following call to StartSearchAndReplace will then search for 680*cdf0e10cSrcweir // the next match. 681*cdf0e10cSrcweir if (meMode == SEARCH 682*cdf0e10cSrcweir && mpSearchItem->GetCommand() == SVX_SEARCHCMD_REPLACE) 683*cdf0e10cSrcweir if (pOutlinerView->GetSelection().HasRange()) 684*cdf0e10cSrcweir pOutlinerView->StartSearchAndReplace(*mpSearchItem); 685*cdf0e10cSrcweir 686*cdf0e10cSrcweir // Search for the next match. 687*cdf0e10cSrcweir sal_uLong nMatchCount = 0; 688*cdf0e10cSrcweir if (mpSearchItem->GetCommand() != SVX_SEARCHCMD_REPLACE_ALL) 689*cdf0e10cSrcweir nMatchCount = pOutlinerView->StartSearchAndReplace(*mpSearchItem); 690*cdf0e10cSrcweir 691*cdf0e10cSrcweir // Go to the next text object when there have been no matches in 692*cdf0e10cSrcweir // the current object or the whole object has already been 693*cdf0e10cSrcweir // processed. 694*cdf0e10cSrcweir if (nMatchCount==0 || mpSearchItem->GetCommand()==SVX_SEARCHCMD_REPLACE_ALL) 695*cdf0e10cSrcweir { 696*cdf0e10cSrcweir ProvideNextTextObject (); 697*cdf0e10cSrcweir 698*cdf0e10cSrcweir if ( ! mbEndOfSearch) 699*cdf0e10cSrcweir { 700*cdf0e10cSrcweir // Remember the current position as the last one with a 701*cdf0e10cSrcweir // text object. 702*cdf0e10cSrcweir maLastValidPosition = maCurrentPosition; 703*cdf0e10cSrcweir 704*cdf0e10cSrcweir // Now that the mbEndOfSearch flag guards this block the 705*cdf0e10cSrcweir // following assertion and return should not be 706*cdf0e10cSrcweir // necessary anymore. 707*cdf0e10cSrcweir DBG_ASSERT(GetEditEngine().HasView(&pOutlinerView->GetEditView() ), 708*cdf0e10cSrcweir "SearchAndReplace without valid view!" ); 709*cdf0e10cSrcweir if ( ! GetEditEngine().HasView( &pOutlinerView->GetEditView() ) ) 710*cdf0e10cSrcweir { 711*cdf0e10cSrcweir mpDrawDocument->GetDocSh()->SetWaitCursor( sal_False ); 712*cdf0e10cSrcweir return true; 713*cdf0e10cSrcweir } 714*cdf0e10cSrcweir 715*cdf0e10cSrcweir if (meMode == SEARCH) 716*cdf0e10cSrcweir nMatchCount = pOutlinerView->StartSearchAndReplace(*mpSearchItem); 717*cdf0e10cSrcweir } 718*cdf0e10cSrcweir } 719*cdf0e10cSrcweir } 720*cdf0e10cSrcweir else if (mpViewShell->ISA(OutlineViewShell)) 721*cdf0e10cSrcweir { 722*cdf0e10cSrcweir mpDrawDocument->GetDocSh()->SetWaitCursor (sal_False); 723*cdf0e10cSrcweir // The following loop is executed more then once only when a 724*cdf0e10cSrcweir // wrap arround search is done. 725*cdf0e10cSrcweir while (true) 726*cdf0e10cSrcweir { 727*cdf0e10cSrcweir int nResult = pOutlinerView->StartSearchAndReplace(*mpSearchItem); 728*cdf0e10cSrcweir if (nResult == 0) 729*cdf0e10cSrcweir { 730*cdf0e10cSrcweir if (HandleFailedSearch ()) 731*cdf0e10cSrcweir { 732*cdf0e10cSrcweir pOutlinerView->SetSelection (GetSearchStartPosition ()); 733*cdf0e10cSrcweir continue; 734*cdf0e10cSrcweir } 735*cdf0e10cSrcweir } 736*cdf0e10cSrcweir else 737*cdf0e10cSrcweir mbStringFound = true; 738*cdf0e10cSrcweir break; 739*cdf0e10cSrcweir } 740*cdf0e10cSrcweir } 741*cdf0e10cSrcweir } 742*cdf0e10cSrcweir 743*cdf0e10cSrcweir mpDrawDocument->GetDocSh()->SetWaitCursor( sal_False ); 744*cdf0e10cSrcweir 745*cdf0e10cSrcweir return mbEndOfSearch; 746*cdf0e10cSrcweir } 747*cdf0e10cSrcweir 748*cdf0e10cSrcweir 749*cdf0e10cSrcweir 750*cdf0e10cSrcweir 751*cdf0e10cSrcweir /** Try to detect whether the document or the view (shell) has changed since 752*cdf0e10cSrcweir the last time <member>StartSearchAndReplace()</member> has been called. 753*cdf0e10cSrcweir */ 754*cdf0e10cSrcweir void Outliner::DetectChange (void) 755*cdf0e10cSrcweir { 756*cdf0e10cSrcweir ::sd::outliner::IteratorPosition aPosition (maCurrentPosition); 757*cdf0e10cSrcweir 758*cdf0e10cSrcweir ::boost::shared_ptr<DrawViewShell> pDrawViewShell ( 759*cdf0e10cSrcweir ::boost::dynamic_pointer_cast<DrawViewShell>(mpViewShell)); 760*cdf0e10cSrcweir 761*cdf0e10cSrcweir // Detect whether the view has been switched from the outside. 762*cdf0e10cSrcweir if (pDrawViewShell.get() != NULL 763*cdf0e10cSrcweir && (aPosition.meEditMode != pDrawViewShell->GetEditMode() 764*cdf0e10cSrcweir || aPosition.mePageKind != pDrawViewShell->GetPageKind())) 765*cdf0e10cSrcweir { 766*cdf0e10cSrcweir // Either the edit mode or the page kind has changed. 767*cdf0e10cSrcweir SetStatusEventHdl(Link()); 768*cdf0e10cSrcweir 769*cdf0e10cSrcweir SdrPageView* pPageView = mpView->GetSdrPageView(); 770*cdf0e10cSrcweir if (pPageView != NULL) 771*cdf0e10cSrcweir mpView->UnmarkAllObj (pPageView); 772*cdf0e10cSrcweir mpView->SdrEndTextEdit(); 773*cdf0e10cSrcweir SetUpdateMode(sal_False); 774*cdf0e10cSrcweir OutlinerView* pOutlinerView = mpImpl->GetOutlinerView(); 775*cdf0e10cSrcweir if (pOutlinerView != NULL) 776*cdf0e10cSrcweir pOutlinerView->SetOutputArea( Rectangle( Point(), Size(1, 1) ) ); 777*cdf0e10cSrcweir if (meMode == SPELL) 778*cdf0e10cSrcweir SetPaperSize( Size(1, 1) ); 779*cdf0e10cSrcweir SetText( String(), GetParagraph( 0 ) ); 780*cdf0e10cSrcweir 781*cdf0e10cSrcweir RememberStartPosition (); 782*cdf0e10cSrcweir 783*cdf0e10cSrcweir mnPageCount = mpDrawDocument->GetSdPageCount(pDrawViewShell->GetPageKind()); 784*cdf0e10cSrcweir maObjectIterator = ::sd::outliner::OutlinerContainer(this).current(); 785*cdf0e10cSrcweir } 786*cdf0e10cSrcweir 787*cdf0e10cSrcweir // Detect change of the set of selected objects. If their number has 788*cdf0e10cSrcweir // changed start again with the first selected object. 789*cdf0e10cSrcweir else if (DetectSelectionChange()) 790*cdf0e10cSrcweir { 791*cdf0e10cSrcweir HandleChangedSelection (); 792*cdf0e10cSrcweir maObjectIterator = ::sd::outliner::OutlinerContainer(this).current(); 793*cdf0e10cSrcweir } 794*cdf0e10cSrcweir 795*cdf0e10cSrcweir // Detect change of page count. Restart search at first/last page in 796*cdf0e10cSrcweir // that case. 797*cdf0e10cSrcweir else if (aPosition.meEditMode == EM_PAGE 798*cdf0e10cSrcweir && mpDrawDocument->GetSdPageCount(aPosition.mePageKind) != mnPageCount) 799*cdf0e10cSrcweir { 800*cdf0e10cSrcweir // The number of pages has changed. 801*cdf0e10cSrcweir mnPageCount = mpDrawDocument->GetSdPageCount(aPosition.mePageKind); 802*cdf0e10cSrcweir maObjectIterator = ::sd::outliner::OutlinerContainer(this).current(); 803*cdf0e10cSrcweir } 804*cdf0e10cSrcweir else if (aPosition.meEditMode == EM_MASTERPAGE 805*cdf0e10cSrcweir && mpDrawDocument->GetSdPageCount(aPosition.mePageKind) != mnPageCount) 806*cdf0e10cSrcweir { 807*cdf0e10cSrcweir // The number of master pages has changed. 808*cdf0e10cSrcweir mnPageCount = mpDrawDocument->GetSdPageCount(aPosition.mePageKind); 809*cdf0e10cSrcweir maObjectIterator = ::sd::outliner::OutlinerContainer(this).current(); 810*cdf0e10cSrcweir } 811*cdf0e10cSrcweir } 812*cdf0e10cSrcweir 813*cdf0e10cSrcweir 814*cdf0e10cSrcweir 815*cdf0e10cSrcweir 816*cdf0e10cSrcweir bool Outliner::DetectSelectionChange (void) 817*cdf0e10cSrcweir { 818*cdf0e10cSrcweir bool bSelectionHasChanged = false; 819*cdf0e10cSrcweir sal_uLong nMarkCount = mpView->GetMarkedObjectList().GetMarkCount(); 820*cdf0e10cSrcweir 821*cdf0e10cSrcweir // If mpObj is NULL then we have not yet found our first match. 822*cdf0e10cSrcweir // Detecting a change makes no sense. 823*cdf0e10cSrcweir if (mpObj != NULL) 824*cdf0e10cSrcweir switch (nMarkCount) 825*cdf0e10cSrcweir { 826*cdf0e10cSrcweir case 0: 827*cdf0e10cSrcweir // The selection has changed when previously there have been 828*cdf0e10cSrcweir // selected objects. 829*cdf0e10cSrcweir bSelectionHasChanged = mbRestrictSearchToSelection; 830*cdf0e10cSrcweir break; 831*cdf0e10cSrcweir case 1: 832*cdf0e10cSrcweir // Check if the only selected object is not the one that we 833*cdf0e10cSrcweir // had selected. 834*cdf0e10cSrcweir if (mpView != NULL) 835*cdf0e10cSrcweir { 836*cdf0e10cSrcweir SdrMark* pMark = mpView->GetMarkedObjectList().GetMark(0); 837*cdf0e10cSrcweir if (pMark != NULL) 838*cdf0e10cSrcweir bSelectionHasChanged = (mpObj != pMark->GetMarkedSdrObj ()); 839*cdf0e10cSrcweir } 840*cdf0e10cSrcweir break; 841*cdf0e10cSrcweir default: 842*cdf0e10cSrcweir // We had selected exactly one object. 843*cdf0e10cSrcweir bSelectionHasChanged = true; 844*cdf0e10cSrcweir break; 845*cdf0e10cSrcweir } 846*cdf0e10cSrcweir 847*cdf0e10cSrcweir return bSelectionHasChanged; 848*cdf0e10cSrcweir } 849*cdf0e10cSrcweir 850*cdf0e10cSrcweir 851*cdf0e10cSrcweir 852*cdf0e10cSrcweir 853*cdf0e10cSrcweir void Outliner::RememberStartPosition (void) 854*cdf0e10cSrcweir { 855*cdf0e10cSrcweir if (mpViewShell->ISA(DrawViewShell)) 856*cdf0e10cSrcweir { 857*cdf0e10cSrcweir ::boost::shared_ptr<DrawViewShell> pDrawViewShell ( 858*cdf0e10cSrcweir ::boost::dynamic_pointer_cast<DrawViewShell>(mpViewShell)); 859*cdf0e10cSrcweir if (pDrawViewShell.get() != NULL) 860*cdf0e10cSrcweir { 861*cdf0e10cSrcweir meStartViewMode = pDrawViewShell->GetPageKind(); 862*cdf0e10cSrcweir meStartEditMode = pDrawViewShell->GetEditMode(); 863*cdf0e10cSrcweir mnStartPageIndex = pDrawViewShell->GetCurPageId() - 1; 864*cdf0e10cSrcweir } 865*cdf0e10cSrcweir 866*cdf0e10cSrcweir if (mpView != NULL) 867*cdf0e10cSrcweir { 868*cdf0e10cSrcweir mpStartEditedObject = mpView->GetTextEditObject(); 869*cdf0e10cSrcweir if (mpStartEditedObject != NULL) 870*cdf0e10cSrcweir { 871*cdf0e10cSrcweir // Try to retrieve current caret position only when there is an 872*cdf0e10cSrcweir // edited object. 873*cdf0e10cSrcweir ::Outliner* pOutliner = 874*cdf0e10cSrcweir static_cast<DrawView*>(mpView)->GetTextEditOutliner(); 875*cdf0e10cSrcweir if (pOutliner!=NULL && pOutliner->GetViewCount()>0) 876*cdf0e10cSrcweir { 877*cdf0e10cSrcweir OutlinerView* pOutlinerView = pOutliner->GetView(0); 878*cdf0e10cSrcweir maStartSelection = pOutlinerView->GetSelection(); 879*cdf0e10cSrcweir } 880*cdf0e10cSrcweir } 881*cdf0e10cSrcweir } 882*cdf0e10cSrcweir } 883*cdf0e10cSrcweir else if (mpViewShell->ISA(OutlineViewShell)) 884*cdf0e10cSrcweir { 885*cdf0e10cSrcweir // Remember the current cursor position. 886*cdf0e10cSrcweir OutlinerView* pView = GetView(0); 887*cdf0e10cSrcweir if (pView != NULL) 888*cdf0e10cSrcweir pView->GetSelection(); 889*cdf0e10cSrcweir } 890*cdf0e10cSrcweir else 891*cdf0e10cSrcweir { 892*cdf0e10cSrcweir mnStartPageIndex = (sal_uInt16)-1; 893*cdf0e10cSrcweir } 894*cdf0e10cSrcweir } 895*cdf0e10cSrcweir 896*cdf0e10cSrcweir 897*cdf0e10cSrcweir 898*cdf0e10cSrcweir 899*cdf0e10cSrcweir void Outliner::RestoreStartPosition (void) 900*cdf0e10cSrcweir { 901*cdf0e10cSrcweir bool bRestore = true; 902*cdf0e10cSrcweir // Take a negative start page index as inidicator that restoring the 903*cdf0e10cSrcweir // start position is not requested. 904*cdf0e10cSrcweir if (mnStartPageIndex == (sal_uInt16)-1 ) 905*cdf0e10cSrcweir bRestore = false; 906*cdf0e10cSrcweir // Dont't resore when the view shell is not valid. 907*cdf0e10cSrcweir if (mpViewShell == NULL) 908*cdf0e10cSrcweir bRestore = false; 909*cdf0e10cSrcweir if ( ! mbViewShellValid) 910*cdf0e10cSrcweir bRestore = false; 911*cdf0e10cSrcweir 912*cdf0e10cSrcweir if (bRestore) 913*cdf0e10cSrcweir { 914*cdf0e10cSrcweir if (mpViewShell->ISA(DrawViewShell)) 915*cdf0e10cSrcweir { 916*cdf0e10cSrcweir ::boost::shared_ptr<DrawViewShell> pDrawViewShell ( 917*cdf0e10cSrcweir ::boost::dynamic_pointer_cast<DrawViewShell>(mpViewShell)); 918*cdf0e10cSrcweir SetViewMode (meStartViewMode); 919*cdf0e10cSrcweir if (pDrawViewShell.get() != NULL) 920*cdf0e10cSrcweir SetPage (meStartEditMode, mnStartPageIndex); 921*cdf0e10cSrcweir 922*cdf0e10cSrcweir 923*cdf0e10cSrcweir if (mpStartEditedObject != NULL) 924*cdf0e10cSrcweir { 925*cdf0e10cSrcweir // Turn on the text toolbar as it is done in FuText so that 926*cdf0e10cSrcweir // undo manager setting/restoring in 927*cdf0e10cSrcweir // sd::View::{Beg,End}TextEdit() works on the same view shell. 928*cdf0e10cSrcweir mpViewShell->GetViewShellBase().GetToolBarManager()->SetToolBarShell( 929*cdf0e10cSrcweir ToolBarManager::TBG_FUNCTION, 930*cdf0e10cSrcweir RID_DRAW_TEXT_TOOLBOX); 931*cdf0e10cSrcweir 932*cdf0e10cSrcweir mpView->SdrBeginTextEdit(mpStartEditedObject); 933*cdf0e10cSrcweir ::Outliner* pOutliner = 934*cdf0e10cSrcweir static_cast<DrawView*>(mpView)->GetTextEditOutliner(); 935*cdf0e10cSrcweir if (pOutliner!=NULL && pOutliner->GetViewCount()>0) 936*cdf0e10cSrcweir { 937*cdf0e10cSrcweir OutlinerView* pOutlinerView = pOutliner->GetView(0); 938*cdf0e10cSrcweir pOutlinerView->SetSelection(maStartSelection); 939*cdf0e10cSrcweir } 940*cdf0e10cSrcweir } 941*cdf0e10cSrcweir } 942*cdf0e10cSrcweir else if (mpViewShell->ISA(OutlineViewShell)) 943*cdf0e10cSrcweir { 944*cdf0e10cSrcweir // Set cursor to its old position. 945*cdf0e10cSrcweir OutlinerView* pView = GetView(0); 946*cdf0e10cSrcweir if (pView != NULL) 947*cdf0e10cSrcweir pView->SetSelection (maStartSelection); 948*cdf0e10cSrcweir } 949*cdf0e10cSrcweir } 950*cdf0e10cSrcweir } 951*cdf0e10cSrcweir 952*cdf0e10cSrcweir 953*cdf0e10cSrcweir 954*cdf0e10cSrcweir 955*cdf0e10cSrcweir /** The main purpose of this method is to iterate over all shape objects of 956*cdf0e10cSrcweir the search area (current selection, current view, or whole document) 957*cdf0e10cSrcweir until a text object has been found that contains at least one match or 958*cdf0e10cSrcweir until no such object can be found anymore. These two conditions are 959*cdf0e10cSrcweir expressed by setting one of the flags <member>mbFoundObject</member> or 960*cdf0e10cSrcweir <member>mbEndOfSearch</member> to <TRUE/>. 961*cdf0e10cSrcweir */ 962*cdf0e10cSrcweir void Outliner::ProvideNextTextObject (void) 963*cdf0e10cSrcweir { 964*cdf0e10cSrcweir mbEndOfSearch = false; 965*cdf0e10cSrcweir mbFoundObject = false; 966*cdf0e10cSrcweir 967*cdf0e10cSrcweir mpView->UnmarkAllObj (mpView->GetSdrPageView()); 968*cdf0e10cSrcweir try 969*cdf0e10cSrcweir { 970*cdf0e10cSrcweir mpView->SdrEndTextEdit(); 971*cdf0e10cSrcweir } 972*cdf0e10cSrcweir catch (::com::sun::star::uno::Exception e) 973*cdf0e10cSrcweir { 974*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 975*cdf0e10cSrcweir } 976*cdf0e10cSrcweir SetUpdateMode(sal_False); 977*cdf0e10cSrcweir OutlinerView* pOutlinerView = mpImpl->GetOutlinerView(); 978*cdf0e10cSrcweir if (pOutlinerView != NULL) 979*cdf0e10cSrcweir pOutlinerView->SetOutputArea( Rectangle( Point(), Size(1, 1) ) ); 980*cdf0e10cSrcweir if (meMode == SPELL) 981*cdf0e10cSrcweir SetPaperSize( Size(1, 1) ); 982*cdf0e10cSrcweir SetText( String(), GetParagraph( 0 ) ); 983*cdf0e10cSrcweir 984*cdf0e10cSrcweir mpTextObj = NULL; 985*cdf0e10cSrcweir 986*cdf0e10cSrcweir // Iterate until a valid text object has been found or the search ends. 987*cdf0e10cSrcweir do 988*cdf0e10cSrcweir { 989*cdf0e10cSrcweir mpObj = NULL; 990*cdf0e10cSrcweir mpParaObj = NULL; 991*cdf0e10cSrcweir 992*cdf0e10cSrcweir if (maObjectIterator != ::sd::outliner::OutlinerContainer(this).end()) 993*cdf0e10cSrcweir { 994*cdf0e10cSrcweir maCurrentPosition = *maObjectIterator; 995*cdf0e10cSrcweir // Switch to the current object only if it is a valid text object. 996*cdf0e10cSrcweir if (IsValidTextObject (maCurrentPosition)) 997*cdf0e10cSrcweir { 998*cdf0e10cSrcweir mpObj = SetObject (maCurrentPosition); 999*cdf0e10cSrcweir } 1000*cdf0e10cSrcweir ++maObjectIterator; 1001*cdf0e10cSrcweir 1002*cdf0e10cSrcweir if (mpObj != NULL) 1003*cdf0e10cSrcweir { 1004*cdf0e10cSrcweir PutTextIntoOutliner (); 1005*cdf0e10cSrcweir 1006*cdf0e10cSrcweir if (mpViewShell != NULL) 1007*cdf0e10cSrcweir switch (meMode) 1008*cdf0e10cSrcweir { 1009*cdf0e10cSrcweir case SEARCH: 1010*cdf0e10cSrcweir PrepareSearchAndReplace (); 1011*cdf0e10cSrcweir break; 1012*cdf0e10cSrcweir case SPELL: 1013*cdf0e10cSrcweir PrepareSpellCheck (); 1014*cdf0e10cSrcweir break; 1015*cdf0e10cSrcweir case TEXT_CONVERSION: 1016*cdf0e10cSrcweir PrepareConversion(); 1017*cdf0e10cSrcweir break; 1018*cdf0e10cSrcweir } 1019*cdf0e10cSrcweir } 1020*cdf0e10cSrcweir } 1021*cdf0e10cSrcweir else 1022*cdf0e10cSrcweir { 1023*cdf0e10cSrcweir mbEndOfSearch = true; 1024*cdf0e10cSrcweir EndOfSearch (); 1025*cdf0e10cSrcweir } 1026*cdf0e10cSrcweir } 1027*cdf0e10cSrcweir while ( ! (mbFoundObject || mbEndOfSearch)); 1028*cdf0e10cSrcweir } 1029*cdf0e10cSrcweir 1030*cdf0e10cSrcweir 1031*cdf0e10cSrcweir 1032*cdf0e10cSrcweir 1033*cdf0e10cSrcweir void Outliner::EndOfSearch (void) 1034*cdf0e10cSrcweir { 1035*cdf0e10cSrcweir // Before we display a dialog we first jump to where the last valid text 1036*cdf0e10cSrcweir // object was found. All page and view mode switching since then was 1037*cdf0e10cSrcweir // temporary and should not be visible to the user. 1038*cdf0e10cSrcweir if ( ! mpViewShell->ISA(OutlineViewShell)) 1039*cdf0e10cSrcweir SetObject (maLastValidPosition); 1040*cdf0e10cSrcweir 1041*cdf0e10cSrcweir if (mbRestrictSearchToSelection) 1042*cdf0e10cSrcweir ShowEndOfSearchDialog (); 1043*cdf0e10cSrcweir else 1044*cdf0e10cSrcweir { 1045*cdf0e10cSrcweir // When no match has been found so far then terminate the search. 1046*cdf0e10cSrcweir if ( ! mbMatchMayExist) 1047*cdf0e10cSrcweir { 1048*cdf0e10cSrcweir ShowEndOfSearchDialog (); 1049*cdf0e10cSrcweir mbEndOfSearch = sal_True; 1050*cdf0e10cSrcweir } 1051*cdf0e10cSrcweir // Ask the user whether to wrap arround and continue the search or 1052*cdf0e10cSrcweir // to terminate. 1053*cdf0e10cSrcweir else if (meMode==TEXT_CONVERSION || ShowWrapArroundDialog ()) 1054*cdf0e10cSrcweir { 1055*cdf0e10cSrcweir mbMatchMayExist = false; 1056*cdf0e10cSrcweir // Everything back to beginning (or end?) of the document. 1057*cdf0e10cSrcweir maObjectIterator = ::sd::outliner::OutlinerContainer(this).begin(); 1058*cdf0e10cSrcweir if (mpViewShell->ISA(OutlineViewShell)) 1059*cdf0e10cSrcweir { 1060*cdf0e10cSrcweir // Set cursor to first character of the document. 1061*cdf0e10cSrcweir OutlinerView* pOutlinerView = mpImpl->GetOutlinerView(); 1062*cdf0e10cSrcweir if (pOutlinerView != NULL) 1063*cdf0e10cSrcweir pOutlinerView->SetSelection (GetSearchStartPosition ()); 1064*cdf0e10cSrcweir } 1065*cdf0e10cSrcweir 1066*cdf0e10cSrcweir mbEndOfSearch = false; 1067*cdf0e10cSrcweir } 1068*cdf0e10cSrcweir else 1069*cdf0e10cSrcweir { 1070*cdf0e10cSrcweir // No wrap arround. 1071*cdf0e10cSrcweir mbEndOfSearch = true; 1072*cdf0e10cSrcweir } 1073*cdf0e10cSrcweir } 1074*cdf0e10cSrcweir } 1075*cdf0e10cSrcweir 1076*cdf0e10cSrcweir void Outliner::ShowEndOfSearchDialog (void) 1077*cdf0e10cSrcweir { 1078*cdf0e10cSrcweir String aString; 1079*cdf0e10cSrcweir if (meMode == SEARCH) 1080*cdf0e10cSrcweir { 1081*cdf0e10cSrcweir if (mbStringFound) 1082*cdf0e10cSrcweir aString = String( SdResId(STR_END_SEARCHING) ); 1083*cdf0e10cSrcweir else 1084*cdf0e10cSrcweir aString = String( SdResId(STR_STRING_NOTFOUND) ); 1085*cdf0e10cSrcweir } 1086*cdf0e10cSrcweir else 1087*cdf0e10cSrcweir { 1088*cdf0e10cSrcweir if (mpView->AreObjectsMarked()) 1089*cdf0e10cSrcweir aString = String(SdResId(STR_END_SPELLING_OBJ)); 1090*cdf0e10cSrcweir else 1091*cdf0e10cSrcweir aString = String(SdResId(STR_END_SPELLING)); 1092*cdf0e10cSrcweir } 1093*cdf0e10cSrcweir 1094*cdf0e10cSrcweir // Show the message in an info box that is modal with respect to the 1095*cdf0e10cSrcweir // whole application. 1096*cdf0e10cSrcweir InfoBox aInfoBox (NULL, aString); 1097*cdf0e10cSrcweir ShowModalMessageBox (aInfoBox); 1098*cdf0e10cSrcweir 1099*cdf0e10cSrcweir mbWholeDocumentProcessed = true; 1100*cdf0e10cSrcweir } 1101*cdf0e10cSrcweir 1102*cdf0e10cSrcweir 1103*cdf0e10cSrcweir 1104*cdf0e10cSrcweir 1105*cdf0e10cSrcweir bool Outliner::ShowWrapArroundDialog (void) 1106*cdf0e10cSrcweir { 1107*cdf0e10cSrcweir bool bDoWrapArround = false; 1108*cdf0e10cSrcweir 1109*cdf0e10cSrcweir // Determine whether to show the dialog. 1110*cdf0e10cSrcweir bool bShowDialog = false; 1111*cdf0e10cSrcweir if (mpSearchItem != NULL) 1112*cdf0e10cSrcweir { 1113*cdf0e10cSrcweir // When searching display the dialog only for single find&replace. 1114*cdf0e10cSrcweir sal_uInt16 nCommand = mpSearchItem->GetCommand(); 1115*cdf0e10cSrcweir bShowDialog = (nCommand==SVX_SEARCHCMD_REPLACE) 1116*cdf0e10cSrcweir || (nCommand==SVX_SEARCHCMD_FIND); 1117*cdf0e10cSrcweir } 1118*cdf0e10cSrcweir else 1119*cdf0e10cSrcweir // Spell checking needs the dialog, too. 1120*cdf0e10cSrcweir bShowDialog = (meMode == SPELL); 1121*cdf0e10cSrcweir 1122*cdf0e10cSrcweir if (bShowDialog) 1123*cdf0e10cSrcweir { 1124*cdf0e10cSrcweir // The question text depends on the search direction. 1125*cdf0e10cSrcweir sal_Bool bImpress = mpDrawDocument!=NULL 1126*cdf0e10cSrcweir && mpDrawDocument->GetDocumentType() == DOCUMENT_TYPE_IMPRESS; 1127*cdf0e10cSrcweir sal_uInt16 nStringId; 1128*cdf0e10cSrcweir if (mbDirectionIsForward) 1129*cdf0e10cSrcweir nStringId = bImpress 1130*cdf0e10cSrcweir ? STR_SAR_WRAP_FORWARD 1131*cdf0e10cSrcweir : STR_SAR_WRAP_FORWARD_DRAW; 1132*cdf0e10cSrcweir else 1133*cdf0e10cSrcweir nStringId = bImpress 1134*cdf0e10cSrcweir ? STR_SAR_WRAP_BACKWARD 1135*cdf0e10cSrcweir : STR_SAR_WRAP_BACKWARD_DRAW; 1136*cdf0e10cSrcweir 1137*cdf0e10cSrcweir // Pop up question box that asks the user whether to wrap arround. 1138*cdf0e10cSrcweir // The dialog is made modal with respect to the whole application. 1139*cdf0e10cSrcweir QueryBox aQuestionBox ( 1140*cdf0e10cSrcweir NULL, 1141*cdf0e10cSrcweir WB_YES_NO | WB_DEF_YES, 1142*cdf0e10cSrcweir String(SdResId(nStringId))); 1143*cdf0e10cSrcweir aQuestionBox.SetImage (QueryBox::GetStandardImage()); 1144*cdf0e10cSrcweir sal_uInt16 nBoxResult = ShowModalMessageBox(aQuestionBox); 1145*cdf0e10cSrcweir bDoWrapArround = (nBoxResult == BUTTONID_YES); 1146*cdf0e10cSrcweir } 1147*cdf0e10cSrcweir 1148*cdf0e10cSrcweir return bDoWrapArround; 1149*cdf0e10cSrcweir } 1150*cdf0e10cSrcweir 1151*cdf0e10cSrcweir 1152*cdf0e10cSrcweir 1153*cdf0e10cSrcweir 1154*cdf0e10cSrcweir bool Outliner::IsValidTextObject (const ::sd::outliner::IteratorPosition& rPosition) 1155*cdf0e10cSrcweir { 1156*cdf0e10cSrcweir SdrTextObj* pObject = dynamic_cast< SdrTextObj* >( rPosition.mxObject.get() ); 1157*cdf0e10cSrcweir return (pObject != NULL) && pObject->HasText() && ! pObject->IsEmptyPresObj(); 1158*cdf0e10cSrcweir } 1159*cdf0e10cSrcweir 1160*cdf0e10cSrcweir 1161*cdf0e10cSrcweir 1162*cdf0e10cSrcweir 1163*cdf0e10cSrcweir void Outliner::PutTextIntoOutliner() 1164*cdf0e10cSrcweir { 1165*cdf0e10cSrcweir mpTextObj = dynamic_cast<SdrTextObj*>( mpObj ); 1166*cdf0e10cSrcweir if ( mpTextObj && mpTextObj->HasText() && !mpTextObj->IsEmptyPresObj() ) 1167*cdf0e10cSrcweir { 1168*cdf0e10cSrcweir SdrText* pText = mpTextObj->getText( mnText ); 1169*cdf0e10cSrcweir mpParaObj = pText ? pText->GetOutlinerParaObject() : NULL; 1170*cdf0e10cSrcweir 1171*cdf0e10cSrcweir if (mpParaObj != NULL) 1172*cdf0e10cSrcweir { 1173*cdf0e10cSrcweir SetText(*mpParaObj); 1174*cdf0e10cSrcweir 1175*cdf0e10cSrcweir ClearModifyFlag(); 1176*cdf0e10cSrcweir } 1177*cdf0e10cSrcweir } 1178*cdf0e10cSrcweir else 1179*cdf0e10cSrcweir { 1180*cdf0e10cSrcweir mpTextObj = NULL; 1181*cdf0e10cSrcweir } 1182*cdf0e10cSrcweir } 1183*cdf0e10cSrcweir 1184*cdf0e10cSrcweir 1185*cdf0e10cSrcweir 1186*cdf0e10cSrcweir 1187*cdf0e10cSrcweir void Outliner::PrepareSpellCheck (void) 1188*cdf0e10cSrcweir { 1189*cdf0e10cSrcweir EESpellState eState = HasSpellErrors(); 1190*cdf0e10cSrcweir DBG_ASSERT(eState != EE_SPELL_NOSPELLER, "No SpellChecker"); 1191*cdf0e10cSrcweir 1192*cdf0e10cSrcweir if (eState == EE_SPELL_NOLANGUAGE) 1193*cdf0e10cSrcweir { 1194*cdf0e10cSrcweir mbError = sal_True; 1195*cdf0e10cSrcweir mbEndOfSearch = sal_True; 1196*cdf0e10cSrcweir ErrorBox aErrorBox (NULL, 1197*cdf0e10cSrcweir WB_OK, 1198*cdf0e10cSrcweir String(SdResId(STR_NOLANGUAGE))); 1199*cdf0e10cSrcweir ShowModalMessageBox (aErrorBox); 1200*cdf0e10cSrcweir } 1201*cdf0e10cSrcweir else if (eState != EE_SPELL_OK) 1202*cdf0e10cSrcweir { 1203*cdf0e10cSrcweir // When spell checking we have to test whether we have processed the 1204*cdf0e10cSrcweir // whole document and have reached the start page again. 1205*cdf0e10cSrcweir if (meMode == SPELL) 1206*cdf0e10cSrcweir { 1207*cdf0e10cSrcweir if (maSearchStartPosition == ::sd::outliner::Iterator()) 1208*cdf0e10cSrcweir // Remember the position of the first text object so that we 1209*cdf0e10cSrcweir // know when we have processed the whole document. 1210*cdf0e10cSrcweir maSearchStartPosition = maObjectIterator; 1211*cdf0e10cSrcweir else if (maSearchStartPosition == maObjectIterator) 1212*cdf0e10cSrcweir { 1213*cdf0e10cSrcweir mbEndOfSearch = true; 1214*cdf0e10cSrcweir } 1215*cdf0e10cSrcweir } 1216*cdf0e10cSrcweir 1217*cdf0e10cSrcweir EnterEditMode( sal_False ); 1218*cdf0e10cSrcweir } 1219*cdf0e10cSrcweir } 1220*cdf0e10cSrcweir 1221*cdf0e10cSrcweir 1222*cdf0e10cSrcweir 1223*cdf0e10cSrcweir 1224*cdf0e10cSrcweir void Outliner::PrepareSearchAndReplace (void) 1225*cdf0e10cSrcweir { 1226*cdf0e10cSrcweir if (HasText( *mpSearchItem )) 1227*cdf0e10cSrcweir { 1228*cdf0e10cSrcweir mbStringFound = true; 1229*cdf0e10cSrcweir mbMatchMayExist = true; 1230*cdf0e10cSrcweir 1231*cdf0e10cSrcweir EnterEditMode (); 1232*cdf0e10cSrcweir 1233*cdf0e10cSrcweir mpDrawDocument->GetDocSh()->SetWaitCursor( sal_False ); 1234*cdf0e10cSrcweir // Start seach at the right end of the current object's text 1235*cdf0e10cSrcweir // depending on the search direction. 1236*cdf0e10cSrcweir OutlinerView* pOutlinerView = mpImpl->GetOutlinerView(); 1237*cdf0e10cSrcweir if (pOutlinerView != NULL) 1238*cdf0e10cSrcweir pOutlinerView->SetSelection (GetSearchStartPosition ()); 1239*cdf0e10cSrcweir } 1240*cdf0e10cSrcweir } 1241*cdf0e10cSrcweir 1242*cdf0e10cSrcweir 1243*cdf0e10cSrcweir 1244*cdf0e10cSrcweir 1245*cdf0e10cSrcweir void Outliner::SetViewMode (PageKind ePageKind) 1246*cdf0e10cSrcweir { 1247*cdf0e10cSrcweir ::boost::shared_ptr<DrawViewShell> pDrawViewShell( 1248*cdf0e10cSrcweir ::boost::dynamic_pointer_cast<DrawViewShell>(mpViewShell)); 1249*cdf0e10cSrcweir if (pDrawViewShell.get()!=NULL && ePageKind != pDrawViewShell->GetPageKind()) 1250*cdf0e10cSrcweir { 1251*cdf0e10cSrcweir // Restore old edit mode. 1252*cdf0e10cSrcweir pDrawViewShell->ChangeEditMode(mpImpl->meOriginalEditMode, sal_False); 1253*cdf0e10cSrcweir 1254*cdf0e10cSrcweir SetStatusEventHdl(Link()); 1255*cdf0e10cSrcweir ::rtl::OUString sViewURL; 1256*cdf0e10cSrcweir switch (ePageKind) 1257*cdf0e10cSrcweir { 1258*cdf0e10cSrcweir case PK_STANDARD: 1259*cdf0e10cSrcweir default: 1260*cdf0e10cSrcweir sViewURL = framework::FrameworkHelper::msImpressViewURL; 1261*cdf0e10cSrcweir break; 1262*cdf0e10cSrcweir case PK_NOTES: 1263*cdf0e10cSrcweir sViewURL = framework::FrameworkHelper::msNotesViewURL; 1264*cdf0e10cSrcweir break; 1265*cdf0e10cSrcweir case PK_HANDOUT: 1266*cdf0e10cSrcweir sViewURL = framework::FrameworkHelper::msHandoutViewURL; 1267*cdf0e10cSrcweir break; 1268*cdf0e10cSrcweir } 1269*cdf0e10cSrcweir // The text object iterator is destroyed when the shells are 1270*cdf0e10cSrcweir // switched but we need it so save it and restore it afterwards. 1271*cdf0e10cSrcweir ::sd::outliner::Iterator aIterator (maObjectIterator); 1272*cdf0e10cSrcweir bool bMatchMayExist = mbMatchMayExist; 1273*cdf0e10cSrcweir 1274*cdf0e10cSrcweir ViewShellBase& rBase = mpViewShell->GetViewShellBase(); 1275*cdf0e10cSrcweir SetViewShell(::boost::shared_ptr<ViewShell>()); 1276*cdf0e10cSrcweir framework::FrameworkHelper::Instance(rBase)->RequestView( 1277*cdf0e10cSrcweir sViewURL, 1278*cdf0e10cSrcweir framework::FrameworkHelper::msCenterPaneURL); 1279*cdf0e10cSrcweir 1280*cdf0e10cSrcweir // Force (well, request) a synchronous update of the configuration. 1281*cdf0e10cSrcweir // In a better world we would handle the asynchronous view update 1282*cdf0e10cSrcweir // instead. But that would involve major restucturing of the 1283*cdf0e10cSrcweir // Outliner code. 1284*cdf0e10cSrcweir framework::FrameworkHelper::Instance(rBase)->RequestSynchronousUpdate(); 1285*cdf0e10cSrcweir SetViewShell(rBase.GetMainViewShell()); 1286*cdf0e10cSrcweir 1287*cdf0e10cSrcweir // Switching to another view shell has intermediatly called 1288*cdf0e10cSrcweir // EndSpelling(). A PrepareSpelling() is pending, so call that now. 1289*cdf0e10cSrcweir PrepareSpelling(); 1290*cdf0e10cSrcweir 1291*cdf0e10cSrcweir // Update the number of pages so that 1292*cdf0e10cSrcweir // <member>DetectChange()</member> has the correct value to compare 1293*cdf0e10cSrcweir // to. 1294*cdf0e10cSrcweir mnPageCount = mpDrawDocument->GetSdPageCount(ePageKind); 1295*cdf0e10cSrcweir 1296*cdf0e10cSrcweir maObjectIterator = aIterator; 1297*cdf0e10cSrcweir mbMatchMayExist = bMatchMayExist; 1298*cdf0e10cSrcweir 1299*cdf0e10cSrcweir // Save edit mode so that it can be restored when switching the view 1300*cdf0e10cSrcweir // shell again. 1301*cdf0e10cSrcweir pDrawViewShell = ::boost::dynamic_pointer_cast<DrawViewShell>(mpViewShell); 1302*cdf0e10cSrcweir OSL_ASSERT(pDrawViewShell.get()!=NULL); 1303*cdf0e10cSrcweir if (pDrawViewShell.get() != NULL) 1304*cdf0e10cSrcweir mpImpl->meOriginalEditMode = pDrawViewShell->GetEditMode(); 1305*cdf0e10cSrcweir } 1306*cdf0e10cSrcweir } 1307*cdf0e10cSrcweir 1308*cdf0e10cSrcweir 1309*cdf0e10cSrcweir 1310*cdf0e10cSrcweir 1311*cdf0e10cSrcweir void Outliner::SetPage (EditMode eEditMode, sal_uInt16 nPageIndex) 1312*cdf0e10cSrcweir { 1313*cdf0e10cSrcweir if ( ! mbRestrictSearchToSelection) 1314*cdf0e10cSrcweir { 1315*cdf0e10cSrcweir ::boost::shared_ptr<DrawViewShell> pDrawViewShell( 1316*cdf0e10cSrcweir ::boost::dynamic_pointer_cast<DrawViewShell>(mpViewShell)); 1317*cdf0e10cSrcweir OSL_ASSERT(pDrawViewShell.get()!=NULL); 1318*cdf0e10cSrcweir if (pDrawViewShell.get() != NULL) 1319*cdf0e10cSrcweir { 1320*cdf0e10cSrcweir pDrawViewShell->ChangeEditMode(eEditMode, sal_False); 1321*cdf0e10cSrcweir pDrawViewShell->SwitchPage(nPageIndex); 1322*cdf0e10cSrcweir } 1323*cdf0e10cSrcweir } 1324*cdf0e10cSrcweir } 1325*cdf0e10cSrcweir 1326*cdf0e10cSrcweir 1327*cdf0e10cSrcweir 1328*cdf0e10cSrcweir 1329*cdf0e10cSrcweir void Outliner::EnterEditMode (sal_Bool bGrabFocus) 1330*cdf0e10cSrcweir { 1331*cdf0e10cSrcweir OutlinerView* pOutlinerView = mpImpl->GetOutlinerView(); 1332*cdf0e10cSrcweir if (mbViewShellValid && pOutlinerView != NULL) 1333*cdf0e10cSrcweir { 1334*cdf0e10cSrcweir pOutlinerView->SetOutputArea( Rectangle( Point(), Size(1, 1))); 1335*cdf0e10cSrcweir SetPaperSize( mpTextObj->GetLogicRect().GetSize() ); 1336*cdf0e10cSrcweir SdrPageView* pPV = mpView->GetSdrPageView(); 1337*cdf0e10cSrcweir 1338*cdf0e10cSrcweir // Make FuText the current function. 1339*cdf0e10cSrcweir SfxUInt16Item aItem (SID_TEXTEDIT, 1); 1340*cdf0e10cSrcweir mpViewShell->GetDispatcher()-> 1341*cdf0e10cSrcweir Execute(SID_TEXTEDIT, SFX_CALLMODE_SYNCHRON | 1342*cdf0e10cSrcweir SFX_CALLMODE_RECORD, &aItem, 0L); 1343*cdf0e10cSrcweir 1344*cdf0e10cSrcweir // To be consistent with the usual behaviour in the Office the text 1345*cdf0e10cSrcweir // object that is put into edit mode would have also to be selected. 1346*cdf0e10cSrcweir // Starting the text edit mode is not enough so we do it here by 1347*cdf0e10cSrcweir // hand. 1348*cdf0e10cSrcweir mbExpectingSelectionChangeEvent = true; 1349*cdf0e10cSrcweir mpView->UnmarkAllObj (pPV); 1350*cdf0e10cSrcweir mpView->MarkObj (mpTextObj, pPV); 1351*cdf0e10cSrcweir 1352*cdf0e10cSrcweir if( mpTextObj ) 1353*cdf0e10cSrcweir mpTextObj->setActiveText( mnText ); 1354*cdf0e10cSrcweir 1355*cdf0e10cSrcweir // Turn on the edit mode for the text object. 1356*cdf0e10cSrcweir mpView->SdrBeginTextEdit(mpTextObj, pPV, mpWindow, sal_True, this, pOutlinerView, sal_True, sal_True, bGrabFocus); 1357*cdf0e10cSrcweir 1358*cdf0e10cSrcweir SetUpdateMode(sal_True); 1359*cdf0e10cSrcweir mbFoundObject = sal_True; 1360*cdf0e10cSrcweir } 1361*cdf0e10cSrcweir } 1362*cdf0e10cSrcweir 1363*cdf0e10cSrcweir 1364*cdf0e10cSrcweir 1365*cdf0e10cSrcweir 1366*cdf0e10cSrcweir /************************************************************************* 1367*cdf0e10cSrcweir |* 1368*cdf0e10cSrcweir |* SpellChecker: Error-LinkHdl 1369*cdf0e10cSrcweir |* 1370*cdf0e10cSrcweir \************************************************************************/ 1371*cdf0e10cSrcweir 1372*cdf0e10cSrcweir IMPL_LINK_INLINE_START( Outliner, SpellError, void *, nLang ) 1373*cdf0e10cSrcweir { 1374*cdf0e10cSrcweir mbError = true; 1375*cdf0e10cSrcweir String aError( SvtLanguageTable::GetLanguageString( (LanguageType)(sal_uLong)nLang ) ); 1376*cdf0e10cSrcweir ErrorHandler::HandleError(* new StringErrorInfo( 1377*cdf0e10cSrcweir ERRCODE_SVX_LINGU_LANGUAGENOTEXISTS, aError) ); 1378*cdf0e10cSrcweir return 0; 1379*cdf0e10cSrcweir } 1380*cdf0e10cSrcweir IMPL_LINK_INLINE_END( Outliner, SpellError, void *, nLang ) 1381*cdf0e10cSrcweir 1382*cdf0e10cSrcweir 1383*cdf0e10cSrcweir 1384*cdf0e10cSrcweir 1385*cdf0e10cSrcweir ESelection Outliner::GetSearchStartPosition (void) 1386*cdf0e10cSrcweir { 1387*cdf0e10cSrcweir ESelection aPosition; 1388*cdf0e10cSrcweir if (mbDirectionIsForward) 1389*cdf0e10cSrcweir { 1390*cdf0e10cSrcweir // The default constructor uses the beginning of the text as default. 1391*cdf0e10cSrcweir aPosition = ESelection (); 1392*cdf0e10cSrcweir } 1393*cdf0e10cSrcweir else 1394*cdf0e10cSrcweir { 1395*cdf0e10cSrcweir // Retrieve the position after the last character in the last 1396*cdf0e10cSrcweir // paragraph. 1397*cdf0e10cSrcweir sal_uInt16 nParagraphCount = static_cast<sal_uInt16>(GetParagraphCount()); 1398*cdf0e10cSrcweir if (nParagraphCount == 0) 1399*cdf0e10cSrcweir aPosition = ESelection(); 1400*cdf0e10cSrcweir else 1401*cdf0e10cSrcweir { 1402*cdf0e10cSrcweir xub_StrLen nLastParagraphLength = GetEditEngine().GetTextLen ( 1403*cdf0e10cSrcweir nParagraphCount-1); 1404*cdf0e10cSrcweir aPosition = ESelection (nParagraphCount-1, nLastParagraphLength); 1405*cdf0e10cSrcweir } 1406*cdf0e10cSrcweir } 1407*cdf0e10cSrcweir 1408*cdf0e10cSrcweir return aPosition; 1409*cdf0e10cSrcweir } 1410*cdf0e10cSrcweir 1411*cdf0e10cSrcweir 1412*cdf0e10cSrcweir 1413*cdf0e10cSrcweir 1414*cdf0e10cSrcweir bool Outliner::HasNoPreviousMatch (void) 1415*cdf0e10cSrcweir { 1416*cdf0e10cSrcweir OutlinerView* pOutlinerView = mpImpl->GetOutlinerView(); 1417*cdf0e10cSrcweir 1418*cdf0e10cSrcweir DBG_ASSERT (pOutlinerView!=NULL, "outline view in Outliner::HasNoPreviousMatch is NULL"); 1419*cdf0e10cSrcweir 1420*cdf0e10cSrcweir // Detect whether the cursor stands at the beginning 1421*cdf0e10cSrcweir // resp. at the end of the text. 1422*cdf0e10cSrcweir return pOutlinerView->GetSelection().IsEqual(GetSearchStartPosition ()) == sal_True; 1423*cdf0e10cSrcweir } 1424*cdf0e10cSrcweir 1425*cdf0e10cSrcweir 1426*cdf0e10cSrcweir 1427*cdf0e10cSrcweir 1428*cdf0e10cSrcweir bool Outliner::HandleFailedSearch (void) 1429*cdf0e10cSrcweir { 1430*cdf0e10cSrcweir bool bContinueSearch = false; 1431*cdf0e10cSrcweir 1432*cdf0e10cSrcweir OutlinerView* pOutlinerView = mpImpl->GetOutlinerView(); 1433*cdf0e10cSrcweir if (pOutlinerView != NULL && mpSearchItem != NULL) 1434*cdf0e10cSrcweir { 1435*cdf0e10cSrcweir // Detect whether there is/may be a prior match. If there is then 1436*cdf0e10cSrcweir // ask the user whether to wrap arround. Otherwise tell the user 1437*cdf0e10cSrcweir // that there is no match. 1438*cdf0e10cSrcweir if (HasNoPreviousMatch ()) 1439*cdf0e10cSrcweir { 1440*cdf0e10cSrcweir // No match found in the whole presentation. Tell the user. 1441*cdf0e10cSrcweir InfoBox aInfoBox (NULL, 1442*cdf0e10cSrcweir String(SdResId(STR_SAR_NOT_FOUND))); 1443*cdf0e10cSrcweir ShowModalMessageBox (aInfoBox); 1444*cdf0e10cSrcweir } 1445*cdf0e10cSrcweir 1446*cdf0e10cSrcweir else 1447*cdf0e10cSrcweir { 1448*cdf0e10cSrcweir // No further matches found. Ask the user whether to wrap 1449*cdf0e10cSrcweir // arround and start again. 1450*cdf0e10cSrcweir bContinueSearch = ShowWrapArroundDialog (); 1451*cdf0e10cSrcweir } 1452*cdf0e10cSrcweir } 1453*cdf0e10cSrcweir 1454*cdf0e10cSrcweir return bContinueSearch; 1455*cdf0e10cSrcweir } 1456*cdf0e10cSrcweir 1457*cdf0e10cSrcweir 1458*cdf0e10cSrcweir SdrObject* Outliner::SetObject ( 1459*cdf0e10cSrcweir const ::sd::outliner::IteratorPosition& rPosition) 1460*cdf0e10cSrcweir { 1461*cdf0e10cSrcweir SetViewMode (rPosition.mePageKind); 1462*cdf0e10cSrcweir SetPage (rPosition.meEditMode, (sal_uInt16)rPosition.mnPageIndex); 1463*cdf0e10cSrcweir mnText = rPosition.mnText; 1464*cdf0e10cSrcweir return rPosition.mxObject.get(); 1465*cdf0e10cSrcweir } 1466*cdf0e10cSrcweir 1467*cdf0e10cSrcweir 1468*cdf0e10cSrcweir 1469*cdf0e10cSrcweir 1470*cdf0e10cSrcweir void Outliner::SetViewShell (const ::boost::shared_ptr<ViewShell>& rpViewShell) 1471*cdf0e10cSrcweir { 1472*cdf0e10cSrcweir if (mpViewShell != rpViewShell) 1473*cdf0e10cSrcweir { 1474*cdf0e10cSrcweir // Set the new view shell. 1475*cdf0e10cSrcweir mpViewShell = rpViewShell; 1476*cdf0e10cSrcweir // When the outline view is not owned by us then we have to clear 1477*cdf0e10cSrcweir // that pointer so that the current one for the new view shell will 1478*cdf0e10cSrcweir // be used (in ProvideOutlinerView). 1479*cdf0e10cSrcweir // if ( ! mbOwnOutlineView) 1480*cdf0e10cSrcweir // mpOutlineView = NULL; 1481*cdf0e10cSrcweir if (mpViewShell.get() != NULL) 1482*cdf0e10cSrcweir { 1483*cdf0e10cSrcweir mpView = mpViewShell->GetView(); 1484*cdf0e10cSrcweir 1485*cdf0e10cSrcweir mpWindow = mpViewShell->GetActiveWindow(); 1486*cdf0e10cSrcweir 1487*cdf0e10cSrcweir mpImpl->ProvideOutlinerView(*this, mpViewShell, mpWindow); 1488*cdf0e10cSrcweir OutlinerView* pOutlinerView = mpImpl->GetOutlinerView(); 1489*cdf0e10cSrcweir if (pOutlinerView != NULL) 1490*cdf0e10cSrcweir pOutlinerView->SetWindow(mpWindow); 1491*cdf0e10cSrcweir } 1492*cdf0e10cSrcweir else 1493*cdf0e10cSrcweir { 1494*cdf0e10cSrcweir mpView = NULL; 1495*cdf0e10cSrcweir mpWindow = NULL; 1496*cdf0e10cSrcweir } 1497*cdf0e10cSrcweir } 1498*cdf0e10cSrcweir } 1499*cdf0e10cSrcweir 1500*cdf0e10cSrcweir 1501*cdf0e10cSrcweir 1502*cdf0e10cSrcweir 1503*cdf0e10cSrcweir void Outliner::HandleChangedSelection (void) 1504*cdf0e10cSrcweir { 1505*cdf0e10cSrcweir maMarkListCopy.clear(); 1506*cdf0e10cSrcweir mbRestrictSearchToSelection = (mpView->AreObjectsMarked()==sal_True); 1507*cdf0e10cSrcweir if (mbRestrictSearchToSelection) 1508*cdf0e10cSrcweir { 1509*cdf0e10cSrcweir // Make a copy of the current mark list. 1510*cdf0e10cSrcweir const SdrMarkList& rMarkList = mpView->GetMarkedObjectList(); 1511*cdf0e10cSrcweir sal_uLong nCount = rMarkList.GetMarkCount(); 1512*cdf0e10cSrcweir if (nCount > 0) 1513*cdf0e10cSrcweir { 1514*cdf0e10cSrcweir maMarkListCopy.clear(); 1515*cdf0e10cSrcweir maMarkListCopy.reserve (nCount); 1516*cdf0e10cSrcweir for (sal_uLong i=0; i<nCount; i++) 1517*cdf0e10cSrcweir maMarkListCopy.push_back (rMarkList.GetMark(i)->GetMarkedSdrObj ()); 1518*cdf0e10cSrcweir } 1519*cdf0e10cSrcweir else 1520*cdf0e10cSrcweir // No marked object. Is this case possible? 1521*cdf0e10cSrcweir mbRestrictSearchToSelection = false; 1522*cdf0e10cSrcweir } 1523*cdf0e10cSrcweir } 1524*cdf0e10cSrcweir 1525*cdf0e10cSrcweir 1526*cdf0e10cSrcweir 1527*cdf0e10cSrcweir 1528*cdf0e10cSrcweir 1529*cdf0e10cSrcweir void Outliner::StartConversion( sal_Int16 nSourceLanguage, sal_Int16 nTargetLanguage, 1530*cdf0e10cSrcweir const Font *pTargetFont, sal_Int32 nOptions, sal_Bool bIsInteractive ) 1531*cdf0e10cSrcweir { 1532*cdf0e10cSrcweir sal_Bool bMultiDoc = mpViewShell->ISA(DrawViewShell); 1533*cdf0e10cSrcweir 1534*cdf0e10cSrcweir meMode = TEXT_CONVERSION; 1535*cdf0e10cSrcweir mbDirectionIsForward = true; 1536*cdf0e10cSrcweir mpSearchItem = NULL; 1537*cdf0e10cSrcweir mnConversionLanguage = nSourceLanguage; 1538*cdf0e10cSrcweir 1539*cdf0e10cSrcweir BeginConversion(); 1540*cdf0e10cSrcweir 1541*cdf0e10cSrcweir OutlinerView* pOutlinerView = mpImpl->GetOutlinerView(); 1542*cdf0e10cSrcweir if (pOutlinerView != NULL) 1543*cdf0e10cSrcweir { 1544*cdf0e10cSrcweir pOutlinerView->StartTextConversion( 1545*cdf0e10cSrcweir nSourceLanguage, 1546*cdf0e10cSrcweir nTargetLanguage, 1547*cdf0e10cSrcweir pTargetFont, 1548*cdf0e10cSrcweir nOptions, 1549*cdf0e10cSrcweir bIsInteractive, 1550*cdf0e10cSrcweir bMultiDoc); 1551*cdf0e10cSrcweir } 1552*cdf0e10cSrcweir 1553*cdf0e10cSrcweir EndConversion(); 1554*cdf0e10cSrcweir } 1555*cdf0e10cSrcweir 1556*cdf0e10cSrcweir 1557*cdf0e10cSrcweir 1558*cdf0e10cSrcweir 1559*cdf0e10cSrcweir /** Prepare to do a text conversion on the current text object. This 1560*cdf0e10cSrcweir includes putting it into edit mode. 1561*cdf0e10cSrcweir */ 1562*cdf0e10cSrcweir void Outliner::PrepareConversion (void) 1563*cdf0e10cSrcweir { 1564*cdf0e10cSrcweir SetUpdateMode(sal_True); 1565*cdf0e10cSrcweir if( HasConvertibleTextPortion( mnConversionLanguage ) ) 1566*cdf0e10cSrcweir { 1567*cdf0e10cSrcweir SetUpdateMode(sal_False); 1568*cdf0e10cSrcweir mbStringFound = sal_True; 1569*cdf0e10cSrcweir mbMatchMayExist = sal_True; 1570*cdf0e10cSrcweir 1571*cdf0e10cSrcweir EnterEditMode (); 1572*cdf0e10cSrcweir 1573*cdf0e10cSrcweir mpDrawDocument->GetDocSh()->SetWaitCursor( sal_False ); 1574*cdf0e10cSrcweir // Start seach at the right end of the current object's text 1575*cdf0e10cSrcweir // depending on the search direction. 1576*cdf0e10cSrcweir // mpOutlineView->SetSelection (GetSearchStartPosition ()); 1577*cdf0e10cSrcweir } 1578*cdf0e10cSrcweir else 1579*cdf0e10cSrcweir { 1580*cdf0e10cSrcweir SetUpdateMode(sal_False); 1581*cdf0e10cSrcweir } 1582*cdf0e10cSrcweir } 1583*cdf0e10cSrcweir 1584*cdf0e10cSrcweir 1585*cdf0e10cSrcweir 1586*cdf0e10cSrcweir 1587*cdf0e10cSrcweir void Outliner::BeginConversion (void) 1588*cdf0e10cSrcweir { 1589*cdf0e10cSrcweir SetRefDevice( SD_MOD()->GetRefDevice( *mpDrawDocument->GetDocSh() ) ); 1590*cdf0e10cSrcweir 1591*cdf0e10cSrcweir ViewShellBase* pBase = PTR_CAST(ViewShellBase, SfxViewShell::Current()); 1592*cdf0e10cSrcweir if (pBase != NULL) 1593*cdf0e10cSrcweir SetViewShell (pBase->GetMainViewShell()); 1594*cdf0e10cSrcweir 1595*cdf0e10cSrcweir if (mpViewShell != NULL) 1596*cdf0e10cSrcweir { 1597*cdf0e10cSrcweir mbStringFound = sal_False; 1598*cdf0e10cSrcweir 1599*cdf0e10cSrcweir // Supposed that we are not located at the very beginning/end of the 1600*cdf0e10cSrcweir // document then there may be a match in the document prior/after 1601*cdf0e10cSrcweir // the current position. 1602*cdf0e10cSrcweir mbMatchMayExist = sal_True; 1603*cdf0e10cSrcweir 1604*cdf0e10cSrcweir maObjectIterator = ::sd::outliner::Iterator(); 1605*cdf0e10cSrcweir maSearchStartPosition = ::sd::outliner::Iterator(); 1606*cdf0e10cSrcweir RememberStartPosition(); 1607*cdf0e10cSrcweir 1608*cdf0e10cSrcweir mpImpl->ProvideOutlinerView(*this, mpViewShell, mpWindow); 1609*cdf0e10cSrcweir 1610*cdf0e10cSrcweir HandleChangedSelection (); 1611*cdf0e10cSrcweir } 1612*cdf0e10cSrcweir ClearModifyFlag(); 1613*cdf0e10cSrcweir } 1614*cdf0e10cSrcweir 1615*cdf0e10cSrcweir 1616*cdf0e10cSrcweir 1617*cdf0e10cSrcweir 1618*cdf0e10cSrcweir void Outliner::EndConversion() 1619*cdf0e10cSrcweir { 1620*cdf0e10cSrcweir EndSpelling(); 1621*cdf0e10cSrcweir } 1622*cdf0e10cSrcweir 1623*cdf0e10cSrcweir 1624*cdf0e10cSrcweir 1625*cdf0e10cSrcweir 1626*cdf0e10cSrcweir sal_Bool Outliner::ConvertNextDocument() 1627*cdf0e10cSrcweir { 1628*cdf0e10cSrcweir if( mpViewShell && mpViewShell->ISA(OutlineViewShell) ) 1629*cdf0e10cSrcweir return false; 1630*cdf0e10cSrcweir 1631*cdf0e10cSrcweir mpDrawDocument->GetDocSh()->SetWaitCursor( sal_True ); 1632*cdf0e10cSrcweir 1633*cdf0e10cSrcweir Initialize ( true ); 1634*cdf0e10cSrcweir 1635*cdf0e10cSrcweir OutlinerView* pOutlinerView = mpImpl->GetOutlinerView(); 1636*cdf0e10cSrcweir if (pOutlinerView != NULL) 1637*cdf0e10cSrcweir { 1638*cdf0e10cSrcweir mpWindow = mpViewShell->GetActiveWindow(); 1639*cdf0e10cSrcweir pOutlinerView->SetWindow(mpWindow); 1640*cdf0e10cSrcweir } 1641*cdf0e10cSrcweir ProvideNextTextObject (); 1642*cdf0e10cSrcweir 1643*cdf0e10cSrcweir mpDrawDocument->GetDocSh()->SetWaitCursor( sal_False ); 1644*cdf0e10cSrcweir ClearModifyFlag(); 1645*cdf0e10cSrcweir 1646*cdf0e10cSrcweir // for text conversion we automaticly wrap around one 1647*cdf0e10cSrcweir // time and stop at the start shape 1648*cdf0e10cSrcweir if( mpFirstObj ) 1649*cdf0e10cSrcweir { 1650*cdf0e10cSrcweir if( (mnText == 0) && (mpFirstObj == mpObj) ) 1651*cdf0e10cSrcweir return false; 1652*cdf0e10cSrcweir } 1653*cdf0e10cSrcweir else 1654*cdf0e10cSrcweir { 1655*cdf0e10cSrcweir mpFirstObj = mpObj; 1656*cdf0e10cSrcweir } 1657*cdf0e10cSrcweir 1658*cdf0e10cSrcweir return !mbEndOfSearch; 1659*cdf0e10cSrcweir } 1660*cdf0e10cSrcweir 1661*cdf0e10cSrcweir 1662*cdf0e10cSrcweir 1663*cdf0e10cSrcweir 1664*cdf0e10cSrcweir sal_uInt16 Outliner::ShowModalMessageBox (Dialog& rMessageBox) 1665*cdf0e10cSrcweir { 1666*cdf0e10cSrcweir // We assume that the parent of the given messge box is NULL, i.e. it is 1667*cdf0e10cSrcweir // modal with respect to the top application window. However, this 1668*cdf0e10cSrcweir // does not affect the search dialog. Therefore we have to lock it here 1669*cdf0e10cSrcweir // while the message box is being shown. We also have to take into 1670*cdf0e10cSrcweir // account that we are called during a spell check and the search dialog 1671*cdf0e10cSrcweir // is not available. 1672*cdf0e10cSrcweir ::Window* pSearchDialog = NULL; 1673*cdf0e10cSrcweir SfxChildWindow* pChildWindow = NULL; 1674*cdf0e10cSrcweir switch (meMode) 1675*cdf0e10cSrcweir { 1676*cdf0e10cSrcweir case SEARCH: 1677*cdf0e10cSrcweir pChildWindow = SfxViewFrame::Current()->GetChildWindow( 1678*cdf0e10cSrcweir SvxSearchDialogWrapper::GetChildWindowId()); 1679*cdf0e10cSrcweir break; 1680*cdf0e10cSrcweir 1681*cdf0e10cSrcweir case SPELL: 1682*cdf0e10cSrcweir pChildWindow = SfxViewFrame::Current()->GetChildWindow( 1683*cdf0e10cSrcweir SpellDialogChildWindow::GetChildWindowId()); 1684*cdf0e10cSrcweir break; 1685*cdf0e10cSrcweir 1686*cdf0e10cSrcweir case TEXT_CONVERSION: 1687*cdf0e10cSrcweir // There should no messages boxes be displayed while doing the 1688*cdf0e10cSrcweir // hangul hanja conversion. 1689*cdf0e10cSrcweir break; 1690*cdf0e10cSrcweir } 1691*cdf0e10cSrcweir 1692*cdf0e10cSrcweir if (pChildWindow != NULL) 1693*cdf0e10cSrcweir pSearchDialog = pChildWindow->GetWindow(); 1694*cdf0e10cSrcweir if (pSearchDialog != NULL) 1695*cdf0e10cSrcweir pSearchDialog->EnableInput(sal_False,sal_True); 1696*cdf0e10cSrcweir 1697*cdf0e10cSrcweir sal_uInt16 nResult = rMessageBox.Execute(); 1698*cdf0e10cSrcweir 1699*cdf0e10cSrcweir // Unlock the search dialog. 1700*cdf0e10cSrcweir if (pSearchDialog != NULL) 1701*cdf0e10cSrcweir pSearchDialog->EnableInput(sal_True,sal_True); 1702*cdf0e10cSrcweir 1703*cdf0e10cSrcweir return nResult; 1704*cdf0e10cSrcweir } 1705*cdf0e10cSrcweir 1706*cdf0e10cSrcweir 1707*cdf0e10cSrcweir 1708*cdf0e10cSrcweir 1709*cdf0e10cSrcweir //===== Outliner::Implementation ============================================== 1710*cdf0e10cSrcweir 1711*cdf0e10cSrcweir Outliner::Implementation::Implementation (void) 1712*cdf0e10cSrcweir : meOriginalEditMode(EM_PAGE), 1713*cdf0e10cSrcweir mbOwnOutlineView(false), 1714*cdf0e10cSrcweir mpOutlineView(NULL) 1715*cdf0e10cSrcweir { 1716*cdf0e10cSrcweir } 1717*cdf0e10cSrcweir 1718*cdf0e10cSrcweir 1719*cdf0e10cSrcweir 1720*cdf0e10cSrcweir 1721*cdf0e10cSrcweir Outliner::Implementation::~Implementation (void) 1722*cdf0e10cSrcweir { 1723*cdf0e10cSrcweir if (mbOwnOutlineView && mpOutlineView!=NULL) 1724*cdf0e10cSrcweir { 1725*cdf0e10cSrcweir mpOutlineView->SetWindow(NULL); 1726*cdf0e10cSrcweir delete mpOutlineView; 1727*cdf0e10cSrcweir mpOutlineView = NULL; 1728*cdf0e10cSrcweir } 1729*cdf0e10cSrcweir } 1730*cdf0e10cSrcweir 1731*cdf0e10cSrcweir 1732*cdf0e10cSrcweir 1733*cdf0e10cSrcweir 1734*cdf0e10cSrcweir OutlinerView* Outliner::Implementation::GetOutlinerView () 1735*cdf0e10cSrcweir { 1736*cdf0e10cSrcweir return mpOutlineView; 1737*cdf0e10cSrcweir } 1738*cdf0e10cSrcweir 1739*cdf0e10cSrcweir 1740*cdf0e10cSrcweir 1741*cdf0e10cSrcweir 1742*cdf0e10cSrcweir /** We try to create a new OutlinerView only when there is none available, 1743*cdf0e10cSrcweir either from an OutlinerViewShell or a previous call to 1744*cdf0e10cSrcweir ProvideOutlinerView(). This is necessary to support the spell checker 1745*cdf0e10cSrcweir which can not cope with exchanging the OutlinerView. 1746*cdf0e10cSrcweir */ 1747*cdf0e10cSrcweir void Outliner::Implementation::ProvideOutlinerView ( 1748*cdf0e10cSrcweir Outliner& rOutliner, 1749*cdf0e10cSrcweir const ::boost::shared_ptr<ViewShell>& rpViewShell, 1750*cdf0e10cSrcweir ::Window* pWindow) 1751*cdf0e10cSrcweir { 1752*cdf0e10cSrcweir if (rpViewShell.get() != NULL) 1753*cdf0e10cSrcweir { 1754*cdf0e10cSrcweir switch (rpViewShell->GetShellType()) 1755*cdf0e10cSrcweir { 1756*cdf0e10cSrcweir case ViewShell::ST_DRAW: 1757*cdf0e10cSrcweir case ViewShell::ST_IMPRESS: 1758*cdf0e10cSrcweir case ViewShell::ST_NOTES: 1759*cdf0e10cSrcweir case ViewShell::ST_HANDOUT: 1760*cdf0e10cSrcweir { 1761*cdf0e10cSrcweir // Create a new outline view to do the search on. 1762*cdf0e10cSrcweir bool bInsert = false; 1763*cdf0e10cSrcweir if (mpOutlineView!=NULL && !mbOwnOutlineView) 1764*cdf0e10cSrcweir mpOutlineView = NULL; 1765*cdf0e10cSrcweir if (mpOutlineView == NULL) 1766*cdf0e10cSrcweir { 1767*cdf0e10cSrcweir mpOutlineView = new OutlinerView(&rOutliner, pWindow); 1768*cdf0e10cSrcweir mbOwnOutlineView = true; 1769*cdf0e10cSrcweir bInsert = true; 1770*cdf0e10cSrcweir } 1771*cdf0e10cSrcweir else 1772*cdf0e10cSrcweir mpOutlineView->SetWindow(pWindow); 1773*cdf0e10cSrcweir sal_uLong nStat = mpOutlineView->GetControlWord(); 1774*cdf0e10cSrcweir nStat &= ~EV_CNTRL_AUTOSCROLL; 1775*cdf0e10cSrcweir mpOutlineView->SetControlWord(nStat); 1776*cdf0e10cSrcweir if (bInsert) 1777*cdf0e10cSrcweir rOutliner.InsertView( mpOutlineView ); 1778*cdf0e10cSrcweir rOutliner.SetUpdateMode(sal_False); 1779*cdf0e10cSrcweir mpOutlineView->SetOutputArea (Rectangle (Point(), Size(1, 1))); 1780*cdf0e10cSrcweir rOutliner.SetPaperSize( Size(1, 1) ); 1781*cdf0e10cSrcweir rOutliner.SetText( String(), rOutliner.GetParagraph( 0 ) ); 1782*cdf0e10cSrcweir 1783*cdf0e10cSrcweir meOriginalEditMode = 1784*cdf0e10cSrcweir ::boost::static_pointer_cast<DrawViewShell>(rpViewShell)->GetEditMode(); 1785*cdf0e10cSrcweir } 1786*cdf0e10cSrcweir break; 1787*cdf0e10cSrcweir 1788*cdf0e10cSrcweir case ViewShell::ST_OUTLINE: 1789*cdf0e10cSrcweir { 1790*cdf0e10cSrcweir if (mpOutlineView!=NULL && mbOwnOutlineView) 1791*cdf0e10cSrcweir delete mpOutlineView; 1792*cdf0e10cSrcweir mpOutlineView = rOutliner.GetView(0); 1793*cdf0e10cSrcweir mbOwnOutlineView = false; 1794*cdf0e10cSrcweir } 1795*cdf0e10cSrcweir break; 1796*cdf0e10cSrcweir 1797*cdf0e10cSrcweir default: 1798*cdf0e10cSrcweir case ViewShell::ST_NONE: 1799*cdf0e10cSrcweir case ViewShell::ST_PRESENTATION: 1800*cdf0e10cSrcweir // Ignored 1801*cdf0e10cSrcweir break; 1802*cdf0e10cSrcweir } 1803*cdf0e10cSrcweir } 1804*cdf0e10cSrcweir } 1805*cdf0e10cSrcweir 1806*cdf0e10cSrcweir 1807*cdf0e10cSrcweir 1808*cdf0e10cSrcweir 1809*cdf0e10cSrcweir void Outliner::Implementation::ReleaseOutlinerView (void) 1810*cdf0e10cSrcweir { 1811*cdf0e10cSrcweir if (mbOwnOutlineView) 1812*cdf0e10cSrcweir { 1813*cdf0e10cSrcweir OutlinerView* pView = mpOutlineView; 1814*cdf0e10cSrcweir mpOutlineView = NULL; 1815*cdf0e10cSrcweir mbOwnOutlineView = false; 1816*cdf0e10cSrcweir if (pView != NULL) 1817*cdf0e10cSrcweir { 1818*cdf0e10cSrcweir pView->SetWindow(NULL); 1819*cdf0e10cSrcweir delete pView; 1820*cdf0e10cSrcweir } 1821*cdf0e10cSrcweir } 1822*cdf0e10cSrcweir else 1823*cdf0e10cSrcweir { 1824*cdf0e10cSrcweir mpOutlineView = NULL; 1825*cdf0e10cSrcweir } 1826*cdf0e10cSrcweir } 1827*cdf0e10cSrcweir 1828*cdf0e10cSrcweir } // end of namespace sd 1829