office-gobmx/sd/inc/OutlinerIterator.hxx

373 lines
14 KiB
C++
Raw Normal View History

2010-10-27 06:53:26 -05:00
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#ifndef SD_OUTLINER_ITERATOR_HXX
#define SD_OUTLINER_ITERATOR_HXX
#include <svx/svdobj.hxx>
#include "pres.hxx"
#include "sal/types.h"
#include <vector>
CWS-TOOLING: integrate CWS impress166 2009-01-27 11:42:29 +0100 af r266972 : #i98508# Handle non DrawViewShell view shells correctly. 2009-01-21 10:41:32 +0100 af r266635 : #i98069# Do not call PreModelChange() for every ModelLock. 2009-01-20 15:25:41 +0100 af r266588 : #i98069# Added friend declaration that became necessary on Solaris after recent changes. 2009-01-19 13:48:47 +0100 af r266493 : #i97478# Prevent SID_PARASPACE_(DE|IN)CREASE from crashing when style sheet is missing. 2009-01-16 11:52:37 +0100 af r266411 : #i97338# Check the dispatcher before using it to show a context menu. 2009-01-15 14:33:55 +0100 sj r266373 : #153716# taking care of font-independent line spacing (editmode and hittest) 2009-01-15 14:29:46 +0100 sj r266372 : #153716# taking care of font-independent line spacing also in presentation styles 2009-01-14 14:04:16 +0100 af r266301 : #i97634# Do view change synchronously. Use shared pointers for view shells. 2009-01-14 14:01:27 +0100 af r266300 : #i97634# Added non-API methods that update the configuration synchronously. 2009-01-14 13:34:40 +0100 af r266295 : #i98069# Be more carefull with handling model updates to avoid assertion regarding number of selected pages. 2009-01-14 11:34:57 +0100 cl r266270 : #i97261# force outliner para oibject after text edit 2009-01-14 10:49:08 +0100 cl r266269 : #i97413# dispose cell undo action if shape dies 2009-01-13 18:50:05 +0100 cl r266247 : #i97347# fixed cell undo crash 2009-01-12 14:16:56 +0100 af r266156 : #i97296# Using is() method to check WeakReference for validity. 2009-01-12 13:52:00 +0100 af r266155 : #i97190# Turned static_cast to dynamic_cast in CreateChildList. 2009-01-12 13:06:57 +0100 af r266153 : #i97552# Catching Exceptions caught while accessing OLE-Object that is to be inserted. 2009-01-12 13:06:37 +0100 cl r266152 : #i96164# applied patch to fix ambiguous operation
2009-02-12 06:44:26 -06:00
#include <boost/shared_ptr.hpp>
class SdDrawDocument;
namespace sd {
CWS-TOOLING: integrate CWS impress166 2009-01-27 11:42:29 +0100 af r266972 : #i98508# Handle non DrawViewShell view shells correctly. 2009-01-21 10:41:32 +0100 af r266635 : #i98069# Do not call PreModelChange() for every ModelLock. 2009-01-20 15:25:41 +0100 af r266588 : #i98069# Added friend declaration that became necessary on Solaris after recent changes. 2009-01-19 13:48:47 +0100 af r266493 : #i97478# Prevent SID_PARASPACE_(DE|IN)CREASE from crashing when style sheet is missing. 2009-01-16 11:52:37 +0100 af r266411 : #i97338# Check the dispatcher before using it to show a context menu. 2009-01-15 14:33:55 +0100 sj r266373 : #153716# taking care of font-independent line spacing (editmode and hittest) 2009-01-15 14:29:46 +0100 sj r266372 : #153716# taking care of font-independent line spacing also in presentation styles 2009-01-14 14:04:16 +0100 af r266301 : #i97634# Do view change synchronously. Use shared pointers for view shells. 2009-01-14 14:01:27 +0100 af r266300 : #i97634# Added non-API methods that update the configuration synchronously. 2009-01-14 13:34:40 +0100 af r266295 : #i98069# Be more carefull with handling model updates to avoid assertion regarding number of selected pages. 2009-01-14 11:34:57 +0100 cl r266270 : #i97261# force outliner para oibject after text edit 2009-01-14 10:49:08 +0100 cl r266269 : #i97413# dispose cell undo action if shape dies 2009-01-13 18:50:05 +0100 cl r266247 : #i97347# fixed cell undo crash 2009-01-12 14:16:56 +0100 af r266156 : #i97296# Using is() method to check WeakReference for validity. 2009-01-12 13:52:00 +0100 af r266155 : #i97190# Turned static_cast to dynamic_cast in CreateChildList. 2009-01-12 13:06:57 +0100 af r266153 : #i97552# Catching Exceptions caught while accessing OLE-Object that is to be inserted. 2009-01-12 13:06:37 +0100 cl r266152 : #i96164# applied patch to fix ambiguous operation
2009-02-12 06:44:26 -06:00
class ViewShell;
class Outliner;
class View;
namespace outliner {
class IteratorImplBase;
class IteratorPosition;
/** Use this enum to specify the initial location of the object pointed to by
a newly created iterator. The values are
<ul><li><const>BEGIN</const> for the first object with reference to
iteration direction.</li>
<li>END for one past the last valid object or, if the iterator is a
backward iterator, the object in front of the first valid one.</li>
<li>CURRENT for the current object. Because there is only a current
page this usually is taken to be the first/last object on the current
page.</li></ul>
*/
enum IteratorLocation {BEGIN,END,CURRENT};
/** Use this enum to specify the type of iterator when creating a new
iterator:
<ul><li>SELECTION for iteration over all objects that belong to the
current mark list.</li>
<li>SINGLE_VIEW for iteration over all objects in the current view.</li>
<li>DOCUMENT for iteratioin over all object in all relevant
views.</li></ul>
*/
enum IteratorType {SELECTION,SINGLE_VIEW,DOCUMENT};
/** This iterator can be used to iterate over all <type>SdrObject</type>
objects of one of three set denoted by the <type>IteratorType</type>:
<ul><li>All objects of the current mark list (selection)
(type==SELECTION).</li>
<li>All objects in the current view (type==SINGLE_VIEW).</li>
<li>All objects in all views (type=DOCUMENT).</li></ul>
<p>Note that the iterator does not change pages or views. It is the
task of the user of the iterator to take the information provided by the
<type>IteratorPosition</type> as returned by the
<member>operator*()</member> method and set view, visible page, and
selection/edit mode markers to reflect this position.</p>
<p>A simple forward iteration from the first to the last object would
instantiate the iterator with
<code>Iterator(pDocument,pViewShell,true,BEGIN)</code> for some document
and view shell. This iterator can then be compared against
<code>Iterator(pDocument,pViewShell,true,END)</code>. On equality the
iteration should be stoped without evaluating the iterator: The position
of an end iterator is not valid.</p>
*/
class Iterator
{
public:
Iterator (void);
/** The copy constructor creates a new iterator by copying the
implementation object.
*/
Iterator (const Iterator& rIterator);
/** Create a new iterator with the implementation object being the
provided one.
@param pObject
A copy of this object will become the implementation object.
*/
explicit Iterator (IteratorImplBase* pObject);
~Iterator (void);
/** Assign the iterator from the given one. The implementation object
of this iterator will be a copy of the given iterator.
@param rIterator
The iterator which to assign from.
*/
Iterator& operator= (const Iterator& rIterator);
/** Return the current position of the iterator.
@return
Returns a reference to the current position. Therefore this
method is not thread safe. The reason for this behaviour is, of
course, to ommit the copying of the returned position.
*/
const IteratorPosition& operator* () const;
/** The prefix increment operator returns the iterator pointing to the
next object. When in doubt prefer this operator over the postfix
increment operator.
@return
Returns a reference to this iterator pointing to the next object.
*/
Iterator& operator++ ();
/** The postfix increment operator returns the iterator still pointing
to the current object. Only the next call to
<member>operator*()</member> will return the next object. When in
doubt rather use the prefix increment operator.
@param dummy
A dummy operator used by the compiler.
@return
Returns a copy of the iterator as it where before the operator
was called.
*/
Iterator operator++ (int);
/** Test equality of two iterators. Two iterators are taken to be equal
when they point are of the same type (their implementation objects
are instances of the same class) and point to the same object.
@param rIterator
The iterator to test equality with.
@return
Returns <TRUE/> when both iterators point to the same object.
*/
bool operator== (const Iterator& rIterator);
/** Test whether two iterators point to different objects. This is just
the negation of the result of the equality operator.
@param rIterator
The iterator to test inequality with.
@return
Returns <TRUE/> when both iterators point to the different objects.
*/
bool operator!= (const Iterator& rIterator);
/** Reverse the direction of iteration. The position of the iterator is
not changed. Thus caling this method twice returns to the old state.
*/
void Reverse (void);
private:
/// The implementation object to which most of the methods are forwarded.
IteratorImplBase* mpIterator;
};
/** This class wraps the <type>Outliner</type> class and represents it as
a container of <type>SdrObject</type> objects. Its main purpose is to
provide iterators for certain sub-sets of those objects. These sub-sets
are a) the set of the currently selected objects, b) all objects in the
current view, and c) all objects in all views.
<p>The direction of the returned iterators depends on the underlying
<type>Outliner</type> object and is usually set in the search
dialog.</p>
*/
class OutlinerContainer
{
public:
/** Create a new wraper object for the given outliner.
@param pOutliner
The outliner that is represented by the new object as
<type>SdrObject</type> container.
*/
OutlinerContainer (::sd::Outliner* pOutliner);
/** Return an iterator that points to the first object of one of the
sets described above. This takes also into account the direction of
iteration.
@return
The returned iterator points either to the first (forward
search) or to the last object (backward search) of the set.
*/
Iterator begin (void);
/** Return an iterator that marks the end of the iteration. This takes
also into account the direction of iteration. The object pointed to
is not valid.
@return
The returned iterator points either to that object past the last
one (forward search) or to the one in front of the first
(backward search).
*/
Iterator end (void);
/** Return an iterator that points to the current object of one of the
sets described above. This takes also into account the direction of
iteration.
@return
The returned iterator points either to the first (forward
search) or to the last object (backward search) of the set of
selected objects or of the current page if the search set spans
more than one page.
*/
Iterator current (void);
private:
/// The wrapped outliner that is represented as object container.
::sd::Outliner* mpOutliner;
/** Create an iterator. The object pointed to depends on the search
direction retrieved from the outliner object
<member>mpOutliner</member> and the given location.
@param aLocation
This specifies whether the returned iterator points to the
first, (one past the) last, or current object.
@return
2010-05-05 10:39:48 -05:00
Returns an iterator as constructed by
<member>CreateSelectionIterator()</member>,
*/
Iterator CreateIterator (IteratorLocation aLocation);
/** Create an iterator that iterates over all currently selected
<type>SdrObjects</type> objects of the <member>mpOutliner</member>
outliner.
@param rObjectList
List of currently selected objects. This list is necessary
so that the selection can be changed without affecting the
iterator.
@param pDocument
The document to which the objects belong.
@param pViewShell
The view shell which displays the objects.
@param bDirectionIsForward
The direction of iteration. It defaults to forward.
@param aLocation
This specifies at which object the iterator points initially.
*/
Iterator CreateSelectionIterator (
const ::std::vector<SdrObjectWeakRef>& rObjectList,
SdDrawDocument* pDocument,
CWS-TOOLING: integrate CWS impress166 2009-01-27 11:42:29 +0100 af r266972 : #i98508# Handle non DrawViewShell view shells correctly. 2009-01-21 10:41:32 +0100 af r266635 : #i98069# Do not call PreModelChange() for every ModelLock. 2009-01-20 15:25:41 +0100 af r266588 : #i98069# Added friend declaration that became necessary on Solaris after recent changes. 2009-01-19 13:48:47 +0100 af r266493 : #i97478# Prevent SID_PARASPACE_(DE|IN)CREASE from crashing when style sheet is missing. 2009-01-16 11:52:37 +0100 af r266411 : #i97338# Check the dispatcher before using it to show a context menu. 2009-01-15 14:33:55 +0100 sj r266373 : #153716# taking care of font-independent line spacing (editmode and hittest) 2009-01-15 14:29:46 +0100 sj r266372 : #153716# taking care of font-independent line spacing also in presentation styles 2009-01-14 14:04:16 +0100 af r266301 : #i97634# Do view change synchronously. Use shared pointers for view shells. 2009-01-14 14:01:27 +0100 af r266300 : #i97634# Added non-API methods that update the configuration synchronously. 2009-01-14 13:34:40 +0100 af r266295 : #i98069# Be more carefull with handling model updates to avoid assertion regarding number of selected pages. 2009-01-14 11:34:57 +0100 cl r266270 : #i97261# force outliner para oibject after text edit 2009-01-14 10:49:08 +0100 cl r266269 : #i97413# dispose cell undo action if shape dies 2009-01-13 18:50:05 +0100 cl r266247 : #i97347# fixed cell undo crash 2009-01-12 14:16:56 +0100 af r266156 : #i97296# Using is() method to check WeakReference for validity. 2009-01-12 13:52:00 +0100 af r266155 : #i97190# Turned static_cast to dynamic_cast in CreateChildList. 2009-01-12 13:06:57 +0100 af r266153 : #i97552# Catching Exceptions caught while accessing OLE-Object that is to be inserted. 2009-01-12 13:06:37 +0100 cl r266152 : #i96164# applied patch to fix ambiguous operation
2009-02-12 06:44:26 -06:00
const ::boost::shared_ptr<ViewShell>& rpViewShell,
bool bDirectionIsForward=true,
IteratorLocation aLocation=BEGIN);
/** Create an iterator that iterates over all <type>SdrObjects</type>
objects of the <member>mpOutliner</member> outliner.
@param pDocument
The document to which the objects belong.
@param pViewShell
The view shell which displays the objects.
@param bDirectionIsForward
The direction of iteration. It defaults to forward.
@param aLocation
This specifies at which object the iterator points initially.
*/
Iterator CreateDocumentIterator (
SdDrawDocument* pDocument,
CWS-TOOLING: integrate CWS impress166 2009-01-27 11:42:29 +0100 af r266972 : #i98508# Handle non DrawViewShell view shells correctly. 2009-01-21 10:41:32 +0100 af r266635 : #i98069# Do not call PreModelChange() for every ModelLock. 2009-01-20 15:25:41 +0100 af r266588 : #i98069# Added friend declaration that became necessary on Solaris after recent changes. 2009-01-19 13:48:47 +0100 af r266493 : #i97478# Prevent SID_PARASPACE_(DE|IN)CREASE from crashing when style sheet is missing. 2009-01-16 11:52:37 +0100 af r266411 : #i97338# Check the dispatcher before using it to show a context menu. 2009-01-15 14:33:55 +0100 sj r266373 : #153716# taking care of font-independent line spacing (editmode and hittest) 2009-01-15 14:29:46 +0100 sj r266372 : #153716# taking care of font-independent line spacing also in presentation styles 2009-01-14 14:04:16 +0100 af r266301 : #i97634# Do view change synchronously. Use shared pointers for view shells. 2009-01-14 14:01:27 +0100 af r266300 : #i97634# Added non-API methods that update the configuration synchronously. 2009-01-14 13:34:40 +0100 af r266295 : #i98069# Be more carefull with handling model updates to avoid assertion regarding number of selected pages. 2009-01-14 11:34:57 +0100 cl r266270 : #i97261# force outliner para oibject after text edit 2009-01-14 10:49:08 +0100 cl r266269 : #i97413# dispose cell undo action if shape dies 2009-01-13 18:50:05 +0100 cl r266247 : #i97347# fixed cell undo crash 2009-01-12 14:16:56 +0100 af r266156 : #i97296# Using is() method to check WeakReference for validity. 2009-01-12 13:52:00 +0100 af r266155 : #i97190# Turned static_cast to dynamic_cast in CreateChildList. 2009-01-12 13:06:57 +0100 af r266153 : #i97552# Catching Exceptions caught while accessing OLE-Object that is to be inserted. 2009-01-12 13:06:37 +0100 cl r266152 : #i96164# applied patch to fix ambiguous operation
2009-02-12 06:44:26 -06:00
const ::boost::shared_ptr<ViewShell>& rpViewShell,
bool bDirectionIsForward=true,
IteratorLocation aLocation=BEGIN);
/** Return the index of a page that contains an object that a new
iterator shall point to. This page index depends primarily on the
location, iteration direction, as well as on edit mode and page
kind.
@param pDocument
The document to which the page belongs.
@param pViewShell
The view shell which displays the page.
@param ePageKind
Specifies the view the page belongs to.
@param eEditMode
Specifies whether the page is a master page.
@param bDirectionIsForward
The direction of iteration.
@param aLocation
This specifies at which object the iterator points initially.
*/
CWS-TOOLING: integrate CWS impress166 2009-01-27 11:42:29 +0100 af r266972 : #i98508# Handle non DrawViewShell view shells correctly. 2009-01-21 10:41:32 +0100 af r266635 : #i98069# Do not call PreModelChange() for every ModelLock. 2009-01-20 15:25:41 +0100 af r266588 : #i98069# Added friend declaration that became necessary on Solaris after recent changes. 2009-01-19 13:48:47 +0100 af r266493 : #i97478# Prevent SID_PARASPACE_(DE|IN)CREASE from crashing when style sheet is missing. 2009-01-16 11:52:37 +0100 af r266411 : #i97338# Check the dispatcher before using it to show a context menu. 2009-01-15 14:33:55 +0100 sj r266373 : #153716# taking care of font-independent line spacing (editmode and hittest) 2009-01-15 14:29:46 +0100 sj r266372 : #153716# taking care of font-independent line spacing also in presentation styles 2009-01-14 14:04:16 +0100 af r266301 : #i97634# Do view change synchronously. Use shared pointers for view shells. 2009-01-14 14:01:27 +0100 af r266300 : #i97634# Added non-API methods that update the configuration synchronously. 2009-01-14 13:34:40 +0100 af r266295 : #i98069# Be more carefull with handling model updates to avoid assertion regarding number of selected pages. 2009-01-14 11:34:57 +0100 cl r266270 : #i97261# force outliner para oibject after text edit 2009-01-14 10:49:08 +0100 cl r266269 : #i97413# dispose cell undo action if shape dies 2009-01-13 18:50:05 +0100 cl r266247 : #i97347# fixed cell undo crash 2009-01-12 14:16:56 +0100 af r266156 : #i97296# Using is() method to check WeakReference for validity. 2009-01-12 13:52:00 +0100 af r266155 : #i97190# Turned static_cast to dynamic_cast in CreateChildList. 2009-01-12 13:06:57 +0100 af r266153 : #i97552# Catching Exceptions caught while accessing OLE-Object that is to be inserted. 2009-01-12 13:06:37 +0100 cl r266152 : #i96164# applied patch to fix ambiguous operation
2009-02-12 06:44:26 -06:00
sal_Int32 GetPageIndex (
SdDrawDocument* pDocument,
const ::boost::shared_ptr<ViewShell>& rpViewShell,
PageKind ePageKind,
EditMode eEditMode,
bool bDirectionIsForward,
IteratorLocation aLocation);
// Do not allow default constructor and copying of outliner containers.
OutlinerContainer (const OutlinerContainer&) {};
OutlinerContainer (void) {};
OutlinerContainer& operator= (const OutlinerContainer&) {return *this;};
};
/** Data collection specifying a <type>SdrObject</type> and its position in
a document and view.
*/
class IteratorPosition
{
public:
/** Create a new object with all data members set to default values.
These values should not be accessed. The only use of the object as
it is is as a marker in comparisons.
*/
IteratorPosition (void);
/** Create a new object with all data members set from the given
position.
@param aPosition
The position object from which to take the values that are
assigned to the data members of this object.
*/
IteratorPosition (const IteratorPosition& aPosition);
/// The destructor is a no-op at the moment.
~IteratorPosition (void);
/** Assign the content of the given position to this one.
@param aPosition
This is the position object from which to take the values of all
data members.
@return
Returns a reference to this object.
*/
IteratorPosition& operator= (const IteratorPosition& aPosition);
/** Compare two positions for equality.
@return
<TRUE/> is returned only when all data members have the same
values in both position objects.
*/
bool operator== (const IteratorPosition& aPosition) const;
/// Pointer to the actual <type>SdrObject</type> object.
SdrObjectWeakRef mxObject;
/// Number of the actual SdrText from the current <type>SdrObject</type>
sal_Int32 mnText;
/// The index of a page where the object is located on.
sal_Int32 mnPageIndex;
/// Page kind of the view.
PageKind mePageKind;
/// Edit mode of the view.
EditMode meEditMode;
};
} } // end of namespace ::sd::outliner
#endif // _SD_OUTLINER_ITERATOR_HXX
2010-10-27 06:53:26 -05:00
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */