LibreOffice Module sd (master) 1
Outliner.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#pragma once
21
22#include <svx/svdoutl.hxx>
23#include "pres.hxx"
24#include "OutlinerIterator.hxx"
26#include <memory>
27#include <utility>
28
29class SdrObject;
30class SdrTextObj;
31class SdDrawDocument;
32
33namespace weld
34{
35class Window;
36}
37
38namespace sd
39{
40class View;
41class ViewShell;
42class Window;
43
46{
49
55
56 SearchSelection(int nPage, OString aRectangles)
57 : m_nPage(nPage)
58 , m_aRectangles(std::move(aRectangles))
59 {
60 }
61
62 bool operator==(const SearchSelection& rOther) const
63 {
64 return m_nPage == rOther.m_nPage && m_aRectangles == rOther.m_aRectangles;
65 }
66};
67
68} // end of namespace sd
69
122class SdOutliner final : public SdrOutliner
123{
124public:
125 friend class ::sd::outliner::OutlinerContainer;
126
139 virtual ~SdOutliner() override;
141 SdOutliner(const Outliner&) = delete;
142 SdOutliner& operator=(const Outliner&) = delete;
143
150 void PrepareSpelling();
151
155 void StartSpelling();
156
163 bool StartSearchAndReplace(const SvxSearchItem* pSearchItem);
164
170
174 void EndSpelling();
175
177 bool ConvertNextDocument() override;
178
181 void StartConversion(LanguageType nSourceLanguage, LanguageType nTargetLanguage,
182 const vcl::Font* pTargetFont, sal_Int32 nOptions, bool bIsInteractive);
183
188 void BeginConversion();
189
191 void EndConversion();
192
197
198private:
199 class Implementation;
200 ::std::unique_ptr<Implementation> mpImpl;
201
204
207 enum mode
208 {
213
220 std::weak_ptr<::sd::ViewShell> mpWeakViewShell;
225
230
235
238
246
248 sal_uInt16 mnPageCount;
249
254
260
264
269
275 ::std::vector<unotools::WeakReference<SdrObject>> maMarkListCopy;
276
284
290
293
295 sal_Int32 mnText;
296
299
302
305
308
312
315
320 std::unique_ptr<const SvxSearchItem> mpSearchItem;
321
334
339
350 void Initialize(bool bDirectionIsForward);
351
354 bool SearchAndReplaceAll();
355
364 bool SearchAndReplaceOnce(std::vector<::sd::SearchSelection>* pSelections = nullptr);
365
366 void sendLOKSearchResultCallback(const std::shared_ptr<sd::ViewShell>& pViewShell,
367 const OutlinerView* pOutlinerView,
368 std::vector<sd::SearchSelection>* pSelections);
369
377 void DetectChange();
378
385
391
396
402
408 void EndOfSearch();
409
415
421
425 void PutTextIntoOutliner();
426
431 void PrepareSpellCheck();
432
437
441 void PrepareConversion();
442
448 void SetViewMode(PageKind ePageKind);
449
458 void SetPage(EditMode eEditMode, sal_uInt16 nPageIndex);
459
462 void EnterEditMode(bool bGrabFocus);
463
471
481 bool HasNoPreviousMatch();
482
492 bool HandleFailedSearch();
493
503 SdrObject* SetObject(const ::sd::outliner::IteratorPosition& rPosition);
504
509 void SetViewShell(const std::shared_ptr<::sd::ViewShell>& rpViewShell);
510
517
526 virtual bool SpellNextDocument() override;
527
533};
534
535/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
The main purpose of this class is searching and replacing as well as spelling of impress documents.
Definition: Outliner.hxx:123
SdOutliner(SdDrawDocument *pDoc, OutlinerMode nMode)
Create a new sd outliner object.
Definition: Outliner.cxx:132
bool HasNoPreviousMatch()
Detect whether there exists a previous match.
Definition: Outliner.cxx:1694
bool HandleFailedSearch()
Handle a failed search (with or without replace) for the outline mode.
Definition: Outliner.cxx:1705
void RememberStartPosition()
Remember the current edited object/caret position/page/view mode when starting to search/spell check ...
Definition: Outliner.cxx:1063
void PrepareSearchAndReplace()
Prepare to search and replace on the current text object.
Definition: Outliner.cxx:1516
void PrepareConversion()
Prepare to do a text conversion on the current text object.
Definition: Outliner.cxx:1824
void StartSpelling()
Initialize a spell check but do not start it yet.
Definition: Outliner.cxx:271
std::unique_ptr< const SvxSearchItem > mpSearchItem
The search item contains various attributes that define the type of search.
Definition: Outliner.hxx:320
SdrObject * mpObj
Current object that may be a text object.
Definition: Outliner.hxx:283
sal_uInt16 mnStartPageIndex
The current page index on starting to search/spell check.
Definition: Outliner.hxx:307
::std::vector< unotools::WeakReference< SdrObject > > maMarkListCopy
When the search is restricted to the current selection then this list contains pointers to all the ob...
Definition: Outliner.hxx:275
SdDrawDocument * GetDoc() const
Definition: Outliner.hxx:196
void ProvideNextTextObject()
Provide next object to search or spell check as text object in edit mode on the current page.
Definition: Outliner.cxx:1191
void sendLOKSearchResultCallback(const std::shared_ptr< sd::ViewShell > &pViewShell, const OutlinerView *pOutlinerView, std::vector< sd::SearchSelection > *pSelections)
Definition: Outliner.cxx:738
::sd::outliner::Iterator maObjectIterator
The actual object iterator.
Definition: Outliner.hxx:323
sal_uInt16 mnPageCount
The number of pages in the current view.
Definition: Outliner.hxx:248
bool mbStringFound
Specifies whether the search string has been found so far.
Definition: Outliner.hxx:237
virtual bool SpellNextDocument() override
Initiate the spell check of the next relevant text object.
Definition: Outliner.cxx:344
bool mbFoundObject
Set to <TRUE> when an object has been prepared successfully for searching/spell checking.
Definition: Outliner.hxx:259
SdOutliner(const Outliner &)=delete
Forbid copy construction and copy assignment.
void DetectChange()
Detect changes of the document or view and react accordingly.
Definition: Outliner.cxx:967
void ShowEndOfSearchDialog()
Show a dialog that tells the user that the search has ended either because there are no more matches ...
Definition: Outliner.cxx:1395
virtual ~SdOutliner() override
Nothing spectacular in the destructor.
Definition: Outliner.cxx:212
SdOutliner & operator=(const Outliner &)=delete
EditMode meStartEditMode
The master page mode that was active when starting to search/spell check.
Definition: Outliner.hxx:304
SdrObject * SetObject(const ::sd::outliner::IteratorPosition &rPosition)
Take a position as returned by an object iterator and switch to the view and page on which the object...
Definition: Outliner.cxx:1732
void PutTextIntoOutliner()
Put text of current text object into outliner so that the text can be searched/spell checked.
Definition: Outliner.cxx:1470
OutlinerParaObject * mpParaObj
Paragraph object of <member>mpTextObj</member>.
Definition: Outliner.hxx:298
void HandleChangedSelection()
Activate or deactivate the search in the current selection.
Definition: Outliner.cxx:1770
bool mbRestrictSearchToSelection
This flag indicates that only the selected objects are to be searched.
Definition: Outliner.hxx:268
bool SearchAndReplaceAll()
Do search and replace for whole document.
Definition: Outliner.cxx:580
std::weak_ptr<::sd::ViewShell > mpWeakViewShell
The view shell containing the view.
Definition: Outliner.hxx:220
VclPtr<::sd::Window > mpWindow
This window contains the view.
Definition: Outliner.hxx:222
bool mbEndOfSearch
A <TRUE> value indicates that the end of the find&replace or spell check has been reached.
Definition: Outliner.hxx:253
void SetViewShell(const std::shared_ptr<::sd::ViewShell > &rpViewShell)
Use this method when the view shell in which to search has changed.
Definition: Outliner.cxx:1741
void Initialize(bool bDirectionIsForward)
Initialize the object iterator.
Definition: Outliner.cxx:510
bool mbDirectionIsForward
This flag indicates whether to search forward or backwards.
Definition: Outliner.hxx:263
void SetPage(EditMode eEditMode, sal_uInt16 nPageIndex)
Switch to the page or master page specified by the <member>mnPage</member> index.
Definition: Outliner.cxx:1610
int mnIgnoreCurrentPageChangesLevel
While the value of this flag is greater than 0 changes of the current page do not lead to selecting t...
Definition: Outliner.hxx:234
bool StartSearchAndReplace(const SvxSearchItem *pSearchItem)
Initiate a find and/or replace on the next relevant text object.
Definition: Outliner.cxx:420
void PrepareSpelling()
Despite the name this method is called prior to spell checking and searching and replacing.
Definition: Outliner.cxx:241
weld::Window * GetMessageBoxParent()
Find the right parent to use for a message.
Definition: Outliner.cxx:1915
void BeginConversion()
This is called internally when text conversion is started.
Definition: Outliner.cxx:1845
void StartConversion(LanguageType nSourceLanguage, LanguageType nTargetLanguage, const vcl::Font *pTargetFont, sal_Int32 nOptions, bool bIsInteractive)
Starts the text conversion (hangul/hanja or Chinese simplified/traditional) for the current viewshell...
Definition: Outliner.cxx:1792
void EndOfSearch()
Handle the situation that the iterator has reached the last object.
Definition: Outliner.cxx:1345
::sd::View * mpView
The view which displays the searched objects.
Definition: Outliner.hxx:215
PageKind meStartViewMode
The view mode that was active when starting to search/spell check.
Definition: Outliner.hxx:301
bool SearchAndReplaceOnce(std::vector<::sd::SearchSelection > *pSelections=nullptr)
Do search and replace for next match.
Definition: Outliner.cxx:816
void IncreIgnoreCurrentPageChangesLevel()
Definition: Outliner.hxx:194
ESelection maStartSelection
The position of the caret when searching /spell checking was started.
Definition: Outliner.hxx:314
void EndConversion()
Release all resources that have been created during the conversion.
Definition: Outliner.cxx:1874
::sd::outliner::IteratorPosition maCurrentPosition
The current position of the object iterator.
Definition: Outliner.hxx:325
void PrepareSpellCheck()
Prepare to do spell checking on the current text object.
Definition: Outliner.cxx:1491
enum SdOutliner::mode meMode
::sd::outliner::IteratorPosition maLastValidPosition
The last valid position describes where the last text object has been found.
Definition: Outliner.hxx:333
void SetViewMode(PageKind ePageKind)
Switch to a new view mode.
Definition: Outliner.cxx:1537
bool ShowWrapAroundDialog()
Show a dialog that asks the user whether to wrap around to the beginning/end of the document and cont...
Definition: Outliner.cxx:1427
LanguageType mnConversionLanguage
this is the language that is used for current text conversion.
Definition: Outliner.hxx:229
SdDrawDocument * mpDrawDocument
The document on whose objects and pages this class operates.
Definition: Outliner.hxx:224
void DecreIgnoreCurrentPageChangesLevel()
Definition: Outliner.hxx:195
::sd::outliner::Iterator maSearchStartPosition
The position when the search started.
Definition: Outliner.hxx:328
ESelection GetSearchStartPosition() const
Return the position at which a new search is started with respect to the search direction as specifie...
Definition: Outliner.cxx:1668
mode
Specifies whether to search and replace, to spell check or to do a text conversion.
Definition: Outliner.hxx:208
@ TEXT_CONVERSION
Definition: Outliner.hxx:211
SdrObject * mpStartEditedObject
The object in edit mode when searching /spell checking was started (if any).
Definition: Outliner.hxx:311
sal_Int32 mnText
Current text to be searched/spelled inside the current text object.
Definition: Outliner.hxx:295
bool ConvertNextDocument() override
callback for textconversion
Definition: Outliner.cxx:1879
::std::unique_ptr< Implementation > mpImpl
Definition: Outliner.hxx:199
SdrTextObj * mpSearchSpellTextObj
Candidate for being searched/spell checked.
Definition: Outliner.hxx:292
int GetIgnoreCurrentPageChangesLevel() const
Definition: Outliner.hxx:193
void EndSpelling()
Release all resources that have been created during the find&replace or spell check.
Definition: Outliner.cxx:281
void EnterEditMode(bool bGrabFocus)
Switch on edit mode for the currently selected text object.
Definition: Outliner.cxx:1626
svx::SpellPortions GetNextSpellSentence()
Iterate over the sentences in all text shapes and stop at the next sentence with spelling errors.
Definition: Outliner.cxx:378
SdrObject * mpFirstObj
this stores the first object that is used for text conversion.
Definition: Outliner.hxx:289
OutlinerView * getOutlinerView()
Returns the current outline view.
Definition: Outliner.cxx:216
bool DetectSelectionChange()
Detect whether the selection has changed.
Definition: Outliner.cxx:1027
bool mbPrepareSpellingPending
When this flag is true then a PrepareSpelling() is executed when StartSearchAndReplace() is called th...
Definition: Outliner.hxx:338
bool mbMatchMayExist
This flag indicates whether there may exist a match of the search string before/after the current pos...
Definition: Outliner.hxx:245
void RestoreStartPosition()
Restore the position stored in the last call of <member>RememberStartPositiony</member>.
Definition: Outliner.cxx:1116
Data collection specifying a <type>SdrObject</type> and its position in a document and view.
This iterator can be used to iterate over all <type>SdrObject</type> objects of one of three set deno...
std::vector< SpellPortion > SpellPortions
OutlinerMode
EditMode
Definition: pres.hxx:53
PageKind
Definition: pres.hxx:45
Describes a single search hit: a set of rectangles on a given page.
Definition: Outliner.hxx:46
bool operator==(const SearchSelection &rOther) const
Definition: Outliner.hxx:62
SearchSelection(int nPage, OString aRectangles)
Definition: Outliner.hxx:56
int m_nPage
0-based index of the page that has the selection.
Definition: Outliner.hxx:48
OString m_aRectangles
List of selection rectangles in twips – multiple rectangles only in case the selection spans over mor...
Definition: Outliner.hxx:54