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