1c45d927aSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3c45d927aSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4c45d927aSAndrew Rist * or more contributor license agreements. See the NOTICE file 5c45d927aSAndrew Rist * distributed with this work for additional information 6c45d927aSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7c45d927aSAndrew Rist * to you under the Apache License, Version 2.0 (the 8c45d927aSAndrew Rist * "License"); you may not use this file except in compliance 9c45d927aSAndrew Rist * with the License. You may obtain a copy of the License at 10c45d927aSAndrew Rist * 11c45d927aSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12c45d927aSAndrew Rist * 13c45d927aSAndrew Rist * Unless required by applicable law or agreed to in writing, 14c45d927aSAndrew Rist * software distributed under the License is distributed on an 15c45d927aSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16c45d927aSAndrew Rist * KIND, either express or implied. See the License for the 17c45d927aSAndrew Rist * specific language governing permissions and limitations 18c45d927aSAndrew Rist * under the License. 19c45d927aSAndrew Rist * 20c45d927aSAndrew Rist *************************************************************/ 21c45d927aSAndrew Rist 22c45d927aSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef SD_OUTLINER_HXX 25cdf0e10cSrcweir #define SD_OUTLINER_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <svx/svdobj.hxx> 28cdf0e10cSrcweir #include <svx/svdoutl.hxx> 29cdf0e10cSrcweir #include "pres.hxx" 30cdf0e10cSrcweir #include "OutlinerIterator.hxx" 31cdf0e10cSrcweir #include <editeng/SpellPortions.hxx> 32cdf0e10cSrcweir #include <memory> 33cdf0e10cSrcweir #include <boost/shared_ptr.hpp> 34967189efSMichael Stahl #include <boost/weak_ptr.hpp> 35967189efSMichael Stahl #include <boost/noncopyable.hpp> 36cdf0e10cSrcweir 37cdf0e10cSrcweir class Dialog; 38cdf0e10cSrcweir class SdPage; 39cdf0e10cSrcweir class SdrObject; 40cdf0e10cSrcweir class SdrTextObj; 41cdf0e10cSrcweir class SdDrawDocument; 42cdf0e10cSrcweir class SfxStyleSheetPool; 43cdf0e10cSrcweir class SdrObjListIter; 44cdf0e10cSrcweir 45cdf0e10cSrcweir namespace sd { 46cdf0e10cSrcweir 47cdf0e10cSrcweir class DrawViewShell; 48cdf0e10cSrcweir class View; 49cdf0e10cSrcweir class ViewShell; 50cdf0e10cSrcweir class Window; 51cdf0e10cSrcweir 52cdf0e10cSrcweir /** The main purpose of this class is searching and replacing as well as 53cdf0e10cSrcweir spelling of impress documents. The main part of both tasks lies in 54cdf0e10cSrcweir iterating over the pages and view modes of a document and apply the 55cdf0e10cSrcweir respective function to all objects containing text on those pages. 56cdf0e10cSrcweir 57cdf0e10cSrcweir <p>Relevant objects: There are two sets of objects to search/spell 58cdf0e10cSrcweir check. One is the set of all selected objects. The other consists of 59cdf0e10cSrcweir all objects on all pages in draw-, notes-, and handout view as well as 60cdf0e10cSrcweir slide- and background view (draw pages and master pages).</p> 61cdf0e10cSrcweir 62cdf0e10cSrcweir <p>Iteration: Search/replace and spelling functions operate on shapes 63cdf0e10cSrcweir containing text. To cover all relevant objects an order has to be 64cdf0e10cSrcweir defined on the objects. For the set of all selected objects this order 65cdf0e10cSrcweir is simply the order in which they can be retrieved from the selection 66cdf0e10cSrcweir object.<br> 67cdf0e10cSrcweir When there is no selection the order is nested. The three modes of the 68cdf0e10cSrcweir draw view are on the outer level: draw mode, notes mode, handout mode. 69cdf0e10cSrcweir The inner level switches between draw pages and master pages. This 70cdf0e10cSrcweir leads to the following order: 71cdf0e10cSrcweir <ol> 72cdf0e10cSrcweir <li>draw pages of draw mode</li> 73cdf0e10cSrcweir <li>master pages of draw mode</li> 74cdf0e10cSrcweir <li>draw pages of notes mode</li> 75cdf0e10cSrcweir <li>master pages of notes mode</li> 76cdf0e10cSrcweir <li>draw pages of handout mode</li> 77cdf0e10cSrcweir <li>master pages of handout mode</li> 78cdf0e10cSrcweir </ol> 79cdf0e10cSrcweir Iteration starts at the top of the current page. When reaching the end 80cdf0e10cSrcweir of the document, i.e. the last master page of the handout mode, it jumps 81cdf0e10cSrcweir to the first draw page of draw mode. In backward searches this order is 82cdf0e10cSrcweir reversed. When doing a <em>replace all</em> then the whole document is 83cdf0e10cSrcweir searched for matches starting at the first page of the draw/slide view 84cdf0e10cSrcweir (or last page of handout/background view even though search 85cdf0e10cSrcweir direction).</p> 86cdf0e10cSrcweir 87cdf0e10cSrcweir <p>The start position is restored after finishing spell checking or 88cdf0e10cSrcweir replacing all matches in a document.</p> 89cdf0e10cSrcweir 90cdf0e10cSrcweir <p>Some related pieces of information: 91cdf0e10cSrcweir The search dialog (<type>SvxSearchDialog</type>) can be controlled in 92cdf0e10cSrcweir more than one way: 93cdf0e10cSrcweir <ul><li>A set of option flags returned by the slot call 94cdf0e10cSrcweir SID_SEARCH_OPTIONS handled by the 95cdf0e10cSrcweir <member>SdDrawDocument::GetState()</member> method.</li> 96cdf0e10cSrcweir <li>The contents of the search item of type 97cdf0e10cSrcweir <type>SvxSearchItem</type>.</li> 98cdf0e10cSrcweir <li>The <member>HasSelection()</member> view shell method that returns 99cdf0e10cSrcweir whether or not a selection exists. However, it is called from the 100cdf0e10cSrcweir search dialog with an argument so that only text selections are 101cdf0e10cSrcweir queried. This is only sufficient for searching the outline view. 102cdf0e10cSrcweir </p> 103cdf0e10cSrcweir */ 104cdf0e10cSrcweir class Outliner 105967189efSMichael Stahl : public SdrOutliner, 106967189efSMichael Stahl public ::boost::noncopyable 107cdf0e10cSrcweir { 108cdf0e10cSrcweir public: 109cdf0e10cSrcweir friend class ::sd::outliner::OutlinerContainer; 110cdf0e10cSrcweir 111cdf0e10cSrcweir /** Create a new sd outliner object. 112cdf0e10cSrcweir @param pDoc 113cdf0e10cSrcweir The draw document from which to take the content. 114cdf0e10cSrcweir @param nMode 115cdf0e10cSrcweir The valid values <const>OUTLINERMODE_DONTKNOW</const>, 116cdf0e10cSrcweir <const>OUTLINERMODE_TEXTOBJECT</const>, 117cdf0e10cSrcweir <const>OUTLINERMODE_TITLEOBJECT</const>, 118cdf0e10cSrcweir <const>OUTLINERMODE_OUTLINEOBJECT</const>, and 119cdf0e10cSrcweir <const>OUTLINERMODE_OUTLINEVIEW</const> are defined in 120cdf0e10cSrcweir editeng/outliner.hxx. 121cdf0e10cSrcweir */ 122cdf0e10cSrcweir Outliner( SdDrawDocument* pDoc, sal_uInt16 nMode ); 123cdf0e10cSrcweir virtual ~Outliner(); 124cdf0e10cSrcweir 125cdf0e10cSrcweir /** Despite the name this method is called prior to spell cheking *and* 126cdf0e10cSrcweir searching and replacing. The position of current view 127cdf0e10cSrcweir mode/page/object/caret position is remembered and, depending on the 128cdf0e10cSrcweir search mode, may be restored after finishing searching/spell 129cdf0e10cSrcweir checking. 130cdf0e10cSrcweir */ 131cdf0e10cSrcweir void PrepareSpelling (void); 132cdf0e10cSrcweir 133cdf0e10cSrcweir /** Initialize a spell check but do not start it yet. This method 134*86e1cf34SPedro Giffuni is a better candidate for the name PrepareSpelling. 135cdf0e10cSrcweir */ 136cdf0e10cSrcweir void StartSpelling (void); 137cdf0e10cSrcweir 138cdf0e10cSrcweir /** Proxy for method from base class to avoid compiler warning */ 139cdf0e10cSrcweir void StartSpelling(EditView&, unsigned char); 140cdf0e10cSrcweir 141cdf0e10cSrcweir /** Initiate a find and/or replace on the next relevant text object. 142cdf0e10cSrcweir @return 143cdf0e10cSrcweir Returns </sal_True> when the search/replace is finished (as 144cdf0e10cSrcweir indicated by user input to the search dialog). A </sal_False> value 145cdf0e10cSrcweir indicates that another call to this method is required. 146cdf0e10cSrcweir */ 147cdf0e10cSrcweir bool StartSearchAndReplace (const SvxSearchItem* pSearchItem); 148cdf0e10cSrcweir 149cdf0e10cSrcweir /** Iterate over the sentences in all text shapes and stop at the 150cdf0e10cSrcweir next sentence with spelling errors. While doing so the view 151cdf0e10cSrcweir mode may be changed and text shapes are set into edit mode. 152cdf0e10cSrcweir */ 153cdf0e10cSrcweir ::svx::SpellPortions GetNextSpellSentence (void); 154cdf0e10cSrcweir 155cdf0e10cSrcweir /** Release all resources that have been created during the find&replace 156cdf0e10cSrcweir or spell check. 157cdf0e10cSrcweir */ 158cdf0e10cSrcweir void EndSpelling (void); 159cdf0e10cSrcweir 160cdf0e10cSrcweir /** callback for textconversion */ 161cdf0e10cSrcweir sal_Bool ConvertNextDocument (void); 162cdf0e10cSrcweir 163cdf0e10cSrcweir /** Starts the text conversion (hangul/hanja or Chinese simplified/traditional) 164cdf0e10cSrcweir for the current viewshell */ 165cdf0e10cSrcweir void StartConversion( sal_Int16 nSourceLanguage, sal_Int16 nTargetLanguage, 166cdf0e10cSrcweir const Font *pTargetFont, sal_Int32 nOptions, sal_Bool bIsInteractive ); 167cdf0e10cSrcweir 168cdf0e10cSrcweir /** This is called internaly when text conversion is started. 169cdf0e10cSrcweir The position of current view mode/page/object/caret position 170cdf0e10cSrcweir is remembered and will be restored after conversion. 171cdf0e10cSrcweir */ 172cdf0e10cSrcweir void BeginConversion (void); 173cdf0e10cSrcweir 174cdf0e10cSrcweir /** Release all resources that have been created during the conversion */ 175cdf0e10cSrcweir void EndConversion (void); 176cdf0e10cSrcweir 177cdf0e10cSrcweir DECL_LINK( SpellError, void * ); 178cdf0e10cSrcweir 179cdf0e10cSrcweir enum ChangeHint { CH_VIEW_SHELL_INVALID, CH_VIEW_SHELL_VALID }; 180cdf0e10cSrcweir 181cdf0e10cSrcweir int GetIgnoreCurrentPageChangesLevel() const { return mnIgnoreCurrentPageChangesLevel; }; 182cdf0e10cSrcweir void IncreIgnoreCurrentPageChangesLevel() { mnIgnoreCurrentPageChangesLevel++; }; 183cdf0e10cSrcweir void DecreIgnoreCurrentPageChangesLevel() { mnIgnoreCurrentPageChangesLevel--; }; 184cdf0e10cSrcweir 185cdf0e10cSrcweir private: 186cdf0e10cSrcweir class Implementation; 187cdf0e10cSrcweir ::std::auto_ptr<Implementation> mpImpl; 188cdf0e10cSrcweir 189cdf0e10cSrcweir /// Specifies whether to search and replace, to spell check or to do a 190cdf0e10cSrcweir /// text conversion. 191cdf0e10cSrcweir enum mode {SEARCH, SPELL, TEXT_CONVERSION} meMode; 192cdf0e10cSrcweir 193cdf0e10cSrcweir /// The view which displays the searched objects. 194cdf0e10cSrcweir ::sd::View* mpView; 195967189efSMichael Stahl /** The view shell containing the view. It is held as weak 196967189efSMichael Stahl pointer to avoid keeping it alive when the view is changed 197967189efSMichael Stahl during searching. 198967189efSMichael Stahl */ 199967189efSMichael Stahl ::boost::weak_ptr<ViewShell> mpWeakViewShell; 200cdf0e10cSrcweir /// This window contains the view. 201cdf0e10cSrcweir ::sd::Window* mpWindow; 202cdf0e10cSrcweir /// The document on whose objects and pages this class operates. 203cdf0e10cSrcweir SdDrawDocument* mpDrawDocument; 204cdf0e10cSrcweir 205cdf0e10cSrcweir /** this is the language that is used for current text conversion. 206cdf0e10cSrcweir Only valid if meMode is TEXT_CONVERSION. 207cdf0e10cSrcweir */ 208cdf0e10cSrcweir sal_Int16 mnConversionLanguage; 209cdf0e10cSrcweir 210cdf0e10cSrcweir /** While the value of this flag is greater than 0 changes of the current page 211cdf0e10cSrcweir do not lead to selecting the corresponding text in the outliner. 212cdf0e10cSrcweir */ 213cdf0e10cSrcweir int mnIgnoreCurrentPageChangesLevel; 214cdf0e10cSrcweir 215cdf0e10cSrcweir /// Specifies whether the search string has been found so far. 216cdf0e10cSrcweir bool mbStringFound; 217cdf0e10cSrcweir 218cdf0e10cSrcweir /** This flag indicates whether there may exist a match of the search 219cdf0e10cSrcweir string before/after the current position in the document. It can be 220cdf0e10cSrcweir set to </sal_False> only when starting from the beginning/end of the 221cdf0e10cSrcweir document. When reaching the end/beginning with it still be set to 222cdf0e10cSrcweir </sal_False> then there exists no match and the search can be terminated. 223cdf0e10cSrcweir */ 224cdf0e10cSrcweir bool mbMatchMayExist; 225cdf0e10cSrcweir 226cdf0e10cSrcweir /// The number of pages in the current view. 227cdf0e10cSrcweir sal_uInt16 mnPageCount; 228cdf0e10cSrcweir 229cdf0e10cSrcweir /// Number of objects on the current page / in the current selection. 230cdf0e10cSrcweir sal_Int32 mnObjectCount; 231cdf0e10cSrcweir 232cdf0e10cSrcweir /** A <TRUE/> value indicates that the end of the find&replace or spell 233cdf0e10cSrcweir check has been reached. 234cdf0e10cSrcweir */ 235cdf0e10cSrcweir bool mbEndOfSearch; 236cdf0e10cSrcweir 237cdf0e10cSrcweir /** Set to <TRUE/> when an object has been prepared successfully for 238cdf0e10cSrcweir searching/spell checking. This flag directs the internal iteration 239cdf0e10cSrcweir which stops when set to </sal_True>. 240cdf0e10cSrcweir */ 241cdf0e10cSrcweir bool mbFoundObject; 242cdf0e10cSrcweir 243*86e1cf34SPedro Giffuni /** When set to <TRUE/> this flag indicates that an error has occurred 244cdf0e10cSrcweir that should terminate the iteration over the objects to search/spell 245cdf0e10cSrcweir check. 246cdf0e10cSrcweir */ 247cdf0e10cSrcweir bool mbError; 248cdf0e10cSrcweir 249cdf0e10cSrcweir /** This flag indicates whether to search forward or backwards. 250cdf0e10cSrcweir */ 251cdf0e10cSrcweir bool mbDirectionIsForward; 252cdf0e10cSrcweir 253cdf0e10cSrcweir /** This flag indicates that only the selected objects are to be 254cdf0e10cSrcweir searched. 255cdf0e10cSrcweir */ 256cdf0e10cSrcweir bool mbRestrictSearchToSelection; 257cdf0e10cSrcweir 258cdf0e10cSrcweir /** When the search is restricted to the current selection then 259cdf0e10cSrcweir this list contains pointers to all the objects of the 260cdf0e10cSrcweir selection. This copy is necessary because during the search 261cdf0e10cSrcweir process the mark list is modified. 262cdf0e10cSrcweir */ 263cdf0e10cSrcweir ::std::vector<SdrObjectWeakRef> maMarkListCopy; 264cdf0e10cSrcweir 265cdf0e10cSrcweir /** This flag inidcates that only the current view is to be used for 266cdf0e10cSrcweir searching and spelling. Automatically switching to other view does 267cdf0e10cSrcweir not take place when this flag is set. 268cdf0e10cSrcweir */ 269cdf0e10cSrcweir bool mbProcessCurrentViewOnly; 270cdf0e10cSrcweir 271cdf0e10cSrcweir /** Current object that may be a text object. The object pointer to 272cdf0e10cSrcweir corresponds to <member>mnObjIndex</member>. While iterating over the 273cdf0e10cSrcweir objects on a page <member>mpObj</member> will point to every object 274cdf0e10cSrcweir while <member>mpTextObj</member> will be set only to valid text 275cdf0e10cSrcweir objects. 276cdf0e10cSrcweir */ 277cdf0e10cSrcweir SdrObject* mpObj; 278cdf0e10cSrcweir 279cdf0e10cSrcweir /** this stores the first object that is used for text conversion. 280*86e1cf34SPedro Giffuni Conversion automatically wraps around the document and stops when it 281cdf0e10cSrcweir finds this object again. 282cdf0e10cSrcweir */ 283cdf0e10cSrcweir SdrObject* mpFirstObj; 284cdf0e10cSrcweir 285cdf0e10cSrcweir /// Candidate for being searched/spell checked. 286cdf0e10cSrcweir SdrTextObj* mpTextObj; 287cdf0e10cSrcweir 288cdf0e10cSrcweir /// Current text to be searched/spelled inside the current text object 289cdf0e10cSrcweir sal_Int32 mnText; 290cdf0e10cSrcweir 291cdf0e10cSrcweir /// Paragraph object of <member>mpTextObj</member>. 292cdf0e10cSrcweir OutlinerParaObject* mpParaObj; 293cdf0e10cSrcweir 294cdf0e10cSrcweir /// The view mode that was active when starting to search/spell check. 295cdf0e10cSrcweir PageKind meStartViewMode; 296cdf0e10cSrcweir 297cdf0e10cSrcweir /// The master page mode that was active when starting to search/spell check. 298cdf0e10cSrcweir EditMode meStartEditMode; 299cdf0e10cSrcweir 300cdf0e10cSrcweir /// The current page index on starting to search/spell check. 301cdf0e10cSrcweir sal_uInt16 mnStartPageIndex; 302cdf0e10cSrcweir 303cdf0e10cSrcweir /// The object in edit mode when searching /spell checking was started 304cdf0e10cSrcweir /// (if any). 305cdf0e10cSrcweir SdrObject* mpStartEditedObject; 306cdf0e10cSrcweir 307cdf0e10cSrcweir /// The position of the caret when searching /spell checking was started. 308cdf0e10cSrcweir ESelection maStartSelection; 309cdf0e10cSrcweir 310cdf0e10cSrcweir /** The search item contains various attributes that define the type of 311cdf0e10cSrcweir search. It is set every time the 312cdf0e10cSrcweir <member>SearchAndReplaceAll</member> method is called. 313cdf0e10cSrcweir */ 314cdf0e10cSrcweir const SvxSearchItem* mpSearchItem; 315cdf0e10cSrcweir 316cdf0e10cSrcweir /// The actual object iterator. 317cdf0e10cSrcweir ::sd::outliner::Iterator maObjectIterator; 318cdf0e10cSrcweir /// The current position of the object iterator. 319cdf0e10cSrcweir ::sd::outliner::IteratorPosition maCurrentPosition; 320cdf0e10cSrcweir /// The position when the search started. Corresponds largely to the 321cdf0e10cSrcweir /// m?Start* members. 322cdf0e10cSrcweir ::sd::outliner::Iterator maSearchStartPosition; 323cdf0e10cSrcweir /** The last valid position desribes where the last text object has been 324cdf0e10cSrcweir found. This position is restored when some dialogs are shown. The 325cdf0e10cSrcweir position is initially set to the where the search begins. 326cdf0e10cSrcweir */ 327cdf0e10cSrcweir ::sd::outliner::IteratorPosition maLastValidPosition; 328cdf0e10cSrcweir 329cdf0e10cSrcweir /** This flag remebers a selection change between a call to the 330cdf0e10cSrcweir selection change listener callback and the next 331cdf0e10cSrcweir <member>DetectChange()</member> method call. 332cdf0e10cSrcweir */ 333cdf0e10cSrcweir bool mbSelectionHasChanged; 334cdf0e10cSrcweir 335cdf0e10cSrcweir /** This flag indicates whether a selection change event is expected due 336cdf0e10cSrcweir to a programatical change of the selection. 337cdf0e10cSrcweir */ 338cdf0e10cSrcweir bool mbExpectingSelectionChangeEvent; 339cdf0e10cSrcweir 340cdf0e10cSrcweir /** This flag is set to true when the whole document has been 341cdf0e10cSrcweir processed once 'officially', i.e. a message box has been shown 342cdf0e10cSrcweir that tells the user so. 343cdf0e10cSrcweir */ 344cdf0e10cSrcweir bool mbWholeDocumentProcessed; 345cdf0e10cSrcweir 346cdf0e10cSrcweir /** When this flag is true then a PrepareSpelling() is executed when 347cdf0e10cSrcweir StartSearchAndReplace() is called the next time. 348cdf0e10cSrcweir */ 349cdf0e10cSrcweir bool mbPrepareSpellingPending; 350cdf0e10cSrcweir 351cdf0e10cSrcweir /** Initialize the object iterator. Call this method after being 352cdf0e10cSrcweir invoked from the search or spellcheck dialog. It creates a new 353cdf0e10cSrcweir iterator pointing at the current object when this has not been done 354cdf0e10cSrcweir before. It reverses the direction of iteration if the given flag 355cdf0e10cSrcweir differs from the current direction. 356cdf0e10cSrcweir @param bDirectionIsForward 357cdf0e10cSrcweir This flag specifies in which direction to iterator over the 358cdf0e10cSrcweir objects. If it differs from the current direction the iterator 359cdf0e10cSrcweir is reversed. 360cdf0e10cSrcweir */ 361cdf0e10cSrcweir void Initialize (bool bDirectionIsForward); 362cdf0e10cSrcweir 363cdf0e10cSrcweir /** Do search and replace for whole document. 364cdf0e10cSrcweir */ 365cdf0e10cSrcweir bool SearchAndReplaceAll (void); 366cdf0e10cSrcweir 367cdf0e10cSrcweir /** Do search and replace for next match. 368cdf0e10cSrcweir @return 369cdf0e10cSrcweir The return value specifies whether the search ended (</sal_True>) or 370cdf0e10cSrcweir another call to this method is required (</sal_False>). 371cdf0e10cSrcweir */ 372cdf0e10cSrcweir bool SearchAndReplaceOnce (void); 373cdf0e10cSrcweir 374cdf0e10cSrcweir /** Detect changes of the document or view and react accordingly. Such 375cdf0e10cSrcweir changes may occur because different calls to 376cdf0e10cSrcweir <member>SearchAndReplace()</member> there usually is user 377cdf0e10cSrcweir interaction. This is at least the press of the search or replace 378cdf0e10cSrcweir button but may include any other action some of which affect the 379cdf0e10cSrcweir search. 380cdf0e10cSrcweir */ 381cdf0e10cSrcweir void DetectChange (void); 382cdf0e10cSrcweir 383cdf0e10cSrcweir /** Detect whether the selection has changed. 384cdf0e10cSrcweir @return 385cdf0e10cSrcweir Return <TRUE/> when the selection has been changed since the 386cdf0e10cSrcweir last call to this method. 387cdf0e10cSrcweir */ 388cdf0e10cSrcweir bool DetectSelectionChange (void); 389cdf0e10cSrcweir 390cdf0e10cSrcweir /** Remember the current edited object/caret position/page/view mode 391cdf0e10cSrcweir when starting to search/spell check so that it can be restored on 392cdf0e10cSrcweir termination. 393cdf0e10cSrcweir */ 394cdf0e10cSrcweir void RememberStartPosition (void); 395cdf0e10cSrcweir 396cdf0e10cSrcweir /** Restore the position stored in the last call of 397cdf0e10cSrcweir <member>RememberStartPositiony</member>. 398cdf0e10cSrcweir */ 399cdf0e10cSrcweir void RestoreStartPosition (void); 400cdf0e10cSrcweir 401cdf0e10cSrcweir /** Provide next object to search or spell check as text object in edit 402cdf0e10cSrcweir mode on the current page. This skips all objects that do not 403cdf0e10cSrcweir match or are no text object. 404cdf0e10cSrcweir */ 405cdf0e10cSrcweir void ProvideNextTextObject (void); 406cdf0e10cSrcweir 407cdf0e10cSrcweir /** Handle the situation that the iterator has reached the last object. 408cdf0e10cSrcweir This may result in setting the <member>mbEndOfSearch</member> flag 409cdf0e10cSrcweir back to </sal_False>. This method may show either the end-of-search 410cdf0e10cSrcweir dialog or the wrap-arround dialog. 411cdf0e10cSrcweir */ 412cdf0e10cSrcweir void EndOfSearch (void); 413cdf0e10cSrcweir 414cdf0e10cSrcweir /** Show a dialog that tells the user that the search has ended either 415cdf0e10cSrcweir because there are no more matches after finding at least one or that 416cdf0e10cSrcweir no match has been found at all. 417cdf0e10cSrcweir */ 418cdf0e10cSrcweir void ShowEndOfSearchDialog (void); 419cdf0e10cSrcweir 420*86e1cf34SPedro Giffuni /** Show a dialog that asks the user whether to wrap around to the 421cdf0e10cSrcweir beginning/end of the document and continue with the search/spell 422cdf0e10cSrcweir check. 423cdf0e10cSrcweir */ 424cdf0e10cSrcweir bool ShowWrapArroundDialog (void); 425cdf0e10cSrcweir 426cdf0e10cSrcweir /** Check whether the object pointed to by the iterator is a valid text 427cdf0e10cSrcweir object. 428cdf0e10cSrcweir @param aPosition 429cdf0e10cSrcweir The object for which to test whether it is a valid text object. 430cdf0e10cSrcweir */ 431cdf0e10cSrcweir bool IsValidTextObject (const ::sd::outliner::IteratorPosition& rPosition); 432cdf0e10cSrcweir 433cdf0e10cSrcweir /** Put text of current text object into outliner so that the text can 434cdf0e10cSrcweir be searched/spell checked. 435cdf0e10cSrcweir */ 436cdf0e10cSrcweir void PutTextIntoOutliner (void); 437cdf0e10cSrcweir 438cdf0e10cSrcweir /** Prepare to do spell checking on the current text object. This 439cdf0e10cSrcweir includes putting it into edit mode. Under certain conditions this 440cdf0e10cSrcweir method sets <member>mbEndOfSearch</member> to <TRUE/>. 441cdf0e10cSrcweir */ 442cdf0e10cSrcweir void PrepareSpellCheck (void); 443cdf0e10cSrcweir 444cdf0e10cSrcweir /** Prepare to search and replace on the current text object. This 445cdf0e10cSrcweir includes putting it into edit mode. 446cdf0e10cSrcweir */ 447cdf0e10cSrcweir void PrepareSearchAndReplace (void); 448cdf0e10cSrcweir 449cdf0e10cSrcweir /** Prepare to do a text conversion on the current text 450cdf0e10cSrcweir object. This includes putting it into edit mode. 451cdf0e10cSrcweir */ 452cdf0e10cSrcweir void PrepareConversion (void); 453cdf0e10cSrcweir 454cdf0e10cSrcweir /** Switch to a new view mode. Try to restore the original edit mode 455cdf0e10cSrcweir before doing so. 456cdf0e10cSrcweir @param ePageKind 457cdf0e10cSrcweir Specifies the new view mode. 458cdf0e10cSrcweir */ 459cdf0e10cSrcweir void SetViewMode (PageKind ePageKind); 460cdf0e10cSrcweir 461cdf0e10cSrcweir /** Switch to the page or master page specified by the 462cdf0e10cSrcweir <member>mnPage</member> index. Master page mode is specified by 463cdf0e10cSrcweir <member>meEditMode</member>. 464cdf0e10cSrcweir @param eEditMode 465cdf0e10cSrcweir The new edit mode. 466cdf0e10cSrcweir @param nPageIndex 467cdf0e10cSrcweir The new page index. 468cdf0e10cSrcweir */ 469cdf0e10cSrcweir void SetPage (EditMode eEditMode, sal_uInt16 nPageIndex); 470cdf0e10cSrcweir 471cdf0e10cSrcweir /** Switch on edit mode for the currently selected text object. 472cdf0e10cSrcweir */ 473cdf0e10cSrcweir void EnterEditMode (sal_Bool bGrabFocus=sal_True); 474cdf0e10cSrcweir 475cdf0e10cSrcweir /** Return the position at which a new search is started with respect to 476cdf0e10cSrcweir the search direction as specified by the argument. 477cdf0e10cSrcweir @return 478cdf0e10cSrcweir The position mentioned above in form of a selection with start 479cdf0e10cSrcweir equals end. 480cdf0e10cSrcweir */ 481cdf0e10cSrcweir ESelection GetSearchStartPosition (void); 482cdf0e10cSrcweir 483cdf0e10cSrcweir /** Detect whether there exists a previous match. Note that only the 484cdf0e10cSrcweir absence of such a match can be detected reliably. An existing match 485cdf0e10cSrcweir is assumed when the search started not at the beginning/end of the 486cdf0e10cSrcweir presentation. This does not have to be true. The user can have set 487cdf0e10cSrcweir the cursor at the middle of the text without a prior search. 488cdf0e10cSrcweir @return 489cdf0e10cSrcweir Returns </True> when there is no previous match and </False> 490cdf0e10cSrcweir when there may be one. 491cdf0e10cSrcweir */ 492cdf0e10cSrcweir bool HasNoPreviousMatch (void); 493cdf0e10cSrcweir 494cdf0e10cSrcweir /** Handle a failed search (with or without replace) for the outline 495cdf0e10cSrcweir mode. Show message boxes when the search failed completely, 496cdf0e10cSrcweir i.e. there is no match in the whole presentation, or when no further 497cdf0e10cSrcweir match exists. 498cdf0e10cSrcweir @return 499*86e1cf34SPedro Giffuni The returned value indicates whether another (wrapped around) 500cdf0e10cSrcweir search shall take place. If that is so, then it is the caller's 501cdf0e10cSrcweir responsibility to set the cursor position accordingly. 502cdf0e10cSrcweir */ 503cdf0e10cSrcweir bool HandleFailedSearch (void); 504cdf0e10cSrcweir 505cdf0e10cSrcweir /** Take a position as returned by an object iterator and switch to the 506cdf0e10cSrcweir view and page on which the object specified by this position is 507cdf0e10cSrcweir located. 508cdf0e10cSrcweir @param rPosition 509cdf0e10cSrcweir This position points to a <type>SdrObject</type> object and 510cdf0e10cSrcweir contains the view and page where it is located. 511cdf0e10cSrcweir @return 512cdf0e10cSrcweir Return a pointer to the <type>SdrObject</type>. 513cdf0e10cSrcweir */ 514cdf0e10cSrcweir SdrObject* SetObject (const ::sd::outliner::IteratorPosition& rPosition); 515cdf0e10cSrcweir 516cdf0e10cSrcweir /** Use this method when the view shell in which to search has changed. 517cdf0e10cSrcweir It handles i.e. registering at the associated view as selection 518cdf0e10cSrcweir change listener. 519cdf0e10cSrcweir */ 520cdf0e10cSrcweir void SetViewShell (const ::boost::shared_ptr<ViewShell>& rpViewShell); 521cdf0e10cSrcweir 522cdf0e10cSrcweir /** Activate or deactivate the search in the current selection. Call 523cdf0e10cSrcweir this method whenever the selection has changed. This method creates 524cdf0e10cSrcweir a copy of the current selection and reassings the object iterator to 525cdf0e10cSrcweir the current() iterator. 526cdf0e10cSrcweir */ 527cdf0e10cSrcweir void HandleChangedSelection (void); 528cdf0e10cSrcweir 529cdf0e10cSrcweir /** Initiate the spell check of the next relevant text object. 530cdf0e10cSrcweir When the outline view is active then this method is called 531*86e1cf34SPedro Giffuni after a wrap around to continue at the beginning of the document. 532cdf0e10cSrcweir @return 533cdf0e10cSrcweir Returns <TRUE/> to indicate that another call to this method is 534cdf0e10cSrcweir required. When all text objects have been processed then 535cdf0e10cSrcweir <FALSE/> is returned. 536cdf0e10cSrcweir */ 537cdf0e10cSrcweir virtual sal_Bool SpellNextDocument (void); 538cdf0e10cSrcweir 539cdf0e10cSrcweir /** Show the given message box and make it modal. It is assumed that 540cdf0e10cSrcweir the parent of the given dialog is NULL, i.e. the application 541cdf0e10cSrcweir window. This function makes sure that the otherwise non-modal 542cdf0e10cSrcweir search dialog, if visible, is locked, too. 543cdf0e10cSrcweir */ 544cdf0e10cSrcweir sal_uInt16 ShowModalMessageBox (Dialog& rMessageBox); 545cdf0e10cSrcweir }; 546cdf0e10cSrcweir 547cdf0e10cSrcweir } // end of namespace sd 548cdf0e10cSrcweir 549cdf0e10cSrcweir #endif 550cdf0e10cSrcweir 551