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