2010-10-14 08:30:41 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2002-02-19 18:11:48 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 11:43:29 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2002-02-19 18:11:48 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2002-02-19 18:11:48 +00:00
|
|
|
*
|
2008-04-10 11:43:29 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2002-02-19 18:11:48 +00:00
|
|
|
*
|
2008-04-10 11:43:29 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2002-02-19 18:11:48 +00:00
|
|
|
*
|
2008-04-10 11:43:29 +00:00
|
|
|
* 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.
|
2002-02-19 18:11:48 +00:00
|
|
|
*
|
2008-04-10 11:43:29 +00:00
|
|
|
* 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).
|
2002-02-19 18:11:48 +00:00
|
|
|
*
|
2008-04-10 11:43:29 +00:00
|
|
|
* 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.
|
2002-02-19 18:11:48 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
#ifndef _ACCPORTIONS_HXX
|
|
|
|
#define _ACCPORTIONS_HXX
|
|
|
|
#include <SwPortionHandler.hxx>
|
|
|
|
#include <sal/types.h>
|
|
|
|
#include <rtl/ustrbuf.hxx>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
class String;
|
|
|
|
class SwTxtNode;
|
2002-02-27 16:28:54 +00:00
|
|
|
struct SwSpecialPos;
|
2002-03-26 17:29:45 +00:00
|
|
|
class SwViewOption;
|
2002-02-19 18:11:48 +00:00
|
|
|
namespace com { namespace sun { namespace star {
|
|
|
|
namespace i18n { struct Boundary; }
|
|
|
|
} } }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* collect text portion data from the layout through SwPortionHandler interface
|
|
|
|
*/
|
|
|
|
class SwAccessiblePortionData : public SwPortionHandler
|
|
|
|
{
|
2002-03-21 10:07:26 +00:00
|
|
|
// the node this portion is referring to
|
|
|
|
const SwTxtNode* pTxtNode;
|
|
|
|
|
2002-02-20 14:22:26 +00:00
|
|
|
// variables used while collecting the data
|
2002-02-19 18:11:48 +00:00
|
|
|
rtl::OUStringBuffer aBuffer;
|
|
|
|
sal_Int32 nModelPosition;
|
|
|
|
sal_Bool bFinished;
|
2002-03-26 17:29:45 +00:00
|
|
|
const SwViewOption* pViewOptions;
|
2002-02-19 18:11:48 +00:00
|
|
|
|
2002-03-21 10:07:26 +00:00
|
|
|
// the accessible string
|
2002-02-19 18:11:48 +00:00
|
|
|
rtl::OUString sAccessibleString;
|
|
|
|
|
|
|
|
// positions array
|
|
|
|
// instances of Position_t must always include the minimum and
|
|
|
|
// maximum positions as first/last elements (to simplify the
|
|
|
|
// algorithms)
|
|
|
|
typedef std::vector<sal_Int32> Positions_t;
|
|
|
|
|
|
|
|
Positions_t aLineBreaks; /// position of line breaks
|
|
|
|
Positions_t aModelPositions; /// position of portion breaks in the model
|
|
|
|
Positions_t aAccessiblePositions; /// portion breaks in sAccessibleString
|
|
|
|
|
2002-04-09 12:42:53 +00:00
|
|
|
typedef std::vector<sal_uInt8> PortionAttrs_t;
|
|
|
|
PortionAttrs_t aPortionAttrs; /// additional portion attributes
|
2002-03-26 17:29:45 +00:00
|
|
|
|
2002-02-19 18:11:48 +00:00
|
|
|
Positions_t* pSentences; /// positions of sentence breaks
|
|
|
|
|
2002-02-27 16:28:54 +00:00
|
|
|
size_t nBeforePortions; /// # of portions before first model character
|
|
|
|
sal_Bool bLastIsSpecial; /// set if last portion was 'Special()'
|
|
|
|
|
2002-02-21 13:55:31 +00:00
|
|
|
/// returns the index of the first position whose value is smaller
|
|
|
|
/// or equal, and whose following value is equal or larger
|
2008-07-01 14:06:50 +00:00
|
|
|
size_t FindBreak( const Positions_t& rPositions, sal_Int32 nValue ) const;
|
2002-02-19 18:11:48 +00:00
|
|
|
|
2002-02-27 16:28:54 +00:00
|
|
|
/// like FindBreak, but finds the last equal or larger position
|
2008-07-01 14:06:50 +00:00
|
|
|
size_t FindLastBreak( const Positions_t& rPositions, sal_Int32 nValue ) const;
|
2002-02-27 16:28:54 +00:00
|
|
|
|
2002-02-19 18:11:48 +00:00
|
|
|
/// fill the boundary with the values from rPositions[nPos]
|
|
|
|
void FillBoundary(com::sun::star::i18n::Boundary& rBound,
|
|
|
|
const Positions_t& rPositions,
|
2008-07-01 14:06:50 +00:00
|
|
|
size_t nPos ) const;
|
2002-02-19 18:11:48 +00:00
|
|
|
|
2002-04-09 12:42:53 +00:00
|
|
|
/// Access to portion attributes
|
2008-07-01 14:06:50 +00:00
|
|
|
sal_Bool IsPortionAttrSet( size_t nPortionNo, sal_uInt8 nAttr ) const;
|
|
|
|
sal_Bool IsSpecialPortion( size_t nPortionNo ) const;
|
|
|
|
sal_Bool IsReadOnlyPortion( size_t nPortionNo ) const;
|
|
|
|
sal_Bool IsGrayPortionType( USHORT nType ) const;
|
2002-04-09 12:42:53 +00:00
|
|
|
|
|
|
|
// helper method for GetEditableRange(...):
|
|
|
|
void AdjustAndCheck( sal_Int32 nPos, size_t& nPortionNo,
|
2008-07-01 14:06:50 +00:00
|
|
|
USHORT& nCorePos, sal_Bool& bEdit ) const;
|
2002-03-20 09:02:26 +00:00
|
|
|
|
2002-02-19 18:11:48 +00:00
|
|
|
public:
|
2002-03-26 17:29:45 +00:00
|
|
|
SwAccessiblePortionData( const SwTxtNode* pTxtNd,
|
|
|
|
const SwViewOption* pViewOpt = NULL );
|
2002-02-19 18:11:48 +00:00
|
|
|
virtual ~SwAccessiblePortionData();
|
|
|
|
|
|
|
|
// SwPortionHandler methods
|
2002-02-28 12:35:57 +00:00
|
|
|
virtual void Text(USHORT nLength, USHORT nType);
|
2002-02-19 18:11:48 +00:00
|
|
|
virtual void Special(USHORT nLength, const String& rText, USHORT nType);
|
|
|
|
virtual void LineBreak();
|
2002-02-21 13:55:31 +00:00
|
|
|
virtual void Skip(USHORT nLength);
|
2002-02-19 18:11:48 +00:00
|
|
|
virtual void Finish();
|
|
|
|
|
2002-02-21 13:55:31 +00:00
|
|
|
|
2002-02-19 18:11:48 +00:00
|
|
|
// access to the portion data
|
2002-02-27 16:28:54 +00:00
|
|
|
|
|
|
|
/// get the text string, as presented by the layout
|
2008-07-01 14:06:50 +00:00
|
|
|
const rtl::OUString& GetAccessibleString() const;
|
2002-02-27 16:28:54 +00:00
|
|
|
|
|
|
|
/// get the start & end positions of the sentence
|
2002-02-19 18:11:48 +00:00
|
|
|
void GetLineBoundary( com::sun::star::i18n::Boundary& rBound,
|
2008-07-01 14:06:50 +00:00
|
|
|
sal_Int32 nPos ) const;
|
2002-02-27 16:28:54 +00:00
|
|
|
|
2003-09-19 09:55:56 +00:00
|
|
|
// get start and end position of the last line
|
2008-07-01 14:06:50 +00:00
|
|
|
void GetLastLineBoundary( com::sun::star::i18n::Boundary& rBound ) const;
|
|
|
|
|
|
|
|
// --> OD 2008-05-30 #i89175#
|
|
|
|
sal_Int32 GetLineCount() const;
|
|
|
|
sal_Int32 GetLineNo( const sal_Int32 nPos ) const;
|
|
|
|
void GetBoundaryOfLine( const sal_Int32 nLineNo,
|
|
|
|
com::sun::star::i18n::Boundary& rLineBound );
|
|
|
|
// <--
|
2003-09-19 09:55:56 +00:00
|
|
|
|
2002-02-27 16:28:54 +00:00
|
|
|
/// get the position in the model string for a given
|
|
|
|
/// (accessibility) position
|
2008-07-01 14:06:50 +00:00
|
|
|
USHORT GetModelPosition( sal_Int32 nPos ) const;
|
2002-02-19 18:11:48 +00:00
|
|
|
|
2002-02-27 16:28:54 +00:00
|
|
|
/// get the position in the accessibility string for a given model position
|
2008-07-01 14:06:50 +00:00
|
|
|
sal_Int32 GetAccessiblePosition( USHORT nPos ) const;
|
2002-02-27 16:28:54 +00:00
|
|
|
|
|
|
|
/// fill a SwSpecialPos structure, suitable for calling
|
|
|
|
/// SwTxtFrm->GetCharRect
|
|
|
|
/// Returns the core position, and fills thr rpPos either with NULL or
|
|
|
|
/// with the &rPos, after putting the appropriate data into it.
|
|
|
|
USHORT FillSpecialPos( sal_Int32 nPos,
|
|
|
|
SwSpecialPos& rPos,
|
2008-07-01 14:06:50 +00:00
|
|
|
SwSpecialPos*& rpPos ) const;
|
2002-02-27 16:28:54 +00:00
|
|
|
|
|
|
|
|
2002-02-19 18:11:48 +00:00
|
|
|
// get boundaries of words/sentences. The data structures are
|
2002-03-21 10:07:26 +00:00
|
|
|
// created on-demand.
|
2002-02-19 18:11:48 +00:00
|
|
|
void GetSentenceBoundary( com::sun::star::i18n::Boundary& rBound,
|
2002-03-21 10:07:26 +00:00
|
|
|
sal_Int32 nPos );
|
2002-03-20 09:02:26 +00:00
|
|
|
|
|
|
|
// get (a) boundary for attribut change
|
|
|
|
void GetAttributeBoundary( com::sun::star::i18n::Boundary& rBound,
|
2008-07-01 14:06:50 +00:00
|
|
|
sal_Int32 nPos ) const;
|
2002-03-20 09:02:26 +00:00
|
|
|
|
2002-04-09 12:42:53 +00:00
|
|
|
/// Convert start and end positions into core positions.
|
|
|
|
/// @returns true if 'special' portions are included either completely
|
|
|
|
/// or not at all. This can be used to test whether editing
|
|
|
|
/// that range would be legal
|
|
|
|
sal_Bool GetEditableRange( sal_Int32 nStart, sal_Int32 nEnd,
|
2008-07-01 14:06:50 +00:00
|
|
|
USHORT& nCoreStart, USHORT& nCoreEnd ) const;
|
2002-06-13 12:13:12 +00:00
|
|
|
|
|
|
|
/// Determine whether this core position is valid for these portions.
|
|
|
|
/// (A paragraph may be split into several frames, e.g. at page
|
|
|
|
/// boundaries. In this case, only part of a paragraph is represented
|
|
|
|
/// through this object. This method determines whether one particular
|
|
|
|
/// position is valid for this object or not.)
|
2008-07-01 14:06:50 +00:00
|
|
|
sal_Bool IsValidCorePosition( USHORT nPos ) const;
|
|
|
|
USHORT GetFirstValidCorePosition() const;
|
|
|
|
USHORT GetLastValidCorePosition() const;
|
2002-02-19 18:11:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2010-10-14 08:30:41 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|